All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Types | Public Member Functions | Private Member Functions | Static Private Member Functions | Private Attributes | List of all members
icarus::trigger::PMTverticalSlicingAlg Class Reference

Algorithm clustering PMT according to their position. More...

#include <PMTverticalSlicingAlg.h>

Public Types

using PMTlist_t = std::vector< geo::OpDetGeo const * >
 Type of optical detector list. More...
 
using PMTtower_t = PMTlist_t
 Type of optical detector list in a PMT tower. More...
 
using PMTtowerOnPlane_t = std::vector< PMTtower_t >
 Type of list of PMT towers on a single optical detector plane. More...
 
using Slices_t = std::vector< PMTtowerOnPlane_t >
 Type of PMT towers, per plane. More...
 

Public Member Functions

 PMTverticalSlicingAlg (std::string logCategory="PMTverticalSlicingAlg")
 Constructor: no configuration parameters so far. More...
 
void appendCryoSlices (Slices_t &slices, geo::CryostatGeo const &cryo) const
 Computes slices from all PMT in cryo and appends them to slices. More...
 
std::vector< std::pair< double,
PMTlist_t > > 
PMTwalls (geo::CryostatGeo const &cryo) const
 Groups optical detectors under the specified cryostat into walls. More...
 
std::vector< std::pair< double,
PMTlist_t > > 
PMTwalls (geo::GeometryCore const &geom) const
 Groups optical detectors in all the detector into walls. More...
 

Private Member Functions

void appendSlices (Slices_t &slices, PMTlist_t const &PMTs, geo::Vector_t const &planeNorm, geo::Vector_t const &clusterDir) const
 Computes slices and appends them to an existing list. More...
 
std::vector< std::pair< double,
PMTlist_t > > 
PMTwalls (PMTlist_t const &PMTs, geo::Vector_t const &dir) const
 Groups the specifies optical detectors into walls. More...
 

Static Private Member Functions

static double PMTwallPosition (PMTlist_t const &PMTs, geo::Vector_t const &dir)
 Returns an (arbitrary) coordinate along dir representing the PMT list. More...
 
template<typename TPCCont >
static geo::Vector_t determineDriftDir (TPCCont const &TPCcont)
 
template<typename TPCCont >
static geo::Vector_t determineLengthDir (TPCCont const &TPCcont)
 
static std::vector< PMTlist_tclusterPMTby (PMTlist_t const &PMTs, geo::Vector_t const &dir)
 Clusters the PMTs along the specified direction. More...
 
static PMTlist_t getCryoPMTs (geo::CryostatGeo const &cryo)
 Returns a list of all geo::OpDetGeo in cryostat cryo. More...
 
static PMTlist_t getPMTs (geo::GeometryCore const &geom)
 Returns a list of all geo::OpDetGeo in the whole geometry. More...
 
static bool areParallel (geo::Vector_t const &a, geo::Vector_t const &b)
 Returns whether a and b are parallel. More...
 

Private Attributes

std::string fLogCategory
 Category for message streaming. More...
 

Detailed Description

Algorithm clustering PMT according to their position.

The algorithm groups the provided PMT by plane (determined from the drift direction of the TPC) and by the beam-like direction (the one that is not the vertical, i.e. TPC "width" direction).

Definition at line 45 of file PMTverticalSlicingAlg.h.

Member Typedef Documentation

Type of optical detector list.

Definition at line 50 of file PMTverticalSlicingAlg.h.

Type of optical detector list in a PMT tower.

Definition at line 53 of file PMTverticalSlicingAlg.h.

Type of list of PMT towers on a single optical detector plane.

Definition at line 56 of file PMTverticalSlicingAlg.h.

Type of PMT towers, per plane.

Definition at line 59 of file PMTverticalSlicingAlg.h.

Constructor & Destructor Documentation

icarus::trigger::PMTverticalSlicingAlg::PMTverticalSlicingAlg ( std::string  logCategory = "PMTverticalSlicingAlg")

Constructor: no configuration parameters so far.

Definition at line 75 of file PMTverticalSlicingAlg.cxx.

76  : fLogCategory(std::move(logCategory))
77  {}
std::string fLogCategory
Category for message streaming.

Member Function Documentation

void icarus::trigger::PMTverticalSlicingAlg::appendCryoSlices ( Slices_t slices,
geo::CryostatGeo const &  cryo 
) const

Computes slices from all PMT in cryo and appends them to slices.

Definition at line 82 of file PMTverticalSlicingAlg.cxx.

83 {
84  geo::Vector_t const& driftDir = determineDriftDir(cryo.IterateTPCs());
85  geo::Vector_t const& widthDir = determineLengthDir(cryo.IterateTPCs());
86  appendSlices(slices, getCryoPMTs(cryo), driftDir, widthDir);
87 } // icarus::trigger::PMTverticalSlicingAlg::appendCryoSlices()
ROOT::Math::DisplacementVector3D< ROOT::Math::Cartesian3D< double >, ROOT::Math::GlobalCoordinateSystemTag > Vector_t
Type for representation of momenta in 3D space.
Definition: geo_vectors.h:164
void appendSlices(Slices_t &slices, PMTlist_t const &PMTs, geo::Vector_t const &planeNorm, geo::Vector_t const &clusterDir) const
Computes slices and appends them to an existing list.
static geo::Vector_t determineLengthDir(TPCCont const &TPCcont)
std::vector< TCSlice > slices
Definition: DataStructs.cxx:13
static geo::Vector_t determineDriftDir(TPCCont const &TPCcont)
static PMTlist_t getCryoPMTs(geo::CryostatGeo const &cryo)
Returns a list of all geo::OpDetGeo in cryostat cryo.
void icarus::trigger::PMTverticalSlicingAlg::appendSlices ( Slices_t slices,
PMTlist_t const &  PMTs,
geo::Vector_t const &  planeNorm,
geo::Vector_t const &  clusterDir 
) const
private

Computes slices and appends them to an existing list.

Definition at line 109 of file PMTverticalSlicingAlg.cxx.

113 {
114 
115  /*
116  * 1. group PMT by plane (cluster on drift direction)
117  * 2. group PMT in each plane by width coordinate (cluster by width direction)
118  */
119 
120  //
121  // 1. group PMT by plane (cluster on drift direction)
122  //
123 
124  std::vector<PMTlist_t> const PMTplanes = clusterPMTby(PMTs, planeNorm);
125 
126  // BEGIN debug
127  {
128  mf::LogTrace log { fLogCategory };
129  log << PMTs.size() << " PMTs grouped into " << PMTplanes.size()
130  << " planes in direction " << planeNorm << ":";
131  for (auto&& [ iPlane, PMTplane ]: util::enumerate(PMTplanes)) {
132  log << "\n [#" << iPlane << "] " << PMTplane.size() << " PMT:";
133  for (geo::OpDetGeo const* opDet: PMTplane)
134  log << " <" << opDet->ID() << ">";
135  } // for
136  }
137  // END debug
138 
139  //
140  // 2. group PMT in each plane by width coordinate (cluster by width direction)
141  //
142  unsigned int NClusteredPMTs [[maybe_unused]] = 0U;
143  for (auto const& PMTplane: PMTplanes) {
144  slices.push_back(clusterPMTby(PMTplane, clusterDir));
145 
146  // BEGIN debug
147  auto const& planeSlices = slices.back();
148  mf::LogTrace log { fLogCategory };
149  log << PMTplane.size() << " PMTs in the plane grouped into "
150  << planeSlices.size() << " towers in direction " << clusterDir << ":";
151  for (auto&& [ iSlice, slice ]: util::enumerate(planeSlices)) {
152  NClusteredPMTs += slice.size();
153  log << "\n [#" << iSlice << "] " << slice.size() << " PMT:";
154  for (geo::OpDetGeo const* opDet: slice) log << " <" << opDet->ID() << ">";
155  } // for planeSlices
156  // END debug
157 
158  } // for planes
159 
160  assert(NClusteredPMTs == PMTs.size());
161 
162 } // icarus::trigger::PMTverticalSlicingAlg::appendSlices()
static std::vector< PMTlist_t > clusterPMTby(PMTlist_t const &PMTs, geo::Vector_t const &dir)
Clusters the PMTs along the specified direction.
auto enumerate(Iterables &&...iterables)
Range-for loop helper tracking the number of iteration.
Definition: enumerate.h:69
std::string fLogCategory
Category for message streaming.
std::vector< TCSlice > slices
Definition: DataStructs.cxx:13
bool icarus::trigger::PMTverticalSlicingAlg::areParallel ( geo::Vector_t const &  a,
geo::Vector_t const &  b 
)
staticprivate

Returns whether a and b are parallel.

Definition at line 248 of file PMTverticalSlicingAlg.cxx.

249 {
250  lar::util::Vector3DComparison cmp { 1e-4 };
251  return cmp.zero(a.Cross(b));
252 } // icarus::trigger::PMTverticalSlicingAlg::areParallel()
Class comparing 2D vectors.
process_name gaushit a
do i e
auto icarus::trigger::PMTverticalSlicingAlg::clusterPMTby ( PMTlist_t const &  PMTs,
geo::Vector_t const &  dir 
)
staticprivate

Clusters the PMTs along the specified direction.

Definition at line 203 of file PMTverticalSlicingAlg.cxx.

204 {
205 #if 0
206  // use the projection of the PMT center on the specified direction as
207  // clustering key; we need a reference point to project... we pick `origin()`.
208  auto const PMTcenterProjection = [dir](geo::OpDetGeo const* opDet)
209  { return (opDet->GetCenter() - geo::origin()).Dot(dir); };
210 #endif // 0
211 
212  PMTprojectorClass const PMTcenterProjection { dir };
213 
214  // PMTs with a coordinate within 5 cm (kind of) will be clustered together
215  constexpr double tol = 5.0; // cm
216  auto const closeEnough
217  = [](double a, double b){ return std::abs(a - b) < tol; };
218 
219  return util::clusterBy(PMTs, PMTcenterProjection, closeEnough, std::less<>());
220 
221 } // icarus::trigger::PMTverticalSlicingAlg::clusterPMTby()
auto const tol
Definition: SurfXYZTest.cc:16
process_name gaushit a
T abs(T value)
auto clusterBy(Coll const &objs, KeyOp keyFunc, CmpOp sameGroup, RefOp objRef, KeySortOp keySort)
Performs a simple clustering.
tuple dir
Definition: dropbox.py:28
constexpr Point origin()
Returns a origin position with a point of the specified type.
Definition: geo_vectors.h:227
template<typename TPCCont >
geo::Vector_t icarus::trigger::PMTverticalSlicingAlg::determineDriftDir ( TPCCont const &  TPCcont)
staticprivate

Definition at line 153 of file PMTverticalSlicingAlg.h.

154 {
155 
156  auto iTPC = util::begin(TPCcont);
157  auto const tend = util::end(TPCcont);
158 
159  if (iTPC == tend) {
160  throw cet::exception("PMTverticalSlicingAlg")
161  << "determineDriftDir(): no TPC in the specified object!";
162  }
163 
164  auto const dir = iTPC->template DriftDir<geo::Vector_t>();
165  while(++iTPC != tend) {
166  if (areParallel(iTPC->template DriftDir<geo::Vector_t>(), dir))
167  continue;
168  throw cet::exception("PMTverticalSlicingAlg")
169  << "determineDriftDir(): TPC " << iTPC->ID()
170  << " has a drift direction incompatible with " << dir << ".\n";
171  } // while
172 
173  return dir;
174 
175 } // icarus::trigger::PMTverticalSlicingAlg::determineDriftDir()
decltype(auto) constexpr end(T &&obj)
ADL-aware version of std::end.
Definition: StdUtils.h:77
static bool areParallel(geo::Vector_t const &a, geo::Vector_t const &b)
Returns whether a and b are parallel.
tuple dir
Definition: dropbox.py:28
decltype(auto) constexpr begin(T &&obj)
ADL-aware version of std::begin.
Definition: StdUtils.h:72
template<typename TPCCont >
geo::Vector_t icarus::trigger::PMTverticalSlicingAlg::determineLengthDir ( TPCCont const &  TPCcont)
staticprivate

Definition at line 181 of file PMTverticalSlicingAlg.h.

182 {
183 
184  auto iTPC = util::begin(TPCcont);
185  auto const tend = util::end(TPCcont);
186 
187  if (iTPC == tend) {
188  throw cet::exception("PMTverticalSlicingAlg")
189  << "determineLengthDir(): no TPC in the specified object!";
190  }
191 
192  auto const dir = iTPC->template LengthDir<geo::Vector_t>();
193  while(++iTPC != tend) {
194  if (areParallel(iTPC->template LengthDir<geo::Vector_t>(), dir))
195  continue;
196  throw cet::exception("PMTverticalSlicingAlg")
197  << "determineLengthDir(): TPC " << iTPC->ID()
198  << " has a width direction incompatible with " << dir << ".\n";
199  } // while
200 
201  return dir;
202 
203 } // icarus::trigger::PMTverticalSlicingAlg::determineLengthDir()
decltype(auto) constexpr end(T &&obj)
ADL-aware version of std::end.
Definition: StdUtils.h:77
static bool areParallel(geo::Vector_t const &a, geo::Vector_t const &b)
Returns whether a and b are parallel.
tuple dir
Definition: dropbox.py:28
decltype(auto) constexpr begin(T &&obj)
ADL-aware version of std::begin.
Definition: StdUtils.h:72
auto icarus::trigger::PMTverticalSlicingAlg::getCryoPMTs ( geo::CryostatGeo const &  cryo)
staticprivate

Returns a list of all geo::OpDetGeo in cryostat cryo.

Definition at line 226 of file PMTverticalSlicingAlg.cxx.

227 {
228  PMTlist_t opDets;
229  for (auto iOpDet: util::counter(cryo.NOpDet()))
230  opDets.push_back(&cryo.OpDet(iOpDet));
231  return opDets;
232 } // icarus::trigger::PMTverticalSlicingAlg::getCryoPMTs()
std::vector< geo::OpDetGeo const * > PMTlist_t
Type of optical detector list.
auto counter(T begin, T end)
Returns an object to iterate values from begin to end in a range-for loop.
Definition: counter.h:285
auto icarus::trigger::PMTverticalSlicingAlg::getPMTs ( geo::GeometryCore const &  geom)
staticprivate

Returns a list of all geo::OpDetGeo in the whole geometry.

Definition at line 237 of file PMTverticalSlicingAlg.cxx.

238 {
239  PMTlist_t opDets;
240  for (geo::CryostatGeo const& cryo: geom.IterateCryostats())
241  append(opDets, getCryoPMTs(cryo));
242  return opDets;
243 } // icarus::trigger::PMTverticalSlicingAlg::getCryoPMTs()
std::vector< geo::OpDetGeo const * > PMTlist_t
Type of optical detector list.
Geometry information for a single cryostat.
Definition: CryostatGeo.h:43
static PMTlist_t getCryoPMTs(geo::CryostatGeo const &cryo)
Returns a list of all geo::OpDetGeo in cryostat cryo.
double icarus::trigger::PMTverticalSlicingAlg::PMTwallPosition ( PMTlist_t const &  PMTs,
geo::Vector_t const &  dir 
)
staticprivate

Returns an (arbitrary) coordinate along dir representing the PMT list.

Definition at line 189 of file PMTverticalSlicingAlg.cxx.

190 {
191  if (PMTs.empty()) return std::numeric_limits<double>::lowest(); // arbitrary
192 
193  PMTprojectorClass const PMTcenterProjection { dir };
195  for (geo::OpDetGeo const* PMT: PMTs) stats.add(PMTcenterProjection(PMT));
196  return stats.Average();
197 
198 } // icarus::trigger::PMTverticalSlicingAlg::PMTwallPosition()
#define PMT
Definition: NestAlg.cxx:19
Weight_t Average() const
Returns the value average.
tuple dir
Definition: dropbox.py:28
void add(Data_t value, Weight_t weight=Weight_t(1.0))
Adds one entry with specified value and weight.
auto icarus::trigger::PMTverticalSlicingAlg::PMTwalls ( geo::CryostatGeo const &  cryo) const

Groups optical detectors under the specified cryostat into walls.

Parameters
cryothe cryostat containing the optical detectors
Returns
a list of pairs: each an absolute drift coordinate and PMT list

The algorithm returns a list of walls, with as first element a coordinate representing the wall (drift coordinate) and the second the list of optical detectors in that wall, in no particular order. The walls are sorted by increasing drift coordinate.

Definition at line 92 of file PMTverticalSlicingAlg.cxx.

94 {
95  return PMTwalls(getCryoPMTs(cryo), determineDriftDir(cryo.IterateTPCs()));
96 } // icarus::trigger::PMTverticalSlicingAlg::PMTwalls(CryostatGeo)
std::vector< std::pair< double, PMTlist_t > > PMTwalls(geo::CryostatGeo const &cryo) const
Groups optical detectors under the specified cryostat into walls.
static geo::Vector_t determineDriftDir(TPCCont const &TPCcont)
static PMTlist_t getCryoPMTs(geo::CryostatGeo const &cryo)
Returns a list of all geo::OpDetGeo in cryostat cryo.
auto icarus::trigger::PMTverticalSlicingAlg::PMTwalls ( geo::GeometryCore const &  geom) const

Groups optical detectors in all the detector into walls.

Parameters
geomthe geometry description of the detector
Returns
a list of pairs: each an absolute drift coordinate and PMT list
See Also
PMTwalls(geo::CryostatGeo const&) const

PMT walls are extracted for each of the cryostats in the detector, and the result is merged into a single collection.

Definition at line 101 of file PMTverticalSlicingAlg.cxx.

103 {
104  return PMTwalls(getPMTs(geom), determineDriftDir(geom.IterateTPCs()));
105 } // icarus::trigger::PMTverticalSlicingAlg::PMTwalls(GeometryCore)
static PMTlist_t getPMTs(geo::GeometryCore const &geom)
Returns a list of all geo::OpDetGeo in the whole geometry.
std::vector< std::pair< double, PMTlist_t > > PMTwalls(geo::CryostatGeo const &cryo) const
Groups optical detectors under the specified cryostat into walls.
static geo::Vector_t determineDriftDir(TPCCont const &TPCcont)
auto icarus::trigger::PMTverticalSlicingAlg::PMTwalls ( PMTlist_t const &  PMTs,
geo::Vector_t const &  dir 
) const
private

Groups the specifies optical detectors into walls.

Parameters
PMTsthe list of PMT to be grouped
dirthe direction normal to the walls
Returns
a list of pairs: each an absolute wall coordinate and PMT list

The algorithm returns a list of walls, with as first element a coordinate representing the wall and the second the list of optical detectors in that wall, in no particular order. The walls are sorted by increasing coordinate.

Definition at line 167 of file PMTverticalSlicingAlg.cxx.

169 {
170  // fill the walls with PMTs
171  std::vector<PMTlist_t> walls = clusterPMTby(PMTs, dir);
172 
173  // determine their coordinate
174  std::vector<std::pair<double, PMTlist_t>> posAndWalls;
175  posAndWalls.reserve(walls.size());
176  for (PMTlist_t& wall: walls)
177  posAndWalls.emplace_back(PMTwallPosition(wall, dir), std::move(wall));
178 
179  // sort by coordinate
180  std::sort(posAndWalls.begin(), posAndWalls.end()); // sort by std::pair::first
181 
182  return posAndWalls;
183 
184 } // icarus::trigger::PMTverticalSlicingAlg::PMTwalls(CryostatGeo)
std::vector< geo::OpDetGeo const * > PMTlist_t
Type of optical detector list.
static std::vector< PMTlist_t > clusterPMTby(PMTlist_t const &PMTs, geo::Vector_t const &dir)
Clusters the PMTs along the specified direction.
tuple dir
Definition: dropbox.py:28
walls no wall
Definition: selectors.fcl:105
static double PMTwallPosition(PMTlist_t const &PMTs, geo::Vector_t const &dir)
Returns an (arbitrary) coordinate along dir representing the PMT list.

Member Data Documentation

std::string icarus::trigger::PMTverticalSlicingAlg::fLogCategory
private

Category for message streaming.

Definition at line 97 of file PMTverticalSlicingAlg.h.


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