Skip to content

Commit cb596e2

Browse files
committed
Accommodate changes due to GeometryCore/ChannelMapAlg separation.
1 parent 49af418 commit cb596e2

29 files changed

Lines changed: 513 additions & 795 deletions
Lines changed: 22 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,28 @@
1-
/**
2-
* @file icarusalg/Geometry/details/AuxDetSorting.cxx
3-
* @brief Functions for sorting ICARUS CRT modules (auxiliary detectors).
4-
* @author Chris Hilgenberg, Gianluca Petrillo (refactoring only)
5-
* @date August 7, 2018
6-
* @see icarusalg/Geometry/details/AuxDetSorting.h
7-
*/
8-
9-
// library header
10-
#include "icarusalg/Geometry/details/AuxDetSorting.h"
11-
12-
// LArSoft libraries
1+
////////////////////////////////////////////////////////////////////////
2+
/// \file GeoObjectSorterICARUS.cxx
3+
/// \brief Interface to algorithm class for sorting standard geo::XXXGeo objects
4+
///
5+
/// \version $Id: $
6+
/// \author brebel@fnal.gov
7+
////////////////////////////////////////////////////////////////////////
8+
9+
#include "icarusalg/Geometry/AuxDetGeoObjectSorterICARUS.h"
10+
1311
#include "larcorealg/Geometry/AuxDetGeo.h"
1412
#include "larcorealg/Geometry/AuxDetSensitiveGeo.h"
1513

16-
// C/C++ standard libraries
1714
#include <string>
18-
#include <algorithm> // std::sort()
19-
#include <cstdlib> // std::atoi()
2015

16+
namespace geo{
2117

22-
namespace {
23-
24-
//--------------------------------------------------------------------------
25-
/// Define sort order for CRT modules in standard configuration.
26-
bool AuxDetStandardSortingRule
27-
(const geo::AuxDetGeo& ad1, const geo::AuxDetGeo& ad2)
18+
//----------------------------------------------------------------------------
19+
AuxDetGeoObjectSorterICARUS::AuxDetGeoObjectSorterICARUS(fhicl::ParameterSet const&)
20+
{
21+
}
22+
23+
//----------------------------------------------------------------------------
24+
bool AuxDetGeoObjectSorterICARUS::compareAuxDets(AuxDetGeo const& ad1, AuxDetGeo const& ad2) const
2825
{
29-
3026
std::string type1 = "", type2 = "";
3127
switch (ad1.NSensitiveVolume()) {
3228
case 20 : type1 = "MINOS"; break;
@@ -50,14 +46,11 @@ namespace {
5046
int ad2Num = std::atoi( ad2name.substr( base2.size(), 3).c_str() );
5147

5248
return ad1Num < ad2Num;
49+
}
5350

54-
} // AuxDetStandardSortingRule()
55-
56-
5751
//----------------------------------------------------------------------------
58-
/// Define sort order for CRT submodules in standard configuration.
59-
bool AuxDetSensitiveStandardSortingRule
60-
(const geo::AuxDetSensitiveGeo& ad1, const geo::AuxDetSensitiveGeo& ad2)
52+
bool AuxDetGeoObjectSorterICARUS::compareAuxDetSensitives(AuxDetSensitiveGeo const& ad1,
53+
AuxDetSensitiveGeo const& ad2) const
6154
{
6255
std::string type1 = "", type2 = "";
6356

@@ -88,27 +81,6 @@ namespace {
8881

8982

9083
return ad1Num < ad2Num;
84+
}
9185

92-
} // AuxDetSensitiveStandardSortingRule()
93-
94-
95-
//----------------------------------------------------------------------------
96-
97-
} // local namespace
98-
99-
100-
//------------------------------------------------------------------------------
101-
void icarus::SortAuxDetsStandard(std::vector<geo::AuxDetGeo> & adgeo) {
102-
std::sort(adgeo.begin(), adgeo.end(), AuxDetStandardSortingRule);
10386
}
104-
105-
106-
//------------------------------------------------------------------------------
107-
void icarus::SortAuxDetSensitiveStandard
108-
(std::vector<geo::AuxDetSensitiveGeo>& adsgeo)
109-
{
110-
std::sort(adsgeo.begin(), adsgeo.end(), AuxDetSensitiveStandardSortingRule);
111-
}
112-
113-
114-
//------------------------------------------------------------------------------
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
////////////////////////////////////////////////////////////////////////
2+
/// \file AuxDetGeoObjectSorterICARUS.h
3+
/// \brief Interface to algorithm class for standard sorting of geo::XXXGeo objects
4+
///
5+
/// \version $Id: $
6+
/// \author wketchum@fnal.gov
7+
////////////////////////////////////////////////////////////////////////
8+
#ifndef GEO_AUXDETGEOOBJECTSORTERICARUS_H
9+
#define GEO_AUXDETGEOOBJECTSORTERICARUS_H
10+
11+
#include "larcorealg/Geometry/AuxDetGeoObjectSorter.h"
12+
13+
#include "fhiclcpp/fwd.h"
14+
15+
namespace geo{
16+
17+
class AuxDetGeoObjectSorterICARUS : public AuxDetGeoObjectSorter {
18+
public:
19+
explicit AuxDetGeoObjectSorterICARUS(fhicl::ParameterSet const&);
20+
21+
private:
22+
bool compareAuxDets(AuxDetGeo const& ad1, AuxDetGeo const& ad2) const override;
23+
bool compareAuxDetSensitives(AuxDetSensitiveGeo const& ad1,
24+
AuxDetSensitiveGeo const& ad2) const override;
25+
};
26+
27+
}
28+
29+
#endif // GEO_AUXDETGEOOBJECTSORTERICARUS_H

icarusalg/Geometry/GeoObjectSorterICARUS.cxx

Lines changed: 7 additions & 89 deletions
Original file line numberDiff line numberDiff line change
@@ -7,31 +7,28 @@
77
////////////////////////////////////////////////////////////////////////
88

99
#include "icarusalg/Geometry/GeoObjectSorterICARUS.h"
10-
#include "icarusalg/Geometry/details/AuxDetSorting.h"
1110

12-
#include "larcorealg/Geometry/AuxDetGeo.h"
13-
#include "larcorealg/Geometry/AuxDetSensitiveGeo.h"
1411
#include "larcorealg/Geometry/CryostatGeo.h"
1512
#include "larcorealg/Geometry/TPCGeo.h"
16-
#include "larcorealg/Geometry/PlaneGeo.h"
17-
#include "larcorealg/Geometry/WireGeo.h"
1813

1914
namespace geo{
2015

2116
//----------------------------------------------------------------------------
22-
// Define sort order for cryostats in standard configuration
23-
static bool sortCryoStandard(const CryostatGeo& c1, const CryostatGeo& c2)
17+
GeoObjectSorterICARUS::GeoObjectSorterICARUS(fhicl::ParameterSet const&)
18+
{
19+
}
20+
21+
//----------------------------------------------------------------------------
22+
bool GeoObjectSorterICARUS::compareCryostats(CryostatGeo const& c1, CryostatGeo const& c2) const
2423
{
2524
auto const xyz1 = c1.GetCenter();
2625
auto const xyz2 = c2.GetCenter();
2726

2827
return xyz1.X() < xyz2.X();
2928
}
3029

31-
3230
//----------------------------------------------------------------------------
33-
// Define sort order for tpcs in standard configuration.
34-
static bool sortTPCStandard(const TPCGeo& t1, const TPCGeo& t2)
31+
bool GeoObjectSorterICARUS::compareTPCs(TPCGeo const& t1, TPCGeo const& t2) const
3532
{
3633
auto const xyz1 = t1.GetCenter();
3734
auto const xyz2 = t2.GetCenter();
@@ -40,83 +37,4 @@ namespace geo{
4037
return xyz1.X() < xyz2.X();
4138
}
4239

43-
const double EPSILON = 0.000001;
44-
45-
//----------------------------------------------------------------------------
46-
// Define sort order for planes in standard configuration
47-
static bool sortPlaneStandard(const PlaneGeo& p1, const PlaneGeo& p2)
48-
{
49-
auto const xyz1 = p1.GetBoxCenter();
50-
auto const xyz2 = p2.GetBoxCenter();
51-
52-
//if the planes are in the same drift coordinate, lower Z is first plane
53-
if( std::abs(xyz1.X() - xyz2.X()) < EPSILON)
54-
return xyz1.Z() < xyz2.Z();
55-
56-
//else
57-
// drift direction is negative, plane number increases in drift direction
58-
return xyz1.X() > xyz2.X();
59-
}
60-
61-
62-
//----------------------------------------------------------------------------
63-
static bool sortWireStandard(WireGeo const& w1, WireGeo const& w2){
64-
auto const [xyz1, xyz2] = std::pair{w1.GetCenter(), w2.GetCenter()};
65-
66-
//we have horizontal wires...
67-
if( std::abs(xyz1.Z()-xyz2.Z()) < EPSILON)
68-
return xyz1.Y() < xyz2.Y();
69-
70-
//in the other cases...
71-
return xyz1.Z() < xyz2.Z();
72-
}
73-
74-
//----------------------------------------------------------------------------
75-
GeoObjectSorterICARUS::GeoObjectSorterICARUS(fhicl::ParameterSet const& p)
76-
{
77-
}
78-
79-
//----------------------------------------------------------------------------
80-
void GeoObjectSorterICARUS::SortAuxDets(std::vector<geo::AuxDetGeo> & adgeo) const
81-
{
82-
icarus::SortAuxDetsStandard(adgeo);
83-
}
84-
85-
//----------------------------------------------------------------------------
86-
void GeoObjectSorterICARUS::SortAuxDetSensitive(std::vector<geo::AuxDetSensitiveGeo> & adsgeo) const
87-
{
88-
icarus::SortAuxDetSensitiveStandard(adsgeo);
89-
}
90-
91-
//----------------------------------------------------------------------------
92-
void GeoObjectSorterICARUS::SortCryostats(std::vector<geo::CryostatGeo> & cgeo) const
93-
{
94-
std::sort(cgeo.begin(), cgeo.end(), sortCryoStandard);
95-
}
96-
97-
//----------------------------------------------------------------------------
98-
void GeoObjectSorterICARUS::SortTPCs(std::vector<geo::TPCGeo> & tgeo) const
99-
{
100-
std::sort(tgeo.begin(), tgeo.end(), sortTPCStandard);
101-
}
102-
103-
//----------------------------------------------------------------------------
104-
void GeoObjectSorterICARUS::SortPlanes(std::vector<geo::PlaneGeo> & pgeo,
105-
geo::DriftDirection_t const driftDir) const
106-
{
107-
// sort the planes to increase in drift direction
108-
// The drift direction has to be set before this method is called. It is set when
109-
// the CryostatGeo objects are sorted by the CryostatGeo::SortSubVolumes method
110-
if (driftDir == geo::kPosX) std::sort(pgeo.rbegin(), pgeo.rend(), sortPlaneStandard);
111-
else if(driftDir == geo::kNegX) std::sort(pgeo.begin(), pgeo.end(), sortPlaneStandard);
112-
else if(driftDir == geo::kUnknownDrift)
113-
throw cet::exception("TPCGeo") << "Drift direction is unknown, can't sort the planes\n";
114-
}
115-
116-
//----------------------------------------------------------------------------
117-
void GeoObjectSorterICARUS::SortWires(std::vector<geo::WireGeo> & wgeo) const
118-
{
119-
std::sort(wgeo.begin(), wgeo.end(), sortWireStandard);
120-
}
121-
12240
}

icarusalg/Geometry/GeoObjectSorterICARUS.h

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -8,28 +8,19 @@
88
#ifndef GEO_GEOOBJECTSORTERICARUS_H
99
#define GEO_GEOOBJECTSORTERICARUS_H
1010

11-
#include <vector>
11+
#include "larcorealg/Geometry/GeoObjectSorter.h"
1212

1313
#include "fhiclcpp/fwd.h"
1414

15-
#include "larcorealg/Geometry/GeoObjectSorter.h"
16-
#include "fhiclcpp/ParameterSet.h"
17-
1815
namespace geo{
1916

2017
class GeoObjectSorterICARUS : public GeoObjectSorter {
2118
public:
19+
explicit GeoObjectSorterICARUS(fhicl::ParameterSet const&);
2220

23-
GeoObjectSorterICARUS(fhicl::ParameterSet const& p);
24-
25-
void SortAuxDets (std::vector<geo::AuxDetGeo> & adgeo) const;
26-
void SortAuxDetSensitive(std::vector<geo::AuxDetSensitiveGeo> & adsgeo) const;
27-
void SortCryostats (std::vector<geo::CryostatGeo> & cgeo) const;
28-
void SortTPCs (std::vector<geo::TPCGeo> & tgeo) const;
29-
void SortPlanes (std::vector<geo::PlaneGeo> & pgeo,
30-
geo::DriftDirection_t driftDir) const;
31-
void SortWires (std::vector<geo::WireGeo> & wgeo) const;
32-
21+
private:
22+
bool compareCryostats(CryostatGeo const& c1, CryostatGeo const& c2) const override;
23+
bool compareTPCs(TPCGeo const& t1, TPCGeo const& t2) const override;
3324
};
3425

3526
}

icarusalg/Geometry/GeoObjectSorterPMTasTPC.cxx

Lines changed: 8 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -4,31 +4,19 @@
44
* @date April 26, 2020
55
* @author Gianluca Petrillo (petrillo@slac.stanford.edu)
66
* @see icarusalg/Geometry/GeoObjectSorterPMTasTPC.h
7-
*
8-
* Nothing, really.
97
*/
108

11-
129
// library header
1310
#include "icarusalg/Geometry/GeoObjectSorterPMTasTPC.h"
1411

15-
// ICARUS libraries
16-
#include "icarusalg/Geometry/details/AuxDetSorting.h"
17-
12+
// LArSoft header
13+
#include "larcorealg/Geometry/OpDetGeo.h"
1814

19-
//------------------------------------------------------------------------------
20-
void icarus::GeoObjectSorterPMTasTPC::SortAuxDets
21-
(std::vector<geo::AuxDetGeo>& adgeo) const
15+
bool icarus::GeoObjectSorterPMTasTPC::compareOpDets(geo::OpDetGeo const& od1,
16+
geo::OpDetGeo const& od2) const
2217
{
23-
icarus::SortAuxDetsStandard(adgeo);
18+
auto const [c1, c2] = std::pair{od1.GetCenter(), od2.GetCenter()};
19+
if (fCmpX(c1, c2)) return c1.X() < c2.X();
20+
if (fCmpY(c2, c2)) return c1.Y() < c2.Y();
21+
return c1.Z() < c2.Z();
2422
}
25-
26-
//------------------------------------------------------------------------------
27-
void icarus::GeoObjectSorterPMTasTPC::SortAuxDetSensitive
28-
(std::vector<geo::AuxDetSensitiveGeo>& adsgeo) const
29-
{
30-
icarus::SortAuxDetSensitiveStandard(adsgeo);
31-
}
32-
33-
34-
//------------------------------------------------------------------------------

0 commit comments

Comments
 (0)