BOSS 7.0.3
BESIII Offline Software System
Loading...
Searching...
No Matches
BesMcTruthWriter.cc
Go to the documentation of this file.
1//---------------------------------------------------------------------------//
2//// BOOST --- BESIII Object_Oriented Simulation Tool //
3////---------------------------------------------------------------------------//
4////Description:
5////Author: Dengzy
6////Created: Mar, 2004
7////Modified:
8////Comment:
9//
10#include "G4DigiManager.hh"
11#include "BesMdcHit.hh"
12#include "BesTofHit.hh"
13#include "BesEmcHit.hh"
14#include "BesMucHit.hh"
15#include "BesTruthTrack.hh"
16#include "BesTruthVertex.hh"
17#include "BesSensitiveManager.hh"
18//#include "G4HCofThisEvent.hh"
19//#include "G4SDManager.hh"
20//#include "G4PrimaryVertex.hh"
21//#include "G4PrimaryParticle.hh"
22
23#include "GaudiKernel/IDataProviderSvc.h"
24#include "GaudiKernel/ISvcLocator.h"
25#include "GaudiKernel/Bootstrap.h"
26#include "GaudiKernel/RegistryEntry.h"
27#include "GaudiKernel/MsgStream.h"
28#include "CLHEP/Vector/LorentzVector.h"
29#include "CLHEP/Geometry/Point3D.h"
30
31#include "McTruth/DecayMode.h"
32#include "McTruth/MdcMcHit.h"
33#include "McTruth/TofMcHit.h"
34#include "McTruth/EmcMcHit.h"
35#include "McTruth/MucMcHit.h"
36
37#include "Identifier/Identifier.h"
38#include "Identifier/MdcID.h"
39#include "Identifier/TofID.h"
40#include "Identifier/EmcID.h"
41#include "Identifier/MucID.h"
42
43#include "McTruth/McEvent.h"
44#include "EventModel/EventModel.h"
45
46#include "GaudiKernel/SmartDataPtr.h"
47#include "BesMcTruthWriter.hh"
48
50{
51 m_DigiMan = G4DigiManager::GetDMpointer();
52 //mdcGeoPointer=BesMdcGeoParameter::GetGeo();
53}
54
56{
57}
58
60{
61 //interface to event data service
62 ISvcLocator* svcLocator = Gaudi::svcLocator();
63 StatusCode sc=svcLocator->service("EventDataSvc", m_evtSvc);
64 if (sc.isFailure())
65 G4cout<<"Could not accesss EventDataSvc!"<<G4endl;
66
67 DataObject *aMcEvent;
68 m_evtSvc->findObject("/Event/MC",aMcEvent);
69 if(aMcEvent==NULL) {
70 McEvent* aMcEvent = new McEvent;
71 sc = m_evtSvc->registerObject("/Event/MC",aMcEvent);
72 if(sc!=StatusCode::SUCCESS)
73 G4cout<< "Could not register McEvent" <<G4endl;
74 }
75
82}
83
85{
87 vector<BesTruthTrack*>* trackList = sensitiveManager->GetTrackList();
88 G4int nTrack = trackList->size();
89 BesTruthTrack* track;
90
91 vector<BesTruthVertex*>* vertexList = sensitiveManager->GetVertexList();
92 G4int nVertex = vertexList->size();
93 BesTruthVertex* vertex;
94
95 //arrange TruthTrack in trackList in order of trackIndex
96 for(int i=0;i<nTrack-1;i++)
97 for(int j=i+1;j<nTrack;j++)
98 if((*trackList)[i]->GetIndex()>(*trackList)[j]->GetIndex())
99 {
100 track=(*trackList)[i];
101 (*trackList)[i]=(*trackList)[j];
102 (*trackList)[j]=track;
103 }
104
106
107 //loop over tracks
108 for(int i=0;i<nTrack;i++)
109 {
110 track = (*trackList) [i];
111
112 // find out the start point
113 bool isPrimary = false;
114 bool startPointFound = false;
115 BesTruthVertex* startPoint;
116
117 for (int i=0;i<nVertex;i++)
118 {
119 vertex = (*vertexList) [i];
120 if ( track->GetVertex()->GetIndex() == vertex->GetIndex() )
121 {
122 if (!vertex->GetParentTrack()) isPrimary = true;
123 startPointFound = true;
124 startPoint = vertex;
125 break;
126 }
127 }
128
129 if (!startPointFound)
130 std::cout << "error in finding the start point of a track" <<std::endl;
131
132
133 bool endPointFound = false;
134 // find out the end point
135 for (int i=0;i<nVertex;i++)
136 {
137 vertex = (*vertexList) [i];
138 if( track->GetTerminalVertex() )
139 {
140 if (track->GetTerminalVertex()->GetIndex() == vertex->GetIndex() )
141 {
142 //create the mc particle
143 Event::McParticle* mcParticle = new Event::McParticle;
144
145 // initialization
146 HepLorentzVector initialMomentum(track->GetP4().x()/1000., track->GetP4().y()/1000., track->GetP4().z()/1000., track->GetP4().t()/1000.);
147
148 HepLorentzVector initialPosition(startPoint->GetPosition().x()/10., startPoint->GetPosition().y()/10., startPoint->GetPosition().z()/10.,startPoint->GetTime());
149
150 mcParticle->initialize(track->GetPDGCode(), 0, initialMomentum, initialPosition);
151
152 // Set track index
153 mcParticle->setTrackIndex( track->GetIndex() );
154
155 // Adding status flag
156 if (isPrimary ) mcParticle->addStatusFlag(Event::McParticle::PRIMARY);
157
158 if (track->GetDaughterIndexes().size()==0)
160
161 //std::cout<<"pdg:"<<track->GetPDGCode()<<" "
162 // <<"source:"<<track->GetSource()<<" "
163 // <<std::endl;
164 if (track->GetSource()=="FromGenerator")
166 else if(track->GetSource()=="FromG4")
168 else
170
171 //std::cout<<"status:"<<mcParticle->statusFlags()<<" "
172 // <<"FGN:"<<mcParticle->decayFromGenerator()<<" "
173 // <<"FG4:"<<mcParticle->decayInFlight()<<std::endl;
174 // Adding vertex index
175 mcParticle->setVertexIndex0(startPoint->GetIndex());
176 mcParticle->setVertexIndex1(vertex->GetIndex());
177
178 // Set the final position
179 HepLorentzVector finalPosition(vertex->GetPosition().x()/10., vertex->GetPosition().y()/10., vertex->GetPosition().z()/10., vertex->GetTime());
180 mcParticle->finalize(finalPosition);
181
182 // push back
183 particleCol->push_back(mcParticle);
184
185 endPointFound = true;
186 }
187 }
188 }
189
190 if (!endPointFound)
191 {
192 //std::cout << "warning in finding the end point of a track" <<std::endl;
193 if (track->GetDaughterIndexes().size()==0)
194 {
195 // create the mc particle
196 Event::McParticle* mcParticle = new Event::McParticle;
197 // initialization
198 HepLorentzVector initialMomentum( track->GetP4().x()/1000., track->GetP4().y()/1000., track->GetP4().z()/1000., track->GetP4().t()/1000.);
199 HepLorentzVector initialPosition(startPoint->GetPosition().x()/10., startPoint->GetPosition().y()/10., startPoint->GetPosition().z()/10., startPoint->GetTime());
200
201 mcParticle->initialize(track->GetPDGCode(), 0, initialMomentum, initialPosition);
202
203 // Set track index
204 mcParticle->setTrackIndex( track->GetIndex() );
205
206 // Adding status flag
208 if (isPrimary ) mcParticle->addStatusFlag(Event::McParticle::PRIMARY);
209
210 // Adding vertex index
211 mcParticle->setVertexIndex0( startPoint->GetIndex() );
212 mcParticle->setVertexIndex1( -99 );
213
214 //std::cout<<"pdg:"<<track->GetPDGCode()<<" "
215 // <<"source:"<<track->GetSource()<<" "
216 // <<std::endl;
217 if (track->GetSource()=="FromGenerator")
219 else if(track->GetSource()=="FromG4")
221 else
223
224 //std::cout<<"status:"<<mcParticle->statusFlags()<<" "
225 // <<"FGN:"<<mcParticle->decayFromGenerator()<<" "
226 // <<"FG4:"<<mcParticle->decayInFlight()<<std::endl;
227
228 // push back
229 particleCol->push_back(mcParticle);
230 continue;
231 }
232 }
233 }
234
235 // Get primary McParticles
236 SmartRefVector<Event::McParticle> primaryParticleCol;
237 Event::McParticleCol::iterator iter_particle;
238 for ( iter_particle = particleCol->begin();
239 iter_particle != particleCol->end(); iter_particle++) {
240
241 if ((*iter_particle)->primaryParticle()) {
242 Event::McParticle* mcPart = (Event::McParticle*)(*iter_particle);
243 primaryParticleCol.push_back(mcPart);
244 }
245 }
246
247 if (primaryParticleCol.empty())
248 std::cout << "no primary particle found!" << std::endl;
249
250 // Add mother particle recursively
251 SmartRefVector<Event::McParticle>::iterator iter_primary;
252 for ( iter_primary = primaryParticleCol.begin();
253 iter_primary != primaryParticleCol.end(); iter_primary++) {
254 if ( !((*iter_primary)->leafParticle()) )
255 AddMother((*iter_primary), particleCol);
256 }
257
258 //register McParticle collection to TDS
259 StatusCode sc = m_evtSvc->registerObject("/Event/MC/McParticleCol", particleCol);
260 if(sc!=StatusCode::SUCCESS)
261 G4cout<< "Could not register McParticle collection" <<G4endl;
262
263 //retrive McParticle from TDS
264 /*SmartDataPtr<Event::McParticleCol> mcParticleCol(m_evtSvc,"/Event/MC/McParticleCol");
265 if(!mcParticleCol)
266 G4cout<<"Could not retrieve McParticelCol"<<G4endl;
267 Event::McParticleCol::iterator iter_mc = mcParticleCol->begin();
268 for (;iter_mc != mcParticleCol->end(); iter_mc++)
269 {
270 G4cout<<(*iter_mc)->getTrackIndex();
271 G4cout<<" "<<(*iter_mc)->particleProperty();
272 G4cout<<" "<<(*iter_mc)->getVertexIndex0();
273 G4cout<<" "<<(*iter_mc)->getVertexIndex1();
274 G4cout<<" "<<(*iter_mc)->initialFourMomentum().x();
275 G4cout<<" "<<(*iter_mc)->initialFourMomentum().y();
276 G4cout<<" "<<(*iter_mc)->initialFourMomentum().z();
277 G4cout<<" "<<(*iter_mc)->initialFourMomentum().t();
278 G4cout<<" "<<(*iter_mc)->initialPosition().x();
279 G4cout<<" "<<(*iter_mc)->initialPosition().y();
280 G4cout<<" "<<(*iter_mc)->initialPosition().z();
281 G4cout<<G4endl;
282 }
283 G4cout<<"end of retrieve McParticle from TDS"<<G4endl;
284 */
285
286}
287
289{
290 if (currentParticle->leafParticle()) {
291 return;
292 }
293 Event::McParticleCol::iterator iter;
294 bool found = false;
295 for ( iter = particleCol->begin(); iter != particleCol->end(); iter++) {
296 if (currentParticle->vertexIndex1() == (*iter)->vertexIndex0()) {
297 found = true;
298 (*iter)->setMother(currentParticle);
299 currentParticle->addDaughter(*iter);
300 AddMother((*iter), particleCol);
301 }
302 }
303 if (!found) std::cout << "AddMother: inconsistency was found!" << std::endl;
304
305}
306
308{
309 SmartDataPtr<DecayMode> decayMode(m_evtSvc,"/Event/MC/DecayMode");
310 if(!decayMode)
311 {
312 //G4cout<<"Could not retrieve DecayMode"<<G4endl;
313 DecayMode* aDecayMode = new DecayMode;
314 //register Decay Mode to TDS
315 int dm[10]={0,0,0,0,0,0,0,0,0,0};
316 aDecayMode->putData(dm,10);
317 StatusCode scDM = m_evtSvc->registerObject("/Event/MC/DecayMode", aDecayMode);
318 if(scDM!=StatusCode::SUCCESS)
319 G4cout<< "Could not register DecayMode" <<G4endl;
320 }
321}
322
324{
325 //Mdc McHit collection defined in BOSS
326 Event::MdcMcHitCol* aMdcMcHitCol = new Event::MdcMcHitCol;
327
328 G4int HCID = -1;
329 HCID = m_DigiMan->GetHitsCollectionID("BesMdcTruthCollection");
330 if(HCID>0)
331 {
332 BesMdcHitsCollection* HC = 0;
333 HC = (BesMdcHitsCollection*) (m_DigiMan->GetHitsCollection(HCID));
334 G4int n_hit = HC->entries();
335 if(n_hit>0)
336 {
337 //arrange hits in hits collection in order of trackIndex
338 BesMdcHit* hit;
339 vector<BesMdcHit*>* vecHC = HC->GetVector();
340 for(int i=0;i<n_hit-1;i++)
341 for(int j=i+1;j<n_hit;j++)
342 if((*vecHC)[i]->GetTrackID()>(*vecHC)[j]->GetTrackID())
343 {
344 hit = (*vecHC)[i];
345 (*vecHC)[i] = (*vecHC)[j];
346 (*vecHC)[j] = hit;
347 }
348
349 //push back MdcMcHits to MdcMcHitCol in TDS
350 for(G4int i=0;i<n_hit;i++)
351 {
352 hit = (*HC)[i];
353 const Identifier ident = MdcID::wire_id ( hit->GetLayerNo(), hit->GetCellNo() );
354 Event::MdcMcHit* mdcMcHit = new Event::MdcMcHit(ident, hit->GetTrackID(),
355 hit->GetPos().x(), hit->GetPos().y(), hit->GetPos().z(),
356 hit->GetDriftD(), hit->GetEdep(),hit->GetPosFlag() );
357 aMdcMcHitCol->push_back(mdcMcHit);
358 }
359
360 }
361 }
362
363 //register MDC McTruth collection to TDS
364 StatusCode scMdc = m_evtSvc->registerObject("/Event/MC/MdcMcHitCol", aMdcMcHitCol);
365 if(scMdc!=StatusCode::SUCCESS)
366 G4cout<< "Could not register MDC McTruth collection" <<G4endl;
367
368 //retrieve MDC McTruth from TDS
369 /*SmartDataPtr<Event::MdcMcHitCol> aMcHitCol(m_evtSvc,"/Event/MC/MdcMcHitCol");
370 if(!aMcHitCol)
371 G4cout<<"Could not retrieve MDC McTruth collection"<<G4endl;
372
373 Event::MdcMcHitCol::iterator iMcHitCol;
374 for(iMcHitCol=aMcHitCol->begin(); iMcHitCol!=aMcHitCol->end(); iMcHitCol++)
375 {
376 const Identifier ident = (*iMcHitCol)->identify();
377 G4cout<<(*iMcHitCol)->getTrackIndex();
378 G4cout<<" "<<MdcID::layer(ident);
379 G4cout<<" "<<MdcID::wire(ident);
380 G4cout<<" "<<(*iMcHitCol)->getDepositEnergy();
381 G4cout<<" "<<(*iMcHitCol)->getDriftDistance();
382 G4cout<<" "<<(*iMcHitCol)->getPositionX();
383 G4cout<<" "<<(*iMcHitCol)->getPositionY();
384 G4cout<<" "<<(*iMcHitCol)->getPositionZ();
385 G4cout<<G4endl;
386 }
387 G4cout<<"end of retrieve MDC McTruth collection"<<G4endl;
388 */
389}
390
392{
393 //Tof McHit collection defined in BOSS
394 Event::TofMcHitCol* aTofMcHitCol = new Event::TofMcHitCol;
395
396 G4int HCID = -1;
397 HCID = m_DigiMan->GetHitsCollectionID("BesTofHitsList");
398 if(HCID>0)
399 {
400 BesTofHitsCollection* HC = 0;
401 HC = (BesTofHitsCollection*) (m_DigiMan->GetHitsCollection(HCID));
402 G4int n_hit = HC->entries();
403 if(n_hit>0)
404 {
405 //arrange hits in hits collection in order of trackIndex
406 BesTofHit* hit;
407 vector<BesTofHit*>* vecHC = HC->GetVector();
408 for( int i=0; i<n_hit-1; i++ ) {
409 for( int j=i+1; j<n_hit; j++ ) {
410 if((*vecHC)[i]->GetTrackIndex()>(*vecHC)[j]->GetTrackIndex()) {
411 hit = (*vecHC)[i];
412 (*vecHC)[i] = (*vecHC)[j];
413 (*vecHC)[j] = hit;
414 }
415 }
416 }
417
418 //push back TofMcHit collection to TDS
419 for( G4int i=0; i<n_hit; i++ ) {
420 hit = (*HC)[i];
421 Identifier ident;
422 unsigned int barrel_ec = hit->GetPartId();
423 // for Scintillator
424 if( TofID::is_scin( barrel_ec ) ) {
425 unsigned int scinNum = hit->GetScinNb();
426 unsigned int layer = 0;
427 if( TofID::is_barrel(barrel_ec) && scinNum>TofID::getPHI_BARREL_MAX()) {
428 layer = 1;
429 scinNum = scinNum - TofID::getPHI_BARREL_MAX() - 1;
430 }
431 ident = TofID::cell_id ( barrel_ec, layer, scinNum, 0);
432 }
433 // for ETF(MRPC)
434 else { // for ETF(MRPC)
435 if( barrel_ec==3 || barrel_ec==4 ) {
436 unsigned int endcap = 0;
437 unsigned int module = hit->GetModule();
438 unsigned int strip = hit->GetStrip();
439 if( barrel_ec==4 ) { // west end cap
440 endcap = 1;
441 }
442 ident = TofID::cell_id( 3, endcap, module, strip, 0 );
443 }
444 }
445 if( barrel_ec>=0 && barrel_ec<=4 ) {
446 Event::TofMcHit* tofMcHit = new Event::TofMcHit( ident, hit->GetTrackIndex(),
447 hit->GetPos().x(), hit->GetPos().y(), hit->GetPos().z(), hit->GetMomentum().x(),
448 hit->GetMomentum().y(), hit->GetMomentum().z(), hit->GetTrackL(), hit->GetTime() );
449 aTofMcHitCol->push_back(tofMcHit);
450 }
451 }
452 }
453 }
454
455 //register TOF McTruth collection to TDS
456 StatusCode scTof = m_evtSvc->registerObject("/Event/MC/TofMcHitCol", aTofMcHitCol);
457 if(scTof!=StatusCode::SUCCESS)
458 G4cout<< "Could not register TOF McTruth collection" <<G4endl;
459
460 //retrieve TOF McTruth from TDS
461 /*SmartDataPtr<Event::TofMcHitCol> aMcHitCol(m_evtSvc,"/Event/MC/TofMcHitCol");
462 if(!aMcHitCol)
463 G4cout<<"Could not retrieve TOF McTruth collection"<<G4endl;
464
465 Event::TofMcHitCol::iterator iMcHitCol;
466 for(iMcHitCol=aMcHitCol->begin(); iMcHitCol!=aMcHitCol->end(); iMcHitCol++)
467 {
468 const Identifier ident = (*iMcHitCol)->identify();
469 G4cout<<(*iMcHitCol)->getTrackIndex();
470 G4cout<<" "<<TofID::barrel_ec(ident);;
471 G4cout<<" "<<TofID::layer(ident);
472 G4cout<<" "<<TofID::phi_module(ident);
473 G4cout<<" "<<(*iMcHitCol)->getPositionX();
474 G4cout<<" "<<(*iMcHitCol)->getPositionY();
475 G4cout<<" "<<(*iMcHitCol)->getPositionZ();
476 G4cout<<" "<<(*iMcHitCol)->getPx();
477 G4cout<<" "<<(*iMcHitCol)->getPy();
478 G4cout<<" "<<(*iMcHitCol)->getPz();
479 G4cout<<" "<<(*iMcHitCol)->getTrackLength();
480 G4cout<<" "<<(*iMcHitCol)->getFlightTime();
481 G4cout<<G4endl;
482 }
483 G4cout<<"end of retrieve TOF McTruth"<<G4endl;
484 */
485}
486
488{
489 //Emc McHit collection defined in BOSS
490 Event::EmcMcHitCol* aEmcMcHitCol = new Event::EmcMcHitCol;
491
492 G4int fullMc = 1;
493 if(fullMc==1) { //full Mc Truth
494 G4int HCID = -1;
495 HCID = m_DigiMan->GetHitsCollectionID("BesEmcTruthHitsList");
496 if(HCID>0)
497 {
499 HC = (BesEmcTruthHitsCollection*) (m_DigiMan->GetHitsCollection(HCID));
500 G4int n_hit = HC->entries();
501 if(n_hit>0)
502 {
503 //arrange hits in hits collection in order of trackIndex
504 BesEmcTruthHit* hit;
505 vector<BesEmcTruthHit*>* vecHC = HC->GetVector();
506 for(int i=0;i<n_hit-1;i++) {
507 for(int j=i+1;j<n_hit;j++) {
508 if((*vecHC)[i]->GetTrackIndex()>(*vecHC)[j]->GetTrackIndex()) {
509 hit = (*vecHC)[i];
510 (*vecHC)[i] = (*vecHC)[j];
511 (*vecHC)[j] = hit;
512 }
513 }
514 }
515
516 for(G4int i=0;i<n_hit;i++)
517 {
518 BesEmcTruthHit* hit;
519 hit = (*HC)[i];
520
521 std::map<Identifier,double> hitMap;
522 std::map<Identifier,double>::const_iterator iHitMap;
523 hitMap.clear();
524 for(iHitMap=hit->Begin();iHitMap!=hit->End();iHitMap++) {
525 hitMap[iHitMap->first]=iHitMap->second;
526 }
527
528 Event::EmcMcHit* emcMcHit = new Event::EmcMcHit(hit->GetIdentify(), hit->GetTrackIndex(),
529 hit->GetPosition().x(), hit->GetPosition().y(), hit->GetPosition().z(),
530 hit->GetMomentum().x(), hit->GetMomentum().y(), hit->GetMomentum().z(),
531 hit->GetEDep() );
532
533 emcMcHit->setHitEmc(hit->GetHitEmc());
534 emcMcHit->setPDGCode(hit->GetPDGCode());
535 emcMcHit->setPDGCharge(hit->GetPDGCharge());
536 emcMcHit->setTime(hit->GetTime());
537 emcMcHit->setHitMap(hitMap);
538
539 aEmcMcHitCol->push_back(emcMcHit);
540 }
541 }
542 }
543 } else { //simple Mc Truth
544 G4int HCID = -1;
545 HCID = m_DigiMan->GetHitsCollectionID("BesEmcHitsList");
546 if(HCID>0)
547 {
548 BesEmcHitsCollection* HC = 0;
549 HC = (BesEmcHitsCollection*) (m_DigiMan->GetHitsCollection(HCID));
550 G4int n_hit = HC->entries();
551 if(n_hit>0)
552 {
553 //arrange hits in hits collection in order of trackIndex
554 BesEmcHit* hit;
555 vector<BesEmcHit*>* vecHC = HC->GetVector();
556 for(int i=0;i<n_hit-1;i++)
557 for(int j=i+1;j<n_hit;j++)
558 if((*vecHC)[i]->GetTrackIndex()>(*vecHC)[j]->GetTrackIndex())
559 {
560 hit = (*vecHC)[i];
561 (*vecHC)[i] = (*vecHC)[j];
562 (*vecHC)[j] = hit;
563 }
564
565 //Emc McHit collection defined in BOSS
566 Event::EmcMcHitCol* aEmcMcHitCol = new Event::EmcMcHitCol;
567
568 for(G4int i=0;i<n_hit;i++)
569 {
570 hit = (*HC)[i];
572
573 std::map<Identifier,double> hitMap;
574 Event::EmcMcHit* emcMcHit = new Event::EmcMcHit(ident, hit->GetTrackIndex(),
575 hit->GetPosCrystal().x(), hit->GetPosCrystal().y(), hit->GetPosCrystal().z(),
576 hit->GetMomentum().x(), hit->GetMomentum().y(), hit->GetMomentum().z(),
577 hit->GetEdepCrystal() );
578
579 aEmcMcHitCol->push_back(emcMcHit);
580 }
581 }
582 }
583 }
584
585 //register EMC McTruth collection to TDS
586 StatusCode scEmc = m_evtSvc->registerObject("/Event/MC/EmcMcHitCol", aEmcMcHitCol);
587 if(scEmc!=StatusCode::SUCCESS)
588 G4cout<< "Could not register EMC McTruth collection" <<G4endl;
589
590 //retrieve EMC McTruth from TDS
591 /*SmartDataPtr<Event::EmcMcHitCol> aMcHitCol(m_evtSvc,"/Event/MC/EmcMcHitCol");
592 if(!aMcHitCol)
593 G4cout<<"Could not retrieve EMC McTruth collection"<<G4endl;
594
595 Event::EmcMcHitCol::iterator iMcHitCol;
596 for(iMcHitCol=aMcHitCol->begin(); iMcHitCol!=aMcHitCol->end(); iMcHitCol++)
597 {
598 const Identifier ident = (*iMcHitCol)->identify();
599 G4cout<<(*iMcHitCol)->getTrackIndex();
600 G4cout<<" "<<EmcID::barrel_ec(ident);
601 G4cout<<" "<<EmcID::theta_module(ident);
602 G4cout<<" "<<EmcID::phi_module(ident);
603 G4cout<<" "<<(*iMcHitCol)->getPositionX();
604 G4cout<<" "<<(*iMcHitCol)->getPositionY();
605 G4cout<<" "<<(*iMcHitCol)->getPositionZ();
606 G4cout<<" "<<(*iMcHitCol)->getPx();
607 G4cout<<" "<<(*iMcHitCol)->getPy();
608 G4cout<<" "<<(*iMcHitCol)->getPz();
609 G4cout<<" "<<(*iMcHitCol)->getDepositEnergy();
610 G4cout<<G4endl;
611 }
612 G4cout<<"end of retrieve EMC McTruth"<<G4endl;
613 */
614}
615
617{
618 //Muc McHit collection defined in BOSS
619 Event::MucMcHitCol* aMucMcHitCol = new Event::MucMcHitCol;
620
621 G4int HCID = -1;
622 HCID = m_DigiMan->GetHitsCollectionID("BesMucHitsList");
623 if(HCID>0)
624 {
625 BesMucHitsCollection* HC = 0;
626 HC = (BesMucHitsCollection*) (m_DigiMan->GetHitsCollection(HCID));
627 G4int n_hit = HC->entries();
628 if(n_hit>0)
629 {
630 //arrange hits in hits collection in order of trackIndex
631 BesMucHit* hit;
632 vector<BesMucHit*>* vecHC = HC->GetVector();
633 for(int i=0;i<n_hit-1;i++)
634 for(int j=i+1;j<n_hit;j++)
635 if((*vecHC)[i]->GetTrackIndex()>(*vecHC)[j]->GetTrackIndex())
636 {
637 hit = (*vecHC)[i];
638 (*vecHC)[i] = (*vecHC)[j];
639 (*vecHC)[j] = hit;
640 }
641
642 for(G4int i=0;i<n_hit;i++)
643 {
644 hit = (*HC)[i];
645 Identifier ident = MucID::channel_id ( hit->GetPart(), hit->GetSeg(), hit->GetGap(),
646 hit->GetStrip() );
647 Event::MucMcHit* mucMcHit = new Event::MucMcHit(ident, hit->GetTrackIndex(),
648 hit->GetPos().x(), hit->GetPos().y(), hit->GetPos().z(), hit->GetMomentum().x(),
649 hit->GetMomentum().y(), hit->GetMomentum().z() );
650 aMucMcHitCol->push_back(mucMcHit);
651 }
652
653 }
654 }
655
656 //register MUC McTruth collection to TDS
657 StatusCode scMuc = m_evtSvc->registerObject("/Event/MC/MucMcHitCol", aMucMcHitCol);
658 if(scMuc!=StatusCode::SUCCESS)
659 G4cout<< "Could not register MUC McTruth collection" <<G4endl;
660
661 //retrieve MUC McTruth from TDS
662 /*SmartDataPtr<Event::MucMcHitCol> aMcHitCol(m_evtSvc,"/Event/MC/MucMcHitCol");
663 if(!aMcHitCol)
664 G4cout<<"Could not retrieve MUC McTruth collection"<<G4endl;
665
666 Event::MucMcHitCol::iterator iMcHitCol;
667 for(iMcHitCol=aMcHitCol->begin(); iMcHitCol!=aMcHitCol->end(); iMcHitCol++)
668 {
669 const Identifier ident = (*iMcHitCol)->identify();
670 G4cout<<(*iMcHitCol)->getTrackIndex();
671 G4cout<<" "<<MucID::part(ident);
672 G4cout<<" "<<MucID::seg(ident);
673 G4cout<<" "<<MucID::gap(ident);
674 G4cout<<" "<<MucID::strip(ident);
675 G4cout<<" "<<(*iMcHitCol)->getPositionX();
676 G4cout<<" "<<(*iMcHitCol)->getPositionY();
677 G4cout<<" "<<(*iMcHitCol)->getPositionZ();
678 G4cout<<" "<<(*iMcHitCol)->getPx();
679 G4cout<<" "<<(*iMcHitCol)->getPy();
680 G4cout<<" "<<(*iMcHitCol)->getPz();
681 G4cout<<G4endl;
682 }
683 G4cout<<"end of retrieve MUC McTruth"<<G4endl;
684 */
685}
686
EvtStreamInputIterator< typename Generator::result_type > iter(Generator gen, int N=0)
G4THitsCollection< BesEmcTruthHit > BesEmcTruthHitsCollection
G4THitsCollection< BesEmcHit > BesEmcHitsCollection
G4THitsCollection< BesMdcHit > BesMdcHitsCollection
G4THitsCollection< BesMucHit > BesMucHitsCollection
G4THitsCollection< BesTofHit > BesTofHitsCollection
std::map< Identifier, G4double >::const_iterator End() const
Definition: BesEmcHit.cc:182
std::map< Identifier, G4double >::const_iterator Begin() const
Definition: BesEmcHit.cc:177
void AddMother(Event::McParticle *, Event::McParticleCol *)
void putData(int *data, unsigned int size)
static Identifier crystal_id(const unsigned int barrel_ec, const unsigned int theta_module, const unsigned int phi_module)
For a single crystal.
Definition: EmcID.cxx:71
void setHitMap(std::map< Identifier, double > &hitMap)
void setVertexIndex0(int index0)
methods for setting and getting vertex indexes
@ ERROR
this particle is a leaf in the particle tree
void initialize(StdHepId id, unsigned int statusBits, const HepLorentzVector &initialMomentum, const HepLorentzVector &initialPosition, const std::string process="")
Set the initial attributes of the McParticle.
Definition: McParticle.cxx:50
bool leafParticle() const
Retrieve whether this is a leaf particle.
Definition: McParticle.cxx:19
void addStatusFlag(unsigned int flag)
add a new flag to the status flags
void finalize(const HepLorentzVector &finalPosition)
Set the final attributes of the McParticle.
Definition: McParticle.cxx:85
void addDaughter(const SmartRef< McParticle > d)
add a daugther particle to this particle
static Identifier wire_id(int wireType, int layer, int wire)
For a single wire.
Definition: MdcID.cxx:77
static Identifier channel_id(int barrel_ec, int segment, int layer, int channel)
For a single crystal.
Definition: MucID.cxx:135
static Identifier cell_id(int barrel_ec, int layer, int phi_module, int end)
For a single crystal.
Definition: TofID.cxx:143
static bool is_scin(const Identifier &id)
Definition: TofID.cxx:102
static value_type getPHI_BARREL_MAX()
Definition: TofID.cxx:217
static bool is_barrel(const Identifier &id)
Test for barrel.
Definition: TofID.cxx:49
ObjectVector< MucMcHit > MucMcHitCol
ObjectList< McParticle > McParticleCol
ObjectVector< EmcMcHit > EmcMcHitCol
ObjectVector< TofMcHit > TofMcHitCol
ObjectVector< MdcMcHit > MdcMcHitCol