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 visible pt")
456 if (sTitle ==
"|eta|")
464 else if (sKeyName ==
"Yaxis")
466 TNamed* tObj = (TNamed*)kKey->ReadObj();
467 std::string sTitle = tObj->GetTitle();
469 if (sTitle ==
"|eta|")
474 else if (sTitle ==
"truth |eta|")
482 std::vector<std::string> vSplitName = {};
483 split(sKeyName,
'_',vSplitName);
484 if (vSplitName[0] ==
"sf")
491 if (sKeyName.find(
"_up_") != std::string::npos or sKeyName.find(
"_down_") != std::string::npos)
495 size_t iPos = sKeyName.find(
'_');
512 TClass *cClass = gROOT->GetClass(kKey->GetClassName());
513 if (cClass->InheritsFrom(
"TH2"))
515 TH1* oObject = (TH1*)kKey->ReadObj();
516 oObject->SetDirectory(0);
520 else if (cClass->InheritsFrom(
"TH1"))
522 TH1* oObject = (TH1*)kKey->ReadObj();
523 oObject->SetDirectory(0);
527 else if (cClass->InheritsFrom(
"TF1"))
529 TObject* oObject = kKey->ReadObj();
556 std::vector<std::string> vSplitInputFilePath = {};
558 std::string sEfficiencyType = vSplitInputFilePath.at(0);
559 std::string sTruthType = vSplitInputFilePath.at(1);
560 std::transform(sEfficiencyType.begin(), sEfficiencyType.end(), sEfficiencyType.begin(), toupper);
561 std::transform(sTruthType.begin(), sTruthType.end(), sTruthType.begin(), toupper);
562 std::string sSystematicBaseString =
"TAUS_"+sTruthType+
"_EFF_"+sEfficiencyType+
"_";
568 if (sEfficiencyType==
"ELERNN" || sEfficiencyType==
"ELEOLR")
m_bNoMultiprong =
true;
570 for (
auto mSF : *
m_mSF)
573 std::vector<std::string> vSplitNP = {};
574 split(mSF.first,
'_',vSplitNP);
575 std::string sNP = vSplitNP.at(0);
576 std::string sNPUppercase = vSplitNP.at(0);
579 if (sNP ==
"sf")
continue;
585 bool bIsRecommended =
false;
586 if (isupper(sNP.at(0)) || isupper(sNP.at(1)))
587 bIsRecommended =
true;
590 std::transform(sNPUppercase.begin(), sNPUppercase.end(), sNPUppercase.begin(), toupper);
591 std::string sSystematicString = sSystematicBaseString+sNPUppercase;
603 ATH_MSG_DEBUG(
"connected base name " << sNP <<
" with systematic " <<sSystematicString);
615 double& dEfficiencyScaleFactor)
const
618 auto it = mSF.find (sHistName);
621 ATH_MSG_ERROR(
"Object with name "<<sHistName<<
" was not found in input file.");
623 for (
auto eEntry : mSF)
632 double dPt =
m_fX(xTau);
633 double dEta =
m_fY(xTau);
635 double dVars[2] = {dPt, dEta};
639 return (std::get<1>(tTuple))(std::get<0>(tTuple), dEfficiencyScaleFactor, dVars);
649 double& dEfficiencyScaleFactor,
double dVars[])
651 double dPt = dVars[0];
653 const TH1* hHist =
dynamic_cast<const TH1*
>(oObject);
662 dPt = std::max(dPt,hHist->GetXaxis()->GetXmin());
664 dPt = std::min(dPt,hHist->GetXaxis()->GetXmax() * .999);
667 int iBin = hHist->FindFixBin(dPt);
668 dEfficiencyScaleFactor = hHist->GetBinContent(iBin);
679 double& dEfficiencyScaleFactor,
double dVars[])
681 double dPt = dVars[0];
682 double dEta = dVars[1];
684 const TH2* hHist =
dynamic_cast<const TH2*
>(oObject);
693 dPt = std::max(dPt,hHist->GetXaxis()->GetXmin());
694 dEta = std::max(dEta,hHist->GetYaxis()->GetXmin());
696 dPt = std::min(dPt,hHist->GetXaxis()->GetXmax() * .999);
697 dEta = std::min(dEta,hHist->GetYaxis()->GetXmax() * .999);
700 int iBin = hHist->FindFixBin(dPt,dEta);
701 dEfficiencyScaleFactor = hHist->GetBinContent(iBin);
711 double& dEfficiencyScaleFactor,
double dVars[])
713 double dPt = dVars[0];
714 double dEta = dVars[1];
716 const TF1* fFunc =
static_cast<const TF1*
>(oObject);
725 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".