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",
"")); m_filenameEff =
trimWhiteSpaces(m_filenameEff);
312 m_filenameSF = string(
env.GetValue(
"FileSF",
"")); m_filenameSF =
trimWhiteSpaces(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"));
363 }
364 setSFCalibrationNames(SFNames);
365
366
367
368
369
370 string AL(
env.GetValue(
"aliases",
""));
371 if (AL.size() > 0) {
372 do {
374 string alias = AL.substr(0, end);
375
376
377
378 string::size_type arrow =
alias.find(
"->");
379 if (arrow == string::npos) continue;
383 if (end != string::npos) AL = AL.substr(end+1);
384 } while (end != string::npos);
385 }
386
387
388 string test=
"runEigenVectorMethod";
389 m_runEigenVectorMethod=(
bool)
env.GetValue(
test.c_str(),0);
390
391 if (m_runEigenVectorMethod) {
392
393
394
395
396 test =
"excludeFromCovMatrix";
397 std::vector<std::string> to_exclude =
split(
env.GetValue(
test.c_str(),
""));
398
399 for (auto const& flavour : m_flavours) {
400 m_excludeFromCovMatrix[flavour] = to_exclude;
401 }
402 for (auto const& flavour : m_flavours) {
403 test =
"excludeFrom";
test += flavour;
test +=
"CovMatrix";
405
406 m_excludeFromCovMatrix[flavour].insert(m_excludeFromCovMatrix[flavour].
end(), to_exclude.begin(), to_exclude.end());
407 }
408
409 unsigned int n_excluded = 0;
410 for (auto const& flavour : m_flavours) {
411 n_excluded += m_excludeFromCovMatrix[flavour].size();
412 }
413 if (m_verbose) {
414 cout << " List of uncertainties to exclude:";
415 if (n_excluded == 0) cout << " none";
416 for (auto const& flavour : m_flavours) {
417 if (m_excludeFromCovMatrix[flavour].
size() > 0) {
418 cout << "\n\t" << flavour << ":\t";
419 for (
unsigned int i = 0;
i < m_excludeFromCovMatrix[flavour].size(); ++
i) {
420 cout << m_excludeFromCovMatrix[flavour].at(i);
421 if (i+1 == m_excludeFromCovMatrix[flavour].
size()) cout <<
"; ";
422 }
423 cout << endl;
424 }
425 }
426 cout << endl;
427 }
428
429
430
431 m_useRecommendedEVExclusions = (
bool)
env.GetValue(
"ExcludeRecommendedFromEigenVectorTreatment",
false);
432
433
434 std::map<string, EVReductionStrategy> mappings;
435 mappings[
"Loose"] =
Loose;
436 mappings[
"Medium"] =
Medium;
437 mappings[
"Tight"] =
Tight;
438 for (auto const& flavour : m_flavours) {
439 test = testPrefix;
test +=
"EigenvectorReduction";
test += flavour;
440 std::string reduction = string(
env.GetValue(
test.c_str(),
"Loose"));
442 m_EVReductions[flavour] = mappings.find(reduction) == mappings.end() ? mappings["Loose"] : mappings.find(reduction)->second;
443 }
444 }
445
446
447 m_maxAbsEta =
env.GetValue(
"MaxAbsEta", 2.5);
448 if (m_maxAbsEta < 0) m_maxAbsEta = 2.5;
449
450
451 string strategy = string(
env.GetValue(
"OutOfBoundsEta",
"GiveUp"));
453 if (strategy ==
"GiveUp") m_absEtaStrategy =
GiveUp;
454 else if (strategy ==
"Flag") m_absEtaStrategy =
Flag;
455 else if (strategy ==
"Ignore") m_absEtaStrategy =
Ignore;
456 else {
457 cerr <<
"unknown |eta| extrapolation strategy: " <<
strategy <<
", setting to GiveUp" << endl;
458 m_absEtaStrategy =
GiveUp;
459 }
460
461
462 strategy = string(
env.GetValue(
"OutOfBoundsOther",
"Flag"));
464 if (strategy ==
"GiveUp") m_otherStrategy =
GiveUp;
466 else if (strategy ==
"Flag") m_otherStrategy =
Flag;
467 else if (strategy ==
"Ignore") m_otherStrategy =
Ignore;
468 else {
469 cerr <<
"unknown general extrapolation strategy: " <<
strategy <<
", setting to Flag" << endl;
470 m_otherStrategy =
Flag;
471 }
472
473
474 m_maxTagWeight =
env.GetValue(
"MaxTagWeight", 10.0);
475
476
477 m_useMCMCSF = (
bool)
env.GetValue(
"useMCMCSF", 1);
478
479 m_useTopologyRescaling = (
bool)
env.GetValue(
"useTopologySF", 0);
480
481 if (m_verbose) cout << "======= end of CalibrationDataInterfaceROOT instantiation ========" << endl;
482}
std::string_view trimWhiteSpaces(std::string_view str) noexcept
Removes all trailing and starting whitespaces from a string.
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,...
size_t size() const
Number of registered mappings.
setBGCode setTAP setLVL2ErrorBits bool