All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Member Functions | Private Attributes | List of all members
sbn::TrackStoppingChi2Alg Class Reference

#include <TrackStoppingChi2Alg.h>

Public Member Functions

 TrackStoppingChi2Alg (fhicl::ParameterSet const &p)
 
StoppingChi2Fit RunFit (const std::vector< float > &dEdxVec, const std::vector< float > &resRangeVec) const
 
StoppingChi2Fit RunFit (const anab::Calorimetry &calo) const
 
StoppingChi2Fit RunFitForCosmicID (const anab::Calorimetry &calo) const
 

Private Attributes

const float fFitRange
 
const float fMaxdEdx
 
const unsigned int fMinHits
 
sbn::TPCGeoAlg fTpcGeo
 

Detailed Description

Definition at line 22 of file TrackStoppingChi2Alg.h.

Constructor & Destructor Documentation

sbn::TrackStoppingChi2Alg::TrackStoppingChi2Alg ( fhicl::ParameterSet const &  p)

Definition at line 7 of file TrackStoppingChi2Alg.cc.

7  :
8  fFitRange(p.get<float>("FitRange"))
9  , fMaxdEdx(p.get<float>("MaxdEdx"))
10  , fMinHits(p.get<unsigned int>("MinHits"))
11 {
12 }
pdgs p
Definition: selectors.fcl:22

Member Function Documentation

sbn::StoppingChi2Fit sbn::TrackStoppingChi2Alg::RunFit ( const std::vector< float > &  dEdxVec,
const std::vector< float > &  resRangeVec 
) const

Definition at line 14 of file TrackStoppingChi2Alg.cc.

15 {
16  if (dEdxVec.size() != resRangeVec.size())
17  throw cet::exception("TrackStoppingChi2Alg") << "dEdx and Res Range do not have same length: " << dEdxVec.size() << " and " << resRangeVec.size() << std::endl;
18 
19  if (dEdxVec.size() < fMinHits)
20  return StoppingChi2Fit();
21 
22  const auto graph(std::make_unique<TGraph>(dEdxVec.size(), &resRangeVec[0], &dEdxVec[0]));
23 
24  // Try and fit a flat polynomial
25  graph->Fit("pol0", "Q");
26  const TF1* polFit = graph->GetFunction("pol0");
27  const float pol0Chi2(polFit ? polFit->GetChisquare() : -5.f);
28  const float pol0Fit(polFit ? polFit->GetParameter(0) : -5.f);
29 
30  // Try to fit an exponential
31  graph->Fit("expo", "Q");
32  const TF1* expFit = graph->GetFunction("expo");
33  const float expChi2(expFit ? expFit->GetChisquare() : -5.f);
34 
35  return StoppingChi2Fit(pol0Chi2, expChi2, pol0Fit);
36 }
sbn::StoppingChi2Fit sbn::TrackStoppingChi2Alg::RunFit ( const anab::Calorimetry calo) const

Definition at line 38 of file TrackStoppingChi2Alg.cc.

39 {
40 
41  std::vector<float> dEdxVec, resRangeVec;
42  // Fill the dEdx vs res range vectors, ignoring the first/last points
43  for (size_t i = 1; i < calo.dEdx().size() - 1; i++) {
44  const float thisdEdx(calo.dEdx()[i]);
45  const float thisResRange(calo.ResidualRange()[i]);
46  if (thisResRange > fFitRange || thisdEdx > fMaxdEdx)
47  continue;
48 
49  dEdxVec.push_back(thisdEdx);
50  resRangeVec.push_back(thisResRange);
51  }
52 
53  return this->RunFit(dEdxVec, resRangeVec);
54 }
const std::vector< float > & ResidualRange() const
Definition: Calorimetry.h:103
const std::vector< float > & dEdx() const
Definition: Calorimetry.h:101
StoppingChi2Fit RunFit(const std::vector< float > &dEdxVec, const std::vector< float > &resRangeVec) const
sbn::StoppingChi2Fit sbn::TrackStoppingChi2Alg::RunFitForCosmicID ( const anab::Calorimetry calo) const

Definition at line 56 of file TrackStoppingChi2Alg.cc.

57 {
58  if(calo.XYZ().size() == 0)
59  return StoppingChi2Fit();
60 
61  geo::Point_t start(calo.XYZ().front());
62  geo::Point_t end(calo.XYZ().back());
63 
64  std::vector<float> dEdxVec, resRangeVec;
65  // Fill the dEdx vs res range vectors, ignoring the first/last points
66  for (size_t i = 1; i < calo.dEdx().size() - 1; i++) {
67  const float thisdEdx(calo.dEdx()[i]);
68  const float thisResRange(calo.ResidualRange()[i]);
69  if (thisResRange > fFitRange || thisdEdx > fMaxdEdx)
70  continue;
71 
72  dEdxVec.push_back(thisdEdx);
73  resRangeVec.push_back(thisResRange);
74  }
75 
77  {
78  std::reverse(dEdxVec.begin(), dEdxVec.end());
79  std::reverse(resRangeVec.begin(), resRangeVec.end());
80  }
81 
82  return this->RunFit(dEdxVec, resRangeVec);
83 }
const std::vector< Point_t > & XYZ() const
Definition: Calorimetry.h:114
const std::vector< float > & ResidualRange() const
Definition: Calorimetry.h:103
double MinDistToWall(geo::Point_t point) const
auto end(FixedBins< T, C > const &) noexcept
Definition: FixedBins.h:585
const std::vector< float > & dEdx() const
Definition: Calorimetry.h:101
StoppingChi2Fit RunFit(const std::vector< float > &dEdxVec, const std::vector< float > &resRangeVec) const
ROOT::Math::PositionVector3D< ROOT::Math::Cartesian3D< double >, ROOT::Math::GlobalCoordinateSystemTag > Point_t
Type for representation of position in physical 3D space.
Definition: geo_vectors.h:184

Member Data Documentation

const float sbn::TrackStoppingChi2Alg::fFitRange
private

Definition at line 38 of file TrackStoppingChi2Alg.h.

const float sbn::TrackStoppingChi2Alg::fMaxdEdx
private

Definition at line 38 of file TrackStoppingChi2Alg.h.

const unsigned int sbn::TrackStoppingChi2Alg::fMinHits
private

Definition at line 39 of file TrackStoppingChi2Alg.h.

sbn::TPCGeoAlg sbn::TrackStoppingChi2Alg::fTpcGeo
private

Definition at line 41 of file TrackStoppingChi2Alg.h.


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