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 f3c381ebd..f51183b46 100644 --- a/sbncode/CAFMaker/CAFMaker_module.cc +++ b/sbncode/CAFMaker/CAFMaker_module.cc @@ -1668,6 +1668,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; + GetByLabelIfExists(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); @@ -1675,7 +1679,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); @@ -1685,7 +1689,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 diff --git a/sbncode/CAFMaker/FillReco.cxx b/sbncode/CAFMaker/FillReco.cxx index d81cb5890..cb3dc5f6c 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,15 @@ namespace caf srflash.timewidth = flash.TimeWidth(); double firstTime = std::numeric_limits::max(); + 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,risemap); } + srflash.rwmtime = getFlashBunchTime(risemap, RWMTimes); 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);