35 const detinfo::DetectorPropertiesData& detProp,
36 const std::vector<art::Ptr<recob::Hit>>& hits,
37 const geo::PlaneID::PlaneID_t plane)
const;
51 art::ServiceHandle<geo::Geometry>
fGeom;
55 :
IShowerTool(pset.get<fhicl::ParameterSet>(
"BaseTools"))
56 , fGradients(pset.get<std::vector<double>>(
"Gradients"))
57 , fIntercepts(pset.get<std::vector<double>>(
"Intercepts"))
58 , fPFParticleLabel(pset.get<
art::InputTag>(
"PFParticleLabel"))
59 , fVerbose(pset.get<int>(
"Verbose"))
60 , fShowerEnergyOutputLabel(pset.get<std::string>(
"ShowerEnergyOutputLabel"))
61 , fShowerBestPlaneOutputLabel(pset.get<std::string>(
"ShowerBestPlaneOutputLabel"))
65 throw cet::exception(
"ShowerLinearEnergy")
66 <<
"The number of planes does not match the size of the fcl parametes passed: Num Planes: "
78 auto const pfpHandle = Event.getValidHandle<std::vector<recob::PFParticle>>(
fPFParticleLabel);
81 auto const clusHandle = Event.getValidHandle<std::vector<recob::Cluster>>(
fPFParticleLabel);
83 const art::FindManyP<recob::Cluster>& fmc =
86 std::vector<art::Ptr<recob::Cluster>> clusters = fmc.at(pfparticle.key());
89 const art::FindManyP<recob::Hit>& fmhc =
93 std::map<geo::PlaneID::PlaneID_t, std::vector<art::Ptr<recob::Hit>>> planeHits;
96 for (
auto const&
cluster : clusters) {
99 std::vector<art::Ptr<recob::Hit>> hits = fmhc.at(
cluster.key());
102 const geo::PlaneID::PlaneID_t plane(
cluster->Plane().Plane);
104 planeHits[plane].insert(planeHits[plane].end(), hits.begin(), hits.end());
108 geo::PlaneID::PlaneID_t bestPlane = std::numeric_limits<geo::PlaneID::PlaneID_t>::max();
109 unsigned int bestPlaneNumHits = 0;
112 std::vector<double> energyVec(
fNumPlanes, -999.);
113 std::vector<double> energyError(
fNumPlanes, -999.);
115 auto const clockData =
116 art::ServiceHandle<detinfo::DetectorClocksService const>()->DataFor(Event);
118 art::ServiceHandle<detinfo::DetectorPropertiesService const>()->DataFor(Event, clockData);
120 for (
auto const& [plane, hits] : planeHits) {
122 unsigned int planeNumHits = hits.size();
127 if (Energy > 0) energyVec.at(plane) = Energy;
129 if (planeNumHits > bestPlaneNumHits) {
131 bestPlaneNumHits = planeNumHits;
137 if (bestPlane < fGeom->Nplanes()) {
140 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, totalEnergy = 0;
157 for (
auto const& hit : hits) {
158 totalCharge += (hit->Integral() * std::exp((sampling_rate(clockData) * hit->PeakTime()) /
159 (detProp.ElectronLifetime() * 1e3)));