![Logo](../../ATLAS-Logo-Square-Blue-RGB.png) |
ATLAS Offline Software
|
Go to the documentation of this file.
23 #ifndef XAOD_STANDALONE
37 HelperFunc(
double&
sf,
const double input)
55 AsgElectronEfficiencyCorrectionTool::AsgElectronEfficiencyCorrectionTool(
56 const std::string& myname)
57 :
asg::AsgMetadataTool(myname)
59 , m_appliedSystematics(nullptr)
65 , m_UncorrRegions(nullptr)
66 , m_nSimpleUncorrSyst(0)
74 m_rootTool = std::make_unique<Root::TElectronEfficiencyCorrectionTool>(
75 (
"T" + (this->
name())).c_str());
78 "CorrectionFileNameList",
80 "List of file names that store the correction factors for simulation.");
82 m_mapFile =
"ElectronEfficiencyCorrection/2015_2025/rel22.2/"
83 "2022_Summer_Prerecom_v1/map4.txt",
84 "Full path to the map file");
86 "RecoKey", m_recoKey =
"",
"Key associated with reconstruction");
88 "IdKey", m_idKey =
"",
"Key associated with identification working point");
90 "IsoKey", m_isoKey =
"",
"Key associated with isolation working point");
92 "TriggerKey", m_trigKey =
"",
"Key associated with trigger working point");
94 m_dataTypeOverwrite = -1,
95 "Force the DataType of the electron to specified value (to "
96 "circumvent problem of incorrect DataType for forward "
97 "electrons in some old releases)");
99 "ResultPrefix", m_resultPrefix =
"",
"The prefix string for the result");
100 declareProperty(
"ResultName", m_resultName =
"",
"The string for the result");
102 m_correlation_model_name =
"SIMPLIFIED",
103 "Uncertainty correlation model. At the moment TOTAL, FULL, "
104 "SIMPLIFIED, SYST, MCTOYS and COMBMCTOYS are implemented. "
105 "SIMPLIFIED is the default option.");
107 m_number_of_toys = 100,
108 "Number of ToyMC replica, affecting MCTOYS and COMBMCTOYS "
109 "correlation models only.");
112 "Seed for ToyMC replica, affecting MCTOYS and COMBMCTOYS "
113 "correlation models only.");
116 "Scales Toy systematics up by this factor, affecting MCTOYS "
117 "and COMBMCTOYS correlation models only.");
120 m_uncorrSimplfEtaBinsUser = { 0.0, 1.37, 4.9 },
121 "Custom Eta/Pt binning for the SIMPLIFIED correlation model.");
124 m_uncorrSimplfEtBinsUser = { 4000,
134 "Custom Eta/Pt binning for the SIMPLIFIED correlation model.");
136 m_eventInfoCollectionName =
"EventInfo",
137 "The EventInfo Collection Name");
139 declareProperty(
"DefaultRandomRunNumber", m_defaultRandomRunNumber = 999999);
157 ATH_MSG_ERROR(
"CorrectionFileNameList as well as SFKeys are empty! Please "
158 "configure it properly...");
159 return StatusCode::FAILURE;
175 return StatusCode::FAILURE;
185 ATH_MSG_ERROR(
"No Root file input specified, and not available map file");
186 return StatusCode::FAILURE;
196 return StatusCode::FAILURE;
203 if (
ifile.find(
"efficiencySF.") != std::string::npos) {
206 if (
ifile.find(
"efficiencySF.offline") != std::string::npos) {
209 if (
ifile.find(
"efficiencySF.offline.RecoTrk") != std::string::npos) {
212 if (
ifile.find(
"efficiencySF.offline.Fwd") != std::string::npos) {
215 if (
ifile.find(
"efficiencySF.Isolation") != std::string::npos) {
218 if (
ifile.find(
"efficiency.") != std::string::npos) {
221 if (
ifile.find(
"efficiencySF.ChargeID") != std::string::npos) {
225 ATH_MSG_ERROR(
"Could NOT find systematics Substring file name "
227 return StatusCode::FAILURE;
244 ATH_MSG_ERROR(
"Something went wrong when specifying bins for the "
245 "SIMPLIFIED correlation model ");
246 return StatusCode::FAILURE;
254 return StatusCode::FAILURE;
288 "Could not initialize the TElectronEfficiencyCorrectionTool!");
289 return StatusCode::FAILURE;
294 std::map<float, std::vector<float>>
tmp;
297 for (
const auto&
i :
tmp) {
304 return StatusCode::FAILURE;
308 ATH_MSG_ERROR(
"(registerSystematics() != StatusCode::SUCCESS)");
309 return StatusCode::FAILURE;
314 return StatusCode::FAILURE;
316 return StatusCode::SUCCESS;
322 double& efficiencyScaleFactor)
const
325 efficiencyScaleFactor = 1;
339 "Pileup tool not run before using ElectronEfficiencyTool! SFs do not "
340 "reflect PU distribution in data");
343 runNumber = randomrunnumber(*(eventInfo));
348 double cluster_eta(-9999.9);
352 ATH_MSG_ERROR(
"ERROR no cluster associated to the Electron \n");
360 cluster_eta = cluster->
eta();
362 cluster_eta = cluster->
etaBE(2);
367 const double energy = cluster->
e();
368 const double parEta = inputObject.
eta();
369 const double coshEta = std::cosh(parEta);
370 double et = (coshEta != 0.) ?
energy / coshEta : 0.;
379 efficiencyScaleFactor);
385 const double cluster_eta,
387 double& efficiencyScaleFactor)
const
406 int indexCorrelated = -999;
407 int correlatedSign = 0;
408 if (!(doSFOnly || doToys || isTotal) && (isFull || isSimplified)) {
410 bool isUncorr = (
sysName.find(
"UncorrUnc") != std::string::npos);
411 int currentUncorReg = -999;
416 }
else if (isSimplified) {
419 if (currentUncorReg < 0) {
431 if (
sysName.find(
"CorrUnc") != std::string::npos) {
433 const auto varNumEnd =
sysName.rfind(
"__");
434 const auto varNumBegin =
sysName.rfind(
"NP") + 2;
436 std::stoi(
sysName.substr(varNumBegin, (varNumEnd - varNumBegin)));
438 indexCorrelated = varIndex;
442 indexCorrelated = varIndex;
460 efficiencyScaleFactor = 1;
464 efficiencyScaleFactor =
result.SF;
476 efficiencyScaleFactor =
sys;
483 return HelperFunc(efficiencyScaleFactor,
sys);
486 return HelperFunc(efficiencyScaleFactor, -1 *
sys);
490 else if (unCorrSign!=0) {
492 return HelperFunc(efficiencyScaleFactor,
sys);
505 return HelperFunc(efficiencyScaleFactor,
sys);
511 return HelperFunc(efficiencyScaleFactor,
sys);
515 if (correlatedSign != 0) {
516 sys = correlatedSign *
result.Corr[indexCorrelated];
517 return HelperFunc(efficiencyScaleFactor,
sys);
526 double efficiencyScaleFactor = 1.0;
531 dec(inputObject) = efficiencyScaleFactor;
543 if (systematic.
empty()) {
549 return (
sys.begin()->ensembleContains(systematic));
551 return (
sys.find(systematic) !=
sys.end());
567 if (
registry.registerSystematics(*
this) != StatusCode::SUCCESS) {
569 "Failed to add systematic to list of recommended systematics.");
570 return StatusCode::FAILURE;
572 return StatusCode::SUCCESS;
598 systConfig, affectingSys, filteredSys)) {
600 "Unsupported combination of systematic variations passed to the tool!");
601 return StatusCode::FAILURE;
604 if (filteredSys.
size() > 1) {
606 "More than one systematic variation passed at the same time");
607 return StatusCode::FAILURE;
610 if (filteredSys.
empty() && !systConfig.
empty()) {
612 for (
const auto& syst : systConfig) {
618 itr =
m_systFilter.insert(std::make_pair(systConfig, filteredSys)).first;
623 return StatusCode::SUCCESS;
676 prefixUncorr + Form(
"UncorrUncertaintyNP%d",
i), 1);
678 prefixUncorr + Form(
"UncorrUncertaintyNP%d",
i), -1);
687 prefixUncorr + Form(
"UncorrUncertaintyNP%d",
i), 1);
689 prefixUncorr + Form(
"UncorrUncertaintyNP%d",
i), -1);
696 return StatusCode::SUCCESS;
701 const double cluster_eta,
702 const double et)
const
704 int ptbin = std::as_const(*m_UncorrRegions).GetXaxis()->FindBin(
et) - 1;
706 ptbin >= std::as_const(*m_UncorrRegions).GetXaxis()->GetNbins()) {
708 " Found electron with Et = "
709 <<
et / 1000. <<
" GeV, where you specified boundaries of ["
710 << std::as_const(*m_UncorrRegions).GetXaxis()->GetBinLowEdge(1) <<
","
714 std::as_const(*m_UncorrRegions).GetXaxis()->GetNbins())
715 <<
"] for the SIMPLIFIED correlation model ");
719 std::as_const(*m_UncorrRegions).GetYaxis()->FindBin(std::abs(cluster_eta)) -
722 etabin >= std::as_const(*m_UncorrRegions).GetYaxis()->GetNbins()) {
724 " Found electron with |eta| = "
725 << std::abs(cluster_eta) <<
", where you specified boundaries of ["
726 << std::as_const(*m_UncorrRegions).GetYaxis()->GetBinLowEdge(1) <<
","
730 std::as_const(*m_UncorrRegions).GetYaxis()->GetNbins())
731 <<
"] for the SIMPLIFIED correlation model ");
740 const double cluster_eta,
741 const double et)
const
746 float cluster_eta_electron = 0;
749 for (; itr_ptBEGIN != itr_ptEND; ++itr_ptBEGIN) {
750 auto itr_ptBEGINplusOne = itr_ptBEGIN;
751 ++itr_ptBEGINplusOne;
754 if (
et >= itr_ptBEGIN->first &&
756 if ((itr_ptBEGIN->second).at(0) >= 0) {
757 cluster_eta_electron = std::abs(cluster_eta);
759 cluster_eta_electron = (cluster_eta);
761 for (
unsigned int etab = 0; etab < ((itr_ptBEGIN->second).
size());
763 unsigned int etabnext = etab + 1;
766 if ((cluster_eta_electron) >= (itr_ptBEGIN->second).at(etab) &&
767 (etabnext == itr_ptBEGIN->second.size() ||
768 cluster_eta_electron < itr_ptBEGIN->second.at(etabnext))) {
780 reg += (itr_ptBEGIN->second).
size();
784 "returning the maximum index");
795 int currentSystRegion = -999;
796 double cluster_eta(-9999.9);
799 et = inputObject.
pt();
802 ATH_MSG_ERROR(
"ERROR no cluster associated to the Electron \n");
803 return currentSystRegion;
805 cluster_eta = cluster->
etaBE(2);
820 return currentSystRegion;
826 const std::string& idkey,
827 const std::string& isokey,
828 const std::string& trigkey)
836 if (!
value.empty()) {
839 if (mapFileName.empty()) {
841 "Map file does not exist, Please set the path and version properly..");
846 <<
" does not exist in the map file, Please configure it properly..");
848 return StatusCode::FAILURE;
852 return StatusCode::SUCCESS;
883 return StatusCode::SUCCESS;
888 if (
status == StatusCode::SUCCESS) {
895 :
"fast simulation")));
902 "Applying SF corrections to data while they make sense only for MC");
909 return StatusCode::SUCCESS;
917 return StatusCode::SUCCESS;
919 return StatusCode::SUCCESS;
922 return StatusCode::SUCCESS;
930 #ifndef XAOD_STANDALONE
936 if (!(
dataType ==
"IS_SIMULATION")) {
939 return StatusCode::SUCCESS;
943 std::string simType(
"");
948 std::transform(simType.begin(), simType.end(), simType.begin(), ::toupper);
949 result = (simType.find(
"ATLFAST") == std::string::npos)
952 return StatusCode::SUCCESS;
962 std::string simType(
"");
967 return StatusCode::SUCCESS;
970 std::transform(simType.begin(), simType.end(), simType.begin(), ::toupper);
971 result = (simType.find(
"ATLFAST") == std::string::npos)
974 return StatusCode::SUCCESS;
978 return StatusCode::FAILURE;
def retrieve(aClass, aKey=None)
Extra patterns decribing particle interation process.
std::pair< unsigned, float > getToyVariationByBaseName(const std::string &basename) const
the toy variation for the given basename
Helper class to provide type-safe access to aux data.
size_t size() const
returns: size of the set
bool empty() const
returns: whether the set is empty
Class to wrap a set of SystematicVariations.
Helper class to provide constant type-safe access to aux data.
const uint16_t AuthorFwdElectron
Electron reconstructed by the Forward cluster-based algorithm.
def TH2F(name, title, nxbins, bins_par2, bins_par3, bins_par4, bins_par5=None, bins_par6=None, path='', **kwargs)
reg
globals -----------------------------------------------------------------—
float etaBE(const unsigned layer) const
Get the eta in one layer of the EM Calo.
ServiceHandle< StoreGateSvc > & evtStore()
The standard StoreGateSvc (event store) Returns (kind of) a pointer to the StoreGateSvc.
@ OutOfValidityRange
Input object is out of validity range.
@ Error
Some error happened during the object correction.
Description of a calorimeter cluster.
Helper class to provide type-safe access to aux data.
virtual double eta() const
The pseudorapidity ( ) of the particle.
::StatusCode StatusCode
StatusCode definition for legacy code.
const xAOD::CaloCluster * caloCluster(size_t index=0) const
Pointer to the xAOD::CaloCluster/s that define the electron candidate.
Amg::Vector3D transform(Amg::Vector3D &v, Amg::Transform3D &tr)
Transform a point from a Trasformation3D.
void insert(const SystematicVariation &systematic)
description: insert a systematic into the set
Information about type of data used to fill particle.
Class describing the basic event information.
std::string PathResolverFindCalibFile(const std::string &logical_file_name)
@ Ok
The correction was done successfully.
std::string convertToOneKey(const std::string &recokey, const std::string &idkey, const std::string &isokey, const std::string &trigkey)
#define ATH_MSG_WARNING(x)
bool empty() const
returns: whether this is an empty systematic, i.e.
This module implements the central registry for handling systematic uncertainties with CP tools.
const_iterator begin() const
description: const iterator to the beginning of the set
Return value from object correction CP tools.
virtual double pt() const override final
The transverse momentum ( ) of the particle.
bool isAvailable(const ELT &e) const
Test to see if this variable exists in the store.
virtual double eta() const override final
The pseudorapidity ( ) of the particle.
Information about type of data used to fill particle.
std::string getValueByKey(const std::string &mapFile, const std::string &key)
static SystematicVariation makeToyEnsemble(const std::string &basename)
constructor for toy systematics ensemble
virtual double e() const
The total energy of the particle.
static StatusCode filterForAffectingSystematics(const SystematicSet &systConfig, const SystematicSet &affectingSystematics, SystematicSet &filteredSystematics)
description: filter the systematics for the affected systematics returns: success guarantee: strong f...
Base class for elements of a container that can have aux data.
static SystematicRegistry & getInstance()
Get the singleton instance of the registry for the curren thread.
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....