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 19 of file ShowerLinearEnergy_tool.cc.

Constructor & Destructor Documentation

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

Definition at line 50 of file ShowerLinearEnergy_tool.cc.

51  : IShowerTool(pset.get<fhicl::ParameterSet>("BaseTools"))
52  , fGradients(pset.get<std::vector<double>>("Gradients"))
53  , fIntercepts(pset.get<std::vector<double>>("Intercepts"))
54  , fPFParticleLabel(pset.get<art::InputTag>("PFParticleLabel"))
55  , fVerbose(pset.get<int>("Verbose"))
56  , fShowerEnergyOutputLabel(pset.get<std::string>("ShowerEnergyOutputLabel"))
57  , fShowerBestPlaneOutputLabel(pset.get<std::string>("ShowerBestPlaneOutputLabel"))
58  {
60  if (fNumPlanes != fGradients.size() || fNumPlanes != fIntercepts.size()) {
61  throw cet::exception("ShowerLinearEnergy")
62  << "The number of planes does not match the size of the fcl parametes passed: Num Planes: "
63  << fNumPlanes << ", Gradients size: " << fGradients.size()
64  << ", Intercpts size: " << fIntercepts.size();
65  }
66  }
std::string string
Definition: nybbler.cc:12
art::ServiceHandle< geo::Geometry > fGeom
unsigned int Nplanes(unsigned int tpc=0, unsigned int cstat=0) const
Returns the total number of wire planes in the specified TPC.
T get(std::string const &key) const
Definition: ParameterSet.h:271
IShowerTool(const fhicl::ParameterSet &pset)
Definition: IShowerTool.h:28
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33

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 69 of file ShowerLinearEnergy_tool.cc.

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

151  {
152 
153  double totalCharge = 0, totalEnergy = 0;
154 
155  for (auto const& hit : hits) {
156  totalCharge += (hit->Integral() * std::exp((sampling_rate(clockData) * hit->PeakTime()) /
157  (detProp.ElectronLifetime() * 1e3)));
158  }
159 
160  totalEnergy = (totalCharge * fGradients.at(plane)) + fIntercepts.at(plane);
161 
162  return totalEnergy;
163  }
Detector simulation of raw signals on wires.
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 47 of file ShowerLinearEnergy_tool.cc.

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

Definition at line 37 of file ShowerLinearEnergy_tool.cc.

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

Definition at line 38 of file ShowerLinearEnergy_tool.cc.

unsigned int ShowerRecoTools::ShowerLinearEnergy::fNumPlanes
private

Definition at line 36 of file ShowerLinearEnergy_tool.cc.

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

Definition at line 40 of file ShowerLinearEnergy_tool.cc.

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

Definition at line 44 of file ShowerLinearEnergy_tool.cc.

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

Definition at line 43 of file ShowerLinearEnergy_tool.cc.

int ShowerRecoTools::ShowerLinearEnergy::fVerbose
private

Definition at line 41 of file ShowerLinearEnergy_tool.cc.


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