From a0442281b318a78250046bd034f005630e26f7ab Mon Sep 17 00:00:00 2001 From: Anna Heggestuen Date: Mon, 2 Jun 2025 19:00:57 -0500 Subject: [PATCH 1/5] read PMTBeamSignal into the CAFMaker to be passed to FillICARUSOpFlash --- sbncode/CAFMaker/CAFMakerParams.h | 6 ++++++ sbncode/CAFMaker/CAFMaker_module.cc | 15 +++++++++++++-- sbncode/CAFMaker/CMakeLists.txt | 1 + 3 files changed, 20 insertions(+), 2 deletions(-) diff --git a/sbncode/CAFMaker/CAFMakerParams.h b/sbncode/CAFMaker/CAFMakerParams.h index 253f0d4c2..572bb5545 100644 --- a/sbncode/CAFMaker/CAFMakerParams.h +++ b/sbncode/CAFMaker/CAFMakerParams.h @@ -374,6 +374,12 @@ namespace caf "OpFlash" }; + Atom PMTBeamSignalLabel { + Name("PMTBeamSignalLabel"), + Comment("Label for special PMT beam timing signals used to build the beam bunch structure"), + "beamTiming:RWM" + }; + Atom CRTSimT0Offset { Name("CRTSimT0Offset"), Comment("start of beam gate/simulation time in the simulated CRT clock"), diff --git a/sbncode/CAFMaker/CAFMaker_module.cc b/sbncode/CAFMaker/CAFMaker_module.cc index 48da84e8f..31212aec0 100644 --- a/sbncode/CAFMaker/CAFMaker_module.cc +++ b/sbncode/CAFMaker/CAFMaker_module.cc @@ -1669,6 +1669,10 @@ void CAFMaker::produce(art::Event& evt) noexcept { std::vector srflashes; if(fDet == kICARUS) { + //Get all of the special PMT Beam Signals (to use as an opFlash reference time below) + art::Handle> PMTBeamSignal_handle; + GetByLabelStrict(evt, fParams.PMTBeamSignalLabel(), PMTBeamSignal_handle); + for (const std::string& pandora_tag_suffix : pandora_tag_suffixes) { art::Handle> flashes_handle; GetByLabelStrict(evt, fParams.OpFlashLabel() + pandora_tag_suffix, flashes_handle); @@ -1676,7 +1680,7 @@ void CAFMaker::produce(art::Event& evt) noexcept { if (flashes_handle.isValid()) { const std::vector &opflashes = *flashes_handle; int cryostat = ( pandora_tag_suffix.find("W") != std::string::npos ) ? 1 : 0; - + // get associated OpHits for each OpFlash art::FindMany findManyHits(flashes_handle, evt, fParams.OpFlashLabel() + pandora_tag_suffix); @@ -1686,7 +1690,14 @@ void CAFMaker::produce(art::Event& evt) noexcept { std::vector const& ophits = findManyHits.at(iflash); srflashes.emplace_back(); - FillICARUSOpFlash(flash, ophits, cryostat, srflashes.back()); + if(PMTBeamSignal_handle.isValid() && isRealData){ + const std::vector &pmtbeamsignals = *PMTBeamSignal_handle; + FillICARUSOpFlash(flash, ophits, cryostat, pmtbeamsignals, srflashes.back()); + } + else{ + const std::vector pmtbeamsignals; + FillICARUSOpFlash(flash, ophits, cryostat, pmtbeamsignals, srflashes.back()); + } iflash++; } } diff --git a/sbncode/CAFMaker/CMakeLists.txt b/sbncode/CAFMaker/CMakeLists.txt index 76c3903d4..4cae127e2 100644 --- a/sbncode/CAFMaker/CMakeLists.txt +++ b/sbncode/CAFMaker/CMakeLists.txt @@ -35,6 +35,7 @@ art_make_library( LIBRARY_NAME sbncode_CAFMaker sbnobj::Common_CRT sbnobj::Common_Reco sbnobj::Common_Analysis + sbnobj::Common_PMT_Data sbnobj::SBND_CRT lardataalg::DetectorInfo art::Framework_Services_System_TriggerNamesService_service From 505cdc88702a885e9f64c756ad5a521b6a26521f Mon Sep 17 00:00:00 2001 From: Anna Heggestuen Date: Mon, 2 Jun 2025 19:06:33 -0500 Subject: [PATCH 2/5] within FillICARUSOpFlash, reconstruct the flash time w.r.t. RWM time using information stored in PMTBeamSignal --- sbncode/CAFMaker/FillReco.cxx | 6 ++++++ sbncode/CAFMaker/FillReco.h | 2 ++ 2 files changed, 8 insertions(+) diff --git a/sbncode/CAFMaker/FillReco.cxx b/sbncode/CAFMaker/FillReco.cxx index d81cb5890..75c46cea5 100644 --- a/sbncode/CAFMaker/FillReco.cxx +++ b/sbncode/CAFMaker/FillReco.cxx @@ -183,6 +183,7 @@ namespace caf void FillICARUSOpFlash(const recob::OpFlash &flash, std::vector const& hits, int cryo, + std::vector RWMTimes, caf::SROpFlash &srflash, bool allowEmpty) { @@ -192,11 +193,16 @@ namespace caf srflash.timewidth = flash.TimeWidth(); double firstTime = std::numeric_limits::max(); + std::map startmap, risemap; for(const auto& hit: hits){ double const hitTime = hit->HasStartTime()? hit->StartTime(): hit->PeakTime(); if (firstTime > hitTime) firstTime = hitTime; + if (!RWMTimes.empty()) + sbn::timing::SelectFirstOpHitByTime(hit,startmap,risemap); } + srflash.rwmtime = getFlashBunchTime(risemap, RWMTimes); + std::cout << "Flash at Time " << flash.Time() << " has " << startmap.size() << " opHit channels, flashTime_rwm = " << srflash.rwmtime << " \n"; srflash.firsttime = firstTime; srflash.cryo = cryo; // 0 in SBND, 0/1 for E/W in ICARUS diff --git a/sbncode/CAFMaker/FillReco.h b/sbncode/CAFMaker/FillReco.h index 6e8ecf292..4b24b4a98 100644 --- a/sbncode/CAFMaker/FillReco.h +++ b/sbncode/CAFMaker/FillReco.h @@ -42,6 +42,7 @@ #include "sbnobj/SBND/CRT/CRTTrack.hh" #include "sbnobj/Common/CRT/CRTPMTMatching.hh" #include "sbnobj/Common/CRT/CRTHitT0TaggingInfo.hh" +#include "sbnobj/Common/PMT/Data/PMTBeamSignal.hh" #include "nusimdata/SimulationBase/MCParticle.h" #include "nusimdata/SimulationBase/MCTruth.h" @@ -256,6 +257,7 @@ namespace caf void FillICARUSOpFlash(const recob::OpFlash &flash, std::vector const& hits, int cryo, + std::vector RWMTimes, caf::SROpFlash &srflash, bool allowEmpty = false); From 9aa0be95ae6243b768c7099dc5a622faeedd431a Mon Sep 17 00:00:00 2001 From: Anna Heggestuen Date: Mon, 2 Jun 2025 19:07:29 -0500 Subject: [PATCH 3/5] remove cout statement --- sbncode/CAFMaker/FillReco.cxx | 1 - 1 file changed, 1 deletion(-) diff --git a/sbncode/CAFMaker/FillReco.cxx b/sbncode/CAFMaker/FillReco.cxx index 75c46cea5..0d69d594b 100644 --- a/sbncode/CAFMaker/FillReco.cxx +++ b/sbncode/CAFMaker/FillReco.cxx @@ -202,7 +202,6 @@ namespace caf sbn::timing::SelectFirstOpHitByTime(hit,startmap,risemap); } srflash.rwmtime = getFlashBunchTime(risemap, RWMTimes); - std::cout << "Flash at Time " << flash.Time() << " has " << startmap.size() << " opHit channels, flashTime_rwm = " << srflash.rwmtime << " \n"; srflash.firsttime = firstTime; srflash.cryo = cryo; // 0 in SBND, 0/1 for E/W in ICARUS From a492b433631af51e140042bae88e8aa7667f2cc6 Mon Sep 17 00:00:00 2001 From: Anna Heggestuen Date: Thu, 5 Jun 2025 14:17:32 -0500 Subject: [PATCH 4/5] remove startmap from SelectFirstOpHitByTime as it is not needed --- sbncode/CAFMaker/FillReco.cxx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sbncode/CAFMaker/FillReco.cxx b/sbncode/CAFMaker/FillReco.cxx index 0d69d594b..cb3dc5f6c 100644 --- a/sbncode/CAFMaker/FillReco.cxx +++ b/sbncode/CAFMaker/FillReco.cxx @@ -193,13 +193,13 @@ namespace caf srflash.timewidth = flash.TimeWidth(); double firstTime = std::numeric_limits::max(); - std::map startmap, risemap; + std::map risemap; for(const auto& hit: hits){ double const hitTime = hit->HasStartTime()? hit->StartTime(): hit->PeakTime(); if (firstTime > hitTime) firstTime = hitTime; if (!RWMTimes.empty()) - sbn::timing::SelectFirstOpHitByTime(hit,startmap,risemap); + sbn::timing::SelectFirstOpHitByTime(hit,risemap); } srflash.rwmtime = getFlashBunchTime(risemap, RWMTimes); srflash.firsttime = firstTime; From 0f63559060a95327629ecc23a7844cb256e5513c Mon Sep 17 00:00:00 2001 From: Anna Heggestuen Date: Thu, 5 Jun 2025 14:33:47 -0500 Subject: [PATCH 5/5] use GetByLabelIfExists for PMTBeamSignalLabel --- sbncode/CAFMaker/CAFMaker_module.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sbncode/CAFMaker/CAFMaker_module.cc b/sbncode/CAFMaker/CAFMaker_module.cc index 31212aec0..b2cdb15f8 100644 --- a/sbncode/CAFMaker/CAFMaker_module.cc +++ b/sbncode/CAFMaker/CAFMaker_module.cc @@ -1671,7 +1671,7 @@ void CAFMaker::produce(art::Event& evt) noexcept { { //Get all of the special PMT Beam Signals (to use as an opFlash reference time below) art::Handle> PMTBeamSignal_handle; - GetByLabelStrict(evt, fParams.PMTBeamSignalLabel(), PMTBeamSignal_handle); + GetByLabelIfExists(evt, fParams.PMTBeamSignalLabel(), PMTBeamSignal_handle); for (const std::string& pandora_tag_suffix : pandora_tag_suffixes) { art::Handle> flashes_handle;