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();
89 G4ThreeVector track_mom = aTrack->GetMomentum();
93 int prepointstatus = prePoint->GetStepStatus();
94 if (prepointstatus == fGeomBoundary ||
95 prepointstatus == fUndefined ||
96 (prepointstatus == fPostStepDoItProc && savepoststepstatus == fGeomBoundary) ||
99 if (prepointstatus == fPostStepDoItProc && savepoststepstatus == fGeomBoundary)
101 cout <<
GetName() <<
": New Hit for " << endl;
106 cout <<
"last track: " << savetrackid
107 <<
", current trackid: " << aTrack->GetTrackID() << endl;
108 cout <<
"phys pre vol: " << volume->GetName()
109 <<
" post vol : " << touchpost->GetVolume()->GetName() << endl;
110 cout <<
" previous phys pre vol: " << savevolpre->GetName()
111 <<
" previous phys post vol: " << savevolpost->GetName() << endl;
119 hit->
set_x(0, prePoint->GetPosition().x() / cm);
120 hit->
set_y(0, prePoint->GetPosition().y() / cm);
121 hit->
set_z(0, prePoint->GetPosition().z() / cm);
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);
187 hit->
set_px(1, track_mom.x()/GeV);
188 hit->
set_py(1, track_mom.y()/GeV);
189 hit->
set_pz(1, track_mom.z()/GeV);
191 hit->
set_t(1, postPoint->GetGlobalTime() / nanosecond);
197 if (active && !IsBlackHole && !geantino)
207 if (G4VUserTrackInformation* p = aTrack->GetUserInformation())
223 if (postPoint->GetStepStatus() == fGeomBoundary ||
224 postPoint->GetStepStatus() == fWorldBoundary ||
225 postPoint->GetStepStatus() == fAtRestDoItProc ||
226 aTrack->GetTrackStatus() == fStopAndKill ||
232 hits_->
AddHit(layer_id, hit);
268 hitnodename =
"G4HIT_" + detector_->
GetName();
272 hits_ = findNode::getClass<PHG4HitContainer>(topNode, hitnodename.c_str());
277 std::cout <<
"PHG4BlockSteppingAction::SetTopNode - unable to find " << hitnodename << std::endl;
bool IsInBlock(G4VPhysicalVolume *) const
void SuperDetector(const std::string &name)
virtual void SetInterfacePointers(PHCompositeNode *)
reimplemented from base class
virtual ~PHG4BlockSteppingAction()
destructor
PHG4BlockSteppingAction(PHG4BlockDetector *, const PHParameters *parameters)
constructor
virtual bool UserSteppingAction(const G4Step *, bool)
stepping action
virtual std::string GetName() const
ConstIterator AddHit(PHG4Hit *newhit)
virtual void set_layer(const unsigned int i)
virtual float get_eion() const
virtual void set_y(const int i, const float f)
virtual void set_shower_id(const int i)
virtual float get_edep() const
virtual void set_px(const int i, const float f)
virtual void set_py(const int i, const float f)
virtual void set_t(const int i, const float f)
virtual void set_pz(const int i, const float f)
virtual void set_eion(const float f)
virtual void Reset()
Clear Event.
virtual void set_z(const int i, const float f)
virtual void set_x(const int i, const float f)
virtual PHG4HitDefs::keytype get_hit_id() const
virtual float get_x(const int i) const
virtual void set_trkid(const int i)
virtual void set_edep(const float f)
virtual void add_g4hit_id(int volume, PHG4HitDefs::keytype id)
std::string GetName() const
std::string GetStepStatus(const int istatus)