15 #include "THashList.h"
24 DiTauSelectionTool::DiTauSelectionTool(
const std::string&
name )
27 , m_aAccept(
"DiTauSelection" )
51 DiTauSelectionTool::~DiTauSelectionTool()
60 bool bConfigViaProperties =
false;
61 if (!bConfigViaProperties and !
m_vPtRegion.empty()) bConfigViaProperties =
true;
62 if (!bConfigViaProperties and
m_dPtMin ==
m_dPtMin) bConfigViaProperties =
true;
63 if (!bConfigViaProperties and
m_dPtMax ==
m_dPtMax) bConfigViaProperties =
true;
64 if (!bConfigViaProperties and !
m_vAbsEtaRegion.empty()) bConfigViaProperties =
true;
67 if (!bConfigViaProperties and !
m_vNSubjetsRegion.empty()) bConfigViaProperties =
true;
71 if (bConfigViaConfigFile and bConfigViaProperties)
73 ATH_MSG_WARNING(
"Configured tool via setProperty and configuration file, which may lead to unexpected configuration.");
74 ATH_MSG_WARNING(
"In doubt check the configuration that is printed when the tool is initialized and the message level is set to debug");
75 ATH_MSG_WARNING(
"For further details please refer to the documentation:");
76 ATH_MSG_WARNING(
"https://gitlab.cern.ch/atlas/athena/blob/master/PhysicsAnalysis/TauID/TauAnalysisTools/doc/README-DiTauSelectionTool.rst");
78 if (!bConfigViaConfigFile and !bConfigViaProperties)
80 ATH_MSG_WARNING(
"No cut configuration provided, the tool will not do anything. For further details please refer to the documentation:");
81 ATH_MSG_WARNING(
"https://gitlab.cern.ch/atlas/athena/blob/master/PhysicsAnalysis/TauID/TauAnalysisTools/doc/README-DiTauSelectionTool.rst");
84 if (bConfigViaConfigFile)
90 ATH_MSG_WARNING(
"Config file for DiTauSelectionTool with path "<<sInputFilePath<<
" does not contain an empty last line. The tool might not be properly configured!");
92 rEnv.ReadFile(sInputFilePath.c_str(),
95 std::vector<std::string> vCuts;
98 if (rEnv.Defined(
"SelectionCuts"))
102 auto lList = rEnv.GetTable();
103 for( Int_t
i = 0;
i < lList->GetEntries(); ++
i )
105 vCuts.push_back( lList->At(
i )->GetName() );
109 int iSelectionCuts = 0;
111 for (
const std::string& sCut : vCuts)
113 if (sCut ==
"PtRegion")
119 else if (sCut ==
"PtMin")
123 m_dPtMin = rEnv.GetValue(
"PtMin",NAN);
125 else if (sCut ==
"PtMax")
129 m_dPtMax = rEnv.GetValue(
"PtMax",NAN);
131 else if (sCut ==
"AbsEtaRegion")
137 else if (sCut ==
"AbsEtaMin")
143 else if (sCut ==
"AbsEtaMax")
149 else if (sCut ==
"NSubjetsRegion")
155 else if (sCut ==
"NSubjetsMin")
161 else if (sCut ==
"NSubjetsMax")
175 using map_type = std::map<DiTauSelectionCuts, std::unique_ptr<TauAnalysisTools::DiTauSelectionCut>>;
176 using pair_type = map_type::value_type;
178 pair_type elements[] =
180 {
DiTauCutPt, std::make_unique<TauAnalysisTools::DiTauSelectionCutPt>(
this)},
181 {
DiTauCutAbsEta, std::make_unique<TauAnalysisTools::DiTauSelectionCutAbsEta>(
this)},
182 {
DiTauCutNSubjets, std::make_unique<TauAnalysisTools::DiTauSelectionCutNSubjets>(
this)},
185 m_cMap = { std::make_move_iterator(
begin(elements) ), std::make_move_iterator(
end(elements) ) };
196 std::string sCuts =
"";
212 return StatusCode::SUCCESS;
219 return StatusCode::SUCCESS;
242 ATH_MSG_FATAL(
"accept(...) Failed to cast particle to tau" );
263 entry.second->fillHistogramCutPre(xDiTau);
271 if (!
entry.second->accept(xDiTau, acceptData))
285 catch (
const std::runtime_error&
error)
292 static std::atomic<uint64_t> warning_count (0
u);
293 auto mycount = ++ warning_count;
306 entry.second->fillHistogramCut(xDiTau);
323 ATH_MSG_WARNING(
"CreateControlPlots was set to true, but no valid file pointer was provided");
333 entry.second->writeControlHistograms();
347 m_hCutFlow = std::make_shared<TH1F>(
"hCutFlow",
"CutFlow;; events",iNBins+1,0,iNBins+1);
356 m_hCutFlow->GetXaxis()->SetBinLabel(iNBins,
entry.second->getName().c_str());
362 template<
typename T,
typename U>
365 if (!vRegion.empty())
368 vRegion.push_back(tMin);
370 vRegion.push_back(-std::numeric_limits<T>::infinity());
373 vRegion.push_back(tMax);
375 vRegion.push_back(std::numeric_limits<T>::infinity());
379 template<
typename T,
typename U>
382 if (!vRegion.empty())
385 vRegion.push_back(tVal);
392 unsigned int iNumRegion = vRegion.size()/2;
393 for(
unsigned int iRegion = 0; iRegion < iNumRegion; iRegion++ )
395 ATH_MSG_DEBUG( sCutName<<
": " << vRegion.at(iRegion*2) <<
" to " << vRegion.at(iRegion*2+1) );
403 for (
auto tVal : vRegion)