 |
ATLAS Offline Software
|
Go to the documentation of this file.
72 :
asg::AsgTool( sName )
74 , m_sSystematicSet(nullptr)
78 , m_bNoMultiprong(false)
80 , m_bSFIsAvailable(false)
81 , m_bSFIsAvailableChecked(false)
91 for (
auto mEntry : *
m_mSF)
92 delete std::get<0>(mEntry.second);
110 m_mSF = std::make_unique< tSFMAP >();
111 std::unique_ptr< TFile > fSF( TFile::Open( sInputFilePath.c_str(),
"READ" ) );
114 ATH_MSG_FATAL(
"Could not open file " << sInputFilePath.c_str());
115 return StatusCode::FAILURE;
122 std::vector<std::string> vInputFilePath;
133 return StatusCode::FAILURE;
135 return StatusCode::SUCCESS;
145 double& dEfficiencyScaleFactor,
unsigned int )
150 dEfficiencyScaleFactor = 1.;
157 dEfficiencyScaleFactor = 1.;
170 ATH_MSG_WARNING(
"Found tau with unknown decay mode. Skip efficiency correction.");
178 dEfficiencyScaleFactor = 1.;
185 std::string sHistName;
187 sHistName =
"sf_all_"+
m_sWP+sMode;
195 dEfficiencyScaleFactor);
198 return tmpCorrectionCode;
205 double dTotalSystematic2 = 0.;
206 double dDirection = 0.;
213 double dUncertaintySyst = 0.;
216 dDirection = syst.parameter();
219 sHistName =
it->second;
220 if (dDirection>0.) sHistName+=
"_up";
221 else sHistName+=
"_down";
230 if( (sHistName.find(
"3P") != std::string::npos && sHistName.find(
"1p") != std::string::npos) ||
231 (sHistName.find(
"1P") != std::string::npos && sHistName.find(
"3p") != std::string::npos))
234 if( (sHistName.find(
"1520") != std::string::npos && sHistName.find(
"loose") != std::string::npos) ){
239 tmpCorrectionCode =
getValue(sHistName,
245 return tmpCorrectionCode;
248 dUncertaintySyst *= dDirection;
251 dTotalSystematic2 += dUncertaintySyst * dUncertaintySyst;
255 dDirection = (dDirection > 0.) ? 1. : -1.;
258 dEfficiencyScaleFactor *= 1. + dDirection * std::sqrt(dTotalSystematic2);
274 unsigned int iRunNumber)
285 ATH_MSG_DEBUG(
m_sVarName <<
" decoration is available on first tau processed, switched off applyEfficiencyScaleFactor for further taus.");
286 ATH_MSG_DEBUG(
"If an application of efficiency scale factors needs to be redone, please pass a shallow copy of the original tau.");
297 return tmpCorrectionCode;
307 return sys.find(systematic) !=
sys.end();
348 return StatusCode::SUCCESS;
352 double dDirection = 0.;
354 for (
auto sSyst : sSystematicSet)
360 ATH_MSG_VERBOSE(
"unsupported systematic variation: "<< sSyst.basename()<<
"; skipping this one");
365 if (sSyst.parameter() * dDirection < 0)
367 ATH_MSG_ERROR(
"unsupported set of systematic variations, you should either use only \"UP\" or only \"DOWN\" systematics in one set!");
369 return StatusCode::FAILURE;
371 dDirection = sSyst.parameter();
375 ATH_MSG_ERROR(
"unsupported set of systematic variations, you should not combine \"TAUS_{TRUE|FAKE}_EFF_*_TOTAL\" with other systematic variations!");
377 return StatusCode::FAILURE;
381 sSystematicSetAvailable.
insert(sSyst);
387 return StatusCode::SUCCESS;
393 return fProngness == 1 ?
"_1p" :
"_3p";
438 TIter itNext(fFile.GetListOfKeys());
439 while ((kKey = (TKey*)itNext()))
443 std::string sKeyName = kKey->GetName();
444 if (sKeyName ==
"Xaxis")
446 TNamed* tObj = (TNamed*)kKey->ReadObj();
447 std::string sTitle = tObj->GetTitle();
449 if (sTitle ==
"P" || sTitle ==
"PFinalCalib")
454 if (sTitle ==
"TruthDecayMode")
459 if (sTitle ==
"truth pt")
464 if (sTitle ==
"|eta|")
472 else if (sKeyName ==
"Yaxis")
474 TNamed* tObj = (TNamed*)kKey->ReadObj();
475 std::string sTitle = tObj->GetTitle();
477 if (sTitle ==
"track-eta")
482 else if (sTitle ==
"|eta|")
487 else if (sTitle ==
"mu")
491 if (
evtStore()->retrieve(xEventInfo,
"EventInfo").isFailure()) {
506 else if (sTitle ==
"truth |eta|")
514 std::vector<std::string> vSplitName = {};
515 split(sKeyName,
'_',vSplitName);
516 if (vSplitName[0] ==
"sf")
523 if (sKeyName.find(
"_up_") != std::string::npos or sKeyName.find(
"_down_") != std::string::npos)
527 size_t iPos = sKeyName.find(
'_');
544 TClass *cClass = gROOT->GetClass(kKey->GetClassName());
545 if (cClass->InheritsFrom(
"TH2"))
547 TH1* oObject = (TH1*)kKey->ReadObj();
548 oObject->SetDirectory(0);
552 else if (cClass->InheritsFrom(
"TH1"))
554 TH1* oObject = (TH1*)kKey->ReadObj();
555 oObject->SetDirectory(0);
559 else if (cClass->InheritsFrom(
"TF1"))
561 TObject* oObject = kKey->ReadObj();
588 std::vector<std::string> vSplitInputFilePath = {};
590 std::string sEfficiencyType = vSplitInputFilePath.at(0);
591 std::string sTruthType = vSplitInputFilePath.at(1);
592 std::transform(sEfficiencyType.begin(), sEfficiencyType.end(), sEfficiencyType.begin(), toupper);
593 std::transform(sTruthType.begin(), sTruthType.end(), sTruthType.begin(), toupper);
594 std::string sSystematicBaseString =
"TAUS_"+sTruthType+
"_EFF_"+sEfficiencyType+
"_";
600 if (sEfficiencyType==
"ELERNN" || sEfficiencyType==
"ELEOLR")
m_bNoMultiprong =
true;
602 for (
auto mSF : *
m_mSF)
605 std::vector<std::string> vSplitNP = {};
606 split(mSF.first,
'_',vSplitNP);
607 std::string sNP = vSplitNP.at(0);
608 std::string sNPUppercase = vSplitNP.at(0);
611 if (sNP ==
"sf")
continue;
617 bool bIsRecommended =
false;
618 if (isupper(sNP.at(0)) || isupper(sNP.at(1)))
619 bIsRecommended =
true;
622 std::transform(sNPUppercase.begin(), sNPUppercase.end(), sNPUppercase.begin(), toupper);
623 std::string sSystematicString = sSystematicBaseString+sNPUppercase;
635 ATH_MSG_DEBUG(
"connected base name " << sNP <<
" with systematic " <<sSystematicString);
647 double& dEfficiencyScaleFactor)
const
650 auto it = mSF.find (sHistName);
653 ATH_MSG_ERROR(
"Object with name "<<sHistName<<
" was not found in input file.");
655 for (
auto eEntry : mSF)
664 double dPt =
m_fX(xTau);
667 double dVars[2] = {dPt,
dEta};
671 return (std::get<1>(tTuple))(std::get<0>(tTuple), dEfficiencyScaleFactor, dVars);
681 double& dEfficiencyScaleFactor,
double dVars[])
683 double dPt = dVars[0];
685 const TH1* hHist =
dynamic_cast<const TH1*
>(oObject);
694 dPt =
std::max(dPt,hHist->GetXaxis()->GetXmin());
696 dPt =
std::min(dPt,hHist->GetXaxis()->GetXmax() * .999);
699 int iBin = hHist->FindFixBin(dPt);
700 dEfficiencyScaleFactor = hHist->GetBinContent(iBin);
711 double& dEfficiencyScaleFactor,
double dVars[])
713 double dPt = dVars[0];
714 double dEta = dVars[1];
716 const TH2* hHist =
dynamic_cast<const TH2*
>(oObject);
725 dPt =
std::max(dPt,hHist->GetXaxis()->GetXmin());
728 dPt =
std::min(dPt,hHist->GetXaxis()->GetXmax() * .999);
732 int iBin = hHist->FindFixBin(dPt,
dEta);
733 dEfficiencyScaleFactor = hHist->GetBinContent(iBin);
743 double& dEfficiencyScaleFactor,
double dVars[])
745 double dPt = dVars[0];
746 double dEta = dVars[1];
748 const TF1* fFunc =
static_cast<const TF1*
>(oObject);
757 dEfficiencyScaleFactor = fFunc->Eval(dPt,
dEta);
bool empty() const
returns: whether the set is empty
size_t nTracks(TauJetParameters::TauTrackFlag flag=TauJetParameters::TauTrackFlag::classifiedCharged) const
Class to wrap a set of SystematicVariations.
std::string name() const
returns: the systematics joined into a single string.
bool panTauDetail(TauJetParameters::PanTauDetails panTauDetail, int &value) const
Get and set values of pantau details variables via enum.
#define ATH_MSG_VERBOSE(x)
uint32_t runNumber() const
The current event's run number.
ServiceHandle< StoreGateSvc > & evtStore()
The standard StoreGateSvc (event store) Returns (kind of) a pointer to the StoreGateSvc.
@ OutOfValidityRange
Input object is out of validity range.
@ Error
Some error happened during the object correction.
Helper class to provide type-safe access to aux data.
::StatusCode StatusCode
StatusCode definition for legacy code.
Class describing a tau jet.
Amg::Vector3D transform(Amg::Vector3D &v, Amg::Transform3D &tr)
Transform a point from a Trasformation3D.
const_iterator end() const
description: const iterator to the end of the set
float averageInteractionsPerCrossing() const
Average interactions per crossing for all BCIDs - for out-of-time pile-up.
void insert(const SystematicVariation &systematic)
description: insert a systematic into the set
Class describing the basic event information.
std::string PathResolverFindCalibFile(const std::string &logical_file_name)
iterator find(const SystematicVariation &sys) const
description: find an element in the set
@ Ok
The correction was done successfully.
#define ATH_MSG_WARNING(x)
bool isAvailable(const ELT &e) const
Test to see if this variable exists in the store.
Return value from object correction CP tools.
bool dEta(const xAOD::TauJet &tau, const xAOD::TauTrack &track, double &out)
Helper class to provide type-safe access to aux data.
float actualInteractionsPerCrossing() const
Average interactions per crossing for the current BCID - for in-time pile-up.