LArSoft  v10_04_05
Liquid Argon Software toolkit - https://larsoft.org/
geo::AuxDetReadoutGeom Class Reference

#include "AuxDetReadoutGeom.h"

Public Member Functions

 AuxDetReadoutGeom (AuxDetReadoutInitializers initializers)
 
std::size_t NearestAuxDet (Point_t const &point, std::vector< AuxDetGeo > const &auxDets, double tolerance=0, bool throwIfAbsent=true) const
 
std::size_t NearestSensitiveAuxDet (Point_t const &point, std::vector< AuxDetGeo > const &auxDets, double tolerance=0, bool throwIfAbsent=true) const
 
std::pair< std::size_t, std::size_t > ChannelToSensitiveAuxDet (std::string const &detName, std::uint32_t channel) const
 
Point_t AuxDetChannelToPosition (std::uint32_t channel, std::string const &auxDetName, std::vector< AuxDetGeo > const &auxDets) const
 

Private Member Functions

std::size_t DetNameToAuxDet (std::string const &detName) const
 

Private Attributes

std::map< std::size_t, std::string > fADGeoToName
 map the AuxDetGeo index to the name More...
 
std::map< std::string, std::size_t > fNameToADGeo
 map the names to the AuxDetGeo index More...
 
std::map< std::size_t, std::vector< chanAndSV > > fADGeoToChannelAndSV
 

Detailed Description

Definition at line 42 of file AuxDetReadoutGeom.h.

Constructor & Destructor Documentation

geo::AuxDetReadoutGeom::AuxDetReadoutGeom ( AuxDetReadoutInitializers  initializers)
explicit

Definition at line 29 of file AuxDetReadoutGeom.cxx.

References geo::AuxDetReadoutInitializers::ADGeoToName, fADGeoToChannelAndSV, and fNameToADGeo.

30  : fADGeoToName{std::move(initializers.ADGeoToName)}
31  , fNameToADGeo{std::move(initializers.NameToADGeo)}
32  , fADGeoToChannelAndSV{std::move(initializers.ADGeoToChannelAndSV)}
33  {}
std::map< std::size_t, std::vector< chanAndSV > > fADGeoToChannelAndSV
std::map< std::string, std::size_t > fNameToADGeo
map the names to the AuxDetGeo index
std::map< std::size_t, std::string > fADGeoToName
map the AuxDetGeo index to the name

Member Function Documentation

geo::Point_t geo::AuxDetReadoutGeom::AuxDetChannelToPosition ( std::uint32_t  channel,
std::string const &  auxDetName,
std::vector< AuxDetGeo > const &  auxDets 
) const

Definition at line 137 of file AuxDetReadoutGeom.cxx.

References fADGeoToChannelAndSV, and fNameToADGeo.

141  {
142  // Figure out which detector we are in
143  auto ad_it = fNameToADGeo.find(auxDetName);
144  if (ad_it == fNameToADGeo.cend()) {
145  throw cet::exception("CRTWireReadoutGeom") << "No AuxDetGeo with name " << auxDetName;
146  }
147  std::size_t const ad = ad_it->second;
148 
149  // Get the vector of channel and sensitive volume pairs
150  auto it = fADGeoToChannelAndSV.find(ad);
151  if (it == fADGeoToChannelAndSV.end()) {
152  throw cet::exception("CRTWireReadoutGeom") << "No entry in channel and sensitive volume"
153  << " map for AuxDet index " << ad << " bail";
154  }
155 
156  // Loop over the vector of channel and sensitive volumes to determine the sensitive
157  // volume for this channel. Then get the origin of the sensitive volume in the world
158  // coordinate system.
159  for (auto const& [ch, svindex] : it->second) {
160  if (ch == channel) { return auxDets[ad].SensitiveVolume(svindex).GetCenter(); }
161  }
162 
163  return {};
164  }
std::map< std::size_t, std::vector< chanAndSV > > fADGeoToChannelAndSV
std::map< std::string, std::size_t > fNameToADGeo
map the names to the AuxDetGeo index
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33
std::pair< std::size_t, std::size_t > geo::AuxDetReadoutGeom::ChannelToSensitiveAuxDet ( std::string const &  detName,
std::uint32_t  channel 
) const

Definition at line 114 of file AuxDetReadoutGeom.cxx.

References DetNameToAuxDet(), and fADGeoToChannelAndSV.

117  {
118  std::size_t adGeoIdx = DetNameToAuxDet(detName);
119 
120  // look for the index of the sensitive volume for the given channel
121  auto it = fADGeoToChannelAndSV.find(adGeoIdx);
122  if (it == fADGeoToChannelAndSV.cend()) {
123  throw cet::exception("Geometry")
124  << "Given AuxDetSensitive channel, " << channel
125  << ", cannot be found in vector associated to AuxDetGeo index: " << adGeoIdx
126  << ". Vector has size " << it->second.size();
127  }
128 
129  // get the vector of channels to AuxDetSensitiveGeo index
130  if (channel < it->second.size()) return {adGeoIdx, it->second[channel].second};
131 
132  throw cet::exception("Geometry") << "Given AuxDetGeo with index " << adGeoIdx
133  << " does not correspond to any vector of sensitive volumes";
134  }
std::map< std::size_t, std::vector< chanAndSV > > fADGeoToChannelAndSV
std::size_t DetNameToAuxDet(std::string const &detName) const
second_as<> second
Type of time stored in seconds, in double precision.
Definition: spacetime.h:82
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33
std::size_t geo::AuxDetReadoutGeom::DetNameToAuxDet ( std::string const &  detName) const
private

Definition at line 167 of file AuxDetReadoutGeom.cxx.

References fADGeoToName.

Referenced by ChannelToSensitiveAuxDet().

168  {
169  // loop over the map of AuxDet names to Geo object numbers to determine which auxdet
170  // we have. If no name in the map matches the provided string, throw an exception;
171  // the list of AuxDetGeo passed as argument is ignored! Note that fADGeoToName must
172  // have been updated by a derived class.
173  auto it = std::find_if(fADGeoToName.begin(), fADGeoToName.end(), [&detName](auto const& pr) {
174  return pr.second == detName;
175  });
176  if (it == fADGeoToName.end()) {
177  throw cet::exception("Geometry") << "No AuxDetGeo matching name: " << detName;
178  }
179  return it->first;
180  }
std::map< std::size_t, std::string > fADGeoToName
map the AuxDetGeo index to the name
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33
std::size_t geo::AuxDetReadoutGeom::NearestAuxDet ( Point_t const &  point,
std::vector< AuxDetGeo > const &  auxDets,
double  tolerance = 0,
bool  throwIfAbsent = true 
) const

Definition at line 36 of file AuxDetReadoutGeom.cxx.

References tca::Length().

Referenced by NearestSensitiveAuxDet().

40  {
41  for (std::size_t a = 0; a < auxDets.size(); ++a) {
42  auto const localPoint = auxDets[a].toLocalCoords(point);
43  double const HalfCenterWidth = 0.5 * (auxDets[a].HalfWidth1() + auxDets[a].HalfWidth2());
44 
45  if (localPoint.Z() >= (-auxDets[a].Length() / 2 - tolerance) &&
46  localPoint.Z() <= (auxDets[a].Length() / 2 + tolerance) &&
47  localPoint.Y() >= (-auxDets[a].HalfHeight() - tolerance) &&
48  localPoint.Y() <= (auxDets[a].HalfHeight() + tolerance) &&
49  // if AuxDet a is a box, then HalfSmallWidth = HalfWidth
50  localPoint.X() >= (-HalfCenterWidth +
51  localPoint.Z() * (HalfCenterWidth - auxDets[a].HalfWidth2()) /
52  (0.5 * auxDets[a].Length()) -
53  tolerance) &&
54  localPoint.X() <= (HalfCenterWidth -
55  localPoint.Z() * (HalfCenterWidth - auxDets[a].HalfWidth2()) /
56  (0.5 * auxDets[a].Length()) +
57  tolerance))
58  return a;
59  } // for loop over AudDet a
60 
61  std::ostringstream msg;
62  msg << "Can't find AuxDet for position " << point;
63 
64  if (throwIfAbsent) { throw cet::exception("AuxDetReadoutGeom") << msg.str(); }
65 
66  mf::LogDebug("AuxDetReadoutGeom") << msg.str();
67  return invalid_index;
68  }
float Length(const PFPStruct &pfp)
Definition: PFPUtils.cxx:3267
MaybeLogger_< ELseverityLevel::ELsev_success, false > LogDebug
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33
std::size_t geo::AuxDetReadoutGeom::NearestSensitiveAuxDet ( Point_t const &  point,
std::vector< AuxDetGeo > const &  auxDets,
double  tolerance = 0,
bool  throwIfAbsent = true 
) const

Definition at line 71 of file AuxDetReadoutGeom.cxx.

References geo::AuxDetSensitiveGeo::HalfHeight(), geo::AuxDetSensitiveGeo::HalfWidth1(), geo::AuxDetSensitiveGeo::HalfWidth2(), geo::AuxDetSensitiveGeo::Length(), NearestAuxDet(), geo::AuxDetGeo::NSensitiveVolume(), geo::AuxDetGeo::SensitiveVolume(), and geo::AuxDetSensitiveGeo::toLocalCoords().

75  {
76  std::size_t const auxDetIdx = NearestAuxDet(point, auxDets, tolerance, throwIfAbsent);
77  if (auxDetIdx == invalid_index) { return invalid_index; }
78 
79  AuxDetGeo const& adg = auxDets[auxDetIdx];
80  for (std::size_t a = 0; a < adg.NSensitiveVolume(); ++a) {
81  AuxDetSensitiveGeo const& adsg = adg.SensitiveVolume(a);
82  auto const localPoint = adsg.toLocalCoords(point);
83 
84  double const HalfCenterWidth = 0.5 * (adsg.HalfWidth1() + adsg.HalfWidth2());
85 
86  if (localPoint.Z() >= -(adsg.Length() / 2 + tolerance) &&
87  localPoint.Z() <= (adsg.Length() / 2 + tolerance) &&
88  localPoint.Y() >= -adsg.HalfHeight() - tolerance &&
89  localPoint.Y() <= adsg.HalfHeight() + tolerance &&
90  // if AuxDet a is a box, then HalfSmallWidth = HalfWidth
91  localPoint.X() >=
92  -HalfCenterWidth +
93  localPoint.Z() * (HalfCenterWidth - adsg.HalfWidth2()) / (0.5 * adsg.Length()) -
94  tolerance &&
95  localPoint.X() <=
96  HalfCenterWidth -
97  localPoint.Z() * (HalfCenterWidth - adsg.HalfWidth2()) / (0.5 * adsg.Length()) +
98  tolerance)
99  return a;
100  } // for loop over AuxDetSensitive a
101 
102  std::ostringstream msg;
103  msg << "Can't find AuxDetSensitive for position " << point;
104 
105  if (throwIfAbsent) { throw cet::exception("AuxDetReadoutGeom") << msg.str(); }
106 
107  mf::LogDebug("AuxDetReadoutGeom") << msg.str();
108  return invalid_index;
109  }
std::size_t NearestAuxDet(Point_t const &point, std::vector< AuxDetGeo > const &auxDets, double tolerance=0, bool throwIfAbsent=true) const
MaybeLogger_< ELseverityLevel::ELsev_success, false > LogDebug
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33

Member Data Documentation

std::map<std::size_t, std::vector<chanAndSV> > geo::AuxDetReadoutGeom::fADGeoToChannelAndSV
private

map the AuxDetGeo index to a vector of pairs corresponding to the channel and AuxDetSensitiveGeo index

Definition at line 69 of file AuxDetReadoutGeom.h.

Referenced by AuxDetChannelToPosition(), AuxDetReadoutGeom(), and ChannelToSensitiveAuxDet().

std::map<std::size_t, std::string> geo::AuxDetReadoutGeom::fADGeoToName
private

map the AuxDetGeo index to the name

Definition at line 66 of file AuxDetReadoutGeom.h.

Referenced by DetNameToAuxDet().

std::map<std::string, std::size_t> geo::AuxDetReadoutGeom::fNameToADGeo
private

map the names to the AuxDetGeo index

Definition at line 67 of file AuxDetReadoutGeom.h.

Referenced by AuxDetChannelToPosition(), and AuxDetReadoutGeom().


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