34 #include "G4OpticalPhoton.hh"
35 #include "G4VProcess.hh"
38 #include "G4Threading.hh"
40 #ifdef G4MULTITHREADED
41 #include "G4AutoLock.hh"
42 namespace { G4Mutex buildMutex = G4MUTEX_INITIALIZER; }
46 SToGS::BaseROOTTreeRun(),
66 G4HCofThisEvent *HCE = evt->GetHCofThisEvent();
71 nb_hits_trac += THC->entries();
75 nb_hits_calo += CHC->entries();
77 nb_hits_tot = nb_hits_trac + nb_hits_calo;
81 G4int istart = 0, iend = evt->GetNumberOfPrimaryVertex();
82 G4int K = 0; G4double H = 0.0;
83 for( G4int i = istart; i < iend ; i++ ){
85 G4int jstart = 0, jend = evt->GetPrimaryVertex(i)->GetNumberOfParticle();
86 for( G4int j = jstart; j < jend; j++ ) {
91 G4PrimaryParticle *prim = evt->GetPrimaryVertex(i)->GetPrimary(j);
93 hit->
fE = (std::sqrt( prim->GetMomentum().mag2() + prim->GetMass() * prim->GetMass()) - prim->GetMass())/CLHEP::keV;
94 hit->
fX = prim->GetPx();
95 hit->
fY = prim->GetPy();
96 hit->
fZ = prim->GetPz();
98 hit->
fFlag = prim->GetTrackID()-1;
100 H += (std::sqrt( prim->GetMomentum().mag2() + prim->GetMass() * prim->GetMass()) - prim->GetMass())/CLHEP::MeV;
105 if ( nb_hits_trac ) {
106 int n_hit = nb_hits_trac;
109 for (
int i = 0 ; i < n_hit; i++) {
114 G4cout <<
" Cannot add more that " << i <<
" hits in the collection " << G4endl;
120 hit->
fE = (*THC)[i]->GetEdep()/CLHEP::keV;
121 hit->
fX = (*THC)[i]->GetPos().x()/CLHEP::cm;
122 hit->
fY = (*THC)[i]->GetPos().y()/CLHEP::cm;
123 hit->
fZ = (*THC)[i]->GetPos().z()/CLHEP::cm;
124 hit->
fT = (*THC)[i]->GetToF();
126 hit->
fFlag = (*THC)[i]->GetPrimaryID()-1 ;
127 hit->
fUID = (*THC)[i]->GetDetID();
129 H += (*THC)[i]->GetEdep()/CLHEP::MeV;
135 int n_hit = nb_hits_calo;
138 for (
int i = 0 ; i < n_hit; i++) {
142 G4cout <<
" Cannot add more that " << i <<
" hits in the collection " << G4endl;
147 hit->
fE = (*CHC)[i]->GetEdep()/CLHEP::keV;
148 hit->
fX = (*CHC)[i]->GetPos().x()/CLHEP::cm;
149 hit->
fY = (*CHC)[i]->GetPos().y()/CLHEP::cm;
150 hit->
fZ = (*CHC)[i]->GetPos().z()/CLHEP::cm;
151 hit->
fT = (*CHC)[i]->GetToF();
153 hit->
fFlag = (*CHC)[i]->GetNbHits() ;
154 hit->
fUID = (*CHC)[i]->GetDetID();
156 H += (*CHC)[i]->GetEdep()/CLHEP::MeV;
167 SToGS::BaseROOTTreeAction(conffile),
169 fOpticalEventBeg(0x0),
170 fOpticalEventEnd(0x0)
173 std::ifstream file(conffile.data());
174 if ( file.is_open() == false ) {
175 G4cout <<
" ** ParisUserAction WARNING ** Cannot open file " << conffile <<
", default parameters to be used "<< G4endl;
178 std::string aline; getline(file,aline);
179 while ( file.good() && !file.eof() ) {
181 if ( aline[0] ==
'#' ){
186 std::string key, what, option; std::istringstream decode(aline); decode.clear();
189 if ( key ==
"scintillation:" ) {
200 #ifdef G4MULTITHREADED
201 G4AutoLock lock(&buildMutex);
204 G4Run* therun = 0x0; G4cout <<
" In ParisUserAction, Generate a new Run " << G4endl;
206 if (
fTree == 0x0 ) {
208 fTree->SetDirectory(0x0);
221 if ( G4Threading::IsWorkerThread() ) {
226 else therun = G4UserRunAction::GenerateRun();
258 if(atrack->GetDefinition()==G4OpticalPhoton::OpticalPhotonDefinition()){
260 if(atrack->GetParentID()>0){
262 if(atrack->GetCreatorProcess()->GetProcessName()==
"Scintillation") {
266 G4int pid = atrack->GetTrackID();
273 hit->
fX = atrack->GetPosition().x();
274 hit->
fY = atrack->GetPosition().y();
275 hit->
fZ = atrack->GetPosition().z();
277 hit->
fTA = atrack->GetGlobalTime();
278 hit->
fTL = atrack->GetLocalTime();
280 hit->
fLength = atrack->GetTrackLength();
281 hit->
fNbSteps = atrack->GetCurrentStepNumber();
296 if(atrack->GetDefinition()==G4OpticalPhoton::OpticalPhotonDefinition()){
298 if(atrack->GetParentID()>0){
300 if(atrack->GetCreatorProcess()->GetProcessName()==
"Scintillation") {
304 G4int pid = atrack->GetTrackID();
311 hit->
fX = atrack->GetPosition().x();
312 hit->
fY = atrack->GetPosition().y();
313 hit->
fZ = atrack->GetPosition().z();
315 hit->
fTA = atrack->GetGlobalTime();
316 hit->
fTL = atrack->GetLocalTime();
318 hit->
fLength = atrack->GetTrackLength();
319 hit->
fNbSteps = atrack->GetCurrentStepNumber();
G4THitsCollection< TrackerHit > TrackerHitsCollection
virtual void PostUserTrackingAction(const G4Track *)
virtual void EndOfRunAction(const G4Run *)
POpticalEvent * fOpticalEventBeg
emitted optical photons
POpticalEvent * fOpticalEventEnd
end of optical photons
G4int fisOptical
true if one has also photons from scintillations
ParisEventRun(TTree *tree)
G4THitsCollection< CopClusterHit > CopClusterHitsCollection
virtual void EndOfRunAction(const G4Run *)
virtual void BeginOfEventAction(const G4Event *)
virtual G4Run * GenerateRun()
virtual void RecordEvent(const G4Event *evt)
void Clear(Option_t *opt)
clear the collection of hits, set H, K to 0
The ParisEventRun has the charge to fill Paris Event from the SToGS G4 hit collections.
void Clear(Option_t *opt)
TTree * fTree
the Tree to be filled
ParisUserAction(G4String conffile="setup/paris_actions.conf")
POpticalHit * AddHit()
add a hit to the current event
PHit * AddHit()
add a hit to the current event
void SetHK(Double_t h, Int_t k)
virtual void BeginOfEventAction(const G4Event *)
virtual void PreUserTrackingAction(const G4Track *)