LArSoft  v07_13_02
Liquid Argon Software toolkit - http://larsoft.org/
OpHitAlg.cxx
Go to the documentation of this file.
1 // -*- mode: c++; c-basic-offset: 2; -*-
14 #include "OpHitAlg.h"
15 
16 namespace opdet{
17  //----------------------------------------------------------------------------
18  void RunHitFinder(std::vector< raw::OpDetWaveform > const&
19  opDetWaveformVector,
20  std::vector< recob::OpHit >& hitVector,
21  pmtana::PulseRecoManager const& pulseRecoMgr,
22  pmtana::PMTPulseRecoBase const& threshAlg,
23  geo::GeometryCore const& geometry,
24  float hitThreshold,
25  detinfo::DetectorClocks const& detectorClocks,
26  calib::IPhotonCalibrator const& calibrator) {
27 
28  for (auto const& waveform : opDetWaveformVector) {
29 
30  const int channel = static_cast< int >(waveform.ChannelNumber());
31 
32  if (!geometry.IsValidOpChannel(channel)) {
33  mf::LogError("OpHitFinder") << "Error! unrecognized channel number "
34  << channel << ". Ignoring pulse";
35  continue;
36  }
37 
38  pulseRecoMgr.Reconstruct(waveform);
39 
40  // Get the result
41  auto const& pulses = threshAlg.GetPulses();
42 
43  const double timeStamp = waveform.TimeStamp();
44 
45 
46  for (auto const& pulse : pulses)
47  ConstructHit(hitThreshold,
48  channel,
49  timeStamp,
50  pulse,
51  hitVector,
52  detectorClocks,
53  calibrator);
54 
55  }
56  }
57 
58 
59  //----------------------------------------------------------------------------
60  void ConstructHit(float hitThreshold,
61  int channel,
62  double timeStamp,
63  pmtana::pulse_param const& pulse,
64  std::vector< recob::OpHit >& hitVector,
65  detinfo::DetectorClocks const& detectorClocks,
66  calib::IPhotonCalibrator const& calibrator) {
67 
68  if (pulse.peak < hitThreshold) return;
69 
70  double absTime = timeStamp + pulse.t_max*detectorClocks.OpticalClock().TickPeriod();
71 
72  double relTime = absTime - detectorClocks.TriggerTime();
73 
74  int frame = detectorClocks.OpticalClock().Frame(timeStamp);
75 
76  double PE = 0.0;
77  if (calibrator.UseArea()) PE = calibrator.PE(pulse.area, channel);
78  else PE = calibrator.PE(pulse.peak, channel);
79 
80  double width = (pulse.t_end - pulse.t_start) * detectorClocks.OpticalClock().TickPeriod();
81 
82  hitVector.emplace_back(channel,
83  relTime,
84  absTime,
85  frame,
86  width,
87  pulse.area,
88  pulse.peak,
89  PE,
90  0.0);
91 
92  }
93 
94 } // End namespace opdet
virtual bool UseArea() const =0
virtual double PE(double adcs, int opchannel) const =0
virtual double TriggerTime() const =0
Harware trigger time (in electronics time frame) [µs].
MaybeLogger_< ELseverityLevel::ELsev_error, false > LogError
int Frame() const
Returns the number of the frame containing the clock current time.
Definition: ElecClock.h:310
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.
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::DetectorClocks const &detectorClocks, calib::IPhotonCalibrator const &calibrator)
Definition: OpHitAlg.cxx:18
Description of geometry of one entire detector.
Conversion of times between different formats and references.
double TickPeriod() const
A single tick period in microseconds.
Definition: ElecClock.h:342
void ConstructHit(float hitThreshold, int channel, double timeStamp, pmtana::pulse_param const &pulse, std::vector< recob::OpHit > &hitVector, detinfo::DetectorClocks const &detectorClocks, calib::IPhotonCalibrator const &calibrator)
Definition: OpHitAlg.cxx:60
virtual const detinfo::ElecClock & OpticalClock() const =0
Lends a constant optical clock with time set to trigger time.
bool IsValidOpChannel(int opChannel) const
Is this a valid OpChannel number?