All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
TriggerAlgoBase.cc
Go to the documentation of this file.
1 ////////////////////////////////////////////////////////////////////////
2 //
3 // \file TriggerAlgoBase_service.cc
4 //
5 ////////////////////////////////////////////////////////////////////////
6 
7 #include "TriggerAlgoBase.h"
8 
9 #include "fhiclcpp/ParameterSet.h"
10 
11 namespace trigger{
12 
13  //****************************************************************************
14  TriggerAlgoBase::TriggerAlgoBase(fhicl::ParameterSet const& pset) {
15  //****************************************************************************
16 
18 
19  Config(pset);
20 
21  }
22 
23  //****************************************************************************
24  void TriggerAlgoBase::Config(fhicl::ParameterSet const& pset) {
25  //****************************************************************************
26 
27  _preceeding_slices = pset.get< int >("PreceedingWindow");
28 
29  _proceeding_slices = pset.get< int >("ProceedingWindow");
30 
31  _deadtime = pset.get< int >("DeadTime");
32 
33  }
34 
35 
36  //****************************************************************************
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 
50  for(std::set<trigdata::TrigTimeSlice_t>::const_iterator iter(_timestamps.begin());
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  }
67 
68  _sim_done = true;
69 
70  }
71 
72  //****************************************************************************
74  //****************************************************************************
75 
76  if(!_time_windows.size()) return false;
77 
78  std::map<trigdata::TrigTimeSlice_t,trigdata::TrigTimeSlice_t>::const_iterator start_time(_time_windows.lower_bound(time));
79 
80  if(start_time==_time_windows.end()) return false;
81 
82  else return ((*start_time).second < time);
83 
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
trigdata::TrigTimeSlice_t _preceeding_slices
preceeding readout-window from trigger time stamp
TriggerAlgoBase(fhicl::ParameterSet const &pset)
then echo fcl sbnd_project sbnd_project sbnd_project sbnd_project production production start_time
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
std::map< trigdata::TrigTimeSlice_t, trigdata::TrigTimeSlice_t > _time_windows
stores VALID readout trigger time windows
void Config(fhicl::ParameterSet const &pset)
Function to extract fhicl parameters.
bool IsTriggered(trigdata::TrigTimeSlice_t time) const
Function to check if &quot;time&quot; (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.