37 for (
auto mEntry : *
m_mSF)
38 delete std::get<0>(mEntry.second);
51 ATH_MSG_INFO(
"Initializing CommonDiTauEfficiencyTool" );
57 m_mSF = std::make_unique< tSFMAP >();
58 std::unique_ptr< TFile > fSF( TFile::Open( sInputFilePath.c_str(),
"READ" ) );
61 ATH_MSG_FATAL(
"Could not open file " << sInputFilePath.c_str());
62 return StatusCode::FAILURE;
69 std::vector<std::string> vInputFilePath;
80 return StatusCode::FAILURE;
82 return StatusCode::SUCCESS;
93 double& dEfficiencyScaleFactor)
98 dEfficiencyScaleFactor = 1.;
104 dEfficiencyScaleFactor);
107 return tmpCorrectionCode;
114 double dTotalSystematic2 = 0.;
115 double dDirection = 0.;
123 double dUncertaintySyst = 0.;
126 dDirection = syst.parameter();
129 std::string sHistName = it->second;
130 if (dDirection>0) sHistName+=
"_up";
131 else sHistName+=
"_down";
135 tmpCorrectionCode =
getValue(sHistName,
141 return tmpCorrectionCode;
144 dUncertaintySyst *= dDirection;
147 dTotalSystematic2 += dUncertaintySyst * dUncertaintySyst;
151 dDirection = (dDirection > 0.) ? 1. : -1.;
154 dEfficiencyScaleFactor *= 1. + dDirection * std::sqrt(dTotalSystematic2);
180 ATH_MSG_DEBUG(
m_sVarName <<
" decoration is available on first ditau processed, switched of applyEfficiencyScaleFactor for further ditaus.");
181 ATH_MSG_DEBUG(
"If an application of efficiency scale factors needs to be redone, please pass a shallow copy of the original ditau.");
192 return tmpCorrectionCode;
202 return sys.find(systematic) != sys.end();
243 return StatusCode::SUCCESS;
247 double dDirection = 0.;
249 for (
const auto & sSyst : sSystematicSet)
255 ATH_MSG_VERBOSE(
"unsupported systematic variation: "<< sSyst.basename()<<
"; skipping this one");
260 if (sSyst.parameter() * dDirection < 0)
262 ATH_MSG_ERROR(
"unsupported set of systematic variations, you should either use only \"UP\" or only \"DOWN\" systematics in one set!");
264 return StatusCode::FAILURE;
266 dDirection = sSyst.parameter();
270 ATH_MSG_ERROR(
"unsupported set of systematic variations, you should not combine \"TAUS_{TRUE|FAKE}_EFF_*_TOTAL\" with other systematic variations!");
272 return StatusCode::FAILURE;
276 sSystematicSetAvailable.
insert(sSyst);
282 return StatusCode::SUCCESS;
296 TIter itNext(fFile->GetListOfKeys());
297 while ((kKey = (TKey*)itNext()))
301 std::string sKeyName = kKey->GetName();
303 std::vector<std::string> vSplitName = {};
304 split(sKeyName,
'_',vSplitName);
305 if (vSplitName[0] ==
"sf")
311 if (sKeyName.find(
"_up_") != std::string::npos or sKeyName.find(
"_down_") != std::string::npos)
315 size_t iPos = sKeyName.find(
'_');
332 TClass *cClass = gROOT->GetClass(kKey->GetClassName());
333 if (cClass->InheritsFrom(
"TH2"))
335 TH2* oObject =
static_cast<TH2*
>(kKey->ReadObj());
336 oObject->SetDirectory(0);
340 else if (cClass->InheritsFrom(
"TH1"))
342 TH1* oObject =
static_cast<TH1*
>(kKey->ReadObj());
343 oObject->SetDirectory(0);
370 std::vector<std::string> vSplitInputFilePath = {};
372 std::string sEfficiencyType = vSplitInputFilePath.at(0);
373 std::string sTruthType = vSplitInputFilePath.at(1);
374 std::transform(sEfficiencyType.begin(), sEfficiencyType.end(), sEfficiencyType.begin(), toupper);
375 std::transform(sTruthType.begin(), sTruthType.end(), sTruthType.begin(), toupper);
376 std::string sSystematicBaseString =
"TAUS_"+sTruthType+
"_EFF_"+sEfficiencyType+
"_";
381 for (
const auto & mSF : *
m_mSF)
384 std::vector<std::string> vSplitNP = {};
385 split(mSF.first,
'_',vSplitNP);
386 std::string sNP = vSplitNP.at(0);
387 std::string sNPUppercase = vSplitNP.at(0);
389 if (sNP ==
"sf")
continue;
391 bool bIsRecommended =
false;
392 if (isupper(sNP.at(0)))
393 bIsRecommended =
true;
395 std::transform(sNPUppercase.begin(), sNPUppercase.end(), sNPUppercase.begin(), toupper);
396 std::string sSystematicString = sSystematicBaseString+sNPUppercase;
406 ATH_MSG_DEBUG(
"connected base name " << sNP <<
" with systematic " <<sSystematicString);
418 double& dEfficiencyScaleFactor)
const
421 auto it = mSF.find (sHistName);
424 ATH_MSG_ERROR(
"Object with name "<<sHistName<<
" was not found in input file.");
426 for (
const auto & eEntry : mSF){
440 double dVars[3] = {dX, dY, dZ};
443 return (std::get<1>(tTuple))(std::get<0>(tTuple), dEfficiencyScaleFactor, dVars);
451 return acc( xDiTau ) * 0.001;
459 return acc( xDiTau ) * 0.001;
467 return acc( xDiTau );
477 double& dEfficiencyScaleFactor,
double dVars[])
479 double dPt = dVars[0];
481 const TH1* hHist =
dynamic_cast<const TH1*
>(oObject);
490 dPt = std::max(dPt,hHist->GetXaxis()->GetXmin());
492 dPt = std::min(dPt,hHist->GetXaxis()->GetXmax() * .999);
495 int iBin = hHist->FindFixBin(dPt);
496 dEfficiencyScaleFactor = hHist->GetBinContent(iBin);
507 double& dEfficiencyScaleFactor,
double dVars[])
509 double dPt = dVars[0];
510 double dEta = dVars[1];
512 const TH2* hHist =
dynamic_cast<const TH2*
>(oObject);
521 dPt = std::max(dPt,hHist->GetXaxis()->GetXmin());
522 dEta = std::max(dEta,hHist->GetYaxis()->GetXmin());
524 dPt = std::min(dPt,hHist->GetXaxis()->GetXmax() * .999);
525 dEta = std::min(dEta,hHist->GetYaxis()->GetXmax() * .999);
528 int iBin = hHist->FindFixBin(dPt,dEta);
529 dEfficiencyScaleFactor = hHist->GetBinContent(iBin);
#define ATH_MSG_DEBUG(x,...)
#define ATH_MSG_ERROR(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)
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.