36 for (
auto mEntry : *
m_mSF)
37 delete std::get<0>(mEntry.second);
50 ATH_MSG_INFO(
"Initializing CommonDiTauEfficiencyTool" );
56 m_mSF = std::make_unique< tSFMAP >();
57 std::unique_ptr< TFile > fSF( TFile::Open( sInputFilePath.c_str(),
"READ" ) );
60 ATH_MSG_FATAL(
"Could not open file " << sInputFilePath.c_str());
61 return StatusCode::FAILURE;
68 std::vector<std::string> vInputFilePath;
79 return StatusCode::FAILURE;
81 return StatusCode::SUCCESS;
92 double& dEfficiencyScaleFactor)
97 dEfficiencyScaleFactor = 1.;
103 dEfficiencyScaleFactor);
106 return tmpCorrectionCode;
113 double dTotalSystematic2 = 0.;
114 double dDirection = 0.;
122 double dUncertaintySyst = 0.;
125 dDirection = syst.parameter();
128 std::string sHistName = it->second;
129 if (dDirection>0) sHistName+=
"_up";
130 else sHistName+=
"_down";
134 tmpCorrectionCode =
getValue(sHistName,
140 return tmpCorrectionCode;
143 dUncertaintySyst *= dDirection;
146 dTotalSystematic2 += dUncertaintySyst * dUncertaintySyst;
150 dDirection = (dDirection > 0.) ? 1. : -1.;
153 dEfficiencyScaleFactor *= 1. + dDirection * std::sqrt(dTotalSystematic2);
179 ATH_MSG_DEBUG(
m_sVarName <<
" decoration is available on first ditau processed, switched of applyEfficiencyScaleFactor for further ditaus.");
180 ATH_MSG_DEBUG(
"If an application of efficiency scale factors needs to be redone, please pass a shallow copy of the original ditau.");
191 return tmpCorrectionCode;
201 return sys.find(systematic) != sys.end();
242 return StatusCode::SUCCESS;
246 double dDirection = 0.;
248 for (
auto sSyst : sSystematicSet)
254 ATH_MSG_VERBOSE(
"unsupported systematic variation: "<< sSyst.basename()<<
"; skipping this one");
259 if (sSyst.parameter() * dDirection < 0)
261 ATH_MSG_ERROR(
"unsupported set of systematic variations, you should either use only \"UP\" or only \"DOWN\" systematics in one set!");
263 return StatusCode::FAILURE;
265 dDirection = sSyst.parameter();
269 ATH_MSG_ERROR(
"unsupported set of systematic variations, you should not combine \"TAUS_{TRUE|FAKE}_EFF_*_TOTAL\" with other systematic variations!");
271 return StatusCode::FAILURE;
275 sSystematicSetAvailable.
insert(sSyst);
281 return StatusCode::SUCCESS;
295 TIter itNext(fFile->GetListOfKeys());
296 while ((kKey = (TKey*)itNext()))
300 std::string sKeyName = kKey->GetName();
302 std::vector<std::string> vSplitName = {};
303 split(sKeyName,
'_',vSplitName);
304 if (vSplitName[0] ==
"sf")
310 if (sKeyName.find(
"_up_") != std::string::npos or sKeyName.find(
"_down_") != std::string::npos)
314 size_t iPos = sKeyName.find(
'_');
331 TClass *cClass = gROOT->GetClass(kKey->GetClassName());
332 if (cClass->InheritsFrom(
"TH2"))
334 TH2* oObject =
static_cast<TH2*
>(kKey->ReadObj());
335 oObject->SetDirectory(0);
339 else if (cClass->InheritsFrom(
"TH1"))
341 TH1* oObject =
static_cast<TH1*
>(kKey->ReadObj());
342 oObject->SetDirectory(0);
369 std::vector<std::string> vSplitInputFilePath = {};
371 std::string sEfficiencyType = vSplitInputFilePath.at(0);
372 std::string sTruthType = vSplitInputFilePath.at(1);
373 std::transform(sEfficiencyType.begin(), sEfficiencyType.end(), sEfficiencyType.begin(), toupper);
374 std::transform(sTruthType.begin(), sTruthType.end(), sTruthType.begin(), toupper);
375 std::string sSystematicBaseString =
"TAUS_"+sTruthType+
"_EFF_"+sEfficiencyType+
"_";
380 for (
auto mSF : *
m_mSF)
383 std::vector<std::string> vSplitNP = {};
384 split(mSF.first,
'_',vSplitNP);
385 std::string sNP = vSplitNP.at(0);
386 std::string sNPUppercase = vSplitNP.at(0);
388 if (sNP ==
"sf")
continue;
390 bool bIsRecommended =
false;
391 if (isupper(sNP.at(0)))
392 bIsRecommended =
true;
394 std::transform(sNPUppercase.begin(), sNPUppercase.end(), sNPUppercase.begin(), toupper);
395 std::string sSystematicString = sSystematicBaseString+sNPUppercase;
405 ATH_MSG_DEBUG(
"connected base name " << sNP <<
" with systematic " <<sSystematicString);
417 double& dEfficiencyScaleFactor)
const
420 auto it = mSF.find (sHistName);
423 ATH_MSG_ERROR(
"Object with name "<<sHistName<<
" was not found in input file.");
425 for (
auto eEntry : mSF)
438 double dVars[3] = {dX, dY, dZ};
441 return (std::get<1>(tTuple))(std::get<0>(tTuple), dEfficiencyScaleFactor, dVars);
449 return acc( xDiTau ) * 0.001;
457 return acc( xDiTau ) * 0.001;
465 return acc( xDiTau );
475 double& dEfficiencyScaleFactor,
double dVars[])
477 double dPt = dVars[0];
479 const TH1* hHist =
dynamic_cast<const TH1*
>(oObject);
488 dPt = std::max(dPt,hHist->GetXaxis()->GetXmin());
490 dPt = std::min(dPt,hHist->GetXaxis()->GetXmax() * .999);
493 int iBin = hHist->FindFixBin(dPt);
494 dEfficiencyScaleFactor = hHist->GetBinContent(iBin);
505 double& dEfficiencyScaleFactor,
double dVars[])
507 double dPt = dVars[0];
508 double dEta = dVars[1];
510 const TH2* hHist =
dynamic_cast<const TH2*
>(oObject);
519 dPt = std::max(dPt,hHist->GetXaxis()->GetXmin());
520 dEta = std::max(dEta,hHist->GetYaxis()->GetXmin());
522 dPt = std::min(dPt,hHist->GetXaxis()->GetXmax() * .999);
523 dEta = std::min(dEta,hHist->GetYaxis()->GetXmax() * .999);
526 int iBin = hHist->FindFixBin(dPt,dEta);
527 dEfficiencyScaleFactor = hHist->GetBinContent(iBin);
#define ATH_MSG_VERBOSE(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.
@ 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
SG::Decorator< T, ALLOC > Decorator
Helper class to provide type-safe access to aux data, specialized for JaggedVecElt.
DiTauJet_v1 DiTauJet
Definition of the current version.