ATLAS Offline Software
IsolationConditionFormula.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
3  */
4 
6 
7 #include <TF1.h>
8 #include <TH3.h>
9 #include <TString.h>
10 
11 #include <algorithm>
12 #include <cmath>
13 
14 namespace CP {
15  IsolationConditionFormula::IsolationConditionFormula(const std::string& name, xAOD::Iso::IsolationType isoType, const std::string& cutFunction,
16  bool invertCut, const std::string& isoDecSuffix) :
17  IsolationCondition(name, isoType, isoDecSuffix),
18  m_cutFunction (std::make_unique<TF1>(cutFunction.c_str(), cutFunction.c_str())),
19  m_invertCut (invertCut)
20  {
21  }
22  IsolationConditionFormula::IsolationConditionFormula(const std::string& name, const std::string& isoType, const std::string& cutFunction,
23  bool invertCut, const std::string& isoDecSuffix) :
24  IsolationCondition(name, isoType, isoDecSuffix),
25  m_cutFunction (std::make_unique<TF1>(cutFunction.c_str(), cutFunction.c_str())),
26  m_invertCut (invertCut)
27  {
28  }
30  const float cutVal = m_cutFunction->Eval(x.pt());
31  const FloatAccessor& acc = accessor();
32  if (!acc.isAvailable(x)) {
33  ATH_MSG_WARNING(__FILE__<<":"<<__LINE__<<"Accessor "<<SG::AuxTypeRegistry::instance().getName(acc.auxid())
34  <<" is not available. Expected when using primary AODs, post-p3793 derivations (only for *FixedRad or FixedCutPflow* for electrons), "
35  <<" pre-p3517 derivations (only for FC*), or pre-p3830 derivations (for other electron WPs)");
36  if (!m_isoDecSuffix.empty()) throw std::runtime_error ("IsolationConditionCombined: IsolationSelectionTool property 'IsoDecSuffix' is set to " + m_isoDecSuffix + ". Must run on derivation made with IsolationCloseByCorrection to create the isolation variables with this suffix, or remove 'IsoDecSuffix'. ");
37  return false;
38  }
39  if (!m_invertCut) return acc(x) <= cutVal;
40  return acc(x) > cutVal;
41  }
42 
44  const float cutVal = m_cutFunction->Eval(x.pt);
45  if (!m_invertCut) return x.isolationValues.at(type()) <= cutVal;
46  return x.isolationValues.at(type()) > cutVal;
47  }
48 
49 } // namespace CP
SG::AuxTypeRegistry::instance
static AuxTypeRegistry & instance()
Return the singleton registry instance.
Definition: AuxTypeRegistry.cxx:639
make_unique
std::unique_ptr< T > make_unique(Args &&... args)
Definition: SkimmingToolEXOT5.cxx:23
SG::ConstAccessor
Helper class to provide constant type-safe access to aux data.
Definition: ConstAccessor.h:55
xAOD::IParticle
Class providing the definition of the 4-vector interface.
Definition: Event/xAOD/xAODBase/xAODBase/IParticle.h:41
CP::IsolationCondition::type
xAOD::Iso::IsolationType type(unsigned int n=0) const
Definition: IsolationCondition.cxx:37
IsolationConditionFormula.h
x
#define x
CP::IsolationConditionFormula::m_cutFunction
std::shared_ptr< TF1 > m_cutFunction
Definition: IsolationConditionFormula.h:28
CP
Select isolated Photons, Electrons and Muons.
Definition: Control/xAODRootAccess/xAODRootAccess/TEvent.h:48
dumpTruth.getName
getName
Definition: dumpTruth.py:34
CP::IsolationCondition
Definition: IsolationCondition.h:30
CP::strObj
Definition: IsolationCondition.h:23
xAOD::Iso::IsolationType
IsolationType
Overall enumeration for isolation types in xAOD files.
Definition: IsolationType.h:26
AthenaPoolTestRead.acc
acc
Definition: AthenaPoolTestRead.py:16
CP::IsolationConditionFormula::accept
virtual bool accept(const xAOD::IParticle &x) const override
Definition: IsolationConditionFormula.cxx:29
CP::IsolationCondition::accessor
const FloatAccessor & accessor(unsigned int n=0) const
Definition: IsolationCondition.cxx:38
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:228
CP::IsolationConditionFormula::IsolationConditionFormula
IsolationConditionFormula(const std::string &name, xAOD::Iso::IsolationType isoType, const std::string &cutFunction, bool invertCut=false, const std::string &isoDecSuffix="")
Definition: IsolationConditionFormula.cxx:15
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition: AthMsgStreamMacros.h:32
CP::IsolationCondition::m_isoDecSuffix
std::string m_isoDecSuffix
Definition: IsolationCondition.h:56
CP::IsolationConditionFormula::m_invertCut
bool m_invertCut
Definition: IsolationConditionFormula.h:29