22 #ifndef LARDATAALG_DETECTORINFO_DETECTORCLOCKSSTANDARDTRIGGERLOADER_H
23 #define LARDATAALG_DETECTORINFO_DETECTORCLOCKSSTANDARDTRIGGERLOADER_H
29 #include "canvas/Utilities/InputTag.h"
30 #include "cetlib_except/exception.h"
56 template <
typename Event>
57 std::optional<std::pair<double, double>>
62 using TriggerHandle_t =
typename Event::template HandleT<std::vector<raw::Trigger>>;
64 TriggerHandle_t triggerHandle;
65 if (!event.template getByLabel(triggerTag, triggerHandle)) {
return std::nullopt; }
69 auto const& triggers = *triggerHandle;
70 if (triggers.empty()) {
return std::nullopt; }
73 if (triggers.size() != 1) {
74 throw cet::exception(
"setDetectorClocksStandardTrigger")
75 <<
"Found " << triggers.size() <<
" trigger objects in '" << triggerTag.encode()
76 <<
"' (only one trigger per event is supported)\n";
79 auto const& trigger = triggers.front();
80 return std::make_optional(std::make_pair(trigger.TriggerTime(), trigger.BeamGateTime()));
103 template <
typename Event>
104 std::optional<double>
108 using TriggerHandle_t =
typename Event::template HandleT<std::vector<raw::Trigger>>;
110 TriggerHandle_t triggerHandle;
111 if (!event.template getByLabel(triggerTag, triggerHandle))
return std::nullopt;
115 auto const& triggers = *triggerHandle;
116 if (triggers.empty())
return std::nullopt;
119 if (triggers.size() != 1) {
120 throw cet::exception(
"setDetectorClocksStandardTrigger")
121 <<
"Found " << triggers.size() <<
" trigger objects in '" << triggerTag.encode()
122 <<
"' (only one trigger per event is supported)\n";
125 return std::make_optional(triggers.front().TriggerTime());
130 #endif // LARDATAALG_DETECTORINFO_DETECTORCLOCKSSTANDARDTRIGGERLOADER_H
std::optional< double > g4ref_time_for_event(art::InputTag const &triggerTag, Event const &event)
Loads DetectorClocksStandard G4Ref correction times.
std::optional< std::pair< double, double > > trigger_times_for_event(art::InputTag const &triggerTag, Event const &event)
Loads DetectorClocksStandard trigger times.