ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/Jeng/scripts/MuonIPS2D.C
Revision: 1.1
Committed: Thu May 20 22:06:53 2010 UTC (14 years, 11 months ago) by jengbou
Content type: text/plain
Branch: MAIN
CVS Tags: HEAD
Log Message:
add file

File Contents

# Content
1 #include "TROOT.h"
2 #include "TH1.h"
3 #include "TH2D.h"
4 #include "TF1.h"
5 #include "TMath.h"
6 #include "TAxis.h"
7 #include "TString.h"
8 #include "TFile.h"
9 #include "TCanvas.h"
10 #include "TLegend.h"
11 #include "map.h"
12 #include "TLatex.h"
13 #include "TColor.h"
14
15 std::map<TString,TString> histName;
16 std::map<TString,TH1*> hs;
17 std::map<TString,TCanvas*> ts;
18
19 void MuonIPS2D()
20 {
21 gROOT->SetStyle("CMS");
22 //gStyle->SetOptFit(1111);
23
24 TFile *fsig = TFile::Open("TTbarJets_madgraph_Spring10_5_all.root");
25 TFile *fbkg = TFile::Open("InclusiveMu15_Spring10_5_all.root");
26
27 // LOAD HISTOGRAMS FROM FILES
28 const int nKin = 3;
29 const int nDim = 2;
30 const int nRef = 2;
31 const int nSel = 3;
32 const int nVar = 3;
33 double weight[2] = {0.001305,0.1255};
34 string kinv[nKin] = {"eta","pt","phi"};
35 string dim[nDim] = {"2D","3D"};
36 string ref[nRef] = {"bs","pv"};
37 string ref1[nRef] = {"Beam Spot","Primary Vertex"};
38 string sel[nSel] = {"cut0","cut1","cut2"};
39 string sel1[nSel] = {"excl0","excl1","excl2"};
40 string varName[nVar] = {"IPS","IP","IPerr"};
41
42 for (int ii = 0; ii < nKin; ii++) {
43 for (int i = 0; i < nDim; i++) {
44 for (int j = 0; j < nRef; j++) {
45 if (dim[i] == "3D" && ref[j] == "bs") continue;
46 TString fileName = TString("Summery_"+kinv[ii]+"_vs_IPs_"+dim[i]+"_"+ref[j]);
47 ts[fileName] = new TCanvas(fileName,fileName,800,800);
48 //ts[fileName]->Divide(nSel,nVar);
49 //for (int k = 0; k < nSel; k++) {
50 ts[fileName]->Divide(2,nVar);
51 for (int k = 1; k < nSel; k++) {
52 for (int vi = 0; vi < nVar; vi++) {
53 TString histComm = TString(varName[vi] + "_" + dim[i] + "_" + ref[j] + "_" + sel[k]);
54 TString histIncl = histComm + "_incl";
55 TString histTagIncl = TString(dim[i] + "_" + ref[j] + "_" + sel[k]);
56 histName[histIncl] = TString("Muons/muon_" + kinv[ii] + "_vs_" + varName[vi] + "_" + histTagIncl);
57 TString histExcl = histComm + "_excl";
58 TString histTagExcl = TString(dim[i] + "_" + ref[j] + "_" + sel1[k]);
59 histName[histExcl] = TString("Muons/muon_" + kinv[ii] + "_vs_" + varName[vi] + "_" + histTagExcl);
60
61 cout << "histComm = " << histComm << endl;
62 cout << "histName[histIncl] = " << histName[histIncl] << endl;
63 cout << "histName[histExcl] = " << histName[histExcl] << endl;
64
65 TString hTT = histIncl + "_TT";
66 hs[hTT] = (TH2D*) fsig->Get(histName[histIncl]);
67 TString hQCD = histIncl + "_QCD";
68 hs[hQCD] = (TH2D*) fbkg->Get(histName[histIncl]);
69 TString hQCDbc = histExcl + "_QCDbc";
70 hs[hQCDbc] = (TH2D*) fbkg->Get(histName[histExcl]);
71
72 // For weighted distributions
73 hs[histComm + "_sig"] = (TH2D*) hs[hTT]->Clone();
74 hs[histComm + "_bkg"] = (TH2D*) hs[hQCD]->Clone(); // QCD other decays
75 hs[histComm + "_bkgbc"] = (TH2D*) hs[hQCDbc]->Clone(); //QCD b/c decays
76
77 if (sel[k] != "cut2") {
78 hs[histComm + "_bkg"]->Scale(0.05);
79 hs[histComm + "_bkgbc"]->Scale(0.05);
80 }
81 // // //ttbar
82 // hs[histComm + "_sig"]->Scale(weight[0]);
83 // // // QCD
84 // hs[histComm + "_bkg"]->Scale(weight[1]);
85 // hs[histComm + "_bkgbc"]->Scale(weight[1]);
86
87 // // Normalized to area 1.
88 // hs[hTT]->Scale(1./hs[hTT]->Integral());
89 // hs[hQCD]->Scale(1./hs[hQCD]->Integral());
90
91
92 // Plot
93 TString CommonTag = TString(varName[vi] + "_" + dim[i] + "_" + ref[j] + "_" + sel[k]);
94
95
96 //cout << "CommonTag = " << CommonTag << endl;
97
98 //ts[fileName]->cd(k+vi*nVar+1);
99 ts[fileName]->cd(k+vi*2);
100 // if (ref[j] == "pv" && sel[k] == "cut2")
101 // hs[CommonTag+"_bkg"]->GetYaxis()->SetRangeUser(0,6);
102 if (kinv[ii] == "pt"){
103 if (sel[k] == "cut2")
104 hs[CommonTag+"_bkg"]->GetXaxis()->SetRangeUser(20,50);
105 if (sel[k] == "cut1")
106 hs[CommonTag+"_bkg"]->GetXaxis()->SetRangeUser(20,150);
107 }
108
109 // if (kinv[ii] == "pt") {
110 hs[CommonTag+"_bkg"]->SetMarkerColor(2);
111 if (sel[k] == "cut2") {
112 hs[CommonTag+"_bkg"]->SetMarkerSize(0.2);
113 hs[CommonTag+"_bkg"]->SetMarkerStyle(23);
114 }
115 hs[CommonTag+"_bkg"]->SetTitle(TString(dim[i]+" "+varName[vi]+" w.r.t. "+ref1[j]+" - "+sel[k]));
116 //hs[CommonTag+"_bkg"]->GetYaxis()->SetTitle(TString(dim[i]+" "+varName[vi]+" ("+ref[j]+") - "+sel[k]));
117 hs[CommonTag+"_bkg"]->GetYaxis()->SetTitle(TString(varName[vi]));
118 hs[CommonTag+"_bkg"]->GetXaxis()->SetTitle(TString(kinv[ii]));
119 hs[CommonTag+"_bkg"]->SetMinimum(0);
120 // if (sel[k] != "cut2" && kinv[ii] == "eta")
121 // hs[CommonTag+"_bkg"]->Draw("box");
122 // else
123 hs[CommonTag+"_bkg"]->SetLabelSize(0.03,"xy");
124 hs[CommonTag+"_bkg"]->SetTitleOffset(1.1,"xy");
125 hs[CommonTag+"_bkg"]->Draw();
126 // hs[CommonTag+"_sig"]->SetMarkerColor(3);
127 // hs[CommonTag+"_sig"]->Draw("same");
128 hs[CommonTag+"_bkgbc"]->SetMarkerColor(4);
129 if (sel[k] == "cut2") {
130 hs[CommonTag+"_bkgbc"]->SetMarkerSize(0.2);
131 hs[CommonTag+"_bkgbc"]->SetMarkerStyle(23);
132 }
133 // if (sel[k] != "cut2" && kinv[ii] == "eta")
134 // hs[CommonTag+"_bkgbc"]->Draw("boxsame");
135 // else
136 hs[CommonTag+"_bkgbc"]->Draw("same");
137 // }
138
139 // if (kinv[ii] == "eta") {
140 // // hs[CommonTag+"_bkg"]->SetMarkerColor(9);
141 // // hs[CommonTag+"_bkg"]->SetMarkerSize(0.2);
142 // // hs[CommonTag+"_bkg"]->SetMarkerStyle(27);
143 // hs[CommonTag+"_bkg"]->SetLineColor(9);
144 // hs[CommonTag+"_bkg"]->GetYaxis()->SetTitle(TString(dim[i]+" "+varName[vi]+" ("+ref[j]+") - "+sel[k]));
145 // hs[CommonTag+"_bkg"]->GetXaxis()->SetTitle(TString(kinv[ii]));
146 // hs[CommonTag+"_bkg"]->SetMinimum(0);
147 // hs[CommonTag+"_bkg"]->Draw("box");
148 // hs[CommonTag+"_bkgbc"]->SetLineColor(6);
149 // //hs[CommonTag+"_bkgbc"]->SetMarkerColor(6);
150 // hs[CommonTag+"_bkgbc"]->Draw("boxsame");
151 // }
152 TLatex* pText=new TLatex(0.5,0.6,"QCD - others");
153 pText->SetTextColor(2);
154 pText->SetNDC(kTRUE);
155 pText->SetTextSize(0.07);
156 pText->Draw();
157
158 TLatex* pText1=new TLatex(0.5,0.7,"QCD - b/c decays");
159 pText1->SetTextColor(4);
160 pText1->SetNDC(kTRUE);
161 pText1->SetTextSize(0.07);
162 pText1->Draw();
163
164 // TLatex* pText2=new TLatex(0.6,0.8,"t#bar{t}");
165 // pText2->SetTextColor(3);
166 // pText2->SetNDC(kTRUE);
167 // pText2->SetTextSize(0.07);
168 // pText2->Draw();
169
170 // TLegend *l0 = new TLegend(0.6,0.6,0.85,0.85);
171 // l0->SetFillStyle(0);
172 // l0->SetFillColor(0);
173 // // l0->AddEntry(hs[CommonTag+"_sig"],"t#bar{t} (S)","l");
174 // l0->AddEntry(hs[CommonTag+"_bkgbc"],"QCD - b/c decays","p");
175 // // l0->AddEntry(hs[CommonTag+"_bkg"],"QCD - others","p");
176 // l0->Draw();
177
178 }
179 }
180 //ts[fileName]->Print(fileName+".png");
181 //hs.clear();
182 }
183 }
184 }
185 }