Deprecated/UpgradeASCIITests/G4TankSimulatorASCII/G4TankPMTAction.cc
Go to the documentation of this file.
1 #include "G4TankPMTAction.h"
2 #include "G4TankTrackingAction.h"
4 #include "G4TankEventAction.h"
5 #include "G4TankSimulator.h"
6 #include "G4TankSteppingAction.h"
7 #include "ParticleCases.h"
8 
9 #include <sevt/PMT.h>
10 #include <sevt/PMTSimData.h>
11 #include <sevt/SEvent.h>
12 #include <sevt/Station.h>
13 #include <sevt/StationSimData.h>
14 
15 #include <utl/ErrorLogger.h>
16 #include <utl/Particle.h>
17 #include <utl/Trace.h>
18 
19 #include <fwk/RunController.h>
20 
21 #include <G4Event.hh>
22 #include <G4HCofThisEvent.hh>
23 #include <G4SDManager.hh>
24 #include <G4Step.hh>
25 #include <G4TouchableHistory.hh>
26 #include <G4Track.hh>
27 #include <G4Trajectory.hh>
28 #include <G4TrajectoryContainer.hh>
29 #include <G4VHitsCollection.hh>
30 
31 #include <iostream>
32 
33 using namespace std;
34 using namespace G4TankSimulatorASCII;
35 using namespace sevt;
36 using namespace utl;
37 using namespace fwk;
38 
39 
40 G4TankPMTAction::G4TankPMTAction(const G4String name, const int pmtIndex) :
41  G4VSensitiveDetector(name),
42  fPMTIndex(pmtIndex)
43 {
44  if (fPMTIndex < 1 || fPMTIndex > 3) {
45  FATAL("G4PMTAction() : invalid PMT index.");
46  exit(EXIT_FAILURE);
47  }
48 
50  dynamic_cast<G4TankSimulator*>(&RunController::GetInstance().GetModule("G4TankSimulatorASCII"));
51 }
52 
53 
54 G4bool
55 G4TankPMTAction::ProcessHits(G4Step* theStep, G4TouchableHistory* /*R0Hist*/)
56 {
57  const double time = theStep->GetPreStepPoint()->GetGlobalTime();
58 
59  // get current particle from G4TankStepping action.
60  // use to reject hits registered in sensitive volume
61  // in case the particle is not a photon
62  const int currentParticle = G4TankSteppingAction::GetCurrentParticleId();
63 
64  // This is related to bug #156
65  if (time >= 1*utl::second || currentParticle)
66  return true;
67 
69 
71 
72  PMTSimData& pmtSim = station.GetPMT(fPMTIndex).GetSimData();
73 
75 
76  switch (particle) {
77  case OFFLINE_PHOTON:
79  if (fG4TankSimulator->GetCurrentParticleIt()->GetSource() == Particle::eShowerFromMuonDecay) {
83  }
84  break;
85  case OFFLINE_ELECTRONS:
87  if (fG4TankSimulator->GetCurrentParticleIt()->GetSource() == Particle::eShowerFromMuonDecay) {
91  }
92  break;
93  case OFFLINE_MUONS:
95  break;
96  default:
98  break;
99  }
100 
101  if (!pmtSim.HasPETimeDistribution())
102  pmtSim.MakePETimeDistribution();
103  pmtSim.GetPETimeDistribution().AddTime(time);
104 
105  if (!pmtSim.HasPETimeDistribution(component))
106  pmtSim.MakePETimeDistribution(component);
107  pmtSim.GetPETimeDistribution(component).AddTime(time);
108 
109  const bool IsFromMuonDecay= theStep->GetTrack()->GetUserInformation();
110  if ( IsFromMuonDecay )
111  {
114  }
115 
116  return true;
117 }
constexpr double second
Definition: AugerUnits.h:145
PMTSimData & GetSimData()
Get object containing PMT simulated data.
Definition: SEvent/PMT.h:40
total (shower and background)
#define FATAL(message)
Macro for logging fatal messages.
Definition: ErrorLogger.h:167
int exit
Definition: dump1090.h:237
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
electrons and positrons from shower
class to hold data at Station level
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.