LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
GenericCRT.cxx
Go to the documentation of this file.
1 
10 #include "GenericCRT.h"
11 
13 
14 #include "CLHEP/Evaluator/Evaluator.h"
15 
16 #include <algorithm> // std::find()
17 #include <utility> // std::move()
18 
19 sim::GenericCRTUtility::GenericCRTUtility(const std::string energyUnitsScale)
20 {
21  HepTool::Evaluator eval;
22  eval.setStdMath();
23  eval.setSystemOfUnits();
24 
25  const std::string scaleExpression = "MeV / " + energyUnitsScale;
26  fEnergyUnitsScale = eval.evaluate(scaleExpression.c_str());
27 
28  if (eval.status() != 0) fEnergyUnitsScale = 1.;
29 }
30 
32 {
33  sim::AuxDetIDE outputIDE;
34 
35  outputIDE.trackID = InputHit.GetTrackID();
36  outputIDE.energyDeposited = InputHit.GetEnergyDeposited() * fEnergyUnitsScale;
37  outputIDE.entryX = InputHit.GetEntryX();
38  outputIDE.entryY = InputHit.GetEntryY();
39  outputIDE.entryZ = InputHit.GetEntryZ();
40  outputIDE.entryT = InputHit.GetEntryT();
41  outputIDE.exitX = InputHit.GetExitX();
42  outputIDE.exitY = InputHit.GetExitY();
43  outputIDE.exitZ = InputHit.GetExitZ();
44  outputIDE.exitT = InputHit.GetExitT();
45  outputIDE.exitMomentumX = InputHit.GetExitMomentumX();
46  outputIDE.exitMomentumY = InputHit.GetExitMomentumY();
47  outputIDE.exitMomentumZ = InputHit.GetExitMomentumZ();
48 
49  return outputIDE;
50 }
51 
53  const std::vector<sim::AuxDetHit>& InputHitVector) const
54 {
55 
56  std::vector<unsigned int> AuxDetChanNumber;
57  AuxDetChanNumber.reserve(size(InputHitVector));
58 
59  for (auto const& hit : InputHitVector) {
60 
62  std::find(AuxDetChanNumber.begin(), AuxDetChanNumber.end(), hit.GetID());
63 
64  if (Chanitr == AuxDetChanNumber.end()) { //If trackID is already in the map, update it
65  //if channel ID is not in the set yet, add it
66  AuxDetChanNumber.push_back(hit.GetID());
67  } //
68  }
69 
70  return AuxDetChanNumber;
71 }
72 
74  const std::vector<sim::AuxDetHit>& InputHitVector,
75  unsigned int inputchannel) const
76 {
77  std::vector<sim::AuxDetIDE> IDEvector;
78  //loop over sim::AuxDetHits and assign them to AuxDetSimChannels.
79 
80  size_t ad_id_no = 9999;
81  size_t ad_sen_id_no = 9999;
82 
83  for (auto const& auxDetHit : InputHitVector) {
84 
85  double xcoordinate = (auxDetHit.GetEntryX() + auxDetHit.GetExitX()) / 2.0;
86  double ycoordinate = (auxDetHit.GetEntryY() + auxDetHit.GetExitY()) / 2.0;
87  double zcoordinate = (auxDetHit.GetEntryZ() + auxDetHit.GetExitZ()) / 2.0;
88  geo::Point_t const worldPos{xcoordinate, ycoordinate, zcoordinate};
89 
90  if (auxDetHit.GetID() == inputchannel) // this is the channel we want.
91  {
92  // Find the IDs given the hit position
93  fGeo->FindAuxDetSensitiveAtPosition(worldPos, ad_id_no, ad_sen_id_no, 0.0001);
94 
95  mf::LogDebug("GenericCRTUtility")
96  << "Found an AuxDetHit with ID " << auxDetHit.GetID() << " for AuxDet ID " << ad_id_no
97  << " Sens ID " << ad_sen_id_no << std::endl;
98 
99  auto tempIDE = toAuxDetIDE(auxDetHit);
100 
102  std::find(IDEvector.begin(), IDEvector.end(), tempIDE);
103 
104  if (IDEitr != IDEvector.end()) { //If trackID is already in the map, update it
105  //Andrzej's note - following logic from AuxDetReadout in Legacy, but why are the other paremeters getting overwritten like that?
106  IDEitr->energyDeposited += tempIDE.energyDeposited;
107  IDEitr->exitX = tempIDE.exitX;
108  IDEitr->exitY = tempIDE.exitY;
109  IDEitr->exitZ = tempIDE.exitZ;
110  IDEitr->exitT = tempIDE.exitT;
111  IDEitr->exitMomentumX = tempIDE.exitMomentumX;
112  IDEitr->exitMomentumY = tempIDE.exitMomentumY;
113  IDEitr->exitMomentumZ = tempIDE.exitMomentumZ;
114  }
115  else { //if trackID is not in the set yet, add it
116  IDEvector.push_back(std::move(tempIDE));
117  } //else
118 
119  // break;
120  } // end if the AuxDetHit channel checks out.
121 
122  } // end main loop on AuxDetHit
123 
124  mf::LogDebug("GenericCRTUtility")
125  << "Returning AuxDetSimChannel for ID " << ad_id_no << " " << ad_sen_id_no << ", with "
126  << IDEvector.size() << " IDEs." << std::endl;
127 
128  //push back the AuxDetSimChannel Vector.
129  //TODO check the last parameter values.
130  return sim::AuxDetSimChannel(ad_id_no, std::move(IDEvector), ad_sen_id_no);
131 }
132 
133 std::vector<sim::AuxDetSimChannel> sim::GenericCRTUtility::GetAuxDetSimChannels(
134  const std::vector<sim::AuxDetHit>& InputHitVector) const
135 {
136  auto const auxDetChannels = GetAuxDetChannels(InputHitVector);
137  std::vector<sim::AuxDetSimChannel> auxDetVector;
138  auxDetVector.reserve(size(auxDetChannels));
139 
140  for (auto const channelNum : auxDetChannels) {
141  auxDetVector.push_back(GetAuxDetSimChannelByNumber(InputHitVector, channelNum));
142  }
143 
144  return auxDetVector;
145 }
intermediate_table::iterator iterator
unsigned int GetTrackID() const
Definition: AuxDetHit.h:119
sim::AuxDetIDE toAuxDetIDE(sim::AuxDetHit const &InputHit) const
Definition: GenericCRT.cxx:31
sim::AuxDetSimChannel GetAuxDetSimChannelByNumber(const std::vector< sim::AuxDetHit > &InputHitVector, unsigned int inputchannel) const
Definition: GenericCRT.cxx:73
float GetExitX() const
Definition: AuxDetHit.h:95
int trackID
Geant4 supplied track ID.
float exitMomentumZ
Exit Z-Momentum of particle.
std::vector< unsigned int > GetAuxDetChannels(const std::vector< sim::AuxDetHit > &InputHitVector) const
Definition: GenericCRT.cxx:52
float GetExitMomentumY() const
Definition: AuxDetHit.h:75
float exitY
Exit position Y of particle.
decltype(auto) constexpr size(T &&obj)
ADL-aware version of std::size.
Definition: StdUtils.h:101
Collection of particles crossing one auxiliary detector cell.
art::ServiceHandle< geo::Geometry const > fGeo
Definition: GenericCRT.h:43
float entryT
Entry time of particle.
std::vector< sim::AuxDetSimChannel > GetAuxDetSimChannels(const std::vector< sim::AuxDetHit > &InputHitVector) const
Definition: GenericCRT.cxx:133
float GetEntryX() const
Definition: AuxDetHit.h:111
void FindAuxDetSensitiveAtPosition(Point_t const &point, std::size_t &adg, std::size_t &sv, double tolerance=0) const
Fills the indices of the sensitive auxiliary detector at location.
float exitMomentumX
Exit X-Momentum of particle.
GenericCRTUtility(const std::string energyUnitsScale)
Definition: GenericCRT.cxx:19
float exitT
Exit time of particle.
float GetExitT() const
Definition: AuxDetHit.h:83
float GetEntryT() const
Definition: AuxDetHit.h:99
float GetEnergyDeposited() const
Definition: AuxDetHit.h:115
float exitZ
Exit position Z of particle.
float entryZ
Entry position Z of particle.
float exitX
Exit position X of particle.
Detector simulation of raw signals on wires.
float energyDeposited
total energy deposited for this track ID and time
float GetExitY() const
Definition: AuxDetHit.h:91
ROOT::Math::PositionVector3D< ROOT::Math::Cartesian3D< double >, ROOT::Math::GlobalCoordinateSystemTag > Point_t
Type for representation of position in physical 3D space.
Definition: geo_vectors.h:180
float entryX
Entry position X of particle.
float entryY
Entry position Y of particle.
float GetExitMomentumX() const
Definition: AuxDetHit.h:79
float GetEntryZ() const
Definition: AuxDetHit.h:103
MaybeLogger_< ELseverityLevel::ELsev_success, false > LogDebug
float GetExitZ() const
Definition: AuxDetHit.h:87
MC truth information to make RawDigits and do back tracking.
float exitMomentumY
Exit Y-Momentum of particle.
float GetExitMomentumZ() const
Definition: AuxDetHit.h:71
float GetEntryY() const
Definition: AuxDetHit.h:107