LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
PxHitConverter.cxx
Go to the documentation of this file.
1 // \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 //
10 
11 #include "PxHitConverter.h"
12 #include "TString.h"
13 
16 
17 namespace util {
18 
19  PxHitConverter::PxHitConverter(GeometryUtilities const& geomUtils) : fGeomUtils{geomUtils} {}
20 
23  std::vector<util::PxHit>& pxhits) const
24  {
25  if (empty(hits)) throw UtilException(Form("Hit list empty! (%s)", __FUNCTION__));
26 
27  std::vector<unsigned int> hit_index;
28  hit_index.reserve(hits.size());
29 
30  //generate full index
31  for (unsigned int ix = 0; ix < hits.size(); ++ix)
32  hit_index.push_back(ix);
33 
34  GeneratePxHit(hit_index, hits, pxhits);
35  }
36 
38  util::PxHit& pxhit) const
39  {
40  pxhit = ToPxHit(hit);
41  }
42 
44  {
45  PxHit pxhit;
46  pxhit.t = hit.PeakTime() * fGeomUtils.TimeToCm();
47  pxhit.w = hit.WireID().Wire * fGeomUtils.WireToCm();
48  pxhit.charge = hit.Integral();
49  pxhit.sumADC = hit.SummedADC();
50  pxhit.peak = hit.PeakAmplitude();
51  pxhit.plane = hit.WireID().Plane;
52  return pxhit;
53  } // PxHitConverter::HitToPxHit(recob::Hit)
54 
56  void PxHitConverter::GeneratePxHit(const std::vector<unsigned int>& hit_index,
58  std::vector<util::PxHit>& pxhits) const
59  {
60  if (empty(hit_index)) throw UtilException(Form("Hit list empty! (%s)", __FUNCTION__));
61 
62  pxhits.clear();
63  pxhits.reserve(hit_index.size());
64 
65  for (auto const& index : hit_index) {
66  auto const& hit = hits[index];
67 
68  PxHit h;
70 
71  pxhits.push_back(h);
72  }
73  }
74 
75 } // end namespace util
Namespace for general, non-LArSoft-specific utilities.
Definition: PIDAAlg.h:26
GeometryUtilities const & fGeomUtils
Class def header for exception classes used in GeometryUtilities.
float Integral() const
Integral under the calibrated signal waveform of the hit, in tick x ADC units.
Definition: Hit.h:244
WireID_t Wire
Index of the wire within its plane.
Definition: geo_types.h:563
geo::WireID const & WireID() const
Initial tdc tick for hit.
Definition: Hit.h:280
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:232
void GenerateSinglePxHit(art::Ptr< recob::Hit > const &hit, PxHit &pxhits) const
auto vector(Vector const &v)
Returns a manipulator which will print the specified array.
Definition: DumpUtils.h:289
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)
void hits()
Definition: readHits.C:15
double t
Definition: PxUtils.h:10
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:481
Detector simulation of raw signals on wires.
double w
Definition: PxUtils.h:9
float PeakTime() const
Time of the signal peak, in tick units.
Definition: Hit.h:220
double charge
area charge
Definition: PxUtils.h:40
float SummedADC() const
The sum of calibrated ADC counts of the hit (0. by default)
Definition: Hit.h:240
2D representation of charge deposited in the TDC/wire plane
Definition: Hit.h:46
double sumADC
sum of ADCs
Definition: PxUtils.h:41
double peak
peak amplitude
Definition: PxUtils.h:42
unsigned int plane
Definition: PxUtils.h:11
decltype(auto) constexpr empty(T &&obj)
ADL-aware version of std::empty.
Definition: StdUtils.h:109