diff --git a/fcl/caf/cafmakerjob_icarus_cosmic_detsim2d.fcl b/fcl/caf/cafmakerjob_icarus_cosmic_detsim2d.fcl new file mode 100644 index 000000000..49caf1078 --- /dev/null +++ b/fcl/caf/cafmakerjob_icarus_cosmic_detsim2d.fcl @@ -0,0 +1,3 @@ +#include "cafmakerjob_icarus_detsim2d.fcl" + +physics.producers.cafmaker.SaveGENIEEventRecord: false diff --git a/fcl/gen/text/prodtext_standard_icarus.fcl b/fcl/gen/text/prodtext_standard_icarus.fcl index 8fc5c4dd9..fb2b7e50f 100644 --- a/fcl/gen/text/prodtext_standard_icarus.fcl +++ b/fcl/gen/text/prodtext_standard_icarus.fcl @@ -26,7 +26,7 @@ # # services.Geometry: @erase # services.GeometryConfigurationWriter: @erase -# services.ExptGeoHelperInterface: @erase +# services.WireReadout: @erase # # The output file name will be `prodtext_standard_icarus_%tc-GenText.root` # (`%tc` being a timestamp assigned by art). diff --git a/fcl/reco/Stage0/Run1/stage0_run1_icarus_mc.fcl b/fcl/reco/Stage0/Run1/stage0_run1_icarus_mc.fcl index 285667241..18081dea6 100644 --- a/fcl/reco/Stage0/Run1/stage0_run1_icarus_mc.fcl +++ b/fcl/reco/Stage0/Run1/stage0_run1_icarus_mc.fcl @@ -8,8 +8,8 @@ process_name: MCstage0 ## Revert the geometry for now -services.Geometry: @local::icarus_legacy_base_geometry -services.ExptGeoHelperInterface: @local::icarus_legacy_base_geometry_helper +services.Geometry: @local::icarus_legacy_base_geometry +services.WireReadout: @local::icarus_legacy_base_wire_readout ## Add the MC module to the list of producers physics.producers: { @table::icarus_stage0_producers diff --git a/icaruscode/Analysis/ICARUSPurityDQM_module.cc b/icaruscode/Analysis/ICARUSPurityDQM_module.cc index bc2b52497..beb363a7f 100644 --- a/icaruscode/Analysis/ICARUSPurityDQM_module.cc +++ b/icaruscode/Analysis/ICARUSPurityDQM_module.cc @@ -1,4 +1,3 @@ - //////////////////////////////////////////////////////////////////////// // // ICARUSPurityDQM class @@ -33,7 +32,7 @@ //#include "messagefacility/MessageLogger/MessageLogger.h" //LArSoft includes -#include "larcore/Geometry/Geometry.h" +#include "larcore/Geometry/WireReadout.h" #include "nusimdata/SimulationBase/MCTruth.h" #include "nug4/ParticleNavigation/ParticleList.h" #include "nug4/ParticleNavigation/EmEveIdCalculator.h" @@ -351,7 +350,7 @@ std::sort(usedhere->begin(),usedhere->end(), [](float &c, float &d){ return c geom; + geo::WireReadoutGeom const& wireReadoutAlg = art::ServiceHandle()->Get(); unsigned int fDataSize; std::vector rawadc; //UNCOMPRESSED ADC VALUES. // get all hits in the event @@ -413,7 +412,7 @@ std::sort(usedhere->begin(),usedhere->end(), [](float &c, float &d){ return cChannel(); ////std::cout << channel << std::endl; - std::vector wids = geom->ChannelToWire(channel); + std::vector wids = wireReadoutAlg.ChannelToWire(channel); // for now, just take the first option returned from ChannelToWire geo::WireID wid = wids[0]; // We need to know the plane to look up parameters @@ -1200,4 +1199,3 @@ namespace icarus{ DEFINE_ART_MODULE(ICARUSPurityDQM) } - diff --git a/icaruscode/Analysis/TPCPurityMonitor_module.cc b/icaruscode/Analysis/TPCPurityMonitor_module.cc index c331bfb7f..79eca472d 100755 --- a/icaruscode/Analysis/TPCPurityMonitor_module.cc +++ b/icaruscode/Analysis/TPCPurityMonitor_module.cc @@ -32,8 +32,7 @@ #include "cetlib/cpu_timer.h" // LArSoft includes -#include "larcore/Geometry/Geometry.h" -#include "larcore/CoreUtils/ServiceUtil.h" // lar::providerFrom() +#include "larcore/Geometry/WireReadout.h" #include "larcoreobj/SimpleTypesAndConstants/geo_types.h" #include "lardata/DetectorInfoServices/LArPropertiesService.h" #include "lardata/DetectorInfoServices/DetectorClocksService.h" @@ -247,7 +246,7 @@ class TPCPurityMonitor : public art::EDProducer int fNumEvents; // Other variables that will be shared between different methods. - const geo::GeometryCore* fGeometry; // pointer to Geometry service + geo::WireReadoutGeom const& fChannelMap = art::ServiceHandle()->Get(); }; // class TPCPurityMonitor // This macro has to be defined for this module to be invoked from a @@ -266,8 +265,6 @@ TPCPurityMonitor::TPCPurityMonitor(fhicl::ParameterSet const& parameterSet) fNumEvents(0) { - fGeometry = lar::providerFrom(); - // We're going to output purity objects produces>("",art::Persistable::Yes); @@ -469,7 +466,7 @@ void TPCPurityMonitor::produce(art::Event& event) { geo::Point_t hitPos = track->LocationAtPoint(trkHitIndex); geo::Vector_t hitDir = track->DirectionAtPoint(trkHitIndex); - const geo::WireGeo& wireGeo = fGeometry->Wire(hitMetaPair.first->WireID()); + const geo::WireGeo& wireGeo = fChannelMap.Wire(hitMetaPair.first->WireID()); geo::Vector_t wireDir = wireGeo.Direction(); pointCloud.emplace_back(hitPos); diff --git a/icaruscode/Analysis/ThroughgoingmuonAnalyzer_module.cc b/icaruscode/Analysis/ThroughgoingmuonAnalyzer_module.cc index 98c06faac..843210212 100644 --- a/icaruscode/Analysis/ThroughgoingmuonAnalyzer_module.cc +++ b/icaruscode/Analysis/ThroughgoingmuonAnalyzer_module.cc @@ -29,6 +29,7 @@ #include "lardata/DetectorInfoServices/DetectorClocksService.h" +#include "larcore/Geometry/WireReadout.h" #include "larcore/Geometry/Geometry.h" #include "larcore/CoreUtils/ServiceUtil.h" // lar::providerFrom() #include "larcorealg/Geometry/CryostatGeo.h" @@ -237,9 +238,8 @@ class ThroughgoingmuonAnalyzer : public art::EDAnalyzer // Useful services, keep copies for now (we can update during begin run periods) const geo::GeometryCore* fGeometry; ///< pointer to Geometry service + const geo::WireReadoutGeom* fChannelMapAlg; ///< pointer to ChannelMapAlg - // Get geometry. - // art::ServiceHandle geom; }; @@ -272,10 +272,11 @@ ThroughgoingmuonAnalyzer::ThroughgoingmuonAnalyzer(fhicl::ParameterSet const& ps // fHitProducerLabelVec = pset.get< std::vector>("HitModuleLabelVec", std::vector() = {"gauss"}); fGeometry = lar::providerFrom(); + fChannelMapAlg = &art::ServiceHandle()->Get(); art::TFileDirectory dir = tfs->mkdir("histos"); - fHitEffvselecVec.resize(fGeometry->Nplanes()); - for(size_t plane = 0; plane < fGeometry->Nplanes(); plane++) + fHitEffvselecVec.resize(fChannelMapAlg->Nplanes()); + for(size_t plane = 0; plane < fChannelMapAlg->Nplanes(); plane++) { fHitEffvselecVec.at(plane) = dir.make (("HitEffvselec" + std::to_string(plane)).c_str(), "Hit Efficiency; Total # e-", 200, 0., 200000., 0., 1.); } @@ -685,7 +686,7 @@ void ThroughgoingmuonAnalyzer::analyze(art::Event const& evt) // This is the "correct" way to check and remove bad channels... if( chanFilt.Status(chanToTDCToIDEMap.first) < fMinAllowedChanStatus) { - std::vector wids = fGeometry->ChannelToWire(chanToTDCToIDEMap.first); + std::vector wids = fChannelMapAlg->ChannelToWire(chanToTDCToIDEMap.first); std::cout << "*** skipping bad channel with status: " << chanFilt.Status(chanToTDCToIDEMap.first) << " for channel: " << chanToTDCToIDEMap.first << ", plane: " << wids[0].Plane @@ -713,7 +714,7 @@ void ThroughgoingmuonAnalyzer::analyze(art::Event const& evt) // The below try-catch block may no longer be necessary // Decode the channel and make sure we have a valid one - std::vector wids = fGeometry->ChannelToWire(chanToTDCToIDEMap.first); + std::vector wids = fChannelMapAlg->ChannelToWire(chanToTDCToIDEMap.first); // Recover plane and wire in the plane unsigned int plane = wids[0].Plane; @@ -1469,7 +1470,7 @@ void ThroughgoingmuonAnalyzer::analyze(art::Event const& evt) std::cout << "-- final quick loop to fill summary hists" << std::endl; - for(size_t idx = 0; idx < fGeometry->Nplanes();idx++) + for(size_t idx = 0; idx < fChannelMapAlg->Nplanes();idx++) { if (nSimChannelHitVec[idx] > 10) { diff --git a/icaruscode/Analysis/WireAna_module.cc b/icaruscode/Analysis/WireAna_module.cc index 6a1f18169..eaa73a056 100755 --- a/icaruscode/Analysis/WireAna_module.cc +++ b/icaruscode/Analysis/WireAna_module.cc @@ -200,16 +200,16 @@ void WireAna::analyze(const art::Event& event) // Recover list of simChannels mapped by channel to make // look up easier below - IWireHistogramTool::SimChannelMap channelMap; + IWireHistogramTool::SimChannelMap wireReadout; if (simChannelHandle.isValid()) { - for(const auto& simChannel : *simChannelHandle) channelMap[simChannel.Channel()] = &simChannel; + for(const auto& simChannel : *simChannelHandle) wireReadout[simChannel.Channel()] = &simChannel; // { // raw::ChannelID_t channel = simChannel.Channel(); // const sim::SimChannel* simChannelPtr = &simChannel; // -// channelMap.at(channel) = simChannelPtr; +// wireReadout.at(channel) = simChannelPtr; // } } @@ -218,7 +218,7 @@ void WireAna::analyze(const art::Event& event) IWireHistogramTool::WirePtrVec wireVec; art::fill_ptr_vector(wireVec, wireHandle); - for(auto& wireHistTool : fWireHistogramToolVec) wireHistTool->fillHistograms(wireVec,channelMap,fNumEvents); + for(auto& wireHistTool : fWireHistogramToolVec) wireHistTool->fillHistograms(wireVec,wireReadout,fNumEvents); } } diff --git a/icaruscode/Analysis/tools/BasicHitAnalysis_tool.cc b/icaruscode/Analysis/tools/BasicHitAnalysis_tool.cc index a20c2beb8..911078e9c 100755 --- a/icaruscode/Analysis/tools/BasicHitAnalysis_tool.cc +++ b/icaruscode/Analysis/tools/BasicHitAnalysis_tool.cc @@ -8,8 +8,7 @@ #include "art_root_io/TFileDirectory.h" #include "messagefacility/MessageLogger/MessageLogger.h" -#include "larcore/Geometry/Geometry.h" -#include "larcore/CoreUtils/ServiceUtil.h" // lar::providerFrom() +#include "larcore/Geometry/WireReadout.h" #include "lardataobj/RecoBase/Hit.h" @@ -126,9 +125,6 @@ class BasicHitAnalysis : virtual public IHitHistogramTool TH2D* fSPPHvsWid[3]; TH2D* fSOPHvsWid[3]; TH2D* fPHRatVsIdx[3]; - - // Useful services, keep copies for now (we can update during begin run periods) - const geo::GeometryCore* fGeometry; ///< pointer to Geometry service }; //---------------------------------------------------------------------------- @@ -140,8 +136,6 @@ class BasicHitAnalysis : virtual public IHitHistogramTool /// BasicHitAnalysis::BasicHitAnalysis(fhicl::ParameterSet const & pset) { - fGeometry = lar::providerFrom(); - configure(pset); // Report. @@ -172,12 +166,13 @@ void BasicHitAnalysis::initializeHists(art::ServiceHandle& tf // Make a directory for these histograms art::TFileDirectory dir = tfs->mkdir(dirName.c_str()); - fHitsByWire.resize(fGeometry->Nplanes()); + auto const& wireReadout = art::ServiceHandle()->Get(); + fHitsByWire.resize(wireReadout.Nplanes()); constexpr geo::TPCID tpcid{0, 0}; - auto const n_wires_0 = fGeometry->Nwires(geo::PlaneID{tpcid, 0}); - auto const n_wires_1 = fGeometry->Nwires(geo::PlaneID{tpcid, 1}); - auto const n_wires_2 = fGeometry->Nwires(geo::PlaneID{tpcid, 2}); + auto const n_wires_0 = wireReadout.Nwires(geo::PlaneID{tpcid, 0}); + auto const n_wires_1 = wireReadout.Nwires(geo::PlaneID{tpcid, 1}); + auto const n_wires_2 = wireReadout.Nwires(geo::PlaneID{tpcid, 2}); fHitsByWire[0] = dir.make("HitsByWire0", ";Wire #", n_wires_0, 0., n_wires_0); fHitsByWire[1] = dir.make("HitsByWire1", ";Wire #", n_wires_1, 0., n_wires_1); fHitsByWire[2] = dir.make("HitsByWire2", ";Wire #", n_wires_2, 0., n_wires_2); diff --git a/icaruscode/Analysis/tools/BasicRawDigitAnalysis_tool.cc b/icaruscode/Analysis/tools/BasicRawDigitAnalysis_tool.cc index 94f50c4cb..23d8026d6 100755 --- a/icaruscode/Analysis/tools/BasicRawDigitAnalysis_tool.cc +++ b/icaruscode/Analysis/tools/BasicRawDigitAnalysis_tool.cc @@ -9,8 +9,7 @@ #include "art_root_io/TFileDirectory.h" #include "messagefacility/MessageLogger/MessageLogger.h" -#include "larcore/Geometry/Geometry.h" -#include "larcore/CoreUtils/ServiceUtil.h" // lar::providerFrom() +#include "larcore/Geometry/WireReadout.h" #include "icaruscode/TPC/Utilities/SignalShapingICARUSService_service.h" #include "lardataalg/DetectorInfo/DetectorClocks.h" #include "lardata/DetectorInfoServices/DetectorPropertiesService.h" @@ -137,7 +136,7 @@ class BasicRawDigitAnalysis : virtual public IRawDigitHistogramTool FFTPointer fFFT; //< Object to handle thread safe FFT // Useful services, keep copies for now (we can update during begin run periods) - const geo::GeometryCore& fGeometry; ///< pointer to Geometry service + const geo::WireReadoutGeom& fChannelMapAlg; ///< pointer to ChannelMapAlg icarusutil::SignalShapingICARUSService& fSignalServices; ///< The signal shaping service const lariov::DetPedestalProvider& fPedestalRetrievalAlg; ///< Keep track of an instance to the pedestal retrieval alg }; @@ -151,7 +150,7 @@ class BasicRawDigitAnalysis : virtual public IRawDigitHistogramTool /// BasicRawDigitAnalysis::BasicRawDigitAnalysis(fhicl::ParameterSet const & pset) : fCharacterizationAlg(pset.get("CharacterizationAlg")), - fGeometry(*lar::providerFrom()), + fChannelMapAlg(art::ServiceHandle()->Get()), fSignalServices(*art::ServiceHandle()), fPedestalRetrievalAlg(*lar::providerFrom()) { @@ -227,7 +226,7 @@ void BasicRawDigitAnalysis::initializeHists(detinfo::DetectorClocksData const& c fAveFFTImaginaryVec.resize(3); fAveSmoothPowerVec.resize(3); - for(size_t plane = 0; plane < fGeometry.Nplanes(); plane++) + for(size_t plane = 0; plane < fChannelMapAlg.Nplanes(); plane++) { size_t numHists = fHiWireByPlane[plane] - fLoWireByPlane[plane]; @@ -305,7 +304,7 @@ void BasicRawDigitAnalysis::initializeHists(detinfo::DetectorClocksData const& c fFullRmsHist[plane] = dir.make(histName.c_str(), ";ADC", 100, 0., 20.); // Need a channel... - raw::ChannelID_t channel = fGeometry.PlaneWireToChannel(geo::WireID(0, 0, plane, 0)); + raw::ChannelID_t channel = fChannelMapAlg.PlaneWireToChannel(geo::WireID(0, 0, plane, 0)); // Recover the filter from signal shaping services... const icarusutil::FrequencyVec& response = fSignalServices.GetResponse(channel).getConvKernel(); @@ -381,7 +380,7 @@ void BasicRawDigitAnalysis::fillHistograms(const detinfo::DetectorClocksData& cl // Decode the channel and make sure we have a valid one std::vector wids; try { - wids = fGeometry.ChannelToWire(channel); + wids = fChannelMapAlg.ChannelToWire(channel); } catch(...) { @@ -570,7 +569,7 @@ void BasicRawDigitAnalysis::endJob(int numEvents) // A task to complete is to fit the average power displays with aim to develop a "good" filter function and // get the signal to noise ratio - for(size_t planeIdx = 0; planeIdx < fGeometry.Nplanes(); planeIdx++) + for(size_t planeIdx = 0; planeIdx < fChannelMapAlg.Nplanes(); planeIdx++) { TH1* avePowerHist = fAveFFTPowerVec[planeIdx]; diff --git a/icaruscode/Analysis/tools/BasicTrackAnalysis_tool.cc b/icaruscode/Analysis/tools/BasicTrackAnalysis_tool.cc index bff20a612..5c46df8cb 100755 --- a/icaruscode/Analysis/tools/BasicTrackAnalysis_tool.cc +++ b/icaruscode/Analysis/tools/BasicTrackAnalysis_tool.cc @@ -10,8 +10,7 @@ #include "messagefacility/MessageLogger/MessageLogger.h" #include "canvas/Persistency/Common/FindManyP.h" -#include "larcore/Geometry/Geometry.h" -#include "larcore/CoreUtils/ServiceUtil.h" // lar::providerFrom() +#include "larcore/Geometry/WireReadout.h" #include "lardataobj/RecoBase/Hit.h" @@ -96,8 +95,6 @@ class BasicTrackAnalysis : virtual public ITrackHistogramTool TH2D* fPulseHVsWidth[3]; TProfile* fPulseHVsHitNo[3]; - // Useful services, keep copies for now (we can update during begin run periods) - const geo::GeometryCore* fGeometry; ///< pointer to Geometry service }; //---------------------------------------------------------------------------- @@ -109,8 +106,6 @@ class BasicTrackAnalysis : virtual public ITrackHistogramTool /// BasicTrackAnalysis::BasicTrackAnalysis(fhicl::ParameterSet const & pset) { - fGeometry = lar::providerFrom(); - configure(pset); // Report. @@ -142,9 +137,10 @@ void BasicTrackAnalysis::initializeHists(art::ServiceHandle& // Make a directory for these histograms art::TFileDirectory dir = tfs->mkdir(dirName.c_str()); - auto const n_wires_0 = fGeometry->Nwires(geo::PlaneID{0, 0, 0}); - auto const n_wires_1 = fGeometry->Nwires(geo::PlaneID{0, 0, 1}); - auto const n_wires_2 = fGeometry->Nwires(geo::PlaneID{0, 0, 2}); + auto const& wireReadout = art::ServiceHandle()->Get(); + auto const n_wires_0 = wireReadout.Nwires(geo::PlaneID{0, 0, 0}); + auto const n_wires_1 = wireReadout.Nwires(geo::PlaneID{0, 0, 1}); + auto const n_wires_2 = wireReadout.Nwires(geo::PlaneID{0, 0, 2}); fHitsByWire[0] = dir.make("HitsByWire0", ";Wire #", n_wires_0, 0., n_wires_0); fHitsByWire[1] = dir.make("HitsByWire1", ";Wire #", n_wires_1, 0., n_wires_1); fHitsByWire[2] = dir.make("HitsByWire2", ";Wire #", n_wires_2, 0., n_wires_2); diff --git a/icaruscode/Analysis/tools/BasicWireAnalysis_tool.cc b/icaruscode/Analysis/tools/BasicWireAnalysis_tool.cc index 98b364755..1e986f922 100755 --- a/icaruscode/Analysis/tools/BasicWireAnalysis_tool.cc +++ b/icaruscode/Analysis/tools/BasicWireAnalysis_tool.cc @@ -9,8 +9,7 @@ #include "art_root_io/TFileDirectory.h" #include "messagefacility/MessageLogger/MessageLogger.h" -#include "larcore/Geometry/Geometry.h" -#include "larcore/CoreUtils/ServiceUtil.h" // lar::providerFrom() +#include "larcore/Geometry/WireReadout.h" #include "larevt/CalibrationDBI/Interface/DetPedestalService.h" #include "larevt/CalibrationDBI/Interface/DetPedestalProvider.h" #include "larreco/HitFinder/HitFinderTools/IWaveformTool.h" @@ -150,7 +149,7 @@ class BasicWireAnalysis : virtual public IWireHistogramTool art::TFileDirectory* fHistDirectory; // Useful services, keep copies for now (we can update during begin run periods) - const geo::GeometryCore& fGeometry; ///< pointer to Geometry service + const geo::WireReadoutGeom& fChannelMapAlg; icarusutil::SignalShapingICARUSService& fSignalServices; ///< The signal shaping service const lariov::DetPedestalProvider& fPedestalRetrievalAlg; ///< Keep track of an instance to the pedestal retrieval alg }; @@ -163,7 +162,7 @@ class BasicWireAnalysis : virtual public IWireHistogramTool /// pset - Fcl parameters. /// BasicWireAnalysis::BasicWireAnalysis(fhicl::ParameterSet const & pset) : - fGeometry(*lar::providerFrom()), + fChannelMapAlg(art::ServiceHandle()->Get()), fSignalServices(*art::ServiceHandle()), fPedestalRetrievalAlg(*lar::providerFrom()) { @@ -222,7 +221,7 @@ void BasicWireAnalysis::initializeHists(art::ServiceHandle& t fDeltaTicksHist.resize(3); fRangeHist.resize(3); - for(size_t plane = 0; plane < fGeometry.Nplanes(); plane++) + for(size_t plane = 0; plane < fChannelMapAlg.Nplanes(); plane++) { std::string histName = "TruncMean_" + std::to_string(plane); @@ -272,7 +271,7 @@ void BasicWireAnalysis::fillHistograms(const IWireHistogramTool::WirePtrVec& raw::ChannelID_t channel = wire->Channel(); // Try to limit to the wire number (since we are already segregated by plane) - std::vector wids = fGeometry.ChannelToWire(channel); + std::vector wids = fChannelMapAlg.ChannelToWire(channel); size_t cryo = wids[0].Cryostat; size_t tpc = wids[0].TPC; size_t plane = wids[0].Plane; diff --git a/icaruscode/Analysis/tools/HitEfficiencyAnalysis_tool.cc b/icaruscode/Analysis/tools/HitEfficiencyAnalysis_tool.cc index 8f133cee7..c6e344e37 100755 --- a/icaruscode/Analysis/tools/HitEfficiencyAnalysis_tool.cc +++ b/icaruscode/Analysis/tools/HitEfficiencyAnalysis_tool.cc @@ -10,6 +10,7 @@ #include "lardata/DetectorInfoServices/DetectorClocksService.h" #include "canvas/Persistency/Common/FindManyP.h" +#include "larcore/Geometry/WireReadout.h" #include "larcore/Geometry/Geometry.h" #include "larcore/CoreUtils/ServiceUtil.h" // lar::providerFrom() @@ -156,7 +157,7 @@ class HitEfficiencyAnalysis : virtual public IHitEfficiencyHistogramTool mutable std::vector fHitStopTickVec; // Useful services, keep copies for now (we can update during begin run periods) - const geo::GeometryCore* fGeometry; ///< pointer to Geometry service + const geo::WireReadoutGeom* fChannelMapAlg; }; //---------------------------------------------------------------------------- @@ -168,7 +169,7 @@ class HitEfficiencyAnalysis : virtual public IHitEfficiencyHistogramTool /// HitEfficiencyAnalysis::HitEfficiencyAnalysis(fhicl::ParameterSet const & pset) : fTree(nullptr) { - fGeometry = lar::providerFrom(); + fChannelMapAlg = &art::ServiceHandle()->Get(); configure(pset); @@ -206,28 +207,29 @@ void HitEfficiencyAnalysis::initializeHists(art::ServiceHandlemkdir(dirName.c_str()); - fTotalElectronsHistVec.resize(fGeometry->Nplanes()); - fMaxElectronsHistVec.resize(fGeometry->Nplanes()); - fHitElectronsVec.resize(fGeometry->Nplanes()); - fHitSumADCVec.resize(fGeometry->Nplanes()); - fHitPulseHeightVec.resize(fGeometry->Nplanes()); - fHitPulseWidthVec.resize(fGeometry->Nplanes()); - fSimNumTDCVec.resize(fGeometry->Nplanes()); - fHitNumTDCVec.resize(fGeometry->Nplanes()); - fNMatchedHitVec.resize(fGeometry->Nplanes()); - fDeltaMidTDCVec.resize(fGeometry->Nplanes()); - fHitVsSimChgVec.resize(fGeometry->Nplanes()); - fNSimChannelHitsVec.resize(fGeometry->Nplanes()); - fNRecobHitVec.resize(fGeometry->Nplanes()); - fHitEfficiencyVec.resize(fGeometry->Nplanes()); + auto const num_planes = fChannelMapAlg->Nplanes(); + fTotalElectronsHistVec.resize(num_planes); + fMaxElectronsHistVec.resize(num_planes); + fHitElectronsVec.resize(num_planes); + fHitSumADCVec.resize(num_planes); + fHitPulseHeightVec.resize(num_planes); + fHitPulseWidthVec.resize(num_planes); + fSimNumTDCVec.resize(num_planes); + fHitNumTDCVec.resize(num_planes); + fNMatchedHitVec.resize(num_planes); + fDeltaMidTDCVec.resize(num_planes); + fHitVsSimChgVec.resize(num_planes); + fNSimChannelHitsVec.resize(num_planes); + fNRecobHitVec.resize(num_planes); + fHitEfficiencyVec.resize(num_planes); - fWireEfficVec.resize(fGeometry->Nplanes()); - fWireEfficPHVec.resize(fGeometry->Nplanes()); + fWireEfficVec.resize(num_planes); + fWireEfficPHVec.resize(num_planes); - fHitEfficVec.resize(fGeometry->Nplanes()); - fHitEfficPHVec.resize(fGeometry->Nplanes()); + fHitEfficVec.resize(num_planes); + fHitEfficPHVec.resize(num_planes); - for(size_t plane = 0; plane < fGeometry->Nplanes(); plane++) + for(size_t plane = 0; plane < num_planes; plane++) { fTotalElectronsHistVec.at(plane) = dir.make(("TotalElecs" + std::to_string(plane)).c_str(), ";# electrons", 250, 0., 100000.); fMaxElectronsHistVec.at(plane) = dir.make(("MaxElecs" + std::to_string(plane)).c_str(), ";# electrons", 250, 0., 20000.); @@ -411,7 +413,7 @@ void HitEfficiencyAnalysis::fillHistograms(const art::Event& event) const // The below try-catch block may no longer be necessary // Decode the channel and make sure we have a valid one - std::vector wids = fGeometry->ChannelToWire(chanToTDCToIDEMap.first); + std::vector wids = fChannelMapAlg->ChannelToWire(chanToTDCToIDEMap.first); // Recover plane and wire in the plane unsigned int plane = wids[0].Plane; @@ -607,7 +609,7 @@ void HitEfficiencyAnalysis::fillHistograms(const art::Event& event) const } } - for(size_t idx = 0; idx < fGeometry->Nplanes();idx++) + for(size_t idx = 0; idx < fChannelMapAlg->Nplanes();idx++) { if (nSimChannelHitVec.at(idx) > 10) { diff --git a/icaruscode/Analysis/tools/HitFinderAnalysis_tool.cc b/icaruscode/Analysis/tools/HitFinderAnalysis_tool.cc index 297c3abc0..c33d5f314 100755 --- a/icaruscode/Analysis/tools/HitFinderAnalysis_tool.cc +++ b/icaruscode/Analysis/tools/HitFinderAnalysis_tool.cc @@ -9,6 +9,7 @@ #include "messagefacility/MessageLogger/MessageLogger.h" #include "lardata/DetectorInfoServices/DetectorClocksService.h" +#include "larcore/Geometry/WireReadout.h" #include "larcore/Geometry/Geometry.h" #include "larcore/CoreUtils/ServiceUtil.h" // lar::providerFrom() #include "larevt/CalibrationDBI/Interface/ChannelStatusService.h" @@ -185,6 +186,7 @@ class HitFinderAnalysis : virtual public IHitEfficiencyHistogramTool // Useful services, keep copies for now (we can update during begin run periods) const geo::GeometryCore* fGeometry; ///< pointer to Geometry service + const geo::WireReadoutGeom* fChannelMapAlg; }; //---------------------------------------------------------------------------- @@ -197,6 +199,7 @@ class HitFinderAnalysis : virtual public IHitEfficiencyHistogramTool HitFinderAnalysis::HitFinderAnalysis(fhicl::ParameterSet const & pset) : fTree(nullptr) { fGeometry = lar::providerFrom(); + fChannelMapAlg = &art::ServiceHandle()->Get(); configure(pset); @@ -238,38 +241,39 @@ void HitFinderAnalysis::initializeHists(art::ServiceHandle& t // Make a directory for these histograms art::TFileDirectory dir = tfs->mkdir(dirName.c_str()); - fTotalElectronsHistVec.resize(fGeometry->Nplanes()); - fMaxElectronsHistVec.resize(fGeometry->Nplanes()); - fHitElectronsVec.resize(fGeometry->Nplanes()); - fHitSumADCVec.resize(fGeometry->Nplanes()); - fHitIntegralHistVec.resize(fGeometry->Nplanes()); - fHitPulseHeightVec.resize(fGeometry->Nplanes()); - fHitPulseWidthVec.resize(fGeometry->Nplanes()); - fSimNumTDCVec.resize(fGeometry->Nplanes()); - fHitNumTDCVec.resize(fGeometry->Nplanes()); - fSnippetLenVec.resize(fGeometry->Nplanes()); - fNMatchedHitVec.resize(fGeometry->Nplanes()); - fDeltaMidTDCVec.resize(fGeometry->Nplanes()); - fHitVsSimChgVec.resize(fGeometry->Nplanes()); - fHitVsSimIntVec.resize(fGeometry->Nplanes()); - fCosXZvRMSVec.resize(fGeometry->Nplanes()); - fToteVHitEIntVec.resize(fGeometry->Nplanes()); - fHitENEvXZVec.resize(fGeometry->Nplanes()); - fNSimChannelHitsVec.resize(fGeometry->Nplanes()); - fNRecobHitVec.resize(fGeometry->Nplanes()); - fHitEfficiencyVec.resize(fGeometry->Nplanes()); - fSimDivHitChgVec.resize(fGeometry->Nplanes()); - fSimDivHitChg1Vec.resize(fGeometry->Nplanes()); - - fWireEfficVec.resize(fGeometry->Nplanes()); - fWireEfficPHVec.resize(fGeometry->Nplanes()); - - fHitEfficVec.resize(fGeometry->Nplanes()); - fHitEfficPHVec.resize(fGeometry->Nplanes()); - fHitEfficXZVec.resize(fGeometry->Nplanes()); - fHitEfficRMSVec.resize(fGeometry->Nplanes()); - - for(size_t plane = 0; plane < fGeometry->Nplanes(); plane++) + auto const num_planes = fChannelMapAlg->Nplanes(); + fTotalElectronsHistVec.resize(num_planes); + fMaxElectronsHistVec.resize(num_planes); + fHitElectronsVec.resize(num_planes); + fHitSumADCVec.resize(num_planes); + fHitIntegralHistVec.resize(num_planes); + fHitPulseHeightVec.resize(num_planes); + fHitPulseWidthVec.resize(num_planes); + fSimNumTDCVec.resize(num_planes); + fHitNumTDCVec.resize(num_planes); + fSnippetLenVec.resize(num_planes); + fNMatchedHitVec.resize(num_planes); + fDeltaMidTDCVec.resize(num_planes); + fHitVsSimChgVec.resize(num_planes); + fHitVsSimIntVec.resize(num_planes); + fCosXZvRMSVec.resize(num_planes); + fToteVHitEIntVec.resize(num_planes); + fHitENEvXZVec.resize(num_planes); + fNSimChannelHitsVec.resize(num_planes); + fNRecobHitVec.resize(num_planes); + fHitEfficiencyVec.resize(num_planes); + fSimDivHitChgVec.resize(num_planes); + fSimDivHitChg1Vec.resize(num_planes); + + fWireEfficVec.resize(num_planes); + fWireEfficPHVec.resize(num_planes); + + fHitEfficVec.resize(num_planes); + fHitEfficPHVec.resize(num_planes); + fHitEfficXZVec.resize(num_planes); + fHitEfficRMSVec.resize(num_planes); + + for(size_t plane = 0; plane < num_planes; plane++) { fTotalElectronsHistVec.at(plane) = dir.make(("TotalElecs" + std::to_string(plane)).c_str(), ";Total # electrons", 250, 0., 100000.); fMaxElectronsHistVec.at(plane) = dir.make(("MaxElecs" + std::to_string(plane)).c_str(), ";Max # electrons", 250, 0., 20000.); @@ -551,7 +555,7 @@ void HitFinderAnalysis::fillHistograms(const art::Event& event) const // The below try-catch block may no longer be necessary // Decode the channel and make sure we have a valid one - std::vector wids = fGeometry->ChannelToWire(chanToTDCToIDEMap.first); + std::vector wids = fChannelMapAlg->ChannelToWire(chanToTDCToIDEMap.first); // Recover plane and wire in the plane unsigned int plane = wids[0].Plane; @@ -807,7 +811,7 @@ void HitFinderAnalysis::fillHistograms(const art::Event& event) const } } - for(size_t idx = 0; idx < fGeometry->Nplanes();idx++) + for(size_t idx = 0; idx < fChannelMapAlg->Nplanes();idx++) { if (nSimChannelHitVec[idx] > 10) { diff --git a/icaruscode/Analysis/tools/SpacePointAnalysisMC_tool.cc b/icaruscode/Analysis/tools/SpacePointAnalysisMC_tool.cc index fa324e578..f15a174c3 100644 --- a/icaruscode/Analysis/tools/SpacePointAnalysisMC_tool.cc +++ b/icaruscode/Analysis/tools/SpacePointAnalysisMC_tool.cc @@ -10,8 +10,7 @@ #include "lardata/DetectorInfoServices/DetectorClocksService.h" #include "canvas/Persistency/Common/FindManyP.h" -#include "larcore/Geometry/Geometry.h" -#include "larcore/CoreUtils/ServiceUtil.h" // lar::providerFrom() +#include "larcore/Geometry/WireReadout.h" #include "lardata/DetectorInfoServices/DetectorClocksService.h" #include "larevt/CalibrationDBI/Interface/ChannelStatusService.h" #include "larevt/CalibrationDBI/Interface/ChannelStatusProvider.h" @@ -429,7 +428,7 @@ class SpacePointAnalysisMC : virtual public IHitEfficiencyHistogramTool mutable HitSpacePointObj fHitSpacePointObj; // Useful services, keep copies for now (we can update during begin run periods) - const geo::GeometryCore* fGeometry; ///< pointer to Geometry service + const geo::WireReadoutGeom* fChannelMapAlg; }; //---------------------------------------------------------------------------- @@ -441,7 +440,7 @@ class SpacePointAnalysisMC : virtual public IHitEfficiencyHistogramTool /// SpacePointAnalysisMC::SpacePointAnalysisMC(fhicl::ParameterSet const & pset) : fTree(nullptr) { - fGeometry = lar::providerFrom(); + fChannelMapAlg = &art::ServiceHandle()->Get(); configure(pset); @@ -502,9 +501,9 @@ void SpacePointAnalysisMC::initializeTuple(TTree* tree) fHitSpacePointObj.setBranches(locTree); - fHitSimObjVec.resize(fGeometry->Nplanes()); + fHitSimObjVec.resize(fChannelMapAlg->Nplanes()); - for(size_t plane = 0; plane < fGeometry->Nplanes(); plane++) + for(size_t plane = 0; plane < fChannelMapAlg->Nplanes(); plane++) { // Set up specific branch for space points locTree = tfs->makeAndRegister("MatchedHits_P"+std::to_string(plane),"Matched Hits Tuple plane "+std::to_string(plane)); @@ -571,7 +570,7 @@ void SpacePointAnalysisMC::fillHistograms(const art::Event& event) const { raw::ChannelID_t channel = simChannel.Channel(); - geo::WireID wireID = fGeometry->ChannelToWire(channel).front(); + geo::WireID wireID = fChannelMapAlg->ChannelToWire(channel).front(); for(const auto& tdcide : simChannel.TDCIDEMap()) { diff --git a/icaruscode/Analysis/tools/SpacePointAnalysis_tool.cc b/icaruscode/Analysis/tools/SpacePointAnalysis_tool.cc index 3b8cd615b..f26b11b47 100644 --- a/icaruscode/Analysis/tools/SpacePointAnalysis_tool.cc +++ b/icaruscode/Analysis/tools/SpacePointAnalysis_tool.cc @@ -11,6 +11,7 @@ #include "canvas/Persistency/Common/FindManyP.h" #include "canvas/Persistency/Common/FindOneP.h" +#include "larcore/Geometry/WireReadout.h" #include "larcore/Geometry/Geometry.h" #include "larcore/CoreUtils/ServiceUtil.h" // lar::providerFrom() #include "lardata/DetectorInfoServices/DetectorClocksService.h" @@ -342,6 +343,7 @@ class SpacePointAnalysis : virtual public IHitEfficiencyHistogramTool // Useful services, keep copies for now (we can update during begin run periods) const geo::GeometryCore* fGeometry; ///< pointer to Geometry service + const geo::WireReadoutGeom* fChannelMap; }; //---------------------------------------------------------------------------- @@ -354,6 +356,7 @@ class SpacePointAnalysis : virtual public IHitEfficiencyHistogramTool SpacePointAnalysis::SpacePointAnalysis(fhicl::ParameterSet const & pset) : fTree(nullptr) { fGeometry = lar::providerFrom(); + fChannelMap = &art::ServiceHandle()->Get(); configure(pset); @@ -408,9 +411,9 @@ void SpacePointAnalysis::initializeTuple(TTree* tree) fHitSpacePointObj.setBranches(locTree); - fHitTupleObjVec.resize(fGeometry->Nplanes()); + fHitTupleObjVec.resize(fChannelMap->Nplanes()); - for(size_t plane = 0; plane < fGeometry->Nplanes(); plane++) + for(size_t plane = 0; plane < fChannelMap->Nplanes(); plane++) { // Set up specific branch for space points locTree = tfs->makeAndRegister("MatchedHits_P"+std::to_string(plane),"Matched Hits Tuple plane "+std::to_string(plane)); @@ -472,7 +475,7 @@ void SpacePointAnalysis::processSpacePoints(const art::Event& e { for(size_t tpcIdx = 0; tpcIdx < fGeometry->NTPC(); tpcIdx++) { - for(size_t planeIdx = 0; planeIdx < fGeometry->Nplanes(); planeIdx++) + for(size_t planeIdx = 0; planeIdx < fChannelMap->Nplanes(); planeIdx++) { geo::PlaneID planeID(cryoIdx,tpcIdx,planeIdx); diff --git a/icaruscode/Analysis/tools/TrackHitEfficiencyAnalysis_tool.cc b/icaruscode/Analysis/tools/TrackHitEfficiencyAnalysis_tool.cc index 3cff4901e..a6840f8eb 100755 --- a/icaruscode/Analysis/tools/TrackHitEfficiencyAnalysis_tool.cc +++ b/icaruscode/Analysis/tools/TrackHitEfficiencyAnalysis_tool.cc @@ -8,6 +8,7 @@ #include "art_root_io/TFileDirectory.h" #include "messagefacility/MessageLogger/MessageLogger.h" +#include "larcore/Geometry/WireReadout.h" #include "larcore/Geometry/Geometry.h" #include "larcore/CoreUtils/ServiceUtil.h" // lar::providerFrom() #include "lardata/DetectorInfoServices/DetectorClocksService.h" @@ -53,7 +54,7 @@ namespace TrackHitEfficiencyAnalysis // Created by Tracy Usher (usher@slac.stanford.edu) on February 19, 2016 // //////////////////////////////////////////////////////////////////////// - + // The following typedefs will, obviously, be useful using HitPtrVec = std::vector>; using ViewHitMap = std::map; @@ -68,12 +69,12 @@ class TrackHitEfficiencyAnalysis : virtual public IHitEfficiencyHistogramTool * @param pset */ explicit TrackHitEfficiencyAnalysis(fhicl::ParameterSet const & pset); - + /** * @brief Destructor */ ~TrackHitEfficiencyAnalysis(); - + // provide for initialization void configure(fhicl::ParameterSet const & pset) override; @@ -98,17 +99,17 @@ class TrackHitEfficiencyAnalysis : virtual public IHitEfficiencyHistogramTool * @param int number of events to use for normalization */ void endJob(int numEvents) override; - + /** * @brief Interface for filling histograms */ void fillHistograms(const art::Event&) const override; - + private: - + // Clear mutable variables void clear() const; - + // Fcl parameters. std::vector fRawDigitProducerLabelVec; std::vector fWireProducerLabelVec; @@ -127,12 +128,12 @@ class TrackHitEfficiencyAnalysis : virtual public IHitEfficiencyHistogramTool // TTree variables mutable TTree* fTree; - + mutable std::vector fTPCVec; mutable std::vector fCryoVec; mutable std::vector fPlaneVec; mutable std::vector fWireVec; - + mutable std::vector fTotalElectronsVec; mutable std::vector fMaxElectronsVec; mutable std::vector fmaxElectronsTickVec; @@ -156,7 +157,7 @@ class TrackHitEfficiencyAnalysis : virtual public IHitEfficiencyHistogramTool mutable std::vector fROIMaxTickVec; mutable std::vector fROILenVec; mutable std::vector fROIDeltaTVec; - + mutable std::vector fHitPeakTimeVec; mutable std::vector fHitPeakAmpVec; mutable std::vector fHitPeakRMSVec; @@ -189,8 +190,9 @@ class TrackHitEfficiencyAnalysis : virtual public IHitEfficiencyHistogramTool // Useful services, keep copies for now (we can update during begin run periods) const geo::GeometryCore* fGeometry; ///< pointer to Geometry service + const geo::WireReadoutGeom* fWireReadout; }; - + //---------------------------------------------------------------------------- /// Constructor. /// @@ -201,9 +203,9 @@ class TrackHitEfficiencyAnalysis : virtual public IHitEfficiencyHistogramTool TrackHitEfficiencyAnalysis::TrackHitEfficiencyAnalysis(fhicl::ParameterSet const & pset) : fTree(nullptr) { fGeometry = lar::providerFrom(); - + fWireReadout = &art::ServiceHandle()->Get(); configure(pset); - + // Report. mf::LogInfo("TrackHitEfficiencyAnalysis") << "TrackHitEfficiencyAnalysis configured\n"; } @@ -247,19 +249,19 @@ void TrackHitEfficiencyAnalysis::initializeHists(art::ServiceHandlemkdir(dirName.c_str()); - + return; } - + void TrackHitEfficiencyAnalysis::initializeTuple(TTree* tree) { fTree = tree; - + fTree->Branch("CryostataVec", "std::vector", &fCryoVec); fTree->Branch("TPCVec", "std::vector", &fTPCVec); fTree->Branch("PlaneVec", "std::vector", &fPlaneVec); fTree->Branch("WireVec", "std::vector", &fWireVec); - + fTree->Branch("TotalElectronsVec", "std::vector", &fTotalElectronsVec); fTree->Branch("MaxElectronsVec", "std::vector", &fMaxElectronsVec); fTree->Branch("StartTick", "std::vector", &fStartTickVec); @@ -270,7 +272,7 @@ void TrackHitEfficiencyAnalysis::initializeTuple(TTree* tree) fTree->Branch("PartDirY", "std::vector", &fPartDirY); fTree->Branch("PartDirZ", "std::vector", &fPartDirZ); fTree->Branch("CosThetaXZ", "std::vector", &fCosThetaXZVec); - + fTree->Branch("NMatchedWires", "std::vector", &fNMatchedWires); fTree->Branch("NMatchedHits", "std::vector", &fNMatchedHits); fTree->Branch("NMatchedTHits", "std::vector", &fNMatchedTHits); @@ -318,7 +320,7 @@ void TrackHitEfficiencyAnalysis::initializeTuple(TTree* tree) return; } - + void TrackHitEfficiencyAnalysis::clear() const { fTPCVec.clear(); @@ -340,7 +342,7 @@ void TrackHitEfficiencyAnalysis::clear() const fRawDigitPulseHeightVec.clear(); fRawDigitMaxTickVec.clear(); fRawDigitMinTickVec.clear(); - + fNMatchedWires.clear(); fNMatchedHits.clear(); fNMatchedTHits.clear(); @@ -389,7 +391,7 @@ void TrackHitEfficiencyAnalysis::fillHistograms(const art::Event& event) const // Basic assumption is that the producer label vecs for RawDigits and Wire data are // all the same length and in the same order. Here we just check for length if (fRawDigitProducerLabelVec.size() != fWireProducerLabelVec.size()) return; - + // Always clear the tuple clear(); @@ -397,24 +399,24 @@ void TrackHitEfficiencyAnalysis::fillHistograms(const art::Event& event) const art::Handle< std::vector> simChannelHandle; event.getByLabel(fSimChannelProducerLabel, simChannelHandle); - + art::Handle< std::vector> mcParticleHandle; event.getByLabel(fMCParticleProducerLabel, mcParticleHandle); // If there is no sim channel informaton then exit if (!simChannelHandle.isValid() || simChannelHandle->empty() || !mcParticleHandle.isValid()) return; - + // what needs to be done? // First we define a straightforward channel to Wire map so we can look up a given // channel's Wire data as we loop over SimChannels. using ChanToWireMap = std::unordered_map; - + ChanToWireMap channelToWireMap; - + // We will use the presence of a RawDigit as an indicator of a good channel... So // we want a mapping between channel and RawDigit using ChanToRawDigitMap = std::unordered_map; - + ChanToRawDigitMap chanToRawDigitMap; // Now start a loop over the individual TPCs to build out the structures for RawDigits and Wires @@ -427,17 +429,17 @@ void TrackHitEfficiencyAnalysis::fillHistograms(const art::Event& event) const event.getByLabel(fWireProducerLabelVec[tpcID], wireHandle); if (!rawDigitHandle.isValid() || !wireHandle.isValid()) return; - + for(const auto& wire : *wireHandle) channelToWireMap[wire.Channel()] = &wire; - + for(const auto& rawDigit : *rawDigitHandle) chanToRawDigitMap[rawDigit.Channel()] = &rawDigit; } - + // Now we create a data structure to relate hits to their channel ID using ChanToHitVecMap = std::unordered_map>; - + ChanToHitVecMap channelToHitVec; - + // And now fill it for(const auto& hitLabel : fHitProducerLabelVec) { @@ -460,22 +462,22 @@ void TrackHitEfficiencyAnalysis::fillHistograms(const art::Event& event) const // It is useful to create a mapping between trackID and MCParticle using TrackIDToMCParticleMap = std::unordered_map; - + TrackIDToMCParticleMap trackIDToMCParticleMap; - + for(const auto& mcParticle : *mcParticleHandle) trackIDToMCParticleMap[mcParticle.TrackId()] = &mcParticle; - + std::vector nSimChannelHitVec = {0,0,0}; std::vector nRecobHitVec = {0,0,0}; std::vector nFakeHitVec = {0,0,0}; std::vector nSimulatedWiresVec = {0,0,0}; - + unsigned int lastwire=-1; - + auto const clockData = art::ServiceHandle()->DataFor(event); - + // const lariov::ChannelStatusProvider& chanFilt = art::ServiceHandle()->GetProvider(); - + // There are several things going on here... for each channel we have particles (track id's) depositing energy in a range to ticks // So... for each channel we want to build a structure that relates particles to tdc ranges and deposited energy (or electrons) // Here is a complicated structure: @@ -483,13 +485,13 @@ void TrackHitEfficiencyAnalysis::fillHistograms(const art::Event& event) const using ChanToTDCIDEMap = std::unordered_map; using PartToChanToTDCToIDEMap = std::unordered_map; using ChannelToSimChannelMap = std::unordered_map; - + PartToChanToTDCToIDEMap partToChanToTDCToIDEMap; ChannelToSimChannelMap channelToSimChannelMap; using StartStopChargeTuple = std::tuple; // start, stop, total charge using StartStopChargeTupleMap = std::map; // reference by track id - + // Build out the above data structure for(const auto& simChannel : *simChannelHandle) { @@ -526,14 +528,14 @@ void TrackHitEfficiencyAnalysis::fillHistograms(const art::Event& event) const short curTDC = tdcIdeItr->first; - // If there is a gap to the last TDC then we process those values + // If there is a gap to the last TDC then we process those values // (we'll then re-enter this loop looking for the next set) if (curTDC - stopItr->first > 7) break; float electronsThisTDC(0.); float maxElectronsByTrackID(0.); - for(const auto& ide : tdcIdeItr->second) + for(const auto& ide : tdcIdeItr->second) { electronsThisTDC += ide.numElectrons; @@ -623,12 +625,12 @@ void TrackHitEfficiencyAnalysis::fillHistograms(const art::Event& event) const // Make sure normalized partAveDir.normalize(); - + float cosThetaXZ = partAveDir[0]; // The below try-catch block may no longer be necessary // Decode the channel and make sure we have a valid one - std::vector wids = fGeometry->ChannelToWire(channel); + std::vector wids = fWireReadout->ChannelToWire(channel); // Recover plane and wire in the plane unsigned int plane = wids[0].Plane; @@ -656,13 +658,13 @@ void TrackHitEfficiencyAnalysis::fillHistograms(const art::Event& event) const stopTick += fOffsetVec[plane]; maxElectronsTick += fOffsetVec[plane]; -// std::cout << " --> startTick/stopTick/maxElectronsTick: " << startTick << "/" << stopTick << "/" << maxElectronsTick +// std::cout << " --> startTick/stopTick/maxElectronsTick: " << startTick << "/" << stopTick << "/" << maxElectronsTick // << " which is from TDC values: " << startItr->first << "/" << stopItr->first << "/" << maxElectronsItr->first << std::endl; - // Apparently it can happen that we have a start tick that exceeds the length of the input waveform. + // Apparently it can happen that we have a start tick that exceeds the length of the input waveform. // We should also make cuts at edges of readout so we don't have distorted waveforms // When this happens skip - if (startTick > 10 && stopTick < 4085) + if (startTick > 10 && stopTick < 4085) { // Set up to extract the "best" parameters in the event of more than one hit for this pulse train short roiMaxValue(0); @@ -702,7 +704,7 @@ void TrackHitEfficiencyAnalysis::fillHistograms(const art::Event& event) const int rawDigitMinTick(0); // Start by getting an estimate of the pulse height from the RawDigits - ChanToRawDigitMap::const_iterator rawDigitItr = chanToRawDigitMap.find(channel); + ChanToRawDigitMap::const_iterator rawDigitItr = chanToRawDigitMap.find(channel); if (rawDigitItr != chanToRawDigitMap.end()) { @@ -837,7 +839,7 @@ void TrackHitEfficiencyAnalysis::fillHistograms(const art::Event& event) const if (nMatchedHits > 0) nRecobHitVec[plane]++; else if (rejectedHit) - { + { unsigned short hitStartTick = rejectedHit->PeakTime() - fSigmaVec[plane] * rejectedHit->RMS(); unsigned short hitStopTick = rejectedHit->PeakTime() + fSigmaVec[plane] * rejectedHit->RMS(); @@ -960,12 +962,12 @@ void TrackHitEfficiencyAnalysis::fillHistograms(const art::Event& event) const return; } - + // Useful for normalizing histograms void TrackHitEfficiencyAnalysis::endJob(int numEvents) { return; } - + DEFINE_ART_CLASS_TOOL(TrackHitEfficiencyAnalysis) } diff --git a/icaruscode/Analysis/trigger/TimeTrackTreeStorageCRT_module.cc b/icaruscode/Analysis/trigger/TimeTrackTreeStorageCRT_module.cc index 206753dc1..1cfa533e5 100644 --- a/icaruscode/Analysis/trigger/TimeTrackTreeStorageCRT_module.cc +++ b/icaruscode/Analysis/trigger/TimeTrackTreeStorageCRT_module.cc @@ -4,7 +4,7 @@ * Animesh Chatterjee (U. Pittsburgh, anc238@pitt.edu), * Gianluca Petrillo (SLAC, petrillo@slac.stanford.edu) * @date February 2023 - * + * * Originally borrowed heavily from Gray Putnam's existing `TrackCaloSkimmer`. */ @@ -25,6 +25,7 @@ #include "lardata/DetectorInfoServices/DetectorPropertiesService.h" #include "lardata/DetectorInfoServices/DetectorClocksService.h" #include "larcore/Geometry/Geometry.h" +#include "larcore/Geometry/WireReadout.h" #include "larcore/CoreUtils/ServiceUtil.h" // lar::providerFrom() #include "lardataalg/DetectorInfo/DetectorTimingTypes.h" // electronics_time #include "lardataalg/DetectorInfo/DetectorTimings.h" @@ -82,7 +83,7 @@ namespace { - + // --------------------------------------------------------------------------- /// Returns the sequence of `track` valid points (as geometry points). std::pair, std::vector> @@ -105,63 +106,63 @@ namespace { } return { std::move(trackPath), std::move(trackMom) }; } // extractTrajectory() - - + + /// Returns the input tag of data product the `ptr` points to. template art::InputTag inputTagOf(art::Ptr ptr, art::Event const& event) { return event.getProductDescription(ptr.id())->inputTag(); } - + } // local namespace // ----------------------------------------------------------------------------- namespace sbn { - class TimeTrackTreeStorage; - + class TimeTrackTreeStorage; + } /** * @brief Fills a ROOT tree with track-based triggering information. - * - * + * + * * Track selection criteria * ========================= - * + * * This module does not perform almost any selection: it processes all the * selected track, output of the module in `T0selProducer`, which include a * track (`recob::Track`) and its time (`anab::T0`). * That module may perform the desired selection; this one will use all tracks * that have a time, even if that time is apparently invalid. - * + * * For every track which is associated to a PFO (`recob::PFParticle`), * the time (`anab::T0`) associated to that PFO is saved in a tree entry. - * + * * For every track which is matched to a CRT hit (from `CRTMatchingProducer` * module), the time of that match is saved, together with some information * about the hit itself. - * - * + * + * * Optical detector information * ----------------------------- - * + * * Currently, _all_ reconstructed flashes in the cryostat are saved together * with _each_ tree entry, i.e. to each selected track. There is no attempt to * match a single flash to a track. - * - * + * + * * Data stored in the tree * ======================== - * + * * Tracks * ------- - * + * * ### Position in the drift direction - * + * * The input tracks are expected to be processed in a Pandora-like way. * That is, if a TPC time is associated with them, then they have been already * translated along the drift direction (_x_) to match the assigned time. - * + * * In case the tracks have no TPC time associated with them, instead, the time * associated from the CRT (not the one from the `T0selProducer` source), * is considered. If that time is valid, then it is used to translate the track @@ -171,21 +172,21 @@ namespace sbn { * between the CRT hit and the track is performed (this correction, of the order * of nanoseconds, is irrelevant to the purpose of trigger efficiency * evaluation). - * - * - * + * + * + * * Calorimetry * ------------ - * + * * Track energy and energy profile are directly taken from the results of * "standard" ICARUS calorimetry application. * Calibration hit by hit is currently still custom, using recombination * correction. - * - * + * + * * Trigger information * ==================== - * + * * There are two distinct groups of information about triggers in the tree. * The first one is the hardware trigger, that is the trigger that was actually * used to decide to record the event. That is the same information for all @@ -195,11 +196,11 @@ namespace sbn { * in this group, one for each simulated trigger logic, and each tree entry, * corresponding to a selected track, may have its own value for each trigger * logic response. - * - * + * + * * Simulated trigger information * ------------------------------ - * + * * A branch is added for each configured trigger logic. * This module actually ignores the details of the logic yielding the results: * a trigger result is a group of data products under the same tag. @@ -213,7 +214,7 @@ namespace sbn { * Note that a trigger object is expected to be present _regardless whether * the trigger fired or not_. It is assumed that the trigger fired if at least * one of the `raw::Trigger::TriggerBits()` is set, not fired otherwise. - * + * * Each branch mirrors a data record, `TriggerInfo_t`, reporting the response * for one simulated trigger logic. * The structure and interpretation of the trigger response branch is described @@ -229,36 +230,36 @@ namespace sbn { * * `gate` (double): start time of the gate where the trigger logic was * simulated. It is in the same time scale as the trigger time, and * directly taken from `raw::Trigger::BeamGateTime()`. - * - * + * + * * Service dependencies * ===================== - * + * * * `Geometry` for determinations related to the position of the cathode and * anodes, and for association of track and hits. * * `LArProperties` as dependency for `DetectorPropertiesService` * * `DetectorClocksService` as dependency for `DetectorPropertiesService` * * `DetectorPropertiesService` for the drift velocity to convert a time shift * into a drift direction shift. - * + * */ class sbn::TimeTrackTreeStorage : public art::EDAnalyzer { - + using TriggerInputSpec_t = sbn::details::TriggerResponseManager::TriggerInputSpec_t; - + public: - + /// Data record the trigger response branch is based on. using TriggerInfo_t = sbn::details::TriggerResponseManager::TriggerInfo_t; - + struct Config { using Name = fhicl::Name; using Comment = fhicl::Comment; - + /// Information on a single trigger source for the tree. struct TriggerSpecConfig { - + fhicl::Atom Name { fhicl::Name("Name"), Comment("name of the trigger (e.g. `\"M5O3\"`)") @@ -267,28 +268,28 @@ class sbn::TimeTrackTreeStorage : public art::EDAnalyzer { fhicl::Name("TriggerTag"), Comment("tag of the input trigger info data product") }; - + }; // TriggerSpecConfig using TriggerSpecConfigTable = fhicl::TableAs; - - + + fhicl::Atom T0selProducer { Name("T0selProducer"), Comment("tag of the tracks to process (as a collection of art::Ptr)") }; - + fhicl::OptionalAtom PFPproducer { Name("PFPproducer"), Comment("tag of associations of particle flow objects and input tracks") }; - + fhicl::OptionalAtom T0Producer { Name("T0Producer"), Comment("tag of the time (t0) of particle flow objects [as PFPproducer]") // default: as PFPproducer }; - + fhicl::Atom TrackProducer { Name("TrackProducer"), Comment("tag of the association of particles to tracks") @@ -298,7 +299,7 @@ class sbn::TimeTrackTreeStorage : public art::EDAnalyzer { fhicl::Atom TrackFitterProducer { Name("TrackFitterProducer"), Comment("tag of the association of the tracks with the hits") - // mandatory + // mandatory }; fhicl::Atom CaloProducer { @@ -306,20 +307,20 @@ class sbn::TimeTrackTreeStorage : public art::EDAnalyzer { Comment("tag of the association of the tracks with the calorimetry module") //mandatory }; - - + + fhicl::Atom BeamGateProducer { Name("BeamGateProducer"), Comment("tag of beam gate information") // mandatory }; - + fhicl::Atom TriggerProducer { Name("TriggerProducer"), Comment("tag of hardware trigger information") // mandatory }; - + fhicl::Atom FlashProducer { Name("FlashProducer"), Comment("tag of flash information") @@ -336,7 +337,7 @@ class sbn::TimeTrackTreeStorage : public art::EDAnalyzer { Name("EmulatedTriggers"), Comment("the emulated triggers to include in the tree") }; - + fhicl::Atom LogCategory { Name("LogCategory"), Comment("label for output messages of this module instance"), @@ -348,7 +349,7 @@ class sbn::TimeTrackTreeStorage : public art::EDAnalyzer { Comment("force all tracks to be downgoing, flipping them when necessary"), false }; - + fhicl::Atom CalorimetryPlane { Name("CalorimetryPlane"), Comment( @@ -357,11 +358,11 @@ class sbn::TimeTrackTreeStorage : public art::EDAnalyzer { ), -1 }; - + }; // Config - + using Parameters = art::EDAnalyzer::Table; - + explicit TimeTrackTreeStorage(Parameters const& p); sbn::selHitInfo makeHit(const recob::Hit &hit, @@ -370,19 +371,19 @@ class sbn::TimeTrackTreeStorage : public art::EDAnalyzer { const recob::TrackHitMeta &thm, bool flippedTrack, const std::vector &calo, - const geo::GeometryCore *geo); + const geo::WireReadoutGeom& wireReadout); void analyze(art::Event const& e) override; - + void endJob() override; private: - + using electronics_time = detinfo::timescales::electronics_time; using microseconds = util::quantities::intervals::microseconds; - + // --- BEGIN -- Configuration parameters ------------------------------------- - + art::InputTag const fT0selProducer; art::InputTag const fTrackProducer; art::InputTag const fPFPproducer; // producer of PFP/track associations @@ -396,16 +397,16 @@ class sbn::TimeTrackTreeStorage : public art::EDAnalyzer { std::string const fLogCategory; bool const fForceDowngoing; ///< Whether to force all tracks to be downgoing. int const fCalorimetryPlaneNumber; ///< Which plane to use for calorimetry. - + // --- END ---- Configuration parameters ------------------------------------- // --- BEGIN -- Tree buffers ------------------------------------------------- - + unsigned int fEvent; unsigned int fRun; unsigned int fSubRun; - - sbn::selTrackInfo fTrackInfo; //change to one entry per track instead of per event + + sbn::selTrackInfo fTrackInfo; //change to one entry per track instead of per event sbn::selBeamInfo fBeamInfo; sbn::selTriggerInfo fTriggerInfo; sbn::selLightInfo fClosestFlash; @@ -415,42 +416,42 @@ class sbn::TimeTrackTreeStorage : public art::EDAnalyzer { std::vector fHitStore; sbn::selCRTInfo fCRTInfo; // --- END ---- Tree buffers ------------------------------------------------- - + // --- BEGIN -- Cached information ------------------------------------------- - + /// PMT geometry objects, grouped by wall (drift) coordinate. std::vector>> fPMTwalls; - + // --- BEGIN -- Cached information ------------------------------------------- - - + + TTree *fStoreTree = nullptr; unsigned int fTotalProcessed = 0; - - + + // `convert()` needs to be a free function friend TriggerInputSpec_t convert(Config::TriggerSpecConfig const& config); - - + + // --- BEGIN -- Trigger response branches ------------------------------------ - + /// Manages filling of trigger result branches. sbn::details::TriggerResponseManager fTriggerResponses; - + // --- END ---- Trigger response branches ------------------------------------ - + /// Extracts CRT information pertaining the specified `track`. sbn::selCRTInfo extractCRTinfoFor( art::Ptr const& track, art::Event const& event, util::OneToOneAssociationCache const& trackToCRTt0, util::OneToOneAssociationCache const& t0ToCRThits ) const; - + /// Accesses detector geometry to return all PMT split by wall. std::vector>> computePMTwalls() const; - + /// Returns the position correction of a `track` based on a time shift. /// ("actual" track time minus the time assumed during reconstruction). /// A non-empty list of the TPCs crossed by the track is required. @@ -461,21 +462,21 @@ class sbn::TimeTrackTreeStorage : public art::EDAnalyzer { geo::GeometryCore const& geom, detinfo::DetectorPropertiesData const& detProp ) const; - + /** * @brief Returns the most significative distance of a `time` from a `range`. * @param time time to be checked * @param range time range `time` is going to be compared to * @returns the most significative distance of a `time` from a `range` - * + * * If `time` is contained in the range, the return value is negative and its * modulus is the distance from the closest `range` boundary; no information * is encoded about which of the boundaries that is. - * + * * If `time` is not contained in the range, the return value is positive and * its modulus is again the distance from the closest `range` boundary, which * is also the one crossed by `time`. - * + * * The rule also holds for ranges where the start time is larger than the stop * time. If `range` is not valid, it is interpreted as a range containing all * time, and the return value is `0`. @@ -483,13 +484,13 @@ class sbn::TimeTrackTreeStorage : public art::EDAnalyzer { static microseconds distanceFromTimeRange( electronics_time time, lar::util::TrackTimeInterval::TimeRange const& range ); - + }; // sbn::TimeTrackTreeStorage // ----------------------------------------------------------------------------- namespace sbn { - + TimeTrackTreeStorage::TriggerInputSpec_t convert (TimeTrackTreeStorage::Config::TriggerSpecConfig const& config) { @@ -498,13 +499,13 @@ namespace sbn { , config.TriggerTag() // inputTag }; } // convert(sbn::TriggerSpecConfig) - + } // namespace sbn // ----------------------------------------------------------------------------- namespace { - + /// A vector-like collection which inserts elements only if not there yet. /// It's designed for small collections. template @@ -513,7 +514,7 @@ namespace { public: using value_type = typename Vector_t::value_type; using const_iterator = typename Vector_t::const_iterator; - + /// Adds a copy of `value` if it's not present yet. void push_back(value_type value) { @@ -521,7 +522,7 @@ namespace { if (std::find(Vector_t::crbegin(), end, value) != end) return; Vector_t::push_back(std::move(value)); } - + using Vector_t::empty; using Vector_t::size; using Vector_t::back; @@ -530,11 +531,11 @@ namespace { using Vector_t::cend; auto begin() const { return cbegin(); } auto end() const { return cend(); } - + Vector_t const& vector() const { return *this; } - + }; // class UniqueVector - + } // local namespace @@ -564,11 +565,11 @@ sbn::TimeTrackTreeStorage::TimeTrackTreeStorage(Parameters const& p) , fTriggerResponses { p().EmulatedTriggers(), consumesCollector(), *fStoreTree } { - + // // declaration of input // - + consumes>>(fT0selProducer); consumes>(fT0selProducer); consumes>(fBeamGateProducer); @@ -597,7 +598,7 @@ sbn::TimeTrackTreeStorage::TimeTrackTreeStorage(Parameters const& p) fStoreTree->Branch("selHits", &fHitStore); if (!fCRTMatchProducer.empty()) fStoreTree->Branch("selCRTHits", &fCRTInfo); // one entry per track - + } // sbn::TimeTrackTreeStorage::TimeTrackTreeStorage() @@ -612,30 +613,31 @@ void sbn::TimeTrackTreeStorage::analyze(art::Event const& e) * * time from CRT (`t0_CRT`) is taken from the CRT/TPC matching * Usually `t0` is equal to either one of the other two times, and one of them * can be missing (or better, with a special invalid value). - * + * */ - + using namespace util::quantities::time_literals; // ""_us using trigger_time = detinfo::timescales::trigger_time; - + // // reach for all the needed services (geometry, timing and detector state) // const geo::GeometryCore *geom = lar::providerFrom(); - + auto const& wireReadout = art::ServiceHandle()->Get(); + detinfo::DetectorClocksData const detClocks = art::ServiceHandle()->DataFor(e); - + detinfo::DetectorPropertiesData const detProp = art::ServiceHandle()->DataFor (e, detClocks) ; - + detinfo::DetectorTimings const detTimings{ detClocks }; - + lar::util::TrackTimeInterval const allowedTrackTime - { *geom, detProp, detTimings }; - + { *geom, wireReadout, detProp, detTimings }; + // // event identification // @@ -643,7 +645,7 @@ void sbn::TimeTrackTreeStorage::analyze(art::Event const& e) fSubRun = e.subRun(); fRun = e.run(); fBeamInfo = {}; - + // // hardware beam gate information // @@ -668,45 +670,45 @@ void sbn::TimeTrackTreeStorage::analyze(art::Event const& e) fTriggerInfo.beamGateTime = triggerinfo.beamGateTimestamp; fTriggerInfo.triggerID = triggerinfo.triggerID; fTriggerInfo.gateID = triggerinfo.gateID; - + // // trigger emulation support // // get an extractor bound to this event sbn::details::TriggerResponseManager::Extractors triggerResponseExtractors = fTriggerResponses.extractorsFor(e); - + // // tracks // - + std::vector> const& tracks = e.getProduct>> (fT0selProducer); if(tracks.empty()) { mf::LogDebug(fLogCategory) << "No tracks in '" << fT0selProducer.encode() << "'."; return; } - + // // additional associations to navigate from tracks to other information // - + // t0 from selection art::FindOneP TrackT0s(tracks,e,fT0selProducer); - + // t0 from TPC (cathode crossing tracks) icarus::ns::util::AssnsCrosser const TrackTPCt0s{ e, fPFPproducer, fT0Producer }; - + // optical flashes std::vector const &particleFlashes = e.getProduct>(fFlashProducer); - + // track calorimetry art::FindMany trackCalorimetry(tracks, e, fCaloProducer); - + // track TPC hits art::FindManyP trkht(tracks,e,fTrackProducer); - + // track t0 from CRT std::optional const> TrackCRTt0s; @@ -721,34 +723,35 @@ void sbn::TimeTrackTreeStorage::analyze(art::Event const& e) T0CRThits.emplace (e.getProduct>(fCRTMatchProducer)); } - + + unsigned int processed = 0; for(unsigned int iTrack = 0; iTrack < tracks.size(); ++iTrack) { art::Ptr const& trackPtr = tracks.at(iTrack); if(trackPtr.isNull()) continue; - + // decide immediately if the track needs to be flipped bool const flipTrack = fForceDowngoing && (trackPtr->StartDirection().Y() > 0.0); - + // // matched CRT information // if (!fCRTMatchProducer.empty()) fCRTInfo = extractCRTinfoFor(trackPtr, e, *TrackCRTt0s, *T0CRThits); bool const hasCRTT0 = (fCRTInfo.time != sbn::selCRTInfo::NoTime); - + // // hit information // - + //Animesh added hit information - 2/8/2022 std::vector const& calorimetry = trackCalorimetry.at(iTrack); std::vector> const& allHits = trkht.at(iTrack); std::vector const& trkmetas = trkht.data(iTrack); - + lar::util::MinMaxCollector hitTimeRange; fHitStore.clear(); @@ -762,7 +765,7 @@ void sbn::TimeTrackTreeStorage::analyze(art::Event const& e) hitTimeRange.add(hit.PeakTime()); if (wire.Plane != 2) continue; fHitStore.push_back(makeHit - (hit, hitPtr.key(), *trackPtr, *pTrkMeta, flipTrack, calorimetry, geom) + (hit, hitPtr.key(), *trackPtr, *pTrkMeta, flipTrack, calorimetry, wireReadout) ); } if (TPCs.empty()) { @@ -771,14 +774,14 @@ void sbn::TimeTrackTreeStorage::analyze(art::Event const& e) throw art::Exception{ art::errors::NotFound } << "Track ID=" << trackPtr->ID() << " is not associated with any hit.\n"; } - + // // track information (at last!!) // sbn::selTrackInfo trackInfo; trackInfo.trackID = trackPtr->ID(); trackInfo.flipped = flipTrack; - + art::Ptr const& t0Ptr = TrackT0s.at(iTrack); if (!t0Ptr) { // this is the t0 that must not be missing, @@ -794,35 +797,35 @@ void sbn::TimeTrackTreeStorage::analyze(art::Event const& e) // on the other end, all the trigger efficiency figures will be bogus bool const hasT0 = (t0Ptr->ID() >= 0); if (hasT0) trackInfo.t0 = t0Ptr->Time() / 1000.0; // otherwise stays NoTime - + art::Ptr const& t0TPCPtr = TrackTPCt0s.assPtr(trackPtr); // differently from CRT, we assume that all available T0 from TPC are valid bool const hasTPCT0 = t0TPCPtr.isNonnull(); if (hasTPCT0) trackInfo.t0_TPC = t0TPCPtr->Time() / 1000.0; // nanoseconds -> microseconds - + trackInfo.t0_CRT = fCRTInfo.time; // replica - + lar::util::TrackTimeInterval::TimeRange const trackTimeRange = allowedTrackTime.timeRangeOfHits(allHits); - + trackInfo.t0_TPC_min = detTimings.toTriggerTime(trackTimeRange.start).value(); trackInfo.t0_TPC_max = detTimings.toTriggerTime(trackTimeRange.stop).value(); - + electronics_time const t0_elec = detTimings.toElectronicsTime(trigger_time{ trackInfo.t0 }); trackInfo.t0_diff = distanceFromTimeRange(t0_elec, trackTimeRange).value(); - + electronics_time const t0_CRT_elec = detTimings.toElectronicsTime(trigger_time{ trackInfo.t0_CRT }); trackInfo.t0_CRT_diff = distanceFromTimeRange(t0_CRT_elec, trackTimeRange).value(); - + trackInfo.hitTick_min = hitTimeRange.min(); trackInfo.hitTick_max = hitTimeRange.max(); - + // // correction on position from time: // if we have a t0 from TPC (cathode-crossing track) we assume it to be @@ -842,11 +845,11 @@ void sbn::TimeTrackTreeStorage::analyze(art::Event const& e) // directions/momenta are not, and explicit treatment is needed. auto const& [ trackPath, trackMom ] = extractTrajectory(*trackPtr, flipTrack, positionShift); - + recob::tracking::Point_t const& startPoint = trackPath.front(); recob::tracking::Point_t const& endPoint = trackPath.back(); recob::tracking::Vector_t const& startDir = trackMom.front(); - + trackInfo.start_x = startPoint.X(); trackInfo.start_y = startPoint.Y(); trackInfo.start_z = startPoint.Z(); @@ -857,23 +860,23 @@ void sbn::TimeTrackTreeStorage::analyze(art::Event const& e) trackInfo.dir_y = startDir.Y(); trackInfo.dir_z = startDir.Z(); trackInfo.length = trackPtr->Length(); - + geo::Point_t const middlePoint = util::pathMiddlePoint(trackPath.begin(), std::prev(trackPath.end())); trackInfo.middle_x = middlePoint.X(); trackInfo.middle_y = middlePoint.Y(); trackInfo.middle_z = middlePoint.Z(); - + // // determination of cathode crossing // // this determination should be independent of track direction; icarus::CathodeDesc_t const cathode = icarus::findTPCcathode(middlePoint, *geom); - + icarus::CathodeCrossing_t crossInfo = icarus::detectCrossing(trackPath.begin(), trackPath.end(), cathode); - + if (crossInfo) { if (positionShift != geo::Vector_t{}) { // in general, we correct only tracks that don't cross the cathode, @@ -886,7 +889,7 @@ void sbn::TimeTrackTreeStorage::analyze(art::Event const& e) std::abs(distance(trackPath.back(), cathode)) ) > aBit ) { - mf::LogPrint(fLogCategory) + mf::LogPrint(fLogCategory) << "Track ID=" << trackPtr->ID() << " (" << startPoint << " to " << endPoint << ", crossing at " << crossInfo.crossingPoint @@ -895,15 +898,15 @@ void sbn::TimeTrackTreeStorage::analyze(art::Event const& e) << trackInfo.t0_CRT << " us)."; } } // position shift check - + auto itBeforeCathode = trackPath.begin() + crossInfo.indexBefore; auto itAfterCathode = trackPath.begin() + crossInfo.indexAfter; - + geo::Point_t middleBeforeCathode = util::pathMiddlePoint(trackPath.begin(), itBeforeCathode); geo::Point_t middleAfterCathode = util::pathMiddlePoint(itAfterCathode, std::prev(trackPath.end())); - + // "before" is defined as "smaller x", so: if (distance(middleAfterCathode, cathode) < 0.0) { assert(distance(middleBeforeCathode, cathode) >= 0.0); @@ -912,29 +915,29 @@ void sbn::TimeTrackTreeStorage::analyze(art::Event const& e) std::swap(crossInfo.before, crossInfo.after); std::swap(middleBeforeCathode, middleAfterCathode); } - + trackInfo.beforecathode = crossInfo.before; trackInfo.aftercathode = crossInfo.after; - + geo::Point_t const& atCathodePoint = crossInfo.crossingPoint; trackInfo.atcathode_x = atCathodePoint.X(); trackInfo.atcathode_y = atCathodePoint.Y(); trackInfo.atcathode_z = atCathodePoint.Z(); - + trackInfo.midbeforecathode_x = middleBeforeCathode.X(); trackInfo.midbeforecathode_y = middleBeforeCathode.Y(); trackInfo.midbeforecathode_z = middleBeforeCathode.Z(); - + trackInfo.midaftercathode_x = middleAfterCathode.X(); trackInfo.midaftercathode_y = middleAfterCathode.Y(); trackInfo.midaftercathode_z = middleAfterCathode.Z(); - + } // if crossing - + // // calorimetry information // - + // pick the plane of choice: anab::Calorimetry const* trackCalo = nullptr; if (fCalorimetryPlaneNumber < 0) { @@ -953,7 +956,7 @@ void sbn::TimeTrackTreeStorage::analyze(art::Event const& e) break; } // for } - + bool const hasCaloInfo = trackCalo && !trackCalo->TrkPitchVec().empty(); if (hasCaloInfo) { trackInfo.energy_range = trackCalo->Range(); @@ -973,9 +976,9 @@ void sbn::TimeTrackTreeStorage::analyze(art::Event const& e) << "Track '" << inputTagOf(trackPtr, e).encode() << "' ID=" << trackInfo.trackID << " has no suitable calorimetry information."; } - + fTrackInfo = std::move(trackInfo); - + // // optical flash information // @@ -993,9 +996,9 @@ void sbn::TimeTrackTreeStorage::analyze(art::Event const& e) float const flash_x = center.X(); float const flash_y = center.Y(); float const flash_z = center.Z(); - + geo::Vector_t const diff_flash_pos = center - middlePoint; - + sbn::selLightInfo flashInfo; flashInfo.flash_id = iFlash; flashInfo.sum_pe = flash_pe; @@ -1007,9 +1010,9 @@ void sbn::TimeTrackTreeStorage::analyze(art::Event const& e) if (hasTPCT0) flashInfo.diff_flash_TPCt0 = flash_time - fTrackInfo.t0_TPC; if (hasCRTT0) flashInfo.diff_flash_CRTt0 = flash_time - fTrackInfo.t0_CRT; flashInfo.diff_flash_pos = std::hypot(diff_flash_pos.Y(), diff_flash_pos.Z()); - + fFlashStore.push_back(flashInfo); - + if (hasT0 && (!closestFlash || std::abs(flashInfo.diff_flash_t0) < std::abs(closestFlash->diff_flash_t0)) ) { @@ -1020,26 +1023,26 @@ void sbn::TimeTrackTreeStorage::analyze(art::Event const& e) ) { nearestFlash = &fFlashStore.back(); } - + } // for flashes - + if (closestFlash) closestFlash->flash_closest_to_track = true; if (nearestFlash) nearestFlash->flash_nearest_to_track = true; - + fClosestFlash = closestFlash? *closestFlash: sbn::selLightInfo{}; fNearestFlash = nearestFlash? *nearestFlash: sbn::selLightInfo{}; - - + + // // trigger emulation information // triggerResponseExtractors.fetch(iTrack); // TODO no check performed; need to find a way - + ++processed; ++fTotalProcessed; fStoreTree->Fill(); } // for particle - + mf::LogInfo(fLogCategory) << "Particles Processed: " << processed; } // sbn::TimeTrackTreeStorage::analyze() @@ -1051,7 +1054,7 @@ sbn::selHitInfo sbn::TimeTrackTreeStorage::makeHit(const recob::Hit &hit, const recob::TrackHitMeta &thm, bool flippedTrack, const std::vector &calo, - const geo::GeometryCore *geom) + const geo::WireReadoutGeom &wireReadout) { // TrackHitInfo to save @@ -1065,7 +1068,7 @@ sbn::selHitInfo sbn::TimeTrackTreeStorage::makeHit(const recob::Hit &hit, hinfo.mult = hit.Multiplicity(); hinfo.wire = hit.WireID().Wire; hinfo.plane = hit.WireID().Plane; - hinfo.channel = geom->PlaneWireToChannel(hit.WireID()); + hinfo.channel = wireReadout.PlaneWireToChannel(hit.WireID()); hinfo.tpc = hit.WireID().TPC; hinfo.end = hit.EndTick(); hinfo.start = hit.StartTick(); @@ -1085,25 +1088,25 @@ sbn::selHitInfo sbn::TimeTrackTreeStorage::makeHit(const recob::Hit &hit, hinfo.px = loc.X(); hinfo.py = loc.Y(); hinfo.pz = loc.Z(); - + geo::Vector_t const dir = (flippedTrack? -1: +1) * trk.DirectionAtPoint(thm.Index()); hinfo.dirx = dir.X(); hinfo.diry = dir.Y(); hinfo.dirz = dir.Z(); - + // And determine if the Hit is on a Calorimetry object for (anab::Calorimetry const* c: calo) { if (c->PlaneID().Plane != hinfo.plane) continue; - + auto const sortRange = [fullRange=c->Range(), flippedTrack] (float rr){ return flippedTrack? (fullRange - rr): rr; }; - + // Found the plane! Now find the hit: for (unsigned i_calo = 0; i_calo < c->dQdx().size(); i_calo++) { // "TpIndices" match to the hit key if (c->TpIndices()[i_calo] != hkey) continue; - // Fill the calo information associated with the hit + // Fill the calo information associated with the hit hinfo.oncalo = true; hinfo.pitch = c->TrkPitchVec()[i_calo]; hinfo.dqdx = c->dQdx()[i_calo]; @@ -1114,7 +1117,7 @@ sbn::selHitInfo sbn::TimeTrackTreeStorage::makeHit(const recob::Hit &hit, break; } // for c } - + return hinfo; } @@ -1125,28 +1128,28 @@ sbn::selCRTInfo sbn::TimeTrackTreeStorage::extractCRTinfoFor( ) const { assert(!fCRTMatchProducer.empty()); assert(trackPtr); - + sbn::selCRTInfo CRTinfo; - + // // fetch the CRT time associated to the track // art::Ptr const t0Ptr = trackToCRTt0(trackPtr); if (!t0Ptr) return {}; // no CRT information associated with this track - + if (t0Ptr->ID() < 0) return {}; // supposedly invalid t0 content - + CRTinfo.time = t0Ptr->Time() / 1000.0; // nanoseconds -> microseconds - + // // fetch the CRT hit(s) information // - + // so far, we expect only one CRT hit; // when this changes, the cache one-to-one won't do any more... // (then ask petrillo@slac.stanford.edu to write the one-to-many version) std::vector hits { t0ToCRThits(t0Ptr).get() }; - + if (hits.empty()) { // we expect that the matching module between CRT hits and TPC tracks // produced a T0 and its associations to both track and hits; @@ -1159,7 +1162,7 @@ sbn::selCRTInfo sbn::TimeTrackTreeStorage::extractCRTinfoFor( << inputTagOf(t0Ptr, event).encode() << "' (ID=" << t0Ptr->ID() << " time=" << t0Ptr->Time() << " ns)!\n"; } - + // currently (v09_67_00) only one CRT hit per track is found; if we found more than one, // we should go back to the documentation or the authors to add the new information sbn::crt::CRTHit const& entryHit = *(hits.front()); @@ -1173,7 +1176,7 @@ sbn::selCRTInfo sbn::TimeTrackTreeStorage::extractCRTinfoFor( , icarus::crt::CRTCommonUtils{}.AuxDetRegionNameToNum(entryHit.tagger) // region }; - + if (hits.size() > 1) { // this means that something has changed in the algorithm, and we should know what throw art::Exception{ art::errors::LogicError } @@ -1184,35 +1187,36 @@ sbn::selCRTInfo sbn::TimeTrackTreeStorage::extractCRTinfoFor( << inputTagOf(t0Ptr, event).encode() << "' (ID=" << t0Ptr->ID() << " time=" << t0Ptr->Time() << "); expecting no more than 1.\n"; } - + return CRTinfo; } // ----------------------------------------------------------------------------- void sbn::TimeTrackTreeStorage::endJob() { - + mf::LogInfo(fLogCategory) << "Processed " << fTotalProcessed << " tracks."; - + } // sbn::TimeTrackTreeStorage::endJob() // ----------------------------------------------------------------------------- std::vector>> sbn::TimeTrackTreeStorage::computePMTwalls() const { - + + auto const& wireReadout = art::ServiceHandle()->Get(); geo::GeometryCore const& geom { *lar::providerFrom() }; - + // run the algorithm to identify the PMT walls (as groups of geo::OpDetGeo) std::vector>> opDetWalls = icarus::trigger::PMTverticalSlicingAlg{}.PMTwalls(geom); - + // and weirdly, the only portable way to go from a OpDetGeo to its channel // is to build a map (maybe because it's not guaranteed to be 1-to-1?) std::map opDetToChannel; - for (auto const channel: util::counter(geom.MaxOpChannel())) - opDetToChannel[&geom.OpDetGeoFromOpChannel(channel)] = channel; - + for (auto const channel: util::counter(wireReadout.MaxOpChannel())) + opDetToChannel[&geom.OpDetGeoFromOpDet(wireReadout.OpDetFromOpChannel(channel))] = channel; + // rewrite the data structure replacing each detector with its readout channel std::vector>> channelWalls; for (auto const& [ coord, PMTs ]: opDetWalls) { @@ -1220,10 +1224,10 @@ sbn::TimeTrackTreeStorage::computePMTwalls() const { channels.reserve(PMTs.size()); for (geo::OpDetGeo const* PMT: PMTs) channels.push_back(opDetToChannel.at(PMT)); - + channelWalls.emplace_back(coord, std::move(channels)); } // for walls - + return channelWalls; } // sbn::TimeTrackTreeStorage::computePMTwalls() @@ -1237,10 +1241,10 @@ geo::Vector_t sbn::TimeTrackTreeStorage::posShiftFromCRTtime( detinfo::DetectorPropertiesData const& detProp ) const { if (TPCs.empty()) return {}; - + auto iTPC = TPCs.begin(); geo::Vector_t const driftDir = geom.TPC(*iTPC).DriftDir(); // toward anode - + // check for consistency of the drift direction while (++iTPC != TPCs.end()) { if (driftDir == geom.TPC(*iTPC).DriftDir()) continue; @@ -1252,9 +1256,9 @@ geo::Vector_t sbn::TimeTrackTreeStorage::posShiftFromCRTtime( log << " " << tpcid << " " << geom.TPC(tpcid).DriftDir(); return {}; } // while - + double const shiftTowardAnode = timeShift * detProp.DriftVelocity(); - + return driftDir * shiftTowardAnode; } // sbn::TimeTrackTreeStorage::posShiftFromCRTtime() @@ -1265,13 +1269,13 @@ auto sbn::TimeTrackTreeStorage::distanceFromTimeRange -> microseconds { using namespace util::quantities::time_literals; - + if (!range.isValid()) return 0_us; // all-inclusive range, perfect match - + // how much beyond the boundary the time is (negative = within boundary): microseconds const startDiff = range.start - time; microseconds const stopDiff = time - range.stop; - + if (range.duration() >= 0_us) { assert(startDiff <= 0_us || stopDiff <= 0_us); // if range contains time, both diffs are negative; @@ -1299,10 +1303,9 @@ auto sbn::TimeTrackTreeStorage::distanceFromTimeRange else return std::max(startDiff, stopDiff); } - + } // distanceFromTimeRange() // ----------------------------------------------------------------------------- DEFINE_ART_MODULE(sbn::TimeTrackTreeStorage) - diff --git a/icaruscode/Analysis/trigger/TimeTrackTreeStorage_module.cc b/icaruscode/Analysis/trigger/TimeTrackTreeStorage_module.cc index 51e6890d3..fac90a8c4 100644 --- a/icaruscode/Analysis/trigger/TimeTrackTreeStorage_module.cc +++ b/icaruscode/Analysis/trigger/TimeTrackTreeStorage_module.cc @@ -18,6 +18,7 @@ // LArSoft libraries // #include "lardata/DetectorInfoServices/DetectorClocksService.h" +#include "larcore/Geometry/WireReadout.h" #include "larcore/Geometry/Geometry.h" #include "larcore/CoreUtils/ServiceUtil.h" // lar::providerFrom() #include "larcorealg/Geometry/GeometryCore.h" @@ -276,7 +277,7 @@ class sbn::TimeTrackTreeStorage : public art::EDAnalyzer { const recob::Track &trk, const recob::TrackHitMeta &thm, const std::vector> &calo, - const geo::GeometryCore *geo); + const geo::WireReadoutGeom &wireReadoutAlg); void analyze(art::Event const& e) override; @@ -419,6 +420,7 @@ sbn::TimeTrackTreeStorage::TimeTrackTreeStorage(Parameters const& p) void sbn::TimeTrackTreeStorage::analyze(art::Event const& e) { const geo::GeometryCore *geom = lar::providerFrom(); + const geo::WireReadoutGeom &wireReadoutAlg = art::ServiceHandle()->Get(); // Implementation of required member function here. fEvent = e.event(); fSubRun = e.subRun(); @@ -597,7 +599,7 @@ void sbn::TimeTrackTreeStorage::analyze(art::Event const& e) for (size_t ih = 0; ih < allHits.size(); ++ih) { //hits[allHits[ih]->WireID().Plane].push_back(ih); - sbn::selHitInfo hinfo = makeHit(*allHits[ih], allHits[ih].key(), *trackPtr, *trkmetas[ih], calorimetrycol, geom); + sbn::selHitInfo hinfo = makeHit(*allHits[ih], allHits[ih].key(), *trackPtr, *trkmetas[ih], calorimetrycol, wireReadoutAlg); if(hinfo.plane == 2) fHitStore.push_back(hinfo); @@ -661,7 +663,7 @@ sbn::selHitInfo sbn::TimeTrackTreeStorage::makeHit(const recob::Hit &hit, const recob::Track &trk, const recob::TrackHitMeta &thm, const std::vector> &calo, - const geo::GeometryCore *geo) + const geo::WireReadoutGeom &wireReadoutAlg) { // TrackHitInfo to save @@ -675,7 +677,7 @@ sbn::selHitInfo sbn::TimeTrackTreeStorage::makeHit(const recob::Hit &hit, hinfo.mult = hit.Multiplicity(); hinfo.wire = hit.WireID().Wire; hinfo.plane = hit.WireID().Plane; - hinfo.channel = geo->PlaneWireToChannel(hit.WireID()); + hinfo.channel = wireReadoutAlg.PlaneWireToChannel(hit.WireID()); hinfo.tpc = hit.WireID().TPC; hinfo.end = hit.EndTick(); hinfo.start = hit.StartTick(); @@ -734,6 +736,7 @@ void sbn::TimeTrackTreeStorage::endJob() { std::vector>> sbn::TimeTrackTreeStorage::computePMTwalls() const { + geo::WireReadoutGeom const& wireReadoutAlg = art::ServiceHandle()->Get(); geo::GeometryCore const& geom { *lar::providerFrom() }; // run the algorithm to identify the PMT walls (as groups of geo::OpDetGeo) @@ -743,8 +746,9 @@ sbn::TimeTrackTreeStorage::computePMTwalls() const { // and weirdly, the only portable way to go from a OpDetGeo to its channel // is to build a map (maybe because it's not guaranteed to be 1-to-1?) std::map opDetToChannel; - for (auto const channel: util::counter(geom.MaxOpChannel())) - opDetToChannel[&geom.OpDetGeoFromOpChannel(channel)] = channel; + for (auto const channel: util::counter(wireReadoutAlg.MaxOpChannel())) { + opDetToChannel[&wireReadoutAlg.OpDetGeoFromOpChannel(channel)] = channel; + } // rewrite the data structure replacing each detector with its readout channel std::vector>> channelWalls; diff --git a/icaruscode/Analysis/trigger/details/CathodeCrossingUtils.cxx b/icaruscode/Analysis/trigger/details/CathodeCrossingUtils.cxx index 3263425dd..1abdd7e69 100644 --- a/icaruscode/Analysis/trigger/details/CathodeCrossingUtils.cxx +++ b/icaruscode/Analysis/trigger/details/CathodeCrossingUtils.cxx @@ -10,6 +10,7 @@ #include "icaruscode/Analysis/trigger/details/CathodeCrossingUtils.h" // LArSoft libraries +#include "larcorealg/Geometry/WireReadoutGeom.h" #include "larcorealg/Geometry/GeometryCore.h" #include "larcorealg/Geometry/CryostatGeo.h" #include "larcorealg/Geometry/TPCGeo.h" @@ -18,14 +19,14 @@ // ----------------------------------------------------------------------------- icarus::CathodeDesc_t icarus::findTPCcathode -(geo::Point_t const& point, geo::GeometryCore const& geom) + (geo::Point_t const& point, geo::GeometryCore const& geom) { geo::CryostatGeo const* pCryo = geom.PositionToCryostatPtr(point); if (!pCryo) return {}; // all invalid, goodbye return { - findCathodeCenter(*pCryo) // center - , -(pCryo->TPC(0).DriftDir()) // normal + findCathodeCenter(*pCryo) // center + , -geom.TPC({pCryo->ID(), 0}).DriftDir() // normal }; } // icarus::findTPCcathode() diff --git a/icaruscode/Analysis/trigger/details/CathodeCrossingUtils.h b/icaruscode/Analysis/trigger/details/CathodeCrossingUtils.h index 41059ee23..691abed9b 100644 --- a/icaruscode/Analysis/trigger/details/CathodeCrossingUtils.h +++ b/icaruscode/Analysis/trigger/details/CathodeCrossingUtils.h @@ -14,6 +14,7 @@ #include "icaruscode/Utilities/TrajectoryUtils.h" // util::findCrossingSegment() // LArSoft libraries +#include "larcorealg/Geometry/fwd.h" #include "larcoreobj/SimpleTypesAndConstants/geo_vectors.h" // geo::Point_t ... // C/C++ standard libraries @@ -23,14 +24,6 @@ #include // std::abs() -// ----------------------------------------------------------------------------- -// forward declarations -namespace geo { - class GeometryCore; - class CryostatGeo; -} - - // ----------------------------------------------------------------------------- namespace icarus { diff --git a/icaruscode/CRT/CMakeLists.txt b/icaruscode/CRT/CMakeLists.txt index 8bfd2d749..08cd40883 100644 --- a/icaruscode/CRT/CMakeLists.txt +++ b/icaruscode/CRT/CMakeLists.txt @@ -1,82 +1,10 @@ - add_subdirectory(CRTUtils) add_subdirectory(CRTDecoder) -art_make( - NO_PLUGINS - EXCLUDE - CRTChannelMapAlg.cxx - CRTGeometryHelper_service.cc - CRTDetSim_module.cc - CRTSimHitProducer_module.cc - CRTTrueHitProducer_module.cc - CRTTzeroProducer_module.cc - CRTTrackProducer_module.cc - CRTSimAnalysis_module.cc - CRTDataAnalysis_module.cc - CrtOpHitMatchAnalysis_module.cc - CRTTruthMatchAnalysis_module.cc - CRTAutoVeto_module.cc - FlashResAna_module.cc - PhotBackground_module.cc - CRTT0Matching_module.cc - CRTTPCMatchingAna_module.cc - CRTPMTMatchingAna_module.cc - CRTTPCTruthEff_module.cc - LIBRARY_NAME - icaruscode_CRTData - SOURCE - CRTGeoObjectSorter.cxx - LIBRARIES - larcorealg::Geometry - larcore::Geometry_Geometry_service - canvas::canvas - cetlib_except::cetlib_except - messagefacility::MF_MessageLogger - messagefacility::headers - fhiclcpp::fhiclcpp - art::Framework_Services_Registry - CLHEP::CLHEP - ROOT::Geom - cetlib::cetlib -) - -art_make_library( - LIBRARY_NAME - icaruscode_CRT - SOURCE - CRTChannelMapAlg.cxx - LIBRARIES - larcorealg::Geometry - larcore::Geometry_Geometry_service - sbnobj::ICARUS_CRT - icaruscode_CRTData - cetlib_except::cetlib_except - messagefacility::MF_MessageLogger - messagefacility::headers - fhiclcpp::fhiclcpp - art::Framework_Services_Registry - CLHEP::CLHEP - ROOT::Geom - cetlib::cetlib - ) - -cet_build_plugin(CRTGeometryHelper art::service - LIBRARIES - larcorealg::Geometry - larcore::Geometry_Geometry_service - icaruscode_CRT - art_root_io::TFileService_service - art::Framework_Services_Registry - messagefacility::MF_MessageLogger - messagefacility::headers - ) - cet_build_plugin(CRTDetSim art::module LIBRARIES larcorealg::Geometry - icaruscode_CRT sbnobj::ICARUS_CRT sbnobj::Common_CRT icaruscode_CRTUtils @@ -93,7 +21,6 @@ cet_build_plugin(CRTDetSim art::module cet_build_plugin(CRTSimHitProducer art::module LIBRARIES larcorealg::Geometry - icaruscode_CRT sbnobj::ICARUS_CRT sbnobj::Common_CRT icaruscode_CRTUtils @@ -110,7 +37,6 @@ cet_build_plugin(CRTSimHitProducer art::module cet_build_plugin( CRTTrueHitProducer art::module LIBRARIES larcorealg::Geometry - icaruscode_CRT sbnobj::ICARUS_CRT sbnobj::Common_CRT icaruscode_CRTUtils @@ -132,7 +58,6 @@ cet_build_plugin( CRTTrueHitProducer art::module cet_build_plugin(CRTTzeroProducer art::module LIBRARIES larcorealg::Geometry - icaruscode_CRT sbnobj::ICARUS_CRT sbnobj::Common_CRT art_root_io::TFileService_service @@ -149,7 +74,6 @@ cet_build_plugin(CRTTzeroProducer art::module cet_build_plugin(CRTTrackProducer art::module LIBRARIES larcorealg::Geometry - icaruscode_CRT sbnobj::ICARUS_CRT sbnobj::Common_CRT icaruscode_CRTUtils @@ -167,7 +91,6 @@ cet_build_plugin(CRTTrackProducer art::module cet_build_plugin(CRTSimAnalysis art::module LIBRARIES sbnobj::ICARUS_CRT - icaruscode_CRT sbnobj::Common_CRT icaruscode_CRTUtils larcore::Geometry_Geometry_service @@ -189,7 +112,6 @@ cet_build_plugin(CRTDataAnalysis art::module LIBRARIES artdaq_core::artdaq-core_Data sbnobj::ICARUS_CRT - icaruscode_CRT sbnobj::Common_CRT icaruscode_CRTUtils larcore::Geometry_Geometry_service @@ -209,8 +131,6 @@ cet_build_plugin(CRTDataAnalysis art::module cet_build_plugin(CRTCalibrationAnalysis art::module LIBRARIES - icaruscode_CRTData - icaruscode_CRT sbnobj::Common_CRT icaruscode_CRTUtils larcore::Geometry_Geometry_service @@ -232,7 +152,6 @@ cet_build_plugin(CRTCalibrationAnalysis art::module cet_build_plugin(CrtOpHitMatchAnalysis art::module LIBRARIES sbnobj::ICARUS_CRT - icaruscode_CRT sbnobj::Common_CRT icaruscode_CRTUtils larcore::Geometry_Geometry_service @@ -252,7 +171,6 @@ cet_build_plugin(CrtOpHitMatchAnalysis art::module cet_build_plugin(CRTPMTMatchingAna art::module LIBRARIES sbnobj::ICARUS_CRT - icaruscode_CRT sbnobj::Common_CRT icaruscode_CRTUtils icaruscode::Decode_DataProducts @@ -273,7 +191,6 @@ cet_build_plugin(CRTPMTMatchingAna art::module cet_build_plugin(CRTPMTMatchingProducer art::module LIBRARIES - icaruscode::CRT sbnobj::Common_CRT icaruscode::CRTUtils larcore::Geometry_Geometry_service @@ -287,7 +204,6 @@ cet_build_plugin(CRTPMTMatchingProducer art::module cet_build_plugin(CRTTruthMatchAnalysis art::module LIBRARIES sbnobj::ICARUS_CRT - icaruscode_CRT sbnobj::Common_CRT icaruscode_CRTUtils larcore::Geometry_Geometry_service @@ -308,7 +224,6 @@ cet_build_plugin(CRTTruthMatchAnalysis art::module cet_build_plugin( CRTAutoVeto art::module LIBRARIES sbnobj::ICARUS_CRT - icaruscode_CRT sbnobj::Common_CRT icaruscode_CRTUtils larcore::Geometry_Geometry_service @@ -364,7 +279,6 @@ cet_build_plugin( PhotBackground art::module larcorealg::Geometry nusimdata::SimulationBase sbnobj::ICARUS_CRT - icaruscode_CRT sbnobj::Common_CRT icaruscode_CRTUtils art::Framework_Core @@ -384,8 +298,6 @@ cet_build_plugin( PhotBackground art::module cet_build_plugin(CRTT0Matching art::module LIBRARIES - icaruscode_CRTData - icaruscode_CRT sbnobj::Common_CRT icaruscode_CRTUtils larcore::Geometry_Geometry_service @@ -424,7 +336,6 @@ cet_build_plugin(CRTT0Matching art::module cet_build_plugin(CRTT0MatchingAna art::module LIBRARIES sbnobj::ICARUS_CRT - icaruscode_CRT sbnobj::Common_CRT icaruscode_CRTUtils larcorealg::Geometry @@ -457,7 +368,6 @@ cet_build_plugin(CRTT0MatchingAna art::module cet_build_plugin(CRTTPCMatchingAna art::module LIBRARIES sbnobj::ICARUS_CRT - icaruscode_CRT sbnobj::Common_CRT icaruscode_CRTUtils larcorealg::Geometry @@ -487,7 +397,6 @@ cet_build_plugin(CRTTPCMatchingAna art::module ) simple_plugin(CRTTPCTruthEff module sbnobj::ICARUS_CRT - icaruscode_CRT sbnobj::Common_CRT icaruscode_CRTUtils larcorealg::Geometry diff --git a/icaruscode/CRT/CRTChannelMapAlg.cxx b/icaruscode/CRT/CRTChannelMapAlg.cxx deleted file mode 100644 index a8b1b97db..000000000 --- a/icaruscode/CRT/CRTChannelMapAlg.cxx +++ /dev/null @@ -1,329 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -/// \file CRTChannelMapAlg.cxx -/// \brief Algorithm class for ICARUS auxiliary detector channel mapping -/// -/// Originally ported from AuxDetChannelMapLArIATAlg.cxx (Author: brebel@fnal.gov) -/// and modified for SBND (Author: mastbaum@uchicago.edu) then ICARUS -/// \version $Id: 0.0 $ -/// \author chilge@rams.colostate.edu -/////////////////////////////////////////////////////////////////////////////// - -#include "art/Framework/Services/Registry/ServiceHandle.h" -#include "messagefacility/MessageLogger/MessageLogger.h" -#include "larcorealg/Geometry/AuxDetGeo.h" -#include "larcorealg/Geometry/AuxDetSensitiveGeo.h" -#include "larcorealg/Geometry/AuxDetGeometryCore.h" -#include "icaruscode/CRT/CRTChannelMapAlg.h" -#include "TVector3.h" -#include -#include -#include - -//namespace icarus{ -//namespace crt { -namespace geo { - - - //--------------------------------------------------------------------------- - CRTChannelMapAlg::CRTChannelMapAlg( - fhicl::ParameterSet const& p) - : fSorter(geo::CRTGeoObjectSorter(p)) {} - - //--------------------------------------------------------------------------- - void CRTChannelMapAlg::Initialize(AuxDetGeometryData_t& geodata) { - Uninitialize(); - - std::vector& adgeo = geodata.auxDets; - std::vector adgeo_copy; - for (size_t i=0; iGetName() << std::endl; - // } - - fSorter.SortCRTs(adgeo); - - /* - for (size_t i=0; iGetName() - << " | name2: " << adgeo_copy[i]->TotalVolume()->GetName() << std::endl; - } - */ - - - // Map the AuxDetGeo names to their position in the sorted vector - // - // The ICARUS CRT is composed of three subsystems - // (1) The top and 'eaves' portion is new construction from CERN/Bologna. - // Each module consists of two layers of 8 strips in an X-Y configuration. - // Each strip contains 2 fibers read out seperately for a total of 32 channels/module. - // Each module is read out by a single CAEN front-end board (same as SBND, uBooNE). - // (2) The sides are made up of MINOS modules. Each module consists of 1 layer of 20 strips. - // Each strip contains a single fiber read out at both ends. 2 strips are optically - // ganged on a single SiPM on each end for a total of 20 channels/module. A single end - // of 3 modules are read out by a single CAEN front-end board. - // (3) The bottom is made up of Double Chooz veto modules. Each module consists of two layers of - // 32 strips in an X-X configuration with the layers laterally offset by 0.5*(strip width). - // Each strip contains a single fiber read out at a single end by an M64 PMT for a total of - // 64 channels / module. The front-end electronics are different from the subsystems 1 & 2. - // - // In the geometry, CRT modules are AuxDets and CRT strips are the - // AuxDetSensitives. Each strip has one-two SiPM channels depending on module - // type, one per optical fiber (not in the geometry). - // - // Top: 84 modules, 1344 strips, 2688 channels - // Front, back eaves: 6 modules, 96 strips, 192 channels - // Left, right eaves: 13 modules, 208 strips, 416 channels - // Front, back sides: 20 modules, 400 strips, 400 channels - // Left, right sides: 54 modules, 1080 strips, 1080 channels - // Bottom: 14 modules, 896 strips, 896 channels - // - // Total: 284 modules, 5808 strips, 7760 channels - // CERN type: 122 modules, 122 FEBs, 3904 channels: 4052-7956 - // MINOS type: 148 modules, 100 FEBs, 2960 channels: 0-3155 (2 channels/FEB not used) - // DblCh type: 14 modules, 14 FEBs, 896 channels: 3156-4051 - - fADGeoToName.clear(); - fADGeoToChannelAndSV.clear(); - - - - int chID = 0; - - //loop over modules - for (size_t a=0; aGetName()); - - // define a list of pair of sensitive volume ID and sensitive volume - // we are making a pair because the sorted strip number is necessary - // while assigning each strip number to a channelID. - std::vector > adslist; - - //get number of strips in this module - size_t nsv = adgeo[a].NSensitiveVolume(); - - // make a pair of sensitive volume ID and sensitive volume - for(int isv = 0; isv < (int)nsv; isv++ ){ - adslist.push_back(std::make_pair(isv,adgeo[a].SensitiveVolume(isv))); - //std::cout << isv << "\t" << std::endl; - } - // std::cout << " before sort................. \t" << std::endl; - //for (size_t a=0; a> " << std::endl; - //CERN modules - if (nsv==16){ - for (size_t svID=0; svID<16; svID++) { - //each strip has 2 fibers, 1 SiPM per fiber at the same strip end - //ch id in range (0,31) - for (size_t ich=0; ich<2; ich++) { - fADGeoToChannelAndSV[a].push_back(std::make_pair(chID, adslist[svID].first)); - chID++; - //std::cout << " " << a << " \t" << volName << "\t "<< id << " \t" << adslist[svID].first << " \t" << chID << std::endl; - } - } - } - //DC modules - if (nsv==64){ - //1 fiber per strip read out at one end - for (size_t svID=0; svID<64; svID++) { - fADGeoToChannelAndSV[a].push_back(std::make_pair(chID, adslist[svID].first)); - chID++; - // std::cout << "module index | " << a << " volName: | " << volName << "channelno: | " << chID << std::endl; - // std::cout << " " << a << " \t" << volName << "\t "<< id << " \t" << adslist[svID].first << " \t" << chID << std::endl; - } - } - //MINOS modules - if (nsv==20){ - - for (size_t svID=0; svID<20; svID+=2) { - // size_t chID = svID/2 + ich+31; //2 fibers on one SiPM, at both ends, w/different FEBs - fADGeoToChannelAndSV[a].push_back(std::make_pair(chID, adslist[svID].first)); - fADGeoToChannelAndSV[a].push_back(std::make_pair(chID, adslist[svID+1].first)); - chID++; - //std::cout << "module index | " << a << " volName: | " << volName << "\t " << adslist[svID].first << "\t " << adslist[svID+1].first<<" channelno: | " << chID << std::endl; - // std::cout << " " << a << " \t" << volName << "\t "<< id << " \t" << adslist[svID].first << " \t" << chID << std::endl; - - if (adslist[svID].second.Length() == 800){ - fADGeoToChannelAndSV[a].push_back(std::make_pair(chID, adslist[svID].first)); - fADGeoToChannelAndSV[a].push_back(std::make_pair(chID, adslist[svID+1].first)); - chID++; - - //std::cout << " " << a << " \t" << volName << "\t "<< id << " \t" << adslist[svID].first << " \t" << chID << std::endl; - - // std::cout << "module index : 800 cm | " << a << " volName: | " << volName << "\t " << adslist[svID].first << "\t " << adslist[svID+1].first << " channelno: | " << chID << std::endl; - } - } - - - } // if side crt strips - //extractIntegerWords(volName); - - - - // print the result - // std::cout << id << std::endl; - - // std::cout << "module index " << a << " volName " << volName << " module no "<< id << " channelID: " << chID << std::endl; - std::cout << " " << a << " \t" << volName << "\t "<< id << " \t" << chID << std::endl; - } //if correct name - else { - throw cet::exception("CRTChannelMap") - << "Unrecognized volume found: " << volName << std::endl; - } - }//for modules - - /* - for (auto& csvItr : fADGeoToChannelAndSV){ - - for (auto& pairItr : csvItr.second) - std::cout << "module index | "<< csvItr.first << " channel: | "<< pairItr.first << " sv: | "<< pairItr.second < const& auxDets, - size_t& ad, - size_t& sv) const { - - // Set the default to be that we don't find the position in any AuxDet - uint32_t channel = UINT_MAX; - //uint32_t channel; - - // Figure out which detector we are in - ad = 0; - sv = this->NearestSensitiveAuxDet(worldLoc, auxDets, ad); - - - // std::cout << ad << "\t"<< auxDets[ad].TotalVolume()->GetName() << std::endl; - // for (auto& adtoname : fADGeoToName) std::cout << "ad: "<second).begin(), (csvItr->second).end(), - [sv](const std::pair& element){ return element.second == sv;} ); - channel = pairItr->first; - */ - // } - - - - for (auto& pairItr : csvItr->second) - if (pairItr.second == sv) channel = pairItr.first; - } - - /*if (channel == UINT_MAX) { - throw cet::exception("CRTChannelMapAlg") - << "position (" - << worldLoc[0] << "," << worldLoc[1] << "," << worldLoc[2] - << ") does not correspond to any AuxDet"; - }*/ - - return channel; - } - - //---------------------------------------------------------------------------- - geo::Point_t CRTChannelMapAlg::AuxDetChannelToPosition( - uint32_t const channel, - std::string const& auxDetName, - std::vector const& auxDets) const { - - // Figure out which detector we are in - size_t ad = UINT_MAX; - if (fNameToADGeo.count(auxDetName) > 0) { - ad = fNameToADGeo.find(auxDetName)->second; - } - else { - throw cet::exception("CRTChannelMapAlg") - << "No AuxDetGeo with name " << auxDetName; - } - - // Get the vector of channel and sensitive volume pairs - auto csvItr = fADGeoToChannelAndSV.find(ad); - - if (csvItr == fADGeoToChannelAndSV.end()) { - throw cet::exception("CRTChannelMapAlg") - << "No entry in channel and sensitive volume" - << " map for AuxDet index " << ad << " bail"; - } - - // Loop over the vector of channel and sensitive volumes to determine the - // sensitive volume for this channel. Then get the origin of the sensitive - // volume in the world coordinate system. - for (auto csv : csvItr->second) { - if (csv.first == channel) { - // Get the center of the sensitive volume for this channel - return auxDets[ad].SensitiveVolume(csv.second).GetCenter(); - } - } - - return {}; - } - -} // namespace crt -//} //namespace icarus diff --git a/icaruscode/CRT/CRTChannelMapAlg.h b/icaruscode/CRT/CRTChannelMapAlg.h deleted file mode 100644 index 54d88f365..000000000 --- a/icaruscode/CRT/CRTChannelMapAlg.h +++ /dev/null @@ -1,51 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -/// \file CRTChannelMapAlg.h -/// \brief Algorithm class for SBND auxiliary detector channel mapping -/// -/// Originally ported from AuxDetChannelMapLArIATAlg.cxx (Author: brebel@fnal.gov) -/// and modified for SBND (Author: mastbaum@uchicago.edu) -/// \version $Id: 0.0 $ -/// \author chilge@rams.colostate.edu -/////////////////////////////////////////////////////////////////////////////// - -#ifndef ICARUS_CRTChannelMapAlg_h -#define ICARUS_CRTChannelMapAlg_h - -#include "larcorealg/Geometry/AuxDetChannelMapAlg.h" -#include "icaruscode/CRT/CRTGeoObjectSorter.h" -#include "fhiclcpp/ParameterSet.h" -#include "TVector3.h" -#include - -//namespace icarus{ -//namespace crt { -namespace geo{ - - class CRTChannelMapAlg : public AuxDetChannelMapAlg { - public: - CRTChannelMapAlg(fhicl::ParameterSet const& p); - - void Initialize(AuxDetGeometryData_t& geodata) override; - - void Uninitialize() override; - - uint32_t PositionToAuxDetChannel( - geo::Point_t const& worldLoc, - std::vector const& auxDets, - size_t& ad, - size_t& sv) const override; - - geo::Point_t AuxDetChannelToPosition( - uint32_t channel, - std::string const& auxDetName, - std::vector const& auxDets) const override; - - - private: - geo::CRTGeoObjectSorter fSorter; ///< Class to sort geo objects - }; - -} // namespace crt -//} //namespace icarus - -#endif // ICARUS_CRTChannelMapAlg_h diff --git a/icaruscode/CRT/CRTGeoObjectSorter.cxx b/icaruscode/CRT/CRTGeoObjectSorter.cxx deleted file mode 100644 index b1384fd7d..000000000 --- a/icaruscode/CRT/CRTGeoObjectSorter.cxx +++ /dev/null @@ -1,157 +0,0 @@ -//////////////////////////////////////////////////////////////////////// -/// \file CRTGeoObjectSorter.cxx -/// \brief Interface to algorithm class for sorting of AuxDetGeo objects -/// -/// Originally ported from AuxDetGeoObjectSorterLArIAT.h (Author: brebel@fnal.gov) -/// and modified for SBND (Author: mastbaum@uchicago.edu) then ICARUS -/// -/// \version $Id: 0.0 $ -/// \author chilge@rams.colostate.edu -//////////////////////////////////////////////////////////////////////// - -#include "icaruscode/CRT/CRTGeoObjectSorter.h" -#include "larcorealg/Geometry/AuxDetGeo.h" -#include "larcorealg/Geometry/AuxDetSensitiveGeo.h" - -namespace geo{ - - //---------------------------------------------------------------------------- - // Define sort order for AuxDets in standard configuration - static bool sortAuxDetICARUS(const AuxDetGeo& ad1, const AuxDetGeo& ad2) { - - // sort based off of GDML name, module number - std::string ad1name = (ad1.TotalVolume())->GetName(); - std::string ad2name = (ad2.TotalVolume())->GetName(); - // assume volume name is "volAuxDetmodule###" - std::string modulePrefix = "module"; - - //keep compatibility with legacy g4 - ad1name.erase(std::remove(ad1name.begin(), ad1name.end(), '_'), ad1name.end()); - ad2name.erase(std::remove(ad2name.begin(), ad2name.end(), '_'), ad2name.end()); - - int ad1Num = atoi( ad1name.substr(ad1name.find(modulePrefix)+modulePrefix.length(),3).c_str() ); - int ad2Num = atoi( ad2name.substr(ad2name.find(modulePrefix)+modulePrefix.length(), 3).c_str() ); - - return ad1Num < ad2Num; - } - - //---------------------------------------------------------------------------- - // Define sort order for AuxDetSensitives in standard configuration - static bool sortAuxDetSensitiveICARUS(const AuxDetSensitiveGeo& ad1, - const AuxDetSensitiveGeo& ad2) - { - // sort based off of GDML name, assuming ordering is encoded - std::string ad1name = (ad1.TotalVolume())->GetName(); - std::string ad2name = (ad2.TotalVolume())->GetName(); - // assume volume name is "volAuxDetSensitivemodule###(,top or bot>)strip##" - std::string modulePrefix = "module"; - std::string stripPrefix = "strip"; - - //keep compatibility with legacy g4 - ad1name.erase(std::remove(ad1name.begin(), ad1name.end(), '_'), ad1name.end()); - ad2name.erase(std::remove(ad2name.begin(), ad2name.end(), '_'), ad2name.end()); - - int ad1Num = atoi( ad1name.substr(ad1name.find(modulePrefix)+modulePrefix.length(), 3).c_str() ); - int ad2Num = atoi( ad2name.substr(ad2name.find(modulePrefix)+modulePrefix.length(), 3).c_str() ); - - if(ad1Num!=ad2Num) return ad1Num < ad2Num; - - ad1Num = atoi( ad1name.substr(ad1name.find(stripPrefix)+stripPrefix.length(), 2).c_str() ); - ad2Num = atoi( ad2name.substr(ad2name.find(stripPrefix)+stripPrefix.length(), 2).c_str() ); - - return ad1Num < ad2Num; - - } - - //---------------------------------------------------------------------------- - // Define sort order for AuxDets in co-ordinate system - - static bool CRTIncreaseX(const AuxDetGeo& ad1, const AuxDetGeo& ad2) { - auto const xyz1 = ad1.GetCenter(); - auto const xyz2 = ad2.GetCenter(); - return xyz1.X() < xyz2.X(); - } - - static bool CRTDecreaseY(const AuxDetGeo& ad1, const AuxDetGeo& ad2) { - auto const xyz1 = ad1.GetCenter(); - auto const xyz2 = ad2.GetCenter(); - return xyz1.Y() > xyz2.Y(); - } - - static bool CRTIncreaseZ(const AuxDetGeo& ad1, const AuxDetGeo& ad2) { - return ad1.GetCenter().Z() < ad2.GetCenter().Z(); - } - - - //---------------------------------------------------------------------------- - // Define sort order for AuxDetSensitive in co-ordinate system - - static bool CRTSensitiveIncreaseX(std::pair const& ads1, - std::pair const& ads2){ - return ads1.second.GetCenter().X() < ads2.second.GetCenter().X(); - } - - - static bool CRTSensitiveDecreaseY(std::pair const& ads1, - std::pair const& ads2){ - return ads1.second.GetCenter().Y() > ads2.second.GetCenter().Y(); - } - - static bool CRTSensitiveIncreaseZ(std::pair const& ads1, - std::pair const& ads2){ - return ads1.second.GetCenter().Z() < ads2.second.GetCenter().Z(); - } - - - //---------------------------------------------------------------------------- - CRTGeoObjectSorter::CRTGeoObjectSorter( - fhicl::ParameterSet const&) {} - - //---------------------------------------------------------------------------- - void CRTGeoObjectSorter::SortAuxDets(std::vector & adgeo) const { - std::sort(adgeo.begin(), adgeo.end(), sortAuxDetICARUS); - } - - //---------------------------------------------------------------------------- - void CRTGeoObjectSorter::SortAuxDetSensitive(std::vector & adsgeo) const { - std::sort(adsgeo.begin(), adsgeo.end(), sortAuxDetSensitiveICARUS); - } - - //---------------------------------------------------------------------------- - // sorting CRT co-ordiantes decreasing vertical coordinate, - // next increasing beam coordinate, and next increasing drift direction - - void CRTGeoObjectSorter::SortCRTs(std::vector & adgeo) const { - - // 3. stable sort by increasing drift direction (_x_) - std::stable_sort (adgeo.begin(), adgeo.end(), CRTIncreaseX); - - - // 2. stable sort by increasing beam coordinate (_z_) - std::stable_sort (adgeo.begin(), adgeo.end(), CRTIncreaseZ); - - // 1. sort by decreasing vertical coordinate (_y_) - std::stable_sort (adgeo.begin(), adgeo.end(), CRTDecreaseY); - } - - - //---------------------------------------------------------------------------- - // sorting CRTs Sensitive with co-ordiantes decreasing vertical coordinate, - // next increasing beam coordinate, and next increasing drift direction - - void CRTGeoObjectSorter::SortCRTSensitive(std::vector > & adsgeo) const { - - // 3. stable sort by increasing drift direction (_x_) - std::stable_sort (adsgeo.begin(), adsgeo.end(), CRTSensitiveIncreaseX); - - - // 2. stable sort by increasing beam coordinate (_z_) - std::stable_sort (adsgeo.begin(), adsgeo.end(), CRTSensitiveIncreaseZ); - - // 1. sort by decreasing vertical coordinate (_y_) - std::stable_sort (adsgeo.begin(), adsgeo.end(), CRTSensitiveDecreaseY); - } - - -} //namespace crt -//} //namespace icarus diff --git a/icaruscode/CRT/CRTGeoObjectSorter.h b/icaruscode/CRT/CRTGeoObjectSorter.h deleted file mode 100644 index 40edfb2da..000000000 --- a/icaruscode/CRT/CRTGeoObjectSorter.h +++ /dev/null @@ -1,38 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -/// \file CRTGeoObjectSorter.h -/// \brief Interface to algorithm class for sorting of AuxDetGeo objects -/// -/// Originally ported from AuxDetGeoObjectSorterLArIAT.h (Author: brebel@fnal.gov) -/// and modified for SBND (Author: mastbaum@uchicago.edu) -/// -/// \version $Id: 0.0 $ -/// \author chilge@rams.colostate.edu -/////////////////////////////////////////////////////////////////////////////// - -#ifndef ICARUS_CRTGeoObjectSorter_h -#define ICARUS_CRTGeoObjectSorter_h - -#include - -#include "larcorealg/Geometry/AuxDetGeoObjectSorter.h" - -//namespace icarus { -//namespace crt { -namespace geo{ - - class CRTGeoObjectSorter : public AuxDetGeoObjectSorter { - public: - - CRTGeoObjectSorter(fhicl::ParameterSet const& p); - - void SortAuxDets (std::vector& adgeo) const; - void SortAuxDetSensitive(std::vector& adsgeo) const; - void SortCRTs (std::vector& adgeo) const; - void SortCRTSensitive (std::vector >& adsgeo) const; - - }; - -} //namespace crt -//} //namespace icarus - -#endif // ICARUS_CRTGeoObjectSorter_h diff --git a/icaruscode/CRT/CRTGeometryHelper.h b/icaruscode/CRT/CRTGeometryHelper.h deleted file mode 100644 index e0fcaa245..000000000 --- a/icaruscode/CRT/CRTGeometryHelper.h +++ /dev/null @@ -1,51 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -/// \file CRTGeometryHelper.h -/// \brief Auxiliary detector geometry helper service for SBND geometries. -/// -/// Handles SBND-specific information for the generic Geometry service -/// within LArSoft. Derived from the ExptGeoHelperInterface class. -/// -/// Originally ported from LArIATAuxDetGeometryHelper.h (Author: brebel@fnal.gov) -/// and modified for SBND (Author: mastbaum@uchicago.edu) -/// -/// \version $Id: 0.0 $ -/// \author chilge@rams.colostate.edu -/////////////////////////////////////////////////////////////////////////////// - -#ifndef ICARUS_CRTExptGeoHelperInterface_h -#define ICARUS_CRTExptGeoHelperInterface_h - -#include "larcore/Geometry/AuxDetExptGeoHelperInterface.h" -#include "larcorealg/Geometry/AuxDetChannelMapAlg.h" -#include "icaruscode/CRT/CRTChannelMapAlg.h" -#include "art/Framework/Services/Registry/ServiceHandle.h" -#include "art/Framework/Services/Registry/ServiceDeclarationMacros.h" -#include - -namespace geo -{ - class CRTChannelMapAlg; -} - -namespace icarus { -namespace crt{ - - class CRTGeometryHelper : public geo::AuxDetExptGeoHelperInterface { - public: - - explicit CRTGeometryHelper(fhicl::ParameterSet const & pset); - - private: - - AuxDetChannelMapAlgPtr_t - doConfigureAuxDetChannelMapAlg(fhicl::ParameterSet const& sortingParameters) const override; - - fhicl::ParameterSet fPset; ///< Copy of configuration parameter set - }; - -} //namespace crt -} // namespace icarus - -DECLARE_ART_SERVICE_INTERFACE_IMPL(icarus::crt::CRTGeometryHelper, geo::AuxDetExptGeoHelperInterface, SHARED) - -#endif // ICARUS_CRTExptGeoHelperInterface_h diff --git a/icaruscode/CRT/CRTGeometryHelper_service.cc b/icaruscode/CRT/CRTGeometryHelper_service.cc deleted file mode 100644 index d631dc40b..000000000 --- a/icaruscode/CRT/CRTGeometryHelper_service.cc +++ /dev/null @@ -1,40 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -/// \file CRTGeometryHelper_service.cc -/// -/// Originally ported from LArIATAuxDetGeometryHelper.h (Author: brebel@fnal.gov) -/// and modified for SBND (Author: mastbaum@uchicago.edu) -/// -/// \version $Id: 0.0 $ -/// \author chilge@rams.colostate.edu -/////////////////////////////////////////////////////////////////////////////// - -#include "larcorealg/Geometry/AuxDetChannelMapAlg.h" -#include "larcorealg/Geometry/AuxDetGeometryCore.h" -#include "larcorealg/Geometry/AuxDetGeo.h" -#include "art/Framework/Services/Registry/ServiceDefinitionMacros.h" -#include "fhiclcpp/ParameterSet.h" -#include "icaruscode/CRT/CRTGeometryHelper.h" -#include "icaruscode/CRT/CRTChannelMapAlg.h" -#include - -namespace icarus { -namespace crt{ - - //------------------------------------------------------------------------ - CRTGeometryHelper::CRTGeometryHelper( - fhicl::ParameterSet const& pset) - : fPset(pset) {} - - //------------------------------------------------------------------------ - CRTGeometryHelper::AuxDetChannelMapAlgPtr_t - CRTGeometryHelper::doConfigureAuxDetChannelMapAlg( - fhicl::ParameterSet const& sortingParameters) const { - - return std::make_unique(sortingParameters); - - } - -} // namespace crt -} // namespace icarus - -DEFINE_ART_SERVICE_INTERFACE_IMPL(icarus::crt::CRTGeometryHelper, geo::AuxDetExptGeoHelperInterface) diff --git a/icaruscode/CRT/CRTPMTMatchingAna_module.cc b/icaruscode/CRT/CRTPMTMatchingAna_module.cc index eea81c6e8..e333ff502 100644 --- a/icaruscode/CRT/CRTPMTMatchingAna_module.cc +++ b/icaruscode/CRT/CRTPMTMatchingAna_module.cc @@ -22,7 +22,7 @@ // LArSoft includes #include "larcore/CoreUtils/ServiceUtil.h" -#include "larcore/Geometry/Geometry.h" +#include "larcore/Geometry/WireReadout.h" #include "larcorealg/Geometry/GeometryCore.h" #include "lardata/DetectorInfoServices/DetectorClocksService.h" //#include "larsim/MCCheater/PhotonBackTrackerService.h" @@ -297,7 +297,7 @@ class icarus::crt::CRTPMTMatchingAna : public art::EDAnalyzer { int fEventType; // Was triggered the event? double fRelGateTime; - geo::GeometryCore const* fGeometryService; ///< pointer to Geometry provider + geo::WireReadoutGeom const* fWireReadout; ///< pointer to Geometry provider TTree* mSelectionTree; @@ -349,7 +349,7 @@ icarus::crt::CRTPMTMatchingAna::CRTPMTMatchingAna(fhicl::ParameterSet const& p) fFlashLabels.push_back(fOpFlashModuleLabel1); // Get a pointer to the geometry service provider. - fGeometryService = lar::providerFrom(); + fWireReadout = &art::ServiceHandle()->Get(); art::ServiceHandle tfs; @@ -527,7 +527,7 @@ void icarus::crt::CRTPMTMatchingAna::analyze(art::Event const& e) { if (firstPeakTime > hit->PeakTime()) firstPeakTime = hit->PeakTime(); if (firstRiseTime > hit->StartTime()+hit->RiseTime()) firstRiseTime = hit->StartTime()+hit->RiseTime(); geo::Point_t const pos = - fGeometryService->OpDetGeoFromOpChannel(hit->OpChannel()) + fWireReadout->OpDetGeoFromOpChannel(hit->OpChannel()) .GetCenter(); double amp = hit->Amplitude(); // ampsum += amp; // unused diff --git a/icaruscode/CRT/CRTPMTMatchingProducer_module.cc b/icaruscode/CRT/CRTPMTMatchingProducer_module.cc index f496ffba9..b491d532f 100644 --- a/icaruscode/CRT/CRTPMTMatchingProducer_module.cc +++ b/icaruscode/CRT/CRTPMTMatchingProducer_module.cc @@ -34,8 +34,9 @@ #include // LArSoft -#include "larcore/Geometry/Geometry.h" -#include "larcorealg/Geometry/GeometryCore.h" +#include "larcore/Geometry/WireReadout.h" +#include "larcorealg/Geometry/OpDetGeo.h" +#include "larcorealg/Geometry/WireReadoutGeom.h" #include "larcore/CoreUtils/ServiceUtil.h" // lar::providerFrom() #include "larcorealg/Geometry/geo_vectors_utils.h" // MiddlePointAccumulator #include "larcorealg/CoreUtils/enumerate.h" @@ -374,7 +375,7 @@ namespace sbn::crt { double const fNuMIinBeamMin; double const fNuMIinBeamMax; - geo::GeometryCore const* const fGeometryService; ///< Pointer to Geometry provider. + geo::WireReadoutGeom const& fWireReadout; ///< Pointer to Geometry provider. /** * @brief Returns a `MatchedCRT` out of the provided information. @@ -407,7 +408,7 @@ namespace sbn::crt { fNuMIBeamGateMax{p().NuMIBeamGateMax()}, fNuMIinBeamMin{p().NuMIinBeamMin()}, fNuMIinBeamMax{p().NuMIinBeamMax()}, - fGeometryService{lar::providerFrom()} + fWireReadout{art::ServiceHandle()->Get()} { async(); @@ -565,7 +566,7 @@ namespace sbn::crt { } geo::Point_t const pos = - fGeometryService->OpDetGeoFromOpChannel(hit->OpChannel()) + fWireReadout.OpDetGeoFromOpChannel(hit->OpChannel()) .GetCenter(); double const amp = hit->Amplitude(); flashCentroid.add(pos, amp); diff --git a/icaruscode/CRT/CRTUtils/CMakeLists.txt b/icaruscode/CRT/CRTUtils/CMakeLists.txt index e726513b2..429bcedb9 100644 --- a/icaruscode/CRT/CRTUtils/CMakeLists.txt +++ b/icaruscode/CRT/CRTUtils/CMakeLists.txt @@ -37,8 +37,6 @@ art_make_library(LIBRARY_NAME icaruscode_CRTUtils Boost::system sbnobj::ICARUS_CRT sbnobj::Common_CRT - icaruscode_CRT - icaruscode_CRTData lardata::DetectorInfoServices_DetectorClocksServiceStandard_service nurandom::RandomUtils_NuRandomService_service ) diff --git a/icaruscode/CRT/CRTUtils/CRTCommonUtils.cc b/icaruscode/CRT/CRTUtils/CRTCommonUtils.cc index 347b874ed..1fbbd6f1f 100644 --- a/icaruscode/CRT/CRTUtils/CRTCommonUtils.cc +++ b/icaruscode/CRT/CRTUtils/CRTCommonUtils.cc @@ -8,7 +8,7 @@ using namespace icarus::crt; CRTCommonUtils::CRTCommonUtils() { - // fGeoService = art::ServiceHandle()->GetProviderPtr(); + fAuxDetGeom = art::ServiceHandle()->GetProviderPtr(); fGeoService = lar::providerFrom(); FillFebMap(); FillAuxDetMaps(); @@ -309,7 +309,7 @@ double CRTCommonUtils::LengthIDE(sim::AuxDetIDE ide) { int CRTCommonUtils::GetLayerID(sim::AuxDetSimChannel const& adsc){ int layer = -1; - auto const& adGeo = fGeoService->AuxDet(adsc.AuxDetID()); + auto const& adGeo = fAuxDetGeom->AuxDet(adsc.AuxDetID()); auto const& adsGeo = adGeo.SensitiveVolume(adsc.AuxDetSensitiveID()); int region = AuxDetRegionNameToNum(GetAuxDetRegion(adsc.AuxDetID())); char type = GetAuxDetType(adsc.AuxDetID()); @@ -371,7 +371,7 @@ int CRTCommonUtils::GetLayerID(sim::AuxDetSimChannel const& adsc){ int CRTCommonUtils::GetLayerID(const art::Ptr adsc){ int layer = -1; - auto const& adGeo = fGeoService->AuxDet(adsc->AuxDetID()); + auto const& adGeo = fAuxDetGeom->AuxDet(adsc->AuxDetID()); auto const& adsGeo = adGeo.SensitiveVolume(adsc->AuxDetSensitiveID()); int region = AuxDetRegionNameToNum(GetAuxDetRegion(adsc->AuxDetID())); char type = GetAuxDetType(adsc->AuxDetID()); @@ -434,7 +434,7 @@ int CRTCommonUtils::GetMINOSLayerID(size_t adid) { int region = AuxDetRegionNameToNum(GetAuxDetRegion(adid)); char type = GetAuxDetType(adid); - auto const& adGeo = fGeoService->AuxDet(adid); + auto const& adGeo = fAuxDetGeom->AuxDet(adid); if(type!='m') { mf::LogError("CRTCommonUtils") << "non-MINOS module provided to GetMINOSLayerID"; return layer; @@ -490,7 +490,7 @@ TVector3 CRTCommonUtils::ChanToLocalCoords(uint8_t mac, int chan) { TVector3 coords(0.,0.,0.); size_t adid = MacToAuxDetID(mac,chan); //CRT module ID - auto const& adGeo = fGeoService->AuxDet(adid); //CRT module + auto const& adGeo = fAuxDetGeom->AuxDet(adid); //CRT module int adsid = ChannelToAuxDetSensitiveID(mac,chan); //CRT strip ID auto const& adsGeo = adGeo.SensitiveVolume(adsid); //CRT strip @@ -507,7 +507,7 @@ TVector3 CRTCommonUtils::ChanToWorldCoords(uint8_t mac, int chan) { TVector3 coords(0.,0.,0.); int adid = MacToAuxDetID(mac,chan); //CRT module ID - auto const& adGeo = fGeoService->AuxDet(adid); //CRT module + auto const& adGeo = fAuxDetGeom->AuxDet(adid); //CRT module int adsid = ChannelToAuxDetSensitiveID(mac,chan); //CRT strip ID auto const& adsGeo = adGeo.SensitiveVolume(adsid); //CRT strip @@ -571,7 +571,7 @@ void CRTCommonUtils::FillFebMap() { void CRTCommonUtils::FillAuxDetMaps() { for(auto const& ad : fAuxDetIdToFeb){ - auto const& adGeo = fGeoService->AuxDet(ad.first); + auto const& adGeo = fAuxDetGeom->AuxDet(ad.first); //AuxDetType switch(adGeo.NSensitiveVolume()) { @@ -628,7 +628,7 @@ string CRTCommonUtils::AuxDetNameToRegion(string name) { TVector3 CRTCommonUtils::WorldToModuleCoords(TVector3 point, size_t adid) { char type = GetAuxDetType(adid); - auto const& adGeo = fGeoService->AuxDet(adid); + auto const& adGeo = fAuxDetGeom->AuxDet(adid); geo::Point_t const world{point.X(), point.Y(), point.Z()}; auto const local = adGeo.toLocalCoords(world); TVector3 localpoint(local.X(),local.Y(),local.Z()); diff --git a/icaruscode/CRT/CRTUtils/CRTCommonUtils.h b/icaruscode/CRT/CRTUtils/CRTCommonUtils.h index 816d43984..51c8a1c4a 100644 --- a/icaruscode/CRT/CRTUtils/CRTCommonUtils.h +++ b/icaruscode/CRT/CRTUtils/CRTCommonUtils.h @@ -83,7 +83,7 @@ class icarus::crt::CRTCommonUtils { private: - //geo::AuxDetGeometryCore const* fGeoService; + geo::AuxDetGeometryCore const* fAuxDetGeom; geo::GeometryCore const* fGeoService; map>> fAuxDetIdToFeb; map> fFebToAuxDetId; diff --git a/icaruscode/CRT/CRTUtils/CRTDetSimAlg.cc b/icaruscode/CRT/CRTUtils/CRTDetSimAlg.cc index ee9ca3baa..b187711b7 100644 --- a/icaruscode/CRT/CRTUtils/CRTDetSimAlg.cc +++ b/icaruscode/CRT/CRTUtils/CRTDetSimAlg.cc @@ -3,6 +3,8 @@ #include "icaruscode/CRT/CRTUtils/CRTDetSimAlg.h" +#include "larcore/Geometry/AuxDetGeometry.h" + namespace icarus{ namespace crt { @@ -471,10 +473,11 @@ namespace icarus{ const uint32_t adid, const uint32_t adsid, const vector& ides) { art::ServiceHandle geoService; + auto const& auxDetGeom = art::ServiceHandle()->GetProvider(); detinfo::ElecClock trigClock = clockData.TriggerClock(); fHasFilledTaggers = true; - const geo::AuxDetGeo& adGeo = geoService->AuxDet(adid); //pointer to module object + const geo::AuxDetGeo& adGeo = auxDetGeom.AuxDet(adid); //pointer to module object const geo::AuxDetSensitiveGeo& adsGeo = adGeo.SensitiveVolume(adsid); //pointer to strip object const char auxDetType = fCrtutils->GetAuxDetType(adid); //CRT module type (c, d, or m) const string region = fCrtutils->GetAuxDetRegion(adid); //CRT region diff --git a/icaruscode/CRT/CRTUtils/CRTHitRecoAlg.cc b/icaruscode/CRT/CRTUtils/CRTHitRecoAlg.cc index 4f9e34249..931632295 100644 --- a/icaruscode/CRT/CRTUtils/CRTHitRecoAlg.cc +++ b/icaruscode/CRT/CRTUtils/CRTHitRecoAlg.cc @@ -3,13 +3,14 @@ #include "larcore/CoreUtils/ServiceUtil.h" // lar::providerFrom() using namespace icarus::crt; + CRTHitRecoAlg::CRTHitRecoAlg(const fhicl::ParameterSet& pset) : CRTHitRecoAlg() { this->reconfigure(pset); } CRTHitRecoAlg::CRTHitRecoAlg() - : fGeometryService(lar::providerFrom()), + : fAuxDetGeom(art::ServiceHandle()->GetProviderPtr()), fChannelMap( art::ServiceHandle{}.get()) {} @@ -385,7 +386,7 @@ sbn::crt::CRTHit CRTHitRecoAlg::MakeTopHit( map>> pesmap; int adid = fCrtutils.MacToAuxDetID(mac, 0); // module ID - auto const& adGeo = fGeometryService->AuxDet(adid); // module + auto const& adGeo = fAuxDetGeom->AuxDet(adid); // module string region = fCrtutils.GetAuxDetRegion(adid); int plane = fCrtutils.AuxDetRegionNameToNum(region); double hitpointerr[3]; @@ -510,7 +511,7 @@ sbn::crt::CRTHit CRTHitRecoAlg::MakeBottomHit(art::Ptr data) { uint8_t mac = data->fMac5; map>> pesmap; int adid = fCrtutils.MacToAuxDetID(mac, 0); // module ID - auto const& adGeo = fGeometryService->AuxDet(adid); // module + auto const& adGeo = fAuxDetGeom->AuxDet(adid); // module string region = fCrtutils.GetAuxDetRegion(adid); int plane = fCrtutils.AuxDetRegionNameToNum(region); double hitpointerr[3]; @@ -588,9 +589,10 @@ sbn::crt::CRTHit CRTHitRecoAlg::MakeSideHit( vector informationA, informationB; int adid = fCrtutils.MacToAuxDetID(coinData[0]->fMac5, 0); // module ID - auto const& adGeo = fGeometryService->AuxDet(adid); // module - string region = fCrtutils.GetAuxDetRegion(adid); //region name - int plane = fCrtutils.AuxDetRegionNameToNum(region); //region code (ranges from 30-50) + auto const& adGeo = fAuxDetGeom->AuxDet(adid); // module + string region = fCrtutils.GetAuxDetRegion(adid); //region name + int plane = fCrtutils.AuxDetRegionNameToNum(region); //region code (ranges from 30-50) + double hitpoint[3], hitpointerr[3]; TVector3 hitpos(0., 0., 0.); diff --git a/icaruscode/CRT/CRTUtils/CRTHitRecoAlg.h b/icaruscode/CRT/CRTUtils/CRTHitRecoAlg.h index 651f5db0e..4634fc8c0 100644 --- a/icaruscode/CRT/CRTUtils/CRTHitRecoAlg.h +++ b/icaruscode/CRT/CRTUtils/CRTHitRecoAlg.h @@ -95,7 +95,7 @@ class icarus::crt::CRTHitRecoAlg { double ez, string tagger); private: - geo::GeometryCore const* fGeometryService; + geo::AuxDetGeometryCore const* fAuxDetGeom; CRTCommonUtils fCrtutils; diff --git a/icaruscode/CRT/CRTUtils/CRTT0MatchAlg.cc b/icaruscode/CRT/CRTUtils/CRTT0MatchAlg.cc index bde2aee8c..34885c675 100644 --- a/icaruscode/CRT/CRTUtils/CRTT0MatchAlg.cc +++ b/icaruscode/CRT/CRTUtils/CRTT0MatchAlg.cc @@ -1,4 +1,6 @@ #include "CRTT0MatchAlg.h" + +#include "larcore/Geometry/WireReadout.h" #include "larcore/CoreUtils/ServiceUtil.h" // lar::providerFrom() namespace icarus{ @@ -31,6 +33,7 @@ namespace icarus{ // fDistEndpointAVedge = pset.get(.DistEndpointAVedge(); fGeometryService = lar::providerFrom();//GeometryService; + fChannelMap = &art::ServiceHandle()->Get(); fSCE = lar::providerFrom(); //fSCE = SCE; return; @@ -357,8 +360,8 @@ namespace icarus{ auto start = tpcTrack.Vertex(); auto end = tpcTrack.End(); // Get the drift direction from the TPC - int driftDirection = TPCGeoUtil::DriftDirectionFromHits(fGeometryService, hits); - std::pair xLimits = TPCGeoUtil::XLimitsFromHits(fGeometryService, hits); + int driftDirection = TPCGeoUtil::DriftDirectionFromHits(*fGeometryService, hits); + std::pair xLimits = TPCGeoUtil::XLimitsFromHits(*fGeometryService, *fChannelMap, hits); // Get the allowed t0 range std::pair t0MinMax = TrackT0Range(detProp, start.X(), end.X(), driftDirection, xLimits); @@ -385,10 +388,10 @@ namespace icarus{ // Get the drift direction from the TPC - int driftDirection = TPCGeoUtil::DriftDirectionFromHits(fGeometryService, hits); + int driftDirection = TPCGeoUtil::DriftDirectionFromHits(*fGeometryService, hits); //std::cout << "size of hit in a track: " << hits.size() << ", driftDirection: "<< driftDirection // << " , tpc: "<< hits[0]->WireID().TPC << std::endl; //<< " , intpc: "<< icarus::TPCGeoUtil::DetectedInTPC(hits) << std::endl; - std::pair xLimits = TPCGeoUtil::XLimitsFromHits(fGeometryService, hits); + std::pair xLimits = TPCGeoUtil::XLimitsFromHits(*fGeometryService, *fChannelMap, hits); // Get the allowed t0 range std::pair t0MinMax = TrackT0Range(detProp, start.X(), end.X(), driftDirection, xLimits); @@ -846,10 +849,10 @@ namespace icarus{ // Get the drift direction from the TPC - int driftDirection = TPCGeoUtil::DriftDirectionFromHits(fGeometryService, hits); + int driftDirection = TPCGeoUtil::DriftDirectionFromHits(*fGeometryService, hits); //std::cout << "size of hit in a track: " << hits.size() << ", driftDirection: "<< driftDirection // << " , tpc: "<< hits[0]->WireID().TPC << std::endl; //<< " , intpc: "<< icarus::TPCGeoUtil::DetectedInTPC(hits) << std::endl; - std::pair xLimits = TPCGeoUtil::XLimitsFromHits(fGeometryService, hits); + std::pair xLimits = TPCGeoUtil::XLimitsFromHits(*fGeometryService, *fChannelMap, hits); // Get the allowed t0 range std::pair t0MinMax = TrackT0Range(detProp, start.X(), end.X(), driftDirection, xLimits); diff --git a/icaruscode/CRT/CRTUtils/CRTT0MatchAlg.h b/icaruscode/CRT/CRTUtils/CRTT0MatchAlg.h index 69d30bd46..b86adb5fe 100644 --- a/icaruscode/CRT/CRTUtils/CRTT0MatchAlg.h +++ b/icaruscode/CRT/CRTUtils/CRTT0MatchAlg.h @@ -211,6 +211,7 @@ namespace icarus{ private: geo::GeometryCore const* fGeometryService; + geo::WireReadoutGeom const* fChannelMap; spacecharge::SpaceCharge const* fSCE; double fMinTrackLength; diff --git a/icaruscode/CRT/CRTUtils/TPCGeoUtil.cc b/icaruscode/CRT/CRTUtils/TPCGeoUtil.cc index 168f9a37f..9494dc730 100644 --- a/icaruscode/CRT/CRTUtils/TPCGeoUtil.cc +++ b/icaruscode/CRT/CRTUtils/TPCGeoUtil.cc @@ -1,23 +1,25 @@ #include "TPCGeoUtil.h" +#include "larcorealg/Geometry/WireReadoutGeom.h" +#include "larcorealg/Geometry/GeometryCore.h" +#include "larcorealg/Geometry/TPCGeo.h" + namespace icarus { namespace TPCGeoUtil { - int DetectedInTPC(std::vector> const& hits, const geo::GeometryCore *GeometryService){ + int DetectedInTPC(std::vector> const& hits, const geo::GeometryCore& geometry) { // Return tpc of hit collection or -1 if in multiple //thanks to Jacob Z for his idea to change this function -tb if(hits.empty()) return -1; // geo::TPCID tpcID = hits[0]->WireID().asTPCID(); -// const geo::TPCGeo& tpcGeo = GeometryService->GetElement(tpcID); - const geo::TPCGeo& tpcGeo = GeometryService->TPC(hits[0]->WireID()); - short int driftDirection_init = tpcGeo.DetectDriftDirection(); +// const geo::TPCGeo& tpcGeo = geometry.GetElement(tpcID); + auto const driftDirection_init = geometry.TPC(hits[0]->WireID()).DriftAxisWithSign(); int tpcid = (int)hits[0]->WireID().TPC; // for(size_t i = 0; i < hits.size(); i++){ // tpcID = hits[i]->WireID().asTPCID(); -// const geo::TPCGeo& tpcGeo_now = GeometryService->GetElement(tpcID); +// const geo::TPCGeo& tpcGeo_now = geometry.GetElement(tpcID); for(art::Ptr const& hit: hits){ - const geo::TPCGeo& tpcGeo_now = GeometryService->TPC(hit->WireID()); - short int driftDirection_now = tpcGeo_now.DetectDriftDirection(); + auto const driftDirection_now = geometry.TPC(hit->WireID()).DriftAxisWithSign(); if(driftDirection_now != driftDirection_init) {return -1;} } return tpcid; @@ -25,34 +27,35 @@ namespace icarus { }//end definition of int DetectedInTPC // Work out the drift limits for a collection of hits - std::pair XLimitsFromHits(const geo::GeometryCore *GeometryService, std::vector> const& hits){ + std::pair XLimitsFromHits(geo::GeometryCore const& geometry, + geo::WireReadoutGeom const& wireReadout, + std::vector> const& hits){ // If there are no hits then return 0 if(hits.empty()) return std::make_pair(0, 0); // If the track is stitched (in multiple TPCs) return 0 - if(DetectedInTPC(hits, GeometryService) == -1) return std::make_pair(0, 0); + if(DetectedInTPC(hits, geometry) == -1) return std::make_pair(0, 0); // Work out the drift direction // geo::TPCID tpcID = hits[0]->WireID().asTPCID(); -// const geo::TPCGeo& tpcGeo = GeometryService->GetElement(tpcID); - const geo::TPCGeo& tpcGeo = GeometryService->TPC(hits[0]->WireID()); +// const geo::TPCGeo& tpcGeo = geometry.GetElement(tpcID); + const geo::TPCGeo& tpcGeo = geometry.TPC(hits[0]->WireID()); return std::make_pair(tpcGeo.MinX(), tpcGeo.MaxX()); } - int DriftDirectionFromHits(const geo::GeometryCore *GeometryService, std::vector> const& hits){ + int DriftDirectionFromHits(const geo::GeometryCore& geometry, std::vector> const& hits){ // If there are no hits then return 0 if(hits.empty()) return 0; // If the track is stitched (in multiple TPCs) return 0 - if(DetectedInTPC(hits, GeometryService) == -1) return 0; + if(DetectedInTPC(hits, geometry) == -1) return 0; // Work out the drift direction // geo::TPCID tpcID = hits[0]->WireID().asTPCID(); -// const geo::TPCGeo& tpcGeo = GeometryService->GetElement(tpcID); - const geo::TPCGeo& tpcGeo = GeometryService->TPC(hits[0]->WireID()); - double driftDirection = tpcGeo.DetectDriftDirection(); - if(std::abs(driftDirection) != 1) driftDirection = 0; - return driftDirection; +// const geo::TPCGeo& tpcGeo = geometry.GetElement(tpcID); + auto const [axis, sign] = geometry.TPC(hits[0]->WireID()).DriftAxisWithSign(); + if(axis != geo::Coordinate::X) return 0; + return to_int(sign); } // Is point inside given TPC @@ -65,4 +68,3 @@ namespace icarus { } // namespace TPCGeoUtil } // namespace icarus - diff --git a/icaruscode/CRT/CRTUtils/TPCGeoUtil.h b/icaruscode/CRT/CRTUtils/TPCGeoUtil.h index 3dd144c00..4fd83b636 100644 --- a/icaruscode/CRT/CRTUtils/TPCGeoUtil.h +++ b/icaruscode/CRT/CRTUtils/TPCGeoUtil.h @@ -11,8 +11,8 @@ #include "messagefacility/MessageLogger/MessageLogger.h" // LArSoft -#include "larcore/Geometry/Geometry.h" -#include "larcorealg/Geometry/GeometryCore.h" +#include "larcorealg/Geometry/fwd.h" +#include "larcoreobj/SimpleTypesAndConstants/geo_vectors.h" #include "nusimdata/SimulationBase/MCParticle.h" #include "lardataobj/RecoBase/Hit.h" @@ -21,12 +21,14 @@ namespace icarus { namespace TPCGeoUtil { - int DetectedInTPC(std::vector> const& hits, const geo::GeometryCore *GeometryService); + int DetectedInTPC(std::vector> const& hits, geo::GeometryCore const& geometry); // Work out the drift limits for a collection of hits - std::pair XLimitsFromHits(const geo::GeometryCore *GeometryService, std::vector> const& hits); + std::pair XLimitsFromHits(geo::GeometryCore const& geometry, + geo::WireReadoutGeom const& wireReadout, + std::vector> const& hits); // Is point inside given TPC bool InsideTPC(geo::Point_t point, const geo::TPCGeo& tpc, double buffer); - int DriftDirectionFromHits(const geo::GeometryCore *GeometryService, std::vector> const& hits); + int DriftDirectionFromHits(const geo::GeometryCore& geometry, std::vector> const& hits); } // namespace TPCGeoUtil } // namespace icarus #endif diff --git a/icaruscode/CRT/CrtOpHitMatchAnalysis_module.cc b/icaruscode/CRT/CrtOpHitMatchAnalysis_module.cc index 5f0a8656e..4f9149f98 100644 --- a/icaruscode/CRT/CrtOpHitMatchAnalysis_module.cc +++ b/icaruscode/CRT/CrtOpHitMatchAnalysis_module.cc @@ -25,6 +25,7 @@ #include "larcore/CoreUtils/ServiceUtil.h" #include "lardata/DetectorInfoServices/DetectorClocksService.h" #include "larcorealg/Geometry/GeometryCore.h" +#include "larcore/Geometry/WireReadout.h" #include "larcore/Geometry/Geometry.h" //#include "larsim/MCCheater/PhotonBackTrackerService.h" @@ -169,6 +170,7 @@ class icarus::crt::CrtOpHitMatchAnalysis : public art::EDAnalyzer { vector> fFlashDelta; geo::GeometryCore const* fGeometryService; ///< pointer to Geometry provider + geo::WireReadoutGeom const* fChannelMapAlg; }; @@ -202,6 +204,7 @@ CrtOpHitMatchAnalysis::CrtOpHitMatchAnalysis(fhicl::ParameterSet const& p) // Get a pointer to the geometry service provider. fGeometryService = lar::providerFrom(); + fChannelMapAlg = &art::ServiceHandle()->Get(); art::ServiceHandle tfs; @@ -338,7 +341,7 @@ void CrtOpHitMatchAnalysis::analyze(art::Event const& e) double t = ophit->StartTime()*1e3-fOpDelay; fHitPE.push_back(ophit->PE()); fHitChan.push_back(ophit->OpChannel()); - auto const pos = fGeometryService->OpDetGeoFromOpChannel(ophit->OpChannel()).GetCenter(); + auto const pos = fChannelMapAlg->OpDetGeoFromOpChannel(ophit->OpChannel()).GetCenter(); fHitXYZT.push_back({pos.X(), pos.Y(), pos.Z(), t}); } @@ -576,7 +579,7 @@ void CrtOpHitMatchAnalysis::analyze(art::Event const& e) flashHitPE = hit->PE(); //FlashHit position/time - auto const pos = fGeometryService->OpDetGeoFromOpChannel(hit->OpChannel()).GetCenter(); + auto const pos = fChannelMapAlg->OpDetGeoFromOpChannel(hit->OpChannel()).GetCenter(); flashHitxyzt = {pos.X(), pos.Y(), pos.Z(), flashHitT}; flashHitDiff = (rcrt - pos).R(); } @@ -620,7 +623,7 @@ void CrtOpHitMatchAnalysis::analyze(art::Event const& e) pemax = hit->PE(); //hitXYZT - auto const pos = fGeometryService->OpDetGeoFromOpChannel(hit->OpChannel()).GetCenter(); + auto const pos = fChannelMapAlg->OpDetGeoFromOpChannel(hit->OpChannel()).GetCenter(); rdiff = (rcrt-pos).R(); //double vel = abs(vdiff.Mag()/(tcrt-thit)); diff --git a/icaruscode/Decode/DaqDecoderICARUSTPC_module.cc b/icaruscode/Decode/DaqDecoderICARUSTPC_module.cc index d2d91a689..2dc93bee0 100644 --- a/icaruscode/Decode/DaqDecoderICARUSTPC_module.cc +++ b/icaruscode/Decode/DaqDecoderICARUSTPC_module.cc @@ -39,8 +39,7 @@ #include "tbb/spin_mutex.h" #include "tbb/concurrent_vector.h" -#include "larcore/Geometry/Geometry.h" -#include "larcore/CoreUtils/ServiceUtil.h" // lar::providerFrom() +#include "larcore/Geometry/WireReadout.h" #include "lardata/DetectorInfoServices/DetectorClocksService.h" #include "lardataobj/RawData/RawDigit.h" @@ -135,8 +134,6 @@ class DaqDecoderICARUSTPC : public art::ReplicatedProducer size_t fFragmentOffset; ///< The fragment offset to set channel numbering - // Useful services, keep copies for now (we can update during begin run periods) - geo::GeometryCore const* fGeometry; ///< pointer to Geometry service }; DEFINE_ART_MODULE(DaqDecoderICARUSTPC) @@ -152,7 +149,7 @@ DaqDecoderICARUSTPC::DaqDecoderICARUSTPC(fhicl::ParameterSet const & pset, art:: art::ReplicatedProducer(pset, frame), fNumEvent(0) { - fGeometry = lar::providerFrom(); + geo::WireReadoutGeom const& wireReadoutAlg = art::ServiceHandle()->Get(); configure(pset); @@ -174,17 +171,17 @@ DaqDecoderICARUSTPC::DaqDecoderICARUSTPC(fhicl::ParameterSet const & pset, art:: // Compute the fragment offset from the channel number for the desired plane // Get a base channel number for the plane we want - mf::LogDebug("DaqDecoderICARUSTPC") << "ICARUS has " << fGeometry->Nchannels() << " in total with " << fGeometry->Views().size() << " views" << std::endl; + mf::LogDebug("DaqDecoderICARUSTPC") << "ICARUS has " << wireReadoutAlg.Nchannels() << " in total with " << wireReadoutAlg.Views().size() << " views" << std::endl; geo::WireID wireID(0, 0, fPlaneToSimulate, 0); mf::LogDebug("DaqDecoderICARUSTPC") << "WireID: " << wireID << std::endl; - geo::WireID firstWireID = fGeometry->GetBeginWireID(geo::PlaneID(0,0,fPlaneToSimulate)); + geo::WireID firstWireID = *wireReadoutAlg.begin(geo::PlaneID(0,0,fPlaneToSimulate)); mf::LogDebug("DaqDecoderICARUSTPC") << "From geo, first WireID: " << firstWireID << std::endl; - raw::ChannelID_t channel = fGeometry->PlaneWireToChannel(wireID); + raw::ChannelID_t channel = wireReadoutAlg.PlaneWireToChannel(wireID); mf::LogDebug("DaqDecoderICARUSTPC") << "Channel: " << channel << std::endl; @@ -194,7 +191,7 @@ DaqDecoderICARUSTPC::DaqDecoderICARUSTPC(fhicl::ParameterSet const & pset, art:: geo::PlaneID tempPlaneID = tempWireID.planeID(); mf::LogDebug("DaqDecoderICARUSTPC") << "thePlane: " << thePlane << ", WireID: " << tempWireID << ", channel: " << - fGeometry->PlaneWireToChannel(tempWireID) << ", view: " << fGeometry->View(tempPlaneID) << std::endl; + wireReadoutAlg.PlaneWireToChannel(tempWireID) << ", view: " << wireReadoutAlg.Plane(tempPlaneID).View() << std::endl; } fFragmentOffset = channel / 576; diff --git a/icaruscode/Decode/DaqDecoderICARUSTPCwROI_module.cc b/icaruscode/Decode/DaqDecoderICARUSTPCwROI_module.cc index d2dd16ac4..438eeaab3 100644 --- a/icaruscode/Decode/DaqDecoderICARUSTPCwROI_module.cc +++ b/icaruscode/Decode/DaqDecoderICARUSTPCwROI_module.cc @@ -40,6 +40,7 @@ #include "tbb/spin_mutex.h" #include "tbb/concurrent_vector.h" +#include "larcore/Geometry/WireReadout.h" #include "larcore/Geometry/Geometry.h" #include "lardata/DetectorInfoServices/DetectorClocksService.h" #include "lardataobj/RawData/RawDigit.h" @@ -211,6 +212,7 @@ DaqDecoderICARUSTPCwROI::DaqDecoderICARUSTPCwROI(fhicl::ParameterSet const & pse { fGeometry = art::ServiceHandle{}.get(); fChannelMap = art::ServiceHandle{}.get(); + geo::WireReadoutGeom const& wireReadoutAlg = art::ServiceHandle()->Get(); configure(pset); @@ -259,14 +261,14 @@ DaqDecoderICARUSTPCwROI::DaqDecoderICARUSTPCwROI(fhicl::ParameterSet const & pse { geo::PlaneID planeID(cryoIdx,logicalTPCIdx,planeIdx); - raw::ChannelID_t channel = fGeometry->PlaneWireToChannel(geo::WireID(planeID, 0)); + raw::ChannelID_t channel = wireReadoutAlg.PlaneWireToChannel(geo::WireID(planeID, 0)); - readout::ROPID ropID = fGeometry->ChannelToROP(channel); + readout::ROPID ropID = wireReadoutAlg.ChannelToROP(channel); fPlaneToROPPlaneMap[planeID] = ropID.ROP; fPlaneToWireOffsetMap[planeID] = channel; - planeToLastWireOffsetMap[planeID] = fGeometry->PlaneWireToChannel(geo::WireID(planeID, fGeometry->Nwires(planeID))); - fROPToNumWiresMap[ropID.ROP] = fGeometry->Nwires(planeID); + planeToLastWireOffsetMap[planeID] = wireReadoutAlg.PlaneWireToChannel(geo::WireID(planeID, wireReadoutAlg.Nwires(planeID))); + fROPToNumWiresMap[ropID.ROP] = wireReadoutAlg.Nwires(planeID); if (ropID.ROP > fNumROPs) fNumROPs = ropID.ROP; diff --git a/icaruscode/Decode/DecoderTools/FakeParticle_tool.cc b/icaruscode/Decode/DecoderTools/FakeParticle_tool.cc index ddd6610a7..91a1f10b7 100644 --- a/icaruscode/Decode/DecoderTools/FakeParticle_tool.cc +++ b/icaruscode/Decode/DecoderTools/FakeParticle_tool.cc @@ -17,7 +17,7 @@ #include "messagefacility/MessageLogger/MessageLogger.h" // LArSoft includes -#include "larcore/Geometry/Geometry.h" +#include "larcore/Geometry/WireReadout.h" #include "lardata/DetectorInfoServices/DetectorPropertiesService.h" // ICARUS package includes @@ -92,7 +92,7 @@ class FakeParticle : virtual public IFakeParticle FFTPointer fFFT; //< Object to handle thread safe FFT - const geo::Geometry* fGeometry; //< pointer to the Geometry service + const geo::WireReadoutGeom* fChannelMapAlg; const detinfo::DetectorProperties* fDetector; //< Pointer to the detector properties icarusutil::SignalShapingICARUSService* fSignalShapingService; //< Access to the response functions }; @@ -119,7 +119,7 @@ void FakeParticle::configure(fhicl::ParameterSet const &pset) fNumElectronsPerMM = pset.get("NumElectronsPerMM", 6000); fPlaneToSimulate = {0, 0, pset.get("PlaneToSimulate", 2)}; - fGeometry = art::ServiceHandle{}.get(); + fChannelMapAlg = &art::ServiceHandle()->Get(); fSignalShapingService = art::ServiceHandle{}.get(); // Convert ticks in us to mm by taking the drift velocity and multiplying by the tick period @@ -130,7 +130,7 @@ void FakeParticle::configure(fhicl::ParameterSet const &pset) fMMPerTick = driftVelocity * samplingRate; - fMMPerWire = fGeometry->WirePitch() * 10.; // wire pitch returned in cm, want mm + fMMPerWire = fChannelMapAlg->Plane({0, 0, 0}).WirePitch() * 10.; // wire pitch returned in cm, want mm // Get slope (tan(theta)) and related angles fTanTheta = std::tan(fStartAngle * M_PI / 180.); @@ -183,7 +183,7 @@ void FakeParticle::overlayFakeParticle(detinfo::DetectorClocksData const& clockD float asicGain = fSignalShapingService->GetASICGain(0) * sampling_rate(clockData) / 1000.; // something like 67.4 // Get a base channel number for the plane we want - raw::ChannelID_t channel = fGeometry->PlaneWireToChannel(geo::WireID{fPlaneToSimulate, 0}); + raw::ChannelID_t channel = fChannelMapAlg->PlaneWireToChannel(geo::WireID{fPlaneToSimulate, 0}); // Recover the response function information for this channel const icarus_tool::IResponse& response = fSignalShapingService->GetResponse(channel); diff --git a/icaruscode/Decode/DecoderTools/TPCDecoderFilter1D_tool.cc b/icaruscode/Decode/DecoderTools/TPCDecoderFilter1D_tool.cc index 83fccfa58..9cd94a71c 100644 --- a/icaruscode/Decode/DecoderTools/TPCDecoderFilter1D_tool.cc +++ b/icaruscode/Decode/DecoderTools/TPCDecoderFilter1D_tool.cc @@ -18,7 +18,7 @@ #include "messagefacility/MessageLogger/MessageLogger.h" // LArSoft includes -#include "larcore/Geometry/Geometry.h" +#include "larcore/Geometry/WireReadout.h" #include "sbndaq-artdaq-core/Overlays/ICARUS/PhysCrateFragment.hh" @@ -181,7 +181,7 @@ class TPCDecoderFilter1D : virtual public IDecoderFilter icarus_signal_processing::FilterFunctionVec fFilterFunctionVec; - const geo::Geometry* fGeometry; //< pointer to the Geometry service + const geo::WireReadoutGeom* fChannelMapAlg; //< pointer to the Geometry service const icarusDB::IICARUSChannelMap* fChannelMap; // Keep track of the FFT @@ -239,7 +239,7 @@ void TPCDecoderFilter1D::configure(fhicl::ParameterSet const &pset) for(const auto& idPair : tempIDVec) fFragmentIDMap[idPair.first] = idPair.second; - fGeometry = art::ServiceHandle{}.get(); + fChannelMapAlg = &art::ServiceHandle{}->Get(); fChannelMap = art::ServiceHandle{}.get(); fFFTFilterFunctionVec.clear(); @@ -473,7 +473,7 @@ void TPCDecoderFilter1D::process_fragment(detinfo::DetectorClocksData const&, if (fDiagnosticOutput) { - std::vector widVec = fGeometry->ChannelToWire(channelPlanePairVec[chanIdx].first); + std::vector widVec = fChannelMapAlg->ChannelToWire(channelPlanePairVec[chanIdx].first); if (widVec.empty()) std::cout << channelPlanePairVec[chanIdx].first << "/" << chanIdx << "=" << fFullRMSVals[channelOnBoard] << " * "; else std::cout << fChannelIDVec[channelOnBoard] << "-" << widVec[0].Cryostat << "/" << widVec[0].TPC << "/" << widVec[0].Plane << "/" << widVec[0].Wire << "=" << fFullRMSVals[channelOnBoard] << " * "; diff --git a/icaruscode/Decode/DecoderTools/TPCDecoderFilter2D_tool.cc b/icaruscode/Decode/DecoderTools/TPCDecoderFilter2D_tool.cc index 3ef5abc32..461b512a5 100644 --- a/icaruscode/Decode/DecoderTools/TPCDecoderFilter2D_tool.cc +++ b/icaruscode/Decode/DecoderTools/TPCDecoderFilter2D_tool.cc @@ -18,7 +18,7 @@ #include "messagefacility/MessageLogger/MessageLogger.h" // LArSoft includes -#include "larcore/Geometry/Geometry.h" +#include "larcore/Geometry/WireReadout.h" #include "sbndaq-artdaq-core/Overlays/ICARUS/PhysCrateFragment.hh" @@ -176,7 +176,7 @@ class TPCDecoderFilter2D : virtual public IDecoderFilter std::vector fPlaneVec; - const geo::Geometry* fGeometry; //< pointer to the Geometry service + const geo::WireReadoutGeom* fChannelMapAlg; const icarusDB::IICARUSChannelMap* fChannelMap; // Keep track of the FFT @@ -229,7 +229,7 @@ void TPCDecoderFilter2D::configure(fhicl::ParameterSet const &pset) for(const auto& idPair : tempIDVec) fFragmentIDMap[idPair.first] = idPair.second; - fGeometry = art::ServiceHandle{}.get(); + fChannelMapAlg = &art::ServiceHandle{}->Get(); fChannelMap = art::ServiceHandle{}.get(); // std::vector highPassSigma = {3.5, 3.5, 0.5}; @@ -416,7 +416,7 @@ void TPCDecoderFilter2D::process_fragment(detinfo::DetectorClocksData const&, if (fDiagnosticOutput) { - std::vector widVec = fGeometry->ChannelToWire(channelPlanePairVec[chanIdx].first); + std::vector widVec = fChannelMapAlg->ChannelToWire(channelPlanePairVec[chanIdx].first); if (widVec.empty()) std::cout << channelPlanePairVec[chanIdx].first << "/" << chanIdx << "=" << fFullRMSVals[channelOnBoard] << " * "; else std::cout << fChannelIDVec[channelOnBoard] << "-" << widVec[0].Cryostat << "/" << widVec[0].TPC << "/" << widVec[0].Plane << "/" << widVec[0].Wire << "=" << fFullRMSVals[channelOnBoard] << " * "; diff --git a/icaruscode/Decode/DecoderTools/TPCNoiseFilter1D_tool.cc b/icaruscode/Decode/DecoderTools/TPCNoiseFilter1D_tool.cc index 357d5a704..64e57e5fe 100644 --- a/icaruscode/Decode/DecoderTools/TPCNoiseFilter1D_tool.cc +++ b/icaruscode/Decode/DecoderTools/TPCNoiseFilter1D_tool.cc @@ -18,7 +18,7 @@ #include "messagefacility/MessageLogger/MessageLogger.h" // LArSoft includes -#include "larcore/Geometry/Geometry.h" +#include "larcore/Geometry/WireReadout.h" #include "sbndaq-artdaq-core/Overlays/ICARUS/PhysCrateFragment.hh" @@ -183,7 +183,7 @@ class TPCNoiseFilter1DMC : virtual public INoiseFilter icarus_signal_processing::FilterFunctionVec fFilterFunctionVec; - const geo::Geometry* fGeometry; //< pointer to the Geometry service + const geo::WireReadoutGeom* fChannelMapAlg; // Keep track of the FFT icarus_signal_processing::FFTFilterFunctionVec fFFTFilterFunctionVec; @@ -235,7 +235,7 @@ void TPCNoiseFilter1DMC::configure(fhicl::ParameterSet const &pset) fDenoiserType = pset.get("DenoiserType", "default"); - fGeometry = art::ServiceHandle{}.get(); + fChannelMapAlg = &art::ServiceHandle{}->Get(); fFFTFilterFunctionVec.clear(); @@ -318,7 +318,7 @@ void TPCNoiseFilter1DMC::process_fragment(detinfo::DetectorClocksData const&, fChannelIDVec[idx] = channelPlaneVec[idx].first; // We need to recover info on which plane we have - std::vector widVec = fGeometry->ChannelToWire(fChannelIDVec[idx]); + std::vector widVec = fChannelMapAlg->ChannelToWire(fChannelIDVec[idx]); // Handle the filter function to use for this channel // Note the modulus... this to enable a workaround for the wirecell 2D drift which misses the channels with no signal diff --git a/icaruscode/Decode/DecoderTools/TPCNoiseFilterCanny_tool.cc b/icaruscode/Decode/DecoderTools/TPCNoiseFilterCanny_tool.cc index 962f6967e..efb9ae3a2 100644 --- a/icaruscode/Decode/DecoderTools/TPCNoiseFilterCanny_tool.cc +++ b/icaruscode/Decode/DecoderTools/TPCNoiseFilterCanny_tool.cc @@ -18,7 +18,7 @@ #include "messagefacility/MessageLogger/MessageLogger.h" // LArSoft includes -#include "larcore/Geometry/Geometry.h" +#include "larcore/Geometry/WireReadout.h" #include "sbndaq-artdaq-core/Overlays/ICARUS/PhysCrateFragment.hh" @@ -205,7 +205,7 @@ class TPCNoiseFilterCannyMC : virtual public INoiseFilter icarus_signal_processing::FilterFunctionVec fFilterFunctionVec; - const geo::Geometry* fGeometry; //< pointer to the Geometry service + const geo::WireReadoutGeom* fChannelMapAlg; // Keep track of the FFT icarus_signal_processing::FFTFilterFunctionVec fFFTFilterFunctionVec; @@ -313,7 +313,7 @@ void TPCNoiseFilterCannyMC::configure(fhicl::ParameterSet const &pset) fBinaryDilation_SX, fBinaryDilation_SY); - fGeometry = art::ServiceHandle{}.get(); + fChannelMapAlg = &art::ServiceHandle{}->Get(); fFFTFilterFunctionVec.clear(); @@ -376,7 +376,7 @@ void TPCNoiseFilterCannyMC::process_fragment(detinfo::DetectorClocksData const&, fChannelIDVec[idx] = channelPlaneVec[idx].first; // We need to recover info on which plane we have - std::vector widVec = fGeometry->ChannelToWire(fChannelIDVec[idx]); + std::vector widVec = fChannelMapAlg->ChannelToWire(fChannelIDVec[idx]); // Handle the filter function to use for this channel unsigned int plane = widVec[0].Plane; diff --git a/icaruscode/Decode/FilterNoiseICARUS_module.cc b/icaruscode/Decode/FilterNoiseICARUS_module.cc index eb713e248..9145cf86e 100644 --- a/icaruscode/Decode/FilterNoiseICARUS_module.cc +++ b/icaruscode/Decode/FilterNoiseICARUS_module.cc @@ -39,8 +39,7 @@ #include "tbb/spin_mutex.h" #include "tbb/concurrent_vector.h" -#include "larcore/Geometry/Geometry.h" -#include "larcore/CoreUtils/ServiceUtil.h" // lar::providerFrom() +#include "larcore/Geometry/WireReadout.h" #include "lardata/DetectorInfoServices/DetectorClocksService.h" #include "lardataobj/RawData/RawDigit.h" @@ -133,8 +132,6 @@ class FilterNoiseICARUS : public art::ReplicatedProducer size_t fFragmentOffset; ///< The fragment offset to set channel numbering - // Useful services, keep copies for now (we can update during begin run periods) - geo::GeometryCore const* fGeometry; ///< pointer to Geometry service }; DEFINE_ART_MODULE(FilterNoiseICARUS) @@ -150,7 +147,7 @@ FilterNoiseICARUS::FilterNoiseICARUS(fhicl::ParameterSet const & pset, art::Proc art::ReplicatedProducer(pset, frame), fNumEvent(0) { - fGeometry = lar::providerFrom(); + geo::WireReadoutGeom const& wireReadoutAlg = art::ServiceHandle()->Get(); configure(pset); @@ -172,17 +169,17 @@ FilterNoiseICARUS::FilterNoiseICARUS(fhicl::ParameterSet const & pset, art::Proc // Compute the fragment offset from the channel number for the desired plane // Get a base channel number for the plane we want - mf::LogDebug("FilterNoiseICARUS") << "ICARUS has " << fGeometry->Nchannels() << " in total with " << fGeometry->Views().size() << " views" << std::endl; + mf::LogDebug("FilterNoiseICARUS") << "ICARUS has " << wireReadoutAlg.Nchannels() << " in total with " << wireReadoutAlg.Views().size() << " views" << std::endl; geo::WireID wireID(0, 0, fPlaneToSimulate, 0); mf::LogDebug("FilterNoiseICARUS") << "WireID: " << wireID << std::endl; - geo::WireID firstWireID = fGeometry->GetBeginWireID(geo::PlaneID(0,0,fPlaneToSimulate)); + geo::WireID firstWireID = *wireReadoutAlg.begin(geo::PlaneID(0,0,fPlaneToSimulate)); mf::LogDebug("FilterNoiseICARUS") << "From geo, first WireID: " << firstWireID << std::endl; - raw::ChannelID_t channel = fGeometry->PlaneWireToChannel(wireID); + raw::ChannelID_t channel = wireReadoutAlg.PlaneWireToChannel(wireID); mf::LogDebug("FilterNoiseICARUS") << "Channel: " << channel << std::endl; @@ -192,7 +189,7 @@ FilterNoiseICARUS::FilterNoiseICARUS(fhicl::ParameterSet const & pset, art::Proc geo::PlaneID tempPlaneID = tempWireID.planeID(); mf::LogDebug("FilterNoiseICARUS") << "thePlane: " << thePlane << ", WireID: " << tempWireID << ", channel: " << - fGeometry->PlaneWireToChannel(tempWireID) << ", view: " << fGeometry->View(tempPlaneID) << std::endl; + wireReadoutAlg.PlaneWireToChannel(tempWireID) << ", view: " << wireReadoutAlg.Plane(tempPlaneID).View() << std::endl; } fFragmentOffset = channel / 576; diff --git a/icaruscode/Decode/MCDecoderICARUSTPCwROI_module.cc b/icaruscode/Decode/MCDecoderICARUSTPCwROI_module.cc index 1ee387e0c..afb9a1ccc 100644 --- a/icaruscode/Decode/MCDecoderICARUSTPCwROI_module.cc +++ b/icaruscode/Decode/MCDecoderICARUSTPCwROI_module.cc @@ -40,7 +40,7 @@ #include "tbb/spin_mutex.h" #include "tbb/concurrent_vector.h" -#include "larcore/Geometry/Geometry.h" +#include "larcore/Geometry/WireReadout.h" #include "lardata/DetectorInfoServices/DetectorClocksService.h" #include "lardataobj/RawData/RawDigit.h" #include "lardataobj/RawData/raw.h" @@ -198,7 +198,7 @@ class MCDecoderICARUSTPCwROI : public art::ReplicatedProducer std::vector> fDecoderToolVec; ///< Decoder tools // Useful services, keep copies for now (we can update during begin run periods) - geo::GeometryCore const* fGeometry; ///< pointer to Geometry service + geo::WireReadoutGeom const* fChannelMapAlg; const icarusDB::IICARUSChannelMap* fChannelMap; }; @@ -215,7 +215,7 @@ MCDecoderICARUSTPCwROI::MCDecoderICARUSTPCwROI(fhicl::ParameterSet const & pset, art::ReplicatedProducer(pset, frame), fLogCategory("MCDecoderICARUSTPCwROI"),fNumEvent(0), fNumROPs(0) { - fGeometry = art::ServiceHandle{}.get(); + fChannelMapAlg = &art::ServiceHandle()->Get(); fChannelMap = art::ServiceHandle{}.get(); configure(pset); @@ -262,14 +262,14 @@ MCDecoderICARUSTPCwROI::MCDecoderICARUSTPCwROI(fhicl::ParameterSet const & pset, { geo::PlaneID planeID(cryoIdx,logicalTPCIdx,planeIdx); - raw::ChannelID_t channel = fGeometry->PlaneWireToChannel(geo::WireID(planeID, 0)); + raw::ChannelID_t channel = fChannelMapAlg->PlaneWireToChannel(geo::WireID(planeID, 0)); - readout::ROPID ropID = fGeometry->ChannelToROP(channel); + readout::ROPID ropID = fChannelMapAlg->ChannelToROP(channel); fPlaneToROPPlaneMap[planeID] = ropID.ROP; fPlaneToWireOffsetMap[planeID] = channel; - planeToLastWireOffsetMap[planeID] = fGeometry->PlaneWireToChannel(geo::WireID(planeID, fGeometry->Nwires(planeID))); - fROPToNumWiresMap[ropID.ROP] = fGeometry->Nwires(planeID); + planeToLastWireOffsetMap[planeID] = fChannelMapAlg->PlaneWireToChannel(geo::WireID(planeID, fChannelMapAlg->Nwires(planeID))); + fROPToNumWiresMap[ropID.ROP] = fChannelMapAlg->Nwires(planeID); // Special case handling // if (ropID.ROP > 1) fROPToNumWiresMap[ropID.ROP] *= 2; @@ -692,7 +692,7 @@ void MCDecoderICARUSTPCwROI::processSingleImage(const detinfo::DetectorClocksDat roiIdx++; } - concurrentROIs.push_back(recob::WireCreator(std::move(ROIVec),channel,fGeometry->View(channel)).move()); + concurrentROIs.push_back(recob::WireCreator(std::move(ROIVec),channel,fChannelMapAlg->View(channel)).move()); }//loop over channel indices return; diff --git a/icaruscode/Filters/FilterCRTPMTMatching_module.cc b/icaruscode/Filters/FilterCRTPMTMatching_module.cc index d1e318b32..85e1005f9 100644 --- a/icaruscode/Filters/FilterCRTPMTMatching_module.cc +++ b/icaruscode/Filters/FilterCRTPMTMatching_module.cc @@ -19,8 +19,7 @@ // LArSoft includes #include "larcore/CoreUtils/ServiceUtil.h" -#include "larcore/Geometry/Geometry.h" -#include "larcorealg/Geometry/GeometryCore.h" +#include "larcore/Geometry/WireReadout.h" #include "lardata/DetectorInfoServices/DetectorClocksService.h" // Data product includes @@ -61,13 +60,13 @@ class icarus::crt::FilterCRTPMTMatching : public art::EDFilter { * and it tries to match them with one or more CRT Hits using a configurable * time interval, which, at the time (19/04/2023) is chosen as +/-100 ns. * If the flash is matched, the relative time will determine if the mu candidate - * is entering or exiting the TPC. Depending on the amound and relative time of + * is entering or exiting the TPC. Depending on the amound and relative time of * the match, a classification is provided to the flash. * The filtering module has 3 options: loose (everything goes through), medium * (removes events where the flash is matched with one Top CRT hit before the * flash) and tight (removes all the events where the flashes are matched with * CRT hits before the Flash). - * If multiple flashes are in the beam gate, the filtering logic applies to the + * If multiple flashes are in the beam gate, the filtering logic applies to the * AND of the flashes classification. * For questions and maintenance ask Francesco Poppi. */ @@ -210,12 +209,12 @@ bool icarus::crt::FilterCRTPMTMatching::filter(art::Event& e) { std::vector EventFlashes; for(auto const & crtpmt : crtpmtMatches) { if(fSpillOnly==true){ - if(crtpmt.flashInBeam==1) EventFlashes.push_back(crtpmt); + if(crtpmt.flashInBeam==1) EventFlashes.push_back(crtpmt); } else { - if(crtpmt.flashInGate==1) EventFlashes.push_back(crtpmt); + if(crtpmt.flashInGate==1) EventFlashes.push_back(crtpmt); } - } + } bool hasOnlyCosmics = false; if (fFilterLevel == "loose") { @@ -231,11 +230,11 @@ bool icarus::crt::FilterCRTPMTMatching::filter(art::Event& e) { f.flashClassification == sbn::crt::MatchType::enTop_mult || f.flashClassification == sbn::crt::MatchType::enTop_exSide_mult) { isCosmic = true; - } - // With Medium filter, everything (inTime) which is associated with Top + } + // With Medium filter, everything (inTime) which is associated with Top // CRT Hit before the Flash is filtered as clear cosmic else - isCosmic = false; + isCosmic = false; hasOnlyCosmics = hasOnlyCosmics && isCosmic; } } @@ -265,9 +264,9 @@ bool icarus::crt::FilterCRTPMTMatching::filter(art::Event& e) { finBeam = f.flashInBeam; fFlashBeamTime_ns = f.flashGateTime*1e3; for (const auto& crt : f.matchedCRTHits){ - fCRTHitPos_X.push_back(crt.position.X()); - fCRTHitPos_Y.push_back(crt.position.Y()); - fCRTHitPos_Z.push_back(crt.position.Z()); + fCRTHitPos_X.push_back(crt.position.X()); + fCRTHitPos_Y.push_back(crt.position.Y()); + fCRTHitPos_Z.push_back(crt.position.Z()); fCRTHitTime_us.push_back(crt.time); fCRTFlashTime_ns.push_back(crt.PMTTimeDiff*1e3); fCRTHitRegion.push_back(crt.region); diff --git a/icaruscode/Filters/FilterDirts_module.cc b/icaruscode/Filters/FilterDirts_module.cc index e5e3d41b0..66fce38a8 100644 --- a/icaruscode/Filters/FilterDirts_module.cc +++ b/icaruscode/Filters/FilterDirts_module.cc @@ -437,7 +437,7 @@ unsigned int icarus::simfilter::FilterDirts::addVolumeByName { std::smatch match; return (std::regex_match(s, match, pattern)); }; auto const findVolume = [&volumePaths, &patternMatcher=matchMe](auto& path) { - if (patternMatcher(path.current().GetVolume()->GetName())) + if (patternMatcher(path.current()->GetVolume()->GetName())) volumePaths.push_back(path); return true; }; @@ -461,11 +461,11 @@ unsigned int icarus::simfilter::FilterDirts::addVolumeByName // // find the coordinates of the volume in local coordinates // - TGeoShape const* pShape = path.current().GetVolume()->GetShape(); + TGeoShape const* pShape = path.current()->GetVolume()->GetShape(); auto pBox = dynamic_cast(pShape); if (!pBox) { throw cet::exception("FilterDirts") << "Volume '" - << path.current().GetName() << "' is a " << pShape->IsA()->GetName() + << path.current()->GetName() << "' is a " << pShape->IsA()->GetName() << ", not a TGeoBBox.\n"; } @@ -493,7 +493,7 @@ unsigned int icarus::simfilter::FilterDirts::addVolumeByName mf::LogVerbatim(fLogCategory) << " c* [volume #" << fVolumes.size() << "] volume box '" - << path.current().GetVolume()->GetName() + << path.current()->GetVolume()->GetName() << "' [(" << (iVolume + 1U) << "/" << volumePaths.size() << "): [ " << box.Min() << " -- " << box.Max() << " ]"; diff --git a/icaruscode/Filters/FilterNeutrinosActiveVolume_module.cc b/icaruscode/Filters/FilterNeutrinosActiveVolume_module.cc index b663c22b5..8f62a11ff 100644 --- a/icaruscode/Filters/FilterNeutrinosActiveVolume_module.cc +++ b/icaruscode/Filters/FilterNeutrinosActiveVolume_module.cc @@ -504,7 +504,7 @@ unsigned int icarus::simfilter::FilterNeutrinosActiveVolume::addVolumeByName { std::smatch match; return (std::regex_match(s, match, pattern)); }; auto const findVolume = [&volumePaths, &patternMatcher=matchMe](auto& path) { - if (patternMatcher(path.current().GetVolume()->GetName())) + if (patternMatcher(path.current()->GetVolume()->GetName())) volumePaths.push_back(path); return true; }; @@ -528,11 +528,11 @@ unsigned int icarus::simfilter::FilterNeutrinosActiveVolume::addVolumeByName // // find the coordinates of the volume in local coordinates // - TGeoShape const* pShape = path.current().GetVolume()->GetShape(); + TGeoShape const* pShape = path.current()->GetVolume()->GetShape(); auto pBox = dynamic_cast(pShape); if (!pBox) { throw cet::exception("FilterNeutrinosActiveVolume") << "Volume '" - << path.current().GetName() << "' is a " << pShape->IsA()->GetName() + << path.current()->GetName() << "' is a " << pShape->IsA()->GetName() << ", not a TGeoBBox.\n"; } @@ -560,7 +560,7 @@ unsigned int icarus::simfilter::FilterNeutrinosActiveVolume::addVolumeByName mf::LogVerbatim(fLogCategory) << " c* [volume #" << fVolumes.size() << "] volume box '" - << path.current().GetVolume()->GetName() + << path.current()->GetVolume()->GetName() << "' [(" << (iVolume + 1U) << "/" << volumePaths.size() << "): [ " << box.Min() << " -- " << box.Max() << " ]"; diff --git a/icaruscode/Geometry/AuxDetGeoObjectSorterICARUS_tool.cc b/icaruscode/Geometry/AuxDetGeoObjectSorterICARUS_tool.cc new file mode 100644 index 000000000..781af06fa --- /dev/null +++ b/icaruscode/Geometry/AuxDetGeoObjectSorterICARUS_tool.cc @@ -0,0 +1,4 @@ +#include "icarusalg/Geometry/AuxDetGeoObjectSorterICARUS.h" +#include "art/Utilities/ToolMacros.h" + +DEFINE_ART_CLASS_TOOL(geo::AuxDetGeoObjectSorterICARUS) diff --git a/icaruscode/Geometry/CMakeLists.txt b/icaruscode/Geometry/CMakeLists.txt index 8d0064144..0606729a1 100644 --- a/icaruscode/Geometry/CMakeLists.txt +++ b/icaruscode/Geometry/CMakeLists.txt @@ -1,4 +1,3 @@ - art_make_library() set( SERVICE_LIBRARIES icarusalg::Geometry @@ -28,6 +27,7 @@ set( TOOL_LIBRARIES ) -cet_build_plugin(ICARUSsplitInductionChannelMapSetupTool art::tool LIBRARIES ${TOOL_LIBRARIES}) -cet_build_plugin(IcarusGeometryHelper art::service LIBRARIES ${SERVICE_LIBRARIES}) - +cet_build_plugin(AuxDetGeoObjectSorterICARUS art::tool LIBRARIES ${TOOL_LIBRARIES}) +cet_build_plugin(GeoObjectSorterPMTasTPC art::tool LIBRARIES ${TOOL_LIBRARIES}) +cet_build_plugin(ICARUSsplitInductionWireReadoutSetupTool art::tool LIBRARIES ${TOOL_LIBRARIES}) +cet_build_plugin(IcarusWireReadout art::service LIBRARIES ${SERVICE_LIBRARIES}) diff --git a/icaruscode/Geometry/GeoObjectSorterPMTasTPC_tool.cc b/icaruscode/Geometry/GeoObjectSorterPMTasTPC_tool.cc new file mode 100644 index 000000000..dd9765a10 --- /dev/null +++ b/icaruscode/Geometry/GeoObjectSorterPMTasTPC_tool.cc @@ -0,0 +1,4 @@ +#include "icarusalg/Geometry/GeoObjectSorterPMTasTPC.h" +#include "art/Utilities/ToolMacros.h" + +DEFINE_ART_CLASS_TOOL(icarus::GeoObjectSorterPMTasTPC) diff --git a/icaruscode/Geometry/ICARUSsplitInductionChannelMapSetupTool_tool.cc b/icaruscode/Geometry/ICARUSsplitInductionWireReadoutSetupTool_tool.cc similarity index 50% rename from icaruscode/Geometry/ICARUSsplitInductionChannelMapSetupTool_tool.cc rename to icaruscode/Geometry/ICARUSsplitInductionWireReadoutSetupTool_tool.cc index bc1d54a5e..43920b496 100644 --- a/icaruscode/Geometry/ICARUSsplitInductionChannelMapSetupTool_tool.cc +++ b/icaruscode/Geometry/ICARUSsplitInductionWireReadoutSetupTool_tool.cc @@ -1,19 +1,20 @@ /** - * @file icaruscode/Geometry/ICARUSsplitInductionChannelMapSetupTool_tool.cc + * @file icaruscode/Geometry/ICARUSsplitInductionWireReadoutSetupTool_tool.cc * @brief Tool to create ICARUS channel mapper with split induction wires. * @author Gianluca Petrillo (petrillo@slac.stanford.edu) * @date October 7, 2019 - * @see `larcore/Geometry/ChannelMapSetupTool.h` - * + * @see `larcore/Geometry/WireReadoutSetupTool.h` + * * This library is header-only. */ // ICARUS libraries -#include "icarusalg/Geometry/ICARUSChannelMapAlg.h" +#include "icarusalg/Geometry/ICARUSWireReadoutGeom.h" // LArSoft libraries -#include "larcore/Geometry/ChannelMapSetupTool.h" -#include "larcorealg/Geometry/ChannelMapAlg.h" +#include "larcore/Geometry/Geometry.h" +#include "larcore/Geometry/WireReadoutSetupTool.h" +#include "larcorealg/Geometry/WireReadoutGeom.h" // framework libraries #include "art/Utilities/ToolConfigTable.h" @@ -22,76 +23,74 @@ // ----------------------------------------------------------------------------- namespace icarus { - class ICARUSsplitInductionChannelMapSetupTool; + class ICARUSsplitInductionWireReadoutSetupTool; } // namespace icarus /** * @brief Interface for a tool creating the standard ICARUS channel mapper. - * - * This tool creates a `icarus::ICARUSChannelMapAlg` mapper. - * + * + * This tool creates a `icarus::ICARUSWireReadoutGeom` mapper. + * */ -class icarus::ICARUSsplitInductionChannelMapSetupTool - : public geo::ChannelMapSetupTool +class icarus::ICARUSsplitInductionWireReadoutSetupTool + : public geo::WireReadoutSetupTool { - + /// Type of channel mapping algorithm being created. - using Mapper_t = icarus::ICARUSChannelMapAlg; - + using Mapper_t = icarus::ICARUSWireReadoutGeom; + public: - + using Parameters = art::ToolConfigTable; - - + + /// Constructor: passes all parameters to the channel mapping algorithm. - ICARUSsplitInductionChannelMapSetupTool(Parameters const& config); - - + ICARUSsplitInductionWireReadoutSetupTool(Parameters const& config); + + protected: - - std::unique_ptr fChannelMap; - - + + Mapper_t::Config fParams; + + // --- BEGIN -- Virtual interface implementation --------------------------- /// @name Virtual interface /// @{ - + /// Returns a pointer to the channel mapping. - virtual std::unique_ptr doChannelMap() override - { return std::move(fChannelMap); } - + std::unique_ptr doWireReadout( + geo::GeometryCore const* geom, + std::unique_ptr sorter) override; + /// @} // --- END -- Virtual interface implementation ----------------------------- - - - /// Creates and returns the channel mapping algorithm. - std::unique_ptr makeChannelMap - (Mapper_t::Config const& config) const; - -}; // class icarus::ICARUSsplitInductionChannelMapSetupTool + + +}; // class icarus::ICARUSsplitInductionWireReadoutSetupTool // ----------------------------------------------------------------------------- // --- Implementation // ----------------------------------------------------------------------------- -icarus::ICARUSsplitInductionChannelMapSetupTool::ICARUSsplitInductionChannelMapSetupTool +icarus::ICARUSsplitInductionWireReadoutSetupTool::ICARUSsplitInductionWireReadoutSetupTool (Parameters const& config) - : fChannelMap(makeChannelMap(config())) + : fParams{config()} {} // ----------------------------------------------------------------------------- -auto icarus::ICARUSsplitInductionChannelMapSetupTool::makeChannelMap - (Mapper_t::Config const& config) const -> std::unique_ptr +std::unique_ptr +icarus::ICARUSsplitInductionWireReadoutSetupTool::doWireReadout + (geo::GeometryCore const* geom, std::unique_ptr sorter) { - return std::make_unique(config); -} // icarus::ICARUSsplitInductionChannelMapSetupTool::makeChannelMap() + return std::make_unique(fParams, geom, std::move(sorter)); +} // ----------------------------------------------------------------------------- -DEFINE_ART_CLASS_TOOL(icarus::ICARUSsplitInductionChannelMapSetupTool) +DEFINE_ART_CLASS_TOOL(icarus::ICARUSsplitInductionWireReadoutSetupTool) // ----------------------------------------------------------------------------- diff --git a/icaruscode/Geometry/IcarusGeometryHelper_service.cc b/icaruscode/Geometry/IcarusGeometryHelper_service.cc deleted file mode 100644 index 2aa4d592a..000000000 --- a/icaruscode/Geometry/IcarusGeometryHelper_service.cc +++ /dev/null @@ -1,76 +0,0 @@ -/** - * @file icaruscode/Geometry/IcarusGeometryHelper_service.cc - * @brief Geometry helper service for ICARUS geometries: implementation file. - * @see `icaruscode/Geometry/IcarusGeometryHelper.h` - */ - -// library header -#include "icaruscode/Geometry/IcarusGeometryHelper.h" - -// LArSoft libraries -#include "larcore/Geometry/ChannelMapSetupTool.h" -#include "larcorealg/Geometry/ChannelMapAlg.h" - -// framework libraries -#include "art/Utilities/make_tool.h" -#include "art/Framework/Services/Registry/ServiceDefinitionMacros.h" -#include "messagefacility/MessageLogger/MessageLogger.h" - -// C/C++ standard libraries -#include - - - -//------------------------------------------------------------------------------ -namespace { - - // name of the tool to create the default channel mapping algorithm - std::string const DefaultChannelMapSetupTool - = "ICARUSsplitInductionChannelMapSetupTool"; - -} // local namespace - - -//------------------------------------------------------------------------------ -auto icarus::IcarusGeometryHelper::doConfigureChannelMapAlg( - fhicl::ParameterSet const& /* sortingParameters */, - std::string const& detectorName - ) const -> ChannelMapAlgPtr_t -{ - // - // detector type check - // - if (detectorName.find("icarus") == std::string::npos) { - MF_LOG_WARNING("IcarusGeometryHelper") - << "Using a ICARUS channel mapping with an unsupported (non-ICARUS?)" - " detector geometry"; - } // if not ICARUS detector - - // - // channel mapping creation and setup - // - return makeChannelMapping(fPset); - -} // icarus::IcarusGeometryHelper::doConfigureChannelMapAlg() - - -//------------------------------------------------------------------------------ -std::unique_ptr -icarus::IcarusGeometryHelper::makeChannelMapping - (fhicl::ParameterSet const& parameters) const -{ - fhicl::ParameterSet mapperDefaultSet; - mapperDefaultSet.put("tool_type", DefaultChannelMapSetupTool); - auto channelMapSetupTool = art::make_tool - (parameters.get("Mapper", mapperDefaultSet)); - - return channelMapSetupTool->setupChannelMap(); -} // icarus::IcarusGeometryHelper::makeChannelMapping() - - -//------------------------------------------------------------------------------ -DEFINE_ART_SERVICE_INTERFACE_IMPL - (icarus::IcarusGeometryHelper, geo::ExptGeoHelperInterface) - - -//------------------------------------------------------------------------------ diff --git a/icaruscode/Geometry/IcarusGeometryHelper.h b/icaruscode/Geometry/IcarusWireReadout.h similarity index 56% rename from icaruscode/Geometry/IcarusGeometryHelper.h rename to icaruscode/Geometry/IcarusWireReadout.h index c6939ff58..55f221462 100644 --- a/icaruscode/Geometry/IcarusGeometryHelper.h +++ b/icaruscode/Geometry/IcarusWireReadout.h @@ -4,15 +4,15 @@ * @see `icaruscode/Geometry/IcarusGeometryHelper_service.cc` * * Handles Icarus-specific information for the generic Geometry service - * within LArSoft. Derived from the `geo::ExptGeoHelperInterface` class. + * within LArSoft. Derived from the `geo::WireReadout` class. */ -#ifndef ICARUSCODE_GEOMETRY_ICARUSGEOMETRYHELPER_H -#define ICARUSCODE_GEOMETRY_ICARUSGEOMETRYHELPER_H +#ifndef ICARUSCODE_GEOMETRY_ICARUSWIREREADOUT_H +#define ICARUSCODE_GEOMETRY_ICARUSWIREREADOUT_H // LArSoft libraries -// #include "larcore/Geometry/ChannelMapSetupTool.h" -#include "larcore/Geometry/ExptGeoHelperInterface.h" +#include "larcorealg/Geometry/fwd.h" +#include "larcore/Geometry/WireReadout.h" // framework libraries #include "art/Framework/Services/Registry/ServiceDeclarationMacros.h" @@ -24,12 +24,11 @@ // ----------------------------------------------------------------------------- // Forward declarations -namespace geo { class ChannelMapAlg; } -namespace icarus { class IcarusGeometryHelper; } +namespace icarus { class IcarusWireReadout; } // ----------------------------------------------------------------------------- /** - * @brief Implementation of `geo::ExptGeoHelperInterface` for ICARUS. + * @brief Implementation of `geo::WireReadout` for ICARUS. * * This service utilizes a _art_ tool to create the proper channel mapper * algorithm instance. @@ -47,35 +46,27 @@ namespace icarus { class IcarusGeometryHelper; } * * */ -class icarus::IcarusGeometryHelper: public geo::ExptGeoHelperInterface { +class icarus::IcarusWireReadout: public geo::WireReadout { public: /// Constructor: records the configuration. - IcarusGeometryHelper(fhicl::ParameterSet const& pset): fPset(pset) {} + IcarusWireReadout(fhicl::ParameterSet const& pset); private: - fhicl::ParameterSet fPset; ///< Copy of configuration parameter set. + std::unique_ptr fWireReadoutGeom; // --- BEGIN -- Virtual interface definitions -------------------------------- - virtual ChannelMapAlgPtr_t doConfigureChannelMapAlg( - fhicl::ParameterSet const& /* sortingParameters */, - std::string const& detectorName - ) const override; - + geo::WireReadoutGeom const& wireReadoutGeom() const override { return *fWireReadoutGeom; } // --- END -- Virtual interface definitions ---------------------------------- - /// Creates and returns the channel mapping instance via a _art_ tool. - std::unique_ptr makeChannelMapping - (fhicl::ParameterSet const& parameters) const; - -}; // icarus::IcarusGeometryHelper +}; // icarus::IcarusWireReadout // ----------------------------------------------------------------------------- -DECLARE_ART_SERVICE_INTERFACE_IMPL(icarus::IcarusGeometryHelper, - geo::ExptGeoHelperInterface, +DECLARE_ART_SERVICE_INTERFACE_IMPL(icarus::IcarusWireReadout, + geo::WireReadout, SHARED) -#endif // ICARUSCODE_GEOMETRY_ICARUSGEOMETRYHELPER_H +#endif // ICARUSCODE_GEOMETRY_ICARUSWIREREADOUT_H diff --git a/icaruscode/Geometry/IcarusWireReadout_service.cc b/icaruscode/Geometry/IcarusWireReadout_service.cc new file mode 100644 index 000000000..9b1842667 --- /dev/null +++ b/icaruscode/Geometry/IcarusWireReadout_service.cc @@ -0,0 +1,71 @@ +/** + * @file icaruscode/Geometry/IcarusWireReadout_service.cc + * @brief Geometry helper service for ICARUS geometries: implementation file. + * @see `icaruscode/Geometry/IcarusWireReadout.h` + */ + +// library header +#include "icaruscode/Geometry/IcarusWireReadout.h" + +// LArSoft libraries +#include "larcore/Geometry/Geometry.h" +#include "larcore/Geometry/WireReadoutSetupTool.h" +#include "larcorealg/Geometry/WireReadoutGeom.h" + +// framework libraries +#include "art/Utilities/make_tool.h" +#include "art/Framework/Services/Registry/ServiceHandle.h" +#include "art/Framework/Services/Registry/ServiceDefinitionMacros.h" +#include "messagefacility/MessageLogger/MessageLogger.h" + +// C/C++ standard libraries +#include + + + +//------------------------------------------------------------------------------ +namespace { + + // name of the tool to create the default channel mapping algorithm + std::string const DefaultChannelMapSetupTool + = "ICARUSsplitInductionChannelMapSetupTool"; + + std::unique_ptr + makeChannelMapping(fhicl::ParameterSet const& parameters, geo::GeometryCore const* geom) + { + fhicl::ParameterSet mapperDefaultSet; + mapperDefaultSet.put("tool_type", DefaultChannelMapSetupTool); + auto wireReadoutSetupTool = art::make_tool + (parameters.get("Mapper", mapperDefaultSet)); + auto wireReadoutSorter = art::make_tool + (parameters.get("SortingParameters")); + + return wireReadoutSetupTool->setupWireReadout(geom, std::move(wireReadoutSorter)); + } +} // local namespace + + +//------------------------------------------------------------------------------ +icarus::IcarusWireReadout::IcarusWireReadout(fhicl::ParameterSet const& pset) +{ + // detector type check + art::ServiceHandle geom; + if (geom->DetectorName().find("icarus") == std::string::npos) { + MF_LOG_WARNING("IcarusWireReadout") + << "Using a ICARUS channel mapping with an unsupported (non-ICARUS?)" + " detector geometry"; + } // if not ICARUS detector + + fWireReadoutGeom = makeChannelMapping(pset, geom.get()); +} + + +//------------------------------------------------------------------------------ + + +//------------------------------------------------------------------------------ +DEFINE_ART_SERVICE_INTERFACE_IMPL + (icarus::IcarusWireReadout, geo::WireReadout) + + +//------------------------------------------------------------------------------ diff --git a/icaruscode/Geometry/dump_icarus_geometry.fcl b/icaruscode/Geometry/dump_icarus_geometry.fcl deleted file mode 100644 index 1d0468831..000000000 --- a/icaruscode/Geometry/dump_icarus_geometry.fcl +++ /dev/null @@ -1,65 +0,0 @@ -# -# File: dump_icarus_geometry.fcl -# Purpouse: Job dumping ICARUS current geomerty into `ICARUS_geometry.txt` file. -# Author: Gianluca Petrillo (petrillo@slac.stanford.edu) -# Date: May 30, 2018 -# Version: 1.0 -# -# This job uses the "default" ICARUS geometry, as configured in the -# `icarus_geometry_services` configuration table. -# -# Service dependencies: -# * Geometry service -# * message facility -# - -#include "geometry_icarus.fcl" -#include "messages_icarus.fcl" - - -process_name: GeometryDump - - -services: { - # use a specific configuration which dumps the geometry on a file. - message: { - destinations: { - GeometryLog: { - type: file - - filename: "ICARUS-geometry.txt" - threshold: INFO - categories: { - DumpGeometry: { limit: -1 } - default: { limit: 0 } - } - } - CriticalLog: { - type: cerr - threshold: SYSTEM - } - # LogDebugFile: @local::message_debugfile_icarus - } # destinations - } # message - - @table::icarus_geometry_services - -} # services - - -physics: { - analyzers: { - geometrydump: { - module_type: DumpGeometry - - # message facility category for the output (default: "DumpGeometry") - outputCategory: "DumpGeometry" - } - } # analyzers - - dumpers: [ geometrydump ] - - end_paths: [ dumpers ] - -} # physics - diff --git a/icaruscode/PMT/Algorithms/PMTverticalSlicingAlg.h b/icaruscode/PMT/Algorithms/PMTverticalSlicingAlg.h index bf1743b64..b97f18b5e 100644 --- a/icaruscode/PMT/Algorithms/PMTverticalSlicingAlg.h +++ b/icaruscode/PMT/Algorithms/PMTverticalSlicingAlg.h @@ -11,6 +11,7 @@ // LArSoft libraries #include "larcorealg/CoreUtils/StdUtils.h" // util::begin(), util::end() +#include "larcorealg/Geometry/fwd.h" #include "larcoreobj/SimpleTypesAndConstants/geo_vectors.h" // geo::Vector_t // framework libraries @@ -22,16 +23,6 @@ #include -// ----------------------------------------------------------------------------- -// --- forward declarations -// --- -namespace geo { - class GeometryCore; - class CryostatGeo; - class OpDetGeo; -} // namespace geo - - //------------------------------------------------------------------------------ namespace icarus::trigger { class PMTverticalSlicingAlg; } /** @@ -64,7 +55,8 @@ class icarus::trigger::PMTverticalSlicingAlg { /// Computes slices from all PMT in `cryo` and appends them to `slices`. - void appendCryoSlices(Slices_t& slices, geo::CryostatGeo const& cryo) const; + void appendCryoSlices(Slices_t& slices, + geo::CryostatGeo const& cryo) const; /** * @brief Groups optical detectors under the specified cryostat into walls. diff --git a/icaruscode/PMT/Calibration/PMTBackgroundphotonsCalibration_module.cc b/icaruscode/PMT/Calibration/PMTBackgroundphotonsCalibration_module.cc index fcae9b439..994966ac8 100644 --- a/icaruscode/PMT/Calibration/PMTBackgroundphotonsCalibration_module.cc +++ b/icaruscode/PMT/Calibration/PMTBackgroundphotonsCalibration_module.cc @@ -15,7 +15,7 @@ // //////////////////////////////////////////////////////////////////////// -#include "larcore/Geometry/Geometry.h" +#include "larcore/Geometry/WireReadout.h" #include "larcore/CoreUtils/ServiceUtil.h" // lar::providerFrom() #include "art/Framework/Core/EDAnalyzer.h" @@ -158,8 +158,7 @@ void pmtcalo::PMTBackgroundphotonsCalibration::beginJob() m_ophit_tree->Branch("amplitude", &m_amplitude, "amplitude/D" ); m_ophit_tree->Branch("integral", &m_integral, "integral/D" ); - auto const geop = lar::providerFrom(); - const unsigned int nPMTs = geop->NOpChannels(); + const unsigned int nPMTs = art::ServiceHandle()->Get().NOpChannels(); char histname[100]; char histtitle[100]; diff --git a/icaruscode/PMT/LibraryMappingTools/ICARUSPhotonMappingTransformations.cxx b/icaruscode/PMT/LibraryMappingTools/ICARUSPhotonMappingTransformations.cxx index 468bdcb2f..f0b5bff01 100644 --- a/icaruscode/PMT/LibraryMappingTools/ICARUSPhotonMappingTransformations.cxx +++ b/icaruscode/PMT/LibraryMappingTools/ICARUSPhotonMappingTransformations.cxx @@ -31,6 +31,7 @@ phot::ICARUSPhotonMappingTransformations::ICARUSPhotonMappingTransformations (Config const& config) : fDumpMapping(config.DumpMapping()) , fGeom(lar::providerFrom()) + , fChannelMapAlg{&art::ServiceHandle()->Get()} , fNOpDetChannels(fGeom? fGeom->NOpDets(): 0) { LibraryIndexToOpDetMap libraryIndices; @@ -140,10 +141,10 @@ void phot::ICARUSPhotonMappingTransformations::prepareLibraryMappings (fGeom->Ncryostats()); lar::util::MinMaxCollector opDetChannelRange; - unsigned int const maxOpChannel = fGeom->MaxOpChannel(); + unsigned int const maxOpChannel = fChannelMapAlg->MaxOpChannel(); for (unsigned int channel = 0; channel < maxOpChannel; ++channel) { - geo::OpDetGeo const& opDet = fGeom->OpDetGeoFromOpChannel(channel); + geo::OpDetGeo const& opDet = fChannelMapAlg->OpDetGeoFromOpChannel(channel); auto const& opDetID = opDet.ID(); if (opDetID.isValid) { @@ -320,7 +321,7 @@ void phot::ICARUSPhotonMappingTransformations::dumpMapping() const { log << "\nMapping of geometry: '" << fGeom->DetectorName() << "':" << "\n - " << fGeom->Ncryostats() << " cryostats" << "\n - optical channels: " << fNOpDetChannels - << "\n - maximum optical detector channel number: " << fGeom->MaxOpChannel() + << "\n - maximum optical detector channel number: " << fChannelMapAlg->MaxOpChannel() << "\n" ; diff --git a/icaruscode/PMT/LibraryMappingTools/ICARUSPhotonMappingTransformations.h b/icaruscode/PMT/LibraryMappingTools/ICARUSPhotonMappingTransformations.h index 2ae56b26e..534a7dfe8 100644 --- a/icaruscode/PMT/LibraryMappingTools/ICARUSPhotonMappingTransformations.h +++ b/icaruscode/PMT/LibraryMappingTools/ICARUSPhotonMappingTransformations.h @@ -12,6 +12,7 @@ // LArSoft libraries #include "larsim/PhotonPropagation/LibraryMappingTools/IPhotonMappingTransformations.h" +#include "larcore/Geometry/WireReadout.h" #include "larcore/Geometry/Geometry.h" #include "larcore/CoreUtils/ServiceUtil.h" // lar::providerFrom() #include "larcorealg/Geometry/GeometryCore.h" @@ -231,6 +232,7 @@ namespace phot { /// Detector geometry service provider. Not really used. geo::GeometryCore const* fGeom = nullptr; + geo::WireReadoutGeom const* fChannelMapAlg = nullptr; // diff --git a/icaruscode/PMT/OpReco/FakeFlash_module.cc b/icaruscode/PMT/OpReco/FakeFlash_module.cc index 116891c70..668b695be 100644 --- a/icaruscode/PMT/OpReco/FakeFlash_module.cc +++ b/icaruscode/PMT/OpReco/FakeFlash_module.cc @@ -24,6 +24,7 @@ #include "larcoreobj/SummaryData/RunData.h" #include "lardataobj/Simulation/SimPhotons.h" #include "lardata/DetectorInfoServices/DetectorClocksService.h" +#include "larcore/Geometry/WireReadout.h" #include "larcore/Geometry/Geometry.h" #include "larcore/CoreUtils/ServiceUtil.h" // lar::providerFrom() #include "larsim/PhotonPropagation/PhotonVisibilityService.h" @@ -104,9 +105,8 @@ FakeFlash::FakeFlash(fhicl::ParameterSet const& p) _slow_tau = p.get("SlowTimeConstant",1.5); // channel range to simulate - auto geop = lar::providerFrom(); _ch_min = 0; - _ch_max = geop->NOpChannels() - 1; + _ch_max = art::ServiceHandle()->Get().NOpChannels() - 1; _ch_min = p.get("ChannelMin",_ch_min); _ch_max = p.get("ChannelMax",_ch_max); assert(_ch_min<_ch_max); diff --git a/icaruscode/PMT/OpReco/FakePhotoS_module.cc b/icaruscode/PMT/OpReco/FakePhotoS_module.cc index be04c1870..7d6ac46c6 100644 --- a/icaruscode/PMT/OpReco/FakePhotoS_module.cc +++ b/icaruscode/PMT/OpReco/FakePhotoS_module.cc @@ -24,6 +24,7 @@ #include "larcoreobj/SummaryData/RunData.h" #include "lardataobj/Simulation/SimPhotons.h" #include "lardata/DetectorInfoServices/DetectorClocksService.h" +#include "larcore/Geometry/WireReadout.h" #include "larcore/Geometry/Geometry.h" #include "larcore/CoreUtils/ServiceUtil.h" // lar::providerFrom() @@ -127,9 +128,9 @@ void FakePhotoS::produce(art::Event& e) auto simph_v = std::unique_ptr >(new std::vector()); if(_ch_v.empty()) { - auto const geop = lar::providerFrom(); - _ch_v.reserve(geop->NOpChannels()); - for(size_t opch=0; opchNOpChannels(); ++opch) + auto const nOpChannels = art::ServiceHandle()->Get().NOpChannels(); + _ch_v.reserve(nOpChannels); + for(size_t opch=0; opchreserve(_ch_v.size()); diff --git a/icaruscode/PMT/OpReco/FlashFinder/FlashFinderFMWKInterface.cxx b/icaruscode/PMT/OpReco/FlashFinder/FlashFinderFMWKInterface.cxx index d969f84fa..30f75cef1 100644 --- a/icaruscode/PMT/OpReco/FlashFinder/FlashFinderFMWKInterface.cxx +++ b/icaruscode/PMT/OpReco/FlashFinder/FlashFinderFMWKInterface.cxx @@ -11,6 +11,7 @@ #include "fhiclcpp/ParameterSet.h" #include "messagefacility/MessageLogger/MessageLogger.h" #include "art_root_io/TFileService.h" +#include "larcore/Geometry/WireReadout.h" #include "larcore/Geometry/Geometry.h" @@ -20,17 +21,18 @@ namespace pmtana { std::vector ListOpChannels(int cryostat) { std::vector res; - ::art::ServiceHandle geo; + auto const& wireReadoutAlg = art::ServiceHandle()->Get(); if(cryostat<0) { - for(size_t opch=0; opchMaxOpChannel(); ++opch) { - if(geo->IsValidOpChannel(opch)) continue; + for(size_t opch=0; opch geo; auto const& bbox = geo->Cryostat(geo::CryostatID(cryostat)).Boundaries(); - for(size_t opch=0; opchMaxOpChannel(); ++opch) { - if(geo->IsValidOpChannel(opch)) continue; - auto const& pt = geo->OpDetGeoFromOpChannel(opch).GetCenter(); + for(size_t opch=0; opch geo; - return geo->OpDetFromOpChannel(opch); + return art::ServiceHandle()->Get().OpDetFromOpChannel(opch); } void OpDetCenterFromOpChannel(size_t opch, double *xyz) { - ::art::ServiceHandle geo; - auto const tmp = geo->OpDetGeoFromOpChannel(opch).GetCenter(); + auto const tmp = + art::ServiceHandle()->Get().OpDetGeoFromOpChannel(opch).GetCenter(); xyz[0] = tmp.X(); xyz[1] = tmp.Y(); xyz[2] = tmp.Z(); diff --git a/icaruscode/PMT/OpReco/FullOpHitFinder_module.cc b/icaruscode/PMT/OpReco/FullOpHitFinder_module.cc index d403bfe8f..fdfee1e67 100644 --- a/icaruscode/PMT/OpReco/FullOpHitFinder_module.cc +++ b/icaruscode/PMT/OpReco/FullOpHitFinder_module.cc @@ -9,6 +9,7 @@ // // LArSoft includes +#include "larcore/Geometry/WireReadout.h" #include "larcore/Geometry/Geometry.h" #include "larcore/CoreUtils/ServiceUtil.h" // lar::providerFrom() #include "lardataobj/RawData/OpDetWaveform.h" @@ -178,13 +179,14 @@ namespace opdet { std::vector pmtX, pmtY, pmtZ; std::vector minX, minY, minZ; std::vector maxX, maxY, maxZ; - auto const geop = lar::providerFrom(); - for(size_t opch=0; opchNOpChannels(); ++opch) { - auto const PMTxyz = geop->OpDetGeoFromOpChannel(opch).GetCenter(); + auto const& wireReadoutAlg = art::ServiceHandle()->Get(); + for(size_t opch=0; opch(); for(auto const& tpc : geop->Iterate()) { minX.push_back(tpc.BoundingBox().MinX()); minY.push_back(tpc.BoundingBox().MinY()); diff --git a/icaruscode/PMT/OpReco/ICARUSFlashAssAna_module.cc b/icaruscode/PMT/OpReco/ICARUSFlashAssAna_module.cc index 467451bed..acd96a95e 100644 --- a/icaruscode/PMT/OpReco/ICARUSFlashAssAna_module.cc +++ b/icaruscode/PMT/OpReco/ICARUSFlashAssAna_module.cc @@ -33,6 +33,7 @@ #include "canvas/Persistency/Common/FindOneP.h" #include "canvas/Persistency/Common/Assns.h" +#include "larcore/Geometry/WireReadout.h" #include "larcore/Geometry/Geometry.h" #include "larcore/CoreUtils/ServiceUtil.h" // lar::providerFrom() #include "lardataobj/RawData/OpDetWaveform.h" @@ -248,7 +249,8 @@ class opana::ICARUSFlashAssAna : public art::EDAnalyzer //---------- // Support variables/products - geo::GeometryCore const *fGeom; + geo::GeometryCore const* fGeom; + geo::WireReadoutGeom const* fChannelMapAlg; std::vector fRWMTimes; }; @@ -266,7 +268,8 @@ opana::ICARUSFlashAssAna::ICARUSFlashAssAna(Parameters const &config) fFlashLabels(config().FlashLabels()), fRWMLabel(config().RWMLabel()), fPEOpHitThreshold(config().PEOpHitThreshold()), - fGeom(lar::providerFrom()) + fGeom(lar::providerFrom()), + fChannelMapAlg(&art::ServiceHandle()->Get()) { } @@ -277,17 +280,14 @@ void opana::ICARUSFlashAssAna::beginJob() art::ServiceHandle tfs; - // Setting up the GEOMETRY tree - // Channel id corresponds to vector index TTree *fGeoTree = tfs->make("geotree", "geometry information"); fGeoTree->Branch("pmt_x", &m_pmt_x); fGeoTree->Branch("pmt_y", &m_pmt_y); fGeoTree->Branch("pmt_z", &m_pmt_z); - - for (std::size_t opch = 0; opch < fGeom->NOpChannels(); ++opch) + + for(size_t opch=0; opchNOpChannels(); ++opch) { - - auto const PMTxyz = fGeom->OpDetGeoFromOpChannel(opch).GetCenter(); + auto const PMTxyz = fChannelMapAlg->OpDetGeoFromOpChannel(opch).GetCenter(); m_pmt_x.push_back(PMTxyz.X()); m_pmt_y.push_back(PMTxyz.Y()); m_pmt_z.push_back(PMTxyz.Z()); @@ -453,8 +453,7 @@ T opana::ICARUSFlashAssAna::Median(std::vector data) const geo::CryostatID::CryostatID_t opana::ICARUSFlashAssAna::getCryostatByChannel(int channel) { - - const geo::OpDetGeo &opdetgeo = fGeom->OpDetGeoFromOpChannel(channel); + const geo::OpDetGeo &opdetgeo = fChannelMapAlg->OpDetGeoFromOpChannel(channel); geo::CryostatID::CryostatID_t cid = opdetgeo.ID().Cryostat; return cid; } diff --git a/icaruscode/PMT/OpReco/ICARUSMCOpFlash_module.cc b/icaruscode/PMT/OpReco/ICARUSMCOpFlash_module.cc index 0a58739d5..16f04b984 100644 --- a/icaruscode/PMT/OpReco/ICARUSMCOpFlash_module.cc +++ b/icaruscode/PMT/OpReco/ICARUSMCOpFlash_module.cc @@ -20,8 +20,9 @@ #include "nusimdata/SimulationBase/MCTruth.h" #include "lardataobj/Simulation/SimPhotons.h" #include "lardata/DetectorInfoServices/DetectorClocksService.h" -#include "larcore/Geometry/Geometry.h" +#include "larcore/Geometry/WireReadout.h" #include "larcore/CoreUtils/ServiceUtil.h" // lar::providerFrom() +#include "larcorealg/Geometry/OpDetGeo.h" #include "lardataobj/RecoBase/OpHit.h" #include "lardataobj/RecoBase/OpFlash.h" @@ -99,7 +100,7 @@ ICARUSMCOpFlash::ICARUSMCOpFlash(fhicl::ParameterSet const& p) void ICARUSMCOpFlash::produce(art::Event& e) { - auto const geop = lar::providerFrom(); + auto const& wireReadoutAlg = art::ServiceHandle()->Get(); auto opf_v = std::unique_ptr >(new std::vector()); art::Handle< std::vector< simb::MCTruth > > mct_h; @@ -135,7 +136,7 @@ void ICARUSMCOpFlash::produce(art::Event& e) } for(auto const& flash_time : flash_time_v) { - std::vector pe_v(geop->NOpChannels(),0.); + std::vector pe_v(wireReadoutAlg.NOpChannels(),0.); double pe_total=-1.; // double pe_sum=0.; // unused // double pe_sum1=0.; // unused @@ -177,7 +178,7 @@ void ICARUSMCOpFlash::GetFlashLocation(std::vector pePerOpChannel, { // Reset variables - auto const geop = lar::providerFrom(); + auto const& wireReadoutAlg = art::ServiceHandle()->Get(); Ycenter = Zcenter = -1.e20; Ywidth = Zwidth = -1.e20; double totalPE = 0.; @@ -186,7 +187,7 @@ void ICARUSMCOpFlash::GetFlashLocation(std::vector pePerOpChannel, for (unsigned int opch = 0; opch < pePerOpChannel.size(); opch++) { // Get physical detector location for this opChannel - auto const PMTxyz = geop->OpDetGeoFromOpChannel(opch).GetCenter(); + auto const PMTxyz = wireReadoutAlg.OpDetGeoFromOpChannel(opch).GetCenter(); // Add up the position, weighting with PEs sumy += pePerOpChannel[opch]*PMTxyz.Y(); diff --git a/icaruscode/PMT/OpReco/ICARUSOpFlashAna_module.cc b/icaruscode/PMT/OpReco/ICARUSOpFlashAna_module.cc index 988be4b69..4b5311b3f 100644 --- a/icaruscode/PMT/OpReco/ICARUSOpFlashAna_module.cc +++ b/icaruscode/PMT/OpReco/ICARUSOpFlashAna_module.cc @@ -18,6 +18,7 @@ #include "messagefacility/MessageLogger/MessageLogger.h" #include "nusimdata/SimulationBase/MCTruth.h" +#include "larcore/Geometry/WireReadout.h" #include "larcore/Geometry/Geometry.h" #include "larcore/CoreUtils/ServiceUtil.h" // lar::providerFrom() #include "lardataobj/RawData/OpDetWaveform.h" @@ -125,13 +126,14 @@ void ICARUSOpFlashAna::beginJob() std::vector pmtX, pmtY, pmtZ; std::vector minX, minY, minZ; std::vector maxX, maxY, maxZ; - auto const geop = lar::providerFrom(); - for(size_t opch=0; opchNOpChannels(); ++opch) { - auto const PMTxyz = geop->OpDetGeoFromOpChannel(opch).GetCenter(); + auto const& wireReadoutAlg = art::ServiceHandle()->Get(); + for(size_t opch=0; opch(); for(auto const& tpc : geop->Iterate()) { minX.push_back(tpc.ActiveBoundingBox().MinX()); minY.push_back(tpc.ActiveBoundingBox().MinY()); diff --git a/icaruscode/PMT/OpReco/ICARUSOpHitAna_module.cc b/icaruscode/PMT/OpReco/ICARUSOpHitAna_module.cc index d7bc85ffc..5a717118e 100644 --- a/icaruscode/PMT/OpReco/ICARUSOpHitAna_module.cc +++ b/icaruscode/PMT/OpReco/ICARUSOpHitAna_module.cc @@ -17,6 +17,7 @@ #include "fhiclcpp/ParameterSet.h" #include "messagefacility/MessageLogger/MessageLogger.h" +#include "larcore/Geometry/WireReadout.h" #include "larcore/Geometry/Geometry.h" #include "larcore/CoreUtils/ServiceUtil.h" // lar::providerFrom() #include "lardataobj/RawData/OpDetWaveform.h" @@ -142,13 +143,14 @@ void ICARUSOpHitAna::beginJob() std::vector pmtX, pmtY, pmtZ; std::vector minX, minY, minZ; std::vector maxX, maxY, maxZ; - auto const geop = lar::providerFrom(); - for(size_t opch=0; opchNOpChannels(); ++opch) { - auto const PMTxyz = geop->OpDetGeoFromOpChannel(opch).GetCenter(); + auto const& wireReadoutAlg = art::ServiceHandle()->Get(); + for(size_t opch=0; opch(); for(auto const& tpc : geop->Iterate()) { minX.push_back(tpc.BoundingBox().MinX()); minY.push_back(tpc.BoundingBox().MinY()); @@ -215,8 +217,8 @@ void ICARUSOpHitAna::analyze(art::Event const& e) // value = mchit location (i.e. array index number) std::vector > mchit_db; // fill the map - auto const geop = lar::providerFrom(); - mchit_db.resize(geop->NOpChannels()); + auto const& wireReadoutAlg = art::ServiceHandle()->Get(); + mchit_db.resize(wireReadoutAlg.NOpChannels()); for(size_t mchit_index=0; mchit_index < mchit_h->size(); ++mchit_index) { auto const& mchit = (*mchit_h)[mchit_index]; _pe_true = mchit.PE(); diff --git a/icaruscode/PMT/OpReco/ICARUSOpHitFinder_module.cc b/icaruscode/PMT/OpReco/ICARUSOpHitFinder_module.cc index 400772c32..f9ae98c29 100644 --- a/icaruscode/PMT/OpReco/ICARUSOpHitFinder_module.cc +++ b/icaruscode/PMT/OpReco/ICARUSOpHitFinder_module.cc @@ -25,7 +25,7 @@ #include "larana/OpticalDetector/OpHitFinder/PedAlgoUB.h" #include "larana/OpticalDetector/OpHitFinder/PulseRecoManager.h" #include "larana/OpticalDetector/OpHitFinder/OpticalRecoTypes.h" // pmtana::Waveform_t -#include "larcore/Geometry/Geometry.h" +#include "larcore/Geometry/WireReadout.h" #include "lardata/DetectorInfoServices/DetectorClocksService.h" #include "lardataalg/DetectorInfo/DetectorClocksData.h" #include "lardataobj/RecoBase/OpHit.h" @@ -490,7 +490,7 @@ opdet::ICARUSOpHitFinder::ICARUSOpHitFinder , fHitThreshold{ params().HitThreshold() } , fUseStartTime{ params().UseStartTime() } // caches - , fMaxOpChannel{ frame.serviceHandle()->MaxOpChannel() } + , fMaxOpChannel{ frame.serviceHandle()->Get().MaxOpChannel() } // algorithms , fPulseRecoMgr{} , fThreshAlg @@ -599,7 +599,6 @@ void opdet::ICARUSOpHitFinder::produce std::vector const beamGateArray = fetchBeamGates(event); - auto const& geom = *(frame.serviceHandle()->provider()); auto const clockData = frame.serviceHandle() ->DataFor(event) @@ -610,7 +609,7 @@ void opdet::ICARUSOpHitFinder::produce RunHitFinder( *waveforms, opHits, fPulseRecoMgr, *fThreshAlg, - geom, + frame.serviceHandle()->Get(), fHitThreshold, clockData, *fCalib, diff --git a/icaruscode/PMT/OpReco/ICARUSOpHitTuple_module.cc b/icaruscode/PMT/OpReco/ICARUSOpHitTuple_module.cc index 61a418a99..05c4e28e4 100644 --- a/icaruscode/PMT/OpReco/ICARUSOpHitTuple_module.cc +++ b/icaruscode/PMT/OpReco/ICARUSOpHitTuple_module.cc @@ -18,6 +18,7 @@ #include "messagefacility/MessageLogger/MessageLogger.h" #include "nusimdata/SimulationBase/MCTruth.h" +#include "larcore/Geometry/WireReadout.h" #include "larcore/Geometry/Geometry.h" #include "larcore/CoreUtils/ServiceUtil.h" // lar::providerFrom() #include "lardataobj/RawData/OpDetWaveform.h" @@ -138,13 +139,14 @@ void ICARUSOpHitTuple::beginJob() std::vector pmtX, pmtY, pmtZ; std::vector minX, minY, minZ; std::vector maxX, maxY, maxZ; - auto const geop = lar::providerFrom(); - for(size_t opch=0; opchNOpChannels(); ++opch) { - auto const PMTxyz = geop->OpDetGeoFromOpChannel(opch).GetCenter(); + auto const& wireReadoutAlg = art::ServiceHandle()->Get(); + for(size_t opch=0; opch(); for(auto const& tpc : geop->Iterate()) { minX.push_back(tpc.BoundingBox().MinX()); minY.push_back(tpc.BoundingBox().MinY()); @@ -229,10 +231,10 @@ void ICARUSOpHitTuple::analyze(art::Event const& e) _event_dr = _event_dx = _event_dy = _event_dz =std::numeric_limits::max(); _tpc = -1; if(_event_time != std::numeric_limits::max()) { - auto const geop = lar::providerFrom(); + auto const& wireReadoutAlg = art::ServiceHandle()->Get(); // measure smallest dr to any pmt - for(size_t opch=0; opchNOpChannels(); ++opch) { - auto const PMTxyz = geop->OpDetGeoFromOpChannel(opch).GetCenter(); + for(size_t opch=0; opch()), fDetClocks(*art::ServiceHandle()), fDetProp(*art::ServiceHandle()), - fTimeIntervalMaker{ fGeom } + fTimeIntervalMaker{ fGeom, art::ServiceHandle()->Get() } { // Call appropriate produces<>() functions here. diff --git a/icaruscode/PMT/PMTStartCalibTime_module.cc b/icaruscode/PMT/PMTStartCalibTime_module.cc index 1212d222a..6095b47ef 100644 --- a/icaruscode/PMT/PMTStartCalibTime_module.cc +++ b/icaruscode/PMT/PMTStartCalibTime_module.cc @@ -31,9 +31,10 @@ // ######################## // ### LArSoft includes ### // ######################## +#include "larcorealg/Geometry/OpDetGeo.h" #include "larcoreobj/SimpleTypesAndConstants/geo_types.h" #include "larcoreobj/SimpleTypesAndConstants/RawTypes.h" // raw::ChannelID_t -#include "larcore/Geometry/Geometry.h" +#include "larcore/Geometry/WireReadout.h" #include "lardataobj/RecoBase/Wire.h" #include "lardataobj/RecoBase/Hit.h" #include "lardataobj/RecoBase/Cluster.h" @@ -204,7 +205,7 @@ void icarus::PMTStartCalibTime::analyze(art::Event const & evt) { ////////////////////////////////// Create the LArsoft services and service handle////////////////////////////// -art::ServiceHandle geom; +geo::WireReadoutGeom const& wireReadoutAlg = art::ServiceHandle()->Get(); std::vector const& optical = *(evt.getValidHandle>(photonLabel)); std::vector const& charge = *(evt.getValidHandle>(chargeLabel)); @@ -323,7 +324,7 @@ for (std::size_t channel = 0; channel < optical.size(); ++channel) { turned_PMT++; } - auto const xyz = geom->OpDetGeoFromOpChannel(channel).GetCenter(); + auto const xyz = wireReadoutAlg.OpDetGeoFromOpChannel(channel).GetCenter(); PMTx[channel] = xyz.X(); PMTy[channel] = xyz.Y(); diff --git a/icaruscode/PMT/PMTWaveformBaselinesFromChannelData_module.cc b/icaruscode/PMT/PMTWaveformBaselinesFromChannelData_module.cc index c9fa52d6a..f7aac3188 100644 --- a/icaruscode/PMT/PMTWaveformBaselinesFromChannelData_module.cc +++ b/icaruscode/PMT/PMTWaveformBaselinesFromChannelData_module.cc @@ -15,7 +15,7 @@ // LArSoft libraries #include "lardata/DetectorInfoServices/DetectorClocksService.h" -#include "larcore/Geometry/Geometry.h" +#include "larcore/Geometry/WireReadout.h" #include "lardataalg/DetectorInfo/DetectorTimings.h" #include "lardataalg/DetectorInfo/DetectorTimingTypes.h" // electronics_time #include "lardataalg/Utilities/quantities/spacetime.h" // nanoseconds @@ -707,9 +707,9 @@ void icarus::PMTWaveformBaselinesFromChannelData::setupPlots { auto const& tfs = *(frame.serviceHandle()); - auto const& geom = *(frame.serviceHandle()->provider()); + auto const& wireReadoutAlg = frame.serviceHandle()->Get(); - fNPlotChannels = geom.NOpChannels(); + fNPlotChannels = wireReadoutAlg.NOpChannels(); fHBaselines = tfs.make( "Baselines", diff --git a/icaruscode/PMT/PMTWaveformBaselinesFromReadoutConfiguration_module.cc b/icaruscode/PMT/PMTWaveformBaselinesFromReadoutConfiguration_module.cc index 5949e2890..af0737c10 100644 --- a/icaruscode/PMT/PMTWaveformBaselinesFromReadoutConfiguration_module.cc +++ b/icaruscode/PMT/PMTWaveformBaselinesFromReadoutConfiguration_module.cc @@ -13,7 +13,7 @@ // #include "icaruscode/Utilities/DataProductPointerMap.h" // LArSoft libraries -#include "larcore/Geometry/Geometry.h" +#include "larcore/Geometry/WireReadout.h" #include "larcore/CoreUtils/ServiceUtil.h" // lar::providerFrom() #include "lardataobj/RawData/OpDetWaveform.h" #include "larcorealg/Geometry/GeometryCore.h" @@ -422,9 +422,9 @@ void icarus::PMTWaveformBaselinesFromReadoutConfiguration::produce void icarus::PMTWaveformBaselinesFromReadoutConfiguration::setupPlots() { auto const& tfs = *(art::ServiceHandle()); - auto const& geom = *(lar::providerFrom()); + auto const& wireReadoutAlg = art::ServiceHandle()->Get(); - unsigned int const nChannels = geom.NOpChannels(); + unsigned int const nChannels = wireReadoutAlg.NOpChannels(); fHBaselines = tfs.make( "Baselines", diff --git a/icaruscode/PMT/PMTWaveformBaselines_module.cc b/icaruscode/PMT/PMTWaveformBaselines_module.cc index 80455461d..9681c90c0 100644 --- a/icaruscode/PMT/PMTWaveformBaselines_module.cc +++ b/icaruscode/PMT/PMTWaveformBaselines_module.cc @@ -10,7 +10,7 @@ // #include "icaruscode/Utilities/DataProductPointerMap.h" // LArSoft libraries -#include "larcore/Geometry/Geometry.h" +#include "larcore/Geometry/WireReadout.h" #include "larcore/CoreUtils/ServiceUtil.h" // lar::providerFrom() #include "lardataalg/Utilities/StatCollector.h" #include "lardataobj/RawData/OpDetWaveform.h" @@ -390,9 +390,9 @@ void icarus::PMTWaveformBaselines::endJob() { void icarus::PMTWaveformBaselines::setupPlots() { auto const& tfs = *(art::ServiceHandle()); - auto const& geom = *(lar::providerFrom()); + geo::WireReadoutGeom const& wireReadoutAlg = art::ServiceHandle()->Get(); - fNPlotChannels = geom.NOpChannels(); + fNPlotChannels = wireReadoutAlg.NOpChannels(); fHBaselines = tfs.make( "Baselines", diff --git a/icaruscode/PMT/PMTcoordinates_module.cc b/icaruscode/PMT/PMTcoordinates_module.cc index 55c6cbbd0..7ac8dfb86 100644 --- a/icaruscode/PMT/PMTcoordinates_module.cc +++ b/icaruscode/PMT/PMTcoordinates_module.cc @@ -31,9 +31,10 @@ // ######################## // ### LArSoft includes ### // ######################## +#include "larcorealg/Geometry/OpDetGeo.h" #include "larcoreobj/SimpleTypesAndConstants/geo_types.h" #include "larcoreobj/SimpleTypesAndConstants/RawTypes.h" // raw::ChannelID_t -#include "larcore/Geometry/Geometry.h" +#include "larcore/Geometry/WireReadout.h" #include "lardataobj/RecoBase/Wire.h" #include "lardataobj/RecoBase/Hit.h" #include "lardataobj/RecoBase/Cluster.h" @@ -169,7 +170,7 @@ void icarus::PMTcoordinates::analyze(art::Event const & evt) { ////////////////////////////////// Create the LArsoft services and service handle////////////////////////////// -art::ServiceHandle geom; +geo::WireReadoutGeom const& wireReadoutAlg = art::ServiceHandle()->Get(); std::vector const& optical = *(evt.getValidHandle>(photonLabel)); std::vector const& charge = *(evt.getValidHandle>(chargeLabel)); @@ -296,7 +297,7 @@ for (std::size_t channel = 0; channel < optical.size(); ++channel) { turned_PMT++; } - auto const xyz = geom->OpDetGeoFromOpChannel(channel).GetCenter(); + auto const xyz = wireReadoutAlg.OpDetGeoFromOpChannel(channel).GetCenter(); PMTx[channel] = xyz.X(); PMTy[channel] = xyz.Y(); diff --git a/icaruscode/PMT/PhotonPropogationICARUS_module.cc b/icaruscode/PMT/PhotonPropogationICARUS_module.cc index d70329d84..023a3dcb4 100644 --- a/icaruscode/PMT/PhotonPropogationICARUS_module.cc +++ b/icaruscode/PMT/PhotonPropogationICARUS_module.cc @@ -20,7 +20,7 @@ // LArSoft libraries #include "larsim/PhotonPropagation/PhotonVisibilityService.h" #include "lardata/DetectorInfoServices/DetectorPropertiesService.h" -#include "larcore/Geometry/Geometry.h" +#include "larcore/Geometry/WireReadout.h" #include "larcore/CoreUtils/ServiceUtil.h" // lar::providerFrom() #include "larcorealg/Geometry/OpDetGeo.h" #include "larcorealg/Geometry/geo_vectors_utils.h" // geo::vect::toPoint() @@ -73,7 +73,7 @@ class PhotonPropogationICARUS : public art::EDProducer unsigned int fNumEvent = 0; ///< Number of events seen. // Useful services, keep copies for now (we can update during begin run periods) - geo::GeometryCore const* fGeometry = nullptr; ///< Pointer to Geometry service. + geo::WireReadoutGeom const* fChannelMapAlg = nullptr; ///< Pointer to Geometry service. CLHEP::HepRandomEngine& fPhotonEngine; /// We don't keep more than this number of photons per `sim::SimPhoton`. @@ -91,7 +91,7 @@ DEFINE_ART_MODULE(PhotonPropogationICARUS) /// pset - Fcl parameters. /// PhotonPropogationICARUS::PhotonPropogationICARUS(fhicl::ParameterSet const & pset) - : EDProducer{pset}, fGeometry(lar::providerFrom()) + : EDProducer{pset}, fChannelMapAlg(&art::ServiceHandle()->Get()) , fPhotonEngine(art::ServiceHandle()->registerAndSeedEngine( createEngine(0, "HepJamesRandom", "icarusphoton"), "HepJamesRandom", "icarusphoton", pset, "SeedPhoton")) @@ -176,7 +176,7 @@ void PhotonPropogationICARUS::produce(art::Event & event) auto const channel = simPhoton.OpChannel(); if (simPhoton.empty()) continue; - auto const& PMTcenter = fGeometry->OpDetGeoFromOpChannel(channel).GetCenter(); + auto const& PMTcenter = fChannelMapAlg->OpDetGeoFromOpChannel(channel).GetCenter(); // TODO restore the "MF_LOG_TRACE" line for normal operations // (MF_LOG_TRACE will print only in debug mode, with debug qualifiers and proper messagefacility settings) diff --git a/icaruscode/PMT/RequireOnBeamWaveforms_module.cc b/icaruscode/PMT/RequireOnBeamWaveforms_module.cc index 1e4d65d26..fd9f9cdb2 100644 --- a/icaruscode/PMT/RequireOnBeamWaveforms_module.cc +++ b/icaruscode/PMT/RequireOnBeamWaveforms_module.cc @@ -10,11 +10,10 @@ #include "icaruscode/IcarusObj/OpDetWaveformMeta.h" #include "icarusalg/Utilities/AtomicPassCounter.h" #include "lardata/DetectorInfoServices/DetectorClocksService.h" -#include "larcore/Geometry/Geometry.h" +#include "larcore/Geometry/WireReadout.h" #include "larcore/CoreUtils/ServiceUtil.h" // lar::providerFrom() #include "lardataalg/DetectorInfo/DetectorTimings.h" // DetectorClocksWithUnits #include "lardataalg/Utilities/quantities/spacetime.h" // nanoseconds, ... -#include "larcorealg/Geometry/GeometryCore.h" #include "larcorealg/CoreUtils/enumerate.h" #include "lardataobj/RawData/OpDetWaveform.h" #include "lardataobj/RawData/TriggerData.h" @@ -348,7 +347,7 @@ std::vector RequireOnBeamWaveforms::buildRequiredChannelList (std::vector const& skipChannels /* = {} */) { std::vector mask - (lar::providerFrom()->MaxOpChannel(), true); + (art::ServiceHandle()->Get().MaxOpChannel(), true); // they will be never missed for (raw::Channel_t const channel: skipChannels) mask[channel] = false; diff --git a/icaruscode/PMT/SimPMTreadout_module.cc b/icaruscode/PMT/SimPMTreadout_module.cc index dcee48f8d..ab768af89 100644 --- a/icaruscode/PMT/SimPMTreadout_module.cc +++ b/icaruscode/PMT/SimPMTreadout_module.cc @@ -15,6 +15,7 @@ #include "icaruscode/IcarusObj/OpDetWaveformMeta.h" // LArSoft libraries +#include "larcore/Geometry/WireReadout.h" #include "larcore/Geometry/Geometry.h" #include "larcore/CoreUtils/ServiceUtil.h" #include "lardata/DetectorInfoServices/DetectorClocksService.h" @@ -438,11 +439,11 @@ class icarus::opdet::SimPMTreadout: public art::EDProducer { /// Creates a map of all PMT channels into cryostat ID. static std::vector makeChannelMap - (geo::GeometryCore const& geom); + (geo::WireReadoutGeom const& wireReadoutAlg); public: - PrimitiveManager(geo::GeometryCore const& geom); + PrimitiveManager(geo::GeometryCore const& geom, geo::WireReadoutGeom const& wireReadoutAlg); /// Returns all the readout windows for the specified channel. std::vector const& forChannel @@ -487,6 +488,7 @@ class icarus::opdet::SimPMTreadout: public art::EDProducer { // --- BEGIN -- Cached values ------------------------------------------------ geo::GeometryCore const& fGeom; ///< Geometry service provider. + geo::WireReadoutGeom const& fChannelMapAlg; detinfo::DetectorTimings const fDetTimings; ///< Timing conversion utility. unsigned int const fNOpChannels; ///< Number of optical detector channels. @@ -662,19 +664,19 @@ void icarus::opdet::SimPMTreadout::PrimitiveManager::refreshCaches // ----------------------------------------------------------------------------- std::vector icarus::opdet::SimPMTreadout::PrimitiveManager::makeChannelMap - (geo::GeometryCore const& geom) + (geo::WireReadoutGeom const& wireReadoutAlg) { std::vector cryos; - for (auto channel: util::counter(geom.NOpChannels())) - cryos.push_back(geom.OpDetGeoFromOpChannel(channel).ID()); + for (auto channel: util::counter(wireReadoutAlg.NOpChannels())) + cryos.push_back(wireReadoutAlg.OpDetGeoFromOpChannel(channel).ID()); return cryos; } // icarus::opdet::SimPMTreadout::PrimitiveManager::makeChannelMap() // ----------------------------------------------------------------------------- icarus::opdet::SimPMTreadout::PrimitiveManager::PrimitiveManager - (geo::GeometryCore const& geom) - : fCryostatOf{ makeChannelMap(geom) } + (geo::GeometryCore const& geom, geo::WireReadoutGeom const& wireReadoutAlg) + : fCryostatOf{ makeChannelMap(wireReadoutAlg) } , fPrimitives{ geom.Ncryostats() } {} @@ -728,8 +730,9 @@ icarus::opdet::SimPMTreadout::SimPMTreadout(Parameters const& config) , fLogCategory { config().LogCategory() } // caches , fGeom { *(lar::providerFrom()) } + , fChannelMapAlg{art::ServiceHandle()->Get()} , fDetTimings { icarus::ns::util::makeDetTimings() } - , fNOpChannels{ fGeom.NOpChannels() } + , fNOpChannels{ fChannelMapAlg.NOpChannels() } , fNCryostats { fGeom.Ncryostats() } , fOpticalTick{ fDetTimings.OpticalClockPeriod() } , fNoiseGeneratorEngine{ @@ -839,7 +842,7 @@ void icarus::opdet::SimPMTreadout::produce(art::Event& event) { // // determine the primitives and the channels they affect // - PrimitiveManager primitives{ fGeom }; + PrimitiveManager primitives{ fGeom, fChannelMapAlg }; // add the trigger primitives for (art::InputTag const& tag: fPrimitiveTags) { diff --git a/icaruscode/PMT/TrigInfo_module.cc b/icaruscode/PMT/TrigInfo_module.cc index d84d87757..c138afcb2 100644 --- a/icaruscode/PMT/TrigInfo_module.cc +++ b/icaruscode/PMT/TrigInfo_module.cc @@ -31,9 +31,10 @@ // ######################## // ### LArSoft includes ### // ######################## +#include "larcorealg/Geometry/OpDetGeo.h" #include "larcoreobj/SimpleTypesAndConstants/geo_types.h" #include "larcoreobj/SimpleTypesAndConstants/RawTypes.h" // raw::ChannelID_t -#include "larcore/Geometry/Geometry.h" +#include "larcore/Geometry/WireReadout.h" #include "lardataobj/RecoBase/Wire.h" #include "lardataobj/RecoBase/Hit.h" #include "lardataobj/RecoBase/Cluster.h" @@ -185,7 +186,7 @@ void icarus::TrigInfo::analyze(art::Event const & evt) ////////////////////////////////// Create the LArsoft services and service handle////////////////////////////// -art::ServiceHandle geom; +geo::WireReadoutGeom const& wireReadoutAlg = art::ServiceHandle()->Get(); std::vector const& optical = *(evt.getValidHandle>(photonLabel)); std::vector const& charge = *(evt.getValidHandle>(chargeLabel)); @@ -313,7 +314,7 @@ for (std::size_t channel = 0; channel < optical.size(); ++channel) { turned_PMT++; } - auto const xyz = geom->OpDetGeoFromOpChannel(channel).GetCenter(); + auto const xyz = wireReadoutAlg.OpDetGeoFromOpChannel(channel).GetCenter(); PMTx[channel] = xyz.X(); PMTy[channel] = xyz.Y(); diff --git a/icaruscode/PMT/Trigger/Algorithms/SlidingWindowDefinitionAlg.cxx b/icaruscode/PMT/Trigger/Algorithms/SlidingWindowDefinitionAlg.cxx index 03098d9e6..13112a0f6 100644 --- a/icaruscode/PMT/Trigger/Algorithms/SlidingWindowDefinitionAlg.cxx +++ b/icaruscode/PMT/Trigger/Algorithms/SlidingWindowDefinitionAlg.cxx @@ -15,6 +15,7 @@ #include "icaruscode/PMT/Algorithms/PMTverticalSlicingAlg.h" // LArSoft libraries +#include "larcorealg/Geometry/WireReadoutGeom.h" #include "larcorealg/Geometry/GeometryCore.h" #include "larcorealg/Geometry/CryostatGeo.h" #include "larcorealg/Geometry/OpDetGeo.h" diff --git a/icaruscode/PMT/Trigger/Algorithms/SlidingWindowDefinitionAlg.h b/icaruscode/PMT/Trigger/Algorithms/SlidingWindowDefinitionAlg.h index d83f31320..eb5e63656 100644 --- a/icaruscode/PMT/Trigger/Algorithms/SlidingWindowDefinitionAlg.h +++ b/icaruscode/PMT/Trigger/Algorithms/SlidingWindowDefinitionAlg.h @@ -13,6 +13,7 @@ #include "icaruscode/PMT/Trigger/Algorithms/SlidingWindowDefs.h" // LArSoft libraries +#include "larcorealg/Geometry/fwd.h" #include "lardataobj/RawData/OpDetWaveform.h" // raw::Channel_t // framework libraries @@ -29,9 +30,6 @@ // // forward declarations // -namespace geo { class GeometryCore; } - -// ----------------------------------------------------------------------------- namespace icarus::trigger { class SlidingWindowDefinitionAlg; } /** * @brief Groups optical detector channels into windows based on position. diff --git a/icaruscode/PMT/Trigger/Algorithms/WindowTopologyAlg.cxx b/icaruscode/PMT/Trigger/Algorithms/WindowTopologyAlg.cxx index 7ef331f68..393d8c79b 100644 --- a/icaruscode/PMT/Trigger/Algorithms/WindowTopologyAlg.cxx +++ b/icaruscode/PMT/Trigger/Algorithms/WindowTopologyAlg.cxx @@ -14,13 +14,16 @@ #include "icarusalg/Utilities/sortBy.h" // also icarus::util::sortCollBy() // LArSoft libraries +#include "larcorealg/Geometry/WireReadoutGeom.h" #include "larcorealg/Geometry/GeometryCore.h" #include "larcorealg/Geometry/CryostatGeo.h" #include "larcorealg/Geometry/OpDetGeo.h" #include "larcorealg/Geometry/TPCGeo.h" #include "larcorealg/Geometry/geo_vectors_utils.h" // MiddlePointAccumulator #include "larcorealg/CoreUtils/enumerate.h" -#include "larcorealg/CoreUtils/zip.h" + +// External libraries +#include "range/v3/view.hpp" // C/C++ standard libraries #include // std::move(), std::sort() @@ -53,10 +56,12 @@ namespace { //------------------------------------------------------------------------------ icarus::trigger::WindowTopologyAlg::WindowTopologyAlg( geo::GeometryCore const& geom, + geo::WireReadoutGeom const& wireReadoutAlg, std::string const& logCategory /* = "WindowTopologyAlg" */ ) : icarus::ns::util::mfLoggingClass(logCategory) , fGeom(&geom) + , fWireReadoutGeom{&wireReadoutAlg} {} @@ -69,13 +74,12 @@ auto icarus::trigger::WindowTopologyAlg::createFromGates std::vector windows; for (auto const& [ cryoGates, cryo ] - : util::zip(gates, fGeom->Iterate())) + : ::ranges::views::zip(gates, fGeom->Iterate())) { - append( windows, createWindowsFromCryostat - (extractGateChannels(cryoGates), cryo, *fGeom, windows.size()) + (extractGateChannels(cryoGates), cryo, *fWireReadoutGeom, windows.size()) ); } // for cryostats @@ -98,7 +102,7 @@ auto icarus::trigger::WindowTopologyAlg::createFromGates assert(!cid.isValid); for (raw::Channel_t const channel: gate.channels()) { - geo::OpDetGeo const& opDet = fGeom->OpDetGeoFromOpChannel(channel); + geo::OpDetGeo const& opDet = fWireReadoutGeom->OpDetGeoFromOpChannel(channel); geo::OpDetID const oid = opDet.ID(); if (!cid) cid = oid; else if (cid != oid) { // just in case @@ -122,7 +126,7 @@ auto icarus::trigger::WindowTopologyAlg::createFromCryostatGates -> WindowChannelMap { return emplaceAndDumpMap( - createWindowsFromCryostat(extractGateChannels(windowChannels), cryo, *fGeom) + createWindowsFromCryostat(extractGateChannels(windowChannels), cryo, *fWireReadoutGeom) ); } // icarus::trigger::WindowTopologyAlg::createFromCryostatGates() @@ -151,7 +155,7 @@ auto icarus::trigger::WindowTopologyAlg::emplaceAndDumpMap(Args&&... args) const auto icarus::trigger::WindowTopologyAlg::createWindowsFromCryostat( WindowChannelColl_t const& windowChannels, geo::CryostatGeo const& cryo, - geo::GeometryCore const& geom, + geo::WireReadoutGeom const& wireReadoutAlg, std::size_t firstWindowIndex /* = 0U */ ) -> std::vector { @@ -189,13 +193,13 @@ auto icarus::trigger::WindowTopologyAlg::createWindowsFromCryostat( std::sort(wComp.channels.begin(), wComp.channels.end()); wComp.cryoid = channels.empty() ? geo::CryostatID{} - : geom.OpDetGeoFromOpChannel(channels.front()).ID().asCryostatID() + : wireReadoutAlg.OpDetGeoFromOpChannel(channels.front()).ID().asCryostatID() ; geo::vect::MiddlePointAccumulator middlePoint; for (raw::Channel_t const channel: channels) { // documentation of OpDetGeoFromOpChannel() does not say what on error... - geo::OpDetGeo const& opDet = geom.OpDetGeoFromOpChannel(channel); + geo::OpDetGeo const& opDet = wireReadoutAlg.OpDetGeoFromOpChannel(channel); middlePoint.add(opDet.GetCenter()); if (opDet.ID() != wComp.cryoid) wComp.cryoid = geo::CryostatID{}; } // for channel @@ -209,8 +213,9 @@ auto icarus::trigger::WindowTopologyAlg::createWindowsFromCryostat( // // 2. sort the windows in drift plane (first cryostat TPC as reference) // - auto const normalProjection = [&refTPC](auto const* info) - { return refTPC.DistanceFromReferencePlane(info->composition.center); }; + auto const& refPlane = wireReadoutAlg.Plane({refTPC.ID(), 0}); + auto const normalProjection = [&refPlane](auto const* info) + { return refPlane.DistanceFromPlane(info->composition.center); }; WindowInfoPtrs_t const windowsByNormal = util::sortCollBy(cryoWindowInfo, normalProjection); @@ -218,8 +223,7 @@ auto icarus::trigger::WindowTopologyAlg::createWindowsFromCryostat( // 3. split the windows per plane // // split the list in two; there is a good deal of faith here - auto const beamCoordinate - = [&refPlane=refTPC.ReferencePlane()](auto const* info) + auto const beamCoordinate = [&refPlane](auto const* info) { return refPlane.PointWidthDepthProjection(info->composition.center).X(); } diff --git a/icaruscode/PMT/Trigger/Algorithms/WindowTopologyAlg.h b/icaruscode/PMT/Trigger/Algorithms/WindowTopologyAlg.h index 3d271def1..d64c36c13 100644 --- a/icaruscode/PMT/Trigger/Algorithms/WindowTopologyAlg.h +++ b/icaruscode/PMT/Trigger/Algorithms/WindowTopologyAlg.h @@ -17,6 +17,9 @@ #include "icaruscode/IcarusObj/OpDetWaveformMeta.h" // sbn::OpDetWaveformMeta #include "icarusalg/Utilities/mfLoggingClass.h" +// LArSoft libraries +#include "larcorealg/Geometry/fwd.h" + // framework libraries #include "cetlib_except/exception.h" @@ -28,12 +31,6 @@ // ----------------------------------------------------------------------------- // forward declaration -namespace geo { - class GeometryCore; - class CryostatGeo; -} - -// ----------------------------------------------------------------------------- namespace icarus::trigger { class WindowTopologyAlg; class WindowTopologyVerification; @@ -71,6 +68,7 @@ class icarus::trigger::WindowTopologyAlg */ WindowTopologyAlg( geo::GeometryCore const& geom, + geo::WireReadoutGeom const& wireReadoutAlg, std::string const& logCategory = "WindowTopologyAlg" ); @@ -149,6 +147,7 @@ class icarus::trigger::WindowTopologyAlg geo::GeometryCore const* const fGeom; ///< Geometry service provider. + geo::WireReadoutGeom const* const fWireReadoutGeom; /// Convenience function: creates and returns a `WindowChannelMap` from the @@ -169,7 +168,7 @@ class icarus::trigger::WindowTopologyAlg static std::vector createWindowsFromCryostat( WindowChannelColl_t const& windowChannels, geo::CryostatGeo const& cryo, - geo::GeometryCore const& geom, + geo::WireReadoutGeom const& wireReadoutAlg, std::size_t firstWindowIndex = 0U ); @@ -338,6 +337,7 @@ class icarus::trigger::WindowTopologyManager WindowTopologyVerification fVerify; geo::GeometryCore const* const fGeom; ///< Geometry service provider. + geo::WireReadoutGeom const* const fChannelMapAlg; public: @@ -356,6 +356,7 @@ class icarus::trigger::WindowTopologyManager */ WindowTopologyManager( geo::GeometryCore const& geom, + geo::WireReadoutGeom const& wireReadoutAlg, std::string const& logCategory = "WindowTopologyManager" ); @@ -460,11 +461,13 @@ inline void icarus::trigger::WindowTopologyVerification::operator() //------------------------------------------------------------------------------ inline icarus::trigger::WindowTopologyManager::WindowTopologyManager( geo::GeometryCore const& geom, + geo::WireReadoutGeom const& wireReadoutAlg, std::string const& logCategory /* = "WindowTopologyManager" */ ) : icarus::ns::util::mfLoggingClass(logCategory) , fVerify{ logCategory } , fGeom(&geom) + , fChannelMapAlg(&wireReadoutAlg) {} @@ -541,7 +544,7 @@ template void icarus::trigger::WindowTopologyManager::extractTopology(Gates const& gates) { icarus::trigger::WindowTopologyAlg const topoMaker - { *fGeom, logCategory() + "_Extractor" }; + { *fGeom, *fChannelMapAlg, logCategory() + "_Extractor" }; fVerify.setTopology(topoMaker.createFromGates(gates)); } // icarus::trigger::WindowTopologyManager::extractTopology() @@ -549,4 +552,3 @@ void icarus::trigger::WindowTopologyManager::extractTopology(Gates const& gates) //------------------------------------------------------------------------------ #endif // ICARUSCODE_PMT_TRIGGER_ALGORITHMS_WINDOWTOPOLOGYALG_H - diff --git a/icaruscode/PMT/Trigger/Algorithms/details/EventInfoUtils.cxx b/icaruscode/PMT/Trigger/Algorithms/details/EventInfoUtils.cxx index fce781daf..4aefce7a7 100644 --- a/icaruscode/PMT/Trigger/Algorithms/details/EventInfoUtils.cxx +++ b/icaruscode/PMT/Trigger/Algorithms/details/EventInfoUtils.cxx @@ -12,6 +12,7 @@ // LArSoft libraries #include "lardataalg/Utilities/quantities/spacetime.h" // microseconds +#include "larcorealg/Geometry/WireReadoutGeom.h" #include "larcorealg/Geometry/GeometryCore.h" #include "larcorealg/Geometry/TPCGeo.h" @@ -100,6 +101,7 @@ icarus::trigger::details::EventInfoExtractor::EventInfoExtractor( TimeSpan_t inSpillTimes, TimeSpan_t inPreSpillTimes, geo::GeometryCore const& geom, + geo::WireReadoutGeom const& wireReadoutAlg, detinfo::DetectorPropertiesData const* detProps, detinfo::DetectorTimings const* detTimings, std::string logCategory @@ -108,6 +110,7 @@ icarus::trigger::details::EventInfoExtractor::EventInfoExtractor( , fEnergyDepositTags(std::move(edepTags)) , fLogCategory(std::move(logCategory)) , fGeom(geom) + , fWireReadoutGeom(wireReadoutAlg) , fDetProps(detProps) , fDetTimings(detTimings) , fInSpillTimes(std::move(inSpillTimes)) @@ -277,11 +280,11 @@ void icarus::trigger::details::EventInfoExtractor::addEnergyDepositionInfo // only channels on any of the first induction planes std::vector const& wires - = fGeom.ChannelToWire(channel.Channel()); + = fWireReadoutGeom.ChannelToWire(channel.Channel()); if (empty(wires)) continue; // ghost channel or something; move on if (wires.front().Plane != 0) continue; // not the first induction plane - geo::PlaneGeo const& plane = fGeom.Plane(wires.front()); + geo::PlaneGeo const& plane = fWireReadoutGeom.Plane(wires.front()); for (auto const& [ tdc, IDEs ]: channel.TDCIDEMap()) { @@ -357,6 +360,7 @@ icarus::trigger::details::EventInfoExtractorMaker::EventInfoExtractorMaker( std::vector truthTags, EDepTags_t edepTags, geo::GeometryCore const& geom, + geo::WireReadoutGeom const& wireReadoutAlg, detinfo::DetectorPropertiesData const* detProps, detinfo::DetectorTimings const* detTimings, std::string logCategory @@ -365,6 +369,7 @@ icarus::trigger::details::EventInfoExtractorMaker::EventInfoExtractorMaker( , fEnergyDepositTags(std::move(edepTags)) , fLogCategory(std::move(logCategory)) , fGeom(geom) + , fWireReadoutGeom{wireReadoutAlg} , fDetProps(detProps) , fDetTimings(detTimings) {} @@ -378,7 +383,7 @@ icarus::trigger::details::EventInfoExtractorMaker::make return EventInfoExtractor{ fGeneratorTags, fEnergyDepositTags, inSpillTimes, inPreSpillTimes, - fGeom, fDetProps, fDetTimings, fLogCategory + fGeom, fWireReadoutGeom, fDetProps, fDetTimings, fLogCategory }; } // icarus::trigger::details::EventInfoExtractorMaker::make() diff --git a/icaruscode/PMT/Trigger/Algorithms/details/EventInfoUtils.h b/icaruscode/PMT/Trigger/Algorithms/details/EventInfoUtils.h index 56268e24c..4056db62b 100644 --- a/icaruscode/PMT/Trigger/Algorithms/details/EventInfoUtils.h +++ b/icaruscode/PMT/Trigger/Algorithms/details/EventInfoUtils.h @@ -21,6 +21,7 @@ #include "lardataalg/Utilities/quantities/energy.h" // gigaelectronvolt, ... #include "lardataobj/Simulation/SimEnergyDeposit.h" #include "lardataobj/Simulation/SimChannel.h" +#include "larcorealg/Geometry/fwd.h" #include "larcoreobj/SimpleTypesAndConstants/geo_vectors.h" // geo::Point_t #include "nusimdata/SimulationBase/MCTruth.h" @@ -38,12 +39,6 @@ //------------------------------------------------------------------------------ //---forward declarations //--- -namespace geo { - class TPCGeo; - class GeometryCore; -} // namespace geo - -//------------------------------------------------------------------------------ namespace icarus::trigger::details { class EventInfoExtractor; class EventInfoExtractorMaker; @@ -183,6 +178,7 @@ class icarus::trigger::details::EventInfoExtractor { TimeSpan_t inSpillTimes, TimeSpan_t inPreSpillTimes, geo::GeometryCore const& geom, + geo::WireReadoutGeom const& wireReadoutAlg, detinfo::DetectorPropertiesData const* detProps, detinfo::DetectorTimings const* detTimings, std::string logCategory = "EventInfoExtractor" @@ -216,6 +212,7 @@ class icarus::trigger::details::EventInfoExtractor { TimeSpan_t inSpillTimes, TimeSpan_t inPreSpillTimes, geo::GeometryCore const& geom, + geo::WireReadoutGeom const& wireReadoutAlg, detinfo::DetectorPropertiesData const* detProps, detinfo::DetectorTimings const* detTimings, std::string logCategory, @@ -285,6 +282,7 @@ class icarus::trigger::details::EventInfoExtractor { // --- BEGIN -- Set up ------------------------------------------------------ geo::GeometryCore const& fGeom; ///< Geometry service provider. + geo::WireReadoutGeom const& fWireReadoutGeom; ///< Detector properties information. detinfo::DetectorPropertiesData const* fDetProps = nullptr; @@ -376,6 +374,7 @@ class icarus::trigger::details::EventInfoExtractorMaker { std::vector truthTags, EDepTags_t edepTags, geo::GeometryCore const& geom, + geo::WireReadoutGeom const& wireReadoutAlg, detinfo::DetectorPropertiesData const* detProps, detinfo::DetectorTimings const* detTimings, std::string logCategory @@ -388,6 +387,7 @@ class icarus::trigger::details::EventInfoExtractorMaker { std::vector truthTags, EDepTags_t edepTags, geo::GeometryCore const& geom, + geo::WireReadoutGeom const& wireReadoutAlg, detinfo::DetectorPropertiesData const* detProps, detinfo::DetectorTimings const* detTimings, std::string logCategory, @@ -420,6 +420,7 @@ class icarus::trigger::details::EventInfoExtractorMaker { EDepTags_t fEnergyDepositTags; std::string const fLogCategory; geo::GeometryCore const& fGeom; + geo::WireReadoutGeom const& fWireReadoutGeom; detinfo::DetectorPropertiesData const* fDetProps = nullptr; detinfo::DetectorTimings const* fDetTimings = nullptr; @@ -461,6 +462,7 @@ icarus::trigger::details::EventInfoExtractor::EventInfoExtractor( TimeSpan_t inSpillTimes, TimeSpan_t inPreSpillTimes, geo::GeometryCore const& geom, + geo::WireReadoutGeom const& wireReadoutAlg, detinfo::DetectorPropertiesData const* detProps, detinfo::DetectorTimings const* detTimings, std::string logCategory, @@ -469,7 +471,7 @@ icarus::trigger::details::EventInfoExtractor::EventInfoExtractor( : EventInfoExtractor{ std::move(truthTags), std::move(edepTags), inSpillTimes, inPreSpillTimes, - geom, detProps, detTimings, std::move(logCategory) + geom, wireReadoutAlg, detProps, detTimings, std::move(logCategory) } { declareConsumables(consumesCollector, fGeneratorTags, fEnergyDepositTags); @@ -608,6 +610,7 @@ icarus::trigger::details::EventInfoExtractorMaker::EventInfoExtractorMaker( std::vector truthTags, EDepTags_t edepTags, geo::GeometryCore const& geom, + geo::WireReadoutGeom const& wireReadoutAlg, detinfo::DetectorPropertiesData const* detProps, detinfo::DetectorTimings const* detTimings, std::string logCategory, @@ -615,7 +618,7 @@ icarus::trigger::details::EventInfoExtractorMaker::EventInfoExtractorMaker( ) : EventInfoExtractorMaker( std::move(truthTags), std::move(edepTags), - geom, detProps, detTimings, std::move(logCategory) + geom, wireReadoutAlg, detProps, detTimings, std::move(logCategory) ) { EventInfoExtractor::declareConsumables @@ -627,4 +630,3 @@ icarus::trigger::details::EventInfoExtractorMaker::EventInfoExtractorMaker( #endif // ICARUSCODE_PMT_TRIGGER_ALGORITHM_DETAILS_EVENTINFOUTILS_H - diff --git a/icaruscode/PMT/Trigger/CMakeLists.txt b/icaruscode/PMT/Trigger/CMakeLists.txt index ffba045ed..7c3506cf8 100644 --- a/icaruscode/PMT/Trigger/CMakeLists.txt +++ b/icaruscode/PMT/Trigger/CMakeLists.txt @@ -91,6 +91,7 @@ cet_build_plugin(WriteBeamGateInfo art::module LIBRARIES cet_build_plugin(FixBeamGateInfo art::module LIBRARIES lardataobj::Simulation larcorealg::headers + larcorealg::CoreUtils lardataalg::headers ) diff --git a/icaruscode/PMT/Trigger/ExtractEnergyDepositionSummary_module.cc b/icaruscode/PMT/Trigger/ExtractEnergyDepositionSummary_module.cc index 129d09ef9..ed7f4d4f4 100644 --- a/icaruscode/PMT/Trigger/ExtractEnergyDepositionSummary_module.cc +++ b/icaruscode/PMT/Trigger/ExtractEnergyDepositionSummary_module.cc @@ -17,6 +17,7 @@ // LArSoft libraries #include "lardata/DetectorInfoServices/DetectorPropertiesService.h" #include "lardata/DetectorInfoServices/DetectorClocksService.h" +#include "larcore/Geometry/WireReadout.h" #include "larcore/Geometry/Geometry.h" #include "larcore/CoreUtils/ServiceUtil.h" // lar::providerFrom() #include "lardataalg/DetectorInfo/DetectorTimings.h" // detinfo::DetectorTimings @@ -298,6 +299,7 @@ icarus::trigger::ExtractEnergyDepositionSummary::ExtractEnergyDepositionSummary , makeEnergyDepSourceTag(config().EnergyDepositTags, config().SimChannelTag) // edepTags , fGeom // geom + , art::ServiceHandle()->Get() , (fDetProps? &(fDetProps->detProps): nullptr) // detProps , (fDetProps? &(fDetProps->detTimings): nullptr) // detTimings , fLogCategory // logCategory diff --git a/icaruscode/PMT/Trigger/LVDSgates_module.cc b/icaruscode/PMT/Trigger/LVDSgates_module.cc index 78c3cd939..fd447d73f 100644 --- a/icaruscode/PMT/Trigger/LVDSgates_module.cc +++ b/icaruscode/PMT/Trigger/LVDSgates_module.cc @@ -15,10 +15,10 @@ #include "sbnobj/ICARUS/PMT/Trigger/Data/OpticalTriggerGate.h" // LArSoft libraries -#include "larcore/Geometry/Geometry.h" +#include "larcore/Geometry/WireReadout.h" #include "larcore/CoreUtils/ServiceUtil.h" // lar::providerFrom() #include "lardataalg/Utilities/MultipleChoiceSelection.h" -#include "larcorealg/Geometry/GeometryCore.h" +#include "larcorealg/Geometry/WireReadoutGeom.h" #include "larcorealg/CoreUtils/StdUtils.h" // util::to_string() #include "larcorealg/CoreUtils/values.h" // util::const_values() #include "larcorealg/CoreUtils/get_elements.h" // util::get_elements() @@ -697,7 +697,7 @@ unsigned int icarus::trigger::LVDSgates::checkPairings() const { // // collect all the errors first // - auto const& geom = *(lar::providerFrom()); + auto const& wireReadoutAlg = art::ServiceHandle()->Get(); // collect configured and duplicate channel numbers @@ -717,14 +717,14 @@ unsigned int icarus::trigger::LVDSgates::checkPairings() const { // collect invalid channel numbers std::vector invalidChannels; for (raw::Channel_t channel: configuredChannels) { - if (!geom.IsValidOpChannel(channel)) invalidChannels.push_back(channel); + if (!wireReadoutAlg.IsValidOpChannel(channel)) invalidChannels.push_back(channel); } // for configured channels // collect missing channels - auto const endChannel = geom.MaxOpChannel() + 1U; + auto const endChannel = wireReadoutAlg.MaxOpChannel() + 1U; std::vector missingChannels; for (auto channel: util::counter(endChannel)) { - if (!geom.IsValidOpChannel(channel)) continue; + if (!wireReadoutAlg.IsValidOpChannel(channel)) continue; if (configuredChannels.count(channel) > 0U) continue; missingChannels.push_back(channel); } // for channel diff --git a/icaruscode/PMT/Trigger/MajorityTriggerSimulation_module.cc b/icaruscode/PMT/Trigger/MajorityTriggerSimulation_module.cc index d2a8436d9..aae0c544d 100644 --- a/icaruscode/PMT/Trigger/MajorityTriggerSimulation_module.cc +++ b/icaruscode/PMT/Trigger/MajorityTriggerSimulation_module.cc @@ -25,6 +25,7 @@ // LArSoft libraries #include "lardata/DetectorInfoServices/DetectorClocksService.h" +#include "larcore/Geometry/WireReadout.h" #include "larcore/Geometry/Geometry.h" #include "larcore/CoreUtils/ServiceUtil.h" // lar::providerFrom() #include "lardataalg/DetectorInfo/DetectorTimings.h" @@ -147,6 +148,7 @@ class icarus::trigger::GeometryChannelSplitter GeometryChannelSplitter( geo::GeometryCore const& geom, + geo::WireReadoutGeom const& wireReadoutAlg, std::string const& logCategory = "GeometryChannelSplitter" ); @@ -165,7 +167,7 @@ class icarus::trigger::GeometryChannelSplitter /// Creates a map like `fChannelCryostat` from the geometry information. static std::vector makeChannelCryostatMap - (geo::GeometryCore const& geom); + (geo::WireReadoutGeom const& wireReadoutAlg); }; // class icarus::trigger::GeometryChannelSplitter @@ -173,11 +175,12 @@ class icarus::trigger::GeometryChannelSplitter //------------------------------------------------------------------------------ icarus::trigger::GeometryChannelSplitter::GeometryChannelSplitter( geo::GeometryCore const& geom, + geo::WireReadoutGeom const& wireReadoutAlg, std::string const& logCategory /* = "GeometryChannelSplitter" */ ) : icarus::ns::util::mfLoggingClass(logCategory) , fNCryostats(geom.Ncryostats()) - , fChannelCryostat(makeChannelCryostatMap(geom)) + , fChannelCryostat(makeChannelCryostatMap(wireReadoutAlg)) {} @@ -200,17 +203,17 @@ icarus::trigger::GeometryChannelSplitter::byCryostat //------------------------------------------------------------------------------ auto icarus::trigger::GeometryChannelSplitter::makeChannelCryostatMap - (geo::GeometryCore const& geom) -> std::vector + (geo::WireReadoutGeom const& wireReadoutAlg) -> std::vector { - auto const nOpChannels = geom.NOpChannels(); + auto const nOpChannels = wireReadoutAlg.NOpChannels(); std::vector channelCryostatMap(nOpChannels); for (auto const opChannel: util::counter(nOpChannels)) { - if (!geom.IsValidOpChannel(opChannel)) continue; + if (!wireReadoutAlg.IsValidOpChannel(opChannel)) continue; channelCryostatMap.at(opChannel) - = geom.OpDetGeoFromOpChannel(opChannel).ID(); + = wireReadoutAlg.OpDetGeoFromOpChannel(opChannel).ID(); } // for all channels return channelCryostatMap; @@ -615,7 +618,9 @@ icarus::trigger::MajorityTriggerSimulation::MajorityTriggerSimulation , fOutputDir (*art::ServiceHandle()) // internal and cached , fCombiner (fLogCategory) - , fChannelSplitter(fGeom, fLogCategory) + , fChannelSplitter(fGeom, + art::ServiceHandle()->Get(), + fLogCategory) , fPlots( fOutputDir, "", "minimum primitives: " + std::to_string(fMinimumPrimitives) ) diff --git a/icaruscode/PMT/Trigger/MakeTriggerSimulationTree_module.cc b/icaruscode/PMT/Trigger/MakeTriggerSimulationTree_module.cc index 66a4eab23..404da3114 100644 --- a/icaruscode/PMT/Trigger/MakeTriggerSimulationTree_module.cc +++ b/icaruscode/PMT/Trigger/MakeTriggerSimulationTree_module.cc @@ -27,6 +27,7 @@ // LArSoft libraries #include "lardata/DetectorInfoServices/DetectorClocksService.h" +#include "larcore/Geometry/WireReadout.h" #include "larcore/Geometry/Geometry.h" #include "larcore/CoreUtils/ServiceUtil.h" // lar::providerFrom() #include "lardataalg/DetectorInfo/DetectorTimings.h" @@ -380,6 +381,7 @@ class icarus::trigger::MakeTriggerSimulationTree: public art::EDAnalyzer { // --- BEGIN Setup variables ------------------------------------------------- geo::GeometryCore const& fGeom; + geo::WireReadoutGeom const& fChannelMapAlg; // --- END Setup variables --------------------------------------------------- @@ -569,6 +571,7 @@ icarus::trigger::MakeTriggerSimulationTree::MakeTriggerSimulationTree , fLogCategory(config().LogCategory()) // setup , fGeom(*lar::providerFrom()) + , fChannelMapAlg{art::ServiceHandle()->Get()} // other data , fIDTree(*(art::ServiceHandle() ->make(config().EventTreeName().c_str(), "Event information") @@ -580,6 +583,7 @@ icarus::trigger::MakeTriggerSimulationTree::MakeTriggerSimulationTree makeEdepTag(config().EnergyDepositTags, config().EnergyDepositSummaryTag), // edepTags fGeom, // geom + fChannelMapAlg, nullptr, // detProps nullptr, // detTimings fLogCategory, // logCategory @@ -731,7 +735,7 @@ geo::Point_t icarus::trigger::MakeTriggerSimulationTree::gateChannelCentroid for (auto const channel: gate.channels()) { try { - centroid.add(fGeom.OpDetGeoFromOpChannel(channel).GetCenter()); + centroid.add(fChannelMapAlg.OpDetGeoFromOpChannel(channel).GetCenter()); } catch (cet::exception const& e) { throw cet::exception("MakeTriggerSimulationTree", "", e) diff --git a/icaruscode/PMT/Trigger/SlidingWindowTriggerEfficiencyPlots_module.cc b/icaruscode/PMT/Trigger/SlidingWindowTriggerEfficiencyPlots_module.cc index 6dcb5e714..8b5ca6e56 100644 --- a/icaruscode/PMT/Trigger/SlidingWindowTriggerEfficiencyPlots_module.cc +++ b/icaruscode/PMT/Trigger/SlidingWindowTriggerEfficiencyPlots_module.cc @@ -23,6 +23,7 @@ #include "lardata/DetectorInfoServices/DetectorClocksService.h" #include "lardata/Utilities/TensorIndices.h" // util::MatrixIndices #include "lardataalg/DetectorInfo/DetectorTimingTypes.h" // optical_time_ticks.. +#include "larcore/Geometry/WireReadout.h" #include "larcorealg/Geometry/GeometryCore.h" #include "larcorealg/Geometry/geo_vectors_utils.h" // MiddlePointAccumulator #include "larcorealg/CoreUtils/counter.h" @@ -557,6 +558,7 @@ icarus::trigger::SlidingWindowTriggerEfficiencyPlots::SlidingWindowTriggerEffici // internal variables , fWindowMapMan{ helper().geometry(), + art::ServiceHandle()->Get(), helper().logCategory() + "_WindowMapManager" } { diff --git a/icaruscode/PMT/Trigger/SlidingWindowTriggerSimulation_module.cc b/icaruscode/PMT/Trigger/SlidingWindowTriggerSimulation_module.cc index 3cd0d1e4f..f95638ca3 100644 --- a/icaruscode/PMT/Trigger/SlidingWindowTriggerSimulation_module.cc +++ b/icaruscode/PMT/Trigger/SlidingWindowTriggerSimulation_module.cc @@ -31,6 +31,7 @@ // LArSoft libraries #include "lardata/DetectorInfoServices/DetectorClocksService.h" +#include "larcore/Geometry/WireReadout.h" #include "larcore/Geometry/Geometry.h" #include "larcore/CoreUtils/ServiceUtil.h" // lar::providerFrom() #include "lardataalg/DetectorInfo/DetectorTimings.h" @@ -595,7 +596,9 @@ icarus::trigger::SlidingWindowTriggerSimulation::SlidingWindowTriggerSimulation , fOutputDir (*art::ServiceHandle()) // internal and cached , fWindowMapMan - { *lar::providerFrom(), fLogCategory + "_WindowMapManager" } + { *lar::providerFrom(), + art::ServiceHandle()->Get(), + fLogCategory + "_WindowMapManager" } , fPlots( fOutputDir, "", "requirement: " + fPattern.description() ) diff --git a/icaruscode/PMT/Trigger/TriggerEfficiencyPlotsBase.cxx b/icaruscode/PMT/Trigger/TriggerEfficiencyPlotsBase.cxx index 23b6cf220..b423ecc66 100644 --- a/icaruscode/PMT/Trigger/TriggerEfficiencyPlotsBase.cxx +++ b/icaruscode/PMT/Trigger/TriggerEfficiencyPlotsBase.cxx @@ -22,6 +22,7 @@ // LArSoft libraries #include "lardata/DetectorInfoServices/DetectorPropertiesService.h" #include "lardata/DetectorInfoServices/DetectorClocksService.h" +#include "larcore/Geometry/WireReadout.h" #include "larcore/Geometry/Geometry.h" #include "larcore/CoreUtils/ServiceUtil.h" // lar::providerFrom() #include "lardataalg/DetectorInfo/DetectorTimingTypes.h" // optical_time_ticks.. @@ -505,6 +506,7 @@ icarus::trigger::TriggerEfficiencyPlotsBase::TriggerEfficiencyPlotsBase , fLogCategory (config.LogCategory()) // services , fGeom (*lar::providerFrom()) + , fChannelMapAlg(art::ServiceHandle()->Get()) , fOutputDir (*art::ServiceHandle()) // cached , fEventInfoExtractorMaker( @@ -512,12 +514,13 @@ icarus::trigger::TriggerEfficiencyPlotsBase::TriggerEfficiencyPlotsBase makeEdepTag(config.EnergyDepositTags, config.EnergyDepositSummaryTag), // edepTags fGeom, // geom + fChannelMapAlg, nullptr, // detProps nullptr, // detTimings fLogCategory, // logCategory consumer // consumesCollector ) - , fChannelCryostat(makeChannelCryostatMap(fGeom)) + , fChannelCryostat(makeChannelCryostatMap(fChannelMapAlg)) { // // more complex parameter parsing @@ -1061,7 +1064,7 @@ void icarus::trigger::TriggerEfficiencyPlotsBase::initializePMTplots (PlotSandbox& plots) const { - unsigned int const nOpChannels = fGeom.NOpChannels(); + unsigned int const nOpChannels = fChannelMapAlg.NOpChannels(); // // plots independent of the trigger primitive requirements @@ -1453,17 +1456,17 @@ bool icarus::trigger::TriggerEfficiencyPlotsBase::deleteEmptyPlots //------------------------------------------------------------------------------ auto icarus::trigger::TriggerEfficiencyPlotsBase::makeChannelCryostatMap - (geo::GeometryCore const& geom) -> std::vector + (geo::WireReadoutGeom const& wireReadoutAlg) -> std::vector { - auto const nOpChannels = geom.NOpChannels(); + auto const nOpChannels = wireReadoutAlg.NOpChannels(); std::vector channelCryostatMap(nOpChannels); for (auto const opChannel: util::counter(nOpChannels)) { - if (!geom.IsValidOpChannel(opChannel)) continue; + if (!wireReadoutAlg.IsValidOpChannel(opChannel)) continue; channelCryostatMap.at(opChannel) - = geom.OpDetGeoFromOpChannel(opChannel).ID(); + = wireReadoutAlg.OpDetGeoFromOpChannel(opChannel).ID(); } // for all channels return channelCryostatMap; diff --git a/icaruscode/PMT/Trigger/TriggerEfficiencyPlotsBase.h b/icaruscode/PMT/Trigger/TriggerEfficiencyPlotsBase.h index c2d04f80c..7741cd726 100644 --- a/icaruscode/PMT/Trigger/TriggerEfficiencyPlotsBase.h +++ b/icaruscode/PMT/Trigger/TriggerEfficiencyPlotsBase.h @@ -36,6 +36,7 @@ #include "lardataalg/Utilities/intervals_fhicl.h" // microseconds from FHiCL #include "larcorealg/Geometry/GeometryCore.h" #include "larcorealg/Geometry/TPCGeo.h" +#include "larcorealg/Geometry/fwd.h" #include "larcorealg/CoreUtils/get_elements.h" #include "larcoreobj/SimpleTypesAndConstants/geo_vectors.h" #include "larcoreobj/SimpleTypesAndConstants/geo_types.h" // geo::CryostatID @@ -1486,6 +1487,7 @@ class icarus::trigger::TriggerEfficiencyPlotsBase { // --- BEGIN Service variables ----------------------------------------------- geo::GeometryCore const& fGeom; + geo::WireReadoutGeom const& fChannelMapAlg; /// ROOT directory where all the plots are written. art::TFileDirectory fOutputDir; @@ -1548,7 +1550,7 @@ class icarus::trigger::TriggerEfficiencyPlotsBase { /// Fills and returns a map of cryostat ID for each optical detector channel. static std::vector makeChannelCryostatMap - (geo::GeometryCore const& geom); + (geo::WireReadoutGeom const& wireReadoutAlg); static std::string thrAndCatName (std::string const& boxName, std::string const& category) diff --git a/icaruscode/PMT/Trigger/TriggerEfficiencyPlots_module.cc b/icaruscode/PMT/Trigger/TriggerEfficiencyPlots_module.cc index 80cf2c49e..6c47661b9 100644 --- a/icaruscode/PMT/Trigger/TriggerEfficiencyPlots_module.cc +++ b/icaruscode/PMT/Trigger/TriggerEfficiencyPlots_module.cc @@ -19,6 +19,7 @@ // LArSoft libraries #include "lardata/DetectorInfoServices/DetectorClocksService.h" #include "lardata/Utilities/TensorIndices.h" // util::MatrixIndices +#include "larcore/Geometry/WireReadout.h" #include "larcore/Geometry/Geometry.h" #include "larcore/CoreUtils/ServiceUtil.h" // lar::providerFrom() #include "lardataalg/DetectorInfo/DetectorTimings.h" @@ -1371,6 +1372,7 @@ class icarus::trigger::TriggerEfficiencyPlots: public art::EDAnalyzer { // --- BEGIN Service variables ----------------------------------------------- geo::GeometryCore const& fGeom; + geo::WireReadoutGeom const& fChannelMapAlg; /// ROOT directory where all the plots are written. art::TFileDirectory fOutputDir; @@ -1518,6 +1520,7 @@ icarus::trigger::TriggerEfficiencyPlots::TriggerEfficiencyPlots , fLogCategory (config().LogCategory()) // services , fGeom (*lar::providerFrom()) + , fChannelMapAlg{art::ServiceHandle()->Get()} , fOutputDir (*art::ServiceHandle()) // cached { @@ -2446,10 +2449,10 @@ auto icarus::trigger::TriggerEfficiencyPlots::ReadTriggerGates std::vector fChannelCryostat; - fChannelCryostat.reserve(fGeom.NOpChannels()); - for (auto const opChannel: util::counter(fGeom.NOpChannels())) { - if (!fGeom.IsValidOpChannel(opChannel)) continue; - fChannelCryostat[opChannel] = fGeom.OpDetGeoFromOpChannel(opChannel).ID(); + fChannelCryostat.reserve(fChannelMapAlg.NOpChannels()); + for (auto const opChannel: util::counter(fChannelMapAlg.NOpChannels())) { + if (!fChannelMapAlg.IsValidOpChannel(opChannel)) continue; + fChannelCryostat[opChannel] = fChannelMapAlg.OpDetGeoFromOpChannel(opChannel).ID(); } // for all channels std::vector> gatesPerCryostat diff --git a/icaruscode/PMT/Trigger/TriggerSimulationOnGates_module.cc b/icaruscode/PMT/Trigger/TriggerSimulationOnGates_module.cc index afb52bce2..eee5c986a 100644 --- a/icaruscode/PMT/Trigger/TriggerSimulationOnGates_module.cc +++ b/icaruscode/PMT/Trigger/TriggerSimulationOnGates_module.cc @@ -32,6 +32,7 @@ // LArSoft libraries #include "lardata/DetectorInfoServices/DetectorClocksService.h" +#include "larcore/Geometry/WireReadout.h" #include "larcore/Geometry/Geometry.h" #include "larcore/CoreUtils/ServiceUtil.h" // lar::providerFrom() #include "lardataalg/DetectorInfo/DetectorTimings.h" @@ -851,7 +852,9 @@ icarus::trigger::TriggerSimulationOnGates::TriggerSimulationOnGates , fOutputDir (*art::ServiceHandle()) // internal and cached , fWindowMapMan - { *lar::providerFrom(), fLogCategory + "_WindowMapManager" } + { *lar::providerFrom(), + art::ServiceHandle()->Get(), + fLogCategory + "_WindowMapManager" } , fPlots( fOutputDir, "", "requirement: " + fPattern.description() ) diff --git a/icaruscode/TPC/ICARUSWireCell/wcls-sim-drift-simchannel.fcl b/icaruscode/TPC/ICARUSWireCell/wcls-sim-drift-simchannel.fcl index bf7b1d1cd..3424485ba 100644 --- a/icaruscode/TPC/ICARUSWireCell/wcls-sim-drift-simchannel.fcl +++ b/icaruscode/TPC/ICARUSWireCell/wcls-sim-drift-simchannel.fcl @@ -7,7 +7,7 @@ services: } # explicitly set the split wire geometry services.Geometry: @local::icarus_geometry -services.ExptGeoHelperInterface: @local::icarus_geometry_helper +services.WireReadout: @local::icarus_wire_readout process_name: wclssim physics :{ diff --git a/icaruscode/TPC/SignalProcessing/HitFinder/GaussHitFinderICARUS_module.cc b/icaruscode/TPC/SignalProcessing/HitFinder/GaussHitFinderICARUS_module.cc index 59da0118e..240041172 100644 --- a/icaruscode/TPC/SignalProcessing/HitFinder/GaussHitFinderICARUS_module.cc +++ b/icaruscode/TPC/SignalProcessing/HitFinder/GaussHitFinderICARUS_module.cc @@ -41,7 +41,7 @@ #include "fhiclcpp/ParameterSet.h" // LArSoft Includes -#include "larcore/Geometry/Geometry.h" +#include "larcore/Geometry/WireReadout.h" #include "larcoreobj/SimpleTypesAndConstants/RawTypes.h" // raw::ChannelID_t #include "lardataobj/RecoBase/Hit.h" #include "larreco/HitFinder/HitFilterAlg.h" @@ -182,8 +182,7 @@ namespace hit { "GaussHitFinderICARUS::FillOutHitParameterVector ERROR! Input config vector has zero size."); std::vector output; - art::ServiceHandle geom; - const unsigned int N_PLANES = geom->Nplanes(); + const unsigned int N_PLANES = art::ServiceHandle()->Get().Nplanes(); if (input.size() == 1) output.resize(N_PLANES, input[0]); @@ -228,7 +227,7 @@ namespace hit { // ################################ // ### Calling Geometry service ### // ################################ - art::ServiceHandle geom; + auto const& wireReadout = art::ServiceHandle()->Get(); // ############################################### // ### Making a ptr vector to put on the event ### @@ -304,7 +303,7 @@ namespace hit { raw::ChannelID_t channel = wire->Channel(); // get the WireID for this hit - std::vector wids = geom->ChannelToWire(channel); + std::vector wids = wireReadout.ChannelToWire(channel); // for now, just take the first option returned from ChannelToWire geo::WireID wid = wids[0]; // We need to know the plane to look up parameters diff --git a/icaruscode/TPC/SignalProcessing/HitFinder/HitConverter_module.cc b/icaruscode/TPC/SignalProcessing/HitFinder/HitConverter_module.cc index 9f339c318..f064c4e80 100644 --- a/icaruscode/TPC/SignalProcessing/HitFinder/HitConverter_module.cc +++ b/icaruscode/TPC/SignalProcessing/HitFinder/HitConverter_module.cc @@ -25,7 +25,6 @@ // LArSoft libraries #include "larcoreobj/SimpleTypesAndConstants/RawTypes.h" // raw::ChannelID_t -#include "larcore/Geometry/Geometry.h" #include "larcore/CoreUtils/ServiceUtil.h" // lar::providerFrom() #include "larcorealg/CoreUtils/zip.h" #include "lardataobj/RecoBase/Hit.h" @@ -52,8 +51,6 @@ class HitConvert : public art::EDProducer bool fDiagnosticOutput; ///< secret diagnostics flag size_t fEventCount; ///< count of event processed - const geo::GeometryCore* fGeometry = lar::providerFrom(); - }; // class HitConvert DEFINE_ART_MODULE(HitConvert) diff --git a/icaruscode/TPC/SignalProcessing/HitFinder/HitFinderTools/CandHitICARUS_tool.cc b/icaruscode/TPC/SignalProcessing/HitFinder/HitFinderTools/CandHitICARUS_tool.cc index 672aef0b2..383fcd6f1 100644 --- a/icaruscode/TPC/SignalProcessing/HitFinder/HitFinderTools/CandHitICARUS_tool.cc +++ b/icaruscode/TPC/SignalProcessing/HitFinder/HitFinderTools/CandHitICARUS_tool.cc @@ -9,7 +9,7 @@ #include "art/Utilities/make_tool.h" #include "messagefacility/MessageLogger/MessageLogger.h" #include "cetlib_except/exception.h" -#include "larcore/Geometry/Geometry.h" +#include "larcore/Geometry/WireReadout.h" #include "larcore/CoreUtils/ServiceUtil.h" // lar::providerFrom() #include @@ -62,7 +62,7 @@ class CandHitICARUS : ICandidateHitFinder float fMinHitHeight; //< Drop candidate hits with height less than this size_t fNumInterveningTicks; //< Number ticks between candidate hits to merge - const geo::GeometryCore* fGeometry = lar::providerFrom(); + const geo::WireReadoutGeom* fChannelMapAlg = &art::ServiceHandle()->Get(); }; //---------------------------------------------------------------------- @@ -99,7 +99,7 @@ void CandHitICARUS::findHitCandidates(const recob::Wire::RegionsOfInterest_t::da HitCandidateVec& hits) const { // get the WireID for this hit - std::vector wids = fGeometry->ChannelToWire(channel); + std::vector wids = fChannelMapAlg->ChannelToWire(channel); // for now, just take the first option returned from ChannelToWire geo::WireID wid = wids[0]; // We need to know the plane to look up parameters diff --git a/icaruscode/TPC/SignalProcessing/HitFinder/ICARUSHitFinder_module.cc b/icaruscode/TPC/SignalProcessing/HitFinder/ICARUSHitFinder_module.cc index cf5565cd3..b95ae1e06 100644 --- a/icaruscode/TPC/SignalProcessing/HitFinder/ICARUSHitFinder_module.cc +++ b/icaruscode/TPC/SignalProcessing/HitFinder/ICARUSHitFinder_module.cc @@ -31,7 +31,7 @@ //LArSoft -#include "larcore/Geometry/Geometry.h" +#include "larcore/Geometry/WireReadout.h" #include "larcore/CoreUtils/ServiceUtil.h" // lar::providerFrom() #include "larevt/Filters/ChannelFilter.h" #include "lardataobj/RawData/RawDigit.h" @@ -43,7 +43,6 @@ //LArSoft From FFT #include "larcoreobj/SimpleTypesAndConstants/geo_types.h" -#include "larcore/Geometry/Geometry.h" #include "larcorealg/Geometry/CryostatGeo.h" #include "larcorealg/Geometry/TPCGeo.h" #include "larcorealg/Geometry/PlaneGeo.h" @@ -228,7 +227,7 @@ double fChi2NDF; ///maximum Chisquared / NDF all mutable ICARUShitFitCache fFitCache; ///< Cached functions for multi-peak fits. mutable ICARUSlongHitFitCache fLongFitCache; ///< Cached functions for long hits. - const geo::GeometryCore* fGeometry = lar::providerFrom(); + const geo::WireReadoutGeom* fChannelMapAlg = &art::ServiceHandle()->Get(); }; // class ICARUSHitFinder @@ -329,9 +328,6 @@ double fChi2NDF; ///maximum Chisquared / NDF all // std::cout << " ICARUSHitFinder produce " << std::endl; - //GET THE GEOMETRY. - art::ServiceHandle geom; - // ############################################### // ### Making a ptr vector to put on the event ### // ############################################### @@ -431,7 +427,7 @@ double fChi2NDF; ///maximum Chisquared / NDF all // get the WireID for this hit - std::vector wids = geom->ChannelToWire(channel); + std::vector wids = fChannelMapAlg->ChannelToWire(channel); // for now, just take the first option returned from ChannelToWire geo::WireID wid = wids[0]; // We need to know the plane to look up parameters @@ -448,7 +444,7 @@ double fChi2NDF; ///maximum Chisquared / NDF all channel = rawdigits->Channel(); fDataSize = rawdigits->Samples(); - std::vector widVec = geom->ChannelToWire(channel); + std::vector widVec = fChannelMapAlg->ChannelToWire(channel); size_t iwire = widVec[0].Wire; // size_t plane = widVec[0].Plane; @@ -486,7 +482,7 @@ double fChi2NDF; ///maximum Chisquared / NDF all - // sigType = geom->SignalType(channel); + // sigType = fChannelMapAlg->SignalType(channel); peakHeight.clear(); endTimes.clear(); @@ -524,7 +520,7 @@ double fChi2NDF; ///maximum Chisquared / NDF all reco_tool::ICandidateHitFinder::MergeHitCandidateVec mergedCandidateHitVec; - std::vector wids = geom->ChannelToWire(channel); + std::vector wids = fChannelMapAlg->ChannelToWire(channel); std::vector tempVec = holder; recob::Wire::RegionsOfInterest_t::datarange_t rangeData(size_t(0),std::move(tempVec)); diff --git a/icaruscode/TPC/SignalProcessing/RawDigitFilter/Algorithms/MorphologicalFilter_tool.cc b/icaruscode/TPC/SignalProcessing/RawDigitFilter/Algorithms/MorphologicalFilter_tool.cc index 69063b23b..5a2ecd098 100644 --- a/icaruscode/TPC/SignalProcessing/RawDigitFilter/Algorithms/MorphologicalFilter_tool.cc +++ b/icaruscode/TPC/SignalProcessing/RawDigitFilter/Algorithms/MorphologicalFilter_tool.cc @@ -10,7 +10,7 @@ #include "messagefacility/MessageLogger/MessageLogger.h" #include "cetlib_except/exception.h" #include "lardata/DetectorInfoServices/DetectorPropertiesService.h" -#include "larcore/Geometry/Geometry.h" +#include "larcore/Geometry/WireReadout.h" #include "larcore/CoreUtils/ServiceUtil.h" // lar::providerFrom() #include "icaruscode/TPC/SignalProcessing/RawDigitFilter/Algorithms/IRawDigitFilter.h" @@ -76,7 +76,7 @@ class MorphologicalFilter : public IRawDigitFilter icarus_signal_processing::WaveformTools fWaveformTool; // Services - const geo::GeometryCore* fGeometry = lar::providerFrom(); + const geo::WireReadoutGeom* fChannelMapAlg = &art::ServiceHandle()->Get(); }; //---------------------------------------------------------------------- @@ -259,7 +259,7 @@ caldata::HistogramMap MorphologicalFilter::initializeHistograms(size_t channel, if (fOutputHistograms) { // Try to limit to the wire number (since we are already segregated by plane) - std::vector wids = fGeometry->ChannelToWire(channel); + std::vector wids = fChannelMapAlg->ChannelToWire(channel); size_t cryo = wids[0].Cryostat; size_t tpc = wids[0].TPC; size_t plane = wids[0].Plane; diff --git a/icaruscode/TPC/SignalProcessing/RawDigitFilter/RawDigitFilterICARUS_module.cc b/icaruscode/TPC/SignalProcessing/RawDigitFilter/RawDigitFilterICARUS_module.cc index abb185bc2..59d1b2901 100755 --- a/icaruscode/TPC/SignalProcessing/RawDigitFilter/RawDigitFilterICARUS_module.cc +++ b/icaruscode/TPC/SignalProcessing/RawDigitFilter/RawDigitFilterICARUS_module.cc @@ -48,7 +48,7 @@ #include "canvas/Persistency/Common/Ptr.h" #include "messagefacility/MessageLogger/MessageLogger.h" -#include "larcore/Geometry/Geometry.h" +#include "larcore/Geometry/WireReadout.h" #include "larevt/CalibrationDBI/Interface/DetPedestalService.h" #include "larevt/CalibrationDBI/Interface/DetPedestalProvider.h" #include "larevt/CalibrationDBI/Interface/ChannelStatusService.h" @@ -117,7 +117,7 @@ class RawDigitFilterICARUS : public art::ReplicatedProducer std::map> fFilterToolMap; // Useful services, keep copies for now (we can update during begin run periods) - geo::GeometryCore const* fGeometry; ///< pointer to Geometry service + geo::WireReadoutGeom const* fChannelMapAlg; const lariov::DetPedestalProvider& fPedestalRetrievalAlg; ///< Keep track of an instance to the pedestal retrieval alg }; @@ -140,7 +140,7 @@ RawDigitFilterICARUS::RawDigitFilterICARUS(fhicl::ParameterSet const & pset, art fPedestalRetrievalAlg(*lar::providerFrom()) { - fGeometry = lar::providerFrom(); + fChannelMapAlg = &art::ServiceHandle()->Get(); configure(pset); produces >(); @@ -239,7 +239,7 @@ void RawDigitFilterICARUS::produce(art::Event & event, art::ProcessingFrame cons // Require a valid handle if (digitVecHandle.isValid() && digitVecHandle->size()>0 ) { - unsigned int maxChannels = fGeometry->Nchannels(); + unsigned int maxChannels = fChannelMapAlg->Nchannels(); // Sadly, the RawDigits come to us in an unsorted condition which is not optimal for // what we want to do here. So we make a vector of pointers to the input raw digits and sort them @@ -308,7 +308,7 @@ void RawDigitFilterICARUS::produce(art::Event & event, art::ProcessingFrame cons // The below try-catch block may no longer be necessary // Decode the channel and make sure we have a valid one - std::vector wids = fGeometry->ChannelToWire(channel); + std::vector wids = fChannelMapAlg->ChannelToWire(channel); if (channel >= maxChannels || wids.empty()) continue; diff --git a/icaruscode/TPC/SignalProcessing/RawDigitFilter/RawDigitSmoother_module.cc b/icaruscode/TPC/SignalProcessing/RawDigitFilter/RawDigitSmoother_module.cc index af484577f..a9bf93fc4 100755 --- a/icaruscode/TPC/SignalProcessing/RawDigitFilter/RawDigitSmoother_module.cc +++ b/icaruscode/TPC/SignalProcessing/RawDigitFilter/RawDigitSmoother_module.cc @@ -29,7 +29,7 @@ #include "canvas/Persistency/Common/Ptr.h" #include "messagefacility/MessageLogger/MessageLogger.h" -#include "larcore/Geometry/Geometry.h" +#include "larcore/Geometry/WireReadout.h" #include "larevt/CalibrationDBI/Interface/DetPedestalService.h" #include "larevt/CalibrationDBI/Interface/DetPedestalProvider.h" @@ -87,7 +87,7 @@ class RawDigitSmoother : public art::EDProducer caldata::RawDigitCharacterizationAlg fCharacterizationAlg; // Useful services, keep copies for now (we can update during begin run periods) - geo::GeometryCore const* fGeometry; ///< pointer to Geometry service + geo::WireReadoutGeom const* fChannelMapAlg; const lariov::DetPedestalProvider& fPedestalRetrievalAlg; ///< Keep track of an instance to the pedestal retrieval alg }; @@ -106,7 +106,7 @@ RawDigitSmoother::RawDigitSmoother(fhicl::ParameterSet const & pset) : EDProduce fPedestalRetrievalAlg(*lar::providerFrom()) { - fGeometry = lar::providerFrom(); + fChannelMapAlg = &art::ServiceHandle()->Get(); configure(pset); produces>("erosion"); @@ -216,7 +216,7 @@ void RawDigitSmoother::produce(art::Event & event) averageRawDigit->reserve(digitVecHandle->size()); medianRawDigit->reserve(digitVecHandle->size()); - unsigned int maxChannels = fGeometry->Nchannels(); + unsigned int maxChannels = fChannelMapAlg->Nchannels(); // Sadly, the RawDigits come to us in an unsorted condition which is not optimal for // what we want to do here. So we make a vector of pointers to the input raw digits and sort them @@ -273,7 +273,7 @@ void RawDigitSmoother::produce(art::Event & event) // Avoid creating and destroying a vector each loop... make a single one here caldata::RawDigitVector inputAdcVector(rawDataSize); - geo::WireID lastWireID = fGeometry->ChannelToWire(rawDigitVec.front()->Channel())[0]; + geo::WireID lastWireID = fChannelMapAlg->ChannelToWire(rawDigitVec.front()->Channel())[0]; // Commence looping over raw digits for(const auto& rawDigit : rawDigitVec) @@ -283,10 +283,10 @@ void RawDigitSmoother::produce(art::Event & event) if (channel >= maxChannels) continue; // Decode the channel and make sure we have a valid one - std::vector wids = fGeometry->ChannelToWire(channel); + std::vector wids = fChannelMapAlg->ChannelToWire(channel); // Look to see if we have crossed to another plane - if (lastWireID.asPlaneID().cmp(wids[0].asPlaneID()) != 0) + if (lastWireID.asPlaneID() != wids[0].asPlaneID()) { // Dispose of the end set of RawDigits (in order) WaveformList::iterator inputWaveItr = inputWaveformList.begin(); @@ -438,7 +438,7 @@ void RawDigitSmoother::produce(art::Event & event) if (fOutputWaveforms) { // Try to limit to the wire number (since we are already segregated by plane) - std::vector wids = fGeometry->ChannelToWire(channel); + std::vector wids = fChannelMapAlg->ChannelToWire(channel); size_t cryo = wids[0].Cryostat; size_t tpc = wids[0].TPC; size_t plane = wids[0].Plane; diff --git a/icaruscode/TPC/SignalProcessing/RawDigitFilter/TPCNoiseMC_module.cc b/icaruscode/TPC/SignalProcessing/RawDigitFilter/TPCNoiseMC_module.cc index c5d9e21e1..4316fc80d 100644 --- a/icaruscode/TPC/SignalProcessing/RawDigitFilter/TPCNoiseMC_module.cc +++ b/icaruscode/TPC/SignalProcessing/RawDigitFilter/TPCNoiseMC_module.cc @@ -8,7 +8,7 @@ //////////////////////////////////////////////////////////////////////// // LArSoft Includes -#include "larcore/Geometry/Geometry.h" +#include "larcore/Geometry/WireReadout.h" #include "larcoreobj/SimpleTypesAndConstants/geo_types.h" #include "lardataobj/RawData/RawDigit.h" #include "lardataobj/RawData/raw.h" @@ -262,7 +262,7 @@ std::cout << " end constructor " << std::endl; void TPCNoiseMC::TPCNoiseMC::analyze(const art::Event& e) { std::cout << " begin analyze " << std::endl; - art::ServiceHandle geom; + geo::WireReadoutGeom const& wireReadoutAlg = art::ServiceHandle()->Get(); // Clear vectors before filling for this event. fChannel.clear(); @@ -318,7 +318,7 @@ std::cout << " run " << fRun << std::endl; // Calculate mean values. float mean(float(std::accumulate(SortedADC.begin(),SortedADC.end(),0))/float(SortedADC.size())); -std::vector widVec = geom->ChannelToWire(RawDigit.Channel()); +std::vector widVec = wireReadoutAlg.ChannelToWire(RawDigit.Channel()); size_t plane = widVec[0].Plane; size_t wire = widVec[0].Wire; size_t tpc = widVec[0].TPC; diff --git a/icaruscode/TPC/SignalProcessing/RawDigitFilter/TPCNoise_module.cc b/icaruscode/TPC/SignalProcessing/RawDigitFilter/TPCNoise_module.cc index 1f12da0c0..a0e03f465 100644 --- a/icaruscode/TPC/SignalProcessing/RawDigitFilter/TPCNoise_module.cc +++ b/icaruscode/TPC/SignalProcessing/RawDigitFilter/TPCNoise_module.cc @@ -8,7 +8,7 @@ //////////////////////////////////////////////////////////////////////// // LArSoft Includes -#include "larcore/Geometry/Geometry.h" +#include "larcore/Geometry/WireReadout.h" #include "larcoreobj/SimpleTypesAndConstants/geo_types.h" #include "lardataobj/RawData/RawDigit.h" #include "lardataobj/RawData/raw.h" @@ -286,7 +286,7 @@ std::cout << " end constructor " << std::endl; void tpcnoise::TPCNoise::analyze(const art::Event& e) { std::cout << " begin analyze " << std::endl; - art::ServiceHandle geom; + auto const& wireReadoutAlg = art::ServiceHandle()->Get(); // Clear vectors before filling for this event. fChannel.clear(); @@ -331,7 +331,7 @@ std::cout << " run " << fRun << std::endl; // Calculate mean values. float mean(float(std::accumulate(SortedADC.begin(),SortedADC.end(),0))/float(SortedADC.size())); -std::vector widVec = geom->ChannelToWire(RawDigit.Channel()); +std::vector widVec = wireReadoutAlg.ChannelToWire(RawDigit.Channel()); size_t plane = widVec[0].Plane; size_t wire = widVec[0].Wire; @@ -440,7 +440,7 @@ std::cout << " intrinsic instance " << fIntrinsicInstance << std::endl; RawLessPed.resize(RawADC.size()); std::transform(RawADC.begin(),RawADC.end(),RawLessPed.begin(),std::bind(std::minus(),std::placeholders::_1,median)); fFFT->getFFTPower(RawLessPed, power); -std::vector widVec = geom->ChannelToWire(RawDigit.Channel()); +std::vector widVec = wireReadoutAlg.ChannelToWire(RawDigit.Channel()); size_t plane = widVec[0].Plane; if(plane==0) { std::transform(fIntrinsicPowerI1.at(0).begin(), fIntrinsicPowerI1.at(0).end(), power.begin(), fIntrinsicPowerI1.at(0).begin(), std::plus()); } @@ -512,7 +512,7 @@ std::cout << " coherent instance " << fCoherentInstance << std::endl; RawLessPed.resize(RawADC.size()); std::transform(RawADC.begin(),RawADC.end(),RawLessPed.begin(),std::bind(std::minus(),std::placeholders::_1,median)); fFFT->getFFTPower(RawLessPed, power); -std::vector widVec = geom->ChannelToWire(RawDigit.Channel()); +std::vector widVec = wireReadoutAlg.ChannelToWire(RawDigit.Channel()); size_t plane = widVec[0].Plane; if(plane==0) { std::transform(fCoherentPowerI1.at(0).begin(), fCoherentPowerI1.at(0).end(), power.begin(), fCoherentPowerI1.at(0).begin(), std::plus()); } diff --git a/icaruscode/TPC/SignalProcessing/RawDigitFilter/mtRawDigitFilterICARUS_module.cc b/icaruscode/TPC/SignalProcessing/RawDigitFilter/mtRawDigitFilterICARUS_module.cc index a582f40a7..58903dbc7 100755 --- a/icaruscode/TPC/SignalProcessing/RawDigitFilter/mtRawDigitFilterICARUS_module.cc +++ b/icaruscode/TPC/SignalProcessing/RawDigitFilter/mtRawDigitFilterICARUS_module.cc @@ -17,7 +17,7 @@ #include "canvas/Persistency/Common/Ptr.h" #include "messagefacility/MessageLogger/MessageLogger.h" -#include "larcore/Geometry/Geometry.h" +#include "larcore/Geometry/WireReadout.h" #include "larevt/CalibrationDBI/Interface/DetPedestalService.h" #include "larevt/CalibrationDBI/Interface/DetPedestalProvider.h" #include "lardata/Utilities/LArFFTWPlan.h" @@ -138,7 +138,7 @@ class RawDigitFilterICARUS : public art::ReplicatedProducer std::map> fFilterToolMap; // Useful services, keep copies for now (we can update during begin run periods) - geo::GeometryCore const* fGeometry; ///< pointer to Geometry service + geo::WireReadoutGeom const* fChannelMapAlg; const lariov::DetPedestalProvider& fPedestalRetrievalAlg; ///< Keep track of an instance to the pedestal retrieval alg // mwang added @@ -237,7 +237,7 @@ RawDigitFilterICARUS::RawDigitFilterICARUS(fhicl::ParameterSet const & pset, art fChannelGroups(pset) { - fGeometry = lar::providerFrom(); + fChannelMapAlg = &art::ServiceHandle()->Get(); configure(pset); produces >(); @@ -322,7 +322,7 @@ void RawDigitFilterICARUS::produce(art::Event & event, art::ProcessingFrame cons // ... Require a valid handle if (digitVecHandle.isValid() && digitVecHandle->size()>0 ){ - unsigned int maxChannels = fGeometry->Nchannels(); + unsigned int maxChannels = fChannelMapAlg->Nchannels(); // .. Let's first sort the rawDigitVec std::vector rawDigitVec; @@ -369,7 +369,7 @@ void RawDigitFilterICARUS::produce(art::Event & event, art::ProcessingFrame cons bool goodChan(true); std::vector wids; try { - wids = fGeometry->ChannelToWire(channel); + wids = fChannelMapAlg->ChannelToWire(channel); } catch(...){ goodChan = false; diff --git a/icaruscode/TPC/SignalProcessing/RecoWire/Decon1DROI_module.cc b/icaruscode/TPC/SignalProcessing/RecoWire/Decon1DROI_module.cc index 720eefd26..388a48fd7 100644 --- a/icaruscode/TPC/SignalProcessing/RecoWire/Decon1DROI_module.cc +++ b/icaruscode/TPC/SignalProcessing/RecoWire/Decon1DROI_module.cc @@ -35,7 +35,7 @@ // LArSoft libraries #include "larcoreobj/SimpleTypesAndConstants/RawTypes.h" // raw::ChannelID_t -#include "larcore/Geometry/Geometry.h" +#include "larcore/Geometry/WireReadout.h" #include "larcore/CoreUtils/ServiceUtil.h" // lar::providerFrom() #include "lardataobj/RawData/RawDigit.h" #include "lardataobj/RawData/raw.h" @@ -140,7 +140,7 @@ class Decon1DROI : public art::ReplicatedProducer icarus_signal_processing::WaveformTools fWaveformTool; - const geo::GeometryCore* fGeometry = lar::providerFrom(); + const geo::WireReadoutGeom& fChannelMapAlg = art::ServiceHandle()->Get(); const lariov::ChannelStatusProvider* fChannelFilter = lar::providerFrom(); const lariov::DetPedestalProvider* fPedRetrievalAlg = lar::providerFrom(); @@ -236,8 +236,8 @@ void Decon1DROI::reconfigure(fhicl::ParameterSet const& pset) fFullRMSVec[planeIdx] = tfs->make( Form("RMSFPlane_%02zu",planeIdx), "Full RMS;RMS (ADC);", 400, 0., 40.); fTruncRMSVec[planeIdx] = tfs->make( Form("RMSTPlane_%02zu",planeIdx), "Truncated RMS;RMS (ADC);", 100, 0., 10.); fNumTruncBinsVec[planeIdx] = tfs->make( Form("NTruncBins_%02zu",planeIdx), ";# bins", 640, 0., 6400.); - fPedByChanVec[planeIdx] = tfs->make(Form("PedByWirePlane_%02zu",planeIdx), ";Wire#", fGeometry->Nwires(planeID), 0., fGeometry->Nwires(planeID), -5., 5.); - fTruncRMSByChanVec[planeIdx] = tfs->make(Form("TruncRMSByWirePlane_%02zu",planeIdx), ";Wire#", fGeometry->Nwires(planeID), 0., fGeometry->Nwires(planeID), 0., 10.); + fPedByChanVec[planeIdx] = tfs->make(Form("PedByWirePlane_%02zu",planeIdx), ";Wire#", fChannelMapAlg.Nwires(planeID), 0., fChannelMapAlg.Nwires(planeID), -5., 5.); + fTruncRMSByChanVec[planeIdx] = tfs->make(Form("TruncRMSByWirePlane_%02zu",planeIdx), ";Wire#", fChannelMapAlg.Nwires(planeID), 0., fChannelMapAlg.Nwires(planeID), 0., 10.); fNumROIsHistVec[planeIdx] = tfs->make( Form("NROISplane_%02zu",planeIdx), ";# ROIs;", 100, 0, 100); fROILenHistVec[planeIdx] = tfs->make( Form("ROISIZEplane_%02zu",planeIdx), ";ROI size;", 500, 0, 500); } @@ -393,7 +393,7 @@ float Decon1DROI::fixTheFreakingWaveform(const std::vector& waveform, raw std::vector wids; try { - wids = fGeometry->ChannelToWire(channel); + wids = fChannelMapAlg.ChannelToWire(channel); } catch(...) { @@ -443,7 +443,7 @@ void Decon1DROI::processChannel(size_t idx, float pedestal = 0.; // Recover the plane info - std::vector wids = fGeometry->ChannelToWire(channel); + std::vector wids = fChannelMapAlg.ChannelToWire(channel); // skip bad channels if( fChannelFilter->Status(channel) < fMinAllowedChanStatus) return; diff --git a/icaruscode/TPC/SignalProcessing/RecoWire/DeconTools/ROIFinderDifferential_tool.cc b/icaruscode/TPC/SignalProcessing/RecoWire/DeconTools/ROIFinderDifferential_tool.cc index 42e69be32..a4579c9cd 100644 --- a/icaruscode/TPC/SignalProcessing/RecoWire/DeconTools/ROIFinderDifferential_tool.cc +++ b/icaruscode/TPC/SignalProcessing/RecoWire/DeconTools/ROIFinderDifferential_tool.cc @@ -11,7 +11,7 @@ #include "messagefacility/MessageLogger/MessageLogger.h" #include "cetlib_except/exception.h" #include "lardata/DetectorInfoServices/DetectorPropertiesService.h" -#include "larcore/Geometry/Geometry.h" +#include "larcore/Geometry/WireReadout.h" #include "larcore/CoreUtils/ServiceUtil.h" // lar::providerFrom() #include "icarus_signal_processing/WaveformTools.h" @@ -77,7 +77,7 @@ class ROIFinderDifferential : public IROIFinder icarus_signal_processing::WaveformTools fWaveformTool; // Services - const geo::GeometryCore* fGeometry = lar::providerFrom(); + const geo::WireReadoutGeom* fChannelMapAlg = &art::ServiceHandle()->Get(); }; //---------------------------------------------------------------------- @@ -164,9 +164,9 @@ void ROIFinderDifferential::FindROIs(const Waveform& waveform, size_t channel, s // max and min is more than the threshold are kept. // First up, determine what kind of wire we have - std::vector wids = fGeometry->ChannelToWire(channel); + std::vector wids = fChannelMapAlg->ChannelToWire(channel); const geo::PlaneID& planeID = wids[0].planeID(); - geo::SigType_t sigType = fGeometry->SignalType(planeID); + geo::SigType_t sigType = fChannelMapAlg->SignalType(planeID); // Local copy of the input waveform Waveform waveformDeriv(waveform.size()); @@ -209,7 +209,7 @@ void ROIFinderDifferential::FindROIs(const Waveform& waveform, size_t channel, s fDiffRmsHist->Fill(truncRMS, 1.); // Try to limit to the wire number (since we are already segregated by plane) - std::vector wids = fGeometry->ChannelToWire(channel); + std::vector wids = fChannelMapAlg->ChannelToWire(channel); size_t wire = wids[0].Wire; // Make a directory for these histograms diff --git a/icaruscode/TPC/SignalProcessing/RecoWire/DeconTools/ROIFinderMorphological_tool.cc b/icaruscode/TPC/SignalProcessing/RecoWire/DeconTools/ROIFinderMorphological_tool.cc index 05f1d1ace..c653347fb 100644 --- a/icaruscode/TPC/SignalProcessing/RecoWire/DeconTools/ROIFinderMorphological_tool.cc +++ b/icaruscode/TPC/SignalProcessing/RecoWire/DeconTools/ROIFinderMorphological_tool.cc @@ -11,7 +11,7 @@ #include "messagefacility/MessageLogger/MessageLogger.h" #include "cetlib_except/exception.h" #include "lardata/DetectorInfoServices/DetectorPropertiesService.h" -#include "larcore/Geometry/Geometry.h" +#include "larcore/Geometry/WireReadout.h" #include "larcore/CoreUtils/ServiceUtil.h" // lar::providerFrom() #include "icarus_signal_processing/WaveformTools.h" @@ -108,7 +108,7 @@ class ROIFinderMorphological : public IROIFinder icarus_signal_processing::WaveformTools fWaveformTool; // Services - const geo::GeometryCore* fGeometry = lar::providerFrom(); + const geo::WireReadoutGeom* fChannelMapAlg = &art::ServiceHandle()->Get(); }; //---------------------------------------------------------------------- @@ -648,7 +648,7 @@ icarus_tool::HistogramMap ROIFinderMorphological::initializeHistograms(size_t ch if (fOutputWaveforms) { // Try to limit to the wire number (since we are already segregated by plane) - std::vector wids = fGeometry->ChannelToWire(channel); + std::vector wids = fChannelMapAlg->ChannelToWire(channel); size_t cryo = wids[0].Cryostat; size_t tpc = wids[0].TPC; // size_t plane = wids[0].Plane; diff --git a/icaruscode/TPC/SignalProcessing/RecoWire/DeconTools/ROIFinderStandard_tool.cc b/icaruscode/TPC/SignalProcessing/RecoWire/DeconTools/ROIFinderStandard_tool.cc index c89a62a10..8310b22a9 100644 --- a/icaruscode/TPC/SignalProcessing/RecoWire/DeconTools/ROIFinderStandard_tool.cc +++ b/icaruscode/TPC/SignalProcessing/RecoWire/DeconTools/ROIFinderStandard_tool.cc @@ -10,7 +10,7 @@ #include "messagefacility/MessageLogger/MessageLogger.h" #include "cetlib_except/exception.h" #include "lardata/DetectorInfoServices/DetectorPropertiesService.h" -#include "larcore/Geometry/Geometry.h" +#include "larcore/Geometry/WireReadout.h" #include "larcore/CoreUtils/ServiceUtil.h" // lar::providerFrom() #include "icaruscode/TPC/Utilities/SignalShapingICARUSService_service.h" @@ -45,7 +45,7 @@ class ROIFinderStandard : public IROIFinder std::vector fPostROIPad; ///< ROI padding // Services - const geo::GeometryCore* fGeometry = lar::providerFrom(); + const geo::WireReadoutGeom* fChannelMapAlg = &art::ServiceHandle()->Get(); art::ServiceHandle fSignalShaping; }; @@ -98,7 +98,7 @@ void ROIFinderStandard::configure(const fhicl::ParameterSet& pset) void ROIFinderStandard::FindROIs(const Waveform& waveform, size_t channel, size_t cnt, double rmsNoise, CandidateROIVec& roiVec) const { // First up, translate the channel to plane - std::vector wids = fGeometry->ChannelToWire(channel); + std::vector wids = fChannelMapAlg->ChannelToWire(channel); const geo::PlaneID& planeID = wids[0].planeID(); size_t numBins(2 * fNumBinsHalf + 1); diff --git a/icaruscode/TPC/SignalProcessing/RecoWire/ROIConverter_module.cc b/icaruscode/TPC/SignalProcessing/RecoWire/ROIConverter_module.cc index 2c71b59c7..c53c17e8a 100644 --- a/icaruscode/TPC/SignalProcessing/RecoWire/ROIConverter_module.cc +++ b/icaruscode/TPC/SignalProcessing/RecoWire/ROIConverter_module.cc @@ -25,7 +25,7 @@ // LArSoft libraries #include "larcoreobj/SimpleTypesAndConstants/RawTypes.h" // raw::ChannelID_t -#include "larcore/Geometry/Geometry.h" +#include "larcore/Geometry/WireReadout.h" #include "larcore/CoreUtils/ServiceUtil.h" // lar::providerFrom() #include "larcorealg/CoreUtils/zip.h" #include "lardataobj/RecoBase/Wire.h" @@ -53,7 +53,7 @@ class ROIConvert : public art::EDProducer bool fDiagnosticOutput; ///< secret diagnostics flag size_t fEventCount; ///< count of event processed - const geo::GeometryCore* fGeometry = lar::providerFrom(); + const geo::WireReadoutGeom* fChannelMapAlg = &art::ServiceHandle()->Get(); }; // class ROIConvert @@ -126,7 +126,7 @@ void ROIConvert::produce(art::Event& evt) { // Recover the channel and the view raw::ChannelID_t channel = channelROI.Channel(); - geo::View_t view = fGeometry->View(channel); + geo::View_t view = fChannelMapAlg->View(channel); // Create an ROI vector for output recob::Wire::RegionsOfInterest_t ROIVec; diff --git a/icaruscode/TPC/SignalProcessing/RecoWire/ROIFinder_module.cc b/icaruscode/TPC/SignalProcessing/RecoWire/ROIFinder_module.cc index 7413421ab..dfd177725 100644 --- a/icaruscode/TPC/SignalProcessing/RecoWire/ROIFinder_module.cc +++ b/icaruscode/TPC/SignalProcessing/RecoWire/ROIFinder_module.cc @@ -34,8 +34,7 @@ // LArSoft libraries #include "larcoreobj/SimpleTypesAndConstants/RawTypes.h" // raw::ChannelID_t #include "larcorealg/CoreUtils/enumerate.h" -#include "larcore/Geometry/Geometry.h" -#include "larcore/CoreUtils/ServiceUtil.h" // lar::providerFrom() +#include "larcore/Geometry/WireReadout.h" #include "lardataobj/RecoBase/Wire.h" #include "lardataobj/RawData/RawDigit.h" #include "lardata/DetectorInfoServices/DetectorClocksService.h" @@ -168,7 +167,7 @@ class ROIFinder : public art::EDProducer std::map> fROIToolMap; - const geo::GeometryCore* fGeometry = lar::providerFrom(); + const geo::WireReadoutGeom& fChannelMapAlg = art::ServiceHandle()->Get(); }; // class ROIFinder @@ -290,7 +289,7 @@ void ROIFinder::produce(art::Event& evt) { raw::ChannelID_t channel = wire.Channel(); - std::vector wireIDVec = fGeometry->ChannelToWire(channel); + std::vector wireIDVec = fChannelMapAlg.ChannelToWire(channel); if (wireIDVec.empty()) continue; @@ -303,7 +302,7 @@ void ROIFinder::produce(art::Event& evt) // Make sure the array is initialized if (mapItr == planeIDToDataPairMap.end()) { - unsigned int nWires = fGeometry->Nwires(planeID); + unsigned int nWires = fChannelMapAlg.Nwires(planeID); std::pair mapInsert = planeIDToDataPairMap.insert({planeID,PlaneIDToDataPair()}); @@ -344,12 +343,12 @@ void ROIFinder::produce(art::Event& evt) ROIVec.add_range(0, std::move(zeroVec)); - std::vector wireIDVec = fGeometry->ChannelToWire(channelVec[idx]); + std::vector wireIDVec = fChannelMapAlg.ChannelToWire(channelVec[idx]); // Given channel a large number so we know to not save mapInfo.second.first[idx] = 100000 + idx; - tempWireVec.emplace_back(recob::WireCreator(std::move(ROIVec),idx,fGeometry->View(wireIDVec[0].planeID())).move()); + tempWireVec.emplace_back(recob::WireCreator(std::move(ROIVec),idx,fChannelMapAlg.Plane(wireIDVec[0].planeID()).View()).move()); mapInfo.second.second.addWire(idx,tempWireVec.back()); } @@ -427,9 +426,9 @@ void ROIFinder::processPlane(size_t idx, ROIVec.add_range(0, std::move(outputArray[waveIdx])); raw::ChannelID_t channel = channelVec[waveIdx]; - geo::View_t view = fGeometry->View(channel); + geo::View_t view = fChannelMapAlg.View(channel); - std::vector chanIDVec = fGeometry->ChannelToWire(channel); + std::vector chanIDVec = fChannelMapAlg.ChannelToWire(channel); morphedVec.push_back(recob::WireCreator(std::move(ROIVec),channel,view).move()); } @@ -519,7 +518,7 @@ void ROIFinder::processPlane(size_t idx, { raw::ChannelID_t channel = channelVec[waveIdx]; - std::vector wireIDVec = fGeometry->ChannelToWire(channel); + std::vector wireIDVec = fChannelMapAlg.ChannelToWire(channel); if (wireIDVec.size() > 1) { @@ -606,11 +605,11 @@ void ROIFinder::processPlane(size_t idx, tbb::spin_mutex::scoped_lock lock(roifinderSpinMutex); raw::ChannelID_t channel = channelVec[waveIdx]; - geo::View_t view = fGeometry->View(channel); + geo::View_t view = fChannelMapAlg.View(channel); // Since we process logical TPC images we need to watch for duplicating entries // We can do that by checking to see if a channel has already been added... - std::vector wireIDVec = fGeometry->ChannelToWire(channel); + std::vector wireIDVec = fChannelMapAlg.ChannelToWire(channel); if (channelROIVec.size() != wireColVec.size()) throw art::Exception(art::errors::LogicError) << "===> ROI output mismatch, channelROIVec, size: " << channelROIVec.size() << ", wireColVec, size: " << wireColVec.size() << "\n"; diff --git a/icaruscode/TPC/SignalProcessing/RecoWire/ROITools/ROIFromDecoder_tool.cc b/icaruscode/TPC/SignalProcessing/RecoWire/ROITools/ROIFromDecoder_tool.cc index 4baaec362..6b793800d 100644 --- a/icaruscode/TPC/SignalProcessing/RecoWire/ROITools/ROIFromDecoder_tool.cc +++ b/icaruscode/TPC/SignalProcessing/RecoWire/ROITools/ROIFromDecoder_tool.cc @@ -11,7 +11,7 @@ #include "messagefacility/MessageLogger/MessageLogger.h" #include "cetlib_except/exception.h" #include "lardata/DetectorInfoServices/DetectorPropertiesService.h" -#include "larcore/Geometry/Geometry.h" +#include "larcore/Geometry/WireReadout.h" #include "larcore/CoreUtils/ServiceUtil.h" // lar::providerFrom() #include "lardataobj/RecoBase/Wire.h" @@ -45,7 +45,7 @@ class ROIFromDecoder : public IROILocator // fhicl parameters std::vector fROILabelVec; ///< List of input files to search - const geo::GeometryCore* fGeometry = lar::providerFrom(); + const geo::WireReadoutGeom& fChannelMapAlg = art::ServiceHandle()->Get(); }; //---------------------------------------------------------------------- @@ -117,7 +117,7 @@ void ROIFromDecoder::FindROIs(const art::Event& event, const ArrayFloat& inputIm for(const auto& wireData : *wireVecHandle) { - std::vector wireIDVec = fGeometry->ChannelToWire(wireData.Channel()); + std::vector wireIDVec = fChannelMapAlg.ChannelToWire(wireData.Channel()); for(const auto& wireID : wireIDVec) { @@ -145,7 +145,7 @@ void ROIFromDecoder::FindROIs(const art::Event& event, const ArrayFloat& inputIm const recob::Wire& wireData = *(wireItr->second); // Get the WireIDs (again) - std::vector wireIDVec = fGeometry->ChannelToWire(channel); + std::vector wireIDVec = fChannelMapAlg.ChannelToWire(channel); for(const auto& wireID : wireIDVec) { diff --git a/icaruscode/TPC/SignalProcessing/RecoWire/RecoWireICARUSRaw_module.cc b/icaruscode/TPC/SignalProcessing/RecoWire/RecoWireICARUSRaw_module.cc index 3505f437c..b1eaf9b39 100644 --- a/icaruscode/TPC/SignalProcessing/RecoWire/RecoWireICARUSRaw_module.cc +++ b/icaruscode/TPC/SignalProcessing/RecoWire/RecoWireICARUSRaw_module.cc @@ -35,6 +35,7 @@ // LArSoft includes #include "larcoreobj/SimpleTypesAndConstants/RawTypes.h" // raw::ChannelID_t +#include "larcore/Geometry/WireReadout.h" #include "larcore/Geometry/Geometry.h" #include "larcore/CoreUtils/ServiceUtil.h" // lar::providerFrom() #include "larcorealg/Geometry/PlaneGeo.h" @@ -118,8 +119,7 @@ namespace recowireraw{ ////////////////////////////////////////////////////// void RecoWireICARUSRaw::produce(art::Event& evt) { - // get the geometry - art::ServiceHandle geom; + auto const& wireReadoutAlg = art::ServiceHandle()->Get(); // make a collection of Wires std::unique_ptr > wirecol(new std::vector); @@ -160,7 +160,7 @@ namespace recowireraw{ // The following test is meant to be temporary until the "correct" solution is implemented if (!fChannelFilter->IsPresent(channel)) continue; - std::vector wids = geom->ChannelToWire(channel); + std::vector wids = wireReadoutAlg.ChannelToWire(channel); if (wids.empty()) continue; @@ -365,4 +365,3 @@ namespace recowireraw{ #endif // RecoWireICARUSRawH - diff --git a/icaruscode/TPC/SignalProcessing/RecoWire/RecoWireICARUS_module.cc b/icaruscode/TPC/SignalProcessing/RecoWire/RecoWireICARUS_module.cc index 507fb26d2..d8eb0d682 100644 --- a/icaruscode/TPC/SignalProcessing/RecoWire/RecoWireICARUS_module.cc +++ b/icaruscode/TPC/SignalProcessing/RecoWire/RecoWireICARUS_module.cc @@ -31,7 +31,7 @@ // LArSoft includes #include "larcoreobj/SimpleTypesAndConstants/RawTypes.h" // raw::ChannelID_t -#include "larcore/Geometry/Geometry.h" +#include "larcore/Geometry/WireReadout.h" #include "larcorealg/Geometry/PlaneGeo.h" #include "lardataobj/RawData/RawDigit.h" #include "lardataobj/RawData/raw.h" @@ -180,11 +180,6 @@ namespace recowire{ ////////////////////////////////////////////////////// void RecoWireICARUS::produce(art::Event& evt) { - - - // get the geometry - art::ServiceHandle geom; - std::vector decayConsts; std::vector kernMap; std::vector>> kernel; @@ -232,6 +227,9 @@ namespace recowire{ std::vector rawadc(transformSize); // vector holding uncompressed adc values std::vector> freqHolder(transformSize+1); // temporary frequency data wirecol->reserve(digitVecHandle->size()); + + auto const& wireReadoutAlg = art::ServiceHandle()->Get(); + // loop over all wires for(unsigned int rdIter = 0; rdIter < digitVecHandle->size(); ++rdIter){ // ++ move holder.clear(); @@ -249,7 +247,7 @@ namespace recowire{ for(bin = 0; bin < dataSize; ++bin) holder[bin]=(rawadc[bin]-digitVec->GetPedestal()); // fExpEndBins only nonzero for detectors needing exponential tail fitting - geo::SigType_t sigtype = geom->SignalType(channel); + geo::SigType_t sigtype = wireReadoutAlg.SignalType(channel); size_t k; if(sigtype == geo::kInduction) k = 0; @@ -395,4 +393,3 @@ namespace recowire{ #endif // RecoWireICARUS_H - diff --git a/icaruscode/TPC/SignalProcessing/RecoWire/RecoWireROIICARUS_module.cc b/icaruscode/TPC/SignalProcessing/RecoWire/RecoWireROIICARUS_module.cc index 56e2917f2..77cfd659e 100644 --- a/icaruscode/TPC/SignalProcessing/RecoWire/RecoWireROIICARUS_module.cc +++ b/icaruscode/TPC/SignalProcessing/RecoWire/RecoWireROIICARUS_module.cc @@ -37,8 +37,7 @@ // LArSoft libraries #include "larcoreobj/SimpleTypesAndConstants/RawTypes.h" // raw::ChannelID_t -#include "larcore/Geometry/Geometry.h" -#include "larcore/CoreUtils/ServiceUtil.h" // lar::providerFrom() +#include "larcore/Geometry/WireReadout.h" #include "lardataobj/RawData/RawDigit.h" #include "lardataobj/RawData/raw.h" #include "lardataobj/RecoBase/Wire.h" @@ -95,7 +94,7 @@ class RecoWireROIICARUS : public art::EDProducer icarus_signal_processing::WaveformTools fWaveformTool; - const geo::GeometryCore* fGeometry = lar::providerFrom(); + const geo::WireReadoutGeom& fChannelMapAlg = art::ServiceHandle()->Get(); // Define here a temporary set of histograms... std::vector fPedestalOffsetVec; @@ -185,8 +184,8 @@ void RecoWireROIICARUS::reconfigure(fhicl::ParameterSet const& pset) fFullRMSVec[planeIdx] = tfs->make( Form("RMSFPlane_%02zu",planeIdx), "Full RMS;RMS (ADC);", 100, 0., 10.); fTruncRMSVec[planeIdx] = tfs->make( Form("RMSTPlane_%02zu",planeIdx), "Truncated RMS;RMS (ADC);", 100, 0., 10.); fNumTruncBinsVec[planeIdx] = tfs->make( Form("NTruncBins_%02zu",planeIdx), ";# bins", 640, 0., 6400.); - fPedByChanVec[planeIdx] = tfs->make(Form("PedByWirePlane_%02zu",planeIdx), ";Wire#", fGeometry->Nwires(planeID), 0., fGeometry->Nwires(planeID), -5., 5.); - fTruncRMSByChanVec[planeIdx] = tfs->make(Form("TruncRMSByWirePlane_%02zu",planeIdx), ";Wire#", fGeometry->Nwires(planeID), 0., fGeometry->Nwires(planeID), 0., 10.); + fPedByChanVec[planeIdx] = tfs->make(Form("PedByWirePlane_%02zu",planeIdx), ";Wire#", fChannelMapAlg.Nwires(planeID), 0., fChannelMapAlg.Nwires(planeID), -5., 5.); + fTruncRMSByChanVec[planeIdx] = tfs->make(Form("TruncRMSByWirePlane_%02zu",planeIdx), ";Wire#", fChannelMapAlg.Nwires(planeID), 0., fChannelMapAlg.Nwires(planeID), 0., 10.); fNumROIsHistVec[planeIdx] = tfs->make( Form("NROISplane_%02zu",planeIdx), ";# ROIs;", 100, 0, 100); fROILenHistVec[planeIdx] = tfs->make( Form("ROISIZEplane_%02zu",planeIdx), ";ROI size;", 500, 0, 500); } @@ -261,7 +260,7 @@ void RecoWireROIICARUS::produce(art::Event& evt) size_t dataSize = digitVec->Samples(); // Recover the plane info - std::vector wids = fGeometry->ChannelToWire(channel); + std::vector wids = fChannelMapAlg.ChannelToWire(channel); const geo::PlaneID& planeID = wids[0].planeID(); // vector holding uncompressed adc values @@ -302,7 +301,7 @@ void RecoWireROIICARUS::produce(art::Event& evt) if (fOutputHistograms) { // First up, determine what kind of wire we have - std::vector wids = fGeometry->ChannelToWire(channel); + std::vector wids = fChannelMapAlg.ChannelToWire(channel); const geo::PlaneID& planeID = wids[0].planeID(); fNumROIsHistVec.at(planeID.Plane)->Fill(candRoiVec.size(), 1.); @@ -390,7 +389,7 @@ float RecoWireROIICARUS::fixTheFreakingWaveform(const std::vector& wavefo // Fill histograms if (fOutputHistograms) { - std::vector wids = fGeometry->ChannelToWire(channel); + std::vector wids = fChannelMapAlg.ChannelToWire(channel); // Recover plane and wire in the plane size_t plane = wids[0].Plane; diff --git a/icaruscode/TPC/SignalProcessing/RecoWire/RecoWireROI_module.cc b/icaruscode/TPC/SignalProcessing/RecoWire/RecoWireROI_module.cc index 631896cce..c7c5670a7 100644 --- a/icaruscode/TPC/SignalProcessing/RecoWire/RecoWireROI_module.cc +++ b/icaruscode/TPC/SignalProcessing/RecoWire/RecoWireROI_module.cc @@ -36,7 +36,7 @@ // LArSoft libraries #include "larcoreobj/SimpleTypesAndConstants/RawTypes.h" // raw::ChannelID_t -#include "larcore/Geometry/Geometry.h" +#include "larcore/Geometry/WireReadout.h" #include "larcore/CoreUtils/ServiceUtil.h" // lar::providerFrom() #include "lardataobj/RawData/RawDigit.h" #include "lardataobj/RawData/raw.h" @@ -111,7 +111,7 @@ class RecoWireROI : public art::EDProducer float SubtractBaseline(const std::vector& holder); - const geo::GeometryCore& fGeometry; + const geo::WireReadoutGeom& fChannelMapAlg; icarusutil::SignalShapingICARUSService& fSignalServices; const lariov::ChannelStatusProvider& fChanFilt; std::unique_ptr> fFFT; ///< Object to handle thread safe FFT @@ -121,7 +121,7 @@ DEFINE_ART_MODULE(RecoWireROI) //------------------------------------------------- RecoWireROI::RecoWireROI(fhicl::ParameterSet const& pset) : EDProducer{pset}, - fGeometry(*lar::providerFrom()), + fChannelMapAlg(art::ServiceHandle()->Get()), fSignalServices(*art::ServiceHandle()), fChanFilt(art::ServiceHandle()->GetProvider()) { @@ -290,7 +290,7 @@ void RecoWireROI::produce(art::Event& evt) // vector holding uncompressed adc values std::vector rawadc(dataSize); - std::vector wids = fGeometry.ChannelToWire(channel); + std::vector wids = fChannelMapAlg.ChannelToWire(channel); size_t thePlane = wids[0].Plane; // Set up the deconvolution and the vector to deconvolve diff --git a/icaruscode/TPC/SignalProcessing/RecoWire/SimTestPulse/SimTestPulseAna_module.cc b/icaruscode/TPC/SignalProcessing/RecoWire/SimTestPulse/SimTestPulseAna_module.cc index ac2e32414..72cc6e916 100644 --- a/icaruscode/TPC/SignalProcessing/RecoWire/SimTestPulse/SimTestPulseAna_module.cc +++ b/icaruscode/TPC/SignalProcessing/RecoWire/SimTestPulse/SimTestPulseAna_module.cc @@ -16,8 +16,8 @@ #include "art_root_io/TFileService.h" #include "fhiclcpp/ParameterSet.h" #include "messagefacility/MessageLogger/MessageLogger.h" -#include "larcore/Geometry/Geometry.h" -#include "larcorealg/Geometry/GeometryCore.h" +#include "larcore/Geometry/WireReadout.h" +#include "larcorealg/Geometry/WireReadoutGeom.h" #include "lardataobj/RawData/RawDigit.h" #include "lardataobj/RecoBase/Wire.h" #include "lardataobj/RecoBase/Hit.h" @@ -193,7 +193,7 @@ void SimTestPulseAna::endJob() void SimTestPulseAna::analyze(art::Event const & e) { - art::ServiceHandle geo; + geo::WireReadoutGeom const& wireReadoutAlg = art::ServiceHandle()->Get(); _run = e.id().run(); _subrun = e.id().subRun(); _event = e.id().event(); @@ -222,7 +222,7 @@ void SimTestPulseAna::analyze(art::Event const & e) for(auto const& ch : hit.channel_list) { _ch = ch; - auto const wid = geo->ChannelToWire(ch).front(); + auto const wid = wireReadoutAlg.ChannelToWire(ch).front(); _wire = (int)(wid.Wire); _plane = wid.Plane; bool found=false; @@ -272,7 +272,7 @@ void SimTestPulseAna::analyze(art::Event const & e) for(auto const& ch : hit.channel_list) { _ch = ch; - auto const wid = geo->ChannelToWire(ch).front(); + auto const wid = wireReadoutAlg.ChannelToWire(ch).front(); _wire = wid.Wire; _plane = wid.Plane; bool found=false; @@ -323,7 +323,7 @@ void SimTestPulseAna::analyze(art::Event const & e) for(auto const& ch : hit.channel_list) { _ch = ch; - auto const wid = geo->ChannelToWire(ch).front(); + auto const wid = wireReadoutAlg.ChannelToWire(ch).front(); _wire = wid.Wire; _plane = wid.Plane; bool found=false; @@ -381,7 +381,7 @@ void SimTestPulseAna::analyze(art::Event const & e) for(auto const& ch : hit.channel_list) { _ch = ch; - auto const wid = geo->ChannelToWire(ch).front(); + auto const wid = wireReadoutAlg.ChannelToWire(ch).front(); _wire = wid.Wire; _plane = wid.Plane; bool found=false; diff --git a/icaruscode/TPC/SignalProcessing/RecoWire/SimTestPulse/SimTestPulseWire_module.cc b/icaruscode/TPC/SignalProcessing/RecoWire/SimTestPulse/SimTestPulseWire_module.cc index af1e98c3d..89183f178 100644 --- a/icaruscode/TPC/SignalProcessing/RecoWire/SimTestPulse/SimTestPulseWire_module.cc +++ b/icaruscode/TPC/SignalProcessing/RecoWire/SimTestPulse/SimTestPulseWire_module.cc @@ -26,6 +26,7 @@ #include "lardataobj/Simulation/SimChannel.h" #include "lardataobj/RawData/TriggerData.h" +#include "larcore/Geometry/WireReadout.h" #include "larcore/Geometry/Geometry.h" #include "larcorealg/Geometry/GeometryCore.h" @@ -177,8 +178,6 @@ void SimTestPulseWire::produce(art::Event & e) geo::Point_t chargeDepCoords = {0., 0., 0.}; auto const clockData = art::ServiceHandle()->DataFor(e); - art::ServiceHandle geo; - auto const detProp = art::ServiceHandle()->DataForJob(clockData); for(size_t idx = 0; idx < fPlaneChannelVec.size(); idx++) @@ -192,6 +191,12 @@ void SimTestPulseWire::produce(art::Event & e) auto& pholder = alternative::ParamHolder::get(); pholder.Clear(); + geo::WireReadoutGeom const& wireReadoutAlg = art::ServiceHandle()->Get(); + const geo::PlaneGeo& planeGeo = wireReadoutAlg.Plane(geo::PlaneID(fCryostat,fTPC,0)); // Get the coordinates of the first wire plane + + auto planeCoords = planeGeo.GetCenter(); + auto planeNormal = planeGeo.GetNormalDirection(); + for(size_t index=0; index < fSimTime_v.size(); ++index) { int tdc = fSimTime_v[index] / clockData.TPCClock().TickPeriod(); @@ -208,11 +213,6 @@ void SimTestPulseWire::produce(art::Event & e) continue; } - const geo::PlaneGeo& planeGeo = geo->Plane(geo::PlaneID(fCryostat,fTPC,0)); // Get the coordinates of the first wire plane - - auto planeCoords = planeGeo.GetCenter(); - auto planeNormal = planeGeo.GetNormalDirection(); - // Assume C=0, T=1 chargeDepCoords = planeCoords; chargeDepCoords.SetX(planeCoords.X() + planeNormal.X()); @@ -234,18 +234,18 @@ void SimTestPulseWire::produce(art::Event & e) geo::WireID wireID(fCryostat,fTPC,plane,wire); - raw::ChannelID_t channel = geo->PlaneWireToChannel(wireID); + raw::ChannelID_t channel = wireReadoutAlg.PlaneWireToChannel(wireID); fPlaneChannelVec[plane].emplace_back(channel); // Let's go backwards... - std::vector wireIDVec = geo->ChannelToWire(channel); + std::vector wireIDVec = wireReadoutAlg.ChannelToWire(channel); std::cout << ">>Channel " << channel << ", C/T/P/W: " << wireID.Cryostat << "/" << wireID.TPC << "/" << wireID.Plane << "/" << wireID.Wire << " returns " << wireIDVec.size() << " IDs, C/T/P/W: " << wireIDVec.front().Cryostat << "/" << wireIDVec.front().TPC << "/" << wireIDVec.front().Plane << "/" << wireIDVec.front().Wire << std::endl; // Recover the positions - const geo::WireGeo& wireGeo = geo->Wire(wireID); + const geo::WireGeo& wireGeo = wireReadoutAlg.Wire(wireID); auto xyz = wireGeo.GetCenter(); xyz.SetX(chargeDepCoords.X()); diff --git a/icaruscode/TPC/SignalProcessing/RecoWire/SimTestPulse/SimTestPulse_module.cc b/icaruscode/TPC/SignalProcessing/RecoWire/SimTestPulse/SimTestPulse_module.cc index 7a396f0d6..aa55eb073 100644 --- a/icaruscode/TPC/SignalProcessing/RecoWire/SimTestPulse/SimTestPulse_module.cc +++ b/icaruscode/TPC/SignalProcessing/RecoWire/SimTestPulse/SimTestPulse_module.cc @@ -26,6 +26,7 @@ #include "lardataobj/Simulation/SimChannel.h" #include "lardataobj/Simulation/SimEnergyDeposit.h" #include "lardataobj/RawData/TriggerData.h" +#include "larcore/Geometry/WireReadout.h" #include "larcore/Geometry/Geometry.h" #include "larcorealg/Geometry/GeometryCore.h" @@ -164,8 +165,6 @@ void SimTestPulse::produce(art::Event & e) geo::Point_t chargeDepCoords = {0., 0., 0.}; auto const clockData = art::ServiceHandle()->DataFor(e); - art::ServiceHandle geo; - auto const detProp = art::ServiceHandle()->DataForJob(clockData); fPlane0Channel_v.clear(); @@ -179,6 +178,12 @@ void SimTestPulse::produce(art::Event & e) auto& pholder = alternative::ParamHolder::get(); pholder.Clear(); + geo::WireReadoutGeom const& wireReadoutAlg = art::ServiceHandle()->Get(); + const geo::PlaneGeo& planeGeo = wireReadoutAlg.Plane(geo::PlaneID(0,0,0)); // Get the coordinates of the first wire plane + + auto planeCoords = planeGeo.GetCenter(); + auto planeNormal = planeGeo.GetNormalDirection(); + for(size_t index=0; index < fSimTime_v.size(); ++index) { int tdc = fSimTime_v[index] / clockData.TPCClock().TickPeriod(); @@ -195,11 +200,6 @@ void SimTestPulse::produce(art::Event & e) continue; } - const geo::PlaneGeo& planeGeo = geo->Plane(geo::PlaneID(0,0,0)); // Get the coordinates of the first wire plane - - auto planeCoords = planeGeo.GetCenter(); - auto planeNormal = planeGeo.GetNormalDirection(); - // Assume C=0, T=1 chargeDepCoords = geo::Point_t(planeCoords.X() + planeNormal.X(),fY_v[index],fZ_v[index]); @@ -226,12 +226,12 @@ void SimTestPulse::produce(art::Event & e) for(size_t plane=0; plane<3; ++plane) { geo::PlaneID planeID(0,0,plane); std::cout << "++ Searching for nearest wire id for planeID: " << planeID << ", xyz: " << chargeDepCoords.X() << "," << chargeDepCoords.Y() << "," << chargeDepCoords.Z() << std::endl; - geo::WireID nearestID = geo->NearestWireID(chargeDepCoords,planeID); + geo::WireID nearestID = wireReadoutAlg.NearestWireID(chargeDepCoords,planeID); std::cout << " WireID: " << nearestID << std::endl; std::cout << "** Searching for nearest channel with plane: " << plane << ", xyz: " << chargeDepCoords.X() << "," << chargeDepCoords.Y() << "," << chargeDepCoords.Z() << std::endl; - auto channel = geo->NearestChannel(chargeDepCoords,planeID); + auto channel = wireReadoutAlg.NearestChannel(chargeDepCoords,planeID); std::cout << " Returned with channel: " << channel << std::endl; - auto wire = geo->ChannelToWire(channel).front().Wire; + auto wire = wireReadoutAlg.ChannelToWire(channel).front().Wire; std::cout << " which gives wire: " << wire << std::endl; if(fVerbose) std::cout << "[BUFFOON!] plane " << plane << " channel " << channel << " ... wire " << wire << std::endl; diff --git a/icaruscode/TPC/SignalProcessing/RecoWire/WaveformIntegrity_module.cc b/icaruscode/TPC/SignalProcessing/RecoWire/WaveformIntegrity_module.cc index d48971769..b06e28e6e 100644 --- a/icaruscode/TPC/SignalProcessing/RecoWire/WaveformIntegrity_module.cc +++ b/icaruscode/TPC/SignalProcessing/RecoWire/WaveformIntegrity_module.cc @@ -35,7 +35,7 @@ // LArSoft libraries #include "larcoreobj/SimpleTypesAndConstants/RawTypes.h" // raw::ChannelID_t -#include "larcore/Geometry/Geometry.h" +#include "larcore/Geometry/WireReadout.h" #include "larcore/CoreUtils/ServiceUtil.h" // lar::providerFrom() #include "lardataobj/RawData/RawDigit.h" #include "lardataobj/RawData/raw.h" @@ -87,7 +87,7 @@ class WaveformIntegrity : public art::ReplicatedProducer icarus_signal_processing::WaveformTools fWaveformTool; - const geo::GeometryCore* fGeometry = lar::providerFrom(); + const geo::WireReadoutGeom* fChannelMapAlg = &art::ServiceHandle()->Get(); const lariov::ChannelStatusProvider* fChannelFilter = lar::providerFrom(); const lariov::DetPedestalProvider* fPedRetrievalAlg = lar::providerFrom(); @@ -180,7 +180,7 @@ void WaveformIntegrity::produce(art::Event& evt, art::ProcessingFrame const& fra short maxDiff = *std::max_element(diffVec.begin(),diffVec.end()); short minDiff = *std::min_element(diffVec.begin(),diffVec.end()); - std::vector wireIDVec = fGeometry->ChannelToWire(newChannel); + std::vector wireIDVec = fChannelMapAlg->ChannelToWire(newChannel); std::cout << "==> Channel: " << newChannel << " - " << wireIDVec[0] << " - has " << diffVec.size() << " max/min: " << maxDiff << "/" << minDiff << std::endl; // for(size_t idx = 0; diffVec.size(); idx++) std::cout << idxVec[idx] << "/" << diffVec[idx] << " "; diff --git a/icaruscode/TPC/Simulation/DetSim/SimReadoutBoardICARUS_module.cc b/icaruscode/TPC/Simulation/DetSim/SimReadoutBoardICARUS_module.cc index cad483392..339e08d3f 100644 --- a/icaruscode/TPC/Simulation/DetSim/SimReadoutBoardICARUS_module.cc +++ b/icaruscode/TPC/Simulation/DetSim/SimReadoutBoardICARUS_module.cc @@ -48,8 +48,7 @@ #include "lardataobj/RawData/raw.h" #include "lardataobj/RawData/TriggerData.h" #include "lardataobj/Simulation/SimChannel.h" -#include "larcore/Geometry/Geometry.h" -#include "larcorealg/Geometry/GeometryCore.h" +#include "larcore/Geometry/WireReadout.h" #include "lardata/Utilities/LArFFT.h" #include "lardata/DetectorInfoServices/DetectorPropertiesService.h" #include "lardata/DetectorInfoServices/DetectorClocksService.h" @@ -138,7 +137,7 @@ class SimReadoutBoardICARUS : public art::EDProducer FFTPointer fFFT; //< Object to handle thread safe FFT //services - const geo::GeometryCore& fGeometry; + const geo::WireReadoutGeom& fChannelMapAlg; icarusutil::SignalShapingICARUSService* fSignalShapingService; //< Access to the response functions const icarusDB::IICARUSChannelMap* fChannelMap; @@ -151,7 +150,7 @@ SimReadoutBoardICARUS::SimReadoutBoardICARUS(fhicl::ParameterSet const& pset) , fPedestalEngine(art::ServiceHandle()->registerAndSeedEngine(createEngine(0, "HepJamesRandom", "pedestal"), "HepJamesRandom", "pedestal", pset, "SeedPedestal")) , fUncNoiseEngine(art::ServiceHandle()->registerAndSeedEngine(createEngine(0, "HepJamesRandom", "noise" ), "HepJamesRandom", "noise", pset, "Seed")) , fCorNoiseEngine(art::ServiceHandle()->registerAndSeedEngine(createEngine(0, "HepJamesRandom", "cornoise"), "HepJamesRandom", "cornoise", pset, "Seed")) - , fGeometry(*lar::providerFrom()) + , fChannelMapAlg{art::ServiceHandle{}->Get()} , fChannelMap(art::ServiceHandle{}.get()) { this->reconfigure(pset); @@ -220,11 +219,11 @@ void SimReadoutBoardICARUS::beginJob() // If in test mode create a test data set if(fTest) { - if(fGeometry.Nchannels()<=fTestWire) + if(fChannelMapAlg.Nchannels()<=fTestWire) throw cet::exception(__FUNCTION__)<<"Invalid test wire channel: "< channels; - for(auto const& plane_id : fGeometry.Iterate()) - channels.push_back(fGeometry.PlaneWireToChannel(geo::WireID(plane_id,fTestWire))); + for(auto const& plane_id : fChannelMapAlg.Iterate()) + channels.push_back(fChannelMapAlg.PlaneWireToChannel(geo::WireID(plane_id,fTestWire))); double xyz[3] = { std::numeric_limits::max() }; for(auto const& ch : channels) { @@ -265,7 +264,7 @@ void SimReadoutBoardICARUS::produce(art::Event& evt) auto const clockData = art::ServiceHandle()->DataFor(evt); // get the geometry to be able to figure out signal types and chan -> plane mappings - const raw::ChannelID_t maxChannel = fGeometry.Nchannels(); + const raw::ChannelID_t maxChannel = fChannelMapAlg.Nchannels(); //-------------------------------------------------------------------- // @@ -332,7 +331,7 @@ void SimReadoutBoardICARUS::produce(art::Event& evt) for(const auto& channelPair : boardPair.second.second) { - wireIDVec = fGeometry.ChannelToWire(channelPair.first); + wireIDVec = fChannelMapAlg.ChannelToWire(channelPair.first); if (wireIDVec.size() > 0) break; } @@ -405,7 +404,7 @@ void SimReadoutBoardICARUS::produce(art::Event& evt) } // Check where this wire is located - std::vector widVec = fGeometry.ChannelToWire(channel); + std::vector widVec = fChannelMapAlg.ChannelToWire(channel); // For now skip the channels with no info // if (widVec.empty()) continue; @@ -476,7 +475,7 @@ void SimReadoutBoardICARUS::produce(art::Event& evt) if(area>0) { - std::vector widVec = fGeometry.ChannelToWire(channel); + std::vector widVec = fChannelMapAlg.ChannelToWire(channel); fSimCharge->Fill(area); fSimChargeWire->Fill(widVec[0].Wire,area); diff --git a/icaruscode/TPC/Simulation/DetSim/SimWireICARUS_module.cc b/icaruscode/TPC/Simulation/DetSim/SimWireICARUS_module.cc index 006e98817..51fca84ff 100644 --- a/icaruscode/TPC/Simulation/DetSim/SimWireICARUS_module.cc +++ b/icaruscode/TPC/Simulation/DetSim/SimWireICARUS_module.cc @@ -48,8 +48,7 @@ #include "lardataobj/RawData/raw.h" #include "lardataobj/RawData/TriggerData.h" #include "lardataobj/Simulation/SimChannel.h" -#include "larcore/Geometry/Geometry.h" -#include "larcorealg/Geometry/GeometryCore.h" +#include "larcore/Geometry/WireReadout.h" #include "lardata/Utilities/LArFFT.h" #include "lardata/DetectorInfoServices/DetectorPropertiesService.h" #include "lardata/DetectorInfoServices/DetectorClocksService.h" @@ -137,7 +136,7 @@ class SimWireICARUS : public art::EDProducer FFTPointer fFFT; //< Object to handle thread safe FFT //services - const geo::GeometryCore& fGeometry; + const geo::WireReadoutGeom& fChannelMapAlg; icarusutil::SignalShapingICARUSService* fSignalShapingService; //< Access to the response functions }; // class SimWireICARUS @@ -149,7 +148,7 @@ SimWireICARUS::SimWireICARUS(fhicl::ParameterSet const& pset) , fPedestalEngine(art::ServiceHandle()->registerAndSeedEngine(createEngine(0, "HepJamesRandom", "pedestal"), "HepJamesRandom", "pedestal", pset, "SeedPedestal")) , fUncNoiseEngine(art::ServiceHandle()->registerAndSeedEngine(createEngine(0, "HepJamesRandom", "noise" ), "HepJamesRandom", "noise", pset, "Seed")) , fCorNoiseEngine(art::ServiceHandle()->registerAndSeedEngine(createEngine(0, "HepJamesRandom", "cornoise"), "HepJamesRandom", "cornoise", pset, "Seed")) - , fGeometry(*lar::providerFrom()) + , fChannelMapAlg{art::ServiceHandle{}->Get()} { this->reconfigure(pset); @@ -220,11 +219,11 @@ void SimWireICARUS::beginJob() // If in test mode create a test data set if(fTest) { - if(fGeometry.Nchannels()<=fTestWire) + if(fChannelMapAlg.Nchannels()<=fTestWire) throw cet::exception(__FUNCTION__)<<"Invalid test wire channel: "< channels; - for(auto const& plane_id : fGeometry.Iterate()) - channels.push_back(fGeometry.PlaneWireToChannel(geo::WireID(plane_id,fTestWire))); + for(auto const& plane_id : fChannelMapAlg.Iterate()) + channels.push_back(fChannelMapAlg.PlaneWireToChannel(geo::WireID(plane_id,fTestWire))); double xyz[3] = { std::numeric_limits::max() }; for(auto const& ch : channels) { @@ -265,7 +264,7 @@ void SimWireICARUS::produce(art::Event& evt) auto const clockData = art::ServiceHandle()->DataFor(evt); // get the geometry to be able to figure out signal types and chan -> plane mappings - const raw::ChannelID_t maxChannel = fGeometry.Nchannels(); + const raw::ChannelID_t maxChannel = fChannelMapAlg.Nchannels(); //-------------------------------------------------------------------- // @@ -327,10 +326,10 @@ void SimWireICARUS::produce(art::Event& evt) for (geo::TPCID const& tpcid : fTPCVec) { - for (geo::PlaneGeo const& plane : fGeometry.Iterate(tpcid)) + for (geo::PlaneGeo const& plane : fChannelMapAlg.Iterate(tpcid)) { - raw::ChannelID_t const planeStartChannel = fGeometry.PlaneWireToChannel({ plane.ID(), 0U }); - raw::ChannelID_t const planeEndChannel = fGeometry.PlaneWireToChannel({ plane.ID(), plane.Nwires() - 1U }) + 1; + raw::ChannelID_t const planeStartChannel = fChannelMapAlg.PlaneWireToChannel({ plane.ID(), 0U }); + raw::ChannelID_t const planeEndChannel = fChannelMapAlg.PlaneWireToChannel({ plane.ID(), plane.Nwires() - 1U }) + 1; channelPairVec.emplace_back(planeStartChannel, planeEndChannel); } // for planes in TPC @@ -378,7 +377,7 @@ void SimWireICARUS::produce(art::Event& evt) noisetmp.resize(fNTimeSamples, 0.); //just in case //use channel number to set some useful numbers - std::vector widVec = fGeometry.ChannelToWire(channel); + std::vector widVec = fChannelMapAlg.ChannelToWire(channel); size_t plane = widVec[0].Plane; size_t wire = widVec[0].Wire; size_t board = wire / 32; diff --git a/icaruscode/TPC/Simulation/Overlay/OverlayICARUS_module.cc b/icaruscode/TPC/Simulation/Overlay/OverlayICARUS_module.cc index 550e567bb..d375ba4ac 100644 --- a/icaruscode/TPC/Simulation/Overlay/OverlayICARUS_module.cc +++ b/icaruscode/TPC/Simulation/Overlay/OverlayICARUS_module.cc @@ -49,7 +49,7 @@ #include "lardataobj/RawData/raw.h" #include "lardataobj/RawData/TriggerData.h" #include "lardataobj/Simulation/SimChannel.h" -#include "larcore/Geometry/Geometry.h" +#include "larcore/Geometry/WireReadout.h" #include "larcorealg/Geometry/GeometryCore.h" #include "lardata/Utilities/LArFFT.h" #include "lardata/DetectorInfoServices/DetectorPropertiesService.h" @@ -113,7 +113,7 @@ class OverlayICARUS : public art::EDProducer FFTPointer fFFT; //< Object to handle thread safe FFT //services - const geo::GeometryCore& fGeometry; + const geo::WireReadoutGeom& fChannelMapAlg; icarusutil::SignalShapingICARUSService* fSignalShapingService; ///< Access to the response functions const lariov::DetPedestalProvider& fPedestalRetrievalAlg; ///< Keep track of an instance to the pedestal retrieval alg @@ -123,8 +123,8 @@ DEFINE_ART_MODULE(OverlayICARUS) //------------------------------------------------- OverlayICARUS::OverlayICARUS(fhicl::ParameterSet const& pset) : EDProducer{pset} - , fGeometry(*lar::providerFrom()), - fPedestalRetrievalAlg(*lar::providerFrom()) + , fChannelMapAlg{art::ServiceHandle()->Get()} + , fPedestalRetrievalAlg(*lar::providerFrom()) { this->reconfigure(pset); @@ -218,7 +218,7 @@ void OverlayICARUS::produce(art::Event& evt) raw::ChannelID_t channel = rawDigit.Channel(); //use channel number to set some useful numbers - std::vector widVec = fGeometry.ChannelToWire(channel); + std::vector widVec = fChannelMapAlg.ChannelToWire(channel); // We skip channels that are not connected to a physical wire if (!widVec.empty()) diff --git a/icaruscode/TPC/Tracking/cluster3D/Cluster3DICARUS_module.cc b/icaruscode/TPC/Tracking/cluster3D/Cluster3DICARUS_module.cc index 2380abf5a..59d2c95ac 100644 --- a/icaruscode/TPC/Tracking/cluster3D/Cluster3DICARUS_module.cc +++ b/icaruscode/TPC/Tracking/cluster3D/Cluster3DICARUS_module.cc @@ -55,6 +55,7 @@ // LArSoft includes #include "larcore/CoreUtils/ServiceUtil.h" #include "larcore/Geometry/Geometry.h" +#include "larcore/Geometry/WireReadout.h" #include "lardata/DetectorInfoServices/DetectorClocksService.h" #include "lardata/DetectorInfoServices/DetectorPropertiesService.h" #include "lardata/Utilities/AssociationUtil.h" @@ -666,7 +667,10 @@ namespace lar_cluster3d { // This goes here to insure that something is always written to the data store auto const clockData = art::ServiceHandle()->DataFor(evt); auto const detProp = art::ServiceHandle()->DataFor(evt, clockData); - util::GeometryUtilities const gser{*lar::providerFrom(), clockData, detProp}; + util::GeometryUtilities const gser{*lar::providerFrom(), + art::ServiceHandle()->Get(), + clockData, + detProp}; ProduceArtClusters(gser, output, *hitPairList, clusterParametersList, clusterHitToArtPtrMap); diff --git a/icaruscode/TPC/Tracking/cluster3D/SnippetHit3DBuilderICARUS_tool.cc b/icaruscode/TPC/Tracking/cluster3D/SnippetHit3DBuilderICARUS_tool.cc index edeec52ed..e58cc8e25 100644 --- a/icaruscode/TPC/Tracking/cluster3D/SnippetHit3DBuilderICARUS_tool.cc +++ b/icaruscode/TPC/Tracking/cluster3D/SnippetHit3DBuilderICARUS_tool.cc @@ -23,6 +23,7 @@ #include "messagefacility/MessageLogger/MessageLogger.h" // LArSoft includes +#include "larcore/Geometry/WireReadout.h" #include "larcore/Geometry/Geometry.h" #include "lardata/ArtDataHelper/HitCreator.h" #include "lardata/DetectorInfoServices/DetectorClocksService.h" @@ -94,7 +95,7 @@ class SnippetHit3DBuilderICARUS : virtual public IHit3DBuilder */ virtual void produces(art::ProducesCollector&) override; - virtual void configure(const fhicl::ParameterSet&) override; + void configure(const fhicl::ParameterSet&); /** * @brief Given a set of recob hits, run DBscan to form 3D clusters @@ -258,18 +259,18 @@ class SnippetHit3DBuilderICARUS : virtual public IHit3DBuilder bool m_useT0Offsets; ///< If true then we will use the LArSoft interplane offsets bool m_outputHistograms; ///< Take the time to create and fill some histograms for diagnostics bool m_makeAssociations; ///< Do we make wire/rawdigit associations to space points? - + bool m_enableMonitoring; ///< float m_wirePitch[3]; mutable std::vector m_timeVector; ///< - + float m_zPosOffset; - + using PlaneToT0OffsetMap = std::map; PlaneToT0OffsetMap m_PlaneToT0OffsetMap; - - // Define some basic histograms + + // Define some basic histograms TTree* m_tupleTree; ///< output analysis tree mutable std::vector m_deltaPeakTimePlane0Vec; @@ -302,7 +303,7 @@ class SnippetHit3DBuilderICARUS : virtual public IHit3DBuilder mutable std::vector m_2hit2ndPHVec; mutable std::vector m_2hitDeltaPHVec; mutable std::vector m_2hitSumPHVec; - + // Get instances of the primary data structures needed mutable Hit2DList m_clusterHit2DMasterList; mutable PlaneToSnippetHitMap m_planeToSnippetHitMap; @@ -311,6 +312,7 @@ class SnippetHit3DBuilderICARUS : virtual public IHit3DBuilder mutable bool m_weHaveAllBeenHereBefore = false; const geo::Geometry* m_geometry; //< pointer to the Geometry service + const geo::WireReadoutGeom* m_wireReadoutAlg; const lariov::ChannelStatusProvider* m_channelFilter; }; @@ -355,12 +357,13 @@ void SnippetHit3DBuilderICARUS::configure(fhicl::ParameterSet const &pset) m_makeAssociations = pset.get("MakeAssociations", false); m_geometry = art::ServiceHandle{}.get(); + m_wireReadoutAlg = &art::ServiceHandle{}->Get(); // Returns the wire pitch per plane assuming they will be the same for all TPCs constexpr geo::TPCID tpcid{0, 0}; - m_wirePitch[0] = m_geometry->WirePitch(geo::PlaneID{tpcid, 0}); - m_wirePitch[1] = m_geometry->WirePitch(geo::PlaneID{tpcid, 1}); - m_wirePitch[2] = m_geometry->WirePitch(geo::PlaneID{tpcid, 2}); + m_wirePitch[0] = m_wireReadoutAlg->Plane(geo::PlaneID{tpcid, 0}).WirePitch(); + m_wirePitch[1] = m_wireReadoutAlg->Plane(geo::PlaneID{tpcid, 1}).WirePitch(); + m_wirePitch[2] = m_wireReadoutAlg->Plane(geo::PlaneID{tpcid, 2}).WirePitch(); // Access ART's TFileService, which will handle creating and writing // histograms and n-tuples for us. @@ -470,10 +473,10 @@ void SnippetHit3DBuilderICARUS::Hit3DBuilder(art::Event& evt, reco::HitPairList& m_planeToSnippetHitMap.clear(); m_planeToWireToHitSetMap.clear(); - // Do the one time initialization of the tick offsets. + // Do the one time initialization of the tick offsets. if (m_PlaneToT0OffsetMap.empty()) { - // Need the detector properties which needs the clocks + // Need the detector properties which needs the clocks auto const clock_data = art::ServiceHandle()->DataFor(evt); auto const det_prop = art::ServiceHandle()->DataFor(evt, clock_data); @@ -482,7 +485,7 @@ void SnippetHit3DBuilderICARUS::Hit3DBuilder(art::Event& evt, reco::HitPairList& { for(size_t tpcIdx = 0; tpcIdx < m_geometry->NTPC(); tpcIdx++) { - for(size_t planeIdx = 0; planeIdx < m_geometry->Nplanes(); planeIdx++) + for(size_t planeIdx = 0; planeIdx < m_wireReadoutAlg->Nplanes(); planeIdx++) { geo::PlaneID planeID(cryoIdx,tpcIdx,planeIdx); @@ -490,7 +493,7 @@ void SnippetHit3DBuilderICARUS::Hit3DBuilder(art::Event& evt, reco::HitPairList& else m_PlaneToT0OffsetMap[planeID] = 0.; } } - } + } } m_timeVector.resize(NUMTIMEVALUES, 0.); @@ -1005,7 +1008,7 @@ bool SnippetHit3DBuilderICARUS::makeHitPair(reco::ClusterHit3D& hitPair, if (m_outputHistograms) { - // brute force... sigh... + // brute force... sigh... int plane1 = hit1->WireID().Plane; int plane2 = hit2->WireID().Plane; int planeIdx = (plane1 + plane2) - 1; // should be 0 for 0-1, 1 for 0-2 and 2 for 1-2 @@ -1298,7 +1301,7 @@ bool SnippetHit3DBuilderICARUS::makeHitTriplet(reco::ClusterHit3D& hitTrip if (std::abs(deltaPeakTime) > maxDeltaPeak) maxDeltaPeak = std::abs(deltaPeakTime); - if (m_outputHistograms) + if (m_outputHistograms) { int deltaTimeIdx = (hitVector[leftIdx]->WireID().Plane + hitVector[rightIdx]->WireID().Plane) - 1; float combRMS = std::sqrt(std::pow(hitVector[leftIdx]->getHit()->RMS(),2) + std::pow(hitVector[rightIdx]->getHit()->RMS(),2)); @@ -1373,7 +1376,7 @@ bool SnippetHit3DBuilderICARUS::makeHitTriplet(reco::ClusterHit3D& hitTrip hitVector, hitDelTSigVec, wireIDVec); - + // Since we are keeping the triplet, mark the hits as used for(const auto& hit2D : hitVector) { @@ -1403,10 +1406,10 @@ bool SnippetHit3DBuilderICARUS::WireIDsIntersect(const geo::WireID& wireID0, con // Do quick check that things are in the same logical TPC if (wireID0.Cryostat != wireID1.Cryostat || wireID0.TPC != wireID1.TPC || wireID0.Plane == wireID1.Plane) return success; - + // Recover wire geometry information for each wire - const geo::WireGeo& wireGeo0 = m_geometry->WireIDToWireGeo(wireID0); - const geo::WireGeo& wireGeo1 = m_geometry->WireIDToWireGeo(wireID1); + const geo::WireGeo& wireGeo0 = m_wireReadoutAlg->Wire(wireID0); + const geo::WireGeo& wireGeo1 = m_wireReadoutAlg->Wire(wireID1); // Get wire position and direction for first wire auto wirePosArr = wireGeo0.GetCenter(); @@ -1497,7 +1500,7 @@ bool SnippetHit3DBuilderICARUS::makeDeadChannelPair(reco::ClusterHit3D& pa size_t maxChanStatus, size_t minChanStatus, float minOverlap) const -{ +{ // Assume failure (most common result) bool result(false); @@ -1530,7 +1533,7 @@ bool SnippetHit3DBuilderICARUS::makeDeadChannelPair(reco::ClusterHit3D& pa if (wireID) { // Recover the channels associated to these wire IDs - raw::ChannelID_t channel = m_geometry->PlaneWireToChannel(wireID); + raw::ChannelID_t channel = m_wireReadoutAlg->PlaneWireToChannel(wireID); // There can be a round off issue so check the next wire as well bool wireStatus = m_channelFilter->IsPresent(channel) && !m_channelFilter->IsGood(channel); @@ -1540,7 +1543,7 @@ bool SnippetHit3DBuilderICARUS::makeDeadChannelPair(reco::ClusterHit3D& pa // Check nearest wire too (potential roundoff issues?) bool wireOneStatus = false; - if (wireID.Wire < m_geometry->Nwires(wireID.asPlaneID()) - 1) + if (wireID.Wire < m_wireReadoutAlg->Nwires(wireID.asPlaneID()) - 1) { wireOneStatus = m_channelFilter->IsPresent(channel+1) && !m_channelFilter->IsGood(channel+1); @@ -1554,18 +1557,13 @@ bool SnippetHit3DBuilderICARUS::makeDeadChannelPair(reco::ClusterHit3D& pa if (!wireStatus) wireID.Wire += 1; // Want to refine position since we "know" the missing wire - geo::WireIDIntersection widIntersect0; - - if (m_geometry->WireIDsIntersect(wireID0, wireID, widIntersect0)) + if (auto widIntersect0 = m_wireReadoutAlg->WireIDsIntersect(wireID0, wireID)) { - geo::WireIDIntersection widIntersect1; - - if (m_geometry->WireIDsIntersect(wireID1, wireID, widIntersect1)) + if (auto widIntersect1 = m_wireReadoutAlg->WireIDsIntersect(wireID1, wireID)) { Eigen::Vector3f newPosition(pair.getPosition()[0],pair.getPosition()[1],pair.getPosition()[2]); - - newPosition[1] = (newPosition[1] + widIntersect0.y + widIntersect1.y) / 3.; - newPosition[2] = (newPosition[2] + widIntersect0.z + widIntersect1.z - 2. * m_zPosOffset) / 3.; + newPosition[1] = (newPosition[1] + widIntersect0->y + widIntersect1->y) / 3.; + newPosition[2] = (newPosition[2] + widIntersect0->z + widIntersect1->z - 2. * m_zPosOffset) / 3.; pairOut = pair; pairOut.setWireID(wireID); @@ -1646,12 +1644,9 @@ geo::WireID SnippetHit3DBuilderICARUS::NearestWireID(const Eigen::Vector3f& posi try { // Switch from NearestWireID to this method to avoid the roundoff error issues... - //double distanceToWire = m_geometry->Plane(wireIDIn).WireCoordinate(geo::vect::toPoint(position.data())); - - //wireID.Wire = int(distanceToWire); + double distanceToWire = m_wireReadoutAlg->Plane(wireIDIn).WireCoordinate(geo::vect::toPoint(position.data())); - // Not sure the thinking above but is wrong... switch back to NearestWireID... - wireID = m_geometry->NearestWireID(geo::vect::toPoint(position.data()),wireIDIn); + wireID.Wire = int(distanceToWire); } catch(...) // I am not sure what type of exception is thrown by the geometry service so catch all { @@ -1660,8 +1655,8 @@ geo::WireID SnippetHit3DBuilderICARUS::NearestWireID(const Eigen::Vector3f& posi mf::LogWarning("SnippetHit3D") << "Exception caught finding nearest wire, position " << std::endl; // Assume extremum for wire number depending on z coordinate - if (position[2] < 0.5 * m_geometry->DetLength()) wireID.Wire = 0; - else wireID.Wire = m_geometry->Nwires(wireIDIn.asPlaneID()) - 1; + if (position[2] < 0.5 * m_geometry->TPC({0, 0}).Length()) wireID.Wire = 0; + else wireID.Wire = m_wireReadoutAlg->Nwires(wireIDIn.asPlaneID()) - 1; } return wireID; @@ -1675,7 +1670,7 @@ float SnippetHit3DBuilderICARUS::DistanceFromPointToHitWire(const Eigen::Vector3 try { // Recover wire geometry information for each wire - const geo::WireGeo& wireGeo = m_geometry->WireIDToWireGeo(wireIDIn); + const geo::WireGeo& wireGeo = m_wireReadoutAlg->Wire(wireIDIn); // Get wire position and direction for first wire auto const wirePosArr = wireGeo.GetCenter(); @@ -1819,7 +1814,7 @@ void SnippetHit3DBuilderICARUS::CollectArtHits(const art::Event& evt) const // For some detectors we can have multiple wire ID's associated to a given channel. // So we recover the list of these wire IDs - const std::vector& wireIDs = m_geometry->ChannelToWire(recobHit->Channel()); + const std::vector& wireIDs = m_wireReadoutAlg->ChannelToWire(recobHit->Channel()); // Start/End ticks to identify the snippet HitStartEndPair hitStartEndPair(recobHit->StartTick(),recobHit->EndTick()); diff --git a/icaruscode/TPC/Utilities/HitCreator.cxx b/icaruscode/TPC/Utilities/HitCreator.cxx index 39d5922c9..c00855689 100644 --- a/icaruscode/TPC/Utilities/HitCreator.cxx +++ b/icaruscode/TPC/Utilities/HitCreator.cxx @@ -23,7 +23,7 @@ #include "canvas/Utilities/Exception.h" // LArSoft libraries -#include "larcore/Geometry/Geometry.h" +#include "larcore/Geometry/WireReadout.h" #include "lardata/Utilities/MakeIndex.h" namespace { @@ -75,8 +75,8 @@ namespace icarus { local_index, goodness_of_fit, dof, - art::ServiceHandle()->View(digits.Channel()), - art::ServiceHandle()->SignalType(digits.Channel()), + art::ServiceHandle()->Get().View(digits.Channel()), + art::ServiceHandle()->Get().SignalType(digits.Channel()), wireID) {} // HitCreator::HitCreator(RawDigit) @@ -112,8 +112,8 @@ namespace icarus { local_index, goodness_of_fit, dof, - art::ServiceHandle()->View(wire.Channel()), - art::ServiceHandle()->SignalType(wire.Channel()), + art::ServiceHandle()->Get().View(wire.Channel()), + art::ServiceHandle()->Get().SignalType(wire.Channel()), wireID) {} // HitCreator::HitCreator(Wire) diff --git a/icaruscode/TPC/Utilities/SignalShapingICARUSService_service.cc b/icaruscode/TPC/Utilities/SignalShapingICARUSService_service.cc index 037c6203c..551c30e7a 100644 --- a/icaruscode/TPC/Utilities/SignalShapingICARUSService_service.cc +++ b/icaruscode/TPC/Utilities/SignalShapingICARUSService_service.cc @@ -19,7 +19,7 @@ #include "TFile.h" // LArSoft include -#include "larcore/Geometry/Geometry.h" +#include "larcore/Geometry/WireReadout.h" #include "larcorealg/Geometry/TPCGeo.h" #include "larcorealg/Geometry/PlaneGeo.h" @@ -99,10 +99,10 @@ const icarus_tool::IResponse& SignalShapingICARUSService::GetResponse(size_t cha { if (!fInit) init(); - art::ServiceHandle geom; + geo::WireReadoutGeom const& wireReadoutAlg = art::ServiceHandle{}->Get(); //use channel number to set some useful numbers - size_t planeIdx = geom->ChannelToWire(channel)[0].Plane; + size_t planeIdx = wireReadoutAlg.ChannelToWire(channel)[0].Plane; return *fPlaneToResponseMap.at(planeIdx).front(); } @@ -121,7 +121,7 @@ void SignalShapingICARUSService::init() { // Do ICARUS-specific configuration of SignalShaping by providing // ICARUS response and filter functions. - art::ServiceHandle geo; + geo::WireReadoutGeom const& wireReadoutAlg = art::ServiceHandle{}->Get(); auto const samplingRate = sampling_rate(art::ServiceHandle()->DataForJob()); @@ -129,7 +129,7 @@ void SignalShapingICARUSService::init() double integral = fPlaneToResponseMap.at(fPlaneForNormalization).front().get()->getFieldResponse()->getIntegral(); double weight = 1. / integral; - for(size_t planeIdx = 0; planeIdx < geo->Nplanes(); planeIdx++) + for(size_t planeIdx = 0; planeIdx < wireReadoutAlg.Nplanes(); planeIdx++) { fPlaneToResponseMap[planeIdx].front().get()->setResponse(samplingRate, weight); } @@ -159,7 +159,7 @@ void SignalShapingICARUSService::init() void SignalShapingICARUSService::SetDecon(double const samplingRate, size_t fftsize, size_t channel) { - art::ServiceHandle geo; + geo::WireReadoutGeom const& wireReadoutAlg = art::ServiceHandle{}->Get(); if (!fInit) init(); @@ -167,7 +167,7 @@ void SignalShapingICARUSService::SetDecon(double const samplingRate, double integral = fPlaneToResponseMap.at(fPlaneForNormalization).front().get()->getFieldResponse()->getIntegral(); double weight = 1. / integral; - for(size_t planeIdx = 0; planeIdx < geo->Nplanes(); planeIdx++) + for(size_t planeIdx = 0; planeIdx < wireReadoutAlg.Nplanes(); planeIdx++) { fPlaneToResponseMap.at(planeIdx).front()->setResponse(samplingRate, weight); } @@ -178,8 +178,8 @@ double SignalShapingICARUSService::GetASICGain(unsigned int channel) const { static const double fcToElectrons(6241.50975); - art::ServiceHandle geom; - size_t planeIdx = geom->ChannelToWire(channel)[0].Plane; + geo::WireReadoutGeom const& wireReadoutAlg = art::ServiceHandle{}->Get(); + size_t planeIdx = wireReadoutAlg.ChannelToWire(channel)[0].Plane; double gain = fPlaneToResponseMap.at(planeIdx).front()->getElectronicsResponse()->getFCperADCMicroS() * fcToElectrons; @@ -196,8 +196,8 @@ double SignalShapingICARUSService::GetShapingTime(unsigned int planeIdx) const double SignalShapingICARUSService::GetRawNoise(unsigned int const channel) const { - art::ServiceHandle geom; - size_t planeIdx = geom->ChannelToWire(channel)[0].Plane; + geo::WireReadoutGeom const& wireReadoutAlg = art::ServiceHandle{}->Get(); + size_t planeIdx = wireReadoutAlg.ChannelToWire(channel)[0].Plane; double gain = fPlaneToResponseMap.at(planeIdx).front()->getElectronicsResponse()->getFCperADCMicroS(); double shaping_time = fPlaneToResponseMap.at(planeIdx).front()->getElectronicsResponse()->getASICShapingTime(); @@ -224,8 +224,8 @@ double SignalShapingICARUSService::GetRawNoise(unsigned int const channel) const double SignalShapingICARUSService::GetDeconNoise(unsigned int const channel) const { - art::ServiceHandle geom; - size_t planeIdx = geom->ChannelToWire(channel)[0].Plane; + geo::WireReadoutGeom const& wireReadoutAlg = art::ServiceHandle{}->Get(); + size_t planeIdx = wireReadoutAlg.ChannelToWire(channel)[0].Plane; double shaping_time = fPlaneToResponseMap.at(planeIdx).front()->getElectronicsResponse()->getASICShapingTime(); int temp; @@ -251,9 +251,9 @@ int SignalShapingICARUSService::ResponseTOffset(unsigned int const channel) cons { if (!fInit) init(); - art::ServiceHandle geom; + geo::WireReadoutGeom const& wireReadoutAlg = art::ServiceHandle{}->Get(); - size_t planeIdx = geom->ChannelToWire(channel)[0].Plane; + size_t planeIdx = wireReadoutAlg.ChannelToWire(channel)[0].Plane; return fPlaneToResponseMap.at(planeIdx).front()->getTOffset(); } diff --git a/ups/product_deps b/ups/product_deps index 74fb620e0..ff8519b93 100644 --- a/ups/product_deps +++ b/ups/product_deps @@ -256,7 +256,7 @@ icarus_signal_processing v09_91_02_02 - icarusalg v09_92_00 - icarusutil v09_88_00_02 - libwda v2_30_0a - -sbncode v09_92_00 - +sbncode v10_04_01 - cetmodules v3_24_01 - only_for_build end_product_list ####################################