All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
BeamGateMaker.h
Go to the documentation of this file.
1 /**
2  * @file icaruscode/PMT/Trigger/Algorithms/BeamGateMaker.h
3  * @brief Class to create an object representing a beam gate.
4  * @author Gianluca Petrillo (petrillo@slac.stanford.edu)
5  * @date April 1, 2019
6  *
7  * This is a header-only library.
8  */
9 
10 #ifndef ICARUSCODE_PMT_TRIGGER_ALGORITHMS_BEAMGATEMAKER_H
11 #define ICARUSCODE_PMT_TRIGGER_ALGORITHMS_BEAMGATEMAKER_H
12 
13 // ICARUS libraries
15 
16 // LArSoft libraries
18 #include "lardataalg/DetectorInfo/DetectorTimingTypes.h" // detinfo::timescales
20 
21 
22 
23 //------------------------------------------------------------------------------
24 //
25 // declarations
26 //
27 namespace icarus::trigger {
28  class BeamGateMaker;
29 } // namespace icarus::trigger
30 
31 
32 //------------------------------------------------------------------------------
33 /**
34  * @brief Simple utility to generate gates around beam time.
35  *
36  * Example: to create an object describing a beam gate of 10 µs, run:
37  * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.cpp}
38  * using namespace util::quantities::time_literals;
39  *
40  * icarus::trigger::BeamGateMaker makeBeamGate
41  * (*lar::providerFrom<detinfo::DetectorClocks>());
42  *
43  * auto const beamGate = makeBeamGate(10_us);
44  * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
45  *
46  * The time of the gate is in
47  * @ref DetectorClocksOpticalElectronicsTime "optical detector electronics ticks".
48  */
50 
51  detinfo::DetectorTimings const fDetTimings; ///< Detector timing provider.
52 
53  /// Value used for default delay.
54  static constexpr util::quantities::microsecond DefaultDelay { 0.0 };
55 
56 
57  public:
58 
63 
64 
65  /// Constructor: uses a copy of the specified detector timing provider.
67  : fDetTimings(detTimings)
68  {}
69 
70  /// Constructor: uses the specified detector clocks service.
72  : BeamGateMaker(detinfo::makeDetectorTimings(clockData)) {}
73 
74  // --- BEGIN -- Start and end time -------------------------------------------
75  /// @name Start and end time
76  /// @{
77 
78  /// Time of beam gate opening, in optical time scale.
79  /// @param delay opening delay after the nominal beam gate time
81  { return fDetTimings.BeamGateTime() + delay; }
82 
83  /// Time of beam gate closure, in optical time scale.
85  (time_interval const duration, time_interval const delay = DefaultDelay)
86  const
87  { return startTime(delay) + duration; }
88 
89  /// Time of beam gate opening, in optical ticks.
90  /// @param delay opening delay after the nominal beam gate time
92  { return fDetTimings.toOpticalTick(startTime(delay)); }
93 
94  /// Time of beam gate closure, in optical ticks.
96  (time_interval const duration, time_interval const delay = DefaultDelay)
97  const
98  { return fDetTimings.toOpticalTick(endTime(duration, delay)); }
99 
100  /// @}
101  // --- END -- Start and end time ---------------------------------------------
102 
103 
104  // @{
105  /**
106  * @brief Returns a gate object of the specified duration.
107  * @tparam Gate type of gate object to be returned
108  * (default: `icarus::trigger::OpticalTriggerGate`)
109  * @param length duration of the gate to be open
110  * @param delay time from beam gate time when this gate opens (default: `0`)
111  * @return a `Gate` object representing a gate opened at beam gate time
112  *
113  * The returned object represents a gate opening at
114  * @ref DetectorClocksBeamGateTime "beam gate time" (with an optional `delay`)
115  * for the specified duration.
116  * The time of the gate is in
117  * @ref DetectorClocksOpticalElectronicsTime "optical ticks".
118  */
119  template <typename Gate = icarus::trigger::OpticalTriggerGate>
120  Gate make(time_interval length, time_interval delay = DefaultDelay) const
121  {
123  beamGate.gateLevels().openFor
124  (startTick(delay).value(), fDetTimings.toOpticalTicks(length).value());
125  return beamGate;
126  }
127 
128  // alias
129  template <typename Gate = icarus::trigger::OpticalTriggerGate>
130  Gate operator()
131  (time_interval length, time_interval delay = DefaultDelay) const
132  { return make<Gate>(length, delay); }
133  // @}
134 
135 }; // class icarus::trigger::BeamGateMaker
136 
137 
138 //------------------------------------------------------------------------------
139 
140 #endif // ICARUSCODE_PMT_TRIGGER_ALGORITHMS_BEAMGATEMAKER_H
electronics_time BeamGateTime() const
optical_tick toOpticalTick(TimePoint time) const
Returns the time point converted in units of optical time ticks.
util::quantities::intervals::microseconds time_interval
detinfo::timescales::optical_time_ticks optical_time_ticks
Definition: BeamGateMaker.h:62
GateData_t & gateLevels()
Access to the underlying gate level data (mutable).
detinfo::timescales::optical_tick optical_tick
Definition: BeamGateMaker.h:61
timescale_traits< OpticalTimeCategory >::tick_interval_t optical_time_ticks
Interface to detinfo::DetectorClocks.
BeamGateMaker(detinfo::DetectorClocksData const &clockData)
Constructor: uses the specified detector clocks service.
Definition: BeamGateMaker.h:71
Gate make(time_interval length, time_interval delay=DefaultDelay) const
Returns a gate object of the specified duration.
Ticks toOpticalTicks(time_interval time) const
Returns the optical ticks corresponding to a time interval.
static constexpr util::quantities::microsecond DefaultDelay
Value used for default delay.
Definition: BeamGateMaker.h:54
A value measured in the specified unit.
Definition: quantities.h:566
detinfo::DetectorTimings makeDetectorTimings(detinfo::DetectorClocksData const &detClocks)
A trigger gate data object for optical detector electronics.
detinfo::timescales::optical_time optical_time
Definition: BeamGateMaker.h:60
timescale_traits< OpticalTimeCategory >::time_point_t optical_time
A point in time on the optical detector electronics time scale.
detinfo::DetectorTimings const fDetTimings
Detector timing provider.
Definition: BeamGateMaker.h:51
An interval (duration, length, distance) between two quantity points.
Definition: intervals.h:114
BeamGateMaker(detinfo::DetectorTimings const &detTimings)
Constructor: uses a copy of the specified detector timing provider.
Definition: BeamGateMaker.h:66
optical_tick endTick(time_interval const duration, time_interval const delay=DefaultDelay) const
Time of beam gate closure, in optical ticks.
Definition: BeamGateMaker.h:96
timescale_traits< OpticalTimeCategory >::tick_t optical_tick
optical_time startTime(time_interval const delay=DefaultDelay) const
Definition: BeamGateMaker.h:80
Contains all timing reference information for the detector.
optical_time endTime(time_interval const duration, time_interval const delay=DefaultDelay) const
Time of beam gate closure, in optical time scale.
Definition: BeamGateMaker.h:85
Logical multi-level gate associated to one or more waveforms.
A class exposing an upgraded interface of detinfo::DetectorClocksData.
Data types for detinfo::DetectorTimings.
Simple utility to generate gates around beam time.
Definition: BeamGateMaker.h:49
temporary value
fDetProps &fDetProps fDetProps &fDetProps detTimings
void openFor(ClockTick_t tick, ClockTicks_t length, OpeningDiff_t count=1)
Open this gate at the specified time, and close it length ticks later.
optical_tick startTick(time_interval const delay=DefaultDelay) const
Definition: BeamGateMaker.h:91