From 536905ba10646764670283e56b8333905f9954f8 Mon Sep 17 00:00:00 2001 From: Riccardo Triozzi Date: Tue, 14 Oct 2025 19:38:36 -0500 Subject: [PATCH 1/4] added new ICARUS HW trigger info --- sbncode/CAFMaker/FillTrigger.cxx | 53 +++++++++++++++++++++++++++----- sbncode/CAFMaker/FillTrigger.h | 1 - 2 files changed, 45 insertions(+), 9 deletions(-) diff --git a/sbncode/CAFMaker/FillTrigger.cxx b/sbncode/CAFMaker/FillTrigger.cxx index 009deccef..75b385f77 100644 --- a/sbncode/CAFMaker/FillTrigger.cxx +++ b/sbncode/CAFMaker/FillTrigger.cxx @@ -4,9 +4,9 @@ namespace caf { void FillTrigger(const sbn::ExtraTriggerInfo& addltrig_info, - const raw::Trigger& trig, - caf::SRTrigger& triggerInfo, - const double time_offset = 0.0) + const raw::Trigger& trig, + caf::SRTrigger& triggerInfo, + const double time_offset = 0.0) { triggerInfo.global_trigger_time = addltrig_info.triggerTimestamp; triggerInfo.beam_gate_time_abs = addltrig_info.beamGateTimestamp; @@ -14,7 +14,6 @@ namespace caf triggerInfo.global_trigger_det_time = trig.TriggerTime() + time_offset; double diff_ts = triggerInfo.global_trigger_det_time - triggerInfo.beam_gate_det_time; triggerInfo.trigger_within_gate = diff_ts; - triggerInfo.prev_global_trigger_time = addltrig_info.previousTriggerTimestamp; triggerInfo.source_type = sbn::bits::value(addltrig_info.sourceType); triggerInfo.trigger_type = sbn::bits::value(addltrig_info.triggerType); @@ -25,14 +24,52 @@ namespace caf triggerInfo.gate_delta = addltrig_info.gateCountFromPreviousTrigger; } - void FillTriggerMC(double absolute_time, caf::SRTrigger& triggerInfo) { + void FillTriggerMC(double absolute_time, caf::SRTrigger& triggerInfo) + { triggerInfo.global_trigger_time = absolute_time; triggerInfo.beam_gate_time_abs = absolute_time; + triggerInfo.trigger_within_gate = 0.; // Set this to 0 since the "MC" trigger is (for now) always at the spill time + } + + void FillTriggerSBND(caf::SRSBNDTimingInfo& timingInfo, + caf::SRTrigger& triggerInfo) + { + triggerInfo.global_trigger_time = timingInfo.hltEtrig; + triggerInfo.beam_gate_time_abs = timingInfo.hltBeamGate; + double diff_ts = triggerInfo.global_trigger_det_time - triggerInfo.beam_gate_det_time; + triggerInfo.trigger_within_gate = diff_ts; + } + + void FillTriggerICARUS(const sbn::ExtraTriggerInfo& addltrig_info, + caf::SRTrigger& triggerInfo) + { + // Per-cryostat additional trigger information, straight from the trigger hardware + const auto& addltrig_info_cryoE = addltrig_info.cryostats[sbn::ExtraTriggerInfo::EastCryostat]; + const auto& addltrig_info_cryoW = addltrig_info.cryostats[sbn::ExtraTriggerInfo::WestCryostat]; - // Set this to 0 since the "MC" trigger is (for now) always at the spill time - triggerInfo.trigger_within_gate = 0.; + // Choose the cryostat that triggered first (if both are available) + if (addltrig_info_cryoE.hasTrigger() && (!addltrig_info_cryoW.hasTrigger() || addltrig_info_cryoE.beamToTrigger <= addltrig_info_cryoW.beamToTrigger)) { + triggerInfo.trigger_cryo_source = 0; ///< East + triggerInfo.trigger_logic_bits = addltrig_info_cryoE.triggerLogicBits; + triggerInfo.beam_to_trigger_time = addltrig_info_cryoE.beamToTrigger; + } + else if (addltrig_info_cryoW.hasTrigger()) { + triggerInfo.trigger_cryo_source = 1; ///< West + triggerInfo.trigger_logic_bits = addltrig_info_cryoW.triggerLogicBits; + triggerInfo.beam_to_trigger_time = addltrig_info_cryoW.beamToTrigger; + } + } - // TODO: fill others? + void FillTriggerEmulation(art::Handle> const& monpulsesFlat, + art::Handle> const& monpulseSizes, + art::Handle const& numPairs, + art::Handle const& passedTrig, + caf::SRTrigger& triggerInfo) + { + triggerInfo.monpulses_flat = *monpulsesFlat; + triggerInfo.monpulse_sizes = *monpulseSizes; + triggerInfo.num_pairs_over_threshold = *numPairs; + triggerInfo.passed_trigger = *passedTrig; } } diff --git a/sbncode/CAFMaker/FillTrigger.h b/sbncode/CAFMaker/FillTrigger.h index b83c2e9f0..f3e510867 100644 --- a/sbncode/CAFMaker/FillTrigger.h +++ b/sbncode/CAFMaker/FillTrigger.h @@ -10,7 +10,6 @@ namespace caf { - void FillTrigger(const sbn::ExtraTriggerInfo& addltrig_info, const raw::Trigger& trig_info, caf::SRTrigger& triggerInfo, From a132aa787ba007f3b3fc8827ea8afc6ca7b88fa8 Mon Sep 17 00:00:00 2001 From: Riccardo Triozzi Date: Wed, 15 Oct 2025 12:12:28 -0500 Subject: [PATCH 2/4] fixed typo --- sbncode/CAFMaker/FillTrigger.cxx | 2 +- sbncode/CAFMaker/FillTrigger.h | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/sbncode/CAFMaker/FillTrigger.cxx b/sbncode/CAFMaker/FillTrigger.cxx index 75b385f77..380aae542 100644 --- a/sbncode/CAFMaker/FillTrigger.cxx +++ b/sbncode/CAFMaker/FillTrigger.cxx @@ -48,7 +48,7 @@ namespace caf const auto& addltrig_info_cryoW = addltrig_info.cryostats[sbn::ExtraTriggerInfo::WestCryostat]; // Choose the cryostat that triggered first (if both are available) - if (addltrig_info_cryoE.hasTrigger() && (!addltrig_info_cryoW.hasTrigger() || addltrig_info_cryoE.beamToTrigger <= addltrig_info_cryoW.beamToTrigger)) { + if (addltrig_info_cryoE.hasTrigger() && (!addltrig_info_cryoW.hasTrigger() || (addltrig_info_cryoE.beamToTrigger <= addltrig_info_cryoW.beamToTrigger))) { triggerInfo.trigger_cryo_source = 0; ///< East triggerInfo.trigger_logic_bits = addltrig_info_cryoE.triggerLogicBits; triggerInfo.beam_to_trigger_time = addltrig_info_cryoE.beamToTrigger; diff --git a/sbncode/CAFMaker/FillTrigger.h b/sbncode/CAFMaker/FillTrigger.h index f3e510867..9dd0e020a 100644 --- a/sbncode/CAFMaker/FillTrigger.h +++ b/sbncode/CAFMaker/FillTrigger.h @@ -17,6 +17,16 @@ namespace caf void FillTriggerMC(double absolute_time, caf::SRTrigger& triggerInfo); + void FillTriggerSBND(caf::SRSBNDTimingInfo& timingInfo, caf::SRTrigger& triggerInfo); + + void FillTriggerICARUS(const sbn::ExtraTriggerInfo& addltrig_info, + caf::SRTrigger& triggerInfo); + + void FillTriggerEmulation(art::Handle> const& monpulsesFlat, + art::Handle> const& monpulseSizes, + art::Handle const& numPairs, + art::Handle const& passedTrig, + caf::SRTrigger& triggerInfo); } #endif From ffaad0875114e839b6b9a0af991d72d669f3c299 Mon Sep 17 00:00:00 2001 From: Riccardo Triozzi Date: Wed, 15 Oct 2025 17:46:35 -0500 Subject: [PATCH 3/4] cleaned up commit from the cherry-pick --- sbncode/CAFMaker/CAFMaker_module.cc | 1 + sbncode/CAFMaker/FillTrigger.cxx | 21 --------------------- sbncode/CAFMaker/FillTrigger.h | 12 +----------- 3 files changed, 2 insertions(+), 32 deletions(-) diff --git a/sbncode/CAFMaker/CAFMaker_module.cc b/sbncode/CAFMaker/CAFMaker_module.cc index 48da84e8f..e2e910454 100644 --- a/sbncode/CAFMaker/CAFMaker_module.cc +++ b/sbncode/CAFMaker/CAFMaker_module.cc @@ -1577,6 +1577,7 @@ void CAFMaker::produce(art::Event& evt) noexcept { caf::SRTrigger srtrigger; if (isValidTrigger) { FillTrigger(*extratrig_handle, trig_handle->at(0), srtrigger, triggerShift); + FillTriggerICARUS(*extratrig_handle, srtrigger); } // If not real data, fill in enough of the SRTrigger to make (e.g.) the CRT // time referencing work. TODO: add more stuff to a "MC"-Trigger? diff --git a/sbncode/CAFMaker/FillTrigger.cxx b/sbncode/CAFMaker/FillTrigger.cxx index 380aae542..2e8d014ea 100644 --- a/sbncode/CAFMaker/FillTrigger.cxx +++ b/sbncode/CAFMaker/FillTrigger.cxx @@ -31,15 +31,6 @@ namespace caf triggerInfo.trigger_within_gate = 0.; // Set this to 0 since the "MC" trigger is (for now) always at the spill time } - void FillTriggerSBND(caf::SRSBNDTimingInfo& timingInfo, - caf::SRTrigger& triggerInfo) - { - triggerInfo.global_trigger_time = timingInfo.hltEtrig; - triggerInfo.beam_gate_time_abs = timingInfo.hltBeamGate; - double diff_ts = triggerInfo.global_trigger_det_time - triggerInfo.beam_gate_det_time; - triggerInfo.trigger_within_gate = diff_ts; - } - void FillTriggerICARUS(const sbn::ExtraTriggerInfo& addltrig_info, caf::SRTrigger& triggerInfo) { @@ -60,16 +51,4 @@ namespace caf } } - void FillTriggerEmulation(art::Handle> const& monpulsesFlat, - art::Handle> const& monpulseSizes, - art::Handle const& numPairs, - art::Handle const& passedTrig, - caf::SRTrigger& triggerInfo) - { - triggerInfo.monpulses_flat = *monpulsesFlat; - triggerInfo.monpulse_sizes = *monpulseSizes; - triggerInfo.num_pairs_over_threshold = *numPairs; - triggerInfo.passed_trigger = *passedTrig; - } - } diff --git a/sbncode/CAFMaker/FillTrigger.h b/sbncode/CAFMaker/FillTrigger.h index 9dd0e020a..0dd78d998 100644 --- a/sbncode/CAFMaker/FillTrigger.h +++ b/sbncode/CAFMaker/FillTrigger.h @@ -6,8 +6,6 @@ #include "sbnanaobj/StandardRecord/SRTrigger.h" #include "lardataobj/RawData/TriggerData.h" -#include - namespace caf { void FillTrigger(const sbn::ExtraTriggerInfo& addltrig_info, @@ -17,16 +15,8 @@ namespace caf void FillTriggerMC(double absolute_time, caf::SRTrigger& triggerInfo); - void FillTriggerSBND(caf::SRSBNDTimingInfo& timingInfo, caf::SRTrigger& triggerInfo); - void FillTriggerICARUS(const sbn::ExtraTriggerInfo& addltrig_info, - caf::SRTrigger& triggerInfo); - - void FillTriggerEmulation(art::Handle> const& monpulsesFlat, - art::Handle> const& monpulseSizes, - art::Handle const& numPairs, - art::Handle const& passedTrig, - caf::SRTrigger& triggerInfo); + caf::SRTrigger& triggerInfo); } #endif From 3f2b0e3e940d3ffc558842ce7ff5803edd91b7b7 Mon Sep 17 00:00:00 2001 From: Riccardo Triozzi Date: Thu, 23 Oct 2025 12:12:05 -0500 Subject: [PATCH 4/4] implemented GP's comment --- sbncode/CAFMaker/FillTrigger.cxx | 24 ++++++++++-------------- 1 file changed, 10 insertions(+), 14 deletions(-) diff --git a/sbncode/CAFMaker/FillTrigger.cxx b/sbncode/CAFMaker/FillTrigger.cxx index 2e8d014ea..868be100f 100644 --- a/sbncode/CAFMaker/FillTrigger.cxx +++ b/sbncode/CAFMaker/FillTrigger.cxx @@ -34,21 +34,17 @@ namespace caf void FillTriggerICARUS(const sbn::ExtraTriggerInfo& addltrig_info, caf::SRTrigger& triggerInfo) { - // Per-cryostat additional trigger information, straight from the trigger hardware - const auto& addltrig_info_cryoE = addltrig_info.cryostats[sbn::ExtraTriggerInfo::EastCryostat]; - const auto& addltrig_info_cryoW = addltrig_info.cryostats[sbn::ExtraTriggerInfo::WestCryostat]; - // Choose the cryostat that triggered first (if both are available) - if (addltrig_info_cryoE.hasTrigger() && (!addltrig_info_cryoW.hasTrigger() || (addltrig_info_cryoE.beamToTrigger <= addltrig_info_cryoW.beamToTrigger))) { - triggerInfo.trigger_cryo_source = 0; ///< East - triggerInfo.trigger_logic_bits = addltrig_info_cryoE.triggerLogicBits; - triggerInfo.beam_to_trigger_time = addltrig_info_cryoE.beamToTrigger; - } - else if (addltrig_info_cryoW.hasTrigger()) { - triggerInfo.trigger_cryo_source = 1; ///< West - triggerInfo.trigger_logic_bits = addltrig_info_cryoW.triggerLogicBits; - triggerInfo.beam_to_trigger_time = addltrig_info_cryoW.beamToTrigger; - } + int const cryo = addltrig_info.cryostats[sbn::ExtraTriggerInfo::EastCryostat].beamToTrigger < addltrig_info.cryostats[sbn::ExtraTriggerInfo::WestCryostat].beamToTrigger + ? sbn::ExtraTriggerInfo::EastCryostat + : sbn::ExtraTriggerInfo::WestCryostat; + + sbn::ExtraTriggerInfo::CryostatInfo const& cryoInfo = addltrig_info.cryostats[cryo]; + if (cryoInfo.hasTrigger()) { + triggerInfo.trigger_cryo_source = cryo; + triggerInfo.trigger_logic_bits = cryoInfo.triggerLogicBits; + triggerInfo.gate_to_trigger_time = static_cast(cryoInfo.beamToTrigger) / 1000.0f; // [us] + } } }