LArSoft  v10_04_05
Liquid Argon Software toolkit - https://larsoft.org/
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
 
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
 
geo::WireReadoutGeom const & fChannelMap = art::ServiceHandle<geo::WireReadout>()->Get()
 
calo::CalorimetryAlg fCalorimetryAlg
 
double fRecombinationFactor
 

Detailed Description

Definition at line 29 of file ShowerNumElectronsEnergy_tool.cc.

Constructor & Destructor Documentation

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

Definition at line 59 of file ShowerNumElectronsEnergy_tool.cc.

60  : IShowerTool(pset.get<fhicl::ParameterSet>("BaseTools"))
61  , fPFParticleLabel(pset.get<art::InputTag>("PFParticleLabel"))
62  , fVerbose(pset.get<int>("Verbose"))
63  , fShowerEnergyOutputLabel(pset.get<std::string>("ShowerEnergyOutputLabel"))
64  , fShowerBestPlaneOutputLabel(pset.get<std::string>("ShowerBestPlaneOutputLabel"))
65  , fCalorimetryAlg(pset.get<fhicl::ParameterSet>("CalorimetryAlg"))
66  , fRecombinationFactor(pset.get<double>("RecombinationFactor"))
67  {}
T get(std::string const &key) const
Definition: ParameterSet.h:314
IShowerTool(const fhicl::ParameterSet &pset)
Definition: IShowerTool.h:31

Member Function Documentation

virtual int ShowerRecoTools::IShowerTool::AddAssociations ( const art::Ptr< recob::PFParticle > &  pfpPtr,
art::Event Event,
reco::shower::ShowerElementHolder ShowerEleHolder 
)
inlinevirtualinherited
template<class T , class A , class B >
void ShowerRecoTools::IShowerTool::AddSingle ( A &  a,
B &  b,
std::string  Name 
)
inlineprotectedinherited

Definition at line 150 of file IShowerTool.h.

References reco::shower::ShowerProducedPtrsHolder::AddSingle().

151  {
152  UniquePtrs->AddSingle<T>(a, b, Name);
153  }
reco::shower::ShowerProducedPtrsHolder * UniquePtrs
Definition: IShowerTool.h:83
void AddSingle(A &a, B &b, const std::string &Name)
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.

References CalculateEnergy(), util::end(), fChannelMap, fPFParticleLabel, fShowerBestPlaneOutputLabel, fShowerEnergyOutputLabel, fVerbose, reco::shower::ShowerElementHolder::GetFindManyP(), art::ProductRetriever::getValidHandle(), hits(), art::Ptr< T >::key(), geo::WireReadoutGeom::Nplanes(), and reco::shower::ShowerElementHolder::SetElement().

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 
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(fChannelMap.Nplanes(), -999.);
115  std::vector<double> energyError(fChannelMap.Nplanes(), -999.);
116 
117  auto const clockData =
119  auto const detProp =
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 < fChannelMap.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  }
unsigned int PlaneID_t
Type for the ID number.
Definition: geo_types.h:365
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:69
Cluster finding and building.
decltype(auto) constexpr end(T &&obj)
ADL-aware version of std::end.
Definition: StdUtils.h:77
void hits()
Definition: readHits.C:15
key_type key() const noexcept
Definition: Ptr.h:166
unsigned int Nplanes(TPCID const &tpcid=details::tpc_zero) const
Returns the total number of planes in the specified TPC.
ValidHandle< PROD > getValidHandle(InputTag const &tag) const
2D representation of charge deposited in the TDC/wire plane
Definition: Hit.h:46
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 150 of file ShowerNumElectronsEnergy_tool.cc.

References DEFINE_ART_CLASS_TOOL, calo::CalorimetryAlg::ElectronsFromADCArea(), fCalorimetryAlg, fRecombinationFactor, hits(), util::kGeVToElectrons, and calo::CalorimetryAlg::LifetimeCorrection().

Referenced by CalculateElement().

154  {
155 
156  double totalCharge = 0;
157  double totalEnergy = 0;
158  double correctedtotalCharge = 0;
159  double nElectrons = 0;
160 
161  for (auto const& hit : hits) {
162  totalCharge +=
163  hit->Integral() *
165  clockData, detProp, hit->PeakTime()); // obtain charge and correct for lifetime
166  }
167 
168  // correct charge due to recombination
169  correctedtotalCharge = totalCharge / fRecombinationFactor;
170  // calculate # of electrons and the corresponding energy
171  nElectrons = fCalorimetryAlg.ElectronsFromADCArea(correctedtotalCharge, plane);
172  totalEnergy = (nElectrons / util::kGeVToElectrons) * 1000; // energy in MeV
173  return totalEnergy;
174  }
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
const shower::LArPandoraShowerAlg& ShowerRecoTools::IShowerTool::GetLArPandoraShowerAlg ( ) const
inlineprotectedinherited

Definition at line 80 of file IShowerTool.h.

Referenced by ShowerRecoTools::ShowerLengthPercentile::CalculateElement(), ShowerRecoTools::Shower3DCylinderTrackHitFinder::CalculateElement(), ShowerRecoTools::ShowerPCAPropergationStartPosition::CalculateElement(), ShowerRecoTools::Shower2DLinearRegressionTrackHitFinder::CalculateElement(), ShowerRecoTools::ShowerPFPVertexStartPosition::CalculateElement(), ShowerRecoTools::ShowerUnidirectiondEdx::CalculateElement(), ShowerRecoTools::ShowerDirectionCheater::CalculateElement(), ShowerRecoTools::ShowerPCADirection::CalculateElement(), ShowerRecoTools::ShowerIncrementalTrackHitFinder::CalculateElement(), ShowerRecoTools::ShowerTrajPointdEdx::CalculateElement(), ShowerRecoTools::ShowerPCADirection::CalculateShowerPCA(), ShowerRecoTools::Shower2DLinearRegressionTrackHitFinder::FindInitialTrackHits(), ShowerRecoTools::Shower3DCylinderTrackHitFinder::FindTrackSpacePoints(), ShowerRecoTools::ShowerIncrementalTrackHitFinder::FitSegmentAndCalculateResidual(), ShowerRecoTools::ShowerIncrementalTrackHitFinder::PruneFrontOfSPSPool(), ShowerRecoTools::ShowerIncrementalTrackHitFinder::PruneTrack(), ShowerRecoTools::ShowerIncrementalTrackHitFinder::RunTestOfIncrementalSpacePointFinder(), ShowerRecoTools::ShowerTrackPCADirection::ShowerPCAVector(), and ShowerRecoTools::ShowerIncrementalTrackHitFinder::ShowerPCAVector().

81  {
82  return fLArPandoraShowerAlg;
83  };
shower::LArPandoraShowerAlg fLArPandoraShowerAlg
Definition: IShowerTool.h:90
template<class T >
art::Ptr<T> ShowerRecoTools::IShowerTool::GetProducedElementPtr ( std::string  Name,
reco::shower::ShowerElementHolder ShowerEleHolder,
int  iter = -1 
)
inlineprotectedinherited

Definition at line 100 of file IShowerTool.h.

References reco::shower::ShowerElementHolder::CheckElement(), reco::shower::ShowerProducedPtrsHolder::CheckUniqueProduerPtr(), reco::shower::ShowerProducedPtrsHolder::GetArtPtr(), and reco::shower::ShowerElementHolder::GetShowerNumber().

103  {
104 
105  //Check the element has been set
106  bool check_element = ShowerEleHolder.CheckElement(Name);
107  if (!check_element) {
108  throw cet::exception("IShowerTool") << "tried to get a element that does not exist. Failed "
109  "at making the art ptr for Element: "
110  << Name << std::endl;
111  }
112 
113  //Check the unique ptr has been set.
114  bool check_ptr = UniquePtrs->CheckUniqueProduerPtr(Name);
115  if (!check_ptr) {
116  throw cet::exception("IShowerTool")
117  << "tried to get a ptr that does not exist. Failed at making the art ptr for Element"
118  << Name;
119  }
120 
121  //Check if the user has defined an index if not just use the current shower index/
122  int index;
123  if (iter != -1) { index = iter; }
124  else {
125  index = ShowerEleHolder.GetShowerNumber();
126  }
127 
128  //Make the ptr
129  return UniquePtrs->GetArtPtr<T>(Name, index);
130  }
reco::shower::ShowerProducedPtrsHolder * UniquePtrs
Definition: IShowerTool.h:83
bool CheckUniqueProduerPtr(const std::string &Name) const
bool CheckElement(const std::string &Name) const
art::Ptr< T > GetArtPtr(const std::string &Name, const int &iter) const
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33
int ShowerRecoTools::IShowerTool::GetVectorPtrSize ( std::string  Name)
inlineprotectedinherited
void ShowerRecoTools::IShowerTool::InitaliseProducerPtr ( reco::shower::ShowerProducedPtrsHolder uniqueproducerPtrs)
inlineinherited

Definition at line 66 of file IShowerTool.h.

67  {
68  UniquePtrs = &uniqueproducerPtrs;
69  }
reco::shower::ShowerProducedPtrsHolder * UniquePtrs
Definition: IShowerTool.h:83
virtual void ShowerRecoTools::IShowerTool::InitialiseProducers ( )
inlinevirtualinherited
template<class T >
void ShowerRecoTools::IShowerTool::InitialiseProduct ( std::string  Name,
std::string  InstanceName = "" 
)
inlineprotectedinherited

Definition at line 135 of file IShowerTool.h.

References art::ProducesCollector::produces(), and reco::shower::ShowerProducedPtrsHolder::SetShowerUniqueProduerPtr().

136  {
137 
138  if (collectorPtr == nullptr) {
139  mf::LogWarning("IShowerTool") << "The art::ProducesCollector ptr has not been set";
140  return;
141  }
142 
143  collectorPtr->produces<T>(InstanceName);
144  UniquePtrs->SetShowerUniqueProduerPtr(type<T>(), Name, InstanceName);
145  }
reco::shower::ShowerProducedPtrsHolder * UniquePtrs
Definition: IShowerTool.h:83
art::ProducesCollector * collectorPtr
Definition: IShowerTool.h:95
void produces(std::string const &instanceName={}, Persistable const persistable=Persistable::Yes)
MaybeLogger_< ELseverityLevel::ELsev_warning, false > LogWarning
int SetShowerUniqueProduerPtr(type< T >, const std::string &Name, const std::string &Instance="")
void ShowerRecoTools::IShowerTool::PrintPtr ( std::string  Name)
inlineprotectedinherited

Definition at line 160 of file IShowerTool.h.

References reco::shower::ShowerProducedPtrsHolder::PrintPtr().

Referenced by ShowerRecoTools::ShowerExampleTool::CalculateElement().

160 { UniquePtrs->PrintPtr(Name); }
reco::shower::ShowerProducedPtrsHolder * UniquePtrs
Definition: IShowerTool.h:83
void PrintPtr(const std::string &Name) const
void ShowerRecoTools::IShowerTool::PrintPtrs ( )
inlineprotectedinherited
int ShowerRecoTools::IShowerTool::RunShowerTool ( const art::Ptr< recob::PFParticle > &  pfparticle,
art::Event Event,
reco::shower::ShowerElementHolder ShowerEleHolder,
std::string  evd_display_name_append = "" 
)
inlineinherited

Definition at line 44 of file IShowerTool.h.

48  {
49 
50  int calculation_status = CalculateElement(pfparticle, Event, ShowerEleHolder);
51  if (calculation_status != 0) return calculation_status;
52  if (fRunEventDisplay) {
54  pfparticle, Event, ShowerEleHolder, evd_display_name_append);
55  }
56  return calculation_status;
57  }
void DebugEVD(art::Ptr< recob::PFParticle > const &pfparticle, art::Event const &Event, const reco::shower::ShowerElementHolder &ShowerEleHolder, std::string const &evd_disp_name_append="") const
virtual int CalculateElement(const art::Ptr< recob::PFParticle > &pfparticle, art::Event &Event, reco::shower::ShowerElementHolder &ShowerEleHolder)=0
const shower::LArPandoraShowerAlg & GetLArPandoraShowerAlg() const
Definition: IShowerTool.h:80
void ShowerRecoTools::IShowerTool::SetPtr ( art::ProducesCollector collector)
inlineinherited

Definition at line 63 of file IShowerTool.h.

63 { collectorPtr = collector; }
art::ProducesCollector * collectorPtr
Definition: IShowerTool.h:95

Member Data Documentation

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

Definition at line 53 of file ShowerNumElectronsEnergy_tool.cc.

Referenced by CalculateEnergy().

geo::WireReadoutGeom const& ShowerRecoTools::ShowerNumElectronsEnergy::fChannelMap = art::ServiceHandle<geo::WireReadout>()->Get()
private

Definition at line 52 of file ShowerNumElectronsEnergy_tool.cc.

Referenced by CalculateElement().

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

Definition at line 45 of file ShowerNumElectronsEnergy_tool.cc.

Referenced by CalculateElement().

double ShowerRecoTools::ShowerNumElectronsEnergy::fRecombinationFactor
private

Definition at line 56 of file ShowerNumElectronsEnergy_tool.cc.

Referenced by CalculateEnergy().

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

Definition at line 49 of file ShowerNumElectronsEnergy_tool.cc.

Referenced by CalculateElement().

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

Definition at line 48 of file ShowerNumElectronsEnergy_tool.cc.

Referenced by CalculateElement().

int ShowerRecoTools::ShowerNumElectronsEnergy::fVerbose
private

Definition at line 46 of file ShowerNumElectronsEnergy_tool.cc.

Referenced by CalculateElement().


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