57{
58
59AsgElectronEfficiencyCorrectionTool::AsgElectronEfficiencyCorrectionTool(
60 const std::string& myname)
61 :
asg::AsgMetadataTool(myname)
62 , m_affectedSys()
63 , m_appliedSystematics(nullptr)
65 , m_sysSubstring("")
67 , m_nCorrSyst(0)
68 , m_nUncorrSyst(0)
69 , m_UncorrRegions(nullptr)
70 , m_nSimpleUncorrSyst(0)
71 , m_toysBasename{}
72 , m_corrVarUp{}
73 , m_corrVarDown{}
74 , m_uncorrVarUp{}
75 , m_uncorrVarDown{}
76 , m_accessors{
std::make_unique<Accessors>(*this)}
77{
78
79 m_rootTool = std::make_unique<Root::TElectronEfficiencyCorrectionTool>(
80 (
"T" + (this->
name())).c_str());
81
82 declareProperty(
83 "CorrectionFileNameList",
84 m_corrFileNameList,
85 "List of file names that store the correction factors for simulation.");
86 declareProperty("MapFilePath",
87 m_mapFile = "ElectronEfficiencyCorrection/2015_2025/rel22.2/2026_Run2Run3_Recommendation_v3/map1.txt",
88 "Full path to the map file");
89 declareProperty(
90 "RecoKey", m_recoKey = "", "Key associated with reconstruction");
91 declareProperty(
92 "IdKey", m_idKey = "", "Key associated with identification working point");
93 declareProperty(
94 "IsoKey", m_isoKey = "", "Key associated with isolation working point");
95 declareProperty(
96 "TriggerKey", m_trigKey = "", "Key associated with trigger working point");
97 declareProperty("ForceDataType",
98 m_dataTypeOverwrite = -1,
99 "Force the DataType of the electron to specified value (to "
100 "circumvent problem of incorrect DataType for forward "
101 "electrons in some old releases)");
102 declareProperty(
103 "ResultPrefix", m_resultPrefix = "", "The prefix string for the result");
104 declareProperty("ResultName", m_resultName = "", "The string for the result");
105 declareProperty("CorrelationModel",
106 m_correlation_model_name = "SIMPLIFIED",
107 "Uncertainty correlation model. At the moment TOTAL, FULL, "
108 "SIMPLIFIED, SYST, MCTOYS and COMBMCTOYS are implemented. "
109 "SIMPLIFIED is the default option.");
110 declareProperty("NumberOfToys",
111 m_number_of_toys = 100,
112 "Number of ToyMC replica, affecting MCTOYS and COMBMCTOYS "
113 "correlation models only.");
114 declareProperty("MCToySeed",
115 m_seed_toys = 0,
116 "Seed for ToyMC replica, affecting MCTOYS and COMBMCTOYS "
117 "correlation models only.");
118 declareProperty("MCToyScale",
119 m_scale_toys = 1,
120 "Scales Toy systematics up by this factor, affecting MCTOYS "
121 "and COMBMCTOYS correlation models only.");
122 declareProperty(
123 "UncorrEtaBinsUser",
124 m_uncorrSimplfEtaBinsUser = { 0.0, 1.37, 4.9 },
125 "Custom Eta/Pt binning for the SIMPLIFIED correlation model.");
126 declareProperty(
127 "UncorrEtBinsUser",
128 m_uncorrSimplfEtBinsUser = { 4000,
129 7000,
130 10000,
131 15000,
132 20000,
133 25000,
134 30000,
135 60000,
136 80000,
137 13600000 },
138 "Custom Eta/Pt binning for the SIMPLIFIED correlation model.");
139 declareProperty("EventInfoCollectionName",
140 m_eventInfoCollectionName = "EventInfo",
141 "The EventInfo Collection Name");
142 declareProperty("UseRandomRunNumber", m_useRandomRunNumber = true);
143 declareProperty("DefaultRandomRunNumber", m_defaultRandomRunNumber = 999999);
144}
145
146AsgElectronEfficiencyCorrectionTool::~AsgElectronEfficiencyCorrectionTool()
147{
148 if (m_UncorrRegions) {
149 delete m_UncorrRegions;
150 }
151}
152
154AsgElectronEfficiencyCorrectionTool::initialize()
155{
156
157 m_rootTool->msg().setLevel(this->
msg().
level());
158
159 if (m_corrFileNameList.empty() && m_recoKey.empty() && m_idKey.empty() &&
160 m_trigKey.empty() && m_isoKey.empty()) {
161 ATH_MSG_ERROR(
"CorrectionFileNameList as well as SFKeys are empty! Please "
162 "configure it properly...");
163 return StatusCode::FAILURE;
164 }
165
166
167
168
169
170
171
172 if (m_dataTypeOverwrite != -1) {
173 if (m_dataTypeOverwrite !=
175 m_dataTypeOverwrite !=
178 << m_dataTypeOverwrite);
179 return StatusCode::FAILURE;
180 }
181 m_dataType =
183 }
184
185
186
187 if (m_corrFileNameList.empty()) {
188 if (getFile(m_recoKey, m_idKey, m_isoKey, m_trigKey).isFailure()) {
189 ATH_MSG_ERROR(
"No Root file input specified, and not available map file");
190 return StatusCode::FAILURE;
191 }
192 }
193
194
195 for (auto& ifile : m_corrFileNameList) {
196
200 return StatusCode::FAILURE;
201 } else {
203 }
204 m_rootTool->addFileName(filename);
205
206
207 if (
ifile.find(
"efficiencySF.") != std::string::npos) {
208 m_sysSubstring = "Trigger_";
209 }
210 if (
ifile.find(
"efficiencySF.offline") != std::string::npos) {
211 m_sysSubstring = "ID_";
212 }
213 if (
ifile.find(
"efficiencySF.offline.RecoTrk") != std::string::npos) {
214 m_sysSubstring = "Reco_";
215 }
216 if (
ifile.find(
"efficiencySF.offline.Fwd") != std::string::npos) {
217 m_sysSubstring = "FwdID_";
218 }
219 if (
ifile.find(
"efficiencySF.Isolation") != std::string::npos ||
ifile.find(
"efficiencySF.isolation") != std::string::npos) {
220 m_sysSubstring = "Iso_";
221 }
222 if (
ifile.find(
"efficiency.") != std::string::npos) {
223 m_sysSubstring = "TriggerEff_";
224 }
225 if (
ifile.find(
"efficiencySF.ChargeID") != std::string::npos) {
226 m_sysSubstring = "ChargeIDSel_";
227 }
228 if (m_sysSubstring.empty()) {
229 ATH_MSG_ERROR(
"Could NOT find systematics Substring file name "
230 << m_sysSubstring);
231 return StatusCode::FAILURE;
232 }
233 }
234
235
236 if (m_correlation_model_name == "COMBMCTOYS") {
238 } else if (m_correlation_model_name == "MCTOYS") {
240 } else if (m_correlation_model_name == "FULL") {
242 } else if (m_correlation_model_name == "SIMPLIFIED") {
244
245 if (m_uncorrSimplfEtaBinsUser.empty() || m_uncorrSimplfEtBinsUser.empty() ||
246 m_uncorrSimplfEtBinsUser.size() < 2 ||
247 m_uncorrSimplfEtaBinsUser.size() < 2) {
248 ATH_MSG_ERROR(
"Something went wrong when specifying bins for the "
249 "SIMPLIFIED correlation model ");
250 return StatusCode::FAILURE;
251 }
252 } else if (m_correlation_model_name == "TOTAL") {
254 } else if (m_correlation_model_name == "SYST") {
256 } else {
257 ATH_MSG_ERROR(
"Unknown correlation model " + m_correlation_model_name);
258 return StatusCode::FAILURE;
259 }
260 ATH_MSG_DEBUG(
"Correlation model: " + m_correlation_model_name
261 << " Enum " << m_correlation_model);
262
263
265 m_UncorrRegions =
new TH2F(
"UncorrRegions",
266 "UncorrRegions",
267 m_uncorrSimplfEtBinsUser.size() - 1,
268 &(m_uncorrSimplfEtBinsUser[0]),
269 m_uncorrSimplfEtaBinsUser.size() - 1,
270 &(m_uncorrSimplfEtaBinsUser[0]));
271 m_UncorrRegions->SetDirectory(nullptr);
272
273
274 m_nSimpleUncorrSyst = (m_uncorrSimplfEtaBinsUser.size() - 1) *
275 (m_uncorrSimplfEtBinsUser.size() - 1);
276 }
277
278 if (m_seed_toys != 0) {
279 m_rootTool->setSeed(m_seed_toys);
280 }
281
283 m_rootTool->bookCombToyMCScaleFactors(m_number_of_toys);
284 }
285
287 m_rootTool->bookToyMCScaleFactors(m_number_of_toys);
288 }
289
290 if (0 == m_rootTool->initialize()) {
292 "Could not initialize the TElectronEfficiencyCorrectionTool!");
293 return StatusCode::FAILURE;
294 }
295
296
297 m_nCorrSyst = m_rootTool->getNSyst();
298 std::map<float, std::vector<float>>
tmp;
299 m_nUncorrSyst = m_rootTool->getNbins(tmp);
300
301 for (const auto& i : tmp) {
302 m_pteta_bins.emplace_back(
i.first,
i.second);
303 }
304
305
306
308 m_rootTool->uncorrEmpty(m_dataType) ) {
309 ATH_MSG_ERROR(
"Called correlation model "+m_correlation_model_name+
310 " but input does not contain necessary histograms.");
311 return StatusCode::FAILURE;
312 }
313
314
315 if (InitSystematics() != StatusCode::SUCCESS) {
317 return StatusCode::FAILURE;
318 }
319
320 if (registerSystematics() != StatusCode::SUCCESS) {
321 ATH_MSG_ERROR(
"(registerSystematics() != StatusCode::SUCCESS)");
322 return StatusCode::FAILURE;
323 }
324
327 return StatusCode::FAILURE;
328 }
329
330 if (m_useRandomRunNumber) {
331 resetAccessor (m_accessors->randomrunnumber, *
this,
"RandomRunNumber");
332 }
334 return StatusCode::SUCCESS;
335}
336
338AsgElectronEfficiencyCorrectionTool::getEfficiencyScaleFactor(
340 double& efficiencyScaleFactor) const
341{
343 if (evtStore()->retrieve(eventInfo, m_eventInfoCollectionName).isFailure()) {
346 }
348}
349
351AsgElectronEfficiencyCorrectionTool::getEfficiencyScaleFactor(
353 double& efficiencyScaleFactor,
355{
356 const Accessors&
acc = *m_accessors;
357
358 efficiencyScaleFactor = 1;
359
360 unsigned int runNumber = m_defaultRandomRunNumber;
361 if (m_useRandomRunNumber) {
362 if (!
acc.randomrunnumber.isAvailable(eventInfo)) {
364 "Pileup tool not run before using ElectronEfficiencyTool! SFs do not "
365 "reflect PU distribution in data");
367 }
369 }
370
371
372
373 double cluster_eta(-9999.9);
374
375 auto cluster =
acc.caloClusterAcc (inputObject) [0].value();
376
377
378 if (
acc.accAuthor.isAvailable(inputObject) &&
380 cluster_eta =
acc.clusterEtaAcc (cluster);
381 } else {
382 cluster_eta =
acc.clusterEtaBEAcc (cluster, 2);
383 }
384
385
386
387 const double energy =
acc.clusterEAcc(cluster);
388 const double parEta =
acc.m_eta(inputObject);
389 const double coshEta = std::cosh(parEta);
390 double et = (coshEta != 0.) ? energy / coshEta : 0.;
391
392
393
394 auto itr_pt = m_pteta_bins.begin();
397 }
398 return getEfficiencyScaleFactor(
et, cluster_eta, runNumber,
399 efficiencyScaleFactor);
400}
401
403AsgElectronEfficiencyCorrectionTool::getEfficiencyScaleFactor(
405 const double cluster_eta,
406 const unsigned int runNumber,
407 double& efficiencyScaleFactor) const
408{
409
410
411
412
414
415
416 bool doSFOnly = appliedSystematics().empty();
422
423
424 int unCorrSign = 0;
425
426 int indexCorrelated = -999;
427 int correlatedSign = 0;
428 if (!(doSFOnly || doToys || isTotal) && (isFull || isSimplified)) {
429 const auto&
sysName = appliedSystematics().begin()->name();
430 bool isUncorr = (
sysName.find(
"UncorrUnc") != std::string::npos);
431 int currentUncorReg = -999;
432 if (isUncorr) {
433
434 if (isFull) {
435 currentUncorReg = currentUncorrSystRegion(cluster_eta,
et);
436 } else if (isSimplified) {
437 currentUncorReg = currentSimplifiedUncorrSystRegion(cluster_eta,
et);
438 }
439 if (currentUncorReg < 0) {
441 }
442
443 if (appliedSystematics().matchSystematic(
444 m_uncorrVarDown[currentUncorReg])) {
445 unCorrSign = -1;
446 } else if (appliedSystematics().matchSystematic(
447 m_uncorrVarUp[currentUncorReg])) {
448 unCorrSign = 1;
449 }
450 } else if (m_nCorrSyst != 0) {
451 if (
sysName.find(
"CorrUnc") != std::string::npos) {
452
453 const auto varNumEnd =
sysName.rfind(
"__");
454 const auto varNumBegin =
sysName.rfind(
"NP") + 2;
455 const int varIndex =
456 std::stoi(
sysName.substr(varNumBegin, (varNumEnd - varNumBegin)));
457 if (appliedSystematics().matchSystematic(m_corrVarUp[varIndex])) {
458 indexCorrelated = varIndex;
459 correlatedSign = 1;
460 } else if (appliedSystematics().matchSystematic(
461 m_corrVarDown[varIndex])) {
462 indexCorrelated = varIndex;
463 correlatedSign = -1;
464 }
465 }
466 }
467 }
468
469
470
471
472
475 m_rootTool->calculate(m_dataType, runNumber, cluster_eta,
et,
476 result, isTotal);
477
478
479 if (!status) {
480 efficiencyScaleFactor = 1;
482 }
483
484 efficiencyScaleFactor =
result.SF;
485
486 if (doSFOnly) {
488 }
489
490
491 if (doToys) {
492 auto toy = appliedSystematics().getToyVariationByBaseName(m_toysBasename);
493 toy.second = m_scale_toys;
494 sys =
result.toys[toy.first - 1] * m_scale_toys;
495
496 efficiencyScaleFactor =
sys;
498 }
499
500 else if (isTotal) {
502 if (appliedSystematics().matchSystematic(m_uncorrVarUp[0])) {
503 return HelperFunc(efficiencyScaleFactor, sys);
504 }
505 if (appliedSystematics().matchSystematic(m_uncorrVarDown[0])) {
506 return HelperFunc(efficiencyScaleFactor, -1 * sys);
507 }
508 }
509
510 else if (unCorrSign!=0) {
512 return HelperFunc(efficiencyScaleFactor, sys);
513 }
514
515
516
517
518
519 if (m_nCorrSyst == 0) {
520
521 if (appliedSystematics().matchSystematic(m_corrVarUp[0])) {
524
525 return HelperFunc(efficiencyScaleFactor, sys);
526 }
527 if (appliedSystematics().matchSystematic(m_corrVarDown[0])) {
530
531 return HelperFunc(efficiencyScaleFactor, sys);
532 }
533 }
534
535 if (correlatedSign != 0) {
536 sys = correlatedSign *
result.Corr[indexCorrelated];
537 return HelperFunc(efficiencyScaleFactor, sys);
538 }
540}
541
543AsgElectronEfficiencyCorrectionTool::applyEfficiencyScaleFactor(
545{
546 double efficiencyScaleFactor = 1.0;
548 getEfficiencyScaleFactor(inputObject, efficiencyScaleFactor);
550 m_resultName + "SF");
551 dec(inputObject) = efficiencyScaleFactor;
553}
554
555
556
557
559bool
560AsgElectronEfficiencyCorrectionTool::isAffectedBySystematic(
562{
563 if (systematic.
empty()) {
564 return false;
565 }
569 return (
sys.begin()->ensembleContains(systematic));
570 } else {
571 return (
sys.find(systematic) !=
sys.end());
572 }
573}
576AsgElectronEfficiencyCorrectionTool::affectingSystematics() const
577{
578 return m_affectedSys;
579}
580
581
583AsgElectronEfficiencyCorrectionTool::registerSystematics()
584{
586
587 if (
registry.registerSystematics(*
this) != StatusCode::SUCCESS) {
589 "Failed to add systematic to list of recommended systematics.");
590 return StatusCode::FAILURE;
591 }
592 return StatusCode::SUCCESS;
593}
596AsgElectronEfficiencyCorrectionTool::recommendedSystematics() const
597{
598 return affectingSystematics();
599}
602AsgElectronEfficiencyCorrectionTool::applySystematicVariation(
604{
605
606 auto itr = m_systFilter.find(systConfig);
607
608 if (itr != m_systFilter.end()) {
610 m_appliedSystematics = &mySysConf;
611 }
612
613 else {
614
618 systConfig, affectingSys, filteredSys)) {
620 "Unsupported combination of systematic variations passed to the tool!");
621 return StatusCode::FAILURE;
622 }
623
624 if (filteredSys.
size() > 1) {
626 "More than one systematic variation passed at the same time");
627 return StatusCode::FAILURE;
628 }
629
630 if (filteredSys.
empty() && !systConfig.
empty()) {
632 for (const auto& syst : systConfig) {
634 }
636 }
637
638 itr = m_systFilter.
insert(std::make_pair(systConfig, filteredSys)).first;
639
641 m_appliedSystematics = &mySysConf;
642 }
643 return StatusCode::SUCCESS;
644}
645
646
647
648
650AsgElectronEfficiencyCorrectionTool::InitSystematics()
651{
652 const std::string
prefix =
"EL_EFF_" + m_sysSubstring;
653 const std::string prefixUncorr =
prefix + m_correlation_model_name +
"_";
654
656 m_toysBasename =
prefix +
"COMBMCTOY";
657 m_affectedSys.insert(
660 m_toysBasename =
prefix +
"MCTOY";
661 m_affectedSys.insert(
663
665 if (m_nCorrSyst == 0) {
668 m_corrVarUp.push_back(varUp);
669 m_corrVarDown.push_back(varDown);
670 m_affectedSys.insert(varUp);
671 m_affectedSys.insert(varDown);
672 } else
673 for (
int i = 0;
i < m_nCorrSyst; ++
i) {
674 auto varUp =
676 auto varDown =
678 m_corrVarUp.push_back(varUp);
679 m_corrVarDown.push_back(varDown);
680 m_affectedSys.insert(varUp);
681 m_affectedSys.insert(varDown);
682 }
683 }
684
687 auto varDown =
689 m_uncorrVarUp.push_back(varUp);
690 m_uncorrVarDown.push_back(varDown);
691 m_affectedSys.insert(varUp);
692 m_affectedSys.insert(varDown);
694 for (
int i = 0;
i < m_nUncorrSyst; ++
i) {
696 prefixUncorr + Form("UncorrUncertaintyNP%d", i), 1);
698 prefixUncorr + Form("UncorrUncertaintyNP%d", i), -1);
699 m_uncorrVarUp.push_back(varUp);
700 m_uncorrVarDown.push_back(varDown);
701 m_affectedSys.insert(varUp);
702 m_affectedSys.insert(varDown);
703 }
705 for (
int i = 0;
i < m_nSimpleUncorrSyst; ++
i) {
707 prefixUncorr + Form("UncorrUncertaintyNP%d", i), 1);
709 prefixUncorr + Form("UncorrUncertaintyNP%d", i), -1);
710 m_uncorrVarUp.push_back(varUp);
711 m_uncorrVarDown.push_back(varDown);
712 m_affectedSys.insert(varUp);
713 m_affectedSys.insert(varDown);
714 }
715 }
716 return StatusCode::SUCCESS;
717}
718
719int
720AsgElectronEfficiencyCorrectionTool::currentSimplifiedUncorrSystRegion(
721 const double cluster_eta,
722 const double et)
const
723{
724 int ptbin = std::as_const(*m_UncorrRegions).GetXaxis()->FindBin(
et) - 1;
725 if (ptbin < 0 ||
726 ptbin >= std::as_const(*m_UncorrRegions).GetXaxis()->GetNbins()) {
728 " Found electron with Et = "
729 <<
et / 1000. <<
" GeV, where you specified boundaries of ["
730 << std::as_const(*m_UncorrRegions).GetXaxis()->GetBinLowEdge(1) << ","
731 << std::as_const(*m_UncorrRegions)
732 .GetXaxis()
733 ->GetBinUpEdge(
734 std::as_const(*m_UncorrRegions).GetXaxis()->GetNbins())
735 << "] for the SIMPLIFIED correlation model ");
736 return -1;
737 }
738 int etabin =
739 std::as_const(*m_UncorrRegions).GetYaxis()->FindBin(std::abs(cluster_eta)) -
740 1;
741 if (etabin < 0 ||
742 etabin >= std::as_const(*m_UncorrRegions).GetYaxis()->GetNbins()) {
744 " Found electron with |eta| = "
745 << std::abs(cluster_eta) << ", where you specified boundaries of ["
746 << std::as_const(*m_UncorrRegions).GetYaxis()->GetBinLowEdge(1) << ","
747 << std::as_const(*m_UncorrRegions)
748 .GetYaxis()
749 ->GetBinUpEdge(
750 std::as_const(*m_UncorrRegions).GetYaxis()->GetNbins())
751 << "] for the SIMPLIFIED correlation model ");
752 return -1;
753 }
754 int reg = ((etabin)*m_UncorrRegions->GetNbinsX() + ptbin);
756}
757
758int
759AsgElectronEfficiencyCorrectionTool::currentUncorrSystRegion(
760 const double cluster_eta,
761 const double et)
const
762{
763 int etabin = 0;
766 float cluster_eta_electron = 0;
767 auto itr_ptBEGIN = m_pteta_bins.begin();
768 auto itr_ptEND = m_pteta_bins.end();
769 for (; itr_ptBEGIN != itr_ptEND; ++itr_ptBEGIN) {
770 auto itr_ptBEGINplusOne = itr_ptBEGIN;
771 ++itr_ptBEGINplusOne;
772
773
774 if (
et >= itr_ptBEGIN->first &&
776 if ((itr_ptBEGIN->second).at(0) >= 0) {
777 cluster_eta_electron = std::abs(cluster_eta);
778 } else {
779 cluster_eta_electron = (cluster_eta);
780 };
781 for (unsigned int etab = 0; etab < ((itr_ptBEGIN->second).size());
782 ++etab) {
783 unsigned int etabnext = etab + 1;
784
785
786 if ((cluster_eta_electron) >= (itr_ptBEGIN->second).at(etab) &&
787 (etabnext == itr_ptBEGIN->second.size() ||
788 cluster_eta_electron < itr_ptBEGIN->
second.at(etabnext))) {
790 break;
791 }
792
793 etabin++;
794 }
795 }
796 if (found) {
797 break;
798 }
799
800 reg += (itr_ptBEGIN->second).
size();
801 }
802 if (!found) {
804 "returning the maximum index");
805 return m_nCorrSyst;
806 }
809}
810
811int
812AsgElectronEfficiencyCorrectionTool::systUncorrVariationIndex(
814{
816}
817
818int
819AsgElectronEfficiencyCorrectionTool::systUncorrVariationIndex(
821{
822 const Accessors&
acc = *m_accessors;
823 int currentSystRegion = -999;
824 double cluster_eta(-9999.9);
826
827 et =
acc.m_pt(inputObject);
828 const auto cluster =
acc.caloClusterAcc (inputObject) [0].value();
829 cluster_eta =
acc.clusterEtaBEAcc (cluster, 2);
830 switch (m_correlation_model) {
832 currentSystRegion = currentSimplifiedUncorrSystRegion(cluster_eta,
et);
833 break;
834 }
836 currentSystRegion = currentUncorrSystRegion(cluster_eta,
et);
837 break;
838 }
839 default: {
840
841 break;
842 }
843 }
844 return currentSystRegion;
845}
846
849AsgElectronEfficiencyCorrectionTool::getFile(const std::string& recokey,
850 const std::string& idkey,
851 const std::string& isokey,
852 const std::string& trigkey)
853{
854
859
860 if (!
value.empty()) {
861 m_corrFileNameList.push_back(value);
862 } else {
863 if (mapFileName.empty()) {
865 "Map file does not exist, Please set the path and version properly..");
866 } else {
868 "Key "
869 << key
870 << " does not exist in the map file, Please configure it properly..");
871 }
872 return StatusCode::FAILURE;
873 }
874
876 return StatusCode::SUCCESS;
877}
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
902AsgElectronEfficiencyCorrectionTool::beginInputFile()
903{
904
905
906 if (m_dataTypeOverwrite != -1)
907 return StatusCode::SUCCESS;
908
911
912 if (status == StatusCode::SUCCESS) {
913 m_metadata_retrieved = true;
916 ? "data"
918 ? "full simulation"
919 : "fast simulation")));
920
922 if (m_dataTypeOverwrite == -1) {
923 m_dataType = dataType_metadata;
924 } else {
926 "Applying SF corrections to data while they make sense only for MC");
927 }
928 }
929 } else {
930 m_metadata_retrieved = false;
932 }
933 return StatusCode::SUCCESS;
934}
935
937AsgElectronEfficiencyCorrectionTool::beginEvent()
938{
939
940 if (m_dataTypeOverwrite != -1)
941 return StatusCode::SUCCESS;
942 if (m_metadata_retrieved)
943 return StatusCode::SUCCESS;
944
945 m_metadata_retrieved = true;
946 return StatusCode::SUCCESS;
947}
948
950AsgElectronEfficiencyCorrectionTool::get_simType_from_metadata(
952{
953
954#ifndef XAOD_STANDALONE
955
958 "/TagInfo", "project_name", dataType, inputMetaStore()))
959 .isSuccess()) {
960 if (!(dataType == "IS_SIMULATION")) {
963 return StatusCode::SUCCESS;
964 }
965
966 if (dataType == "IS_SIMULATION") {
967 std::string simType("");
969 "SimulationFlavour",
970 simType,
971 inputMetaStore()));
972 std::transform(simType.begin(), simType.end(), simType.begin(), ::toupper);
973 result = (simType.find(
"ATLFAST") == std::string::npos)
976 return StatusCode::SUCCESS;
977 }
978 }
979#endif
980
981
984 ATH_CHECK(inputMetaStore()->retrieve(fmd,
"FileMetaData"));
985
986 std::string simType("");
988 if (!s) {
991 return StatusCode::SUCCESS;
992 } else {
994 std::transform(simType.begin(), simType.end(), simType.begin(), ::toupper);
995 result = (simType.find(
"ATLFAST") == std::string::npos)
998 return StatusCode::SUCCESS;
999 }
1000 } else {
1002 return StatusCode::FAILURE;
1003 }
1004}
1005
1006
1007
1009{
1010 const Accessors&
acc = *m_accessors;
1012 {
1014 switch (getEfficiencyScaleFactor(electron, sf, event).code())
1015 {
1017 acc.m_sfDec(electron) =
sf;
1018 acc.m_validDec(electron) =
true;
1019 break;
1021 acc.m_sfDec(electron) =
sf;
1022 acc.m_validDec(electron) =
false;
1023 break;
1024 default:
1025 throw std::runtime_error("Error in getEfficiencyScaleFactor");
1026 }
1027 }
1028}
1029
1031{
1032 const Accessors&
acc = *m_accessors;
1034 {
1035 auto eventInfo =
acc.m_eventInfo(event);
1036 callSingleEvent (
acc.m_electrons(event), eventInfo);
1037 }
1038}
1039}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_DEBUG(x,...)
#define ATH_MSG_ERROR(x,...)
#define ATH_MSG_WARNING(x,...)
float et(const xAOD::jFexSRJetRoI *j)
std::string PathResolverFindCalibFile(const std::string &logical_file_name)
size_t size() const
Number of registered mappings.
static std::string retrieveMetadata(const std::string &folder, const std::string &key, const ServiceHandle< StoreGateSvc > &inputMetaStore)
method that always returns as a string you can use from, e.g, pyROOT with evt = ROOT....
Return value from object correction CP tools.
@ Error
Some error happened during the object correction.
@ OutOfValidityRange
Input object is out of validity range.
@ Ok
The correction was done successfully.
This module implements the central registry for handling systematic uncertainties with CP tools.
static SystematicRegistry & getInstance()
Get the singleton instance of the registry for the curren thread.
Class to wrap a set of SystematicVariations.
bool empty() const
returns: whether the set is empty
void insert(const SystematicVariation &systematic)
description: insert a systematic into the set
size_t size() const
returns: size of the set
static StatusCode filterForAffectingSystematics(const SystematicSet &systConfig, const SystematicSet &affectingSystematics, SystematicSet &filteredSystematics)
description: filter the systematics for the affected systematics returns: success guarantee: strong f...
bool empty() const
returns: whether this is an empty systematic, i.e.
static SystematicVariation makeToyEnsemble(const std::string &basename)
constructor for toy systematics ensemble
bool contains(const std::string &s, const std::string ®x)
does a string contain the substring
::StatusCode StatusCode
StatusCode definition for legacy code.
std::string getValueByKey(const std::string &mapFile, const std::string &key)
std::string convertToOneKey(const std::string &recokey, const std::string &idkey, const std::string &isokey, const std::string &trigkey)
Information about type of data used to fill particle.
Information about type of data used to fill particle.
SG::Decorator< T, ALLOC > Decorator
Helper class to provide type-safe access to aux data, specialized for JaggedVecElt.
ObjectId< ElectronDef > ElectronId
ObjectRange< EventContextDef > EventContextRange
ObjectId< EventContextDef > EventContextId
ObjectRange< ElectronDef > ElectronRange
ObjectId< EventInfoDef > EventInfoId
void resetAccessor(AccessorTemplate< CI, CT, CAM, CM > &accessor, ColumnarTool< CM > &columnBase, const std::string &name, ColumnAccessorOptions &&options={})
reset a column accessor to point to a new column
TH2F(name, title, nxbins, bins_par2, bins_par3, bins_par4, bins_par5=None, bins_par6=None, path='', **kwargs)
const uint16_t AuthorFwdElectron
Electron reconstructed by the Forward cluster-based algorithm.
EventInfo_v1 EventInfo
Definition of the latest event info version.
FileMetaData_v1 FileMetaData
Declare the latest version of the class.
Electron_v1 Electron
Definition of the current "egamma version".
Extra patterns decribing particle interation process.