40 const detinfo::DetectorPropertiesData& detProp,
41 const std::vector<art::Ptr<recob::Hit>>& hits,
42 const geo::PlaneID::PlaneID_t plane)
const;
51 art::ServiceHandle<geo::Geometry>
fGeom;
59 :
IShowerTool(pset.get<fhicl::ParameterSet>(
"BaseTools"))
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"))
75 <<
"~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Shower Reco Energy Tool ~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
79 auto const pfpHandle = Event.getValidHandle<std::vector<recob::PFParticle>>(
fPFParticleLabel);
82 auto const clusHandle = Event.getValidHandle<std::vector<recob::Cluster>>(
fPFParticleLabel);
84 const art::FindManyP<recob::Cluster>& fmc =
87 std::vector<art::Ptr<recob::Cluster>> clusters = fmc.at(pfparticle.key());
90 const art::FindManyP<recob::Hit>& fmhc =
94 std::map<geo::PlaneID::PlaneID_t, std::vector<art::Ptr<recob::Hit>>> planeHits;
97 for (
auto const&
cluster : clusters) {
100 std::vector<art::Ptr<recob::Hit>> hits = fmhc.at(
cluster.key());
103 const geo::PlaneID::PlaneID_t plane(
cluster->Plane().Plane);
105 planeHits[plane].insert(planeHits[plane].end(), hits.begin(), hits.end());
109 geo::PlaneID::PlaneID_t bestPlane = std::numeric_limits<geo::PlaneID::PlaneID_t>::max();
110 unsigned int bestPlaneNumHits = 0;
113 std::vector<double> energyVec(
fGeom->Nplanes(), -999.);
114 std::vector<double> energyError(
fGeom->Nplanes(), -999.);
116 auto const clockData =
117 art::ServiceHandle<detinfo::DetectorClocksService const>()->DataFor(Event);
119 art::ServiceHandle<detinfo::DetectorPropertiesService const>()->DataFor(Event, clockData);
121 for (
auto const& [plane, hits] : planeHits) {
123 unsigned int planeNumHits = hits.size();
128 if (Energy > 0) energyVec.at(plane) = Energy;
130 if (planeNumHits > bestPlaneNumHits) {
132 bestPlaneNumHits = planeNumHits;
138 if (bestPlane < fGeom->Nplanes()) {
141 int bestPlaneVal(bestPlane);
150 const detinfo::DetectorPropertiesData& detProp,
151 const std::vector<art::Ptr<recob::Hit>>& hits,
152 const geo::PlaneID::PlaneID_t plane)
const
155 double totalCharge = 0;
156 double totalEnergy = 0;
157 double correctedtotalCharge = 0;
158 double nElectrons = 0;
160 for (
auto const& hit : hits) {
164 clockData, detProp, hit->PeakTime());
170 nElectrons =
fCalorimetryAlg.ElectronsFromADCArea(correctedtotalCharge, plane);
171 totalEnergy = (nElectrons / util::kGeVToElectrons) * 1000;