12 #include "art/Utilities/ToolMacros.h"
26 namespace ShowerRecoTools {
51 art::ServiceHandle<geo::Geometry>
fGeom;
60 , fPFParticleLabel(pset.
get<art::InputTag>(
"PFParticleLabel"))
61 , fVerbose(pset.
get<int>(
"Verbose"))
62 , fShowerEnergyOutputLabel(pset.
get<
std::string>(
"ShowerEnergyOutputLabel"))
63 , fShowerBestPlaneOutputLabel(pset.
get<
std::string>(
"ShowerBestPlaneOutputLabel"))
64 , fCalorimetryAlg(pset.
get<fhicl::ParameterSet>(
"CalorimetryAlg"))
65 , fRecombinationFactor(pset.
get<double>(
"RecombinationFactor"))
76 <<
"~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Shower Reco Energy Tool ~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
80 auto const pfpHandle = Event.getValidHandle<std::vector<recob::PFParticle>>(
fPFParticleLabel);
83 auto const clusHandle = Event.getValidHandle<std::vector<recob::Cluster>>(
fPFParticleLabel);
85 const art::FindManyP<recob::Cluster>& fmc =
88 std::vector<art::Ptr<recob::Cluster>> clusters = fmc.at(pfparticle.key());
91 const art::FindManyP<recob::Hit>& fmhc =
95 std::map<geo::PlaneID::PlaneID_t, std::vector<art::Ptr<recob::Hit>>> planeHits;
98 for (
auto const&
cluster : clusters) {
101 std::vector<art::Ptr<recob::Hit>> hits = fmhc.at(
cluster.key());
106 planeHits[plane].insert(planeHits[plane].
end(), hits.begin(), hits.end());
111 unsigned int bestPlaneNumHits = 0;
114 std::vector<double> energyVec(
fGeom->Nplanes(), -999.);
115 std::vector<double> energyError(
fGeom->Nplanes(), -999.);
117 auto const clockData =
118 art::ServiceHandle<detinfo::DetectorClocksService const>()->DataFor(Event);
120 art::ServiceHandle<detinfo::DetectorPropertiesService const>()->DataFor(Event, clockData);
122 for (
auto const& [plane, hits] : planeHits) {
124 unsigned int planeNumHits = hits.size();
129 if (Energy > 0) energyVec.at(plane) =
Energy;
131 if (planeNumHits > bestPlaneNumHits) {
133 bestPlaneNumHits = planeNumHits;
139 if (bestPlane < fGeom->Nplanes()) {
142 int bestPlaneVal(bestPlane);
157 double totalCharge = 0;
158 double totalEnergy = 0;
159 double correctedtotalCharge = 0;
160 double nElectrons = 0;
162 for (
auto const&
hit : hits) {
166 clockData, detProp,
hit->PeakTime());
double std(const std::vector< short > &wf, const double ped_mean, size_t start, size_t nsample)
unsigned int PlaneID_t
Type for the ID number.
void SetElement(T &dataproduct, const std::string &Name, bool checktag=false)
Set of hits with a 2D structure.
const art::FindManyP< T1 > & GetFindManyP(const art::ValidHandle< std::vector< T2 > > &handle, const art::Event &evt, const art::InputTag &moduleTag)
auto vector(Vector const &v)
Returns a manipulator which will print the specified array.
double ElectronsFromADCArea(double area, unsigned short plane) const
constexpr double kGeVToElectrons
23.6eV per ion pair, 1e9 eV/GeV
auto end(FixedBins< T, C > const &) noexcept
Declaration of cluster object.
Contains all timing reference information for the detector.
2D representation of charge deposited in the TDC/wire plane
double LifetimeCorrection(detinfo::DetectorClocksData const &clock_data, detinfo::DetectorPropertiesData const &det_prop, double time, double T0=0) const
Collection of Physical constants used in LArSoft.
BEGIN_PROLOG could also be cout