66 std::vector<std::array<raw::TimeStamp_t, 2>> this_trigger_ranges;
67 const std::vector<raw::ADC_Count_t> &adcs = waveform;
78 bool is_arapuca =
false;
79 if( opdet_type.find(
"arapuca") != std::string::npos ) is_arapuca =
true;
80 bool is_daphne =
false;
82 if (sampling_type ==
"daphne") is_daphne =
true;
90 if (start > trigger_window[1])
return;
91 size_t start_i = start > trigger_window[0] ? 0 : (size_t)((trigger_window[0] - start) / optical_period(clockData,is_daphne));
96 tick_to_timestamp(clockData, waveform.
TimeStamp(), start_i,is_daphne))) {
101 tick_to_timestamp(clockData, waveform.
TimeStamp(), start_i,is_daphne)));
104 if (start_i >= adcs.size())
return;
108 size_t end_i = end < trigger_window[1] ? adcs.size()-1 : (size_t)((trigger_window[1] - start) / optical_period(clockData,is_daphne));
113 tick_to_timestamp(clockData, waveform.
TimeStamp(), end_i+1,is_daphne)) && end_i+1 < adcs.size()) {
118 tick_to_timestamp(clockData, waveform.
TimeStamp(), end_i+1,is_daphne)));
120 std::vector<std::array<raw::TimeStamp_t, 2>> this_trigger_locations;
121 bool above_threshold =
false;
122 bool beam_trigger_added =
false;
123 double t_since_last_trigger = 99999.;
127 for (
size_t i = start_i; i <= end_i; i++) {
129 t_since_last_trigger += optical_period(clockData,is_daphne);
130 bool isLive = (t_since_last_trigger > t_deadtime);
133 if (isLive && !above_threshold && val > threshold) {
135 trigger_start = time;
136 above_threshold =
true;
137 t_since_last_trigger = 0;
140 else if (above_threshold && (val < threshold || i+1 == end_i)) {
143 above_threshold =
false;
150 beam_trigger_added =
true;
151 t_since_last_trigger = 0;
165 for (
const std::array<raw::TimeStamp_t, 2> &trigger_range: this_trigger_ranges) {
fhicl::Atom< int > PulsePolarityArapuca
bool IsTriggerEnabled(detinfo::DetectorClocksData const &clockData, detinfo::DetectorPropertiesData const &detProp, raw::TimeStamp_t trigger_time) const
fhicl::Atom< int > TriggerThresholdADCPMT
std::array< double, 2 > TriggerEnableWindow(detinfo::DetectorClocksData const &clockData, detinfo::DetectorPropertiesData const &detProp) const
std::map< raw::Channel_t, std::vector< std::array< raw::TimeStamp_t, 2 > > > fTriggerRangesPerChannel
std::size_t size(FixedBins< T, C > const &) noexcept
double TimeStamp_t
us since 1970, based on TimeService
fhicl::Atom< int > TriggerThresholdADCArapuca
opdet::sbndPDMapAlg fOpDetMap
auto end(FixedBins< T, C > const &) noexcept
void AddTriggerLocation(std::vector< std::array< raw::TimeStamp_t, 2 >> &triggers, std::array< raw::TimeStamp_t, 2 > range)
fhicl::Atom< bool > BeamTriggerEnable
fhicl::Atom< double > TriggerHoldoff
fhicl::Atom< double > BeamTriggerHoldoff
std::string electronicsType(size_t ch) const
fhicl::Atom< double > BeamTriggerTime
std::string pdType(size_t ch) const override
fhicl::Atom< int > PulsePolarityPMT