OpHitAlg.cxx
Go to the documentation of this file.
1 // -*- mode: c++; c-basic-offset: 2; -*-
2 /*!
3  * Title: OpHit Algorithims
4  * Authors, editors: Ben Jones, MIT
5  * Wes Ketchum wketchum@lanl.gov
6  * Gleb Sinev gleb.sinev@duke.edu
7  * Alex Himmel ahimmel@fnal.gov
8  * Kevin Wood kevin.wood@stonybrook.edu
9  *
10  * Description:
11  * These are the algorithms used by OpHitFinder to produce optical hits.
12  */
13 
14 #include "OpHitAlg.h"
15 
23 
24 #include <vector>
25 
26 namespace opdet {
27  //----------------------------------------------------------------------------
28  void
29  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, channel, timeStamp, pulse, hitVector, clocksData, calibrator, use_start_time);
59  }
60  }
61 
62  //----------------------------------------------------------------------------
63  void
64  ConstructHit(float hitThreshold,
65  int channel,
66  double timeStamp,
67  pmtana::pulse_param const& pulse,
68  std::vector<recob::OpHit>& hitVector,
69  detinfo::DetectorClocksData const& clocksData,
70  calib::IPhotonCalibrator const& calibrator,
71  bool use_start_time)
72  {
73 
74  if (pulse.peak < hitThreshold) return;
75 
76  double absTime = timeStamp + clocksData.OpticalClock().TickPeriod() * (use_start_time ? pulse.t_start : pulse.t_max);
77 
78  double relTime = absTime - clocksData.TriggerTime();
79 
80  int frame = clocksData.OpticalClock().Frame(timeStamp);
81 
82  double PE = 0.0;
83  if (calibrator.UseArea())
84  PE = calibrator.PE(pulse.area, channel);
85  else
86  PE = calibrator.PE(pulse.peak, channel);
87 
88  double width = (pulse.t_end - pulse.t_start) * clocksData.OpticalClock().TickPeriod();
89 
90  hitVector.emplace_back(
91  channel, relTime, absTime, frame, width, pulse.area, pulse.peak, PE, 0.0);
92  }
93 
94 } // End namespace opdet
virtual bool UseArea() const =0
virtual double PE(double adcs, int opchannel) const =0
uint8_t channel
Definition: CRTFragment.hh:201
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:304
constexpr double TickPeriod() const noexcept
A single tick period in microseconds.
Definition: ElecClock.h:352
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.
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:64
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
bool IsValidOpChannel(int opChannel) const
Is this a valid OpChannel number?
pure virtual base interface for detector clocks
Class definition file of PulseRecoManager.