1#include "GaudiKernel/MsgStream.h"
2#include "GaudiKernel/SmartDataPtr.h"
4#include "EventNavigator/EventNavigator.h"
5#include "EventNavigator/BesNavigatorInit.h"
8#include "McTruth/McParticle.h"
9#include "McTruth/EmcMcHit.h"
10#include "McTruth/MdcMcHit.h"
11#include "McTruth/MucMcHit.h"
12#include "McTruth/TofMcHit.h"
15#include "MdcRecEvent/RecMdcTrack.h"
16#include "MdcRecEvent/RecMdcKalTrack.h"
17#include "MdcRecEvent/RecMdcHit.h"
20#include "EmcRecEventModel/RecEmcShower.h"
23#include "TofRecEvent/RecTofTrack.h"
24#include "TofRecEvent/RecBTofHit.h"
25#include "TofRecEvent/RecETofHit.h"
28#include "MucRecEvent/RecMucTrack.h"
29#include "MucRecEvent/MucRecHit.h"
32#include "EmcRecEventModel/RecEmcDigit.h"
33#include "MdcRawEvent/MdcDigi.h"
43 declareProperty(
"FillMdcInfo", b_fillMdc=
true);
44 declareProperty(
"FillTofInfo", b_fillTof=
true);
45 declareProperty(
"FillEmcInfo", b_fillEmc=
true);
46 declareProperty(
"FillMucInfo", b_fillMuc=
true);
47 declareProperty(
"MdcCut", m_mdcCut=7);
48 declareProperty(
"PrepareHitMaps", b_fillHitMaps =
false);
55 return StatusCode::SUCCESS;
61 MsgStream log(
msgSvc(), name());
65 SmartDataPtr<EventNavigator> nav(eventSvc(),
"/Event/Navigator");
68 log << MSG::DEBUG <<
"Create EventNavigator" << endreq;
74 log << MSG::DEBUG <<
"Found EventNavigator (read from DST)" << endreq;
81 SmartDataPtr<McParticleCol> mcParticles(eventSvc(),
"/Event/MC/McParticleCol");
84 log << MSG::ERROR <<
"Unable to retrieve McParticleCol" << endreq;
85 return StatusCode::FAILURE;
88 log << MSG::DEBUG <<
"McParticleCol retrieved of size "<< mcParticles->size() << endreq;
90 for(McParticleCol::const_iterator it = mcParticles->begin(); it != mcParticles->end(); it++)
92 m_navigator->
addIdLink( (*it)->trackIndex(), *it );
114 StatusCode sc = eventSvc()->registerObject(
"/Event/Navigator",m_navigator);
115 if (sc != StatusCode::SUCCESS)
117 log << MSG::ERROR <<
"Could not register EventNavigator" << endreq;
118 return StatusCode::FAILURE;
121 log << MSG::INFO <<
"EventNavigator registered successfully in TDS" << endreq;
124 if( log.level() < 3 )
126 log << MSG::DEBUG <<
"Write EventNavigator" << endreq;
127 m_navigator->
Print();
130 return StatusCode::SUCCESS;
136 return StatusCode::SUCCESS;
141 MsgStream log(
msgSvc(), name());
145 SmartDataPtr<MdcMcHitCol> mdcMcHits(eventSvc(),
"/Event/MC/MdcMcHitCol");
148 log << MSG::DEBUG <<
"MdcMcHitsCol retrieved of size "<< mdcMcHits->size() << endreq;
150 if (mdcMcHits->size() != 0)
153 for(MdcMcHitCol::const_iterator it = mdcMcHits->begin(); it != mdcMcHits->end(); it++)
156 m_navigator->
getMcMdcMcHitsIdx().insert( pair<int,int>((*it)->identify().get_value(), (*it)->getTrackIndex()));
163 log << MSG::DEBUG <<
"Unable to retrieve MdcMcHitCol" << endreq;
167 SmartDataPtr<RecMdcHitCol> mdcRecHits(eventSvc(),
"/Event/Recon/RecMdcHitCol");
170 log << MSG::DEBUG <<
"MdcRecHitCol retrieved of size "<< mdcRecHits->size() << endreq;
172 if (mdcRecHits->size() != 0)
176 for(RecMdcHitCol::iterator it=mdcRecHits->begin(); it!=mdcRecHits->end(); it++)
178 int mdcId = ((*it)->getMdcId()).get_value();
181 const pair<IndexMap::const_iterator, IndexMap::const_iterator> range = mchits.equal_range(mdcId);
182 for(IndexMap::const_iterator jt = range.first; jt != range.second; jt++)
184 m_navigator->
getMcMdcTracksIdx().insert( pair<int,int>((*jt).second, (*it)->getTrkId()));
189 log << MSG::DEBUG <<
"Unable to retrieve RecMdcHitCol" << endreq;
194 SmartDataPtr<RecMdcTrackCol> mdcTracks(eventSvc(),
"/Event/Recon/RecMdcTrackCol");
197 log << MSG::DEBUG <<
"MdcTrackCol retrieved of size "<< mdcTracks->size() << endreq;
198 for(RecMdcTrackCol::const_iterator it = mdcTracks->begin(); it != mdcTracks->end(); it++)
199 m_navigator->
addIdLink( (*it)->trackId(), *it );
203 log << MSG::DEBUG <<
"Unable to retrieve RecMdcTrackCol" << endreq;
207 SmartDataPtr<RecMdcKalTrackCol> mdcKalTracks(eventSvc(),
"/Event/Recon/RecMdcKalTrackCol");
210 log << MSG::DEBUG <<
"MdcKalTrackCol retrieved of size "<< mdcKalTracks->size() << endreq;
211 for(RecMdcKalTrackCol::const_iterator it = mdcKalTracks->begin(); it != mdcKalTracks->end(); it++)
212 m_navigator->
addIdLink( (*it)->trackId(), *it );
216 log << MSG::DEBUG <<
"Unable to retrieve RecMdcTrackCol" << endreq;
220 IndexMap::const_iterator i;
222 for(i = index.begin(); i != index.end(); i++)
234 m_navigator->
addLink(mcParticle, mdcTrack);
235 m_navigator->
addLink(mdcTrack, mcParticle);
239 if( mdcKalTrack != 0 )
241 m_navigator->
addLink(mcParticle, mdcKalTrack);
242 m_navigator->
addLink(mdcKalTrack, mcParticle);
250 MsgStream log(
msgSvc(), name());
254 SmartDataPtr<EmcMcHitCol> emcMcHits(eventSvc(),
"/Event/MC/EmcMcHitCol");
257 log << MSG::DEBUG <<
"EmcMcHitsCol retrieved of size "<< emcMcHits->size() << endreq;
259 if (emcMcHits->size() != 0)
262 for(EmcMcHitCol::const_iterator it = emcMcHits->begin(); it != emcMcHits->end(); it++)
265 int crystalId = (*it)->identify().get_value();
266 int McParticleID = 0;
269 McParticleID = (*it)->getTrackIndex();
270 m_navigator->
getMcEmcMcHitsIdx().insert( pair<int,int>(crystalId, McParticleID));
275 const map<Identifier,double>& hitmap = (*it)->getHitMap();
276 map<Identifier,double>::const_iterator jt;
277 for (jt=hitmap.begin(); jt!=hitmap.end(); jt++)
279 int crystalId = (*jt).first.get_value();
281 if(McParticleID !=0 )
283 m_navigator->
getMcEmcMcHitsIdx().insert( pair<int,int>(crystalId, McParticleID));
291 log << MSG::DEBUG <<
"Unable to retrieve EmcMcHitCol" << endreq;
296 SmartDataPtr<RecEmcShowerCol> emcRecShowers(eventSvc(),
"/Event/Recon/RecEmcShowerCol");
299 log << MSG::DEBUG <<
"RecEmcShowerCol retrieved of size "<< emcRecShowers->size() << endreq;
303 for(RecEmcShowerCol::const_iterator it = emcRecShowers->begin();
304 it != emcRecShowers->end();
307 int showerId = (*it)->getShowerId().get_value();
315 for(RecEmcFractionMap::const_iterator jt = fractionMap.begin();
316 jt != fractionMap.end();
319 int crystalId = (*jt).first.get_value();
320 const pair<IndexMap::const_iterator, IndexMap::const_iterator> range = mchits.equal_range(crystalId);
322 for(IndexMap::const_iterator kt = range.first; kt != range.second; kt++)
332 log << MSG::DEBUG <<
"Unable to retrieve RecEmcShowerCol" << endreq;
337 IndexMap::const_iterator i;
339 for(i = index.begin(); i != index.end(); i++)
349 if( ! emcShowers.empty() )
351 RecEmcShowerVector::const_iterator j;
352 for(j=emcShowers.begin(); j!=emcShowers.end(); j++)
354 m_navigator->
addLink(mcParticle, *j);
355 m_navigator->
addLink(*j, mcParticle);
map< RecEmcID, RecEmcFraction, less< RecEmcID > > RecEmcFractionMap
std::multimap< int, int > IndexMap
std::vector< const RecEmcShower * > RecEmcShowerVector
BesNavigatorInit(const std::string &name, ISvcLocator *pSvcLocator)
IndexMap & getMcMdcMcHitsIdx()
IndexMap & getMcEmcMcHitsIdx()
const RecMdcKalTrack * getMdcKalTrack(int id)
void addLink(const Event::McParticle *key, const RecMdcTrack *value)
const Event::McParticle * getMcParticle(int id)
IndexMap & getMcEmcRecShowersIdx()
IndexMap & getMcMdcTracksIdx()
const RecMdcTrack * getMdcTrack(int id)
RecEmcShowerVector getEmcRecShowers(int id)
void addIdLink(int id, Event::McParticle *ptr)