88 for (
auto mEntry : *
m_mSF)
89 delete std::get<0>(mEntry.second);
107 m_mSF = std::make_unique< tSFMAP >();
108 std::unique_ptr< TFile > fSF( TFile::Open( sInputFilePath.c_str(),
"READ" ) );
111 ATH_MSG_FATAL(
"Could not open file " << sInputFilePath.c_str());
112 return StatusCode::FAILURE;
119 std::vector<std::string> vInputFilePath;
130 return StatusCode::FAILURE;
132 return StatusCode::SUCCESS;
142 double& dEfficiencyScaleFactor,
unsigned int )
147 dEfficiencyScaleFactor = 1.;
154 dEfficiencyScaleFactor = 1.;
167 ATH_MSG_WARNING(
"Found tau with unknown decay mode. Skip efficiency correction.");
175 dEfficiencyScaleFactor = 1.;
182 std::string sHistName;
184 sHistName =
"sf_all_"+
m_sWP+sMode;
192 dEfficiencyScaleFactor);
195 return tmpCorrectionCode;
202 double dTotalSystematic2 = 0.;
203 double dDirection = 0.;
210 double dUncertaintySyst = 0.;
213 dDirection = syst.parameter();
216 sHistName = it->second;
217 if (dDirection>0.) sHistName+=
"_up";
218 else sHistName+=
"_down";
227 if( (sHistName.find(
"3P") != std::string::npos && sHistName.find(
"1p") != std::string::npos) ||
228 (sHistName.find(
"1P") != std::string::npos && sHistName.find(
"3p") != std::string::npos))
231 if( (sHistName.find(
"1520") != std::string::npos && sHistName.find(
"loose") != std::string::npos) ){
236 tmpCorrectionCode =
getValue(sHistName,
242 return tmpCorrectionCode;
245 dUncertaintySyst *= dDirection;
248 dTotalSystematic2 += dUncertaintySyst * dUncertaintySyst;
252 dDirection = (dDirection > 0.) ? 1. : -1.;
255 dEfficiencyScaleFactor *= 1. + dDirection * std::sqrt(dTotalSystematic2);
271 unsigned int iRunNumber)
282 ATH_MSG_DEBUG(
m_sVarName <<
" decoration is available on first tau processed, switched off applyEfficiencyScaleFactor for further taus.");
283 ATH_MSG_DEBUG(
"If an application of efficiency scale factors needs to be redone, please pass a shallow copy of the original tau.");
294 return tmpCorrectionCode;
304 return sys.find(systematic) != sys.end();
345 return StatusCode::SUCCESS;
349 double dDirection = 0.;
351 for (
auto sSyst : sSystematicSet)
357 ATH_MSG_VERBOSE(
"unsupported systematic variation: "<< sSyst.basename()<<
"; skipping this one");
362 if (sSyst.parameter() * dDirection < 0)
364 ATH_MSG_ERROR(
"unsupported set of systematic variations, you should either use only \"UP\" or only \"DOWN\" systematics in one set!");
366 return StatusCode::FAILURE;
368 dDirection = sSyst.parameter();
372 ATH_MSG_ERROR(
"unsupported set of systematic variations, you should not combine \"TAUS_{TRUE|FAKE}_EFF_*_TOTAL\" with other systematic variations!");
374 return StatusCode::FAILURE;
378 sSystematicSetAvailable.
insert(sSyst);
384 return StatusCode::SUCCESS;
390 return fProngness == 1 ?
"_1p" :
"_3p";
435 TIter itNext(fFile.GetListOfKeys());
436 while ((kKey = (TKey*)itNext()))
440 std::string sKeyName = kKey->GetName();
441 if (sKeyName ==
"Xaxis")
443 TNamed* tObj = (TNamed*)kKey->ReadObj();
444 std::string sTitle = tObj->GetTitle();
446 if (sTitle ==
"TruthDecayMode")
451 if (sTitle ==
"truth pt")
456 if (sTitle ==
"truth visible pt")
461 if (sTitle ==
"|eta|")
469 else if (sKeyName ==
"Yaxis")
471 TNamed* tObj = (TNamed*)kKey->ReadObj();
472 std::string sTitle = tObj->GetTitle();
474 if (sTitle ==
"|eta|")
479 else if (sTitle ==
"truth |eta|")
487 std::vector<std::string> vSplitName = {};
488 split(sKeyName,
'_',vSplitName);
489 if (vSplitName[0] ==
"sf")
496 if (sKeyName.find(
"_up_") != std::string::npos or sKeyName.find(
"_down_") != std::string::npos)
500 size_t iPos = sKeyName.find(
'_');
517 TClass *cClass = gROOT->GetClass(kKey->GetClassName());
518 if (cClass->InheritsFrom(
"TH2"))
520 TH1* oObject = (TH1*)kKey->ReadObj();
521 oObject->SetDirectory(0);
525 else if (cClass->InheritsFrom(
"TH1"))
527 TH1* oObject = (TH1*)kKey->ReadObj();
528 oObject->SetDirectory(0);
532 else if (cClass->InheritsFrom(
"TF1"))
534 TObject* oObject = kKey->ReadObj();
561 std::vector<std::string> vSplitInputFilePath = {};
563 std::string sEfficiencyType = vSplitInputFilePath.at(0);
564 std::string sTruthType = vSplitInputFilePath.at(1);
565 std::transform(sEfficiencyType.begin(), sEfficiencyType.end(), sEfficiencyType.begin(), toupper);
566 std::transform(sTruthType.begin(), sTruthType.end(), sTruthType.begin(), toupper);
567 std::string sSystematicBaseString =
"TAUS_"+sTruthType+
"_EFF_"+sEfficiencyType+
"_";
573 if (sEfficiencyType==
"ELERNN" || sEfficiencyType==
"ELEOLR")
m_bNoMultiprong =
true;
575 for (
auto mSF : *
m_mSF)
578 std::vector<std::string> vSplitNP = {};
579 split(mSF.first,
'_',vSplitNP);
580 std::string sNP = vSplitNP.at(0);
581 std::string sNPUppercase = vSplitNP.at(0);
584 if (sNP ==
"sf")
continue;
590 bool bIsRecommended =
false;
591 if (isupper(sNP.at(0)) || isupper(sNP.at(1)))
592 bIsRecommended =
true;
595 std::transform(sNPUppercase.begin(), sNPUppercase.end(), sNPUppercase.begin(), toupper);
596 std::string sSystematicString = sSystematicBaseString+sNPUppercase;
608 ATH_MSG_DEBUG(
"connected base name " << sNP <<
" with systematic " <<sSystematicString);
620 double& dEfficiencyScaleFactor)
const
623 auto it = mSF.find (sHistName);
626 ATH_MSG_ERROR(
"Object with name "<<sHistName<<
" was not found in input file.");
628 for (
auto eEntry : mSF)
637 double dPt =
m_fX(xTau);
638 double dEta =
m_fY(xTau);
640 double dVars[2] = {dPt, dEta};
644 return (std::get<1>(tTuple))(std::get<0>(tTuple), dEfficiencyScaleFactor, dVars);
654 double& dEfficiencyScaleFactor,
double dVars[])
656 double dPt = dVars[0];
658 const TH1* hHist =
dynamic_cast<const TH1*
>(oObject);
667 dPt = std::max(dPt,hHist->GetXaxis()->GetXmin());
669 dPt = std::min(dPt,hHist->GetXaxis()->GetXmax() * .999);
672 int iBin = hHist->FindFixBin(dPt);
673 dEfficiencyScaleFactor = hHist->GetBinContent(iBin);
684 double& dEfficiencyScaleFactor,
double dVars[])
686 double dPt = dVars[0];
687 double dEta = dVars[1];
689 const TH2* hHist =
dynamic_cast<const TH2*
>(oObject);
698 dPt = std::max(dPt,hHist->GetXaxis()->GetXmin());
699 dEta = std::max(dEta,hHist->GetYaxis()->GetXmin());
701 dPt = std::min(dPt,hHist->GetXaxis()->GetXmax() * .999);
702 dEta = std::min(dEta,hHist->GetYaxis()->GetXmax() * .999);
705 int iBin = hHist->FindFixBin(dPt,dEta);
706 dEfficiencyScaleFactor = hHist->GetBinContent(iBin);
716 double& dEfficiencyScaleFactor,
double dVars[])
718 double dPt = dVars[0];
719 double dEta = dVars[1];
721 const TF1* fFunc =
static_cast<const TF1*
>(oObject);
730 dEfficiencyScaleFactor = fFunc->Eval(dPt, dEta);
#define ATH_MSG_VERBOSE(x)
#define ATH_MSG_WARNING(x)
std::string PathResolverFindCalibFile(const std::string &logical_file_name)
Return value from object correction CP tools.
@ Error
Some error happened during the object correction.
@ OutOfValidityRange
Input object is out of validity range.
@ 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.
bool isAvailable(const ELT &e) const
Test to see if this variable exists in the store.
bool panTauDetail(TauJetParameters::PanTauDetails panTauDetail, int &value) const
Get and set values of pantau details variables via enum.
size_t nTracks(TauJetParameters::TauTrackFlag flag=TauJetParameters::TauTrackFlag::classifiedCharged) const
TauJet_v3 TauJet
Definition of the current "tau version".