1 |
buchmann |
1.1 |
#include <iostream>
|
2 |
|
|
#include <sstream>
|
3 |
|
|
#include <fstream>
|
4 |
|
|
#include "jsoncpp.cpp"
|
5 |
|
|
#include "TColor.h"
|
6 |
|
|
|
7 |
|
|
using namespace std;
|
8 |
|
|
|
9 |
|
|
Color_t GetColor(string JSONColor) {
|
10 |
|
|
if(JSONColor=="dy_color") return kYellow;
|
11 |
|
|
if(JSONColor=="wjets_color") return kGray;
|
12 |
|
|
if(JSONColor=="ttbar_color") return kMagenta+2;
|
13 |
|
|
if(JSONColor=="singletop_color") return kBlue;
|
14 |
|
|
if(JSONColor=="qcd_color") return kPink;
|
15 |
|
|
if(JSONColor=="diboson_color") return kGreen+2;
|
16 |
|
|
if(JSONColor=="lm_color") return kViolet+7;
|
17 |
buchmann |
1.2 |
if(JSONColor=="wg_color") return kGreen;
|
18 |
buchmann |
1.5 |
if(JSONColor=="tth_color") return TColor::GetColor("#D8F781");
|
19 |
buchmann |
1.1 |
if(Contains(JSONColor,"#")) return TColor::GetColor(JSONColor.c_str());
|
20 |
|
|
write_error(__FUNCTION__,"Invalid color requested: "+JSONColor);
|
21 |
|
|
assert(0);
|
22 |
|
|
return 0;
|
23 |
|
|
}
|
24 |
|
|
|
25 |
|
|
float GetCrossSection8TeV(string JSONXS) {
|
26 |
|
|
if(JSONXS=="Data") return 1.0;
|
27 |
|
|
|
28 |
|
|
// at 8 TeV: 3503.71 (https://twiki.cern.ch/twiki/bin/view/CMS/Zpt8TeV)
|
29 |
|
|
if(JSONXS=="ZJetsCrossSection") return 3532.8;
|
30 |
|
|
if(JSONXS=="LowZJetsCrossSection") return 11050*0.069*1.15; // LO xs * filter eff * k-factor (same as ZJets)
|
31 |
|
|
if(JSONXS=="TTbarCrossSection") return 225.197;
|
32 |
|
|
if(JSONXS=="WJetsCrossSection") return 37509.0;
|
33 |
|
|
|
34 |
|
|
if(JSONXS=="SingleTop_T_SChannel") return 3.79;
|
35 |
|
|
if(JSONXS=="SingleTop_Tbar_SChannel") return 1.76;
|
36 |
|
|
if(JSONXS=="SingleTop_Tbar_TChannel") return 30.7;
|
37 |
|
|
if(JSONXS=="SingleTop_T_TChannel") return 56.4;
|
38 |
|
|
if(JSONXS=="SingleTop_T_TWChannel") return 11.1;
|
39 |
|
|
if(JSONXS=="SingleTop_Tbar_TWChannel") return 11.1;
|
40 |
|
|
|
41 |
|
|
if(JSONXS=="ZZJetsTo2L2Q") return 2.449;
|
42 |
|
|
if(JSONXS=="ZZJetsTo4L") return 0.1769;
|
43 |
|
|
if(JSONXS=="WZJetsTo3LNu") return 1.06;
|
44 |
|
|
if(JSONXS=="WWJetsTo2L2Nu") return 5.81;
|
45 |
|
|
if(JSONXS=="ZZJetsTo2L2Nu") return 0.3;
|
46 |
|
|
if(JSONXS=="LM4") return 2.88199;
|
47 |
buchmann |
1.2 |
if(JSONXS=="LM6") return 0.501773;
|
48 |
buchmann |
1.1 |
|
49 |
buchmann |
1.5 |
if(JSONXS=="TTWCrossSection") return 0.232;
|
50 |
|
|
if(JSONXS=="TTZCrossSection") return 0.208;
|
51 |
|
|
if(JSONXS=="TTGCrossSection") return 2.166;
|
52 |
|
|
if(JSONXS=="TTHCrossSection") return 0.130;
|
53 |
buchmann |
1.3 |
|
54 |
|
|
|
55 |
|
|
if(JSONXS=="TTbarCrossSectionMatchingUp")return 236.9;
|
56 |
|
|
if(JSONXS=="TTbarCrossSectionMatchingDown")return 223.2;
|
57 |
|
|
if(JSONXS=="TTbarCrossSectionScaleUp")return 167.7;
|
58 |
|
|
if(JSONXS=="TTbarCrossSectionScaleDown")return 391.4;
|
59 |
|
|
if(JSONXS=="TTbarCrossSectionM166")return 277.6;
|
60 |
|
|
if(JSONXS=="TTbarCrossSectionM169")return 256.0;
|
61 |
|
|
if(JSONXS=="TTbarCrossSectionM175")return 215.6;
|
62 |
|
|
if(JSONXS=="TTbarCrossSectionM178")return 192.6;
|
63 |
|
|
|
64 |
|
|
|
65 |
|
|
|
66 |
|
|
|
67 |
buchmann |
1.1 |
write_error(__FUNCTION__,"Invalid cross section requested : "+JSONXS);
|
68 |
|
|
assert(0);
|
69 |
|
|
}
|
70 |
|
|
|
71 |
|
|
float GetCrossSection7TeV(string JSONXS) {
|
72 |
buchmann |
1.2 |
if(JSONXS=="Data") return 1.0;
|
73 |
|
|
|
74 |
|
|
// at 8 TeV: 3503.71 (https://twiki.cern.ch/twiki/bin/view/CMS/Zpt8TeV)
|
75 |
|
|
if(JSONXS=="ZJetsCrossSection") return 3048.0;
|
76 |
|
|
if(JSONXS=="LowZJetsCrossSection") return 11908; // LO xs * filter eff * k-factor (same as ZJets)
|
77 |
|
|
if(JSONXS=="TTbarCrossSection") return 165.0;
|
78 |
|
|
if(JSONXS=="WJetsCrossSection") return 31314.0;
|
79 |
|
|
if(JSONXS=="ZToNuNu") return 5760.0;
|
80 |
|
|
|
81 |
|
|
|
82 |
|
|
if(JSONXS=="SingleTop_T_SChannel") return 4.63;
|
83 |
|
|
if(JSONXS=="SingleTop_T_TChannel") return 64.57;
|
84 |
|
|
if(JSONXS=="SingleTop_T_TWChannel") return 15.74;
|
85 |
|
|
|
86 |
|
|
if(JSONXS=="VVJets") return 4.8;
|
87 |
|
|
|
88 |
|
|
if(JSONXS=="LM3") return 0.0;
|
89 |
|
|
if(JSONXS=="LM4") return 1.879*1.35;
|
90 |
|
|
if(JSONXS=="LM6") return 0.3104*1.30;
|
91 |
|
|
if(JSONXS=="LM8") return 0.7300*1.41;
|
92 |
|
|
|
93 |
|
|
write_error(__FUNCTION__,"Invalid cross section requested : "+JSONXS);
|
94 |
|
|
assert(0);
|
95 |
buchmann |
1.1 |
}
|
96 |
|
|
|
97 |
|
|
float GetCrossSection(string JSONXS, string Year) {
|
98 |
|
|
if(Year=="2012") {
|
99 |
|
|
return GetCrossSection8TeV(JSONXS);
|
100 |
|
|
}
|
101 |
|
|
if(Year=="2011") {
|
102 |
|
|
return GetCrossSection7TeV(JSONXS);
|
103 |
|
|
}
|
104 |
|
|
write_error(__FUNCTION__,"Invalid year requested: "+Year);
|
105 |
|
|
assert(0);
|
106 |
|
|
}
|
107 |
|
|
|
108 |
buchmann |
1.2 |
int LoadSamplesFromJSON(string SampleListPath, bool SplitByJetFlavors, bool SplitByLeptonFlavors, bool SplitDibosons, bool SplitOthers=true) {
|
109 |
|
|
cout << "Going to load samples from " << SampleListPath << endl;
|
110 |
|
|
SampleListPath="Modules/JSON/"+SampleListPath;
|
111 |
buchmann |
1.1 |
Json::Value root;
|
112 |
|
|
Json::Reader reader;
|
113 |
|
|
|
114 |
|
|
stringstream filecontent;
|
115 |
|
|
ifstream infile;
|
116 |
|
|
infile.open (SampleListPath.c_str());
|
117 |
buchmann |
1.2 |
if(!(infile.good())) {
|
118 |
|
|
cout << "There was a problem opening the file " << SampleListPath << endl;
|
119 |
|
|
assert(0);
|
120 |
|
|
}
|
121 |
|
|
|
122 |
buchmann |
1.1 |
string currline;
|
123 |
buchmann |
1.2 |
while(getline(infile,currline)) {
|
124 |
buchmann |
1.1 |
filecontent<<currline; // Prints our STRING.
|
125 |
|
|
}
|
126 |
|
|
|
127 |
|
|
infile.close();
|
128 |
|
|
string FileContent=filecontent.str();
|
129 |
|
|
bool parsingSuccessful = reader.parse( FileContent, root );
|
130 |
|
|
if ( !parsingSuccessful ) {
|
131 |
|
|
cout << "Failed to parse sample list at " << SampleListPath << endl;
|
132 |
|
|
cout << reader.getFormattedErrorMessages();
|
133 |
buchmann |
1.3 |
cout << "If you don't see the the problem in your configuration right away, you could paste it here to visualize it: http://chris.photobooks.com/json/default.htm " << endl;
|
134 |
buchmann |
1.1 |
assert(parsingSuccessful);
|
135 |
|
|
}
|
136 |
|
|
|
137 |
|
|
string CMSSW_version="undefined";
|
138 |
|
|
string Year="undefined";
|
139 |
|
|
|
140 |
|
|
map<string,int> DYmap;
|
141 |
|
|
DYmap["Z+Jets"]=90;
|
142 |
|
|
//only by jet flavor
|
143 |
buchmann |
1.3 |
DYmap["Z+b"]=93;
|
144 |
buchmann |
1.1 |
DYmap["Z+c"]=92;
|
145 |
buchmann |
1.3 |
DYmap["Z+l"]=91;
|
146 |
buchmann |
1.1 |
//only by lepton flavor
|
147 |
|
|
DYmap["Z+ee,#mu#mu"]=94;
|
148 |
|
|
DYmap["Z+#tau#tau"]=95;
|
149 |
buchmann |
1.2 |
int OtherGroup=91;
|
150 |
|
|
int DibosonGroupNumber=90;
|
151 |
buchmann |
1.1 |
|
152 |
|
|
|
153 |
|
|
bool BeVerboseWhenReordering=false;
|
154 |
|
|
|
155 |
|
|
if( root.size() > 0 ) {
|
156 |
|
|
set_treename();
|
157 |
|
|
|
158 |
|
|
Year = root["Year"].asString();
|
159 |
|
|
CMSSW_version = root["CMSSWv"].asString();
|
160 |
|
|
const Json::Value samplecollections = root["samplecollections"];
|
161 |
|
|
for (int icoll = 0; icoll < samplecollections.size(); ++icoll) {
|
162 |
|
|
for (int iprocess=0; iprocess < root["samplecollections"][icoll]["samples"].size(); ++iprocess) {
|
163 |
|
|
for(int isrc=0; isrc < root["samplecollections"][icoll]["samples"][iprocess]["source"].size();isrc++) {
|
164 |
|
|
int groupNumber = iprocess;
|
165 |
|
|
string groupName = root["samplecollections"][icoll]["samples"][iprocess]["groupname"].asString();
|
166 |
|
|
bool IsSignal = root["samplecollections"][icoll]["samples"][iprocess]["IsSignal"]=="No"?0:1;
|
167 |
buchmann |
1.2 |
bool IsActive = root["samplecollections"][icoll]["samples"][iprocess]["IsActive"]=="No"?0:1;
|
168 |
buchmann |
1.1 |
Color_t groupColor = GetColor(root["samplecollections"][icoll]["samples"][iprocess]["groupcolor"].asString());
|
169 |
|
|
bool IsData = root["samplecollections"][icoll]["samples"][iprocess]["grouptype"]=="MC"?0:1;
|
170 |
|
|
string FileName = root["samplecollections"][icoll]["samples"][iprocess]["source"][isrc]["filename"].asString();
|
171 |
|
|
string SampleColl = samplecollections[icoll]["samplecollection"].asString();
|
172 |
|
|
float CrossSection = GetCrossSection(root["samplecollections"][icoll]["samples"][iprocess]["source"][isrc]["crosssection"].asString(),Year);
|
173 |
|
|
|
174 |
buchmann |
1.2 |
if(!IsActive) continue;
|
175 |
|
|
|
176 |
buchmann |
1.1 |
bool registered=false;
|
177 |
|
|
if(groupName=="") {
|
178 |
|
|
dout << "Found an empty group name for file " << FileName << " - panicking, good bye!" << endl;
|
179 |
|
|
assert(groupName!="");
|
180 |
|
|
}
|
181 |
|
|
|
182 |
buchmann |
1.4 |
if(Contains(groupName,"2l2q")) {// ZZ -> 2l2q
|
183 |
|
|
groupColor=TColor::GetColor("#FE9A2E");
|
184 |
|
|
}
|
185 |
|
|
|
186 |
buchmann |
1.1 |
if(Contains(groupName,"Z+Jets")) {
|
187 |
|
|
//may need to merge ...
|
188 |
|
|
if(BeVerboseWhenReordering) cout << groupName << endl;
|
189 |
|
|
if(!SplitByJetFlavors&&!SplitByLeptonFlavors) {
|
190 |
|
|
//merge everything
|
191 |
|
|
if(BeVerboseWhenReordering) cout << " thrown " << groupName << " to Z+Jets" << endl;
|
192 |
|
|
groupName="Z+Jets";
|
193 |
|
|
groupNumber=DYmap["Z+Jets"];
|
194 |
|
|
}
|
195 |
|
|
if(!SplitByJetFlavors&&SplitByLeptonFlavors) {
|
196 |
|
|
//arrange them by lepton flavor
|
197 |
|
|
if(Contains(groupName,"ZToEEMM")) {
|
198 |
|
|
if(BeVerboseWhenReordering) cout << " thrown " << groupName << " to Z+ee,mm" << endl;
|
199 |
buchmann |
1.2 |
groupName="Z(ee,#mu#mu)+Jets";
|
200 |
buchmann |
1.1 |
groupNumber=DYmap["Z+ee,#mu#mu"];
|
201 |
|
|
}
|
202 |
|
|
if(Contains(groupName,"ZToTauTau")) {
|
203 |
|
|
if(BeVerboseWhenReordering) cout << " thrown " << groupName << " to Z+tautau" << endl;
|
204 |
buchmann |
1.2 |
groupName="Z(#tau#tau)+Jets";
|
205 |
buchmann |
1.1 |
groupNumber=DYmap["Z+#tau#tau"];
|
206 |
buchmann |
1.2 |
groupColor=kRed;
|
207 |
buchmann |
1.1 |
}
|
208 |
|
|
}
|
209 |
|
|
|
210 |
|
|
if(!SplitByLeptonFlavors&&SplitByJetFlavors) {
|
211 |
|
|
//arrange them by jet flavor
|
212 |
|
|
if(Contains(groupName,"Z+b")) {
|
213 |
|
|
if(BeVerboseWhenReordering) cout << " thrown " << groupName << " to Z+b" << endl;
|
214 |
|
|
groupName="Z+b";
|
215 |
|
|
groupNumber=DYmap["Z+b"];
|
216 |
|
|
}
|
217 |
|
|
if(Contains(groupName,"Z+c")) {
|
218 |
|
|
if(BeVerboseWhenReordering) cout << " thrown " << groupName << " to Z+c" << endl;
|
219 |
|
|
groupName="Z+c";
|
220 |
|
|
groupNumber=DYmap["Z+c"];
|
221 |
buchmann |
1.3 |
groupColor=kViolet+7;
|
222 |
buchmann |
1.1 |
}
|
223 |
|
|
if(Contains(groupName,"Z+l")) {
|
224 |
|
|
if(BeVerboseWhenReordering) cout << " thrown " << groupName << " to Z+l" << endl;
|
225 |
|
|
groupName="Z+l";
|
226 |
|
|
groupNumber=DYmap["Z+l"];
|
227 |
buchmann |
1.3 |
groupColor=kPink;
|
228 |
buchmann |
1.1 |
}
|
229 |
|
|
}
|
230 |
|
|
}
|
231 |
|
|
|
232 |
buchmann |
1.2 |
if((Contains(groupName,"ZZ")||Contains(groupName,"WZ")||Contains(groupName,"Dibosons")) && !SplitDibosons) {
|
233 |
|
|
if(BeVerboseWhenReordering) cout << groupName << endl;
|
234 |
|
|
//merge everything
|
235 |
|
|
if(BeVerboseWhenReordering) cout << " thrown " << groupName << " to Dibosons" << endl;
|
236 |
|
|
groupName="Dibosons";
|
237 |
|
|
groupNumber=DibosonGroupNumber;
|
238 |
|
|
}
|
239 |
|
|
|
240 |
buchmann |
1.5 |
if((Contains(groupName,"Dibosons")||Contains(groupName,"W+Jets")||Contains(groupName,"Single-top")||Contains(groupName,"TTV")||Contains(groupName,"TTH"))&&!SplitOthers) {
|
241 |
buchmann |
1.2 |
if(BeVerboseWhenReordering) cout << groupName << endl;
|
242 |
|
|
//merge everything
|
243 |
buchmann |
1.4 |
if(BeVerboseWhenReordering) cout << " thrown " << groupName << " to Others" << endl;
|
244 |
buchmann |
1.2 |
groupName="Others";
|
245 |
|
|
groupNumber=OtherGroup;
|
246 |
|
|
groupColor=kGreen+2;//same as diboson
|
247 |
|
|
}
|
248 |
|
|
|
249 |
buchmann |
1.1 |
if(SampleColl=="allsamples") {
|
250 |
|
|
PlottingSetup::allsamples.AddSample(FileName,groupName,0,CrossSection,IsData,IsSignal,groupNumber,groupColor);
|
251 |
|
|
registered=true;
|
252 |
|
|
}
|
253 |
|
|
|
254 |
|
|
if(SampleColl=="systsamples") {
|
255 |
|
|
PlottingSetup::systsamples.AddSample(FileName,groupName,0,CrossSection,IsData,IsSignal,groupNumber,groupColor);
|
256 |
|
|
registered=true;
|
257 |
|
|
}
|
258 |
|
|
|
259 |
buchmann |
1.5 |
if(SampleColl=="SingleLeptonData") {
|
260 |
|
|
PlottingSetup::SingleLeptonData.AddSample(FileName,groupName,0,CrossSection,IsData,IsSignal,groupNumber,groupColor);
|
261 |
|
|
registered=true;
|
262 |
|
|
}
|
263 |
|
|
|
264 |
buchmann |
1.2 |
|
265 |
|
|
|
266 |
buchmann |
1.1 |
if(!registered) {
|
267 |
|
|
write_error(__FUNCTION__,"The sample collection specified in the JSON, "+SampleColl+", is not known");
|
268 |
|
|
}
|
269 |
|
|
|
270 |
|
|
assert(registered);
|
271 |
|
|
}
|
272 |
|
|
}
|
273 |
|
|
}
|
274 |
|
|
|
275 |
buchmann |
1.2 |
// PlottingSetup::allsamples.ListSamples();
|
276 |
|
|
// PlottingSetup::systsamples.ListSamples();
|
277 |
buchmann |
1.1 |
|
278 |
|
|
} else {
|
279 |
|
|
cout << "Problem with JSON file. " << endl;
|
280 |
|
|
assert(root.size() > 0);
|
281 |
|
|
}
|
282 |
|
|
}
|