LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
geo::AuxDetChannelMapAlg Class Referenceabstract

#include "AuxDetChannelMapAlg.h"

Public Member Functions

virtual ~AuxDetChannelMapAlg ()=default
 
virtual void Initialize (AuxDetGeometryData_t &geodata)=0
 
virtual void Uninitialize ()=0
 
virtual size_t NearestAuxDet (Point_t const &point, std::vector< AuxDetGeo > const &auxDets, double tolerance=0) const
 
virtual size_t NearestSensitiveAuxDet (Point_t const &point, std::vector< AuxDetGeo > const &auxDets, size_t &ad, double tolerance=0) const
 
virtual size_t ChannelToAuxDet (std::vector< AuxDetGeo > const &auxDets, std::string const &detName, uint32_t channel) const
 
virtual std::pair< size_t, size_t > ChannelToSensitiveAuxDet (std::vector< AuxDetGeo > const &auxDets, std::string const &detName, uint32_t channel) const
 
virtual uint32_t PositionToAuxDetChannel (Point_t const &worldLoc, std::vector< AuxDetGeo > const &auxDets, size_t &ad, size_t &sv) const =0
 
virtual Point_t AuxDetChannelToPosition (uint32_t channel, std::string const &auxDetName, std::vector< AuxDetGeo > const &auxDets) const =0
 

Protected Attributes

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

Private Types

using chanAndSV = std::pair< uint32_t, size_t >
 

Detailed Description

Definition at line 27 of file AuxDetChannelMapAlg.h.

Member Typedef Documentation

using geo::AuxDetChannelMapAlg::chanAndSV = std::pair<uint32_t, size_t>
private

Definition at line 29 of file AuxDetChannelMapAlg.h.

Constructor & Destructor Documentation

virtual geo::AuxDetChannelMapAlg::~AuxDetChannelMapAlg ( )
virtualdefault

Member Function Documentation

virtual Point_t geo::AuxDetChannelMapAlg::AuxDetChannelToPosition ( uint32_t  channel,
std::string const &  auxDetName,
std::vector< AuxDetGeo > const &  auxDets 
) const
pure virtual
size_t geo::AuxDetChannelMapAlg::ChannelToAuxDet ( std::vector< AuxDetGeo > const &  auxDets,
std::string const &  detName,
uint32_t  channel 
) const
virtual

Definition at line 85 of file AuxDetChannelMapAlg.cxx.

References fADGeoToName.

Referenced by ChannelToSensitiveAuxDet().

88  {
89  // loop over the map of AuxDet names to Geo object numbers to determine which auxdet
90  // we have. If no name in the map matches the provided string, throw an exception;
91  // the list of AuxDetGeo passed as argument is ignored!
92  // Note that fADGeoToName must have been updated by a derived class.
93  for (auto itr : fADGeoToName)
94  if (itr.second.compare(detName) == 0) return itr.first;
95 
96  throw cet::exception("Geometry") << "No AuxDetGeo matching name: " << detName;
97  }
std::map< size_t, std::string > fADGeoToName
map the AuxDetGeo index to the name
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33
std::pair< size_t, size_t > geo::AuxDetChannelMapAlg::ChannelToSensitiveAuxDet ( std::vector< AuxDetGeo > const &  auxDets,
std::string const &  detName,
uint32_t  channel 
) const
virtual

Definition at line 102 of file AuxDetChannelMapAlg.cxx.

References ChannelToAuxDet(), and fADGeoToChannelAndSV.

106  {
107  size_t adGeoIdx = ChannelToAuxDet(auxDets, detName, channel);
108 
109  // look for the index of the sensitive volume for the given channel
110  if (fADGeoToChannelAndSV.count(adGeoIdx) > 0) {
111 
112  auto itr = fADGeoToChannelAndSV.find(adGeoIdx);
113 
114  // get the vector of channels to AuxDetSensitiveGeo index
115  if (channel < itr->second.size())
116  return std::make_pair(adGeoIdx, itr->second[channel].second);
117 
118  throw cet::exception("Geometry")
119  << "Given AuxDetSensitive channel, " << channel
120  << ", cannot be found in vector associated to AuxDetGeo index: " << adGeoIdx
121  << ". Vector has size " << itr->second.size();
122  }
123 
124  throw cet::exception("Geometry") << "Given AuxDetGeo with index " << adGeoIdx
125  << " does not correspond to any vector of sensitive volumes";
126  }
std::map< size_t, std::vector< chanAndSV > > fADGeoToChannelAndSV
virtual size_t ChannelToAuxDet(std::vector< AuxDetGeo > const &auxDets, std::string const &detName, uint32_t channel) 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
virtual void geo::AuxDetChannelMapAlg::Initialize ( AuxDetGeometryData_t geodata)
pure virtual
size_t geo::AuxDetChannelMapAlg::NearestAuxDet ( Point_t const &  point,
std::vector< AuxDetGeo > const &  auxDets,
double  tolerance = 0 
) const
virtual

Definition at line 17 of file AuxDetChannelMapAlg.cxx.

References tca::Length().

Referenced by NearestSensitiveAuxDet().

20  {
21  for (size_t a = 0; a < auxDets.size(); ++a) {
22  auto const localPoint = auxDets[a].toLocalCoords(point);
23  double const HalfCenterWidth = 0.5 * (auxDets[a].HalfWidth1() + auxDets[a].HalfWidth2());
24 
25  if (localPoint.Z() >= (-auxDets[a].Length() / 2 - tolerance) &&
26  localPoint.Z() <= (auxDets[a].Length() / 2 + tolerance) &&
27  localPoint.Y() >= (-auxDets[a].HalfHeight() - tolerance) &&
28  localPoint.Y() <= (auxDets[a].HalfHeight() + tolerance) &&
29  // if AuxDet a is a box, then HalfSmallWidth = HalfWidth
30  localPoint.X() >= (-HalfCenterWidth +
31  localPoint.Z() * (HalfCenterWidth - auxDets[a].HalfWidth2()) /
32  (0.5 * auxDets[a].Length()) -
33  tolerance) &&
34  localPoint.X() <= (HalfCenterWidth -
35  localPoint.Z() * (HalfCenterWidth - auxDets[a].HalfWidth2()) /
36  (0.5 * auxDets[a].Length()) +
37  tolerance))
38  return a;
39 
40  } // for loop over AudDet a
41 
42  // throw an exception because we couldn't find the sensitive volume
43  throw cet::exception("AuxDetChannelMapAlg") << "Can't find AuxDet for position (" << point.X()
44  << "," << point.Y() << "," << point.Z() << ")\n";
45  }
float Length(const PFPStruct &pfp)
Definition: PFPUtils.cxx:3269
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33
size_t geo::AuxDetChannelMapAlg::NearestSensitiveAuxDet ( Point_t const &  point,
std::vector< AuxDetGeo > const &  auxDets,
size_t &  ad,
double  tolerance = 0 
) const
virtual

Definition at line 48 of file AuxDetChannelMapAlg.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().

52  {
53  ad = NearestAuxDet(point, auxDets, tolerance);
54 
55  AuxDetGeo const& adg = auxDets[ad];
56 
57  for (size_t a = 0; a < adg.NSensitiveVolume(); ++a) {
58  AuxDetSensitiveGeo const& adsg = adg.SensitiveVolume(a);
59  auto const localPoint = adsg.toLocalCoords(point);
60 
61  double const HalfCenterWidth = 0.5 * (adsg.HalfWidth1() + adsg.HalfWidth2());
62 
63  if (localPoint.Z() >= -(adsg.Length() / 2 + tolerance) &&
64  localPoint.Z() <= adsg.Length() / 2 + tolerance &&
65  localPoint.Y() >= -(adsg.HalfHeight() + tolerance) &&
66  localPoint.Y() <= adsg.HalfHeight() + tolerance &&
67  // if AuxDet a is a box, then HalfSmallWidth = HalfWidth
68  localPoint.X() >=
69  -HalfCenterWidth +
70  localPoint.Z() * (HalfCenterWidth - adsg.HalfWidth2()) / (0.5 * adsg.Length()) -
71  tolerance &&
72  localPoint.X() <=
73  HalfCenterWidth -
74  localPoint.Z() * (HalfCenterWidth - adsg.HalfWidth2()) / (0.5 * adsg.Length()) +
75  tolerance)
76  return a;
77  } // for loop over AuxDetSensitive a
78 
79  // throw an exception because we couldn't find the sensitive volume
80  throw cet::exception("Geometry") << "Can't find AuxDetSensitive for position (" << point.X()
81  << "," << point.Y() << "," << point.Z() << ")\n";
82  }
virtual size_t NearestAuxDet(Point_t const &point, std::vector< AuxDetGeo > const &auxDets, double tolerance=0) const
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33
virtual uint32_t geo::AuxDetChannelMapAlg::PositionToAuxDetChannel ( Point_t const &  worldLoc,
std::vector< AuxDetGeo > const &  auxDets,
size_t &  ad,
size_t &  sv 
) const
pure virtual
virtual void geo::AuxDetChannelMapAlg::Uninitialize ( )
pure virtual

Member Data Documentation

std::map<size_t, std::vector<chanAndSV> > geo::AuxDetChannelMapAlg::fADGeoToChannelAndSV
protected

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

Definition at line 70 of file AuxDetChannelMapAlg.h.

Referenced by ChannelToSensitiveAuxDet().

std::map<size_t, std::string> geo::AuxDetChannelMapAlg::fADGeoToName
protected

map the AuxDetGeo index to the name

Definition at line 67 of file AuxDetChannelMapAlg.h.

Referenced by ChannelToAuxDet().

std::map<std::string, size_t> geo::AuxDetChannelMapAlg::fNameToADGeo
protected

map the names to the AuxDetGeo index

Definition at line 68 of file AuxDetChannelMapAlg.h.


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