LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
PxHitConverter.h
Go to the documentation of this file.
1 // \file PxHitConverter.h
3 //
4 // \brief conversion utulities from recob::Hit to PxHit
5 //
6 // \author andrzej.szelc@yale.edu, based on LarLite code by Kazu
7 //
9 
10 #ifndef UTIL_PXHITCONVERTER_H
11 #define UTIL_PXHITCONVERTER_H
12 
13 #include "PxUtils.h"
16 
18 
19 #include <algorithm>
20 #include <type_traits>
21 #include <vector>
22 
24 namespace util {
25  class GeometryUtilities;
26 
28  public:
29  explicit PxHitConverter(GeometryUtilities const& geomUtils);
30 
32  void GeneratePxHit(const std::vector<unsigned int>& hit_index,
34  std::vector<PxHit>& pxhits) const;
35 
38  std::vector<PxHit>& pxhits) const;
39 
40  void GenerateSinglePxHit(art::Ptr<recob::Hit> const& hit, PxHit& pxhits) const;
41 
43  PxHit HitToPxHit(recob::Hit const& hit) const;
44 
47  template <typename HitObj>
48  PxHit ToPxHit(HitObj const& hit) const;
49 
51  template <typename Cont, typename Hit = typename Cont::value_type>
52  std::vector<PxHit> ToPxHitVector(Cont const& hits) const;
53 
54  private:
56  }; // class PxHitConverter
57 
58 } //namespace util
59 
60 //******************************************************************************
61 //*** Template implementation
62 //***
63 template <typename HitObj>
65 {
66  // check that the argument is an object convertible to a recob::Hit,
67  // or it is a pointer to such an object
68  static_assert(
69  std::is_convertible<typename lar::util::dereferenced_type<HitObj>::type, recob::Hit>::value,
70  "The argument to PxHitConverter::ToPxHit() does not point to a recob::Hit");
72 } // PxHitConverter::ToPxHit()
73 
74 template <typename Cont, typename Hit /* = typename Cont::value_type */>
75 std::vector<util::PxHit> util::PxHitConverter::ToPxHitVector(Cont const& hits) const
76 {
77  std::vector<PxHit> pxhits;
78  pxhits.reserve(hits.size());
79  std::transform(hits.begin(), hits.end(), std::back_inserter(pxhits), [this](Hit const& hit) {
80  return this->ToPxHit(hit);
81  });
82  return pxhits;
83 } // util::PxHitConverter::ToPxHitVector()
84 
85 #endif // UTIL_PXHITCONVERTER_H
Namespace for general, non-LArSoft-specific utilities.
Definition: PIDAAlg.h:26
GeometryUtilities const & fGeomUtils
Declaration of signal hit object.
PxHit ToPxHit(HitObj const &hit) const
PxHitConverter(GeometryUtilities const &geomUtils)
void GenerateSinglePxHit(art::Ptr< recob::Hit > const &hit, PxHit &pxhits) const
details::dereference_class< T, details::has_dereference_class< T >::value >::reference_type dereference(T &v)
Returns the value pointed by the argument, or the argument itself.
Definition: Dereference.h:241
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)
std::vector< PxHit > ToPxHitVector(Cont const &hits) const
Returns a vector of PxHit out of a vector of hits.
void hits()
Definition: readHits.C:15
PxHit HitToPxHit(recob::Hit const &hit) const
Generates and returns a PxHit out of a recob::Hit.
double value
Definition: spectrum.C:18
Detector simulation of raw signals on wires.
2D representation of charge deposited in the TDC/wire plane
Definition: Hit.h:46