|
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.");
81 declareProperty(
"MapFilePath",
82 m_mapFile =
"ElectronEfficiencyCorrection/2015_2025/rel22.2/"
83 "2024_Consolidated_Prerecom_v1/map1.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");
93 declareProperty(
"ForceDataType",
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");
101 declareProperty(
"CorrelationModel",
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.");
106 declareProperty(
"NumberOfToys",
107 m_number_of_toys = 100,
108 "Number of ToyMC replica, affecting MCTOYS and COMBMCTOYS "
109 "correlation models only.");
110 declareProperty(
"MCToySeed",
112 "Seed for ToyMC replica, affecting MCTOYS and COMBMCTOYS "
113 "correlation models only.");
114 declareProperty(
"MCToyScale",
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.");
135 declareProperty(
"EventInfoCollectionName",
136 m_eventInfoCollectionName =
"EventInfo",
137 "The EventInfo Collection Name");
138 declareProperty(
"UseRandomRunNumber", m_useRandomRunNumber =
true);
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) {
306 " but input does not contain necessary histograms.");
307 return StatusCode::FAILURE;
313 return StatusCode::FAILURE;
317 ATH_MSG_ERROR(
"(registerSystematics() != StatusCode::SUCCESS)");
318 return StatusCode::FAILURE;
323 return StatusCode::FAILURE;
325 return StatusCode::SUCCESS;
331 double& efficiencyScaleFactor)
const
334 efficiencyScaleFactor = 1;
348 "Pileup tool not run before using ElectronEfficiencyTool! SFs do not "
349 "reflect PU distribution in data");
352 runNumber = randomrunnumber(*(eventInfo));
357 double cluster_eta(-9999.9);
361 ATH_MSG_ERROR(
"ERROR no cluster associated to the Electron \n");
369 cluster_eta = cluster->
eta();
371 cluster_eta = cluster->
etaBE(2);
376 const double energy = cluster->
e();
377 const double parEta = inputObject.
eta();
378 const double coshEta = std::cosh(parEta);
379 double et = (coshEta != 0.) ?
energy / coshEta : 0.;
388 efficiencyScaleFactor);
394 const double cluster_eta,
396 double& efficiencyScaleFactor)
const
415 int indexCorrelated = -999;
416 int correlatedSign = 0;
417 if (!(doSFOnly || doToys || isTotal) && (isFull || isSimplified)) {
419 bool isUncorr = (
sysName.find(
"UncorrUnc") != std::string::npos);
420 int currentUncorReg = -999;
425 }
else if (isSimplified) {
428 if (currentUncorReg < 0) {
440 if (
sysName.find(
"CorrUnc") != std::string::npos) {
442 const auto varNumEnd =
sysName.rfind(
"__");
443 const auto varNumBegin =
sysName.rfind(
"NP") + 2;
445 std::stoi(
sysName.substr(varNumBegin, (varNumEnd - varNumBegin)));
447 indexCorrelated = varIndex;
451 indexCorrelated = varIndex;
469 efficiencyScaleFactor = 1;
473 efficiencyScaleFactor =
result.SF;
485 efficiencyScaleFactor =
sys;
492 return HelperFunc(efficiencyScaleFactor,
sys);
495 return HelperFunc(efficiencyScaleFactor, -1 *
sys);
499 else if (unCorrSign!=0) {
501 return HelperFunc(efficiencyScaleFactor,
sys);
514 return HelperFunc(efficiencyScaleFactor,
sys);
520 return HelperFunc(efficiencyScaleFactor,
sys);
524 if (correlatedSign != 0) {
525 sys = correlatedSign *
result.Corr[indexCorrelated];
526 return HelperFunc(efficiencyScaleFactor,
sys);
535 double efficiencyScaleFactor = 1.0;
540 dec(inputObject) = efficiencyScaleFactor;
552 if (systematic.
empty()) {
558 return (
sys.begin()->ensembleContains(systematic));
560 return (
sys.find(systematic) !=
sys.end());
576 if (
registry.registerSystematics(*
this) != StatusCode::SUCCESS) {
578 "Failed to add systematic to list of recommended systematics.");
579 return StatusCode::FAILURE;
581 return StatusCode::SUCCESS;
607 systConfig, affectingSys, filteredSys)) {
609 "Unsupported combination of systematic variations passed to the tool!");
610 return StatusCode::FAILURE;
613 if (filteredSys.
size() > 1) {
615 "More than one systematic variation passed at the same time");
616 return StatusCode::FAILURE;
619 if (filteredSys.
empty() && !systConfig.
empty()) {
621 for (
const auto& syst : systConfig) {
627 itr =
m_systFilter.insert(std::make_pair(systConfig, filteredSys)).first;
632 return StatusCode::SUCCESS;
685 prefixUncorr + Form(
"UncorrUncertaintyNP%d",
i), 1);
687 prefixUncorr + Form(
"UncorrUncertaintyNP%d",
i), -1);
696 prefixUncorr + Form(
"UncorrUncertaintyNP%d",
i), 1);
698 prefixUncorr + Form(
"UncorrUncertaintyNP%d",
i), -1);
705 return StatusCode::SUCCESS;
710 const double cluster_eta,
711 const double et)
const
713 int ptbin = std::as_const(*m_UncorrRegions).GetXaxis()->FindBin(
et) - 1;
715 ptbin >= std::as_const(*m_UncorrRegions).GetXaxis()->GetNbins()) {
717 " Found electron with Et = "
718 <<
et / 1000. <<
" GeV, where you specified boundaries of ["
719 << std::as_const(*m_UncorrRegions).GetXaxis()->GetBinLowEdge(1) <<
","
723 std::as_const(*m_UncorrRegions).GetXaxis()->GetNbins())
724 <<
"] for the SIMPLIFIED correlation model ");
728 std::as_const(*m_UncorrRegions).GetYaxis()->FindBin(std::abs(cluster_eta)) -
731 etabin >= std::as_const(*m_UncorrRegions).GetYaxis()->GetNbins()) {
733 " Found electron with |eta| = "
734 << std::abs(cluster_eta) <<
", where you specified boundaries of ["
735 << std::as_const(*m_UncorrRegions).GetYaxis()->GetBinLowEdge(1) <<
","
739 std::as_const(*m_UncorrRegions).GetYaxis()->GetNbins())
740 <<
"] for the SIMPLIFIED correlation model ");
749 const double cluster_eta,
750 const double et)
const
755 float cluster_eta_electron = 0;
758 for (; itr_ptBEGIN != itr_ptEND; ++itr_ptBEGIN) {
759 auto itr_ptBEGINplusOne = itr_ptBEGIN;
760 ++itr_ptBEGINplusOne;
763 if (
et >= itr_ptBEGIN->first &&
765 if ((itr_ptBEGIN->second).at(0) >= 0) {
766 cluster_eta_electron = std::abs(cluster_eta);
768 cluster_eta_electron = (cluster_eta);
770 for (
unsigned int etab = 0; etab < ((itr_ptBEGIN->second).
size());
772 unsigned int etabnext = etab + 1;
775 if ((cluster_eta_electron) >= (itr_ptBEGIN->second).at(etab) &&
776 (etabnext == itr_ptBEGIN->second.size() ||
777 cluster_eta_electron < itr_ptBEGIN->second.at(etabnext))) {
789 reg += (itr_ptBEGIN->second).
size();
793 "returning the maximum index");
804 int currentSystRegion = -999;
805 double cluster_eta(-9999.9);
808 et = inputObject.
pt();
811 ATH_MSG_ERROR(
"ERROR no cluster associated to the Electron \n");
812 return currentSystRegion;
814 cluster_eta = cluster->
etaBE(2);
829 return currentSystRegion;
835 const std::string& idkey,
836 const std::string& isokey,
837 const std::string& trigkey)
845 if (!
value.empty()) {
848 if (mapFileName.empty()) {
850 "Map file does not exist, Please set the path and version properly..");
855 <<
" does not exist in the map file, Please configure it properly..");
857 return StatusCode::FAILURE;
861 return StatusCode::SUCCESS;
892 return StatusCode::SUCCESS;
897 if (
status == StatusCode::SUCCESS) {
904 :
"fast simulation")));
911 "Applying SF corrections to data while they make sense only for MC");
918 return StatusCode::SUCCESS;
926 return StatusCode::SUCCESS;
928 return StatusCode::SUCCESS;
931 return StatusCode::SUCCESS;
939 #ifndef XAOD_STANDALONE
945 if (!(
dataType ==
"IS_SIMULATION")) {
948 return StatusCode::SUCCESS;
952 std::string simType(
"");
957 std::transform(simType.begin(), simType.end(), simType.begin(), ::toupper);
958 result = (simType.find(
"ATLFAST") == std::string::npos)
961 return StatusCode::SUCCESS;
971 std::string simType(
"");
976 return StatusCode::SUCCESS;
979 std::transform(simType.begin(), simType.end(), simType.begin(), ::toupper);
980 result = (simType.find(
"ATLFAST") == std::string::npos)
983 return StatusCode::SUCCESS;
987 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)
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....