LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
AuxDetReadout.cxx
Go to the documentation of this file.
1 
9 
10 #include "Geant4/G4Step.hh"
11 #include "Geant4/G4StepPoint.hh"
12 #include "Geant4/G4ThreeVector.hh"
13 
14 #include <algorithm> // std::find()
15 #include <utility> // std::move()
16 
17 namespace larg4 {
18 
19  AuxDetReadout::AuxDetReadout(std::string const& name, unsigned int adNum, unsigned int svNum)
20  : G4VSensitiveDetector(name), fAuxDet(adNum), fAuxDetSensitive(svNum)
21  {}
22 
23  //----------------------------------------------------------------------
25 
26  //---------------------------------------------------------------------------------------
27  // Called at the start of each event.
29  //---------------------------------------------------------------------------------------
30  // Called at the end of each event.
32  {
34  }
35  //---------------------------------------------------------------------------------------
37  {
38  fAuxDetIDEs.clear();
39  }
40 
41  //---------------------------------------------------------------------------------------
42  // Called for each step. Create a vector of AuxDetSimTrack objects. One for each new TrackID.
43  // update the exit position points if this TrackID is already on the vector.
44  G4bool AuxDetReadout::ProcessHits(G4Step* step, G4TouchableHistory*)
45  {
46  // collect the info for this step
47 
48  const int trackID = ParticleListAction::GetCurrentTrackID();
49 
50  G4double energyDeposited = step->GetTotalEnergyDeposit() / CLHEP::GeV;
51 
52  G4ThreeVector startG4(step->GetPreStepPoint()->GetPosition());
53  double startWorld[3] = {
54  startG4.getX() / CLHEP::cm, startG4.getY() / CLHEP::cm, startG4.getZ() / CLHEP::cm};
55 
56  double startTime = step->GetPreStepPoint()->GetGlobalTime() / CLHEP::ns;
57 
58  G4ThreeVector stopG4(step->GetPostStepPoint()->GetPosition());
59  double stopWorld[3] = {
60  stopG4.getX() / CLHEP::cm, stopG4.getY() / CLHEP::cm, stopG4.getZ() / CLHEP::cm};
61 
62  G4ThreeVector stopG4Momentum(step->GetPostStepPoint()->GetMomentum());
63  double stopWorldMomVector[3] = {stopG4Momentum.getX() / CLHEP::GeV,
64  stopG4Momentum.getY() / CLHEP::GeV,
65  stopG4Momentum.getZ() / CLHEP::GeV};
66 
67  double stopTime = step->GetPostStepPoint()->GetGlobalTime() / CLHEP::ns;
68 
69  this->AddParticleStep(trackID,
70  energyDeposited,
71  startWorld[0],
72  startWorld[1],
73  startWorld[2],
74  startTime,
75  stopWorld[0],
76  stopWorld[1],
77  stopWorld[2],
78  stopTime,
79  stopWorldMomVector[0],
80  stopWorldMomVector[1],
81  stopWorldMomVector[2]);
82 
83  return true;
84  }
85 
86  // Moved here from AuxDetSimChannel.cxx
87  void AuxDetReadout::AddParticleStep(int inputTrackID,
88  float inputEnergyDeposited,
89  float inputEntryX,
90  float inputEntryY,
91  float inputEntryZ,
92  float inputEntryT,
93  float inputExitX,
94  float inputExitY,
95  float inputExitZ,
96  float inputExitT,
97  float inputExitMomentumX,
98  float inputExitMomentumY,
99  float inputExitMomentumZ)
100  {
101 
102  sim::AuxDetIDE auxDetIDE;
103  auxDetIDE.trackID = inputTrackID;
104  auxDetIDE.energyDeposited = inputEnergyDeposited;
105  auxDetIDE.entryX = inputEntryX;
106  auxDetIDE.entryY = inputEntryY;
107  auxDetIDE.entryZ = inputEntryZ;
108  auxDetIDE.entryT = inputEntryT;
109  auxDetIDE.exitX = inputExitX;
110  auxDetIDE.exitY = inputExitY;
111  auxDetIDE.exitZ = inputExitZ;
112  auxDetIDE.exitT = inputExitT;
113  auxDetIDE.exitMomentumX = inputExitMomentumX;
114  auxDetIDE.exitMomentumY = inputExitMomentumY;
115  auxDetIDE.exitMomentumZ = inputExitMomentumZ;
116 
118  std::find(fAuxDetIDEs.begin(), fAuxDetIDEs.end(), auxDetIDE);
119 
120  if (IDEitr != fAuxDetIDEs.end()) { //If trackID is already in the map, update it
121 
122  IDEitr->energyDeposited += inputEnergyDeposited;
123  IDEitr->exitX = inputExitX;
124  IDEitr->exitY = inputExitY;
125  IDEitr->exitZ = inputExitZ;
126  IDEitr->exitT = inputExitT;
127  IDEitr->exitMomentumX = inputExitMomentumX;
128  IDEitr->exitMomentumY = inputExitMomentumY;
129  IDEitr->exitMomentumZ = inputExitMomentumZ;
130  }
131  else { //if trackID is not in the set yet, add it
132  fAuxDetIDEs.push_back(std::move(auxDetIDE));
133  } //else
134  } //AddParticleStep
135 
136  //---------------------------------------------------------------------------------------
137  // Never used but still have to be defined for G4
140 
141 } // namespace larg4
AuxDetReadout(std::string const &name, unsigned int adNum, unsigned int svNum)
intermediate_table::iterator iterator
virtual G4bool ProcessHits(G4Step *, G4TouchableHistory *)
virtual void PrintAll()
int trackID
Geant4 supplied track ID.
float exitMomentumZ
Exit Z-Momentum of particle.
Geant4 interface.
virtual void EndOfEvent(G4HCofThisEvent *)
float exitY
Exit position Y of particle.
Collection of particles crossing one auxiliary detector cell.
uint32_t fAuxDet
which AuxDet this AuxDetReadout corresponds to
Definition: AuxDetReadout.h:74
Use Geant4&#39;s user "hooks" to maintain a list of particles generated by Geant4.
float entryT
Entry time of particle.
virtual void DrawAll()
float exitMomentumX
Exit X-Momentum of particle.
virtual void clear()
float exitT
Exit time of particle.
float exitZ
Exit position Z of particle.
float entryZ
Entry position Z of particle.
float exitX
Exit position X of particle.
float energyDeposited
total energy deposited for this track ID and time
float entryX
Entry position X of particle.
float entryY
Entry position Y of particle.
virtual void AddParticleStep(int inputTrackID, float inputEnergyDeposited, float inputEntryX, float inputEntryY, float inputEntryZ, float inputEntryT, float inputExitX, float inputExitY, float inputExitZ, float inputExitT, float inputExitMomentumX, float inputExitMomentumY, float inputExitMomentumZ)
MC truth information to make RawDigits and do back tracking.
sim::AuxDetSimChannel fAuxDetSimChannel
Contains the sim::AuxDetSimChannel for this AuxDet.
Definition: AuxDetReadout.h:77
std::vector< sim::AuxDetIDE > fAuxDetIDEs
list of IDEs in one channel
Definition: AuxDetReadout.h:78
float exitMomentumY
Exit Y-Momentum of particle.
virtual void Initialize(G4HCofThisEvent *)
A Geant4 sensitive detector that accumulates information.
uint32_t fAuxDetSensitive
which sensitive volume of the AuxDet this AuxDetReadout corresponds to
Definition: AuxDetReadout.h:76