24 #include <phparameter/PHParameters.h>
40 #include <Geant4/G4NavigationHistory.hh>
41 #include <Geant4/G4ParticleDefinition.hh>
42 #include <Geant4/G4ReferenceCountedHandle.hh>
43 #include <Geant4/G4Step.hh>
44 #include <Geant4/G4StepPoint.hh>
45 #include <Geant4/G4StepStatus.hh>
46 #include <Geant4/G4String.hh>
47 #include <Geant4/G4SystemOfUnits.hh>
48 #include <Geant4/G4ThreeVector.hh>
49 #include <Geant4/G4TouchableHandle.hh>
50 #include <Geant4/G4Track.hh>
51 #include <Geant4/G4TrackStatus.hh>
52 #include <Geant4/G4Types.hh>
53 #include <Geant4/G4VPhysicalVolume.hh>
54 #include <Geant4/G4VTouchable.hh>
55 #include <Geant4/G4VUserTrackInformation.hh>
69 , m_Detector(detector)
70 , m_Params(parameters)
71 , m_HitContainerCAL(nullptr)
72 , m_HitContainerTracking(nullptr)
73 , m_HitContainerVirt(nullptr)
75 , m_SaveShower(nullptr)
76 , m_SaveVolPre(nullptr)
77 , m_SaveVolPost(nullptr)
78 , m_SaveLightYieldFlag(m_Params->get_int_param(
"lightyield"))
80 , m_SavePreStepStatus(-1)
81 , m_SavePostStepStatus(-1)
82 , m_ActiveFlag(m_Params->get_int_param(
"active"))
83 , m_BlackHoleFlag(m_Params->get_int_param(
"blackhole"))
84 , m_UseG4StepsFlag(m_Params->get_int_param(
"use_g4steps"))
85 , m_Tmin(m_Params->get_double_param(
"tmin") *
ns)
86 , m_Tmax(m_Params->get_double_param(
"tmax") *
ns)
106 G4TouchableHandle touch = aStep->GetPreStepPoint()->GetTouchableHandle();
107 G4TouchableHandle touchpost = aStep->GetPostStepPoint()->GetTouchableHandle();
111 G4VPhysicalVolume *
volume = touch->GetVolume();
112 G4LogicalVolume *volumeLogical = volume->GetLogicalVolume();
113 G4Material *mat = volumeLogical->GetMaterial();
117 int trackingMaterial = (mat->GetName().compareTo(
"G4_Si")==0) ? 1 : 0;
119 if ( !activeMaterial && !virtualMaterial )
124 G4double edep = aStep->GetTotalEnergyDeposit() /
GeV;
125 G4double eion = (aStep->GetTotalEnergyDeposit() - aStep->GetNonIonizingEnergyDeposit()) /
GeV;
126 const G4Track *aTrack = aStep->GetTrack();
137 if ((!std::isfinite(
m_Tmin) && !std::isfinite(
m_Tmax)) ||
138 aTrack->GetGlobalTime() <
m_Tmin ||
139 aTrack->GetGlobalTime() >
m_Tmax)
141 edep = aTrack->GetKineticEnergy() /
GeV;
142 G4Track *killtrack =
const_cast<G4Track *
>(aTrack);
143 killtrack->SetTrackStatus(fStopAndKill);
149 int layer_id = volume->GetCopyNo();
159 bool geantino =
false;
161 if (aTrack->GetParticleDefinition()->GetPDGEncoding() == 0 &&
162 aTrack->GetParticleDefinition()->GetParticleName().find(
"geantino") !=
167 G4StepPoint *prePoint = aStep->GetPreStepPoint();
168 G4StepPoint *postPoint = aStep->GetPostStepPoint();
170 switch (prePoint->GetStepStatus())
172 case fPostStepDoItProc:
183 std::cout <<
GetName() <<
": New Hit for " << std::endl;
184 std::cout <<
"prestep status: "
186 <<
", poststep status: "
188 <<
", last pre step status: "
190 <<
", last post step status: "
193 <<
", current trackid: " << aTrack->GetTrackID() << std::endl;
194 std::cout <<
"phys pre vol: " << volume->GetName()
195 <<
" post vol : " << touchpost->GetVolume()->GetName() << std::endl;
196 std::cout <<
" previous phys pre vol: " <<
m_SaveVolPre->GetName()
197 <<
" previous phys post vol: " <<
m_SaveVolPost->GetName() << std::endl;
219 m_Hit->
set_t(0, prePoint->GetGlobalTime() / nanosecond);
243 if (G4VUserTrackInformation *
p = aTrack->GetUserInformation())
255 <<
" PHG4CylinderSteppingAction: Entry hit z " <<
m_Hit->
get_z(0) *
cm
256 <<
" outside acceptance, zmin " <<
m_Zmin
257 <<
", zmax " <<
m_Zmax <<
", layer: " << layer_id << std::endl;
266 std::cout <<
GetName() <<
": hit was not created" << std::endl;
267 std::cout <<
"prestep status: "
269 <<
", poststep status: "
271 <<
", last pre step status: "
273 <<
", last post step status: "
276 <<
", current trackid: " << aTrack->GetTrackID() << std::endl;
277 std::cout <<
"phys pre vol: " << volume->GetName()
278 <<
" post vol : " << touchpost->GetVolume()->GetName() << std::endl;
279 std::cout <<
" previous phys pre vol: " <<
m_SaveVolPre->GetName()
280 <<
" previous phys post vol: " <<
m_SaveVolPost->GetName() << std::endl;
288 std::cout <<
GetName() <<
": hits do not belong to the same track" << std::endl;
290 <<
", current trackid: " << aTrack->GetTrackID()
291 <<
", prestep status: " << prePoint->GetStepStatus()
310 m_Hit->
set_t(1, postPoint->GetGlobalTime() / nanosecond);
317 <<
" PHG4CylinderSteppingAction: Exit hit z " <<
m_Hit->
get_z(1) *
cm
318 <<
" outside acceptance zmin " <<
m_Zmin
319 <<
", zmax " <<
m_Zmax <<
", layer: " << layer_id << std::endl;
340 if (G4VUserTrackInformation*
p = aTrack->GetUserInformation())
349 if (postPoint->GetStepStatus() == fGeomBoundary ||
350 postPoint->GetStepStatus() == fWorldBoundary ||
351 postPoint->GetStepStatus() == fAtRestDoItProc ||
352 aTrack->GetTrackStatus() == fStopAndKill ||
362 if( trackingMaterial ) {
369 if( virtualMaterial )
403 std::cout <<
PHWHERE <<
" EICG4LumiSteppingAction::SetTopNode - unable to find "
408 if (!m_HitContainerTracking)
410 std::cout <<
PHWHERE <<
" EICG4LumiSteppingAction::SetTopNode - unable to find "
415 if (!m_HitContainerVirt)
417 std::cout <<
PHWHERE <<
" EICG4LumiSteppingAction::SetTopNode - unable to find "