diff --git a/sbncode/CAFMaker/CAFMaker_module.cc b/sbncode/CAFMaker/CAFMaker_module.cc index 80e099102..7621fc6cf 100644 --- a/sbncode/CAFMaker/CAFMaker_module.cc +++ b/sbncode/CAFMaker/CAFMaker_module.cc @@ -1664,26 +1664,50 @@ void CAFMaker::produce(art::Event& evt) noexcept { // Get all of the OpFlashes std::vector srflashes; + if(fDet == kICARUS) + { + for (const std::string& pandora_tag_suffix : pandora_tag_suffixes) { + art::Handle> flashes_handle; + GetByLabelStrict(evt, fParams.OpFlashLabel() + pandora_tag_suffix, flashes_handle); + // fill into event + if (flashes_handle.isValid()) { + const std::vector &opflashes = *flashes_handle; + int cryostat = ( pandora_tag_suffix.find("W") != std::string::npos ) ? 1 : 0; - for (const std::string& pandora_tag_suffix : pandora_tag_suffixes) { - art::Handle> flashes_handle; - GetByLabelStrict(evt, fParams.OpFlashLabel() + pandora_tag_suffix, flashes_handle); - // fill into event - 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); - // get associated OpHits for each OpFlash - art::FindMany findManyHits(flashes_handle, evt, fParams.OpFlashLabel() + pandora_tag_suffix); + int iflash=0; + for (const recob::OpFlash& flash : opflashes) { - int iflash=0; - for (const recob::OpFlash& flash : opflashes) { + std::vector const& ophits = findManyHits.at(iflash); - std::vector const& ophits = findManyHits.at(iflash); + srflashes.emplace_back(); + FillICARUSOpFlash(flash, ophits, cryostat, srflashes.back()); + iflash++; + } + } + } + } + else if(fDet == kSBND) + { + std::vector tpc_suffixes_sbnd = {"tpc0", "tpc1"}; - srflashes.emplace_back(); - FillOpFlash(flash, ophits, cryostat, srflashes.back()); - iflash++; + for (size_t tpc=0; tpc> flashes_handle; + GetByLabelStrict(evt, fParams.OpFlashLabel() + tpc_suffixes_sbnd[tpc], flashes_handle); + // fill into event + if (flashes_handle.isValid()) { + const std::vector &opflashes = *flashes_handle; + // get associated OpHits for each OpFlash + art::FindMany findManyHits(flashes_handle, evt, fParams.OpFlashLabel() + tpc_suffixes_sbnd[tpc]); + int iflash=0; + for (const recob::OpFlash& flash : opflashes) { + std::vector const& ophits = findManyHits.at(iflash); + srflashes.emplace_back(); + FillSBNDOpFlash(flash, ophits, tpc, srflashes.back()); + iflash++; + } } } } diff --git a/sbncode/CAFMaker/FillReco.cxx b/sbncode/CAFMaker/FillReco.cxx index 59d8e69f3..a37b83e9e 100644 --- a/sbncode/CAFMaker/FillReco.cxx +++ b/sbncode/CAFMaker/FillReco.cxx @@ -179,7 +179,7 @@ namespace caf } - void FillOpFlash(const recob::OpFlash &flash, + void FillICARUSOpFlash(const recob::OpFlash &flash, std::vector const& hits, int cryo, caf::SROpFlash &srflash, @@ -227,6 +227,41 @@ namespace caf } } + void FillSBNDOpFlash(const recob::OpFlash &flash, + std::vector const& hits, + int tpc, + caf::SROpFlash &srflash, + bool allowEmpty) { + + srflash.setDefault(); + + srflash.time = flash.Time(); + srflash.timewidth = flash.TimeWidth(); + + double firstTime = std::numeric_limits::max(); + for(const auto& hit: hits){ + double const hitTime = hit->HasStartTime()? hit->StartTime(): hit->PeakTime(); + if (firstTime > hitTime) + firstTime = hitTime; + } + srflash.firsttime = firstTime; + srflash.tpc = tpc; + + srflash.totalpe = flash.TotalPE(); + srflash.fasttototal = flash.FastToTotal(); + srflash.onbeamtime = flash.OnBeamTime(); + + srflash.center.SetXYZ( -9999.f, flash.YCenter(), flash.ZCenter() ); + srflash.width.SetXYZ( -9999.f, flash.YWidth(), flash.ZWidth() ); + + // Checks if ( recob::OpFlash.XCenter() != std::numeric_limits::max() ) + // See LArSoft OpFlash.h at https://nusoft.fnal.gov/larsoft/doxsvn/html/OpFlash_8h_source.html + if ( flash.hasXCenter() ) { + srflash.center.SetX( flash.XCenter() ); + srflash.width.SetX( flash.XWidth() ); + } + } + std::vector double_to_float_vector(const std::vector& v) { std::vector ret; diff --git a/sbncode/CAFMaker/FillReco.h b/sbncode/CAFMaker/FillReco.h index c6df1ab39..6bc38ad92 100644 --- a/sbncode/CAFMaker/FillReco.h +++ b/sbncode/CAFMaker/FillReco.h @@ -217,11 +217,18 @@ namespace caf caf::SRSBNDCRTTrack &srsbndcrttrack, bool allowEmpty = false); - void FillOpFlash(const recob::OpFlash &flash, + void FillICARUSOpFlash(const recob::OpFlash &flash, std::vector const& hits, int cryo, caf::SROpFlash &srflash, bool allowEmpty = false); + + void FillSBNDOpFlash(const recob::OpFlash &flash, + std::vector const& hits, + int tpc, + caf::SROpFlash &srflash, + bool allowEmpty = false); + void FillCRTPMTMatch(const sbn::crt::CRTPMTMatching &match, caf::SRCRTPMTMatch &srmatch, bool allowEmpty = false);