From e172c7010be2e44694350ce5ac62a6de587319af Mon Sep 17 00:00:00 2001 From: Jack Smedley Date: Mon, 23 Oct 2023 10:10:14 -0500 Subject: [PATCH 01/34] Updated producer, changed fcls --- .../OpReco/BarycenterMatchProducer_module.cc | 545 ++++++++++++++++++ icaruscode/PMT/OpReco/CMakeLists.txt | 2 + .../PMT/OpReco/fcl/barycentermatch_data.fcl | 82 +++ .../PMT/OpReco/fcl/barycentermatch_mc.fcl | 82 +++ 4 files changed, 711 insertions(+) create mode 100644 icaruscode/PMT/OpReco/BarycenterMatchProducer_module.cc create mode 100644 icaruscode/PMT/OpReco/fcl/barycentermatch_data.fcl create mode 100644 icaruscode/PMT/OpReco/fcl/barycentermatch_mc.fcl diff --git a/icaruscode/PMT/OpReco/BarycenterMatchProducer_module.cc b/icaruscode/PMT/OpReco/BarycenterMatchProducer_module.cc new file mode 100644 index 000000000..35ac72842 --- /dev/null +++ b/icaruscode/PMT/OpReco/BarycenterMatchProducer_module.cc @@ -0,0 +1,545 @@ +//////////////////////////////////////////////////////////////////////// +// Class: BarycenterMatchProducer +// Plugin Type: producer (Unknown Unknown) +// File: BarycenterMatchProducer_module.cc +// +// Generated at Sun Oct 22 14:43:16 2023 by John Smedley using cetskelgen +// from version . +//////////////////////////////////////////////////////////////////////// + +#include "art/Framework/Core/EDProducer.h" +#include "art/Framework/Core/ModuleMacros.h" +#include "art/Framework/Principal/Event.h" +#include "art/Framework/Principal/Handle.h" +#include "art/Framework/Principal/Run.h" +#include "art/Framework/Principal/SubRun.h" +#include "canvas/Utilities/InputTag.h" +#include "fhiclcpp/ParameterSet.h" +#include "messagefacility/MessageLogger/MessageLogger.h" +#include "art_root_io/TFileService.h" +#include "art/Framework/Services/Registry/ServiceHandle.h" +#include "art/Persistency/Common/PtrMaker.h" +#include "canvas/Persistency/Common/FindOne.h" +#include "canvas/Persistency/Common/FindOneP.h" +#include "canvas/Persistency/Common/FindMany.h" +#include "canvas/Persistency/Common/FindManyP.h" + +//LArSoft includes +#include "icarusalg/Utilities/TrackTimeInterval.h" +#include "lardata/DetectorInfoServices/DetectorPropertiesService.h" +#include "lardata/DetectorInfoServices/DetectorClocksService.h" +#include "lardataalg/DetectorInfo/DetectorPropertiesData.h" +#include "lardataalg/DetectorInfo/DetectorClocksData.h" +#include "larcore/Geometry/Geometry.h" +#include "larcorealg/Geometry/GeometryCore.h" +#include "larcore/CoreUtils/ServiceUtil.h" + +//Data product includes +#include "lardataobj/RecoBase/OpHit.h" +#include "lardataobj/RecoBase/OpFlash.h" +#include "lardataobj/RecoBase/Slice.h" +#include "lardataobj/RecoBase/Hit.h" +#include "lardataobj/RecoBase/SpacePoint.h" +#include "lardataobj/RecoBase/PFParticle.h" +#include "lardataobj/AnalysisBase/T0.h" +#include "lardataobj/RawData/TriggerData.h" +#include "sbnobj/Common/Reco/BarycenterMatch.h" + +//ROOT includes +#include "TTree.h" +#include "TVector3.h" + +#include + +using microseconds = util::quantities::intervals::microseconds; +using electronics_time = detinfo::timescales::electronics_time; + +class BarycenterMatchProducer; + + +class BarycenterMatchProducer : public art::EDProducer { +public: + explicit BarycenterMatchProducer(fhicl::ParameterSet const& p); + // The compiler-generated destructor is fine for non-base + // classes without bare pointers or other resource use. + + // Plugins should not be copied or assigned. + BarycenterMatchProducer(BarycenterMatchProducer const&) = delete; + BarycenterMatchProducer(BarycenterMatchProducer&&) = delete; + BarycenterMatchProducer& operator=(BarycenterMatchProducer const&) = delete; + BarycenterMatchProducer& operator=(BarycenterMatchProducer&&) = delete; + + // Required functions. + void produce(art::Event& e) override; + +private: + + // Declare member data here. + void InitializeSlice(); + double CentroidOverlap(double center1, double center2, double width1, double width2); + double CalculateAsymmetry(art::Ptr flash, int cryo); + void updateChargeVars(double sumCharge, TVector3 sumPos, TVector3 sumPosSqr, double triggerFlashCenter); + void updateFlashVars(art::Ptr flash, double shift, double firstHit); + void updateMatchInfo(sbn::BarycenterMatch& matchInfo); + + // Input parameters + std::vector fCryoTags; ///< Labels for each cryostat + std::string fOpFlashLabel; ///< Label for PMT reconstruction products + std::string fPandoraLabel; ///< Label for Pandora output products + std::string fTriggerLabel; ///< Label for trigger product + bool fCollectionOnly; ///< Only use TPC spacepoints from the collection plane + bool fUseTimeRange; ///< Reject impossible matches based on allowed time range of TPC hits relative to trigger + bool fVerbose; ///< Print extra info, fcl input + double fNominalTrigTime; ///< Typical time of triggering flash, EYEBALLED (us) + double fTriggerTolerance; ///< Spread of triggering flash times, EYEBALLED (us) + double fTimeRangeMargin; ///< Symmetric acceptable margin for allowed time range of TPC hits (us) + + // Event-level data members + int fRun; ///< Number of the run being processed + int fEvent; ///< Number of the event being processed + int fCryo; ///< Cryostat this event occured in + int fSliceNum; ///< Number of slice in the event + double fChargeT0; ///< Start time for cathode-crossing PFPs, not always available (us) + double fChargeTotal; ///< Total charge in slice + double fChargeCenterXGlobal; ///< Weighted mean X position of spacepoints (cm) + double fChargeCenterXLocal; ///< Weighted mean X position of spacepoints, measured with respect to the cathode (cm) + double fChargeCenterY; ///< Weighted mean Y position of spacepoints (cm) + double fChargeCenterZ; ///< Weighted mean Z position of spacepoints (cm) + double fChargeWidthX; ///< Weighted standard deviation of X position of spacepoints (cm) + double fChargeWidthY; ///< Weighted standard deviation of Y position of spacepoints (cm) + double fChargeWidthZ; ///< Weighted standard deviation of Z position of spacepoints (cm) + double fFlashFirstHit; ///< Earliest OpHit time in matched OpFlash (us) + double fFlashTime; ///< Matched OpFlash time (us) + double fFlashPEs; ///< Brightness of matched flash (photoelectrons) + double fFlashAsymmetry; ///< East-West asymmetry of PEs in matched flash + double fFlashCenterY; ///< Weighted mean Y postion of hit PMTs (cm) + double fFlashCenterZ; ///< Weighted mean Z postion of hit PMTs (cm) + double fFlashWidthY; ///< Weighted standard deviation of Y postion of hit PMTs (cm) + double fFlashWidthZ; ///< Weighted standard deviation of Z postion of hit PMTs (cm) + double fDeltaT; ///< | Matched flash time - charge T0 | when available (us) + double fDeltaY; ///< | Matched flash Y center - charge Y center | (cm) + double fDeltaZ; ///< | Matched flash Z cetner - charge Z center | (cm) + double fRadius; ///< Hypotenuse of DeltaY and DeltaZ, PARAMETER MINIMIZED BY MATCHING (cm) + double fOverlapY; ///< Spacial overlap of flash and charge centroids in Y [>0] OR distance apart if no overlap [<0] (cm) + double fOverlapZ; ///< Spacial overlap of flash and charge centroids in Z [>0] OR distance apart if no overlap [<0] (cm) + double fDeltaZ_Trigger; ///< | Triggering flash Z cetner - charge Z center | (cm) + + TTree* fMatchTree; ///< Tree to store all match information + + // Detector geometry and properties + geo::GeometryCore const& fGeom; + detinfo::DetectorClocksService const& fDetClocks; + detinfo::DetectorPropertiesService const& fDetProp; + lar::util::TrackTimeIntervalMaker const fTimeIntervalMaker; +}; + + +BarycenterMatchProducer::BarycenterMatchProducer(fhicl::ParameterSet const& p) + : EDProducer{p}, + // More initializers here. + fCryoTags(p.get>("CryoTags")), + fOpFlashLabel(p.get("OpFlashLabel")), + fPandoraLabel(p.get("PandoraLabel")), + fTriggerLabel(p.get("TriggerLabel")), + fCollectionOnly(p.get("CollectionOnly")), + fUseTimeRange(p.get("UseTimeRange")), + fVerbose(p.get("Verbose")), + fNominalTrigTime(p.get("NominalTrigTime")), + fTriggerTolerance(p.get("TriggerTolerance")), + fTimeRangeMargin(p.get("TimeRangeMargin")), + fGeom(*lar::providerFrom()), + fDetClocks(*art::ServiceHandle()), + fDetProp(*art::ServiceHandle()), + fTimeIntervalMaker{ fGeom } +{ + // Call appropriate produces<>() functions here. + + produces< std::vector >(); +// produces< art::Assns >(); +// produces< art::Assns >(); +// produces< art::Assns >(); + + // Call appropriate consumes<>() for any products to be retrieved by this module. + art::ServiceHandle tfs; + fMatchTree = tfs->make("matchTree","TPC Slice - OpFlash Matching Analysis"); + + //Event Info + fMatchTree->Branch("run", &fRun, "run/I" ); + fMatchTree->Branch("event", &fEvent, "event/I" ); + fMatchTree->Branch("cryo", &fCryo, "cryo/I" ); + fMatchTree->Branch("sliceNum", &fSliceNum, "sliceNum/I" ); + + //Charge Info + fMatchTree->Branch("chargeT0", &fChargeT0, "chargeT0/d" ); + fMatchTree->Branch("chargeTotal", &fChargeTotal, "chargeTotal/d" ); + fMatchTree->Branch("chargeCenterXGlobal", &fChargeCenterXGlobal, "chargeCenterXGlobal/d"); + fMatchTree->Branch("chargeCenterXLocal", &fChargeCenterXLocal, "chargeCenterXLocal/d" ); + fMatchTree->Branch("chargeCenterY", &fChargeCenterY, "chargeCenterY/d" ); + fMatchTree->Branch("chargeCenterZ", &fChargeCenterZ, "chargeCenterZ/d" ); + fMatchTree->Branch("chargeWidthX", &fChargeWidthX, "chargeWidthX/d" ); + fMatchTree->Branch("chargeWidthY", &fChargeWidthY, "chargeWidthY/d" ); + fMatchTree->Branch("chargeWidthZ", &fChargeWidthZ, "chargeWidthZ/d" ); + + //Matched Flash Info + fMatchTree->Branch("flashFirstHit", &fFlashFirstHit, "flashFirstHit/d" ); + fMatchTree->Branch("flashTime", &fFlashTime, "flashTime/d" ); + fMatchTree->Branch("flashPEs", &fFlashPEs, "flashPEs/d" ); + fMatchTree->Branch("flashAsymmetry", &fFlashAsymmetry, "flashAsymmetry/d" ); + fMatchTree->Branch("flashCenterY", &fFlashCenterY, "flashCenterY/d" ); + fMatchTree->Branch("flashCenterZ", &fFlashCenterZ, "flashCenterZ/d" ); + fMatchTree->Branch("flashWidthY", &fFlashWidthY, "flashWidthY/d" ); + fMatchTree->Branch("flashWidthZ", &fFlashWidthZ, "flashWidthZ/d" ); + + //Match Quality Info + fMatchTree->Branch("deltaT", &fDeltaT, "deltaT/d" ); + fMatchTree->Branch("deltaY", &fDeltaY, "deltaY/d" ); + fMatchTree->Branch("deltaZ", &fDeltaZ, "deltaZ/d" ); + fMatchTree->Branch("radius", &fRadius, "radius/d" ); + fMatchTree->Branch("overlapY", &fOverlapY, "overlapY/d" ); + fMatchTree->Branch("overlapZ", &fOverlapZ, "overlapZ/d" ); + fMatchTree->Branch("deltaZ_Trigger", &fDeltaZ_Trigger, "deltaZ_Trigger/d" ); + +} + +void BarycenterMatchProducer::produce(art::Event& e) +{ + // Implementation of required member function here. + fEvent = e.id().event(); + fRun = e.run(); + const bool isData = e.isRealData(); + + art::Handle> triggerHandle; + e.getByLabel(fTriggerLabel, triggerHandle); + raw::Trigger trigger; + double shiftFactor = 0.; + bool triggeredEvt = false; + if ( triggerHandle.isValid() && triggerHandle->size() == 1 ) { + trigger = (*triggerHandle).at(0); + if ( trigger.TriggerTime() >= 0 ) { + shiftFactor = trigger.TriggerTime() - trigger.BeamGateTime(); + triggeredEvt = true; + } + if ( fVerbose ) std::cout << std::endl << "Valid trigger found. Trigger time: " << trigger.TriggerTime() << ", Beam gate time: " << trigger.BeamGateTime() << ", Difference: " << shiftFactor << ", Is data? " << isData << std::endl; + } + else if ( fVerbose ) std::cout << std::endl << "~~~~~~~~~~~~~ No valid trigger found for this event! ~~~~~~~~~~~~~" << std::endl; + + microseconds margin(fTimeRangeMargin); + detinfo::DetectorTimings const detTimings{ fDetClocks.DataFor(e) }; + detinfo::DetectorPropertiesData const& detProp { fDetProp.DataFor(e, detTimings.clockData()) }; + lar::util::TrackTimeInterval const timeIntervals = fTimeIntervalMaker(detProp, detTimings); + + auto matchInfoVector = std::make_unique< std::vector >(); +// art::PtrMaker< sbn::BarycenterMatch > const makeInfoPtr(e); //What does this do? Only Gianluca can know... +// auto sliceAssns = std::make_unique< art::Assns >(); +// auto flashAssns = std::make_unique< art::Assns >(); +// auto crossAssns = std::make_unique< art::Assns >(); + + //For cryo... + for ( const std::string cryoTag : fCryoTags ) { + //East-->0, West-->1 + fCryo = ( cryoTag.find("W") != std::string::npos ) ? 1 : 0; + + +/* ~~~~~~~~~~~~~~~~~~~~ Flash Section + * + * Here we gather the OpFlashes found in this cryostat and their OpHits + * We iterate through the flashes to identify a triggering flash and the earliest time associated with each flash + */ + + //Fetch the flashes and their associated hits; pointer vector needed for assns + art::Handle> flashHandle; + e.getByLabel(fOpFlashLabel + cryoTag, flashHandle); + art::FindMany fmOpHits(flashHandle, e, fOpFlashLabel + cryoTag); + std::vector> flashVector; + art::fill_ptr_vector(flashVector, flashHandle); + + int nFlashes = (*flashHandle).size(); + + double triggerFlashCenter = -9999.; + double flashTime_Trigger, flashTime_Beam; + //For flash... + for ( int i = 0; i < nFlashes; i++ ) { + const recob::OpFlash &flash = (*flashHandle).at(i); + + flashTime_Trigger = flash.Time(); + flashTime_Beam = flash.Time(); + if ( isData ) flashTime_Beam += shiftFactor; + else flashTime_Trigger += -1.*shiftFactor; + + //Is this a triggering flash? + if ( triggeredEvt && abs(flashTime_Trigger - fNominalTrigTime) < fTriggerTolerance ) triggerFlashCenter = flash.ZCenter(); + + if ( fVerbose ) std::cout << std::endl << "Flash time wrt trigger: " << flashTime_Trigger << ", Flash time wrt beam gate: " << flashTime_Beam << std::endl; //TODO: Remove print statements later + + } // End for flash + + if ( fVerbose ) std::cout << "Event: " << fEvent << ", Cryo: " << cryoTag << ", nFlashes: " << nFlashes << ", Triggering flash center: " << triggerFlashCenter << std::endl; //TODO: Remove print statements later + + +/* ~~~~~~~~~~~~~~~~~~~~ TPC Section + * Here we start by gathering the Slices in the event + * For each slice, the charge centroid is first calculated + * Then we iterate through flashes to identify the best match flash + * If a triggering flash was found earlier, the barycetner distance to the triggering flash is also stored + */ + + //Fetch slices, TPC hits, and PFPs; pointer vector needed for assns + art::Handle> sliceHandle; + e.getByLabel(fPandoraLabel + cryoTag, sliceHandle); + art::FindManyP fmTPCHits(sliceHandle, e, fPandoraLabel + cryoTag); + art::FindManyP fmPFPs(sliceHandle, e, fPandoraLabel + cryoTag); + std::vector> sliceVector; + art::fill_ptr_vector(sliceVector, sliceHandle); + + int nSlices = (*sliceHandle).size(); + + //For slice... + for ( int j = 0; j < nSlices; j++ ) { + fSliceNum = j; +// const art::Ptr& slicePtr = sliceVector.at(j); + InitializeSlice(); + sbn::BarycenterMatch sliceMatchInfo; + updateMatchInfo(sliceMatchInfo); + + const std::vector> &tpcHitsVec = fmTPCHits.at(j); + const std::vector> &pfpsVec = fmPFPs.at(j); + art::FindOne f1SpacePoint(tpcHitsVec, e, fPandoraLabel + cryoTag); + + int nHits = tpcHitsVec.size(); + int nPFPs = pfpsVec.size(); + + //Establish possible time range for this slice + lar::util::TrackTimeInterval::TimeRange const& timeRange = timeIntervals.timeRangeOfHits(tpcHitsVec); + const bool rangeIsValid = timeRange.isValid(); + + //Retrieve Pandora's T0 for this slice if available, same for every PFP in slice so we only need one + if ( nPFPs != 0 ) { + art::FindOne f1T0( {pfpsVec.at(0)}, e, fPandoraLabel + cryoTag); + if ( f1T0.at(0).isValid() ) { + fChargeT0 = f1T0.at(0).ref().Time() / 1e3; + if ( isData ) fChargeT0 += shiftFactor; + } + } + + double thisCharge; + double sumCharge = 0.; + TVector3 thisPoint, thisPointSqr; + TVector3 sumPos {0.,0.,0.}; + TVector3 sumPosSqr {0.,0.,0.}; + + //For hit... + for ( int k = 0; k < nHits; k++ ) { + const art::Ptr &tpcHit = tpcHitsVec.at(k); + + //Only use hits with associated SpacePoints, and optionally only collection plane hits + if ( fCollectionOnly && tpcHit->SignalType() != geo::kCollection ) continue; + if ( !f1SpacePoint.at(k).isValid() ) continue; + + const recob::SpacePoint point = f1SpacePoint.at(k).ref(); + thisCharge = tpcHit->Integral(); + thisPoint = point.XYZ(); + thisPointSqr = {thisPoint[0]*thisPoint[0], thisPoint[1]*thisPoint[1], thisPoint[2]*thisPoint[2]}; + sumCharge += thisCharge; + sumPos += thisPoint * thisCharge; + sumPosSqr += thisPointSqr * thisCharge; + } //End for hit + + //No charge found in slice... + if ( sumCharge == 0. ) { + fMatchTree->Fill(); +// art::Ptr const infoPtr = makeInfoPtr(matchInfoVector->size()); +// sliceAssns->addSingle(infoPtr, slicePtr); + matchInfoVector->push_back(std::move(sliceMatchInfo)); + if ( fVerbose ) std::cout << "No charge found in Event " << fEvent << " Slice " << j << "! Continuing..." << std::endl; //TODO: Remove print statements later, or maybe keep this one? + continue; + } + + //Update charge variables + updateChargeVars(sumCharge, sumPos, sumPosSqr, triggerFlashCenter); + updateMatchInfo(sliceMatchInfo); + + int matchIndex = -5; + double minDistance = 1e6; + double thisFlashCenterY, thisFlashCenterZ, thisDistance; + + //For flash... + for ( int m = 0; m < nFlashes; m++ ) { + const recob::OpFlash &flash = (*flashHandle).at(m); + + if ( fUseTimeRange && rangeIsValid ) { + electronics_time eTime (flash.AbsTime()); + if ( !timeRange.contains(eTime, margin) ) continue; + } + + //TODO: if ( flash has entering CRT match ) continue? Or at least just store that as a bool? + + //Find index of flash that minimizes barycenter distance in YZ place + thisFlashCenterY = flash.YCenter(); + thisFlashCenterZ = flash.ZCenter(); + thisDistance = std::hypot( (thisFlashCenterY - fChargeCenterY), (thisFlashCenterZ - fChargeCenterZ) ); + if ( thisDistance < minDistance ) { + minDistance = thisDistance; + matchIndex = m; + } + } //End for flash + + //No valid match found... + if ( matchIndex == -5 ) { + fMatchTree->Fill(); +// art::Ptr const infoPtr = makeInfoPtr(matchInfoVector->size()); +// sliceAssns->addSingle(infoPtr, slicePtr); + matchInfoVector->push_back(std::move(sliceMatchInfo)); + if ( fVerbose ) std::cout << "No matching flash found for Event " << fEvent << " Slice " << j << "! Continuing..." << std::endl; //TODO: Remove print statements later, or maybe keep this one? + continue; + } + + //Update match variables + const art::Ptr& flashPtr = flashVector.at(matchIndex); + + const std::vector &opHitsVec = fmOpHits.at(matchIndex); + double minTime = 1e6; + //For OpHit... + for (const recob::OpHit *opHit : opHitsVec ) { + if ( opHit->PeakTime() < minTime ) minTime = opHit->PeakTime(); //TODO: Rise time or peak time? + } //End for OpHit + if ( isData ) minTime += shiftFactor; + + updateFlashVars(flashPtr, (isData ? shiftFactor : 0.), minTime); + updateMatchInfo(sliceMatchInfo); + + +// art::Ptr const infoPtr = makeInfoPtr(matchInfoVector->size()); +// sliceAssns->addSingle(infoPtr, slicePtr); +// flashAssns->addSingle(infoPtr, flashPtr); +// crossAssns->addSingle(slicePtr, flashPtr, infoPtr); + matchInfoVector->push_back(std::move(sliceMatchInfo)); + fMatchTree->Fill(); + + } //End for slice + + } //End for cryo + + e.put(std::move(matchInfoVector)); +// e.put(std::move(sliceAssns)); +// e.put(std::move(flashAssns)); +// e.put(std::move(crossAssns)); + +} //End produce() + +void BarycenterMatchProducer::InitializeSlice() { + fChargeT0 = -9999.; + fChargeTotal = -9999.; + fChargeCenterXGlobal = -9999.; + fChargeCenterXLocal = -9999.; + fChargeCenterY = -9999.; + fChargeCenterZ = -9999.; + fChargeWidthX = -9999.; + fChargeWidthY = -9999.; + fChargeWidthZ = -9999.; + fFlashFirstHit = -9999.; + fFlashTime = -9999.; + fFlashPEs = -9999.; + fFlashCenterY = -9999.; + fFlashCenterZ = -9999.; + fFlashWidthY = -9999.; + fFlashWidthZ = -9999.; + fDeltaT = -9999.; + fDeltaY = -9999.; + fDeltaZ = -9999.; + fRadius = -9999.; + fOverlapY = -9999.; + fOverlapZ = -9999.; + fDeltaZ_Trigger = -9999.; +} //End InitializeSlice() + + +double BarycenterMatchProducer::CentroidOverlap(double center1, double center2, double width1, double width2) { + //Centroid 2 is contained within Centroid 1, so overlap is the whole Centroid 2 + if ( (center1 - width1 < center2 - width2) && (center1 + width1 > center2 + width2) ) return (2 * width2); + + //Centroid 1 is contained within Centroid 2, so overlap is the whole Centroid 1 + else if ( (center1 - width1 > center2 - width2) && (center1 + width1 < center2 + width2) ) return (2 * width1); + + double difference = center1 - center2; + if ( center1 > center2 ) difference *= -1; + return difference + width1 + width2; +} //End CentroidOverlap() + + +double BarycenterMatchProducer::CalculateAsymmetry(art::Ptr flash, int cryo) { + double sumEast = 0.; + double sumWest = 0.; + + //East Cryo flashes have a 180-element PE vector; 0-89 --> East wall, 90-179 --> West wall + //West Cryo flashes have a 360-element PE vector; 0-179 --> ALL 0, 180-269 --> East wall, and 270-359 --> West wall + int countingOffset = 0; + if ( cryo == 1 ) countingOffset += 180; + + for ( int PMT = 0; PMT < 180; PMT++ ) { + if ( PMT <= 89 ) sumEast += flash->PEs().at(PMT + countingOffset); + else sumWest += flash->PEs().at(PMT + countingOffset); + } + + return (sumWest - sumEast) / (sumWest + sumEast); +} //End CalculateAsymmetry() + + +//TODO: Get the cathode position and shift global X to local X in a less hacky way +//According to a geometrydump, the cathode X positions are +/-(210.14, 210.29), depending on the TPC. Here I just averaged those... +void BarycenterMatchProducer::updateChargeVars(double sumCharge, TVector3 sumPos, TVector3 sumPosSqr, double triggerFlashCenter) { + fChargeCenterXGlobal = sumPos[0] / sumCharge; + fChargeCenterXLocal = fChargeCenterXGlobal - 210.215 * (2*fCryo - 1); + fChargeCenterY = sumPos[1] / sumCharge; + fChargeCenterZ = sumPos[2] / sumCharge; + fChargeWidthX = std::sqrt( sumPosSqr[0]/sumCharge - (sumPos[0]/sumCharge)*(sumPos[0]/sumCharge) ); + fChargeWidthY = std::sqrt( sumPosSqr[1]/sumCharge - (sumPos[1]/sumCharge)*(sumPos[1]/sumCharge) ); + fChargeWidthZ = std::sqrt( sumPosSqr[2]/sumCharge - (sumPos[2]/sumCharge)*(sumPos[2]/sumCharge) ); + if ( triggerFlashCenter != -9999 ) fDeltaZ_Trigger = abs(triggerFlashCenter - fChargeCenterZ); +} //End updateChargeVars() + + +void BarycenterMatchProducer::updateFlashVars(art::Ptr flash, double shift, double firstHit) { + double matchedTime = flash->Time() + shift; + double matchedYCenter = flash->YCenter(); + double matchedZCenter = flash->ZCenter(); + double matchedYWidth = flash->YWidth(); + double matchedZWidth = flash->ZWidth(); + + fFlashFirstHit = firstHit; + fFlashTime = matchedTime; + fFlashPEs = flash->TotalPE(); + fFlashAsymmetry = CalculateAsymmetry(flash, fCryo); + fFlashCenterY = matchedYCenter; + fFlashCenterZ = matchedZCenter; + fFlashWidthY = matchedYWidth; + fFlashWidthZ = matchedZWidth; + if ( fChargeT0 != -9999 ) fDeltaT = abs(matchedTime - fChargeT0); + fDeltaY = abs(matchedYCenter - fChargeCenterY); + fDeltaZ = abs(matchedZCenter - fChargeCenterZ); + fRadius = std::hypot(fDeltaY, fDeltaZ); + fOverlapY = CentroidOverlap(matchedYCenter, fChargeCenterY, matchedYWidth, fChargeWidthY); + fOverlapZ = CentroidOverlap(matchedZCenter, fChargeCenterZ, matchedZWidth, fChargeWidthZ); +} //End updateFlashVars() + + +void BarycenterMatchProducer::updateMatchInfo(sbn::BarycenterMatch& matchInfo) { + matchInfo.fChargeTotal = fChargeTotal; + matchInfo.fChargeCenterXLocal = fChargeCenterXLocal; + matchInfo.fChargeCenter = {fChargeCenterXGlobal, fChargeCenterY, fChargeCenterZ}; + matchInfo.fChargeWidth = {fChargeWidthX, fChargeWidthY, fChargeWidthZ}; + matchInfo.fFlashFirstHit = fFlashFirstHit; + matchInfo.fFlashTime = fFlashTime; + matchInfo.fFlashPEs = fFlashPEs; + matchInfo.fFlashCenter = {-9999., fFlashCenterY, fFlashCenterZ}; + matchInfo.fFlashWidth = {-9999., fFlashWidthY, fFlashWidthZ}; + matchInfo.fDeltaT = fDeltaT; + matchInfo.fDeltaY = fDeltaY; + matchInfo.fDeltaZ = fDeltaZ; + matchInfo.fRadius = fRadius; + matchInfo.fOverlapY = fOverlapY; + matchInfo.fOverlapZ = fOverlapZ; + matchInfo.fDeltaZ_Trigger = fDeltaZ_Trigger; +} //End updateMatchInfo() + + +DEFINE_ART_MODULE(BarycenterMatchProducer) diff --git a/icaruscode/PMT/OpReco/CMakeLists.txt b/icaruscode/PMT/OpReco/CMakeLists.txt index a3b92e795..c047d0ea2 100644 --- a/icaruscode/PMT/OpReco/CMakeLists.txt +++ b/icaruscode/PMT/OpReco/CMakeLists.txt @@ -16,6 +16,7 @@ cet_build_plugin(ICARUSOpHitFinder art::module set( MODULE_LIBRARIES + icarusalg::Utilities sbnobj::Common_Trigger larcorealg::Geometry larcore::Geometry_Geometry_service @@ -59,6 +60,7 @@ cet_build_plugin(ICARUSOpFlashAna art::module LIBRARIES ${MODULE_LIBRARIES}) cet_build_plugin(ICARUSOpHitAna art::module LIBRARIES ${MODULE_LIBRARIES}) cet_build_plugin(ICARUSOpHitTuple art::module LIBRARIES ${MODULE_LIBRARIES}) cet_build_plugin(ICARUSParticleAna art::module LIBRARIES ${MODULE_LIBRARIES}) +cet_build_plugin(BarycenterMatchProducer art::module LIBRARIES ${MODULE_LIBRARIES}) install_headers() diff --git a/icaruscode/PMT/OpReco/fcl/barycentermatch_data.fcl b/icaruscode/PMT/OpReco/fcl/barycentermatch_data.fcl new file mode 100644 index 000000000..89e7bf62c --- /dev/null +++ b/icaruscode/PMT/OpReco/fcl/barycentermatch_data.fcl @@ -0,0 +1,82 @@ +# A script to run the producer module: BarycenterMatchProducer + +#include "services_icarus_simulation.fcl" +#include "services_common_icarus.fcl" + +process_name: BarycenterMatchProducer + +services: +{ + # Load the service that manages root files for histograms. + TFileService: { fileName: "tpcpmtmatchingana.root" } + # This constrols the display in the output of how long each job step takes for each event. + TimeTracker: {} + + + + # This parameter controls the level of descriptive output from various LArSoft modules. + message: @local::icarus_message_services_prod_debug + @table::icarus_common_services + +} # services + + +# The 'source' section tells the script to expect an input file with art::Event records. +source: +{ + module_type: RootInput + + # Number of events to analyze; "-1" means all of the events in the input + # file. You can override this value with the "-n" option on the command line. + maxEvents: -1 + +} + +# This is empty, because we're not writing an output file with art::Event objects. +outputs: +{ + out1: + { + module_type: RootOutput + fileName: "%ifb_%tc_BarycenterMatch.root" + dataTier: "reconstructed" + saveMemoryObjectThreshold: 0 + compressionLevel: 1 + fastCloning: true + } +} + +# The 'physics' section defines and configures some modules to do work on each event. +physics: +{ + producers: + { + BarycenterMatchProducer: + { + module_type: "BarycenterMatchProducer" + # The input parameters + CryoTags: ["CryoE","CryoW"] + OpFlashLabel: "opflash" + PandoraLabel: "pandoraGaus" + TriggerLabel: "daqTrigger" + CollectionOnly: true + UseTimeRange: true + Verbose: true + NominalTrigTime: -0.6 + TriggerTolerance: 0.15 + TimeRangeMargin: 35. + } + } + + # Schedule job step(s) for execution by defining the analysis module for this job. + reco: [ BarycenterMatchProducer ] + + stream1: [ out1 ] + + trigger_paths: [reco] + + # "end_paths" is a keyword and contains the modules that do not modify the art::Event; + # i.e., analyzers and output streams. + end_paths: [ stream1 ] + +} diff --git a/icaruscode/PMT/OpReco/fcl/barycentermatch_mc.fcl b/icaruscode/PMT/OpReco/fcl/barycentermatch_mc.fcl new file mode 100644 index 000000000..4d1e7480f --- /dev/null +++ b/icaruscode/PMT/OpReco/fcl/barycentermatch_mc.fcl @@ -0,0 +1,82 @@ +# A script to run the producer module: BarycenterMatchProducer + +#include "services_icarus_simulation.fcl" +#include "services_common_icarus.fcl" + +process_name: BarycenterMatchProducer + +services: +{ + # Load the service that manages root files for histograms. + TFileService: { fileName: "tpcpmtmatchingana.root" } + # This constrols the display in the output of how long each job step takes for each event. + TimeTracker: {} + + + + # This parameter controls the level of descriptive output from various LArSoft modules. + message: @local::icarus_message_services_prod_debug + @table::icarus_common_services + +} # services + + +# The 'source' section tells the script to expect an input file with art::Event records. +source: +{ + module_type: RootInput + + # Number of events to analyze; "-1" means all of the events in the input + # file. You can override this value with the "-n" option on the command line. + maxEvents: -1 + +} + +# This is empty, because we're not writing an output file with art::Event objects. +outputs: +{ + out1: + { + module_type: RootOutput + fileName: "%ifb_%tc_BarycenterMatch.root" + dataTier: "reconstructed" + saveMemoryObjectThreshold: 0 + compressionLevel: 1 + fastCloning: true + } +} + +# The 'physics' section defines and configures some modules to do work on each event. +physics: +{ + producers: + { + BarycenterMatchProducer: + { + module_type: "BarycenterMatchProducer" + # The input parameters + CryoTags: ["CryoE","CryoW"] + OpFlashLabel: "opflash" + PandoraLabel: "pandoraGaus" + TriggerLabel: "emuTrigger" + CollectionOnly: true + UseTimeRange: true + Verbose: true + NominalTrigTime: -0.22 + TriggerTolerance: 0.15 + TimeRangeMargin: 35. + } + } + + # Schedule job step(s) for execution by defining the analysis module for this job. + reco: [ BarycenterMatchProducer ] + + stream1: [ out1 ] + + trigger_paths: [reco] + + # "end_paths" is a keyword and contains the modules that do not modify the art::Event; + # i.e., analyzers and output streams. + end_paths: [ stream1 ] + +} From a2ea98b805e0f15f5a647389852e7fc1974bbf43 Mon Sep 17 00:00:00 2001 From: Jack Smedley Date: Wed, 25 Oct 2023 12:16:28 -0500 Subject: [PATCH 02/34] Expand on fcl configurations --- .../OpReco/BarycenterMatchProducer_module.cc | 30 +++--- .../PMT/OpReco/fcl/barycentermatch_config.fcl | 97 +++++++++++++++++++ .../PMT/OpReco/fcl/barycentermatch_data.fcl | 20 +--- .../PMT/OpReco/fcl/barycentermatch_mc.fcl | 20 +--- 4 files changed, 120 insertions(+), 47 deletions(-) create mode 100644 icaruscode/PMT/OpReco/fcl/barycentermatch_config.fcl diff --git a/icaruscode/PMT/OpReco/BarycenterMatchProducer_module.cc b/icaruscode/PMT/OpReco/BarycenterMatchProducer_module.cc index 35ac72842..ff563b0ec 100644 --- a/icaruscode/PMT/OpReco/BarycenterMatchProducer_module.cc +++ b/icaruscode/PMT/OpReco/BarycenterMatchProducer_module.cc @@ -155,8 +155,8 @@ BarycenterMatchProducer::BarycenterMatchProducer(fhicl::ParameterSet const& p) // Call appropriate produces<>() functions here. produces< std::vector >(); -// produces< art::Assns >(); -// produces< art::Assns >(); + produces< art::Assns >(); + produces< art::Assns >(); // produces< art::Assns >(); // Call appropriate consumes<>() for any products to be retrieved by this module. @@ -229,9 +229,9 @@ void BarycenterMatchProducer::produce(art::Event& e) lar::util::TrackTimeInterval const timeIntervals = fTimeIntervalMaker(detProp, detTimings); auto matchInfoVector = std::make_unique< std::vector >(); -// art::PtrMaker< sbn::BarycenterMatch > const makeInfoPtr(e); //What does this do? Only Gianluca can know... -// auto sliceAssns = std::make_unique< art::Assns >(); -// auto flashAssns = std::make_unique< art::Assns >(); + art::PtrMaker< sbn::BarycenterMatch > const makeInfoPtr(e); //What does this do? Only Gianluca can know... + auto sliceAssns = std::make_unique< art::Assns >(); + auto flashAssns = std::make_unique< art::Assns >(); // auto crossAssns = std::make_unique< art::Assns >(); //For cryo... @@ -296,7 +296,7 @@ void BarycenterMatchProducer::produce(art::Event& e) //For slice... for ( int j = 0; j < nSlices; j++ ) { fSliceNum = j; -// const art::Ptr& slicePtr = sliceVector.at(j); + const art::Ptr& slicePtr = sliceVector.at(j); InitializeSlice(); sbn::BarycenterMatch sliceMatchInfo; updateMatchInfo(sliceMatchInfo); @@ -347,8 +347,8 @@ void BarycenterMatchProducer::produce(art::Event& e) //No charge found in slice... if ( sumCharge == 0. ) { fMatchTree->Fill(); -// art::Ptr const infoPtr = makeInfoPtr(matchInfoVector->size()); -// sliceAssns->addSingle(infoPtr, slicePtr); + art::Ptr const infoPtr = makeInfoPtr(matchInfoVector->size()); + sliceAssns->addSingle(infoPtr, slicePtr); matchInfoVector->push_back(std::move(sliceMatchInfo)); if ( fVerbose ) std::cout << "No charge found in Event " << fEvent << " Slice " << j << "! Continuing..." << std::endl; //TODO: Remove print statements later, or maybe keep this one? continue; @@ -386,8 +386,8 @@ void BarycenterMatchProducer::produce(art::Event& e) //No valid match found... if ( matchIndex == -5 ) { fMatchTree->Fill(); -// art::Ptr const infoPtr = makeInfoPtr(matchInfoVector->size()); -// sliceAssns->addSingle(infoPtr, slicePtr); + art::Ptr const infoPtr = makeInfoPtr(matchInfoVector->size()); + sliceAssns->addSingle(infoPtr, slicePtr); matchInfoVector->push_back(std::move(sliceMatchInfo)); if ( fVerbose ) std::cout << "No matching flash found for Event " << fEvent << " Slice " << j << "! Continuing..." << std::endl; //TODO: Remove print statements later, or maybe keep this one? continue; @@ -408,9 +408,9 @@ void BarycenterMatchProducer::produce(art::Event& e) updateMatchInfo(sliceMatchInfo); -// art::Ptr const infoPtr = makeInfoPtr(matchInfoVector->size()); -// sliceAssns->addSingle(infoPtr, slicePtr); -// flashAssns->addSingle(infoPtr, flashPtr); + art::Ptr const infoPtr = makeInfoPtr(matchInfoVector->size()); + sliceAssns->addSingle(infoPtr, slicePtr); + flashAssns->addSingle(infoPtr, flashPtr); // crossAssns->addSingle(slicePtr, flashPtr, infoPtr); matchInfoVector->push_back(std::move(sliceMatchInfo)); fMatchTree->Fill(); @@ -420,8 +420,8 @@ void BarycenterMatchProducer::produce(art::Event& e) } //End for cryo e.put(std::move(matchInfoVector)); -// e.put(std::move(sliceAssns)); -// e.put(std::move(flashAssns)); + e.put(std::move(sliceAssns)); + e.put(std::move(flashAssns)); // e.put(std::move(crossAssns)); } //End produce() diff --git a/icaruscode/PMT/OpReco/fcl/barycentermatch_config.fcl b/icaruscode/PMT/OpReco/fcl/barycentermatch_config.fcl new file mode 100644 index 000000000..fde5a135e --- /dev/null +++ b/icaruscode/PMT/OpReco/fcl/barycentermatch_config.fcl @@ -0,0 +1,97 @@ +BEGIN_PROLOG + +#Common paramters for the barycenter matching +barycentermatch_common_params: +{ + OpFlashLabel: "opflash" + PandoraLabel: "pandoraGaus" + CollectionOnly: true + UseTimeRange: true + Verbose: true + TriggerTolerance: 0.15 + TimeRangeMargin: 35. +} + + +#Parameters specific to data and Monte Carlo separately +###### + +barycentermatch_data_params: +{ + TriggerLabel: "daqTrigger" + NominalTrigTime: -0.6 +} + +barycentermatch_mc_params: +{ + TriggerLabel: "emuTrigger" + NominalTrigTime: -0.22 +} + +###### + + +#Separate configurations for data or MC for running the matching over BOTH cryostats +###### + +data_barycentermatchproducer: +{ + module_type: "icaruscode/PMT/OpReco/BarycenterMatchProducer" + @table::barycentermatch_common_params + @table::barycentermatch_data_params + CryoTags: ["CryoE","CryoW"] +} + +mc_barycentermatchproducer: +{ + module_type: "icaruscode/PMT/OpReco/BarycenterMatchProducer" + @table::barycentermatch_common_params + @table::barycentermatch_mc_params + CryoTags: ["CryoE","CryoW"] +} + +###### + +#Separate configurations for data or MC for running the matching over the east cryostat +###### + +data_barycentermatchproducer_east: +{ + module_type: "icaruscode/PMT/OpReco/BarycenterMatchProducer" + @table::barycentermatch_common_params + @table::barycentermatch_data_params + CryoTags: ["CryoE"] +} + +mc_barycentermatchproducer_east: +{ + module_type: "icaruscode/PMT/OpReco/BarycenterMatchProducer" + @table::barycentermatch_common_params + @table::barycentermatch_mc_params + CryoTags: ["CryoE"] +} + +###### + +#Separate configurations for data or MC for running the matching over the west cryostat +###### + +data_barycentermatchproducer_west: +{ + module_type: "icaruscode/PMT/OpReco/BarycenterMatchProducer" + @table::barycentermatch_common_params + @table::barycentermatch_data_params + CryoTags: ["CryoW"] +} + +mc_barycentermatchproducer_west: +{ + module_type: "icaruscode/PMT/OpReco/BarycenterMatchProducer" + @table::barycentermatch_common_params + @table::barycentermatch_mc_params + CryoTags: ["CryoW"] +} + +###### + +END_PROLOG diff --git a/icaruscode/PMT/OpReco/fcl/barycentermatch_data.fcl b/icaruscode/PMT/OpReco/fcl/barycentermatch_data.fcl index 89e7bf62c..2d4a1f105 100644 --- a/icaruscode/PMT/OpReco/fcl/barycentermatch_data.fcl +++ b/icaruscode/PMT/OpReco/fcl/barycentermatch_data.fcl @@ -1,5 +1,7 @@ # A script to run the producer module: BarycenterMatchProducer +#include "barycentermatch_config.fcl" + #include "services_icarus_simulation.fcl" #include "services_common_icarus.fcl" @@ -51,25 +53,11 @@ physics: { producers: { - BarycenterMatchProducer: - { - module_type: "BarycenterMatchProducer" - # The input parameters - CryoTags: ["CryoE","CryoW"] - OpFlashLabel: "opflash" - PandoraLabel: "pandoraGaus" - TriggerLabel: "daqTrigger" - CollectionOnly: true - UseTimeRange: true - Verbose: true - NominalTrigTime: -0.6 - TriggerTolerance: 0.15 - TimeRangeMargin: 35. - } + barycentermatch: @local::data_barycentermatchproducer } # Schedule job step(s) for execution by defining the analysis module for this job. - reco: [ BarycenterMatchProducer ] + reco: [ barycentermatch ] stream1: [ out1 ] diff --git a/icaruscode/PMT/OpReco/fcl/barycentermatch_mc.fcl b/icaruscode/PMT/OpReco/fcl/barycentermatch_mc.fcl index 4d1e7480f..84278fcb3 100644 --- a/icaruscode/PMT/OpReco/fcl/barycentermatch_mc.fcl +++ b/icaruscode/PMT/OpReco/fcl/barycentermatch_mc.fcl @@ -1,5 +1,7 @@ # A script to run the producer module: BarycenterMatchProducer +#include "barycentermatch_config.fcl" + #include "services_icarus_simulation.fcl" #include "services_common_icarus.fcl" @@ -51,25 +53,11 @@ physics: { producers: { - BarycenterMatchProducer: - { - module_type: "BarycenterMatchProducer" - # The input parameters - CryoTags: ["CryoE","CryoW"] - OpFlashLabel: "opflash" - PandoraLabel: "pandoraGaus" - TriggerLabel: "emuTrigger" - CollectionOnly: true - UseTimeRange: true - Verbose: true - NominalTrigTime: -0.22 - TriggerTolerance: 0.15 - TimeRangeMargin: 35. - } + barycentermatch: @local::mc_barycentermatchproducer } # Schedule job step(s) for execution by defining the analysis module for this job. - reco: [ BarycenterMatchProducer ] + reco: [ barycentermatch ] stream1: [ out1 ] From 989202aaf3ff66a9c8ccd7ad3369f3540342935d Mon Sep 17 00:00:00 2001 From: Jack Smedley Date: Thu, 26 Oct 2023 12:22:36 -0500 Subject: [PATCH 03/34] Move TTree behind a fcl parameter, start cleaning up comments --- .../OpReco/BarycenterMatchProducer_module.cc | 108 ++++++++++-------- .../PMT/OpReco/fcl/barycentermatch_config.fcl | 1 + 2 files changed, 61 insertions(+), 48 deletions(-) diff --git a/icaruscode/PMT/OpReco/BarycenterMatchProducer_module.cc b/icaruscode/PMT/OpReco/BarycenterMatchProducer_module.cc index ff563b0ec..9aa4f7442 100644 --- a/icaruscode/PMT/OpReco/BarycenterMatchProducer_module.cc +++ b/icaruscode/PMT/OpReco/BarycenterMatchProducer_module.cc @@ -5,6 +5,11 @@ // // Generated at Sun Oct 22 14:43:16 2023 by John Smedley using cetskelgen // from version . +// +// @file icaruscode/PMT/OpReco/BarycenterMatchProducer_module.cc +// @brief Producer to match Pandora slices to their best match OpFlash by minimizing barycetner distance, as well as compare slices to the triggering OpFlash +// @author Jack Smedley ( jsmedley@fnal.gov ) +// //////////////////////////////////////////////////////////////////////// #include "art/Framework/Core/EDProducer.h" @@ -75,12 +80,12 @@ class BarycenterMatchProducer : public art::EDProducer { private: // Declare member data here. - void InitializeSlice(); - double CentroidOverlap(double center1, double center2, double width1, double width2); - double CalculateAsymmetry(art::Ptr flash, int cryo); - void updateChargeVars(double sumCharge, TVector3 sumPos, TVector3 sumPosSqr, double triggerFlashCenter); - void updateFlashVars(art::Ptr flash, double shift, double firstHit); - void updateMatchInfo(sbn::BarycenterMatch& matchInfo); + void InitializeSlice(); ///< Re-initialize all slice-level data members + double CentroidOverlap(double center1, double center2, double width1, double width2); ///< Return overlap between charge and light centroids OR distance apart if no overlap + double CalculateAsymmetry(art::Ptr flash, int cryo); ///< Return the east-west asymmetry of PEs in a given OpFlash + void updateChargeVars(double sumCharge, TVector3 sumPos, TVector3 sumPosSqr, double triggerFlashCenter); ///< Update slice-level data members with charge and trigger match info + void updateFlashVars(art::Ptr flash, double shift, double firstHit); ///< Update slice-level data members with best match info + void updateMatchInfo(sbn::BarycenterMatch& matchInfo); ///< Update match product with slice-level data members // Input parameters std::vector fCryoTags; ///< Labels for each cryostat @@ -89,7 +94,8 @@ class BarycenterMatchProducer : public art::EDProducer { std::string fTriggerLabel; ///< Label for trigger product bool fCollectionOnly; ///< Only use TPC spacepoints from the collection plane bool fUseTimeRange; ///< Reject impossible matches based on allowed time range of TPC hits relative to trigger - bool fVerbose; ///< Print extra info, fcl input + bool fVerbose; ///< Print extra info + bool fFillMatchTree; ///< Fill an output TTree in the supplemental file double fNominalTrigTime; ///< Typical time of triggering flash, EYEBALLED (us) double fTriggerTolerance; ///< Spread of triggering flash times, EYEBALLED (us) double fTimeRangeMargin; ///< Symmetric acceptable margin for allowed time range of TPC hits (us) @@ -99,6 +105,7 @@ class BarycenterMatchProducer : public art::EDProducer { int fEvent; ///< Number of the event being processed int fCryo; ///< Cryostat this event occured in int fSliceNum; ///< Number of slice in the event + // Slice-level data members double fChargeT0; ///< Start time for cathode-crossing PFPs, not always available (us) double fChargeTotal; ///< Total charge in slice double fChargeCenterXGlobal; ///< Weighted mean X position of spacepoints (cm) @@ -144,6 +151,7 @@ BarycenterMatchProducer::BarycenterMatchProducer(fhicl::ParameterSet const& p) fCollectionOnly(p.get("CollectionOnly")), fUseTimeRange(p.get("UseTimeRange")), fVerbose(p.get("Verbose")), + fFillMatchTree(p.get("FillMatchTree")), fNominalTrigTime(p.get("NominalTrigTime")), fTriggerTolerance(p.get("TriggerTolerance")), fTimeRangeMargin(p.get("TimeRangeMargin")), @@ -160,44 +168,48 @@ BarycenterMatchProducer::BarycenterMatchProducer(fhicl::ParameterSet const& p) // produces< art::Assns >(); // Call appropriate consumes<>() for any products to be retrieved by this module. - art::ServiceHandle tfs; - fMatchTree = tfs->make("matchTree","TPC Slice - OpFlash Matching Analysis"); - - //Event Info - fMatchTree->Branch("run", &fRun, "run/I" ); - fMatchTree->Branch("event", &fEvent, "event/I" ); - fMatchTree->Branch("cryo", &fCryo, "cryo/I" ); - fMatchTree->Branch("sliceNum", &fSliceNum, "sliceNum/I" ); - - //Charge Info - fMatchTree->Branch("chargeT0", &fChargeT0, "chargeT0/d" ); - fMatchTree->Branch("chargeTotal", &fChargeTotal, "chargeTotal/d" ); - fMatchTree->Branch("chargeCenterXGlobal", &fChargeCenterXGlobal, "chargeCenterXGlobal/d"); - fMatchTree->Branch("chargeCenterXLocal", &fChargeCenterXLocal, "chargeCenterXLocal/d" ); - fMatchTree->Branch("chargeCenterY", &fChargeCenterY, "chargeCenterY/d" ); - fMatchTree->Branch("chargeCenterZ", &fChargeCenterZ, "chargeCenterZ/d" ); - fMatchTree->Branch("chargeWidthX", &fChargeWidthX, "chargeWidthX/d" ); - fMatchTree->Branch("chargeWidthY", &fChargeWidthY, "chargeWidthY/d" ); - fMatchTree->Branch("chargeWidthZ", &fChargeWidthZ, "chargeWidthZ/d" ); - - //Matched Flash Info - fMatchTree->Branch("flashFirstHit", &fFlashFirstHit, "flashFirstHit/d" ); - fMatchTree->Branch("flashTime", &fFlashTime, "flashTime/d" ); - fMatchTree->Branch("flashPEs", &fFlashPEs, "flashPEs/d" ); - fMatchTree->Branch("flashAsymmetry", &fFlashAsymmetry, "flashAsymmetry/d" ); - fMatchTree->Branch("flashCenterY", &fFlashCenterY, "flashCenterY/d" ); - fMatchTree->Branch("flashCenterZ", &fFlashCenterZ, "flashCenterZ/d" ); - fMatchTree->Branch("flashWidthY", &fFlashWidthY, "flashWidthY/d" ); - fMatchTree->Branch("flashWidthZ", &fFlashWidthZ, "flashWidthZ/d" ); - - //Match Quality Info - fMatchTree->Branch("deltaT", &fDeltaT, "deltaT/d" ); - fMatchTree->Branch("deltaY", &fDeltaY, "deltaY/d" ); - fMatchTree->Branch("deltaZ", &fDeltaZ, "deltaZ/d" ); - fMatchTree->Branch("radius", &fRadius, "radius/d" ); - fMatchTree->Branch("overlapY", &fOverlapY, "overlapY/d" ); - fMatchTree->Branch("overlapZ", &fOverlapZ, "overlapZ/d" ); - fMatchTree->Branch("deltaZ_Trigger", &fDeltaZ_Trigger, "deltaZ_Trigger/d" ); + + if ( fFillMatchTree ) { + art::ServiceHandle tfs; + fMatchTree = tfs->make("matchTree","TPC Slice - OpFlash Matching Analysis"); + + //Event Info + fMatchTree->Branch("run", &fRun, "run/I" ); + fMatchTree->Branch("event", &fEvent, "event/I" ); + fMatchTree->Branch("cryo", &fCryo, "cryo/I" ); + fMatchTree->Branch("sliceNum", &fSliceNum, "sliceNum/I" ); + + //Charge Info + fMatchTree->Branch("chargeT0", &fChargeT0, "chargeT0/d" ); + fMatchTree->Branch("chargeTotal", &fChargeTotal, "chargeTotal/d" ); + fMatchTree->Branch("chargeCenterXGlobal", &fChargeCenterXGlobal, "chargeCenterXGlobal/d"); + fMatchTree->Branch("chargeCenterXLocal", &fChargeCenterXLocal, "chargeCenterXLocal/d" ); + fMatchTree->Branch("chargeCenterY", &fChargeCenterY, "chargeCenterY/d" ); + fMatchTree->Branch("chargeCenterZ", &fChargeCenterZ, "chargeCenterZ/d" ); + fMatchTree->Branch("chargeWidthX", &fChargeWidthX, "chargeWidthX/d" ); + fMatchTree->Branch("chargeWidthY", &fChargeWidthY, "chargeWidthY/d" ); + fMatchTree->Branch("chargeWidthZ", &fChargeWidthZ, "chargeWidthZ/d" ); + + //Matched Flash Info + fMatchTree->Branch("flashFirstHit", &fFlashFirstHit, "flashFirstHit/d" ); + fMatchTree->Branch("flashTime", &fFlashTime, "flashTime/d" ); + fMatchTree->Branch("flashPEs", &fFlashPEs, "flashPEs/d" ); + fMatchTree->Branch("flashAsymmetry", &fFlashAsymmetry, "flashAsymmetry/d" ); + fMatchTree->Branch("flashCenterY", &fFlashCenterY, "flashCenterY/d" ); + fMatchTree->Branch("flashCenterZ", &fFlashCenterZ, "flashCenterZ/d" ); + fMatchTree->Branch("flashWidthY", &fFlashWidthY, "flashWidthY/d" ); + fMatchTree->Branch("flashWidthZ", &fFlashWidthZ, "flashWidthZ/d" ); + + //Match Quality Info + fMatchTree->Branch("deltaT", &fDeltaT, "deltaT/d" ); + fMatchTree->Branch("deltaY", &fDeltaY, "deltaY/d" ); + fMatchTree->Branch("deltaZ", &fDeltaZ, "deltaZ/d" ); + fMatchTree->Branch("radius", &fRadius, "radius/d" ); + fMatchTree->Branch("overlapY", &fOverlapY, "overlapY/d" ); + fMatchTree->Branch("overlapZ", &fOverlapZ, "overlapZ/d" ); + fMatchTree->Branch("deltaZ_Trigger", &fDeltaZ_Trigger, "deltaZ_Trigger/d" ); + + } //End MatchTree } @@ -346,7 +358,7 @@ void BarycenterMatchProducer::produce(art::Event& e) //No charge found in slice... if ( sumCharge == 0. ) { - fMatchTree->Fill(); + if ( fFillMatchTree ) fMatchTree->Fill(); art::Ptr const infoPtr = makeInfoPtr(matchInfoVector->size()); sliceAssns->addSingle(infoPtr, slicePtr); matchInfoVector->push_back(std::move(sliceMatchInfo)); @@ -385,7 +397,7 @@ void BarycenterMatchProducer::produce(art::Event& e) //No valid match found... if ( matchIndex == -5 ) { - fMatchTree->Fill(); + if ( fFillMatchTree ) fMatchTree->Fill(); art::Ptr const infoPtr = makeInfoPtr(matchInfoVector->size()); sliceAssns->addSingle(infoPtr, slicePtr); matchInfoVector->push_back(std::move(sliceMatchInfo)); @@ -413,7 +425,7 @@ void BarycenterMatchProducer::produce(art::Event& e) flashAssns->addSingle(infoPtr, flashPtr); // crossAssns->addSingle(slicePtr, flashPtr, infoPtr); matchInfoVector->push_back(std::move(sliceMatchInfo)); - fMatchTree->Fill(); + if ( fFillMatchTree ) fMatchTree->Fill(); } //End for slice diff --git a/icaruscode/PMT/OpReco/fcl/barycentermatch_config.fcl b/icaruscode/PMT/OpReco/fcl/barycentermatch_config.fcl index fde5a135e..84ef86c70 100644 --- a/icaruscode/PMT/OpReco/fcl/barycentermatch_config.fcl +++ b/icaruscode/PMT/OpReco/fcl/barycentermatch_config.fcl @@ -8,6 +8,7 @@ barycentermatch_common_params: CollectionOnly: true UseTimeRange: true Verbose: true + FillMatchTree: true TriggerTolerance: 0.15 TimeRangeMargin: 35. } From 06b459844250ad796ba8643bf182c0e1d1a2aa21 Mon Sep 17 00:00:00 2001 From: Jack Smedley Date: Thu, 26 Oct 2023 17:48:49 -0500 Subject: [PATCH 04/34] Make cryo loop more generic, don't shift data times here, generally clean up --- .../OpReco/BarycenterMatchProducer_module.cc | 99 +++++++++---------- .../PMT/OpReco/fcl/barycentermatch_config.fcl | 16 +-- 2 files changed, 53 insertions(+), 62 deletions(-) diff --git a/icaruscode/PMT/OpReco/BarycenterMatchProducer_module.cc b/icaruscode/PMT/OpReco/BarycenterMatchProducer_module.cc index 9aa4f7442..17c47c203 100644 --- a/icaruscode/PMT/OpReco/BarycenterMatchProducer_module.cc +++ b/icaruscode/PMT/OpReco/BarycenterMatchProducer_module.cc @@ -7,7 +7,7 @@ // from version . // // @file icaruscode/PMT/OpReco/BarycenterMatchProducer_module.cc -// @brief Producer to match Pandora slices to their best match OpFlash by minimizing barycetner distance, as well as compare slices to the triggering OpFlash +// @brief Producer to match Pandora slices to their best match OpFlash by minimizing barycenter distance, as well as compare slices to the triggering OpFlash // @author Jack Smedley ( jsmedley@fnal.gov ) // //////////////////////////////////////////////////////////////////////// @@ -84,11 +84,11 @@ class BarycenterMatchProducer : public art::EDProducer { double CentroidOverlap(double center1, double center2, double width1, double width2); ///< Return overlap between charge and light centroids OR distance apart if no overlap double CalculateAsymmetry(art::Ptr flash, int cryo); ///< Return the east-west asymmetry of PEs in a given OpFlash void updateChargeVars(double sumCharge, TVector3 sumPos, TVector3 sumPosSqr, double triggerFlashCenter); ///< Update slice-level data members with charge and trigger match info - void updateFlashVars(art::Ptr flash, double shift, double firstHit); ///< Update slice-level data members with best match info + void updateFlashVars(art::Ptr flash, double firstHit); ///< Update slice-level data members with best match info void updateMatchInfo(sbn::BarycenterMatch& matchInfo); ///< Update match product with slice-level data members // Input parameters - std::vector fCryoTags; ///< Labels for each cryostat + std::vector fInputTags; ///< Suffix added onto fOpFlashLabel and fPandoraLabel, used by ICARUS for separate cryostat labels but could be empty std::string fOpFlashLabel; ///< Label for PMT reconstruction products std::string fPandoraLabel; ///< Label for Pandora output products std::string fTriggerLabel; ///< Label for trigger product @@ -125,11 +125,11 @@ class BarycenterMatchProducer : public art::EDProducer { double fFlashWidthZ; ///< Weighted standard deviation of Z postion of hit PMTs (cm) double fDeltaT; ///< | Matched flash time - charge T0 | when available (us) double fDeltaY; ///< | Matched flash Y center - charge Y center | (cm) - double fDeltaZ; ///< | Matched flash Z cetner - charge Z center | (cm) + double fDeltaZ; ///< | Matched flash Z center - charge Z center | (cm) double fRadius; ///< Hypotenuse of DeltaY and DeltaZ, PARAMETER MINIMIZED BY MATCHING (cm) double fOverlapY; ///< Spacial overlap of flash and charge centroids in Y [>0] OR distance apart if no overlap [<0] (cm) double fOverlapZ; ///< Spacial overlap of flash and charge centroids in Z [>0] OR distance apart if no overlap [<0] (cm) - double fDeltaZ_Trigger; ///< | Triggering flash Z cetner - charge Z center | (cm) + double fDeltaZ_Trigger; ///< | Triggering flash Z center - charge Z center | (cm) TTree* fMatchTree; ///< Tree to store all match information @@ -144,7 +144,7 @@ class BarycenterMatchProducer : public art::EDProducer { BarycenterMatchProducer::BarycenterMatchProducer(fhicl::ParameterSet const& p) : EDProducer{p}, // More initializers here. - fCryoTags(p.get>("CryoTags")), + fInputTags(p.get>("InputTags")), fOpFlashLabel(p.get("OpFlashLabel")), fPandoraLabel(p.get("PandoraLabel")), fTriggerLabel(p.get("TriggerLabel")), @@ -165,7 +165,6 @@ BarycenterMatchProducer::BarycenterMatchProducer(fhicl::ParameterSet const& p) produces< std::vector >(); produces< art::Assns >(); produces< art::Assns >(); -// produces< art::Assns >(); // Call appropriate consumes<>() for any products to be retrieved by this module. @@ -220,86 +219,83 @@ void BarycenterMatchProducer::produce(art::Event& e) fRun = e.run(); const bool isData = e.isRealData(); + //Fetch trigger info and if MC check whether this event triggered art::Handle> triggerHandle; e.getByLabel(fTriggerLabel, triggerHandle); raw::Trigger trigger; - double shiftFactor = 0.; + double triggerWithinGate = 0.; bool triggeredEvt = false; if ( triggerHandle.isValid() && triggerHandle->size() == 1 ) { trigger = (*triggerHandle).at(0); if ( trigger.TriggerTime() >= 0 ) { - shiftFactor = trigger.TriggerTime() - trigger.BeamGateTime(); + triggerWithinGate = trigger.TriggerTime() - trigger.BeamGateTime(); triggeredEvt = true; } - if ( fVerbose ) std::cout << std::endl << "Valid trigger found. Trigger time: " << trigger.TriggerTime() << ", Beam gate time: " << trigger.BeamGateTime() << ", Difference: " << shiftFactor << ", Is data? " << isData << std::endl; + if ( fVerbose ) std::cout << "Valid trigger product found. Trigger time: " << trigger.TriggerTime() << ", Beam gate time: " << trigger.BeamGateTime() << ", Difference: " << triggerWithinGate << std::endl; } - else if ( fVerbose ) std::cout << std::endl << "~~~~~~~~~~~~~ No valid trigger found for this event! ~~~~~~~~~~~~~" << std::endl; + else if ( fVerbose ) std::cout << "No valid trigger product found for this event!" << std::endl; + //Infstracture for checking allowed time range of a slice microseconds margin(fTimeRangeMargin); detinfo::DetectorTimings const detTimings{ fDetClocks.DataFor(e) }; detinfo::DetectorPropertiesData const& detProp { fDetProp.DataFor(e, detTimings.clockData()) }; lar::util::TrackTimeInterval const timeIntervals = fTimeIntervalMaker(detProp, detTimings); + //Initialize new data products auto matchInfoVector = std::make_unique< std::vector >(); - art::PtrMaker< sbn::BarycenterMatch > const makeInfoPtr(e); //What does this do? Only Gianluca can know... + art::PtrMaker< sbn::BarycenterMatch > const makeInfoPtr(e); auto sliceAssns = std::make_unique< art::Assns >(); auto flashAssns = std::make_unique< art::Assns >(); -// auto crossAssns = std::make_unique< art::Assns >(); - //For cryo... - for ( const std::string cryoTag : fCryoTags ) { + //For InputTag... + for ( const std::string inputTag : fInputTags ) { //East-->0, West-->1 - fCryo = ( cryoTag.find("W") != std::string::npos ) ? 1 : 0; + fCryo = ( inputTag.find("W") != std::string::npos ) ? 1 : 0; /* ~~~~~~~~~~~~~~~~~~~~ Flash Section * * Here we gather the OpFlashes found in this cryostat and their OpHits - * We iterate through the flashes to identify a triggering flash and the earliest time associated with each flash + * We iterate through the flashes to identify a triggering flash */ - //Fetch the flashes and their associated hits; pointer vector needed for assns + //Fetch the flashes and their associated hits, pointer vector needed for generating associations art::Handle> flashHandle; - e.getByLabel(fOpFlashLabel + cryoTag, flashHandle); - art::FindMany fmOpHits(flashHandle, e, fOpFlashLabel + cryoTag); + e.getByLabel(fOpFlashLabel + inputTag, flashHandle); + art::FindMany fmOpHits(flashHandle, e, fOpFlashLabel + inputTag); std::vector> flashVector; art::fill_ptr_vector(flashVector, flashHandle); int nFlashes = (*flashHandle).size(); double triggerFlashCenter = -9999.; - double flashTime_Trigger, flashTime_Beam; + double flashTime_Trigger; //For flash... for ( int i = 0; i < nFlashes; i++ ) { const recob::OpFlash &flash = (*flashHandle).at(i); - flashTime_Trigger = flash.Time(); - flashTime_Beam = flash.Time(); - if ( isData ) flashTime_Beam += shiftFactor; - else flashTime_Trigger += -1.*shiftFactor; - //Is this a triggering flash? + flashTime_Trigger = flash.Time(); + if ( !isData ) flashTime_Trigger += -1.*triggerWithinGate; if ( triggeredEvt && abs(flashTime_Trigger - fNominalTrigTime) < fTriggerTolerance ) triggerFlashCenter = flash.ZCenter(); - if ( fVerbose ) std::cout << std::endl << "Flash time wrt trigger: " << flashTime_Trigger << ", Flash time wrt beam gate: " << flashTime_Beam << std::endl; //TODO: Remove print statements later + } //End for flash - } // End for flash - - if ( fVerbose ) std::cout << "Event: " << fEvent << ", Cryo: " << cryoTag << ", nFlashes: " << nFlashes << ", Triggering flash center: " << triggerFlashCenter << std::endl; //TODO: Remove print statements later + if ( fVerbose ) std::cout << "Event: " << fEvent << ", Cryo: " << inputTag << ", nFlashes: " << nFlashes << ", Triggering flash center: " << triggerFlashCenter << std::endl; /* ~~~~~~~~~~~~~~~~~~~~ TPC Section * Here we start by gathering the Slices in the event * For each slice, the charge centroid is first calculated * Then we iterate through flashes to identify the best match flash - * If a triggering flash was found earlier, the barycetner distance to the triggering flash is also stored + * If a triggering flash was found in this cyrostat, the barycenter distance to the triggering flash is also stored */ - //Fetch slices, TPC hits, and PFPs; pointer vector needed for assns + //Fetch slices, TPC hits, and PFPs; pointer vector needed for generating associations art::Handle> sliceHandle; - e.getByLabel(fPandoraLabel + cryoTag, sliceHandle); - art::FindManyP fmTPCHits(sliceHandle, e, fPandoraLabel + cryoTag); - art::FindManyP fmPFPs(sliceHandle, e, fPandoraLabel + cryoTag); + e.getByLabel(fPandoraLabel + inputTag, sliceHandle); + art::FindManyP fmTPCHits(sliceHandle, e, fPandoraLabel + inputTag); + art::FindManyP fmPFPs(sliceHandle, e, fPandoraLabel + inputTag); std::vector> sliceVector; art::fill_ptr_vector(sliceVector, sliceHandle); @@ -315,7 +311,7 @@ void BarycenterMatchProducer::produce(art::Event& e) const std::vector> &tpcHitsVec = fmTPCHits.at(j); const std::vector> &pfpsVec = fmPFPs.at(j); - art::FindOne f1SpacePoint(tpcHitsVec, e, fPandoraLabel + cryoTag); + art::FindOne f1SpacePoint(tpcHitsVec, e, fPandoraLabel + inputTag); int nHits = tpcHitsVec.size(); int nPFPs = pfpsVec.size(); @@ -326,10 +322,9 @@ void BarycenterMatchProducer::produce(art::Event& e) //Retrieve Pandora's T0 for this slice if available, same for every PFP in slice so we only need one if ( nPFPs != 0 ) { - art::FindOne f1T0( {pfpsVec.at(0)}, e, fPandoraLabel + cryoTag); + art::FindOne f1T0( {pfpsVec.at(0)}, e, fPandoraLabel + inputTag); if ( f1T0.at(0).isValid() ) { fChargeT0 = f1T0.at(0).ref().Time() / 1e3; - if ( isData ) fChargeT0 += shiftFactor; } } @@ -362,7 +357,7 @@ void BarycenterMatchProducer::produce(art::Event& e) art::Ptr const infoPtr = makeInfoPtr(matchInfoVector->size()); sliceAssns->addSingle(infoPtr, slicePtr); matchInfoVector->push_back(std::move(sliceMatchInfo)); - if ( fVerbose ) std::cout << "No charge found in Event " << fEvent << " Slice " << j << "! Continuing..." << std::endl; //TODO: Remove print statements later, or maybe keep this one? + if ( fVerbose ) std::cout << "No charge found in Event: " << fEvent << " Slice: " << j << "! Continuing..." << std::endl; continue; } @@ -378,6 +373,7 @@ void BarycenterMatchProducer::produce(art::Event& e) for ( int m = 0; m < nFlashes; m++ ) { const recob::OpFlash &flash = (*flashHandle).at(m); + //Skip over flashes that are very out of time with respect to the slice if ( fUseTimeRange && rangeIsValid ) { electronics_time eTime (flash.AbsTime()); if ( !timeRange.contains(eTime, margin) ) continue; @@ -401,40 +397,35 @@ void BarycenterMatchProducer::produce(art::Event& e) art::Ptr const infoPtr = makeInfoPtr(matchInfoVector->size()); sliceAssns->addSingle(infoPtr, slicePtr); matchInfoVector->push_back(std::move(sliceMatchInfo)); - if ( fVerbose ) std::cout << "No matching flash found for Event " << fEvent << " Slice " << j << "! Continuing..." << std::endl; //TODO: Remove print statements later, or maybe keep this one? + if ( fVerbose ) std::cout << "No matching flash found for Event: " << fEvent << " Slice: " << j << "! Continuing..." << std::endl; continue; } - //Update match variables + //Best match flash pointer const art::Ptr& flashPtr = flashVector.at(matchIndex); + //Find time of first OpHit in matched flash const std::vector &opHitsVec = fmOpHits.at(matchIndex); double minTime = 1e6; - //For OpHit... - for (const recob::OpHit *opHit : opHitsVec ) { - if ( opHit->PeakTime() < minTime ) minTime = opHit->PeakTime(); //TODO: Rise time or peak time? - } //End for OpHit - if ( isData ) minTime += shiftFactor; + for (const recob::OpHit *opHit : opHitsVec ) { if ( opHit->PeakTime() < minTime ) minTime = opHit->PeakTime(); } - updateFlashVars(flashPtr, (isData ? shiftFactor : 0.), minTime); + //Update match info + updateFlashVars(flashPtr, minTime); updateMatchInfo(sliceMatchInfo); - - art::Ptr const infoPtr = makeInfoPtr(matchInfoVector->size()); sliceAssns->addSingle(infoPtr, slicePtr); flashAssns->addSingle(infoPtr, flashPtr); -// crossAssns->addSingle(slicePtr, flashPtr, infoPtr); matchInfoVector->push_back(std::move(sliceMatchInfo)); if ( fFillMatchTree ) fMatchTree->Fill(); } //End for slice - } //End for cryo + } //End for InputTag + //Store new products at the end of the event e.put(std::move(matchInfoVector)); e.put(std::move(sliceAssns)); e.put(std::move(flashAssns)); -// e.put(std::move(crossAssns)); } //End produce() @@ -510,8 +501,8 @@ void BarycenterMatchProducer::updateChargeVars(double sumCharge, TVector3 sumPos } //End updateChargeVars() -void BarycenterMatchProducer::updateFlashVars(art::Ptr flash, double shift, double firstHit) { - double matchedTime = flash->Time() + shift; +void BarycenterMatchProducer::updateFlashVars(art::Ptr flash, double firstHit) { + double matchedTime = flash->Time(); double matchedYCenter = flash->YCenter(); double matchedZCenter = flash->ZCenter(); double matchedYWidth = flash->YWidth(); diff --git a/icaruscode/PMT/OpReco/fcl/barycentermatch_config.fcl b/icaruscode/PMT/OpReco/fcl/barycentermatch_config.fcl index 84ef86c70..245472aee 100644 --- a/icaruscode/PMT/OpReco/fcl/barycentermatch_config.fcl +++ b/icaruscode/PMT/OpReco/fcl/barycentermatch_config.fcl @@ -7,8 +7,8 @@ barycentermatch_common_params: PandoraLabel: "pandoraGaus" CollectionOnly: true UseTimeRange: true - Verbose: true - FillMatchTree: true + Verbose: false + FillMatchTree: flase TriggerTolerance: 0.15 TimeRangeMargin: 35. } @@ -40,7 +40,7 @@ data_barycentermatchproducer: module_type: "icaruscode/PMT/OpReco/BarycenterMatchProducer" @table::barycentermatch_common_params @table::barycentermatch_data_params - CryoTags: ["CryoE","CryoW"] + InputTags: ["CryoE","CryoW"] } mc_barycentermatchproducer: @@ -48,7 +48,7 @@ mc_barycentermatchproducer: module_type: "icaruscode/PMT/OpReco/BarycenterMatchProducer" @table::barycentermatch_common_params @table::barycentermatch_mc_params - CryoTags: ["CryoE","CryoW"] + InputTags: ["CryoE","CryoW"] } ###### @@ -61,7 +61,7 @@ data_barycentermatchproducer_east: module_type: "icaruscode/PMT/OpReco/BarycenterMatchProducer" @table::barycentermatch_common_params @table::barycentermatch_data_params - CryoTags: ["CryoE"] + InputTags: ["CryoE"] } mc_barycentermatchproducer_east: @@ -69,7 +69,7 @@ mc_barycentermatchproducer_east: module_type: "icaruscode/PMT/OpReco/BarycenterMatchProducer" @table::barycentermatch_common_params @table::barycentermatch_mc_params - CryoTags: ["CryoE"] + InputTags: ["CryoE"] } ###### @@ -82,7 +82,7 @@ data_barycentermatchproducer_west: module_type: "icaruscode/PMT/OpReco/BarycenterMatchProducer" @table::barycentermatch_common_params @table::barycentermatch_data_params - CryoTags: ["CryoW"] + InputTags: ["CryoW"] } mc_barycentermatchproducer_west: @@ -90,7 +90,7 @@ mc_barycentermatchproducer_west: module_type: "icaruscode/PMT/OpReco/BarycenterMatchProducer" @table::barycentermatch_common_params @table::barycentermatch_mc_params - CryoTags: ["CryoW"] + InputTags: ["CryoW"] } ###### From 003aea6608d626c8f63969b5a953c3b75d84f485 Mon Sep 17 00:00:00 2001 From: Jack Smedley Date: Thu, 26 Oct 2023 17:53:57 -0500 Subject: [PATCH 05/34] Fix typo --- icaruscode/PMT/OpReco/BarycenterMatchProducer_module.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/icaruscode/PMT/OpReco/BarycenterMatchProducer_module.cc b/icaruscode/PMT/OpReco/BarycenterMatchProducer_module.cc index 17c47c203..ef73c6c7d 100644 --- a/icaruscode/PMT/OpReco/BarycenterMatchProducer_module.cc +++ b/icaruscode/PMT/OpReco/BarycenterMatchProducer_module.cc @@ -235,7 +235,7 @@ void BarycenterMatchProducer::produce(art::Event& e) } else if ( fVerbose ) std::cout << "No valid trigger product found for this event!" << std::endl; - //Infstracture for checking allowed time range of a slice + //Infrastructure for checking allowed time range of a slice microseconds margin(fTimeRangeMargin); detinfo::DetectorTimings const detTimings{ fDetClocks.DataFor(e) }; detinfo::DetectorPropertiesData const& detProp { fDetProp.DataFor(e, detTimings.clockData()) }; From a64b8b7993ca27d990e64b273c86c55a5423e725 Mon Sep 17 00:00:00 2001 From: Jack Smedley Date: Thu, 26 Oct 2023 18:54:19 -0500 Subject: [PATCH 06/34] Fix sbnobj naming convention --- .../OpReco/BarycenterMatchProducer_module.cc | 32 +++++++++---------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/icaruscode/PMT/OpReco/BarycenterMatchProducer_module.cc b/icaruscode/PMT/OpReco/BarycenterMatchProducer_module.cc index ef73c6c7d..198fbbb23 100644 --- a/icaruscode/PMT/OpReco/BarycenterMatchProducer_module.cc +++ b/icaruscode/PMT/OpReco/BarycenterMatchProducer_module.cc @@ -526,22 +526,22 @@ void BarycenterMatchProducer::updateFlashVars(art::Ptr flash, do void BarycenterMatchProducer::updateMatchInfo(sbn::BarycenterMatch& matchInfo) { - matchInfo.fChargeTotal = fChargeTotal; - matchInfo.fChargeCenterXLocal = fChargeCenterXLocal; - matchInfo.fChargeCenter = {fChargeCenterXGlobal, fChargeCenterY, fChargeCenterZ}; - matchInfo.fChargeWidth = {fChargeWidthX, fChargeWidthY, fChargeWidthZ}; - matchInfo.fFlashFirstHit = fFlashFirstHit; - matchInfo.fFlashTime = fFlashTime; - matchInfo.fFlashPEs = fFlashPEs; - matchInfo.fFlashCenter = {-9999., fFlashCenterY, fFlashCenterZ}; - matchInfo.fFlashWidth = {-9999., fFlashWidthY, fFlashWidthZ}; - matchInfo.fDeltaT = fDeltaT; - matchInfo.fDeltaY = fDeltaY; - matchInfo.fDeltaZ = fDeltaZ; - matchInfo.fRadius = fRadius; - matchInfo.fOverlapY = fOverlapY; - matchInfo.fOverlapZ = fOverlapZ; - matchInfo.fDeltaZ_Trigger = fDeltaZ_Trigger; + matchInfo.chargeTotal = fChargeTotal; + matchInfo.chargeCenterXLocal = fChargeCenterXLocal; + matchInfo.chargeCenter = {fChargeCenterXGlobal, fChargeCenterY, fChargeCenterZ}; + matchInfo.chargeWidth = {fChargeWidthX, fChargeWidthY, fChargeWidthZ}; + matchInfo.flashFirstHit = fFlashFirstHit; + matchInfo.flashTime = fFlashTime; + matchInfo.flashPEs = fFlashPEs; + matchInfo.flashCenter = {-9999., fFlashCenterY, fFlashCenterZ}; + matchInfo.flashWidth = {-9999., fFlashWidthY, fFlashWidthZ}; + matchInfo.deltaT = fDeltaT; + matchInfo.deltaY = fDeltaY; + matchInfo.deltaZ = fDeltaZ; + matchInfo.radius = fRadius; + matchInfo.overlapY = fOverlapY; + matchInfo.overlapZ = fOverlapZ; + matchInfo.deltaZ_Trigger = fDeltaZ_Trigger; } //End updateMatchInfo() From 4c3cc1248657af03a2bb183ec6b63eadf871d51e Mon Sep 17 00:00:00 2001 From: Jack Smedley Date: Fri, 27 Oct 2023 12:38:47 -0500 Subject: [PATCH 07/34] Update fcls --- icaruscode/PMT/OpReco/fcl/barycentermatch_config.fcl | 2 +- icaruscode/PMT/OpReco/fcl/barycentermatch_data.fcl | 5 +++-- icaruscode/PMT/OpReco/fcl/barycentermatch_mc.fcl | 5 +++-- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/icaruscode/PMT/OpReco/fcl/barycentermatch_config.fcl b/icaruscode/PMT/OpReco/fcl/barycentermatch_config.fcl index 245472aee..f1746102f 100644 --- a/icaruscode/PMT/OpReco/fcl/barycentermatch_config.fcl +++ b/icaruscode/PMT/OpReco/fcl/barycentermatch_config.fcl @@ -8,7 +8,7 @@ barycentermatch_common_params: CollectionOnly: true UseTimeRange: true Verbose: false - FillMatchTree: flase + FillMatchTree: false TriggerTolerance: 0.15 TimeRangeMargin: 35. } diff --git a/icaruscode/PMT/OpReco/fcl/barycentermatch_data.fcl b/icaruscode/PMT/OpReco/fcl/barycentermatch_data.fcl index 2d4a1f105..4442b00f8 100644 --- a/icaruscode/PMT/OpReco/fcl/barycentermatch_data.fcl +++ b/icaruscode/PMT/OpReco/fcl/barycentermatch_data.fcl @@ -53,11 +53,12 @@ physics: { producers: { - barycentermatch: @local::data_barycentermatchproducer + barycentermatchCryoE: @local::data_barycentermatchproducer_east + barycentermatchCryoW: @local::data_barycentermatchproducer_west } # Schedule job step(s) for execution by defining the analysis module for this job. - reco: [ barycentermatch ] + reco: [ barycentermatchCryoE, barycentermatchCryoW ] stream1: [ out1 ] diff --git a/icaruscode/PMT/OpReco/fcl/barycentermatch_mc.fcl b/icaruscode/PMT/OpReco/fcl/barycentermatch_mc.fcl index 84278fcb3..ea7366e27 100644 --- a/icaruscode/PMT/OpReco/fcl/barycentermatch_mc.fcl +++ b/icaruscode/PMT/OpReco/fcl/barycentermatch_mc.fcl @@ -53,11 +53,12 @@ physics: { producers: { - barycentermatch: @local::mc_barycentermatchproducer + barycentermatchCryoE: @local::mc_barycentermatchproducer_east + barycentermatchCryoW: @local::mc_barycentermatchproducer_west } # Schedule job step(s) for execution by defining the analysis module for this job. - reco: [ barycentermatch ] + reco: [ barycentermatchCryoE, barycentermatchCryoW ] stream1: [ out1 ] From 97f63af594ce20c1338547178f9a75bc96e82187 Mon Sep 17 00:00:00 2001 From: JackSmedley <85366220+JackSmedley@users.noreply.github.com> Date: Fri, 17 Nov 2023 13:07:33 -0600 Subject: [PATCH 08/34] Replace getByLabel for trigger Co-authored-by: Gianluca Petrillo --- icaruscode/PMT/OpReco/BarycenterMatchProducer_module.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/icaruscode/PMT/OpReco/BarycenterMatchProducer_module.cc b/icaruscode/PMT/OpReco/BarycenterMatchProducer_module.cc index 198fbbb23..53f967781 100644 --- a/icaruscode/PMT/OpReco/BarycenterMatchProducer_module.cc +++ b/icaruscode/PMT/OpReco/BarycenterMatchProducer_module.cc @@ -220,8 +220,8 @@ void BarycenterMatchProducer::produce(art::Event& e) const bool isData = e.isRealData(); //Fetch trigger info and if MC check whether this event triggered - art::Handle> triggerHandle; - e.getByLabel(fTriggerLabel, triggerHandle); + art::Handle const triggerHandle + = e.getHandle>(fTriggerLabel); raw::Trigger trigger; double triggerWithinGate = 0.; bool triggeredEvt = false; From 21185711ada274ca179d81fe370e9d08792fdaf6 Mon Sep 17 00:00:00 2001 From: JackSmedley <85366220+JackSmedley@users.noreply.github.com> Date: Fri, 17 Nov 2023 13:08:36 -0600 Subject: [PATCH 09/34] Replace getByLabel for OpFlashes Co-authored-by: Gianluca Petrillo --- icaruscode/PMT/OpReco/BarycenterMatchProducer_module.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/icaruscode/PMT/OpReco/BarycenterMatchProducer_module.cc b/icaruscode/PMT/OpReco/BarycenterMatchProducer_module.cc index 53f967781..d346dc97b 100644 --- a/icaruscode/PMT/OpReco/BarycenterMatchProducer_module.cc +++ b/icaruscode/PMT/OpReco/BarycenterMatchProducer_module.cc @@ -260,8 +260,8 @@ void BarycenterMatchProducer::produce(art::Event& e) */ //Fetch the flashes and their associated hits, pointer vector needed for generating associations - art::Handle> flashHandle; - e.getByLabel(fOpFlashLabel + inputTag, flashHandle); + art::Handle const flashHandle + = e.getHandle>(fOpFlashLabel + inputTag); art::FindMany fmOpHits(flashHandle, e, fOpFlashLabel + inputTag); std::vector> flashVector; art::fill_ptr_vector(flashVector, flashHandle); From f62e5f2fac1b2923191dbb80bf368ec6c5af9364 Mon Sep 17 00:00:00 2001 From: JackSmedley <85366220+JackSmedley@users.noreply.github.com> Date: Fri, 17 Nov 2023 13:09:16 -0600 Subject: [PATCH 10/34] Replace getByLabel for slices Co-authored-by: Gianluca Petrillo --- icaruscode/PMT/OpReco/BarycenterMatchProducer_module.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/icaruscode/PMT/OpReco/BarycenterMatchProducer_module.cc b/icaruscode/PMT/OpReco/BarycenterMatchProducer_module.cc index d346dc97b..d9b877b38 100644 --- a/icaruscode/PMT/OpReco/BarycenterMatchProducer_module.cc +++ b/icaruscode/PMT/OpReco/BarycenterMatchProducer_module.cc @@ -292,8 +292,8 @@ void BarycenterMatchProducer::produce(art::Event& e) */ //Fetch slices, TPC hits, and PFPs; pointer vector needed for generating associations - art::Handle> sliceHandle; - e.getByLabel(fPandoraLabel + inputTag, sliceHandle); + art::Handle const sliceHandle + = e.getHandle>(fPandoraLabel + inputTag); art::FindManyP fmTPCHits(sliceHandle, e, fPandoraLabel + inputTag); art::FindManyP fmPFPs(sliceHandle, e, fPandoraLabel + inputTag); std::vector> sliceVector; From 91cad5d4483781c3554072aa244a1d62fb57ec1e Mon Sep 17 00:00:00 2001 From: JackSmedley <85366220+JackSmedley@users.noreply.github.com> Date: Fri, 17 Nov 2023 13:13:14 -0600 Subject: [PATCH 11/34] Don't copy trigger product Co-authored-by: Gianluca Petrillo --- icaruscode/PMT/OpReco/BarycenterMatchProducer_module.cc | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/icaruscode/PMT/OpReco/BarycenterMatchProducer_module.cc b/icaruscode/PMT/OpReco/BarycenterMatchProducer_module.cc index d9b877b38..63bda27e1 100644 --- a/icaruscode/PMT/OpReco/BarycenterMatchProducer_module.cc +++ b/icaruscode/PMT/OpReco/BarycenterMatchProducer_module.cc @@ -222,11 +222,10 @@ void BarycenterMatchProducer::produce(art::Event& e) //Fetch trigger info and if MC check whether this event triggered art::Handle const triggerHandle = e.getHandle>(fTriggerLabel); - raw::Trigger trigger; double triggerWithinGate = 0.; bool triggeredEvt = false; - if ( triggerHandle.isValid() && triggerHandle->size() == 1 ) { - trigger = (*triggerHandle).at(0); + if ( triggerHandle.isValid() && triggerHandle->size() >= 1 ) { + raw::Trigger const& trigger = triggerHandle->at(0); if ( trigger.TriggerTime() >= 0 ) { triggerWithinGate = trigger.TriggerTime() - trigger.BeamGateTime(); triggeredEvt = true; From 28167d14fa25eea1ab66de6be2c7268f2295137f Mon Sep 17 00:00:00 2001 From: JackSmedley <85366220+JackSmedley@users.noreply.github.com> Date: Fri, 17 Nov 2023 13:13:41 -0600 Subject: [PATCH 12/34] Don't copy inputTag Co-authored-by: Gianluca Petrillo --- icaruscode/PMT/OpReco/BarycenterMatchProducer_module.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/icaruscode/PMT/OpReco/BarycenterMatchProducer_module.cc b/icaruscode/PMT/OpReco/BarycenterMatchProducer_module.cc index 63bda27e1..98c9f7894 100644 --- a/icaruscode/PMT/OpReco/BarycenterMatchProducer_module.cc +++ b/icaruscode/PMT/OpReco/BarycenterMatchProducer_module.cc @@ -247,7 +247,7 @@ void BarycenterMatchProducer::produce(art::Event& e) auto flashAssns = std::make_unique< art::Assns >(); //For InputTag... - for ( const std::string inputTag : fInputTags ) { + for ( const std::string& inputTag : fInputTags ) { //East-->0, West-->1 fCryo = ( inputTag.find("W") != std::string::npos ) ? 1 : 0; From 091ec68db3aa1120c9b42bb4083f3945e92719e2 Mon Sep 17 00:00:00 2001 From: JackSmedley <85366220+JackSmedley@users.noreply.github.com> Date: Fri, 17 Nov 2023 13:14:35 -0600 Subject: [PATCH 13/34] Get flashPtr from handle Co-authored-by: Gianluca Petrillo --- icaruscode/PMT/OpReco/BarycenterMatchProducer_module.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/icaruscode/PMT/OpReco/BarycenterMatchProducer_module.cc b/icaruscode/PMT/OpReco/BarycenterMatchProducer_module.cc index 98c9f7894..875b094d2 100644 --- a/icaruscode/PMT/OpReco/BarycenterMatchProducer_module.cc +++ b/icaruscode/PMT/OpReco/BarycenterMatchProducer_module.cc @@ -401,7 +401,7 @@ void BarycenterMatchProducer::produce(art::Event& e) } //Best match flash pointer - const art::Ptr& flashPtr = flashVector.at(matchIndex); + const art::Ptr flashPtr { flashHandle, matchIndex }; //Find time of first OpHit in matched flash const std::vector &opHitsVec = fmOpHits.at(matchIndex); From 9a4a951792e0df3bc4168b54e4c6d8480feee85a Mon Sep 17 00:00:00 2001 From: JackSmedley <85366220+JackSmedley@users.noreply.github.com> Date: Fri, 17 Nov 2023 13:15:12 -0600 Subject: [PATCH 14/34] Remove flashVector Co-authored-by: Gianluca Petrillo --- icaruscode/PMT/OpReco/BarycenterMatchProducer_module.cc | 2 -- 1 file changed, 2 deletions(-) diff --git a/icaruscode/PMT/OpReco/BarycenterMatchProducer_module.cc b/icaruscode/PMT/OpReco/BarycenterMatchProducer_module.cc index 875b094d2..9a04e10dd 100644 --- a/icaruscode/PMT/OpReco/BarycenterMatchProducer_module.cc +++ b/icaruscode/PMT/OpReco/BarycenterMatchProducer_module.cc @@ -262,8 +262,6 @@ void BarycenterMatchProducer::produce(art::Event& e) art::Handle const flashHandle = e.getHandle>(fOpFlashLabel + inputTag); art::FindMany fmOpHits(flashHandle, e, fOpFlashLabel + inputTag); - std::vector> flashVector; - art::fill_ptr_vector(flashVector, flashHandle); int nFlashes = (*flashHandle).size(); From 67257027677b5ddbe801d71de4b795ccacdd1bf5 Mon Sep 17 00:00:00 2001 From: JackSmedley <85366220+JackSmedley@users.noreply.github.com> Date: Fri, 17 Nov 2023 13:16:03 -0600 Subject: [PATCH 15/34] Use unchecked access for opflash Co-authored-by: Gianluca Petrillo --- icaruscode/PMT/OpReco/BarycenterMatchProducer_module.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/icaruscode/PMT/OpReco/BarycenterMatchProducer_module.cc b/icaruscode/PMT/OpReco/BarycenterMatchProducer_module.cc index 9a04e10dd..48473612a 100644 --- a/icaruscode/PMT/OpReco/BarycenterMatchProducer_module.cc +++ b/icaruscode/PMT/OpReco/BarycenterMatchProducer_module.cc @@ -269,7 +269,7 @@ void BarycenterMatchProducer::produce(art::Event& e) double flashTime_Trigger; //For flash... for ( int i = 0; i < nFlashes; i++ ) { - const recob::OpFlash &flash = (*flashHandle).at(i); + const recob::OpFlash &flash = (*flashHandle)[i]; //Is this a triggering flash? flashTime_Trigger = flash.Time(); From 2b199fb2a61687945e4d1bdf55530fe59a0fe3a0 Mon Sep 17 00:00:00 2001 From: JackSmedley <85366220+JackSmedley@users.noreply.github.com> Date: Fri, 17 Nov 2023 13:17:04 -0600 Subject: [PATCH 16/34] Get slcPtr from handle Co-authored-by: Gianluca Petrillo --- icaruscode/PMT/OpReco/BarycenterMatchProducer_module.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/icaruscode/PMT/OpReco/BarycenterMatchProducer_module.cc b/icaruscode/PMT/OpReco/BarycenterMatchProducer_module.cc index 48473612a..8ebd0d65d 100644 --- a/icaruscode/PMT/OpReco/BarycenterMatchProducer_module.cc +++ b/icaruscode/PMT/OpReco/BarycenterMatchProducer_module.cc @@ -301,7 +301,7 @@ void BarycenterMatchProducer::produce(art::Event& e) //For slice... for ( int j = 0; j < nSlices; j++ ) { fSliceNum = j; - const art::Ptr& slicePtr = sliceVector.at(j); + const art::Ptr slicePtr { sliceHandle, j }; InitializeSlice(); sbn::BarycenterMatch sliceMatchInfo; updateMatchInfo(sliceMatchInfo); From cc1eec129983150198168741e67c536aca9def1d Mon Sep 17 00:00:00 2001 From: JackSmedley <85366220+JackSmedley@users.noreply.github.com> Date: Fri, 17 Nov 2023 13:17:41 -0600 Subject: [PATCH 17/34] Remove sliceVector Co-authored-by: Gianluca Petrillo --- icaruscode/PMT/OpReco/BarycenterMatchProducer_module.cc | 2 -- 1 file changed, 2 deletions(-) diff --git a/icaruscode/PMT/OpReco/BarycenterMatchProducer_module.cc b/icaruscode/PMT/OpReco/BarycenterMatchProducer_module.cc index 8ebd0d65d..c11a343dc 100644 --- a/icaruscode/PMT/OpReco/BarycenterMatchProducer_module.cc +++ b/icaruscode/PMT/OpReco/BarycenterMatchProducer_module.cc @@ -293,8 +293,6 @@ void BarycenterMatchProducer::produce(art::Event& e) = e.getHandle>(fPandoraLabel + inputTag); art::FindManyP fmTPCHits(sliceHandle, e, fPandoraLabel + inputTag); art::FindManyP fmPFPs(sliceHandle, e, fPandoraLabel + inputTag); - std::vector> sliceVector; - art::fill_ptr_vector(sliceVector, sliceHandle); int nSlices = (*sliceHandle).size(); From 7c35319523374c40bc14e2829a2d7b4e948e184e Mon Sep 17 00:00:00 2001 From: JackSmedley <85366220+JackSmedley@users.noreply.github.com> Date: Fri, 17 Nov 2023 13:19:55 -0600 Subject: [PATCH 18/34] Remove FindOneP include Co-authored-by: Gianluca Petrillo --- icaruscode/PMT/OpReco/BarycenterMatchProducer_module.cc | 1 - 1 file changed, 1 deletion(-) diff --git a/icaruscode/PMT/OpReco/BarycenterMatchProducer_module.cc b/icaruscode/PMT/OpReco/BarycenterMatchProducer_module.cc index c11a343dc..24da82447 100644 --- a/icaruscode/PMT/OpReco/BarycenterMatchProducer_module.cc +++ b/icaruscode/PMT/OpReco/BarycenterMatchProducer_module.cc @@ -25,7 +25,6 @@ #include "art/Framework/Services/Registry/ServiceHandle.h" #include "art/Persistency/Common/PtrMaker.h" #include "canvas/Persistency/Common/FindOne.h" -#include "canvas/Persistency/Common/FindOneP.h" #include "canvas/Persistency/Common/FindMany.h" #include "canvas/Persistency/Common/FindManyP.h" From 04e37c5f471a1ef235f22ef1baf5bebed87c36e7 Mon Sep 17 00:00:00 2001 From: JackSmedley <85366220+JackSmedley@users.noreply.github.com> Date: Fri, 17 Nov 2023 13:20:54 -0600 Subject: [PATCH 19/34] Include suggested documentation Co-authored-by: Gianluca Petrillo --- .../OpReco/BarycenterMatchProducer_module.cc | 151 ++++++++++++++++++ 1 file changed, 151 insertions(+) diff --git a/icaruscode/PMT/OpReco/BarycenterMatchProducer_module.cc b/icaruscode/PMT/OpReco/BarycenterMatchProducer_module.cc index 24da82447..e9f74b49b 100644 --- a/icaruscode/PMT/OpReco/BarycenterMatchProducer_module.cc +++ b/icaruscode/PMT/OpReco/BarycenterMatchProducer_module.cc @@ -61,6 +61,157 @@ using electronics_time = detinfo::timescales::electronics_time; class BarycenterMatchProducer; +/** + * @brief Matches optical flashes and charge slices based on their location. + * + * + * This algorithm associates slices of charge from the TPC (`recob::Slice`) to + * reconstructed scintillation light flashes (`recob::OpFlash`). + * + * For each one of the `InputTags` tags, one slice and one flash set are + * identified and matching is done between them. + * + * Each slice is associated independently to the closest among the flashes. + * Distance is computed between the charge centroid of the slice and the one + * of the flash. + * + * All flashes are candidate for matching with any given slice. If + * `UseTimeRange` is specified, though, an allowed time range is determined + * for the slice based on the drift time of its TPC hits (in the extreme case, + * a slice covering from anode to cathode has an allowed time interval reduced + * to a single instant). In this case, only flashes that are no farther from + * this interval (with a set margin, `TimeRangeMargin`, accommodating for some + * reconstruction biases) are kept in the candidate pool. + * + * Matching of a slice immediately fails if no charge is associated to it, or, + * in the case `UseTimeRange` is set, if there are no reconstructed flash + * compatible with the time interval of the slice. Whenever the candidate pool + * contains at least a flash, the matching is "successful", meaning that it + * yields a result. It is the privilege of the analyzer to decide whether that + * is a good match or not, based on the information in the matching data + * product associated to the slice. If the matching did not succeed, matching + * information will still be associated with the slice, but most or all of its + * information will be placeholders. + * + * It is possible that a flash ends being associated with multiple slices. + * + * In addition, if a trigger time is available, the algorithm will attempt to + * identify the triggering flash and, if found, will provide the distance of + * each slice from that flash. + * + * Content of the matching information: + * + * * `ChargeT0` (microseconds): time associated to the slice via particle flow + * object; it is left in the original time reference. If no `anab::T0` + * object is associated, this variable is assigned the magic value `-9999`. + * + * ### Definition of the centroids + * + * The centroid of the slice is defined as the position of all the valid space + * points associated with the slice, weighted by their charge. + * Space points (`recob::SpacePoint`) are associated each to a TPC hit + * (`recob::Hit`); the charge of the hit is used as a weight, with no further + * calibration applied. + * If `CollectionOnly` is specified, only space points associated to hits on + * a collection plane are included. + * + * The centroid of a flash is defined only in its projection on the PMT plane. + * Its definition is delegated to the flash reconstruction algorithm + * (`recob::OpFlash::YCenter()` and `recob::OpFlash::ZCenter()`). + * In particular note that there is no attempt to enforce a location based on + * the earliest light. In fact, the standard flash reconstruction algorithm + * builds the center of the flash from _all_ the associated hits no matter + * their time. + * + * ### Determination of the trigger flash + * + * If a trigger time is found from the `TriggerLabel` data product, the module + * will attempt to identify the triggering flash. + * The identification is based solely on the time of the trigger and of the + * flash. + * In ICARUS data, the time reference is the trigger time, therefore the time + * of the global trigger is a fixed value by definition. Nevertheless, to + * accommodate relative delays between the trigger and the light systems, a + * "nominal" trigger time (`NominalTrigTime`) is used instead of the actual + * one, and this other time is controlled directly by the module caller. + * In ICARUS simulation the mechanism is the same; the times are stored with + * respect to the simulation time, but the module will take care of + * the appropriate conversion, so the configuration parameter holds the same + * meaning and scale as in data. + * + * + * Input + * ------ + * + * * `std::vector` (based on `OpFlashLabel`): collection of + * reconstructed flashes to be associated to the charge; also their + * associations to `recob::OpHit` (and those hits themselves). + * * `std::vector` (based on `PandoraLabel`): collection of + * reconstructed TPC charge slices to be associated to the light; also their + * associations to `recob::Hit` and `recob::PFParticle`, and + * `recob::SpacePoint` objects associated to those hits + * (and also the associated objects as well). + * * `std::vector` (`TriggerLabel`): collection of the global + * triggers (only at most one is expected). + * + * + * Output + * ------- + * + * A single collection, merging all the input, is produced for each of the + * following data products in the _art_/ROOT output: + * + * * `std::vector`: collection of matching information; + * one matching information object is present for each slice in the input + * collections, in the same order as the input. + * * `art::Assns`: association of each + * matched slice with its matching information. + * * `art::Assns`: association of each + * matched light flash with its matching information. + * + * Note that while there is currently no direct association between the slice + * and the flash, the information contained in `sbn::BarycenterMatch` is very + * detailed. + * + * In addition, if `FillMatchTree` is set, a ROOT tree called `matchTree` will + * be written via `TFileService`. The tree contains one entry per slice, + * whether matched or not, + * + * + * Configuration parameters + * ------------------------- + * + * * `InputTags` (list of strings, mandatory): suffixes to be added to the + * labels of the reconstructed data products to be used in the matching. + * Two typical choices are to process independently parts of the detector, + * e.g. `[ "cryoE", "cryoW" ]` to process east cryostat first and west one + * next, or to have a single empty suffix (`[ "" ]`) to use as input tags + * exactly the labels as specified by the following parameters. + * * `OpFlashLabel` (string, mandatory): base of the tag of the input flashes. + * * `PandoraLabel` (string, mandatory): base of the tag of input slices, and + * their associations to hits, space points, particle flow objects etc. + * * `TriggerLabel` (input tag, mandatory): information on the global trigger + * (hardware or synthetic). + * * `CollectionOnly` (flag, default: `true`): if set, only hits from + * collection planes will contribute to the centroid of the TPC slice. + * * `UseTimeRange` (flag, default: `true`): if set, a slice is assigned an + * allowed time interval based on the drift time of its hits and only + * flashes falling in that interval are considered for matching. Otherwise, + * all flashes are game for matching. + * * `Verbose` (flag, default: `false`): enables verbose output directly to + * console standard output. + * * `FillMatchTree` (flag, default: `false`): if set to `true`, a ROOT tree + * with detailed matching information called `"matchTree"` will be written + * via `TFileService`. + * * `NominalTrigTime` (real, mandatory, in microseconds): the time, in + * electronics scale, when the trigger is expected to arrive. + * * `TriggerTolerance` (real, mandatory, in microseconds): the tolerance used + * to identify a light flash associated with the trigger. + * * `TimeRangeMargin` (real, microseconds; default: `0`): when `UseTimeRange` + * is set, the allowed time interval for each slice is extended on both + * sides by this amount of time. + * + */ class BarycenterMatchProducer : public art::EDProducer { public: explicit BarycenterMatchProducer(fhicl::ParameterSet const& p); From c381d044bd0fe225d325e1a05ef2c591dc4a36d9 Mon Sep 17 00:00:00 2001 From: JackSmedley <85366220+JackSmedley@users.noreply.github.com> Date: Fri, 17 Nov 2023 13:22:55 -0600 Subject: [PATCH 20/34] Add several includes Co-authored-by: Gianluca Petrillo --- icaruscode/PMT/OpReco/BarycenterMatchProducer_module.cc | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/icaruscode/PMT/OpReco/BarycenterMatchProducer_module.cc b/icaruscode/PMT/OpReco/BarycenterMatchProducer_module.cc index e9f74b49b..7b7bd9804 100644 --- a/icaruscode/PMT/OpReco/BarycenterMatchProducer_module.cc +++ b/icaruscode/PMT/OpReco/BarycenterMatchProducer_module.cc @@ -53,7 +53,12 @@ #include "TTree.h" #include "TVector3.h" +#include // std::hypot(), std::abs(), std::sqrt() +#include #include +#include +#include // std::move() +#include using microseconds = util::quantities::intervals::microseconds; using electronics_time = detinfo::timescales::electronics_time; From 5602894f3065c25d478c5d04bb8a9ab380853291 Mon Sep 17 00:00:00 2001 From: JackSmedley <85366220+JackSmedley@users.noreply.github.com> Date: Fri, 17 Nov 2023 13:23:56 -0600 Subject: [PATCH 21/34] Add consumes<> statements Co-authored-by: Gianluca Petrillo --- .../PMT/OpReco/BarycenterMatchProducer_module.cc | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/icaruscode/PMT/OpReco/BarycenterMatchProducer_module.cc b/icaruscode/PMT/OpReco/BarycenterMatchProducer_module.cc index 7b7bd9804..0763ae6c4 100644 --- a/icaruscode/PMT/OpReco/BarycenterMatchProducer_module.cc +++ b/icaruscode/PMT/OpReco/BarycenterMatchProducer_module.cc @@ -322,6 +322,18 @@ BarycenterMatchProducer::BarycenterMatchProducer(fhicl::ParameterSet const& p) produces< art::Assns >(); // Call appropriate consumes<>() for any products to be retrieved by this module. + consumes>(fTriggerLabel); + for ( const std::string& inputTag : fInputTags ) { + consumes>(fOpFlashLabel + inputTag); + consumes>(fPandoraLabel + inputTag); + + // via art::FindMany: + consumes>(fOpFlashLabel + inputTag); + consumes>(fPandoraLabel + inputTag); + consumes>(fPandoraLabel + inputTag); + consumes>(fPandoraLabel + inputTag); + consumes>(fPandoraLabel + inputTag); + } // for if ( fFillMatchTree ) { art::ServiceHandle tfs; From 4c3ef9e692b7fa38492b4a2fbe4d2e9fe7053581 Mon Sep 17 00:00:00 2001 From: JackSmedley <85366220+JackSmedley@users.noreply.github.com> Date: Fri, 17 Nov 2023 13:25:02 -0600 Subject: [PATCH 22/34] Add spactime.h include for microseconds Co-authored-by: Gianluca Petrillo --- icaruscode/PMT/OpReco/BarycenterMatchProducer_module.cc | 1 + 1 file changed, 1 insertion(+) diff --git a/icaruscode/PMT/OpReco/BarycenterMatchProducer_module.cc b/icaruscode/PMT/OpReco/BarycenterMatchProducer_module.cc index 0763ae6c4..b3c20eed0 100644 --- a/icaruscode/PMT/OpReco/BarycenterMatchProducer_module.cc +++ b/icaruscode/PMT/OpReco/BarycenterMatchProducer_module.cc @@ -34,6 +34,7 @@ #include "lardata/DetectorInfoServices/DetectorClocksService.h" #include "lardataalg/DetectorInfo/DetectorPropertiesData.h" #include "lardataalg/DetectorInfo/DetectorClocksData.h" +#include "lardataalg/Utilities/quantities/spacetime.h" // microseconds #include "larcore/Geometry/Geometry.h" #include "larcorealg/Geometry/GeometryCore.h" #include "larcore/CoreUtils/ServiceUtil.h" From acfbd1d64aa673a1c9378417e7613748bb0577ee Mon Sep 17 00:00:00 2001 From: JackSmedley <85366220+JackSmedley@users.noreply.github.com> Date: Fri, 17 Nov 2023 13:25:55 -0600 Subject: [PATCH 23/34] Remove extraneous class definition Co-authored-by: Gianluca Petrillo --- icaruscode/PMT/OpReco/BarycenterMatchProducer_module.cc | 2 -- 1 file changed, 2 deletions(-) diff --git a/icaruscode/PMT/OpReco/BarycenterMatchProducer_module.cc b/icaruscode/PMT/OpReco/BarycenterMatchProducer_module.cc index b3c20eed0..4d60b0ce3 100644 --- a/icaruscode/PMT/OpReco/BarycenterMatchProducer_module.cc +++ b/icaruscode/PMT/OpReco/BarycenterMatchProducer_module.cc @@ -64,8 +64,6 @@ using microseconds = util::quantities::intervals::microseconds; using electronics_time = detinfo::timescales::electronics_time; -class BarycenterMatchProducer; - /** * @brief Matches optical flashes and charge slices based on their location. From 06c6ed2cefb26e5044d58d8b3e372165ef473ff3 Mon Sep 17 00:00:00 2001 From: JackSmedley <85366220+JackSmedley@users.noreply.github.com> Date: Fri, 17 Nov 2023 13:27:04 -0600 Subject: [PATCH 24/34] Remove extra lines in data fcl, pt.1 Co-authored-by: Gianluca Petrillo --- icaruscode/PMT/OpReco/fcl/barycentermatch_data.fcl | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/icaruscode/PMT/OpReco/fcl/barycentermatch_data.fcl b/icaruscode/PMT/OpReco/fcl/barycentermatch_data.fcl index 4442b00f8..73f575d45 100644 --- a/icaruscode/PMT/OpReco/fcl/barycentermatch_data.fcl +++ b/icaruscode/PMT/OpReco/fcl/barycentermatch_data.fcl @@ -23,17 +23,6 @@ services: } # services -# The 'source' section tells the script to expect an input file with art::Event records. -source: -{ - module_type: RootInput - - # Number of events to analyze; "-1" means all of the events in the input - # file. You can override this value with the "-n" option on the command line. - maxEvents: -1 - -} - # This is empty, because we're not writing an output file with art::Event objects. outputs: { From c6e4b22b1af346535d283402705341b5fc2bed5d Mon Sep 17 00:00:00 2001 From: JackSmedley <85366220+JackSmedley@users.noreply.github.com> Date: Fri, 17 Nov 2023 13:27:42 -0600 Subject: [PATCH 25/34] Remove extra lines in data fcl, the sequel Co-authored-by: Gianluca Petrillo --- icaruscode/PMT/OpReco/fcl/barycentermatch_data.fcl | 1 - 1 file changed, 1 deletion(-) diff --git a/icaruscode/PMT/OpReco/fcl/barycentermatch_data.fcl b/icaruscode/PMT/OpReco/fcl/barycentermatch_data.fcl index 73f575d45..1c0370994 100644 --- a/icaruscode/PMT/OpReco/fcl/barycentermatch_data.fcl +++ b/icaruscode/PMT/OpReco/fcl/barycentermatch_data.fcl @@ -23,7 +23,6 @@ services: } # services -# This is empty, because we're not writing an output file with art::Event objects. outputs: { out1: From d227951ce44df19be97bf9fd4593af38eda43ad8 Mon Sep 17 00:00:00 2001 From: JackSmedley <85366220+JackSmedley@users.noreply.github.com> Date: Fri, 17 Nov 2023 13:28:23 -0600 Subject: [PATCH 26/34] Remove extra lines from MC fcl Co-authored-by: Gianluca Petrillo --- icaruscode/PMT/OpReco/fcl/barycentermatch_mc.fcl | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/icaruscode/PMT/OpReco/fcl/barycentermatch_mc.fcl b/icaruscode/PMT/OpReco/fcl/barycentermatch_mc.fcl index ea7366e27..ab9d9744a 100644 --- a/icaruscode/PMT/OpReco/fcl/barycentermatch_mc.fcl +++ b/icaruscode/PMT/OpReco/fcl/barycentermatch_mc.fcl @@ -22,19 +22,6 @@ services: } # services - -# The 'source' section tells the script to expect an input file with art::Event records. -source: -{ - module_type: RootInput - - # Number of events to analyze; "-1" means all of the events in the input - # file. You can override this value with the "-n" option on the command line. - maxEvents: -1 - -} - -# This is empty, because we're not writing an output file with art::Event objects. outputs: { out1: From 7ace536d1dcab9175d8e70b9da472615eb447c89 Mon Sep 17 00:00:00 2001 From: Jack Smedley Date: Fri, 17 Nov 2023 16:38:49 -0600 Subject: [PATCH 27/34] Add DeltaY and Radius for trigger match, flip NominalTrigTime to TriggerDelay, etc --- .../OpReco/BarycenterMatchProducer_module.cc | 70 +++++++++++-------- .../PMT/OpReco/fcl/barycentermatch_config.fcl | 8 +-- .../PMT/OpReco/fcl/barycentermatch_data.fcl | 2 +- 3 files changed, 46 insertions(+), 34 deletions(-) diff --git a/icaruscode/PMT/OpReco/BarycenterMatchProducer_module.cc b/icaruscode/PMT/OpReco/BarycenterMatchProducer_module.cc index 4d60b0ce3..e30f1f47f 100644 --- a/icaruscode/PMT/OpReco/BarycenterMatchProducer_module.cc +++ b/icaruscode/PMT/OpReco/BarycenterMatchProducer_module.cc @@ -136,7 +136,7 @@ using electronics_time = detinfo::timescales::electronics_time; * In ICARUS data, the time reference is the trigger time, therefore the time * of the global trigger is a fixed value by definition. Nevertheless, to * accommodate relative delays between the trigger and the light systems, a - * "nominal" trigger time (`NominalTrigTime`) is used instead of the actual + * "nominal" trigger time (`TriggerDelay`) is used instead of the actual * one, and this other time is controlled directly by the module caller. * In ICARUS simulation the mechanism is the same; the times are stored with * respect to the simulation time, but the module will take care of @@ -207,7 +207,7 @@ using electronics_time = detinfo::timescales::electronics_time; * * `FillMatchTree` (flag, default: `false`): if set to `true`, a ROOT tree * with detailed matching information called `"matchTree"` will be written * via `TFileService`. - * * `NominalTrigTime` (real, mandatory, in microseconds): the time, in + * * `TriggerDelay` (real, mandatory, in microseconds): the time, in * electronics scale, when the trigger is expected to arrive. * * `TriggerTolerance` (real, mandatory, in microseconds): the tolerance used * to identify a light flash associated with the trigger. @@ -235,9 +235,9 @@ class BarycenterMatchProducer : public art::EDProducer { // Declare member data here. void InitializeSlice(); ///< Re-initialize all slice-level data members - double CentroidOverlap(double center1, double center2, double width1, double width2); ///< Return overlap between charge and light centroids OR distance apart if no overlap + double CentroidOverlap(double center1, double center2, double width1, double width2) const; ///< Return overlap between charge and light centroids OR distance apart if no overlap double CalculateAsymmetry(art::Ptr flash, int cryo); ///< Return the east-west asymmetry of PEs in a given OpFlash - void updateChargeVars(double sumCharge, TVector3 sumPos, TVector3 sumPosSqr, double triggerFlashCenter); ///< Update slice-level data members with charge and trigger match info + void updateChargeVars(double sumCharge, TVector3 const& sumPos, TVector3 const& sumPosSqr, std::array const& triggerFlashCenter); ///< Update slice-level data members with charge and trigger match info void updateFlashVars(art::Ptr flash, double firstHit); ///< Update slice-level data members with best match info void updateMatchInfo(sbn::BarycenterMatch& matchInfo); ///< Update match product with slice-level data members @@ -250,9 +250,9 @@ class BarycenterMatchProducer : public art::EDProducer { bool fUseTimeRange; ///< Reject impossible matches based on allowed time range of TPC hits relative to trigger bool fVerbose; ///< Print extra info bool fFillMatchTree; ///< Fill an output TTree in the supplemental file - double fNominalTrigTime; ///< Typical time of triggering flash, EYEBALLED (us) + double fTriggerDelay; ///< Typical time of triggering flash, EYEBALLED (us) double fTriggerTolerance; ///< Spread of triggering flash times, EYEBALLED (us) - double fTimeRangeMargin; ///< Symmetric acceptable margin for allowed time range of TPC hits (us) + microseconds fTimeRangeMargin; ///< Symmetric acceptable margin for allowed time range of TPC hits (us) // Event-level data members int fRun; ///< Number of the run being processed @@ -261,7 +261,7 @@ class BarycenterMatchProducer : public art::EDProducer { int fSliceNum; ///< Number of slice in the event // Slice-level data members double fChargeT0; ///< Start time for cathode-crossing PFPs, not always available (us) - double fChargeTotal; ///< Total charge in slice + double fChargeTotal; ///< Total charge in slice (integrated ADC counts) double fChargeCenterXGlobal; ///< Weighted mean X position of spacepoints (cm) double fChargeCenterXLocal; ///< Weighted mean X position of spacepoints, measured with respect to the cathode (cm) double fChargeCenterY; ///< Weighted mean Y position of spacepoints (cm) @@ -280,10 +280,12 @@ class BarycenterMatchProducer : public art::EDProducer { double fDeltaT; ///< | Matched flash time - charge T0 | when available (us) double fDeltaY; ///< | Matched flash Y center - charge Y center | (cm) double fDeltaZ; ///< | Matched flash Z center - charge Z center | (cm) - double fRadius; ///< Hypotenuse of DeltaY and DeltaZ, PARAMETER MINIMIZED BY MATCHING (cm) - double fOverlapY; ///< Spacial overlap of flash and charge centroids in Y [>0] OR distance apart if no overlap [<0] (cm) - double fOverlapZ; ///< Spacial overlap of flash and charge centroids in Z [>0] OR distance apart if no overlap [<0] (cm) + double fRadius; ///< Hypotenuse of DeltaY and DeltaZ *parameter minimized by matching* (cm) + double fOverlapY; ///< Spatial overlap of flash and charge centroids in Y [>0] OR distance apart if no overlap [<0] (cm) + double fOverlapZ; ///< Spatial overlap of flash and charge centroids in Z [>0] OR distance apart if no overlap [<0] (cm) + double fDeltaY_Trigger; ///< | Triggering flash Y center - charge Y center | (cm) double fDeltaZ_Trigger; ///< | Triggering flash Z center - charge Z center | (cm) + double fRadius_Trigger; ///< Hypotenuse of DeltaY_Trigger and DeltaZ_Trigger (cm) TTree* fMatchTree; ///< Tree to store all match information @@ -302,13 +304,13 @@ BarycenterMatchProducer::BarycenterMatchProducer(fhicl::ParameterSet const& p) fOpFlashLabel(p.get("OpFlashLabel")), fPandoraLabel(p.get("PandoraLabel")), fTriggerLabel(p.get("TriggerLabel")), - fCollectionOnly(p.get("CollectionOnly")), - fUseTimeRange(p.get("UseTimeRange")), - fVerbose(p.get("Verbose")), - fFillMatchTree(p.get("FillMatchTree")), - fNominalTrigTime(p.get("NominalTrigTime")), - fTriggerTolerance(p.get("TriggerTolerance")), - fTimeRangeMargin(p.get("TimeRangeMargin")), + fCollectionOnly(p.get("CollectionOnly", true)), + fUseTimeRange(p.get("UseTimeRange", true)), + fVerbose(p.get("Verbose", false)), + fFillMatchTree(p.get("FillMatchTree", false)), + fTriggerDelay(p.get("TriggerDelay", 0.0)), + fTriggerTolerance(p.get("TriggerTolerance", 25.0)), + fTimeRangeMargin(fUseTimeRange? p.get("TimeRangeMargin"): microseconds{0.0}), fGeom(*lar::providerFrom()), fDetClocks(*art::ServiceHandle()), fDetProp(*art::ServiceHandle()), @@ -373,6 +375,8 @@ BarycenterMatchProducer::BarycenterMatchProducer(fhicl::ParameterSet const& p) fMatchTree->Branch("overlapY", &fOverlapY, "overlapY/d" ); fMatchTree->Branch("overlapZ", &fOverlapZ, "overlapZ/d" ); fMatchTree->Branch("deltaZ_Trigger", &fDeltaZ_Trigger, "deltaZ_Trigger/d" ); + fMatchTree->Branch("deltaY_Trigger", &fDeltaY_Trigger, "deltaY_Trigger/d" ); + fMatchTree->Branch("radius_Trigger", &fRadius_Trigger, "dadius_Trigger/d" ); } //End MatchTree @@ -397,11 +401,11 @@ void BarycenterMatchProducer::produce(art::Event& e) triggeredEvt = true; } if ( fVerbose ) std::cout << "Valid trigger product found. Trigger time: " << trigger.TriggerTime() << ", Beam gate time: " << trigger.BeamGateTime() << ", Difference: " << triggerWithinGate << std::endl; + std::cout << "TEMPORARY Trigger time: " << trigger.TriggerTime() << std::endl; } else if ( fVerbose ) std::cout << "No valid trigger product found for this event!" << std::endl; //Infrastructure for checking allowed time range of a slice - microseconds margin(fTimeRangeMargin); detinfo::DetectorTimings const detTimings{ fDetClocks.DataFor(e) }; detinfo::DetectorPropertiesData const& detProp { fDetProp.DataFor(e, detTimings.clockData()) }; lar::util::TrackTimeInterval const timeIntervals = fTimeIntervalMaker(detProp, detTimings); @@ -431,20 +435,21 @@ void BarycenterMatchProducer::produce(art::Event& e) int nFlashes = (*flashHandle).size(); - double triggerFlashCenter = -9999.; + std::array triggerFlashCenter = {-9999., -9999.}; double flashTime_Trigger; //For flash... for ( int i = 0; i < nFlashes; i++ ) { const recob::OpFlash &flash = (*flashHandle)[i]; + std::cout << "TEMPORARY flash.Time(): " << flash.Time() << ", flash.AbsTime(): " << flash.AbsTime() << std::endl; //Is this a triggering flash? flashTime_Trigger = flash.Time(); - if ( !isData ) flashTime_Trigger += -1.*triggerWithinGate; - if ( triggeredEvt && abs(flashTime_Trigger - fNominalTrigTime) < fTriggerTolerance ) triggerFlashCenter = flash.ZCenter(); + if ( !isData ) flashTime_Trigger -= triggerWithinGate; + if ( triggeredEvt && abs(flashTime_Trigger + fTriggerDelay) < fTriggerTolerance ) triggerFlashCenter = {flash.YCenter(), flash.ZCenter()}; } //End for flash - if ( fVerbose ) std::cout << "Event: " << fEvent << ", Cryo: " << inputTag << ", nFlashes: " << nFlashes << ", Triggering flash center: " << triggerFlashCenter << std::endl; + if ( fVerbose ) std::cout << "Event: " << fEvent << ", Cryo: " << inputTag << ", nFlashes: " << nFlashes << ", Triggering flash center Y: " << triggerFlashCenter[0] << ", Triggering flash center Z: " << triggerFlashCenter[1] << std::endl; /* ~~~~~~~~~~~~~~~~~~~~ TPC Section @@ -460,10 +465,10 @@ void BarycenterMatchProducer::produce(art::Event& e) art::FindManyP fmTPCHits(sliceHandle, e, fPandoraLabel + inputTag); art::FindManyP fmPFPs(sliceHandle, e, fPandoraLabel + inputTag); - int nSlices = (*sliceHandle).size(); + unsigned nSlices = (*sliceHandle).size(); //For slice... - for ( int j = 0; j < nSlices; j++ ) { + for ( unsigned j = 0; j < nSlices; j++ ) { fSliceNum = j; const art::Ptr slicePtr { sliceHandle, j }; InitializeSlice(); @@ -537,7 +542,7 @@ void BarycenterMatchProducer::produce(art::Event& e) //Skip over flashes that are very out of time with respect to the slice if ( fUseTimeRange && rangeIsValid ) { electronics_time eTime (flash.AbsTime()); - if ( !timeRange.contains(eTime, margin) ) continue; + if ( !timeRange.contains(eTime, fTimeRangeMargin) ) continue; } //TODO: if ( flash has entering CRT match ) continue? Or at least just store that as a bool? @@ -563,7 +568,8 @@ void BarycenterMatchProducer::produce(art::Event& e) } //Best match flash pointer - const art::Ptr flashPtr { flashHandle, matchIndex }; + unsigned unsignedMatchIndex = matchIndex; + const art::Ptr flashPtr { flashHandle, unsignedMatchIndex }; //Find time of first OpHit in matched flash const std::vector &opHitsVec = fmOpHits.at(matchIndex); @@ -614,10 +620,12 @@ void BarycenterMatchProducer::InitializeSlice() { fOverlapY = -9999.; fOverlapZ = -9999.; fDeltaZ_Trigger = -9999.; + fDeltaY_Trigger = -9999.; + fRadius_Trigger = -9999.; } //End InitializeSlice() -double BarycenterMatchProducer::CentroidOverlap(double center1, double center2, double width1, double width2) { +double BarycenterMatchProducer::CentroidOverlap(double center1, double center2, double width1, double width2) const { //Centroid 2 is contained within Centroid 1, so overlap is the whole Centroid 2 if ( (center1 - width1 < center2 - width2) && (center1 + width1 > center2 + width2) ) return (2 * width2); @@ -650,7 +658,7 @@ double BarycenterMatchProducer::CalculateAsymmetry(art::Ptr flas //TODO: Get the cathode position and shift global X to local X in a less hacky way //According to a geometrydump, the cathode X positions are +/-(210.14, 210.29), depending on the TPC. Here I just averaged those... -void BarycenterMatchProducer::updateChargeVars(double sumCharge, TVector3 sumPos, TVector3 sumPosSqr, double triggerFlashCenter) { +void BarycenterMatchProducer::updateChargeVars(double sumCharge, TVector3 const& sumPos, TVector3 const& sumPosSqr, std::array const& triggerFlashCenter) { fChargeCenterXGlobal = sumPos[0] / sumCharge; fChargeCenterXLocal = fChargeCenterXGlobal - 210.215 * (2*fCryo - 1); fChargeCenterY = sumPos[1] / sumCharge; @@ -658,7 +666,11 @@ void BarycenterMatchProducer::updateChargeVars(double sumCharge, TVector3 sumPos fChargeWidthX = std::sqrt( sumPosSqr[0]/sumCharge - (sumPos[0]/sumCharge)*(sumPos[0]/sumCharge) ); fChargeWidthY = std::sqrt( sumPosSqr[1]/sumCharge - (sumPos[1]/sumCharge)*(sumPos[1]/sumCharge) ); fChargeWidthZ = std::sqrt( sumPosSqr[2]/sumCharge - (sumPos[2]/sumCharge)*(sumPos[2]/sumCharge) ); - if ( triggerFlashCenter != -9999 ) fDeltaZ_Trigger = abs(triggerFlashCenter - fChargeCenterZ); + if ( triggerFlashCenter[1] != -9999. ) { + fDeltaY_Trigger = abs(triggerFlashCenter[0] - fChargeCenterY); + fDeltaZ_Trigger = abs(triggerFlashCenter[1] - fChargeCenterZ); + fRadius_Trigger = std::hypot(fDeltaY_Trigger, fDeltaZ_Trigger); + } } //End updateChargeVars() diff --git a/icaruscode/PMT/OpReco/fcl/barycentermatch_config.fcl b/icaruscode/PMT/OpReco/fcl/barycentermatch_config.fcl index f1746102f..071271232 100644 --- a/icaruscode/PMT/OpReco/fcl/barycentermatch_config.fcl +++ b/icaruscode/PMT/OpReco/fcl/barycentermatch_config.fcl @@ -19,14 +19,14 @@ barycentermatch_common_params: barycentermatch_data_params: { - TriggerLabel: "daqTrigger" - NominalTrigTime: -0.6 + TriggerLabel: "daqTrigger" + TriggerDelay: 0.6 } barycentermatch_mc_params: { - TriggerLabel: "emuTrigger" - NominalTrigTime: -0.22 + TriggerLabel: "emuTrigger" + TriggerDelay: 0.22 } ###### diff --git a/icaruscode/PMT/OpReco/fcl/barycentermatch_data.fcl b/icaruscode/PMT/OpReco/fcl/barycentermatch_data.fcl index 1c0370994..1ade68241 100644 --- a/icaruscode/PMT/OpReco/fcl/barycentermatch_data.fcl +++ b/icaruscode/PMT/OpReco/fcl/barycentermatch_data.fcl @@ -46,7 +46,7 @@ physics: } # Schedule job step(s) for execution by defining the analysis module for this job. - reco: [ barycentermatchCryoE, barycentermatchCryoW ] + reco: [ barycentermatchCryoE, barycentermatchCryoW ] stream1: [ out1 ] From d333143d84a5193e4d52aba39c91bb437b90b032 Mon Sep 17 00:00:00 2001 From: JackSmedley <85366220+JackSmedley@users.noreply.github.com> Date: Fri, 17 Nov 2023 16:41:12 -0600 Subject: [PATCH 28/34] Move TVector initializers Co-authored-by: Gianluca Petrillo --- icaruscode/PMT/OpReco/BarycenterMatchProducer_module.cc | 1 - 1 file changed, 1 deletion(-) diff --git a/icaruscode/PMT/OpReco/BarycenterMatchProducer_module.cc b/icaruscode/PMT/OpReco/BarycenterMatchProducer_module.cc index 4d60b0ce3..a1fd49573 100644 --- a/icaruscode/PMT/OpReco/BarycenterMatchProducer_module.cc +++ b/icaruscode/PMT/OpReco/BarycenterMatchProducer_module.cc @@ -491,7 +491,6 @@ void BarycenterMatchProducer::produce(art::Event& e) double thisCharge; double sumCharge = 0.; - TVector3 thisPoint, thisPointSqr; TVector3 sumPos {0.,0.,0.}; TVector3 sumPosSqr {0.,0.,0.}; From 2206119662cb70b56ec93024d573e03b2b63ffd7 Mon Sep 17 00:00:00 2001 From: JackSmedley <85366220+JackSmedley@users.noreply.github.com> Date: Fri, 17 Nov 2023 16:42:12 -0600 Subject: [PATCH 29/34] Initialize TVectors here, reference by dimension method rather than index Co-authored-by: Gianluca Petrillo --- icaruscode/PMT/OpReco/BarycenterMatchProducer_module.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/icaruscode/PMT/OpReco/BarycenterMatchProducer_module.cc b/icaruscode/PMT/OpReco/BarycenterMatchProducer_module.cc index a1fd49573..70d8372ff 100644 --- a/icaruscode/PMT/OpReco/BarycenterMatchProducer_module.cc +++ b/icaruscode/PMT/OpReco/BarycenterMatchProducer_module.cc @@ -504,8 +504,8 @@ void BarycenterMatchProducer::produce(art::Event& e) const recob::SpacePoint point = f1SpacePoint.at(k).ref(); thisCharge = tpcHit->Integral(); - thisPoint = point.XYZ(); - thisPointSqr = {thisPoint[0]*thisPoint[0], thisPoint[1]*thisPoint[1], thisPoint[2]*thisPoint[2]}; + TVector3 const thisPoint = point.XYZ(); + TVector3 const thisPointSqr {thisPoint.X()*thisPoint.X(), thisPoint.Y()*thisPoint.Y(), thisPoint.Z()*thisPoint.Z()}; sumCharge += thisCharge; sumPos += thisPoint * thisCharge; sumPosSqr += thisPointSqr * thisCharge; From d47b5ce004ddee42f0f5bc158fcf1a5f0b9e0ff2 Mon Sep 17 00:00:00 2001 From: Jack Smedley Date: Fri, 17 Nov 2023 17:24:13 -0600 Subject: [PATCH 30/34] Adding some comments so Git sees the chnages on these lines, will delete later --- icaruscode/PMT/OpReco/BarycenterMatchProducer_module.cc | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/icaruscode/PMT/OpReco/BarycenterMatchProducer_module.cc b/icaruscode/PMT/OpReco/BarycenterMatchProducer_module.cc index 943e5a181..883fa594c 100644 --- a/icaruscode/PMT/OpReco/BarycenterMatchProducer_module.cc +++ b/icaruscode/PMT/OpReco/BarycenterMatchProducer_module.cc @@ -496,8 +496,9 @@ void BarycenterMatchProducer::produce(art::Event& e) double thisCharge; double sumCharge = 0.; - TVector3 sumPos {0.,0.,0.}; - TVector3 sumPosSqr {0.,0.,0.}; + //Forcing Git to recognize there was a change here... + TVector3 sumPos {0.,0.,0.};//Forcing Git to recognize there was a change here... + TVector3 sumPosSqr {0.,0.,0.};//Forcing Git to recognize there was a change here... //For hit... for ( int k = 0; k < nHits; k++ ) { @@ -509,8 +510,8 @@ void BarycenterMatchProducer::produce(art::Event& e) const recob::SpacePoint point = f1SpacePoint.at(k).ref(); thisCharge = tpcHit->Integral(); - TVector3 const thisPoint = point.XYZ(); - TVector3 const thisPointSqr {thisPoint.X()*thisPoint.X(), thisPoint.Y()*thisPoint.Y(), thisPoint.Z()*thisPoint.Z()}; + TVector3 const thisPoint = point.XYZ();//Forcing Git to recognize there was a change here... + TVector3 const thisPointSqr {thisPoint.X()*thisPoint.X(), thisPoint.Y()*thisPoint.Y(), thisPoint.Z()*thisPoint.Z()};//Forcing Git to recognize there was a change here... sumCharge += thisCharge; sumPos += thisPoint * thisCharge; sumPosSqr += thisPointSqr * thisCharge; From 506c9fca3444bbe2d936d4f0b69fc7dc892a23be Mon Sep 17 00:00:00 2001 From: Jack Smedley Date: Sat, 18 Nov 2023 12:27:50 -0600 Subject: [PATCH 31/34] Clean up trigger flash determination --- .../OpReco/BarycenterMatchProducer_module.cc | 64 +++++++++---------- .../PMT/OpReco/fcl/barycentermatch_config.fcl | 2 +- 2 files changed, 32 insertions(+), 34 deletions(-) diff --git a/icaruscode/PMT/OpReco/BarycenterMatchProducer_module.cc b/icaruscode/PMT/OpReco/BarycenterMatchProducer_module.cc index 883fa594c..e9dd02e60 100644 --- a/icaruscode/PMT/OpReco/BarycenterMatchProducer_module.cc +++ b/icaruscode/PMT/OpReco/BarycenterMatchProducer_module.cc @@ -234,12 +234,12 @@ class BarycenterMatchProducer : public art::EDProducer { private: // Declare member data here. - void InitializeSlice(); ///< Re-initialize all slice-level data members - double CentroidOverlap(double center1, double center2, double width1, double width2) const; ///< Return overlap between charge and light centroids OR distance apart if no overlap - double CalculateAsymmetry(art::Ptr flash, int cryo); ///< Return the east-west asymmetry of PEs in a given OpFlash + void InitializeSlice(); ///< Re-initialize all slice-level data members + double CentroidOverlap(double center1, double center2, double width1, double width2) const; ///< Return overlap between charge and light centroids OR distance apart if no overlap + double CalculateAsymmetry(art::Ptr flash, int cryo); ///< Return the east-west asymmetry of PEs in a given OpFlash void updateChargeVars(double sumCharge, TVector3 const& sumPos, TVector3 const& sumPosSqr, std::array const& triggerFlashCenter); ///< Update slice-level data members with charge and trigger match info - void updateFlashVars(art::Ptr flash, double firstHit); ///< Update slice-level data members with best match info - void updateMatchInfo(sbn::BarycenterMatch& matchInfo); ///< Update match product with slice-level data members + void updateFlashVars(art::Ptr flash, double firstHit); ///< Update slice-level data members with best match info + void updateMatchInfo(sbn::BarycenterMatch& matchInfo); ///< Update match product with slice-level data members // Input parameters std::vector fInputTags; ///< Suffix added onto fOpFlashLabel and fPandoraLabel, used by ICARUS for separate cryostat labels but could be empty @@ -250,7 +250,7 @@ class BarycenterMatchProducer : public art::EDProducer { bool fUseTimeRange; ///< Reject impossible matches based on allowed time range of TPC hits relative to trigger bool fVerbose; ///< Print extra info bool fFillMatchTree; ///< Fill an output TTree in the supplemental file - double fTriggerDelay; ///< Typical time of triggering flash, EYEBALLED (us) + double fTriggerDelay; ///< Typical time of triggering flash, EYEBALLED (us) double fTriggerTolerance; ///< Spread of triggering flash times, EYEBALLED (us) microseconds fTimeRangeMargin; ///< Symmetric acceptable margin for allowed time range of TPC hits (us) @@ -310,7 +310,7 @@ BarycenterMatchProducer::BarycenterMatchProducer(fhicl::ParameterSet const& p) fFillMatchTree(p.get("FillMatchTree", false)), fTriggerDelay(p.get("TriggerDelay", 0.0)), fTriggerTolerance(p.get("TriggerTolerance", 25.0)), - fTimeRangeMargin(fUseTimeRange? p.get("TimeRangeMargin"): microseconds{0.0}), + fTimeRangeMargin(fUseTimeRange? microseconds{p.get("TimeRangeMargin")}: microseconds{0.0}), fGeom(*lar::providerFrom()), fDetClocks(*art::ServiceHandle()), fDetProp(*art::ServiceHandle()), @@ -387,21 +387,15 @@ void BarycenterMatchProducer::produce(art::Event& e) // Implementation of required member function here. fEvent = e.id().event(); fRun = e.run(); - const bool isData = e.isRealData(); //Fetch trigger info and if MC check whether this event triggered art::Handle const triggerHandle = e.getHandle>(fTriggerLabel); - double triggerWithinGate = 0.; - bool triggeredEvt = false; + double triggerTime = -9999.; if ( triggerHandle.isValid() && triggerHandle->size() >= 1 ) { raw::Trigger const& trigger = triggerHandle->at(0); - if ( trigger.TriggerTime() >= 0 ) { - triggerWithinGate = trigger.TriggerTime() - trigger.BeamGateTime(); - triggeredEvt = true; - } - if ( fVerbose ) std::cout << "Valid trigger product found. Trigger time: " << trigger.TriggerTime() << ", Beam gate time: " << trigger.BeamGateTime() << ", Difference: " << triggerWithinGate << std::endl; - std::cout << "TEMPORARY Trigger time: " << trigger.TriggerTime() << std::endl; + triggerTime = trigger.TriggerTime(); + if ( fVerbose ) std::cout << "Valid trigger product found. Trigger time: " << trigger.TriggerTime() << ", Beam gate time: " << trigger.BeamGateTime() << ", Difference: " << trigger.TriggerTime() - trigger.BeamGateTime() << std::endl; } else if ( fVerbose ) std::cout << "No valid trigger product found for this event!" << std::endl; @@ -432,22 +426,25 @@ void BarycenterMatchProducer::produce(art::Event& e) art::Handle const flashHandle = e.getHandle>(fOpFlashLabel + inputTag); art::FindMany fmOpHits(flashHandle, e, fOpFlashLabel + inputTag); - int nFlashes = (*flashHandle).size(); std::array triggerFlashCenter = {-9999., -9999.}; - double flashTime_Trigger; - //For flash... - for ( int i = 0; i < nFlashes; i++ ) { - const recob::OpFlash &flash = (*flashHandle)[i]; - - std::cout << "TEMPORARY flash.Time(): " << flash.Time() << ", flash.AbsTime(): " << flash.AbsTime() << std::endl; - //Is this a triggering flash? - flashTime_Trigger = flash.Time(); - if ( !isData ) flashTime_Trigger -= triggerWithinGate; - if ( triggeredEvt && abs(flashTime_Trigger + fTriggerDelay) < fTriggerTolerance ) triggerFlashCenter = {flash.YCenter(), flash.ZCenter()}; + //If triggered event.. + if ( triggerTime >= 0. ) { + double minTimeDiff = 1.6; + //For flash... + for ( int i = 0; i < nFlashes; i++ ) { + const recob::OpFlash &flash = (*flashHandle)[i]; + + //Identify the triggering flash + double timeDiff = abs( (triggerTime - flash.AbsTime()) - fTriggerDelay ); + if ( timeDiff < fTriggerTolerance && timeDiff < minTimeDiff ) { + triggerFlashCenter = {flash.YCenter(), flash.ZCenter()}; + minTimeDiff = timeDiff; + } - } //End for flash + } //End for flash + } //End if triggered event if ( fVerbose ) std::cout << "Event: " << fEvent << ", Cryo: " << inputTag << ", nFlashes: " << nFlashes << ", Triggering flash center Y: " << triggerFlashCenter[0] << ", Triggering flash center Z: " << triggerFlashCenter[1] << std::endl; @@ -496,9 +493,8 @@ void BarycenterMatchProducer::produce(art::Event& e) double thisCharge; double sumCharge = 0.; - //Forcing Git to recognize there was a change here... - TVector3 sumPos {0.,0.,0.};//Forcing Git to recognize there was a change here... - TVector3 sumPosSqr {0.,0.,0.};//Forcing Git to recognize there was a change here... + TVector3 sumPos {0.,0.,0.}; + TVector3 sumPosSqr {0.,0.,0.}; //For hit... for ( int k = 0; k < nHits; k++ ) { @@ -510,8 +506,8 @@ void BarycenterMatchProducer::produce(art::Event& e) const recob::SpacePoint point = f1SpacePoint.at(k).ref(); thisCharge = tpcHit->Integral(); - TVector3 const thisPoint = point.XYZ();//Forcing Git to recognize there was a change here... - TVector3 const thisPointSqr {thisPoint.X()*thisPoint.X(), thisPoint.Y()*thisPoint.Y(), thisPoint.Z()*thisPoint.Z()};//Forcing Git to recognize there was a change here... + TVector3 const thisPoint = point.XYZ(); + TVector3 const thisPointSqr {thisPoint.X()*thisPoint.X(), thisPoint.Y()*thisPoint.Y(), thisPoint.Z()*thisPoint.Z()}; sumCharge += thisCharge; sumPos += thisPoint * thisCharge; sumPosSqr += thisPointSqr * thisCharge; @@ -714,7 +710,9 @@ void BarycenterMatchProducer::updateMatchInfo(sbn::BarycenterMatch& matchInfo) { matchInfo.radius = fRadius; matchInfo.overlapY = fOverlapY; matchInfo.overlapZ = fOverlapZ; + matchInfo.deltaY_Trigger = fDeltaY_Trigger; matchInfo.deltaZ_Trigger = fDeltaZ_Trigger; + matchInfo.radius_Trigger = fRadius_Trigger; } //End updateMatchInfo() diff --git a/icaruscode/PMT/OpReco/fcl/barycentermatch_config.fcl b/icaruscode/PMT/OpReco/fcl/barycentermatch_config.fcl index 071271232..4e8f58c5f 100644 --- a/icaruscode/PMT/OpReco/fcl/barycentermatch_config.fcl +++ b/icaruscode/PMT/OpReco/fcl/barycentermatch_config.fcl @@ -26,7 +26,7 @@ barycentermatch_data_params: barycentermatch_mc_params: { TriggerLabel: "emuTrigger" - TriggerDelay: 0.22 + TriggerDelay: 0.02 } ###### From c78a226054d713220373a24cabcb9d7d922960fc Mon Sep 17 00:00:00 2001 From: Jack Smedley Date: Sat, 18 Nov 2023 13:39:06 -0600 Subject: [PATCH 32/34] Change name to be more descriptive --- icaruscode/PMT/OpReco/CMakeLists.txt | 2 +- ...> TPCPMTBarycenterMatchProducer_module.cc} | 70 ++++++------- .../PMT/OpReco/fcl/barycentermatch_config.fcl | 98 ------------------- .../fcl/tpcpmtbarycentermatch_config.fcl | 98 +++++++++++++++++++ ..._mc.fcl => tpcpmtbarycentermatch_data.fcl} | 15 +-- ..._data.fcl => tpcpmtbarycentermatch_mc.fcl} | 15 ++- 6 files changed, 149 insertions(+), 149 deletions(-) rename icaruscode/PMT/OpReco/{BarycenterMatchProducer_module.cc => TPCPMTBarycenterMatchProducer_module.cc} (92%) delete mode 100644 icaruscode/PMT/OpReco/fcl/barycentermatch_config.fcl create mode 100644 icaruscode/PMT/OpReco/fcl/tpcpmtbarycentermatch_config.fcl rename icaruscode/PMT/OpReco/fcl/{barycentermatch_mc.fcl => tpcpmtbarycentermatch_data.fcl} (72%) rename icaruscode/PMT/OpReco/fcl/{barycentermatch_data.fcl => tpcpmtbarycentermatch_mc.fcl} (72%) diff --git a/icaruscode/PMT/OpReco/CMakeLists.txt b/icaruscode/PMT/OpReco/CMakeLists.txt index c047d0ea2..ac84f4f01 100644 --- a/icaruscode/PMT/OpReco/CMakeLists.txt +++ b/icaruscode/PMT/OpReco/CMakeLists.txt @@ -60,7 +60,7 @@ cet_build_plugin(ICARUSOpFlashAna art::module LIBRARIES ${MODULE_LIBRARIES}) cet_build_plugin(ICARUSOpHitAna art::module LIBRARIES ${MODULE_LIBRARIES}) cet_build_plugin(ICARUSOpHitTuple art::module LIBRARIES ${MODULE_LIBRARIES}) cet_build_plugin(ICARUSParticleAna art::module LIBRARIES ${MODULE_LIBRARIES}) -cet_build_plugin(BarycenterMatchProducer art::module LIBRARIES ${MODULE_LIBRARIES}) +cet_build_plugin(TPCPMTBarycenterMatchProducer art::module LIBRARIES ${MODULE_LIBRARIES}) install_headers() diff --git a/icaruscode/PMT/OpReco/BarycenterMatchProducer_module.cc b/icaruscode/PMT/OpReco/TPCPMTBarycenterMatchProducer_module.cc similarity index 92% rename from icaruscode/PMT/OpReco/BarycenterMatchProducer_module.cc rename to icaruscode/PMT/OpReco/TPCPMTBarycenterMatchProducer_module.cc index e9dd02e60..c283db978 100644 --- a/icaruscode/PMT/OpReco/BarycenterMatchProducer_module.cc +++ b/icaruscode/PMT/OpReco/TPCPMTBarycenterMatchProducer_module.cc @@ -1,12 +1,12 @@ //////////////////////////////////////////////////////////////////////// -// Class: BarycenterMatchProducer +// Class: TPCPMTBarycenterMatchProducer // Plugin Type: producer (Unknown Unknown) -// File: BarycenterMatchProducer_module.cc +// File: TPCPMTBarycenterMatchProducer_module.cc // // Generated at Sun Oct 22 14:43:16 2023 by John Smedley using cetskelgen // from version . // -// @file icaruscode/PMT/OpReco/BarycenterMatchProducer_module.cc +// @file icaruscode/PMT/OpReco/TPCPMTBarycenterMatchProducer_module.cc // @brief Producer to match Pandora slices to their best match OpFlash by minimizing barycenter distance, as well as compare slices to the triggering OpFlash // @author Jack Smedley ( jsmedley@fnal.gov ) // @@ -48,7 +48,7 @@ #include "lardataobj/RecoBase/PFParticle.h" #include "lardataobj/AnalysisBase/T0.h" #include "lardataobj/RawData/TriggerData.h" -#include "sbnobj/Common/Reco/BarycenterMatch.h" +#include "sbnobj/Common/Reco/TPCPMTBarycenterMatch.h" //ROOT includes #include "TTree.h" @@ -165,16 +165,16 @@ using electronics_time = detinfo::timescales::electronics_time; * A single collection, merging all the input, is produced for each of the * following data products in the _art_/ROOT output: * - * * `std::vector`: collection of matching information; + * * `std::vector`: collection of matching information; * one matching information object is present for each slice in the input * collections, in the same order as the input. - * * `art::Assns`: association of each + * * `art::Assns`: association of each * matched slice with its matching information. - * * `art::Assns`: association of each + * * `art::Assns`: association of each * matched light flash with its matching information. * * Note that while there is currently no direct association between the slice - * and the flash, the information contained in `sbn::BarycenterMatch` is very + * and the flash, the information contained in `sbn::TPCPMTBarycenterMatch` is very * detailed. * * In addition, if `FillMatchTree` is set, a ROOT tree called `matchTree` will @@ -216,17 +216,17 @@ using electronics_time = detinfo::timescales::electronics_time; * sides by this amount of time. * */ -class BarycenterMatchProducer : public art::EDProducer { +class TPCPMTBarycenterMatchProducer : public art::EDProducer { public: - explicit BarycenterMatchProducer(fhicl::ParameterSet const& p); + explicit TPCPMTBarycenterMatchProducer(fhicl::ParameterSet const& p); // The compiler-generated destructor is fine for non-base // classes without bare pointers or other resource use. // Plugins should not be copied or assigned. - BarycenterMatchProducer(BarycenterMatchProducer const&) = delete; - BarycenterMatchProducer(BarycenterMatchProducer&&) = delete; - BarycenterMatchProducer& operator=(BarycenterMatchProducer const&) = delete; - BarycenterMatchProducer& operator=(BarycenterMatchProducer&&) = delete; + TPCPMTBarycenterMatchProducer(TPCPMTBarycenterMatchProducer const&) = delete; + TPCPMTBarycenterMatchProducer(TPCPMTBarycenterMatchProducer&&) = delete; + TPCPMTBarycenterMatchProducer& operator=(TPCPMTBarycenterMatchProducer const&) = delete; + TPCPMTBarycenterMatchProducer& operator=(TPCPMTBarycenterMatchProducer&&) = delete; // Required functions. void produce(art::Event& e) override; @@ -239,7 +239,7 @@ class BarycenterMatchProducer : public art::EDProducer { double CalculateAsymmetry(art::Ptr flash, int cryo); ///< Return the east-west asymmetry of PEs in a given OpFlash void updateChargeVars(double sumCharge, TVector3 const& sumPos, TVector3 const& sumPosSqr, std::array const& triggerFlashCenter); ///< Update slice-level data members with charge and trigger match info void updateFlashVars(art::Ptr flash, double firstHit); ///< Update slice-level data members with best match info - void updateMatchInfo(sbn::BarycenterMatch& matchInfo); ///< Update match product with slice-level data members + void updateMatchInfo(sbn::TPCPMTBarycenterMatch& matchInfo); ///< Update match product with slice-level data members // Input parameters std::vector fInputTags; ///< Suffix added onto fOpFlashLabel and fPandoraLabel, used by ICARUS for separate cryostat labels but could be empty @@ -297,7 +297,7 @@ class BarycenterMatchProducer : public art::EDProducer { }; -BarycenterMatchProducer::BarycenterMatchProducer(fhicl::ParameterSet const& p) +TPCPMTBarycenterMatchProducer::TPCPMTBarycenterMatchProducer(fhicl::ParameterSet const& p) : EDProducer{p}, // More initializers here. fInputTags(p.get>("InputTags")), @@ -318,9 +318,9 @@ BarycenterMatchProducer::BarycenterMatchProducer(fhicl::ParameterSet const& p) { // Call appropriate produces<>() functions here. - produces< std::vector >(); - produces< art::Assns >(); - produces< art::Assns >(); + produces< std::vector >(); + produces< art::Assns >(); + produces< art::Assns >(); // Call appropriate consumes<>() for any products to be retrieved by this module. consumes>(fTriggerLabel); @@ -382,7 +382,7 @@ BarycenterMatchProducer::BarycenterMatchProducer(fhicl::ParameterSet const& p) } -void BarycenterMatchProducer::produce(art::Event& e) +void TPCPMTBarycenterMatchProducer::produce(art::Event& e) { // Implementation of required member function here. fEvent = e.id().event(); @@ -405,10 +405,10 @@ void BarycenterMatchProducer::produce(art::Event& e) lar::util::TrackTimeInterval const timeIntervals = fTimeIntervalMaker(detProp, detTimings); //Initialize new data products - auto matchInfoVector = std::make_unique< std::vector >(); - art::PtrMaker< sbn::BarycenterMatch > const makeInfoPtr(e); - auto sliceAssns = std::make_unique< art::Assns >(); - auto flashAssns = std::make_unique< art::Assns >(); + auto matchInfoVector = std::make_unique< std::vector >(); + art::PtrMaker< sbn::TPCPMTBarycenterMatch > const makeInfoPtr(e); + auto sliceAssns = std::make_unique< art::Assns >(); + auto flashAssns = std::make_unique< art::Assns >(); //For InputTag... for ( const std::string& inputTag : fInputTags ) { @@ -469,7 +469,7 @@ void BarycenterMatchProducer::produce(art::Event& e) fSliceNum = j; const art::Ptr slicePtr { sliceHandle, j }; InitializeSlice(); - sbn::BarycenterMatch sliceMatchInfo; + sbn::TPCPMTBarycenterMatch sliceMatchInfo; updateMatchInfo(sliceMatchInfo); const std::vector> &tpcHitsVec = fmTPCHits.at(j); @@ -516,7 +516,7 @@ void BarycenterMatchProducer::produce(art::Event& e) //No charge found in slice... if ( sumCharge == 0. ) { if ( fFillMatchTree ) fMatchTree->Fill(); - art::Ptr const infoPtr = makeInfoPtr(matchInfoVector->size()); + art::Ptr const infoPtr = makeInfoPtr(matchInfoVector->size()); sliceAssns->addSingle(infoPtr, slicePtr); matchInfoVector->push_back(std::move(sliceMatchInfo)); if ( fVerbose ) std::cout << "No charge found in Event: " << fEvent << " Slice: " << j << "! Continuing..." << std::endl; @@ -556,7 +556,7 @@ void BarycenterMatchProducer::produce(art::Event& e) //No valid match found... if ( matchIndex == -5 ) { if ( fFillMatchTree ) fMatchTree->Fill(); - art::Ptr const infoPtr = makeInfoPtr(matchInfoVector->size()); + art::Ptr const infoPtr = makeInfoPtr(matchInfoVector->size()); sliceAssns->addSingle(infoPtr, slicePtr); matchInfoVector->push_back(std::move(sliceMatchInfo)); if ( fVerbose ) std::cout << "No matching flash found for Event: " << fEvent << " Slice: " << j << "! Continuing..." << std::endl; @@ -575,7 +575,7 @@ void BarycenterMatchProducer::produce(art::Event& e) //Update match info updateFlashVars(flashPtr, minTime); updateMatchInfo(sliceMatchInfo); - art::Ptr const infoPtr = makeInfoPtr(matchInfoVector->size()); + art::Ptr const infoPtr = makeInfoPtr(matchInfoVector->size()); sliceAssns->addSingle(infoPtr, slicePtr); flashAssns->addSingle(infoPtr, flashPtr); matchInfoVector->push_back(std::move(sliceMatchInfo)); @@ -592,7 +592,7 @@ void BarycenterMatchProducer::produce(art::Event& e) } //End produce() -void BarycenterMatchProducer::InitializeSlice() { +void TPCPMTBarycenterMatchProducer::InitializeSlice() { fChargeT0 = -9999.; fChargeTotal = -9999.; fChargeCenterXGlobal = -9999.; @@ -621,7 +621,7 @@ void BarycenterMatchProducer::InitializeSlice() { } //End InitializeSlice() -double BarycenterMatchProducer::CentroidOverlap(double center1, double center2, double width1, double width2) const { +double TPCPMTBarycenterMatchProducer::CentroidOverlap(double center1, double center2, double width1, double width2) const { //Centroid 2 is contained within Centroid 1, so overlap is the whole Centroid 2 if ( (center1 - width1 < center2 - width2) && (center1 + width1 > center2 + width2) ) return (2 * width2); @@ -634,7 +634,7 @@ double BarycenterMatchProducer::CentroidOverlap(double center1, double center2, } //End CentroidOverlap() -double BarycenterMatchProducer::CalculateAsymmetry(art::Ptr flash, int cryo) { +double TPCPMTBarycenterMatchProducer::CalculateAsymmetry(art::Ptr flash, int cryo) { double sumEast = 0.; double sumWest = 0.; @@ -654,7 +654,7 @@ double BarycenterMatchProducer::CalculateAsymmetry(art::Ptr flas //TODO: Get the cathode position and shift global X to local X in a less hacky way //According to a geometrydump, the cathode X positions are +/-(210.14, 210.29), depending on the TPC. Here I just averaged those... -void BarycenterMatchProducer::updateChargeVars(double sumCharge, TVector3 const& sumPos, TVector3 const& sumPosSqr, std::array const& triggerFlashCenter) { +void TPCPMTBarycenterMatchProducer::updateChargeVars(double sumCharge, TVector3 const& sumPos, TVector3 const& sumPosSqr, std::array const& triggerFlashCenter) { fChargeCenterXGlobal = sumPos[0] / sumCharge; fChargeCenterXLocal = fChargeCenterXGlobal - 210.215 * (2*fCryo - 1); fChargeCenterY = sumPos[1] / sumCharge; @@ -670,7 +670,7 @@ void BarycenterMatchProducer::updateChargeVars(double sumCharge, TVector3 const& } //End updateChargeVars() -void BarycenterMatchProducer::updateFlashVars(art::Ptr flash, double firstHit) { +void TPCPMTBarycenterMatchProducer::updateFlashVars(art::Ptr flash, double firstHit) { double matchedTime = flash->Time(); double matchedYCenter = flash->YCenter(); double matchedZCenter = flash->ZCenter(); @@ -694,7 +694,7 @@ void BarycenterMatchProducer::updateFlashVars(art::Ptr flash, do } //End updateFlashVars() -void BarycenterMatchProducer::updateMatchInfo(sbn::BarycenterMatch& matchInfo) { +void TPCPMTBarycenterMatchProducer::updateMatchInfo(sbn::TPCPMTBarycenterMatch& matchInfo) { matchInfo.chargeTotal = fChargeTotal; matchInfo.chargeCenterXLocal = fChargeCenterXLocal; matchInfo.chargeCenter = {fChargeCenterXGlobal, fChargeCenterY, fChargeCenterZ}; @@ -716,4 +716,4 @@ void BarycenterMatchProducer::updateMatchInfo(sbn::BarycenterMatch& matchInfo) { } //End updateMatchInfo() -DEFINE_ART_MODULE(BarycenterMatchProducer) +DEFINE_ART_MODULE(TPCPMTBarycenterMatchProducer) diff --git a/icaruscode/PMT/OpReco/fcl/barycentermatch_config.fcl b/icaruscode/PMT/OpReco/fcl/barycentermatch_config.fcl deleted file mode 100644 index 4e8f58c5f..000000000 --- a/icaruscode/PMT/OpReco/fcl/barycentermatch_config.fcl +++ /dev/null @@ -1,98 +0,0 @@ -BEGIN_PROLOG - -#Common paramters for the barycenter matching -barycentermatch_common_params: -{ - OpFlashLabel: "opflash" - PandoraLabel: "pandoraGaus" - CollectionOnly: true - UseTimeRange: true - Verbose: false - FillMatchTree: false - TriggerTolerance: 0.15 - TimeRangeMargin: 35. -} - - -#Parameters specific to data and Monte Carlo separately -###### - -barycentermatch_data_params: -{ - TriggerLabel: "daqTrigger" - TriggerDelay: 0.6 -} - -barycentermatch_mc_params: -{ - TriggerLabel: "emuTrigger" - TriggerDelay: 0.02 -} - -###### - - -#Separate configurations for data or MC for running the matching over BOTH cryostats -###### - -data_barycentermatchproducer: -{ - module_type: "icaruscode/PMT/OpReco/BarycenterMatchProducer" - @table::barycentermatch_common_params - @table::barycentermatch_data_params - InputTags: ["CryoE","CryoW"] -} - -mc_barycentermatchproducer: -{ - module_type: "icaruscode/PMT/OpReco/BarycenterMatchProducer" - @table::barycentermatch_common_params - @table::barycentermatch_mc_params - InputTags: ["CryoE","CryoW"] -} - -###### - -#Separate configurations for data or MC for running the matching over the east cryostat -###### - -data_barycentermatchproducer_east: -{ - module_type: "icaruscode/PMT/OpReco/BarycenterMatchProducer" - @table::barycentermatch_common_params - @table::barycentermatch_data_params - InputTags: ["CryoE"] -} - -mc_barycentermatchproducer_east: -{ - module_type: "icaruscode/PMT/OpReco/BarycenterMatchProducer" - @table::barycentermatch_common_params - @table::barycentermatch_mc_params - InputTags: ["CryoE"] -} - -###### - -#Separate configurations for data or MC for running the matching over the west cryostat -###### - -data_barycentermatchproducer_west: -{ - module_type: "icaruscode/PMT/OpReco/BarycenterMatchProducer" - @table::barycentermatch_common_params - @table::barycentermatch_data_params - InputTags: ["CryoW"] -} - -mc_barycentermatchproducer_west: -{ - module_type: "icaruscode/PMT/OpReco/BarycenterMatchProducer" - @table::barycentermatch_common_params - @table::barycentermatch_mc_params - InputTags: ["CryoW"] -} - -###### - -END_PROLOG diff --git a/icaruscode/PMT/OpReco/fcl/tpcpmtbarycentermatch_config.fcl b/icaruscode/PMT/OpReco/fcl/tpcpmtbarycentermatch_config.fcl new file mode 100644 index 000000000..03ebf930c --- /dev/null +++ b/icaruscode/PMT/OpReco/fcl/tpcpmtbarycentermatch_config.fcl @@ -0,0 +1,98 @@ +BEGIN_PROLOG + +#Common paramters for the barycenter matching +tpcpmtbarycentermatch_common_params: +{ + OpFlashLabel: "opflash" + PandoraLabel: "pandoraGaus" + CollectionOnly: true + UseTimeRange: true + Verbose: false + FillMatchTree: false + TriggerTolerance: 0.15 + TimeRangeMargin: 35. +} + + +#Parameters specific to data and Monte Carlo separately +###### + +tpcpmtbarycentermatch_data_params: +{ + TriggerLabel: "daqTrigger" + TriggerDelay: 0.6 +} + +tpcpmtbarycentermatch_mc_params: +{ + TriggerLabel: "emuTrigger" + TriggerDelay: 0.02 +} + +###### + + +#Separate configurations for data or MC for running the matching over BOTH cryostats +###### + +data_tpcpmtbarycentermatchproducer: +{ + module_type: "icaruscode/PMT/OpReco/TPCPMTBarycenterMatchProducer" + @table::tpcpmtbarycentermatch_common_params + @table::tpcpmtbarycentermatch_data_params + InputTags: ["CryoE","CryoW"] +} + +mc_tpcpmtbarycentermatchproducer: +{ + module_type: "icaruscode/PMT/OpReco/TPCPMTBarycenterMatchProducer" + @table::tpcpmtbarycentermatch_common_params + @table::tpcpmtbarycentermatch_mc_params + InputTags: ["CryoE","CryoW"] +} + +###### + +#Separate configurations for data or MC for running the matching over the east cryostat +###### + +data_tpcpmtbarycentermatchproducer_east: +{ + module_type: "icaruscode/PMT/OpReco/TPCPMTBarycenterMatchProducer" + @table::tpcpmtbarycentermatch_common_params + @table::tpcpmtbarycentermatch_data_params + InputTags: ["CryoE"] +} + +mc_tpcpmtbarycentermatchproducer_east: +{ + module_type: "icaruscode/PMT/OpReco/TPCPMTBarycenterMatchProducer" + @table::tpcpmtbarycentermatch_common_params + @table::tpcpmtbarycentermatch_mc_params + InputTags: ["CryoE"] +} + +###### + +#Separate configurations for data or MC for running the matching over the west cryostat +###### + +data_tpcpmtbarycentermatchproducer_west: +{ + module_type: "icaruscode/PMT/OpReco/TPCPMTBarycenterMatchProducer" + @table::tpcpmtbarycentermatch_common_params + @table::tpcpmtbarycentermatch_data_params + InputTags: ["CryoW"] +} + +mc_tpcpmtbarycentermatchproducer_west: +{ + module_type: "icaruscode/PMT/OpReco/TPCPMTBarycenterMatchProducer" + @table::tpcpmtbarycentermatch_common_params + @table::tpcpmtbarycentermatch_mc_params + InputTags: ["CryoW"] +} + +###### + +END_PROLOG diff --git a/icaruscode/PMT/OpReco/fcl/barycentermatch_mc.fcl b/icaruscode/PMT/OpReco/fcl/tpcpmtbarycentermatch_data.fcl similarity index 72% rename from icaruscode/PMT/OpReco/fcl/barycentermatch_mc.fcl rename to icaruscode/PMT/OpReco/fcl/tpcpmtbarycentermatch_data.fcl index ab9d9744a..b264b0b99 100644 --- a/icaruscode/PMT/OpReco/fcl/barycentermatch_mc.fcl +++ b/icaruscode/PMT/OpReco/fcl/tpcpmtbarycentermatch_data.fcl @@ -1,11 +1,11 @@ -# A script to run the producer module: BarycenterMatchProducer +# A script to run the producer module: TPCPMTBarycenterMatchProducer -#include "barycentermatch_config.fcl" +#include "tpcpmtbarycentermatch_config.fcl" #include "services_icarus_simulation.fcl" #include "services_common_icarus.fcl" -process_name: BarycenterMatchProducer +process_name: TPCPMTBarycenterMatchProducer services: { @@ -22,12 +22,13 @@ services: } # services + outputs: { out1: { module_type: RootOutput - fileName: "%ifb_%tc_BarycenterMatch.root" + fileName: "%ifb_%tc_TPCPMTBarycenterMatch.root" dataTier: "reconstructed" saveMemoryObjectThreshold: 0 compressionLevel: 1 @@ -40,12 +41,12 @@ physics: { producers: { - barycentermatchCryoE: @local::mc_barycentermatchproducer_east - barycentermatchCryoW: @local::mc_barycentermatchproducer_west + tpcpmtbarycentermatchCryoE: @local::data_tpcpmtbarycentermatchproducer_east + tpcpmtbarycentermatchCryoW: @local::data_tpcpmtbarycentermatchproducer_west } # Schedule job step(s) for execution by defining the analysis module for this job. - reco: [ barycentermatchCryoE, barycentermatchCryoW ] + reco: [ tpcpmtbarycentermatchCryoE, tpcpmtbarycentermatchCryoW ] stream1: [ out1 ] diff --git a/icaruscode/PMT/OpReco/fcl/barycentermatch_data.fcl b/icaruscode/PMT/OpReco/fcl/tpcpmtbarycentermatch_mc.fcl similarity index 72% rename from icaruscode/PMT/OpReco/fcl/barycentermatch_data.fcl rename to icaruscode/PMT/OpReco/fcl/tpcpmtbarycentermatch_mc.fcl index 1ade68241..8d19e5cae 100644 --- a/icaruscode/PMT/OpReco/fcl/barycentermatch_data.fcl +++ b/icaruscode/PMT/OpReco/fcl/tpcpmtbarycentermatch_mc.fcl @@ -1,11 +1,11 @@ -# A script to run the producer module: BarycenterMatchProducer +# A script to run the producer module: TPCPMTBarycenterMatchProducer -#include "barycentermatch_config.fcl" +#include "tpcpmtbarycentermatch_config.fcl" #include "services_icarus_simulation.fcl" #include "services_common_icarus.fcl" -process_name: BarycenterMatchProducer +process_name: TPCPMTBarycenterMatchProducer services: { @@ -22,13 +22,12 @@ services: } # services - outputs: { out1: { module_type: RootOutput - fileName: "%ifb_%tc_BarycenterMatch.root" + fileName: "%ifb_%tc_TPCPMTBarycenterMatch.root" dataTier: "reconstructed" saveMemoryObjectThreshold: 0 compressionLevel: 1 @@ -41,12 +40,12 @@ physics: { producers: { - barycentermatchCryoE: @local::data_barycentermatchproducer_east - barycentermatchCryoW: @local::data_barycentermatchproducer_west + tpcpmtbarycentermatchCryoE: @local::mc_tpcpmtbarycentermatchproducer_east + tpcpmtbarycentermatchCryoW: @local::mc_tpcpmtbarycentermatchproducer_west } # Schedule job step(s) for execution by defining the analysis module for this job. - reco: [ barycentermatchCryoE, barycentermatchCryoW ] + reco: [ tpcpmtbarycentermatchCryoE, tpcpmtbarycentermatchCryoW ] stream1: [ out1 ] From 27abcb85a6f4efd5e31d9f5f9c182f9d04e67f06 Mon Sep 17 00:00:00 2001 From: Jack Smedley Date: Sat, 18 Nov 2023 13:59:48 -0600 Subject: [PATCH 33/34] Update brief to accomodate sign change in fTriggerDelay --- .../OpReco/TPCPMTBarycenterMatchProducer_module.cc | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/icaruscode/PMT/OpReco/TPCPMTBarycenterMatchProducer_module.cc b/icaruscode/PMT/OpReco/TPCPMTBarycenterMatchProducer_module.cc index c283db978..650341286 100644 --- a/icaruscode/PMT/OpReco/TPCPMTBarycenterMatchProducer_module.cc +++ b/icaruscode/PMT/OpReco/TPCPMTBarycenterMatchProducer_module.cc @@ -135,9 +135,10 @@ using electronics_time = detinfo::timescales::electronics_time; * flash. * In ICARUS data, the time reference is the trigger time, therefore the time * of the global trigger is a fixed value by definition. Nevertheless, to - * accommodate relative delays between the trigger and the light systems, a - * "nominal" trigger time (`TriggerDelay`) is used instead of the actual - * one, and this other time is controlled directly by the module caller. + * accommodate relative delays between the trigger and the light systems, an + * expected time difference between the reconstrcuted flash (`TriggerDelay`) + * is accounted for with a cushion ('TriggerTolerance'). These parameters are + * measured in microseconds and controlled directly by the module caller. * In ICARUS simulation the mechanism is the same; the times are stored with * respect to the simulation time, but the module will take care of * the appropriate conversion, so the configuration parameter holds the same @@ -207,8 +208,8 @@ using electronics_time = detinfo::timescales::electronics_time; * * `FillMatchTree` (flag, default: `false`): if set to `true`, a ROOT tree * with detailed matching information called `"matchTree"` will be written * via `TFileService`. - * * `TriggerDelay` (real, mandatory, in microseconds): the time, in - * electronics scale, when the trigger is expected to arrive. + * * `TriggerDelay` (real, mandatory, in microseconds): the expected time + * difference between the scintillation flash and the global trigger. * * `TriggerTolerance` (real, mandatory, in microseconds): the tolerance used * to identify a light flash associated with the trigger. * * `TimeRangeMargin` (real, microseconds; default: `0`): when `UseTimeRange` From 9926f069149bab66ea6bd93d3cb1c9bd353ff3e3 Mon Sep 17 00:00:00 2001 From: Jack Smedley Date: Mon, 20 Nov 2023 21:40:07 -0600 Subject: [PATCH 34/34] Add producers to stage1, redefine label in cafmaker_defs --- fcl/caf/cafmaker_defs.fcl | 1 + fcl/reco/Definitions/stage1_icarus_defs.fcl | 9 +++++++++ fcl/reco/Stage1/Run2/stage1_run2_icarus.fcl | 1 + fcl/reco/Stage1/Run2/stage1_run2_icarus_MC.fcl | 5 +++++ 4 files changed, 16 insertions(+) diff --git a/fcl/caf/cafmaker_defs.fcl b/fcl/caf/cafmaker_defs.fcl index 3431a05a7..b1ac51753 100644 --- a/fcl/caf/cafmaker_defs.fcl +++ b/fcl/caf/cafmaker_defs.fcl @@ -326,6 +326,7 @@ cafmaker.TriggerLabel: "emuTrigger" cafmaker.FlashTrigLabel: "" # unavailable cafmaker.SimChannelLabel: "largeant" cafmaker.SystWeightLabels: ["genieweight", "fluxweight"] +cafmaker.TPCPMTBarycenterMatchLabel: "tpcpmtbarycentermatch" cafmaker.TrackHitFillRREndCut: 30 # include entire PID region # Add CAFMaker to the list of producers diff --git a/fcl/reco/Definitions/stage1_icarus_defs.fcl b/fcl/reco/Definitions/stage1_icarus_defs.fcl index 28beab569..2380db397 100644 --- a/fcl/reco/Definitions/stage1_icarus_defs.fcl +++ b/fcl/reco/Definitions/stage1_icarus_defs.fcl @@ -21,6 +21,7 @@ ## The below can be found from the softlink to Supera in sbncode #include "supera_modules.fcl" #include "crtpmtmatching_parameters.fcl" +#include "tpcpmtbarycentermatch_config.fcl" BEGIN_PROLOG @@ -65,6 +66,9 @@ icarus_stage1_producers: CRTT0Matching: @local::standard_crtt0producer CRTT0MatchingW: @local::standard_crtt0producerW CRTT0MatchingE: @local::standard_crtt0producerE + + tpcpmtbarycentermatchCryoE: @local::data_tpcpmtbarycentermatchproducer_east + tpcpmtbarycentermatchCryoW: @local::data_tpcpmtbarycentermatchproducer_west } icarus_stage1_filters: @@ -191,6 +195,11 @@ icarus_pandora_Gauss: [ icarus_reco_fm: [ fmatchCryoE, fmatchCryoW ] +icarus_tpcpmtbarycentermatch: [ + tpcpmtbarycentermatchCryoE, + tpcpmtbarycentermatchCryoW + ] + icarus_crttrack: [crttrack] icarus_crtt0match: [CRTT0Matching] diff --git a/fcl/reco/Stage1/Run2/stage1_run2_icarus.fcl b/fcl/reco/Stage1/Run2/stage1_run2_icarus.fcl index 45fc0d295..40ea40c2a 100644 --- a/fcl/reco/Stage1/Run2/stage1_run2_icarus.fcl +++ b/fcl/reco/Stage1/Run2/stage1_run2_icarus.fcl @@ -5,6 +5,7 @@ process_name: stage1 physics.reco: [ @sequence::icarus_filter_cluster3D, @sequence::icarus_pandora_Gauss, @sequence::icarus_reco_fm, + @sequence::icarus_tpcpmtbarycentermatch, @sequence::icarus_crttrack, @sequence::icarus_crtt0match, caloskimCalorimetryCryoE, caloskimCalorimetryCryoW] diff --git a/fcl/reco/Stage1/Run2/stage1_run2_icarus_MC.fcl b/fcl/reco/Stage1/Run2/stage1_run2_icarus_MC.fcl index 3f9590ae7..f4e7c7366 100644 --- a/fcl/reco/Stage1/Run2/stage1_run2_icarus_MC.fcl +++ b/fcl/reco/Stage1/Run2/stage1_run2_icarus_MC.fcl @@ -28,10 +28,15 @@ physics.producers: { mcassociationsGausCryoW: @local::standard_mcparticlehitmatching } +#Redefine TPCPMTBarycenterMatch producers with MC parameters +physics.producers.tpcpmtbarycentermatchCryoE: @local::mc_tpcpmtbarycentermatchproducer_east +physics.producers.tpcpmtbarycentermatchCryoW: @local::mc_tpcpmtbarycentermatchproducer_west + physics.reco: [ @sequence::icarus_reco_Gauss_CryoE , @sequence::icarus_reco_Gauss_CryoW , @sequence::icarus_reco_fm, + @sequence::icarus_tpcpmtbarycentermatch, caloskimCalorimetryCryoE, caloskimCalorimetryCryoW, mcassociationsGausCryoE, mcassociationsGausCryoW ]