PxHitConverter.cxx
Go to the documentation of this file.
1 ////////////////////////////////////////////////////////////////////////
2 // \file PxHitConverter.cxx
3 //
4 // \brief conversion utulities from recob::Hit to PxHit
5 //
6 // \author andrzej.szelc@yale.edu, based on LarLite code by Kazu
7 //
8 //
9 ////////////////////////////////////////////////////////////////////////
10 
11 #include "PxHitConverter.h"
12 #include "TString.h"
13 
16 
17 namespace util {
18 
19  PxHitConverter::PxHitConverter(GeometryUtilities const& geomUtils) : fGeomUtils{geomUtils} {}
20 
21  /// Generate: from 1 set of hits => 1 set of PxHits using indexes (association)
22  void
24  std::vector<util::PxHit>& pxhits) const
25  {
26  if (empty(hits)) throw UtilException(Form("Hit list empty! (%s)", __FUNCTION__));
27 
28  std::vector<unsigned int> hit_index;
29  hit_index.reserve(hits.size());
30 
31  //generate full index
32  for (unsigned int ix = 0; ix < hits.size(); ++ix)
33  hit_index.push_back(ix);
34 
35  GeneratePxHit(hit_index, hits, pxhits);
36  }
37 
38  void
40  {
41  pxhit = ToPxHit(hit);
42  }
43 
44  PxHit
46  {
47  PxHit pxhit;
48  pxhit.t = hit.PeakTime() * fGeomUtils.TimeToCm();
49  pxhit.w = hit.WireID().Wire * fGeomUtils.WireToCm();
50  pxhit.charge = hit.Integral();
51  pxhit.sumADC = hit.SummedADC();
52  pxhit.peak = hit.PeakAmplitude();
53  pxhit.plane = hit.WireID().Plane;
54  return pxhit;
55  } // PxHitConverter::HitToPxHit(recob::Hit)
56 
57  /// Generate: from 1 set of hits => 1 set of PxHits using indexes (association)
58  void
59  PxHitConverter::GeneratePxHit(const std::vector<unsigned int>& hit_index,
61  std::vector<util::PxHit>& pxhits) const
62  {
63  if (empty(hit_index)) throw UtilException(Form("Hit list empty! (%s)", __FUNCTION__));
64 
65  pxhits.clear();
66  pxhits.reserve(hit_index.size());
67 
68  for (auto const& index : hit_index) {
69  auto const& hit = hits[index];
70 
71  PxHit h;
73 
74  pxhits.push_back(h);
75  }
76  }
77 
78 } // end namespace util
Namespace for general, non-LArSoft-specific utilities.
GeometryUtilities const & fGeomUtils
Class def header for exception classes used in GeometryUtilities.
geo::WireID WireID() const
Definition: Hit.h:233
struct vector vector
Double_t TimeToCm() const
Double_t WireToCm() const
float Integral() const
Integral under the calibrated signal waveform of the hit, in tick x ADC units.
Definition: Hit.h:224
WireID_t Wire
Index of the wire within its plane.
Definition: geo_types.h:580
PxHit ToPxHit(HitObj const &hit) const
PxHitConverter(GeometryUtilities const &geomUtils)
float PeakAmplitude() const
The estimated amplitude of the hit at its peak, in ADC units.
Definition: Hit.h:221
void GenerateSinglePxHit(art::Ptr< recob::Hit > const &hit, PxHit &pxhits) const
void GeneratePxHit(const std::vector< unsigned int > &hit_index, const std::vector< art::Ptr< recob::Hit >> hits, std::vector< PxHit > &pxhits) const
Generate: from 1 set of hits => 1 set of PxHits using indexes (association)
double t
Definition: PxUtils.h:11
PxHit HitToPxHit(recob::Hit const &hit) const
Generates and returns a PxHit out of a recob::Hit.
PlaneID_t Plane
Index of the plane within its TPC.
Definition: geo_types.h:493
Detector simulation of raw signals on wires.
double w
Definition: PxUtils.h:10
float PeakTime() const
Time of the signal peak, in tick units.
Definition: Hit.h:218
double charge
area charge
Definition: PxUtils.h:39
float SummedADC() const
The sum of calibrated ADC counts of the hit (0. by default)
Definition: Hit.h:223
2D representation of charge deposited in the TDC/wire plane
Definition: Hit.h:48
double sumADC
sum of ADCs
Definition: PxUtils.h:40
double peak
peak amplitude
Definition: PxUtils.h:41
unsigned int plane
Definition: PxUtils.h:12
decltype(auto) constexpr empty(T &&obj)
ADL-aware version of std::empty.
Definition: StdUtils.h:97