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 009deccef..868be100f 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,27 @@ 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 + } - // Set this to 0 since the "MC" trigger is (for now) always at the spill time - triggerInfo.trigger_within_gate = 0.; + void FillTriggerICARUS(const sbn::ExtraTriggerInfo& addltrig_info, + caf::SRTrigger& triggerInfo) + { + // Choose the cryostat that triggered first (if both are available) + int const cryo = addltrig_info.cryostats[sbn::ExtraTriggerInfo::EastCryostat].beamToTrigger < addltrig_info.cryostats[sbn::ExtraTriggerInfo::WestCryostat].beamToTrigger + ? sbn::ExtraTriggerInfo::EastCryostat + : sbn::ExtraTriggerInfo::WestCryostat; - // TODO: fill others? + 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] + } } } diff --git a/sbncode/CAFMaker/FillTrigger.h b/sbncode/CAFMaker/FillTrigger.h index b83c2e9f0..0dd78d998 100644 --- a/sbncode/CAFMaker/FillTrigger.h +++ b/sbncode/CAFMaker/FillTrigger.h @@ -6,11 +6,8 @@ #include "sbnanaobj/StandardRecord/SRTrigger.h" #include "lardataobj/RawData/TriggerData.h" -#include - namespace caf { - void FillTrigger(const sbn::ExtraTriggerInfo& addltrig_info, const raw::Trigger& trig_info, caf::SRTrigger& triggerInfo, @@ -18,6 +15,8 @@ namespace caf void FillTriggerMC(double absolute_time, caf::SRTrigger& triggerInfo); + void FillTriggerICARUS(const sbn::ExtraTriggerInfo& addltrig_info, + caf::SRTrigger& triggerInfo); } #endif