8 fFitRange(p.
get<float>(
"FitRange"))
9 , fMaxdEdx(p.
get<float>(
"MaxdEdx"))
10 , fMinHits(p.
get<unsigned int>(
"MinHits"))
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;
19 if (dEdxVec.size() < fMinHits)
22 const auto graph(std::make_unique<TGraph>(dEdxVec.size(), &resRangeVec[0], &dEdxVec[0]));
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);
31 graph->Fit(
"expo",
"Q");
32 const TF1* expFit = graph->GetFunction(
"expo");
33 const float expChi2(expFit ? expFit->GetChisquare() : -5.f);
41 std::vector<float> dEdxVec, resRangeVec;
43 for (
size_t i = 1; i < calo.
dEdx().size() - 1; i++) {
44 const float thisdEdx(calo.
dEdx()[i]);
46 if (thisResRange > fFitRange || thisdEdx > fMaxdEdx)
49 dEdxVec.push_back(thisdEdx);
50 resRangeVec.push_back(thisResRange);
53 return this->RunFit(dEdxVec, resRangeVec);
58 if(calo.
XYZ().size() == 0)
64 std::vector<float> dEdxVec, resRangeVec;
66 for (
size_t i = 1; i < calo.
dEdx().size() - 1; i++) {
67 const float thisdEdx(calo.
dEdx()[i]);
69 if (thisResRange > fFitRange || thisdEdx > fMaxdEdx)
72 dEdxVec.push_back(thisdEdx);
73 resRangeVec.push_back(thisResRange);
76 if(fTpcGeo.MinDistToWall(start) > fTpcGeo.MinDistToWall(
end))
78 std::reverse(dEdxVec.begin(), dEdxVec.end());
79 std::reverse(resRangeVec.begin(), resRangeVec.end());
82 return this->RunFit(dEdxVec, resRangeVec);
const std::vector< Point_t > & XYZ() const
const std::vector< float > & ResidualRange() const
process_name can override from command line with o or output calo
auto end(FixedBins< T, C > const &) noexcept
TrackStoppingChi2Alg(fhicl::ParameterSet const &p)
const std::vector< float > & dEdx() const
StoppingChi2Fit RunFitForCosmicID(const anab::Calorimetry &calo) const
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.