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