LArSoft  v06_85_00
Liquid Argon Software toolkit - http://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 (const double *point, std::vector< geo::AuxDetGeo * > const &auxDets) const
 
virtual size_t NearestSensitiveAuxDet (const double *point, std::vector< geo::AuxDetGeo * > const &auxDets, size_t &ad) 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::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

typedef std::pair< uint32_t, size_t > chanAndSV
 

Detailed Description

Definition at line 32 of file AuxDetChannelMapAlg.h.

Member Typedef Documentation

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

Definition at line 34 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 87 of file AuxDetChannelMapAlg.cxx.

References fADGeoToName.

Referenced by ChannelToSensitiveAuxDet().

90  {
91  // loop over the map of AuxDet names to Geo object numbers to determine which auxdet
92  // we have. If no name in the map matches the provided string, throw an exception;
93  // the list of AuxDetGeo passed as argument is ignored!
94  // Note that fADGeoToName must have been updated by a derived class.
95  for(auto itr : fADGeoToName)
96  if( itr.second.compare(detName) == 0 ) return itr.first;
97 
98 
99  throw cet::exception("Geometry") << "No AuxDetGeo matching name: " << detName;
100 
101  return UINT_MAX;
102  }
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 107 of file AuxDetChannelMapAlg.cxx.

References ChannelToAuxDet(), and fADGeoToChannelAndSV.

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

Definition at line 15 of file AuxDetChannelMapAlg.cxx.

Referenced by NearestSensitiveAuxDet().

17  {
18  double HalfCenterWidth = 0.;
19  double localPoint[3] = {0.};
20 
21  for(size_t a = 0; a < auxDets.size(); ++a) {
22 
23  auxDets[a]->WorldToLocal(point, localPoint);
24 
25  HalfCenterWidth = 0.5 * (auxDets[a]->HalfWidth1() + auxDets[a]->HalfWidth2());
26 
27  if(localPoint[2] >= - auxDets[a]->Length()/2 &&
28  localPoint[2] <= auxDets[a]->Length()/2 &&
29  localPoint[1] >= - auxDets[a]->HalfHeight() &&
30  localPoint[1] <= auxDets[a]->HalfHeight() &&
31  // if AuxDet a is a box, then HalfSmallWidth = HalfWidth
32  localPoint[0] >= - HalfCenterWidth + localPoint[2]*(HalfCenterWidth - auxDets[a]->HalfWidth2())/(0.5 * auxDets[a]->Length()) &&
33  localPoint[0] <= HalfCenterWidth - localPoint[2]*(HalfCenterWidth - auxDets[a]->HalfWidth2())/(0.5 * auxDets[a]->Length())
34  ) return a;
35 
36  }// for loop over AudDet a
37 
38  // throw an exception because we couldn't find the sensitive volume
39  throw cet::exception("AuxDetChannelMapAlg") << "Can't find AuxDet for position ("
40  << point[0] << ","
41  << point[1] << ","
42  << point[2] << ")\n";
43 
44  return UINT_MAX;
45 
46  }
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 
) const
virtual

Definition at line 49 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::WorldToLocal().

52  {
53  double HalfCenterWidth = 0.;
54  double localPoint[3] = {0.};
55 
56  ad = this->NearestAuxDet(point, auxDets);
57 
58  geo::AuxDetGeo* adg = auxDets[ad];
59 
60  for(size_t a = 0; a < adg->NSensitiveVolume(); ++a) {
61 
62  geo::AuxDetSensitiveGeo const& adsg = adg->SensitiveVolume(a);
63  adsg.WorldToLocal(point, localPoint);
64 
65  HalfCenterWidth = 0.5 * (adsg.HalfWidth1() + adsg.HalfWidth2());
66 
67  if(localPoint[2] >= - adsg.Length()/2 &&
68  localPoint[2] <= adsg.Length()/2 &&
69  localPoint[1] >= - adsg.HalfHeight() &&
70  localPoint[1] <= adsg.HalfHeight() &&
71  // if AuxDet a is a box, then HalfSmallWidth = HalfWidth
72  localPoint[0] >= - HalfCenterWidth + localPoint[2]*(HalfCenterWidth - adsg.HalfWidth2())/(0.5 * adsg.Length()) &&
73  localPoint[0] <= HalfCenterWidth - localPoint[2]*(HalfCenterWidth - adsg.HalfWidth2())/(0.5 * adsg.Length())
74  ) return a;
75  }// for loop over AuxDetSensitive a
76 
77  // throw an exception because we couldn't find the sensitive volume
78  throw cet::exception("Geometry") << "Can't find AuxDetSensitive for position ("
79  << point[0] << ","
80  << point[1] << ","
81  << point[2] << ")\n";
82 
83  return UINT_MAX;
84  }
AuxDetSensitiveGeo const & SensitiveVolume(size_t sv) const
Definition: AuxDetGeo.h:159
virtual size_t NearestAuxDet(const double *point, std::vector< geo::AuxDetGeo * > const &auxDets) const
size_t NSensitiveVolume() const
Definition: AuxDetGeo.h:160
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 73 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 71 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 72 of file AuxDetChannelMapAlg.h.


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