23DiTauSelectionTool::DiTauSelectionTool(
const std::string& name )
25 , m_sOmniIDWP(
"OMNIIDNONE")
27 , m_aAccept(
"DiTauSelection" )
44 bool bConfigViaProperties =
false;
45 if (!bConfigViaProperties and !std::isnan(
m_dPtMin.value())) bConfigViaProperties =
true;
46 if (!bConfigViaProperties and !
m_vAbsEtaRegion.empty()) bConfigViaProperties =
true;
47 if (!bConfigViaProperties and !std::isnan(
m_dAbsEtaMin.value())) bConfigViaProperties =
true;
48 if (!bConfigViaProperties and !std::isnan(
m_dAbsEtaMax.value())) bConfigViaProperties =
true;
49 if (!bConfigViaProperties and !std::isnan(
m_dNSubjetsMin.value())) bConfigViaProperties =
true;
50 if (!bConfigViaProperties and !
m_vAbsCharges.empty()) bConfigViaProperties =
true;
51 if (!bConfigViaProperties and !std::isnan(
m_iAbsCharge.value())) bConfigViaProperties =
true;
52 if (!bConfigViaProperties and !std::isnan(
m_dOmniScoreMin.value())) bConfigViaProperties =
true;
53 if (!bConfigViaProperties and
m_iOmniIDWP != 0) bConfigViaProperties =
true;
55 if (bConfigViaConfigFile and bConfigViaProperties)
57 ATH_MSG_ERROR(
"Configured tool via setProperty and configuration file, which may lead to unexpected configuration. Please setup the DiTauSelectionTool 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-DiTauSelectionTool.rst or contact the TauCP group.");
58 return StatusCode::FAILURE;
61 if (!bConfigViaConfigFile and !bConfigViaProperties)
63 ATH_MSG_WARNING(
"No cut configuration provided, the tool will not do anything. For further details please refer to the documentation:");
64 ATH_MSG_WARNING(
"https://gitlab.cern.ch/atlas/athena/blob/main/PhysicsAnalysis/TauID/TauAnalysisTools/doc/README-DiTauSelectionTool.rst");
67 if (bConfigViaConfigFile)
73 ATH_MSG_WARNING(
"Config file for DiTauSelectionTool with path "<<sInputFilePath<<
" does not contain an empty last line. The tool might not be properly configured!");
75 rEnv.ReadFile(sInputFilePath.c_str(),
78 std::vector<std::string> vCuts;
81 if (rEnv.Defined(
"SelectionCuts"))
85 auto lList = rEnv.GetTable();
86 for( Int_t i = 0; i < lList->GetEntries(); ++i )
88 vCuts.push_back( lList->At( i )->GetName() );
92 int iSelectionCuts = 0;
94 for (
const std::string& sCut : vCuts)
100 m_dPtMin = rEnv.GetValue(
"PtMin",NAN);
102 else if (sCut ==
"AbsEtaRegion")
108 else if (sCut ==
"AbsEtaMin")
114 else if (sCut ==
"AbsEtaMax")
120 else if (sCut ==
"NSubjetsMin")
126 else if (sCut ==
"AbsCharges")
132 else if (sCut ==
"AbsCharge")
138 else if (sCut ==
"OmniScoreMin")
145 for (
const std::string& checkCut : vCuts){
146 if (checkCut.find(
"OmniScoreRegion") != std::string::npos) {
147 ATH_MSG_ERROR(
"Misconfig due to OmniScoreRegion and OmniScoreMin cuts both present in the config file. Please CHECK carefully config file again and choose of the two");
148 return StatusCode::FAILURE;
155 else if (sCut ==
"OmniIDWP")
159 m_sOmniIDWP = rEnv.GetValue(
"OmniIDWP",
"OMNIIDNONE");
163 for (
const std::string& checkCut : vCuts){
164 if (checkCut.find(
"OmniScore") != std::string::npos) {
165 ATH_MSG_ERROR(
"Misconfig due to OmniIDWP and OmniScore cuts both present in the config file. Please CHECK carefully config file again");
166 return StatusCode::FAILURE;
186 using map_type = std::map<DiTauSelectionCuts, std::unique_ptr<TauAnalysisTools::DiTauSelectionCut>>;
187 using pair_type = map_type::value_type;
189 pair_type elements[] =
191 {
DiTauCutPt, std::make_unique<TauAnalysisTools::DiTauSelectionCutPt>(
this)},
192 {
DiTauCutAbsEta, std::make_unique<TauAnalysisTools::DiTauSelectionCutAbsEta>(
this)},
193 {
DiTauCutNSubjets, std::make_unique<TauAnalysisTools::DiTauSelectionCutNSubjets>(
this)},
194 {
DiTauCutAbsCharge, std::make_unique<TauAnalysisTools::DiTauSelectionCutAbsCharge>(
this)},
195 {
DiTauCutOmniScore, std::make_unique<TauAnalysisTools::DiTauSelectionCutOmniScore>(
this)},
196 {
DiTauCutOmniIDWP, std::make_unique<TauAnalysisTools::DiTauSelectionCutOmniIDWP>(
this)},
199 m_cMap = { std::make_move_iterator( begin(elements) ), std::make_move_iterator( end(elements) ) };
215 std::string sCuts =
"";
228 for (
const auto& entry :
m_cMap ) {
234 return StatusCode::SUCCESS;
241 return StatusCode::SUCCESS;
264 ATH_MSG_FATAL(
"accept(...) Failed to cast particle to tau" );
284 for (
const auto& entry :
m_cMap)
285 entry.second->fillHistogramCutPre(xDiTau);
289 for (
const auto& entry :
m_cMap)
293 if (!entry.second->accept(xDiTau, acceptData))
307 catch (
const std::runtime_error&
error)
314 static std::atomic<uint64_t> warning_count (0u);
315 auto mycount = ++ warning_count;
327 for (
const auto& entry :
m_cMap)
328 entry.second->fillHistogramCut(xDiTau);
345 ATH_MSG_WARNING(
"CreateControlPlots was set to true, but no valid file pointer was provided");
349 m_fOutFile->mkdir((this->name()+
"_control").c_str());
350 m_fOutFile->cd((this->name()+
"_control").c_str());
354 for (
const auto& entry :
m_cMap)
355 entry.second->writeControlHistograms();
365 for (
const auto& entry :
m_cMap)
369 m_hCutFlow = std::make_shared<TH1F>(
"hCutFlow",
"CutFlow;; events",iNBins+1,0,iNBins+1);
375 for (
const auto& entry :
m_cMap)
378 m_hCutFlow->GetXaxis()->SetBinLabel(iNBins, entry.second->getName().c_str());
384template<
typename T,
typename U>
387 if (!vRegion.empty())
389 if (!std::isnan(tMin))
390 vRegion.push_back(tMin);
392 vRegion.push_back(-std::numeric_limits<T>::infinity());
394 if (!std::isnan(tMax))
395 vRegion.push_back(tMax);
397 vRegion.push_back(std::numeric_limits<T>::infinity());
401template<
typename T,
typename U>
404 if (!vRegion.empty())
407 vRegion.push_back(tVal);
414 unsigned int iNumRegion = vRegion.size()/2;
415 for(
unsigned int iRegion = 0; iRegion < iNumRegion; iRegion++ )
417 ATH_MSG_DEBUG( sCutName<<
": " << vRegion.at(iRegion*2) <<
" to " << vRegion.at(iRegion*2+1) );
425 for (
auto tVal : vRegion)
439 if (sOmniIDWP ==
"OMNIIDNONE")
return int(
OMNIIDNONE);
441 else if (sOmniIDWP ==
"OMNIIDLOOSE")
return int(
OMNIIDLOOSE);
442 else if (sOmniIDWP ==
"OMNIIDMEDIUM")
return int(
OMNIIDMEDIUM);
443 else if (sOmniIDWP ==
"OMNIIDTIGHT")
return int(
OMNIIDTIGHT);
445 ATH_MSG_ERROR(
"omni ID working point "<<sOmniIDWP<<
" is unknown, the OmniIDWP cut will not accept any ditau!" );
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_DEBUG(x,...)
#define ATH_MSG_ERROR(x,...)
#define ATH_MSG_WARNING(x,...)
#define ATH_MSG_INFO(x,...)
#define ATH_MSG_FATAL(x,...)
std::string PathResolverFindCalibFile(const std::string &logical_file_name)
Class providing the definition of the 4-vector interface.
virtual Type::ObjectType type() const =0
The type of the object as a simple enumeration.
@ Jet
The object is a jet.
DiTauJet_v1 DiTauJet
Definition of the current version.