All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Member Functions | Private Attributes | List of all members
sim::GenericCRTUtility Class Reference

#include <GenericCRT.h>

Public Member Functions

 GenericCRTUtility (const std::string energyUnitsScale)
 
sim::AuxDetIDE toAuxDetIDE (sim::AuxDetHit const &InputHit) const
 
std::vector< unsigned int > GetAuxDetChannels (const std::vector< sim::AuxDetHit > &InputHitVector) const
 
std::vector
< sim::AuxDetSimChannel
GetAuxDetSimChannels (const std::vector< sim::AuxDetHit > &InputHitVector) const
 
sim::AuxDetSimChannel GetAuxDetSimChannelByNumber (const std::vector< sim::AuxDetHit > &InputHitVector, unsigned int inputchannel) const
 

Private Attributes

art::ServiceHandle
< geo::Geometry const > 
fGeo
 
double fEnergyUnitsScale
 

Detailed Description

Definition at line 27 of file GenericCRT.h.

Constructor & Destructor Documentation

sim::GenericCRTUtility::GenericCRTUtility ( const std::string  energyUnitsScale)

Title: GenericCRT Utility Class Author: Andrzej Szelc (andrz.nosp@m.ejs@.nosp@m.fnal..nosp@m.gov)

Description: Class with Algorithms to convert sim::AuxDetHits to sim::AuxDetSimChannels

Definition at line 20 of file GenericCRT.cxx.

21 {
22  HepTool::Evaluator eval;
23  eval.setStdMath();
24  eval.setSystemOfUnits();
25 
26  const std::string scaleExpression = "MeV / " + energyUnitsScale;
27  fEnergyUnitsScale = eval.evaluate(scaleExpression.c_str());
28 
29  if(eval.status() != 0) fEnergyUnitsScale = 1.;
30 }

Member Function Documentation

std::vector< unsigned int > sim::GenericCRTUtility::GetAuxDetChannels ( const std::vector< sim::AuxDetHit > &  InputHitVector) const

Definition at line 56 of file GenericCRT.cxx.

57 {
58 
59  std::vector<unsigned int> AuxDetChanNumber;
60  AuxDetChanNumber.reserve(size(InputHitVector));
61 
62 
63  for(auto const& hit : InputHitVector)
64  {
65 
66  std::vector<unsigned int>::iterator Chanitr
67  = std::find(AuxDetChanNumber.begin(), AuxDetChanNumber.end(), hit.GetID());
68 
69  if(Chanitr == AuxDetChanNumber.end()){ //If trackID is already in the map, update it
70  //if channel ID is not in the set yet, add it
71  AuxDetChanNumber.push_back(hit.GetID());
72  }//
73 
74  }
75 
76  return AuxDetChanNumber;
77 
78 }
std::size_t size(FixedBins< T, C > const &) noexcept
Definition: FixedBins.h:561
process_name hit
Definition: cheaterreco.fcl:51
sim::AuxDetSimChannel sim::GenericCRTUtility::GetAuxDetSimChannelByNumber ( const std::vector< sim::AuxDetHit > &  InputHitVector,
unsigned int  inputchannel 
) const

Definition at line 82 of file GenericCRT.cxx.

83 {
84  std::vector<sim::AuxDetIDE> IDEvector;
85  //loop over sim::AuxDetHits and assign them to AuxDetSimChannels.
86 
87  size_t ad_id_no = 9999;
88  size_t ad_sen_id_no = 9999;
89 
90  for (auto const& auxDetHit : InputHitVector)
91  {
92 
93  double xcoordinate = (auxDetHit.GetEntryX() + auxDetHit.GetExitX())/2.0;
94  double ycoordinate = (auxDetHit.GetEntryY() + auxDetHit.GetExitY())/2.0;
95  double zcoordinate = (auxDetHit.GetEntryZ() + auxDetHit.GetExitZ())/2.0;
96  double worldPos[3] = {xcoordinate,ycoordinate,zcoordinate};
97 
98  if(auxDetHit.GetID() == inputchannel) // this is the channel we want.
99  {
100  // Find the IDs given the hit position
101  fGeo->FindAuxDetSensitiveAtPosition(worldPos, ad_id_no, ad_sen_id_no, 0.0001);
102 
103  mf::LogDebug("GenericCRTUtility") << "Found an AuxDetHit with ID " << auxDetHit.GetID()
104  << " for AuxDet ID " << ad_id_no
105  << " Sens ID " << ad_sen_id_no << std::endl;
106 
107  auto tempIDE = toAuxDetIDE(auxDetHit);
108 
109  std::vector<sim::AuxDetIDE>::iterator IDEitr
110  = std::find(IDEvector.begin(), IDEvector.end(), tempIDE);
111 
112  if(IDEitr != IDEvector.end()){ //If trackID is already in the map, update it
113  //Andrzej's note - following logic from AuxDetReadout in Legacy, but why are the other paremeters getting overwritten like that?
114  IDEitr->energyDeposited += tempIDE.energyDeposited;
115  IDEitr->exitX = tempIDE.exitX;
116  IDEitr->exitY = tempIDE.exitY;
117  IDEitr->exitZ = tempIDE.exitZ;
118  IDEitr->exitT = tempIDE.exitT;
119  IDEitr->exitMomentumX = tempIDE.exitMomentumX;
120  IDEitr->exitMomentumY = tempIDE.exitMomentumY;
121  IDEitr->exitMomentumZ = tempIDE.exitMomentumZ;
122  }
123  else{ //if trackID is not in the set yet, add it
124  IDEvector.push_back(std::move(tempIDE));
125  }//else
126 
127  // break;
128  } // end if the AuxDetHit channel checks out.
129 
130  } // end main loop on AuxDetHit
131 
132 
133  mf::LogDebug("GenericCRTUtility") << "Returning AuxDetSimChannel for ID "
134  << ad_id_no << " " << ad_sen_id_no
135  << ", with " << IDEvector.size() << " IDEs." << std::endl;
136 
137  //push back the AuxDetSimChannel Vector.
138  //TODO check the last parameter values.
139  return sim::AuxDetSimChannel(ad_id_no, std::move(IDEvector), ad_sen_id_no);
140 }
sim::AuxDetIDE toAuxDetIDE(sim::AuxDetHit const &InputHit) const
Definition: GenericCRT.cxx:32
Collection of particles crossing one auxiliary detector cell.
art::ServiceHandle< geo::Geometry const > fGeo
Definition: GenericCRT.h:43
std::vector< sim::AuxDetSimChannel > sim::GenericCRTUtility::GetAuxDetSimChannels ( const std::vector< sim::AuxDetHit > &  InputHitVector) const

Definition at line 145 of file GenericCRT.cxx.

146 {
147  auto const auxDetChannels = GetAuxDetChannels(InputHitVector);
148  std::vector<sim::AuxDetSimChannel> auxDetVector;
149  auxDetVector.reserve(size(auxDetChannels));
150 
151  for (auto const channelNum : auxDetChannels) {
152  auxDetVector.push_back(GetAuxDetSimChannelByNumber(InputHitVector, channelNum));
153  }
154 
155  return auxDetVector;
156 }
sim::AuxDetSimChannel GetAuxDetSimChannelByNumber(const std::vector< sim::AuxDetHit > &InputHitVector, unsigned int inputchannel) const
Definition: GenericCRT.cxx:82
std::vector< unsigned int > GetAuxDetChannels(const std::vector< sim::AuxDetHit > &InputHitVector) const
Definition: GenericCRT.cxx:56
std::size_t size(FixedBins< T, C > const &) noexcept
Definition: FixedBins.h:561
sim::AuxDetIDE sim::GenericCRTUtility::toAuxDetIDE ( sim::AuxDetHit const &  InputHit) const

Definition at line 32 of file GenericCRT.cxx.

33 {
34  sim::AuxDetIDE outputIDE;
35 
36  outputIDE.trackID = InputHit.GetTrackID();
37  outputIDE.energyDeposited = InputHit.GetEnergyDeposited() * fEnergyUnitsScale;
38  outputIDE.entryX = InputHit.GetEntryX();
39  outputIDE.entryY = InputHit.GetEntryY();
40  outputIDE.entryZ = InputHit.GetEntryZ();
41  outputIDE.entryT = InputHit.GetEntryT();
42  outputIDE.exitX = InputHit.GetExitX();
43  outputIDE.exitY = InputHit.GetExitY();
44  outputIDE.exitZ = InputHit.GetExitZ();
45  outputIDE.exitT = InputHit.GetExitT();
46  outputIDE.exitMomentumX = InputHit.GetExitMomentumX();
47  outputIDE.exitMomentumY = InputHit.GetExitMomentumY();
48  outputIDE.exitMomentumZ = InputHit.GetExitMomentumZ();
49 
50 
51  return outputIDE;
52 }
int trackID
Geant4 supplied track ID.
float exitMomentumZ
Exit Z-Momentum of particle.
float exitY
Exit position Y of particle.
float entryT
Entry time of particle.
float exitMomentumX
Exit X-Momentum of particle.
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.
MC truth information to make RawDigits and do back tracking.
float exitMomentumY
Exit Y-Momentum of particle.

Member Data Documentation

double sim::GenericCRTUtility::fEnergyUnitsScale
private

Definition at line 45 of file GenericCRT.h.

art::ServiceHandle<geo::Geometry const> sim::GenericCRTUtility::fGeo
private

Definition at line 43 of file GenericCRT.h.


The documentation for this class was generated from the following files: