#include <algorithm>
#include "TFile.h"
#include "TTree.h"
#include "TString.h"
#include "TH1F.h"
#include "TCanvas.h"
#include "TROOT.h"
#include "TEventList.h"
#include "TDirectory.h"
#include <iostream>
#include "TLine.h"
#include "TLatex.h"
#include "TStyle.h"
#include "TObjArray.h"
#include "TPRegexp.h"
#include <map>
#include "TLegend.h"
Go to the source code of this file.
|
void | setStyle () |
|
int | countEvents (TTree *t, TString ccut) |
|
double | suppression (TH1 *h1, TH1 *h2, double cut) |
|
void | findLimits (TTree *t, TString var, TString ccut, double &low, double &high, double frac=0.98) |
|
void | drawHistos (TTree *t, TString var, TString title, TString precut, TString newcut, double val, double val2=-999.) |
|
int | showvarexample () |
|
int countEvents |
( |
TTree * |
t, |
|
|
TString |
ccut |
|
) |
| |
Definition at line 56 of file showvarexample.C.
References ev, evcnt, and i.
59 t->SetBranchStatus(
"*",1);
61 t->SetBranchStatus(
"*",0);
62 t->SetBranchStatus(
"evt",1);
64 TEventList *el=(TEventList*)gDirectory->Get(
"el");
67 t->SetBranchAddress(
"evt",&ev);
71 for (
int i=0;
i<el->GetN();++
i)
73 t->GetEntry(el->GetEntry(
i));
76 t->SetBranchStatus(
"*",1);
Definition at line 131 of file showvarexample.C.
References countEvents(), findLimits(), h1, h2, signi, suppression(), and TString.
Referenced by showvarexample().
133 double sigl, sigh, bgl, bgh;
141 lt.SetTextSize(0.06);
144 lt2.SetTextSize(0.06);
145 lt2.SetTextColor(kBlue+2);
153 double eff=
countEvents(
t,
"mode==900&&tag&&"+precut+
"&&"+newcut);
156 double seff=
countEvents(
t,
"mode!=900&&tag&&"+precut+
"&&"+newcut);
160 TString sigcut =
"mode!=900&&tag&&"+precut;
161 TString bgcut =
"mode==900&&tag&&"+precut;
166 if (sigl>bgl) sigl=bgl;
167 if (sigh<bgh) sigh=bgh;
169 if (var==
"dtht") sigh=0.5;
171 TH1F *
h1=
new TH1F(
"h1",title,200,sigl,sigh);
172 TH1F *
h2=
new TH1F(
"h2",title,200,sigl,sigh);
177 t->Project(
"h1",var, sigcut);
178 t->Project(
"h2",var, bgcut);
182 h1->Scale(1.0/h1->Integral());
183 h2->Scale(1.0/h2->Integral());
184 h1->SetTitleSize(0.05);
186 double maxi = h1->GetMaximum();
187 if (h2->GetMaximum()>maxi ) maxi = h2->GetMaximum();
189 h1->SetMaximum(maxi);
190 h2->SetMaximum(maxi);
192 h1->DrawNormalized();
193 h2->DrawNormalized(
"same");
195 double axmin = h1->GetXaxis()->GetXmin(),axmax = h1->GetXaxis()->GetXmax();
197 l.DrawLine(
val,0,
val, maxi*0.9);
198 if (val2!=-999) l.DrawLine(val2,0, val2, maxi*0.9);
201 lt.DrawLatex(axmin+(axmax-axmin)*0.53,0.53*maxi,TString::Format(
"#epsilon_{bg} = %5.2f%%",100*eff));
202 lt2.DrawLatex(axmin+(axmax-axmin)*0.53,0.65*maxi,TString::Format(
"#epsilon_{sig} = %5.2f%%",100*seff));
204 TLegend *leg1 =
new TLegend(0.67,0.7,0.98,0.88);
205 leg1->AddEntry(
"h1",
"signal",
"l");
206 leg1->AddEntry(
"h2",
"BG",
"l");
Double_t val[nBoxes][nFEBox]
double suppression(TH1 *h1, TH1 *h2, double cut)
void findLimits(TTree *t, TString var, TString ccut, double &low, double &high, double frac=0.98)
int countEvents(TTree *t, TEventList &el)
void findLimits |
( |
TTree * |
t, |
|
|
TString |
var, |
|
|
TString |
ccut, |
|
|
double & |
low, |
|
|
double & |
high, |
|
|
double |
frac = 0.98 |
|
) |
| |
Definition at line 97 of file showvarexample.C.
References htemp, and i.
99 low =
t->GetMinimum(var);
100 high =
t->GetMaximum(var);
103 double miss = (1.-frac)/2;
107 t->Draw(
">>el",ccut);
108 t->SetEventList(&el);
110 double llow =
t->GetMinimum(var);
111 double lhigh =
t->GetMaximum(var);
113 TH1F
htemp(
"htemp",
"",500,llow, lhigh);
114 t->Project(
"htemp",var);
117 double integ =
htemp.Integral();
121 while (sum<miss) sum+=
htemp.GetBinContent(i++)/integ;
125 while (sum<miss) sum+=
htemp.GetBinContent(i--)/integ;
Definition at line 31 of file showvarexample.C.
33 gStyle->SetPadTopMargin(0.12);
34 gStyle->SetPadBottomMargin(0.12);
35 gStyle->SetPadLeftMargin(0.17);
36 gStyle->SetPadRightMargin(0.02);
38 gStyle->SetLabelSize(0.075,
"X");
39 gStyle->SetLabelSize(0.065,
"Y");
41 gStyle->SetStatY(0.87);
42 gStyle->SetStatX(0.98);
43 gStyle->SetStatW(0.4);
44 gStyle->SetStatH(0.12);
45 gStyle->SetOptStat(0);
47 gStyle->SetTitleH(0.1);
48 gStyle->SetTitleX(0.15);
49 gStyle->SetTitleOffset(1.1,
"x");
50 gStyle->SetTitleXSize(0.076);
51 gStyle->SetNdivisions(505);
Definition at line 211 of file showvarexample.C.
References c1, countEvents(), drawHistos(), f, i, name1, name2, name3, name4, setStyle(), t, and TString.
217 TFile *
f=
new TFile(
"data/M55_ndpm.root",
"READ");
219 TTree *
t=(TTree*)f->Get(
"ndpm");
221 TCanvas *
c1=
new TCanvas(
"c1",
"c1",10,10,1600,400);
223 TObjArray* branches = t->GetListOfBranches();
225 TString bgcut =
"mode==900 && tag";
301 drawHistos(t, var1,name1,
"1",cut1,val1,val11);
305 drawHistos(t, var3,name3, cut1+
"&&"+cut2,cut3,val3);
307 drawHistos(t, var4,name4, cut1+
"&&"+cut2+
"&&"+cut3,cut4,val4);
312 cout<<100*preEff<<endl;
void drawHistos(TTree *t, TString var, TString title, TString precut, TString newcut, double val, double val2=-999.)
int countEvents(TTree *t, TEventList &el)
double suppression |
( |
TH1 * |
h1, |
|
|
TH1 * |
h2, |
|
|
double |
cut |
|
) |
| |
Definition at line 81 of file showvarexample.C.
References cut, i, and n.
Referenced by drawHistos().
83 int n=
h1->GetNbinsX();
84 double sum1=0, sum2=0;
85 double int1 =
h1->Integral();
86 double int2 =
h2->Integral();
90 while (
h1->GetBinCenter(i)<
cut)
92 sum1 +=
h1->GetBinContent(i)/int1;
93 sum2 +=
h2->GetBinContent(i++)/int2;