Public Member Functions | Protected Attributes | Private Types | List of all members
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 (const double *point, std::vector< geo::AuxDetGeo > const &auxDets, double tolerance=0) const
 
virtual size_t NearestSensitiveAuxDet (const double *point, std::vector< geo::AuxDetGeo > const &auxDets, size_t &ad, double tolerance=0) const
 
virtual size_t ChannelToAuxDet (std::vector< geo::AuxDetGeo > const &auxDets, std::string const &detName, uint32_t const &channel) const
 
virtual std::pair< size_t, size_t > ChannelToSensitiveAuxDet (std::vector< geo::AuxDetGeo > const &auxDets, std::string const &detName, uint32_t const &channel) const
 
virtual uint32_t PositionToAuxDetChannel (double const worldLoc[3], std::vector< geo::AuxDetGeo > const &auxDets, size_t &ad, size_t &sv) const =0
 
virtual const TVector3 AuxDetChannelToPosition (uint32_t const &channel, std::string const &auxDetName, std::vector< geo::AuxDetGeo > const &auxDets) const =0
 

Protected Attributes

std::map< size_t, std::stringfADGeoToName
 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

typedef std::pair< uint32_t, size_t > chanAndSV
 

Detailed Description

Definition at line 28 of file AuxDetChannelMapAlg.h.

Member Typedef Documentation

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

Definition at line 30 of file AuxDetChannelMapAlg.h.

Constructor & Destructor Documentation

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

Member Function Documentation

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

Definition at line 94 of file AuxDetChannelMapAlg.cxx.

97  {
98  // loop over the map of AuxDet names to Geo object numbers to determine which auxdet
99  // we have. If no name in the map matches the provided string, throw an exception;
100  // the list of AuxDetGeo passed as argument is ignored!
101  // Note that fADGeoToName must have been updated by a derived class.
102  for(auto itr : fADGeoToName)
103  if( itr.second.compare(detName) == 0 ) return itr.first;
104 
105 
106  throw cet::exception("Geometry") << "No AuxDetGeo matching name: " << detName;
107 
108  return UINT_MAX;
109  }
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< geo::AuxDetGeo > const &  auxDets,
std::string const &  detName,
uint32_t const &  channel 
) const
virtual

Definition at line 114 of file AuxDetChannelMapAlg.cxx.

117  {
118  size_t adGeoIdx = this->ChannelToAuxDet(auxDets, detName, channel);
119 
120  // look for the index of the sensitive volume for the given channel
121  if( fADGeoToChannelAndSV.count(adGeoIdx) > 0 ){
122 
123  auto itr = fADGeoToChannelAndSV.find(adGeoIdx);
124 
125  // get the vector of channels to AuxDetSensitiveGeo index
126  if( channel < itr->second.size() )
127  return std::make_pair(adGeoIdx, itr->second[channel].second);
128 
129  throw cet::exception("Geometry") << "Given AuxDetSensitive channel, " << channel
130  << ", cannot be found in vector associated to AuxDetGeo index: "
131  << adGeoIdx << ". Vector has size " << itr->second.size();
132  }
133 
134  throw cet::exception("Geometry") << "Given AuxDetGeo with index " << adGeoIdx
135  << " does not correspond to any vector of sensitive volumes";
136 
137  return std::make_pair(adGeoIdx, UINT_MAX);
138  }
virtual size_t ChannelToAuxDet(std::vector< geo::AuxDetGeo > const &auxDets, std::string const &detName, uint32_t const &channel) const
std::map< size_t, std::vector< chanAndSV > > fADGeoToChannelAndSV
uint8_t channel
Definition: CRTFragment.hh:201
second_as<> second
Type of time stored in seconds, in double precision.
Definition: spacetime.h:85
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 ( const double *  point,
std::vector< geo::AuxDetGeo > const &  auxDets,
double  tolerance = 0 
) const
virtual

Definition at line 20 of file AuxDetChannelMapAlg.cxx.

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

Definition at line 54 of file AuxDetChannelMapAlg.cxx.

58  {
59  double HalfCenterWidth = 0.;
60  double localPoint[3] = {0.};
61 
62  ad = this->NearestAuxDet(point, auxDets, tolerance);
63 
64  geo::AuxDetGeo const& adg = auxDets[ad];
65 
66  for(size_t a = 0; a < adg.NSensitiveVolume(); ++a) {
67 
68  geo::AuxDetSensitiveGeo const& adsg = adg.SensitiveVolume(a);
69  adsg.WorldToLocal(point, localPoint);
70 
71  HalfCenterWidth = 0.5 * (adsg.HalfWidth1() + adsg.HalfWidth2());
72 
73 
74  if(localPoint[2] >= - (adsg.Length()/2 + tolerance) &&
75  localPoint[2] <= adsg.Length()/2 + tolerance &&
76  localPoint[1] >= - (adsg.HalfHeight() + tolerance) &&
77  localPoint[1] <= adsg.HalfHeight() + tolerance &&
78  // if AuxDet a is a box, then HalfSmallWidth = HalfWidth
79  localPoint[0] >= - HalfCenterWidth + localPoint[2]*(HalfCenterWidth - adsg.HalfWidth2())/(0.5 * adsg.Length()) - tolerance &&
80  localPoint[0] <= HalfCenterWidth - localPoint[2]*(HalfCenterWidth - adsg.HalfWidth2())/(0.5 * adsg.Length()) + tolerance
81  ) return a;
82  }// for loop over AuxDetSensitive a
83 
84  // throw an exception because we couldn't find the sensitive volume
85  throw cet::exception("Geometry") << "Can't find AuxDetSensitive for position ("
86  << point[0] << ","
87  << point[1] << ","
88  << point[2] << ")\n";
89 
90  return UINT_MAX;
91  }
AuxDetSensitiveGeo const & SensitiveVolume(size_t sv) const
Definition: AuxDetGeo.h:171
auto const tolerance
virtual size_t NearestAuxDet(const double *point, std::vector< geo::AuxDetGeo > const &auxDets, double tolerance=0) const
const double a
size_t NSensitiveVolume() const
Definition: AuxDetGeo.h:172
void WorldToLocal(const double *world, double *auxdet) const
Transform point from world frame to local auxiliary detector frame.
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33
virtual uint32_t geo::AuxDetChannelMapAlg::PositionToAuxDetChannel ( double const  worldLoc[3],
std::vector< geo::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 71 of file AuxDetChannelMapAlg.h.

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

map the AuxDetGeo index to the name

Definition at line 69 of file AuxDetChannelMapAlg.h.

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

map the names to the AuxDetGeo index

Definition at line 70 of file AuxDetChannelMapAlg.h.


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