Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,32 +1,28 @@
/**
* @file icarusalg/Geometry/details/AuxDetSorting.cxx
* @brief Functions for sorting ICARUS CRT modules (auxiliary detectors).
* @author Chris Hilgenberg, Gianluca Petrillo (refactoring only)
* @date August 7, 2018
* @see icarusalg/Geometry/details/AuxDetSorting.h
* @file icarusalg/Geometry/AuxDetGeoObjectSorterICARUS.cxx
* @brief Interface to algorithm class for sorting standard geo::XXXGeo objects
* @author Chris Hilgenberg
* @date August 7, 2018.
* @see icarusalg/Geometry/AuxDetGeoObjectSorterICARUS.h
*/

// library header
#include "icarusalg/Geometry/details/AuxDetSorting.h"
#include "icarusalg/Geometry/AuxDetGeoObjectSorterICARUS.h"

// LArSoft libraries
#include "larcorealg/Geometry/AuxDetGeo.h"
#include "larcorealg/Geometry/AuxDetSensitiveGeo.h"

// C/C++ standard libraries
#include <string>
#include <algorithm> // std::sort()
#include <cstdlib> // std::atoi()

namespace geo{

namespace {

//--------------------------------------------------------------------------
/// Define sort order for CRT modules in standard configuration.
bool AuxDetStandardSortingRule
(const geo::AuxDetGeo& ad1, const geo::AuxDetGeo& ad2)
//----------------------------------------------------------------------------
AuxDetGeoObjectSorterICARUS::AuxDetGeoObjectSorterICARUS(fhicl::ParameterSet const&)
{
}

//----------------------------------------------------------------------------
bool AuxDetGeoObjectSorterICARUS::compareAuxDets(AuxDetGeo const& ad1, AuxDetGeo const& ad2) const
{

std::string type1 = "", type2 = "";
switch (ad1.NSensitiveVolume()) {
case 20 : type1 = "MINOS"; break;
Expand Down Expand Up @@ -54,14 +50,11 @@ namespace {
int ad2Num = std::atoi( ad2name.substr( base2.size(), 3).c_str() );

return ad1Num < ad2Num;
}

} // AuxDetStandardSortingRule()


//----------------------------------------------------------------------------
/// Define sort order for CRT submodules in standard configuration.
bool AuxDetSensitiveStandardSortingRule
(const geo::AuxDetSensitiveGeo& ad1, const geo::AuxDetSensitiveGeo& ad2)
bool AuxDetGeoObjectSorterICARUS::compareAuxDetSensitives(AuxDetSensitiveGeo const& ad1,
AuxDetSensitiveGeo const& ad2) const
{
std::string type1 = "", type2 = "";

Expand Down Expand Up @@ -96,27 +89,6 @@ namespace {


return ad1Num < ad2Num;
}

} // AuxDetSensitiveStandardSortingRule()


//----------------------------------------------------------------------------

} // local namespace


//------------------------------------------------------------------------------
void icarus::SortAuxDetsStandard(std::vector<geo::AuxDetGeo> & adgeo) {
std::sort(adgeo.begin(), adgeo.end(), AuxDetStandardSortingRule);
}


//------------------------------------------------------------------------------
void icarus::SortAuxDetSensitiveStandard
(std::vector<geo::AuxDetSensitiveGeo>& adsgeo)
{
std::sort(adsgeo.begin(), adsgeo.end(), AuxDetSensitiveStandardSortingRule);
}


//------------------------------------------------------------------------------
28 changes: 28 additions & 0 deletions icarusalg/Geometry/AuxDetGeoObjectSorterICARUS.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/**
* @file icarusalg/Geometry/AuxDetGeoObjectSorterICARUS.h
* @brief Interface to algorithm class for standard sorting of geo::XXXGeo objects
*
* @author Chris Hilgenberg
*/
#ifndef ICARUSALG_GEOMETRY_AUXDETGEOOBJECTSORTERICARUS_H
#define ICARUSALG_GEOMETRY_AUXDETGEOOBJECTSORTERICARUS_H

#include "larcorealg/Geometry/AuxDetGeoObjectSorter.h"

#include "fhiclcpp/fwd.h"

namespace geo{

class AuxDetGeoObjectSorterICARUS : public AuxDetGeoObjectSorter {
public:
explicit AuxDetGeoObjectSorterICARUS(fhicl::ParameterSet const&);

private:
bool compareAuxDets(AuxDetGeo const& ad1, AuxDetGeo const& ad2) const override;
bool compareAuxDetSensitives(AuxDetSensitiveGeo const& ad1,
AuxDetSensitiveGeo const& ad2) const override;
};

}

#endif // ICARUSALG_GEOMETRY_AUXDETGEOOBJECTSORTERICARUS_H
100 changes: 9 additions & 91 deletions icarusalg/Geometry/GeoObjectSorterICARUS.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -7,116 +7,34 @@
////////////////////////////////////////////////////////////////////////

#include "icarusalg/Geometry/GeoObjectSorterICARUS.h"
#include "icarusalg/Geometry/details/AuxDetSorting.h"

#include "larcorealg/Geometry/AuxDetGeo.h"
#include "larcorealg/Geometry/AuxDetSensitiveGeo.h"
#include "larcorealg/Geometry/CryostatGeo.h"
#include "larcorealg/Geometry/TPCGeo.h"
#include "larcorealg/Geometry/PlaneGeo.h"
#include "larcorealg/Geometry/WireGeo.h"

namespace geo{

//----------------------------------------------------------------------------
// Define sort order for cryostats in standard configuration
static bool sortCryoStandard(const CryostatGeo& c1, const CryostatGeo& c2)
GeoObjectSorterICARUS::GeoObjectSorterICARUS(fhicl::ParameterSet const&)
{
auto const xyz1 = c1.GetCenter();
auto const xyz2 = c2.GetCenter();

return xyz1.X() < xyz2.X();
}


//----------------------------------------------------------------------------
// Define sort order for tpcs in standard configuration.
static bool sortTPCStandard(const TPCGeo& t1, const TPCGeo& t2)
bool GeoObjectSorterICARUS::compareCryostats(CryostatGeo const& c1, CryostatGeo const& c2) const
{
auto const xyz1 = t1.GetCenter();
auto const xyz2 = t2.GetCenter();
auto const& xyz1 = c1.GetCenter();
auto const& xyz2 = c2.GetCenter();

// sort TPCs according to x
return xyz1.X() < xyz2.X();
}

const double EPSILON = 0.000001;

//----------------------------------------------------------------------------
// Define sort order for planes in standard configuration
static bool sortPlaneStandard(const PlaneGeo& p1, const PlaneGeo& p2)
{
auto const xyz1 = p1.GetBoxCenter();
auto const xyz2 = p2.GetBoxCenter();

//if the planes are in the same drift coordinate, lower Z is first plane
if( std::abs(xyz1.X() - xyz2.X()) < EPSILON)
return xyz1.Z() < xyz2.Z();

//else
// drift direction is negative, plane number increases in drift direction
return xyz1.X() > xyz2.X();
}


//----------------------------------------------------------------------------
static bool sortWireStandard(WireGeo const& w1, WireGeo const& w2){
auto const [xyz1, xyz2] = std::pair{w1.GetCenter(), w2.GetCenter()};

//we have horizontal wires...
if( std::abs(xyz1.Z()-xyz2.Z()) < EPSILON)
return xyz1.Y() < xyz2.Y();

//in the other cases...
return xyz1.Z() < xyz2.Z();
}

//----------------------------------------------------------------------------
GeoObjectSorterICARUS::GeoObjectSorterICARUS(fhicl::ParameterSet const& p)
{
}

//----------------------------------------------------------------------------
void GeoObjectSorterICARUS::SortAuxDets(std::vector<geo::AuxDetGeo> & adgeo) const
bool GeoObjectSorterICARUS::compareTPCs(TPCGeo const& t1, TPCGeo const& t2) const
{
icarus::SortAuxDetsStandard(adgeo);
}

//----------------------------------------------------------------------------
void GeoObjectSorterICARUS::SortAuxDetSensitive(std::vector<geo::AuxDetSensitiveGeo> & adsgeo) const
{
icarus::SortAuxDetSensitiveStandard(adsgeo);
}
auto const& xyz1 = t1.GetCenter();
auto const& xyz2 = t2.GetCenter();

//----------------------------------------------------------------------------
void GeoObjectSorterICARUS::SortCryostats(std::vector<geo::CryostatGeo> & cgeo) const
{
std::sort(cgeo.begin(), cgeo.end(), sortCryoStandard);
}

//----------------------------------------------------------------------------
void GeoObjectSorterICARUS::SortTPCs(std::vector<geo::TPCGeo> & tgeo) const
{
std::sort(tgeo.begin(), tgeo.end(), sortTPCStandard);
}

//----------------------------------------------------------------------------
void GeoObjectSorterICARUS::SortPlanes(std::vector<geo::PlaneGeo> & pgeo,
geo::DriftDirection_t const driftDir) const
{
// sort the planes to increase in drift direction
// The drift direction has to be set before this method is called. It is set when
// the CryostatGeo objects are sorted by the CryostatGeo::SortSubVolumes method
if (driftDir == geo::kPosX) std::sort(pgeo.rbegin(), pgeo.rend(), sortPlaneStandard);
else if(driftDir == geo::kNegX) std::sort(pgeo.begin(), pgeo.end(), sortPlaneStandard);
else if(driftDir == geo::kUnknownDrift)
throw cet::exception("TPCGeo") << "Drift direction is unknown, can't sort the planes\n";
}

//----------------------------------------------------------------------------
void GeoObjectSorterICARUS::SortWires(std::vector<geo::WireGeo> & wgeo) const
{
std::sort(wgeo.begin(), wgeo.end(), sortWireStandard);
// sort TPCs according to x
return xyz1.X() < xyz2.X();
}

}
19 changes: 5 additions & 14 deletions icarusalg/Geometry/GeoObjectSorterICARUS.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,28 +8,19 @@
#ifndef GEO_GEOOBJECTSORTERICARUS_H
#define GEO_GEOOBJECTSORTERICARUS_H

#include <vector>
#include "larcorealg/Geometry/GeoObjectSorter.h"

#include "fhiclcpp/fwd.h"

#include "larcorealg/Geometry/GeoObjectSorter.h"
#include "fhiclcpp/ParameterSet.h"

namespace geo{

class GeoObjectSorterICARUS : public GeoObjectSorter {
public:
explicit GeoObjectSorterICARUS(fhicl::ParameterSet const&);

GeoObjectSorterICARUS(fhicl::ParameterSet const& p);

void SortAuxDets (std::vector<geo::AuxDetGeo> & adgeo) const;
void SortAuxDetSensitive(std::vector<geo::AuxDetSensitiveGeo> & adsgeo) const;
void SortCryostats (std::vector<geo::CryostatGeo> & cgeo) const;
void SortTPCs (std::vector<geo::TPCGeo> & tgeo) const;
void SortPlanes (std::vector<geo::PlaneGeo> & pgeo,
geo::DriftDirection_t driftDir) const;
void SortWires (std::vector<geo::WireGeo> & wgeo) const;

private:
bool compareCryostats(CryostatGeo const& c1, CryostatGeo const& c2) const override;
bool compareTPCs(TPCGeo const& t1, TPCGeo const& t2) const override;
};

}
Expand Down
29 changes: 9 additions & 20 deletions icarusalg/Geometry/GeoObjectSorterPMTasTPC.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -4,31 +4,20 @@
* @date April 26, 2020
* @author Gianluca Petrillo (petrillo@slac.stanford.edu)
* @see icarusalg/Geometry/GeoObjectSorterPMTasTPC.h
*
* Nothing, really.
*/


// library header
#include "icarusalg/Geometry/GeoObjectSorterPMTasTPC.h"

// ICARUS libraries
#include "icarusalg/Geometry/details/AuxDetSorting.h"

// LArSoft header
#include "larcorealg/Geometry/OpDetGeo.h"

//------------------------------------------------------------------------------
void icarus::GeoObjectSorterPMTasTPC::SortAuxDets
(std::vector<geo::AuxDetGeo>& adgeo) const
bool icarus::GeoObjectSorterPMTasTPC::compareOpDets(geo::OpDetGeo const& od1,
geo::OpDetGeo const& od2) const
{
icarus::SortAuxDetsStandard(adgeo);
auto const& c1 = od1.GetCenter();
auto const& c2 = od2.GetCenter();
if (fCmpX(c1, c2)) return c1.X() < c2.X();
if (fCmpZ(c1, c2)) return c1.Z() < c2.Z();
return c1.Y() < c2.Y();
}

//------------------------------------------------------------------------------
void icarus::GeoObjectSorterPMTasTPC::SortAuxDetSensitive
(std::vector<geo::AuxDetSensitiveGeo>& adsgeo) const
{
icarus::SortAuxDetSensitiveStandard(adsgeo);
}


//------------------------------------------------------------------------------
Loading