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;
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_ERROR(
"Configured tool via setProperty and configuration file, which may lead to unexpected configuration. Please setup the TauSelectionTool using only one of the two methods. For further details please refer to the documentation https://gitlab.cern.ch/atlas/athena/blob/main/PhysicsAnalysis/TauID/TauAnalysisTools/doc/README-TauSelectionTool.rst or contact the TauCP group.");
74 return StatusCode::FAILURE;
76 if (!bConfigViaConfigFile and !bConfigViaProperties)
78 ATH_MSG_WARNING(
"No cut configuration provided, the tool will not do anything. 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");
80 return StatusCode::SUCCESS;
83 if (bConfigViaConfigFile)
89 ATH_MSG_WARNING(
"Config file for TauSelectionTool with path "<<sInputFilePath<<
" does not contain an empty last line. The tool might not be properly configured!");
91 rEnv.ReadFile(sInputFilePath.c_str(),
94 std::vector<std::string> vCuts;
97 if (rEnv.Defined(
"SelectionCuts"))
101 auto lList = rEnv.GetTable();
102 for( Int_t
i = 0;
i < lList->GetEntries(); ++
i )
104 vCuts.push_back( lList->At(
i )->GetName() );
108 int iSelectionCuts = 0;
110 for (
const std::string& sCut : vCuts)
112 if (sCut ==
"PtRegion")
114 iSelectionCuts = iSelectionCuts |
CutPt;
118 else if (sCut ==
"PtMin")
120 iSelectionCuts = iSelectionCuts |
CutPt;
122 m_dPtMin = rEnv.GetValue(
"PtMin",NAN);
124 else if (sCut ==
"PtMax")
126 iSelectionCuts = iSelectionCuts |
CutPt;
128 m_dPtMax = rEnv.GetValue(
"PtMax",NAN);
130 else if (sCut ==
"AbsEtaRegion")
132 iSelectionCuts = iSelectionCuts |
CutAbsEta;
136 else if (sCut ==
"AbsEtaMin")
138 iSelectionCuts = iSelectionCuts |
CutAbsEta;
142 else if (sCut ==
"AbsEtaMax")
144 iSelectionCuts = iSelectionCuts |
CutAbsEta;
148 else if (sCut ==
"AbsCharges")
154 else if (sCut ==
"AbsCharge")
160 else if (sCut ==
"NTracks")
162 iSelectionCuts = iSelectionCuts |
CutNTrack;
166 else if (sCut ==
"NTrack")
168 iSelectionCuts = iSelectionCuts |
CutNTrack;
172 else if (sCut ==
"JetRNNSigTransRegion")
178 else if (sCut ==
"JetRNNSigTransMin")
184 else if (sCut ==
"JetRNNSigTransMax")
190 else if (sCut ==
"GNTauSigTransRegion")
199 else if (sCut ==
"GNTauSigTransMin")
208 else if (sCut ==
"GNTauSigTransMax")
217 else if (sCut ==
"EleRNNSigTransRegion")
223 else if (sCut ==
"EleRNNSigTransMin")
229 else if (sCut ==
"EleRNNSigTransMax")
235 else if (sCut ==
"JetIDWP")
242 for (
const std::string& checkCut : vCuts){
243 if (checkCut.find(
"SigTrans") != std::string::npos) {
244 ATH_MSG_ERROR(
"Misconfig due to JetIDWP and SigTrans cuts both present in the config file. Please CHECK carefully config file again");
245 return StatusCode::FAILURE;
249 else if (sCut ==
"EleIDWP")
255 else if (sCut ==
"MuonOLR")
272 if(
m_sJetIDWP.find(
"GNTAU") != std::string::npos)
293 using map_type = std::map<SelectionCuts, std::unique_ptr<TauAnalysisTools::TauSelectionCut>>;
294 using pair_type = map_type::value_type;
296 pair_type elements[] =
298 {
CutPt, std::make_unique<TauAnalysisTools::TauSelectionCutPt>(
this)},
299 {
CutAbsEta, std::make_unique<TauAnalysisTools::TauSelectionCutAbsEta>(
this)},
300 {
CutAbsCharge, std::make_unique<TauAnalysisTools::TauSelectionCutAbsCharge>(
this)},
301 {
CutNTrack, std::make_unique<TauAnalysisTools::TauSelectionCutNTracks>(
this)},
303 {
CutGNTauScoreSigTrans, std::make_unique<TauAnalysisTools::TauSelectionCutGNTauScoreSigTrans>(
this)},
304 {
CutJetIDWP, std::make_unique<TauAnalysisTools::TauSelectionCutJetIDWP>(
this)},
306 {
CutEleIDWP, std::make_unique<TauAnalysisTools::TauSelectionCutEleIDWP>(
this)},
307 {
CutMuonOLR, std::make_unique<TauAnalysisTools::TauSelectionCutMuonOLR>(
this)}
310 m_cMap = { std::make_move_iterator(
begin(elements) ), std::make_move_iterator(
end(elements) ) };
335 std::string sCuts =
"";
358 return StatusCode::SUCCESS;
365 return StatusCode::SUCCESS;
388 ATH_MSG_FATAL(
"accept(...) Failed to cast particle to tau" );
409 entry.second->fillHistogramCutPre(xTau);
417 if (!
entry.second->accept(xTau, acceptData))
431 catch (
const std::runtime_error&
error)
438 static std::atomic<uint64_t> warning_count (0
u);
439 auto mycount = ++ warning_count;
452 entry.second->fillHistogramCut(xTau);
469 ATH_MSG_WARNING(
"CreateControlPlots was set to true, but no valid file pointer was provided");
479 entry.second->writeControlHistograms();
493 m_hCutFlow = std::make_shared<TH1F>(
"hCutFlow",
"CutFlow;; events",iNBins+1,0,iNBins+1);
502 m_hCutFlow->GetXaxis()->SetBinLabel(iNBins,
entry.second->getName().c_str());
508 template<
typename T,
typename U>
511 if (!vRegion.empty())
514 vRegion.push_back(tMin);
516 vRegion.push_back(-std::numeric_limits<T>::infinity());
519 vRegion.push_back(tMax);
521 vRegion.push_back(std::numeric_limits<T>::infinity());
525 template<
typename T,
typename U>
528 if (!vRegion.empty())
531 vRegion.push_back(tVal);
538 unsigned int iNumRegion = vRegion.size()/2;
539 for(
unsigned int iRegion = 0; iRegion < iNumRegion; iRegion++ )
541 ATH_MSG_DEBUG( sCutName<<
": " << vRegion.at(iRegion*2) <<
" to " << vRegion.at(iRegion*2+1) );
549 for (
auto tVal : vRegion)
573 ATH_MSG_ERROR(
"jet ID working point "<<sJetIDWP<<
" is unknown, the JetIDWP cut will not accept any tau!" );
585 ATH_MSG_ERROR(
"electron ID working point " << sEleIDWP <<
" is unknown, the EleIDWP cut will not accept any tau!" );
597 return "JETIDRNNVERYLOOSE";
599 return "JETIDRNNLOOSE";
601 return "JETIDRNNMEDIUM";
603 return "JETIDRNNTIGHT";
605 return "JETIDGNTAUVERYLOOSE";
607 return "JETIDGNTAULOOSE";
609 return "JETIDGNTAUMEDIUM";
611 return "JETIDGNTAUTIGHT";
614 ATH_MSG_WARNING(
"JetID working point with enum " << iJetIDWP <<
" is unknown, the JetIDWP cut will not accept any tau!" );
629 return "ELEIDRNNLOOSE";
631 return "ELEIDRNNMEDIUM";
633 return "ELEIDRNNTIGHT";
635 ATH_MSG_WARNING(
"EleID working point with enum " << iEleIDWP <<
" is unknown, the EleIDWP cut will not accept any tau!" );