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 #include <boost/io/ios_state.hpp>
49 , m_Detector(detector)
50 , m_Params(parameters)
51 , m_HitContainer(nullptr)
53 , m_SaveShower(nullptr)
54 , m_SaveVolPre(nullptr)
55 , m_SaveVolPost(nullptr)
56 , m_SaveLightYieldFlag(m_Params->get_int_param(
"lightyield"))
58 , m_SavePreStepStatus(-1)
59 , m_SavePostStepStatus(-1)
60 , m_ActiveFlag(m_Params->get_int_param(
"active"))
61 , m_BlackHoleFlag(m_Params->get_int_param(
"blackhole"))
62 , m_UseG4StepsFlag(m_Params->get_int_param(
"use_g4steps"))
63 , m_Zmin(m_Params->get_double_param(
"place_z") *
cm - m_Params->get_double_param(
"length") *
cm / 2.)
64 , m_Zmax(m_Params->get_double_param(
"place_z") *
cm + m_Params->get_double_param(
"length") *
cm / 2.)
65 , m_Tmin(m_Params->get_double_param(
"tmin") *
ns)
66 , m_Tmax(m_Params->get_double_param(
"tmax") *
ns)
86 G4TouchableHandle touch = aStep->GetPreStepPoint()->GetTouchableHandle();
87 G4TouchableHandle touchpost = aStep->GetPostStepPoint()->GetTouchableHandle();
89 G4VPhysicalVolume*
volume = touch->GetVolume();
98 G4double edep = aStep->GetTotalEnergyDeposit() /
GeV;
100 const G4Track* aTrack = aStep->GetTrack();
105 if ((!std::isfinite(
m_Tmin) && !std::isfinite(
m_Tmax)) ||
106 aTrack->GetGlobalTime() <
m_Tmin ||
107 aTrack->GetGlobalTime() >
m_Tmax)
109 edep = aTrack->GetKineticEnergy() /
GeV;
110 G4Track* killtrack =
const_cast<G4Track*
>(aTrack);
111 killtrack->SetTrackStatus(fStopAndKill);
119 bool geantino =
false;
123 if (aTrack->GetParticleDefinition()->GetPDGEncoding() == 0 &&
124 aTrack->GetParticleDefinition()->GetParticleName().find(
"geantino") != std::string::npos)
128 G4StepPoint* prePoint = aStep->GetPreStepPoint();
129 G4StepPoint* postPoint = aStep->GetPostStepPoint();
135 int prepointstatus = prePoint->GetStepStatus();
136 if (prepointstatus == fGeomBoundary ||
137 prepointstatus == fUndefined ||
143 std::cout <<
GetName() <<
": New Hit for " << std::endl;
149 <<
", current trackid: " << aTrack->GetTrackID() << std::endl;
150 std::cout <<
"phys pre vol: " << volume->GetName()
151 <<
" post vol : " << touchpost->GetVolume()->GetName() << std::endl;
152 std::cout <<
" previous phys pre vol: " <<
m_SaveVolPre->GetName()
153 <<
" previous phys post vol: " <<
m_SaveVolPost->GetName() << std::endl;
173 m_Hit->
set_t(0, prePoint->GetGlobalTime() / nanosecond);
187 if (G4VUserTrackInformation*
p = aTrack->GetUserInformation())
199 boost::io::ios_precision_saver ips(std::cout);
201 <<
" PHG4CylinderSteppingAction: Entry hit z " <<
m_Hit->
get_z(0) *
cm
202 <<
" outside acceptance, zmin " <<
m_Zmin
203 <<
", zmax " <<
m_Zmax <<
", layer: " << layer_id << std::endl;
213 std::cout <<
GetName() <<
": hit was not created" << std::endl;
219 <<
", current trackid: " << aTrack->GetTrackID() << std::endl;
220 std::cout <<
"phys pre vol: " << volume->GetName()
221 <<
" post vol : " << touchpost->GetVolume()->GetName() << std::endl;
222 std::cout <<
" previous phys pre vol: " <<
m_SaveVolPre->GetName()
223 <<
" previous phys post vol: " <<
m_SaveVolPost->GetName() << std::endl;
230 std::cout <<
"hits do not belong to the same track" << std::endl;
232 <<
", current trackid: " << aTrack->GetTrackID()
249 m_Hit->
set_t(1, postPoint->GetGlobalTime() / nanosecond);
255 <<
" PHG4CylinderSteppingAction: Exit hit z " <<
m_Hit->
get_z(1) *
cm
256 <<
" outside acceptance zmin " <<
m_Zmin
257 <<
", zmax " <<
m_Zmax <<
", layer: " << layer_id << std::endl;
267 double eion = edep - aStep->GetNonIonizingEnergyDeposit() /
GeV;
278 if (G4VUserTrackInformation*
p = aTrack->GetUserInformation())
294 if (postPoint->GetStepStatus() == fGeomBoundary ||
295 postPoint->GetStepStatus() == fWorldBoundary ||
296 postPoint->GetStepStatus() == fAtRestDoItProc ||
297 aTrack->GetTrackStatus() == fStopAndKill ||
339 std::cout <<
"PHG4CylinderSteppingAction::SetTopNode - unable to find " <<
m_HitNodeName << std::endl;