All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
ManagedTriggerGateBuilder.h
Go to the documentation of this file.
1 /**
2  * @file icaruscode/PMT/Trigger/Algorithms/ManagedTriggerGateBuilder.h
3  * @brief Algorithm to produce trigger gates out of optical readout waveforms.
4  * @author Gianluca Petrillo (petrillo@slac.stanford.edu)
5  * @date April 1, 2019
6  * @see `icaruscode/PMT/Trigger/Algorithms/ManagedTriggerGateBuilder.tcc`
7  *
8  */
9 
10 #ifndef ICARUSCODE_PMT_TRIGGER_ALGORITHMS_MANAGEDTRIGGERGATEBUILDER_H
11 #define ICARUSCODE_PMT_TRIGGER_ALGORITHMS_MANAGEDTRIGGERGATEBUILDER_H
12 
13 
14 // ICARUS libraries
16 
17 // LArSoft libraries
19 
20 // C/C++ standard libraries
21 #include <vector>
22 
23 
24 namespace icarus::trigger {
25 
26  // ---------------------------------------------------------------------------
27  //
28  // declarations
29  //
30 
31  class ManagedTriggerGateBuilder;
32 
33  // ---------------------------------------------------------------------------
34 
35 } // namespace icarus::trigger
36 
37 
38 //------------------------------------------------------------------------------
39 /**
40  * @brief Base interface for gate builders.
41  * @see `icarus::trigger::DynamicTriggerGateBuilder`,
42  * `icarus::trigger::FixedTriggerGateBuilder`
43  *
44  * This base class provides a skeleton building algorithm that can be customised
45  * by templates.
46  * The allowed customization includes what to do when a threshold is crossed
47  * in a gate.
48  *
49  * Note that actions are performed only when the sample crosses a threshold.
50  * The algorithm keeps track at each time of which are the thresholds enclosing
51  * the signal level, and if the level crosses one of them, the gates associated
52  * to those thresholds, and only them, are offered a chance to react.
53  */
56 {
58 
59  public:
60 
61  using Base_t::Base_t;
62 
63  protected:
64 
65  // This class describes the interface of a gate manager but is incomplete.
66  struct GateManager {
67 
68  protected:
69  struct GateInfoBase {
70  // OpticalTriggerGateData_t:
72  // icarus::trigger::ReadoutTriggerGate:
73  using TriggerGateData_t = TriggerGate_t::TriggerGate_t;
74 
75  TriggerGate_t* pGate = nullptr; ///< Pointer to the gate.
76 
78  TriggerGateData_t* operator->() const { return &gate(); }
79  TriggerGateData_t& gate() const { return pGate->gate(); }
80  void addTrackingInfo(raw::OpDetWaveform const& waveform) const
81  { return pGate->tracking().add(&waveform); }
82 
83  void belowThresholdAt(optical_tick tick); // undefined: don't call!
84  void aboveThresholdAt(optical_tick tick); // undefined: don't call!
85 
86  }; // struct GateInfoBase
87 
88  public:
90 
92 
93  }; // struct GateManager
94 
95 
96  /// Returns a collection of `TriggerGates` objects sorted by threshold.
97  template <typename GateMgr>
98  std::vector<TriggerGates> unifiedBuild
99  (GateMgr&& gateManager, std::vector<WaveformWithBaseline> const& waveforms)
100  const;
101 
102  /// Computes the gates for all the waveforms in one optical channel.
103  template <typename GateInfo, typename Waveforms>
104  void buildChannelGates
105  (std::vector<GateInfo>& channelGates, Waveforms const& channelWaveforms)
106  const;
107 
108 }; // class icarus::trigger::ManagedTriggerGateBuilder
109 
110 
111 //------------------------------------------------------------------------------
112 //--- template implementation
113 //------------------------------------------------------------------------------
114 #include "icaruscode/PMT/Trigger/Algorithms/ManagedTriggerGateBuilder.tcc"
115 
116 //------------------------------------------------------------------------------
117 
118 #endif // ICARUSCODE_PMT_TRIGGER_ALGORITHMS_MANAGEDTRIGGERGATEBUILDER_H
void buildChannelGates(std::vector< GateInfo > &channelGates, Waveforms const &channelWaveforms) const
Computes the gates for all the waveforms in one optical channel.
Algorithm to produce trigger gates out of optical readout waveforms.
icarus::trigger::TrackedOpticalTriggerGate< raw::OpDetWaveform > triggergate_t
GateInfo_t create(GateInfo_t::TriggerGate_t &gate) const
tick_as<> tick
Tick number, represented by std::ptrdiff_t.
Definition: electronics.h:75
timescale_traits< OpticalTimeCategory >::tick_t optical_tick
std::vector< TriggerGates > unifiedBuild(GateMgr &&gateManager, std::vector< WaveformWithBaseline > const &waveforms) const
Returns a collection of TriggerGates objects sorted by threshold.
Algorithm to produce trigger gates out of optical readout waveforms.