GenericCRT.cxx
Go to the documentation of this file.
1 /*!
2  * Title: GenericCRT Utility Class
3  * Author: Andrzej Szelc (andrzejs@fnal.gov)
4  *
5  * Description:
6  * Class with Algorithms to convert sim::AuxDetHits to sim::AuxDetSimChannels
7  *
8 */
9 
10 
11 #include "GenericCRT.h"
12 
13 #include <utility> // std::move()
14 #include <algorithm> // std::find()
15 
16 
18  {
19  sim::AuxDetIDE outputIDE;
20 
21  outputIDE.trackID = InputHit.GetTrackID();
22  outputIDE.energyDeposited = InputHit.GetEnergyDeposited();
23  outputIDE.entryX = InputHit.GetEntryX();
24  outputIDE.entryY = InputHit.GetEntryY();
25  outputIDE.entryZ = InputHit.GetEntryZ();
26  outputIDE.entryT = InputHit.GetEntryT();
27  outputIDE.exitX = InputHit.GetExitX();
28  outputIDE.exitY = InputHit.GetExitY();
29  outputIDE.exitZ = InputHit.GetExitZ();
30  outputIDE.exitT = InputHit.GetExitT();
31  outputIDE.exitMomentumX = InputHit.GetExitMomentumX();
32  outputIDE.exitMomentumY = InputHit.GetExitMomentumY();
33  outputIDE.exitMomentumZ = InputHit.GetExitMomentumZ();
34 
35 
36  return outputIDE;
37 }
38 
39 
40 
41 std::vector<unsigned int> sim::GenericCRTUtility::GetAuxDetChannels(const std::vector<sim::AuxDetHit>& InputHitVector) const
42 {
43 
44  std::vector<unsigned int> AuxDetChanNumber;
45  AuxDetChanNumber.reserve(size(InputHitVector));
46 
47 
48  for(auto const& hit : InputHitVector)
49  {
50 
52  = std::find(AuxDetChanNumber.begin(), AuxDetChanNumber.end(), hit.GetID());
53 
54  if(Chanitr == AuxDetChanNumber.end()){ //If trackID is already in the map, update it
55  //if channel ID is not in the set yet, add it
56  AuxDetChanNumber.push_back(hit.GetID());
57  }//
58 
59  }
60 
61 return AuxDetChanNumber;
62 
63 }
64 
65 
66 
67 sim::AuxDetSimChannel sim::GenericCRTUtility::GetAuxDetSimChannelByNumber(const std::vector<sim::AuxDetHit>& InputHitVector, unsigned int inputchannel) const
68 {
69  std::vector<sim::AuxDetIDE> IDEvector;
70  //loop over sim::AuxDetHits and assign them to AuxDetSimChannels.
71 
72  size_t ad_id_no = 9999;
73  size_t ad_sen_id_no = 9999;
74 
75  for (auto const& auxDetHit : InputHitVector)
76  {
77 
78  double xcoordinate = (auxDetHit.GetEntryX() + auxDetHit.GetExitX())/2.0;
79  double ycoordinate = (auxDetHit.GetEntryY() + auxDetHit.GetExitY())/2.0;
80  double zcoordinate = (auxDetHit.GetEntryZ() + auxDetHit.GetExitZ())/2.0;
81  double worldPos[3] = {xcoordinate,ycoordinate,zcoordinate};
82  fGeo->FindAuxDetSensitiveAtPosition(worldPos, ad_id_no, ad_sen_id_no, 0.0001);
83  if(auxDetHit.GetID() == inputchannel) // this is the channel we want.
84  {
85  auto tempIDE = toAuxDetIDE(auxDetHit);
86 
88  = std::find(IDEvector.begin(), IDEvector.end(), tempIDE);
89 
90  if(IDEitr != IDEvector.end()){ //If trackID is already in the map, update it
91  //Andrzej's note - following logic from AuxDetReadout in Legacy, but why are the other paremeters getting overwritten like that?
92  IDEitr->energyDeposited += tempIDE.energyDeposited;
93  IDEitr->exitX = tempIDE.exitX;
94  IDEitr->exitY = tempIDE.exitY;
95  IDEitr->exitZ = tempIDE.exitZ;
96  IDEitr->exitT = tempIDE.exitT;
97  IDEitr->exitMomentumX = tempIDE.exitMomentumX;
98  IDEitr->exitMomentumY = tempIDE.exitMomentumY;
99  IDEitr->exitMomentumZ = tempIDE.exitMomentumZ;
100  }
101  else{ //if trackID is not in the set yet, add it
102  IDEvector.push_back(std::move(tempIDE));
103  }//else
104 
105  break;
106  } // end if the AuxDetHit channel checks out.
107 
108  } // end main loop on AuxDetHit
109 
110  //push back the AuxDetSimChannel Vector.
111  //TODO check the last parameter values.
112  return sim::AuxDetSimChannel(ad_id_no, std::move(IDEvector), ad_sen_id_no);
113 }
114 
115 
116 
117 
118 std::vector<sim::AuxDetSimChannel> sim::GenericCRTUtility::GetAuxDetSimChannels(const std::vector<sim::AuxDetHit>& InputHitVector) const
119 {
120  auto const auxDetChannels = GetAuxDetChannels(InputHitVector);
121  std::vector<sim::AuxDetSimChannel> auxDetVector;
122  auxDetVector.reserve(size(auxDetChannels));
123 
124  for (auto const channelNum : auxDetChannels) {
125  auxDetVector.push_back(GetAuxDetSimChannelByNumber(InputHitVector, channelNum));
126  }
127 
128  return auxDetVector;
129 }
void FindAuxDetSensitiveAtPosition(geo::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.
intermediate_table::iterator iterator
unsigned int GetTrackID() const
Definition: AuxDetHit.h:169
sim::AuxDetIDE toAuxDetIDE(sim::AuxDetHit const &InputHit) const
Definition: GenericCRT.cxx:17
sim::AuxDetSimChannel GetAuxDetSimChannelByNumber(const std::vector< sim::AuxDetHit > &InputHitVector, unsigned int inputchannel) const
Definition: GenericCRT.cxx:67
float GetExitX() const
Definition: AuxDetHit.h:121
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:41
float GetExitMomentumY() const
Definition: AuxDetHit.h:81
float exitY
Exit position Y of particle.
decltype(auto) constexpr size(T &&obj)
ADL-aware version of std::size.
Definition: StdUtils.h:92
Collection of particles crossing one auxiliary detector cell.
art::ServiceHandle< geo::Geometry const > fGeo
Definition: GenericCRT.h:40
float entryT
Entry time of particle.
std::vector< sim::AuxDetSimChannel > GetAuxDetSimChannels(const std::vector< sim::AuxDetHit > &InputHitVector) const
Definition: GenericCRT.cxx:118
float GetEntryX() const
Definition: AuxDetHit.h:153
def move(depos, offset)
Definition: depos.py:107
float exitMomentumX
Exit X-Momentum of particle.
float exitT
Exit time of particle.
float GetExitT() const
Definition: AuxDetHit.h:97
float GetEntryT() const
Definition: AuxDetHit.h:129
float GetEnergyDeposited() const
Definition: AuxDetHit.h:161
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:113
float entryX
Entry position X of particle.
float entryY
Entry position Y of particle.
float GetExitMomentumX() const
Definition: AuxDetHit.h:89
float GetEntryZ() const
Definition: AuxDetHit.h:137
float GetExitZ() const
Definition: AuxDetHit.h:105
MC truth information to make RawDigits and do back tracking.
float exitMomentumY
Exit Y-Momentum of particle.
float GetExitMomentumZ() const
Definition: AuxDetHit.h:73
float GetEntryY() const
Definition: AuxDetHit.h:145