LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
ShowerRecoTools::ShowerBayesianTrucatingdEdx Class Reference
Inheritance diagram for ShowerRecoTools::ShowerBayesianTrucatingdEdx:
ShowerRecoTools::IShowerTool

Public Member Functions

 ShowerBayesianTrucatingdEdx (const fhicl::ParameterSet &pset)
 
int CalculateElement (const art::Ptr< recob::PFParticle > &pfparticle, art::Event &Event, reco::shower::ShowerElementHolder &ShowerEleHolder) override
 
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)
 

Protected Member Functions

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 Member Functions

double CalculatePosterior (std::string priorname, std::vector< double > &values, int &minprob, float &mean, float &likelihood)
 
double CalculatePosterior (std::string priorname, std::vector< double > &values)
 
bool isProbabilityGood (float &old_prob, float &new_prob)
 
bool isPosteriorProbabilityGood (double &prob, double &old_posteior)
 
bool CheckPoint (std::string priorname, double &value)
 
std::vector< double > GetLikelihooddEdxVec (double &electronprob, double &photonprob, std::string prior, std::vector< double > &dEdxVec)
 
std::vector< double > MakeSeed (std::vector< double > &dEdxVec)
 
void ForceSeedToFit (std::vector< double > &SeedTrack, std::string &prior, float &mean, double &posterior)
 
void RecurivelyAddHit (std::vector< double > &SeedTrack, std::vector< double > &dEdxVec, std::string &prior, int &SkippedHitsNum, float &old_mean, double &old_posteior)
 

Private Attributes

TH1F * electronpriorHist
 
TH1F * photonpriorHist
 
int fVerbose
 
std::string fdEdxInputLabel
 
int fNumSeedHits
 
float fProbSeedCut
 
float fProbPointCut
 
float fPostiorCut
 
int fnSkipHits
 
std::string fShowerdEdxOutputLabel
 
bool fDefineBestPlane
 
std::string fShowerBestPlaneOutputLabel
 

Detailed Description

Definition at line 26 of file ShowerBayesianTrucatingdEdx_tool.cc.

Constructor & Destructor Documentation

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

Definition at line 91 of file ShowerBayesianTrucatingdEdx_tool.cc.

References electronpriorHist, fin, fhicl::ParameterSet::get(), and photonpriorHist.

92  : IShowerTool(pset.get<fhicl::ParameterSet>("BaseTools"))
93  , fVerbose(pset.get<int>("Verbose"))
94  , fdEdxInputLabel(pset.get<std::string>("dEdxInputLabel"))
95  , fNumSeedHits(pset.get<int>("NumSeedHits"))
96  , fProbSeedCut(pset.get<float>("ProbSeedCut"))
97  , fProbPointCut(pset.get<float>("ProbPointCut"))
98  , fPostiorCut(pset.get<float>("PostiorCut"))
99  , fnSkipHits(pset.get<int>("nSkipHits"))
100  , fShowerdEdxOutputLabel(pset.get<std::string>("ShowerdEdxOutputLabel"))
101  , fDefineBestPlane(pset.get<bool>("DefineBestPlane"))
102  , fShowerBestPlaneOutputLabel(pset.get<std::string>("ShowerBestPlaneOutputLabel"))
103  {
104 
105  //Get the prior file name
106  std::string fname;
107  cet::search_path sp("FW_SEARCH_PATH");
108  auto PriorPath = pset.get<std::string>("PriorFname");
109  if (!sp.find_file(PriorPath, fname)) {
110  throw cet::exception("ShowerBayesianTrucatingdEdx") << "Could not find the prior file";
111  }
112  std::string electron_histoname = pset.get<std::string>("PriorElectronHistoName");
113  std::string photon_histoname = pset.get<std::string>("PriorPhotonHistoName");
114 
115  TFile fin(fname.c_str(), "READ");
116  if (!fin.IsOpen()) {
117  throw cet::exception("ShowerBayesianTrucatingdEdx") << "Could read the prior file. Stopping";
118  }
119 
120  //Get the histograms.
121  electronpriorHist = dynamic_cast<TH1F*>(fin.Get(electron_histoname.c_str()));
122  if (!electronpriorHist) {
123  throw cet::exception("ShowerBayesianTrucatingdEdx") << "Could not read the electron hist";
124  }
125  photonpriorHist = dynamic_cast<TH1F*>(fin.Get(photon_histoname.c_str()));
126  if (!photonpriorHist) {
127  throw cet::exception("ShowerBayesianTrucatingdEdx") << "Could not read the photon hist ";
128  }
129 
130  if (electronpriorHist->GetNbinsX() != photonpriorHist->GetNbinsX()) {
131  throw cet::exception("ShowerBayesianTrucatingdEdx") << "Histrogram bins do not match";
132  }
133 
134  //Normalise the histograms.
135  electronpriorHist->Scale(1 / electronpriorHist->Integral());
136  photonpriorHist->Scale(1 / photonpriorHist->Integral());
137  }
TString fin
Definition: Style.C:24
T get(std::string const &key) const
Definition: ParameterSet.h:314
IShowerTool(const fhicl::ParameterSet &pset)
Definition: IShowerTool.h:33
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33

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 152 of file IShowerTool.h.

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

153  {
154  UniquePtrs->AddSingle<T>(a, b, Name);
155  }
reco::shower::ShowerProducedPtrsHolder * UniquePtrs
Definition: IShowerTool.h:85
void AddSingle(A &a, B &b, const std::string &Name)
int ShowerRecoTools::ShowerBayesianTrucatingdEdx::CalculateElement ( const art::Ptr< recob::PFParticle > &  pfparticle,
art::Event Event,
reco::shower::ShowerElementHolder ShowerEleHolder 
)
overridevirtual

Implements ShowerRecoTools::IShowerTool.

Definition at line 139 of file ShowerBayesianTrucatingdEdx_tool.cc.

References reco::shower::ShowerElementHolder::CheckElement(), fdEdxInputLabel, fDefineBestPlane, fShowerBestPlaneOutputLabel, fShowerdEdxOutputLabel, fVerbose, reco::shower::ShowerElementHolder::GetElement(), GetLikelihooddEdxVec(), reco::shower::ShowerElementHolder::SetElement(), and util::size().

143  {
144 
145  //The idea , to some peoples distaste, is to attempt to improve the dEdx value by assuming
146  //The particle is either a) electron b) a e-e+ pair.
147  //We will take the start of track and work down until a few hits destory our postier probability.
148 
149  //Note: tried takeing the postior with the highest sum of the probabilitys on all three
150  // planes and on the 2 planes with the most hits. Made things worse.
151 
152  //Get the vectors of the dEdx Elements
153  if (!ShowerEleHolder.CheckElement(fdEdxInputLabel)) {
154  if (fVerbose)
155  mf::LogError("ShowerBayesianTrucatingdEdx")
156  << "Start position not set, returning " << std::endl;
157  return 1;
158  }
159 
160  std::map<int, std::vector<double>> dEdx_plane_final;
161  std::map<int, std::vector<double>> dEdx_vec_planes;
162  ShowerEleHolder.GetElement(fdEdxInputLabel, dEdx_vec_planes);
163 
164  //Do this for each plane;
165  for (auto const& dEdx_vec_plane : dEdx_vec_planes) {
166 
167  //Set up out final value if we don't have any points.
168  if (dEdx_vec_plane.second.size() < 1) {
169  dEdx_plane_final[dEdx_vec_plane.first] = {};
170  continue;
171  }
172 
173  std::vector<double> dEdx_vec = dEdx_vec_plane.second;
174 
175  double electronprob_eprior = 0;
176  double photonprob_eprior = 0;
177 
178  double electronprob_pprior = 0;
179  double photonprob_pprior = 0;
180 
181  std::vector<double> dEdx_electronprior =
182  GetLikelihooddEdxVec(electronprob_eprior, photonprob_eprior, "electron", dEdx_vec);
183  std::vector<double> dEdx_photonprior =
184  GetLikelihooddEdxVec(electronprob_pprior, photonprob_pprior, "photon", dEdx_vec);
185 
186  //Use the vector which maximises both priors.
187  if (electronprob_eprior < photonprob_pprior) {
188  dEdx_plane_final[dEdx_vec_plane.first] = dEdx_photonprior;
189  }
190  else {
191  dEdx_plane_final[dEdx_vec_plane.first] = dEdx_electronprior;
192  }
193 
194  } //Plane Loop
195 
196  //Calculate the median of the of dEdx.
197  std::vector<double> dEdx_final;
198  std::vector<double> dEdx_finalErr;
199 
200  int max_hits = -999;
201  int best_plane = -999;
202 
203  bool check = false;
204  for (auto const& dEdx_plane : dEdx_plane_final) {
205 
206  //Redefine the best plane
207  if ((int)(dEdx_plane.second).size() > max_hits) {
208  best_plane = dEdx_plane.first;
209  max_hits = (dEdx_plane.second).size();
210  }
211 
212  if ((dEdx_plane.second).empty()) {
213  dEdx_final.push_back(-999);
214  dEdx_finalErr.push_back(-999);
215  continue;
216  }
217 
218  dEdx_final.push_back(TMath::Median((dEdx_plane.second).size(), &(dEdx_plane.second)[0]));
219  dEdx_finalErr.push_back(-999);
220  check = true;
221  }
222 
223  //Check at least one plane has the information
224  if (!check) return 1;
225 
226  if (fDefineBestPlane) { ShowerEleHolder.SetElement(best_plane, fShowerBestPlaneOutputLabel); }
227 
228  ShowerEleHolder.SetElement(dEdx_final, dEdx_finalErr, fShowerdEdxOutputLabel);
229 
230  return 0;
231  }
std::vector< double > GetLikelihooddEdxVec(double &electronprob, double &photonprob, std::string prior, std::vector< double > &dEdxVec)
void SetElement(T &dataproduct, const std::string &Name, bool checktag=false)
MaybeLogger_< ELseverityLevel::ELsev_error, false > LogError
decltype(auto) constexpr size(T &&obj)
ADL-aware version of std::size.
Definition: StdUtils.h:101
bool CheckElement(const std::string &Name) const
int GetElement(const std::string &Name, T &Element) const
double ShowerRecoTools::ShowerBayesianTrucatingdEdx::CalculatePosterior ( std::string  priorname,
std::vector< double > &  values,
int &  minprob,
float &  mean,
float &  likelihood 
)
private

Definition at line 242 of file ShowerBayesianTrucatingdEdx_tool.cc.

References bin, electronpriorHist, photonpriorHist, value, and xaxis.

Referenced by CalculatePosterior(), ForceSeedToFit(), and GetLikelihooddEdxVec().

247  {
248 
249  //Posterior prob;
250  float posterior = 1;
251  float meanprob = 0;
252  float likelihood_other = 1;
253  likelihood = 1;
254 
255  //Minimum probability temp
256  float minprob_temp = 9999;
257  minprob_iter = 0;
258 
259  TH1F* prior_hist = nullptr;
260  TH1F* other_hist = nullptr;
261 
262  if (priorname == "electron") {
263  prior_hist = electronpriorHist;
264  other_hist = photonpriorHist;
265  }
266  if (priorname == "photon") {
267  prior_hist = photonpriorHist;
268  other_hist = electronpriorHist;
269  }
270 
271  TAxis* xaxis = prior_hist->GetXaxis();
272 
273  //Loop over the hits and calculate the probability
274  for (int i = 0; i < (int)values.size(); ++i) {
275 
276  float value = values[i];
277 
278  Int_t bin = xaxis->FindBin(value);
279 
280  float prob = -9999;
281  float other_prob = -9999;
282 
283  if (bin != xaxis->GetNbins() || bin == 0) {
284  //Calculate the likelihood
285  prob = prior_hist->GetBinContent(bin);
286  other_prob = other_hist->GetBinContent(bin);
287  }
288  else {
289  prob = 0;
290  other_prob = 0;
291  }
292 
293  if (prob < minprob_temp) {
294  minprob_temp = prob;
295  minprob_iter = i;
296  }
297 
298  if (prob == 0 && other_prob == 0) { continue; }
299 
300  //Calculate the posterior the mean probability and liklihood
301  meanprob += prior_hist->GetBinContent(bin);
302  likelihood *= prob;
303  likelihood_other *= other_prob;
304  }
305 
306  posterior = likelihood / (likelihood + likelihood_other);
307 
308  meanprob /= values.size();
309  mean = meanprob;
310  return posterior;
311  }
TGaxis * xaxis
Definition: plot_hist.C:61
float bin[41]
Definition: plottest35.C:14
double value
Definition: spectrum.C:18
double mean(const std::vector< short > &wf, size_t start, size_t nsample)
Definition: UtilFunc.cxx:13
double ShowerRecoTools::ShowerBayesianTrucatingdEdx::CalculatePosterior ( std::string  priorname,
std::vector< double > &  values 
)
private

Definition at line 233 of file ShowerBayesianTrucatingdEdx_tool.cc.

References CalculatePosterior(), and pmtana::mean().

235  {
236  int minprob_iter = -999;
237  float mean = -999;
238  float likelihood = -999;
239  return CalculatePosterior(priorname, values, minprob_iter, mean, likelihood);
240  }
double CalculatePosterior(std::string priorname, std::vector< double > &values, int &minprob, float &mean, float &likelihood)
double mean(const std::vector< short > &wf, size_t start, size_t nsample)
Definition: UtilFunc.cxx:13
bool ShowerRecoTools::ShowerBayesianTrucatingdEdx::CheckPoint ( std::string  priorname,
double &  value 
)
private

Definition at line 313 of file ShowerBayesianTrucatingdEdx_tool.cc.

References bin, electronpriorHist, fProbPointCut, photonpriorHist, and xaxis.

Referenced by isPosteriorProbabilityGood(), and RecurivelyAddHit().

314  {
315 
316  TH1F* prior_hist = nullptr;
317 
318  if (priorname == "electron") { prior_hist = electronpriorHist; }
319  if (priorname == "photon") { prior_hist = photonpriorHist; }
320 
321  TAxis* xaxis = prior_hist->GetXaxis();
322 
323  Int_t bin = xaxis->FindBin(value);
324 
325  float prob = -9999;
326 
327  if (bin != xaxis->GetNbins() + 1 || bin == 0) {
328  //Calculate the likelihood
329  prob = prior_hist->GetBinContent(bin);
330  }
331  else {
332  prob = 0;
333  }
334 
335  //Return the probability of getting that point.
336  return prob > fProbPointCut;
337  }
TGaxis * xaxis
Definition: plot_hist.C:61
float bin[41]
Definition: plottest35.C:14
double value
Definition: spectrum.C:18
void ShowerRecoTools::ShowerBayesianTrucatingdEdx::ForceSeedToFit ( std::vector< double > &  SeedTrack,
std::string &  prior,
float &  mean,
double &  posterior 
)
private

Definition at line 392 of file ShowerBayesianTrucatingdEdx_tool.cc.

References CalculatePosterior(), and fProbSeedCut.

Referenced by GetLikelihooddEdxVec(), and isPosteriorProbabilityGood().

396  {
397 
398  int minprob_iter = 999;
399  float likelihood = -999;
400  float prob = CalculatePosterior(prior, SeedTrack, minprob_iter, mean, likelihood);
401  while ((mean < fProbSeedCut || prob <= 0) && SeedTrack.size() > 1) {
402 
403  //Remove the the worse point.
404  // std::cout << "removing hit with dEdx: " << SeedTrack.at(minprob_iter) << std::endl;
405  SeedTrack.erase(SeedTrack.begin() + minprob_iter);
406  minprob_iter = 999;
407 
408  //Recalculate
409  prob = CalculatePosterior(prior, SeedTrack, minprob_iter, mean, likelihood);
410  }
411  posterior = prob;
412  // std::cout << "seed has been fit with size: " << SeedTrack.size() << std::endl;
413  return;
414  }
double CalculatePosterior(std::string priorname, std::vector< double > &values, int &minprob, float &mean, float &likelihood)
double mean(const std::vector< short > &wf, size_t start, size_t nsample)
Definition: UtilFunc.cxx:13
const shower::LArPandoraShowerAlg& ShowerRecoTools::IShowerTool::GetLArPandoraShowerAlg ( ) const
inlineprotectedinherited

Definition at line 82 of file IShowerTool.h.

Referenced by ShowerRecoTools::ShowerLengthPercentile::CalculateElement(), ShowerRecoTools::ShowerUnidirectiondEdx::CalculateElement(), ShowerRecoTools::Shower3DCylinderTrackHitFinder::CalculateElement(), ShowerRecoTools::ShowerPCAPropergationStartPosition::CalculateElement(), ShowerRecoTools::Shower2DLinearRegressionTrackHitFinder::CalculateElement(), ShowerRecoTools::ShowerPFPVertexStartPosition::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().

83  {
84  return fLArPandoraShowerAlg;
85  };
shower::LArPandoraShowerAlg fLArPandoraShowerAlg
Definition: IShowerTool.h:92
std::vector< double > ShowerRecoTools::ShowerBayesianTrucatingdEdx::GetLikelihooddEdxVec ( double &  electronprob,
double &  photonprob,
std::string  prior,
std::vector< double > &  dEdxVec 
)
private

Definition at line 339 of file ShowerBayesianTrucatingdEdx_tool.cc.

References CalculatePosterior(), ForceSeedToFit(), MakeSeed(), pmtana::mean(), and RecurivelyAddHit().

Referenced by CalculateElement(), and isPosteriorProbabilityGood().

344  {
345 
346  //have a pool
347  std::vector<double> dEdxVec_temp = dEdxVec;
348 
349  //Get The seed track.
350  std::vector<double> SeedTrack = MakeSeed(dEdxVec_temp);
351  // if(SeedTrack.size() < 1){
352  // return SeedTrack;
353  // }
354 
355  //Force the seed the be a good likelihood.
356  float mean = 999;
357  double posterior = 999;
358  ForceSeedToFit(SeedTrack, prior, mean, posterior);
359 
360  //Recursively add dEdx
361  int SkippedHitsNum = 0;
362  RecurivelyAddHit(SeedTrack, dEdxVec_temp, prior, SkippedHitsNum, mean, posterior);
363 
364  //Calculate the likelihood of the vector with the photon and electron priors.
365  electronprob = CalculatePosterior("electron", SeedTrack);
366  photonprob = CalculatePosterior("photon", SeedTrack);
367 
368  return SeedTrack;
369  }
std::vector< double > MakeSeed(std::vector< double > &dEdxVec)
void ForceSeedToFit(std::vector< double > &SeedTrack, std::string &prior, float &mean, double &posterior)
double CalculatePosterior(std::string priorname, std::vector< double > &values, int &minprob, float &mean, float &likelihood)
void RecurivelyAddHit(std::vector< double > &SeedTrack, std::vector< double > &dEdxVec, std::string &prior, int &SkippedHitsNum, float &old_mean, double &old_posteior)
double mean(const std::vector< short > &wf, size_t start, size_t nsample)
Definition: UtilFunc.cxx:13
template<class T >
art::Ptr<T> ShowerRecoTools::IShowerTool::GetProducedElementPtr ( std::string  Name,
reco::shower::ShowerElementHolder ShowerEleHolder,
int  iter = -1 
)
inlineprotectedinherited

Definition at line 102 of file IShowerTool.h.

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

105  {
106 
107  //Check the element has been set
108  bool check_element = ShowerEleHolder.CheckElement(Name);
109  if (!check_element) {
110  throw cet::exception("IShowerTool") << "tried to get a element that does not exist. Failed "
111  "at making the art ptr for Element: "
112  << Name << std::endl;
113  }
114 
115  //Check the unique ptr has been set.
116  bool check_ptr = UniquePtrs->CheckUniqueProduerPtr(Name);
117  if (!check_ptr) {
118  throw cet::exception("IShowerTool")
119  << "tried to get a ptr that does not exist. Failed at making the art ptr for Element"
120  << Name;
121  }
122 
123  //Check if the user has defined an index if not just use the current shower index/
124  int index;
125  if (iter != -1) { index = iter; }
126  else {
127  index = ShowerEleHolder.GetShowerNumber();
128  }
129 
130  //Make the ptr
131  return UniquePtrs->GetArtPtr<T>(Name, index);
132  }
reco::shower::ShowerProducedPtrsHolder * UniquePtrs
Definition: IShowerTool.h:85
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 68 of file IShowerTool.h.

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

Definition at line 137 of file IShowerTool.h.

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

138  {
139 
140  if (collectorPtr == nullptr) {
141  mf::LogWarning("IShowerTool") << "The art::ProducesCollector ptr has not been set";
142  return;
143  }
144 
145  collectorPtr->produces<T>(InstanceName);
146  UniquePtrs->SetShowerUniqueProduerPtr(type<T>(), Name, InstanceName);
147  }
reco::shower::ShowerProducedPtrsHolder * UniquePtrs
Definition: IShowerTool.h:85
art::ProducesCollector * collectorPtr
Definition: IShowerTool.h:97
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="")
bool ShowerRecoTools::ShowerBayesianTrucatingdEdx::isPosteriorProbabilityGood ( double &  prob,
double &  old_posteior 
)
inlineprivate
bool ShowerRecoTools::ShowerBayesianTrucatingdEdx::isProbabilityGood ( float &  old_prob,
float &  new_prob 
)
inlineprivate

Definition at line 44 of file ShowerBayesianTrucatingdEdx_tool.cc.

References fProbSeedCut.

45  {
46  return (old_prob - new_prob) < fProbSeedCut;
47  }
std::vector< double > ShowerRecoTools::ShowerBayesianTrucatingdEdx::MakeSeed ( std::vector< double > &  dEdxVec)
private

Definition at line 371 of file ShowerBayesianTrucatingdEdx_tool.cc.

References fNumSeedHits.

Referenced by GetLikelihooddEdxVec(), and isPosteriorProbabilityGood().

372  {
373 
374  std::vector<double> seed_vector;
375 
376  //Add the first hits to the seed
377  int MaxHit = fNumSeedHits;
378  if (fNumSeedHits > (int)dEdxVec.size()) { MaxHit = (int)dEdxVec.size(); }
379 
380  // if(MaxHit == 0){
381  // mf::LogError("ShowerBayesianTrucatingdEdx") << "Size of the vector is 0 cannot perform the dEdx cutting "<< std::endl;
382  //}
383 
384  for (int hit_iter = 0; hit_iter < MaxHit; ++hit_iter) {
385  seed_vector.push_back(dEdxVec[0]);
386  dEdxVec.erase(dEdxVec.begin());
387  }
388 
389  return seed_vector;
390  }
void ShowerRecoTools::IShowerTool::PrintPtr ( std::string  Name)
inlineprotectedinherited

Definition at line 162 of file IShowerTool.h.

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

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

162 { UniquePtrs->PrintPtr(Name); }
reco::shower::ShowerProducedPtrsHolder * UniquePtrs
Definition: IShowerTool.h:85
void PrintPtr(const std::string &Name) const
void ShowerRecoTools::IShowerTool::PrintPtrs ( )
inlineprotectedinherited
void ShowerRecoTools::ShowerBayesianTrucatingdEdx::RecurivelyAddHit ( std::vector< double > &  SeedTrack,
std::vector< double > &  dEdxVec,
std::string &  prior,
int &  SkippedHitsNum,
float &  old_mean,
double &  old_posteior 
)
private

Definition at line 416 of file ShowerBayesianTrucatingdEdx_tool.cc.

References CheckPoint(), DEFINE_ART_CLASS_TOOL, and fnSkipHits.

Referenced by GetLikelihooddEdxVec(), and isPosteriorProbabilityGood().

422  {
423 
424  //If we have no more hits to add then lets finish.
425  if (dEdxVec.size() < 1) { return; }
426 
427  bool ok = CheckPoint(prior, dEdxVec[0]);
428  // int minprob_iter=999;
429  // float mean = -999;
430  // float likelihood =999;
431  // if(ok){std::cout << "passed first cut" << std::endl;}
432  // else{std::cout << "failed first cut" << std::endl;}
433  // double prob = CalculatePosterior(prior,SeedTrack,minprob_iter,mean,likelihood);
434  // ok *= isProbabilityGood(mean,old_mean);
435  // if(ok){std::cout << "passed second cut" << std::endl;}
436  // else{std::cout << "failed second cut" << std::endl;}
437  // ok *= isPosteriorProbabilityGood(prob,old_posteior);
438  // if(ok){std::cout << "passed this cut" << std::endl;}
439  // else{std::cout << "failed third cut" << std::endl;}
440 
441  //If we failed lets try the next hits
442  if (!ok) {
443  // std::cout << "failed the pass point: " << dEdxVec[0] << " trying another hit" << SkippedHitsNum << std::endl;
444  //if(SeedTrack.size() > 1){SeedTrack.pop_back();}
445  ++SkippedHitsNum;
446  if (SkippedHitsNum > fnSkipHits) { return; }
447  }
448  else {
449  //Add the next point in question.
450  // std::cout << "adding value: " << dEdxVec[0] << std::endl;
451  //Reset the skip number
452  SkippedHitsNum = 0;
453  SeedTrack.push_back(dEdxVec[0]);
454  }
455 
456  //We have analysed this hit now lets remove it.
457  dEdxVec.erase(dEdxVec.begin());
458 
459  RecurivelyAddHit(SeedTrack, dEdxVec, prior, SkippedHitsNum, old_mean, old_posteior);
460 
461  return;
462  }
void RecurivelyAddHit(std::vector< double > &SeedTrack, std::vector< double > &dEdxVec, std::string &prior, int &SkippedHitsNum, float &old_mean, double &old_posteior)
bool CheckPoint(std::string priorname, double &value)
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 46 of file IShowerTool.h.

50  {
51 
52  int calculation_status = CalculateElement(pfparticle, Event, ShowerEleHolder);
53  if (calculation_status != 0) return calculation_status;
54  if (fRunEventDisplay) {
56  pfparticle, Event, ShowerEleHolder, evd_display_name_append);
57  }
58  return calculation_status;
59  }
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:82
void ShowerRecoTools::IShowerTool::SetPtr ( art::ProducesCollector collector)
inlineinherited

Definition at line 65 of file IShowerTool.h.

65 { collectorPtr = collector; }
art::ProducesCollector * collectorPtr
Definition: IShowerTool.h:97

Member Data Documentation

TH1F* ShowerRecoTools::ShowerBayesianTrucatingdEdx::electronpriorHist
private
std::string ShowerRecoTools::ShowerBayesianTrucatingdEdx::fdEdxInputLabel
private

Definition at line 80 of file ShowerBayesianTrucatingdEdx_tool.cc.

Referenced by CalculateElement().

bool ShowerRecoTools::ShowerBayesianTrucatingdEdx::fDefineBestPlane
private

Definition at line 87 of file ShowerBayesianTrucatingdEdx_tool.cc.

Referenced by CalculateElement().

int ShowerRecoTools::ShowerBayesianTrucatingdEdx::fnSkipHits
private

Definition at line 85 of file ShowerBayesianTrucatingdEdx_tool.cc.

Referenced by RecurivelyAddHit().

int ShowerRecoTools::ShowerBayesianTrucatingdEdx::fNumSeedHits
private

Definition at line 81 of file ShowerBayesianTrucatingdEdx_tool.cc.

Referenced by MakeSeed().

float ShowerRecoTools::ShowerBayesianTrucatingdEdx::fPostiorCut
private

Definition at line 84 of file ShowerBayesianTrucatingdEdx_tool.cc.

Referenced by isPosteriorProbabilityGood().

float ShowerRecoTools::ShowerBayesianTrucatingdEdx::fProbPointCut
private

Definition at line 83 of file ShowerBayesianTrucatingdEdx_tool.cc.

Referenced by CheckPoint().

float ShowerRecoTools::ShowerBayesianTrucatingdEdx::fProbSeedCut
private

Definition at line 82 of file ShowerBayesianTrucatingdEdx_tool.cc.

Referenced by ForceSeedToFit(), and isProbabilityGood().

std::string ShowerRecoTools::ShowerBayesianTrucatingdEdx::fShowerBestPlaneOutputLabel
private

Definition at line 88 of file ShowerBayesianTrucatingdEdx_tool.cc.

Referenced by CalculateElement().

std::string ShowerRecoTools::ShowerBayesianTrucatingdEdx::fShowerdEdxOutputLabel
private

Definition at line 86 of file ShowerBayesianTrucatingdEdx_tool.cc.

Referenced by CalculateElement().

int ShowerRecoTools::ShowerBayesianTrucatingdEdx::fVerbose
private

Definition at line 79 of file ShowerBayesianTrucatingdEdx_tool.cc.

Referenced by CalculateElement().

TH1F* ShowerRecoTools::ShowerBayesianTrucatingdEdx::photonpriorHist
private

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