All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
ChannelMapSBNDAlg.cxx
Go to the documentation of this file.
1 /**
2  * @file ChannelMappingSBNDAlg.cxx
3  *
4  * Overrides ChannelMapAlg in larcorealg to change exceptions to messages
5  */
6 
8 #include "messagefacility/MessageLogger/MessageLogger.h"
9 
10 namespace geo {
11 
12  size_t ChannelMapSBNDAlg::NearestAuxDet(const double* point, std::vector<geo::AuxDetGeo> const& auxDets, double tolerance) const
13  {
14  double HalfCenterWidth = 0.;
15  double localPoint[3] = {0.};
16 
17 
18  for(size_t a = 0; a < auxDets.size(); ++a) {
19 
20  auxDets[a].WorldToLocal(point, localPoint);
21 
22  HalfCenterWidth = 0.5 * (auxDets[a].HalfWidth1() + auxDets[a].HalfWidth2());
23 
24  if( localPoint[2] >= - (auxDets[a].Length()/2 + tolerance) &&
25  localPoint[2] <= (auxDets[a].Length()/2 + tolerance) &&
26  localPoint[1] >= - auxDets[a].HalfHeight() - tolerance &&
27  localPoint[1] <= auxDets[a].HalfHeight() + tolerance &&
28  // if AuxDet a is a box, then HalfSmallWidth = HalfWidth
29  localPoint[0] >= - HalfCenterWidth + localPoint[2]*(HalfCenterWidth - auxDets[a].HalfWidth2())/(0.5 * auxDets[a].Length()) - tolerance &&
30  localPoint[0] <= HalfCenterWidth - localPoint[2]*(HalfCenterWidth - auxDets[a].HalfWidth2())/(0.5 * auxDets[a].Length()) + tolerance
31  ) return a;
32 
33  }// for loop over AudDet a
34 
35  // log a message because we couldn't find the aux det volume, exception in base class
36  mf::LogDebug("ChannelMapSBND") << "Can't find AuxDet for position ("
37  << point[0] << ","
38  << point[1] << ","
39  << point[2] << ")\n";
40 
41  return UINT_MAX;
42 
43  }
44 
45  //----------------------------------------------------------------------------
46  size_t ChannelMapSBNDAlg::NearestSensitiveAuxDet(const double* point, std::vector<geo::AuxDetGeo> const& auxDets, double tolerance) const
47  {
48  double HalfCenterWidth = 0.;
49  double localPoint[3] = {0.};
50 
51  size_t auxDetIdx = this->NearestAuxDet(point, auxDets, tolerance);
52 
53  if(auxDetIdx == UINT_MAX)
54  return UINT_MAX;
55 
56  geo::AuxDetGeo const& adg = auxDets[auxDetIdx];
57 
58  for(size_t a = 0; a < adg.NSensitiveVolume(); ++a) {
59 
60  geo::AuxDetSensitiveGeo const& adsg = adg.SensitiveVolume(a);
61  adsg.WorldToLocal(point, localPoint);
62 
63  HalfCenterWidth = 0.5 * (adsg.HalfWidth1() + adsg.HalfWidth2());
64 
65  if( localPoint[2] >= - (adsg.Length()/2 + tolerance) &&
66  localPoint[2] <= (adsg.Length()/2 + tolerance) &&
67  localPoint[1] >= - adsg.HalfHeight() - tolerance &&
68  localPoint[1] <= adsg.HalfHeight() + tolerance &&
69  // if AuxDet a is a box, then HalfSmallWidth = HalfWidth
70  localPoint[0] >= - HalfCenterWidth + localPoint[2]*(HalfCenterWidth - adsg.HalfWidth2())/(0.5 * adsg.Length()) - tolerance &&
71  localPoint[0] <= HalfCenterWidth - localPoint[2]*(HalfCenterWidth - adsg.HalfWidth2())/(0.5 * adsg.Length()) + tolerance
72  ) return a;
73  }// for loop over AuxDetSensitive a
74 
75  // log a message because we couldn't find the sensitive aux det volume, exception in base class
76  mf::LogDebug("ChannelMapSBND") << "Can't find AuxDetSensitive for position ("
77  << point[0] << ","
78  << point[1] << ","
79  << point[2] << ")\n";
80 
81  return UINT_MAX;
82  }
83 
84 } // namespace geo
float Length(const PFPStruct &pfp)
Definition: PFPUtils.cxx:3304
AuxDetSensitiveGeo const & SensitiveVolume(size_t sv) const
Definition: AuxDetGeo.h:171
auto const tolerance
process_name gaushit a
virtual size_t NearestSensitiveAuxDet(const double *point, std::vector< geo::AuxDetGeo > const &auxDets, double tolerance=0) const override
Returns sensitive auxiliary detector closest to specified point.
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.
Channel mapping for SBND.
virtual size_t NearestAuxDet(const double *point, std::vector< geo::AuxDetGeo > const &auxDets, double tolerance=0) const override
Returns the auxiliary detector closest to the specified point.