All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
OpDetWaveformMetaUtils.cxx
Go to the documentation of this file.
1 /**
2  * @file icaruscode/PMT/Algorithms/OpDetWaveformMetaUtils.cxx
3  * @brief Writes a collection of sbn::OpDetWaveformMeta from PMT waveforms.
4  * @author Gianluca Petrillo (petrillo@slac.stanford.edu)
5  * @date November 22, 2021
6  * @see icaruscode/PMT/Algorithms/OpDetWaveformMetaUtils.h
7  */
8 
9 
10 // library header
12 
13 // LArSoft libraries
16 
17 
18 // -----------------------------------------------------------------------------
19 // --- sbn::OpDetWaveformMetaMaker
20 // -----------------------------------------------------------------------------
23  : fOpDetTickPeriod{ detTimings.OpticalClockPeriod() }
24  , fTriggerTime{ detTimings.TriggerTime() }
25  , fBeamGateTime{ detTimings.BeamGateTime() }
26  {}
27 
28 
29 // -----------------------------------------------------------------------------
31  : fOpDetTickPeriod{ opDetTickPeriod }
32  {}
33 
34 
35 // -----------------------------------------------------------------------------
37  (raw::OpDetWaveform const& waveform) const
38 {
39 
41 
42  raw::Channel_t const channel = waveform.ChannelNumber();
43  std::size_t const nSamples = waveform.Waveform().size();
44  electronics_time const startTime { waveform.TimeStamp() };
45  electronics_time const endTime
46  = startTime + waveform.Waveform().size() * fOpDetTickPeriod;
47 
49  channel // channel
50  , nSamples // nSamples
51  , startTime.value() // startTime
52  , endTime.value() // endTime
53  /* the following are left default:
54  // flags
55  */
56  };
57 
58  auto const setFlag = [&info]
60  { if (value) info.flags.set(flag); else info.flags.unset(flag); };
61 
62  auto const isInWaveform = [startTime,endTime](electronics_time t)
63  { return (t >= startTime) && (t < endTime); };
64 
65  if (fTriggerTime) {
66  setFlag
67  (sbn::OpDetWaveformMeta::bits::WithTrigger, isInWaveform(*fTriggerTime));
68  }
69 
70  if (fBeamGateTime) {
71  setFlag
72  (sbn::OpDetWaveformMeta::bits::WithBeamGate, isInWaveform(*fBeamGateTime));
73  }
74 
75  return info;
76 
77 } // sbn::OpDetWaveformMetaMaker::make()
78 
79 
80 // -----------------------------------------------------------------------------
81 // --- functions
82 // -----------------------------------------------------------------------------
84  raw::OpDetWaveform const& waveform,
85  detinfo::DetectorTimings const& detTimings
86 ) {
87  return sbn::OpDetWaveformMetaMaker{ detTimings }.make(waveform);
88 }
89 
90 
92  raw::OpDetWaveform const& waveform,
94 ) {
95  return sbn::OpDetWaveformMetaMaker{ opDetTickPeriod }.make(waveform);
96 }
97 
98 
99 // -----------------------------------------------------------------------------
electronics_time BeamGateTime() const
Writes a collection of sbn::OpDetWaveformMeta from PMT waveforms.
sbn::OpDetWaveformMeta make(raw::OpDetWaveform const &waveform) const
Creates a sbn::OpDetWaveformMeta out of the specified waveform.
OpDetWaveformMeta makeOpDetWaveformMeta(raw::OpDetWaveform const &waveform, detinfo::DetectorTimings const &detTimings)
Creates a sbn::OpDetWaveformMeta out of a raw::OpDetWaveform.
then echo unknown compiler flag
Derivative information from raw::OpDetWaveform data.
std::vector< ADC_Count_t > & Waveform()
Interface to detinfo::DetectorClocks.
detinfo::timescales::electronics_time electronics_time
OpDetWaveformMetaMaker(detinfo::DetectorTimings const &detTimings)
typename Mask_t::Flag_t Flag_t
Type identifying a single flag.
Definition: FlagSet.h:60
An interval (duration, length, distance) between two quantity points.
Definition: intervals.h:114
electronics_time TriggerTime() const
static constexpr Flag_t WithBeamGate
Whether this time interval includes the nominal beam gate opening.
Converter from raw::OpDetWaveform into sbn::OpDetWaveformMeta.
static constexpr Flag_t WithTrigger
Whether this time interval includes the hardware trigger time.
A class exposing an upgraded interface of detinfo::DetectorClocksData.
temporary value
fDetProps &fDetProps fDetProps &fDetProps detTimings
auto OpticalClockPeriod() const
Returns the duration of the optical clock period and tick.
timescale_traits< ElectronicsTimeCategory >::time_point_t electronics_time
A point in time on the electronics time scale.