LArSoft  v10_04_05
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::WireReadoutGeom const& wireReadoutGeom,
34  float hitThreshold,
35  detinfo::DetectorClocksData const& clocksData,
36  calib::IPhotonCalibrator const& calibrator,
37  bool use_start_time)
38  {
39  for (auto const& waveform : opDetWaveformVector) {
40  const int channel = static_cast<int>(waveform.ChannelNumber());
41 
42  if (!wireReadoutGeom.IsValidOpChannel(channel)) {
43  mf::LogError("OpHitFinder")
44  << "Error! unrecognized channel number " << channel << ". Ignoring pulse";
45  continue;
46  }
47 
48  pulseRecoMgr.Reconstruct(waveform);
49 
50  // Get the result
51  auto const& pulses = threshAlg.GetPulses();
52 
53  const double timeStamp = waveform.TimeStamp();
54 
55  for (auto const& pulse : pulses)
56  ConstructHit(hitThreshold,
57  channel,
58  timeStamp,
59  pulse,
60  hitVector,
61  clocksData,
62  calibrator,
63  use_start_time);
64  }
65  }
66 
67  //----------------------------------------------------------------------------
68  void ConstructHit(float hitThreshold,
69  int channel,
70  double timeStamp,
71  pmtana::pulse_param const& pulse,
72  std::vector<recob::OpHit>& hitVector,
73  detinfo::DetectorClocksData const& clocksData,
74  calib::IPhotonCalibrator const& calibrator,
75  bool use_start_time)
76  {
77  if (pulse.peak < hitThreshold) return;
78 
79  double absTime = timeStamp + clocksData.OpticalClock().TickPeriod() *
80  (use_start_time ? pulse.t_start : pulse.t_max);
81 
82  double relTime = absTime - clocksData.TriggerTime();
83 
84  double startTime =
85  timeStamp + clocksData.OpticalClock().TickPeriod() * pulse.t_start - clocksData.TriggerTime();
86 
87  double riseTime = clocksData.OpticalClock().TickPeriod() * pulse.t_rise;
88 
89  int frame = clocksData.OpticalClock().Frame(timeStamp);
90 
91  double PE = 0.0;
92  if (calibrator.UseArea())
93  PE = calibrator.PE(pulse.area, channel);
94  else
95  PE = calibrator.PE(pulse.peak, channel);
96 
97  double width = (pulse.t_end - pulse.t_start) * clocksData.OpticalClock().TickPeriod();
98 
99  hitVector.emplace_back(channel,
100  relTime,
101  absTime,
102  startTime,
103  riseTime,
104  frame,
105  width,
106  pulse.area,
107  pulse.peak,
108  PE,
109  0.0);
110  }
111 
112 } // End namespace opdet
virtual bool UseArea() const =0
virtual double PE(double adcs, int opchannel) const =0
bool IsValidOpChannel(int opChannel) const
Is this a valid OpChannel number?
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
void RunHitFinder(std::vector< raw::OpDetWaveform > const &opDetWaveformVector, std::vector< recob::OpHit > &hitVector, pmtana::PulseRecoManager const &pulseRecoMgr, pmtana::PMTPulseRecoBase const &threshAlg, geo::WireReadoutGeom const &wireReadoutGeom, float hitThreshold, detinfo::DetectorClocksData const &clocksData, calib::IPhotonCalibrator const &calibrator, bool use_start_time)
Definition: OpHitAlg.cxx:29
const pulse_param_array & GetPulses() const
A getter for the whole array of pulse_param struct object.
Interface for a class providing readout channel mapping to geometry.
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].
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:68
Contains all timing reference information for the detector.
Class def header for a class ElecClock.
Interface to geometry for wire readouts .
Class definition file of PulseRecoManager.