#include <BesNavigatorInit.h>
Public Member Functions | |
BesNavigatorInit (const std::string &name, ISvcLocator *pSvcLocator) | |
StatusCode | initialize () |
StatusCode | execute () |
StatusCode | finalize () |
void | fillMdcInfo () |
void | fillEmcInfo () |
void | fillTofInfo () |
void | fillMucInfo () |
Private Attributes | |
EventNavigator * | m_navigator |
EvtNavigatorState | state |
bool | b_fillMdc |
bool | b_fillTof |
bool | b_fillEmc |
bool | b_fillMuc |
bool | b_fillHitMaps |
int | m_mdcCut |
Definition at line 8 of file BesNavigatorInit.h.
BesNavigatorInit::BesNavigatorInit | ( | const std::string & | name, | |
ISvcLocator * | pSvcLocator | |||
) |
Definition at line 41 of file BesNavigatorInit.cxx.
References b_fillEmc, b_fillHitMaps, b_fillMdc, b_fillMuc, b_fillTof, m_mdcCut, SIMU, and state.
00041 : Algorithm(name, pSvcLocator){ 00042 // Subdetector flags 00043 declareProperty("FillMdcInfo", b_fillMdc=true); 00044 declareProperty("FillTofInfo", b_fillTof=true); 00045 declareProperty("FillEmcInfo", b_fillEmc=true); 00046 declareProperty("FillMucInfo", b_fillMuc=true); 00047 declareProperty("MdcCut", m_mdcCut=7); 00048 declareProperty("PrepareHitMaps", b_fillHitMaps = false); 00049 state = SIMU; 00050 }
StatusCode BesNavigatorInit::execute | ( | ) |
Definition at line 60 of file BesNavigatorInit.cxx.
References EventNavigator::addIdLink(), b_fillEmc, b_fillMdc, b_fillMuc, b_fillTof, Bes_Common::DEBUG, calibUtil::ERROR, fillEmcInfo(), fillMdcInfo(), fillMucInfo(), fillTofInfo(), Bes_Common::INFO, m_mdcCut, m_navigator, msgSvc(), EventNavigator::Print(), RECO, EventNavigator::setMdcCut(), SIMU, and state.
00060 { 00061 MsgStream log(msgSvc(), name()); 00062 00063 state = SIMU; 00064 00065 SmartDataPtr<EventNavigator> nav(eventSvc(),"/Event/Navigator"); 00066 if( ! nav ) 00067 { 00068 log << MSG::DEBUG << "Create EventNavigator" << endreq; 00069 m_navigator = new EventNavigator; 00070 m_navigator->setMdcCut(m_mdcCut); 00071 } 00072 else 00073 { 00074 log << MSG::DEBUG << "Found EventNavigator (read from DST)" << endreq; 00075 m_navigator = nav; 00076 state = RECO; 00077 if( log.level() < 3 ) 00078 m_navigator->Print(); 00079 } 00080 00081 SmartDataPtr<McParticleCol> mcParticles(eventSvc(),"/Event/MC/McParticleCol"); 00082 if( ! mcParticles ) 00083 { 00084 log << MSG::ERROR << "Unable to retrieve McParticleCol" << endreq; 00085 return StatusCode::FAILURE; 00086 } 00087 else 00088 log << MSG::DEBUG << "McParticleCol retrieved of size "<< mcParticles->size() << endreq; 00089 00090 for(McParticleCol::const_iterator it = mcParticles->begin(); it != mcParticles->end(); it++) 00091 { 00092 m_navigator->addIdLink( (*it)->trackIndex(), *it ); 00093 } 00094 00095 // store MDC relations 00096 if( b_fillMdc ) 00097 fillMdcInfo(); 00098 00099 // store EMC relations 00100 if( b_fillEmc ) 00101 fillEmcInfo(); 00102 00103 // store TOF relations 00104 if( b_fillTof ) 00105 fillTofInfo(); 00106 00107 // store MUC relations 00108 if( b_fillMuc ) 00109 fillMucInfo(); 00110 00111 // Register EventNavigator to Gaudi TDS 00112 if (state == SIMU) 00113 { 00114 StatusCode sc = eventSvc()->registerObject("/Event/Navigator",m_navigator); 00115 if (sc != StatusCode::SUCCESS) 00116 { 00117 log << MSG::ERROR << "Could not register EventNavigator" << endreq; 00118 return StatusCode::FAILURE; 00119 } 00120 else 00121 log << MSG::INFO << "EventNavigator registered successfully in TDS" << endreq; 00122 } 00123 00124 if( log.level() < 3 ) 00125 { 00126 log << MSG::DEBUG << "Write EventNavigator" << endreq; 00127 m_navigator->Print(); 00128 } 00129 00130 return StatusCode::SUCCESS; 00131 }
void BesNavigatorInit::fillEmcInfo | ( | ) |
Definition at line 248 of file BesNavigatorInit.cxx.
References EventNavigator::addIdLink(), EventNavigator::addLink(), Bes_Common::DEBUG, EventNavigator::getEmcRecShowers(), EventNavigator::getMcEmcMcHitsIdx(), EventNavigator::getMcEmcRecShowersIdx(), EventNavigator::getMcParticle(), genRecEmupikp::i, ganga-rec::j, m_navigator, msgSvc(), and genRecEmupikp::range.
Referenced by execute().
00249 { 00250 MsgStream log(msgSvc(), name()); 00251 00252 //****** Process hits ****** 00253 // If simulated hits are there, fill index map (read from DST if no hits in TDS) 00254 SmartDataPtr<EmcMcHitCol> emcMcHits(eventSvc(),"/Event/MC/EmcMcHitCol"); 00255 if( emcMcHits ) 00256 { 00257 log << MSG::DEBUG << "EmcMcHitsCol retrieved of size "<< emcMcHits->size() << endreq; 00258 00259 if (emcMcHits->size() != 0) 00260 m_navigator->getMcEmcMcHitsIdx().clear(); 00261 00262 for(EmcMcHitCol::const_iterator it = emcMcHits->begin(); it != emcMcHits->end(); it++) 00263 { 00264 //first put Id of crystal, which particle hits initially 00265 int crystalId = (*it)->identify().get_value(); 00266 int McParticleID = 0; 00267 if(crystalId != 0) // not gamma converted in TOF 00268 { 00269 McParticleID = (*it)->getTrackIndex(); 00270 m_navigator->getMcEmcMcHitsIdx().insert( pair<int,int>(crystalId, McParticleID)); 00271 // m_navigator->addIdLink( crystalId, *it ); 00272 } 00273 00274 //then add all other crystals touched by shower 00275 const map<Identifier,double>& hitmap = (*it)->getHitMap(); 00276 map<Identifier,double>::const_iterator jt; 00277 for (jt=hitmap.begin(); jt!=hitmap.end(); jt++) 00278 { 00279 int crystalId = (*jt).first.get_value(); 00280 00281 if(McParticleID !=0 ) // not gamma converted in TOF 00282 { 00283 m_navigator->getMcEmcMcHitsIdx().insert( pair<int,int>(crystalId, McParticleID)); // CrystalId, McParticleID 00284 } 00285 //m_navigator->addIdLink( (*jt).first.get_value(), *it ); 00286 } 00287 } 00288 } 00289 else 00290 { 00291 log << MSG::DEBUG << "Unable to retrieve EmcMcHitCol" << endreq; 00292 } 00293 00294 // ****** Get EMC top level objects from TDS ****** 00295 // EMC Reconstructed Showers 00296 SmartDataPtr<RecEmcShowerCol> emcRecShowers(eventSvc(),"/Event/Recon/RecEmcShowerCol"); 00297 if( emcRecShowers ) 00298 { 00299 log << MSG::DEBUG << "RecEmcShowerCol retrieved of size "<< emcRecShowers->size() << endreq; 00300 00301 IndexMap& mchits = m_navigator->getMcEmcMcHitsIdx(); 00302 00303 for(RecEmcShowerCol::const_iterator it = emcRecShowers->begin(); 00304 it != emcRecShowers->end(); 00305 it++) 00306 { 00307 int showerId = (*it)->getShowerId().get_value(); 00308 m_navigator->addIdLink( showerId, *it ); 00309 00310 // calculate relations only during reco and store them to DST. 00311 // EmcMcHit tables are removed then. 00312 if(! mchits.empty()) 00313 { 00314 const RecEmcFractionMap& fractionMap = (*it)->getFractionMap(); 00315 for(RecEmcFractionMap::const_iterator jt = fractionMap.begin(); 00316 jt != fractionMap.end(); 00317 jt++) 00318 { 00319 int crystalId = (*jt).first.get_value(); 00320 const pair<IndexMap::const_iterator, IndexMap::const_iterator> range = mchits.equal_range(crystalId); // McParticles which hit given crystal 00321 00322 for(IndexMap::const_iterator kt = range.first; kt != range.second; kt++) 00323 { 00324 m_navigator->getMcEmcRecShowersIdx().insert( pair<int,int>((*kt).second, showerId)); // McParticle id <-> RecShower ShowerId 00325 } 00326 } 00327 } 00328 } 00329 } 00330 else 00331 { 00332 log << MSG::DEBUG << "Unable to retrieve RecEmcShowerCol" << endreq; 00333 } 00334 00335 00336 //****** Make main relations between top level objects *** 00337 IndexMap::const_iterator i; 00338 IndexMap& index = m_navigator->getMcEmcRecShowersIdx(); 00339 for(i = index.begin(); i != index.end(); i++) 00340 { 00341 // i.first = McParticle id; i.second = MdcTrack id 00342 const McParticle* mcParticle = m_navigator->getMcParticle((*i).first); 00343 00344 if (mcParticle == 0) 00345 continue; 00346 00347 const RecEmcShowerVector& emcShowers = m_navigator->getEmcRecShowers((*i).second); 00348 00349 if( ! emcShowers.empty() ) 00350 { 00351 RecEmcShowerVector::const_iterator j; 00352 for(j=emcShowers.begin(); j!=emcShowers.end(); j++) 00353 { 00354 m_navigator->addLink(mcParticle, *j); 00355 m_navigator->addLink(*j, mcParticle); 00356 } 00357 } 00358 } 00359 }
void BesNavigatorInit::fillMdcInfo | ( | ) |
Definition at line 139 of file BesNavigatorInit.cxx.
References EventNavigator::addIdLink(), EventNavigator::addLink(), Bes_Common::DEBUG, EventNavigator::getMcMdcMcHitsIdx(), EventNavigator::getMcMdcTracksIdx(), EventNavigator::getMcParticle(), EventNavigator::getMdcKalTrack(), EventNavigator::getMdcTrack(), genRecEmupikp::i, m_navigator, msgSvc(), and genRecEmupikp::range.
Referenced by execute().
00140 { 00141 MsgStream log(msgSvc(), name()); 00142 00143 //****** Process hits ****** 00144 // If simulated hits are there, fill index map (read from DST if no hits in TDS) 00145 SmartDataPtr<MdcMcHitCol> mdcMcHits(eventSvc(),"/Event/MC/MdcMcHitCol"); 00146 if( mdcMcHits ) 00147 { 00148 log << MSG::DEBUG << "MdcMcHitsCol retrieved of size "<< mdcMcHits->size() << endreq; 00149 00150 if (mdcMcHits->size() != 0) 00151 m_navigator->getMcMdcMcHitsIdx().clear(); 00152 00153 for(MdcMcHitCol::const_iterator it = mdcMcHits->begin(); it != mdcMcHits->end(); it++) 00154 { 00155 // fill relation MdcHit id <-> McParticle 00156 m_navigator->getMcMdcMcHitsIdx().insert( pair<int,int>((*it)->identify().get_value(), (*it)->getTrackIndex())); 00157 00158 // m_navigator->addIdLink( (*it)->identify().get_value(), *it ); 00159 } 00160 } 00161 else 00162 { 00163 log << MSG::DEBUG << "Unable to retrieve MdcMcHitCol" << endreq; 00164 } 00165 00166 // If reconstructed hits are there, fill index map (read from DST if no hits in TDS) 00167 SmartDataPtr<RecMdcHitCol> mdcRecHits(eventSvc(),"/Event/Recon/RecMdcHitCol"); 00168 if( mdcRecHits ) 00169 { 00170 log << MSG::DEBUG << "MdcRecHitCol retrieved of size "<< mdcRecHits->size() << endreq; 00171 00172 if (mdcRecHits->size() != 0) 00173 m_navigator->getMcMdcTracksIdx().clear(); 00174 00175 IndexMap& mchits = m_navigator->getMcMdcMcHitsIdx(); 00176 for(RecMdcHitCol::iterator it=mdcRecHits->begin(); it!=mdcRecHits->end(); it++) 00177 { 00178 int mdcId = ((*it)->getMdcId()).get_value(); 00179 // m_navigator->addIdLink( mdcId, *it); 00180 00181 const pair<IndexMap::const_iterator, IndexMap::const_iterator> range = mchits.equal_range(mdcId); 00182 for(IndexMap::const_iterator jt = range.first; jt != range.second; jt++) 00183 { 00184 m_navigator->getMcMdcTracksIdx().insert( pair<int,int>((*jt).second, (*it)->getTrkId())); 00185 } 00186 } 00187 } 00188 else 00189 log << MSG::DEBUG << "Unable to retrieve RecMdcHitCol" << endreq; 00190 00191 00192 // ****** Get MDC top level objects from TDS ****** 00193 // MDC Reconstructed Tracks 00194 SmartDataPtr<RecMdcTrackCol> mdcTracks(eventSvc(),"/Event/Recon/RecMdcTrackCol"); 00195 if( mdcTracks ) 00196 { 00197 log << MSG::DEBUG << "MdcTrackCol retrieved of size "<< mdcTracks->size() << endreq; 00198 for(RecMdcTrackCol::const_iterator it = mdcTracks->begin(); it != mdcTracks->end(); it++) 00199 m_navigator->addIdLink( (*it)->trackId(), *it ); 00200 } 00201 else 00202 { 00203 log << MSG::DEBUG << "Unable to retrieve RecMdcTrackCol" << endreq; 00204 } 00205 00206 // MDC Kalman Tracks 00207 SmartDataPtr<RecMdcKalTrackCol> mdcKalTracks(eventSvc(),"/Event/Recon/RecMdcKalTrackCol"); 00208 if( mdcKalTracks ) 00209 { 00210 log << MSG::DEBUG << "MdcKalTrackCol retrieved of size "<< mdcKalTracks->size() << endreq; 00211 for(RecMdcKalTrackCol::const_iterator it = mdcKalTracks->begin(); it != mdcKalTracks->end(); it++) 00212 m_navigator->addIdLink( (*it)->trackId(), *it ); 00213 } 00214 else 00215 { 00216 log << MSG::DEBUG << "Unable to retrieve RecMdcTrackCol" << endreq; 00217 } 00218 00219 //****** Make main relations between top level objects *** 00220 IndexMap::const_iterator i; 00221 IndexMap& index = m_navigator->getMcMdcTracksIdx(); 00222 for(i = index.begin(); i != index.end(); i++) 00223 { 00224 // i.first = McParticle id; i.second = MdcTrack id 00225 const McParticle* mcParticle = m_navigator->getMcParticle((*i).first); 00226 00227 if (mcParticle == 0) 00228 continue; 00229 00230 const RecMdcTrack* mdcTrack = m_navigator->getMdcTrack((*i).second); 00231 00232 if( mdcTrack != 0 ) 00233 { 00234 m_navigator->addLink(mcParticle, mdcTrack); 00235 m_navigator->addLink(mdcTrack, mcParticle); 00236 } 00237 00238 const RecMdcKalTrack* mdcKalTrack = m_navigator->getMdcKalTrack((*i).second); // same trkid 00239 if( mdcKalTrack != 0 ) 00240 { 00241 m_navigator->addLink(mcParticle, mdcKalTrack); 00242 m_navigator->addLink(mdcKalTrack, mcParticle); 00243 } 00244 } 00245 }
void BesNavigatorInit::fillMucInfo | ( | ) |
void BesNavigatorInit::fillTofInfo | ( | ) |
StatusCode BesNavigatorInit::finalize | ( | ) |
StatusCode BesNavigatorInit::initialize | ( | ) |
bool BesNavigatorInit::b_fillEmc [private] |
bool BesNavigatorInit::b_fillHitMaps [private] |
bool BesNavigatorInit::b_fillMdc [private] |
bool BesNavigatorInit::b_fillMuc [private] |
bool BesNavigatorInit::b_fillTof [private] |
int BesNavigatorInit::m_mdcCut [private] |
EventNavigator* BesNavigatorInit::m_navigator [private] |
Definition at line 21 of file BesNavigatorInit.h.
Referenced by execute(), fillEmcInfo(), and fillMdcInfo().
EvtNavigatorState BesNavigatorInit::state [private] |