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"))
61 G4TouchableHandle touch = aStep->GetPreStepPoint()->GetTouchableHandle();
62 G4TouchableHandle touchpost = aStep->GetPostStepPoint()->GetTouchableHandle();
73 G4double edep = aStep->GetTotalEnergyDeposit() /
GeV;
74 G4double eion = (aStep->GetTotalEnergyDeposit() - aStep->GetNonIonizingEnergyDeposit()) /
GeV;
75 const G4Track *aTrack = aStep->GetTrack();
80 edep = aTrack->GetKineticEnergy() /
GeV;
81 auto killtrack =
const_cast<G4Track *
>(aTrack);
82 killtrack->SetTrackStatus(fStopAndKill);
86 aTrack->GetParticleDefinition()->GetPDGEncoding() == 0 &&
87 aTrack->GetParticleDefinition()->GetParticleName().find(
"geantino") != std::string::npos;
89 G4StepPoint *prePoint = aStep->GetPreStepPoint();
90 G4StepPoint *postPoint = aStep->GetPostStepPoint();
103 switch (prePoint->GetStepStatus())
105 case fPostStepDoItProc:
110 std::cout <<
"PHG4MicromegasSteppingAction::UserSteppingAction - " <<
GetName() <<
": New Hit for " << std::endl;
117 std::cout <<
"last track: " <<
m_SaveTrackId <<
", current trackid: " << aTrack->GetTrackID() << std::endl;
118 std::cout <<
"phys pre vol: " << volume->GetName() <<
" post vol : " << touchpost->GetVolume()->GetName() << std::endl;
119 std::cout <<
" previous phys pre vol: " <<
m_SaveVolPre->GetName() <<
" previous phys post vol: " <<
m_SaveVolPost->GetName() << std::endl;
140 m_hit->set_px(0, prePoint->GetMomentum().x() /
GeV);
141 m_hit->set_py(0, prePoint->GetMomentum().y() /
GeV);
142 m_hit->set_pz(0, prePoint->GetMomentum().z() /
GeV);
152 m_hit->set_x(0, prePoint->GetPosition().x() /
cm);
153 m_hit->set_y(0, prePoint->GetPosition().y() /
cm);
154 m_hit->set_z(0, prePoint->GetPosition().z() /
cm);
157 m_hit->set_t(0, prePoint->GetGlobalTime() / nanosecond);
160 m_hit->set_trkid(aTrack->GetTrackID());
169 if (G4VUserTrackInformation *
p = aTrack->GetUserInformation())
173 m_hit->set_trkid(pp->GetUserTrackId());
184 if (!
m_hit || !std::isfinite(
m_hit->get_x(0)))
186 std::cout <<
GetName() <<
": hit was not created" << std::endl;
192 std::cout <<
"last track: " <<
m_SaveTrackId <<
", current trackid: " << aTrack->GetTrackID() << std::endl;
193 std::cout <<
"phys pre vol: " << volume->GetName() <<
" post vol : " << touchpost->GetVolume()->GetName() << std::endl;
194 std::cout <<
" previous phys pre vol: " <<
m_SaveVolPre->GetName() <<
" previous phys post vol: " <<
m_SaveVolPost->GetName() << std::endl;
203 std::cout <<
GetName() <<
": hits do not belong to the same track" << std::endl;
205 <<
", current trackid: " << aTrack->GetTrackID()
206 <<
", prestep status: " << prePoint->GetStepStatus()
234 if (postPoint->GetStepStatus() == fGeomBoundary ||
235 postPoint->GetStepStatus() == fWorldBoundary ||
236 postPoint->GetStepStatus() == fAtRestDoItProc ||
237 aTrack->GetTrackStatus() == fStopAndKill)
244 m_hit->set_x(1, postPoint->GetPosition().x() /
cm);
245 m_hit->set_y(1, postPoint->GetPosition().y() /
cm);
246 m_hit->set_z(1, postPoint->GetPosition().z() /
cm);
248 m_hit->set_t(1, postPoint->GetGlobalTime() / nanosecond);
251 m_hit->set_px(1, postPoint->GetMomentum().x() /
GeV);
252 m_hit->set_py(1, postPoint->GetMomentum().y() /
GeV);
253 m_hit->set_pz(1, postPoint->GetMomentum().z() /
GeV);
256 if (G4VUserTrackInformation *
p = aTrack->GetUserInformation())
310 std::cout <<
"PHG4MicromegasSteppingAction::SetTopNode - unable to find " <<
m_HitNodeName << std::endl;
315 if (!m_SupportHitContainer)
319 std::cout <<
"PHG4MicromegasSteppingAction::SetTopNode - unable to find " <<
m_SupportNodeName << std::endl;
331 else if (type ==
"G4HIT_SUPPORT")
336 std::cout <<
"Invalid output hit node type " << type << std::endl;