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