BOSS 7.1.1
BESIII Offline Software System
Loading...
Searching...
No Matches
BesAsciiIO Class Reference

#include <BesAsciiIO.hh>

Public Member Functions

 BesAsciiIO (G4int, G4int, G4int, G4int, G4int, G4int, G4int, G4int, G4String)
 
 ~BesAsciiIO ()
 
void SetMdcTruFlag (G4int flag)
 
void SetTofTruFlag (G4int flag)
 
void SetEmcTruFlag (G4int flag)
 
void SetMucTruFlag (G4int flag)
 
void SetMdcDigiFlag (G4int flag)
 
void SetTofDigiFlag (G4int flag)
 
void SetEmcDigiFlag (G4int flag)
 
void SetMucDigiFlag (G4int flag)
 
void SetAsciiFile (G4String name)
 
void SaveAsciiEvents (G4int, const G4Event *)
 
void SaveDecayMode (EVENT &)
 
void SaveTrackTruth (EVENT &)
 
void SaveVertexTruth (EVENT &)
 
void SaveMdcTruth (EVENT &)
 
void SaveTofTruth (EVENT &)
 
void SaveEmcTruth (EVENT &)
 
void SaveMucTruth (EVENT &)
 
void SaveMdcDigits (EVENT &)
 
void SaveTofDigits (EVENT &)
 
void SaveEmcDigits (EVENT &)
 
void SaveMucDigits (EVENT &)
 
void SaveHitAsciiEvents (G4int, const G4Event *)
 
void SaveDecayMode (HitEVENT &)
 
void SaveTrackTruth (HitEVENT &)
 
void SaveVertexTruth (HitEVENT &)
 
void SaveMdcTruth (HitEVENT &)
 
void SaveTofTruth (HitEVENT &)
 
void SaveEmcTruth (HitEVENT &)
 
void SaveMucTruth (HitEVENT &)
 
void SaveMdcHits (HitEVENT &)
 
void SaveTofHits (HitEVENT &)
 
void SaveEmcHits (HitEVENT &)
 
void SaveMucHits (HitEVENT &)
 

Detailed Description

Definition at line 22 of file BesAsciiIO.hh.

Constructor & Destructor Documentation

◆ BesAsciiIO()

BesAsciiIO::BesAsciiIO ( G4int mdcTruFlag,
G4int mdcDigiFlag,
G4int tofTruFlag,
G4int tofDigiFlag,
G4int emcTruFlag,
G4int emcDigiFlag,
G4int mucTruFlag,
G4int mucDigiFlag,
G4String name )

Definition at line 42 of file BesAsciiIO.cc.

48:m_mdcTruFlag(mdcTruFlag),m_mdcDigiFlag(mdcDigiFlag),
49 m_tofTruFlag(tofTruFlag),m_tofDigiFlag(tofDigiFlag),
50 m_emcTruFlag(emcTruFlag),m_emcDigiFlag(emcDigiFlag),
51 m_mucTruFlag(mucTruFlag),m_mucDigiFlag(mucDigiFlag),
52 m_asciiFile(name)
53{
54 m_DigiMan = G4DigiManager::GetDMpointer();
55}

◆ ~BesAsciiIO()

BesAsciiIO::~BesAsciiIO ( )

Definition at line 57 of file BesAsciiIO.cc.

58{
59}

Member Function Documentation

◆ SaveAsciiEvents()

void BesAsciiIO::SaveAsciiEvents ( G4int runId,
const G4Event * evt )

Definition at line 61 of file BesAsciiIO.cc.

62{
63 EVENT asciiEvt;
64
65 asciiEvt.set_initialized();
66 asciiEvt.header.set_initialized();
67 asciiEvt.header.eventNo=evt->GetEventID();
68 asciiEvt.header.runNo= runId;
69 asciiEvt.decayMode.set_initialized();
70 SaveDecayMode(asciiEvt);
71
72 asciiEvt.trackTruth.set_initialized();
74 SaveTrackTruth(asciiEvt);
75 SaveVertexTruth(asciiEvt);
76
77 if(m_mdcTruFlag)
78 {
79 asciiEvt.mdcTruth.set_initialized();
80 SaveMdcTruth(asciiEvt);
81 }
82
83 if(m_mdcDigiFlag)
84 {
85 asciiEvt.mdcDigi.set_initialized();
86 SaveMdcDigits(asciiEvt);
87 }
88
89 if(m_tofTruFlag)
90 {
91 asciiEvt.tofTruth.set_initialized();
92 SaveTofTruth(asciiEvt);
93 }
94
95 if(m_tofDigiFlag)
96 {
97 asciiEvt.tofDigi.set_initialized();
98 SaveTofDigits(asciiEvt);
99 }
100
101 if(m_emcTruFlag)
102 {
103 asciiEvt.emcTruth.set_initialized();
104 SaveEmcTruth(asciiEvt);
105 }
106
107 if(m_emcDigiFlag)
108 {
109 asciiEvt.emcDigi.set_initialized();
110 SaveEmcDigits(asciiEvt);
111 }
112
113 if(m_mucTruFlag)
114 {
115 asciiEvt.mucTruth.set_initialized();
116 SaveMucTruth(asciiEvt);
117 }
118
119 if(m_mucDigiFlag)
120 {
121 asciiEvt.mucDigi.set_initialized();
122 SaveMucDigits(asciiEvt);
123 }
124
125 ofstream os;
126 if(evt->GetEventID()==0)
127 {
128 os.open(m_asciiFile);
129 FRMTVERSION version;
130 version.set_initialized();
131 version.major = 1;
132 version.minor = 0;
133 os << version;
134 }
135 else
136 os.open(m_asciiFile,ios::out|ios::app);
137
138 try {
139 os << asciiEvt;
140 }
141 catch (AsciiWrongTag& ex) {
142 std::cerr << "wrong tag, got " << ex.got()
143 << " expected: " << ex.expected()
144 << std::endl;
145 } catch (AsciiDumpException& ) {
146 std::cerr << "AsciiDumpException was caught!" << std::endl;
147 }
148 os.close();
149}
std::string got() const
Definition dmplib.hh:22
std::string expected() const
Definition dmplib.hh:21
void SaveMucDigits(EVENT &)
void SaveTrackTruth(EVENT &)
void SaveDecayMode(EVENT &)
void SaveMdcDigits(EVENT &)
void SaveMucTruth(EVENT &)
void SaveEmcDigits(EVENT &)
void SaveEmcTruth(EVENT &)
void SaveTofTruth(EVENT &)
void SaveMdcTruth(EVENT &)
void SaveTofDigits(EVENT &)
void SaveVertexTruth(EVENT &)
TRACKTRUTH trackTruth
Definition AsciiData.hh:395
TOFDIGI tofDigi
Definition AsciiData.hh:400
MDCTRUTH mdcTruth
Definition AsciiData.hh:397
MDCDIGI mdcDigi
Definition AsciiData.hh:398
VERTEXTRUTH vertexTruth
Definition AsciiData.hh:396
MUCDIGI mucDigi
Definition AsciiData.hh:404
EMCTRUTH emcTruth
Definition AsciiData.hh:401
MUCTRUTH mucTruth
Definition AsciiData.hh:403
EVHEAD header
Definition AsciiData.hh:393
DECAYMODE decayMode
Definition AsciiData.hh:394
EMCDIGI emcDigi
Definition AsciiData.hh:402
TOFTRUTH tofTruth
Definition AsciiData.hh:399
int runNo
Definition AsciiData.hh:26
int eventNo
Definition AsciiData.hh:27
void set_initialized()
Definition dmplib.hh:69

Referenced by BesEventAction::EndOfEventAction().

◆ SaveDecayMode() [1/2]

void BesAsciiIO::SaveDecayMode ( EVENT & asciiEvt)

Definition at line 151 of file BesAsciiIO.cc.

152{
153 asciiEvt.decayMode.size=10;
154 //interface to event data service
155 ISvcLocator* svcLocator = Gaudi::svcLocator();
156 IDataProviderSvc* evtSvc;
157 StatusCode sc=svcLocator->service("EventDataSvc", evtSvc);
158 if (sc.isFailure())
159 G4cout<<"Could not accesss EventDataSvc!"<<G4endl;
160
161 SmartDataPtr<DecayMode> decayMode(evtSvc,"/Event/MC/DecayMode");
162 if(!decayMode)
163 {
164 for(int i=0;i<10;i++)
165 asciiEvt.decayMode.data[i]=0;
166 }
167 else
168 {
169 int dm[10]={0,0,0,0,0,0,0,0,0,0};
170 decayMode->getData(dm,10);
171 for(int i=0;i<10;i++)
172 asciiEvt.decayMode.data[i]=dm[i];
173 }
174}
int data[10]
Definition AsciiData.hh:37

Referenced by SaveAsciiEvents(), and SaveHitAsciiEvents().

◆ SaveDecayMode() [2/2]

void BesAsciiIO::SaveDecayMode ( HitEVENT & asciiEvt)

Definition at line 665 of file BesAsciiIO.cc.

666{
667 asciiEvt.decayMode.size=10;
668 //interface to event data service
669 ISvcLocator* svcLocator = Gaudi::svcLocator();
670 IDataProviderSvc* evtSvc;
671 StatusCode sc=svcLocator->service("EventDataSvc", evtSvc);
672 if (sc.isFailure())
673 G4cout<<"Could not accesss EventDataSvc!"<<G4endl;
674
675 SmartDataPtr<DecayMode> decayMode(evtSvc,"/Event/MC/DecayMode");
676 if(!decayMode)
677 {
678 for(int i=0;i<10;i++)
679 asciiEvt.decayMode.data[i]=0;
680 }
681 else
682 {
683 int dm[10]={0,0,0,0,0,0,0,0,0,0};
684 decayMode->getData(dm,10);
685 for(int i=0;i<10;i++)
686 asciiEvt.decayMode.data[i]=dm[i];
687 }
688}
DECAYMODE decayMode
Definition AsciiData.hh:414

◆ SaveEmcDigits()

void BesAsciiIO::SaveEmcDigits ( EVENT & asciiEvt)

Definition at line 511 of file BesAsciiIO.cc.

512{
513 G4int emcDigiCollID = -1;
514 emcDigiCollID = m_DigiMan->GetDigiCollectionID("BesEmcDigitsCollection");
515 if(emcDigiCollID>=0)
516 {
517 BesEmcDigitsCollection* emcDC = (BesEmcDigitsCollection*)m_DigiMan->GetDigiCollection(emcDigiCollID);
518 G4int nDigi = emcDC->entries();
519 if(nDigi>0)
520 {
521 //arrange digis in digitsCollection in order of trackIndex
522 BesEmcDigi* digi;
523 vector<BesEmcDigi*>* vecDC = emcDC->GetVector();
524 for(int i=0;i<nDigi-1;i++)
525 for(int j=i+1;j<nDigi;j++)
526 if((*vecDC)[i]->GetTrackIndex()>(*vecDC)[j]->GetTrackIndex())
527 {
528 digi = (*vecDC)[i];
529 (*vecDC)[i] = (*vecDC)[j];
530 (*vecDC)[j] = digi;
531 }
532 for(int i=0;i<nDigi;i++)
533 {
534 EmcDigiType emcData;
535 digi = (*emcDC)[i];
536 emcData.trackIndex = digi->GetTrackIndex();
537 emcData.partId = digi->GetPartId();
538 emcData.numTheta = digi->GetThetaNb();
539 emcData.numPhi = digi->GetPhiNb();
540 emcData.energyDeposit = digi->GetEnergy();
541 emcData.hitTime = (G4double)digi->GetTime();
542 asciiEvt.emcDigi.digiCol.push_back(emcData);
543 }
544 }
545 }
546 asciiEvt.emcDigi.nDigi=asciiEvt.emcDigi.digiCol.size();
547}
G4TDigiCollection< BesEmcDigi > BesEmcDigitsCollection
Definition BesEmcDigi.hh:69
G4int GetTrackIndex()
Definition BesEmcDigi.hh:54
G4int GetThetaNb()
Definition BesEmcDigi.hh:50
G4double GetEnergy()
Definition BesEmcDigi.hh:52
G4int GetPhiNb()
Definition BesEmcDigi.hh:51
G4double GetTime()
Definition BesEmcDigi.hh:53
G4int GetPartId()
Definition BesEmcDigi.hh:49
std::vector< EmcDigiType > digiCol
Definition AsciiData.hh:323
int nDigi
Definition AsciiData.hh:322
float hitTime
Definition AsciiData.hh:313
float energyDeposit
Definition AsciiData.hh:312

Referenced by SaveAsciiEvents().

◆ SaveEmcHits()

void BesAsciiIO::SaveEmcHits ( HitEVENT & )
inline

Definition at line 70 of file BesAsciiIO.hh.

70{};

◆ SaveEmcTruth() [1/2]

void BesAsciiIO::SaveEmcTruth ( EVENT & asciiEvt)

Definition at line 350 of file BesAsciiIO.cc.

351{
352 G4int HCID = -1;
353 HCID = m_DigiMan->GetHitsCollectionID("BesEmcHitsList");
354 if(HCID>0)
355 {
356 BesEmcHitsCollection* HC = 0;
357 HC = (BesEmcHitsCollection*) (m_DigiMan->GetHitsCollection(HCID));
358 G4int n_hit = HC->entries();
359 if(n_hit>0)
360 {
361 //arrange hits in hits collection in order of trackIndex
362 BesEmcHit* hit;
363 vector<BesEmcHit*>* vecHC = HC->GetVector();
364 for(int i=0;i<n_hit-1;i++)
365 for(int j=i+1;j<n_hit;j++)
366 if((*vecHC)[i]->GetTrackIndex()>(*vecHC)[j]->GetTrackIndex())
367 {
368 hit = (*vecHC)[i];
369 (*vecHC)[i] = (*vecHC)[j];
370 (*vecHC)[j] = hit;
371 }
372
373 for(G4int i=0;i<n_hit;i++)
374 {
375 hit = (*HC)[i];
376 EmcTruthType emcTruth;
377 emcTruth.trackIndex = hit->GetTrackIndex();
378 emcTruth.partId = hit->GetPartId();
379 emcTruth.numTheta = hit->GetNumThetaCrystal();
380 emcTruth.numPhi = hit->GetNumPhiCrystal();
381 emcTruth.posX = hit->GetPosCrystal().x();
382 emcTruth.posY = hit->GetPosCrystal().y();
383 emcTruth.posZ = hit->GetPosCrystal().z();
384 emcTruth.px = hit->GetMomentum().x();
385 emcTruth.py = hit->GetMomentum().y();
386 emcTruth.pz = hit->GetMomentum().z();
387 emcTruth.totalEdep = hit->GetEdepCrystal();
388
389 asciiEvt.emcTruth.truthCol.push_back(emcTruth);
390 }
391 }
392 }
393 asciiEvt.emcTruth.nTruth=asciiEvt.emcTruth.truthCol.size();
394}
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
std::vector< EmcTruthType > truthCol
Definition AsciiData.hh:172
float totalEdep
Definition AsciiData.hh:162

Referenced by SaveAsciiEvents().

◆ SaveEmcTruth() [2/2]

void BesAsciiIO::SaveEmcTruth ( HitEVENT & )
inline

Definition at line 65 of file BesAsciiIO.hh.

65{};

◆ SaveHitAsciiEvents()

void BesAsciiIO::SaveHitAsciiEvents ( G4int runId,
const G4Event * evt )

Definition at line 577 of file BesAsciiIO.cc.

577 {
578 HitEVENT asciiEvt;
579
580 asciiEvt.set_initialized();
581 asciiEvt.header.set_initialized();
582 asciiEvt.header.eventNo=evt->GetEventID();
583 asciiEvt.header.runNo= runId;
584 asciiEvt.decayMode.set_initialized();
585 SaveDecayMode(asciiEvt);
586
587 asciiEvt.trackTruth.set_initialized();
588 asciiEvt.vertexTruth.set_initialized();
589 SaveTrackTruth(asciiEvt);
590 SaveVertexTruth(asciiEvt);
591
592 if(m_mdcTruFlag)
593 {
594 asciiEvt.mdcTruth.set_initialized();
595 SaveMdcTruth(asciiEvt);
596 }
597
598 if(m_mdcDigiFlag)
599 {
600 asciiEvt.mdcHit.set_initialized();
601 SaveMdcHits(asciiEvt);
602 }
603 /*
604 if(m_tofTruFlag)
605 {
606 asciiEvt.tofTruth.set_initialized();
607 SaveTofTruth(asciiEvt);
608 }
609
610 if(m_tofDigiFlag)
611 {
612 asciiEvt.tofHit.set_initialized();
613 SaveTofHits(asciiEvt);
614 }
615
616 if(m_emcTruFlag)
617 {
618 asciiEvt.emcTruth.set_initialized();
619 SaveEmcTruth(asciiEvt);
620 }
621
622 if(m_emcDigiFlag)
623 {
624 asciiEvt.emcHit.set_initialized();
625 SaveEmcHits(asciiEvt);
626 }
627
628 if(m_mucTruFlag)
629 {
630 asciiEvt.mucTruth.set_initialized();
631 SaveMucTruth(asciiEvt);
632 }
633
634 if(m_mucDigiFlag)
635 {
636 asciiEvt.mucHit.set_initialized();
637 SaveMucHits(asciiEvt);
638 }
639 */
640 ofstream os;
641 if(evt->GetEventID()==0){
642 os.open(m_asciiFile);
643 FRMTVERSION version;
644 version.set_initialized();
645 version.major = 1;
646 version.minor = 0;
647 os << version;
648 }
649 else
650 os.open(m_asciiFile,ios::out|ios::app);
651
652 try {
653 os << asciiEvt;
654 }catch (AsciiWrongTag& ex) {
655 std::cerr << "wrong tag, got " << ex.got()
656 << " expected: " << ex.expected()
657 << std::endl;
658 } catch (AsciiDumpException& ) {
659 std::cerr << "AsciiDumpException was caught!" << std::endl;
660 }
661
662 os.close();
663}
void SaveMdcHits(HitEVENT &)
MDCTRUTH mdcTruth
Definition AsciiData.hh:417
MDCHIT mdcHit
Definition AsciiData.hh:418
EVHEAD header
Definition AsciiData.hh:413
VERTEXTRUTH vertexTruth
Definition AsciiData.hh:416
TRACKTRUTH trackTruth
Definition AsciiData.hh:415

Referenced by BesEventAction::EndOfEventAction().

◆ SaveMdcDigits()

void BesAsciiIO::SaveMdcDigits ( EVENT & asciiEvt)

Definition at line 441 of file BesAsciiIO.cc.

442{
443 G4int mdcDigiCollID = -1;
444 mdcDigiCollID = m_DigiMan->GetDigiCollectionID("BesMdcDigisCollection");
445 if(mdcDigiCollID>=0){
446 BesMdcDigisCollection* mdcDC = (BesMdcDigisCollection*)m_DigiMan->GetDigiCollection(mdcDigiCollID);
447 G4int nDigi = mdcDC->entries();
448 if(nDigi>0)
449 {
450 BesMdcDigi* mdcDigi;
451 for(int i=0;i<nDigi;i++)
452 {
453 MdcDigiType mdcData;
454 mdcDigi=(*mdcDC)[i];
455 mdcData.trackIndex = mdcDigi->GetTrackID();
456 mdcData.layerNo = mdcDigi->GetLayerNo();
457 mdcData.cellNo = mdcDigi->GetCellNo();
458 mdcData.energyDeposit = mdcDigi->GetEdep();
459 mdcData.driftTime = mdcDigi->GetDriftT();
460 asciiEvt.mdcDigi.digiCol.push_back(mdcData);
461 }
462 }
463 }
464 asciiEvt.mdcDigi.nDigi=asciiEvt.mdcDigi.digiCol.size();
465}
G4TDigiCollection< BesMdcDigi > BesMdcDigisCollection
Definition BesMdcDigi.hh:59
G4int GetLayerNo()
Definition BesMdcDigi.hh:44
G4double GetEdep()
Definition BesMdcDigi.hh:46
G4int GetCellNo()
Definition BesMdcDigi.hh:45
G4int GetTrackID()
Definition BesMdcDigi.hh:43
G4double GetDriftT()
Definition BesMdcDigi.hh:47
int nDigi
Definition AsciiData.hh:223
std::vector< MdcDigiType > digiCol
Definition AsciiData.hh:224
float driftTime
Definition AsciiData.hh:214
float energyDeposit
Definition AsciiData.hh:213

Referenced by SaveAsciiEvents().

◆ SaveMdcHits()

void BesAsciiIO::SaveMdcHits ( HitEVENT & asciiEvt)

Definition at line 816 of file BesAsciiIO.cc.

817{
818 G4int mdcHitCollID = -1;
819 mdcHitCollID = m_DigiMan->GetHitsCollectionID("BesMdcHitsCollection");
820 if(mdcHitCollID>=0)
821 {
822 BesMdcHitsCollection* mdcDC = (BesMdcHitsCollection*)m_DigiMan->GetHitsCollection(mdcHitCollID);
823 G4int nHit = mdcDC->entries();
824 if(nHit>0)
825 {
826 BesMdcHit* mdcHit;
827 for(int i=0;i<nHit;i++)
828 {
829 MdcHitType mdcData;
830 mdcHit=(*mdcDC)[i];
831 mdcData.trackIndex = mdcHit->GetTrackID();
832 mdcData.layerNo = mdcHit->GetLayerNo();
833 mdcData.cellNo = mdcHit->GetCellNo();
834 mdcData.posX = mdcHit->GetPos().x();
835 mdcData.posY = mdcHit->GetPos().y();
836 mdcData.posZ = mdcHit->GetPos().z();
837 mdcData.energyDeposit = mdcHit->GetEdep();
838 mdcData.driftDistance = mdcHit->GetDriftD();
839 mdcData.globalT = mdcHit->GetGlobalT();
840 mdcData.theta = mdcHit->GetTheta();
841 mdcData.enterAngle = mdcHit->GetEnterAngle();
842 mdcData.posFlag = mdcHit->GetPosFlag();
843
844 asciiEvt.mdcHit.hitCol.push_back(mdcData);
845 }
846 }
847 }
848 asciiEvt.mdcHit.nHit=asciiEvt.mdcHit.hitCol.size();
849}
G4THitsCollection< BesMdcHit > BesMdcHitsCollection
Definition BesMdcHit.hh:78
G4double GetEdep()
Definition BesMdcHit.hh:53
G4double GetTheta()
Definition BesMdcHit.hh:58
G4int GetTrackID()
Definition BesMdcHit.hh:50
G4int GetPosFlag()
Definition BesMdcHit.hh:60
G4double GetGlobalT()
Definition BesMdcHit.hh:57
G4double GetEnterAngle()
Definition BesMdcHit.hh:59
G4int GetLayerNo()
Definition BesMdcHit.hh:51
G4double GetDriftD()
Definition BesMdcHit.hh:55
G4ThreeVector GetPos()
Definition BesMdcHit.hh:54
G4int GetCellNo()
Definition BesMdcHit.hh:52
int nHit
Definition AsciiData.hh:253
std::vector< MdcHitType > hitCol
Definition AsciiData.hh:254
float posFlag
Definition AsciiData.hh:244
float driftDistance
Definition AsciiData.hh:240
float enterAngle
Definition AsciiData.hh:243
float energyDeposit
Definition AsciiData.hh:239
float globalT
Definition AsciiData.hh:241
float theta
Definition AsciiData.hh:242

Referenced by SaveHitAsciiEvents().

◆ SaveMdcTruth() [1/2]

void BesAsciiIO::SaveMdcTruth ( EVENT & asciiEvt)

Definition at line 260 of file BesAsciiIO.cc.

261{
262 G4int HCID = -1;
263 HCID = m_DigiMan->GetHitsCollectionID("BesMdcTruthCollection");
264 if(HCID>0)
265 {
266 BesMdcHitsCollection* HC = 0;
267 HC = (BesMdcHitsCollection*) (m_DigiMan->GetHitsCollection(HCID));
268 G4int n_hit = HC->entries();
269 if(n_hit>0)
270 {
271 //arrange hits in hits collection in order of trackIndex
272 BesMdcHit* hit;
273 vector<BesMdcHit*>* vecHC = HC->GetVector();
274 for(int i=0;i<n_hit-1;i++)
275 for(int j=i+1;j<n_hit;j++)
276 if((*vecHC)[i]->GetTrackID()>(*vecHC)[j]->GetTrackID())
277 {
278 hit = (*vecHC)[i];
279 (*vecHC)[i] = (*vecHC)[j];
280 (*vecHC)[j] = hit;
281 }
282
283 for(G4int i=0;i<n_hit;i++)
284 {
285 hit = (*HC)[i];
286 MdcTruthType mdcTruth;
287 mdcTruth.trackIndex = hit->GetTrackID();
288 mdcTruth.layerNo = hit->GetLayerNo();
289 mdcTruth.cellNo = hit->GetCellNo();
290 mdcTruth.edep = hit->GetEdep();
291 mdcTruth.driftD = hit->GetDriftD();
292 mdcTruth.posX = hit->GetPos().x();
293 mdcTruth.posY = hit->GetPos().y();
294 mdcTruth.posZ = hit->GetPos().z();
295 mdcTruth.posFlag = hit->GetPosFlag();
296
297 asciiEvt.mdcTruth.truthCol.push_back(mdcTruth);
298 }
299 }
300 }
301 asciiEvt.mdcTruth.nTruth = asciiEvt.mdcTruth.truthCol.size();
302}
std::vector< MdcTruthType > truthCol
Definition AsciiData.hh:114

Referenced by SaveAsciiEvents(), and SaveHitAsciiEvents().

◆ SaveMdcTruth() [2/2]

void BesAsciiIO::SaveMdcTruth ( HitEVENT & asciiEvt)

Definition at line 772 of file BesAsciiIO.cc.

773{
774 G4int HCID = -1;
775 HCID = m_DigiMan->GetHitsCollectionID("BesMdcTruthCollection");
776 if(HCID>0)
777 {
778 BesMdcHitsCollection* HC = 0;
779 HC = (BesMdcHitsCollection*) (m_DigiMan->GetHitsCollection(HCID));
780 G4int n_hit = HC->entries();
781 if(n_hit>0)
782 {
783 //arrange hits in hits collection in order of trackIndex
784 BesMdcHit* hit;
785 vector<BesMdcHit*>* vecHC = HC->GetVector();
786 for(int i=0;i<n_hit-1;i++)
787 for(int j=i+1;j<n_hit;j++)
788 if((*vecHC)[i]->GetTrackID()>(*vecHC)[j]->GetTrackID())
789 {
790 hit = (*vecHC)[i];
791 (*vecHC)[i] = (*vecHC)[j];
792 (*vecHC)[j] = hit;
793 }
794
795 for(G4int i=0;i<n_hit;i++)
796 {
797 hit = (*HC)[i];
798 MdcTruthType mdcTruth;
799 mdcTruth.trackIndex = hit->GetTrackID();
800 mdcTruth.layerNo = hit->GetLayerNo();
801 mdcTruth.cellNo = hit->GetCellNo();
802 mdcTruth.edep = hit->GetEdep();
803 mdcTruth.driftD = hit->GetDriftD();
804 mdcTruth.posX = hit->GetPos().x();
805 mdcTruth.posY = hit->GetPos().y();
806 mdcTruth.posZ = hit->GetPos().z();
807 mdcTruth.posFlag = hit->GetPosFlag();
808
809 asciiEvt.mdcTruth.truthCol.push_back(mdcTruth);
810 }
811 }
812 }
813 asciiEvt.mdcTruth.nTruth = asciiEvt.mdcTruth.truthCol.size();
814}

◆ SaveMucDigits()

void BesAsciiIO::SaveMucDigits ( EVENT & asciiEvt)

Definition at line 549 of file BesAsciiIO.cc.

550{
551 G4int mucDigiCollID =-1;
552 mucDigiCollID = m_DigiMan->GetDigiCollectionID("BesMucDigisCollection");
553 if(mucDigiCollID>=0)
554 {
555 BesMucDigisCollection* mucDC = (BesMucDigisCollection*)m_DigiMan->GetDigiCollection(mucDigiCollID);
556 G4int nDigi = mucDC->entries();
557 if(nDigi > 0) {
558 BesMucDigi* mucDigi;
559 for(int i = 0; i < nDigi; i++)
560 {
561 MucDigiType mucData;
562 mucDigi = (*mucDC)[i];
563 mucData.trackIndex = mucDigi->GetTrackIndex();
564 mucData.partNo = mucDigi->GetPartId();
565 mucData.segNo = mucDigi->GetSegId();
566 mucData.gapNo = mucDigi->GetGapId();
567 mucData.stripNo = mucDigi->GetStripId();
568
569 asciiEvt.mucDigi.digiCol.push_back(mucData);
570 }
571 }
572 }
573 asciiEvt.mucDigi.nDigi=asciiEvt.mucDigi.digiCol.size();
574}
G4TDigiCollection< BesMucDigi > BesMucDigisCollection
Definition BesMucDigi.hh:56
G4int GetPartId()
Definition BesMucDigi.hh:43
G4int GetStripId()
Definition BesMucDigi.hh:46
G4int GetSegId()
Definition BesMucDigi.hh:44
G4int GetTrackIndex()
Definition BesMucDigi.hh:42
G4int GetGapId()
Definition BesMucDigi.hh:45
int nDigi
Definition AsciiData.hh:364
std::vector< MucDigiType > digiCol
Definition AsciiData.hh:365

Referenced by SaveAsciiEvents().

◆ SaveMucHits()

void BesAsciiIO::SaveMucHits ( HitEVENT & )
inline

Definition at line 71 of file BesAsciiIO.hh.

71{};

◆ SaveMucTruth() [1/2]

void BesAsciiIO::SaveMucTruth ( EVENT & asciiEvt)

Definition at line 396 of file BesAsciiIO.cc.

397{
398 G4int HCID = -1;
399 HCID = m_DigiMan->GetHitsCollectionID("BesMucHitsList");
400 if(HCID>0)
401 {
402 BesMucHitsCollection* HC = 0;
403 HC = (BesMucHitsCollection*) (m_DigiMan->GetHitsCollection(HCID));
404 G4int n_hit = HC->entries();
405 if(n_hit>0)
406 {
407 //arrange hits in hits collection in order of trackIndex
408 BesMucHit* hit;
409 vector<BesMucHit*>* vecHC = HC->GetVector();
410 for(int i=0;i<n_hit-1;i++)
411 for(int j=i+1;j<n_hit;j++)
412 if((*vecHC)[i]->GetTrackIndex()>(*vecHC)[j]->GetTrackIndex())
413 {
414 hit = (*vecHC)[i];
415 (*vecHC)[i] = (*vecHC)[j];
416 (*vecHC)[j] = hit;
417 }
418
419 for(G4int i=0;i<n_hit;i++)
420 {
421 hit = (*HC)[i];
422 MucTruthType mucTruth;
423 mucTruth.trackIndex = hit->GetTrackIndex();
424 mucTruth.partId = hit->GetPart();
425 mucTruth.segId = hit->GetSeg();
426 mucTruth.gapId = hit->GetGap();
427 mucTruth.stripId = hit->GetStrip();
428 mucTruth.posX = hit->GetPos().x();
429 mucTruth.posY = hit->GetPos().y();
430 mucTruth.posZ = hit->GetPos().z();
431 mucTruth.px = hit->GetMomentum().x();
432 mucTruth.py = hit->GetMomentum().y();
433 mucTruth.pz = hit->GetMomentum().z();
434 asciiEvt.mucTruth.truthCol.push_back(mucTruth);
435 }
436 }
437 }
438 asciiEvt.mucTruth.nTruth=asciiEvt.mucTruth.truthCol.size();
439}
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
std::vector< MucTruthType > truthCol
Definition AsciiData.hh:201

Referenced by SaveAsciiEvents().

◆ SaveMucTruth() [2/2]

void BesAsciiIO::SaveMucTruth ( HitEVENT & )
inline

Definition at line 66 of file BesAsciiIO.hh.

66{};

◆ SaveTofDigits()

void BesAsciiIO::SaveTofDigits ( EVENT & asciiEvt)

Definition at line 468 of file BesAsciiIO.cc.

469{
470
471 G4int tofDigiCollID = -1;
472 tofDigiCollID = m_DigiMan->GetDigiCollectionID("BesTofDigitsCollection");
473
474 if(tofDigiCollID>=0)
475 {
476 BesTofDigitsCollection* tofDC = (BesTofDigitsCollection*)m_DigiMan->GetDigiCollection(tofDigiCollID);
477 G4int nDigi = tofDC->entries();
478 if(nDigi>0)
479 {
480 //arrange digis in digitsCollection in order of trackIndex
481 BesTofDigi* digi;
482 vector<BesTofDigi*>* vecDC = tofDC->GetVector();
483 for(int i=0;i<nDigi-1;i++)
484 for(int j=i+1;j<nDigi;j++)
485 if((*vecDC)[i]->GetTrackIndex()>(*vecDC)[j]->GetTrackIndex())
486 {
487 digi = (*vecDC)[i];
488 (*vecDC)[i] = (*vecDC)[j];
489 (*vecDC)[j] = digi;
490 }
491
492 for(int i=0;i<nDigi;i++)
493 {
494 TofDigiType tofData;
495 digi = (*tofDC)[i];
496 tofData.trackIndex = digi->GetTrackIndex();
497 tofData.partId = digi->GetPartId();
498 tofData.scinNb = digi->GetScinNb();
499 tofData.forwADC = digi->GetForwADC();
500 tofData.forwTDC = digi->GetForwTDC();
501 tofData.backADC = digi->GetBackADC();
502 tofData.backTDC = digi->GetBackTDC();
503
504 asciiEvt.tofDigi.digiCol.push_back(tofData);
505 }
506 }
507 }
508 asciiEvt.tofDigi.nDigi=asciiEvt.tofDigi.digiCol.size();
509}
G4TDigiCollection< BesTofDigi > BesTofDigitsCollection
Definition BesTofDigi.hh:79
G4int GetPartId()
Definition BesTofDigi.hh:53
G4double GetForwTDC()
Definition BesTofDigi.hh:58
G4int GetScinNb()
Definition BesTofDigi.hh:55
G4int GetTrackIndex()
Definition BesTofDigi.hh:52
G4double GetBackTDC()
Definition BesTofDigi.hh:59
G4double GetBackADC()
Definition BesTofDigi.hh:57
G4double GetForwADC()
Definition BesTofDigi.hh:56
int nDigi
Definition AsciiData.hh:279
std::vector< TofDigiType > digiCol
Definition AsciiData.hh:280
float backADC
Definition AsciiData.hh:268
float backTDC
Definition AsciiData.hh:269
float forwTDC
Definition AsciiData.hh:267
float forwADC
Definition AsciiData.hh:266

Referenced by SaveAsciiEvents().

◆ SaveTofHits()

void BesAsciiIO::SaveTofHits ( HitEVENT & )
inline

Definition at line 69 of file BesAsciiIO.hh.

69{};

◆ SaveTofTruth() [1/2]

void BesAsciiIO::SaveTofTruth ( EVENT & asciiEvt)

Definition at line 304 of file BesAsciiIO.cc.

305{
306 G4int HCID = -1;
307 HCID = m_DigiMan->GetHitsCollectionID("BesTofHitsList");
308 if(HCID>0)
309 {
310 BesTofHitsCollection* HC = 0;
311 HC = (BesTofHitsCollection*) (m_DigiMan->GetHitsCollection(HCID));
312 G4int n_hit = HC->entries();
313 if(n_hit>0)
314 {
315 //arrange hits in hits collection in order of trackIndex
316 BesTofHit* hit;
317 vector<BesTofHit*>* vecHC = HC->GetVector();
318 for(int i=0;i<n_hit-1;i++)
319 for(int j=i+1;j<n_hit;j++)
320 if((*vecHC)[i]->GetTrackIndex()>(*vecHC)[j]->GetTrackIndex())
321 {
322 hit = (*vecHC)[i];
323 (*vecHC)[i] = (*vecHC)[j];
324 (*vecHC)[j] = hit;
325 }
326
327 for(G4int i=0;i<n_hit;i++)
328 {
329 hit = (*HC)[i];
330 TofTruthType tofTruth;
331 tofTruth.trackIndex = hit->GetTrackIndex();
332 tofTruth.partId = hit->GetPartId();
333 tofTruth.scinNb = hit->GetScinNb();
334 tofTruth.posX = hit->GetPos().x();
335 tofTruth.posY = hit->GetPos().y();
336 tofTruth.posZ = hit->GetPos().z();
337 tofTruth.px = hit->GetMomentum().x();
338 tofTruth.py = hit->GetMomentum().y();
339 tofTruth.pz = hit->GetMomentum().z();
340 tofTruth.trackL = hit->GetTrackL();
341 tofTruth.time = hit->GetTime();
342
343 asciiEvt.tofTruth.truthCol.push_back(tofTruth);
344 }
345 }
346 }
347 asciiEvt.tofTruth.nTruth=asciiEvt.tofTruth.truthCol.size();
348}
G4THitsCollection< BesTofHit > BesTofHitsCollection
Definition BesTofHit.hh:116
G4double GetTime()
Definition BesTofHit.hh:74
G4ThreeVector GetPos()
Definition BesTofHit.hh:73
G4int GetScinNb()
Definition BesTofHit.hh:69
G4int GetPartId()
Definition BesTofHit.hh:68
G4double GetTrackL()
Definition BesTofHit.hh:72
G4ThreeVector GetMomentum()
Definition BesTofHit.hh:77
G4int GetTrackIndex()
Definition BesTofHit.hh:66
std::vector< TofTruthType > truthCol
Definition AsciiData.hh:143

Referenced by SaveAsciiEvents().

◆ SaveTofTruth() [2/2]

void BesAsciiIO::SaveTofTruth ( HitEVENT & )
inline

Definition at line 64 of file BesAsciiIO.hh.

64{};

◆ SaveTrackTruth() [1/2]

void BesAsciiIO::SaveTrackTruth ( EVENT & asciiEvt)

Definition at line 176 of file BesAsciiIO.cc.

177{
178
180
181 vector<BesTruthTrack*>* trackList = sensitiveManager->GetTrackList();
182
183 //arrange TruthTrack in trackList in order of trackIndex
184 G4int nTrack = trackList->size();
185 BesTruthTrack* track;
186 for(int i=0;i<nTrack-1;i++)
187 for(int j=i+1;j<nTrack;j++)
188 if((*trackList)[i]->GetIndex()>(*trackList)[j]->GetIndex())
189 {
190 track=(*trackList)[i];
191 (*trackList)[i]=(*trackList)[j];
192 (*trackList)[j]=track;
193 }
194
195 for(int i=0;i<nTrack;i++)
196 {
197 TrackTruthType trackTruth;
198 track = (*(sensitiveManager->GetTrackList())) [i];
199 trackTruth.trackIndex = track->GetIndex();
200 if(track->GetIndex()<0)
201 G4cout<<"trackIndex<0!"<<G4endl;
202 trackTruth.PDGCode = track->GetPDGCode();
203 trackTruth.PDGCharge = track->GetPDGCharge();
204 trackTruth.v0Index = track->GetVertex()->GetIndex();
205 if( track->GetTerminalVertex() )
206 trackTruth.v1Index = track->GetTerminalVertex()->GetIndex();
207 else
208 trackTruth.v1Index = -99;
209 trackTruth.px = track->GetP4().x()/1000.;
210 trackTruth.py = track->GetP4().y()/1000.;
211 trackTruth.pz = track->GetP4().z()/1000.;
212 trackTruth.E = track->GetP4().t()/1000.;
213
214 G4int size = track->GetDaughterIndexes().size();
215 if(size>0)
216 {
217 trackTruth.minDaughterIndex = (track->GetDaughterIndexes())[0];
218 trackTruth.maxDaughterIndex = (track->GetDaughterIndexes())[size-1];
219 }
220 else
221 {
222 trackTruth.minDaughterIndex = -99;
223 trackTruth.maxDaughterIndex = -99;
224 }
225
226
227 asciiEvt.trackTruth.truthCol.push_back(trackTruth);
228 }
229
230 asciiEvt.trackTruth.nTruth=asciiEvt.trackTruth.truthCol.size();
231}
std::vector< BesTruthTrack * > * GetTrackList()
static BesSensitiveManager * GetSensitiveManager()
G4int GetPDGCode() const
HepLorentzVector GetP4() const
BesTruthVertex * GetTerminalVertex() const
BesTruthVertex * GetVertex() const
G4double GetPDGCharge() const
vector< int > GetDaughterIndexes() const
G4int GetIndex() const
G4int GetIndex() const
std::vector< TrackTruthType > truthCol
Definition AsciiData.hh:64

Referenced by SaveAsciiEvents(), and SaveHitAsciiEvents().

◆ SaveTrackTruth() [2/2]

void BesAsciiIO::SaveTrackTruth ( HitEVENT & asciiEvt)

Definition at line 690 of file BesAsciiIO.cc.

691{
692
694
695 vector<BesTruthTrack*>* trackList = sensitiveManager->GetTrackList();
696
697 //arrange TruthTrack in trackList in order of trackIndex
698 G4int nTrack = trackList->size();
699 BesTruthTrack* track;
700 for(int i=0;i<nTrack-1;i++)
701 for(int j=i+1;j<nTrack;j++)
702 if((*trackList)[i]->GetIndex()>(*trackList)[j]->GetIndex())
703 {
704 track=(*trackList)[i];
705 (*trackList)[i]=(*trackList)[j];
706 (*trackList)[j]=track;
707 }
708
709 for(int i=0;i<nTrack;i++)
710 {
711 TrackTruthType trackTruth;
712 track = (*(sensitiveManager->GetTrackList())) [i];
713 trackTruth.trackIndex = track->GetIndex();
714 trackTruth.PDGCode = track->GetPDGCode();
715 trackTruth.PDGCharge = track->GetPDGCharge();
716 trackTruth.v0Index = track->GetVertex()->GetIndex();
717 if( track->GetTerminalVertex() )
718 trackTruth.v1Index = track->GetTerminalVertex()->GetIndex();
719 else
720 trackTruth.v1Index = -99;
721 trackTruth.px = track->GetP4().x();
722 trackTruth.py = track->GetP4().y();
723 trackTruth.pz = track->GetP4().z();
724 trackTruth.E = track->GetP4().t();
725
726 G4int size = track->GetDaughterIndexes().size();
727 if(size>0)
728 {
729 trackTruth.minDaughterIndex = (track->GetDaughterIndexes())[0];
730 trackTruth.maxDaughterIndex = (track->GetDaughterIndexes())[size-1];
731 }
732 else
733 {
734 trackTruth.minDaughterIndex = -99;
735 trackTruth.maxDaughterIndex = -99;
736 }
737
738
739 asciiEvt.trackTruth.truthCol.push_back(trackTruth);
740 }
741
742 asciiEvt.trackTruth.nTruth=asciiEvt.trackTruth.truthCol.size();
743}

◆ SaveVertexTruth() [1/2]

void BesAsciiIO::SaveVertexTruth ( EVENT & asciiEvt)

Definition at line 233 of file BesAsciiIO.cc.

234{
236
237 vector<BesTruthVertex*>* vertexList = sensitiveManager->GetVertexList();
238
239 G4int nVertex = vertexList->size();
240 BesTruthVertex* vertex;
241 for(int i=0;i<nVertex;i++)
242 {
243 VertexTruthType vertexTruth;
244 vertex = (*vertexList) [i];
245 vertexTruth.vertexIndex = vertex->GetIndex();
246 if(vertex->GetParentTrack())
247 vertexTruth.parentTrackIndex = vertex->GetParentTrack()->GetIndex();
248 else
249 vertexTruth.parentTrackIndex = -99;
250
251 vertexTruth.posX = vertex->GetPosition().x()/10.;
252 vertexTruth.posY = vertex->GetPosition().y()/10.;
253 vertexTruth.posZ = vertex->GetPosition().z()/10.;
254 vertexTruth.time = vertex->GetTime();
255 asciiEvt.vertexTruth.truthCol.push_back(vertexTruth);
256 }
257 asciiEvt.vertexTruth.nTruth = asciiEvt.vertexTruth.truthCol.size();
258}
std::vector< BesTruthVertex * > * GetVertexList()
BesTruthTrack * GetParentTrack() const
G4double GetTime() const
G4ThreeVector GetPosition() const
std::vector< VertexTruthType > truthCol
Definition AsciiData.hh:86

Referenced by SaveAsciiEvents(), and SaveHitAsciiEvents().

◆ SaveVertexTruth() [2/2]

void BesAsciiIO::SaveVertexTruth ( HitEVENT & asciiEvt)

Definition at line 745 of file BesAsciiIO.cc.

746{
748
749 vector<BesTruthVertex*>* vertexList = sensitiveManager->GetVertexList();
750
751 G4int nVertex = vertexList->size();
752 BesTruthVertex* vertex;
753 for(int i=0;i<nVertex;i++)
754 {
755 VertexTruthType vertexTruth;
756 vertex = (*vertexList) [i];
757 vertexTruth.vertexIndex = vertex->GetIndex();
758 if(vertex->GetParentTrack())
759 vertexTruth.parentTrackIndex = vertex->GetParentTrack()->GetIndex();
760 else
761 vertexTruth.parentTrackIndex = -99;
762
763 vertexTruth.posX = vertex->GetPosition().x();
764 vertexTruth.posY = vertex->GetPosition().y();
765 vertexTruth.posZ = vertex->GetPosition().z();
766 vertexTruth.time = vertex->GetTime();
767 asciiEvt.vertexTruth.truthCol.push_back(vertexTruth);
768 }
769 asciiEvt.vertexTruth.nTruth = asciiEvt.vertexTruth.truthCol.size();
770}

◆ SetAsciiFile()

void BesAsciiIO::SetAsciiFile ( G4String name)
inline

Definition at line 39 of file BesAsciiIO.hh.

39{m_asciiFile=name;}

◆ SetEmcDigiFlag()

void BesAsciiIO::SetEmcDigiFlag ( G4int flag)
inline

Definition at line 37 of file BesAsciiIO.hh.

37{m_emcDigiFlag=flag;}

◆ SetEmcTruFlag()

void BesAsciiIO::SetEmcTruFlag ( G4int flag)
inline

Definition at line 32 of file BesAsciiIO.hh.

32{m_emcTruFlag=flag;}

◆ SetMdcDigiFlag()

void BesAsciiIO::SetMdcDigiFlag ( G4int flag)
inline

Definition at line 35 of file BesAsciiIO.hh.

35{m_mdcDigiFlag=flag;}

◆ SetMdcTruFlag()

void BesAsciiIO::SetMdcTruFlag ( G4int flag)
inline

Definition at line 30 of file BesAsciiIO.hh.

30{m_mdcTruFlag=flag;}

◆ SetMucDigiFlag()

void BesAsciiIO::SetMucDigiFlag ( G4int flag)
inline

Definition at line 38 of file BesAsciiIO.hh.

38{m_mucDigiFlag=flag;}

◆ SetMucTruFlag()

void BesAsciiIO::SetMucTruFlag ( G4int flag)
inline

Definition at line 33 of file BesAsciiIO.hh.

33{m_mucTruFlag=flag;}

◆ SetTofDigiFlag()

void BesAsciiIO::SetTofDigiFlag ( G4int flag)
inline

Definition at line 36 of file BesAsciiIO.hh.

36{m_tofDigiFlag=flag;}

◆ SetTofTruFlag()

void BesAsciiIO::SetTofTruFlag ( G4int flag)
inline

Definition at line 31 of file BesAsciiIO.hh.

31{m_tofTruFlag=flag;}

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