LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
trigger::TriggerAlgoBase Class Referenceabstract

#include "TriggerAlgoBase.h"

Public Member Functions

 TriggerAlgoBase (fhicl::ParameterSet const &pset)
 
virtual ~TriggerAlgoBase ()=default
 
virtual void RunTriggerSim (const art::Event &event)
 Function to run trigger simulation ... children class may be override. More...
 
virtual void ClearTriggerInfo ()
 Function to clear simulated trigger information. More...
 
bool HasRunTriggerSim () const
 Getter for a boolean which "true" value indicates trigger simulation is run already. More...
 
bool IsTriggered (trigdata::TrigTimeSlice_t time) const
 Function to check if "time" (input arg.) is within any of valid readout windows or not. More...
 
const std::map< trigdata::TrigTimeSlice_t, trigdata::TrigTimeSlice_t > * GetTimeWindows () const
 Getter to a const pointer of _time_windows std::map variable. More...
 
const std::set< trigdata::TrigTimeSlice_t > * GetTriggerTimeStamps () const
 Getter to a const pointer of _timestamps std::set variable. More...
 

Protected Member Functions

virtual void FillData (const art::Event &event)=0
 Function to fill _timestamps std::set variable ... TO BE IMPLEMENTED in children. More...
 
virtual void SimTrigger ()
 Function to analyze _timestamps and store valid readout windows in _time_windows. More...
 
void Config (fhicl::ParameterSet const &pset)
 Function to extract fhicl parameters. More...
 

Protected Attributes

std::set< trigdata::TrigTimeSlice_t_timestamps
 stores CANDIDATE readout trigger timestamps More...
 
std::map< trigdata::TrigTimeSlice_t, trigdata::TrigTimeSlice_t_time_windows
 stores VALID readout trigger time windows More...
 
trigdata::TrigTimeSlice_t _preceeding_slices
 preceeding readout-window from trigger time stamp More...
 
trigdata::TrigTimeSlice_t _proceeding_slices
 proceeding readout-window from trigger time stamp More...
 
trigdata::TrigTimeSlice_t _deadtime
 trigger deadtime AFTER each valid trigger timestamps More...
 
bool _sim_done
 run utility boolean, set to true after trigger simulation is run More...
 

Detailed Description

Simple read-out trigger logic base class. This class applies a logic of data readout trigger.

Given an input array of readout trigger timestamps, this module applies trigger deadtime and readout window to decide which data packet to be readout and stored.

In the following, I use a notation TS to represent trigdata::TrigTimeSlice_t for short. Note TS is what is used as absolute scale of time in this algorithm. Each experiment may implement different reference point or unit to this time scale. See TriggerTypes.h for definition.

std::set<TS> _timestamps should be filled with time-stamps (with an arbitrary unit of your choise) of readout candidate triggers. This should be done in FillData(art::Event& event) function, which is virtual in this header and needs to be implemented in the inherited class.

After filling timestamps, one calls SimTrigger() to analyze and decide time windows during which incoming data should be readout and stored. This function stores a valid readout time window in the std::map<TS,TS> type variable, _time_windows. This map contains the ending time stamp of each readout window as a key, and the starting time stamp as a value.

Once SimTrigger() is called, then one can ask whether a specific time T is within the valid readout windows or not by a function, IsTriggered(TS time). This function returns true if the given time stamp is included in any of valid readout window. Else, returns false.

For further specifications that may have to do with a specific experiment or electronics should implement their specific complications in the inherited class. This includes FillData() virtual function since different experiments certainly have different data format from which readout trigger candidates' timestamp is extracted.

Note: IsTriggered(TS time) function performs a search of closest readout window to "time", and hence could be expensive (though stl::upper_bound is pretty fast).

Definition at line 69 of file TriggerAlgoBase.h.

Constructor & Destructor Documentation

trigger::TriggerAlgoBase::TriggerAlgoBase ( fhicl::ParameterSet const &  pset)

Definition at line 14 of file TriggerAlgoBase.cc.

References ClearTriggerInfo(), and Config().

15  {
16  //****************************************************************************
17 
19 
20  Config(pset);
21  }
void Config(fhicl::ParameterSet const &pset)
Function to extract fhicl parameters.
virtual void ClearTriggerInfo()
Function to clear simulated trigger information.
virtual trigger::TriggerAlgoBase::~TriggerAlgoBase ( )
virtualdefault

Member Function Documentation

virtual void trigger::TriggerAlgoBase::ClearTriggerInfo ( )
inlinevirtual

Function to clear simulated trigger information.

Definition at line 83 of file TriggerAlgoBase.h.

Referenced by TriggerAlgoBase().

84  {
85  _sim_done = false;
86  _timestamps.clear();
87  _time_windows.clear();
88  };
std::set< trigdata::TrigTimeSlice_t > _timestamps
stores CANDIDATE readout trigger timestamps
std::map< trigdata::TrigTimeSlice_t, trigdata::TrigTimeSlice_t > _time_windows
stores VALID readout trigger time windows
bool _sim_done
run utility boolean, set to true after trigger simulation is run
void trigger::TriggerAlgoBase::Config ( fhicl::ParameterSet const &  pset)
protected

Function to extract fhicl parameters.

Definition at line 24 of file TriggerAlgoBase.cc.

References _deadtime, _preceeding_slices, _proceeding_slices, and fhicl::ParameterSet::get().

Referenced by TriggerAlgoBase().

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  }
trigdata::TrigTimeSlice_t _proceeding_slices
proceeding readout-window from trigger time stamp
trigdata::TrigTimeSlice_t _preceeding_slices
preceeding readout-window from trigger time stamp
trigdata::TrigTimeSlice_t _deadtime
trigger deadtime AFTER each valid trigger timestamps
virtual void trigger::TriggerAlgoBase::FillData ( const art::Event event)
protectedpure virtual

Function to fill _timestamps std::set variable ... TO BE IMPLEMENTED in children.

const std::map<trigdata::TrigTimeSlice_t, trigdata::TrigTimeSlice_t>* trigger::TriggerAlgoBase::GetTimeWindows ( ) const
inline

Getter to a const pointer of _time_windows std::map variable.

Definition at line 97 of file TriggerAlgoBase.h.

98  {
99  return &_time_windows;
100  };
std::map< trigdata::TrigTimeSlice_t, trigdata::TrigTimeSlice_t > _time_windows
stores VALID readout trigger time windows
const std::set<trigdata::TrigTimeSlice_t>* trigger::TriggerAlgoBase::GetTriggerTimeStamps ( ) const
inline

Getter to a const pointer of _timestamps std::set variable.

Definition at line 103 of file TriggerAlgoBase.h.

104  {
105  return &_timestamps;
106  };
std::set< trigdata::TrigTimeSlice_t > _timestamps
stores CANDIDATE readout trigger timestamps
bool trigger::TriggerAlgoBase::HasRunTriggerSim ( ) const
inline

Getter for a boolean which "true" value indicates trigger simulation is run already.

Definition at line 91 of file TriggerAlgoBase.h.

91 { return _sim_done; };
bool _sim_done
run utility boolean, set to true after trigger simulation is run
bool trigger::TriggerAlgoBase::IsTriggered ( trigdata::TrigTimeSlice_t  time) const

Function to check if "time" (input arg.) is within any of valid readout windows or not.

Definition at line 70 of file TriggerAlgoBase.cc.

References _time_windows.

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  }
intermediate_table::const_iterator const_iterator
std::map< trigdata::TrigTimeSlice_t, trigdata::TrigTimeSlice_t > _time_windows
stores VALID readout trigger time windows
virtual void trigger::TriggerAlgoBase::RunTriggerSim ( const art::Event event)
inlinevirtual

Function to run trigger simulation ... children class may be override.

Definition at line 76 of file TriggerAlgoBase.h.

77  {
78  FillData(event);
79  SimTrigger();
80  };
virtual void FillData(const art::Event &event)=0
Function to fill _timestamps std::set variable ... TO BE IMPLEMENTED in children. ...
virtual void SimTrigger()
Function to analyze _timestamps and store valid readout windows in _time_windows. ...
void trigger::TriggerAlgoBase::SimTrigger ( )
protectedvirtual

Function to analyze _timestamps and store valid readout windows in _time_windows.

Definition at line 36 of file TriggerAlgoBase.cc.

References _deadtime, _preceeding_slices, _proceeding_slices, _sim_done, _time_windows, and _timestamps.

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  }
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
bool _sim_done
run utility boolean, set to true after trigger simulation is run
trigdata::TrigTimeSlice_t _deadtime
trigger deadtime AFTER each valid trigger timestamps

Member Data Documentation

trigdata::TrigTimeSlice_t trigger::TriggerAlgoBase::_deadtime
protected

trigger deadtime AFTER each valid trigger timestamps

Definition at line 131 of file TriggerAlgoBase.h.

Referenced by Config(), and SimTrigger().

trigdata::TrigTimeSlice_t trigger::TriggerAlgoBase::_preceeding_slices
protected

preceeding readout-window from trigger time stamp

Definition at line 125 of file TriggerAlgoBase.h.

Referenced by Config(), and SimTrigger().

trigdata::TrigTimeSlice_t trigger::TriggerAlgoBase::_proceeding_slices
protected

proceeding readout-window from trigger time stamp

Definition at line 128 of file TriggerAlgoBase.h.

Referenced by Config(), and SimTrigger().

bool trigger::TriggerAlgoBase::_sim_done
protected

run utility boolean, set to true after trigger simulation is run

Definition at line 134 of file TriggerAlgoBase.h.

Referenced by SimTrigger().

std::map<trigdata::TrigTimeSlice_t, trigdata::TrigTimeSlice_t> trigger::TriggerAlgoBase::_time_windows
protected

stores VALID readout trigger time windows

Definition at line 122 of file TriggerAlgoBase.h.

Referenced by IsTriggered(), and SimTrigger().

std::set<trigdata::TrigTimeSlice_t> trigger::TriggerAlgoBase::_timestamps
protected

stores CANDIDATE readout trigger timestamps

Definition at line 119 of file TriggerAlgoBase.h.

Referenced by SimTrigger().


The documentation for this class was generated from the following files: