DAS  3.0
Das Analysis System
ResolutionFit

Description

Performs a fit of the resolution with the NSC function, including ad-hoc modification $d$ for possibly non-linearities in the jet resolution:

\[ \frac{\sigma}{p_\mathrm{T}} = \sqrt{ \frac{N^2}{p_\mathrm{T}^2} + \frac{S^2}{p_\mathrm{T}^d} + C^2 } \]

where N stands for noise, S for stochastic, and C for constant.

+ Inheritance diagram for ResolutionFit:
+ Collaboration diagram for ResolutionFit:

Public Types

enum  {
  N = 0, S, C, d,
  NPARS
}
 
enum  Status { failed = 0b0000, base = 0b0001, modified = 0b0010 }
 

Public Member Functions

 ResolutionFit (const unique_ptr< TH1 > &h, ostream &cout)
 
void NSC ()
 
void NSCd ()
 
 ~ResolutionFit ()
 
- Public Member Functions inherited from AbstractFit
virtual bool good () const
 

Private Member Functions

void Write (const char *) override
 

Additional Inherited Members

- Public Attributes inherited from AbstractFit
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
 
- Protected Member Functions inherited from AbstractFit
 AbstractFit (const unique_ptr< TH1 > &h, ostream &cout, int npars)
 
virtual ~AbstractFit ()
 
void fit (std::pair< float, float >, const char *)
 

Member Enumeration Documentation

◆ anonymous enum

anonymous enum
Enumerator
NPARS 
49  {
50  N = 0,
51  S,
52  C,
53  d,
54  NPARS
55  };

◆ Status

enum Status
Enumerator
failed 
base 
modified 
57  {
58  failed = 0b0000,
59  base = 0b0001,
60  modified = 0b0010,
61  };

Constructor & Destructor Documentation

◆ ResolutionFit()

ResolutionFit ( const unique_ptr< TH1 > &  h,
ostream &  cout 
)
inline

Preparing for fit, setting ranges.

Todo:
take average of last three points?
65  :
67  {
68  interval.first = 32;
69  for (int N = h->GetNbinsX()+1; h->GetBinContent(N) == 0 && N > 0; --N)
70  interval.second = h->GetBinLowEdge(N-3);
71 
72  f = make_unique<TF1>("f", ::mNSC, interval.first, interval.second, NPARS);
73  p[N] = 2.; e[N] = 1;
74  p[S] = 1.; e[S] = 0.5;
75  p[C] = 0.05; e[C] = 0.03;
76  p[d] = 1; e[d] = 0.1;
77  f->SetParameters(p);
78  f->SetParErrors (e);
79 
80  f->SetParName(N, "N");
81  f->SetParName(S, "S");
82  f->SetParName(C, "C");
83  f->SetParName(d, "d");
84 
85  f->SetNpx(2000); // Increase points used to draw TF1 object when saving
86  }

◆ ~ResolutionFit()

~ResolutionFit ( )
inline
92  {
93  for (int i = 0; i < NPARS; ++i)
94  if (!isfinite(p[i]))
95  BOOST_THROW_EXCEPTION( runtime_error(Form("Fit parameter %d is not finite", i)) );
96  }

Member Function Documentation

◆ NSC()

void NSC ( )
103 {
104  f->SetParLimits(N, 0, 10);
105  f->SetParLimits(S, 0, 3);
106  f->SetParLimits(C, 0, 0.1);
107  f->FixParameter(d, 1);
108 
109  fit(interval, __func__);
110 
111  if (!chi2ndf) return;
112  status |= Status::base;
113  Write(__func__);
114 }

◆ NSCd()

void NSCd ( )
117 {
118  f->SetParLimits(N, -10, 10);
119  f->SetParLimits(S, p[S]/2, p[S]*2);
120  f->SetParLimits(C, p[C]/2, p[C]*2);
121  f->SetParLimits(d, 0.5, 1.5);
122 
123  auto lastChi2ndf = chi2ndf;
124  float L = interval.first;
125  const int N = h->GetNbinsX();
126  for (int im = h->FindBin(L); im > 0; --im) {
127  if (h->GetBinContent(im) == 0) continue;
128  L = h->GetBinLowEdge(im);
129  float R = interval.second;
130  for (int iM = h->FindBin(R); iM <= N; ++iM) {
131  if (h->GetBinContent(iM) == 0) continue;
132  R = h->GetBinLowEdge(iM+1);
133  fit({L,R}, __func__);
134  }
135  }
136 
137  if (!chi2ndf || *chi2ndf >= *lastChi2ndf) return;
138  status |= Status::modified;
139  Write(__func__);
140 }

◆ Write()

void Write ( const char *  name)
overrideprivatevirtual

Write best current estimate in current directory.

Three color codes are used to categorize fits on their final state (after all 3 fits are performed):

  • Red for a failed fit
  • Orange a successful NSC fit
  • Green a successful modified NSC fit

Reimplemented from AbstractFit.

151 {
152  bool goodNSC = (status & Status::base) == Status::base;
153  bool goodNSCd = (status & Status::modified) == Status::modified;
154  if (goodNSCd) f->SetLineColor(kGreen+1);
155  else if (goodNSC ) f->SetLineColor(kOrange+1);
156  else f->SetLineColor(kRed+1);
157 
159 }

The documentation for this struct was generated from the following file:
DYToLL_M-50_13TeV_pythia8_cff_GEN_SIM_RECOBEFMIX_DIGI_L1_DIGI2RAW_L1Reco_RECO.name
name
Definition: DYToLL_M-50_13TeV_pythia8_cff_GEN_SIM_RECOBEFMIX_DIGI_L1_DIGI2RAW_L1Reco_RECO.py:48
DAS::JetEnergy::ResolutionFit::S
@ S
Definition: fitJetResolution.cc:51
DAS::JetEnergy::AbstractFit::fit
void fit(std::pair< float, float >, const char *)
Definition: fit.h:98
DAS::JetEnergy::ResolutionFit::C
@ C
Definition: fitJetResolution.cc:52
DAS::JetEnergy::ResolutionFit::base
@ base
Definition: fitJetResolution.cc:59
DAS::JetEnergy::ResolutionFit::Write
void Write(const char *) override
Definition: fitJetResolution.cc:150
DAS::JetEnergy::ResolutionFit::modified
@ modified
Definition: fitJetResolution.cc:60
DAS::JetEnergy::AbstractFit::Write
virtual void Write(const char *name)
Write the function to the current TDirectory.
Definition: fit.h:65
DAS::JetEnergy::ResolutionFit::NPARS
@ NPARS
Definition: fitJetResolution.cc:54
DAS::JetEnergy::AbstractFit::interval
std::pair< float, float > interval
best fit range
Definition: fit.h:32
mNSC
double mNSC(double *x, double *p)
Definition: resolution.h:105
DAS::JetEnergy::AbstractFit::cout
std::ostream & cout
output stream, can be overwritten to reduce I/O
Definition: fit.h:25
DAS::JetEnergy::ResolutionFit::N
@ N
Definition: fitJetResolution.cc:50
DAS::JetEnergy::AbstractFit::chi2ndf
std::optional< double > chi2ndf
Definition: fit.h:31
DAS::JetEnergy::AbstractFit::e
double * e
uncertainties on best parameter estimates
Definition: fit.h:28
DAS::JetEnergy::AbstractFit::AbstractFit
AbstractFit(const unique_ptr< TH1 > &h, ostream &cout, int npars)
Definition: fit.h:38
DAS::JetEnergy::AbstractFit::status
std::uint32_t status
a bit-field to be used in daughter classes
Definition: fit.h:24
DAS::JetEnergy::AbstractFit::h
const std::unique_ptr< TH1 > & h
histogram ready to be fitted
Definition: fit.h:23
DAS::JetEnergy::ResolutionFit::failed
@ failed
Definition: fitJetResolution.cc:58
DAS::JetEnergy::AbstractFit::p
double * p
best parameter estimation
Definition: fit.h:27
DAS::JetEnergy::AbstractFit::f
std::unique_ptr< TF1 > f
Starting by passing Gaussian range.
Definition: fit.h:30
DAS::JetEnergy::ResolutionFit::d
@ d
Definition: fitJetResolution.cc:53