GeoObjectSorter.cxx
Go to the documentation of this file.
1 ////////////////////////////////////////////////////////////////////////
2 /// \file GeoObjectSorter.cxx
3 /// \brief Interface to algorithm class for sorting geo::XXXGeo objects
4 ///
5 /// \author brebel@fnal.gov
6 ////////////////////////////////////////////////////////////////////////
7 
10 
11 #include <algorithm>
12 #include <vector>
13 
14 namespace geo{
15 
16  static bool sortorderOpDets(const OpDetGeo& t1, const OpDetGeo& t2)
17  {
18  double xyz1[3] = {0.}, xyz2[3] = {0.};
19  double local[3] = {0.};
20  t1.LocalToWorld(local, xyz1);
21  t2.LocalToWorld(local, xyz2);
22 
23  if(xyz1[2]!=xyz2[2])
24  return xyz1[2]>xyz2[2];
25  else if(xyz1[1]!=xyz2[1])
26  return xyz1[1]>xyz2[1];
27  else
28  return xyz1[0]>xyz2[0];
29  }
30 
31  void GeoObjectSorter::SortOpDets(std::vector<geo::OpDetGeo> & opdet) const
32  {
33  std::sort(opdet.begin(), opdet.end(), sortorderOpDets);
34  }
35 }
virtual void SortOpDets(std::vector< geo::OpDetGeo > &opdet) const
Interface to algorithm class for sorting geo::XXXGeo objects.
static bool sortorderOpDets(const OpDetGeo &t1, const OpDetGeo &t2)
Encapsulate the geometry of an optical detector.
LArSoft geometry interface.
Definition: ChannelGeo.h:16
void LocalToWorld(const double *opdet, double *world) const
Transform point from local optical detector frame to world frame.
Definition: OpDetGeo.h:112