All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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 #include "messagefacility/MessageLogger/MessageLogger.h"
24 
25 #include <vector>
26 
27 namespace opdet {
28  //----------------------------------------------------------------------------
29  void
30  RunHitFinder(std::vector<raw::OpDetWaveform> const& opDetWaveformVector,
31  std::vector<recob::OpHit>& hitVector,
32  pmtana::PulseRecoManager const& pulseRecoMgr,
33  pmtana::PMTPulseRecoBase const& threshAlg,
35  float hitThreshold,
36  detinfo::DetectorClocksData const& clocksData,
37  calib::IPhotonCalibrator const& calibrator,
38  bool use_start_time)
39  {
40 
41  for (auto const& waveform : opDetWaveformVector) {
42 
43  const int channel = static_cast<int>(waveform.ChannelNumber());
44 
45  if (!geometry.IsValidOpChannel(channel)) {
46  mf::LogError("OpHitFinder")
47  << "Error! unrecognized channel number " << channel << ". Ignoring pulse";
48  continue;
49  }
50 
51  pulseRecoMgr.Reconstruct(waveform);
52 
53  // Get the result
54  auto const& pulses = threshAlg.GetPulses();
55 
56  const double timeStamp = waveform.TimeStamp();
57 
58  for (auto const& pulse : pulses)
59  ConstructHit(hitThreshold, channel, timeStamp, pulse, hitVector, clocksData, calibrator, use_start_time);
60  }
61  }
62 
63  //----------------------------------------------------------------------------
64  void
65  ConstructHit(float hitThreshold,
66  int channel,
67  double timeStamp,
68  pmtana::pulse_param const& pulse,
69  std::vector<recob::OpHit>& hitVector,
70  detinfo::DetectorClocksData const& clocksData,
71  calib::IPhotonCalibrator const& calibrator,
72  bool use_start_time)
73  {
74 
75  if (pulse.peak < hitThreshold) return;
76 
77  double absTime = timeStamp + clocksData.OpticalClock().TickPeriod() * (use_start_time ? pulse.t_start : pulse.t_max);
78 
79  double relTime = absTime - clocksData.TriggerTime();
80 
81  double startTime = timeStamp + clocksData.OpticalClock().TickPeriod() * pulse.t_start - clocksData.TriggerTime();
82 
83  double riseTime = clocksData.OpticalClock().TickPeriod() * pulse.t_rise;
84 
85  int frame = clocksData.OpticalClock().Frame(timeStamp);
86 
87  double PE = 0.0;
88  if (calibrator.UseArea())
89  PE = calibrator.PE(pulse.area, channel);
90  else
91  PE = calibrator.PE(pulse.peak, channel);
92 
93  double width = (pulse.t_end - pulse.t_start) * clocksData.OpticalClock().TickPeriod();
94 
95  hitVector.emplace_back(channel, relTime, absTime, startTime, riseTime, frame, width, pulse.area, pulse.peak, PE, 0.0);
96 
97  }
98 
99 } // End namespace opdet
virtual bool UseArea() const =0
const geo::GeometryCore * geometry
virtual double PE(double adcs, int opchannel) const =0
constexpr int Frame() const noexcept
Returns the number of the frame containing the clock current time.
Definition: ElecClock.h:304
pure virtual base interface for detector clocks
constexpr double TickPeriod() const noexcept
A single tick period in microseconds.
Definition: ElecClock.h:352
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.
Description of geometry of one entire detector.
double TriggerTime() const
Trigger electronics clock time in [us].
ElecClock const & OpticalClock() const noexcept
Borrow a const Optical clock with time set to Trigger time [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:65
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:30
Class def header for a class ElecClock.
bool IsValidOpChannel(int opChannel) const
Is this a valid OpChannel number?
Class definition file of PulseRecoManager.