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

Functions

int main (int argc, char *argv[])
 

Function Documentation

◆ main()

int main ( int  argc,
char *  argv[] 
)
12 {
13  gROOT->SetBatch();
14  auto c = new TCanvas("DoubleCrystalBall", "DoubleCrystalBall", 600, 800);
15 
16  double x1 = -0.8,
17  x2 = 0.8,
18  y1 = 1e-6,
19  y2 = 100;
20  c->DrawFrame(x1, y1, x2, y2, ";#Delta;");
21  c->SetTicks(1,1);
22  c->SetLogy();
23 
24  double N = 1,
25  mu = 0.,
26  sigma = 0.1,
27  kL = -0.05,
28  nL = 100,
29  kR = 0.3,
30  nR = 3;
31 
32  double p[] = { N, mu, sigma, kL, nL, kR, nR };
33 
34  TF1 * f = new TF1("DoubleCrystalBall", DAS::DoubleCrystalBall::Distribution(), x1, x2, 7);
35  f->SetParameters(p);
36  f->Draw("same");
37  cout << "Integral of CB = " << f->Integral(x1, x2) << endl;
38 
39  TF1 * g = new TF1("gaus", "gaus(0)", x1, x2);
40  double q[] = {N/(sigma*sqrt(2*M_PI)), mu, sigma};
41  g->SetParameters(q);
42  g->SetLineColor(kBlue);
43  g->SetLineStyle(2);
44  g->SetLineWidth(1);
45  g->Draw("same");
46  cout << "Integral of Gaussian = " << g->Integral(x1, x2) << endl;
47 
48  TLegend * legend = new TLegend(0.6, 0.7, 0.89, 0.85);
49  legend->SetBorderSize(0);
50  legend->AddEntry(f, "Double Crystal-Ball", "l");
51  legend->AddEntry(g, "Gaussian with same core parameters", "l");
52 
53  auto line = [&](TF1 * f, Style_t s, double x, TString title = "") {
54  TLine * line = new TLine;
55  line->SetLineStyle(s);
56  line->DrawLine(x, y1, x, f->Eval(x));
57  if (title != "") legend->AddEntry(line, title, "l");
58  };
59  line(f, 1, mu, Form("mean (#mu = %.2f)", mu));
60  line(f, 2, mu+sigma, Form("mean #pm width (#sigma = %.2f)", sigma));
61  line(f, 2, mu-sigma);
62  line(f, 3, kL, Form("k_{L} = %.2f, n_{L} = %.0f", kL, nL));
63  line(f, 3, kR, Form("k_{R} = %.2f, n_{R} = %.0f", kR, nR));
64 
65  legend->Draw();
66  c->RedrawAxis();
67  c->Print("DoubleCrystalBall.pdf(");
68 
70 
71  auto c2 = new TCanvas("IntDoubleCrystalBall", "IntDoubleCrystalBall", 600, 800);
72 
73  y1 = -0.5;//1e-2; //1e-10;
74  y2 = 1.5;//10*N/sigma; //20;
75  c2->DrawFrame(x1, y1, x2, y2, ";#Delta;");
76  c2->SetTicks(1,1);
77  //c2->SetLogy();
78 
79  TF1 * f2 = new TF1("IntDoubleCrystalBall", DAS::DoubleCrystalBall::Integral(), x1, x2, 7);
80  f2->SetParameters(p);
81  f2->Draw("same");
82 
83  auto myErf = [](double * x, double *p) {
84  double N = p[0], mu = p[1], sigma = p[2];
85  double z = (*x-mu)/sigma;
86  return N*(1+erf(z/sqrt(2)))/2;
87  };
88 
89  TF1 * g2 = new TF1("myErf", myErf, x1, x2, 3);
90  g2->SetParameters(p);
91  g2->SetLineColor(kBlue);
92  g2->SetLineStyle(2);
93  g2->SetLineWidth(1);
94  g2->Draw("same");
95 
96  legend = new TLegend(0.2, 0.7, 0.49, 0.85);
97  legend->SetBorderSize(0);
98  legend->AddEntry(f, "Integrated DCB", "l");
99  legend->AddEntry(g, "Error function", "l");
100 
101  line(f2, 1, mu, Form("mean (#mu = %.2f)", mu));
102  line(f2, 2, mu+sigma, Form("mean #pm width (#sigma = %.2f)", sigma));
103  line(f2, 2, mu-sigma);
104  line(f2, 3, kL, Form("k_{L} = %.2f, n_{L} = %.0f", kL, nL));
105  line(f2, 3, kR, Form("k_{R} = %.2f, n_{R} = %.0f", kR, nR));
106 
107  legend->Draw();
108  c2->RedrawAxis();
109  c2->Print("DoubleCrystalBall.pdf");
110 
112 
113  auto c3 = new TCanvas("DerivLogDoubleCrystalBall", "DerivLogDoubleCrystalBall", 600, 800);
114 
115  y1 = -50;
116  y2 = 50;
117  c3->DrawFrame(x1, y1, x2, y2, ";#Delta;");
118  c3->SetTicks(1,1);
119 
120  TF1 * f3 = new TF1("DerivLogDoubleCrystalBall", DAS::DoubleCrystalBall::DLog(), x1, x2, 7);
121  f3->SetParameters(p);
122  f3->Draw("same");
123 
124  TF1 * g3 = new TF1("derivLogGauss", "-(x-[0])/([1]*[1])", x1, x2);
125  g3->SetParameters(&p[1]);
126  g3->SetLineColor(kBlue);
127  g3->SetLineStyle(2);
128  g3->SetLineWidth(1);
129  g3->Draw("same");
130 
131  legend = new TLegend(0.6, 0.7, 0.89, 0.85);
132  legend->SetBorderSize(0);
133  legend->AddEntry(f, "Derivative of Log of DCB", "l");
134  legend->AddEntry(g, "Same for pure Gaussian", "l");
135 
136  line(f3, 1, mu, Form("mean (#mu = %.2f)", mu));
137  line(f3, 2, mu+sigma, Form("mean #pm width (#sigma = %.2f)", sigma));
138  line(f3, 2, mu-sigma);
139  line(f3, 3, kL, Form("k_{L} = %.2f, n_{L} = %.0f", kL, nL));
140  line(f3, 3, kR, Form("k_{R} = %.2f, n_{R} = %.0f", kR, nR));
141 
142  legend->Draw();
143 
144  c3->RedrawAxis();
145  c3->Print("DoubleCrystalBall.pdf)");
146 
147  return EXIT_SUCCESS;
148 }
DAS::DoubleCrystalBall::Integral
Definition: DoubleCrystalBall.h:93
Ntupliser_cfg.p
p
Definition: Ntupliser_cfg.py:358
Ntupliser_cfg.f
f
Definition: Ntupliser_cfg.py:252
DAS::DoubleCrystalBall::Distribution
Definition: DoubleCrystalBall.h:83
DAS::DoubleCrystalBall::DLog
Definition: DoubleCrystalBall.h:106