-
Notifications
You must be signed in to change notification settings - Fork 0
/
plotFR.C
75 lines (63 loc) · 2.45 KB
/
plotFR.C
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
//----------------------------------------------------
// This macro is a template that you can use to make
// your own 2D fake rate.
// It all starts from a baby ntuple. The baby ntuple
// has one entry per lepton and is made using the
// code in myBabyMaker.C.
//
// The content of the ntuple is documented in the
// header file.
//
// This macro reads a baby ntuple and makes
// a muon fake rate with some sensible cuts.
// It should be easy to follow modify to do
// what ever else you want to do
//--------------------------------------------------
void plotFR( TChain* ch2, TCut numCut, TCut denCut, char* label){
//-------------------------------------------------------
// Now you define the pt and eta bins for your fake rate
//-------------------------------------------------------
double ybin[6]={10.,15.,20.,25.,30., 35.};
int nbinsy = 5;
double xbin[5]={0.0, 1.0, 1.479, 2.0, 2.5};
int nbinsx = 4;
//---------------------------
// Load some useful tools
//----------------------------
gROOT->LoadMacro("eff2.C");
gROOT->LoadMacro("eff.C");
gStyle->SetOptStat(0);
//----------------------------------------------------
// Here we define cuts for numerator and denominator
//-----------------------------------------------------
// A cut against Ws
TCut notWCut = "tcmet<20 && mt<25";
// A pt cut...
// Remember, we use 35 (at least for muons) to
// minimize the impact of Ws
TCut ptCut = "pt>10 && pt<35";
// The numerator selection
TCut isNum = numCut + ptCut + notWCut;
//The denominator selection
TCut isDen = denCut + ptCut + notWCut;
//--------------------------------------------------------
// Book your numerator and denominator histograms
//--------------------------------------------------------
TH2F* num = new TH2F( Form("%s_num", label), Form("%s_num", label), nbinsx, xbin, nbinsy, ybin);
TH2F* den = new TH2F( Form("%s_den", label), Form("%s_den", label), nbinsx, xbin, nbinsy, ybin);
//------------------------------------------
// Fill the Histograms
//-------------------------------------------
TCanvas *can = new TCanvas();
ch2->Draw( Form("pt:abs(eta)>>%s_num", label), isNum);
ch2->Draw( Form("pt:abs(eta)>>%s_den", label), isDen);
ch2->Draw( Form("pt>>%s_num1", label), isNum);
ch2->Draw( Form("pt>>%s_den1", label), isDen);
delete can;
//------------------------------------------
// Get the fake rate
// The output histogram name is "fr"
//------------------------------------------
TH2F* fr = eff2(den, num, Form("%s_fr", label) );
return;
}