AuxDetReadout.cxx
Go to the documentation of this file.
1 ////////////////////////////////////////////////////////////////////////
2 /// \file AuxDetReadout.cxx
3 /// \brief A Geant4 sensitive detector that accumulates information.
4 /// \author miceli@fnal.gov
5 ////////////////////////////////////////////////////////////////////////
6 
9 
10 #include "Geant4/G4Step.hh"
11 #include "Geant4/G4StepPoint.hh"
12 #include "Geant4/G4ThreeVector.hh"
13 
14 #include <utility> // std::move()
15 #include <algorithm> // std::find()
16 
17 namespace larg4 {
18 
20  unsigned int adNum,
21  unsigned int svNum)
22  : G4VSensitiveDetector(name)
23  , fAuxDet(adNum)
24  , fAuxDetSensitive(svNum)
25  {
26  }
27 
28  //----------------------------------------------------------------------
30 
31  //---------------------------------------------------------------------------------------
32  // Called at the start of each event.
33  void AuxDetReadout::Initialize(G4HCofThisEvent*)
34  {}
35  //---------------------------------------------------------------------------------------
36  // Called at the end of each event.
37  void AuxDetReadout::EndOfEvent(G4HCofThisEvent*)
38  {
40  }
41  //---------------------------------------------------------------------------------------
43  {
44  fAuxDetIDEs.clear();
45  }
46 
47  //---------------------------------------------------------------------------------------
48  // Called for each step. Create a vector of AuxDetSimTrack objects. One for each new TrackID.
49  // update the exit position points if this TrackID is already on the vector.
50  G4bool AuxDetReadout::ProcessHits( G4Step* step, G4TouchableHistory* )
51  {
52  // collect the info for this step
53 
54  const int trackID = ParticleListAction::GetCurrentTrackID();
55 
56  G4double energyDeposited = step->GetTotalEnergyDeposit()/CLHEP::GeV;
57 
58  G4ThreeVector startG4(step->GetPreStepPoint()->GetPosition() );
59  double startWorld[3] = {startG4.getX()/CLHEP::cm,
60  startG4.getY()/CLHEP::cm,
61  startG4.getZ()/CLHEP::cm};
62 
63  double startTime = step->GetPreStepPoint()->GetGlobalTime()/CLHEP::ns;
64 
65  G4ThreeVector stopG4( step->GetPostStepPoint()->GetPosition());
66  double stopWorld[3] = {stopG4.getX()/CLHEP::cm,
67  stopG4.getY()/CLHEP::cm,
68  stopG4.getZ()/CLHEP::cm};
69 
70  G4ThreeVector stopG4Momentum( step->GetPostStepPoint()->GetMomentum());
71  double stopWorldMomVector[3] = {stopG4Momentum.getX()/CLHEP::GeV,
72  stopG4Momentum.getY()/CLHEP::GeV,
73  stopG4Momentum.getZ()/CLHEP::GeV};
74 
75  double stopTime = step->GetPostStepPoint()->GetGlobalTime()/CLHEP::ns;
76 
77  this->AddParticleStep( trackID,
78  energyDeposited,
79  startWorld[0],
80  startWorld[1],
81  startWorld[2],
82  startTime,
83  stopWorld[0],
84  stopWorld[1],
85  stopWorld[2],
86  stopTime,
87  stopWorldMomVector[0],
88  stopWorldMomVector[1],
89  stopWorldMomVector[2]
90  );
91 
92  return true;
93  }
94 
95  // Moved here from AuxDetSimChannel.cxx
97  int inputTrackID,
98  float inputEnergyDeposited,
99  float inputEntryX,
100  float inputEntryY,
101  float inputEntryZ,
102  float inputEntryT,
103  float inputExitX,
104  float inputExitY,
105  float inputExitZ,
106  float inputExitT,
107  float inputExitMomentumX,
108  float inputExitMomentumY,
109  float inputExitMomentumZ){
110 
111  sim::AuxDetIDE auxDetIDE;
112  auxDetIDE.trackID = inputTrackID;
113  auxDetIDE.energyDeposited = inputEnergyDeposited;
114  auxDetIDE.entryX = inputEntryX;
115  auxDetIDE.entryY = inputEntryY;
116  auxDetIDE.entryZ = inputEntryZ;
117  auxDetIDE.entryT = inputEntryT;
118  auxDetIDE.exitX = inputExitX;
119  auxDetIDE.exitY = inputExitY;
120  auxDetIDE.exitZ = inputExitZ;
121  auxDetIDE.exitT = inputExitT;
122  auxDetIDE.exitMomentumX = inputExitMomentumX;
123  auxDetIDE.exitMomentumY = inputExitMomentumY;
124  auxDetIDE.exitMomentumZ = inputExitMomentumZ;
125 
127  = std::find(fAuxDetIDEs.begin(), fAuxDetIDEs.end(), auxDetIDE);
128 
129  if(IDEitr != fAuxDetIDEs.end()){ //If trackID is already in the map, update it
130 
131  IDEitr->energyDeposited += inputEnergyDeposited;
132  IDEitr->exitX = inputExitX;
133  IDEitr->exitY = inputExitY;
134  IDEitr->exitZ = inputExitZ;
135  IDEitr->exitT = inputExitT;
136  IDEitr->exitMomentumX = inputExitMomentumX;
137  IDEitr->exitMomentumY = inputExitMomentumY;
138  IDEitr->exitMomentumZ = inputExitMomentumZ;
139  }
140  else{ //if trackID is not in the set yet, add it
141  fAuxDetIDEs.push_back(std::move(auxDetIDE));
142  }//else
143  }//AddParticleStep
144 
145  //---------------------------------------------------------------------------------------
146  // Never used but still have to be defined for G4
149 
150 } // namespace larg4
static constexpr double cm
Definition: Units.h:68
static QCString name
Definition: declinfo.cpp:673
AuxDetReadout(std::string const &name, unsigned int adNum, unsigned int svNum)
intermediate_table::iterator iterator
virtual G4bool ProcessHits(G4Step *, G4TouchableHistory *)
virtual void PrintAll()
std::string string
Definition: nybbler.cc:12
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:77
float entryT
Entry time of particle.
static constexpr double GeV
Definition: Units.h:28
virtual void DrawAll()
def move(depos, offset)
Definition: depos.py:107
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:79
std::vector< sim::AuxDetIDE > fAuxDetIDEs
list of IDEs in one channel
Definition: AuxDetReadout.h:80
float exitMomentumY
Exit Y-Momentum of particle.
virtual void Initialize(G4HCofThisEvent *)
QAsciiDict< Entry > ns
A Geant4 sensitive detector that accumulates information.
uint32_t fAuxDetSensitive
which sensitive volume of the AuxDet this AuxDetReadout corresponds to
Definition: AuxDetReadout.h:78