293 :
294 m_runEigenVectorMethod(
false), m_EVStrategy(
SFEigen), m_useRecommendedEVExclusions(
false), m_verbose(
true),
295 m_absEtaStrategy(GiveUp), m_otherStrategy(Flag)
296{
297
298
299
300
301
302
303 m_taggerName = taggerName;
304
306 env.ReadFile(configname.c_str(),kEnvGlobal);
307
308
309
310 TString
filename =
env.GetValue(
"File",
"BTaggingPerformanceCalibrations.root");
311 m_filenameEff = string(
env.GetValue(
"FileEff",
""));
trim(m_filenameEff);
312 m_filenameSF = string(
env.GetValue(
"FileSF",
""));
trim(m_filenameSF);
313 if (m_filenameEff == "") {
314 m_filenameEff = pathname +
filename.Data();
315 }
316 if (m_filenameSF == "") {
317 m_filenameSF = pathname +
filename.Data();
318 }
319
320 if (m_verbose) {
321 cout << "=== CalibrationDataInterfaceROOT::CalibrationDataInterfaceROOT ===" << endl;
322 cout << " Config name : " << configname << endl;
323 cout << " taggerName : " << taggerName << endl;
324 cout << " Efficiency file name : " << m_filenameEff << endl
325 << " SF file name : " << m_filenameSF << endl;
326 }
327
328 m_fileEff = TFile::Open(m_filenameEff.c_str(), "READ");
329 if (m_filenameEff == m_filenameSF)
330 m_fileSF = m_fileEff;
331 else
332 m_fileSF = TFile::Open(m_filenameSF.c_str(), "READ");
333
334 if (m_verbose) {
336 m_fileSF->GetObject("VersionInfo/BuildNumber", s);
337 if (s) cout <<
" CDI file build number: " <<
s->GetName() << endl;
338 cout << endl;
339 }
340
341 m_flavours = { "B", "C", "T", "Light" };
342 string testPrefix(taggerName); testPrefix += ".";
343
344
345
346
347 string::size_type
end;
348
349
350 std::map<string, std::vector<string> > effNames;
351 for (auto const& flavour : m_flavours) {
352 string test(testPrefix);
test +=
"EfficiencyCalibration";
test += flavour;
test +=
"Name";
353 effNames[flavour] =
split(
string(
env.GetValue(
test.c_str(),
"default")));
354 }
355 setEffCalibrationNames(effNames);
356
357
358 std::map<string, string> SFNames;
359 for (auto const& flavour : m_flavours) {
360 string test(testPrefix);
test +=
"ScaleFactorCalibration";
test += flavour;
test +=
"Name";
361 SFNames[flavour] = string(
env.GetValue(
test.c_str(),
"default"));
trim(SFNames[flavour]);
362 }
363 setSFCalibrationNames(SFNames);
364
365
366
367
368
369 string AL(
env.GetValue(
"aliases",
""));
370 if (AL.size() > 0) {
371 do {
373 string alias = AL.substr(0, end);
374
375
376
377 string::size_type arrow =
alias.find(
"->");
378 if (arrow == string::npos) continue;
381 if (end != string::npos) AL = AL.substr(end+1);
382 } while (end != string::npos);
383 }
384
385
386 string test=
"runEigenVectorMethod";
387 m_runEigenVectorMethod=(
bool)
env.GetValue(
test.c_str(),0);
388
389 if (m_runEigenVectorMethod) {
390
391
392
393
394 test =
"excludeFromCovMatrix";
395 std::vector<std::string> to_exclude =
split(
env.GetValue(
test.c_str(),
""));
396
397 for (auto const& flavour : m_flavours) {
398 m_excludeFromCovMatrix[flavour] = to_exclude;
399 }
400 for (auto const& flavour : m_flavours) {
401 test =
"excludeFrom";
test += flavour;
test +=
"CovMatrix";
403
404 m_excludeFromCovMatrix[flavour].insert(m_excludeFromCovMatrix[flavour].
end(), to_exclude.begin(), to_exclude.end());
405 }
406
407 unsigned int n_excluded = 0;
408 for (auto const& flavour : m_flavours) {
409 n_excluded += m_excludeFromCovMatrix[flavour].size();
410 }
411 if (m_verbose) {
412 cout << " List of uncertainties to exclude:";
413 if (n_excluded == 0) cout << " none";
414 for (auto const& flavour : m_flavours) {
415 if (m_excludeFromCovMatrix[flavour].
size() > 0) {
416 cout << "\n\t" << flavour << ":\t";
417 for (
unsigned int i = 0;
i < m_excludeFromCovMatrix[flavour].size(); ++
i) {
418 cout << m_excludeFromCovMatrix[flavour].at(i);
419 if (i+1 == m_excludeFromCovMatrix[flavour].
size()) cout <<
"; ";
420 }
421 cout << endl;
422 }
423 }
424 cout << endl;
425 }
426
427
428
429 m_useRecommendedEVExclusions = (
bool)
env.GetValue(
"ExcludeRecommendedFromEigenVectorTreatment",
false);
430
431
432 std::map<string, EVReductionStrategy> mappings;
433 mappings[
"Loose"] =
Loose;
434 mappings[
"Medium"] =
Medium;
435 mappings[
"Tight"] =
Tight;
436 for (auto const& flavour : m_flavours) {
437 test = testPrefix;
test +=
"EigenvectorReduction";
test += flavour;
438 std::string reduction = string(
env.GetValue(
test.c_str(),
"Loose"));
trim(reduction);
439 m_EVReductions[flavour] = mappings.find(reduction) == mappings.end() ? mappings["Loose"] : mappings.find(reduction)->second;
440 }
441 }
442
443
444 m_maxAbsEta =
env.GetValue(
"MaxAbsEta", 2.5);
445 if (m_maxAbsEta < 0) m_maxAbsEta = 2.5;
446
447
448 string strategy = string(
env.GetValue(
"OutOfBoundsEta",
"GiveUp"));
trim(strategy);
449 if (strategy ==
"GiveUp") m_absEtaStrategy =
GiveUp;
450 else if (strategy ==
"Flag") m_absEtaStrategy =
Flag;
451 else if (strategy ==
"Ignore") m_absEtaStrategy =
Ignore;
452 else {
453 cerr <<
"unknown |eta| extrapolation strategy: " <<
strategy <<
", setting to GiveUp" << endl;
454 m_absEtaStrategy =
GiveUp;
455 }
456
457
458 strategy = string(
env.GetValue(
"OutOfBoundsOther",
"Flag"));
trim(strategy);
459 if (strategy ==
"GiveUp") m_otherStrategy =
GiveUp;
461 else if (strategy ==
"Flag") m_otherStrategy =
Flag;
462 else if (strategy ==
"Ignore") m_otherStrategy =
Ignore;
463 else {
464 cerr <<
"unknown general extrapolation strategy: " <<
strategy <<
", setting to Flag" << endl;
465 m_otherStrategy =
Flag;
466 }
467
468
469 m_maxTagWeight =
env.GetValue(
"MaxTagWeight", 10.0);
470
471
472 m_useMCMCSF = (
bool)
env.GetValue(
"useMCMCSF", 1);
473
474 m_useTopologyRescaling = (
bool)
env.GetValue(
"useTopologySF", 0);
475
476 if (m_verbose) cout << "======= end of CalibrationDataInterfaceROOT instantiation ========" << endl;
477}
std::vector< std::string > split(const std::string &str, const char token=';')
local utility function: split string into a vector of substrings separated by a specified separator,...
setBGCode setTAP setLVL2ErrorBits bool