5 #include <phparameter/PHParameters.h>
22 #include <G4ParticleDefinition.hh>
23 #include <G4ReferenceCountedHandle.hh>
25 #include <G4StepStatus.hh>
26 #include <G4SystemOfUnits.hh>
27 #include <G4ThreeVector.hh>
28 #include <G4TouchableHandle.hh>
29 #include <G4TrackStatus.hh>
31 #include <G4VPhysicalVolume.hh>
32 #include <G4VProcess.hh>
33 #include <G4VTouchable.hh>
34 #include <G4VUserTrackInformation.hh>
46 , m_Detector(detector)
47 , m_Params(parameters)
48 , m_HitContainer(nullptr)
50 , m_SaveHitContainer(nullptr)
51 , m_SaveVolPre(nullptr)
52 , m_SaveVolPost(nullptr)
54 , m_SavePreStepStatus(-1)
55 , m_SavePostStepStatus(-1)
56 , m_ActiveFlag(m_Params->get_int_param(
"active"))
101 std::cout <<
"[>>>>>] call EICG4dRICHSteppingAction::UserSteppingAction" << std::endl;
105 G4TouchableHandle preTouch = aStep->GetPreStepPoint()->GetTouchableHandle();
106 G4TouchableHandle postTouch = aStep->GetPostStepPoint()->GetTouchableHandle();
107 G4VPhysicalVolume *preVol = preTouch->GetVolume();
108 G4VPhysicalVolume *postVol = postTouch->GetVolume();
109 G4StepPoint *prePoint = aStep->GetPreStepPoint();
110 G4StepPoint *postPoint = aStep->GetPostStepPoint();
113 if (postPoint->GetStepStatus() == fWorldBoundary)
121 G4String prePointVolName = prePoint->GetPhysicalVolume()->GetName();
122 G4String postPointVolName = postPoint->GetPhysicalVolume()->GetName();
123 G4String preTouchVolName = preVol->GetName();
124 G4String postTouchVolName = postVol->GetName();
127 const G4Track *aTrack = aStep->GetTrack();
128 G4String particleName = aTrack->GetParticleDefinition()->GetParticleName();
131 std::cout <<
"[-] track ID=" << aTrack->GetTrackID()
132 <<
", particle=" << particleName << std::endl;
142 std::cout <<
"[_] step preVol=" << preTouchVolName
143 <<
", postVol=" << postTouchVolName <<
", whichactive=" << whichactive
152 if (prePointVolName.contains(
"dRICHpetal") && postPointVolName.contains(
"dRICHpsst"))
156 else if (prePointVolName.contains(
"World") && postPointVolName.contains(
"dRICHvessel"))
160 else if (prePointVolName.contains(
"dRICHvessel") && postPointVolName.contains(
"World"))
171 std::cout <<
"[__] step is ENTERING vessel" << std::endl;
187 edep = aStep->GetTotalEnergyDeposit() /
GeV;
188 eion = (aStep->GetTotalEnergyDeposit() -
189 aStep->GetNonIonizingEnergyDeposit()) /
205 switch (prePoint->GetStepStatus())
208 case fPostStepDoItProc:
214 std::cout <<
"[__] first step in a new volume" << std::endl;
223 std::cerr <<
"ERROR: impossible G4 Step" << std::endl;
224 std::cout <<
GetName() <<
": New Hit for " << std::endl;
225 std::cout <<
"prestep status: "
227 <<
", poststep status: "
229 <<
", last pre step status: "
231 <<
", last post step status: "
235 <<
", current trackid: " << aTrack->GetTrackID() << std::endl;
236 std::cout <<
"phys pre vol: " << preTouchVolName
237 <<
" post vol : " << postTouch->GetVolume()->GetName() << std::endl;
238 std::cout <<
" previous phys pre vol: " <<
m_SaveVolPre->GetName()
239 <<
" previous phys post vol: " <<
m_SaveVolPost->GetName() << std::endl;
254 this->
InitHit(prePoint, aTrack,
true);
264 if (prePoint->GetStepStatus() != fGeomBoundary &&
265 prePoint->GetStepStatus() != fUndefined && hitType !=
hEntrance)
276 this->
InitHit(prePoint, aTrack,
true);
283 this->
InitHit(prePoint, aTrack,
true);
285 this->
InitHit(prePoint, aTrack,
false);
291 std::cout <<
"[+] prepoint status=";
292 if (prePoint->GetStepStatus() == fGeomBoundary)
293 std::cout <<
"fGeomBoundary";
294 else if (prePoint->GetStepStatus() == fUndefined)
295 std::cout <<
"fUndefined";
297 std::cout <<
"UNKNOWN!";
298 std::cout << std::endl;
299 if (aTrack->GetTrackID() > 1 && aTrack->GetCreatorProcess())
301 std::cout <<
"[-] secondary track, creator process="
302 << aTrack->GetCreatorProcess()->GetProcessName();
306 std::cout <<
"[-] primary track, particle=" << particleName;
308 std::cout << std::endl;
312 if (G4VUserTrackInformation *
p = aTrack->GetUserInformation())
328 std::cout <<
"m_Hit @" <<
static_cast<void *
>(
m_Hit) <<
" isfinite = " << std::isfinite(
m_Hit->
get_x(0)) << std::endl;
329 std::cout <<
GetName() <<
": hit was not created" << std::endl;
330 std::cout <<
"prestep status: "
332 <<
", poststep status: "
334 <<
", last pre step status: "
336 <<
", last post step status: "
339 <<
", current trackid: " << aTrack->GetTrackID() << std::endl;
340 std::cout <<
"phys pre vol: " << preTouchVolName
341 <<
" post vol : " << postTouch->GetVolume()->GetName() << std::endl;
342 std::cout <<
" previous phys pre vol: " <<
m_SaveVolPre->GetName()
343 <<
" previous phys post vol: " <<
m_SaveVolPost->GetName() << std::endl;
350 std::cout <<
GetName() <<
": hits do not belong to the same track" << std::endl;
352 <<
", current trackid: " << aTrack->GetTrackID()
353 <<
", prestep status: " << prePoint->GetStepStatus()
373 std::cout <<
"[_] m_EdepSum=" <<
m_EdepSum <<
", m_EionSum=" <<
m_EionSum << std::endl;
388 if (postPoint->GetStepStatus() == fGeomBoundary
389 || postPoint->GetStepStatus() == fWorldBoundary
390 || postPoint->GetStepStatus() == fAtRestDoItProc
391 || aTrack->GetTrackStatus() == fStopAndKill)
395 std::cout <<
"[---+] last step in the volume (pre=" << prePointVolName <<
", post=" << postPointVolName <<
")" << std::endl;
409 if (aTrack->GetTrackID() == 1)
416 if (aTrack->GetTrackID() == 1)
422 if (particleName ==
"opticalphoton")
424 else if (particleName ==
"gamma")
439 m_Hit->
set_pdg(aTrack->GetParticleDefinition()->GetPDGEncoding());
449 else if (aTrack->GetCreatorProcess())
457 if (aTrack->GetCreatorProcess())
469 m_Hit->
set_t(1, postPoint->GetGlobalTime() / nanosecond);
472 if (G4VUserTrackInformation *
p = aTrack->GetUserInformation())
485 std::cout <<
"[-+] m_EdepSum=" <<
m_EdepSum <<
", m_EionSum=" <<
m_EionSum << std::endl;
509 const G4Track *aTrack_,
510 bool resetAccumulators)
514 m_Hit->
set_t(0, prePoint_->GetGlobalTime() / nanosecond);
519 if (resetAccumulators)
531 m_HitContainer = findNode::getClass<PHG4HitContainer>(topNode, hitnodename);
535 std::cout <<
"EICG4dRICHSteppingAction::SetTopNode - unable to find " << hitnodename << std::endl;