G4UMDScintStripAction.cc
Go to the documentation of this file.
2 #include "G4StationSimulator.h"
4 #include "G4Utils.h"
5 
6 #include <utl/Particle.h>
7 #include <utl/ParticleCases.h>
8 
9 #include <utl/Segment.h>
10 #include <utl/Plane.h>
11 #include <utl/Point.h>
12 #include <utl/GeometryUtilities.h>
13 #include <utl/PhysicalConstants.h>
14 
15 #include <mdet/MDetector.h>
16 #include <mdet/Counter.h>
17 
18 #include <G4Step.hh>
19 #include <G4TouchableHistory.hh>
20 #include <G4ios.hh>
21 #include <G4SystemOfUnits.hh>
22 #include <G4RunManager.hh>
23 #include <G4OpticalPhoton.hh>
24 
25 
26 namespace G4StationSimulatorOG {
27 
29  G4VSensitiveDetector(name),
30  fG4StationSimulator(
31  dynamic_cast<G4StationSimulator&>(fwk::RunController::GetInstance().GetModule("G4StationSimulatorOG"))
32  )
33  { }
34 
35 
36  G4bool
37  G4UMDScintStripAction::ProcessHits(G4Step* const step, G4TouchableHistory* const /*rOhist*/)
38  {
39  // If it is an opticalphoton, continue
40  if (step->GetTrack()->GetDefinition() == G4OpticalPhoton::OpticalPhotonDefinition())
41  return true;
42 
43  // Retrieve current physical volumen and its name (i.e. the current physical strip)
44  G4VPhysicalVolume* const currentPhysVol = step->GetPreStepPoint()->GetPhysicalVolume();
45  // Retrieve mother volume of the current physical volumen and its name (i.e. the current physical module)
46  G4VPhysicalVolume* const motherPhysVol = step->GetPreStepPoint()->GetTouchableHandle()->GetVolume(1);
47  //const G4String& moduleName = motherPhysVol->GetName();
48 
49  const G4int stripId = currentPhysVol->GetCopyNo();
50  const G4int moduleId = motherPhysVol->GetCopyNo();
51 
52  // Particle
53  const int particleId = step->GetTrack()->GetDefinition()->GetPDGEncoding();
54  const double stepLen = step->GetStepLength() * (utl::m / CLHEP::m);
55 
57 
59 
60  const auto position = To<utl::Point>(step->GetTrack()->GetPosition(), cs, utl::meter/CLHEP::meter);
61 
62  const utl::TimeInterval time = step->GetTrack()->GetGlobalTime() * (utl::ns / CLHEP::ns);
63 
64  // Only first step inside scintillator (PreStepPoint() == fGeomBoundary on:
65  //
66  // vol1 | vol2 (Scint) | vol3
67  // | |
68  // | CurrStep |
69  // |o----------------o |
70  // | |
71  // |PrePoint PostPoint |
72  // | |
73  // | |
74  // | |
75  //
76  // GeomBoundary Vol1-Vol2 GeomBoundary Vol2-Vol3
77 
78  if (step->GetPreStepPoint()->GetStepStatus() == fGeomBoundary) {
79 
80  G4StationTrackingAction* const trackingA = (G4StationTrackingAction*)G4RunManager::GetRunManager()->GetUserTrackingAction();
82 
83  const double kineticEnergy = step->GetTrack()->GetKineticEnergy() * (utl::MeV / CLHEP::MeV);
84  const auto direction = To<utl::Vector>(step->GetPreStepPoint()->GetMomentumDirection(), cs, 1);
85  const utl::Particle injectedParticle(particleId, type, position, direction, time, 1, kineticEnergy);
86 
87  // Skip non muon particles if desired (useful to study corner-clipping impact by particles other than muons)
89  particleId != utl::Particle::eMuon &&
90  particleId != utl::Particle::eAntiMuon)
91  return false;
92 
93  fG4StationSimulator.AddInjectedParticle(moduleId, stripId, injectedParticle);
94  // Allows to keep memory of the first time the current particle enters in the current strip
95  trackingA->SetFirstStepInVolume(false);
96 
97  }
98 
100 
101  const double depE = step->GetTotalEnergyDeposit() * (utl::eV / CLHEP::eV);
102 
103  // if no energy is deposited, no photons (and thus no photoelectrons) will be produced
104  if (!depE)
105  return true;
106 
107  const mdet::Module& detMod = dCounter.GetModule(moduleId);
108  const mdet::Scintillator& detSci = detMod.GetScintillator(stripId);
109  const mdet::Fiber& fiber = detMod.GetFiberFor(detSci);
110 
112 
113  if (!counter.HasModule(moduleId))
114  counter.MakeModule(moduleId);
115 
116  mevt::Module& evtMod = counter.GetModule(moduleId);
117 
118  if (!evtMod.HasScintillator(stripId))
119  evtMod.MakeScintillator(stripId);
120 
121  mevt::Scintillator& evtScint = evtMod.GetScintillator(stripId);
122 
123  if (!evtScint.HasSimData())
124  evtScint.MakeSimData();
125 
126  mevt::ScintillatorSimData& simData = evtScint.GetSimData();
127 
128  if (!simData.HasAnalogicTrace())
129  simData.MakeAnalogicTrace();
130 
131  simData.AddEnergyDeposit(depE);
132  if (particleId == utl::Particle::eMuon || particleId == utl::Particle::eAntiMuon)
133  simData.AddEnergyDepositMuons(depE);
134 
135  // Compute a plane perpendicular to the fiber.
136  const auto& fcs = fiber.GetLocalCoordinateSystem();
137  const utl::Plane targetPlane(utl::Point(0, 0, 0, fcs), utl::Vector(1, 0, 0, fcs));
138 
139  // The on-scintillator distance is the distance from the current point to the plane
140  // Notice this distance is signed; can be negative value (depending on the normal-to-the-plane orientation).
141  const double onScint = std::abs(utl::Distance(position, targetPlane));
142 
143  // Extra fiber length to arrive to the optical sensor (either PMT or SiPM).
144  const double onManifold = fiber.GetOnManifoldLength();
145 
146  // Total distance.
147  const double pathLen = onScint + onManifold;
148 
149  // Compute the number of photo-electron from attenuation curve
150  unsigned int nSPE = fiber.ComputeSPENumber(pathLen, stepLen, depE);
151 
152  // These are the same for every spe:
153  const double pathDelay = pathLen * fiber.GetRefractionIndex() / utl::kSpeedOfLight;
154 
155  // Now the arrival time
156  const double particleDelay = time.GetInterval();
157 
158  for (unsigned int n = 0; n < nSPE; ++n) {
159  const double delay =
160  pathDelay +
161  fiber.ComputeDecayDelay() +
162  detSci.ComputeDecayDelay() +
163  particleDelay;
164  fG4StationSimulator.AddUMDPhoton(moduleId, stripId, delay);
165  }
166  }
167 
168  return true;
169  }
170 
171 }
const double eV
Definition: GalacticUnits.h:35
void AddEnergyDepositMuons(const double edep)
constexpr double eV
Definition: AugerUnits.h:185
const Module & GetModule(const int mId) const
Retrieve by id a constant module.
Point object.
Definition: Point.h:32
bool HasScintillator(const int sId) const
unsigned int ComputeSPENumber(double x, double l, double e) const
Computes a number of SPE given the impinging distance, the length of the track and the energy of the ...
Definition: Fiber.cc:227
void MakeScintillator(const int sId)
const mdet::Counter & GetDetectorUMDCounter() const
Describes a particle for Simulation.
Definition: Particle.h:26
utl::CoordinateSystemPtr GetLocalCoordinateSystem() const
Local system based on position and configured rotations.
const double meter
Definition: GalacticUnits.h:29
const Fiber & GetFiberFor(const Component &c) const
Linking between fibers, scintillators, channels and pixels.
double Distance(const Line &line1, const Line &line2)
constexpr double MeV
Definition: AugerUnits.h:184
Scintillator & GetScintillator(const int sId)
Actual muon-sensitive objects.
Scintillator level event data.
boost::shared_ptr< const CoordinateTransformer > CoordinateSystemPtr
Shared pointer for coordinate systems.
Module level event data.
Definition: MEvent/Module.h:41
Class describing a Plane object.
Definition: Plane.h:17
void AddInjectedParticle(const size_t modId, const size_t pixId, const utl::Particle &injectedParticle) const
static int delay
Definition: XbAlgo.cc:20
const double ns
double abs(const SVector< n, T > &v)
constexpr double meter
Definition: AugerUnits.h:81
Array of Scintillator.
virtual G4bool ProcessHits(G4Step *const step, G4TouchableHistory *const rOhist) override
void AddEnergyDeposit(const double edep)
Root detector of the muon detector hierarchy.
constexpr double kSpeedOfLight
Scintillator level simulation data.
A TimeInterval is used to represent time elapsed between two events.
Definition: TimeInterval.h:43
void MakeModule(const int mId)
class that handles Geant4 SD Station simulation adopted from G4TankSimulator
Vector object.
Definition: Vector.h:30
double ComputeDecayDelay() const
Computes a delay due to decay process.
Definition: Fiber.cc:116
constexpr double ns
Definition: AugerUnits.h:162
double ComputeDecayDelay() const
Computes a delay due to decay process.
bool HasSimData() const
Optical mdet::Fiber used to conect mdet::Scintillator to mdet::Pixel.
Definition: Fiber.h:54
const Scintillator & GetScintillator(int sId) const
Direct accesor by id.
constexpr double m
Definition: AugerUnits.h:121
void AddUMDPhoton(const size_t modId, const size_t pixId, const double peTime) const
ScintillatorSimData & GetSimData()
double GetRefractionIndex() const
The refraction (or refractive) index of the fiber.
Definition: Fiber.cc:102
double GetOnManifoldLength() const
The length of the fiber along the path that joins the scintillator to its pixel on the PMT...
Definition: Fiber.cc:65

, generated on Tue Sep 26 2023.