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 ==
"P" || sTitle ==
"PFinalCalib")
451 if (sTitle ==
"TruthDecayMode")
456 if (sTitle ==
"truth pt")
461 if (sTitle ==
"truth visible pt")
466 if (sTitle ==
"|eta|")
474 else if (sKeyName ==
"Yaxis")
476 TNamed* tObj = (TNamed*)kKey->ReadObj();
477 std::string sTitle = tObj->GetTitle();
479 if (sTitle ==
"track-eta")
484 else if (sTitle ==
"|eta|")
489 else if (sTitle ==
"mu")
493 if (
evtStore()->retrieve(xEventInfo,
"EventInfo").isFailure()) {
508 else if (sTitle ==
"truth |eta|")
516 std::vector<std::string> vSplitName = {};
517 split(sKeyName,
'_',vSplitName);
518 if (vSplitName[0] ==
"sf")
525 if (sKeyName.find(
"_up_") != std::string::npos or sKeyName.find(
"_down_") != std::string::npos)
529 size_t iPos = sKeyName.find(
'_');
546 TClass *cClass = gROOT->GetClass(kKey->GetClassName());
547 if (cClass->InheritsFrom(
"TH2"))
549 TH1* oObject = (TH1*)kKey->ReadObj();
550 oObject->SetDirectory(0);
554 else if (cClass->InheritsFrom(
"TH1"))
556 TH1* oObject = (TH1*)kKey->ReadObj();
557 oObject->SetDirectory(0);
561 else if (cClass->InheritsFrom(
"TF1"))
563 TObject* oObject = kKey->ReadObj();
590 std::vector<std::string> vSplitInputFilePath = {};
592 std::string sEfficiencyType = vSplitInputFilePath.at(0);
593 std::string sTruthType = vSplitInputFilePath.at(1);
594 std::transform(sEfficiencyType.begin(), sEfficiencyType.end(), sEfficiencyType.begin(), toupper);
595 std::transform(sTruthType.begin(), sTruthType.end(), sTruthType.begin(), toupper);
596 std::string sSystematicBaseString =
"TAUS_"+sTruthType+
"_EFF_"+sEfficiencyType+
"_";
602 if (sEfficiencyType==
"ELERNN" || sEfficiencyType==
"ELEOLR")
m_bNoMultiprong =
true;
604 for (
auto mSF : *
m_mSF)
607 std::vector<std::string> vSplitNP = {};
608 split(mSF.first,
'_',vSplitNP);
609 std::string sNP = vSplitNP.at(0);
610 std::string sNPUppercase = vSplitNP.at(0);
613 if (sNP ==
"sf")
continue;
619 bool bIsRecommended =
false;
620 if (isupper(sNP.at(0)) || isupper(sNP.at(1)))
621 bIsRecommended =
true;
624 std::transform(sNPUppercase.begin(), sNPUppercase.end(), sNPUppercase.begin(), toupper);
625 std::string sSystematicString = sSystematicBaseString+sNPUppercase;
637 ATH_MSG_DEBUG(
"connected base name " << sNP <<
" with systematic " <<sSystematicString);
649 double& dEfficiencyScaleFactor)
const
652 auto it = mSF.find (sHistName);
655 ATH_MSG_ERROR(
"Object with name "<<sHistName<<
" was not found in input file.");
657 for (
auto eEntry : mSF)
666 double dPt =
m_fX(xTau);
667 double dEta =
m_fY(xTau);
669 double dVars[2] = {dPt, dEta};
673 return (std::get<1>(tTuple))(std::get<0>(tTuple), dEfficiencyScaleFactor, dVars);
683 double& dEfficiencyScaleFactor,
double dVars[])
685 double dPt = dVars[0];
687 const TH1* hHist =
dynamic_cast<const TH1*
>(oObject);
696 dPt = std::max(dPt,hHist->GetXaxis()->GetXmin());
698 dPt = std::min(dPt,hHist->GetXaxis()->GetXmax() * .999);
701 int iBin = hHist->FindFixBin(dPt);
702 dEfficiencyScaleFactor = hHist->GetBinContent(iBin);
713 double& dEfficiencyScaleFactor,
double dVars[])
715 double dPt = dVars[0];
716 double dEta = dVars[1];
718 const TH2* hHist =
dynamic_cast<const TH2*
>(oObject);
727 dPt = std::max(dPt,hHist->GetXaxis()->GetXmin());
728 dEta = std::max(dEta,hHist->GetYaxis()->GetXmin());
730 dPt = std::min(dPt,hHist->GetXaxis()->GetXmax() * .999);
731 dEta = std::min(dEta,hHist->GetYaxis()->GetXmax() * .999);
734 int iBin = hHist->FindFixBin(dPt,dEta);
735 dEfficiencyScaleFactor = hHist->GetBinContent(iBin);
745 double& dEfficiencyScaleFactor,
double dVars[])
747 double dPt = dVars[0];
748 double dEta = dVars[1];
750 const TF1* fFunc =
static_cast<const TF1*
>(oObject);
759 dEfficiencyScaleFactor = fFunc->Eval(dPt, dEta);
#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.
@ 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.
float averageInteractionsPerCrossing() const
Average interactions per crossing for all BCIDs - for out-of-time pile-up.
float actualInteractionsPerCrossing() const
Average interactions per crossing for the current BCID - for in-time pile-up.
uint32_t runNumber() const
The current event's run number.
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
EventInfo_v1 EventInfo
Definition of the latest event info version.
TauJet_v3 TauJet
Definition of the current "tau version".