ATLAS Offline Software
IsolationConditionHist.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
3  */
4 
5 // $Id: IsolationConditionHist.cxx 678002 2015-06-24 15:39:36Z morrisj $
7 // #include <xAODPrimitives/tools/getIsolationAccessor.h>
8 #include <TF1.h>
9 #include <TH3.h>
10 
11 #include <algorithm>
12 #include <cmath>
13 
15 
16 namespace CP {
17  constexpr float MeVtoGeV = 1.e-3;
18  IsolationConditionHist::IsolationConditionHist(const std::string& name, xAOD::Iso::IsolationType isoType, const std::string& isolationFunction,
19  std::unique_ptr<TH3F> efficiencyHisto3D) :
20  IsolationCondition(name, isoType),
21  m_efficiencyHisto3D(std::move(efficiencyHisto3D)),
22  m_isolationFunction (std::make_unique<TF1>(isolationFunction.c_str(), isolationFunction.c_str(), 0.0, 1000.0))
23  {
25  std::string xtitle(m_efficiencyHisto3D->GetXaxis()->GetTitle());
26  m_ptGeV = (xtitle.find("GeV") != std::string::npos);
27  }
29  const float cutValue = getCutValue(x.pt(), x.eta());
30  return accessor()(x) <= cutValue * x.pt();
31  }
32 
34  const float cutValue = getCutValue(x.pt, x.eta);
35  return x.isolationValues[type()] <= cutValue * x.pt;
36  }
37 
38  float IsolationConditionHist::getCutValue(const float pt, const float eta) const {
39  float xpt = pt * MeVtoGeV; // convert to GeV
40  if (!m_interp)
41  return m_efficiencyHisto3D->GetBinContent(m_efficiencyHisto3D->GetXaxis()->FindBin((m_ptGeV ? xpt : pt)),
42  m_efficiencyHisto3D->GetYaxis()->FindBin(eta),
43  std::min(int(m_isolationFunction->Eval(xpt)), 99));
44  return m_interp->Interpol3d(m_ptGeV ? xpt : pt, eta, std::min(m_isolationFunction->Eval(xpt), 99.), m_efficiencyHisto3D);
45  }
46 } // namespace CP
CP::IsolationConditionHist::getCutValue
float getCutValue(const float pt, const float eta) const
Definition: IsolationConditionHist.cxx:38
make_unique
std::unique_ptr< T > make_unique(Args &&... args)
Definition: SkimmingToolEXOT5.cxx:23
test_pyathena.pt
pt
Definition: test_pyathena.py:11
CP::MeVtoGeV
constexpr float MeVtoGeV
Definition: IsolationCloseByCorrectionTool.cxx:33
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
x
#define x
CP
Select isolated Photons, Electrons and Muons.
Definition: Control/xAODRootAccess/xAODRootAccess/TEvent.h:48
CP::IsolationCondition
Definition: IsolationCondition.h:30
CP::strObj
Definition: IsolationCondition.h:23
CP::IsolationConditionHist::IsolationConditionHist
IsolationConditionHist(const std::string &name, xAOD::Iso::IsolationType isoType, const std::string &isolationFunction, std::unique_ptr< TH3F > efficiencyHisto3D)
Definition: IsolationConditionHist.cxx:18
CP::IsolationConditionHist::m_isolationFunction
std::unique_ptr< TF1 > m_isolationFunction
Definition: IsolationConditionHist.h:36
CP::IsolationConditionHist::m_efficiencyHisto3D
std::shared_ptr< TH3F > m_efficiencyHisto3D
Definition: IsolationConditionHist.h:35
xAOD::Iso::IsolationType
IsolationType
Overall enumeration for isolation types in xAOD files.
Definition: IsolationType.h:26
CP::IsolationConditionHist::m_ptGeV
bool m_ptGeV
Definition: IsolationConditionHist.h:37
CP::IsolationConditionHist::accept
bool accept(const xAOD::IParticle &x) const override
Definition: IsolationConditionHist.cxx:28
min
#define min(a, b)
Definition: cfImp.cxx:40
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:221
plotting.yearwise_efficiency.xtitle
string xtitle
Definition: yearwise_efficiency.py:32
IsolationConditionHist.h
CP::IsolationConditionHist::m_interp
std::shared_ptr< Interp3D > m_interp
Definition: IsolationConditionHist.h:38
Interp3D.h