DUNEAnaHitUtils.cxx
Go to the documentation of this file.
1 /**
2 *
3 * @file dunereco/AnaUtils/DUNEAnaHitUtils.cxx
4 *
5 * @brief Utility containing helpful functions for end users to access information about hits
6 */
7 
8 //STL
9 #include <algorithm>
10 //ROOT
11 //ART
13 //LARSOFT
18 //DUNE
20 
21 namespace dune_ana
22 {
23 
24 std::vector<art::Ptr<recob::SpacePoint>> DUNEAnaHitUtils::GetSpacePoints(const art::Ptr<recob::Hit> &pHit,
25  const art::Event &evt, const std::string &hitLabel, const std::string &hitToSpacePointLabel)
26 
27 {
28  return DUNEAnaHitUtils::GetAssocProductVector<recob::SpacePoint>(pHit,evt,hitLabel,hitToSpacePointLabel);
29 }
30 
31 std::vector<art::Ptr<recob::Hit>> DUNEAnaHitUtils::GetHitsOnPlane(const std::vector<art::Ptr<recob::Hit>> &hits,
32  const geo::PlaneID::PlaneID_t planeID)
33 {
34  std::vector<art::Ptr<recob::Hit>> hitsOnPlane;
35  std::vector<art::Ptr<recob::Hit>>::const_iterator hitIt = hits.begin();
36  while ((hitIt
37  = std::find_if(hitIt, hits.end(), [planeID](const art::Ptr<recob::Hit> &hit){return hit->WireID().Plane==planeID; }))
38  != hits.end())
39  hitsOnPlane.emplace_back(*(hitIt++));
40  return hitsOnPlane;
41 
42 }
43 
45  detinfo::DetectorPropertiesData const& detProp,
46  const art::Ptr<recob::Hit> &pHit)
47 {
48  return DUNEAnaHitUtils::LifetimeCorrection(clockData, detProp,
49  pHit->PeakTime(), clockData.TriggerTime());
50 }
51 
53  detinfo::DetectorPropertiesData const& detProp,
54  const double timeInTicks, const double t0InMicroS)
55 {
56  const double tpcSamplingRateInMicroS(clockData.TPCClock().TickPeriod());
57  const double tpcTriggerOffsetInTicks(trigger_offset(clockData));
58 
59  const double timeCorrectedForT0((timeInTicks - tpcTriggerOffsetInTicks)*tpcSamplingRateInMicroS - t0InMicroS);
60  const double tauLifetime(detProp.ElectronLifetime());
61 
62  return std::exp(timeCorrectedForT0/tauLifetime);
63 }
64 
66  detinfo::DetectorPropertiesData const& detProp,
67  const std::vector<art::Ptr<recob::Hit> > &hits)
68 {
69  double totalHitCharge(0);
70  for (unsigned int iHit = 0; iHit < hits.size(); iHit++)
71  totalHitCharge += hits[iHit]->Integral() * DUNEAnaHitUtils::LifetimeCorrection(clockData, detProp, hits[iHit]);
72 
73  return totalHitCharge;
74 }
75 
76 } // namespace dune_ana
Utility containing helpful functions for end users to access information about Hits.
std::string string
Definition: nybbler.cc:12
static std::vector< art::Ptr< recob::SpacePoint > > GetSpacePoints(const art::Ptr< recob::Hit > &pHit, const art::Event &evt, const std::string &hitLabel, const std::string &hitToSpacePointLabel)
Get the space points associated with the hit.
unsigned int PlaneID_t
Type for the ID number.
Definition: geo_types.h:473
struct vector vector
intermediate_table::const_iterator const_iterator
constexpr double TickPeriod() const noexcept
A single tick period in microseconds.
Definition: ElecClock.h:352
static double LifetimeCorrection(detinfo::DetectorClocksData const &clockData, detinfo::DetectorPropertiesData const &detProp, const art::Ptr< recob::Hit > &pHit)
get the lifetime correction for a hit, assumes the detector properties GetTriggerOffset is T0 ...
ElecClock const & TPCClock() const noexcept
Borrow a const TPC clock with time set to Trigger time [us].
static double LifetimeCorrectedTotalHitCharge(detinfo::DetectorClocksData const &clockData, detinfo::DetectorPropertiesData const &detProp, const std::vector< art::Ptr< recob::Hit > > &hits)
get the total hit charge, corrected for lifetime
double TriggerTime() const
Trigger electronics clock time in [us].
Detector simulation of raw signals on wires.
float PeakTime() const
Time of the signal peak, in tick units.
Definition: Hit.h:218
Declaration of signal hit object.
Contains all timing reference information for the detector.
int trigger_offset(DetectorClocksData const &data)
TCEvent evt
Definition: DataStructs.cxx:7
static std::vector< art::Ptr< recob::Hit > > GetHitsOnPlane(const std::vector< art::Ptr< recob::Hit >> &hits, const geo::PlaneID::PlaneID_t planeID)
Get all hits on a specific plane.