BOSS 8.0.0
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.

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

◆ ~BesAsciiIO()

BesAsciiIO::~BesAsciiIO ( )

Definition at line 57 of file BesAsciiIO.cc.

57{}

Member Function Documentation

◆ SaveAsciiEvents()

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

Definition at line 59 of file BesAsciiIO.cc.

59 {
60 EVENT asciiEvt;
61
62 asciiEvt.set_initialized();
63 asciiEvt.header.set_initialized();
64 asciiEvt.header.eventNo = evt->GetEventID();
65 asciiEvt.header.runNo = runId;
66 asciiEvt.decayMode.set_initialized();
67 SaveDecayMode( asciiEvt );
68
69 asciiEvt.trackTruth.set_initialized();
71 SaveTrackTruth( asciiEvt );
72 SaveVertexTruth( asciiEvt );
73
74 if ( m_mdcTruFlag )
75 {
76 asciiEvt.mdcTruth.set_initialized();
77 SaveMdcTruth( asciiEvt );
78 }
79
80 if ( m_mdcDigiFlag )
81 {
82 asciiEvt.mdcDigi.set_initialized();
83 SaveMdcDigits( asciiEvt );
84 }
85
86 if ( m_tofTruFlag )
87 {
88 asciiEvt.tofTruth.set_initialized();
89 SaveTofTruth( asciiEvt );
90 }
91
92 if ( m_tofDigiFlag )
93 {
94 asciiEvt.tofDigi.set_initialized();
95 SaveTofDigits( asciiEvt );
96 }
97
98 if ( m_emcTruFlag )
99 {
100 asciiEvt.emcTruth.set_initialized();
101 SaveEmcTruth( asciiEvt );
102 }
103
104 if ( m_emcDigiFlag )
105 {
106 asciiEvt.emcDigi.set_initialized();
107 SaveEmcDigits( asciiEvt );
108 }
109
110 if ( m_mucTruFlag )
111 {
112 asciiEvt.mucTruth.set_initialized();
113 SaveMucTruth( asciiEvt );
114 }
115
116 if ( m_mucDigiFlag )
117 {
118 asciiEvt.mucDigi.set_initialized();
119 SaveMucDigits( asciiEvt );
120 }
121
122 ofstream os;
123 if ( evt->GetEventID() == 0 )
124 {
125 os.open( m_asciiFile );
126 FRMTVERSION version;
127 version.set_initialized();
128 version.major = 1;
129 version.minor = 0;
130 os << version;
131 }
132 else os.open( m_asciiFile, ios::out | ios::app );
133
134 try
135 { os << asciiEvt; } catch ( AsciiWrongTag& ex )
136 {
137 std::cerr << "wrong tag, got " << ex.got() << " expected: " << ex.expected() << std::endl;
138 } catch ( AsciiDumpException& )
139 { std::cerr << "AsciiDumpException was caught!" << std::endl; }
140 os.close();
141}
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 &)

Referenced by BesEventAction::EndOfEventAction().

◆ SaveDecayMode() [1/2]

void BesAsciiIO::SaveDecayMode ( EVENT & asciiEvt)

Definition at line 143 of file BesAsciiIO.cc.

143 {
144 asciiEvt.decayMode.size = 10;
145 // interface to event data service
146 ISvcLocator* svcLocator = Gaudi::svcLocator();
147 IDataProviderSvc* evtSvc;
148 StatusCode sc = svcLocator->service( "EventDataSvc", evtSvc );
149 if ( sc.isFailure() ) G4cout << "Could not accesss EventDataSvc!" << G4endl;
150
151 SmartDataPtr<DecayMode> decayMode( evtSvc, "/Event/MC/DecayMode" );
152 if ( !decayMode )
153 {
154 for ( int i = 0; i < 10; i++ ) asciiEvt.decayMode.data[i] = 0;
155 }
156 else
157 {
158 int dm[10] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
159 decayMode->getData( dm, 10 );
160 for ( int i = 0; i < 10; i++ ) asciiEvt.decayMode.data[i] = dm[i];
161 }
162}

Referenced by SaveAsciiEvents(), and SaveHitAsciiEvents().

◆ SaveDecayMode() [2/2]

void BesAsciiIO::SaveDecayMode ( HitEVENT & asciiEvt)

Definition at line 641 of file BesAsciiIO.cc.

641 {
642 asciiEvt.decayMode.size = 10;
643 // interface to event data service
644 ISvcLocator* svcLocator = Gaudi::svcLocator();
645 IDataProviderSvc* evtSvc;
646 StatusCode sc = svcLocator->service( "EventDataSvc", evtSvc );
647 if ( sc.isFailure() ) G4cout << "Could not accesss EventDataSvc!" << G4endl;
648
649 SmartDataPtr<DecayMode> decayMode( evtSvc, "/Event/MC/DecayMode" );
650 if ( !decayMode )
651 {
652 for ( int i = 0; i < 10; i++ ) asciiEvt.decayMode.data[i] = 0;
653 }
654 else
655 {
656 int dm[10] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
657 decayMode->getData( dm, 10 );
658 for ( int i = 0; i < 10; i++ ) asciiEvt.decayMode.data[i] = dm[i];
659 }
660}

◆ SaveEmcDigits()

void BesAsciiIO::SaveEmcDigits ( EVENT & asciiEvt)

Definition at line 489 of file BesAsciiIO.cc.

489 {
490 G4int emcDigiCollID = -1;
491 emcDigiCollID = m_DigiMan->GetDigiCollectionID( "BesEmcDigitsCollection" );
492 if ( emcDigiCollID >= 0 )
493 {
495 (BesEmcDigitsCollection*)m_DigiMan->GetDigiCollection( emcDigiCollID );
496 G4int nDigi = emcDC->entries();
497 if ( nDigi > 0 )
498 {
499 // arrange digis in digitsCollection in order of trackIndex
500 BesEmcDigi* digi;
501 vector<BesEmcDigi*>* vecDC = emcDC->GetVector();
502 for ( int i = 0; i < nDigi - 1; i++ )
503 for ( int j = i + 1; j < nDigi; j++ )
504 if ( ( *vecDC )[i]->GetTrackIndex() > ( *vecDC )[j]->GetTrackIndex() )
505 {
506 digi = ( *vecDC )[i];
507 ( *vecDC )[i] = ( *vecDC )[j];
508 ( *vecDC )[j] = digi;
509 }
510 for ( int i = 0; i < nDigi; i++ )
511 {
512 EmcDigiType emcData;
513 digi = ( *emcDC )[i];
514 emcData.trackIndex = digi->GetTrackIndex();
515 emcData.partId = digi->GetPartId();
516 emcData.numTheta = digi->GetThetaNb();
517 emcData.numPhi = digi->GetPhiNb();
518 emcData.energyDeposit = digi->GetEnergy();
519 emcData.hitTime = (G4double)digi->GetTime();
520 asciiEvt.emcDigi.digiCol.push_back( emcData );
521 }
522 }
523 }
524 asciiEvt.emcDigi.nDigi = asciiEvt.emcDigi.digiCol.size();
525}
G4TDigiCollection< BesEmcDigi > BesEmcDigitsCollection
std::vector< EmcDigiType > digiCol

Referenced by SaveAsciiEvents().

◆ SaveEmcHits()

void BesAsciiIO::SaveEmcHits ( HitEVENT & )
inline

Definition at line 68 of file BesAsciiIO.hh.

68{};

◆ SaveEmcTruth() [1/2]

void BesAsciiIO::SaveEmcTruth ( EVENT & asciiEvt)

Definition at line 330 of file BesAsciiIO.cc.

330 {
331 G4int HCID = -1;
332 HCID = m_DigiMan->GetHitsCollectionID( "BesEmcHitsList" );
333 if ( HCID > 0 )
334 {
335 BesEmcHitsCollection* HC = 0;
336 HC = (BesEmcHitsCollection*)( m_DigiMan->GetHitsCollection( HCID ) );
337 G4int n_hit = HC->entries();
338 if ( n_hit > 0 )
339 {
340 // arrange hits in hits collection in order of trackIndex
341 BesEmcHit* hit;
342 vector<BesEmcHit*>* vecHC = HC->GetVector();
343 for ( int i = 0; i < n_hit - 1; i++ )
344 for ( int j = i + 1; j < n_hit; j++ )
345 if ( ( *vecHC )[i]->GetTrackIndex() > ( *vecHC )[j]->GetTrackIndex() )
346 {
347 hit = ( *vecHC )[i];
348 ( *vecHC )[i] = ( *vecHC )[j];
349 ( *vecHC )[j] = hit;
350 }
351
352 for ( G4int i = 0; i < n_hit; i++ )
353 {
354 hit = ( *HC )[i];
355 EmcTruthType emcTruth;
356 emcTruth.trackIndex = hit->GetTrackIndex();
357 emcTruth.partId = hit->GetPartId();
358 emcTruth.numTheta = hit->GetNumThetaCrystal();
359 emcTruth.numPhi = hit->GetNumPhiCrystal();
360 emcTruth.posX = hit->GetPosCrystal().x();
361 emcTruth.posY = hit->GetPosCrystal().y();
362 emcTruth.posZ = hit->GetPosCrystal().z();
363 emcTruth.px = hit->GetMomentum().x();
364 emcTruth.py = hit->GetMomentum().y();
365 emcTruth.pz = hit->GetMomentum().z();
366 emcTruth.totalEdep = hit->GetEdepCrystal();
367
368 asciiEvt.emcTruth.truthCol.push_back( emcTruth );
369 }
370 }
371 }
372 asciiEvt.emcTruth.nTruth = asciiEvt.emcTruth.truthCol.size();
373}
G4THitsCollection< BesEmcHit > BesEmcHitsCollection
std::vector< EmcTruthType > truthCol

Referenced by SaveAsciiEvents().

◆ SaveEmcTruth() [2/2]

void BesAsciiIO::SaveEmcTruth ( HitEVENT & )
inline

Definition at line 63 of file BesAsciiIO.hh.

63{};

◆ SaveHitAsciiEvents()

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

Definition at line 556 of file BesAsciiIO.cc.

556 {
557 HitEVENT asciiEvt;
558
559 asciiEvt.set_initialized();
560 asciiEvt.header.set_initialized();
561 asciiEvt.header.eventNo = evt->GetEventID();
562 asciiEvt.header.runNo = runId;
563 asciiEvt.decayMode.set_initialized();
564 SaveDecayMode( asciiEvt );
565
566 asciiEvt.trackTruth.set_initialized();
567 asciiEvt.vertexTruth.set_initialized();
568 SaveTrackTruth( asciiEvt );
569 SaveVertexTruth( asciiEvt );
570
571 if ( m_mdcTruFlag )
572 {
573 asciiEvt.mdcTruth.set_initialized();
574 SaveMdcTruth( asciiEvt );
575 }
576
577 if ( m_mdcDigiFlag )
578 {
579 asciiEvt.mdcHit.set_initialized();
580 SaveMdcHits( asciiEvt );
581 }
582 /*
583 if(m_tofTruFlag)
584 {
585 asciiEvt.tofTruth.set_initialized();
586 SaveTofTruth(asciiEvt);
587 }
588
589 if(m_tofDigiFlag)
590 {
591 asciiEvt.tofHit.set_initialized();
592 SaveTofHits(asciiEvt);
593 }
594
595 if(m_emcTruFlag)
596 {
597 asciiEvt.emcTruth.set_initialized();
598 SaveEmcTruth(asciiEvt);
599 }
600
601 if(m_emcDigiFlag)
602 {
603 asciiEvt.emcHit.set_initialized();
604 SaveEmcHits(asciiEvt);
605 }
606
607 if(m_mucTruFlag)
608 {
609 asciiEvt.mucTruth.set_initialized();
610 SaveMucTruth(asciiEvt);
611 }
612
613 if(m_mucDigiFlag)
614 {
615 asciiEvt.mucHit.set_initialized();
616 SaveMucHits(asciiEvt);
617 }
618 */
619 ofstream os;
620 if ( evt->GetEventID() == 0 )
621 {
622 os.open( m_asciiFile );
623 FRMTVERSION version;
624 version.set_initialized();
625 version.major = 1;
626 version.minor = 0;
627 os << version;
628 }
629 else os.open( m_asciiFile, ios::out | ios::app );
630
631 try
632 { os << asciiEvt; } catch ( AsciiWrongTag& ex )
633 {
634 std::cerr << "wrong tag, got " << ex.got() << " expected: " << ex.expected() << std::endl;
635 } catch ( AsciiDumpException& )
636 { std::cerr << "AsciiDumpException was caught!" << std::endl; }
637
638 os.close();
639}
void SaveMdcHits(HitEVENT &)

Referenced by BesEventAction::EndOfEventAction().

◆ SaveMdcDigits()

void BesAsciiIO::SaveMdcDigits ( EVENT & asciiEvt)

Definition at line 419 of file BesAsciiIO.cc.

419 {
420 G4int mdcDigiCollID = -1;
421 mdcDigiCollID = m_DigiMan->GetDigiCollectionID( "BesMdcDigisCollection" );
422 if ( mdcDigiCollID >= 0 )
423 {
424 BesMdcDigisCollection* mdcDC =
425 (BesMdcDigisCollection*)m_DigiMan->GetDigiCollection( mdcDigiCollID );
426 G4int nDigi = mdcDC->entries();
427 if ( nDigi > 0 )
428 {
429 BesMdcDigi* mdcDigi;
430 for ( int i = 0; i < nDigi; i++ )
431 {
432 MdcDigiType mdcData;
433 mdcDigi = ( *mdcDC )[i];
434 mdcData.trackIndex = mdcDigi->GetTrackID();
435 mdcData.layerNo = mdcDigi->GetLayerNo();
436 mdcData.cellNo = mdcDigi->GetCellNo();
437 mdcData.energyDeposit = mdcDigi->GetEdep();
438 mdcData.driftTime = mdcDigi->GetDriftT();
439 asciiEvt.mdcDigi.digiCol.push_back( mdcData );
440 }
441 }
442 }
443 asciiEvt.mdcDigi.nDigi = asciiEvt.mdcDigi.digiCol.size();
444}
G4TDigiCollection< BesMdcDigi > BesMdcDigisCollection
std::vector< MdcDigiType > digiCol

Referenced by SaveAsciiEvents().

◆ SaveMdcHits()

void BesAsciiIO::SaveMdcHits ( HitEVENT & asciiEvt)

Definition at line 782 of file BesAsciiIO.cc.

782 {
783 G4int mdcHitCollID = -1;
784 mdcHitCollID = m_DigiMan->GetHitsCollectionID( "BesMdcHitsCollection" );
785 if ( mdcHitCollID >= 0 )
786 {
787 BesMdcHitsCollection* mdcDC =
788 (BesMdcHitsCollection*)m_DigiMan->GetHitsCollection( mdcHitCollID );
789 G4int nHit = mdcDC->entries();
790 if ( nHit > 0 )
791 {
792 BesMdcHit* mdcHit;
793 for ( int i = 0; i < nHit; i++ )
794 {
795 MdcHitType mdcData;
796 mdcHit = ( *mdcDC )[i];
797 mdcData.trackIndex = mdcHit->GetTrackID();
798 mdcData.layerNo = mdcHit->GetLayerNo();
799 mdcData.cellNo = mdcHit->GetCellNo();
800 mdcData.posX = mdcHit->GetPos().x();
801 mdcData.posY = mdcHit->GetPos().y();
802 mdcData.posZ = mdcHit->GetPos().z();
803 mdcData.energyDeposit = mdcHit->GetEdep();
804 mdcData.driftDistance = mdcHit->GetDriftD();
805 mdcData.globalT = mdcHit->GetGlobalT();
806 mdcData.theta = mdcHit->GetTheta();
807 mdcData.enterAngle = mdcHit->GetEnterAngle();
808 mdcData.posFlag = mdcHit->GetPosFlag();
809
810 asciiEvt.mdcHit.hitCol.push_back( mdcData );
811 }
812 }
813 }
814 asciiEvt.mdcHit.nHit = asciiEvt.mdcHit.hitCol.size();
815}
G4THitsCollection< BesMdcHit > BesMdcHitsCollection
std::vector< MdcHitType > hitCol

Referenced by SaveHitAsciiEvents().

◆ SaveMdcTruth() [1/2]

void BesAsciiIO::SaveMdcTruth ( EVENT & asciiEvt)

Definition at line 242 of file BesAsciiIO.cc.

242 {
243 G4int HCID = -1;
244 HCID = m_DigiMan->GetHitsCollectionID( "BesMdcTruthCollection" );
245 if ( HCID > 0 )
246 {
247 BesMdcHitsCollection* HC = 0;
248 HC = (BesMdcHitsCollection*)( m_DigiMan->GetHitsCollection( HCID ) );
249 G4int n_hit = HC->entries();
250 if ( n_hit > 0 )
251 {
252 // arrange hits in hits collection in order of trackIndex
253 BesMdcHit* hit;
254 vector<BesMdcHit*>* vecHC = HC->GetVector();
255 for ( int i = 0; i < n_hit - 1; i++ )
256 for ( int j = i + 1; j < n_hit; j++ )
257 if ( ( *vecHC )[i]->GetTrackID() > ( *vecHC )[j]->GetTrackID() )
258 {
259 hit = ( *vecHC )[i];
260 ( *vecHC )[i] = ( *vecHC )[j];
261 ( *vecHC )[j] = hit;
262 }
263
264 for ( G4int i = 0; i < n_hit; i++ )
265 {
266 hit = ( *HC )[i];
267 MdcTruthType mdcTruth;
268 mdcTruth.trackIndex = hit->GetTrackID();
269 mdcTruth.layerNo = hit->GetLayerNo();
270 mdcTruth.cellNo = hit->GetCellNo();
271 mdcTruth.edep = hit->GetEdep();
272 mdcTruth.driftD = hit->GetDriftD();
273 mdcTruth.posX = hit->GetPos().x();
274 mdcTruth.posY = hit->GetPos().y();
275 mdcTruth.posZ = hit->GetPos().z();
276 mdcTruth.posFlag = hit->GetPosFlag();
277
278 asciiEvt.mdcTruth.truthCol.push_back( mdcTruth );
279 }
280 }
281 }
282 asciiEvt.mdcTruth.nTruth = asciiEvt.mdcTruth.truthCol.size();
283}
std::vector< MdcTruthType > truthCol

Referenced by SaveAsciiEvents(), and SaveHitAsciiEvents().

◆ SaveMdcTruth() [2/2]

void BesAsciiIO::SaveMdcTruth ( HitEVENT & asciiEvt)

Definition at line 739 of file BesAsciiIO.cc.

739 {
740 G4int HCID = -1;
741 HCID = m_DigiMan->GetHitsCollectionID( "BesMdcTruthCollection" );
742 if ( HCID > 0 )
743 {
744 BesMdcHitsCollection* HC = 0;
745 HC = (BesMdcHitsCollection*)( m_DigiMan->GetHitsCollection( HCID ) );
746 G4int n_hit = HC->entries();
747 if ( n_hit > 0 )
748 {
749 // arrange hits in hits collection in order of trackIndex
750 BesMdcHit* hit;
751 vector<BesMdcHit*>* vecHC = HC->GetVector();
752 for ( int i = 0; i < n_hit - 1; i++ )
753 for ( int j = i + 1; j < n_hit; j++ )
754 if ( ( *vecHC )[i]->GetTrackID() > ( *vecHC )[j]->GetTrackID() )
755 {
756 hit = ( *vecHC )[i];
757 ( *vecHC )[i] = ( *vecHC )[j];
758 ( *vecHC )[j] = hit;
759 }
760
761 for ( G4int i = 0; i < n_hit; i++ )
762 {
763 hit = ( *HC )[i];
764 MdcTruthType mdcTruth;
765 mdcTruth.trackIndex = hit->GetTrackID();
766 mdcTruth.layerNo = hit->GetLayerNo();
767 mdcTruth.cellNo = hit->GetCellNo();
768 mdcTruth.edep = hit->GetEdep();
769 mdcTruth.driftD = hit->GetDriftD();
770 mdcTruth.posX = hit->GetPos().x();
771 mdcTruth.posY = hit->GetPos().y();
772 mdcTruth.posZ = hit->GetPos().z();
773 mdcTruth.posFlag = hit->GetPosFlag();
774
775 asciiEvt.mdcTruth.truthCol.push_back( mdcTruth );
776 }
777 }
778 }
779 asciiEvt.mdcTruth.nTruth = asciiEvt.mdcTruth.truthCol.size();
780}

◆ SaveMucDigits()

void BesAsciiIO::SaveMucDigits ( EVENT & asciiEvt)

Definition at line 527 of file BesAsciiIO.cc.

527 {
528 G4int mucDigiCollID = -1;
529 mucDigiCollID = m_DigiMan->GetDigiCollectionID( "BesMucDigisCollection" );
530 if ( mucDigiCollID >= 0 )
531 {
532 BesMucDigisCollection* mucDC =
533 (BesMucDigisCollection*)m_DigiMan->GetDigiCollection( mucDigiCollID );
534 G4int nDigi = mucDC->entries();
535 if ( nDigi > 0 )
536 {
537 BesMucDigi* mucDigi;
538 for ( int i = 0; i < nDigi; i++ )
539 {
540 MucDigiType mucData;
541 mucDigi = ( *mucDC )[i];
542 mucData.trackIndex = mucDigi->GetTrackIndex();
543 mucData.partNo = mucDigi->GetPartId();
544 mucData.segNo = mucDigi->GetSegId();
545 mucData.gapNo = mucDigi->GetGapId();
546 mucData.stripNo = mucDigi->GetStripId();
547
548 asciiEvt.mucDigi.digiCol.push_back( mucData );
549 }
550 }
551 }
552 asciiEvt.mucDigi.nDigi = asciiEvt.mucDigi.digiCol.size();
553}
G4TDigiCollection< BesMucDigi > BesMucDigisCollection
std::vector< MucDigiType > digiCol

Referenced by SaveAsciiEvents().

◆ SaveMucHits()

void BesAsciiIO::SaveMucHits ( HitEVENT & )
inline

Definition at line 69 of file BesAsciiIO.hh.

69{};

◆ SaveMucTruth() [1/2]

void BesAsciiIO::SaveMucTruth ( EVENT & asciiEvt)

Definition at line 375 of file BesAsciiIO.cc.

375 {
376 G4int HCID = -1;
377 HCID = m_DigiMan->GetHitsCollectionID( "BesMucHitsList" );
378 if ( HCID > 0 )
379 {
380 BesMucHitsCollection* HC = 0;
381 HC = (BesMucHitsCollection*)( m_DigiMan->GetHitsCollection( HCID ) );
382 G4int n_hit = HC->entries();
383 if ( n_hit > 0 )
384 {
385 // arrange hits in hits collection in order of trackIndex
386 BesMucHit* hit;
387 vector<BesMucHit*>* vecHC = HC->GetVector();
388 for ( int i = 0; i < n_hit - 1; i++ )
389 for ( int j = i + 1; j < n_hit; j++ )
390 if ( ( *vecHC )[i]->GetTrackIndex() > ( *vecHC )[j]->GetTrackIndex() )
391 {
392 hit = ( *vecHC )[i];
393 ( *vecHC )[i] = ( *vecHC )[j];
394 ( *vecHC )[j] = hit;
395 }
396
397 for ( G4int i = 0; i < n_hit; i++ )
398 {
399 hit = ( *HC )[i];
400 MucTruthType mucTruth;
401 mucTruth.trackIndex = hit->GetTrackIndex();
402 mucTruth.partId = hit->GetPart();
403 mucTruth.segId = hit->GetSeg();
404 mucTruth.gapId = hit->GetGap();
405 mucTruth.stripId = hit->GetStrip();
406 mucTruth.posX = hit->GetPos().x();
407 mucTruth.posY = hit->GetPos().y();
408 mucTruth.posZ = hit->GetPos().z();
409 mucTruth.px = hit->GetMomentum().x();
410 mucTruth.py = hit->GetMomentum().y();
411 mucTruth.pz = hit->GetMomentum().z();
412 asciiEvt.mucTruth.truthCol.push_back( mucTruth );
413 }
414 }
415 }
416 asciiEvt.mucTruth.nTruth = asciiEvt.mucTruth.truthCol.size();
417}
G4THitsCollection< BesMucHit > BesMucHitsCollection
std::vector< MucTruthType > truthCol

Referenced by SaveAsciiEvents().

◆ SaveMucTruth() [2/2]

void BesAsciiIO::SaveMucTruth ( HitEVENT & )
inline

Definition at line 64 of file BesAsciiIO.hh.

64{};

◆ SaveTofDigits()

void BesAsciiIO::SaveTofDigits ( EVENT & asciiEvt)

Definition at line 446 of file BesAsciiIO.cc.

446 {
447
448 G4int tofDigiCollID = -1;
449 tofDigiCollID = m_DigiMan->GetDigiCollectionID( "BesTofDigitsCollection" );
450
451 if ( tofDigiCollID >= 0 )
452 {
454 (BesTofDigitsCollection*)m_DigiMan->GetDigiCollection( tofDigiCollID );
455 G4int nDigi = tofDC->entries();
456 if ( nDigi > 0 )
457 {
458 // arrange digis in digitsCollection in order of trackIndex
459 BesTofDigi* digi;
460 vector<BesTofDigi*>* vecDC = tofDC->GetVector();
461 for ( int i = 0; i < nDigi - 1; i++ )
462 for ( int j = i + 1; j < nDigi; j++ )
463 if ( ( *vecDC )[i]->GetTrackIndex() > ( *vecDC )[j]->GetTrackIndex() )
464 {
465 digi = ( *vecDC )[i];
466 ( *vecDC )[i] = ( *vecDC )[j];
467 ( *vecDC )[j] = digi;
468 }
469
470 for ( int i = 0; i < nDigi; i++ )
471 {
472 TofDigiType tofData;
473 digi = ( *tofDC )[i];
474 tofData.trackIndex = digi->GetTrackIndex();
475 tofData.partId = digi->GetPartId();
476 tofData.scinNb = digi->GetScinNb();
477 tofData.forwADC = digi->GetForwADC();
478 tofData.forwTDC = digi->GetForwTDC();
479 tofData.backADC = digi->GetBackADC();
480 tofData.backTDC = digi->GetBackTDC();
481
482 asciiEvt.tofDigi.digiCol.push_back( tofData );
483 }
484 }
485 }
486 asciiEvt.tofDigi.nDigi = asciiEvt.tofDigi.digiCol.size();
487}
G4TDigiCollection< BesTofDigi > BesTofDigitsCollection
std::vector< TofDigiType > digiCol

Referenced by SaveAsciiEvents().

◆ SaveTofHits()

void BesAsciiIO::SaveTofHits ( HitEVENT & )
inline

Definition at line 67 of file BesAsciiIO.hh.

67{};

◆ SaveTofTruth() [1/2]

void BesAsciiIO::SaveTofTruth ( EVENT & asciiEvt)

Definition at line 285 of file BesAsciiIO.cc.

285 {
286 G4int HCID = -1;
287 HCID = m_DigiMan->GetHitsCollectionID( "BesTofHitsList" );
288 if ( HCID > 0 )
289 {
290 BesTofHitsCollection* HC = 0;
291 HC = (BesTofHitsCollection*)( m_DigiMan->GetHitsCollection( HCID ) );
292 G4int n_hit = HC->entries();
293 if ( n_hit > 0 )
294 {
295 // arrange hits in hits collection in order of trackIndex
296 BesTofHit* hit;
297 vector<BesTofHit*>* vecHC = HC->GetVector();
298 for ( int i = 0; i < n_hit - 1; i++ )
299 for ( int j = i + 1; j < n_hit; j++ )
300 if ( ( *vecHC )[i]->GetTrackIndex() > ( *vecHC )[j]->GetTrackIndex() )
301 {
302 hit = ( *vecHC )[i];
303 ( *vecHC )[i] = ( *vecHC )[j];
304 ( *vecHC )[j] = hit;
305 }
306
307 for ( G4int i = 0; i < n_hit; i++ )
308 {
309 hit = ( *HC )[i];
310 TofTruthType tofTruth;
311 tofTruth.trackIndex = hit->GetTrackIndex();
312 tofTruth.partId = hit->GetPartId();
313 tofTruth.scinNb = hit->GetScinNb();
314 tofTruth.posX = hit->GetPos().x();
315 tofTruth.posY = hit->GetPos().y();
316 tofTruth.posZ = hit->GetPos().z();
317 tofTruth.px = hit->GetMomentum().x();
318 tofTruth.py = hit->GetMomentum().y();
319 tofTruth.pz = hit->GetMomentum().z();
320 tofTruth.trackL = hit->GetTrackL();
321 tofTruth.time = hit->GetTime();
322
323 asciiEvt.tofTruth.truthCol.push_back( tofTruth );
324 }
325 }
326 }
327 asciiEvt.tofTruth.nTruth = asciiEvt.tofTruth.truthCol.size();
328}
G4THitsCollection< BesTofHit > BesTofHitsCollection
std::vector< TofTruthType > truthCol

Referenced by SaveAsciiEvents().

◆ SaveTofTruth() [2/2]

void BesAsciiIO::SaveTofTruth ( HitEVENT & )
inline

Definition at line 62 of file BesAsciiIO.hh.

62{};

◆ SaveTrackTruth() [1/2]

void BesAsciiIO::SaveTrackTruth ( EVENT & asciiEvt)

Definition at line 164 of file BesAsciiIO.cc.

164 {
165
166 BesSensitiveManager* sensitiveManager = BesSensitiveManager::GetSensitiveManager();
167
168 vector<BesTruthTrack*>* trackList = sensitiveManager->GetTrackList();
169
170 // arrange TruthTrack in trackList in order of trackIndex
171 G4int nTrack = trackList->size();
172 BesTruthTrack* track;
173 for ( int i = 0; i < nTrack - 1; i++ )
174 for ( int j = i + 1; j < nTrack; j++ )
175 if ( ( *trackList )[i]->GetIndex() > ( *trackList )[j]->GetIndex() )
176 {
177 track = ( *trackList )[i];
178 ( *trackList )[i] = ( *trackList )[j];
179 ( *trackList )[j] = track;
180 }
181
182 for ( int i = 0; i < nTrack; i++ )
183 {
184 TrackTruthType trackTruth;
185 track = ( *( sensitiveManager->GetTrackList() ) )[i];
186 trackTruth.trackIndex = track->GetIndex();
187 if ( track->GetIndex() < 0 ) G4cout << "trackIndex<0!" << G4endl;
188 trackTruth.PDGCode = track->GetPDGCode();
189 trackTruth.PDGCharge = track->GetPDGCharge();
190 trackTruth.v0Index = track->GetVertex()->GetIndex();
191 if ( track->GetTerminalVertex() )
192 trackTruth.v1Index = track->GetTerminalVertex()->GetIndex();
193 else trackTruth.v1Index = -99;
194 trackTruth.px = track->GetP4().x() / 1000.;
195 trackTruth.py = track->GetP4().y() / 1000.;
196 trackTruth.pz = track->GetP4().z() / 1000.;
197 trackTruth.E = track->GetP4().t() / 1000.;
198
199 G4int size = track->GetDaughterIndexes().size();
200 if ( size > 0 )
201 {
202 trackTruth.minDaughterIndex = ( track->GetDaughterIndexes() )[0];
203 trackTruth.maxDaughterIndex = ( track->GetDaughterIndexes() )[size - 1];
204 }
205 else
206 {
207 trackTruth.minDaughterIndex = -99;
208 trackTruth.maxDaughterIndex = -99;
209 }
210
211 asciiEvt.trackTruth.truthCol.push_back( trackTruth );
212 }
213
214 asciiEvt.trackTruth.nTruth = asciiEvt.trackTruth.truthCol.size();
215}
std::vector< TrackTruthType > truthCol

Referenced by SaveAsciiEvents(), and SaveHitAsciiEvents().

◆ SaveTrackTruth() [2/2]

void BesAsciiIO::SaveTrackTruth ( HitEVENT & asciiEvt)

Definition at line 662 of file BesAsciiIO.cc.

662 {
663
664 BesSensitiveManager* sensitiveManager = BesSensitiveManager::GetSensitiveManager();
665
666 vector<BesTruthTrack*>* trackList = sensitiveManager->GetTrackList();
667
668 // arrange TruthTrack in trackList in order of trackIndex
669 G4int nTrack = trackList->size();
670 BesTruthTrack* track;
671 for ( int i = 0; i < nTrack - 1; i++ )
672 for ( int j = i + 1; j < nTrack; j++ )
673 if ( ( *trackList )[i]->GetIndex() > ( *trackList )[j]->GetIndex() )
674 {
675 track = ( *trackList )[i];
676 ( *trackList )[i] = ( *trackList )[j];
677 ( *trackList )[j] = track;
678 }
679
680 for ( int i = 0; i < nTrack; i++ )
681 {
682 TrackTruthType trackTruth;
683 track = ( *( sensitiveManager->GetTrackList() ) )[i];
684 trackTruth.trackIndex = track->GetIndex();
685 trackTruth.PDGCode = track->GetPDGCode();
686 trackTruth.PDGCharge = track->GetPDGCharge();
687 trackTruth.v0Index = track->GetVertex()->GetIndex();
688 if ( track->GetTerminalVertex() )
689 trackTruth.v1Index = track->GetTerminalVertex()->GetIndex();
690 else trackTruth.v1Index = -99;
691 trackTruth.px = track->GetP4().x();
692 trackTruth.py = track->GetP4().y();
693 trackTruth.pz = track->GetP4().z();
694 trackTruth.E = track->GetP4().t();
695
696 G4int size = track->GetDaughterIndexes().size();
697 if ( size > 0 )
698 {
699 trackTruth.minDaughterIndex = ( track->GetDaughterIndexes() )[0];
700 trackTruth.maxDaughterIndex = ( track->GetDaughterIndexes() )[size - 1];
701 }
702 else
703 {
704 trackTruth.minDaughterIndex = -99;
705 trackTruth.maxDaughterIndex = -99;
706 }
707
708 asciiEvt.trackTruth.truthCol.push_back( trackTruth );
709 }
710
711 asciiEvt.trackTruth.nTruth = asciiEvt.trackTruth.truthCol.size();
712}

◆ SaveVertexTruth() [1/2]

void BesAsciiIO::SaveVertexTruth ( EVENT & asciiEvt)

Definition at line 217 of file BesAsciiIO.cc.

217 {
218 BesSensitiveManager* sensitiveManager = BesSensitiveManager::GetSensitiveManager();
219
220 vector<BesTruthVertex*>* vertexList = sensitiveManager->GetVertexList();
221
222 G4int nVertex = vertexList->size();
223 BesTruthVertex* vertex;
224 for ( int i = 0; i < nVertex; i++ )
225 {
226 VertexTruthType vertexTruth;
227 vertex = ( *vertexList )[i];
228 vertexTruth.vertexIndex = vertex->GetIndex();
229 if ( vertex->GetParentTrack() )
230 vertexTruth.parentTrackIndex = vertex->GetParentTrack()->GetIndex();
231 else vertexTruth.parentTrackIndex = -99;
232
233 vertexTruth.posX = vertex->GetPosition().x() / 10.;
234 vertexTruth.posY = vertex->GetPosition().y() / 10.;
235 vertexTruth.posZ = vertex->GetPosition().z() / 10.;
236 vertexTruth.time = vertex->GetTime();
237 asciiEvt.vertexTruth.truthCol.push_back( vertexTruth );
238 }
239 asciiEvt.vertexTruth.nTruth = asciiEvt.vertexTruth.truthCol.size();
240}
std::vector< VertexTruthType > truthCol

Referenced by SaveAsciiEvents(), and SaveHitAsciiEvents().

◆ SaveVertexTruth() [2/2]

void BesAsciiIO::SaveVertexTruth ( HitEVENT & asciiEvt)

Definition at line 714 of file BesAsciiIO.cc.

714 {
715 BesSensitiveManager* sensitiveManager = BesSensitiveManager::GetSensitiveManager();
716
717 vector<BesTruthVertex*>* vertexList = sensitiveManager->GetVertexList();
718
719 G4int nVertex = vertexList->size();
720 BesTruthVertex* vertex;
721 for ( int i = 0; i < nVertex; i++ )
722 {
723 VertexTruthType vertexTruth;
724 vertex = ( *vertexList )[i];
725 vertexTruth.vertexIndex = vertex->GetIndex();
726 if ( vertex->GetParentTrack() )
727 vertexTruth.parentTrackIndex = vertex->GetParentTrack()->GetIndex();
728 else vertexTruth.parentTrackIndex = -99;
729
730 vertexTruth.posX = vertex->GetPosition().x();
731 vertexTruth.posY = vertex->GetPosition().y();
732 vertexTruth.posZ = vertex->GetPosition().z();
733 vertexTruth.time = vertex->GetTime();
734 asciiEvt.vertexTruth.truthCol.push_back( vertexTruth );
735 }
736 asciiEvt.vertexTruth.nTruth = asciiEvt.vertexTruth.truthCol.size();
737}

◆ SetAsciiFile()

void BesAsciiIO::SetAsciiFile ( G4String name)
inline

Definition at line 37 of file BesAsciiIO.hh.

37{ m_asciiFile = name; }

◆ SetEmcDigiFlag()

void BesAsciiIO::SetEmcDigiFlag ( G4int flag)
inline

Definition at line 35 of file BesAsciiIO.hh.

35{ m_emcDigiFlag = flag; }

◆ SetEmcTruFlag()

void BesAsciiIO::SetEmcTruFlag ( G4int flag)
inline

Definition at line 30 of file BesAsciiIO.hh.

30{ m_emcTruFlag = flag; }

◆ SetMdcDigiFlag()

void BesAsciiIO::SetMdcDigiFlag ( G4int flag)
inline

Definition at line 33 of file BesAsciiIO.hh.

33{ m_mdcDigiFlag = flag; }

◆ SetMdcTruFlag()

void BesAsciiIO::SetMdcTruFlag ( G4int flag)
inline

Definition at line 28 of file BesAsciiIO.hh.

28{ m_mdcTruFlag = flag; }

◆ SetMucDigiFlag()

void BesAsciiIO::SetMucDigiFlag ( G4int flag)
inline

Definition at line 36 of file BesAsciiIO.hh.

36{ m_mucDigiFlag = flag; }

◆ SetMucTruFlag()

void BesAsciiIO::SetMucTruFlag ( G4int flag)
inline

Definition at line 31 of file BesAsciiIO.hh.

31{ m_mucTruFlag = flag; }

◆ SetTofDigiFlag()

void BesAsciiIO::SetTofDigiFlag ( G4int flag)
inline

Definition at line 34 of file BesAsciiIO.hh.

34{ m_tofDigiFlag = flag; }

◆ SetTofTruFlag()

void BesAsciiIO::SetTofTruFlag ( G4int flag)
inline

Definition at line 29 of file BesAsciiIO.hh.

29{ m_tofTruFlag = flag; }

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