LArSoft  v06_85_00
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  std::vector< double > const& SPESize,
27  bool areaToPE,
28  std::vector< double > const& SPEShiftPerChan ) {
29 
30  for (auto const& waveform : opDetWaveformVector) {
31 
32  const int channel = static_cast< int >(waveform.ChannelNumber());
33 
34  if (!geometry.IsValidOpChannel(channel)) {
35  mf::LogError("OpHitFinder") << "Error! unrecognized channel number "
36  << channel << ". Ignoring pulse";
37  continue;
38  }
39 
40  pulseRecoMgr.Reconstruct(waveform);
41 
42  // Get the result
43  auto const& pulses = threshAlg.GetPulses();
44 
45  const double timeStamp = waveform.TimeStamp();
46 
47 
48  for (auto const& pulse : pulses)
49  ConstructHit(hitThreshold,
50  channel,
51  timeStamp,
52  pulse,
53  detectorClocks,
54  SPESize.at(channel),
55  areaToPE,
56  hitVector,
57  SPEShiftPerChan.at(channel) );
58 
59  }
60 
61  }
62  //----------------------------------------------------------------------------
63  // For backward compatibility
64  void RunHitFinder(std::vector< raw::OpDetWaveform > const&
65  opDetWaveformVector,
66  std::vector< recob::OpHit >& hitVector,
67  pmtana::PulseRecoManager const& pulseRecoMgr,
68  pmtana::PMTPulseRecoBase const& threshAlg,
69  geo::GeometryCore const& geometry,
70  float hitThreshold,
71  detinfo::DetectorClocks const& detectorClocks,
72  std::vector< double > const& SPESize,
73  bool areaToPE) {
74 
75  // if no SPEShiftPerChan vec is given, use one with no shift for all channels
76  std::vector< double > noSPEShift(geometry.NOpChannels() , 0. );
77 
78  RunHitFinder(opDetWaveformVector,
79  hitVector,
80  pulseRecoMgr,
81  threshAlg,
82  geometry,
83  hitThreshold,
84  detectorClocks,
85  SPESize,
86  areaToPE,
87  noSPEShift);
88 
89  }
90  //----------------------------------------------------------------------------
91  void ConstructHit(float hitThreshold,
92  int channel,
93  double timeStamp,
94  pmtana::pulse_param const& pulse,
95  detinfo::DetectorClocks const& detectorClocks,
96  double SPESize,
97  bool areaToPE,
98  std::vector< recob::OpHit >& hitVector,
99  double SPEShift=0.) {
100 
101  if (pulse.peak < hitThreshold) return;
102 
103  double absTime = timeStamp
104  + pulse.t_max*detectorClocks.OpticalClock().TickPeriod();
105 
106  double relTime = absTime - detectorClocks.TriggerTime();
107 
108  int frame = detectorClocks.OpticalClock().Frame(timeStamp);
109 
110  double PE = 0.0;
111  if (areaToPE) PE = pulse.area/SPESize + SPEShift;
112  else PE = pulse.peak/SPESize + SPEShift;
113 
114  double width = (pulse.t_end - pulse.t_start)
115  *detectorClocks.OpticalClock().TickPeriod();
116 
117  hitVector.emplace_back(channel,
118  relTime,
119  absTime,
120  frame,
121  width,
122  pulse.area,
123  pulse.peak,
124  PE,
125  0.0);
126 
127  }
128 
129 } // End namespace opdet
virtual double TriggerTime() const =0
Harware trigger time (in electronics time frame) [µs].
MaybeLogger_< ELseverityLevel::ELsev_error, false > LogError
unsigned int NOpChannels() const
Number of electronics channels for all the optical detectors.
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, std::vector< double > const &SPESize, bool areaToPE, std::vector< double > const &SPEShiftPerChan)
Definition: OpHitAlg.cxx:18
Description of geometry of one entire detector.
Conversion of times between different formats and references.
void ConstructHit(float hitThreshold, int channel, double timeStamp, pmtana::pulse_param const &pulse, detinfo::DetectorClocks const &detectorClocks, double SPESize, bool areaToPE, std::vector< recob::OpHit > &hitVector, double SPEShift=0.)
Definition: OpHitAlg.cxx:91
double TickPeriod() const
A single tick period in microseconds.
Definition: ElecClock.h:342
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?