10 #include <phparameter/PHParameters.h>
25 #include <Geant4/G4ParticleDefinition.hh>
26 #include <Geant4/G4ReferenceCountedHandle.hh>
27 #include <Geant4/G4Step.hh>
28 #include <Geant4/G4StepPoint.hh>
29 #include <Geant4/G4StepStatus.hh>
30 #include <Geant4/G4String.hh>
31 #include <Geant4/G4SystemOfUnits.hh>
32 #include <Geant4/G4ThreeVector.hh>
33 #include <Geant4/G4TouchableHandle.hh>
34 #include <Geant4/G4Track.hh>
35 #include <Geant4/G4TrackStatus.hh>
36 #include <Geant4/G4Types.hh>
37 #include <Geant4/G4VPhysicalVolume.hh>
38 #include <Geant4/G4VTouchable.hh>
39 #include <Geant4/G4VUserTrackInformation.hh>
50 , m_Detector(detector)
51 , m_Params(parameters)
52 , m_ActiveFlag(m_Params->get_int_param(
"active"))
53 , m_BlackHoleFlag(m_Params->get_int_param(
"blackhole"))
60 G4TouchableHandle touch = aStep->GetPreStepPoint()->GetTouchableHandle();
61 G4TouchableHandle touchpost = aStep->GetPostStepPoint()->GetTouchableHandle();
64 G4VPhysicalVolume *
volume = touch->GetVolume();
68 G4double edep = aStep->GetTotalEnergyDeposit() /
GeV;
69 G4double eion = (aStep->GetTotalEnergyDeposit() - aStep->GetNonIonizingEnergyDeposit()) /
GeV;
70 const G4Track *aTrack = aStep->GetTrack();
75 edep = aTrack->GetKineticEnergy() /
GeV;
76 auto killtrack =
const_cast<G4Track *
>(aTrack);
77 killtrack->SetTrackStatus(fStopAndKill);
81 aTrack->GetParticleDefinition()->GetPDGEncoding() == 0 &&
82 aTrack->GetParticleDefinition()->GetParticleName().find(
"geantino") != std::string::npos;
84 G4StepPoint *prePoint = aStep->GetPreStepPoint();
85 G4StepPoint *postPoint = aStep->GetPostStepPoint();
98 switch (prePoint->GetStepStatus())
101 case fPostStepDoItProc:
107 std::cout <<
"PHG4MicromegasSteppingAction::UserSteppingAction - " <<
GetName() <<
": New Hit for " << std::endl;
114 std::cout <<
"last track: " <<
m_SaveTrackId <<
", current trackid: " << aTrack->GetTrackID() << std::endl;
115 std::cout <<
"phys pre vol: " << volume->GetName() <<
" post vol : " << touchpost->GetVolume()->GetName() << std::endl;
116 std::cout <<
" previous phys pre vol: " <<
m_SaveVolPre->GetName() <<
" previous phys post vol: " <<
m_SaveVolPost->GetName() << std::endl;
130 m_hit->set_x(0, prePoint->GetPosition().x() /
cm);
131 m_hit->set_y(0, prePoint->GetPosition().y() /
cm);
132 m_hit->set_z(0, prePoint->GetPosition().z() /
cm);
135 m_hit->set_px(0, prePoint->GetMomentum().x() /
GeV);
136 m_hit->set_py(0, prePoint->GetMomentum().y() /
GeV);
137 m_hit->set_pz(0, prePoint->GetMomentum().z() /
GeV);
140 m_hit->set_t(0, prePoint->GetGlobalTime() / nanosecond);
143 m_hit->set_trkid(aTrack->GetTrackID());
154 if (G4VUserTrackInformation *
p = aTrack->GetUserInformation())
158 m_hit->set_trkid(pp->GetUserTrackId());
169 if (!
m_hit || !std::isfinite(
m_hit->get_x(0)))
171 std::cout <<
GetName() <<
": hit was not created" << std::endl;
177 std::cout <<
"last track: " <<
m_SaveTrackId <<
", current trackid: " << aTrack->GetTrackID() << std::endl;
178 std::cout <<
"phys pre vol: " << volume->GetName() <<
" post vol : " << touchpost->GetVolume()->GetName() << std::endl;
179 std::cout <<
" previous phys pre vol: " <<
m_SaveVolPre->GetName() <<
" previous phys post vol: " <<
m_SaveVolPost->GetName() << std::endl;
188 std::cout <<
GetName() <<
": hits do not belong to the same track" << std::endl;
190 <<
", current trackid: " << aTrack->GetTrackID()
191 <<
", prestep status: " << prePoint->GetStepStatus()
219 if (postPoint->GetStepStatus() == fGeomBoundary ||
220 postPoint->GetStepStatus() == fWorldBoundary ||
221 postPoint->GetStepStatus() == fAtRestDoItProc ||
222 aTrack->GetTrackStatus() == fStopAndKill)
229 m_hit->set_x(1, postPoint->GetPosition().x() /
cm);
230 m_hit->set_y(1, postPoint->GetPosition().y() /
cm);
231 m_hit->set_z(1, postPoint->GetPosition().z() /
cm);
233 m_hit->set_px(1, postPoint->GetMomentum().x() /
GeV);
234 m_hit->set_py(1, postPoint->GetMomentum().y() /
GeV);
235 m_hit->set_pz(1, postPoint->GetMomentum().z() /
GeV);
237 m_hit->set_t(1, postPoint->GetGlobalTime() / nanosecond);
238 if (G4VUserTrackInformation *
p = aTrack->GetUserInformation())
278 m_hitContainer = findNode::getClass<PHG4HitContainer>(topNode, hitnodename);
279 if (!
m_hitContainer) std::cout <<
"PHG4MicromegasSteppingAction::SetTopNode - unable to find " << hitnodename << std::endl;