-
Notifications
You must be signed in to change notification settings - Fork 2
/
OHltConfig.cpp
483 lines (437 loc) · 15.3 KB
/
OHltConfig.cpp
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
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
#include "OHltConfig.h"
#include "HLTDatasets.h"
using namespace std;
using namespace libconfig;
OHltConfig::OHltConfig(TString cfgfile, OHltMenu *omenu)
{
// init
/**** General Menu & Run conditions ****/
nEntries = -1;
nPrintStatusEvery = 10000;
isRealData= false;
isCounts= false;
isMCPUreweight = false;
MCPUfile = "";
DataPUfile = "";
MCPUhisto = "";
DataPUhisto = "";
menuTag = "";
preFilterLogicString = "";
versionTag = "";
doPrintAll = true;
doDeterministicPrescale = false;
useNonIntegerPrescales = false;
readRefPrescalesFromNtuple = false;
nonlinearPileupFit = "";
alcaCondition = "";
lumiBinsForPileupFit = 150;
dsList = "";
iLumi = 1.E31;
bunchCrossingTime = 25.0E-09;
maxFilledBunches = 3564;
nFilledBunches = 156;
cmsEnergy = 10.;
lumiSectionLength = 23.3;
lumiScaleFactor = 1.0;
prescaleNormalization = 1;
isL1Menu = false;
doL1preloop = true;
doSelectBranches = false;
selectBranchL1 = true;
selectBranchHLT = true;
selectBranchOpenHLT = true;
selectBranchReco = true;
selectBranchL1extra = true;
selectBranchMC = true;
try
{
/* Load the configuration.. */
cout << "Loading "<<cfgfile;
cfg.readFile(cfgfile);
cout << " ... ok" << endl;
// temporary vars
const char* stmp; float ftmp; bool btmp; int itmp;
/**** General Menu & Run conditions ****/
cfg.lookupValue("run.nEntries",nEntries);
cfg.lookupValue("run.nPrintStatusEvery",nPrintStatusEvery);
cfg.lookupValue("run.isRealData",isRealData);
omenu->SetIsRealData(isRealData);
cfg.lookupValue("run.isCounts",isCounts);
cfg.lookupValue("run.isMCPUreweight",isMCPUreweight);
cfg.lookupValue("run.MCPUfile",stmp); MCPUfile = TString(stmp);
cfg.lookupValue("run.DataPUfile",stmp); DataPUfile = TString(stmp);
cfg.lookupValue("run.MCPUhisto",stmp); MCPUhisto = TString(stmp);
cfg.lookupValue("run.DataPUhisto",stmp); DataPUhisto = TString(stmp);
cfg.lookupValue("run.menuTag",stmp); menuTag = TString(stmp);
cfg.lookupValue("run.versionTag",stmp); versionTag = TString(stmp);
cfg.lookupValue("run.doPrintAll",doPrintAll);
cfg.lookupValue("run.dsList",stmp); dsList= TString(stmp);
cfg.lookupValue("run.doDeterministicPrescale",doDeterministicPrescale);
cfg.lookupValue("run.useNonIntegerPrescales",useNonIntegerPrescales);
cfg.lookupValue("run.readRefPrescalesFromNtuple",readRefPrescalesFromNtuple);
cfg.lookupValue("run.nonlinearPileupFit",stmp); nonlinearPileupFit = TString(stmp);
cfg.lookupValue("run.alcaCondition",stmp); alcaCondition = TString(stmp);
cfg.lookupValue("run.lumiBinsForPileupFit",lumiBinsForPileupFit);
cout << "General Menu & Run conditions...ok"<< endl;
/**********************************/
/**** Beam conditions ****/
cfg.lookupValue("beam.iLumi",iLumi);
cfg.lookupValue("beam.bunchCrossingTime",bunchCrossingTime);
cfg.lookupValue("beam.maxFilledBunches",maxFilledBunches);
cfg.lookupValue("beam.nFilledBunches",nFilledBunches);
cfg.lookupValue("beam.cmsEnergy",cmsEnergy);
cout << "Beam conditions...ok"<< endl;
/**********************************/
/**** Real data conditions ****/
cfg.lookupValue("data.lumiSectionLength",lumiSectionLength);
cfg.lookupValue("data.lumiScaleFactor",lumiScaleFactor);
cfg.lookupValue("data.prescaleNormalization",prescaleNormalization);
getPreFilter();
fillRunBlockList();
cout << "Real data conditions...ok"<< endl;
/******************************/
/**** Samples & Processes ****/
Setting &p = cfg.lookup("process.names");
const int nproc = (const int)p.getLength();
//cout << nproc << endl;
if (nproc > 1) {
cout << "DANGER: at the moment more than one name is not supported. You can change OHltConfig.cpp and OHltRateEff.cpp if you know what you're doing." << endl;
return;
}
Setting &isPS = cfg.lookup("process.isPhysicsSample");
Setting &xs = cfg.lookup("process.sigmas");
Setting &pa = cfg.lookup("process.paths");
Setting &fn = cfg.lookup("process.fnames");
Setting &muc = cfg.lookup("process.doMuonCuts");
Setting &mucfm = cfg.lookup("process.doMuonCutsforMuons");
Setting &ec = cfg.lookup("process.doElecCuts");
const int nfiles = (const int)fn.getLength();
for (int i=0;i<nproc;i++)
{
stmp = p[i];
pnames.push_back(TString(stmp));
itmp = isPS[i];
pisPhysicsSample.push_back(itmp);
stmp = pa[i];
// LA add trailing slash to directories if missing
string ppath = stmp;
string lastChar=ppath.substr(ppath.size()-1);
if (lastChar.compare("/") != 0 ) ppath.append("/");
for (int j=0;j<nfiles;j++)
{
ppaths.push_back(TString(ppath));
//stmp = fn[i];
stmp = fn[j];
pfnames.push_back(TString(stmp));
}
ftmp = xs[i];
psigmas.push_back(ftmp);
btmp = muc[i];
pdomucuts.push_back(btmp);
btmp = mucfm[i];
pdomucutsformuons.push_back(btmp);
btmp = ec[i];
pdoecuts.push_back(btmp);
}
cout << "Samples & Processes...ok"<< endl;
for (int i=0;i<nproc;i++)
{ //RR
printf("Name [%d]: %s\n",i,pnames.at(i).Data());
printf("Path [%d]: %s\n",i,ppaths.at(i).Data());
}
for (int i=0;i<nfiles;i++)
{
printf("File [%d]: %s\n",i,pfnames.at(i).Data());
}
/**********************************/
/**** Branch Selections ****/
// Only for experts:
// Select certain branches to speed up code.
// Modify only if you know what you do!
cfg.lookupValue("branch.doSelectBranches",doSelectBranches);
cfg.lookupValue("branch.selectBranchL1",selectBranchL1);
cfg.lookupValue("branch.selectBranchHLT",selectBranchHLT);
cfg.lookupValue("branch.selectBranchOpenHLT",selectBranchOpenHLT);
cfg.lookupValue("branch.selectBranchL1extra",selectBranchL1extra);
cfg.lookupValue("branch.selectBranchReco",selectBranchReco);
cfg.lookupValue("branch.selectBranchMC",selectBranchMC);
cout << "Branch Selections...ok"<< endl;
/**********************************/
print();
fillMenu(omenu);
printMenu(omenu);
//cout << "Done!" << endl;
}
catch (...)
{
cout << endl << "Reading cfg file "<< cfgfile <<" failed. Exit!" << endl;
}
convert(); // Convert cross-sections to cm^2
}
void OHltConfig::getPreFilter()
{
// Lookup in prefilter in LogicParser String format
// temporary vars
const char* stmp;
try
{
if (cfg.lookupValue("menu.preFilterByBits",stmp))
preFilterLogicString = TString(stmp);
}
catch (...)
{
cout << endl << "No PreFilter String found! " << endl;
}
}
void OHltConfig::fillRunBlockList()
{
// Lookup runLumiblockList, format: (runnr, minLumiBlock, maxLumiBlock)
// temporary vars
int itmp1;
int itmp2;
int itmp3;
try
{
Setting &m = cfg.lookup("data.runLumiblockList");
const int nm = (const int)m.getLength();
for (int i=0;i<nm;i++)
{
TString ss0 = "data.runLumiblockList.["; ss0 +=i; ss0=ss0+"].[0]";
Setting &tt0 = cfg.lookup(ss0.Data());
itmp1 = tt0;
TString ss3 = "data.runLumiblockList.["; ss3 +=i; ss3=ss3+"].[1]";
Setting &tt3 = cfg.lookup(ss3.Data());
itmp2 = tt3;
TString ss1 = "data.runLumiblockList.["; ss1 +=i; ss1=ss1+"].[2]";
Setting &tt1 = cfg.lookup(ss1.Data());
itmp3 = tt1;
vector<int> tmpItem;
tmpItem.push_back(itmp1);
tmpItem.push_back(itmp2);
tmpItem.push_back(itmp3);
runLumiblockList.push_back(tmpItem);
}
}
catch (...)
{
cout << endl << "No runLumiblock list! " << endl;
}
}
void OHltConfig::fillMenu(OHltMenu *omenu)
{
// temporary vars
const char* stmp;
float ftmp;
float itmpfloat;
int itmp;
int refprescaletmp; //bool btmp;
const char* seedstmp;
/**** Menu ****/
cfg.lookupValue("menu.isL1Menu", isL1Menu);
omenu->SetIsL1Menu(isL1Menu);
cfg.lookupValue("menu.doL1preloop", doL1preloop);
omenu->SetDoL1preloop(doL1preloop);
Setting &m = cfg.lookup("menu.triggers");
const int nm = (const int)m.getLength();
//cout << nm << endl;
for (int i=0; i<nm; i++)
{
TString ss0 = "menu.triggers.[";
ss0 +=i;
ss0=ss0+"].[0]";
Setting &tt0 = cfg.lookup(ss0.Data());
stmp = tt0;
//cout << "Trigger: " << stmp << endl;
if (isL1Menu)
{
TString ss1 = "menu.triggers.[";
ss1 +=i;
ss1=ss1+"].[1]";
Setting &tt1 = cfg.lookup(ss1.Data());
if (useNonIntegerPrescales == true)
itmpfloat = tt1;
else
itmp = tt1;
//cout << itmp << endl;
TString ss2 = "menu.triggers.[";
ss2 +=i;
ss2=ss2+"].[2]";
Setting &tt2 = cfg.lookup(ss2.Data());
ftmp = tt2;
//cout << ftmp << endl;
if (useNonIntegerPrescales == true)
omenu->AddTrigger(stmp, itmpfloat, ftmp);
else
omenu->AddTrigger(stmp, itmp, ftmp);
omenu->AddL1forPreLoop(stmp, itmp);
}
else
{
TString ss3 = "menu.triggers.[";
ss3 +=i;
ss3=ss3+"].[1]";
Setting &tt3 = cfg.lookup(ss3.Data());
seedstmp = tt3;
//cout << "Seed: " << seedstmp << endl;
TString ss1 = "menu.triggers.[";
ss1 +=i;
ss1=ss1+"].[2]";
Setting &tt1 = cfg.lookup(ss1.Data());
if (useNonIntegerPrescales == true)
itmpfloat = tt1;
else
itmp = tt1;
//cout << "Prescale: "<< itmp << endl;
TString ss2 = "menu.triggers.[";
ss2 +=i;
ss2=ss2+"].[3]";
Setting &tt2 = cfg.lookup(ss2.Data());
ftmp = tt2;
//cout << "SampleSize: "<< ftmp << endl;
// JH - testing reference prescale
refprescaletmp = 1;
TString ss4 = "menu.triggers.[";
ss4 +=i;
ss4=ss4+"].[4]";
if (cfg.exists(ss4.Data()))
{
Setting &tt4 = cfg.lookup(ss4.Data());
refprescaletmp = tt4;
}
else
{
refprescaletmp = 1;
}
if (useNonIntegerPrescales == true)
omenu->AddTrigger(stmp, seedstmp, itmpfloat, ftmp, refprescaletmp);
else
omenu->AddTrigger(stmp, seedstmp, itmp, ftmp, refprescaletmp);
}
}
if (!isL1Menu)
{
Setting &lm = cfg.lookup("menu.L1triggers");
const int lnm = (const int)lm.getLength();
//cout << lnm << endl;
for (int i=0; i<lnm; i++)
{
TString ss0 = "menu.L1triggers.[";
ss0 +=i;
ss0=ss0+"].[0]";
Setting &tt0 = cfg.lookup(ss0.Data());
stmp = tt0;
//cout << stmp << endl;
if (doL1preloop)
{
TString ss1 = "menu.L1triggers.[";
ss1 +=i;
ss1=ss1+"].[1]";
Setting &tt1 = cfg.lookup(ss1.Data());
if (useNonIntegerPrescales == true)
itmpfloat = tt1;
else
itmp = tt1;
}
else
{
itmp = 1;
}
if (useNonIntegerPrescales == true)
omenu->AddL1forPreLoop(stmp, itmpfloat);
else
omenu->AddL1forPreLoop(stmp, itmp);
}
}
/**********************************/
}
void OHltConfig::print()
{
cout << "---------------------------------------------" << endl;
cout << "Configuration settings: " << endl;
cout << "---------------------------------------------" << endl;
cout << "nEntries: " << nEntries << endl;
cout << "nPrintStatusEvery: " << nPrintStatusEvery << endl;
cout << "menuTag: " << menuTag << endl;
cout << "versionTag: " << versionTag << endl;
cout << "isRealData: " << isRealData << endl;
if (isRealData == true)
{
cout << "Time of one LumiSection: " << lumiSectionLength << endl;
if (fabs(lumiScaleFactor-1.) > 0.001)
cout << "Luminosity scaled by: " << lumiScaleFactor << endl;
cout << "PD prescale factor: " << prescaleNormalization << endl;
}
cout << "isCounts: " << isCounts << endl;
cout << "isMCPUreweight: " << isMCPUreweight << endl;
if (isMCPUreweight == true)
{
cout << "MCPUfile: " << MCPUfile << endl;
cout << "DataPUfile: " << DataPUfile << endl;
}
cout << "doPrintAll: " << doPrintAll << endl;
cout << "doDeterministicPrescale: " << doDeterministicPrescale << endl;
cout << "useNonIntegerPrescales: " << useNonIntegerPrescales << endl;
cout << "readRefPrescalesFromNtuple: " << readRefPrescalesFromNtuple << endl;
cout << "nonlinearPileupFit: " << nonlinearPileupFit << endl;
cout << "lumiBinsForPileupFit: " << lumiBinsForPileupFit << endl;
cout << "preFilterLogicString: " << preFilterLogicString << endl;
cout << "---------------------------------------------" << endl;
cout << "iLumi: " << iLumi << endl;
cout << "bunchCrossingTime: " << bunchCrossingTime << endl;
cout << "maxFilledBunches: " << maxFilledBunches << endl;
cout << "nFilledBunches: " << nFilledBunches << endl;
cout << "cmsEnergy: " << cmsEnergy << endl;
cout << "---------------------------------------------" << endl;
cout << "doSelectBranches: " << doSelectBranches << endl;
cout << "selectBranchL1: " << selectBranchL1 << endl;
cout << "selectBranchHLT: " << selectBranchHLT << endl;
cout << "selectBranchOpenHLT: " << selectBranchOpenHLT << endl;
cout << "selectBranchL1extra: " << selectBranchL1extra << endl;
cout << "selectBranchReco: " << selectBranchReco << endl;
cout << "selectBranchMC: " << selectBranchMC << endl;
cout << "---------------------------------------------" << endl;
cout << endl;
cout << "Number of Samples: "<<pnames.size()<< endl;
cout << "**********************************" << endl;
for (unsigned int i=0; i<pnames.size(); i++)
{
cout << "pnames["<<i<<"]: " << pnames[i] << endl;
cout << "ppaths["<<i<<"]: " << ppaths[i] << endl;
cout << "psigmas["<<i<<"]: " << psigmas[i] << endl;
cout << "pdomucuts["<<i<<"]: " << pdomucuts[i] << endl;
cout << "pdomucutsformuons["<<i<<"]: " << pdomucutsformuons[i] << endl;
cout << "pdoecuts["<<i<<"]: " << pdoecuts[i] << endl;
cout << endl;
}
for (unsigned int i=0; i<pfnames.size(); i++)
{
cout << "pfnames["<<i<<"]: " << pfnames[i] << endl;
}
cout << "**********************************" << endl;
unsigned int nrunLumiList = runLumiblockList.size();
if (nrunLumiList>0)
{
cout << endl;
cout << "List of (runNo, minLumiblockID, maxLumiblockID) "<< endl;
cout << "**********************************" << endl;
for (unsigned int i=0; i<nrunLumiList; i++)
{
cout<<runLumiblockList[i][0]<< ", " << runLumiblockList[i][1]<< ", "
<< runLumiblockList[i][2]<<endl;
}
cout << "**********************************" << endl;
}
cout << "---------------------------------------------" << endl;
}
void OHltConfig::printMenu(OHltMenu *omenu)
{
omenu->print();
}
void OHltConfig::convert()
{
// Convert cross-sections to cm^2
for (unsigned int i = 0; i < psigmas.size(); i++)
{
psigmas[i] *= 1.E-36;
}
}