15 #include <Geant4/G4NavigationHistory.hh>
16 #include <Geant4/G4ParticleDefinition.hh>
17 #include <Geant4/G4ReferenceCountedHandle.hh>
18 #include <Geant4/G4Step.hh>
19 #include <Geant4/G4StepPoint.hh>
20 #include <Geant4/G4StepStatus.hh>
21 #include <Geant4/G4String.hh>
22 #include <Geant4/G4SystemOfUnits.hh>
23 #include <Geant4/G4ThreeVector.hh>
24 #include <Geant4/G4TouchableHandle.hh>
25 #include <Geant4/G4Track.hh>
26 #include <Geant4/G4TrackStatus.hh>
27 #include <Geant4/G4Types.hh>
28 #include <Geant4/G4VPhysicalVolume.hh>
29 #include <Geant4/G4VTouchable.hh>
30 #include <Geant4/G4VUserTrackInformation.hh>
32 #include <boost/tokenizer.hpp>
36 #include <boost/version.hpp>
37 #if (__GNUC__ == 4 && __GNUC_MINOR__ == 4 && BOOST_VERSION == 105700)
38 #pragma GCC diagnostic ignored "-Wuninitialized"
39 #pragma message "ignoring bogus gcc warning in boost header lexical_cast.hpp"
40 #include <boost/lexical_cast.hpp>
41 #pragma GCC diagnostic warning "-Wuninitialized"
43 #include <boost/lexical_cast.hpp>
56 , m_Detector(detector)
57 , m_HitContainer(nullptr)
58 , m_AbsorberhitContainer(nullptr)
60 , m_SaveShower(nullptr)
77 G4TouchableHandle touch = aStep->GetPreStepPoint()->GetTouchableHandle();
104 int layer_id = -9999;
105 int stave_id = -9999;
109 if (layer_id < 0 || stave_id < 0)
111 cout <<
PHWHERE <<
"invalid Mvtx's layer (" << layer_id <<
") or stave (" << stave_id <<
") index " << endl;
124 cout <<
"Entering PHG4MvtxSteppingAction::UserSteppingAction for volume " << vtest->GetName() << endl;
126 cout <<
"Entering PHG4MvtxSteppingAction::UserSteppingAction for volume 1 up " << vtest1->GetName() << endl;
128 cout <<
"Entering PHG4MvtxSteppingAction::UserSteppingAction for volume 2 up " << vtest2->GetName() << endl;
130 cout <<
"Entering PHG4MvtxSteppingAction::UserSteppingAction for volume 3 up " << vtest3->GetName() << endl;
132 cout <<
"Entering PHG4MvtxSteppingAction::UserSteppingAction for volume 4 up " << vtest4->GetName() << endl;
146 int half_stave_number = -1;
147 int module_number = -1;
148 int chip_number = -1;
152 <<
" UserSteppingAction: layer " << layer_id;
153 boost::char_separator<char> sep(
"_");
154 boost::tokenizer<boost::char_separator<char> >::const_iterator tokeniter;
159 boost::tokenizer<boost::char_separator<char> > tok1(v1->GetName(), sep);
160 tokeniter = tok1.begin();
162 chip_number = boost::lexical_cast<
int>(*tokeniter);
163 if (
Verbosity() > 0) cout <<
" chip " << chip_number;
165 boost::tokenizer<boost::char_separator<char> > tok2(v2->GetName(), sep);
166 tokeniter = tok2.begin();
168 module_number = boost::lexical_cast<
int>(*tokeniter);
169 if (
Verbosity() > 0) cout <<
" module " << module_number;
178 boost::tokenizer<boost::char_separator<char> > tok3(v3->GetName(), sep);
179 tokeniter = tok3.begin();
184 if (
Verbosity() > 0) cout <<
" stave " << stave_id;
188 half_stave_number = boost::lexical_cast<
int>(*tokeniter);
189 if (
Verbosity() > 0) cout <<
" half_stave " << half_stave_number;
197 G4double edep = aStep->GetTotalEnergyDeposit() /
GeV;
198 const G4Track* aTrack = aStep->GetTrack();
199 if (
Verbosity() > 0) cout <<
" edep = " << edep << endl;
204 edep = aTrack->GetKineticEnergy() /
GeV;
205 G4Track* killtrack =
const_cast<G4Track*
>(aTrack);
206 killtrack->SetTrackStatus(fStopAndKill);
212 bool geantino =
false;
216 if (aTrack->GetParticleDefinition()->GetPDGEncoding() == 0 &&
217 aTrack->GetParticleDefinition()->GetParticleName().find(
"geantino") != string::npos)
222 G4ThreeVector worldPosition;
223 G4TouchableHandle theTouchable;
225 G4StepPoint* prePoint = aStep->GetPreStepPoint();
226 G4StepPoint* postPoint = aStep->GetPostStepPoint();
230 G4ParticleDefinition* def = aTrack->GetDefinition();
231 cout <<
" Particle: " << def->GetParticleName() << endl;
234 switch (prePoint->GetStepStatus())
250 worldPosition = prePoint->GetPosition();
254 theTouchable = prePoint->GetTouchableHandle();
255 cout <<
"entering: depth = " << theTouchable->GetHistory()->GetDepth() << endl;
257 cout <<
"entering volume name = " << vol1->GetName() << endl;
277 m_Hit->
set_t(0, prePoint->GetGlobalTime() / nanosecond);
280 if (G4VUserTrackInformation*
p = aTrack->GetUserInformation())
349 m_Hit->
set_t(1, postPoint->GetGlobalTime() / nanosecond);
358 if (G4VUserTrackInformation*
p = aTrack->GetUserInformation())
369 G4StepPoint* prePointA = aStep->GetPreStepPoint();
370 G4StepPoint* postPointA = aStep->GetPostStepPoint();
371 cout <<
"----- PHg4MvtxSteppingAction::UserSteppingAction - active volume = " << sensor_volume->GetName() << endl;
372 cout <<
" layer = " << layer_id << endl;
373 cout <<
" stave number = " << stave_id <<
" half_stave_number = " << half_stave_number << endl;
374 cout <<
" module number = " << module_number << endl;
375 cout <<
" chip number = " << chip_number << endl;
376 cout <<
" prepoint x position " << prePointA->GetPosition().x() /
cm << endl;
377 cout <<
" prepoint y position " << prePointA->GetPosition().y() /
cm << endl;
378 cout <<
" prepoint z position " << prePointA->GetPosition().z() /
cm << endl;
379 cout <<
" postpoint x position " << postPointA->GetPosition().x() /
cm << endl;
380 cout <<
" postpoint y position " << postPointA->GetPosition().y() /
cm << endl;
381 cout <<
" postpoint z position " << postPointA->GetPosition().z() /
cm << endl;
382 cout <<
" edep " << edep << endl;
387 cout <<
" stepping action found hit:" << endl;
401 if (postPoint->GetStepStatus() == fGeomBoundary ||
402 postPoint->GetStepStatus() == fWorldBoundary ||
403 postPoint->GetStepStatus() == fAtRestDoItProc ||
404 aTrack->GetTrackStatus() == fStopAndKill)
442 string absorbernodename;
455 m_HitContainer = findNode::getClass<PHG4HitContainer>(topNode, hitnodename.c_str());
461 std::cout <<
"PHG4MvtxSteppingAction::SetTopNode - unable to find " << hitnodename << std::endl;
463 if (!m_AbsorberhitContainer)
467 cout <<
"PHG4MvtxSteppingAction::SetTopNode - unable to find " << absorbernodename << endl;