14 #include <Geant4/G4IonisParamMat.hh>
15 #include <Geant4/G4Material.hh>
16 #include <Geant4/G4MaterialCutsCouple.hh>
17 #include <Geant4/G4ParticleDefinition.hh>
18 #include <Geant4/G4ReferenceCountedHandle.hh>
19 #include <Geant4/G4Step.hh>
20 #include <Geant4/G4StepStatus.hh>
21 #include <Geant4/G4String.hh>
22 #include <Geant4/G4SystemOfUnits.hh>
23 #include <Geant4/G4ThreeVector.hh>
24 #include <Geant4/G4TouchableHandle.hh>
25 #include <Geant4/G4Track.hh>
26 #include <Geant4/G4VSolid.hh>
27 #include <Geant4/G4TrackStatus.hh>
28 #include <Geant4/G4Types.hh>
29 #include <Geant4/G4VPhysicalVolume.hh>
30 #include <Geant4/G4VTouchable.hh>
31 #include <Geant4/G4VUserTrackInformation.hh>
32 #include <Geant4/G4VSensitiveDetector.hh>
33 #include <Geant4/G4OpticalPhoton.hh>
34 #include <Geant4/G4Scintillation.hh>
35 #include <Geant4/G4Cerenkov.hh>
37 #include <boost/tokenizer.hpp>
41 #include <boost/version.hpp>
42 #if (__GNUC__ == 4 && __GNUC_MINOR__ == 4 && BOOST_VERSION == 105700)
43 #pragma GCC diagnostic ignored "-Wuninitialized"
44 #pragma message "ignoring bogus gcc warning in boost header lexical_cast.hpp"
45 #include <boost/lexical_cast.hpp>
46 #pragma GCC diagnostic warning "-Wuninitialized"
48 #include <boost/lexical_cast.hpp>
63 , absorberhits_(nullptr)
64 , hitcontainer(nullptr)
71 , absorbertruth(absorberactive)
72 , light_scint_model(1)
88 G4TouchableHandle touch = aStep->GetPreStepPoint()->GetTouchableHandle();
90 G4VPhysicalVolume*
volume = touch->GetVolume();
145 G4double edep = aStep->GetTotalEnergyDeposit() /
GeV;
146 G4double eion = (aStep->GetTotalEnergyDeposit() - aStep->GetNonIonizingEnergyDeposit()) /
GeV;
147 G4double light_yield = 0;
150 const G4Track* aTrack = aStep->GetTrack();
155 edep = aTrack->GetKineticEnergy() /
GeV;
156 G4Track* killtrack =
const_cast<G4Track*
>(aTrack);
157 killtrack->SetTrackStatus(fStopAndKill);
165 bool geantino =
false;
166 if (aTrack->GetParticleDefinition()->GetPDGEncoding() == 0 &&
167 aTrack->GetParticleDefinition()->GetParticleName().find(
"geantino") != string::npos)
173 G4StepPoint* prePoint = aStep->GetPreStepPoint();
174 G4StepPoint* postPoint = aStep->GetPostStepPoint();
177 switch (prePoint->GetStepStatus())
196 hit->
set_x(0, prePoint->GetPosition().x() /
cm);
197 hit->
set_y(0, prePoint->GetPosition().y() /
cm);
198 hit->
set_z(0, prePoint->GetPosition().z() /
cm);
201 hit->
set_t(0, prePoint->GetGlobalTime() / nanosecond);
221 if (G4VUserTrackInformation*
p = aTrack->GetUserInformation())
240 static bool once =
true;
241 if (once && edep > 0)
247 cout <<
"PHG4ForwardDualReadoutSteppingAction::UserSteppingAction::"
250 <<
" use scintillating light model at each Geant4 steps. "
253 << aTrack->GetMaterialCutsCouple()->GetMaterial()->GetName()
255 <<
"Birk Constant = "
256 << aTrack->GetMaterialCutsCouple()->GetMaterial()->GetIonisation()->GetBirksConstant()
258 <<
"edep = " << edep <<
", "
261 <<
"light_yield = " << light_yield << endl;
276 float fNcerenkov = 0;
281 G4int fCerenkovSubType;
283 G4Scintillation scin;
284 fScinType = scin.GetProcessType();
285 fScinSubType = scin.GetProcessSubType();
287 fCerenkovType = cer.GetProcessType();
288 fCerenkovSubType = cer.GetProcessSubType();
297 if(aTrack->GetDynamicParticle()->GetParticleDefinition() == G4OpticalPhoton::OpticalPhotonDefinition())
302 G4int ptype = aTrack->GetCreatorProcess()->GetProcessType();
303 G4int pstype = aTrack->GetCreatorProcess()->GetProcessSubType();
306 G4Material* prevMaterial = aStep->GetPreStepPoint()->GetMaterial();
307 if((ptype == fScinType) && (pstype == fScinSubType) && (prevMaterial->GetName().find(
"G4_POLYSTYRENE") != std::string::npos)){ fNscin++;}
309 if( (ptype == fCerenkovType) && (pstype == fCerenkovSubType) && ((prevMaterial->GetName().find(
"PMMA") != std::string::npos) || (prevMaterial->GetName().find(
"Quartz") != std::string::npos))){ fNcerenkov++;}
355 hit->
set_x(1, postPoint->GetPosition().x() /
cm);
356 hit->
set_y(1, postPoint->GetPosition().y() /
cm);
357 hit->
set_z(1, postPoint->GetPosition().z() /
cm);
359 hit->
set_t(1, postPoint->GetGlobalTime() / nanosecond);
380 if (G4VUserTrackInformation*
p = aTrack->GetUserInformation())
394 if (postPoint->GetStepStatus() == fGeomBoundary ||
395 postPoint->GetStepStatus() == fWorldBoundary ||
396 postPoint->GetStepStatus() == fAtRestDoItProc ||
397 aTrack->GetTrackStatus() == fStopAndKill)
431 std::string hitnodename;
432 std::string absorbernodename;
447 hits_ = findNode::getClass<PHG4HitContainer>(topNode, hitnodename);
448 absorberhits_ = findNode::getClass<PHG4HitContainer>(topNode, absorbernodename);
453 std::cout <<
"PHG4ForwardDualReadoutSteppingAction::SetTopNode - unable to find " << hitnodename << std::endl;
459 cout <<
"PHG4ForwardDualReadoutSteppingAction::SetTopNode - unable to find " << absorbernodename << endl;
489 G4VPhysicalVolume* tower = touch->GetVolume(1);
501 boost::char_separator<char> sep(
"_");
502 boost::tokenizer<boost::char_separator<char> > tok(volume->GetName(), sep);
503 boost::tokenizer<boost::char_separator<char> >::const_iterator tokeniter;
504 for (tokeniter = tok.begin(); tokeniter != tok.end(); ++tokeniter)
506 if (*tokeniter ==
"j")
509 if (tokeniter == tok.end())
break;
510 j = boost::lexical_cast<
int>(*tokeniter);
512 else if (*tokeniter ==
"k")
515 if (tokeniter == tok.end())
break;
516 k = boost::lexical_cast<
int>(*tokeniter);