15 #include "THashList.h"
26 , m_sJetIDWP(
"JETIDNONE")
27 , m_sEleIDWP(
"ELEIDNONE")
29 , m_aAccept(
"TauSelection" )
38 declareProperty(
"ConfigPath",
m_sConfigPath =
"TauAnalysisTools/"+std::string(sSharedFilesVersion)+
"/Selection/recommended_selection_r22.conf");
75 bool bConfigViaProperties =
false;
76 if (!bConfigViaProperties and !
m_vPtRegion.empty()) bConfigViaProperties =
true;
77 if (!bConfigViaProperties and
m_dPtMin ==
m_dPtMin) bConfigViaProperties =
true;
78 if (!bConfigViaProperties and
m_dPtMax ==
m_dPtMax) bConfigViaProperties =
true;
79 if (!bConfigViaProperties and !
m_vAbsEtaRegion.empty()) bConfigViaProperties =
true;
82 if (!bConfigViaProperties and !
m_vAbsCharges.empty()) bConfigViaProperties =
true;
84 if (!bConfigViaProperties and !
m_vNTracks.empty()) bConfigViaProperties =
true;
92 if (!bConfigViaProperties and
m_iJetIDWP != 0) bConfigViaProperties =
true;
93 if (!bConfigViaProperties and !
m_vEleRNNRegion.empty()) bConfigViaProperties =
true;
96 if (!bConfigViaProperties and
m_iEleIDWP != 0) bConfigViaProperties =
true;
97 if (!bConfigViaProperties and
m_bMuonOLR) bConfigViaProperties =
true;
99 if (bConfigViaConfigFile and bConfigViaProperties)
101 ATH_MSG_WARNING(
"Configured tool via setProperty and configuration file, which may lead to unexpected configuration.");
102 ATH_MSG_WARNING(
"In doubt check the configuration that is printed when the tool is initialized and the message level is set to debug");
103 ATH_MSG_WARNING(
"For further details please refer to the documentation:");
104 ATH_MSG_WARNING(
"https://gitlab.cern.ch/atlas/athena/blob/master/PhysicsAnalysis/TauID/TauAnalysisTools/doc/README-TauSelectionTool.rst");
106 if (!bConfigViaConfigFile and !bConfigViaProperties)
108 ATH_MSG_WARNING(
"No cut configuration provided, the tool will not do anything. For further details please refer to the documentation:");
109 ATH_MSG_WARNING(
"https://gitlab.cern.ch/atlas/athena/blob/master/PhysicsAnalysis/TauID/TauAnalysisTools/doc/README-TauSelectionTool.rst");
112 if (bConfigViaConfigFile)
118 ATH_MSG_WARNING(
"Config file for TauSelectionTool with path "<<sInputFilePath<<
" does not contain an empty last line. The tool might not be properly configured!");
120 rEnv.ReadFile(sInputFilePath.c_str(),
123 std::vector<std::string> vCuts;
126 if (rEnv.Defined(
"SelectionCuts"))
130 auto lList = rEnv.GetTable();
131 for( Int_t
i = 0;
i < lList->GetEntries(); ++
i )
133 vCuts.push_back( lList->At(
i )->GetName() );
137 int iSelectionCuts = 0;
139 for (
const std::string& sCut : vCuts)
141 if (sCut ==
"PtRegion")
143 iSelectionCuts = iSelectionCuts |
CutPt;
147 else if (sCut ==
"PtMin")
149 iSelectionCuts = iSelectionCuts |
CutPt;
151 m_dPtMin = rEnv.GetValue(
"PtMin",NAN);
153 else if (sCut ==
"PtMax")
155 iSelectionCuts = iSelectionCuts |
CutPt;
157 m_dPtMax = rEnv.GetValue(
"PtMax",NAN);
159 else if (sCut ==
"AbsEtaRegion")
161 iSelectionCuts = iSelectionCuts |
CutAbsEta;
165 else if (sCut ==
"AbsEtaMin")
167 iSelectionCuts = iSelectionCuts |
CutAbsEta;
171 else if (sCut ==
"AbsEtaMax")
173 iSelectionCuts = iSelectionCuts |
CutAbsEta;
177 else if (sCut ==
"AbsCharges")
183 else if (sCut ==
"AbsCharge")
189 else if (sCut ==
"NTracks")
191 iSelectionCuts = iSelectionCuts |
CutNTrack;
195 else if (sCut ==
"NTrack")
197 iSelectionCuts = iSelectionCuts |
CutNTrack;
201 else if (sCut ==
"JetRNNSigTransRegion")
207 else if (sCut ==
"JetRNNSigTransMin")
213 else if (sCut ==
"JetRNNSigTransMax")
219 else if (sCut ==
"GNTauSigTransRegion")
225 else if (sCut ==
"GNTauSigTransMin")
231 else if (sCut ==
"GNTauSigTransMax")
237 else if (sCut ==
"EleRNNRegion")
243 else if (sCut ==
"EleRNNMin")
249 else if (sCut ==
"EleRNNMax")
255 else if (sCut ==
"JetIDWP")
261 else if (sCut ==
"EleIDWP")
267 else if (sCut ==
"MuonOLR")
301 using map_type = std::map<SelectionCuts, std::unique_ptr<TauAnalysisTools::TauSelectionCut>>;
302 using pair_type = map_type::value_type;
304 pair_type elements[] =
306 {
CutPt, std::make_unique<TauAnalysisTools::TauSelectionCutPt>(
this)},
307 {
CutAbsEta, std::make_unique<TauAnalysisTools::TauSelectionCutAbsEta>(
this)},
308 {
CutAbsCharge, std::make_unique<TauAnalysisTools::TauSelectionCutAbsCharge>(
this)},
309 {
CutNTrack, std::make_unique<TauAnalysisTools::TauSelectionCutNTracks>(
this)},
311 {
CutGNTauScoreSigTrans, std::make_unique<TauAnalysisTools::TauSelectionCutGNTauScoreSigTrans>(
this)},
312 {
CutJetIDWP, std::make_unique<TauAnalysisTools::TauSelectionCutJetIDWP>(
this)},
313 {
CutEleRNNScore, std::make_unique<TauAnalysisTools::TauSelectionCutRNNEleScore>(
this)},
314 {
CutEleIDWP, std::make_unique<TauAnalysisTools::TauSelectionCutEleIDWP>(
this)},
315 {
CutMuonOLR, std::make_unique<TauAnalysisTools::TauSelectionCutMuonOLR>(
this)}
318 m_cMap = { std::make_move_iterator(
begin(elements) ), std::make_move_iterator(
end(elements) ) };
343 std::string sCuts =
"";
366 return StatusCode::SUCCESS;
373 return StatusCode::SUCCESS;
396 ATH_MSG_FATAL(
"accept(...) Failed to cast particle to tau" );
417 entry.second->fillHistogramCutPre(xTau);
425 if (!
entry.second->accept(xTau, acceptData))
439 catch (
const std::runtime_error&
error)
446 static std::atomic<uint64_t> warning_count (0
u);
447 auto mycount = ++ warning_count;
460 entry.second->fillHistogramCut(xTau);
477 ATH_MSG_WARNING(
"CreateControlPlots was set to true, but no valid file pointer was provided");
487 entry.second->writeControlHistograms();
501 m_hCutFlow = std::make_shared<TH1F>(
"hCutFlow",
"CutFlow;; events",iNBins+1,0,iNBins+1);
510 m_hCutFlow->GetXaxis()->SetBinLabel(iNBins,
entry.second->getName().c_str());
516 template<
typename T,
typename U>
519 if (!vRegion.empty())
522 vRegion.push_back(tMin);
524 vRegion.push_back(-std::numeric_limits<T>::infinity());
527 vRegion.push_back(tMax);
529 vRegion.push_back(std::numeric_limits<T>::infinity());
533 template<
typename T,
typename U>
536 if (!vRegion.empty())
539 vRegion.push_back(tVal);
546 unsigned int iNumRegion = vRegion.size()/2;
547 for(
unsigned int iRegion = 0; iRegion < iNumRegion; iRegion++ )
549 ATH_MSG_DEBUG( sCutName<<
": " << vRegion.at(iRegion*2) <<
" to " << vRegion.at(iRegion*2+1) );
557 for (
auto tVal : vRegion)
581 ATH_MSG_ERROR(
"jet ID working point "<<sJetIDWP<<
" is unknown, the JetIDWP cut will not accept any tau!" );
593 ATH_MSG_ERROR(
"electron ID working point " << sEleIDWP <<
" is unknown, the EleIDWP cut will not accept any tau!" );
607 return "JETIDRNNVERYLOOSE";
609 return "JETIDRNNLOOSE";
611 return "JETIDRNNMEDIUM";
613 return "JETIDRNNTIGHT";
615 return "JETIDGNTAUVERYLOOSE";
617 return "JETIDGNTAULOOSE";
619 return "JETIDGNTAUMEDIUM";
621 return "JETIDGNTAUTIGHT";
624 ATH_MSG_WARNING(
"JetID working point with enum " << iJetIDWP <<
" is unknown, the JetIDWP cut will not accept any tau!" );
639 return "ELEIDRNNLOOSE";
641 return "ELEIDRNNMEDIUM";
643 return "ELEIDRNNTIGHT";
645 ATH_MSG_WARNING(
"EleID working point with enum " << iEleIDWP <<
" is unknown, the EleIDWP cut will not accept any tau!" );