9 #include <phparameter/PHParameters.h>
25 #include <Geant4/G4ParticleDefinition.hh>
26 #include <Geant4/G4ReferenceCountedHandle.hh>
27 #include <Geant4/G4Step.hh>
28 #include <Geant4/G4StepPoint.hh>
29 #include <Geant4/G4StepStatus.hh>
30 #include <Geant4/G4String.hh>
31 #include <Geant4/G4SystemOfUnits.hh>
32 #include <Geant4/G4ThreeVector.hh>
33 #include <Geant4/G4TouchableHandle.hh>
34 #include <Geant4/G4Track.hh>
35 #include <Geant4/G4TrackStatus.hh>
36 #include <Geant4/G4Types.hh>
37 #include <Geant4/G4VPhysicalVolume.hh>
38 #include <Geant4/G4VTouchable.hh>
39 #include <Geant4/G4VUserTrackInformation.hh>
41 #include <boost/tokenizer.hpp>
45 #include <boost/version.hpp>
46 #if (__GNUC__ == 4 && __GNUC_MINOR__ == 4 && BOOST_VERSION == 105700)
47 #pragma GCC diagnostic ignored "-Wuninitialized"
48 #pragma message "ignoring bogus gcc warning in boost header lexical_cast.hpp"
49 #include <boost/lexical_cast.hpp>
50 #pragma GCC diagnostic warning "-Wuninitialized"
52 #include <boost/lexical_cast.hpp>
60 using namespace CLHEP;
68 IsBlackHole(params->get_int_param(
"blackhole"))
71 detectorname(params->get_string_param(
"detectorname"))
72 , superdetector(params->get_string_param(
"superdetector"))
74 , absorberhits_(nullptr)
76 , savehitcontainer(nullptr)
79 , savepoststepstatus(-1)
90 G4TouchableHandle touch = aStep->GetPreStepPoint()->GetTouchableHandle();
91 G4VPhysicalVolume*
volume = touch->GetVolume();
97 G4double edep = aStep->GetTotalEnergyDeposit() /
GeV;
98 G4double eion = (aStep->GetTotalEnergyDeposit() - aStep->GetNonIonizingEnergyDeposit()) /
GeV;
100 const G4Track* aTrack = aStep->GetTrack();
103 bool geantino =
false;
104 if (aTrack->GetParticleDefinition()->GetPDGEncoding() == 0 && aTrack->GetParticleDefinition()->GetParticleName().find(
"geantino") != std::string::npos)
117 int module_id = touch->GetReplicaNumber(2) - 1;
118 int PID = aTrack->GetDefinition()->GetPDGEncoding();
119 std::string PName = aTrack->GetDefinition()->GetParticleName();
125 edep = aTrack->GetKineticEnergy() /
GeV;
126 G4Track* killtrack =
const_cast<G4Track*
>(aTrack);
127 killtrack->SetTrackStatus(fStopAndKill);
131 G4StepPoint* prePoint = aStep->GetPreStepPoint();
132 G4StepPoint* postPoint = aStep->GetPostStepPoint();
134 switch (prePoint->GetStepStatus())
142 hit->
set_x(0, prePoint->GetPosition().x() /
cm);
143 hit->
set_y(0, prePoint->GetPosition().y() /
cm);
144 hit->
set_z(0, prePoint->GetPosition().z() /
cm);
147 hit->
set_t(0, prePoint->GetGlobalTime() / nanosecond);
161 edep = aTrack->GetKineticEnergy() /
GeV;
162 G4Track* killtrack =
const_cast<G4Track*
>(aTrack);
163 killtrack->SetTrackStatus(fStopAndKill);
173 if (G4VUserTrackInformation*
p = aTrack->GetUserInformation())
192 std::cout << __FILE__ <<
"::" << __func__ <<
"::" <<
GetName() <<
": hit was not created" << std::endl;
193 std::cout <<
"prestep status: " << prePoint->GetStepStatus()
202 std::cout << __FILE__ <<
"::" << __func__ <<
"::" <<
GetName() <<
": hits do not belong to the same track" << std::endl;
204 <<
", current trackid: " << aTrack->GetTrackID()
229 if (G4VUserTrackInformation*
p = aTrack->GetUserInformation())
241 if (postPoint->GetStepStatus() == fGeomBoundary ||
242 postPoint->GetStepStatus() == fWorldBoundary ||
243 postPoint->GetStepStatus() == fAtRestDoItProc ||
244 aTrack->GetTrackStatus() == fStopAndKill)
277 std::string hitnodename;
278 std::string absorbernodename;
292 hits_ = findNode::getClass<PHG4HitContainer>(topNode, hitnodename.c_str());
293 absorberhits_ = findNode::getClass<PHG4HitContainer>(topNode, absorbernodename.c_str());
326 boost::char_separator<char> sep(
"_");
327 boost::tokenizer<boost::char_separator<char>> tok(volume->GetName(), sep);
328 boost::tokenizer<boost::char_separator<char>>::const_iterator tokeniter;
330 for (tokeniter = tok.begin(); tokeniter != tok.end(); ++tokeniter)
332 if (*tokeniter ==
"impr")
335 if (tokeniter != tok.end())
337 sector_id = boost::lexical_cast<
int>(*tokeniter);
341 std::cout <<
PHWHERE <<
" Error parsing " << volume->GetName()
342 <<
" for mRICH sector id " << std::endl;
346 else if (*tokeniter ==
"pv")
349 if (tokeniter != tok.end())
351 mRICH_id = boost::lexical_cast<
int>(*tokeniter);
355 std::cout <<
PHWHERE <<
" Error parsing " << volume->GetName()
356 <<
" for mRICH id " << std::endl;
362 module_id = (sector_id - 1) * 100 + mRICH_id;
364 if (
Verbosity() >=
Fun4AllBase::VERBOSITY_SOME) std::cout <<
"name of volume: " << volume->GetName() <<
", sector_id = " << sector_id <<
", mRICH_id = " << mRICH_id <<
", module_id = " << module_id << std::endl;