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>
57 , m_Detector(detector)
58 , m_HitContainer(nullptr)
59 , m_AbsorberhitContainer(nullptr)
61 , m_SaveShower(nullptr)
78 G4TouchableHandle touch = aStep->GetPreStepPoint()->GetTouchableHandle();
80 G4VPhysicalVolume* sensor_volume = touch->GetVolume();
105 int layer_id = -9999;
106 int stave_id = -9999;
108 G4VPhysicalVolume* vstave = touch->GetVolume(3);
110 if (layer_id < 0 || stave_id < 0)
112 cout <<
PHWHERE <<
"invalid Mvtx's layer (" << layer_id <<
") or stave (" << stave_id <<
") index " << endl;
124 G4VPhysicalVolume* vtest = touch->GetVolume();
125 cout <<
"Entering PHG4MvtxSteppingAction::UserSteppingAction for volume " << vtest->GetName() << endl;
126 G4VPhysicalVolume* vtest1 = touch->GetVolume(1);
127 cout <<
"Entering PHG4MvtxSteppingAction::UserSteppingAction for volume 1 up " << vtest1->GetName() << endl;
128 G4VPhysicalVolume* vtest2 = touch->GetVolume(2);
129 cout <<
"Entering PHG4MvtxSteppingAction::UserSteppingAction for volume 2 up " << vtest2->GetName() << endl;
130 G4VPhysicalVolume* vtest3 = touch->GetVolume(3);
131 cout <<
"Entering PHG4MvtxSteppingAction::UserSteppingAction for volume 3 up " << vtest3->GetName() << endl;
132 G4VPhysicalVolume* vtest4 = touch->GetVolume(4);
133 cout <<
"Entering PHG4MvtxSteppingAction::UserSteppingAction for volume 4 up " << vtest4->GetName() << endl;
147 int half_stave_number = -1;
148 int module_number = -1;
149 int chip_number = -1;
153 <<
" UserSteppingAction: layer " << layer_id;
154 boost::char_separator<char> sep(
"_");
155 boost::tokenizer<boost::char_separator<char> >::const_iterator tokeniter;
159 G4VPhysicalVolume*
v1 = touch->GetVolume(1);
160 boost::tokenizer<boost::char_separator<char> > tok1(v1->GetName(), sep);
161 tokeniter = tok1.begin();
163 chip_number = boost::lexical_cast<
int>(*tokeniter);
164 if (
Verbosity() > 0) cout <<
" chip " << chip_number;
165 G4VPhysicalVolume*
v2 = touch->GetVolume(2);
166 boost::tokenizer<boost::char_separator<char> > tok2(v2->GetName(), sep);
167 tokeniter = tok2.begin();
169 module_number = boost::lexical_cast<
int>(*tokeniter);
170 if (
Verbosity() > 0) cout <<
" module " << module_number;
178 G4VPhysicalVolume*
v3 = touch->GetVolume(3);
179 boost::tokenizer<boost::char_separator<char> > tok3(v3->GetName(), sep);
180 tokeniter = tok3.begin();
185 if (
Verbosity() > 0) cout <<
" stave " << stave_id;
189 half_stave_number = boost::lexical_cast<
int>(*tokeniter);
190 if (
Verbosity() > 0) cout <<
" half_stave " << half_stave_number;
198 G4double edep = aStep->GetTotalEnergyDeposit() /
GeV;
199 const G4Track* aTrack = aStep->GetTrack();
200 if (
Verbosity() > 0) cout <<
" edep = " << edep << endl;
205 edep = aTrack->GetKineticEnergy() /
GeV;
206 G4Track* killtrack =
const_cast<G4Track*
>(aTrack);
207 killtrack->SetTrackStatus(fStopAndKill);
213 bool geantino =
false;
217 if (aTrack->GetParticleDefinition()->GetPDGEncoding() == 0 &&
218 aTrack->GetParticleDefinition()->GetParticleName().find(
"geantino") != string::npos)
223 G4ThreeVector worldPosition;
224 G4TouchableHandle theTouchable;
226 G4StepPoint* prePoint = aStep->GetPreStepPoint();
227 G4StepPoint* postPoint = aStep->GetPostStepPoint();
231 G4ParticleDefinition* def = aTrack->GetDefinition();
232 cout <<
" Particle: " << def->GetParticleName() << endl;
235 switch (prePoint->GetStepStatus())
251 worldPosition = prePoint->GetPosition();
255 theTouchable = prePoint->GetTouchableHandle();
256 cout <<
"entering: depth = " << theTouchable->GetHistory()->GetDepth() << endl;
257 G4VPhysicalVolume *vol1 = theTouchable->GetVolume();
258 cout <<
"entering volume name = " << vol1->GetName() << endl;
278 m_Hit->
set_t(0, prePoint->GetGlobalTime() / nanosecond);
281 if (G4VUserTrackInformation*
p = aTrack->GetUserInformation())
350 m_Hit->
set_t(1, postPoint->GetGlobalTime() / nanosecond);
359 if (G4VUserTrackInformation*
p = aTrack->GetUserInformation())
370 G4StepPoint* prePoint = aStep->GetPreStepPoint();
371 G4StepPoint* postPoint = aStep->GetPostStepPoint();
372 cout <<
"----- PHg4MvtxSteppingAction::UserSteppingAction - active volume = " << sensor_volume->GetName() << endl;
373 cout <<
" layer = " << layer_id << endl;
374 cout <<
" stave number = " << stave_id <<
" half_stave_number = " << half_stave_number << endl;
375 cout <<
" module number = " << module_number << endl;
376 cout <<
" chip number = " << chip_number << endl;
377 cout <<
" prepoint x position " << prePoint->GetPosition().x() /
cm << endl;
378 cout <<
" prepoint y position " << prePoint->GetPosition().y() /
cm << endl;
379 cout <<
" prepoint z position " << prePoint->GetPosition().z() /
cm << endl;
380 cout <<
" postpoint x position " << postPoint->GetPosition().x() /
cm << endl;
381 cout <<
" postpoint y position " << postPoint->GetPosition().y() /
cm << endl;
382 cout <<
" postpoint z position " << postPoint->GetPosition().z() /
cm << endl;
383 cout <<
" edep " << edep << endl;
388 cout <<
" stepping action found hit:" << endl;
402 if (postPoint->GetStepStatus() == fGeomBoundary ||
403 postPoint->GetStepStatus() == fWorldBoundary ||
404 postPoint->GetStepStatus() == fAtRestDoItProc ||
405 aTrack->GetTrackStatus() == fStopAndKill)
443 string absorbernodename;
456 m_HitContainer = findNode::getClass<PHG4HitContainer>(topNode, hitnodename.c_str());
462 std::cout <<
"PHG4MvtxSteppingAction::SetTopNode - unable to find " << hitnodename << std::endl;
464 if (!m_AbsorberhitContainer)
468 cout <<
"PHG4MvtxSteppingAction::SetTopNode - unable to find " << absorbernodename << endl;