56 "File that stores the correction factors for simulation for converted photons");
59 "File that stores the correction factors for simulation for unconverted photons");
61 declareProperty(
"MapFilePath",
m_mapFile =
"PhotonEfficiencyCorrection/2015_2025/rel22.2/2024_FinalRun2_Recommendation_v1/map1.txt",
62 "Full path to the map file");
65 "Force the DataType of the Photon to specified value");
71 declareProperty(
"IsoKey",
m_isoWP=
"",
"Set isolation WP, if this string is empty the tool will return ID SF");
78 "Set if use RandomRunNumber from eventinfo");
80 "Set default run number manually");
82 "boolean to treat barrel standalone TRT conversion as unconverted for Run3 ");
102 std::vector < std::string > corrFileNameList;
114 ATH_MSG_ERROR (
"Fail to resolve input file name, check if you set MapFilePath or CorrectionFileName properly" );
115 return StatusCode::FAILURE ;
119 for (
auto & i : corrFileNameList){
124 if (filename.empty()){
126 return StatusCode::FAILURE ;
153 ATH_MSG_ERROR(
"Could not initialize the TElectronEfficiencyCorrectionTool!");
154 return StatusCode::FAILURE;
160 std::map<float, std::vector<float>> pteta_bins_unc;
165 for (
const auto& [pt_unc, eta_unc]: pteta_bins_unc) {
171 return StatusCode::FAILURE;
174 return StatusCode::SUCCESS ;
186 auto clusters = egam(acc.caloClusterAcc);
187 if (clusters.size()<1||!clusters[0].has_value()){
191 auto cluster = clusters[0].value();
194 const double energy = cluster(acc.clusterEAcc);
196 if ( std::abs(egam(acc.etaAcc)) < 999.) {
197 const double cosheta = std::cosh(egam(acc.etaAcc));
198 et = (cosheta != 0.) ? energy / cosheta : 0.;
202 double eta2 = cluster(acc.clusterEtaBEAcc,2);
213 if (std::abs(eta2) >
MAXETA) {
217 << eta2 <<
" Returning SF = 1 + / - 1");
224 <<
et <<
" Returning SF = 1 + / - 1");
231 <<
et / 1e3 <<
"GeV Returning SF = 1 + / - 1");
238 if (!acc.randomRunNumberAcc.isAvailable(eventInfo)) {
240 "Pileup tool not run before using PhotonEfficiencyTool! SFs do not "
241 "reflect PU distribution in data");
244 runnumber = acc.randomRunNumberAcc(eventInfo);
251 PATCore::ParticleDataType::DataType::Data;
257 bool excludeTRT =
false;
260 const auto [isConv, missingLinks] = acc.isConvertedPhotonAcc(egam, excludeTRT);
263 ATH_MSG_ERROR(
"Missing vertex or track links when trying to calculate the conversion type. missingLinks=" << std::hex << missingLinks);
266 static std::atomic<bool> warned {
false};
267 if (warned.exchange(
true) ==
false) {
268 ATH_MSG_WARNING(
"Missing vertex or track links when trying to calculate the conversion type. missingLinks=" << std::hex << missingLinks);
269 ATH_MSG_WARNING(
"This may indicate that the DAOD is incorrectly missing some conversion vertices.");
270 ATH_MSG_WARNING(
"This is your only warning, repeat occurrences will be reported at the DEBUG level.");
272 ATH_MSG_DEBUG(
"Missing vertex or track links when trying to calculate the conversion type. missingLinks=" << std::hex << missingLinks);
319 efficiencyScaleFactor=sfresult.
SF;
326 efficiencyScaleFactor=sfresult.
SF+sigma*sfresult.
Total;
352 efficiencyScaleFactorError=sfresult.
Total;
358 double efficiencyScaleFactor = 1.0;
361 dec(inputObject) = efficiencyScaleFactor;
369 if(!systematic.
empty()){
371 return sys.find(systematic) != sys.end();
392 ATH_MSG_ERROR(
"Failed to add systematic to list of recommended systematics.");
393 return StatusCode::FAILURE;
395 return StatusCode::SUCCESS;
420 ATH_MSG_ERROR(
"Unsupported combination of systematics passed to the tool!");
421 return StatusCode::FAILURE;
424 itr =
m_systFilter.insert(std::make_pair(systConfig, filteredSys)).first;
429 return StatusCode::SUCCESS;
440 if(mapFileName.empty()){
446 std::string correction_type =
"ID_Tight";
447 if(!trigWP.empty()) correction_type =
"Trigger_"+trigWP+
"_"+isoWP;
448 else if(!isoWP.empty()) correction_type =
"ISO_"+isoWP;
451 if(trigWP.empty()) {correction_type += isConv ?
"_Converted" :
"_Unconverted";}
456 std::ifstream is(mapFileName);
465 int nPos = strLine.find(
'=');
467 if ((
signed int)std::string::npos == nPos)
continue;
468 std::string strKey = strLine.substr(0,nPos);
469 std::string strVal = strLine.substr(nPos + 1, strLine.length() - nPos + 1);
472 if(0==correction_type.compare(strKey)) {value=strVal;
break;}
482 for (
auto photon : photons)
489 acc.sfDec(photon) = sf;
490 acc.validDec(photon) =
true;
492 case OutOfValidityRange:
493 acc.sfDec(photon) = sf;
494 acc.validDec(photon) =
false;
497 throw std::runtime_error(
"Error in getEfficiencyScaleFactor");
507 auto eventInfo = acc.eventInfoAcc(event);
#define ATH_MSG_WARNING(x)
float et(const xAOD::jFexSRJetRoI *j)
std::string PathResolverFindCalibFile(const std::string &logical_file_name)
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)
ServiceHandle< StoreGateSvc > & evtStore()
Return value from object correction CP tools.
ErrorCode
Possible values for the correction code.
@ 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.
StatusCode registerSystematics(const IReentrantSystematicsTool &tool)
effects: register all the systematics from the tool
Class to wrap a set of SystematicVariations.
void insert(const SystematicVariation &systematic)
description: insert a systematic into the set
float getParameterByBaseName(const std::string &basename) const
returns: the parameter value for the given basename
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.
SG::Decorator< T, ALLOC > Decorator
std::string find(const std::string &s)
return a remapped string
static std::vector< uint32_t > runnumber
ObjectRange< ContainerId::egamma > EgammaRange
ObjectId< ContainerId::egamma > EgammaId
ObjectRange< ContainerId::eventContext > EventContextRange
ObjectId< ContainerId::eventContext > EventContextId
ObjectId< ContainerId::eventInfo > EventInfoId
EventInfo_v1 EventInfo
Definition of the latest event info version.
Egamma_v1 Egamma
Definition of the current "egamma version".
Extra patterns decribing particle interation process.