BOSS 8.0.0
BESIII Offline Software System
Loading...
Searching...
No Matches
BesNavigatorInit Class Reference

#include <BesNavigatorInit.h>

Inheritance diagram for BesNavigatorInit:

Public Member Functions

 BesNavigatorInit (const std::string &name, ISvcLocator *pSvcLocator)
StatusCode initialize ()
StatusCode execute ()
StatusCode finalize ()
void fillMdcInfo ()
void fillEmcInfo ()
void fillTofInfo ()
void fillMucInfo ()
 BesNavigatorInit (const std::string &name, ISvcLocator *pSvcLocator)
StatusCode initialize ()
StatusCode execute ()
StatusCode finalize ()
void fillMdcInfo ()
void fillEmcInfo ()
void fillTofInfo ()
void fillMucInfo ()
 BesNavigatorInit (const std::string &name, ISvcLocator *pSvcLocator)
StatusCode initialize ()
StatusCode execute ()
StatusCode finalize ()
void fillMdcInfo ()
void fillEmcInfo ()
void fillTofInfo ()
void fillMucInfo ()

Detailed Description

Constructor & Destructor Documentation

◆ BesNavigatorInit() [1/3]

BesNavigatorInit::BesNavigatorInit ( const std::string & name,
ISvcLocator * pSvcLocator )

Definition at line 41 of file BesNavigatorInit.cxx.

42 : Algorithm( name, pSvcLocator ) {
43 // Subdetector flags
44 declareProperty( "FillMdcInfo", b_fillMdc = true );
45 declareProperty( "FillTofInfo", b_fillTof = true );
46 declareProperty( "FillEmcInfo", b_fillEmc = true );
47 declareProperty( "FillMucInfo", b_fillMuc = true );
48 declareProperty( "MdcCut", m_mdcCut = 7 );
49 declareProperty( "PrepareHitMaps", b_fillHitMaps = false );
50 state = SIMU;
51}

Referenced by BesNavigatorInit().

◆ BesNavigatorInit() [2/3]

BesNavigatorInit::BesNavigatorInit ( const std::string & name,
ISvcLocator * pSvcLocator )

◆ BesNavigatorInit() [3/3]

BesNavigatorInit::BesNavigatorInit ( const std::string & name,
ISvcLocator * pSvcLocator )

Member Function Documentation

◆ execute() [1/3]

StatusCode BesNavigatorInit::execute ( )

Definition at line 59 of file BesNavigatorInit.cxx.

59 {
60 MsgStream log( msgSvc(), name() );
61
62 state = SIMU;
63
64 SmartDataPtr<EventNavigator> nav( eventSvc(), "/Event/Navigator" );
65 if ( !nav )
66 {
67 log << MSG::DEBUG << "Create EventNavigator" << endmsg;
68 m_navigator = new EventNavigator;
69 m_navigator->setMdcCut( m_mdcCut );
70 }
71 else
72 {
73 log << MSG::DEBUG << "Found EventNavigator (read from DST)" << endmsg;
74 m_navigator = nav;
75 state = RECO;
76 if ( log.level() < 3 ) m_navigator->Print();
77 }
78
79 SmartDataPtr<McParticleCol> mcParticles( eventSvc(), "/Event/MC/McParticleCol" );
80 if ( !mcParticles )
81 {
82 log << MSG::ERROR << "Unable to retrieve McParticleCol" << endmsg;
83 return StatusCode::FAILURE;
84 }
85 else
86 log << MSG::DEBUG << "McParticleCol retrieved of size " << mcParticles->size() << endmsg;
87
88 for ( McParticleCol::const_iterator it = mcParticles->begin(); it != mcParticles->end();
89 it++ )
90 { m_navigator->addIdLink( ( *it )->trackIndex(), *it ); }
91
92 // store MDC relations
93 if ( b_fillMdc ) fillMdcInfo();
94
95 // store EMC relations
96 if ( b_fillEmc ) fillEmcInfo();
97
98 // store TOF relations
99 if ( b_fillTof ) fillTofInfo();
100
101 // store MUC relations
102 if ( b_fillMuc ) fillMucInfo();
103
104 // Register EventNavigator to Gaudi TDS
105 if ( state == SIMU )
106 {
107 StatusCode sc = eventSvc()->registerObject( "/Event/Navigator", m_navigator );
108 if ( sc != StatusCode::SUCCESS )
109 {
110 log << MSG::ERROR << "Could not register EventNavigator" << endmsg;
111 return StatusCode::FAILURE;
112 }
113 else log << MSG::INFO << "EventNavigator registered successfully in TDS" << endmsg;
114 }
115
116 if ( log.level() < 3 )
117 {
118 log << MSG::DEBUG << "Write EventNavigator" << endmsg;
119 m_navigator->Print();
120 }
121
122 return StatusCode::SUCCESS;
123}
IMessageSvc * msgSvc()

◆ execute() [2/3]

StatusCode BesNavigatorInit::execute ( )

◆ execute() [3/3]

StatusCode BesNavigatorInit::execute ( )

◆ fillEmcInfo() [1/3]

void BesNavigatorInit::fillEmcInfo ( )

Definition at line 228 of file BesNavigatorInit.cxx.

228 {
229 MsgStream log( msgSvc(), name() );
230
231 //****** Process hits ******
232 // If simulated hits are there, fill index map (read from DST if no hits in TDS)
233 SmartDataPtr<EmcMcHitCol> emcMcHits( eventSvc(), "/Event/MC/EmcMcHitCol" );
234 if ( emcMcHits )
235 {
236 log << MSG::DEBUG << "EmcMcHitsCol retrieved of size " << emcMcHits->size() << endmsg;
237
238 if ( emcMcHits->size() != 0 ) m_navigator->getMcEmcMcHitsIdx().clear();
239
240 for ( EmcMcHitCol::const_iterator it = emcMcHits->begin(); it != emcMcHits->end(); it++ )
241 {
242 // first put Id of crystal, which particle hits initially
243 int crystalId = ( *it )->identify().get_value();
244 int McParticleID = 0;
245 if ( crystalId != 0 ) // not gamma converted in TOF
246 {
247 McParticleID = ( *it )->getTrackIndex();
248 m_navigator->getMcEmcMcHitsIdx().insert( pair<int, int>( crystalId, McParticleID ) );
249 // m_navigator->addIdLink( crystalId, *it );
250 }
251
252 // then add all other crystals touched by shower
253 const map<Identifier, double>& hitmap = ( *it )->getHitMap();
254 map<Identifier, double>::const_iterator jt;
255 for ( jt = hitmap.begin(); jt != hitmap.end(); jt++ )
256 {
257 int crystalId = ( *jt ).first.get_value();
258
259 if ( McParticleID != 0 ) // not gamma converted in TOF
260 {
261 m_navigator->getMcEmcMcHitsIdx().insert(
262 pair<int, int>( crystalId, McParticleID ) ); // CrystalId, McParticleID
263 }
264 // m_navigator->addIdLink( (*jt).first.get_value(), *it );
265 }
266 }
267 }
268 else { log << MSG::DEBUG << "Unable to retrieve EmcMcHitCol" << endmsg; }
269
270 // ****** Get EMC top level objects from TDS ******
271 // EMC Reconstructed Showers
272 SmartDataPtr<RecEmcShowerCol> emcRecShowers( eventSvc(), "/Event/Recon/RecEmcShowerCol" );
273 if ( emcRecShowers )
274 {
275 log << MSG::DEBUG << "RecEmcShowerCol retrieved of size " << emcRecShowers->size()
276 << endmsg;
277
278 IndexMap& mchits = m_navigator->getMcEmcMcHitsIdx();
279
280 for ( RecEmcShowerCol::const_iterator it = emcRecShowers->begin();
281 it != emcRecShowers->end(); it++ )
282 {
283 int showerId = ( *it )->getShowerId().get_value();
284 m_navigator->addIdLink( showerId, *it );
285
286 // calculate relations only during reco and store them to DST.
287 // EmcMcHit tables are removed then.
288 if ( !mchits.empty() )
289 {
290 const RecEmcFractionMap& fractionMap = ( *it )->getFractionMap();
291 for ( RecEmcFractionMap::const_iterator jt = fractionMap.begin();
292 jt != fractionMap.end(); jt++ )
293 {
294 int crystalId = ( *jt ).first.get_value();
295 const pair<IndexMap::const_iterator, IndexMap::const_iterator> range =
296 mchits.equal_range( crystalId ); // McParticles which hit given crystal
297
298 for ( IndexMap::const_iterator kt = range.first; kt != range.second; kt++ )
299 {
300 m_navigator->getMcEmcRecShowersIdx().insert( pair<int, int>(
301 ( *kt ).second, showerId ) ); // McParticle id <-> RecShower ShowerId
302 }
303 }
304 }
305 }
306 }
307 else { log << MSG::DEBUG << "Unable to retrieve RecEmcShowerCol" << endmsg; }
308
309 //****** Make main relations between top level objects ***
310 IndexMap::const_iterator i;
311 IndexMap& index = m_navigator->getMcEmcRecShowersIdx();
312 for ( i = index.begin(); i != index.end(); i++ )
313 {
314 // i.first = McParticle id; i.second = MdcTrack id
315 const McParticle* mcParticle = m_navigator->getMcParticle( ( *i ).first );
316
317 if ( mcParticle == 0 ) continue;
318
319 const RecEmcShowerVector& emcShowers = m_navigator->getEmcRecShowers( ( *i ).second );
320
321 if ( !emcShowers.empty() )
322 {
323 RecEmcShowerVector::const_iterator j;
324 for ( j = emcShowers.begin(); j != emcShowers.end(); j++ )
325 {
326 m_navigator->addLink( mcParticle, *j );
327 m_navigator->addLink( *j, mcParticle );
328 }
329 }
330 }
331}
map< RecEmcID, RecEmcFraction, less< RecEmcID > > RecEmcFractionMap
std::vector< const RecEmcShower * > RecEmcShowerVector

Referenced by execute().

◆ fillEmcInfo() [2/3]

void BesNavigatorInit::fillEmcInfo ( )

◆ fillEmcInfo() [3/3]

void BesNavigatorInit::fillEmcInfo ( )

◆ fillMdcInfo() [1/3]

void BesNavigatorInit::fillMdcInfo ( )

Definition at line 129 of file BesNavigatorInit.cxx.

129 {
130 MsgStream log( msgSvc(), name() );
131
132 //****** Process hits ******
133 // If simulated hits are there, fill index map (read from DST if no hits in TDS)
134 SmartDataPtr<MdcMcHitCol> mdcMcHits( eventSvc(), "/Event/MC/MdcMcHitCol" );
135 if ( mdcMcHits )
136 {
137 log << MSG::DEBUG << "MdcMcHitsCol retrieved of size " << mdcMcHits->size() << endmsg;
138
139 if ( mdcMcHits->size() != 0 ) m_navigator->getMcMdcMcHitsIdx().clear();
140
141 for ( MdcMcHitCol::const_iterator it = mdcMcHits->begin(); it != mdcMcHits->end(); it++ )
142 {
143 // fill relation MdcHit id <-> McParticle
144 m_navigator->getMcMdcMcHitsIdx().insert(
145 pair<int, int>( ( *it )->identify().get_value(), ( *it )->getTrackIndex() ) );
146
147 // m_navigator->addIdLink( (*it)->identify().get_value(), *it );
148 }
149 }
150 else { log << MSG::DEBUG << "Unable to retrieve MdcMcHitCol" << endmsg; }
151
152 // If reconstructed hits are there, fill index map (read from DST if no hits in TDS)
153 SmartDataPtr<RecMdcHitCol> mdcRecHits( eventSvc(), "/Event/Recon/RecMdcHitCol" );
154 if ( mdcRecHits )
155 {
156 log << MSG::DEBUG << "MdcRecHitCol retrieved of size " << mdcRecHits->size() << endmsg;
157
158 if ( mdcRecHits->size() != 0 ) m_navigator->getMcMdcTracksIdx().clear();
159
160 IndexMap& mchits = m_navigator->getMcMdcMcHitsIdx();
161 for ( RecMdcHitCol::iterator it = mdcRecHits->begin(); it != mdcRecHits->end(); it++ )
162 {
163 int mdcId = ( ( *it )->getMdcId() ).get_value();
164 // m_navigator->addIdLink( mdcId, *it);
165
166 const pair<IndexMap::const_iterator, IndexMap::const_iterator> range =
167 mchits.equal_range( mdcId );
168 for ( IndexMap::const_iterator jt = range.first; jt != range.second; jt++ )
169 {
170 m_navigator->getMcMdcTracksIdx().insert(
171 pair<int, int>( ( *jt ).second, ( *it )->getTrkId() ) );
172 }
173 }
174 }
175 else log << MSG::DEBUG << "Unable to retrieve RecMdcHitCol" << endmsg;
176
177 // ****** Get MDC top level objects from TDS ******
178 // MDC Reconstructed Tracks
179 SmartDataPtr<RecMdcTrackCol> mdcTracks( eventSvc(), "/Event/Recon/RecMdcTrackCol" );
180 if ( mdcTracks )
181 {
182 log << MSG::DEBUG << "MdcTrackCol retrieved of size " << mdcTracks->size() << endmsg;
183 for ( RecMdcTrackCol::const_iterator it = mdcTracks->begin(); it != mdcTracks->end();
184 it++ )
185 m_navigator->addIdLink( ( *it )->trackId(), *it );
186 }
187 else { log << MSG::DEBUG << "Unable to retrieve RecMdcTrackCol" << endmsg; }
188
189 // MDC Kalman Tracks
190 SmartDataPtr<RecMdcKalTrackCol> mdcKalTracks( eventSvc(), "/Event/Recon/RecMdcKalTrackCol" );
191 if ( mdcKalTracks )
192 {
193 log << MSG::DEBUG << "MdcKalTrackCol retrieved of size " << mdcKalTracks->size() << endmsg;
194 for ( RecMdcKalTrackCol::const_iterator it = mdcKalTracks->begin();
195 it != mdcKalTracks->end(); it++ )
196 m_navigator->addIdLink( ( *it )->trackId(), *it );
197 }
198 else { log << MSG::DEBUG << "Unable to retrieve RecMdcTrackCol" << endmsg; }
199
200 //****** Make main relations between top level objects ***
201 IndexMap::const_iterator i;
202 IndexMap& index = m_navigator->getMcMdcTracksIdx();
203 for ( i = index.begin(); i != index.end(); i++ )
204 {
205 // i.first = McParticle id; i.second = MdcTrack id
206 const McParticle* mcParticle = m_navigator->getMcParticle( ( *i ).first );
207
208 if ( mcParticle == 0 ) continue;
209
210 const RecMdcTrack* mdcTrack = m_navigator->getMdcTrack( ( *i ).second );
211
212 if ( mdcTrack != 0 )
213 {
214 m_navigator->addLink( mcParticle, mdcTrack );
215 m_navigator->addLink( mdcTrack, mcParticle );
216 }
217
218 const RecMdcKalTrack* mdcKalTrack =
219 m_navigator->getMdcKalTrack( ( *i ).second ); // same trkid
220 if ( mdcKalTrack != 0 )
221 {
222 m_navigator->addLink( mcParticle, mdcKalTrack );
223 m_navigator->addLink( mdcKalTrack, mcParticle );
224 }
225 }
226}

Referenced by execute().

◆ fillMdcInfo() [2/3]

void BesNavigatorInit::fillMdcInfo ( )

◆ fillMdcInfo() [3/3]

void BesNavigatorInit::fillMdcInfo ( )

◆ fillMucInfo() [1/3]

void BesNavigatorInit::fillMucInfo ( )

Definition at line 335 of file BesNavigatorInit.cxx.

335{}

Referenced by execute().

◆ fillMucInfo() [2/3]

void BesNavigatorInit::fillMucInfo ( )

◆ fillMucInfo() [3/3]

void BesNavigatorInit::fillMucInfo ( )

◆ fillTofInfo() [1/3]

void BesNavigatorInit::fillTofInfo ( )

Definition at line 333 of file BesNavigatorInit.cxx.

333{}

Referenced by execute().

◆ fillTofInfo() [2/3]

void BesNavigatorInit::fillTofInfo ( )

◆ fillTofInfo() [3/3]

void BesNavigatorInit::fillTofInfo ( )

◆ finalize() [1/3]

StatusCode BesNavigatorInit::finalize ( )

Definition at line 127 of file BesNavigatorInit.cxx.

127{ return StatusCode::SUCCESS; }

◆ finalize() [2/3]

StatusCode BesNavigatorInit::finalize ( )

◆ finalize() [3/3]

StatusCode BesNavigatorInit::finalize ( )

◆ initialize() [1/3]

StatusCode BesNavigatorInit::initialize ( )

Definition at line 55 of file BesNavigatorInit.cxx.

55{ return StatusCode::SUCCESS; }

◆ initialize() [2/3]

StatusCode BesNavigatorInit::initialize ( )

◆ initialize() [3/3]

StatusCode BesNavigatorInit::initialize ( )

The documentation for this class was generated from the following files: