G4XTankPMTAction.cc
Go to the documentation of this file.
1 #include "G4XTankPMTAction.h"
2 #include "G4XTankEventAction.h"
3 #include "G4XTankSimulator.h"
5 
6 #include <sevt/PMT.h>
7 #include <sevt/PMTSimData.h>
8 #include <sevt/SEvent.h>
9 #include <sevt/Station.h>
10 #include <sevt/StationSimData.h>
11 
12 #include <utl/ErrorLogger.h>
13 #include <utl/Particle.h>
14 #include <utl/ParticleCases.h>
15 #include <utl/Trace.h>
16 
17 #include <fwk/RunController.h>
18 
19 #include <G4Event.hh>
20 #include <G4HCofThisEvent.hh>
21 #include <G4SDManager.hh>
22 #include <G4Step.hh>
23 #include <G4TouchableHistory.hh>
24 #include <G4Track.hh>
25 #include <G4Trajectory.hh>
26 #include <G4TrajectoryContainer.hh>
27 #include <G4VHitsCollection.hh>
28 
29 #include <iostream>
30 
31 using namespace std;
32 using namespace G4XTankSimulatorAG;
33 using namespace sevt;
34 using namespace utl;
35 using namespace fwk;
36 
37 
38 G4XTankPMTAction::G4XTankPMTAction(const G4String name, const int pmtIndex) :
39  G4VSensitiveDetector(name),
40  fPMTIndex(pmtIndex)
41 {
42  if (fPMTIndex < 1 || fPMTIndex > 3) {
43  FATAL("G4PMTAction() : invalid PMT index.");
44  exit(EXIT_FAILURE);
45  }
46 
48  dynamic_cast<G4XTankSimulator*>(&RunController::GetInstance().GetModule("G4XTankSimulatorAG"));
49 }
50 
51 
52 G4bool
53 G4XTankPMTAction::ProcessHits(G4Step* theStep, G4TouchableHistory* /*R0Hist*/)
54 {
55  const double time = theStep->GetPreStepPoint()->GetGlobalTime();
56 
57  // get current particle from G4XTankStepping action.
58  // use to reject hits registered in sensitive volume
59  // in case the particle is not a photon
60  const int currentParticle = G4XTankSteppingAction::GetCurrentParticleId();
61 
62  // This is related to bug #156
63  if (time >= 1*utl::second || currentParticle)
64  return true;
65 
67 
69 
70  PMTSimData& pmtSim = station.GetPMT(fPMTIndex).GetSimData();
71 
73 
74  switch (particle) {
75  case OFFLINE_PHOTON:
77  if (fG4XTankSimulator->GetCurrentParticleIt()->GetSource() == Particle::eShowerFromMuonDecay) {
81  }
82  break;
83  case OFFLINE_ELECTRONS:
85  if (fG4XTankSimulator->GetCurrentParticleIt()->GetSource() == Particle::eShowerFromMuonDecay) {
89  }
90  break;
91  case OFFLINE_MUONS:
93  break;
94  case OFFLINE_HADRONS:
96  break;
97  default:
98  {
99  ostringstream warn;
100  warn << "Unknown utl::Particle type " << particle << " encountered!";
101  WARNING(warn);
102  }
103  pmtSim.GetPETimeDistribution().AddTime(time);
104  return true;
105  }
106 
107  if (!pmtSim.HasPETimeDistribution())
108  pmtSim.MakePETimeDistribution();
109  pmtSim.GetPETimeDistribution().AddTime(time);
110 
111  if (!pmtSim.HasPETimeDistribution(component))
112  pmtSim.MakePETimeDistribution(component);
113  pmtSim.GetPETimeDistribution(component).AddTime(time);
114 
115  return true;
116 }
constexpr double second
Definition: AugerUnits.h:145
PMTSimData & GetSimData()
Get object containing PMT simulated data.
Definition: SEvent/PMT.h:40
total (shower and background)
class that handles Geant4 SD simulation
#define FATAL(message)
Macro for logging fatal messages.
Definition: ErrorLogger.h:167
int exit
Definition: dump1090.h:237
static sevt::StationSimData::ParticleIterator GetCurrentParticleIt()
bool HasPETimeDistribution(const StationConstants::SignalComponent source=StationConstants::eTotal) const
Check if a PE release time distribution exists (optionally for a given source)
Definition: PMTSimData.h:65
G4bool ProcessHits(G4Step *theStep, G4TouchableHistory *R0Hist)
electrons and positrons from shower
class to hold data at Station level
#define WARNING(message)
Macro for logging warning messages.
Definition: ErrorLogger.h:163
static sevt::SEvent::StationIterator GetCurrentEventStationIt()
PMT & GetPMT(const unsigned int pmtId)
Retrive a PMT by Id.
Class to hold simulated data at PMT level.
Definition: PMTSimData.h:40
struct particle_info particle[80]
utl::TimeDistributionI & GetPETimeDistribution(const StationConstants::SignalComponent source=StationConstants::eTotal)
Simulated photoelectron time distribution.
Definition: PMTSimData.h:54
void AddTime(const double time, const T weight=T(1))
Add an entry (optionally weighted) for the given time. Slot will be computed.
mu+ and mu- (including signal from mu decay electrons) from shower
void MakePETimeDistribution(const StationConstants::SignalComponent source=StationConstants::eTotal)
Create a PE release time distribution (optionally for given source)
Definition: PMTSimData.cc:12

, generated on Tue Sep 26 2023.