15 #include "THashList.h"
25 DiTauSelectionTool::DiTauSelectionTool(
const std::string&
name )
28 , m_aAccept(
"DiTauSelection" )
32 DiTauSelectionTool::~DiTauSelectionTool()
48 bool bConfigViaProperties =
false;
49 if (!bConfigViaProperties and !
m_vPtRegion.empty()) bConfigViaProperties =
true;
50 if (!bConfigViaProperties and !std::isnan(
m_dPtMin.value())) bConfigViaProperties =
true;
51 if (!bConfigViaProperties and !std::isnan(
m_dPtMax.value())) bConfigViaProperties =
true;
52 if (!bConfigViaProperties and !
m_vAbsEtaRegion.empty()) bConfigViaProperties =
true;
53 if (!bConfigViaProperties and !std::isnan(
m_dAbsEtaMin.value())) bConfigViaProperties =
true;
54 if (!bConfigViaProperties and !std::isnan(
m_dAbsEtaMax.value())) bConfigViaProperties =
true;
55 if (!bConfigViaProperties and !
m_vNSubjetsRegion.empty()) bConfigViaProperties =
true;
56 if (!bConfigViaProperties and !std::isnan(
m_dNSubjetsMin.value())) bConfigViaProperties =
true;
57 if (!bConfigViaProperties and !std::isnan(
m_dNSubjetsMax.value())) bConfigViaProperties =
true;
58 if (!bConfigViaProperties and !
m_vAbsCharges.empty()) bConfigViaProperties =
true;
59 if (!bConfigViaProperties and !std::isnan(
m_iAbsCharge.value())) bConfigViaProperties =
true;
60 if (!bConfigViaProperties and !
m_vOmniScoreRegion.empty()) bConfigViaProperties =
true;
61 if (!bConfigViaProperties and !std::isnan(
m_dOmniScoreMin.value())) bConfigViaProperties =
true;
62 if (!bConfigViaProperties and !std::isnan(
m_dOmniScoreMax.value())) bConfigViaProperties =
true;
65 if (bConfigViaConfigFile and bConfigViaProperties)
67 ATH_MSG_WARNING(
"Configured tool via setProperty and configuration file, which may lead to unexpected configuration.");
68 ATH_MSG_WARNING(
"In doubt check the configuration that is printed when the tool is initialized and the message level is set to debug");
69 ATH_MSG_WARNING(
"For further details please refer to the documentation:");
70 ATH_MSG_WARNING(
"https://gitlab.cern.ch/atlas/athena/blob/main/PhysicsAnalysis/TauID/TauAnalysisTools/doc/README-DiTauSelectionTool.rst");
72 if (!bConfigViaConfigFile and !bConfigViaProperties)
74 ATH_MSG_WARNING(
"No cut configuration provided, the tool will not do anything. For further details please refer to the documentation:");
75 ATH_MSG_WARNING(
"https://gitlab.cern.ch/atlas/athena/blob/main/PhysicsAnalysis/TauID/TauAnalysisTools/doc/README-DiTauSelectionTool.rst");
78 if (bConfigViaConfigFile)
84 ATH_MSG_WARNING(
"Config file for DiTauSelectionTool with path "<<sInputFilePath<<
" does not contain an empty last line. The tool might not be properly configured!");
86 rEnv.ReadFile(sInputFilePath.c_str(),
89 std::vector<std::string> vCuts;
92 if (rEnv.Defined(
"SelectionCuts"))
96 auto lList = rEnv.GetTable();
97 for( Int_t
i = 0;
i < lList->GetEntries(); ++
i )
99 vCuts.push_back( lList->At(
i )->GetName() );
103 int iSelectionCuts = 0;
105 for (
const std::string& sCut : vCuts)
107 if (sCut ==
"PtRegion")
113 else if (sCut ==
"PtMin")
117 m_dPtMin = rEnv.GetValue(
"PtMin",NAN);
119 else if (sCut ==
"PtMax")
123 m_dPtMax = rEnv.GetValue(
"PtMax",NAN);
125 else if (sCut ==
"AbsEtaRegion")
131 else if (sCut ==
"AbsEtaMin")
137 else if (sCut ==
"AbsEtaMax")
143 else if (sCut ==
"NSubjetsRegion")
149 else if (sCut ==
"NSubjetsMin")
155 else if (sCut ==
"NSubjetsMax")
161 else if (sCut ==
"AbsCharges")
167 else if (sCut ==
"AbsCharge")
173 else if (sCut ==
"OmniScoreRegion")
182 else if (sCut ==
"OmniScoreMin")
189 for (
const std::string& checkCut : vCuts){
190 if (checkCut.find(
"OmniScoreRegion") != std::string::npos) {
191 ATH_MSG_ERROR(
"Misconfig due to OmniScoreRegion and OmniScoreMin cuts both present in the config file. Please CHECK carefully config file again and choose of the two");
192 return StatusCode::FAILURE;
199 else if (sCut ==
"OmniScoreMax")
206 for (
const std::string& checkCut : vCuts){
207 if (checkCut.find(
"OmniScoreRegion") != std::string::npos) {
208 ATH_MSG_ERROR(
"Misconfig due to OmniScoreRegion and OmniScoreMax cuts both present in the config file. Please CHECK carefully config file again and choose of the two");
209 return StatusCode::FAILURE;
232 using map_type = std::map<DiTauSelectionCuts, std::unique_ptr<TauAnalysisTools::DiTauSelectionCut>>;
233 using pair_type = map_type::value_type;
235 pair_type elements[] =
237 {
DiTauCutPt, std::make_unique<TauAnalysisTools::DiTauSelectionCutPt>(
this)},
238 {
DiTauCutAbsEta, std::make_unique<TauAnalysisTools::DiTauSelectionCutAbsEta>(
this)},
239 {
DiTauCutNSubjets, std::make_unique<TauAnalysisTools::DiTauSelectionCutNSubjets>(
this)},
240 {
DiTauCutAbsCharge, std::make_unique<TauAnalysisTools::DiTauSelectionCutAbsCharge>(
this)},
241 {
DiTauCutOmniScore, std::make_unique<TauAnalysisTools::DiTauSelectionCutOmniScore>(
this)},
244 m_cMap = { std::make_move_iterator(
begin(elements) ), std::make_move_iterator(
end(elements) ) };
259 std::string sCuts =
"";
277 return StatusCode::SUCCESS;
284 return StatusCode::SUCCESS;
307 ATH_MSG_FATAL(
"accept(...) Failed to cast particle to tau" );
328 entry.second->fillHistogramCutPre(xDiTau);
336 if (!
entry.second->accept(xDiTau, acceptData))
350 catch (
const std::runtime_error&
error)
357 static std::atomic<uint64_t> warning_count (0
u);
358 auto mycount = ++ warning_count;
371 entry.second->fillHistogramCut(xDiTau);
388 ATH_MSG_WARNING(
"CreateControlPlots was set to true, but no valid file pointer was provided");
398 entry.second->writeControlHistograms();
412 m_hCutFlow = std::make_shared<TH1F>(
"hCutFlow",
"CutFlow;; events",iNBins+1,0,iNBins+1);
421 m_hCutFlow->GetXaxis()->SetBinLabel(iNBins,
entry.second->getName().c_str());
427 template<
typename T,
typename U>
430 if (!vRegion.empty())
432 if (!std::isnan(tMin))
433 vRegion.push_back(tMin);
435 vRegion.push_back(-std::numeric_limits<T>::infinity());
437 if (!std::isnan(tMax))
438 vRegion.push_back(tMax);
440 vRegion.push_back(std::numeric_limits<T>::infinity());
444 template<
typename T,
typename U>
447 if (!vRegion.empty())
450 vRegion.push_back(tVal);
457 unsigned int iNumRegion = vRegion.size()/2;
458 for(
unsigned int iRegion = 0; iRegion < iNumRegion; iRegion++ )
460 ATH_MSG_DEBUG( sCutName<<
": " << vRegion.at(iRegion*2) <<
" to " << vRegion.at(iRegion*2+1) );
468 for (
auto tVal : vRegion)