LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
OpHitAlg.cxx
Go to the documentation of this file.
1 // -*- mode: c++; c-basic-offset: 2; -*-
14 #include "OpHitAlg.h"
15 
24 
25 #include <vector>
26 
27 namespace opdet {
28  //----------------------------------------------------------------------------
29  void RunHitFinder(std::vector<raw::OpDetWaveform> const& opDetWaveformVector,
30  std::vector<recob::OpHit>& hitVector,
31  pmtana::PulseRecoManager const& pulseRecoMgr,
32  pmtana::PMTPulseRecoBase const& threshAlg,
33  geo::GeometryCore const& geometry,
34  float hitThreshold,
35  detinfo::DetectorClocksData const& clocksData,
36  calib::IPhotonCalibrator const& calibrator,
37  bool use_start_time)
38  {
39 
40  for (auto const& waveform : opDetWaveformVector) {
41 
42  const int channel = static_cast<int>(waveform.ChannelNumber());
43 
44  if (!geometry.IsValidOpChannel(channel)) {
45  mf::LogError("OpHitFinder")
46  << "Error! unrecognized channel number " << channel << ". Ignoring pulse";
47  continue;
48  }
49 
50  pulseRecoMgr.Reconstruct(waveform);
51 
52  // Get the result
53  auto const& pulses = threshAlg.GetPulses();
54 
55  const double timeStamp = waveform.TimeStamp();
56 
57  for (auto const& pulse : pulses)
58  ConstructHit(hitThreshold,
59  channel,
60  timeStamp,
61  pulse,
62  hitVector,
63  clocksData,
64  calibrator,
65  use_start_time);
66  }
67  }
68 
69  //----------------------------------------------------------------------------
70  void ConstructHit(float hitThreshold,
71  int channel,
72  double timeStamp,
73  pmtana::pulse_param const& pulse,
74  std::vector<recob::OpHit>& hitVector,
75  detinfo::DetectorClocksData const& clocksData,
76  calib::IPhotonCalibrator const& calibrator,
77  bool use_start_time)
78  {
79 
80  if (pulse.peak < hitThreshold) return;
81 
82  double absTime = timeStamp + clocksData.OpticalClock().TickPeriod() *
83  (use_start_time ? pulse.t_start : pulse.t_max);
84 
85  double relTime = absTime - clocksData.TriggerTime();
86 
87  double startTime =
88  timeStamp + clocksData.OpticalClock().TickPeriod() * pulse.t_start - clocksData.TriggerTime();
89 
90  double riseTime = clocksData.OpticalClock().TickPeriod() * pulse.t_rise;
91 
92  int frame = clocksData.OpticalClock().Frame(timeStamp);
93 
94  double PE = 0.0;
95  if (calibrator.UseArea())
96  PE = calibrator.PE(pulse.area, channel);
97  else
98  PE = calibrator.PE(pulse.peak, channel);
99 
100  double width = (pulse.t_end - pulse.t_start) * clocksData.OpticalClock().TickPeriod();
101 
102  hitVector.emplace_back(channel,
103  relTime,
104  absTime,
105  startTime,
106  riseTime,
107  frame,
108  width,
109  pulse.area,
110  pulse.peak,
111  PE,
112  0.0);
113  }
114 
115 } // End namespace opdet
virtual bool UseArea() const =0
virtual double PE(double adcs, int opchannel) const =0
MaybeLogger_< ELseverityLevel::ELsev_error, false > LogError
constexpr int Frame() const noexcept
Returns the number of the frame containing the clock current time.
Definition: ElecClock.h:269
pure virtual base interface for detector clocks
constexpr double TickPeriod() const noexcept
A single tick period in microseconds.
Definition: ElecClock.h:310
Access the description of detector geometry.
const pulse_param_array & GetPulses() const
A getter for the whole array of pulse_param struct object.
bool Reconstruct(const pmtana::Waveform_t &) const
Implementation of ana_base::analyze method.
ElecClock const & OpticalClock() const noexcept
Borrow a const Optical clock with time set to Trigger time [us].
Description of geometry of one entire detector.
Definition: GeometryCore.h:119
double TriggerTime() const
Trigger electronics clock time in [us].
void ConstructHit(float hitThreshold, int channel, double timeStamp, pmtana::pulse_param const &pulse, std::vector< recob::OpHit > &hitVector, detinfo::DetectorClocksData const &clocksData, calib::IPhotonCalibrator const &calibrator, bool use_start_time)
Definition: OpHitAlg.cxx:70
Contains all timing reference information for the detector.
void RunHitFinder(std::vector< raw::OpDetWaveform > const &opDetWaveformVector, std::vector< recob::OpHit > &hitVector, pmtana::PulseRecoManager const &pulseRecoMgr, pmtana::PMTPulseRecoBase const &threshAlg, geo::GeometryCore const &geometry, float hitThreshold, detinfo::DetectorClocksData const &clocksData, calib::IPhotonCalibrator const &calibrator, bool use_start_time)
Definition: OpHitAlg.cxx:29
Class def header for a class ElecClock.
bool IsValidOpChannel(int opChannel) const
Is this a valid OpChannel number?
Class definition file of PulseRecoManager.