92 for (
auto& mEntry :
m_mSF)
112 std::unique_ptr<TFile> fSF( TFile::Open(sInputFilePath.c_str()) );
114 ATH_MSG_FATAL(
"Could not open file " << sInputFilePath.c_str());
115 return StatusCode::FAILURE;
125 return StatusCode::FAILURE;
135 return StatusCode::SUCCESS;
158 bool compatibility =
true;
163 throw std::runtime_error(
"CommonSmearingTool::applyCorrection: combinedTEStool is null");
168 accTESCompatibility(xTau) = char(compatibility);
188 double dCorrection = 1.;
193 tmpCorrectionCode =
getValue(
"sf"+sProng,
198 return tmpCorrectionCode;
205 double dTotalSystematic2 = 0.;
206 double dDirection = 0.;
215 double dUncertaintySyst = 0.;
216 tmpCorrectionCode =
getValue(it->second+sProng,
221 return tmpCorrectionCode;
224 dDirection = syst.parameter();
227 dUncertaintySyst *= dDirection;
230 dTotalSystematic2 += dUncertaintySyst * dUncertaintySyst;
234 dDirection = (dDirection > 0.) ? 1. : -1.;
237 dCorrection *= 1 + dDirection * std::sqrt(dTotalSystematic2);
244 xTau.
eta(), xTau.
phi(), xTau.
m());
261 "There's a possible memory leak!" );
266 xTauCopy->makePrivateStore( xTau );
279 return sys.find(systematic) != sys.end();
319 return StatusCode::SUCCESS;
323 double dDirection = 0.;
325 for (
auto& sSyst : sSystematicSet)
331 ATH_MSG_VERBOSE(
"unsupported systematic variation: "<< sSyst.basename()<<
"; skipping this one");
335 if (sSyst.parameter() * dDirection < 0)
337 ATH_MSG_ERROR(
"unsupported set of systematic variations, you should either use only \"UP\" or only \"DOWN\" systematics in one set!");
339 return StatusCode::FAILURE;
341 dDirection = sSyst.parameter();
345 ATH_MSG_ERROR(
"unsupported set of systematic variations, you should not combine \"TAUS_{TRUE|FAKE}_SME_TOTAL\" with other systematic variations!");
347 return StatusCode::FAILURE;
351 sSystematicSetAvailable.
insert(sSyst);
357 return StatusCode::SUCCESS;
370 return StatusCode::SUCCESS;
377 return StatusCode::SUCCESS;
383 return fProngness == 1 ?
"_1p" :
"_3p";
395 TIter itNext(fFile->GetListOfKeys());
396 while ((kKey = (TKey*)itNext()))
398 TClass *cClass = gROOT->GetClass(kKey->GetClassName());
402 std::string sKeyName = kKey->GetName();
403 if (sKeyName ==
"Xaxis")
405 TNamed* tObj = (TNamed*)kKey->ReadObj();
406 std::string sTitle = tObj->GetTitle();
414 if (sKeyName ==
"Yaxis")
416 TNamed* tObj = (TNamed*)kKey->ReadObj();
417 std::string sTitle = tObj->GetTitle();
419 if (sTitle ==
"|eta|")
425 if (!cClass->InheritsFrom(
"TH1"))
427 T tObj = (T)kKey->ReadObj();
428 tObj->SetDirectory(0);
429 mMap[sKeyName] = tObj;
437 std::vector<std::string> vInputFilePath;
439 std::string sInputFileName = vInputFilePath.back();
442 std::vector<std::string> vSplitInputFilePath = {};
443 split(sInputFileName,
'_',vSplitInputFilePath);
444 std::string sEfficiencyType = vSplitInputFilePath.at(0);
445 std::string sTruthType = vSplitInputFilePath.at(1);
446 std::transform(sEfficiencyType.begin(), sEfficiencyType.end(), sEfficiencyType.begin(), toupper);
447 std::transform(sTruthType.begin(), sTruthType.end(), sTruthType.begin(), toupper);
448 std::string sSystematicBaseString =
"TAUS_" + sTruthType +
"_SME_" + sEfficiencyType +
"_";
454 for (
auto& mSF :
m_mSF)
457 std::vector<std::string> vSplitNP = {};
458 split(mSF.first,
'_',vSplitNP);
460 std::string sNPUppercase;
461 if (vSplitNP.size() > 2)
463 sNP = vSplitNP.at(0)+
'_'+vSplitNP.at(1);
464 sNPUppercase = vSplitNP.at(0) +
'_' + vSplitNP.at(1);
466 sNP = vSplitNP.at(0);
467 sNPUppercase = vSplitNP.at(0);
471 if (sNP ==
"sf")
continue;
473 if (mSF.first.find(
"_1p") == std::string::npos)
continue;
476 bool bIsRecommended =
false;
477 if (isupper(sNP.at(0)))
478 bIsRecommended =
true;
481 std::transform(sNPUppercase.begin(), sNPUppercase.end(), sNPUppercase.begin(), toupper);
482 std::string sSystematicString = sSystematicBaseString + sNPUppercase;
494 ATH_MSG_DEBUG(
"connected histogram base name " << sNP <<
" with systematic " << sSystematicString);
502 double& dEfficiencyScaleFactor)
const
504 TH1* hHist =
m_mSF.at(sHistName);
505 if (hHist ==
nullptr)
507 ATH_MSG_ERROR(
"Histogram with name " << sHistName <<
" was not found in input file.");
511 double dPt =
m_fX(xTau);
512 double dEta =
m_fY(xTau);
515 dPt = std::max(dPt,hHist->GetXaxis()->GetXmin());
516 dEta = std::max(dEta,hHist->GetYaxis()->GetXmin());
518 dPt = std::min(dPt,hHist->GetXaxis()->GetXmax() * .999);
519 dEta = std::min(dEta,hHist->GetYaxis()->GetXmax() * .999);
521 int iBin = hHist->FindFixBin(dPt,dEta);
522 dEfficiencyScaleFactor = hHist->GetBinContent(iBin);
526 std::string sTitle = hHist->GetTitle();
529 TF1 f(
"",sTitle.c_str(), 0, 1000);
530 if (sHistName.find(
"sf_") != std::string::npos)
531 dEfficiencyScaleFactor = (dEfficiencyScaleFactor -1.) *f.Eval(
m_fX(xTau)) + 1.;
533 dEfficiencyScaleFactor *= f.Eval(
m_fX(xTau));
#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,...)
#define ATH_MSG_VERBOSE(x,...)
#define ATH_MSG_INFO(x,...)
#define ATH_MSG_FATAL(x,...)
std::string PathResolverFindCalibFile(const std::string &logical_file_name)
ServiceHandle< StoreGateSvc > & evtStore()
Return value from object correction CP tools.
@ Error
Some error happened during the object correction.
@ Ok
The correction was done successfully.
Class to wrap a set of SystematicVariations.
std::string name() const
returns: the systematics joined into a single string.
void insert(const SystematicVariation &systematic)
description: insert a systematic into the set
size_t size() const
returns: size of the set
Helper class to provide type-safe access to aux data.
Helper class to provide constant type-safe access to aux data.
bool isAvailable(const ELT &e) const
Test to see if this variable exists in the store.
bool getTESCompatibility(const xAOD::TauJet &tau) const
Check if MVA TES and CaloTES are compatible, invoked by TauSmearing tool.
bool eventType(EventType type) const
Check for one particular bitmask value.
@ IS_SIMULATION
true: simulation, false: data
virtual double phi() const
The azimuthal angle ( ) of the particle.
void setP4(double pt, double eta, double phi, double m)
Set methods for IParticle values.
double ptFinalCalib() const
virtual double m() const
The invariant mass of the particle.
virtual double eta() const
The pseudorapidity ( ) of the particle.
size_t nTracks(TauJetParameters::TauTrackFlag flag=TauJetParameters::TauTrackFlag::classifiedCharged) const
EventInfo_v1 EventInfo
Definition of the latest event info version.
TauJet_v3 TauJet
Definition of the current "tau version".