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::ShowerNumElectronsEnergy Class Reference
Inheritance diagram for ShowerRecoTools::ShowerNumElectronsEnergy:
ShowerRecoTools::IShowerTool

Public Member Functions

 ShowerNumElectronsEnergy (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

art::InputTag fPFParticleLabel
 
int fVerbose
 
std::string fShowerEnergyOutputLabel
 
std::string fShowerBestPlaneOutputLabel
 
art::ServiceHandle< geo::GeometryfGeom
 
calo::CalorimetryAlg fCalorimetryAlg
 
double fRecombinationFactor
 

Detailed Description

Definition at line 28 of file ShowerNumElectronsEnergy_tool.cc.

Constructor & Destructor Documentation

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

Definition at line 58 of file ShowerNumElectronsEnergy_tool.cc.

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"))
66  {}
IShowerTool(const fhicl::ParameterSet &pset)
Definition: IShowerTool.h:29

Member Function Documentation

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

Implements ShowerRecoTools::IShowerTool.

Definition at line 69 of file ShowerNumElectronsEnergy_tool.cc.

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

155  {
156 
157  double totalCharge = 0;
158  double totalEnergy = 0;
159  double correctedtotalCharge = 0;
160  double nElectrons = 0;
161 
162  for (auto const& hit : hits) {
163  totalCharge +=
164  hit->Integral() *
166  clockData, detProp, hit->PeakTime()); // obtain charge and correct for lifetime
167  }
168 
169  // correct charge due to recombination
170  correctedtotalCharge = totalCharge / fRecombinationFactor;
171  // calculate # of electrons and the corresponding energy
172  nElectrons = fCalorimetryAlg.ElectronsFromADCArea(correctedtotalCharge, plane);
173  totalEnergy = (nElectrons / util::kGeVToElectrons) * 1000; // energy in MeV
174  return totalEnergy;
175  }
process_name hit
Definition: cheaterreco.fcl:51
double ElectronsFromADCArea(double area, unsigned short plane) const
constexpr double kGeVToElectrons
23.6eV per ion pair, 1e9 eV/GeV
double LifetimeCorrection(detinfo::DetectorClocksData const &clock_data, detinfo::DetectorPropertiesData const &det_prop, double time, double T0=0) const

Member Data Documentation

calo::CalorimetryAlg ShowerRecoTools::ShowerNumElectronsEnergy::fCalorimetryAlg
private

Definition at line 52 of file ShowerNumElectronsEnergy_tool.cc.

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

Definition at line 51 of file ShowerNumElectronsEnergy_tool.cc.

art::InputTag ShowerRecoTools::ShowerNumElectronsEnergy::fPFParticleLabel
private

Definition at line 44 of file ShowerNumElectronsEnergy_tool.cc.

double ShowerRecoTools::ShowerNumElectronsEnergy::fRecombinationFactor
private

Definition at line 55 of file ShowerNumElectronsEnergy_tool.cc.

std::string ShowerRecoTools::ShowerNumElectronsEnergy::fShowerBestPlaneOutputLabel
private

Definition at line 48 of file ShowerNumElectronsEnergy_tool.cc.

std::string ShowerRecoTools::ShowerNumElectronsEnergy::fShowerEnergyOutputLabel
private

Definition at line 47 of file ShowerNumElectronsEnergy_tool.cc.

int ShowerRecoTools::ShowerNumElectronsEnergy::fVerbose
private

Definition at line 45 of file ShowerNumElectronsEnergy_tool.cc.


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