All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Member Functions | Private Member Functions | Private Attributes | List of all members
ShowerRecoTools::ShowerLinearEnergy Class Reference
Inheritance diagram for ShowerRecoTools::ShowerLinearEnergy:
ShowerRecoTools::IShowerTool

Public Member Functions

 ShowerLinearEnergy (const fhicl::ParameterSet &pset)
 
int CalculateElement (const art::Ptr< recob::PFParticle > &pfparticle, art::Event &Event, reco::shower::ShowerElementHolder &ShowerElementHolder) override
 

Private Member Functions

double CalculateEnergy (const detinfo::DetectorClocksData &clockData, const detinfo::DetectorPropertiesData &detProp, const std::vector< art::Ptr< recob::Hit >> &hits, const geo::PlaneID::PlaneID_t plane) const
 
- Private Member Functions inherited from ShowerRecoTools::IShowerTool
 IShowerTool (const fhicl::ParameterSet &pset)
 
virtual ~IShowerTool () noexcept=default
 
int RunShowerTool (const art::Ptr< recob::PFParticle > &pfparticle, art::Event &Event, reco::shower::ShowerElementHolder &ShowerEleHolder, std::string evd_display_name_append="")
 
virtual void InitialiseProducers ()
 
void SetPtr (art::ProducesCollector *collector)
 
void InitaliseProducerPtr (reco::shower::ShowerProducedPtrsHolder &uniqueproducerPtrs)
 
virtual int AddAssociations (const art::Ptr< recob::PFParticle > &pfpPtr, art::Event &Event, reco::shower::ShowerElementHolder &ShowerEleHolder)
 
const shower::LArPandoraShowerAlgGetLArPandoraShowerAlg () const
 
template<class T >
art::Ptr< T > GetProducedElementPtr (std::string Name, reco::shower::ShowerElementHolder &ShowerEleHolder, int iter=-1)
 
template<class T >
void InitialiseProduct (std::string Name, std::string InstanceName="")
 
template<class T , class A , class B >
void AddSingle (A &a, B &b, std::string Name)
 
int GetVectorPtrSize (std::string Name)
 
void PrintPtrs ()
 
void PrintPtr (std::string Name)
 

Private Attributes

unsigned int fNumPlanes
 
std::vector< double > fGradients
 
std::vector< double > fIntercepts
 
art::InputTag fPFParticleLabel
 
int fVerbose
 
std::string fShowerEnergyOutputLabel
 
std::string fShowerBestPlaneOutputLabel
 
art::ServiceHandle< geo::GeometryfGeom
 

Detailed Description

Definition at line 23 of file ShowerLinearEnergy_tool.cc.

Constructor & Destructor Documentation

ShowerRecoTools::ShowerLinearEnergy::ShowerLinearEnergy ( const fhicl::ParameterSet &  pset)

Definition at line 54 of file ShowerLinearEnergy_tool.cc.

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"))
62  {
63  fNumPlanes = fGeom->Nplanes();
64  if (fNumPlanes != fGradients.size() || fNumPlanes != fIntercepts.size()) {
65  throw cet::exception("ShowerLinearEnergy")
66  << "The number of planes does not match the size of the fcl parametes passed: Num Planes: "
67  << fNumPlanes << ", Gradients size: " << fGradients.size()
68  << ", Intercpts size: " << fIntercepts.size();
69  }
70  }
art::ServiceHandle< geo::Geometry > fGeom
IShowerTool(const fhicl::ParameterSet &pset)
Definition: IShowerTool.h:29

Member Function Documentation

int ShowerRecoTools::ShowerLinearEnergy::CalculateElement ( const art::Ptr< recob::PFParticle > &  pfparticle,
art::Event &  Event,
reco::shower::ShowerElementHolder ShowerElementHolder 
)
overridevirtual

Implements ShowerRecoTools::IShowerTool.

Definition at line 73 of file ShowerLinearEnergy_tool.cc.

76  {
77 
78  // Get the assocated pfParicle vertex PFParticles
79  auto const pfpHandle = Event.getValidHandle<std::vector<recob::PFParticle>>(fPFParticleLabel);
80 
81  //Get the clusters
82  auto const clusHandle = Event.getValidHandle<std::vector<recob::Cluster>>(fPFParticleLabel);
83 
84  const art::FindManyP<recob::Cluster>& fmc =
85  ShowerEleHolder.GetFindManyP<recob::Cluster>(pfpHandle, Event, fPFParticleLabel);
86  // art::FindManyP<recob::Cluster> fmc(pfpHandle, Event, fPFParticleLabel);
87  std::vector<art::Ptr<recob::Cluster>> clusters = fmc.at(pfparticle.key());
88 
89  //Get the hit association
90  const art::FindManyP<recob::Hit>& fmhc =
91  ShowerEleHolder.GetFindManyP<recob::Hit>(clusHandle, Event, fPFParticleLabel);
92  // art::FindManyP<recob::Hit> fmhc(clusHandle, Event, fPFParticleLabel);
93 
94  std::map<geo::PlaneID::PlaneID_t, std::vector<art::Ptr<recob::Hit>>> planeHits;
95 
96  //Loop over the clusters in the plane and get the hits
97  for (auto const& cluster : clusters) {
98 
99  //Get the hits
100  std::vector<art::Ptr<recob::Hit>> hits = fmhc.at(cluster.key());
101 
102  //Get the plane.
103  const geo::PlaneID::PlaneID_t plane(cluster->Plane().Plane);
104 
105  planeHits[plane].insert(planeHits[plane].end(), hits.begin(), hits.end());
106  }
107 
108  // Calculate the energy for each plane && best plane
109  geo::PlaneID::PlaneID_t bestPlane = std::numeric_limits<geo::PlaneID::PlaneID_t>::max();
110  unsigned int bestPlaneNumHits = 0;
111 
112  //Holder for the final product
113  std::vector<double> energyVec(fNumPlanes, -999.);
114  std::vector<double> energyError(fNumPlanes, -999.);
115 
116  auto const clockData =
117  art::ServiceHandle<detinfo::DetectorClocksService const>()->DataFor(Event);
118  auto const detProp =
119  art::ServiceHandle<detinfo::DetectorPropertiesService const>()->DataFor(Event, clockData);
120 
121  for (auto const& [plane, hits] : planeHits) {
122 
123  unsigned int planeNumHits = hits.size();
124 
125  //Calculate the Energy for
126  double Energy = CalculateEnergy(clockData, detProp, hits, plane);
127  // If the energy is negative, leave it at -999
128  if (Energy > 0) energyVec.at(plane) = Energy;
129 
130  if (planeNumHits > bestPlaneNumHits) {
131  bestPlane = plane;
132  bestPlaneNumHits = planeNumHits;
133  }
134  }
135 
136  ShowerEleHolder.SetElement(energyVec, energyError, fShowerEnergyOutputLabel);
137  // Only set the best plane if it has some hits in it
138  if (bestPlane < fGeom->Nplanes()) {
139  // Need to cast as an int for legacy default of -999
140  // have to define a new variable as we pass-by-reference when filling
141  int bestPlaneVal(bestPlane);
142  ShowerEleHolder.SetElement(bestPlaneVal, fShowerBestPlaneOutputLabel);
143  }
144 
145  return 0;
146  }
process_name cluster
Definition: cheaterreco.fcl:51
double CalculateEnergy(const detinfo::DetectorClocksData &clockData, const detinfo::DetectorPropertiesData &detProp, const std::vector< art::Ptr< recob::Hit >> &hits, const geo::PlaneID::PlaneID_t plane) const
unsigned int PlaneID_t
Type for the ID number.
Definition: geo_types.h:473
Set of hits with a 2D structure.
Definition: Cluster.h:71
auto end(FixedBins< T, C > const &) noexcept
Definition: FixedBins.h:585
process_name Energy
Definition: lArDet.fcl:66
2D representation of charge deposited in the TDC/wire plane
Definition: Hit.h:48
auto const detProp
double ShowerRecoTools::ShowerLinearEnergy::CalculateEnergy ( const detinfo::DetectorClocksData clockData,
const detinfo::DetectorPropertiesData detProp,
const std::vector< art::Ptr< recob::Hit >> &  hits,
const geo::PlaneID::PlaneID_t  plane 
) const
private

Definition at line 151 of file ShowerLinearEnergy_tool.cc.

155  {
156 
157  double totalCharge = 0, totalEnergy = 0;
158 
159  for (auto const& hit : hits) {
160  totalCharge += (hit->Integral() * std::exp((sampling_rate(clockData) * hit->PeakTime()) /
161  (detProp.ElectronLifetime() * 1e3)));
162  }
163 
164  totalEnergy = (totalCharge * fGradients.at(plane)) + fIntercepts.at(plane);
165 
166  return totalEnergy;
167  }
process_name hit
Definition: cheaterreco.fcl:51
double sampling_rate(DetectorClocksData const &data)
Returns the period of the TPC readout electronics clock.

Member Data Documentation

art::ServiceHandle<geo::Geometry> ShowerRecoTools::ShowerLinearEnergy::fGeom
private

Definition at line 51 of file ShowerLinearEnergy_tool.cc.

std::vector<double> ShowerRecoTools::ShowerLinearEnergy::fGradients
private

Definition at line 41 of file ShowerLinearEnergy_tool.cc.

std::vector<double> ShowerRecoTools::ShowerLinearEnergy::fIntercepts
private

Definition at line 42 of file ShowerLinearEnergy_tool.cc.

unsigned int ShowerRecoTools::ShowerLinearEnergy::fNumPlanes
private

Definition at line 40 of file ShowerLinearEnergy_tool.cc.

art::InputTag ShowerRecoTools::ShowerLinearEnergy::fPFParticleLabel
private

Definition at line 44 of file ShowerLinearEnergy_tool.cc.

std::string ShowerRecoTools::ShowerLinearEnergy::fShowerBestPlaneOutputLabel
private

Definition at line 48 of file ShowerLinearEnergy_tool.cc.

std::string ShowerRecoTools::ShowerLinearEnergy::fShowerEnergyOutputLabel
private

Definition at line 47 of file ShowerLinearEnergy_tool.cc.

int ShowerRecoTools::ShowerLinearEnergy::fVerbose
private

Definition at line 45 of file ShowerLinearEnergy_tool.cc.


The documentation for this class was generated from the following file: