-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmyplots.C
More file actions
208 lines (163 loc) · 7.58 KB
/
myplots.C
File metadata and controls
208 lines (163 loc) · 7.58 KB
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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
#include "SampleInfo.h"
#include "SUSYLooperHists.C"
#include "TLegend.h"
#include <vector>
// just to overlay some plots, should be more automated, e.g. how to check which histo is data, axis ranges, overflows, ratio plots
void plotHist ( vector <TFile*> Files, vector <SampleInfo> Names, TString Histname)
{
TCanvas* canvas = new TCanvas(Histname+"can",Histname+"can");
TLegend* alegend = new TLegend(0.6,0.6,0.99,0.99);
alegend->SetFillColor(0);
TH1D* histMC = NULL; // histogramm for all MCs added
int first=0;
for (unsigned int i =0 ;i< Names.size(); i++)
{
TH1D* hist = (TH1D*) Files[i]->Get(Histname);
hist->SetLineColor(Names[i].color);
cout << Names[i].CrossSection <<endl;
// hist->Scale(Names[i].weight());
alegend->AddEntry(hist, Names[i].LegendLabel,"lp");
if(i==0) {
// can be done more automated, i.e. check CrossSection<0 to use "data" style
hist->SetMarkerStyle(20);
hist->SetMarkerSize(1.5);
hist->Draw("P");
}
else hist->Draw("HIST same");
if(Names[i].CrossSection>0) { // for data the x-section is set to -1
if(first==0){
histMC = ( TH1D*) hist->Clone();
first++;
}
else{
histMC->Add(hist,1);
}
}
}
if(histMC==NULL)
{
cout <<"WARNING: The plotHist aim to overlay MC and data, no MC has been givem (no .0 X-section found)"<<endl;
}
else{
histMC->SetLineColor(kRed);
// alegend->AddEntry(histMC,"all MC","lp");
histMC->SetLineWidth(3);
// histMC->Draw("same");
}
alegend->Draw("same");
}
void plotHist2D ( vector <TFile*> Files, vector <SampleInfo> Names, TString Histname)
{
TCanvas* canvas = new TCanvas(Histname+"can",Histname+"can");
canvas->Divide(2);
TH2D* histMC = NULL; // histogramm for all MCs added
int first=0;
for (unsigned int i =0 ;i< Names.size(); i++)
{
TH2D* hist = (TH2D*) Files[i]->Get(Histname);
if(Names[i].CrossSection>0) { // for data the x-section is set to -1
if(first==0){
histMC = ( TH2D*) hist->Clone();
first++;
}
else{
histMC->Add(hist,1);
}
}
else{
canvas->cd(1);
hist->Draw("colz");
}
}
if(histMC==NULL)
{
cout <<"WARNING: The plotHist aim to overlay MC and data, no MC has been givem (no .0 X-section found)"<<endl;
}
else{
canvas->cd(2);
histMC->Draw("colz");
}
}
void myplots()
{
// initialising the samples to run on
// all files are at eos, so start with these
SampleInfo eosZll(19.7,2655795,40.5,TString("root://eoscms.cern.ch//eos/cms/store/cmst3/group/susy/markus/preliminary_samples_11thApril_2014/DYJetsToLLPtZ100/markusTreeProducer/markusTreeProducer_tree.root"),TString("Z_ll"),TString("Z(ll)"),2);
// You can copy them over to your local directory to gain speed
SampleInfo Zll(19.7,2655795,40.5,TString("../data_test_antonios/DYJetsToLLPtZ100/markusTreeProducer/markusTreeProducer_tree.root"),TString("Z(ll)"),TString("Zll"),2);
// pathes below to local directories
SampleInfo wjet(19.7 ,12742383,282,TString("../data_test_antonios/WPT100JETS/markusTreeProducer/markusTreeProducer_tree.root"),TString("Wjet"),TString("Wjet"),2);
SampleInfo ttsemi(19.7,320./963.*24895259,106.15,TString("../data_test_antonios/myhaddedFileTsemi.root"),TString("TTbarSemiLep"),TString("tt(l)"),7);
SampleInfo ttlep(19.7,11947326*0.467,25.8,TString("../data_test_antonios/myhaddedFileTlep.root"),TString("TTbarFullyLep"),TString("tt(ll)"),8);
// SampleInfo Znunu50(19.7,4040980,435.71,TString("../data_test_antonios/ZJetsToNuNu100/markusTreeProducer/markusTreeProducer_tree.root"),TString("Znunu50"),TString("Z(#nu#nu)"),5);
// SampleInfo Znunu100(19.7,4416646,186.84,TString("../data_test_antonios/ZJetsToNuNu100/markusTreeProducer/markusTreeProducer_tree.root"),TString("Znunu100"),TString("Z(#nu#nu)"),5);
// SampleInfo Znunu200(19.7,5055885,45.60,TString("../data_test_antonios/ZJetsToNuNu100/markusTreeProducer/markusTreeProducer_tree.root"),TString("Znunu200"),TString("Z(#nu#nu)"),5); SampleInfo Znunu400(19.7,1006928,6.25,TString("../data_test_antonios/ZJetsToNuNu100/markusTreeProducer/markusTreeProducer_tree.root"),TString("Znunu400"),TString("Z(#nu#nu)"),5);
// SampleInfo data(19.7,947236 ,-1,TString("data.root"),TString("datapl"),TString("datapl"),1);
SampleInfo signal(19.7,947236 ,-1,TString(""),TString("signal"),TString("signal"),1);
SampleInfo ZZll(19.7,947236 ,0.28,TString("/afs/cern.ch/work/m/mstoye/CMGTools_SUSY/CMSSW_5_3_14/src/CMGTools/TTHAnalysis/cfg/ZZllnunumad/ZZJetsTo2L2Nu/markusTreeProducer/markusTreeProducer_tree.root"),TString("ZZ(ll#nu#nu)+2jet+PS;M(ll) GeV > 12"),TString("ZZll"),3);
SampleInfo WZll(19.7, 2007116 ,0.8674,TString("/afs/cern.ch/work/m/mstoye/CMGTools_SUSY/CMSSW_5_3_14/src/CMGTools/TTHAnalysis/cfg/WZmad/WZJets/markusTreeProducer/markusTreeProducer_tree.root"),TString("WZ(ll)"),TString("WZll"),4);
SampleInfo WW(19.7, 9976539,54.80,TString("/disk2/WWtree.root"),TString("WW"),TString("WW"),7);
SampleInfo singleTop(19.7,991118 ,22,TString("/disk2/singleTop.root"),TString("t"),TString("t"),12);
SampleInfo privateZZll(19.7,2149 ,0.006,TString("/afs/cern.ch/work/m/mstoye/CMGTools_SUSY/CMSSW_5_3_14/src/CMGTools/TTHAnalysis/cfg/test/ZZnunullPrivate_Chunk0/markusTreeProducer/markusTreeProducer_tree.root"),TString("ZZ(ll#nu#nu)+1jet+PS;12> M(ll) GeV >1"),TString("mZZ"),12);
// signal
// for a quick plot a Tfiles are stored in vectors, can be done in many ways
vector <TFile*> Files;
vector <SampleInfo> Names;
// SUSYLooperHists myZll(eosZll);
// TFile* myZllfile = myZll.Loop();
// Files.push_back(myZllfile);
// Names.push_back(eosZll);
// cout << endl<< "see the difference local vs. eos" <<endl <<endl;
/*
SUSYLooperHists mydata(data);
TFile* mydataplots = mydata.Loop();
Files.push_back(mydataplots);
Names.push_back(data);
SUSYLooperHists myLocalZll(Zll);
TFile* myLocalZllfile = myLocalZll.Loop();
Files.push_back(myLocalZllfile);
Names.push_back(Zll);
SUSYLooperHists myWZll(WZll);
TFile* myWZllfile = myWZll.Loop();
Files.push_back(myWZllfile);
Names.push_back(WZll);
SUSYLooperHists mytt2l(ttlep);
TFile* myttlep = mytt2l.Loop();
Files.push_back(myttlep);
Names.push_back(ttlep);
*/
SUSYLooperHists myprivateZZll(privateZZll);
TFile* myprivateZZllfile = myprivateZZll.Loop();
Files.push_back(myprivateZZllfile);
Names.push_back(privateZZll);
SUSYLooperHists myZZll(ZZll);
TFile* myZZllfile = myZZll.Loop();
Files.push_back(myZZllfile);
Names.push_back(ZZll);
// SUSYLooperHists myWs(wjet);
// TFile* myWplots = myWs.Loop();
// Files.push_back(myWplots);
// Names.push_back(wjet);
/*
SUSYLooperHists myWW(WW);
TFile* myWWplots = myWW.Loop();
Files.push_back(myWWplots);
Names.push_back(WW);
SUSYLooperHists mysingleTop(singleTop);
TFile* mysingleTopplots = mysingleTop.Loop();
Files.push_back(mysingleTopplots);
Names.push_back(singleTop);
*/
/*
SampleInfo T23(1.99608,156000,19.7,TString("../data_test_antonios/T2degTest/markusTreeProducer/markusTreeProducer_tree.root"),TString("PrelimT2_out"),TString("PrelimT2_out"),4);
SUSYLooperHists T2loop3(T23);
TFile* T2loopFile3 = T2loop3.Loop();
Files.push_back(T2loopFile3);
Names.push_back(T23);
*/
// this is a plot to test the loops, for regular/frequent plotting with overlaying histograms code should be written in a automated manner starting from stored Tfiles
plotHist(Files,Names,TString("GenMassll"));
plotHist(Files,Names,TString("IP3D"));
plotHist(Files,Names,TString("Dz"));
plotHist(Files,Names,TString("Dxy"));
}