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 25 of file ShowerNumElectronsEnergy_tool.cc.

Constructor & Destructor Documentation

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

Definition at line 55 of file ShowerNumElectronsEnergy_tool.cc.

56  : IShowerTool(pset.get<fhicl::ParameterSet>("BaseTools"))
57  , fPFParticleLabel(pset.get<art::InputTag>("PFParticleLabel"))
58  , fVerbose(pset.get<int>("Verbose"))
59  , fShowerEnergyOutputLabel(pset.get<std::string>("ShowerEnergyOutputLabel"))
60  , fShowerBestPlaneOutputLabel(pset.get<std::string>("ShowerBestPlaneOutputLabel"))
61  , fCalorimetryAlg(pset.get<fhicl::ParameterSet>("CalorimetryAlg"))
62  , fRecombinationFactor(pset.get<double>("RecombinationFactor"))
63  {}
std::string string
Definition: nybbler.cc:12
T get(std::string const &key) const
Definition: ParameterSet.h:271
IShowerTool(const fhicl::ParameterSet &pset)
Definition: IShowerTool.h:28

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 66 of file ShowerNumElectronsEnergy_tool.cc.

69  {
70 
71  if (fVerbose)
72  std::cout
73  << "~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Shower Reco Energy Tool ~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
74  << std::endl;
75 
76  // Get the assocated pfParicle vertex PFParticles
77  auto const pfpHandle = Event.getValidHandle<std::vector<recob::PFParticle>>(fPFParticleLabel);
78 
79  //Get the clusters
80  auto const clusHandle = Event.getValidHandle<std::vector<recob::Cluster>>(fPFParticleLabel);
81 
82  const art::FindManyP<recob::Cluster>& fmc =
83  ShowerEleHolder.GetFindManyP<recob::Cluster>(pfpHandle, Event, fPFParticleLabel);
84  // art::FindManyP<recob::Cluster> fmc(pfpHandle, Event, fPFParticleLabel);
85  std::vector<art::Ptr<recob::Cluster>> clusters = fmc.at(pfparticle.key());
86 
87  //Get the hit association
88  const art::FindManyP<recob::Hit>& fmhc =
89  ShowerEleHolder.GetFindManyP<recob::Hit>(clusHandle, Event, fPFParticleLabel);
90  // art::FindManyP<recob::Hit> fmhc(clusHandle, Event, fPFParticleLabel);
91 
92  std::map<geo::PlaneID::PlaneID_t, std::vector<art::Ptr<recob::Hit>>> planeHits;
93 
94  //Loop over the clusters in the plane and get the hits
95  for (auto const& cluster : clusters) {
96 
97  //Get the hits
98  std::vector<art::Ptr<recob::Hit>> hits = fmhc.at(cluster.key());
99 
100  //Get the plane.
101  const geo::PlaneID::PlaneID_t plane(cluster->Plane().Plane);
102 
103  planeHits[plane].insert(planeHits[plane].end(), hits.begin(), hits.end());
104  }
105 
106  // Calculate the energy for each plane && best plane
108  unsigned int bestPlaneNumHits = 0;
109 
110  //Holder for the final product
111  std::vector<double> energyVec(fGeom->Nplanes(), -999.);
112  std::vector<double> energyError(fGeom->Nplanes(), -999.);
113 
114  auto const clockData =
116  auto const detProp =
118 
119  for (auto const& [plane, hits] : planeHits) {
120 
121  unsigned int planeNumHits = hits.size();
122 
123  //Calculate the Energy for
124  double Energy = CalculateEnergy(clockData, detProp, hits, plane);
125  // If the energy is negative, leave it at -999
126  if (Energy > 0) energyVec.at(plane) = Energy;
127 
128  if (planeNumHits > bestPlaneNumHits) {
129  bestPlane = plane;
130  bestPlaneNumHits = planeNumHits;
131  }
132  }
133 
134  ShowerEleHolder.SetElement(energyVec, energyError, fShowerEnergyOutputLabel);
135  // Only set the best plane if it has some hits in it
136  if (bestPlane < fGeom->Nplanes()) {
137  // Need to cast as an int for legacy default of -999
138  // have to define a new variable as we pass-by-reference when filling
139  int bestPlaneVal(bestPlane);
140  ShowerEleHolder.SetElement(bestPlaneVal, fShowerBestPlaneOutputLabel);
141  }
142 
143  return 0;
144  }
end
while True: pbar.update(maxval-len(onlies[E][S])) #print iS, "/", len(onlies[E][S]) found = False for...
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
Cluster finding and building.
unsigned int Nplanes(unsigned int tpc=0, unsigned int cstat=0) const
Returns the total number of wire planes in the specified TPC.
key_type key() const noexcept
Definition: Ptr.h:216
ValidHandle< PROD > getValidHandle(InputTag const &tag) const
Definition: DataViewImpl.h:441
static int max(int a, int b)
2D representation of charge deposited in the TDC/wire plane
Definition: Hit.h:48
QTextStream & endl(QTextStream &s)
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 148 of file ShowerNumElectronsEnergy_tool.cc.

152  {
153 
154  double totalCharge = 0;
155  double totalEnergy = 0;
156  double correctedtotalCharge = 0;
157  double nElectrons = 0;
158 
159  for (auto const& hit : hits) {
160  totalCharge +=
161  hit->Integral() *
163  clockData, detProp, hit->PeakTime()); // obtain charge and correct for lifetime
164  }
165 
166  // correct charge due to recombination
167  correctedtotalCharge = totalCharge / fRecombinationFactor;
168  // calculate # of electrons and the corresponding energy
169  nElectrons = fCalorimetryAlg.ElectronsFromADCArea(correctedtotalCharge, plane);
170  totalEnergy = (nElectrons / util::kGeVToElectrons) * 1000; // energy in MeV
171  return totalEnergy;
172  }
double ElectronsFromADCArea(double area, unsigned short plane) const
constexpr double kGeVToElectrons
23.6eV per ion pair, 1e9 eV/GeV
Detector simulation of raw signals on wires.
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 49 of file ShowerNumElectronsEnergy_tool.cc.

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

Definition at line 48 of file ShowerNumElectronsEnergy_tool.cc.

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

Definition at line 41 of file ShowerNumElectronsEnergy_tool.cc.

double ShowerRecoTools::ShowerNumElectronsEnergy::fRecombinationFactor
private

Definition at line 52 of file ShowerNumElectronsEnergy_tool.cc.

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

Definition at line 45 of file ShowerNumElectronsEnergy_tool.cc.

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

Definition at line 44 of file ShowerNumElectronsEnergy_tool.cc.

int ShowerRecoTools::ShowerNumElectronsEnergy::fVerbose
private

Definition at line 42 of file ShowerNumElectronsEnergy_tool.cc.


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