10#include "BesMdcHit.hh"
11#include "BesMdcDigi.hh"
12#include "BesTofHit.hh"
13#include "BesTofDigi.hh"
14#include "BesEmcHit.hh"
15#include "BesEmcDigi.hh"
16#include "BesMucHit.hh"
17#include "BesMucDigi.hh"
18#include "BesEventAction.hh"
19#include "G4RunManager.hh"
20#include "BesTruthTrack.hh"
21#include "BesTruthVertex.hh"
22#include "BesSensitiveManager.hh"
23#include "G4HCofThisEvent.hh"
24#include "G4SDManager.hh"
25#include "G4PrimaryVertex.hh"
26#include "G4PrimaryParticle.hh"
28#include "BesAsciiIO.hh"
29#include "AsciiDmp/dmplib.hh"
30#include "G4DigiManager.hh"
34#include "GaudiKernel/IDataProviderSvc.h"
35#include "GaudiKernel/ISvcLocator.h"
36#include "GaudiKernel/Bootstrap.h"
37#include "GaudiKernel/RegistryEntry.h"
38#include "GaudiKernel/MsgStream.h"
39#include "GaudiKernel/SmartDataPtr.h"
40#include "McTruth/DecayMode.h"
43 G4int mdcTruFlag,G4int mdcDigiFlag,
44 G4int tofTruFlag, G4int tofDigiFlag,
45 G4int emcTruFlag, G4int emcDigiFlag,
46 G4int mucTruFlag, G4int mucDigiFlag,
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),
54 m_DigiMan = G4DigiManager::GetDMpointer();
126 if(evt->GetEventID()==0)
128 os.open(m_asciiFile);
136 os.open(m_asciiFile,ios::out|ios::app);
142 std::cerr <<
"wrong tag, got " << ex.
got()
146 std::cerr <<
"AsciiDumpException was caught!" << std::endl;
155 ISvcLocator* svcLocator = Gaudi::svcLocator();
156 IDataProviderSvc* evtSvc;
157 StatusCode sc=svcLocator->service(
"EventDataSvc", evtSvc);
159 G4cout<<
"Could not accesss EventDataSvc!"<<G4endl;
161 SmartDataPtr<DecayMode> decayMode(evtSvc,
"/Event/MC/DecayMode");
164 for(
int i=0;i<10;i++)
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++)
181 vector<BesTruthTrack*>* trackList = sensitiveManager->
GetTrackList();
184 G4int nTrack = trackList->size();
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())
190 track=(*trackList)[i];
191 (*trackList)[i]=(*trackList)[j];
192 (*trackList)[j]=track;
195 for(
int i=0;i<nTrack;i++)
201 G4cout<<
"trackIndex<0!"<<G4endl;
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.;
237 vector<BesTruthVertex*>* vertexList = sensitiveManager->
GetVertexList();
239 G4int nVertex = vertexList->size();
241 for(
int i=0;i<nVertex;i++)
244 vertex = (*vertexList) [i];
263 HCID = m_DigiMan->GetHitsCollectionID(
"BesMdcTruthCollection");
268 G4int n_hit = HC->entries();
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())
279 (*vecHC)[i] = (*vecHC)[j];
283 for(G4int i=0;i<n_hit;i++)
307 HCID = m_DigiMan->GetHitsCollectionID(
"BesTofHitsList");
312 G4int n_hit = HC->entries();
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())
323 (*vecHC)[i] = (*vecHC)[j];
327 for(G4int i=0;i<n_hit;i++)
353 HCID = m_DigiMan->GetHitsCollectionID(
"BesEmcHitsList");
358 G4int n_hit = HC->entries();
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())
369 (*vecHC)[i] = (*vecHC)[j];
373 for(G4int i=0;i<n_hit;i++)
399 HCID = m_DigiMan->GetHitsCollectionID(
"BesMucHitsList");
404 G4int n_hit = HC->entries();
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())
415 (*vecHC)[i] = (*vecHC)[j];
419 for(G4int i=0;i<n_hit;i++)
443 G4int mdcDigiCollID = -1;
444 mdcDigiCollID = m_DigiMan->GetDigiCollectionID(
"BesMdcDigisCollection");
445 if(mdcDigiCollID>=0){
447 G4int nDigi = mdcDC->entries();
451 for(
int i=0;i<nDigi;i++)
471 G4int tofDigiCollID = -1;
472 tofDigiCollID = m_DigiMan->GetDigiCollectionID(
"BesTofDigitsCollection");
477 G4int nDigi = tofDC->entries();
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())
488 (*vecDC)[i] = (*vecDC)[j];
492 for(
int i=0;i<nDigi;i++)
513 G4int emcDigiCollID = -1;
514 emcDigiCollID = m_DigiMan->GetDigiCollectionID(
"BesEmcDigitsCollection");
518 G4int nDigi = emcDC->entries();
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())
529 (*vecDC)[i] = (*vecDC)[j];
532 for(
int i=0;i<nDigi;i++)
551 G4int mucDigiCollID =-1;
552 mucDigiCollID = m_DigiMan->GetDigiCollectionID(
"BesMucDigisCollection");
556 G4int nDigi = mucDC->entries();
559 for(
int i = 0; i < nDigi; i++)
562 mucDigi = (*mucDC)[i];
641 if(evt->GetEventID()==0){
642 os.open(m_asciiFile);
650 os.open(m_asciiFile,ios::out|ios::app);
655 std::cerr <<
"wrong tag, got " << ex.
got()
659 std::cerr <<
"AsciiDumpException was caught!" << std::endl;
669 ISvcLocator* svcLocator = Gaudi::svcLocator();
670 IDataProviderSvc* evtSvc;
671 StatusCode sc=svcLocator->service(
"EventDataSvc", evtSvc);
673 G4cout<<
"Could not accesss EventDataSvc!"<<G4endl;
675 SmartDataPtr<DecayMode> decayMode(evtSvc,
"/Event/MC/DecayMode");
678 for(
int i=0;i<10;i++)
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++)
695 vector<BesTruthTrack*>* trackList = sensitiveManager->
GetTrackList();
698 G4int nTrack = trackList->size();
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())
704 track=(*trackList)[i];
705 (*trackList)[i]=(*trackList)[j];
706 (*trackList)[j]=track;
709 for(
int i=0;i<nTrack;i++)
721 trackTruth.
px = track->
GetP4().x();
722 trackTruth.
py = track->
GetP4().y();
723 trackTruth.
pz = track->
GetP4().z();
724 trackTruth.
E = track->
GetP4().t();
749 vector<BesTruthVertex*>* vertexList = sensitiveManager->
GetVertexList();
751 G4int nVertex = vertexList->size();
753 for(
int i=0;i<nVertex;i++)
756 vertex = (*vertexList) [i];
775 HCID = m_DigiMan->GetHitsCollectionID(
"BesMdcTruthCollection");
780 G4int n_hit = HC->entries();
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())
791 (*vecHC)[i] = (*vecHC)[j];
795 for(G4int i=0;i<n_hit;i++)
818 G4int mdcHitCollID = -1;
819 mdcHitCollID = m_DigiMan->GetHitsCollectionID(
"BesMdcHitsCollection");
823 G4int nHit = mdcDC->entries();
827 for(
int i=0;i<nHit;i++)
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
void SaveMdcHits(HitEVENT &)
void SaveMucDigits(EVENT &)
void SaveTrackTruth(EVENT &)
void SaveDecayMode(EVENT &)
BesAsciiIO(G4int, G4int, G4int, G4int, G4int, G4int, G4int, G4int, G4String)
void SaveMdcDigits(EVENT &)
void SaveMucTruth(EVENT &)
void SaveEmcDigits(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 *)
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< 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