DAS  3.0
Das Analysis System
ModifiedGaussianCore.cc File Reference
#include <cstdlib>
#include "Core/JEC/interface/resolution.h"
#include <TROOT.h>
#include <TCanvas.h>
#include <TLine.h>
#include <TLegend.h>
#include <TF1.h>
+ Include dependency graph for ModifiedGaussianCore.cc:

Functions

double difference (double *x, double *p)
 
int main (int argc, char *argv[])
 

Function Documentation

◆ difference()

double difference ( double *  x,
double *  p 
)
11 {
12  double N = p[0], mu = p[1], sigma = p[2];
13  double gauss = N*exp(-0.5*pow((*x-mu)/sigma,2));
14  return ModifiedGaussianCore(x, p) - gauss;
15 }

◆ main()

int main ( int  argc,
char *  argv[] 
)
18 {
19  gROOT->SetBatch();
20  auto c = new TCanvas("ModifiedGaussianCore", "ModifiedGaussianCore", 600, 800);
21 
22  double x1 = -0.8,
23  x2 = 0.8,
24  y1 = 1e-6,
25  y2 = 1;
26  c->DrawFrame(x1, y1, x2, y2, ";#Delta;");
27  c->SetTicks(1,1);
28  c->SetLogy();
29 
30  double N = 0.1,
31  mu = 0.01,
32  sigma = 0.13,
33  B = -10,
34  C = 10;
35 
36  TF1 * f = new TF1("ModifiedGaussianCore", ModifiedGaussianCore, x1, x2, 5);
37  double p[] = { N, mu, sigma, B, C };
38  f->SetParameters(p);
39  f->Draw("same");
40 
41  TF1 * g = new TF1("gaus", "gaus(0)", x1, x2);
42  g->SetParameters(p);
43  g->SetLineColor(kBlue);
44  g->SetLineStyle(2);
45  g->SetLineWidth(1);
46  g->Draw("same");
47 
48  TF1 * h = new TF1("diff", difference, x1, x2, 5);
49  h->SetParameters(p);
50  h->SetLineColor(kGreen+2);
51  h->SetLineWidth(1);
52  h->Draw("same");
53 
54  TLegend * legend = new TLegend(0.6, 0.7, 0.89, 0.85);
55  legend->SetBorderSize(0);
56  legend->AddEntry(f, "global function", "l");
57  legend->AddEntry(g, "Gaussian core", "l");
58  legend->AddEntry(h, "difference", "l");
59 
60  auto line = [&](Style_t s, double x, TString title = "") {
61  TLine * line = new TLine;
62  line->SetLineStyle(s);
63  line->DrawLine(x, y1, x, f->Eval(x));
64  if (title != "") legend->AddEntry(line, title, "l");
65  };
66  line(1, mu, Form("mean (#mu = %.2f)", mu));
67  line(2, mu+sigma, Form("mean #pm width (#sigma = %.2f)", sigma));
68  line(2, mu-sigma);
69 
70  legend->Draw();
71  c->RedrawAxis();
72  c->Print("ModifiedGaussianCore.pdf");
73 
74  return EXIT_SUCCESS;
75 }
Ntupliser_cfg.p
p
Definition: Ntupliser_cfg.py:362
Ntupliser_cfg.f
f
Definition: Ntupliser_cfg.py:256
B
< SOURCE_DIR >< SOURCE_SUBDIR > B
Definition: Core-cfgcmd.txt:1
difference
double difference(double *x, double *p)
Definition: ModifiedGaussianCore.cc:10
ModifiedGaussianCore
double ModifiedGaussianCore(double *x, double *p)
Advanced function to fit resolution including non-Gaussian deviations and pile-up jets.
Definition: resolution.h:201