5 #include <phparameter/PHParameters.h>
15 #include <Geant4/G4Step.hh>
16 #include <Geant4/G4SystemOfUnits.hh>
29 , savevolpost(nullptr)
31 , saveprestepstatus(-1)
32 , savepoststepstatus(-1)
33 , active(params->get_int_param(
"active"))
34 , IsBlackHole(params->get_int_param(
"blackhole"))
35 , use_g4_steps(params->get_int_param(
"use_g4steps"))
51 G4TouchableHandle touch = aStep->GetPreStepPoint()->GetTouchableHandle();
52 G4TouchableHandle touchpost = aStep->GetPostStepPoint()->GetTouchableHandle();
54 G4VPhysicalVolume* volume = touch->GetVolume();
62 G4double edep = aStep->GetTotalEnergyDeposit() / GeV;
63 G4double eion = (aStep->GetTotalEnergyDeposit() - aStep->GetNonIonizingEnergyDeposit()) / GeV;
64 const G4Track* aTrack = aStep->GetTrack();
69 edep = aTrack->GetKineticEnergy() / GeV;
70 G4Track* killtrack =
const_cast<G4Track*
>(aTrack);
71 killtrack->SetTrackStatus(fStopAndKill);
78 bool geantino =
false;
82 if (aTrack->GetParticleDefinition()->GetPDGEncoding() == 0 &&
83 aTrack->GetParticleDefinition()->GetParticleName().find(
"geantino") != string::npos)
87 G4StepPoint* prePoint = aStep->GetPreStepPoint();
88 G4StepPoint* postPoint = aStep->GetPostStepPoint();
92 int prepointstatus = prePoint->GetStepStatus();
93 if (prepointstatus == fGeomBoundary ||
94 prepointstatus == fUndefined ||
95 (prepointstatus == fPostStepDoItProc && savepoststepstatus == fGeomBoundary) ||
98 if (prepointstatus == fPostStepDoItProc && savepoststepstatus == fGeomBoundary)
100 cout <<
GetName() <<
": New Hit for " << endl;
105 cout <<
"last track: " << savetrackid
106 <<
", current trackid: " << aTrack->GetTrackID() << endl;
107 cout <<
"phys pre vol: " << volume->GetName()
108 <<
" post vol : " << touchpost->GetVolume()->GetName() << endl;
109 cout <<
" previous phys pre vol: " << savevolpre->GetName()
110 <<
" previous phys post vol: " << savevolpost->GetName() << endl;
118 hit->
set_x(0, prePoint->GetPosition().x() / cm);
119 hit->
set_y(0, prePoint->GetPosition().y() / cm);
120 hit->
set_z(0, prePoint->GetPosition().z() / cm);
122 G4ThreeVector track_mom = aTrack->GetMomentum();
123 hit->
set_px(0, track_mom.x()/GeV);
124 hit->
set_py(0, track_mom.y()/GeV);
125 hit->
set_pz(0, track_mom.z()/GeV);
127 hit->
set_t(0, prePoint->GetGlobalTime() / nanosecond);
130 savetrackid = aTrack->GetTrackID();
134 if (!geantino && !IsBlackHole && active)
138 if (G4VUserTrackInformation* p = aTrack->GetUserInformation())
144 saveshower = pp->GetShower();
151 if (!hit || !isfinite(hit->
get_x(0)))
153 cout <<
GetName() <<
": hit was not created" << endl;
158 cout <<
"last track: " << savetrackid
159 <<
", current trackid: " << aTrack->GetTrackID() << endl;
160 cout <<
"phys pre vol: " << volume->GetName()
161 <<
" post vol : " << touchpost->GetVolume()->GetName() << endl;
162 cout <<
" previous phys pre vol: " << savevolpre->GetName()
163 <<
" previous phys post vol: " << savevolpost->GetName() << endl;
166 savepoststepstatus = postPoint->GetStepStatus();
168 if (aTrack->GetTrackID() != savetrackid)
170 cout <<
"hits do not belong to the same track" << endl;
171 cout <<
"saved track: " << savetrackid
172 <<
", current trackid: " << aTrack->GetTrackID()
176 saveprestepstatus = prePoint->GetStepStatus();
177 savepoststepstatus = postPoint->GetStepStatus();
179 savevolpost = touchpost->GetVolume();
184 hit->
set_x(1, postPoint->GetPosition().x() / cm);
185 hit->
set_y(1, postPoint->GetPosition().y() / cm);
186 hit->
set_z(1, postPoint->GetPosition().z() / cm);
188 hit->
set_t(1, postPoint->GetGlobalTime() / nanosecond);
194 if (active && !IsBlackHole && !geantino)
204 if (G4VUserTrackInformation* p = aTrack->GetUserInformation())
220 if (postPoint->GetStepStatus() == fGeomBoundary ||
221 postPoint->GetStepStatus() == fWorldBoundary ||
222 postPoint->GetStepStatus() == fAtRestDoItProc ||
223 aTrack->GetTrackStatus() == fStopAndKill ||
229 hits_->
AddHit(layer_id, hit);
265 hitnodename =
"G4HIT_" + detector_->
GetName();
269 hits_ = findNode::getClass<PHG4HitContainer>(topNode, hitnodename.c_str());
274 std::cout <<
"PHG4BlockSteppingAction::SetTopNode - unable to find " << hitnodename << std::endl;
virtual float get_x(const int i) const
virtual void set_trkid(const int i)
virtual void set_shower_id(const int i)
virtual void set_t(const int i, const float f)
virtual void SetInterfacePointers(PHCompositeNode *)
reimplemented from base class
virtual void Reset()
Clear Event.
virtual PHG4HitDefs::keytype get_hit_id() const
virtual void set_px(const int i, const float f)
PHG4BlockSteppingAction(PHG4BlockDetector *, const PHParameters *parameters)
constructor
std::string GetStepStatus(const int istatus)
virtual float get_edep() const
void SuperDetector(const std::string &name)
virtual bool UserSteppingAction(const G4Step *, bool)
stepping action
virtual void set_y(const int i, const float f)
virtual void set_py(const int i, const float f)
virtual float get_eion() const
virtual void add_g4hit_id(int volume, PHG4HitDefs::keytype id)
virtual void set_x(const int i, const float f)
virtual void set_edep(const float f)
virtual void set_eion(const float f)
virtual void set_pz(const int i, const float f)
virtual void set_layer(const unsigned int i)
bool IsInBlock(G4VPhysicalVolume *) const
std::string GetName() const
virtual std::string GetName() const
virtual void set_z(const int i, const float f)
virtual ~PHG4BlockSteppingAction()
destructor
ConstIterator AddHit(PHG4Hit *newhit)