LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
TriggerAlgoBase.cc
Go to the documentation of this file.
1 //
3 // \file TriggerAlgoBase_service.cc
4 //
6 
7 #include "TriggerAlgoBase.h"
8 
10 
11 namespace trigger {
12 
13  //****************************************************************************
15  {
16  //****************************************************************************
17 
19 
20  Config(pset);
21  }
22 
23  //****************************************************************************
25  {
26  //****************************************************************************
27 
28  _preceeding_slices = pset.get<int>("PreceedingWindow");
29 
30  _proceeding_slices = pset.get<int>("ProceedingWindow");
31 
32  _deadtime = pset.get<int>("DeadTime");
33  }
34 
35  //****************************************************************************
37  {
38  //****************************************************************************
39 
40  if (_sim_done) return;
41 
42  _time_windows.clear();
43 
44  trigdata::TrigTimeSlice_t last_timestamp = 0;
45 
46  trigdata::TrigTimeSlice_t window_begin = 0;
47 
48  trigdata::TrigTimeSlice_t window_end = 0;
49 
51  iter != _timestamps.end();
52  ++iter) {
53 
54  if (!(last_timestamp) || (*iter) > (last_timestamp + _deadtime)) {
55 
56  window_begin = ((*iter) > _preceeding_slices) ? ((*iter) - _preceeding_slices) : 0;
57 
58  window_end = (*iter) + _proceeding_slices;
59 
60  _time_windows.insert(std::make_pair(window_end, window_begin));
61 
62  last_timestamp = (*iter);
63  }
64  }
65 
66  _sim_done = true;
67  }
68 
69  //****************************************************************************
71  {
72  //****************************************************************************
73 
74  if (!_time_windows.size()) return false;
75 
77  _time_windows.lower_bound(time));
78 
79  if (start_time == _time_windows.end())
80  return false;
81 
82  else
83  return ((*start_time).second < time);
84  }
85 
86 } // namespace trigger
uint64_t TrigTimeSlice_t
A unit of time used in trigger logic.
Definition: TriggerTypes.hh:9
std::set< trigdata::TrigTimeSlice_t > _timestamps
stores CANDIDATE readout trigger timestamps
trigdata::TrigTimeSlice_t _proceeding_slices
proceeding readout-window from trigger time stamp
intermediate_table::const_iterator const_iterator
trigdata::TrigTimeSlice_t _preceeding_slices
preceeding readout-window from trigger time stamp
std::map< trigdata::TrigTimeSlice_t, trigdata::TrigTimeSlice_t > _time_windows
stores VALID readout trigger time windows
T get(std::string const &key) const
Definition: ParameterSet.h:314
TriggerAlgoBase(fhicl::ParameterSet const &pset)
virtual void SimTrigger()
Function to analyze _timestamps and store valid readout windows in _time_windows. ...
bool _sim_done
run utility boolean, set to true after trigger simulation is run
void Config(fhicl::ParameterSet const &pset)
Function to extract fhicl parameters.
bool IsTriggered(trigdata::TrigTimeSlice_t time) const
Function to check if "time" (input arg.) is within any of valid readout windows or not...
trigdata::TrigTimeSlice_t _deadtime
trigger deadtime AFTER each valid trigger timestamps
virtual void ClearTriggerInfo()
Function to clear simulated trigger information.