All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
DynamicTriggerGateBuilder.h
Go to the documentation of this file.
1 /**
2  * @file icaruscode/PMT/Trigger/Algorithms/DynamicTriggerGateBuilder.h
3  * @brief Dynamic gate builder.
4  * @author Gianluca Petrillo (petrillo@slac.stanford.edu)
5  * @date April 1, 2019
6  * @see `icaruscode/PMT/Trigger/Algorithms/DynamicTriggerGateBuilder.cxx`
7  *
8  */
9 
10 #ifndef ICARUSCODE_PMT_TRIGGER_ALGORITHMS_DYNAMICTRIGGERGATEBUILDER_H
11 #define ICARUSCODE_PMT_TRIGGER_ALGORITHMS_DYNAMICTRIGGERGATEBUILDER_H
12 
13 
14 // ICARUS libraries
17 
18 // LArSoft libraries
21 
22 // framework libraries
23 #include "messagefacility/MessageLogger/MessageLogger.h"
24 #include "fhiclcpp/types/Atom.h"
25 
26 // C/C++ standard libraries
27 #include <vector>
28 
29 
30 namespace icarus::trigger {
31 
32  // ---------------------------------------------------------------------------
33  //
34  // declarations
35  //
36 
37  class DynamicTriggerGateBuilder;
38 
39  // ---------------------------------------------------------------------------
40 
41 } // namespace icarus::trigger
42 
43 
44 //------------------------------------------------------------------------------
45 /**
46  * @brief Dynamic gate builder.
47  * @see `icarus::trigger::FixedTriggerGateBuilder`
48  *
49  * Gates are opened when the waveform goes above threshold, and closed when it
50  * goes below.
51  *
52  * By construction a gate with higher threshold will be fully included in one
53  * with lower threshold.
54  *
55  */
58 {
60 
61  class DynamicGateManager: private GateManager {
62 
63  struct DynamicGateInfo: public GateInfoBase {
64  DynamicGateInfo(TriggerGate_t& gate): GateInfoBase(gate) {}
65 
66  void belowThresholdAt(optical_tick tick) { gate().closeAt(tick.value()); }
67  void aboveThresholdAt(optical_tick tick) { gate().openAt(tick.value()); }
68 
69  }; // struct DynamicGateInfo
70 
71  public:
73 
74  DynamicGateManager() = default;
75 
76  GateInfo_t create(GateInfo_t::TriggerGate_t& gate) const
77  { return { gate }; }
78 
79  }; // struct DynamicGateManager
80 
81  public:
82 
83  // --- BEGIN Configuration ---------------------------------------------------
84  struct Config: public Base_t::Config {
85 
86  using Name = fhicl::Name;
87  using Comment = fhicl::Comment;
88 
89 
90  }; // struct Config
91  // --- END Configuration -----------------------------------------------------
92 
93 
94  /// Constructor: sets the configuration.
96  : Base_t(config) {}
97 
98 
99  /// Returns a collection of `TriggerGates` objects sorted by threshold.
100  virtual std::vector<TriggerGates> build
101  (std::vector<WaveformWithBaseline> const& waveforms) const override
102  { return unifiedBuild(DynamicGateManager(), waveforms); }
103 
104 
105 }; // class icarus::trigger::DynamicTriggerGateBuilder
106 
107 
108 //------------------------------------------------------------------------------
109 
110 
111 #endif // ICARUSCODE_PMT_TRIGGER_ALGORITHMS_DYNAMICTRIGGERGATEBUILDER_H
GateInfo_t create(GateInfo_t::TriggerGate_t &gate) const
virtual std::vector< TriggerGates > build(std::vector< WaveformWithBaseline > const &waveforms) const override
Returns a collection of TriggerGates objects sorted by threshold.
Simple type definitions for trigger algorithms.
tick_as<> tick
Tick number, represented by std::ptrdiff_t.
Definition: electronics.h:75
BEGIN_PROLOG vertical distance to the surface Name
Algorithm to produce trigger gates out of optical readout waveforms.
Dimensioned variables related to electronics.
timescale_traits< OpticalTimeCategory >::tick_t optical_tick
DynamicTriggerGateBuilder(Config const &config)
Constructor: sets the configuration.
std::vector< TriggerGates > unifiedBuild(GateMgr &&gateManager, std::vector< WaveformWithBaseline > const &waveforms) const
Returns a collection of TriggerGates objects sorted by threshold.