10#include "BesMdcHit.hh"
11#include "BesMdcDigi.hh"
12#include "BesCgemHit.hh"
13#include "BesCgemDigi.hh"
14#include "BesTofHit.hh"
15#include "BesTofDigi.hh"
16#include "BesEmcHit.hh"
17#include "BesEmcDigi.hh"
18#include "BesMucHit.hh"
19#include "BesMucDigi.hh"
20#include "BesEventAction.hh"
21#include "G4RunManager.hh"
22#include "BesTruthTrack.hh"
23#include "BesTruthVertex.hh"
24#include "BesSensitiveManager.hh"
25#include "G4HCofThisEvent.hh"
26#include "G4SDManager.hh"
27#include "G4PrimaryVertex.hh"
28#include "G4PrimaryParticle.hh"
30#include "BesAsciiIO.hh"
31#include "AsciiDmp/dmplib.hh"
32#include "G4DigiManager.hh"
36#include "GaudiKernel/IDataProviderSvc.h"
37#include "GaudiKernel/ISvcLocator.h"
38#include "GaudiKernel/Bootstrap.h"
39#include "GaudiKernel/RegistryEntry.h"
40#include "GaudiKernel/MsgStream.h"
41#include "GaudiKernel/SmartDataPtr.h"
42#include "McTruth/DecayMode.h"
45 G4int mdcTruFlag,G4int mdcDigiFlag,
46 G4int cgemTruFlag,G4int cgemDigiFlag,
47 G4int tofTruFlag, G4int tofDigiFlag,
48 G4int emcTruFlag, G4int emcDigiFlag,
49 G4int mucTruFlag, G4int mucDigiFlag,
51:m_mdcTruFlag(mdcTruFlag),m_mdcDigiFlag(mdcDigiFlag),
52 m_cgemTruFlag(cgemTruFlag),m_cgemDigiFlag(cgemDigiFlag),
53 m_tofTruFlag(tofTruFlag),m_tofDigiFlag(tofDigiFlag),
54 m_emcTruFlag(emcTruFlag),m_emcDigiFlag(emcDigiFlag),
55 m_mucTruFlag(mucTruFlag),m_mucDigiFlag(mucDigiFlag),
58 m_DigiMan = G4DigiManager::GetDMpointer();
142 if(evt->GetEventID()==0)
144 os.open(m_asciiFile);
152 os.open(m_asciiFile,ios::out|ios::app);
158 std::cerr <<
"wrong tag, got " << ex.
got()
162 std::cerr <<
"AsciiDumpException was caught!" << std::endl;
171 ISvcLocator* svcLocator = Gaudi::svcLocator();
172 IDataProviderSvc* evtSvc;
173 StatusCode sc=svcLocator->service(
"EventDataSvc", evtSvc);
175 G4cout<<
"Could not accesss EventDataSvc!"<<G4endl;
177 SmartDataPtr<DecayMode> decayMode(evtSvc,
"/Event/MC/DecayMode");
180 for(
int i=0;i<10;i++)
185 int dm[10]={0,0,0,0,0,0,0,0,0,0};
186 decayMode->getData(dm,10);
187 for(
int i=0;i<10;i++)
197 vector<BesTruthTrack*>* trackList = sensitiveManager->
GetTrackList();
200 G4int nTrack = trackList->size();
202 for(
int i=0;i<nTrack-1;i++)
203 for(
int j=i+1;j<nTrack;j++)
204 if((*trackList)[i]->GetIndex()>(*trackList)[j]->GetIndex())
206 track=(*trackList)[i];
207 (*trackList)[i]=(*trackList)[j];
208 (*trackList)[j]=track;
211 for(
int i=0;i<nTrack;i++)
217 G4cout<<
"trackIndex<0!"<<G4endl;
225 trackTruth.
px = track->
GetP4().x()/1000.;
226 trackTruth.
py = track->
GetP4().y()/1000.;
227 trackTruth.
pz = track->
GetP4().z()/1000.;
228 trackTruth.
E = track->
GetP4().t()/1000.;
253 vector<BesTruthVertex*>* vertexList = sensitiveManager->
GetVertexList();
255 G4int nVertex = vertexList->size();
257 for(
int i=0;i<nVertex;i++)
260 vertex = (*vertexList) [i];
279 HCID = m_DigiMan->GetHitsCollectionID(
"BesMdcTruthCollection");
284 G4int n_hit = HC->entries();
289 vector<BesMdcHit*>* vecHC = HC->GetVector();
290 for(
int i=0;i<n_hit-1;i++)
291 for(
int j=i+1;j<n_hit;j++)
292 if((*vecHC)[i]->GetTrackID()>(*vecHC)[j]->GetTrackID())
295 (*vecHC)[i] = (*vecHC)[j];
299 for(G4int i=0;i<n_hit;i++)
323 HCID = m_DigiMan->GetHitsCollectionID(
"BesCgemTruthCollection");
328 G4int n_hit = HC->entries();
333 vector<BesCgemHit*>* vecHC = HC->GetVector();
334 for(
int i=0;i<n_hit-1;i++)
335 for(
int j=i+1;j<n_hit;j++)
336 if((*vecHC)[i]->GetTrackID()>(*vecHC)[j]->GetTrackID())
339 (*vecHC)[i] = (*vecHC)[j];
343 for(G4int i=0;i<n_hit;i++)
377 HCID = m_DigiMan->GetHitsCollectionID(
"BesTofHitsList");
382 G4int n_hit = HC->entries();
387 vector<BesTofHit*>* 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())
393 (*vecHC)[i] = (*vecHC)[j];
397 for(G4int i=0;i<n_hit;i++)
423 HCID = m_DigiMan->GetHitsCollectionID(
"BesEmcHitsList");
428 G4int n_hit = HC->entries();
433 vector<BesEmcHit*>* vecHC = HC->GetVector();
434 for(
int i=0;i<n_hit-1;i++)
435 for(
int j=i+1;j<n_hit;j++)
436 if((*vecHC)[i]->GetTrackIndex()>(*vecHC)[j]->GetTrackIndex())
439 (*vecHC)[i] = (*vecHC)[j];
443 for(G4int i=0;i<n_hit;i++)
469 HCID = m_DigiMan->GetHitsCollectionID(
"BesMucHitsList");
474 G4int n_hit = HC->entries();
479 vector<BesMucHit*>* vecHC = HC->GetVector();
480 for(
int i=0;i<n_hit-1;i++)
481 for(
int j=i+1;j<n_hit;j++)
482 if((*vecHC)[i]->GetTrackIndex()>(*vecHC)[j]->GetTrackIndex())
485 (*vecHC)[i] = (*vecHC)[j];
489 for(G4int i=0;i<n_hit;i++)
513 G4int mdcDigiCollID = -1;
514 mdcDigiCollID = m_DigiMan->GetDigiCollectionID(
"BesMdcDigisCollection");
515 if(mdcDigiCollID>=0){
517 G4int nDigi = mdcDC->entries();
521 for(
int i=0;i<nDigi;i++)
539 G4int cgemDigiCollID = -1;
540 cgemDigiCollID = m_DigiMan->GetDigiCollectionID(
"BesCgemDigisCollection");
541 if(cgemDigiCollID>=0)
544 G4int nDigi = cgemDC->entries();
548 for(
int i=0;i<nDigi;i++)
551 cgemDigi=(*cgemDC)[i];
572 G4int tofDigiCollID = -1;
573 tofDigiCollID = m_DigiMan->GetDigiCollectionID(
"BesTofDigitsCollection");
578 G4int nDigi = tofDC->entries();
583 vector<BesTofDigi*>* vecDC = tofDC->GetVector();
584 for(
int i=0;i<nDigi-1;i++)
585 for(
int j=i+1;j<nDigi;j++)
586 if((*vecDC)[i]->GetTrackIndex()>(*vecDC)[j]->GetTrackIndex())
589 (*vecDC)[i] = (*vecDC)[j];
593 for(
int i=0;i<nDigi;i++)
614 G4int emcDigiCollID = -1;
615 emcDigiCollID = m_DigiMan->GetDigiCollectionID(
"BesEmcDigitsCollection");
619 G4int nDigi = emcDC->entries();
624 vector<BesEmcDigi*>* vecDC = emcDC->GetVector();
625 for(
int i=0;i<nDigi-1;i++)
626 for(
int j=i+1;j<nDigi;j++)
627 if((*vecDC)[i]->GetTrackIndex()>(*vecDC)[j]->GetTrackIndex())
630 (*vecDC)[i] = (*vecDC)[j];
633 for(
int i=0;i<nDigi;i++)
652 G4int mucDigiCollID =-1;
653 mucDigiCollID = m_DigiMan->GetDigiCollectionID(
"BesMucDigisCollection");
657 G4int nDigi = mucDC->entries();
660 for(
int i = 0; i < nDigi; i++)
663 mucDigi = (*mucDC)[i];
754 if(evt->GetEventID()==0){
755 os.open(m_asciiFile);
763 os.open(m_asciiFile,ios::out|ios::app);
768 std::cerr <<
"wrong tag, got " << ex.
got()
772 std::cerr <<
"AsciiDumpException was caught!" << std::endl;
782 ISvcLocator* svcLocator = Gaudi::svcLocator();
783 IDataProviderSvc* evtSvc;
784 StatusCode sc=svcLocator->service(
"EventDataSvc", evtSvc);
786 G4cout<<
"Could not accesss EventDataSvc!"<<G4endl;
788 SmartDataPtr<DecayMode> decayMode(evtSvc,
"/Event/MC/DecayMode");
791 for(
int i=0;i<10;i++)
796 int dm[10]={0,0,0,0,0,0,0,0,0,0};
797 decayMode->getData(dm,10);
798 for(
int i=0;i<10;i++)
808 vector<BesTruthTrack*>* trackList = sensitiveManager->
GetTrackList();
811 G4int nTrack = trackList->size();
813 for(
int i=0;i<nTrack-1;i++)
814 for(
int j=i+1;j<nTrack;j++)
815 if((*trackList)[i]->GetIndex()>(*trackList)[j]->GetIndex())
817 track=(*trackList)[i];
818 (*trackList)[i]=(*trackList)[j];
819 (*trackList)[j]=track;
822 for(
int i=0;i<nTrack;i++)
834 trackTruth.
px = track->
GetP4().x();
835 trackTruth.
py = track->
GetP4().y();
836 trackTruth.
pz = track->
GetP4().z();
837 trackTruth.
E = track->
GetP4().t();
862 vector<BesTruthVertex*>* vertexList = sensitiveManager->
GetVertexList();
864 G4int nVertex = vertexList->size();
866 for(
int i=0;i<nVertex;i++)
869 vertex = (*vertexList) [i];
888 HCID = m_DigiMan->GetHitsCollectionID(
"BesMdcTruthCollection");
893 G4int n_hit = HC->entries();
898 vector<BesMdcHit*>* vecHC = HC->GetVector();
899 for(
int i=0;i<n_hit-1;i++)
900 for(
int j=i+1;j<n_hit;j++)
901 if((*vecHC)[i]->GetTrackID()>(*vecHC)[j]->GetTrackID())
904 (*vecHC)[i] = (*vecHC)[j];
908 for(G4int i=0;i<n_hit;i++)
932 HCID = m_DigiMan->GetHitsCollectionID(
"BesCgemTruthCollection");
937 G4int n_hit = HC->entries();
942 vector<BesCgemHit*>* vecHC = HC->GetVector();
943 for(
int i=0;i<n_hit-1;i++)
944 for(
int j=i+1;j<n_hit;j++)
945 if((*vecHC)[i]->GetTrackID()>(*vecHC)[j]->GetTrackID())
948 (*vecHC)[i] = (*vecHC)[j];
952 for(G4int i=0;i<n_hit;i++)
985 G4int mdcHitCollID = -1;
986 mdcHitCollID = m_DigiMan->GetHitsCollectionID(
"BesMdcHitsCollection");
990 G4int nHit = mdcDC->entries();
994 for(
int i=0;i<nHit;i++)
1020 G4int cgemHitCollID = -1;
1021 cgemHitCollID = m_DigiMan->GetHitsCollectionID(
"BesCgemHitsCollection");
1022 if(cgemHitCollID>=0)
1025 G4int nHit = cgemDC->entries();
1029 for(
int i=0;i<nHit;i++)
1032 cgemHit=(*cgemDC)[i];
G4TDigiCollection< BesCgemDigi > BesCgemDigisCollection
G4THitsCollection< BesCgemHit > BesCgemHitsCollection
G4TDigiCollection< BesEmcDigi > BesEmcDigitsCollection
G4THitsCollection< BesEmcHit > BesEmcHitsCollection
G4TDigiCollection< BesMdcDigi > BesMdcDigisCollection
G4THitsCollection< BesMdcHit > BesMdcHitsCollection
G4TDigiCollection< BesMucDigi > BesMucDigisCollection
G4THitsCollection< BesMucHit > BesMucHitsCollection
G4TDigiCollection< BesTofDigi > BesTofDigitsCollection
G4THitsCollection< BesTofHit > BesTofHitsCollection
std::string expected() const
BesAsciiIO(G4int, G4int, G4int, G4int, G4int, G4int, G4int, G4int, G4int, G4int, G4String)
void SaveMdcHits(HitEVENT &)
void SaveCgemDigits(EVENT &)
void SaveMucDigits(EVENT &)
void SaveTrackTruth(EVENT &)
void SaveDecayMode(EVENT &)
void SaveMdcDigits(EVENT &)
void SaveMucTruth(EVENT &)
void SaveEmcDigits(EVENT &)
void SaveCgemHits(HitEVENT &)
void SaveCgemTruth(EVENT &)
void SaveEmcTruth(EVENT &)
void SaveTofTruth(EVENT &)
void SaveHitAsciiEvents(G4int, const G4Event *)
void SaveMdcTruth(EVENT &)
void SaveTofDigits(EVENT &)
void SaveVertexTruth(EVENT &)
void SaveAsciiEvents(G4int, const G4Event *)
G4double GetGlobalTime() const
G4double GetEnergyDeposit() const
G4int GetStripType() const
G4ThreeVector GetPositionOfPrePoint() const
G4ThreeVector GetMomentumOfPostPoint() const
G4double GetGlobalTime() const
G4double GetStepLength() const
G4ThreeVector GetPositionOfPostPoint() const
G4double GetTotalEnergyDeposit() const
G4ThreeVector GetMomentumOfPrePoint() const
G4ThreeVector GetPosCrystal()
G4double GetEdepCrystal()
G4ThreeVector GetMomentum()
G4int GetNumThetaCrystal()
G4ThreeVector GetMomentum()
std::vector< BesTruthVertex * > * GetVertexList()
std::vector< BesTruthTrack * > * GetTrackList()
static BesSensitiveManager * GetSensitiveManager()
G4ThreeVector GetMomentum()
HepLorentzVector GetP4() const
BesTruthVertex * GetTerminalVertex() const
BesTruthVertex * GetVertex() const
G4double GetPDGCharge() const
vector< int > GetDaughterIndexes() const
BesTruthTrack * GetParentTrack() const
G4ThreeVector GetPosition() const
std::vector< CgemDigiType > digiCol
std::vector< CgemHitType > hitCol
std::vector< CgemTruthType > truthCol
std::vector< EmcDigiType > digiCol
std::vector< EmcTruthType > truthCol
std::vector< MdcDigiType > digiCol
std::vector< MdcHitType > hitCol
std::vector< MdcTruthType > truthCol
std::vector< MucDigiType > digiCol
std::vector< MucTruthType > truthCol
std::vector< TofDigiType > digiCol
std::vector< TofTruthType > truthCol
std::vector< TrackTruthType > truthCol
std::vector< VertexTruthType > truthCol