8 #include <det/Detector.h>
9 #include <sdet/SDetector.h>
10 #include <sdet/Station.h>
12 #include <sevt/PMTSimData.h>
13 #include <sevt/SEvent.h>
14 #include <sevt/Station.h>
15 #include <sevt/StationSimData.h>
16 #include <utl/config.h>
17 #include <utl/ErrorLogger.h>
18 #include <utl/Particle.h>
19 #include <utl/Trace.h>
20 #include <utl/AugerCoordinateSystem.h>
21 #include <fwk/RunController.h>
24 #include <G4VProcess.hh>
25 #include <G4SteppingManager.hh>
27 #include <G4TrackVector.hh>
28 #include <G4Trajectory.hh>
29 #include <G4TrajectoryContainer.hh>
37 namespace G4StationSimulatorOG {
39 G4StationSteppingAction::RPCTrackIDListMap G4StationSteppingAction::fgRPCTrackIDListMap;
40 G4StationSteppingAction::RPCParticleListMap G4StationSteppingAction::fgRPCParticleListMap;
42 int G4StationSteppingAction::fgParticleId = 0;
46 G4StationSteppingAction::UserSteppingAction(
const G4Step*
const step)
48 const auto& track = *step->GetTrack();
49 fgParticleId = track.GetDefinition()->GetPDGEncoding();
51 if (!fgParticleId && track.GetNextVolume()) {
52 const auto&
next = track.GetNextVolume()->GetName();
54 ++G4StationTrackingAction::fNumBounces;
60 const auto& currentVolume = track.GetVolume()->GetName();
61 if (currentVolume !=
"rpc_gas")
64 const auto& mother = *track.GetTouchable()->GetVolume(1);
65 const auto& grandmother = *track.GetTouchable()->GetVolume(2);
67 if (mother.GetName() !=
"rpc_glass" || grandmother.GetName() !=
"rpc") {
69 err <<
"RPC gas not found where expected : mother is "
70 << mother.GetName() <<
" (should be rpc_glass) and grandmother is "
71 << grandmother.GetName() <<
" (should be rpc)";
75 const G4int rpcId = grandmother.GetCopyNo();
77 const int particleID = track.GetDefinition()->GetPDGEncoding();
78 const int trackID = track.GetTrackID();
80 const auto& prePoint = *step->GetPreStepPoint();
83 const double enDepNonIoni = step->GetNonIonizingEnergyDeposit() /
CLHEP::MeV *
utl::MeV;
84 const double enDepIoni = dedx - enDepNonIoni;
86 const double w = track.GetWeight();
87 const bool isSec = w < 0;
89 auto& secondary = *G4UserSteppingAction::fpSteppingManager->GetfSecondary();
91 for (
const auto sp : secondary) {
93 if (
s.GetVolume()->GetName() !=
"rpc_gas")
96 s.SetWeight(-trackID);
99 bool trackSave =
true;
100 auto& trackId = fgRPCTrackIDListMap[rpcId];
101 auto& particleList = fgRPCParticleListMap[rpcId];
105 for (
unsigned int t = 0, n = trackId.size(); t < n; ++t) {
106 if (trackId[t] != -w)
109 auto&
p = particleList[t];
110 const double enLoss =
p.GetWeight();
111 p.SetWeight(enDepIoni + enLoss);
118 for (
unsigned int t = 0, n = trackId.size(); t < n; ++t) {
119 if (trackId[t] != trackID)
122 auto&
p = particleList[t];
123 const double enLoss =
p.GetWeight();
124 p.SetWeight(enDepIoni + enLoss);
132 if (trackSave && !isSec) {
134 trackId.push_back(trackID);
136 const sdet::Station& station = G4StationSimulator::fgCurrent.GetDetectorStation();
140 const G4ThreeVector pos = prePoint.GetPosition() - G4StationConstruction::fgTankCenter;
143 const auto direction = To<utl::Vector>(prePoint.GetMomentumDirection(), cs, 1);
146 utl::Particle& currentParticle = G4StationSimulator::fgCurrent.GetParticle();
149 utl::Particle newParticle(particleType, source, position, direction, time, enDepIoni, ke1);
153 if (track.GetParentID())
162 particleList.push_back(newParticle);
const utl::Point & GetProductionPoint() const
Detector description interface for Station-related data.
bool HasProductionPoint() const
Describes a particle for Simulation.
Base class for exceptions arising because configuration data are not valid.
void SetProductionPoint(const utl::Point &point)
Iterator next(Iterator it)
utl::CoordinateSystemPtr GetLocalCoordinateSystem() const
Get the Auger reference system centered on the tank.
Source GetSource() const
Source of the particle (eg. shower or background)
void SetParent(Particle &parent)