Public Member Functions | Protected Attributes | List of all members
fnex::FitEval_ChiSq Class Referenceabstract

#include "/cvmfs/nova-development.opensciencegrid.org/novasoft/releases/N20-11-28/FNEX/custom/FitEval_ChiSq.h"

Inheritance diagram for fnex::FitEval_ChiSq:
fnex::FitEvaluation

Public Member Functions

 FitEval_ChiSq (fhicl::ParameterSet const &pset)
 
 ~FitEval_ChiSq ()
 
void Reconfigure (fhicl::ParameterSet const &pset)
 
double FitValue (const TH1D &hData, const TH1D &hMC, std::vector< double > const &pDataVals=std::vector< double >(0), std::vector< double > const &pDataWeights=std::vector< double >(0))
 
int NDOF (const TH1D &hData, const TH1D &hMC, std::vector< double > const &pDataVals=std::vector< double >(0), std::vector< double > const &pDataWeights=std::vector< double >(0))
 
virtual double FitValue (TH1D const &hData, TH1D const &hMC, std::vector< double > const &pDataVals=std::vector< double >(0), std::vector< double > const &pDataWeights=std::vector< double >(0))=0
 
virtual int NDOF (TH1D const &hData, TH1D const &hMC, std::vector< double > const &pDataVals=std::vector< double >(0), std::vector< double > const &pDataWeights=std::vector< double >(0))=0
 
bool IsConfigured ()
 
void SetRange (double pRangeMin, double pRangeMax)
 
void SetRangeMin (double p)
 
void SetRangeMax (double p)
 
double GetRangeMin ()
 
double GetRangeMax ()
 
void EnforceSanity ()
 

Protected Attributes

bool fIsConfigured
 
double fRangeMin
 
double fRangeMax
 

Detailed Description

Definition at line 11 of file FitEval_ChiSq.h.

Constructor & Destructor Documentation

fnex::FitEval_ChiSq::FitEval_ChiSq ( fhicl::ParameterSet const &  pset)
explicit

Definition at line 6 of file FitEval_ChiSq.cxx.

References Reconfigure().

7  : FitEvaluation(pset)
8  {
9  this->Reconfigure(pset);
10  }
FitEvaluation(fhicl::ParameterSet const &pset)
void Reconfigure(fhicl::ParameterSet const &pset)
fnex::FitEval_ChiSq::~FitEval_ChiSq ( )
inline

Definition at line 17 of file FitEval_ChiSq.h.

References FitValue(), NDOF(), and Reconfigure().

17 {};

Member Function Documentation

void fnex::FitEvaluation::EnforceSanity ( )
inherited
virtual double fnex::FitEvaluation::FitValue ( TH1D const &  hData,
TH1D const &  hMC,
std::vector< double > const &  pDataVals = std::vector< double >(0),
std::vector< double > const &  pDataWeights = std::vector< double >(0) 
)
pure virtualinherited
double fnex::FitEval_ChiSq::FitValue ( const TH1D &  hData,
const TH1D &  hMC,
std::vector< double > const &  pDataVals = std::vector<double>(0),
std::vector< double > const &  pDataWeights = std::vector<double>(0) 
)

Definition at line 21 of file FitEval_ChiSq.cxx.

References fnex::FitEvaluation::fRangeMax, fnex::FitEvaluation::fRangeMin, make_syst_table_plots::ibin, and test_ParserArtEvents::log.

Referenced by ~FitEval_ChiSq().

24  {
25 
26  // Sanity checks
27  if(hData.GetNbinsX() < 1)
28  throw cet::exception("FitEval_ChiSqr")
29  << "hData must have > 0 bins!";
30  if(hData.GetNbinsX() != hMC.GetNbinsX())
31  throw cet::exception("FitEval_ChiSqr")
32  << "hData and hMC must have same number of bins! Data: "
33  << hData.GetNbinsX()
34  << " MC: "
35  << hMC.GetNbinsX();
36 
37  // Get min/max bins based on fit range
38  unsigned int binMin = hData.GetXaxis()->FindBin(fRangeMin);
39  unsigned int binMax = hData.GetXaxis()->FindBin(fRangeMax)-1;
40 
41  // Find chisq
42  double chisq = 0.0;
43  double bin_data = 0.;
44  double bin_mc = 0.;
45  for(unsigned int ibin = binMin; ibin <= binMax; ++ibin){
46  bin_data = hData.GetBinContent(ibin);
47  bin_mc = hMC.GetBinContent(ibin);
48  if(bin_mc <= 0) continue;
49  if(bin_data <= 0) {
50  chisq += 2. * bin_mc;
51  continue;
52  }
53  chisq += 2. * (bin_mc - bin_data + bin_data * (std::log(bin_data) - std::log(bin_mc) ) );
54  }
55 
56  // Return chisq
57  return chisq;
58 
59  }
::xsd::cxx::tree::exception< char > exception
Definition: Database.h:225
double fnex::FitEvaluation::GetRangeMax ( )
inlineinherited

Definition at line 41 of file FitEvaluation.h.

References fnex::FitEvaluation::EnforceSanity(), and fnex::FitEvaluation::fRangeMax.

41 { return fRangeMax; }
double fnex::FitEvaluation::GetRangeMin ( )
inlineinherited

Definition at line 40 of file FitEvaluation.h.

References fnex::FitEvaluation::fRangeMin.

40 { return fRangeMin; }
bool fnex::FitEvaluation::IsConfigured ( )
inherited

Definition at line 12 of file FitEvaluation.cxx.

References fnex::FitEvaluation::fIsConfigured.

Referenced by fnex::FitEvaluation::~FitEvaluation().

12  {
13  return fIsConfigured;
14  }
int fnex::FitEval_ChiSq::NDOF ( const TH1D &  hData,
const TH1D &  hMC,
std::vector< double > const &  pDataVals = std::vector<double>(0),
std::vector< double > const &  pDataWeights = std::vector<double>(0) 
)

Definition at line 62 of file FitEval_ChiSq.cxx.

References fnex::FitEvaluation::fRangeMax, fnex::FitEvaluation::fRangeMin, and make_syst_table_plots::ibin.

Referenced by ~FitEval_ChiSq().

65  {
66 
67  // Sanity checks
68  if(hData.GetNbinsX() < 1)
69  throw cet::exception("FitEval_ChiSqr")
70  << "hData must have > 0 bins!";
71  if(hData.GetNbinsX() != hMC.GetNbinsX())
72  throw cet::exception("FitEval_ChiSqr")
73  << "hData and hMC must have same number of bins! Data: "
74  << hData.GetNbinsX()
75  << " MC: "
76  << hMC.GetNbinsX();
77 
78  // Get min/max bins based on fit range
79  unsigned int binMin = hData.GetXaxis()->FindBin(fRangeMin);
80  unsigned int binMax = hData.GetXaxis()->FindBin(fRangeMax)-1;
81 
82  // Find chisq
83  int ndof = 0;
84  double bin_mc = 0;
85  for(unsigned int ibin = binMin; ibin <= binMax; ++ibin){
86  bin_mc = hMC.GetBinContent(ibin);
87  if(bin_mc <= 0) continue;
88  ++ndof;
89  }
90 
91  // Return chisq
92  return ndof;
93 
94  }
::xsd::cxx::tree::exception< char > exception
Definition: Database.h:225
virtual int fnex::FitEvaluation::NDOF ( TH1D const &  hData,
TH1D const &  hMC,
std::vector< double > const &  pDataVals = std::vector< double >(0),
std::vector< double > const &  pDataWeights = std::vector< double >(0) 
)
pure virtualinherited
void fnex::FitEval_ChiSq::Reconfigure ( fhicl::ParameterSet const &  pset)
virtual

Implements fnex::FitEvaluation.

Definition at line 13 of file FitEval_ChiSq.cxx.

References fnex::FitEvaluation::fIsConfigured.

Referenced by FitEval_ChiSq(), and ~FitEval_ChiSq().

13  {
14  fIsConfigured = true;
15  return;
16  }
void fnex::FitEvaluation::SetRange ( double  pRangeMin,
double  pRangeMax 
)
inherited

Definition at line 16 of file FitEvaluation.cxx.

References fnex::FitEvaluation::EnforceSanity(), fnex::FitEvaluation::fRangeMax, and fnex::FitEvaluation::fRangeMin.

Referenced by fnex::FitEvaluation::~FitEvaluation().

16  {
17  fRangeMin = pRangeMin;
18  fRangeMax = pRangeMax;
19  this->EnforceSanity();
20  }
void fnex::FitEvaluation::SetRangeMax ( double  p)
inherited

Definition at line 27 of file FitEvaluation.cxx.

References fnex::FitEvaluation::EnforceSanity(), and fnex::FitEvaluation::fRangeMax.

Referenced by fnex::FitEvaluation::~FitEvaluation().

27  {
28  fRangeMax = p;
29  this->EnforceSanity();
30  }
const char * p
Definition: xmltok.h:285
void fnex::FitEvaluation::SetRangeMin ( double  p)
inherited

Definition at line 22 of file FitEvaluation.cxx.

References fnex::FitEvaluation::EnforceSanity(), and fnex::FitEvaluation::fRangeMin.

Referenced by fnex::FitEvaluation::~FitEvaluation().

22  {
23  fRangeMin = p;
24  this->EnforceSanity();
25  }
const char * p
Definition: xmltok.h:285

Member Data Documentation

bool fnex::FitEvaluation::fIsConfigured
protectedinherited
double fnex::FitEvaluation::fRangeMax
protectedinherited
double fnex::FitEvaluation::fRangeMin
protectedinherited

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