7 #include <phparameter/PHParameters.h>
19 #include <Geant4/G4ParticleDefinition.hh>
20 #include <Geant4/G4ReferenceCountedHandle.hh>
21 #include <Geant4/G4Step.hh>
22 #include <Geant4/G4StepPoint.hh>
23 #include <Geant4/G4StepStatus.hh>
24 #include <Geant4/G4String.hh>
25 #include <Geant4/G4SystemOfUnits.hh>
26 #include <Geant4/G4ThreeVector.hh>
27 #include <Geant4/G4TouchableHandle.hh>
28 #include <Geant4/G4Track.hh>
29 #include <Geant4/G4TrackStatus.hh>
30 #include <Geant4/G4Types.hh>
31 #include <Geant4/G4VPhysicalVolume.hh>
32 #include <Geant4/G4VTouchable.hh>
33 #include <Geant4/G4VUserTrackInformation.hh>
35 #pragma GCC diagnostic push
36 #pragma GCC diagnostic ignored "-Wshadow"
37 #include <boost/io/ios_state.hpp>
38 #pragma GCC diagnostic pop
52 , m_Detector(detector)
53 , m_Params(parameters)
54 , m_HitContainer(nullptr)
56 , m_SaveShower(nullptr)
57 , m_SaveVolPre(nullptr)
58 , m_SaveVolPost(nullptr)
59 , m_SaveLightYieldFlag(m_Params->get_int_param(
"lightyield"))
61 , m_SavePreStepStatus(-1)
62 , m_SavePostStepStatus(-1)
63 , m_ActiveFlag(m_Params->get_int_param(
"active"))
64 , m_BlackHoleFlag(m_Params->get_int_param(
"blackhole"))
65 , m_UseG4StepsFlag(m_Params->get_int_param(
"use_g4steps"))
66 , m_Zmin(m_Params->get_double_param(
"place_z") *
cm - m_Params->get_double_param(
"length") *
cm / 2.)
67 , m_Zmax(m_Params->get_double_param(
"place_z") *
cm + m_Params->get_double_param(
"length") *
cm / 2.)
68 , m_Tmin(m_Params->get_double_param(
"tmin") *
ns)
69 , m_Tmax(m_Params->get_double_param(
"tmax") *
ns)
89 G4TouchableHandle touch = aStep->GetPreStepPoint()->GetTouchableHandle();
90 G4TouchableHandle touchpost = aStep->GetPostStepPoint()->GetTouchableHandle();
101 G4double edep = aStep->GetTotalEnergyDeposit() /
GeV;
103 const G4Track* aTrack = aStep->GetTrack();
108 if ((!std::isfinite(
m_Tmin) && !std::isfinite(
m_Tmax)) ||
109 aTrack->GetGlobalTime() <
m_Tmin ||
110 aTrack->GetGlobalTime() >
m_Tmax)
112 edep = aTrack->GetKineticEnergy() /
GeV;
113 G4Track* killtrack =
const_cast<G4Track*
>(aTrack);
114 killtrack->SetTrackStatus(fStopAndKill);
122 bool geantino =
false;
126 if (aTrack->GetParticleDefinition()->GetPDGEncoding() == 0 &&
127 aTrack->GetParticleDefinition()->GetParticleName().find(
"geantino") != std::string::npos)
131 G4StepPoint* prePoint = aStep->GetPreStepPoint();
132 G4StepPoint* postPoint = aStep->GetPostStepPoint();
138 int prepointstatus = prePoint->GetStepStatus();
139 if (prepointstatus == fGeomBoundary ||
140 prepointstatus == fUndefined ||
146 std::cout <<
GetName() <<
": New Hit for " << std::endl;
152 <<
", current trackid: " << aTrack->GetTrackID() << std::endl;
153 std::cout <<
"phys pre vol: " << volume->GetName()
154 <<
" post vol : " << touchpost->GetVolume()->GetName() << std::endl;
155 std::cout <<
" previous phys pre vol: " <<
m_SaveVolPre->GetName()
156 <<
" previous phys post vol: " <<
m_SaveVolPost->GetName() << std::endl;
176 m_Hit->
set_t(0, prePoint->GetGlobalTime() / nanosecond);
190 if (G4VUserTrackInformation*
p = aTrack->GetUserInformation())
202 boost::io::ios_precision_saver ips(std::cout);
204 <<
" PHG4CylinderSteppingAction: Entry hit z " <<
m_Hit->
get_z(0) *
cm
205 <<
" outside acceptance, zmin " <<
m_Zmin
206 <<
", zmax " <<
m_Zmax <<
", layer: " << layer_id << std::endl;
216 std::cout <<
GetName() <<
": hit was not created" << std::endl;
222 <<
", current trackid: " << aTrack->GetTrackID() << std::endl;
223 std::cout <<
"phys pre vol: " << volume->GetName()
224 <<
" post vol : " << touchpost->GetVolume()->GetName() << std::endl;
225 std::cout <<
" previous phys pre vol: " <<
m_SaveVolPre->GetName()
226 <<
" previous phys post vol: " <<
m_SaveVolPost->GetName() << std::endl;
233 std::cout <<
"hits do not belong to the same track" << std::endl;
235 <<
", current trackid: " << aTrack->GetTrackID()
252 m_Hit->
set_t(1, postPoint->GetGlobalTime() / nanosecond);
258 <<
" PHG4CylinderSteppingAction: Exit hit z " <<
m_Hit->
get_z(1) *
cm
259 <<
" outside acceptance zmin " <<
m_Zmin
260 <<
", zmax " <<
m_Zmax <<
", layer: " << layer_id << std::endl;
270 double eion = edep - aStep->GetNonIonizingEnergyDeposit() /
GeV;
281 if (G4VUserTrackInformation*
p = aTrack->GetUserInformation())
297 if (postPoint->GetStepStatus() == fGeomBoundary ||
298 postPoint->GetStepStatus() == fWorldBoundary ||
299 postPoint->GetStepStatus() == fAtRestDoItProc ||
300 aTrack->GetTrackStatus() == fStopAndKill ||
342 std::cout <<
"PHG4CylinderSteppingAction::SetTopNode - unable to find " <<
m_HitNodeName << std::endl;