14 #include "THashList.h"
25 , m_sJetIDWP(
"JETIDNONE")
26 , m_sEleIDWP(
"ELEIDNONE")
28 , m_aAccept(
"TauSelection" )
50 bool bConfigViaProperties =
false;
51 if (!bConfigViaProperties and !
m_vPtRegion.empty()) bConfigViaProperties =
true;
52 if (!bConfigViaProperties and !std::isnan(
m_dPtMin.value())) bConfigViaProperties =
true;
53 if (!bConfigViaProperties and !std::isnan(
m_dPtMax.value())) bConfigViaProperties =
true;
54 if (!bConfigViaProperties and !
m_vAbsEtaRegion.empty()) bConfigViaProperties =
true;
55 if (!bConfigViaProperties and !std::isnan(
m_dAbsEtaMin.value())) bConfigViaProperties =
true;
56 if (!bConfigViaProperties and !std::isnan(
m_dAbsEtaMax.value())) bConfigViaProperties =
true;
57 if (!bConfigViaProperties and !
m_vAbsCharges.empty()) bConfigViaProperties =
true;
58 if (!bConfigViaProperties and !std::isnan(
m_iAbsCharge.value())) bConfigViaProperties =
true;
59 if (!bConfigViaProperties and !
m_vNTracks.empty()) bConfigViaProperties =
true;
60 if (!bConfigViaProperties and !std::isnan(
m_iNTrack.value())) bConfigViaProperties =
true;
62 if (!bConfigViaProperties and !std::isnan(
m_dJetRNNSigTransMin.value())) bConfigViaProperties =
true;
63 if (!bConfigViaProperties and !std::isnan(
m_dJetRNNSigTransMax.value())) bConfigViaProperties =
true;
65 if (!bConfigViaProperties and !std::isnan(
m_dGNTauSigTransMin.value())) bConfigViaProperties =
true;
66 if (!bConfigViaProperties and !std::isnan(
m_dGNTauSigTransMax.value())) bConfigViaProperties =
true;
67 if (!bConfigViaProperties and
m_iJetIDWP != 0) bConfigViaProperties =
true;
69 if (!bConfigViaProperties and !std::isnan(
m_dEleRNNSigTransMin.value())) bConfigViaProperties =
true;
70 if (!bConfigViaProperties and !std::isnan(
m_dEleRNNSigTransMax.value())) bConfigViaProperties =
true;
71 if (!bConfigViaProperties and
m_iEleIDWP != 0) bConfigViaProperties =
true;
72 if (!bConfigViaProperties and
m_bMuonOLR) bConfigViaProperties =
true;
74 if (bConfigViaConfigFile and bConfigViaProperties)
76 ATH_MSG_WARNING(
"Configured tool via setProperty and configuration file, which may lead to unexpected configuration.");
77 ATH_MSG_WARNING(
"In doubt check the configuration that is printed when the tool is initialized and the message level is set to debug");
78 ATH_MSG_WARNING(
"For further details please refer to the documentation:");
79 ATH_MSG_WARNING(
"https://gitlab.cern.ch/atlas/athena/blob/main/PhysicsAnalysis/TauID/TauAnalysisTools/doc/README-TauSelectionTool.rst");
81 if (!bConfigViaConfigFile and !bConfigViaProperties)
83 ATH_MSG_WARNING(
"No cut configuration provided, the tool will not do anything. For further details please refer to the documentation:");
84 ATH_MSG_WARNING(
"https://gitlab.cern.ch/atlas/athena/blob/main/PhysicsAnalysis/TauID/TauAnalysisTools/doc/README-TauSelectionTool.rst");
85 return StatusCode::SUCCESS;
88 if (bConfigViaConfigFile)
94 ATH_MSG_WARNING(
"Config file for TauSelectionTool with path "<<sInputFilePath<<
" does not contain an empty last line. The tool might not be properly configured!");
96 rEnv.ReadFile(sInputFilePath.c_str(),
99 std::vector<std::string> vCuts;
102 if (rEnv.Defined(
"SelectionCuts"))
106 auto lList = rEnv.GetTable();
107 for( Int_t
i = 0;
i < lList->GetEntries(); ++
i )
109 vCuts.push_back( lList->At(
i )->GetName() );
113 int iSelectionCuts = 0;
115 for (
const std::string& sCut : vCuts)
117 if (sCut ==
"PtRegion")
119 iSelectionCuts = iSelectionCuts |
CutPt;
123 else if (sCut ==
"PtMin")
125 iSelectionCuts = iSelectionCuts |
CutPt;
127 m_dPtMin = rEnv.GetValue(
"PtMin",NAN);
129 else if (sCut ==
"PtMax")
131 iSelectionCuts = iSelectionCuts |
CutPt;
133 m_dPtMax = rEnv.GetValue(
"PtMax",NAN);
135 else if (sCut ==
"AbsEtaRegion")
137 iSelectionCuts = iSelectionCuts |
CutAbsEta;
141 else if (sCut ==
"AbsEtaMin")
143 iSelectionCuts = iSelectionCuts |
CutAbsEta;
147 else if (sCut ==
"AbsEtaMax")
149 iSelectionCuts = iSelectionCuts |
CutAbsEta;
153 else if (sCut ==
"AbsCharges")
159 else if (sCut ==
"AbsCharge")
165 else if (sCut ==
"NTracks")
167 iSelectionCuts = iSelectionCuts |
CutNTrack;
171 else if (sCut ==
"NTrack")
173 iSelectionCuts = iSelectionCuts |
CutNTrack;
177 else if (sCut ==
"JetRNNSigTransRegion")
183 else if (sCut ==
"JetRNNSigTransMin")
189 else if (sCut ==
"JetRNNSigTransMax")
195 else if (sCut ==
"GNTauSigTransRegion")
204 else if (sCut ==
"GNTauSigTransMin")
213 else if (sCut ==
"GNTauSigTransMax")
222 else if (sCut ==
"EleRNNSigTransRegion")
228 else if (sCut ==
"EleRNNSigTransMin")
234 else if (sCut ==
"EleRNNSigTransMax")
240 else if (sCut ==
"JetIDWP")
248 for (
const std::string& checkCut : vCuts){
249 if (checkCut.find(
"SigTrans") != std::string::npos) {
250 ATH_MSG_ERROR(
"Misconfig due to JetIDWP and SigTrans cuts both present in the config file. Please CHECK carefully config file again");
251 return StatusCode::FAILURE;
255 else if (sCut ==
"EleIDWP")
261 else if (sCut ==
"MuonOLR")
278 if(
m_sJetIDWP.find(
"GNTAU") != std::string::npos)
299 using map_type = std::map<SelectionCuts, std::unique_ptr<TauAnalysisTools::TauSelectionCut>>;
300 using pair_type = map_type::value_type;
302 pair_type elements[] =
304 {
CutPt, std::make_unique<TauAnalysisTools::TauSelectionCutPt>(
this)},
305 {
CutAbsEta, std::make_unique<TauAnalysisTools::TauSelectionCutAbsEta>(
this)},
306 {
CutAbsCharge, std::make_unique<TauAnalysisTools::TauSelectionCutAbsCharge>(
this)},
307 {
CutNTrack, std::make_unique<TauAnalysisTools::TauSelectionCutNTracks>(
this)},
309 {
CutGNTauScoreSigTrans, std::make_unique<TauAnalysisTools::TauSelectionCutGNTauScoreSigTrans>(
this)},
310 {
CutJetIDWP, std::make_unique<TauAnalysisTools::TauSelectionCutJetIDWP>(
this)},
312 {
CutEleIDWP, std::make_unique<TauAnalysisTools::TauSelectionCutEleIDWP>(
this)},
313 {
CutMuonOLR, std::make_unique<TauAnalysisTools::TauSelectionCutMuonOLR>(
this)}
316 m_cMap = { std::make_move_iterator(
begin(elements) ), std::make_move_iterator(
end(elements) ) };
341 std::string sCuts =
"";
364 return StatusCode::SUCCESS;
371 return StatusCode::SUCCESS;
394 ATH_MSG_FATAL(
"accept(...) Failed to cast particle to tau" );
415 entry.second->fillHistogramCutPre(xTau);
423 if (!
entry.second->accept(xTau, acceptData))
437 catch (
const std::runtime_error&
error)
444 static std::atomic<uint64_t> warning_count (0
u);
445 auto mycount = ++ warning_count;
458 entry.second->fillHistogramCut(xTau);
475 ATH_MSG_WARNING(
"CreateControlPlots was set to true, but no valid file pointer was provided");
485 entry.second->writeControlHistograms();
499 m_hCutFlow = std::make_shared<TH1F>(
"hCutFlow",
"CutFlow;; events",iNBins+1,0,iNBins+1);
508 m_hCutFlow->GetXaxis()->SetBinLabel(iNBins,
entry.second->getName().c_str());
514 template<
typename T,
typename U>
517 if (!vRegion.empty())
520 vRegion.push_back(tMin);
522 vRegion.push_back(-std::numeric_limits<T>::infinity());
525 vRegion.push_back(tMax);
527 vRegion.push_back(std::numeric_limits<T>::infinity());
531 template<
typename T,
typename U>
534 if (!vRegion.empty())
537 vRegion.push_back(tVal);
544 unsigned int iNumRegion = vRegion.size()/2;
545 for(
unsigned int iRegion = 0; iRegion < iNumRegion; iRegion++ )
547 ATH_MSG_DEBUG( sCutName<<
": " << vRegion.at(iRegion*2) <<
" to " << vRegion.at(iRegion*2+1) );
555 for (
auto tVal : vRegion)
579 ATH_MSG_ERROR(
"jet ID working point "<<sJetIDWP<<
" is unknown, the JetIDWP cut will not accept any tau!" );
591 ATH_MSG_ERROR(
"electron ID working point " << sEleIDWP <<
" is unknown, the EleIDWP cut will not accept any tau!" );
605 return "JETIDRNNVERYLOOSE";
607 return "JETIDRNNLOOSE";
609 return "JETIDRNNMEDIUM";
611 return "JETIDRNNTIGHT";
613 return "JETIDGNTAUVERYLOOSE";
615 return "JETIDGNTAULOOSE";
617 return "JETIDGNTAUMEDIUM";
619 return "JETIDGNTAUTIGHT";
622 ATH_MSG_WARNING(
"JetID working point with enum " << iJetIDWP <<
" is unknown, the JetIDWP cut will not accept any tau!" );
637 return "ELEIDRNNLOOSE";
639 return "ELEIDRNNMEDIUM";
641 return "ELEIDRNNTIGHT";
643 ATH_MSG_WARNING(
"EleID working point with enum " << iEleIDWP <<
" is unknown, the EleIDWP cut will not accept any tau!" );