90 for (
auto& mEntry :
m_mSF)
110 std::unique_ptr<TFile> fSF( TFile::Open(sInputFilePath.c_str()) );
112 ATH_MSG_FATAL(
"Could not open file " << sInputFilePath.c_str());
113 return StatusCode::FAILURE;
123 return StatusCode::FAILURE;
133 return StatusCode::SUCCESS;
150 bool compatibility =
true;
157 accTESCompatibility(xTau) = char(compatibility);
177 double dCorrection = 1.;
182 tmpCorrectionCode =
getValue(
"sf"+sProng,
187 return tmpCorrectionCode;
194 double dTotalSystematic2 = 0.;
195 double dDirection = 0.;
202 double dUncertaintySyst = 0.;
203 tmpCorrectionCode =
getValue(it->second+sProng,
208 return tmpCorrectionCode;
211 dDirection = syst.parameter();
214 dUncertaintySyst *= dDirection;
217 dTotalSystematic2 += dUncertaintySyst * dUncertaintySyst;
221 dDirection = (dDirection > 0.) ? 1. : -1.;
224 dCorrection *= 1 + dDirection * std::sqrt(dTotalSystematic2);
231 xTau.
eta(), xTau.
phi(), xTau.
m());
248 "There's a possible memory leak!" );
266 return sys.find(systematic) != sys.end();
306 return StatusCode::SUCCESS;
310 double dDirection = 0.;
312 for (
auto& sSyst : sSystematicSet)
318 ATH_MSG_VERBOSE(
"unsupported systematic variation: "<< sSyst.basename()<<
"; skipping this one");
322 if (sSyst.parameter() * dDirection < 0)
324 ATH_MSG_ERROR(
"unsupported set of systematic variations, you should either use only \"UP\" or only \"DOWN\" systematics in one set!");
326 return StatusCode::FAILURE;
328 dDirection = sSyst.parameter();
332 ATH_MSG_ERROR(
"unsupported set of systematic variations, you should not combine \"TAUS_{TRUE|FAKE}_SME_TOTAL\" with other systematic variations!");
334 return StatusCode::FAILURE;
338 sSystematicSetAvailable.
insert(sSyst);
344 return StatusCode::SUCCESS;
357 return StatusCode::SUCCESS;
364 return StatusCode::SUCCESS;
370 return fProngness == 1 ?
"_1p" :
"_3p";
382 TIter itNext(fFile->GetListOfKeys());
383 while ((kKey = (TKey*)itNext()))
385 TClass *cClass = gROOT->GetClass(kKey->GetClassName());
389 std::string sKeyName = kKey->GetName();
390 if (sKeyName ==
"Xaxis")
392 TNamed* tObj = (TNamed*)kKey->ReadObj();
393 std::string sTitle = tObj->GetTitle();
395 if (sTitle ==
"P" || sTitle ==
"PFinalCalib")
401 if (sKeyName ==
"Yaxis")
403 TNamed* tObj = (TNamed*)kKey->ReadObj();
404 std::string sTitle = tObj->GetTitle();
406 if (sTitle ==
"track-eta")
411 else if (sTitle ==
"|eta|")
417 if (!cClass->InheritsFrom(
"TH1"))
419 T tObj = (T)kKey->ReadObj();
420 tObj->SetDirectory(0);
421 mMap[sKeyName] = tObj;
429 std::vector<std::string> vInputFilePath;
431 std::string sInputFileName = vInputFilePath.back();
434 std::vector<std::string> vSplitInputFilePath = {};
435 split(sInputFileName,
'_',vSplitInputFilePath);
436 std::string sEfficiencyType = vSplitInputFilePath.at(0);
437 std::string sTruthType = vSplitInputFilePath.at(1);
438 std::transform(sEfficiencyType.begin(), sEfficiencyType.end(), sEfficiencyType.begin(), toupper);
439 std::transform(sTruthType.begin(), sTruthType.end(), sTruthType.begin(), toupper);
440 std::string sSystematicBaseString =
"TAUS_" + sTruthType +
"_SME_" + sEfficiencyType +
"_";
446 for (
auto& mSF :
m_mSF)
449 std::vector<std::string> vSplitNP = {};
450 split(mSF.first,
'_',vSplitNP);
452 std::string sNPUppercase;
453 if (vSplitNP.size() > 2)
455 sNP = vSplitNP.at(0)+
'_'+vSplitNP.at(1);
456 sNPUppercase = vSplitNP.at(0) +
'_' + vSplitNP.at(1);
458 sNP = vSplitNP.at(0);
459 sNPUppercase = vSplitNP.at(0);
463 if (sNP ==
"sf")
continue;
465 if (mSF.first.find(
"_1p") == std::string::npos)
continue;
468 bool bIsRecommended =
false;
469 if (isupper(sNP.at(0)))
470 bIsRecommended =
true;
473 std::transform(sNPUppercase.begin(), sNPUppercase.end(), sNPUppercase.begin(), toupper);
474 std::string sSystematicString = sSystematicBaseString + sNPUppercase;
486 ATH_MSG_DEBUG(
"connected histogram base name " << sNP <<
" with systematic " << sSystematicString);
494 double& dEfficiencyScaleFactor)
const
496 TH1* hHist =
m_mSF.at(sHistName);
497 if (hHist ==
nullptr)
499 ATH_MSG_ERROR(
"Histogram with name " << sHistName <<
" was not found in input file.");
503 double dPt =
m_fX(xTau);
504 double dEta =
m_fY(xTau);
507 dPt = std::max(dPt,hHist->GetXaxis()->GetXmin());
508 dEta = std::max(dEta,hHist->GetYaxis()->GetXmin());
510 dPt = std::min(dPt,hHist->GetXaxis()->GetXmax() * .999);
511 dEta = std::min(dEta,hHist->GetYaxis()->GetXmax() * .999);
513 int iBin = hHist->FindFixBin(dPt,dEta);
514 dEfficiencyScaleFactor = hHist->GetBinContent(iBin);
518 std::string sTitle = hHist->GetTitle();
521 TF1 f(
"",sTitle.c_str(), 0, 1000);
522 if (sHistName.find(
"sf_") != std::string::npos)
523 dEfficiencyScaleFactor = (dEfficiencyScaleFactor -1.) *f.Eval(
m_fX(xTau)) + 1.;
525 dEfficiencyScaleFactor *= f.Eval(
m_fX(xTau));
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_VERBOSE(x)
#define ATH_MSG_WARNING(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.
void makePrivateStore()
Create a new (empty) private store for this object.
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".