|
DAS
3.0
Das Analysis System
|
Go to the documentation of this file.
10 #include <TFitResult.h>
23 const std::unique_ptr<TH1>&
h;
30 std::unique_ptr<TF1>
f;
40 p(new double[npars]),
e(new double[npars])
45 for (
int i = 0; i <
f->GetNpar(); ++i) {
46 if (isfinite(
p[i]))
continue;
47 const char * what = Form(
"Fit parameter %d is not finite", i);
48 BOOST_THROW_EXCEPTION( std::runtime_error(what) );
61 void fit (std::pair<float,float>,
const char *);
70 f->SetLineStyle(kDashed);
86 s << fixed << setprecision(3);
87 for (
int i = 0; i < fit.
f->GetNpar(); ++i) {
89 fit.
f->GetParLimits(i, m, M);
91 s << setw(10) << fit.
f->GetParameter(i);
107 for (
int i = 0; i <
f->GetNpar(); ++i) {
109 f->GetParLimits(i,m,M);
110 if (
p[i] >= m &&
p[i] <= M)
continue;
119 TFitResultPtr result =
h->Fit(
f.get(),
"QS0NRE");
129 double currentChi2ndf =
f->GetChisquare()/
f->GetNDF();
131 bool success = result >= 0 && result % 10 == 0 && currentChi2ndf < 10000;
140 bool improvement = !
chi2ndf || abs(currentChi2ndf-1) <= abs(*
chi2ndf-1);
142 cout <<
h->GetTitle() <<
" with " <<
bold << fitName <<
normal <<
" in ["
143 << fixed << setprecision(2) <<
range.first <<
"," <<
range.second <<
"]: " << defaultfloat
145 << fixed << setprecision(3) << setw(15) << currentChi2ndf << defaultfloat
146 <<
"\t(status = " << (int) result <<
")" <<
def << endl;
149 if (!success || !improvement)
return;
155 for (
int i = 0; i <
f->GetNpar(); ++i) {
156 p[i] =
f->GetParameter(i);
157 e[i] =
f->GetParError (i);
name
Definition: DYToLL_M-50_13TeV_pythia8_cff_GEN_SIM_RECOBEFMIX_DIGI_L1_DIGI2RAW_L1Reco_RECO.py:48
cerr
Definition: Ntupliser_cfg.py:93
void fit(std::pair< float, float >, const char *)
Definition: fit.h:98
static const char * def
Definition: Step.h:36
virtual ~AbstractFit()
Definition: fit.h:43
virtual void Write(const char *name)
Write the function to the current TDirectory.
Definition: fit.h:65
static const char * red
Definition: Step.h:34
std::ostream & operator<<(std::ostream &s, const DAS::JetEnergy::AbstractFit &fit)
Definition: fit.h:83
static const char * orange
Definition: colours.h:6
std::pair< float, float > interval
best fit range
Definition: fit.h:32
std::ostream & cout
output stream, can be overwritten to reduce I/O
Definition: fit.h:25
static const char * normal
Definition: colours.h:8
static const char * green
Definition: Step.h:33
std::optional< double > chi2ndfErr
best chi2/ndf
Definition: fit.h:31
virtual bool good() const
Definition: fit.h:34
std::optional< double > chi2ndf
Definition: fit.h:31
double * e
uncertainties on best parameter estimates
Definition: fit.h:28
AbstractFit(const unique_ptr< TH1 > &h, ostream &cout, int npars)
Definition: fit.h:38
std::uint32_t status
a bit-field to be used in daughter classes
Definition: fit.h:24
const std::unique_ptr< TH1 > & h
histogram ready to be fitted
Definition: fit.h:23
range
Definition: metPhiCorrectionExample.py:100
Definition: applyJERsmearing.cc:41
double * p
best parameter estimation
Definition: fit.h:27
std::unique_ptr< TF1 > f
Starting by passing Gaussian range.
Definition: fit.h:30
static const char * bold
Definition: Step.h:35