14 #include "THashList.h"
22 , m_sJetIDWP(
"JETIDNONE")
23 , m_sEleIDWP(
"ELEIDNONE")
25 , m_aAccept(
"TauSelection" )
47 bool bConfigViaProperties =
false;
48 if (!bConfigViaProperties and !
m_vPtRegion.empty()) bConfigViaProperties =
true;
49 if (!bConfigViaProperties and !std::isnan(
m_dPtMin.value())) bConfigViaProperties =
true;
50 if (!bConfigViaProperties and !std::isnan(
m_dPtMax.value())) bConfigViaProperties =
true;
51 if (!bConfigViaProperties and !
m_vAbsEtaRegion.empty()) bConfigViaProperties =
true;
52 if (!bConfigViaProperties and !std::isnan(
m_dAbsEtaMin.value())) bConfigViaProperties =
true;
53 if (!bConfigViaProperties and !std::isnan(
m_dAbsEtaMax.value())) bConfigViaProperties =
true;
54 if (!bConfigViaProperties and !
m_vAbsCharges.empty()) bConfigViaProperties =
true;
55 if (!bConfigViaProperties and !std::isnan(
m_iAbsCharge.value())) bConfigViaProperties =
true;
56 if (!bConfigViaProperties and !
m_vNTracks.empty()) bConfigViaProperties =
true;
57 if (!bConfigViaProperties and !std::isnan(
m_iNTrack.value())) bConfigViaProperties =
true;
59 if (!bConfigViaProperties and !std::isnan(
m_dJetRNNSigTransMin.value())) bConfigViaProperties =
true;
60 if (!bConfigViaProperties and !std::isnan(
m_dJetRNNSigTransMax.value())) bConfigViaProperties =
true;
62 if (!bConfigViaProperties and !std::isnan(
m_dGNTauSigTransMin.value())) bConfigViaProperties =
true;
63 if (!bConfigViaProperties and !std::isnan(
m_dGNTauSigTransMax.value())) bConfigViaProperties =
true;
64 if (!bConfigViaProperties and
m_iJetIDWP != 0) bConfigViaProperties =
true;
66 if (!bConfigViaProperties and !std::isnan(
m_dEleRNNSigTransMin.value())) bConfigViaProperties =
true;
67 if (!bConfigViaProperties and !std::isnan(
m_dEleRNNSigTransMax.value())) bConfigViaProperties =
true;
68 if (!bConfigViaProperties and
m_iEleIDWP != 0) bConfigViaProperties =
true;
69 if (!bConfigViaProperties and
m_bMuonOLR) 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/main/PhysicsAnalysis/TauID/TauAnalysisTools/doc/README-TauSelectionTool.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/main/PhysicsAnalysis/TauID/TauAnalysisTools/doc/README-TauSelectionTool.rst");
82 return StatusCode::SUCCESS;
85 if (bConfigViaConfigFile)
91 ATH_MSG_WARNING(
"Config file for TauSelectionTool with path "<<sInputFilePath<<
" does not contain an empty last line. The tool might not be properly configured!");
93 rEnv.ReadFile(sInputFilePath.c_str(),
96 std::vector<std::string> vCuts;
99 if (rEnv.Defined(
"SelectionCuts"))
103 auto lList = rEnv.GetTable();
104 for( Int_t
i = 0;
i < lList->GetEntries(); ++
i )
106 vCuts.push_back( lList->At(
i )->GetName() );
110 int iSelectionCuts = 0;
112 for (
const std::string& sCut : vCuts)
114 if (sCut ==
"PtRegion")
116 iSelectionCuts = iSelectionCuts |
CutPt;
120 else if (sCut ==
"PtMin")
122 iSelectionCuts = iSelectionCuts |
CutPt;
124 m_dPtMin = rEnv.GetValue(
"PtMin",NAN);
126 else if (sCut ==
"PtMax")
128 iSelectionCuts = iSelectionCuts |
CutPt;
130 m_dPtMax = rEnv.GetValue(
"PtMax",NAN);
132 else if (sCut ==
"AbsEtaRegion")
134 iSelectionCuts = iSelectionCuts |
CutAbsEta;
138 else if (sCut ==
"AbsEtaMin")
140 iSelectionCuts = iSelectionCuts |
CutAbsEta;
144 else if (sCut ==
"AbsEtaMax")
146 iSelectionCuts = iSelectionCuts |
CutAbsEta;
150 else if (sCut ==
"AbsCharges")
156 else if (sCut ==
"AbsCharge")
162 else if (sCut ==
"NTracks")
164 iSelectionCuts = iSelectionCuts |
CutNTrack;
168 else if (sCut ==
"NTrack")
170 iSelectionCuts = iSelectionCuts |
CutNTrack;
174 else if (sCut ==
"JetRNNSigTransRegion")
180 else if (sCut ==
"JetRNNSigTransMin")
186 else if (sCut ==
"JetRNNSigTransMax")
192 else if (sCut ==
"GNTauSigTransRegion")
201 else if (sCut ==
"GNTauSigTransMin")
210 else if (sCut ==
"GNTauSigTransMax")
219 else if (sCut ==
"EleRNNSigTransRegion")
225 else if (sCut ==
"EleRNNSigTransMin")
231 else if (sCut ==
"EleRNNSigTransMax")
237 else if (sCut ==
"JetIDWP")
245 for (
const std::string& checkCut : vCuts){
246 if (checkCut.find(
"SigTrans") != std::string::npos) {
247 ATH_MSG_ERROR(
"Misconfig due to JetIDWP and SigTrans cuts both present in the config file. Please CHECK carefully config file again");
248 return StatusCode::FAILURE;
252 else if (sCut ==
"EleIDWP")
258 else if (sCut ==
"MuonOLR")
275 if(
m_sJetIDWP.find(
"GNTAU") != std::string::npos)
296 using map_type = std::map<SelectionCuts, std::unique_ptr<TauAnalysisTools::TauSelectionCut>>;
297 using pair_type = map_type::value_type;
299 pair_type elements[] =
301 {
CutPt, std::make_unique<TauAnalysisTools::TauSelectionCutPt>(
this)},
302 {
CutAbsEta, std::make_unique<TauAnalysisTools::TauSelectionCutAbsEta>(
this)},
303 {
CutAbsCharge, std::make_unique<TauAnalysisTools::TauSelectionCutAbsCharge>(
this)},
304 {
CutNTrack, std::make_unique<TauAnalysisTools::TauSelectionCutNTracks>(
this)},
306 {
CutGNTauScoreSigTrans, std::make_unique<TauAnalysisTools::TauSelectionCutGNTauScoreSigTrans>(
this)},
307 {
CutJetIDWP, std::make_unique<TauAnalysisTools::TauSelectionCutJetIDWP>(
this)},
309 {
CutEleIDWP, std::make_unique<TauAnalysisTools::TauSelectionCutEleIDWP>(
this)},
310 {
CutMuonOLR, std::make_unique<TauAnalysisTools::TauSelectionCutMuonOLR>(
this)}
313 m_cMap = { std::make_move_iterator(
begin(elements) ), std::make_move_iterator(
end(elements) ) };
338 std::string sCuts =
"";
361 return StatusCode::SUCCESS;
368 return StatusCode::SUCCESS;
391 ATH_MSG_FATAL(
"accept(...) Failed to cast particle to tau" );
412 entry.second->fillHistogramCutPre(xTau);
420 if (!
entry.second->accept(xTau, acceptData))
434 catch (
const std::runtime_error&
error)
441 static std::atomic<uint64_t> warning_count (0
u);
442 auto mycount = ++ warning_count;
455 entry.second->fillHistogramCut(xTau);
472 ATH_MSG_WARNING(
"CreateControlPlots was set to true, but no valid file pointer was provided");
482 entry.second->writeControlHistograms();
496 m_hCutFlow = std::make_shared<TH1F>(
"hCutFlow",
"CutFlow;; events",iNBins+1,0,iNBins+1);
505 m_hCutFlow->GetXaxis()->SetBinLabel(iNBins,
entry.second->getName().c_str());
511 template<
typename T,
typename U>
514 if (!vRegion.empty())
517 vRegion.push_back(tMin);
519 vRegion.push_back(-std::numeric_limits<T>::infinity());
522 vRegion.push_back(tMax);
524 vRegion.push_back(std::numeric_limits<T>::infinity());
528 template<
typename T,
typename U>
531 if (!vRegion.empty())
534 vRegion.push_back(tVal);
541 unsigned int iNumRegion = vRegion.size()/2;
542 for(
unsigned int iRegion = 0; iRegion < iNumRegion; iRegion++ )
544 ATH_MSG_DEBUG( sCutName<<
": " << vRegion.at(iRegion*2) <<
" to " << vRegion.at(iRegion*2+1) );
552 for (
auto tVal : vRegion)
576 ATH_MSG_ERROR(
"jet ID working point "<<sJetIDWP<<
" is unknown, the JetIDWP cut will not accept any tau!" );
588 ATH_MSG_ERROR(
"electron ID working point " << sEleIDWP <<
" is unknown, the EleIDWP cut will not accept any tau!" );
602 return "JETIDRNNVERYLOOSE";
604 return "JETIDRNNLOOSE";
606 return "JETIDRNNMEDIUM";
608 return "JETIDRNNTIGHT";
610 return "JETIDGNTAUVERYLOOSE";
612 return "JETIDGNTAULOOSE";
614 return "JETIDGNTAUMEDIUM";
616 return "JETIDGNTAUTIGHT";
619 ATH_MSG_WARNING(
"JetID working point with enum " << iJetIDWP <<
" is unknown, the JetIDWP cut will not accept any tau!" );
634 return "ELEIDRNNLOOSE";
636 return "ELEIDRNNMEDIUM";
638 return "ELEIDRNNTIGHT";
640 ATH_MSG_WARNING(
"EleID working point with enum " << iEleIDWP <<
" is unknown, the EleIDWP cut will not accept any tau!" );