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/main/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/main/PhysicsAnalysis/TauID/TauAnalysisTools/doc/README-TauSelectionTool.rst");
110 return StatusCode::SUCCESS;
113 if (bConfigViaConfigFile)
119 ATH_MSG_WARNING(
"Config file for TauSelectionTool with path "<<sInputFilePath<<
" does not contain an empty last line. The tool might not be properly configured!");
121 rEnv.ReadFile(sInputFilePath.c_str(),
124 std::vector<std::string> vCuts;
127 if (rEnv.Defined(
"SelectionCuts"))
131 auto lList = rEnv.GetTable();
132 for( Int_t
i = 0;
i < lList->GetEntries(); ++
i )
134 vCuts.push_back( lList->At(
i )->GetName() );
138 int iSelectionCuts = 0;
140 for (
const std::string& sCut : vCuts)
142 if (sCut ==
"PtRegion")
144 iSelectionCuts = iSelectionCuts |
CutPt;
148 else if (sCut ==
"PtMin")
150 iSelectionCuts = iSelectionCuts |
CutPt;
152 m_dPtMin = rEnv.GetValue(
"PtMin",NAN);
154 else if (sCut ==
"PtMax")
156 iSelectionCuts = iSelectionCuts |
CutPt;
158 m_dPtMax = rEnv.GetValue(
"PtMax",NAN);
160 else if (sCut ==
"AbsEtaRegion")
162 iSelectionCuts = iSelectionCuts |
CutAbsEta;
166 else if (sCut ==
"AbsEtaMin")
168 iSelectionCuts = iSelectionCuts |
CutAbsEta;
172 else if (sCut ==
"AbsEtaMax")
174 iSelectionCuts = iSelectionCuts |
CutAbsEta;
178 else if (sCut ==
"AbsCharges")
184 else if (sCut ==
"AbsCharge")
190 else if (sCut ==
"NTracks")
192 iSelectionCuts = iSelectionCuts |
CutNTrack;
196 else if (sCut ==
"NTrack")
198 iSelectionCuts = iSelectionCuts |
CutNTrack;
202 else if (sCut ==
"JetRNNSigTransRegion")
208 else if (sCut ==
"JetRNNSigTransMin")
214 else if (sCut ==
"JetRNNSigTransMax")
220 else if (sCut ==
"GNTauSigTransRegion")
226 else if (sCut ==
"GNTauSigTransMin")
232 else if (sCut ==
"GNTauSigTransMax")
238 else if (sCut ==
"EleRNNRegion")
244 else if (sCut ==
"EleRNNMin")
250 else if (sCut ==
"EleRNNMax")
256 else if (sCut ==
"JetIDWP")
264 for (
const std::string& checkCut : vCuts){
265 if (checkCut.find(
"SigTrans") != std::string::npos) {
266 ATH_MSG_ERROR(
"Misconfig due to JetIDWP and SigTrans cuts both present in the config file. Please CHECK carefully config file again");
267 return StatusCode::FAILURE;
271 else if (sCut ==
"EleIDWP")
277 else if (sCut ==
"MuonOLR")
311 using map_type = std::map<SelectionCuts, std::unique_ptr<TauAnalysisTools::TauSelectionCut>>;
312 using pair_type = map_type::value_type;
314 pair_type elements[] =
316 {
CutPt, std::make_unique<TauAnalysisTools::TauSelectionCutPt>(
this)},
317 {
CutAbsEta, std::make_unique<TauAnalysisTools::TauSelectionCutAbsEta>(
this)},
318 {
CutAbsCharge, std::make_unique<TauAnalysisTools::TauSelectionCutAbsCharge>(
this)},
319 {
CutNTrack, std::make_unique<TauAnalysisTools::TauSelectionCutNTracks>(
this)},
321 {
CutGNTauScoreSigTrans, std::make_unique<TauAnalysisTools::TauSelectionCutGNTauScoreSigTrans>(
this)},
322 {
CutJetIDWP, std::make_unique<TauAnalysisTools::TauSelectionCutJetIDWP>(
this)},
323 {
CutEleRNNScore, std::make_unique<TauAnalysisTools::TauSelectionCutRNNEleScore>(
this)},
324 {
CutEleIDWP, std::make_unique<TauAnalysisTools::TauSelectionCutEleIDWP>(
this)},
325 {
CutMuonOLR, std::make_unique<TauAnalysisTools::TauSelectionCutMuonOLR>(
this)}
328 m_cMap = { std::make_move_iterator(
begin(elements) ), std::make_move_iterator(
end(elements) ) };
353 std::string sCuts =
"";
376 return StatusCode::SUCCESS;
383 return StatusCode::SUCCESS;
406 ATH_MSG_FATAL(
"accept(...) Failed to cast particle to tau" );
427 entry.second->fillHistogramCutPre(xTau);
435 if (!
entry.second->accept(xTau, acceptData))
449 catch (
const std::runtime_error&
error)
456 static std::atomic<uint64_t> warning_count (0
u);
457 auto mycount = ++ warning_count;
470 entry.second->fillHistogramCut(xTau);
487 ATH_MSG_WARNING(
"CreateControlPlots was set to true, but no valid file pointer was provided");
497 entry.second->writeControlHistograms();
511 m_hCutFlow = std::make_shared<TH1F>(
"hCutFlow",
"CutFlow;; events",iNBins+1,0,iNBins+1);
520 m_hCutFlow->GetXaxis()->SetBinLabel(iNBins,
entry.second->getName().c_str());
526 template<
typename T,
typename U>
529 if (!vRegion.empty())
532 vRegion.push_back(tMin);
534 vRegion.push_back(-std::numeric_limits<T>::infinity());
537 vRegion.push_back(tMax);
539 vRegion.push_back(std::numeric_limits<T>::infinity());
543 template<
typename T,
typename U>
546 if (!vRegion.empty())
549 vRegion.push_back(tVal);
556 unsigned int iNumRegion = vRegion.size()/2;
557 for(
unsigned int iRegion = 0; iRegion < iNumRegion; iRegion++ )
559 ATH_MSG_DEBUG( sCutName<<
": " << vRegion.at(iRegion*2) <<
" to " << vRegion.at(iRegion*2+1) );
567 for (
auto tVal : vRegion)
591 ATH_MSG_ERROR(
"jet ID working point "<<sJetIDWP<<
" is unknown, the JetIDWP cut will not accept any tau!" );
603 ATH_MSG_ERROR(
"electron ID working point " << sEleIDWP <<
" is unknown, the EleIDWP cut will not accept any tau!" );
617 return "JETIDRNNVERYLOOSE";
619 return "JETIDRNNLOOSE";
621 return "JETIDRNNMEDIUM";
623 return "JETIDRNNTIGHT";
625 return "JETIDGNTAUVERYLOOSE";
627 return "JETIDGNTAULOOSE";
629 return "JETIDGNTAUMEDIUM";
631 return "JETIDGNTAUTIGHT";
634 ATH_MSG_WARNING(
"JetID working point with enum " << iJetIDWP <<
" is unknown, the JetIDWP cut will not accept any tau!" );
649 return "ELEIDRNNLOOSE";
651 return "ELEIDRNNMEDIUM";
653 return "ELEIDRNNTIGHT";
655 ATH_MSG_WARNING(
"EleID working point with enum " << iEleIDWP <<
" is unknown, the EleIDWP cut will not accept any tau!" );