diff --git a/icarusalg/Geometry/details/AuxDetSorting.cxx b/icarusalg/Geometry/AuxDetGeoObjectSorterICARUS.cxx similarity index 66% rename from icarusalg/Geometry/details/AuxDetSorting.cxx rename to icarusalg/Geometry/AuxDetGeoObjectSorterICARUS.cxx index 688cd95..95717e5 100644 --- a/icarusalg/Geometry/details/AuxDetSorting.cxx +++ b/icarusalg/Geometry/AuxDetGeoObjectSorterICARUS.cxx @@ -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 -#include // std::sort() -#include // 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; @@ -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 = ""; @@ -96,27 +89,6 @@ namespace { return ad1Num < ad2Num; + } - } // AuxDetSensitiveStandardSortingRule() - - - //---------------------------------------------------------------------------- - -} // local namespace - - -//------------------------------------------------------------------------------ -void icarus::SortAuxDetsStandard(std::vector & adgeo) { - std::sort(adgeo.begin(), adgeo.end(), AuxDetStandardSortingRule); -} - - -//------------------------------------------------------------------------------ -void icarus::SortAuxDetSensitiveStandard - (std::vector& adsgeo) -{ - std::sort(adsgeo.begin(), adsgeo.end(), AuxDetSensitiveStandardSortingRule); } - - -//------------------------------------------------------------------------------ diff --git a/icarusalg/Geometry/AuxDetGeoObjectSorterICARUS.h b/icarusalg/Geometry/AuxDetGeoObjectSorterICARUS.h new file mode 100644 index 0000000..7c7794f --- /dev/null +++ b/icarusalg/Geometry/AuxDetGeoObjectSorterICARUS.h @@ -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 diff --git a/icarusalg/Geometry/GeoObjectSorterICARUS.cxx b/icarusalg/Geometry/GeoObjectSorterICARUS.cxx index e4d875f..2361957 100644 --- a/icarusalg/Geometry/GeoObjectSorterICARUS.cxx +++ b/icarusalg/Geometry/GeoObjectSorterICARUS.cxx @@ -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 & adgeo) const + bool GeoObjectSorterICARUS::compareTPCs(TPCGeo const& t1, TPCGeo const& t2) const { - icarus::SortAuxDetsStandard(adgeo); - } - - //---------------------------------------------------------------------------- - void GeoObjectSorterICARUS::SortAuxDetSensitive(std::vector & adsgeo) const - { - icarus::SortAuxDetSensitiveStandard(adsgeo); - } + auto const& xyz1 = t1.GetCenter(); + auto const& xyz2 = t2.GetCenter(); - //---------------------------------------------------------------------------- - void GeoObjectSorterICARUS::SortCryostats(std::vector & cgeo) const - { - std::sort(cgeo.begin(), cgeo.end(), sortCryoStandard); - } - - //---------------------------------------------------------------------------- - void GeoObjectSorterICARUS::SortTPCs(std::vector & tgeo) const - { - std::sort(tgeo.begin(), tgeo.end(), sortTPCStandard); - } - - //---------------------------------------------------------------------------- - void GeoObjectSorterICARUS::SortPlanes(std::vector & 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 & wgeo) const - { - std::sort(wgeo.begin(), wgeo.end(), sortWireStandard); + // sort TPCs according to x + return xyz1.X() < xyz2.X(); } } diff --git a/icarusalg/Geometry/GeoObjectSorterICARUS.h b/icarusalg/Geometry/GeoObjectSorterICARUS.h index b219c05..049d7b7 100644 --- a/icarusalg/Geometry/GeoObjectSorterICARUS.h +++ b/icarusalg/Geometry/GeoObjectSorterICARUS.h @@ -8,28 +8,19 @@ #ifndef GEO_GEOOBJECTSORTERICARUS_H #define GEO_GEOOBJECTSORTERICARUS_H -#include +#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 & adgeo) const; - void SortAuxDetSensitive(std::vector & adsgeo) const; - void SortCryostats (std::vector & cgeo) const; - void SortTPCs (std::vector & tgeo) const; - void SortPlanes (std::vector & pgeo, - geo::DriftDirection_t driftDir) const; - void SortWires (std::vector & wgeo) const; - + private: + bool compareCryostats(CryostatGeo const& c1, CryostatGeo const& c2) const override; + bool compareTPCs(TPCGeo const& t1, TPCGeo const& t2) const override; }; } diff --git a/icarusalg/Geometry/GeoObjectSorterPMTasTPC.cxx b/icarusalg/Geometry/GeoObjectSorterPMTasTPC.cxx index 7159317..e252a2a 100644 --- a/icarusalg/Geometry/GeoObjectSorterPMTasTPC.cxx +++ b/icarusalg/Geometry/GeoObjectSorterPMTasTPC.cxx @@ -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& 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& adsgeo) const -{ - icarus::SortAuxDetSensitiveStandard(adsgeo); -} - - -//------------------------------------------------------------------------------ diff --git a/icarusalg/Geometry/GeoObjectSorterPMTasTPC.h b/icarusalg/Geometry/GeoObjectSorterPMTasTPC.h index b43faf8..8940e8a 100644 --- a/icarusalg/Geometry/GeoObjectSorterPMTasTPC.h +++ b/icarusalg/Geometry/GeoObjectSorterPMTasTPC.h @@ -9,22 +9,19 @@ #ifndef ICARUSCODE_GEOMETRY_GEOOBJECTSORTERPMTASTPC_H #define ICARUSCODE_GEOMETRY_GEOOBJECTSORTERPMTASTPC_H -// ICARUS libraries -#include "icarusalg/Geometry/details/PMTsorting.h" // icarus::PMTsorterStandard - // LArSoft libraries #include "larcorealg/Geometry/GeoObjectSorterStandard.h" -#include "larcorealg/Geometry/OpDetGeo.h" +#include "larcorealg/Geometry/fwd.h" #include "larcorealg/CoreUtils/RealComparisons.h" -#include "larcorealg/CoreUtils/span.h" // util::span +#include "larcoreobj/SimpleTypesAndConstants/geo_vectors.h" // framework libraries +#include "fhiclcpp/types/Atom.h" #include "fhiclcpp/types/Table.h" #include "fhiclcpp/ParameterSet.h" -// C/C++ standard libraries -#include - +// C++ standard library +#include // ----------------------------------------------------------------------------- namespace icarus { class GeoObjectSorterPMTasTPC; } @@ -75,18 +72,36 @@ namespace icarus { class GeoObjectSorterPMTasTPC; } */ class icarus::GeoObjectSorterPMTasTPC: public geo::GeoObjectSorterStandard { - /// The sorting algorithm we use. - using PMTsorter_t = icarus::PMTsorterStandard; + public: - using PMTsorterConfigTable = fhicl::Table; + struct Config { - public: + using Name = fhicl::Name; + using Comment = fhicl::Comment; + + fhicl::Atom ToleranceX { + Name("ToleranceX"), + Comment("tolerance when sorting optical detectors on x coordinate [cm]"), + 1.0 // default + }; + + fhicl::Atom ToleranceZ { + Name("ToleranceZ"), + Comment("tolerance when sorting optical detectors on z coordinate [cm]"), + 1.0 // default + }; + + }; // Config + + struct KeysToIgnore { + std::set operator()() const { return {"tool_type"}; } + }; /// Constructor: passes the configuration to the base class. - GeoObjectSorterPMTasTPC(fhicl::ParameterSet const& pset) - : geo::GeoObjectSorterStandard(pset) - , fPMTsorter - (PMTsorterConfigTable{ pset.get("OpDetSorter", fhicl::ParameterSet{}) }()) + GeoObjectSorterPMTasTPC(fhicl::Table const& config) + : geo::GeoObjectSorterStandard(config.get_PSet()) + , fCmpX{ config().ToleranceX() } + , fCmpZ{ config().ToleranceZ() } {} @@ -101,28 +116,38 @@ class icarus::GeoObjectSorterPMTasTPC: public geo::GeoObjectSorterStandard { * This algorithm requires all optical detectors to have their center defined * (`geo::OpDetGeo::GetCenter()`). No other information is used. * - * @note The current implementation is very sensitive to rounding errors! - * */ - virtual void SortOpDets(std::vector& opDets) const override - { fPMTsorter.sort(opDets); } + bool compareOpDets(geo::OpDetGeo const& od1, geo::OpDetGeo const& od2) const override; + private: - /// Custom ICARUS sorting of CRT. - virtual void SortAuxDets(std::vector& adgeo) const override; - - /// Custom ICARUS sorting of CRT submodules. - virtual void SortAuxDetSensitive - (std::vector & adsgeo) const override; + /// `geo::OpDetGeo` comparer according to one coordinate of their center. + /// Accommodates for some tolerance. + template + struct CoordComparer { - private: + /// Object used for comparison; includes a tolerance. + lar::util::RealComparisons const fCmp; - PMTsorter_t fPMTsorter; ///< PMT sorting algorithm. + /// Constructor: fixes the tolerance for the comparison. + CoordComparer(double tol = 0.0): fCmp(tol) {} -}; // icarus::GeoObjectSorterPMTasTPC + /// Returns whether `A` has a different coordinate `Coord` than `B`. + bool operator() (geo::Point_t const& A, geo::Point_t const& B) const + { + return fCmp.nonEqual((A.*Coord)(), (B.*Coord)()); + } + }; // CoordComparer -static_assert(std::is_base_of_v); + + /// Comparison according to _x_ coordinate of `geo::OpDetGeo` center. + CoordComparer<&geo::Point_t::X> const fCmpX; + + /// Comparison according to _z_ coordinate of `geo::OpDetGeo` center. + CoordComparer<&geo::Point_t::Z> const fCmpZ; + +}; // icarus::GeoObjectSorterPMTasTPC // ----------------------------------------------------------------------------- diff --git a/icarusalg/Geometry/ICARUSChannelMapAlg.cxx b/icarusalg/Geometry/ICARUSWireReadoutGeom.cxx similarity index 77% rename from icarusalg/Geometry/ICARUSChannelMapAlg.cxx rename to icarusalg/Geometry/ICARUSWireReadoutGeom.cxx index 5c83045..73c5fc2 100644 --- a/icarusalg/Geometry/ICARUSChannelMapAlg.cxx +++ b/icarusalg/Geometry/ICARUSWireReadoutGeom.cxx @@ -1,22 +1,25 @@ /** - * @file icarusalg/Geometry/ICARUSChannelMapAlg.cxx + * @file icarusalg/Geometry/ICARUSWireReadoutGeom.cxx * @brief Channel mapping algorithms for ICARUS detector: implementation file. * @date October 19, 2019 * @author Gianluca Petrillo (petrillo@slac.stanford.edu) - * @see icarusalg/Geometry/ICARUSChannelMapAlg.h + * @see icarusalg/Geometry/ICARUSWireReadoutGeom.h */ // library header -#include "icarusalg/Geometry/ICARUSChannelMapAlg.h" +#include "icarusalg/Geometry/ICARUSWireReadoutGeom.h" // ICARUS libraries #include "icarusalg/Geometry/details/ROPandTPCsetBuildingAlg.h" // LArSoft libraries #include "larcorealg/Geometry/CryostatGeo.h" +#include "larcorealg/Geometry/GeometryCore.h" #include "larcorealg/Geometry/TPCGeo.h" #include "larcorealg/Geometry/PlaneGeo.h" #include "larcorealg/Geometry/ReadoutDataContainers.h" +#include "larcorealg/Geometry/WireReadoutGeomBuilderStandard.h" +#include "larcorealg/Geometry/WireReadoutSorter.h" #include "larcorealg/Geometry/details/extractMaxGeometryElements.h" #include "larcorealg/CoreUtils/enumerate.h" #include "larcorealg/CoreUtils/counter.h" @@ -30,6 +33,7 @@ #include "cetlib_except/exception.h" // cet::exception // C/C++ libraries +#include #include #include #include @@ -42,16 +46,6 @@ namespace { - // --------------------------------------------------------------------------- - fhicl::ParameterSet getOptionalParameterSet - (fhicl::OptionalDelegatedParameter const& param) - { - fhicl::ParameterSet pset; // empty by default - param.get_if_present(pset); - return pset; - } // fhicl::ParameterSet getOptionalParameterSet() - - // --------------------------------------------------------------------------- // Creates a STL vector with the result of the transformation of `coll`. @@ -75,46 +69,32 @@ namespace { // ----------------------------------------------------------------------------- -icarus::ICARUSChannelMapAlg::ICARUSChannelMapAlg(Config const& config) - : fWirelessChannelCounts +icarus::ICARUSWireReadoutGeom::ICARUSWireReadoutGeom(Config const& config, + geo::GeometryCore const* geom, + std::unique_ptr sorter) + : WireReadoutGeom{geom, + std::make_unique(config.builder), + std::move(sorter)} + , fWirelessChannelCounts (extractWirelessChannelParams(config.WirelessChannels())) - , fSorter(getOptionalParameterSet(config.Sorter)) - {} - - -// ----------------------------------------------------------------------------- -void icarus::ICARUSChannelMapAlg::Initialize(geo::GeometryData_t const& geodata) { // This is the only INFO level message we want this object to produce; // given the dynamic nature of the channel mapping choice, // it's better for the log to have some indication of chosen channel mapping. - mf::LogInfo("ICARUSChannelMapAlg") - << "Initializing ICARUSChannelMapAlg channel mapping algorithm."; + mf::LogInfo("ICARUSWireReadoutGeom") + << "Initializing ICARUSWireReadoutGeom channel mapping algorithm."; - buildReadoutPlanes(geodata.cryostats); + buildReadoutPlanes(geom->Cryostats()); - fillChannelToWireMap(geodata.cryostats); + fillChannelToWireMap(geom->Cryostats()); - MF_LOG_TRACE("ICARUSChannelMapAlg") - << "ICARUSChannelMapAlg::Initialize() completed."; - -} // icarus::ICARUSChannelMapAlg::Initialize() - - -// ----------------------------------------------------------------------------- -void icarus::ICARUSChannelMapAlg::Uninitialize() { - - fReadoutMapInfo.clear(); - - fChannelToWireMap.clear(); - - fPlaneInfo.clear(); - -} // icarus::ICARUSChannelMapAlg::Uninitialize() + MF_LOG_TRACE("ICARUSWireReadoutGeom") + << "ICARUSWireReadoutGeom::Initialize() completed."; + } //------------------------------------------------------------------------------ -std::vector icarus::ICARUSChannelMapAlg::ChannelToWire +std::vector icarus::ICARUSWireReadoutGeom::ChannelToWire (raw::ChannelID_t channel) const { // @@ -134,7 +114,7 @@ std::vector icarus::ICARUSChannelMapAlg::ChannelToWire = fChannelToWireMap.find(channel); if (!channelInfo) { throw cet::exception("Geometry") - << "icarus::ICARUSChannelMapAlg::ChannelToWire(" << channel + << "icarus::ICARUSWireReadoutGeom::ChannelToWire(" << channel << "): invalid channel requested (must be lower than " << Nchannels() << ")\n"; } @@ -161,82 +141,82 @@ std::vector icarus::ICARUSChannelMapAlg::ChannelToWire return AllSegments; -} // icarus::ICARUSChannelMapAlg::ChannelToWire() +} // icarus::ICARUSWireReadoutGeom::ChannelToWire() //------------------------------------------------------------------------------ -unsigned int icarus::ICARUSChannelMapAlg::Nchannels() const { +unsigned int icarus::ICARUSWireReadoutGeom::Nchannels() const { return fChannelToWireMap.nChannels(); -} // icarus::ICARUSChannelMapAlg::Nchannels() +} // icarus::ICARUSWireReadoutGeom::Nchannels() //------------------------------------------------------------------------------ -unsigned int icarus::ICARUSChannelMapAlg::Nchannels +unsigned int icarus::ICARUSWireReadoutGeom::Nchannels (readout::ROPID const& ropid) const { icarus::details::ChannelToWireMap::ChannelsInROPStruct const* ROPinfo = fChannelToWireMap.find(ropid); return ROPinfo? ROPinfo->nChannels: 0U; -} // icarus::ICARUSChannelMapAlg::Nchannels(ROPID) +} // icarus::ICARUSWireReadoutGeom::Nchannels(ROPID) //------------------------------------------------------------------------------ -double icarus::ICARUSChannelMapAlg::WireCoordinate +double icarus::ICARUSWireReadoutGeom::WireCoordinate (double YPos, double ZPos, geo::PlaneID const& planeID) const { /* * this should NOT be called... it shouldn't be here at all! */ - cet::exception e("ICARUSChannelMapAlg"); - e << "ICARUSChannelMapAlg does not support `WireCoordinate()` call." + cet::exception e("ICARUSWireReadoutGeom"); + e << "ICARUSWireReadoutGeom does not support `WireCoordinate()` call." "\nPlease update calling software to use geo::PlaneGeo::WireCoordinate()`:" "\n"; lar::debug::printBacktrace(e, 4U); throw e; -} // icarus::ICARUSChannelMapAlg::WireCoordinate() +} // icarus::ICARUSWireReadoutGeom::WireCoordinate() //------------------------------------------------------------------------------ -geo::WireID icarus::ICARUSChannelMapAlg::NearestWireID +geo::WireID icarus::ICARUSWireReadoutGeom::NearestWireID (const geo::Point_t& worldPos, geo::PlaneID const& planeID) const { /* * this should NOT be called... it shouldn't be here at all! */ - cet::exception e("ICARUSChannelMapAlg"); - e << "ICARUSChannelMapAlg does not support `NearestWireID()` call." + cet::exception e("ICARUSWireReadoutGeom"); + e << "ICARUSWireReadoutGeom does not support `NearestWireID()` call." "\nPlease update calling software to use geo::PlaneGeo::NearestWireID()`:" "\n"; lar::debug::printBacktrace(e, 3U); throw e; -} // icarus::ICARUSChannelMapAlg::NearestWireID() +} // icarus::ICARUSWireReadoutGeom::NearestWireID() //------------------------------------------------------------------------------ -raw::ChannelID_t icarus::ICARUSChannelMapAlg::PlaneWireToChannel +raw::ChannelID_t icarus::ICARUSWireReadoutGeom::PlaneWireToChannel (geo::WireID const& wireID) const { return fPlaneInfo[wireID].firstChannel() + wireID.Wire; -} // icarus::ICARUSChannelMapAlg::PlaneWireToChannel() +} // icarus::ICARUSWireReadoutGeom::PlaneWireToChannel() //------------------------------------------------------------------------------ -std::set const& icarus::ICARUSChannelMapAlg::PlaneIDs() const { +std::set const& icarus::ICARUSWireReadoutGeom::PlaneIDs() const { /* * this should NOT be called... it shouldn't be here at all! */ - cet::exception e("ICARUSChannelMapAlg"); - e << "ICARUSChannelMapAlg does not support `PlaneIDs()` call." + cet::exception e("ICARUSWireReadoutGeom"); + e << "ICARUSWireReadoutGeom does not support `PlaneIDs()` call." "\nPlease update calling software to use geo::GeometryCore::IteratePlanes()`" "\n"; @@ -244,46 +224,46 @@ std::set const& icarus::ICARUSChannelMapAlg::PlaneIDs() const { throw e; -} // icarus::ICARUSChannelMapAlg::PlaneIDs() +} // icarus::ICARUSWireReadoutGeom::PlaneIDs() //------------------------------------------------------------------------------ -unsigned int icarus::ICARUSChannelMapAlg::NTPCsets +unsigned int icarus::ICARUSWireReadoutGeom::NTPCsets (readout::CryostatID const& cryoid) const { return HasCryostat(cryoid)? TPCsetCount(cryoid): 0U; -} // icarus::ICARUSChannelMapAlg::NTPCsets() +} // icarus::ICARUSWireReadoutGeom::NTPCsets() //------------------------------------------------------------------------------ /// Returns the largest number of TPC sets any cryostat in the detector has -unsigned int icarus::ICARUSChannelMapAlg::MaxTPCsets() const { +unsigned int icarus::ICARUSWireReadoutGeom::MaxTPCsets() const { assert(fReadoutMapInfo); return fReadoutMapInfo.MaxTPCsets(); -} // icarus::ICARUSChannelMapAlg::MaxTPCsets() +} // icarus::ICARUSWireReadoutGeom::MaxTPCsets() //------------------------------------------------------------------------------ /// Returns whether we have the specified TPC set /// @return whether the TPC set is valid and exists -bool icarus::ICARUSChannelMapAlg::HasTPCset +bool icarus::ICARUSWireReadoutGeom::HasTPCset (readout::TPCsetID const& tpcsetid) const { return HasCryostat(tpcsetid)? (tpcsetid.TPCset < TPCsetCount(tpcsetid)): false; -} // icarus::ICARUSChannelMapAlg::HasTPCset() +} // icarus::ICARUSWireReadoutGeom::HasTPCset() //------------------------------------------------------------------------------ -readout::TPCsetID icarus::ICARUSChannelMapAlg::TPCtoTPCset +readout::TPCsetID icarus::ICARUSWireReadoutGeom::TPCtoTPCset (geo::TPCID const& tpcid) const { return tpcid? TPCtoTPCset()[tpcid]: readout::TPCsetID{}; -} // icarus::ICARUSChannelMapAlg::TPCtoTPCset() +} // icarus::ICARUSWireReadoutGeom::TPCtoTPCset() //------------------------------------------------------------------------------ -std::vector icarus::ICARUSChannelMapAlg::TPCsetToTPCs +std::vector icarus::ICARUSWireReadoutGeom::TPCsetToTPCs (readout::TPCsetID const& tpcsetid) const { std::vector TPCs; @@ -295,11 +275,11 @@ std::vector icarus::ICARUSChannelMapAlg::TPCsetToTPCs std::mem_fn(&geo::TPCGeo::ID) ); return TPCs; -} // icarus::ICARUSChannelMapAlg::TPCsetToTPCs() +} // icarus::ICARUSWireReadoutGeom::TPCsetToTPCs() //------------------------------------------------------------------------------ -geo::TPCID icarus::ICARUSChannelMapAlg::FirstTPCinTPCset +geo::TPCID icarus::ICARUSWireReadoutGeom::FirstTPCinTPCset (readout::TPCsetID const& tpcsetid) const { if (!tpcsetid) return {}; @@ -307,27 +287,27 @@ geo::TPCID icarus::ICARUSChannelMapAlg::FirstTPCinTPCset auto const& TPClist = TPCsetTPCs(tpcsetid); return TPClist.empty()? geo::TPCID{}: TPClist.front()->ID(); -} // icarus::ICARUSChannelMapAlg::FirstTPCinTPCset() +} // icarus::ICARUSWireReadoutGeom::FirstTPCinTPCset() //------------------------------------------------------------------------------ -unsigned int icarus::ICARUSChannelMapAlg::NROPs +unsigned int icarus::ICARUSWireReadoutGeom::NROPs (readout::TPCsetID const& tpcsetid) const { return HasTPCset(tpcsetid)? ROPcount(tpcsetid): 0U; -} // icarus::ICARUSChannelMapAlg::NROPs() +} // icarus::ICARUSWireReadoutGeom::NROPs() //------------------------------------------------------------------------------ -unsigned int icarus::ICARUSChannelMapAlg::MaxROPs() const { +unsigned int icarus::ICARUSWireReadoutGeom::MaxROPs() const { assert(fReadoutMapInfo); return fReadoutMapInfo.MaxROPs(); -} // icarus::ICARUSChannelMapAlg::MaxROPs() +} // icarus::ICARUSWireReadoutGeom::MaxROPs() //------------------------------------------------------------------------------ -bool icarus::ICARUSChannelMapAlg::HasROP(readout::ROPID const& ropid) const { +bool icarus::ICARUSWireReadoutGeom::HasROP(readout::ROPID const& ropid) const { return HasTPCset(ropid)? (ropid.ROP < ROPcount(ropid)): false; -} // icarus::ICARUSChannelMapAlg::HasROP() +} // icarus::ICARUSWireReadoutGeom::HasROP() //------------------------------------------------------------------------------ @@ -343,15 +323,15 @@ bool icarus::ICARUSChannelMapAlg::HasROP(readout::ROPID const& ropid) const { * does not necessarily imply that the plane specified by the ID actually * exists. */ -readout::ROPID icarus::ICARUSChannelMapAlg::WirePlaneToROP +readout::ROPID icarus::ICARUSWireReadoutGeom::WirePlaneToROP (geo::PlaneID const& planeid) const { return planeid? PlaneToROP(planeid): readout::ROPID{}; -} // icarus::ICARUSChannelMapAlg::WirePlaneToROP() +} // icarus::ICARUSWireReadoutGeom::WirePlaneToROP() //------------------------------------------------------------------------------ -std::vector icarus::ICARUSChannelMapAlg::ROPtoWirePlanes +std::vector icarus::ICARUSWireReadoutGeom::ROPtoWirePlanes (readout::ROPID const& ropid) const { std::vector Planes; @@ -363,11 +343,11 @@ std::vector icarus::ICARUSChannelMapAlg::ROPtoWirePlanes std::mem_fn(&geo::PlaneGeo::ID) ); return Planes; -} // icarus::ICARUSChannelMapAlg::ROPtoWirePlanes() +} // icarus::ICARUSWireReadoutGeom::ROPtoWirePlanes() //------------------------------------------------------------------------------ -std::vector icarus::ICARUSChannelMapAlg::ROPtoTPCs +std::vector icarus::ICARUSWireReadoutGeom::ROPtoTPCs (readout::ROPID const& ropid) const { std::vector TPCs; @@ -390,53 +370,53 @@ std::vector icarus::ICARUSChannelMapAlg::ROPtoTPCs std::mem_fn(&geo::PlaneGeo::ID) ); return TPCs; -} // icarus::ICARUSChannelMapAlg::ROPtoTPCs() +} // icarus::ICARUSWireReadoutGeom::ROPtoTPCs() //------------------------------------------------------------------------------ -readout::ROPID icarus::ICARUSChannelMapAlg::ChannelToROP +readout::ROPID icarus::ICARUSWireReadoutGeom::ChannelToROP (raw::ChannelID_t channel) const { if (!raw::isValidChannelID(channel)) return {}; icarus::details::ChannelToWireMap::ChannelsInROPStruct const* info = fChannelToWireMap.find(channel); return info? info->ropid: readout::ROPID{}; -} // icarus::ICARUSChannelMapAlg::ChannelToROP() +} // icarus::ICARUSWireReadoutGeom::ChannelToROP() //------------------------------------------------------------------------------ -raw::ChannelID_t icarus::ICARUSChannelMapAlg::FirstChannelInROP +raw::ChannelID_t icarus::ICARUSWireReadoutGeom::FirstChannelInROP (readout::ROPID const& ropid) const { if (!ropid) return raw::InvalidChannelID; icarus::details::ChannelToWireMap::ChannelsInROPStruct const* info = fChannelToWireMap.find(ropid); return info? info->firstChannel: raw::InvalidChannelID; -} // icarus::ICARUSChannelMapAlg::FirstChannelInROP() +} // icarus::ICARUSWireReadoutGeom::FirstChannelInROP() //------------------------------------------------------------------------------ -geo::PlaneID icarus::ICARUSChannelMapAlg::FirstWirePlaneInROP +geo::PlaneID icarus::ICARUSWireReadoutGeom::FirstWirePlaneInROP (readout::ROPID const& ropid) const { if (!ropid) return {}; PlaneColl_t const& planes = ROPplanes(ropid); return planes.empty()? geo::PlaneID{}: planes.front()->ID(); -} // icarus::ICARUSChannelMapAlg::FirstWirePlaneInROP() +} // icarus::ICARUSWireReadoutGeom::FirstWirePlaneInROP() //------------------------------------------------------------------------------ -bool icarus::ICARUSChannelMapAlg::HasCryostat +bool icarus::ICARUSWireReadoutGeom::HasCryostat (readout::CryostatID const& cryoid) const { assert(fReadoutMapInfo); return cryoid.Cryostat < fReadoutMapInfo.NCryostats(); -} // icarus::ICARUSChannelMapAlg::HasCryostat() +} // icarus::ICARUSWireReadoutGeom::HasCryostat() //------------------------------------------------------------------------------ -void icarus::ICARUSChannelMapAlg::fillChannelToWireMap - (geo::GeometryData_t::CryostatList_t const& Cryostats) +void icarus::ICARUSWireReadoutGeom::fillChannelToWireMap + (std::vector const& Cryostats) { // @@ -450,7 +430,7 @@ void icarus::ICARUSChannelMapAlg::fillChannelToWireMap // assert(fPlaneInfo.empty()); std::array maxSizes - = geo::details::extractMaxGeometryElements<3U>(Cryostats); + = geo::details::extractMaxGeometryElements<3U>(Cryostats, *this); fPlaneInfo.resize(maxSizes[0U], maxSizes[1U], maxSizes[2U]); @@ -480,7 +460,7 @@ void icarus::ICARUSChannelMapAlg::fillChannelToWireMap for (readout::ROPID::ROPID_t r: util::counter(nROPs)) { - mf::LogTrace log("ICARUSChannelMapAlg"); + mf::LogTrace log("ICARUSWireReadoutGeom"); readout::ROPID const rid { sid, r }; auto const planeType = findPlaneType(rid); @@ -523,7 +503,7 @@ void icarus::ICARUSChannelMapAlg::fillChannelToWireMap = plane.NearestWireID(lastWirePos); /* - mf::LogTrace("ICARUSChannelMapAlg") + mf::LogTrace("ICARUSWireReadoutGeom") << (*std::prev(iPlane))->ID() << " W:" << ((*std::prev(iPlane))->Nwires() - 1) << " ending at " << (*std::prev(iPlane))->LastWire().GetEnd() << " matched " << lastMatchedWireID @@ -566,20 +546,20 @@ void icarus::ICARUSChannelMapAlg::fillChannelToWireMap } // for cryostat fChannelToWireMap.setEndChannel(nextChannel); - mf::LogTrace("ICARUSChannelMapAlg") + mf::LogTrace("ICARUSWireReadoutGeom") << "Counted " << fChannelToWireMap.nChannels() << " channels."; -} // icarus::ICARUSChannelMapAlg::fillChannelToWireMap() +} // icarus::ICARUSWireReadoutGeom::fillChannelToWireMap() // ----------------------------------------------------------------------------- -void icarus::ICARUSChannelMapAlg::buildReadoutPlanes - (geo::GeometryData_t::CryostatList_t const& Cryostats) +void icarus::ICARUSWireReadoutGeom::buildReadoutPlanes + (std::vector const& Cryostats) { // the algorithm is delegated: - icarus::details::ROPandTPCsetBuildingAlg builder("ICARUSChannelMapAlg"); + icarus::details::ROPandTPCsetBuildingAlg builder("ICARUSWireReadoutGeom"); - auto results = builder.run(Cryostats); + auto results = builder.run(*this, Cryostats); fReadoutMapInfo.set( std::move(results).TPCsetCount(), std::move(results).TPCsetTPCs(), @@ -587,11 +567,11 @@ void icarus::ICARUSChannelMapAlg::buildReadoutPlanes std::move(results).TPCtoTPCset(), std::move(results).PlaneToROP() ); -} // icarus::ICARUSChannelMapAlg::buildReadoutPlanes() +} // icarus::ICARUSWireReadoutGeom::buildReadoutPlanes() // ----------------------------------------------------------------------------- -auto icarus::ICARUSChannelMapAlg::findPlaneType(readout::ROPID const& rid) const +auto icarus::ICARUSWireReadoutGeom::findPlaneType(readout::ROPID const& rid) const -> PlaneType_t { /* @@ -613,11 +593,11 @@ auto icarus::ICARUSChannelMapAlg::findPlaneType(readout::ROPID const& rid) const return PlaneTypes[planeNo]; else return kUnknownType; -} // icarus::ICARUSChannelMapAlg::findPlaneType() +} // icarus::ICARUSWireReadoutGeom::findPlaneType() // ---------------------------------------------------------------------------- -geo::SigType_t icarus::ICARUSChannelMapAlg::SignalTypeForChannelImpl +geo::SigType_t icarus::ICARUSWireReadoutGeom::SignalTypeForChannelImpl (raw::ChannelID_t const channel) const { /* @@ -639,11 +619,11 @@ geo::SigType_t icarus::ICARUSChannelMapAlg::SignalTypeForChannelImpl return geo::kMysteryType; } // switch -} // icarus::ICARUSChannelMapAlg::SignalTypeForChannelImpl() +} // icarus::ICARUSWireReadoutGeom::SignalTypeForChannelImpl() // ----------------------------------------------------------------------------- -auto icarus::ICARUSChannelMapAlg::extractWirelessChannelParams +auto icarus::ICARUSWireReadoutGeom::extractWirelessChannelParams (Config::WirelessChannelStruct const& params) -> WirelessChannelCounts_t { return { @@ -679,11 +659,11 @@ auto icarus::ICARUSChannelMapAlg::extractWirelessChannelParams } }; -} // icarus::ICARUSChannelMapAlg::extractWirelessChannelParams() +} // icarus::ICARUSWireReadoutGeom::extractWirelessChannelParams() // ---------------------------------------------------------------------------- -std::string icarus::ICARUSChannelMapAlg::PlaneTypeName(PlaneType_t planeType) { +std::string icarus::ICARUSWireReadoutGeom::PlaneTypeName(PlaneType_t planeType) { using namespace std::string_literals; switch (planeType) { @@ -695,7 +675,7 @@ std::string icarus::ICARUSChannelMapAlg::PlaneTypeName(PlaneType_t planeType) { return "unsupported ("s + std::to_string(planeType) + ")"s; } // switch -} // icarus::ICARUSChannelMapAlg::PlaneTypeName() +} // icarus::ICARUSWireReadoutGeom::PlaneTypeName() // ---------------------------------------------------------------------------- diff --git a/icarusalg/Geometry/ICARUSChannelMapAlg.h b/icarusalg/Geometry/ICARUSWireReadoutGeom.h similarity index 94% rename from icarusalg/Geometry/ICARUSChannelMapAlg.h rename to icarusalg/Geometry/ICARUSWireReadoutGeom.h index 747c4be..297d8a2 100644 --- a/icarusalg/Geometry/ICARUSChannelMapAlg.h +++ b/icarusalg/Geometry/ICARUSWireReadoutGeom.h @@ -1,24 +1,21 @@ /** - * @file icarusalg/Geometry/ICARUSChannelMapAlg.h + * @file icarusalg/Geometry/ICARUSWireReadoutGeom.h * @brief Channel mapping algorithms for ICARUS detector. * @date October 19, 2019 * @author Gianluca Petrillo (petrillo@slac.stanford.edu) - * @see `icarusalg/Geometry/ICARUSChannelMapAlg.cxx` + * @see `icarusalg/Geometry/ICARUSWireReadoutGeom.cxx` */ -#ifndef ICARUSCODE_GEOMETRY_ICARUSCHANNELMAPALG_H -#define ICARUSCODE_GEOMETRY_ICARUSCHANNELMAPALG_H +#ifndef ICARUSCODE_GEOMETRY_ICARUSWIREREADOUTGEOM_H +#define ICARUSCODE_GEOMETRY_ICARUSWIREREADOUTGEOM_H // ICARUS libraries -#include "icarusalg/Geometry/GeoObjectSorterPMTasTPC.h" #include "icarusalg/Geometry/details/ChannelToWireMap.h" #include "icarusalg/Geometry/details/GeometryObjectCollections.h" // LArSoft libraries -#include "larcorealg/Geometry/ChannelMapAlg.h" -// #include "larcorealg/Geometry/GeoObjectSorterStandard.h" -#include "larcorealg/Geometry/GeometryData.h" -#include "larcorealg/Geometry/GeometryDataContainers.h" +#include "larcorealg/Geometry/WireReadoutGeom.h" +#include "larcorealg/Geometry/WireReadoutGeomBuilderStandard.h" #include "larcorealg/Geometry/ReadoutDataContainers.h" #include "larcoreobj/SimpleTypesAndConstants/readout_types.h" #include "larcoreobj/SimpleTypesAndConstants/geo_types.h" @@ -26,19 +23,21 @@ // framework libraries #include "fhiclcpp/types/OptionalDelegatedParameter.h" #include "fhiclcpp/types/Atom.h" +#include "fhiclcpp/types/OptionalTable.h" #include "fhiclcpp/types/Table.h" #include "fhiclcpp/ParameterSet.h" // C/C++ standard libraries #include #include +#include // ----------------------------------------------------------------------------- // forward declarations namespace icarus { - class ICARUSChannelMapAlg; + class ICARUSWireReadoutGeom; } // namespace icarus @@ -163,7 +162,7 @@ namespace icarus { * * */ -class icarus::ICARUSChannelMapAlg: public geo::ChannelMapAlg { +class icarus::ICARUSWireReadoutGeom: public geo::WireReadoutGeom { // import definitions using TPCColl_t = icarus::details::TPCColl_t; @@ -251,35 +250,30 @@ class icarus::ICARUSChannelMapAlg: public geo::ChannelMapAlg { }; // WirelessChannelStruct - fhicl::OptionalDelegatedParameter Sorter { - Name("Sorter"), - Comment("configuration of the geometry object sorter") - }; - fhicl::Table WirelessChannels { Name("WirelessChannels"), Comment("configuration of channels with no connected wire") }; + fhicl::Table builder { + Name("Builder") + }; + }; // struct Config /// Type of FHiCL configuration table for this object. using Parameters = fhicl::Table; /// Constructor: taked a configuration object. - ICARUSChannelMapAlg(Config const& config); + ICARUSWireReadoutGeom(Config const& config, + geo::GeometryCore const* geom, + std::unique_ptr sorter); /// Constructor: takes a FHiCL table object. - ICARUSChannelMapAlg(Parameters const& config) - : ICARUSChannelMapAlg(config()) {} - - - /// Prepares the algorithm extracting information from the geometry. - virtual void Initialize(geo::GeometryData_t const& geodata) override; - - - /// Frees the resources of this algorithm. - virtual void Uninitialize() override; + ICARUSWireReadoutGeom(Parameters const& config, + geo::GeometryCore const* geom, + std::unique_ptr sorter) + : ICARUSWireReadoutGeom(config(), geom, std::move(sorter)) {} // --- BEGIN -- Channel mapping ---------------------------------------------- @@ -486,10 +480,6 @@ class icarus::ICARUSChannelMapAlg: public geo::ChannelMapAlg { // --- END -- Readout plane interface ---------------------------------------- - /// Return the sorter. - virtual geo::GeoObjectSorter const& Sorter() const override - { return fSorter; } - private: /// Type for counts of wireless channels: per TPC set (even/odd), then per @@ -632,14 +622,6 @@ class icarus::ICARUSChannelMapAlg: public geo::ChannelMapAlg { // --- END -- Configuration parameters --------------------------------------- - // --- BEGIN -- Sorting ------------------------------------------------------ - /// Algorithms to sort geometry elements. -// geo::GeoObjectSorterStandard fSorter; - icarus::GeoObjectSorterPMTasTPC fSorter; - - // --- END -- Sorting -------------------------------------------------------- - - using PlaneType_t = std::size_t; ///< Type for plane type identifier. /// Identifier for first induction plane type. @@ -726,7 +708,7 @@ class icarus::ICARUSChannelMapAlg: public geo::ChannelMapAlg { * */ void fillChannelToWireMap - (geo::GeometryData_t::CryostatList_t const& Cryostats); + (std::vector const& Cryostats); /** @@ -745,7 +727,7 @@ class icarus::ICARUSChannelMapAlg: public geo::ChannelMapAlg { * and with all their ID's set. * */ - void buildReadoutPlanes(geo::GeometryData_t::CryostatList_t const& Cryostats); + void buildReadoutPlanes(std::vector const& Cryostats); /** @@ -777,7 +759,7 @@ class icarus::ICARUSChannelMapAlg: public geo::ChannelMapAlg { -}; // class icarus::ICARUSChannelMapAlg +}; // class icarus::ICARUSWireReadoutGeom -#endif // ICARUSCODE_GEOMETRY_ICARUSCHANNELMAPALG_H +#endif // ICARUSCODE_GEOMETRY_ICARUSWIREREADOUTGEOM_H diff --git a/icarusalg/Geometry/ICARUSstandaloneGeometrySetup.h b/icarusalg/Geometry/ICARUSstandaloneGeometrySetup.h index 29e9d9f..4553e20 100644 --- a/icarusalg/Geometry/ICARUSstandaloneGeometrySetup.h +++ b/icarusalg/Geometry/ICARUSstandaloneGeometrySetup.h @@ -18,7 +18,7 @@ // ICARUS libraries -#include "icarusalg/Geometry/ICARUSChannelMapAlg.h" +#include "icarusalg/Geometry/ICARUSWireReadoutGeom.h" // LArSoft libraries #include "larcorealg/Geometry/StandaloneGeometrySetup.h" @@ -71,11 +71,11 @@ namespace icarus::geo { auto const& config = details::ConfigObjectMaker::make (pset.get("ChannelMapping")); - auto channelMap = std::make_unique + auto wireReadout = std::make_unique (config, std::forward(args)...); return lar::standalone::SetupGeometryWithChannelMapping - (pset, move(channelMap)); + (pset, move(wireReadout)); } // SetupICARUSGeometry() @@ -114,11 +114,11 @@ namespace lar::standalone { // --------------------------------------------------------------------------- /// Specialization of `lar::standalone::SetupGeometry()` - /// for ICARUS channel mapping `icarus::ICARUSChannelMapAlg`. + /// for ICARUS channel mapping `icarus::ICARUSWireReadoutGeom`. template <> inline std::unique_ptr - SetupGeometry(fhicl::ParameterSet const& pset) - { return icarus::geo::SetupICARUSGeometry(pset); } + SetupGeometry(fhicl::ParameterSet const& pset) + { return icarus::geo::SetupICARUSGeometry(pset); } // --------------------------------------------------------------------------- diff --git a/icarusalg/Geometry/LoadStandardICARUSgeometry.h b/icarusalg/Geometry/LoadStandardICARUSgeometry.h index 6f14e73..32e26bd 100644 --- a/icarusalg/Geometry/LoadStandardICARUSgeometry.h +++ b/icarusalg/Geometry/LoadStandardICARUSgeometry.h @@ -22,7 +22,7 @@ // ICARUS libraries #include "icarusalg/Geometry/ICARUSstandaloneGeometrySetup.h" -#include "icarusalg/Geometry/ICARUSChannelMapAlg.h" +#include "icarusalg/Geometry/ICARUSWireReadoutGeom.h" // LArSoft and framework libraries #include "larcorealg/Geometry/GeometryCore.h" @@ -60,7 +60,7 @@ namespace icarus::geo { * * ICARUS geometry configuration has special conventions, which include: * * a full `ChannelMapping` configuration in the `Geometry` configuration - * block, equivalent to the one passed to `ExptGeoHelperInterface` service; + * block, equivalent to the one passed to `WireReadout` service; * * within it, a `tool_type` name. * * The `ChannelMapping` table *must* be present in the configuration, and the @@ -142,11 +142,11 @@ icarus::geo::LoadStandardICARUSgeometry [[nodiscard]] ); } - std::string const channelMappingToolType + std::string const wireReadoutpingToolType = geomConfig.get("ChannelMapping.tool_type", ""s); - if (channelMappingToolType != MagicToolName) { + if (wireReadoutpingToolType != MagicToolName) { throw std::runtime_error("icarus::geo::LoadStandardICARUSgeometry() " - ": unexpected value '" + channelMappingToolType + ": unexpected value '" + wireReadoutpingToolType + "' for `ChannelMapping.tool_type` configuration parameter (expected: '" + MagicToolName + "').\nConfiguration:\n" + std::string(80, '-') + '\n' @@ -165,7 +165,7 @@ icarus::geo::LoadStandardICARUSgeometry [[nodiscard]] // 4. return the geometry object - return SetupICARUSGeometry(geomConfig); + return SetupICARUSGeometry(geomConfig); } // icarus::geo::LoadStandardICARUSgeometry() diff --git a/icarusalg/Geometry/WireReadoutSorterICARUS.cxx b/icarusalg/Geometry/WireReadoutSorterICARUS.cxx new file mode 100644 index 0000000..91ac139 --- /dev/null +++ b/icarusalg/Geometry/WireReadoutSorterICARUS.cxx @@ -0,0 +1,32 @@ +/** + * @file icarusalg/Geometry/WireReadoutSorterICARUS.cxx + * @brief Interface to algorithm class for sorting standard geo::XXXGeo objects + */ + +#include "icarusalg/Geometry/WireReadoutSorterICARUS.h" + +#include "larcorealg/Geometry/WireGeo.h" + +namespace { + constexpr double EPSILON = 0.000001; +} + +namespace geo { + + WireReadoutSorterICARUS::WireReadoutSorterICARUS() = default; + WireReadoutSorterICARUS::WireReadoutSorterICARUS(fhicl::ParameterSet const&) {} + + //---------------------------------------------------------------------------- + bool WireReadoutSorterICARUS::compareWires(WireGeo const& w1, WireGeo const& w2) const { + auto const& xyz1 = w1.GetCenter(); + auto const& xyz2 = 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(); + } + +} diff --git a/icarusalg/Geometry/WireReadoutSorterICARUS.h b/icarusalg/Geometry/WireReadoutSorterICARUS.h new file mode 100644 index 0000000..17df539 --- /dev/null +++ b/icarusalg/Geometry/WireReadoutSorterICARUS.h @@ -0,0 +1,25 @@ +/** + * @file icarusalg/Geometry/WireReadoutSorterICARUS.h + * @brief Interface to algorithm class for standard sorting of geo::XXXGeo objects + */ +#ifndef ICARUSALG_GEOMETRY_WIREREADOUTSORTERICARUS_H +#define ICARUSALG_GEOMETRY_WIREREADOUTSORTERICARUS_H + +#include "fhiclcpp/fwd.h" + +#include "larcorealg/Geometry/WireReadoutSorter.h" + +namespace geo { + + class WireReadoutSorterICARUS : public WireReadoutSorter { + public: + WireReadoutSorterICARUS(); + explicit WireReadoutSorterICARUS(fhicl::ParameterSet const&); + + private: + bool compareWires(WireGeo const& a, WireGeo const& b) const override; + }; + +} + +#endif // ICARUSALG_GEOMETRY_WIREREADOUTSORTERICARUS_H diff --git a/icarusalg/Geometry/details/AuxDetSorting.h b/icarusalg/Geometry/details/AuxDetSorting.h deleted file mode 100644 index a34d069..0000000 --- a/icarusalg/Geometry/details/AuxDetSorting.h +++ /dev/null @@ -1,39 +0,0 @@ -/** - * @file icarusalg/Geometry/details/AuxDetSorting.h - * @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.cxx - */ - -#ifndef ICARUSALG_GEOMETRY_DETAILS_AUXDETSORTING_H -#define ICARUSALG_GEOMETRY_DETAILS_AUXDETSORTING_H - - -// LArSoft libraries -#include "larcorealg/Geometry/AuxDetGeo.h" -#include "larcorealg/Geometry/AuxDetSensitiveGeo.h" - -// C/C++ standard libraries -#include - - -namespace icarus { - - //---------------------------------------------------------------------------- - /// Sorts ICARUS CRT modules in standard configuration. - void SortAuxDetsStandard(std::vector& adgeo); - - - //---------------------------------------------------------------------------- - /// Sorts ICARUS CRT submodules in standard configuration. - void SortAuxDetSensitiveStandard - (std::vector& adsgeo); - - - //---------------------------------------------------------------------------- - -} // namespace icarus - - -#endif // ICARUSALG_GEOMETRY_DETAILS_AUXDETSORTING_H diff --git a/icarusalg/Geometry/details/PMTsorting.cxx b/icarusalg/Geometry/details/PMTsorting.cxx deleted file mode 100644 index ba570d3..0000000 --- a/icarusalg/Geometry/details/PMTsorting.cxx +++ /dev/null @@ -1,80 +0,0 @@ -/** - * @file icarusalg/Geometry/details/PMTsorting.cxx - * @brief PMT sorting functions for ICARUS. - * @date April 26, 2020 - * @author Gianluca Petrillo (petrillo@slac.stanford.edu) - * @see icarusalg/Geometry/details/PMTsorting.h - */ - - -// library header -#include "icarusalg/Geometry/details/PMTsorting.h" - -// LArSoft libraries -// #include "larcorealg/CoreUtils/span.h" - -// C/C++ standard libraries -#include -#include // std::next(), std::prev() -#include // std::sort(), std::stable_sort() -#include - - -// ----------------------------------------------------------------------------- -void icarus::PMTsorterStandard::sort(std::vector& opDets) const { - assert(opDets.size() % 2 == 0); // must be even! - - /* - * 1. sort all optical detectors by _x_ - * 2. split them by plane - * 3. sort the detectors within each plane. - */ - - // - // 1. sort all optical detectors by _x_ - // - std::sort(begin(opDets), end(opDets), fSmallerCenterX); - - // - // 2. split them by plane: we take a horrible shortcut here... - // - - std::vector OpDetsPerPlane; - - // just split the list in two - auto const middle = std::next(opDets.begin(), opDets.size() / 2U); - assert(fSmallerCenterX(*std::prev(middle), *middle)); - - OpDetsPerPlane.emplace_back(opDets.begin(), middle); - OpDetsPerPlane.emplace_back(middle, opDets.end()); - assert(OpDetsPerPlane[0].size() == OpDetsPerPlane[1].size()); - - // - // 3. sort the detectors within each plane. - // - for (auto const& planeOpDets: OpDetsPerPlane) - sortInPlane(util::make_span(planeOpDets)); - - // all done in place, no return - -} // icarus::PMTsorterStandard::sort() - - -// ----------------------------------------------------------------------------- -void icarus::PMTsorterStandard::sortInPlane(OpDetSpan_t const& opDets) const { - /* - * 0. assume it's already sorted by _x_ - * 1. sort by vertical coordinate (_y_) - * 2. stable sort by beam coordinate (_z_) - */ - - // 1. sort by vertical coordinate (_y_) - std::stable_sort(begin(opDets), end(opDets), fSmallerCenterY); - - // 2. stable sort by beam coordinate (_z_) - std::stable_sort(begin(opDets), end(opDets), fSmallerCenterZ); - -} // icarus::PMTsorterStandard::sortInPlane() - - -// ----------------------------------------------------------------------------- diff --git a/icarusalg/Geometry/details/PMTsorting.h b/icarusalg/Geometry/details/PMTsorting.h deleted file mode 100644 index bf4c5f6..0000000 --- a/icarusalg/Geometry/details/PMTsorting.h +++ /dev/null @@ -1,170 +0,0 @@ -/** - * @file icarusalg/Geometry/details/PMTsorting.h - * @brief Geometry obect sorter with PMT following TPC wire order. - * @date April 26, 2020 - * @author Gianluca Petrillo (petrillo@slac.stanford.edu) - * @see icarusalg/Geometry/details/PMTsorting.cxx - */ - -#ifndef ICARUSALG_GEOMETRY_DETAILS_PMTSORTING_H -#define ICARUSALG_GEOMETRY_DETAILS_PMTSORTING_H - - -// LArSoft libraries -#include "larcorealg/Geometry/OpDetGeo.h" -#include "larcorealg/CoreUtils/RealComparisons.h" -#include "larcorealg/CoreUtils/span.h" // util::span -#include "larcoreobj/SimpleTypesAndConstants/geo_vectors.h" // geo::Point_t - -// framework libraries -#include "fhiclcpp/types/Atom.h" - -// C/C++ standard libraries -#include - - -// ----------------------------------------------------------------------------- -namespace icarus { class PMTsorterStandard; } - -/** - * @brief Sorter sorting PMT to follow the same order as TPC (standard). - * - * This class sorts the elements of the LArSoft detector description. - * The "standard" algorithm (`geo::GeoObjectSorterStandard`) arranges TPC - * elements with x, then z, then y. The PMT are arranged so that their channels - * mimic the order of the TPC channels. - * - * The algorithm for assigning channels to the PMT follows the criteria: - * - * * PMT are ordered by increasing _x_ (related to drift direction); - * * channels are assigned value ranges increasing with _x_ coordinate; - * * within a wire plane, PMT number increases with its _z_ (beam direction) - * coordinate; - * * in case of same _z_ (in ICARUS all PMT are in 2- or 3-PMT "towers"), an - * increasing _y_ order (geographical vertical, toward the sky) is chosen. - * - * PMT channels are assigned by a fixed LArSoft algorithm, cryostat by cryostat - * with increasing cryostat number (first `C:0`, then `C:1`, ...). - * - * - * Configuration parameters - * ------------------------- - * - * This sorter supports the following parameters: - * - * * `ToleranceX`, `ToleranceY`, `ToleranceZ` (double, default: `1.0`): - * rounding used for sorting optical detector position, in centimeters; - * if the coordinate of two optical detectors are closer than the tolerance - * for that coordinate (absolute), they two detectors are considered to be at - * the same position in that coordinate - * (note that the default value is very generous). - * - */ -class icarus::PMTsorterStandard { - - /// List of optical detector pointers for sorting. - using OpDetList_t = std::vector; - - /// Part of list of optical detector pointers for sorting. - using OpDetSpan_t = util::span; - - public: - - struct Config { - - using Name = fhicl::Name; - using Comment = fhicl::Comment; - - fhicl::Atom ToleranceX { - Name("ToleranceX"), - Comment("tolerance when sorting optical detectors on x coordinate [cm]"), - 1.0 // default - }; - - fhicl::Atom ToleranceY { - Name("ToleranceY"), - Comment("tolerance when sorting optical detectors on x coordinate [cm]"), - 1.0 // default - }; - - fhicl::Atom ToleranceZ { - Name("ToleranceZ"), - Comment("tolerance when sorting optical detectors on x coordinate [cm]"), - 1.0 // default - }; - - }; // Config - - - /// Constructor: passes the configuration to the base class. - PMTsorterStandard(Config const& config) - : fSmallerCenterX{ config.ToleranceX() } - , fSmallerCenterY{ config.ToleranceY() } - , fSmallerCenterZ{ config.ToleranceZ() } - {} - - - // @{ - /** - * @brief Sorts the specified optical detectors. - * @param opDets collection of pointers to all optical detectors in a cryostat - * - * The collection `opDets` of optical detectors is sorted in place. - * Sorting criteria are documented in `icarus::GeoObjectSorterPMTasTPC` class - * documentation. - * - * This algorithm requires all optical detectors to have their center defined - * (`geo::OpDetGeo::GetCenter()`). No other information is used. - * - * @note The current implementation is very sensitive to rounding errors! - * - */ - void sort(std::vector& opDets) const; - - void operator() (std::vector& opDets) const { sort(opDets); } - // @} - - - private: - - /// `geo::OpDetGeo` comparer according to one coordinate of their center. - /// Accomodates for some tolerance. - template - struct OpDetGeoCenterCoordComparer { - - /// Object used for comparison; includes a tolerance. - lar::util::RealComparisons const fCmp; - - /// Constructor: fixes the tolerance for the comparison. - OpDetGeoCenterCoordComparer(double tol = 0.0): fCmp(tol) {} - - /// Returns whether `A` has a center coordinate `Coord` smaller than `B`. - bool operator() (geo::OpDetGeo const& A, geo::OpDetGeo const& B) const - { - return fCmp.strictlySmaller - ((A.GetCenter().*Coord)(), (B.GetCenter().*Coord)()); - } - - }; // OpDetGeoCenterCoordComparer - - - /// Sorting criterium according to _x_ coordinate of `geo::OpDetGeo` center. - OpDetGeoCenterCoordComparer<&geo::Point_t::X> const fSmallerCenterX; - - /// Sorting criterium according to _y_ coordinate of `geo::OpDetGeo` center. - OpDetGeoCenterCoordComparer<&geo::Point_t::Y> const fSmallerCenterY; - - /// Sorting criterium according to _z_ coordinate of `geo::OpDetGeo` center. - OpDetGeoCenterCoordComparer<&geo::Point_t::Z> const fSmallerCenterZ; - - - /// Sorts the `geo::OpDetGeo` assuming they belong to the same plane. - void sortInPlane(OpDetSpan_t const& opDets) const; - -}; // icarus::PMTsorterStandard - - -// ----------------------------------------------------------------------------- - - -#endif // ICARUSALG_GEOMETRY_DETAILS_PMTSORTING_H diff --git a/icarusalg/Geometry/details/ROPandTPCsetBuildingAlg.cxx b/icarusalg/Geometry/details/ROPandTPCsetBuildingAlg.cxx index 5c6d316..0c09519 100644 --- a/icarusalg/Geometry/details/ROPandTPCsetBuildingAlg.cxx +++ b/icarusalg/Geometry/details/ROPandTPCsetBuildingAlg.cxx @@ -350,7 +350,8 @@ geo::View_t icarus::details::ROPnumberDispatcher::ROPview // --- icarus::details::ROPandTPCsetBuildingAlg // ----------------------------------------------------------------------------- auto icarus::details::ROPandTPCsetBuildingAlg::run - (geo::GeometryData_t::CryostatList_t const& Cryostats) -> Results_t + (geo::WireReadoutGeom const& wireReadout, + std::vector const& Cryostats) -> Results_t { /* * The goals: @@ -391,7 +392,7 @@ auto icarus::details::ROPandTPCsetBuildingAlg::run { return std::abs(plane.ThetaZ()) < 1e-3; }; std::vector> AllPlanesInROPs - = groupPlanesAndTPCs(standaloneHorizontalWires); + = groupPlanesAndTPCs(wireReadout, standaloneHorizontalWires); std::vector>> const AllTPCsInTPCsets = extractTPCsetsFromROPs(AllPlanesInROPs); @@ -416,8 +417,8 @@ auto icarus::details::ROPandTPCsetBuildingAlg::run // // 5. invert the maps // - fillTPCtoTPCsetMap(); - fillPlaneToROPmap(); + fillTPCtoTPCsetMap(wireReadout); + fillPlaneToROPmap(wireReadout); // // output @@ -454,7 +455,7 @@ void icarus::details::ROPandTPCsetBuildingAlg::clear() { // ----------------------------------------------------------------------------- template auto icarus::details::ROPandTPCsetBuildingAlg::groupPlanesAndTPCs - (Pred standalonePlane) + (geo::WireReadoutGeom const& wireReadout, Pred standalonePlane) -> std::vector> { /* @@ -466,7 +467,7 @@ auto icarus::details::ROPandTPCsetBuildingAlg::groupPlanesAndTPCs // input check // assert(fCryostats); - geo::GeometryData_t::CryostatList_t const& Cryostats = *fCryostats; + std::vector const& Cryostats = *fCryostats; // // output @@ -498,11 +499,9 @@ auto icarus::details::ROPandTPCsetBuildingAlg::groupPlanesAndTPCs // readout plane sets // std::vector planes; - for (geo::TPCGeo const& tpc: cryo.IterateTPCs()) { - for (geo::PlaneGeo const& plane: tpc.IteratePlanes()) { + for (geo::PlaneGeo const& plane : wireReadout.Iterate(cryo.ID())) { planes.push_back(&plane); - } // for planes - } // for TPCs + } std::vector protoGroups = groupPlanesByDriftCoord(planes); @@ -542,9 +541,9 @@ auto icarus::details::ROPandTPCsetBuildingAlg::groupPlanesAndTPCs // ----------------------------------------------------------------------------- -auto icarus::details::ROPandTPCsetBuildingAlg::groupPlanesAndTPCs() +auto icarus::details::ROPandTPCsetBuildingAlg::groupPlanesAndTPCs(geo::WireReadoutGeom const& wireReadout) -> std::vector> -{ return groupPlanesAndTPCs([](geo::PlaneGeo const&){ return false; }); } +{ return groupPlanesAndTPCs(wireReadout, [](geo::PlaneGeo const&){ return false; }); } // ----------------------------------------------------------------------------- @@ -614,7 +613,7 @@ void icarus::details::ROPandTPCsetBuildingAlg::fillTPCsInSet // input check // assert(fCryostats); - geo::GeometryData_t::CryostatList_t const& Cryostats = *fCryostats; + std::vector const& Cryostats = *fCryostats; unsigned int const MaxTPCsets = fMaxTPCsets; @@ -674,7 +673,7 @@ auto icarus::details::ROPandTPCsetBuildingAlg::groupPlanesIntoROPs( // input check // assert(fCryostats); - geo::GeometryData_t::CryostatList_t const& Cryostats = *fCryostats; + std::vector const& Cryostats = *fCryostats; assert(!fTPCsetTPCs.empty()); readout::TPCsetDataContainer const& TPCsetTPCs = fTPCsetTPCs; @@ -837,7 +836,7 @@ void icarus::details::ROPandTPCsetBuildingAlg::fillPlanesInROP( // ---------------------------------------------------------------------------- -void icarus::details::ROPandTPCsetBuildingAlg::fillTPCtoTPCsetMap() { +void icarus::details::ROPandTPCsetBuildingAlg::fillTPCtoTPCsetMap(geo::WireReadoutGeom const& wireReadout) { // // invert the TPC sets map content @@ -856,7 +855,7 @@ void icarus::details::ROPandTPCsetBuildingAlg::fillTPCtoTPCsetMap() { // output // auto const [ NCryostats, MaxTPCs ] - = geo::details::extractMaxGeometryElements<2U>(Cryostats); + = geo::details::extractMaxGeometryElements<2U>(Cryostats, wireReadout); MF_LOG_TRACE(fLogCategory) << "Detected " << NCryostats << " cryostats." @@ -887,7 +886,7 @@ void icarus::details::ROPandTPCsetBuildingAlg::fillTPCtoTPCsetMap() { // ---------------------------------------------------------------------------- -void icarus::details::ROPandTPCsetBuildingAlg::fillPlaneToROPmap() { +void icarus::details::ROPandTPCsetBuildingAlg::fillPlaneToROPmap(geo::WireReadoutGeom const& wireReadout) { // // invert the TPC sets map content @@ -906,7 +905,7 @@ void icarus::details::ROPandTPCsetBuildingAlg::fillPlaneToROPmap() { // output // auto const [ NCryostats, MaxTPCs, MaxPlanes ] - = geo::details::extractMaxGeometryElements<3U>(Cryostats); + = geo::details::extractMaxGeometryElements<3U>(Cryostats, wireReadout); MF_LOG_TRACE(fLogCategory) << "Detected " << NCryostats << " cryostats." diff --git a/icarusalg/Geometry/details/ROPandTPCsetBuildingAlg.h b/icarusalg/Geometry/details/ROPandTPCsetBuildingAlg.h index 2769801..4de1f06 100644 --- a/icarusalg/Geometry/details/ROPandTPCsetBuildingAlg.h +++ b/icarusalg/Geometry/details/ROPandTPCsetBuildingAlg.h @@ -14,10 +14,10 @@ #include "icarusalg/Geometry/details/GeometryObjectCollections.h" // LArSoft libraries -#include "larcorealg/Geometry/GeometryData.h" #include "larcorealg/Geometry/CryostatGeo.h" #include "larcorealg/Geometry/TPCGeo.h" #include "larcorealg/Geometry/PlaneGeo.h" +#include "larcorealg/Geometry/fwd.h" #include "larcorealg/Geometry/ReadoutDataContainers.h" #include "larcorealg/Geometry/GeometryDataContainers.h" #include "larcoreobj/SimpleTypesAndConstants/readout_types.h" // readout::TPCsetID, ... @@ -176,7 +176,7 @@ class icarus::details::ROPandTPCsetBuildingAlg { * the results one by one (see `Results_t` for the interface). * */ - Results_t run(geo::GeometryData_t::CryostatList_t const& Cryostats); + Results_t run(geo::WireReadoutGeom const& wireReadout, std::vector const& Cryostats); private: @@ -189,7 +189,7 @@ class icarus::details::ROPandTPCsetBuildingAlg { // --- END -- Configuration -------------------------------------------------- - geo::GeometryData_t::CryostatList_t const* fCryostats = nullptr; + std::vector const* fCryostats = nullptr; // --- BEGIN -- Output ------------------------------------------------------- /// @name Output @@ -245,7 +245,7 @@ class icarus::details::ROPandTPCsetBuildingAlg { */ template std::vector> groupPlanesAndTPCs - (Pred standalonePlane); + (geo::WireReadoutGeom const& wireReadout, Pred standalonePlane); /** * @brief Extracts composition of all readout planes. @@ -255,7 +255,7 @@ class icarus::details::ROPandTPCsetBuildingAlg { * a list of TPC sets (second index: TPC set within the cryostat) * each listing its TPC (third index: runs through all TPCs). */ - std::vector> groupPlanesAndTPCs(); + std::vector> groupPlanesAndTPCs(geo::WireReadoutGeom const& wireReadout); /** @@ -332,7 +332,7 @@ class icarus::details::ROPandTPCsetBuildingAlg { * * It requires `fCryostats` and `fTPCsetTPCs` to have been computed already. */ - void fillTPCtoTPCsetMap(); + void fillTPCtoTPCsetMap(geo::WireReadoutGeom const& wireReadout); /** @@ -343,7 +343,7 @@ class icarus::details::ROPandTPCsetBuildingAlg { * It requires `fCryostats` and `fROPplanes` to have been computed * already. */ - void fillPlaneToROPmap(); + void fillPlaneToROPmap(geo::WireReadoutGeom const& wireReadout); /// Returns the `planes` sorted by decreasing normal coordinate. std::vector sortByNormalCoordinate diff --git a/icarusalg/Geometry/geometry_icarus.fcl b/icarusalg/Geometry/geometry_icarus.fcl index 4a3a844..7a22c34 100644 --- a/icarusalg/Geometry/geometry_icarus.fcl +++ b/icarusalg/Geometry/geometry_icarus.fcl @@ -77,6 +77,8 @@ # no configuration for no-overburden detector; # legacy (`icarus_v3`) configurations added; # configurations renamed ("icarus_standard_geometry") +# 20250206 (Kyle Knoepfel, petrillo@slac.stanford.edu, et al) +# updates for LArSoft v10 # @@ -89,8 +91,8 @@ BEGIN_PROLOG icarus_geometry_template: { SurfaceY: 6.9e2 # in cm, vertical distance to the surface - Name: "icarus_v2" # see ICARUS wiki for a list - DisableWiresInG4: true + Name: "icarus_v4" + GDML: "icarus_refactored_nounderscore_20230918.gdml" } # icarus_geometry_template @@ -109,12 +111,15 @@ icarus_geometry_template: { ### # -# ExptGeoHelperInterface +# WireReadout # -icarus_standard_geometry_helper: { - service_provider: IcarusGeometryHelper +icarus_standard_wire_readout: { + service_provider: IcarusWireReadout + SortingParameters: { + tool_type: WireReadoutSorterStandard + } Mapper: { - tool_type: "ICARUSsplitInductionChannelMapSetupTool" + tool_type: "ICARUSsplitInductionWireReadoutSetupTool" WirelessChannels: { @@ -137,7 +142,7 @@ icarus_standard_geometry_helper: { } # Mapper -} # icarus_standard_geometry_helper +} # icarus_standard_wire_readout ################################################################################ @@ -164,12 +169,20 @@ icarus_standard_geometry_helper: { icarus_standard_geometry: { @table::icarus_geometry_template - Name: "icarus_v4" - GDML: "icarus_refactored_nounderscore_20230918.gdml" - ROOT: "icarus_refactored_nounderscore_20230918.gdml" + SortingParameters: { + tool_type: GeoObjectSorterPMTasTPC + } +} - ChannelMapping: @local::icarus_standard_geometry_helper.Mapper +# +# AuxDetGeometry service configuration: +# +icarus_standard_auxdetgeometry: { + @table::icarus_geometry_template + SortingParameters: { + tool_type: AuxDetGeoObjectSorterICARUS + } } # icarus_standard_geometry # @@ -177,8 +190,9 @@ icarus_standard_geometry: { # icarus_standard_geometry_services: { - Geometry: @local::icarus_standard_geometry - ExptGeoHelperInterface: @local::icarus_standard_geometry_helper + AuxDetGeometry: @local::icarus_standard_auxdetgeometry + Geometry: @local::icarus_standard_geometry + WireReadout: @local::icarus_standard_wire_readout GeometryConfigurationWriter: {} } # icarus_standard_geometry_services @@ -220,24 +234,9 @@ icarus_geometry_services: @local::icarus_standard_geometry_services icarus_geometry: @local::icarus_geometry_services.Geometry icarus_geo: @local::icarus_geometry # backward compatibility -icarus_geometry_helper: @local::icarus_geometry_services.ExptGeoHelperInterface - -# -# Unit test configuration -# -# ICARUS has moved the configuration of the channel mapping out of -# "SortingParameters", for obvious reasons; but the test framework that -# this test uses assumes it will find it there. -# Also, our channel mapper does not appreciate finding a tool type parameter -# in its configuration. -# -# This configuration was written for unit test service utilities as found in -# LArSoft v09_82_01. -# +icarus_wire_readout: @local::icarus_geometry_services.WireReadout icarus_unit_test_geometry: @local::icarus_geometry -icarus_unit_test_geometry.SortingParameters: @local::icarus_unit_test_geometry.ChannelMapping -icarus_unit_test_geometry.SortingParameters.tool_type: @erase ################################################################################ @@ -257,11 +256,13 @@ icarus_unit_test_geometry.SortingParameters.tool_type: @erase ### Base legacy configuration, only used for FHiCL stability; i.e., if changed, ### all existing legacy configurations need to explicitly revert the change. ### -icarus_legacy_base_geometry_helper: { - service_provider: IcarusGeometryHelper +icarus_legacy_base_wire_readout: { + service_provider: IcarusWireReadout + SortingParameters: { + tool_type: WireReadoutSorterStandard + } Mapper: { - tool_type: "ICARUSsplitInductionChannelMapSetupTool" - + tool_type: "ICARUSsplitInductionWireReadoutSetupTool" WirelessChannels: { FirstInductionPreChannels: 0 @@ -282,7 +283,7 @@ icarus_legacy_base_geometry_helper: { } # WirelessChannels } # Mapper -} # icarus_legacy_base_geometry_helper +} # icarus_legacy_base_wire_readout icarus_legacy_base_geometry: { @@ -293,15 +294,14 @@ icarus_legacy_base_geometry: { GDML: @nil ROOT: @nil - ChannelMapping: @local::icarus_legacy_base_geometry_helper.Mapper + ChannelMapping: @local::icarus_legacy_base_wire_readout.Mapper } # icarus_legacy_base_geometry icarus_legacy_base_geometry_services: { Geometry: @local::icarus_legacy_base_geometry - ExptGeoHelperInterface: @local::icarus_legacy_base_geometry_helper + WireReadout: @local::icarus_legacy_base_wire_readout GeometryConfigurationWriter: {} - } # icarus_legacy_base_geometry_services @@ -373,7 +373,7 @@ icarus_geometry_services_legacy_icarus_splitwires: ### These are old names for the configuration presets. ### icarus_split_induction_overburden_geometry: @local::icarus_standard_geometry -icarus_split_induction_geometry_helper: @local::icarus_standard_geometry_helper +icarus_split_induction_wire_readout: @local::icarus_standard_wire_readout icarus_split_induction_overburden_geometry_services: @local::icarus_standard_geometry_services ################################################################################ diff --git a/icarusalg/Utilities/TrackTimeInterval.cxx b/icarusalg/Utilities/TrackTimeInterval.cxx index 528ebef..3b7aaa0 100644 --- a/icarusalg/Utilities/TrackTimeInterval.cxx +++ b/icarusalg/Utilities/TrackTimeInterval.cxx @@ -12,6 +12,8 @@ // LArSoft libraries #include "larcorealg/CoreUtils/counter.h" +#include "larcorealg/Geometry/PlaneGeo.h" +#include "larcorealg/Geometry/WireReadoutGeom.h" #include "lardataobj/RecoBase/Hit.h" // C/C++ standard libraries @@ -24,11 +26,12 @@ // ----------------------------------------------------------------------------- lar::util::TrackTimeInterval::TrackTimeInterval( geo::GeometryCore const& geom, + geo::WireReadoutGeom const& wireReadout, detinfo::DetectorPropertiesData detProp, detinfo::DetectorTimings detTimings ) : TrackTimeInterval - { buildGeomCache(geom), std::move(detProp), std::move(detTimings) } + { buildGeomCache(geom, wireReadout), std::move(detProp), std::move(detTimings) } {} @@ -108,29 +111,31 @@ lar::util::TrackTimeInterval::TrackTimeInterval( // ----------------------------------------------------------------------------- -auto lar::util::TrackTimeInterval::buildGeomCache(geo::GeometryCore const& geom) +auto lar::util::TrackTimeInterval::buildGeomCache + (geo::GeometryCore const& geom, geo::WireReadoutGeom const& wireReadout) -> GeometryCache_t { return { - extractTimeLimits(geom), // limits - { geom.Ncryostats(), geom.MaxTPCsets() }, // TPCsetDims - extractTPCtoSetMap(geom) // TPCtoSet + extractTimeLimits(geom, wireReadout), // limits + { geom.Ncryostats(), wireReadout.MaxTPCsets() }, // TPCsetDims + extractTPCtoSetMap(geom, wireReadout) // TPCtoSet }; } // lar::util::TrackTimeInterval::buildGeomCache() // ----------------------------------------------------------------------------- auto lar::util::TrackTimeInterval::extractTimeLimits - (geo::GeometryCore const& geom) -> GeometryCache_t::LimitsCache_t + (geo::GeometryCore const& geom, geo::WireReadoutGeom const& wireReadout) + -> GeometryCache_t::LimitsCache_t { // this infrastructure and coding style is a remnant of a previous version // which needed more information per plane and that information was different // by plane; the following is still correct, has fewer assumptions and it's // easier to expand, but a bit more wordy. - GeometryCache_t::LimitsCache_t limits = geom.makePlaneData(); + GeometryCache_t::LimitsCache_t limits{geom.Ncryostats(), geom.MaxTPCs(), wireReadout.MaxPlanes()}; for (geo::TPCGeo const& TPC: geom.Iterate()) { - geo::PlaneGeo const& firstPlane = TPC.FirstPlane(); + geo::PlaneGeo const& firstPlane = wireReadout.FirstPlane(TPC.ID()); // in ICARUS the hit time is corrected as if it were on the first plane // (the most inner one); @@ -142,9 +147,7 @@ auto lar::util::TrackTimeInterval::extractTimeLimits centimeters const driftDistance { std::abs(TPC.DriftDir().Dot(cathodeCenter - firstPlaneCenter)) }; // cm - for (geo::PlaneGeo const& plane: TPC.IteratePlanes()) { - - geo::PlaneID const& planeID = plane.ID(); + for (geo::PlaneID const& planeID: wireReadout.Iterate(TPC.ID())) { limits[planeID] = { driftDistance }; @@ -157,13 +160,14 @@ auto lar::util::TrackTimeInterval::extractTimeLimits // ----------------------------------------------------------------------------- auto lar::util::TrackTimeInterval::extractTPCtoSetMap - (geo::GeometryCore const& geom) -> GeometryCache_t::TPCtoSetMap_t + (geo::GeometryCore const& geom, geo::WireReadoutGeom const& wireReadout) + -> GeometryCache_t::TPCtoSetMap_t { - GeometryCache_t::TPCtoSetMap_t map = geom.makeTPCData(); + GeometryCache_t::TPCtoSetMap_t map{geom.Ncryostats(), geom.MaxTPCs()}; - for (readout::TPCsetID const tpcsetID: geom.Iterate()) { + for (readout::TPCsetID const tpcsetID: wireReadout.Iterate()) { assert(tpcsetID.isValid); - for (geo::TPCID tpcID: geom.TPCsetToTPCs(tpcsetID)) { + for (geo::TPCID tpcID: wireReadout.TPCsetToTPCs(tpcsetID)) { assert(tpcID.isValid); map[tpcID] = tpcsetID; } @@ -299,8 +303,8 @@ std::ostream& lar::util::operator<< // --- lar::util::TrackTimeIntervalMaker // ----------------------------------------------------------------------------- lar::util::TrackTimeIntervalMaker::TrackTimeIntervalMaker - (geo::GeometryCore const& geom) - : fGeomCache{ TrackTimeInterval::buildGeomCache(geom) } + (geo::GeometryCore const& geom, geo::WireReadoutGeom const& wireReadout) + : fGeomCache{ TrackTimeInterval::buildGeomCache(geom, wireReadout) } {} diff --git a/icarusalg/Utilities/TrackTimeInterval.h b/icarusalg/Utilities/TrackTimeInterval.h index a5eb9b0..3fbeb31 100644 --- a/icarusalg/Utilities/TrackTimeInterval.h +++ b/icarusalg/Utilities/TrackTimeInterval.h @@ -16,6 +16,7 @@ #include "lardataalg/DetectorInfo/DetectorPropertiesData.h" #include "lardataalg/Utilities/quantities/spacetime.h" #include "larcorealg/Geometry/GeometryCore.h" +#include "larcorealg/Geometry/ReadoutDataContainers.h" #include "larcoreobj/SimpleTypesAndConstants/readout_types.h" #include "larcoreobj/SimpleTypesAndConstants/geo_types.h" @@ -175,6 +176,7 @@ class lar::util::TrackTimeInterval { /// Constructor: initializes with the specified detector properties. TrackTimeInterval( geo::GeometryCore const& geom, + geo::WireReadoutGeom const& wireReadout, detinfo::DetectorPropertiesData detProp, detinfo::DetectorTimings detTimings ); @@ -306,14 +308,15 @@ class lar::util::TrackTimeInterval { /// Creates a geometry cache. - static GeometryCache_t buildGeomCache(geo::GeometryCore const& geom); + static GeometryCache_t buildGeomCache + (geo::GeometryCore const& geom, geo::WireReadoutGeom const& wireReadout); /// Returns the time limits of all the planes in the specified TPC. static GeometryCache_t::LimitsCache_t extractTimeLimits - (geo::GeometryCore const& geom); + (geo::GeometryCore const& geom, geo::WireReadoutGeom const& wireReadout); static GeometryCache_t::TPCtoSetMap_t extractTPCtoSetMap - (geo::GeometryCore const& geom); + (geo::GeometryCore const& geom, geo::WireReadoutGeom const& wireReadout); /** @@ -474,7 +477,7 @@ class lar::util::TrackTimeIntervalMaker { public: /// Constructor: creates a cache from the geometry. - TrackTimeIntervalMaker(geo::GeometryCore const& geom); + TrackTimeIntervalMaker(geo::GeometryCore const& geom, geo::WireReadoutGeom const& wireReadout); //@{ /// Returns a new `TrackTimeInterval` with the specified detector properties. diff --git a/icarusalg/gallery/MCTruthBase/MCTruthAssociations.cpp b/icarusalg/gallery/MCTruthBase/MCTruthAssociations.cpp index c4de60f..d54b86c 100644 --- a/icarusalg/gallery/MCTruthBase/MCTruthAssociations.cpp +++ b/icarusalg/gallery/MCTruthBase/MCTruthAssociations.cpp @@ -560,11 +560,12 @@ double MCTruthAssociations::length(const detinfo::DetectorPropertiesData& detPro { // Get fiducial volume boundary. double xmin = -0.1; - double xmax = 2.*fGeometry->DetHalfWidth() + 0.1; - double ymin = -fGeometry->DetHalfHeight() + 0.1; - double ymax = fGeometry->DetHalfHeight() + 0.1; + geo::TPCGeo const& tpcGeo = fGeometry->TPC({0, 0}); + double xmax = 2.*tpcGeo.HalfWidth() + 0.1; + double ymin = -tpcGeo.HalfHeight() + 0.1; + double ymax = tpcGeo.HalfHeight() + 0.1; double zmin = -0.1; - double zmax = fGeometry->DetLength() + 0.1; + double zmax = tpcGeo.Length() + 0.1; double readOutWindowSize = detProp.ReadOutWindowSize(); diff --git a/icarusalg/gallery/examples/DetectorActivityRatePlots/C++/DetectorActivityRatePlots.cpp b/icarusalg/gallery/examples/DetectorActivityRatePlots/C++/DetectorActivityRatePlots.cpp index e5f883d..0a21300 100644 --- a/icarusalg/gallery/examples/DetectorActivityRatePlots/C++/DetectorActivityRatePlots.cpp +++ b/icarusalg/gallery/examples/DetectorActivityRatePlots/C++/DetectorActivityRatePlots.cpp @@ -38,7 +38,7 @@ #include "lardataalg/DetectorInfo/LArPropertiesStandardTestHelpers.h" #include "lardataalg/DetectorInfo/LArPropertiesStandard.h" // - Geometry -#include "icarusalg/Geometry/ICARUSChannelMapAlg.h" +#include "icarusalg/Geometry/ICARUSWireReadoutGeom.h" #include "larcorealg/Geometry/StandaloneGeometrySetup.h" #include "larcorealg/Geometry/GeometryCore.h" @@ -862,7 +862,7 @@ int makePlots // (and make sure the corresponding headers are also uncommented) // // geometry setup (it's special) - auto geom = lar::standalone::SetupGeometry + auto geom = lar::standalone::SetupGeometry (config.get("services.Geometry")); // LArProperties setup diff --git a/icarusalg/gallery/examples/galleryAnalysis/C++/galleryAnalysis.cpp b/icarusalg/gallery/examples/galleryAnalysis/C++/galleryAnalysis.cpp index 7759d52..c6cabc6 100644 --- a/icarusalg/gallery/examples/galleryAnalysis/C++/galleryAnalysis.cpp +++ b/icarusalg/gallery/examples/galleryAnalysis/C++/galleryAnalysis.cpp @@ -39,7 +39,7 @@ // - Geometry #include "larcorealg/Geometry/StandaloneGeometrySetup.h" #include "larcorealg/Geometry/GeometryCore.h" -#include "icarusalg/Geometry/ICARUSChannelMapAlg.h" +#include "icarusalg/Geometry/ICARUSWireReadoutGeom.h" // - configuration #include "larcorealg/Geometry/StandaloneBasicSetup.h" @@ -95,7 +95,7 @@ int galleryAnalysis(std::string const& configFile, std::vector cons // // geometry setup (it's special) - auto geom = lar::standalone::SetupGeometry(config.get("services.Geometry")); + auto geom = lar::standalone::SetupGeometry(config.get("services.Geometry")); // LArProperties setup auto larp = testing::setupProvider(config.get("services.LArPropertiesService")); diff --git a/test/Geometry/ChannelMapConfig.h b/test/Geometry/ChannelMapConfig.h new file mode 100644 index 0000000..108d1fa --- /dev/null +++ b/test/Geometry/ChannelMapConfig.h @@ -0,0 +1,17 @@ +#ifndef ICARUSALG_TEST_GEOMETRY_CHANNELMAPCONFIG_H +#define ICARUSALG_TEST_GEOMETRY_CHANNELMAPCONFIG_H + +#include "fhiclcpp/ParameterSet.h" + +namespace testing { + template + fhicl::ParameterSet wireReadoutConfig(Environment const& environment) + { + auto result = environment.ServiceParameters("WireReadout") + .template get("Mapper"); + result.erase("tool_type"); + return result; + } +} + +#endif diff --git a/test/Geometry/geometry_icarus_test.cxx b/test/Geometry/geometry_icarus_test.cxx index b2c4311..c217e4b 100644 --- a/test/Geometry/geometry_icarus_test.cxx +++ b/test/Geometry/geometry_icarus_test.cxx @@ -13,12 +13,16 @@ */ // ICARUS libraries -#include "icarusalg/Geometry/ICARUSChannelMapAlg.h" +#include "icarusalg/Geometry/GeoObjectSorterPMTasTPC.h" +#include "icarusalg/Geometry/ICARUSWireReadoutGeom.h" +#include "icarusalg/Geometry/WireReadoutSorterICARUS.h" #include "test/Geometry/geometry_unit_test_icarus.h" +#include "test/Geometry/ChannelMapConfig.h" // LArSoft libraries #include "larcorealg/test/Geometry/GeometryTestAlg.h" #include "larcorealg/Geometry/GeometryCore.h" +#include "larcorealg/Geometry/StandaloneGeometrySetup.h" // utility libraries #include "messagefacility/MessageLogger/MessageLogger.h" @@ -33,8 +37,7 @@ // we use an existing class provided for this purpose, since our test // environment allows us to tailor it at run time. using IcarusGeometryConfiguration - = icarus::testing::IcarusGeometryEnvironmentConfiguration - ; + = icarus::testing::IcarusGeometryEnvironmentConfiguration; /* * GeometryTesterFixture, configured with the object above, is used in a @@ -44,7 +47,7 @@ using IcarusGeometryConfiguration * - `geo::GeometryCore const* GlobalGeometry()` (static member) */ using IcarusGeometryTestEnvironment - = testing::GeometryTesterEnvironment; + = testing::GeometryTesterEnvironment; //------------------------------------------------------------------------------ @@ -97,25 +100,29 @@ int main(int argc, char const** argv) { // testing environment setup // IcarusGeometryTestEnvironment TestEnvironment(config); + using namespace lar::standalone; + auto const wireReadoutAlg = + SetupReadout(wireReadoutConfig(TestEnvironment), + TestEnvironment.Geometry()); + auto const auxDetGeom = SetupAuxDetGeometry(TestEnvironment.ServiceParameters("AuxDetGeometry")); // // run the test algorithm // - // 1. we initialize it from the configuration in the environment, - geo::GeometryTestAlg Tester(TestEnvironment.TesterParameters()); + // 1. we initialize it from the environment, + geo::GeometryTestAlg Tester(TestEnvironment.Geometry(), + wireReadoutAlg.get(), + auxDetGeom.get(), + TestEnvironment.TesterParameters()); - // 2. we set it up with the geometry from the environment - Tester.Setup(*TestEnvironment.Geometry()); - - // 3. then we run it! + // 2. then we run it! unsigned int nErrors = Tester.Run(); - // 4. And finally we cross fingers. + // 3. And finally we cross fingers. if (nErrors > 0) { mf::LogError("geometry_test_ICARUS") << nErrors << " errors detected!"; } return nErrors; } // main() - diff --git a/test/Geometry/geometry_iterator_icarus_test.cxx b/test/Geometry/geometry_iterator_icarus_test.cxx index 6b28023..4859f3a 100644 --- a/test/Geometry/geometry_iterator_icarus_test.cxx +++ b/test/Geometry/geometry_iterator_icarus_test.cxx @@ -13,7 +13,10 @@ #define BOOST_TEST_MODULE GeometryIteratorTestICARUS // ICARUS libraries -#include "icarusalg/Geometry/ICARUSChannelMapAlg.h" +#include "icarusalg/Geometry/ICARUSWireReadoutGeom.h" +#include "icarusalg/Geometry/GeoObjectSorterPMTasTPC.h" +#include "icarusalg/Geometry/WireReadoutSorterICARUS.h" +#include "test/Geometry/ChannelMapConfig.h" // LArSoft libraries #include "test/Geometry/geometry_unit_test_icarus.h" @@ -31,10 +34,7 @@ // We wrap it in testing::BoostCommandLineConfiguration<> so that it can learn // the configuration file name from the command line. struct IcarusGeometryConfiguration: - public testing::BoostCommandLineConfiguration< - icarus::testing::IcarusGeometryEnvironmentConfiguration - - > + public testing::BoostCommandLineConfiguration { /// Constructor: overrides the application name; ignores command line IcarusGeometryConfiguration() @@ -47,16 +47,15 @@ struct IcarusGeometryConfiguration: * It provides: * - `Tester`, a configured instance of the test algorithm. */ -class IcarusGeometryIteratorTestFixture: - private testing::GeometryTesterEnvironment +struct IcarusGeometryIteratorTestFixture: + testing::GeometryTesterEnvironment { - public: - geo::GeometryIteratorTestAlg Tester; - - /// Constructor: initialize the tester with the Geometry from base class - IcarusGeometryIteratorTestFixture(): Tester(Geometry()) - {} - + std::unique_ptr WireReadout{ + std::make_unique( + wireReadoutConfig(*this), + Geometry(), + std::make_unique())}; + geo::GeometryIteratorTestAlg Tester{Geometry(), WireReadout.get()}; }; // class IcarusGeometryIteratorTestFixture diff --git a/test/Geometry/geometry_iterator_loop_icarus_test.cxx b/test/Geometry/geometry_iterator_loop_icarus_test.cxx index 94c2fed..225653a 100644 --- a/test/Geometry/geometry_iterator_loop_icarus_test.cxx +++ b/test/Geometry/geometry_iterator_loop_icarus_test.cxx @@ -16,10 +16,13 @@ // ICARUS libraries -#include "icarusalg/Geometry/ICARUSChannelMapAlg.h" +#include "icarusalg/Geometry/ICARUSWireReadoutGeom.h" +#include "icarusalg/Geometry/GeoObjectSorterPMTasTPC.h" +#include "icarusalg/Geometry/WireReadoutSorterICARUS.h" // LArSoft libraries #include "test/Geometry/geometry_unit_test_icarus.h" +#include "test/Geometry/ChannelMapConfig.h" #include "larcorealg/test/Geometry/GeometryIteratorLoopTestAlg.h" #include "larcorealg/Geometry/GeometryCore.h" @@ -35,18 +38,16 @@ // we use an existing class provided for this purpose, since our test // environment allows us to tailor it at run time. using IcarusGeometryConfiguration - = icarus::testing::IcarusGeometryEnvironmentConfiguration - ; + = icarus::testing::IcarusGeometryEnvironmentConfiguration; /* * GeometryTesterFixture, configured with the object above, is used in a * non-Boost-unit-test context. * It provides: * - `geo::GeometryCore const* Geometry()` - * - `geo::GeometryCore const* GlobalGeometry()` (static member) */ using IcarusGeometryTestEnvironment - = testing::GeometryTesterEnvironment; + = testing::GeometryTesterEnvironment; //------------------------------------------------------------------------------ @@ -100,13 +101,19 @@ int main(int argc, char const** argv) { // testing environment setup // IcarusGeometryTestEnvironment TestEnvironment(config); + + auto wireReadoutAlg = + std::make_unique(wireReadoutConfig(TestEnvironment), + TestEnvironment.Geometry(), + std::make_unique() + ); // // run the test algorithm // // 1. we initialize it with the geometry from the environment, - geo::GeometryIteratorLoopTestAlg Tester(TestEnvironment.Geometry()); + geo::GeometryIteratorLoopTestAlg Tester(TestEnvironment.Geometry(), wireReadoutAlg.get()); // 2. then we run it! unsigned int nErrors = Tester.Run(); diff --git a/test/Geometry/geometry_unit_test_icarus.h b/test/Geometry/geometry_unit_test_icarus.h index 94f30a4..4774768 100644 --- a/test/Geometry/geometry_unit_test_icarus.h +++ b/test/Geometry/geometry_unit_test_icarus.h @@ -17,7 +17,7 @@ // LArSoft libraries #include "larcorealg/TestUtils/geometry_unit_test_base.h" -#include "icarusalg/Geometry/ICARUSChannelMapAlg.h" +#include "icarusalg/Geometry/ICARUSWireReadoutGeom.h" // C/C++ standard libraries #include @@ -30,7 +30,6 @@ namespace icarus { /** ************************************************************************ * @brief Class holding the configuration for a ICARUS fixture - * @tparam CHANNELMAP the class used for channel mapping * @see BasicGeometryEnvironmentConfiguration * * This class needs to be fully constructed by the default constructor @@ -39,18 +38,16 @@ namespace icarus { * that can store an instance of it and extract configuration information * from it. * - * This class should be used with `icarus::ICARUSChannelMapAlg`. + * This class should be used with `icarus::ICARUSWireReadoutGeom`. * * We reuse BasicGeometryEnvironmentConfiguration as base class and then we * fix its setup. */ - template struct IcarusGeometryEnvironmentConfiguration: - public ::testing::BasicGeometryEnvironmentConfiguration + public ::testing::BasicGeometryEnvironmentConfiguration { // remember that BasicGeometryEnvironmentConfiguration is not polymorphic - using base_t - = ::testing::BasicGeometryEnvironmentConfiguration; + using base_t = ::testing::BasicGeometryEnvironmentConfiguration; /// Default constructor IcarusGeometryEnvironmentConfiguration() { IcarusDefaultInit(); } diff --git a/test/Utilities/TrackTimeInterval_test.cc b/test/Utilities/TrackTimeInterval_test.cc index 4295455..d441371 100644 --- a/test/Utilities/TrackTimeInterval_test.cc +++ b/test/Utilities/TrackTimeInterval_test.cc @@ -18,7 +18,9 @@ // ICARUS libraries #include "icarusalg/Utilities/TrackTimeInterval.h" -#include "icarusalg/Geometry/ICARUSChannelMapAlg.h" +#include "icarusalg/Geometry/GeoObjectSorterPMTasTPC.h" +#include "icarusalg/Geometry/ICARUSWireReadoutGeom.h" +#include "icarusalg/Geometry/WireReadoutSorterICARUS.h" // LArSoft libraries #include "lardataalg/DetectorInfo/DetectorPropertiesStandard.h" @@ -31,6 +33,7 @@ #include "larcorealg/Geometry/GeometryCore.h" #include "larcorealg/Geometry/TPCGeo.h" #include "larcorealg/Geometry/PlaneGeo.h" +#include "larcorealg/Geometry/StandaloneGeometrySetup.h" #include "larcorealg/CoreUtils/counter.h" #include "larcoreobj/SimpleTypesAndConstants/geo_types.h" #include "larcorealg/TestUtils/boost_unit_test_base.h" @@ -52,9 +55,9 @@ //--- The test environment //--- -using TesterConfiguration = - testing::BasicGeometryEnvironmentConfiguration; -using TestEnvironment = testing::GeometryTesterEnvironment; +using TesterConfiguration = testing::BasicGeometryEnvironmentConfiguration; +using TestEnvironment = testing::GeometryTesterEnvironment; class TestFixture { @@ -77,6 +80,10 @@ class TestFixture { gEnv.emplace(config); TestEnvironment& testEnv = *gEnv; + using lar::standalone::SetupReadout; + auto wireReadout = SetupReadout + ({}, testEnv.Provider()); + testEnv.AcquireProvider(std::move(wireReadout)); // DetectorPropertiesStandard and all its dependencies support the simple set // up (see testing::TesterEnvironment::SimpleProviderSetup()), except for // Geometry, that has been configured already in the geometry-aware @@ -153,15 +160,16 @@ BOOST_AUTO_TEST_CASE(PrintHitsOnAllPlanes) = testEnv.Provider()->DataForJob(); geo::GeometryCore const& geom = *(testEnv.Provider()); + geo::WireReadoutGeom const& wireReadout = *(testEnv.Provider()); detinfo::DetectorPropertiesData detProp = testEnv.Provider()->DataFor(detClockData); const int MaxTick = detProp.ReadOutWindowSize(); lar::util::TrackTimeInterval const chargeTime - { geom, detProp, detinfo::DetectorTimings{ detClockData } }; + { geom, wireReadout, detProp, detinfo::DetectorTimings{ detClockData } }; - for (geo::PlaneGeo const& plane: geom.Iterate()) { + for (geo::PlaneGeo const& plane: wireReadout.Iterate()) { // // make some hits on this plane @@ -169,8 +177,8 @@ BOOST_AUTO_TEST_CASE(PrintHitsOnAllPlanes) std::vector hits; geo::WireID const wireID{ plane.ID(), 1 }; - raw::ChannelID_t const channel = geom.PlaneWireToChannel(wireID); - geo::SigType_t const signalType = geom.SignalType(channel); + raw::ChannelID_t const channel = wireReadout.PlaneWireToChannel(wireID); + geo::SigType_t const signalType = wireReadout.SignalType(channel); geo::View_t const view = plane.View(); int tick = 0; @@ -209,29 +217,30 @@ BOOST_AUTO_TEST_CASE(HitsOnPlanes) detinfo::DetectorTimings const detTiming{ detClockData }; geo::GeometryCore const& geom = *(testEnv.Provider()); + geo::WireReadoutGeom const& wireReadout = *(testEnv.Provider()); detinfo::DetectorPropertiesData detProp = testEnv.Provider()->DataFor(detClockData); - lar::util::TrackTimeInterval const chargeTime{ geom, detProp, detTiming }; + lar::util::TrackTimeInterval const chargeTime{ geom, wireReadout, detProp, detTiming }; - electronics_time const triggerTime [[maybe_unused]] = detTiming.TriggerTime(); + electronics_time const triggerTime = detTiming.TriggerTime(); double const driftVelocity = detProp.DriftVelocity(); for (geo::TPCGeo const& TPC: geom.Iterate()) { // refer to the first plane (ICARUS does that) - geo::Point_t const firstPlaneCenter = TPC.FirstPlane().GetCenter(); + geo::Point_t const firstPlaneCenter = wireReadout.FirstPlane(TPC.ID()).GetCenter(); geo::Point_t const cathodeCenter = TPC.GetCathodeCenter(); double const driftDistance = std::abs(cathodeCenter.X() - firstPlaneCenter.X()); util::quantities::microseconds const driftTime { driftDistance / driftVelocity }; - for (geo::PlaneGeo const& plane: TPC.IteratePlanes()) { + for (geo::PlaneGeo const& plane: wireReadout.Iterate(TPC.ID())) { geo::WireID const wireID{ plane.ID(), 1 }; - raw::ChannelID_t const channel = geom.PlaneWireToChannel(wireID); - geo::SigType_t const signalType = geom.SignalType(channel); + raw::ChannelID_t const channel = wireReadout.PlaneWireToChannel(wireID); + geo::SigType_t const signalType = wireReadout.SignalType(channel); geo::View_t const view = plane.View(); // a hit at the anode at trigger time arrives immediately at trigger time; @@ -285,10 +294,11 @@ BOOST_AUTO_TEST_CASE(PrintHitTimes) detinfo::DetectorTimings const detTiming{ detClockData }; geo::GeometryCore const& geom = *(testEnv.Provider()); + geo::WireReadoutGeom const& wireReadout = *(testEnv.Provider()); detinfo::DetectorPropertiesData detProp = testEnv.Provider()->DataFor(detClockData); - lar::util::TrackTimeInterval const chargeTime{ geom, detProp, detTiming }; + lar::util::TrackTimeInterval const chargeTime{ geom, wireReadout, detProp, detTiming }; double const driftVelocity = detProp.DriftVelocity(); // cm/us @@ -297,10 +307,10 @@ BOOST_AUTO_TEST_CASE(PrintHitTimes) BOOST_TEST_MESSAGE("Hit times for " << TPC.ID()); double const driftLength = std::abs( - TPC.DriftDir().Dot(TPC.GetCathodeCenter() - TPC.FirstPlane().GetCenter()) + TPC.DriftDir().Dot(TPC.GetCathodeCenter() - wireReadout.FirstPlane(TPC.ID()).GetCenter()) ); - geo::PlaneGeo const& plane = TPC.FirstPlane(); + geo::PlaneGeo const& plane = wireReadout.FirstPlane(TPC.ID()); geo::WireID::WireID_t const refWireNo = 100; double const xC = TPC.GetCathodeCenter().X(); @@ -308,8 +318,8 @@ BOOST_AUTO_TEST_CASE(PrintHitTimes) auto const xCoord = [x0=xA,L=xC-xA](double u){ return x0 + L * u; }; raw::ChannelID_t const refChannel - = geom.PlaneWireToChannel({ plane.ID(), 100 }); - geo::SigType_t const signalType = geom.SignalType(refChannel); + = wireReadout.PlaneWireToChannel({ plane.ID(), 100 }); + geo::SigType_t const signalType = wireReadout.SignalType(refChannel); geo::View_t const view = plane.View(); std::default_random_engine engine; // default seed, not that random @@ -347,11 +357,12 @@ BOOST_AUTO_TEST_CASE(timeRangeOfHits_singleTPCset) detinfo::DetectorTimings const detTiming{ detClockData }; geo::GeometryCore const& geom = *(testEnv.Provider()); + geo::WireReadoutGeom const& wireReadout = *(testEnv.Provider()); detinfo::DetectorPropertiesData detProp = testEnv.Provider()->DataFor(detClockData); // let's try the maker this time... - lar::util::TrackTimeIntervalMaker const trackTimeIntervalMaker{ geom }; + lar::util::TrackTimeIntervalMaker const trackTimeIntervalMaker{ geom, wireReadout }; lar::util::TrackTimeInterval const chargeTime = trackTimeIntervalMaker(detProp, detTiming); @@ -362,10 +373,10 @@ BOOST_AUTO_TEST_CASE(timeRangeOfHits_singleTPCset) BOOST_TEST_MESSAGE("Track test for " << TPC.ID()); double const driftLength = std::abs( - TPC.DriftDir().Dot(TPC.GetCathodeCenter() - TPC.FirstPlane().GetCenter()) + TPC.DriftDir().Dot(TPC.GetCathodeCenter() - wireReadout.FirstPlane(TPC.ID()).GetCenter()) ); - geo::PlaneGeo const& plane = TPC.FirstPlane(); + geo::PlaneGeo const& plane = wireReadout.FirstPlane(TPC.ID()); geo::WireID::WireID_t const refWireNo = 100; double const xC = TPC.GetCathodeCenter().X(); @@ -373,8 +384,8 @@ BOOST_AUTO_TEST_CASE(timeRangeOfHits_singleTPCset) auto const xCoord = [x0=xA,L=xC-xA](double u){ return x0 + L * u; }; raw::ChannelID_t const refChannel - = geom.PlaneWireToChannel({ plane.ID(), 100 }); - geo::SigType_t const signalType = geom.SignalType(refChannel); + = wireReadout.PlaneWireToChannel({ plane.ID(), 100 }); + geo::SigType_t const signalType = wireReadout.SignalType(refChannel); geo::View_t const view = plane.View(); std::default_random_engine engine; // default seed, not that random diff --git a/ups/product_deps b/ups/product_deps index 073bb30..9b09b65 100644 --- a/ups/product_deps +++ b/ups/product_deps @@ -250,8 +250,8 @@ gdmldir product_dir gdml #################################### product version qual flags guideline_sl v4_0_0 - -larsoftobj v09_36_00 - -sbnobj v09_19_05 - +larsoftobj v10_00_02 - +sbnobj v10_00_02 - cetmodules v3_24_01 - only_for_build end_product_list ####################################