CGEM BOSS 6.6.5.g
BESIII Offline Software System
Loading...
Searching...
No Matches
BesMcTruthWriter Class Reference

#include <BesMcTruthWriter.hh>

Public Member Functions

 BesMcTruthWriter ()
 
 ~BesMcTruthWriter ()
 
void SaveMcTruth ()
 
void SaveMcParticle ()
 
void AddMother (Event::McParticle *, Event::McParticleCol *)
 
void SaveDecayMode ()
 
void SaveMdcTruth ()
 
void SaveCgemTruth ()
 
void SaveTofTruth ()
 
void SaveEmcTruth ()
 
void SaveMucTruth ()
 

Detailed Description

Definition at line 24 of file BesMcTruthWriter.hh.

Constructor & Destructor Documentation

◆ BesMcTruthWriter()

BesMcTruthWriter::BesMcTruthWriter ( )

Definition at line 58 of file BesMcTruthWriter.cc.

59{
60 m_DigiMan = G4DigiManager::GetDMpointer();
61 //mdcGeoPointer=BesMdcGeoParameter::GetGeo();
62
63 // set m_cgem_misAligned
64 m_cgem_misAligned=0;
65 ISvcLocator* svcLocator = Gaudi::svcLocator();
66 static IJobOptionsSvc* jobSvc = 0;
67 StatusCode sc = svcLocator->service("JobOptionsSvc", jobSvc);
68 if ( sc.isFailure() ) {
69 std::cout << "BesMcTruthWriter: Can't get the JobOptionsSvc " << std::endl;
70 //return sc;
71 }
72 else
73 {
74 const vector<const Property*>* properties = jobSvc->getProperties("BesSim");
75 if ( properties != NULL ) {
76 for ( unsigned int i = 0; i < properties->size(); ++i ) {
77 if ( properties->at(i)->name() == "CgemMisAligned" ) {
78 string strRnd = properties->at(i)->toString();
79 sscanf(strRnd.c_str(), "%i", &m_cgem_misAligned);
80 cout<<"BesMcTruthWriter: cgem_misAligned is set to "<<m_cgem_misAligned<<" by jobOptions"<<endl;
81 break;
82 }
83 }
84 }
85 }
86
87
88}

◆ ~BesMcTruthWriter()

BesMcTruthWriter::~BesMcTruthWriter ( )

Definition at line 90 of file BesMcTruthWriter.cc.

91{
92}

Member Function Documentation

◆ AddMother()

void BesMcTruthWriter::AddMother ( Event::McParticle currentParticle,
Event::McParticleCol particleCol 
)

Definition at line 324 of file BesMcTruthWriter.cc.

325{
326 if (currentParticle->leafParticle()) {
327 return;
328 }
329 Event::McParticleCol::iterator iter;
330 bool found = false;
331 for ( iter = particleCol->begin(); iter != particleCol->end(); iter++) {
332 if (currentParticle->vertexIndex1() == (*iter)->vertexIndex0()) {
333 found = true;
334 (*iter)->setMother(currentParticle);
335 currentParticle->addDaughter(*iter);
336 AddMother((*iter), particleCol);
337 }
338 }
339 if (!found) std::cout << "AddMother: inconsistency was found!" << std::endl;
340
341}
EvtStreamInputIterator< typename Generator::result_type > iter(Generator gen, int N=0)
void AddMother(Event::McParticle *, Event::McParticleCol *)
int vertexIndex1() const
Definition: McParticle.h:125
bool leafParticle() const
Retrieve whether this is a leaf particle.
Definition: McParticle.cxx:19
void addDaughter(const SmartRef< McParticle > d)
add a daugther particle to this particle
Definition: McParticle.h:147

Referenced by AddMother(), and SaveMcParticle().

◆ SaveCgemTruth()

void BesMcTruthWriter::SaveCgemTruth ( )
  • push back CgemMcHits to CgemMcHitCol in TDS *‍/

Definition at line 442 of file BesMcTruthWriter.cc.

443{
444 //G4cout << "|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||" << G4endl;
445 //G4cout << "INFO : BesSim::BesMcTruthWriter::SaveCgemTruth(), Begin! " << G4endl;
446 /* Cgem McHit collection defined in BOSS */
447 Event::CgemMcHitCol* aCgemMcHitCol = new Event::CgemMcHitCol;
448
449 G4int HCID = -1;
450 G4int BESID = -1;
451 HCID = m_DigiMan->GetHitsCollectionID("BesCgemTruthCollection");
452 BESID = m_DigiMan->GetHitsCollectionID("BesCgemHitsCollection");
453 if (HCID > 0)
454 {
455 BesCgemHitsCollection *HC = 0;
456 HC = (BesCgemHitsCollection*)(m_DigiMan->GetHitsCollection(HCID));
457 BesCgemHitsCollection *BES = 0;
458 /*Add BEShit for Identifier by sunxh*/
459 BES = (BesCgemHitsCollection*)(m_DigiMan->GetHitsCollection(BESID));
460 G4int n_hit = HC->entries();
461 G4int n_BEShit = BES->entries();
462 if (n_hit > 0)
463 {
464 /* arrange hits in hits collection in order of trackIndex */
465 BesCgemHit* hit;
466 BesCgemHit* BEShit;
467 vector<BesCgemHit*>* vecHC = HC->GetVector();
468 for(int i=0; i<n_hit-1; i++)
469 for(int j=i+1; j<n_hit; j++)
470 if((*vecHC)[i]->GetTrackID()>(*vecHC)[j]->GetTrackID())
471 {
472 hit = (*vecHC)[i];
473 (*vecHC)[i] = (*vecHC)[j];
474 (*vecHC)[j] = hit;
475 }
476
477 ///* push back CgemMcHits to CgemMcHitCol in TDS */
478 //for(G4int i=0;i<n_hit;i++)
479 //{
480 //hit = (*HC)[i];
481 //const Identifier ident = CgemID::chip_id ( hit->GetLayerID(), hit->GetSheetID(),
482 // hit->GetChipID(), hit->GetRow(),
483 // hit->GetCol() );
484
485 //ident.show();
486 //G4cout<<" "<<ident.get_valueMSB()<<" "<<ident.get_valueLSB()<<" "<<CgemID::layer(ident)<<" "<<CgemID::ladder(ident)
487 //<<" "<<CgemID::chip(ident) <<" "<<CgemID::row(ident)<<" "<<CgemID::column(ident)<<G4endl;
488
489 //Event::CgemMcHit* cgemMcHit = new Event::CgemMcHit(ident, hit->GetTrackID(),
490 // hit->GetPos().x(), hit->GetPos().y(), hit->GetPos().z(), hit->GetEdep() );
491 //aCgemMcHitCol->push_back(cgemMcHit);
492 /*for(G4int j=0;j<n_BEShit;j++)
493 {
494 BEShit = (*BES)[j];
495
496 G4cout << "McWriter track_ID1 = "<< BEShit->GetTrackID() << G4endl;
497 G4cout << "McWriter HitID1 = "<< BEShit->GetHitID() << G4endl;
498 TArrayI BES_Ident = BEShit->GetIdentifier();
499 for(int jj = 0; jj < BES_Ident.GetSize(); jj++){
500 G4cout << "McWriter ident1["<<jj<<"] = "<< BES_Ident.GetAt(jj) << G4endl;
501 }
502 }*/
503 /* push back CgemMcHits to CgemMcHitCol in TDS */
504 for(G4int i=0;i<n_hit;i++)
505 {
506 hit = (*HC)[i];
507
508 // cout<<"hitTrack_ID = "<<hit->GetTrackID()<<"\thitPDG = "<<hit->GetPDGCode()<<"\thitParent ID = "<<hit->GetParentID()<<endl;
509
510 /* Since no ID in Hit, create McHit without Identifier object */
511 Event::CgemMcHit *cgemMcHit = new Event::CgemMcHit(
512 hit->GetTrackID(), hit->GetLayerID() , hit->GetPDGCode(),
513 hit->GetParentID(), hit->GetTotalEnergyDeposit() ,
514 hit->GetPositionOfPrePoint().x() , hit->GetPositionOfPrePoint().y() ,
515 hit->GetPositionOfPrePoint().z() , hit->GetPositionOfPostPoint().x() ,
516 hit->GetPositionOfPostPoint().y() , hit->GetPositionOfPostPoint().z() ,
517 hit->GetMomentumOfPrePoint().x() , hit->GetMomentumOfPrePoint().y() ,
518 hit->GetMomentumOfPrePoint().z() , hit->GetMomentumOfPostPoint().x() ,
519 hit->GetMomentumOfPostPoint().y() , hit->GetMomentumOfPostPoint().z() );
520 /*
521 hit->GetPrePositionInCu().x() , hit->GetPrePositionInCu().y() ,
522 hit->GetPrePositionInCu().z() , hit->GetPostPositionInCu().x() ,
523 hit->GetPostPositionInCu().y() , hit->GetPostPositionInCu().z() ,
524 hit->GetMomentumOfCuPre().x() , hit->GetMomentumOfCuPre().y() ,
525 hit->GetMomentumOfCuPre().z() , hit->GetMomentumOfCuPost().x() ,
526 hit->GetMomentumOfCuPost().y() , hit->GetMomentumOfCuPost().z() );
527 */
528
529 if(m_cgem_misAligned==1)
530 {
537 }
538 cgemMcHit->SetIsSecondary(hit->GetIsSecondary());
539
540 // G4cout << "McWriter track_ID = "<< hit->GetTrackID() << G4endl;
541 int tmp[2000];
542 int size(0);
543 for(G4int j=0;j<n_BEShit;j++)
544 {
545 BEShit = (*BES)[j];
546 // cout<<"BEShitTrack_ID = "<<BEShit->GetTrackID()<<"\tBEShitPDG = "<<BEShit->GetPDGCode()<<"\tBEShitParent ID = "<<BEShit->GetParentID()<<endl;
547 if(BEShit->GetTrackID() != hit->GetTrackID())continue;
548 TArrayI hit_ID = hit->GetIdentifier();
549 for(int ii = 0; ii < hit_ID.GetSize(); ii++){
550 if(hit_ID.GetAt(ii) != BEShit->GetHitID())continue;
551 // G4cout << "McWriter EneDp = "<< BEShit->GetTotalEnergyDeposit() << G4endl;
552
553 TArrayI BES_Ident = BEShit->GetIdentifier();
554 for(int jj = 0; jj < BES_Ident.GetSize(); jj++){
555 tmp[size] = BES_Ident.GetAt(jj);
556 size++;
557 }
558 }
559 }
560 cgemMcHit->AddIdentifier(tmp,size);
561 cgemMcHit->SetCreatorProcess(hit->GetCreatorProcess());
562
563 aCgemMcHitCol->push_back(cgemMcHit);
564
565 /*End Add*/
566
567 } /* End of 'for(G4int i=0;i<n_hit;i++)' */
568 } /* End of 'if (n_hit > 0)' */
569 } /* End of 'if (HCID > 0)' */
570 //register CGEM McTruth collection to TDS
571 StatusCode scCgem = m_evtSvc->registerObject("/Event/MC/CgemMcHitCol", aCgemMcHitCol);
572 if(scCgem!=StatusCode::SUCCESS)
573 {
574 G4cout << "ERROR : BesSim::BesMcTruthWriter::SaveCgemTruth(), Could not register CGEM McTruth collection!" << G4endl;
575 }
576
577 /*
578 //retrieve CGEM McTruth from TDS
579 SmartDataPtr<Event::CgemMcHitCol> aMcHitCol(m_evtSvc,"/Event/MC/CgemMcHitCol");
580 if(!aMcHitCol)
581 G4cout<<"Could not retrieve CGEM McTruth collection"<<G4endl;
582
583 Event::CgemMcHitCol::iterator iMcHitCol;
584 for(iMcHitCol=aMcHitCol->begin(); iMcHitCol!=aMcHitCol->end(); iMcHitCol++)
585 {
586 cout<<"Track_ID = "<<(*iMcHitCol)->GetTrackID()<<"\tPDG = "<<(*iMcHitCol)->GetPDGCode()<<"\tParent ID = "<<(*iMcHitCol)->GetParentID()<<endl;
587 // const Identifier ident = (*iMcHitCol)->identify();
588 // G4cout<<(*iMcHitCol)->getTrackIndex();
589 // G4cout<<" "<<CgemID::layer(ident);
590 // G4cout<<" "<<CgemID::wire(ident);
591 // G4cout<<" "<<(*iMcHitCol)->getDepositEnergy();
592 // G4cout<<" "<<(*iMcHitCol)->getDriftDistance();
593 // G4cout<<" "<<(*iMcHitCol)->getPositionX();
594 // G4cout<<" "<<(*iMcHitCol)->getPositionY();
595 // G4cout<<" "<<(*iMcHitCol)->getPositionZ();
596 // G4cout<<G4endl;
597 }
598 G4cout<<"end of retrieve CGEM McTruth collection"<<G4endl;
599 */
600}
G4THitsCollection< BesCgemHit > BesCgemHitsCollection
Definition: BesCgemHit.hh:177
G4ThreeVector GetPositionOfPrePoint() const
Definition: BesCgemHit.hh:118
G4ThreeVector GetMomentumOfPostPoint() const
Definition: BesCgemHit.hh:123
TArrayI GetIdentifier() const
Definition: BesCgemHit.hh:129
G4int GetHitID() const
Definition: BesCgemHit.hh:108
G4ThreeVector GetPositionOfPostPointAlign() const
Definition: BesCgemHit.hh:121
G4ThreeVector GetPositionOfPrePointAlign() const
Definition: BesCgemHit.hh:120
G4int GetIsSecondary() const
Definition: BesCgemHit.hh:111
G4int GetPDGCode() const
Definition: BesCgemHit.hh:113
G4int GetTrackID() const
Definition: BesCgemHit.hh:110
G4ThreeVector GetPositionOfPostPoint() const
Definition: BesCgemHit.hh:119
G4double GetTotalEnergyDeposit() const
Definition: BesCgemHit.hh:116
G4ThreeVector GetMomentumOfPrePoint() const
Definition: BesCgemHit.hh:122
G4String GetCreatorProcess() const
Definition: BesCgemHit.hh:131
G4int GetLayerID() const
Definition: BesCgemHit.hh:112
G4int GetParentID() const
Definition: BesCgemHit.hh:114
void AddIdentifier(Int_t f_ID_Identifier[2000], Int_t N_dim)
Definition: CgemMcHit.h:73
void SetPositionXOfPrePoint(double f_XYZ_pre_x)
Definition: CgemMcHit.h:56
void SetPositionZOfPrePoint(double f_XYZ_pre_z)
Definition: CgemMcHit.h:58
void SetIsSecondary(int isSec)
Definition: CgemMcHit.h:51
void SetPositionXOfPostPoint(double f_XYZ_post_x)
Definition: CgemMcHit.h:59
void SetPositionYOfPrePoint(double f_XYZ_pre_y)
Definition: CgemMcHit.h:57
void SetCreatorProcess(string creatorProcess)
Definition: CgemMcHit.h:74
void SetPositionYOfPostPoint(double f_XYZ_post_y)
Definition: CgemMcHit.h:60
void SetPositionZOfPostPoint(double f_XYZ_post_z)
Definition: CgemMcHit.h:61
ObjectVector< CgemMcHit > CgemMcHitCol
Definition: CgemMcHit.h:186

Referenced by SaveMcTruth().

◆ SaveDecayMode()

void BesMcTruthWriter::SaveDecayMode ( )

Definition at line 343 of file BesMcTruthWriter.cc.

344{
345 SmartDataPtr<DecayMode> decayMode(m_evtSvc,"/Event/MC/DecayMode");
346 if(!decayMode)
347 {
348 //G4cout<<"Could not retrieve DecayMode"<<G4endl;
349 DecayMode* aDecayMode = new DecayMode;
350 //register Decay Mode to TDS
351 int dm[10]={0,0,0,0,0,0,0,0,0,0};
352 aDecayMode->putData(dm,10);
353 StatusCode scDM = m_evtSvc->registerObject("/Event/MC/DecayMode", aDecayMode);
354 if(scDM!=StatusCode::SUCCESS)
355 G4cout<< "Could not register DecayMode" <<G4endl;
356 }
357}
void putData(int *data, unsigned int size)

Referenced by SaveMcTruth().

◆ SaveEmcTruth()

void BesMcTruthWriter::SaveEmcTruth ( )

Definition at line 705 of file BesMcTruthWriter.cc.

706{
707 //Emc McHit collection defined in BOSS
708 Event::EmcMcHitCol* aEmcMcHitCol = new Event::EmcMcHitCol;
709
710 G4int fullMc = 1;
711 if(fullMc==1) { //full Mc Truth
712 G4int HCID = -1;
713 HCID = m_DigiMan->GetHitsCollectionID("BesEmcTruthHitsList");
714 if(HCID>0)
715 {
717 HC = (BesEmcTruthHitsCollection*) (m_DigiMan->GetHitsCollection(HCID));
718 G4int n_hit = HC->entries();
719 if(n_hit>0)
720 {
721 //arrange hits in hits collection in order of trackIndex
722 BesEmcTruthHit* hit;
723 vector<BesEmcTruthHit*>* vecHC = HC->GetVector();
724 for(int i=0;i<n_hit-1;i++) {
725 for(int j=i+1;j<n_hit;j++) {
726 if((*vecHC)[i]->GetTrackIndex()>(*vecHC)[j]->GetTrackIndex()) {
727 hit = (*vecHC)[i];
728 (*vecHC)[i] = (*vecHC)[j];
729 (*vecHC)[j] = hit;
730 }
731 }
732 }
733
734 for(G4int i=0;i<n_hit;i++)
735 {
736 BesEmcTruthHit* hit;
737 hit = (*HC)[i];
738
739 std::map<Identifier,double> hitMap;
740 std::map<Identifier,double>::const_iterator iHitMap;
741 hitMap.clear();
742 for(iHitMap=hit->Begin();iHitMap!=hit->End();iHitMap++) {
743 hitMap[iHitMap->first]=iHitMap->second;
744 }
745
746 Event::EmcMcHit* emcMcHit = new Event::EmcMcHit(hit->GetIdentify(), hit->GetTrackIndex(),
747 hit->GetPosition().x(), hit->GetPosition().y(), hit->GetPosition().z(),
748 hit->GetMomentum().x(), hit->GetMomentum().y(), hit->GetMomentum().z(),
749 hit->GetEDep() );
750
751 emcMcHit->setHitEmc(hit->GetHitEmc());
752 emcMcHit->setPDGCode(hit->GetPDGCode());
753 emcMcHit->setPDGCharge(hit->GetPDGCharge());
754 emcMcHit->setTime(hit->GetTime());
755 emcMcHit->setHitMap(hitMap);
756
757 aEmcMcHitCol->push_back(emcMcHit);
758 }
759 }
760 }
761 } else { //simple Mc Truth
762 G4int HCID = -1;
763 HCID = m_DigiMan->GetHitsCollectionID("BesEmcHitsList");
764 if(HCID>0)
765 {
766 BesEmcHitsCollection* HC = 0;
767 HC = (BesEmcHitsCollection*) (m_DigiMan->GetHitsCollection(HCID));
768 G4int n_hit = HC->entries();
769 if(n_hit>0)
770 {
771 //arrange hits in hits collection in order of trackIndex
772 BesEmcHit* hit;
773 vector<BesEmcHit*>* vecHC = HC->GetVector();
774 for(int i=0;i<n_hit-1;i++)
775 for(int j=i+1;j<n_hit;j++)
776 if((*vecHC)[i]->GetTrackIndex()>(*vecHC)[j]->GetTrackIndex())
777 {
778 hit = (*vecHC)[i];
779 (*vecHC)[i] = (*vecHC)[j];
780 (*vecHC)[j] = hit;
781 }
782
783 //Emc McHit collection defined in BOSS
784 Event::EmcMcHitCol* aEmcMcHitCol = new Event::EmcMcHitCol;
785
786 for(G4int i=0;i<n_hit;i++)
787 {
788 hit = (*HC)[i];
790
791 std::map<Identifier,double> hitMap;
792 Event::EmcMcHit* emcMcHit = new Event::EmcMcHit(ident, hit->GetTrackIndex(),
793 hit->GetPosCrystal().x(), hit->GetPosCrystal().y(), hit->GetPosCrystal().z(),
794 hit->GetMomentum().x(), hit->GetMomentum().y(), hit->GetMomentum().z(),
795 hit->GetEdepCrystal() );
796
797 aEmcMcHitCol->push_back(emcMcHit);
798 }
799 }
800 }
801 }
802
803 //register EMC McTruth collection to TDS
804 StatusCode scEmc = m_evtSvc->registerObject("/Event/MC/EmcMcHitCol", aEmcMcHitCol);
805 if(scEmc!=StatusCode::SUCCESS)
806 G4cout<< "Could not register EMC McTruth collection" <<G4endl;
807
808 //retrieve EMC McTruth from TDS
809 /*SmartDataPtr<Event::EmcMcHitCol> aMcHitCol(m_evtSvc,"/Event/MC/EmcMcHitCol");
810 if(!aMcHitCol)
811 G4cout<<"Could not retrieve EMC McTruth collection"<<G4endl;
812
813 Event::EmcMcHitCol::iterator iMcHitCol;
814 for(iMcHitCol=aMcHitCol->begin(); iMcHitCol!=aMcHitCol->end(); iMcHitCol++)
815 {
816 const Identifier ident = (*iMcHitCol)->identify();
817 G4cout<<(*iMcHitCol)->getTrackIndex();
818 G4cout<<" "<<EmcID::barrel_ec(ident);
819 G4cout<<" "<<EmcID::theta_module(ident);
820 G4cout<<" "<<EmcID::phi_module(ident);
821 G4cout<<" "<<(*iMcHitCol)->getPositionX();
822 G4cout<<" "<<(*iMcHitCol)->getPositionY();
823 G4cout<<" "<<(*iMcHitCol)->getPositionZ();
824 G4cout<<" "<<(*iMcHitCol)->getPx();
825 G4cout<<" "<<(*iMcHitCol)->getPy();
826 G4cout<<" "<<(*iMcHitCol)->getPz();
827 G4cout<<" "<<(*iMcHitCol)->getDepositEnergy();
828 G4cout<<G4endl;
829 }
830 G4cout<<"end of retrieve EMC McTruth"<<G4endl;
831 */
832}
G4THitsCollection< BesEmcTruthHit > BesEmcTruthHitsCollection
Definition: BesEmcHit.hh:181
G4THitsCollection< BesEmcHit > BesEmcHitsCollection
Definition: BesEmcHit.hh:83
G4int GetNumPhiCrystal()
Definition: BesEmcHit.hh:63
G4ThreeVector GetPosCrystal()
Definition: BesEmcHit.hh:59
G4double GetEdepCrystal()
Definition: BesEmcHit.hh:56
G4int GetTrackIndex()
Definition: BesEmcHit.hh:64
G4ThreeVector GetMomentum()
Definition: BesEmcHit.hh:66
G4int GetNumThetaCrystal()
Definition: BesEmcHit.hh:62
G4int GetPartId()
Definition: BesEmcHit.hh:61
G4int GetTrackIndex() const
Definition: BesEmcHit.hh:136
G4int GetHitEmc() const
Definition: BesEmcHit.hh:138
G4ThreeVector GetPosition() const
Definition: BesEmcHit.hh:145
G4double GetTime() const
Definition: BesEmcHit.hh:143
std::map< Identifier, G4double >::const_iterator End() const
Definition: BesEmcHit.cc:182
G4double GetPDGCharge() const
Definition: BesEmcHit.hh:140
G4double GetEDep() const
Definition: BesEmcHit.hh:142
std::map< Identifier, G4double >::const_iterator Begin() const
Definition: BesEmcHit.cc:177
G4int GetPDGCode() const
Definition: BesEmcHit.hh:139
G4ThreeVector GetMomentum() const
Definition: BesEmcHit.hh:144
Identifier GetIdentify() const
Definition: BesEmcHit.hh:135
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 setPDGCode(int code)
Definition: EmcMcHit.h:75
void setHitEmc(int is)
Definition: EmcMcHit.h:74
void setPDGCharge(double charge)
Definition: EmcMcHit.h:76
void setTime(double time)
Definition: EmcMcHit.h:77
void setHitMap(std::map< Identifier, double > &hitMap)
Definition: EmcMcHit.h:94
ObjectVector< EmcMcHit > EmcMcHitCol
Definition: EmcMcHit.h:132

Referenced by SaveMcTruth().

◆ SaveMcParticle()

void BesMcTruthWriter::SaveMcParticle ( )

Definition at line 120 of file BesMcTruthWriter.cc.

121{
123 vector<BesTruthTrack*>* trackList = sensitiveManager->GetTrackList();
124 G4int nTrack = trackList->size();
125 BesTruthTrack* track;
126
127 vector<BesTruthVertex*>* vertexList = sensitiveManager->GetVertexList();
128 G4int nVertex = vertexList->size();
129 BesTruthVertex* vertex;
130
131 //arrange TruthTrack in trackList in order of trackIndex
132 for(int i=0;i<nTrack-1;i++)
133 for(int j=i+1;j<nTrack;j++)
134 if((*trackList)[i]->GetIndex()>(*trackList)[j]->GetIndex())
135 {
136 track=(*trackList)[i];
137 (*trackList)[i]=(*trackList)[j];
138 (*trackList)[j]=track;
139 }
140
142
143 //loop over tracks
144 for(int i=0;i<nTrack;i++)
145 {
146 track = (*trackList) [i];
147
148 // find out the start point
149 bool isPrimary = false;
150 bool startPointFound = false;
151 BesTruthVertex* startPoint;
152
153 for (int i=0;i<nVertex;i++)
154 {
155 vertex = (*vertexList) [i];
156 if ( track->GetVertex()->GetIndex() == vertex->GetIndex() )
157 {
158 if (!vertex->GetParentTrack()) isPrimary = true;
159 startPointFound = true;
160 startPoint = vertex;
161 break;
162 }
163 }
164
165 if (!startPointFound)
166 std::cout << "error in finding the start point of a track" <<std::endl;
167
168
169 bool endPointFound = false;
170 // find out the end point
171 for (int i=0;i<nVertex;i++)
172 {
173 vertex = (*vertexList) [i];
174 if( track->GetTerminalVertex() )
175 {
176 if (track->GetTerminalVertex()->GetIndex() == vertex->GetIndex() )
177 {
178 //create the mc particle
179 Event::McParticle* mcParticle = new Event::McParticle;
180
181 // initialization
182 HepLorentzVector initialMomentum(track->GetP4().x()/1000., track->GetP4().y()/1000., track->GetP4().z()/1000., track->GetP4().t()/1000.);
183
184 HepLorentzVector initialPosition(startPoint->GetPosition().x()/10., startPoint->GetPosition().y()/10., startPoint->GetPosition().z()/10.,startPoint->GetTime());
185
186 mcParticle->initialize(track->GetPDGCode(), 0, initialMomentum, initialPosition);
187
188 // Set track index
189 mcParticle->setTrackIndex( track->GetIndex() );
190
191 // Adding status flag
192 if (isPrimary ) mcParticle->addStatusFlag(Event::McParticle::PRIMARY);
193
194 if (track->GetDaughterIndexes().size()==0)
196
197 //std::cout<<"pdg:"<<track->GetPDGCode()<<" "
198 // <<"source:"<<track->GetSource()<<" "
199 // <<std::endl;
200 if (track->GetSource()=="FromGenerator")
202 else if(track->GetSource()=="FromG4")
204 else
206
207 //std::cout<<"status:"<<mcParticle->statusFlags()<<" "
208 // <<"FGN:"<<mcParticle->decayFromGenerator()<<" "
209 // <<"FG4:"<<mcParticle->decayInFlight()<<std::endl;
210 // Adding vertex index
211 mcParticle->setVertexIndex0(startPoint->GetIndex());
212 mcParticle->setVertexIndex1(vertex->GetIndex());
213
214 // Set the final position
215 HepLorentzVector finalPosition(vertex->GetPosition().x()/10., vertex->GetPosition().y()/10., vertex->GetPosition().z()/10., vertex->GetTime());
216 mcParticle->finalize(finalPosition);
217
218 // push back
219 particleCol->push_back(mcParticle);
220
221 endPointFound = true;
222 }
223 }
224 }
225
226 if (!endPointFound)
227 {
228 //std::cout << "warning in finding the end point of a track" <<std::endl;
229 if (track->GetDaughterIndexes().size()==0)
230 {
231 // create the mc particle
232 Event::McParticle* mcParticle = new Event::McParticle;
233 // initialization
234 HepLorentzVector initialMomentum( track->GetP4().x()/1000., track->GetP4().y()/1000., track->GetP4().z()/1000., track->GetP4().t()/1000.);
235 HepLorentzVector initialPosition(startPoint->GetPosition().x()/10., startPoint->GetPosition().y()/10., startPoint->GetPosition().z()/10., startPoint->GetTime());
236
237 mcParticle->initialize(track->GetPDGCode(), 0, initialMomentum, initialPosition);
238
239 // Set track index
240 mcParticle->setTrackIndex( track->GetIndex() );
241
242 // Adding status flag
244 if (isPrimary ) mcParticle->addStatusFlag(Event::McParticle::PRIMARY);
245
246 // Adding vertex index
247 mcParticle->setVertexIndex0( startPoint->GetIndex() );
248 mcParticle->setVertexIndex1( -99 );
249
250 //std::cout<<"pdg:"<<track->GetPDGCode()<<" "
251 // <<"source:"<<track->GetSource()<<" "
252 // <<std::endl;
253 if (track->GetSource()=="FromGenerator")
255 else if(track->GetSource()=="FromG4")
257 else
259
260 //std::cout<<"status:"<<mcParticle->statusFlags()<<" "
261 // <<"FGN:"<<mcParticle->decayFromGenerator()<<" "
262 // <<"FG4:"<<mcParticle->decayInFlight()<<std::endl;
263
264 // push back
265 particleCol->push_back(mcParticle);
266 continue;
267 }
268 }
269 }
270
271 // Get primary McParticles
272 SmartRefVector<Event::McParticle> primaryParticleCol;
273 Event::McParticleCol::iterator iter_particle;
274 for ( iter_particle = particleCol->begin();
275 iter_particle != particleCol->end(); iter_particle++) {
276
277 if ((*iter_particle)->primaryParticle()) {
278 Event::McParticle* mcPart = (Event::McParticle*)(*iter_particle);
279 primaryParticleCol.push_back(mcPart);
280 }
281 }
282
283 if (primaryParticleCol.empty())
284 std::cout << "no primary particle found!" << std::endl;
285
286 // Add mother particle recursively
287 SmartRefVector<Event::McParticle>::iterator iter_primary;
288 for ( iter_primary = primaryParticleCol.begin();
289 iter_primary != primaryParticleCol.end(); iter_primary++) {
290 if ( !((*iter_primary)->leafParticle()) )
291 AddMother((*iter_primary), particleCol);
292 }
293
294 //register McParticle collection to TDS
295 StatusCode sc = m_evtSvc->registerObject("/Event/MC/McParticleCol", particleCol);
296 if(sc!=StatusCode::SUCCESS)
297 G4cout<< "Could not register McParticle collection" <<G4endl;
298
299 //retrive McParticle from TDS
300 /*SmartDataPtr<Event::McParticleCol> mcParticleCol(m_evtSvc,"/Event/MC/McParticleCol");
301 if(!mcParticleCol)
302 G4cout<<"Could not retrieve McParticelCol"<<G4endl;
303 Event::McParticleCol::iterator iter_mc = mcParticleCol->begin();
304 for (;iter_mc != mcParticleCol->end(); iter_mc++)
305 {
306 G4cout<<(*iter_mc)->getTrackIndex();
307 G4cout<<" "<<(*iter_mc)->particleProperty();
308 G4cout<<" "<<(*iter_mc)->getVertexIndex0();
309 G4cout<<" "<<(*iter_mc)->getVertexIndex1();
310 G4cout<<" "<<(*iter_mc)->initialFourMomentum().x();
311 G4cout<<" "<<(*iter_mc)->initialFourMomentum().y();
312 G4cout<<" "<<(*iter_mc)->initialFourMomentum().z();
313 G4cout<<" "<<(*iter_mc)->initialFourMomentum().t();
314 G4cout<<" "<<(*iter_mc)->initialPosition().x();
315 G4cout<<" "<<(*iter_mc)->initialPosition().y();
316 G4cout<<" "<<(*iter_mc)->initialPosition().z();
317 G4cout<<G4endl;
318 }
319 G4cout<<"end of retrieve McParticle from TDS"<<G4endl;
320 */
321
322}
std::vector< BesTruthVertex * > * GetVertexList()
std::vector< BesTruthTrack * > * GetTrackList()
static BesSensitiveManager * GetSensitiveManager()
G4int GetPDGCode() const
HepLorentzVector GetP4() const
BesTruthVertex * GetTerminalVertex() const
BesTruthVertex * GetVertex() const
G4String GetSource()
vector< int > GetDaughterIndexes() const
G4int GetIndex() const
BesTruthTrack * GetParentTrack() const
G4double GetTime() const
G4ThreeVector GetPosition() const
G4int GetIndex() const
void setVertexIndex0(int index0)
methods for setting and getting vertex indexes
Definition: McParticle.h:119
@ PRIMARY
Decayed in flight.
Definition: McParticle.h:37
@ ERROR
this particle is a leaf in the particle tree
Definition: McParticle.h:39
@ DECAYFLT
Decayed by generator.
Definition: McParticle.h:36
@ LEAF
primary particle
Definition: McParticle.h:38
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
void addStatusFlag(unsigned int flag)
add a new flag to the status flags
Definition: McParticle.h:103
void finalize(const HepLorentzVector &finalPosition)
Set the final attributes of the McParticle.
Definition: McParticle.cxx:85
void setVertexIndex1(int index1)
Definition: McParticle.h:123
void setTrackIndex(int trackIndex)
Definition: McParticle.h:128
ObjectList< McParticle > McParticleCol
Definition: McParticle.h:205

Referenced by SaveMcTruth().

◆ SaveMcTruth()

void BesMcTruthWriter::SaveMcTruth ( )

Definition at line 94 of file BesMcTruthWriter.cc.

95{
96 //interface to event data service
97 ISvcLocator* svcLocator = Gaudi::svcLocator();
98 StatusCode sc=svcLocator->service("EventDataSvc", m_evtSvc);
99 if (sc.isFailure())
100 G4cout<<"Could not accesss EventDataSvc!"<<G4endl;
101
102 DataObject *aMcEvent;
103 m_evtSvc->findObject("/Event/MC",aMcEvent);
104 if(aMcEvent==NULL) {
105 McEvent* aMcEvent = new McEvent;
106 sc = m_evtSvc->registerObject("/Event/MC",aMcEvent);
107 if(sc!=StatusCode::SUCCESS)
108 G4cout<< "Could not register McEvent" <<G4endl;
109 }
110
113 SaveMdcTruth();
115 SaveTofTruth();
116 SaveEmcTruth();
117 SaveMucTruth();
118}
Definition: McEvent.h:8

Referenced by BesTDSWriter::SaveAll().

◆ SaveMdcTruth()

void BesMcTruthWriter::SaveMdcTruth ( )

Definition at line 359 of file BesMcTruthWriter.cc.

360{
361 //Mdc McHit collection defined in BOSS
362 Event::MdcMcHitCol* aMdcMcHitCol = new Event::MdcMcHitCol;
363
364 G4int HCID = -1;
365 //HCID = m_DigiMan->GetHitsCollectionID("BesMdcTruthCollection");
366 HCID = m_DigiMan->GetHitsCollectionID("BesMdcHitsCollection");
367 //G4cout<< "SaveMdcTruth(): BesMdcHitsCollection ID="<<HCID <<G4endl;
368 if(HCID>=0)
369 {
370 BesMdcHitsCollection* HC = 0;
371 HC = (BesMdcHitsCollection*) (m_DigiMan->GetHitsCollection(HCID));
372 G4int n_hit = HC->entries();
373 //G4cout<< "SaveMdcTruth(): BesMdcHitsCollection n_hit="<<n_hit <<G4endl;
374 if(n_hit>0)
375 {
376 //arrange hits in hits collection in order of trackIndex
377 BesMdcHit* hit;
378 /*
379 vector<BesMdcHit*>* vecHC = HC->GetVector();
380 for(int i=0;i<n_hit-1;i++)
381 for(int j=i+1;j<n_hit;j++)
382 if((*vecHC)[i]->GetTrackID()>(*vecHC)[j]->GetTrackID())
383 {
384 hit = (*vecHC)[i];
385 (*vecHC)[i] = (*vecHC)[j];
386 (*vecHC)[j] = hit;
387 }
388 */
389
390 //push back MdcMcHits to MdcMcHitCol in TDS
391 for(G4int i=0;i<n_hit;i++)
392 {
393 hit = (*HC)[i];
394 const Identifier ident = MdcID::wire_id ( hit->GetLayerNo(), hit->GetCellNo() );
395 Event::MdcMcHit* mdcMcHit = new Event::MdcMcHit(ident, hit->GetTrackID(),
396 hit->GetPos().x(), hit->GetPos().y(), hit->GetPos().z(),
397 hit->GetDriftD(), hit->GetEdep(),hit->GetPosFlag() );
398 G4ThreeVector p3=hit->GetMomentum();
399 mdcMcHit->setMomentumX(p3.x());
400 mdcMcHit->setMomentumY(p3.y());
401 mdcMcHit->setMomentumZ(p3.z());
402 mdcMcHit->setIsSecondary(hit->GetIsSecondary());
403 mdcMcHit->setCurrentTrackPID(hit->GetPDGCode());
404 mdcMcHit->setFlightLength(hit->GetFlightLength());
405 mdcMcHit->setCreatorProcess(hit->GetCreatorProcess());
406 mdcMcHit->setDigiIdx(hit->GetDigiId());
407 //mdcMcHit->();
408 aMdcMcHitCol->push_back(mdcMcHit);
409 }
410
411 }
412 }
413
414 //register MDC McTruth collection to TDS
415 StatusCode scMdc = m_evtSvc->registerObject("/Event/MC/MdcMcHitCol", aMdcMcHitCol);
416 if(scMdc!=StatusCode::SUCCESS)
417 G4cout<< "Could not register MDC McTruth collection" <<G4endl;
418
419 //retrieve MDC McTruth from TDS
420 /*SmartDataPtr<Event::MdcMcHitCol> aMcHitCol(m_evtSvc,"/Event/MC/MdcMcHitCol");
421 if(!aMcHitCol)
422 G4cout<<"Could not retrieve MDC McTruth collection"<<G4endl;
423
424 Event::MdcMcHitCol::iterator iMcHitCol;
425 for(iMcHitCol=aMcHitCol->begin(); iMcHitCol!=aMcHitCol->end(); iMcHitCol++)
426 {
427 const Identifier ident = (*iMcHitCol)->identify();
428 G4cout<<(*iMcHitCol)->getTrackIndex();
429 G4cout<<" "<<MdcID::layer(ident);
430 G4cout<<" "<<MdcID::wire(ident);
431 G4cout<<" "<<(*iMcHitCol)->getDepositEnergy();
432 G4cout<<" "<<(*iMcHitCol)->getDriftDistance();
433 G4cout<<" "<<(*iMcHitCol)->getPositionX();
434 G4cout<<" "<<(*iMcHitCol)->getPositionY();
435 G4cout<<" "<<(*iMcHitCol)->getPositionZ();
436 G4cout<<G4endl;
437 }
438 G4cout<<"end of retrieve MDC McTruth collection"<<G4endl;
439 */
440}
G4THitsCollection< BesMdcHit > BesMdcHitsCollection
Definition: BesMdcHit.hh:97
G4double GetEdep()
Definition: BesMdcHit.hh:59
G4int GetTrackID()
Definition: BesMdcHit.hh:56
G4String GetCreatorProcess()
Definition: BesMdcHit.hh:71
G4int GetPosFlag()
Definition: BesMdcHit.hh:66
G4int GetPDGCode()
Definition: BesMdcHit.hh:69
G4int GetLayerNo()
Definition: BesMdcHit.hh:57
G4ThreeVector GetMomentum()
Definition: BesMdcHit.hh:67
G4int GetIsSecondary()
Definition: BesMdcHit.hh:70
G4double GetFlightLength()
Definition: BesMdcHit.hh:68
G4double GetDriftD()
Definition: BesMdcHit.hh:61
G4ThreeVector GetPos()
Definition: BesMdcHit.hh:60
G4int GetCellNo()
Definition: BesMdcHit.hh:58
G4int GetDigiId()
Definition: BesMdcHit.hh:72
void setMomentumZ(double momentumZ)
Definition: MdcMcHit.h:101
void setCreatorProcess(string creatorProcess)
Definition: MdcMcHit.h:106
void setMomentumY(double momentumY)
Definition: MdcMcHit.h:100
void setFlightLength(double flightLength)
Definition: MdcMcHit.h:105
void setMomentumX(double momentumX)
Definition: MdcMcHit.h:99
void setDigiIdx(int id)
Definition: MdcMcHit.h:107
void setIsSecondary(int isSec)
Definition: MdcMcHit.h:94
void setCurrentTrackPID(int currentTrackPID)
Definition: MdcMcHit.h:92
static Identifier wire_id(int wireType, int layer, int wire)
For a single wire.
Definition: MdcID.cxx:77
ObjectVector< MdcMcHit > MdcMcHitCol
Definition: MdcMcHit.h:151

Referenced by SaveMcTruth().

◆ SaveMucTruth()

void BesMcTruthWriter::SaveMucTruth ( )

Definition at line 834 of file BesMcTruthWriter.cc.

835{
836 //Muc McHit collection defined in BOSS
837 Event::MucMcHitCol* aMucMcHitCol = new Event::MucMcHitCol;
838
839 G4int HCID = -1;
840 HCID = m_DigiMan->GetHitsCollectionID("BesMucHitsList");
841 if(HCID>0)
842 {
843 BesMucHitsCollection* HC = 0;
844 HC = (BesMucHitsCollection*) (m_DigiMan->GetHitsCollection(HCID));
845 G4int n_hit = HC->entries();
846 if(n_hit>0)
847 {
848 //arrange hits in hits collection in order of trackIndex
849 BesMucHit* hit;
850 vector<BesMucHit*>* vecHC = HC->GetVector();
851 for(int i=0;i<n_hit-1;i++)
852 for(int j=i+1;j<n_hit;j++)
853 if((*vecHC)[i]->GetTrackIndex()>(*vecHC)[j]->GetTrackIndex())
854 {
855 hit = (*vecHC)[i];
856 (*vecHC)[i] = (*vecHC)[j];
857 (*vecHC)[j] = hit;
858 }
859
860 for(G4int i=0;i<n_hit;i++)
861 {
862 hit = (*HC)[i];
863 Identifier ident = MucID::channel_id ( hit->GetPart(), hit->GetSeg(), hit->GetGap(),
864 hit->GetStrip() );
865 Event::MucMcHit* mucMcHit = new Event::MucMcHit(ident, hit->GetTrackIndex(),
866 hit->GetPos().x(), hit->GetPos().y(), hit->GetPos().z(), hit->GetMomentum().x(),
867 hit->GetMomentum().y(), hit->GetMomentum().z() );
868 aMucMcHitCol->push_back(mucMcHit);
869 }
870
871 }
872 }
873
874 //register MUC McTruth collection to TDS
875 StatusCode scMuc = m_evtSvc->registerObject("/Event/MC/MucMcHitCol", aMucMcHitCol);
876 if(scMuc!=StatusCode::SUCCESS)
877 G4cout<< "Could not register MUC McTruth collection" <<G4endl;
878
879 //retrieve MUC McTruth from TDS
880 /*SmartDataPtr<Event::MucMcHitCol> aMcHitCol(m_evtSvc,"/Event/MC/MucMcHitCol");
881 if(!aMcHitCol)
882 G4cout<<"Could not retrieve MUC McTruth collection"<<G4endl;
883
884 Event::MucMcHitCol::iterator iMcHitCol;
885 for(iMcHitCol=aMcHitCol->begin(); iMcHitCol!=aMcHitCol->end(); iMcHitCol++)
886 {
887 const Identifier ident = (*iMcHitCol)->identify();
888 G4cout<<(*iMcHitCol)->getTrackIndex();
889 G4cout<<" "<<MucID::part(ident);
890 G4cout<<" "<<MucID::seg(ident);
891 G4cout<<" "<<MucID::gap(ident);
892 G4cout<<" "<<MucID::strip(ident);
893 G4cout<<" "<<(*iMcHitCol)->getPositionX();
894 G4cout<<" "<<(*iMcHitCol)->getPositionY();
895 G4cout<<" "<<(*iMcHitCol)->getPositionZ();
896 G4cout<<" "<<(*iMcHitCol)->getPx();
897 G4cout<<" "<<(*iMcHitCol)->getPy();
898 G4cout<<" "<<(*iMcHitCol)->getPz();
899 G4cout<<G4endl;
900 }
901 G4cout<<"end of retrieve MUC McTruth"<<G4endl;
902 */
903}
G4THitsCollection< BesMucHit > BesMucHitsCollection
Definition: BesMucHit.hh:104
G4int GetTrackIndex()
Definition: BesMucHit.hh:63
G4ThreeVector GetPos()
Definition: BesMucHit.hh:68
G4int GetSeg()
Definition: BesMucHit.hh:75
G4int GetStrip()
Definition: BesMucHit.hh:77
G4int GetPart()
Definition: BesMucHit.hh:74
G4ThreeVector GetMomentum()
Definition: BesMucHit.hh:71
G4int GetGap()
Definition: BesMucHit.hh:76
static Identifier channel_id(int barrel_ec, int segment, int layer, int channel)
For a single crystal.
Definition: MucID.cxx:135
ObjectVector< MucMcHit > MucMcHitCol
Definition: MucMcHit.h:89

Referenced by SaveMcTruth().

◆ SaveTofTruth()

void BesMcTruthWriter::SaveTofTruth ( )

Definition at line 602 of file BesMcTruthWriter.cc.

603{
604 //Tof McHit collection defined in BOSS
605 Event::TofMcHitCol* aTofMcHitCol = new Event::TofMcHitCol;
606
607 G4int HCID = -1;
608 HCID = m_DigiMan->GetHitsCollectionID("BesTofHitsList");
609 if(HCID>0)
610 {
611 BesTofHitsCollection* HC = 0;
612 HC = (BesTofHitsCollection*) (m_DigiMan->GetHitsCollection(HCID));
613 G4int n_hit = HC->entries();
614 if(n_hit>0)
615 {
616 //arrange hits in hits collection in order of trackIndex
617 BesTofHit* hit;
618 vector<BesTofHit*>* vecHC = HC->GetVector();
619 for(int i=0;i<n_hit-1;i++)
620 for(int j=i+1;j<n_hit;j++)
621 if((*vecHC)[i]->GetTrackIndex()>(*vecHC)[j]->GetTrackIndex())
622 {
623 hit = (*vecHC)[i];
624 (*vecHC)[i] = (*vecHC)[j];
625 (*vecHC)[j] = hit;
626 }
627
628 //push back TofMcHit collection to TDS
629 for(G4int i=0;i<n_hit;i++)
630 {
631 hit = (*HC)[i];
632 unsigned int scinNum, barrel_ec, layer = 0;
633 scinNum = hit->GetScinNb();
634 barrel_ec = hit->GetPartId();
635
636 //std::cout << "BesMcTruthWriter PartID | scinNum " << barrel_ec << " | " << scinNum << std::endl;
637 //std::cout << "BesMcTruthWriter is_barrel(barrel_ec) " << TofID::is_barrel(barrel_ec) << std::endl;
638
639
640 if (TofID::is_barrel(barrel_ec) && scinNum > TofID::getPHI_BARREL_MAX()) {
641 layer = 1;
642 scinNum = scinNum - TofID::getPHI_BARREL_MAX() - 1;
643 }
644
645
646
647 Identifier ident;
648
649 if(barrel_ec==0 || barrel_ec==1 || barrel_ec==2 ) //Old-Tof
650 {
651 ident = TofID::cell_id ( barrel_ec, layer, scinNum, 0);
652 }
653 else //MRPC Part
654 {
655 int help = BesTofDigitizerEcV4::Calculate_Readoutstrip_number_continuum(hit->GetPos().x()*mm,hit->GetPos().y()*mm, barrel_ec, scinNum);
657 //std::cout << "BesMcTruthWriter Readoutstrip " << help << std::endl;
658 //std::cout << "BesMcTruthWriter unique Identifier " << scinNum << std::endl;
659 ident = TofID::cell_id_mrpc_mc ( barrel_ec, scinNum);
660 }
661
662
663
664 Event::TofMcHit* tofMcHit = new Event::TofMcHit( ident, hit->GetTrackIndex(),
665 hit->GetPos().x(), hit->GetPos().y(), hit->GetPos().z(), hit->GetMomentum().x(),
666 hit->GetMomentum().y(), hit->GetMomentum().z(), hit->GetTrackL(), hit->GetTime() );
667
668 aTofMcHitCol->push_back(tofMcHit);
669 }
670 }
671 }
672
673 //register TOF McTruth collection to TDS
674 StatusCode scTof = m_evtSvc->registerObject("/Event/MC/TofMcHitCol", aTofMcHitCol);
675 if(scTof!=StatusCode::SUCCESS)
676 G4cout<< "Could not register TOF McTruth collection" <<G4endl;
677
678 //retrieve TOF McTruth from TDS
679 /*SmartDataPtr<Event::TofMcHitCol> aMcHitCol(m_evtSvc,"/Event/MC/TofMcHitCol");
680 if(!aMcHitCol)
681 G4cout<<"Could not retrieve TOF McTruth collection"<<G4endl;
682
683 Event::TofMcHitCol::iterator iMcHitCol;
684 for(iMcHitCol=aMcHitCol->begin(); iMcHitCol!=aMcHitCol->end(); iMcHitCol++)
685 {
686 const Identifier ident = (*iMcHitCol)->identify();
687 G4cout<<(*iMcHitCol)->getTrackIndex();
688 G4cout<<" "<<TofID::barrel_ec(ident);;
689 G4cout<<" "<<TofID::layer(ident);
690 G4cout<<" "<<TofID::phi_module(ident);
691 G4cout<<" "<<(*iMcHitCol)->getPositionX();
692 G4cout<<" "<<(*iMcHitCol)->getPositionY();
693 G4cout<<" "<<(*iMcHitCol)->getPositionZ();
694 G4cout<<" "<<(*iMcHitCol)->getPx();
695 G4cout<<" "<<(*iMcHitCol)->getPy();
696 G4cout<<" "<<(*iMcHitCol)->getPz();
697 G4cout<<" "<<(*iMcHitCol)->getTrackLength();
698 G4cout<<" "<<(*iMcHitCol)->getFlightTime();
699 G4cout<<G4endl;
700 }
701 G4cout<<"end of retrieve TOF McTruth"<<G4endl;
702 */
703}
G4THitsCollection< BesTofHit > BesTofHitsCollection
Definition: BesTofHit.hh:108
std::string help()
Definition: HelloServer.cpp:35
static G4int Produce_unique_identifier(G4int module_mrpc_f, G4int readoutstripnumber_f)
static G4int Calculate_Readoutstrip_number_continuum(G4double x_mm, G4double y_mm, G4int partId_f, G4int module_mrpc_f)
G4double GetTime()
Definition: BesTofHit.hh:66
G4ThreeVector GetPos()
Definition: BesTofHit.hh:65
G4int GetScinNb()
Definition: BesTofHit.hh:61
G4int GetPartId()
Definition: BesTofHit.hh:60
G4double GetTrackL()
Definition: BesTofHit.hh:64
G4ThreeVector GetMomentum()
Definition: BesTofHit.hh:69
G4int GetTrackIndex()
Definition: BesTofHit.hh:58
static Identifier cell_id(int barrel_ec, int layer, int phi_module, int end)
For a single crystal.
Definition: TofID.cxx:156
static value_type getPHI_BARREL_MAX()
Definition: TofID.cxx:237
static bool is_barrel(const Identifier &id)
Test for barrel.
Definition: TofID.cxx:78
static Identifier cell_id_mrpc_mc(int partID, int scinNum)
Definition: TofID.cxx:189
ObjectVector< TofMcHit > TofMcHitCol
Definition: TofMcHit.h:100

Referenced by SaveMcTruth().


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