All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
ShowerEnergyAlg.cxx
Go to the documentation of this file.
1 ////////////////////////////////////////////////////////////////////////
2 // Class: ShowerEnergyAlg
3 // File: ShowerEnergyAlg.cxx
4 // Author: Mike Wallbank (m.wallbank@sheffield.ac.uk), November 2015
5 //
6 // Shower energy finding class
7 ////////////////////////////////////////////////////////////////////////
8 
9 #include "canvas/Persistency/Common/PtrVector.h"
10 
19 #include "range/v3/numeric.hpp"
20 #include "range/v3/view.hpp"
21 
22 #include <cmath>
23 
24 using lar::to_element;
25 
26 shower::ShowerEnergyAlg::ShowerEnergyAlg(fhicl::ParameterSet const& pset)
27  : fLinearFunctions{{{pset.get<double>("UGradient"), pset.get<double>("UIntercept")},
28  {pset.get<double>("VGradient"), pset.get<double>("VIntercept")},
29  {pset.get<double>("ZGradient"), pset.get<double>("ZIntercept")}}}
30 {}
31 
32 double
34  detinfo::DetectorPropertiesData const& detprop,
35  std::vector<art::Ptr<recob::Hit>> const& hits,
36  geo::PlaneID::PlaneID_t const plane) const
37 {
38  // Should we throw instead if the plane is not in the range [0,3)?
39  if (plane >= fLinearFunctions.size()) { return 0.; }
40 
41  auto const coeff = sampling_rate(clockData) / (detprop.ElectronLifetime() * 1e3);
42 
43  auto in_plane = [plane](auto const& hit) { return hit.WireID().Plane == plane; };
44  auto charge = [coeff](auto const& hit) {
45  return hit.Integral() * std::exp(coeff * hit.PeakTime());
46  };
47 
48  double const totalCharge =
49  ranges::accumulate(hits | ranges::views::transform(to_element) | ranges::views::filter(in_plane) |
51  0.);
52 
53  return fLinearFunctions[plane].energy_from(totalCharge);
54 }
Utilities related to art service access.
constexpr to_element_t to_element
Definition: ToElement.h:24
static constexpr Sample_t transform(Sample_t sample)
double ShowerEnergy(detinfo::DetectorClocksData const &clockData, detinfo::DetectorPropertiesData const &detProp, std::vector< art::Ptr< recob::Hit >> const &hits, geo::PlaneID::PlaneID_t plane) const
Declaration of signal hit object.
unsigned int PlaneID_t
Type for the ID number.
Definition: geo_types.h:473
process_name hit
Definition: cheaterreco.fcl:51
ShowerEnergyAlg(fhicl::ParameterSet const &pset)
auto vector(Vector const &v)
Returns a manipulator which will print the specified array.
Definition: DumpUtils.h:265
Definition of data types for geometry description.
physics filters filter
Contains all timing reference information for the detector.
double sampling_rate(DetectorClocksData const &data)
Returns the period of the TPC readout electronics clock.