LArSoft  v10_04_05
Liquid Argon Software toolkit - https://larsoft.org/
GeoObjectSorter.cxx
Go to the documentation of this file.
1 
12 
13 #include <algorithm>
14 #include <utility>
15 
16 namespace {
17  template <typename T, typename Arg>
18  auto bind(bool (T::*ft)(Arg const&, Arg const&) const, T const* t)
19  {
20  return [t, ft](auto const& a, auto const& b) { return (t->*ft)(a, b); };
21  }
22 }
23 
24 namespace geo {
25 
26  void GeoObjectSorter::sort(std::vector<CryostatGeo>& cryostats) const
27  {
28  std::sort(cryostats.begin(), cryostats.end(), bind(&GeoObjectSorter::compareCryostats, this));
29  }
30 
31  void GeoObjectSorter::sort(std::vector<TPCGeo>& tpcs) const
32  {
33  std::sort(tpcs.begin(), tpcs.end(), bind(&GeoObjectSorter::compareTPCs, this));
34  }
35 
36  void GeoObjectSorter::sort(std::vector<OpDetGeo>& ods) const
37  {
38  std::sort(ods.begin(), ods.end(), bind(&GeoObjectSorter::compareOpDets, this));
39  }
40 
41  bool GeoObjectSorter::compareOpDets(OpDetGeo const& od1, OpDetGeo const& od2) const
42  {
43  auto const [xyz1, xyz2] = std::make_pair(od1.GetCenter(), od2.GetCenter());
44 
45  if (xyz1.Z() != xyz2.Z()) return xyz1.Z() > xyz2.Z();
46  if (xyz1.Y() != xyz2.Y()) return xyz1.Y() > xyz2.Y();
47  return xyz1.X() > xyz2.X();
48  }
49 }
Encapsulate the construction of a single cyostat .
Encapsulate the geometry of the sensitive portion of an auxiliary detector .
Point_t const & GetCenter() const
Definition: OpDetGeo.h:71
Interface to algorithm class for sorting geo::AuxDet objects .
virtual bool compareCryostats(CryostatGeo const &c1, CryostatGeo const &c2) const =0
void sort(std::vector< CryostatGeo > &cryostats) const
Encapsulate the geometry of an auxiliary detector.
Encapsulate the geometry of an optical detector.
virtual bool compareOpDets(OpDetGeo const &od1, OpDetGeo const &od2) const
virtual bool compareTPCs(TPCGeo const &t1, TPCGeo const &t2) const =0
ROOT libraries.
Encapsulate the construction of a single detector plane .