12 #include <phparameter/PHParameters.h>
13 #include <phparameter/PHParametersContainer.h>
20 #include <Geant4/G4NavigationHistory.hh>
21 #include <Geant4/G4ParticleDefinition.hh>
22 #include <Geant4/G4ReferenceCountedHandle.hh>
23 #include <Geant4/G4Step.hh>
24 #include <Geant4/G4StepPoint.hh>
25 #include <Geant4/G4StepStatus.hh>
26 #include <Geant4/G4String.hh>
27 #include <Geant4/G4SystemOfUnits.hh>
28 #include <Geant4/G4ThreeVector.hh>
29 #include <Geant4/G4TouchableHandle.hh>
30 #include <Geant4/G4Track.hh>
31 #include <Geant4/G4TrackStatus.hh>
32 #include <Geant4/G4Types.hh>
33 #include <Geant4/G4VPhysicalVolume.hh>
34 #include <Geant4/G4VTouchable.hh>
35 #include <Geant4/G4VUserTrackInformation.hh>
37 #include <boost/tokenizer.hpp>
41 #include <boost/version.hpp>
42 #if (__GNUC__ == 4 && __GNUC_MINOR__ == 4 && BOOST_VERSION == 105700)
43 #pragma GCC diagnostic ignored "-Wuninitialized"
44 #pragma message "ignoring bogus gcc warning in boost header lexical_cast.hpp"
45 #include <boost/lexical_cast.hpp>
46 #pragma GCC diagnostic warning "-Wuninitialized"
48 #include <boost/lexical_cast.hpp>
60 , m_Detector(detector)
64 for (
auto iter = begin_end.first; iter != begin_end.second; ++iter)
94 G4TouchableHandle touch = aStep->GetPreStepPoint()->GetTouchableHandle();
122 int layer_id = -9999;
123 int stave_id = -9999;
125 int half_stave_number = -1;
126 int module_number = -1;
127 int chip_number = -1;
137 if (layer_id < 0 || stave_id < 0)
139 std::cout <<
PHWHERE <<
"invalid Mvtx's layer (" << layer_id <<
") or stave (" << stave_id <<
") index " << std::endl;
152 std::cout <<
"Entering PHG4MvtxSteppingAction::UserSteppingAction for volume " << vtest->GetName() << std::endl;
154 std::cout <<
"Entering PHG4MvtxSteppingAction::UserSteppingAction for volume 1 up " << vtest1->GetName() << std::endl;
156 std::cout <<
"Entering PHG4MvtxSteppingAction::UserSteppingAction for volume 2 up " << vtest2->GetName() << std::endl;
158 std::cout <<
"Entering PHG4MvtxSteppingAction::UserSteppingAction for volume 3 up " << vtest3->GetName() << std::endl;
160 std::cout <<
"Entering PHG4MvtxSteppingAction::UserSteppingAction for volume 4 up " << vtest4->GetName() << std::endl;
175 std::cout << std::endl
176 <<
" UserSteppingAction: layer " << layer_id;
178 boost::char_separator<char> sep(
"_");
179 boost::tokenizer<boost::char_separator<char> >::const_iterator tokeniter;
184 boost::tokenizer<boost::char_separator<char> > tok1(v1->GetName(), sep);
185 tokeniter = tok1.begin();
187 chip_number = boost::lexical_cast<
int>(*tokeniter);
190 std::cout <<
" chip " << chip_number;
193 boost::tokenizer<boost::char_separator<char> > tok2(v2->GetName(), sep);
194 tokeniter = tok2.begin();
196 module_number = boost::lexical_cast<
int>(*tokeniter);
199 std::cout <<
" module " << module_number;
209 boost::tokenizer<boost::char_separator<char> > tok3(v3->GetName(), sep);
210 tokeniter = tok3.begin();
217 std::cout <<
" stave " << stave_id;
222 half_stave_number = boost::lexical_cast<
int>(*tokeniter);
225 std::cout <<
" half_stave " << half_stave_number;
234 G4double edep = aStep->GetTotalEnergyDeposit() /
GeV;
235 const G4Track* aTrack = aStep->GetTrack();
238 std::cout <<
" edep = " << edep << std::endl;
244 edep = aTrack->GetKineticEnergy() /
GeV;
245 G4Track* killtrack =
const_cast<G4Track*
>(aTrack);
246 killtrack->SetTrackStatus(fStopAndKill);
256 bool geantino =
false;
260 if (aTrack->GetParticleDefinition()->GetPDGEncoding() == 0 &&
261 aTrack->GetParticleDefinition()->GetParticleName().find(
"geantino") != std::string::npos)
266 G4ThreeVector worldPosition;
267 G4TouchableHandle theTouchable;
269 G4StepPoint* prePoint = aStep->GetPreStepPoint();
270 G4StepPoint* postPoint = aStep->GetPostStepPoint();
274 G4ParticleDefinition* def = aTrack->GetDefinition();
275 std::cout <<
" Particle: " << def->GetParticleName() << std::endl;
278 switch (prePoint->GetStepStatus())
295 worldPosition = prePoint->GetPosition();
299 theTouchable = prePoint->GetTouchableHandle();
300 std::cout <<
"entering: depth = " << theTouchable->GetHistory()->GetDepth() << std::endl;
302 std::cout <<
"entering volume name = " << vol1->GetName() << std::endl;
315 std::cout <<
"adding support hit" << std::endl;
328 m_Hit->
set_t(0, prePoint->GetGlobalTime() / nanosecond);
331 if (G4VUserTrackInformation*
p = aTrack->GetUserInformation())
403 m_Hit->
set_t(1, postPoint->GetGlobalTime() / nanosecond);
412 if (G4VUserTrackInformation*
p = aTrack->GetUserInformation())
423 G4StepPoint* prePointA = aStep->GetPreStepPoint();
424 G4StepPoint* postPointA = aStep->GetPostStepPoint();
425 std::cout <<
"----- PHg4MvtxSteppingAction::UserSteppingAction - active volume = " << sensor_volume->GetName() << std::endl;
426 std::cout <<
" layer = " << layer_id << std::endl;
427 std::cout <<
" stave number = " << stave_id <<
" half_stave_number = " << half_stave_number << std::endl;
428 std::cout <<
" module number = " << module_number << std::endl;
429 std::cout <<
" chip number = " << chip_number << std::endl;
430 std::cout <<
" prepoint x position " << prePointA->GetPosition().x() /
cm << std::endl;
431 std::cout <<
" prepoint y position " << prePointA->GetPosition().y() /
cm << std::endl;
432 std::cout <<
" prepoint z position " << prePointA->GetPosition().z() /
cm << std::endl;
433 std::cout <<
" postpoint x position " << postPointA->GetPosition().x() /
cm << std::endl;
434 std::cout <<
" postpoint y position " << postPointA->GetPosition().y() /
cm << std::endl;
435 std::cout <<
" postpoint z position " << postPointA->GetPosition().z() /
cm << std::endl;
436 std::cout <<
" edep " << edep << std::endl;
441 std::cout <<
" stepping action found hit:" << std::endl;
443 std::cout << std::endl
455 if (postPoint->GetStepStatus() == fGeomBoundary ||
456 postPoint->GetStepStatus() == fWorldBoundary ||
457 postPoint->GetStepStatus() == fAtRestDoItProc ||
458 aTrack->GetTrackStatus() == fStopAndKill)
503 std::cout <<
"PHG4MvtxSteppingAction::SetTopNode - unable to find " <<
m_HitNodeName << std::endl;
507 if (!m_SupportHitContainer)
511 std::cout <<
"PHG4MvtxSteppingAction::SetTopNode - unable to find " <<
m_SupportNodeName << std::endl;
523 else if (type ==
"G4HIT_SUPPORT")
528 std::cout <<
"Invalid output hit node type " << type << std::endl;