|
DAS
3.0
Das Analysis System
|
Performs a double-sided Crystal-Ball fit of the given response step by step. Three methods are provided to fit the gaussian core and each of the power- law tails.
|
enum | {
N = 0,
MU,
SIGMA,
KL,
NL,
KR,
NR,
NPARS
} |
|
enum | Status { failed = 0b0000,
core = 0b0001,
LHStail = 0b0010,
RHStail = 0b0100
} |
|
|
void | Write (const char *) override |
|
|
const std::unique_ptr< TH1 > & | h |
|
std::uint32_t | status |
|
std::ostream & | cout |
|
double * | p |
|
double * | e |
|
std::unique_ptr< TF1 > | f |
|
std::optional< double > | chi2ndf |
|
std::optional< double > | chi2ndfErr |
|
std::pair< float, float > | interval |
|
| AbstractFit (const unique_ptr< TH1 > &h, ostream &cout, int npars) |
|
virtual | ~AbstractFit () |
|
void | fit (std::pair< float, float >, const char *) |
|
◆ anonymous enum
Enumerator |
---|
N | |
MU | |
SIGMA | |
KL | |
NL | |
KR | |
NR | |
NPARS | |
◆ Status
Enumerator |
---|
failed | |
core | |
LHStail | |
RHStail | |
◆ ResponseFit()
ResponseFit |
( |
const unique_ptr< TH1 > & |
h, |
|
|
ostream & |
cout |
|
) |
| |
|
inline |
Preparing for fit, setting ranges. Assuming response is centered around 1
- Todo:
- tune range?
136 logdd->Write(
"logdd");
138 double mu =
h->GetMean(),
139 sigma =
h->GetStdDev();
141 float rmin = 0.65, rmax = 1.5;
145 static auto LHS = make_unique<TF1>(
"tail",
"[0]*exp( [1]*x)", 0., rmin),
146 RHS = make_unique<TF1>(
"tail",
"[0]*exp(-[1]*x)", rmax, 2.);
147 h->Fit(LHS.get(),
"N0QR");
148 h->Fit(RHS.get(),
"N0QR");
152 p[
N ] = 1.;
e[
N ] = 0.001;
153 p[
MU ] = mu;
e[
MU ] =
h->GetMeanError();
156 p[
NL ] = LHS->GetParameter(1);
e[
NL ] = LHS->GetParError(1);
158 p[
NR ] = RHS->GetParameter(1);
e[
NR ] = RHS->GetParError(1);
162 f->SetParName(
N ,
"N" );
163 f->SetParName(
MU ,
"#mu" );
164 f->SetParName(
SIGMA,
"#sigma");
165 f->SetParName(
KL ,
"k_{L}" );
166 f->SetParName(
NL ,
"N_{L}" );
167 f->SetParName(
KR ,
"k_{R}" );
168 f->SetParName(
NR ,
"N_{R}" );
174 IDSCB->SetParameters(
p);
175 IDSCB->SetLineColor(
f->GetLineColor());
176 IDSCB->SetLineStyle(
f->GetLineStyle());
178 IDSCB->Write(
"DSCB_Integral");
◆ DSCB()
Crystal-Ball fit with tail on the RHS
The fit performance is scanned for all possible RHS boundaries.
245 f->SetParLimits(
N, min(0.9,
p[
N]), max(1.1,
p[
N]));
246 if ((
status & Status::LHStail) == Status::LHStail)
249 f->FixParameter(
KL,
p[
KL]);
250 f->FixParameter(
NL,
p[
NL]);
255 int BinL =
h->FindBin(L);
256 for (
int BinR =
h->FindBin(
interval.second); BinR <= h->GetNbinsX(); ++BinR) {
257 if (
h->GetBinContent(BinR) == 0)
continue;
258 if (BinR - BinL < f->GetNumberFreeParameters())
continue;
259 float R =
h->GetBinLowEdge(BinR+1);
260 if (R <=
p[
MU])
continue;
262 f->SetParLimits(
KR,
p[
MU], R);
263 f->SetParLimits(
NR, 1.001, min(1e3,
p[
NR]*2));
264 fit({L, R}, __func__);
268 status |= Status::RHStail;
◆ gausCore()
Get Gaussian core parameters.
195 f->SetParLimits(
N , 0.9, 1.1);
198 f->FixParameter(
KL,
p[
KL]);
199 f->FixParameter(
NL,
p[
NL]);
200 f->FixParameter(
KR,
p[
KR]);
201 f->FixParameter(
NR,
p[
NR]);
◆ good()
◆ SSCB()
Crystal-Ball fit with tail on the LHS
The fit performance is scanned for all possible LHS boundaries.
216 f->SetParLimits(
N , min(0.9,
p[
N]), max(1.1,
p[
N]));
222 int BinR =
h->FindBin(R);
223 for (
int BinL =
h->FindBin(
interval.first); BinL > 0; --BinL) {
224 if (
h->GetBinContent(BinL) == 0)
continue;
225 if (BinR - BinL < f->GetNumberFreeParameters())
continue;
226 float L =
h->GetBinLowEdge(BinL);
227 if (L >=
p[
MU])
continue;
229 f->SetParLimits(
KL, L,
p[
MU]);
230 f->SetParLimits(
NL, 1.001, min(1e3,
p[
NL]*2));
231 fit({L, R}, __func__);
235 status |= Status::LHStail;
◆ Write()
void Write |
( |
const char * |
name | ) |
|
|
overrideprivatevirtual |
Write best current estimate in current directory.
Four color codes are used to categorize fits on their final state (after all 3 fits are performed):
- Red for a failed fit (all fit stages failed, or fit quality did not pass some criteria, e.g., chi2/ndf)
- Magenta a successful Gaussian core fit (fits at stage 2 and 3 failed)
- Orange a successful SSCB fit (stage 1 fit could either succeed or fail, and stage 3 failed)
- Green a successful DSCB fit (stage 1 and 2 fits could have either failed or succeded)
Reimplemented from AbstractFit.
283 bool goodCore = (
status & Status::core ) == Status::core ;
284 bool goodLHS = (
status & Status::LHStail) == Status::LHStail;
285 bool goodRHS = (
status & Status::RHStail) == Status::RHStail;
286 if (goodLHS && goodRHS)
f->SetLineColor(kGreen+1);
287 else if (goodLHS xor goodRHS)
f->SetLineColor(kOrange+1);
288 else if (goodCore )
f->SetLineColor(kMagenta+1);
289 else f->SetLineColor(kRed+1);
294 dlog->SetParameters(
p);
295 dlog->SetLineColor(
f->GetLineColor());
296 dlog->SetLineStyle(
f->GetLineStyle());
298 static TString dlogName =
"DLog";
299 dlog->Write(dlogName +
name);
The documentation for this struct was generated from the following file:
- /builds/cms-analysis/general/DasAnalysisSystem/Core/Installer/Core/JEC/bin/fitJetResponse.cc
pair< float, float > findDLogExtrema(const unique_ptr< TH1 > &DLog, const double mu, const pair< float, float > Range)
Definition: fitJetResponse.cc:76
name
Definition: DYToLL_M-50_13TeV_pythia8_cff_GEN_SIM_RECOBEFMIX_DIGI_L1_DIGI2RAW_L1Reco_RECO.py:48
Definition: DoubleCrystalBall.h:93
void fit(std::pair< float, float >, const char *)
Definition: fit.h:98
@ failed
Definition: fitJetResponse.cc:119
unique_ptr< TH1 > DerivativeFivePointStencil(const unique_ptr< TH1 > &h, double(*f)(double)=id)
Definition: resolution.h:49
@ MU
Definition: fitJetResponse.cc:113
@ NL
Definition: fitJetResponse.cc:114
void Write(const char *) override
Definition: fitJetResponse.cc:281
virtual void Write(const char *name)
Write the function to the current TDirectory.
Definition: fit.h:65
Definition: DoubleCrystalBall.h:83
@ N
Definition: fitJetResponse.cc:112
std::pair< float, float > interval
best fit range
Definition: fit.h:32
@ core
Definition: fitJetResponse.cc:120
std::ostream & cout
output stream, can be overwritten to reduce I/O
Definition: fit.h:25
@ LHStail
Definition: fitJetResponse.cc:121
@ NR
Definition: fitJetResponse.cc:114
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
@ SIGMA
Definition: fitJetResponse.cc:113
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
Definition: DoubleCrystalBall.h:106
@ KR
Definition: fitJetResponse.cc:114
const std::unique_ptr< TH1 > & h
histogram ready to be fitted
Definition: fit.h:23
@ NPARS
Definition: fitJetResponse.cc:115
@ RHStail
Definition: fitJetResponse.cc:122
@ KL
Definition: fitJetResponse.cc:114
double * p
best parameter estimation
Definition: fit.h:27
double safelog(double x)
Definition: resolution.h:19
std::unique_ptr< TF1 > f
Starting by passing Gaussian range.
Definition: fit.h:30