ATLAS Offline Software
AsgElectronChargeIDSelectorTool.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 // Dear emacs, this is -*-c++-*-
6 #ifndef __ASGELECTRONCHARGEIDSELECTORTOOL__
7 #define __ASGELECTRONCHARGEIDSELECTORTOOL__
8 
9 // Atlas includes
11 #include "AsgTools/AsgTool.h"
14 #include "MVAUtils/BDT.h"
15 #include "PATCore/AcceptData.h"
16 #include <unordered_map>
17 
19  : public asg::AsgTool
20  , virtual public IAsgElectronLikelihoodTool
21 {
25 
26 public:
28  AsgElectronChargeIDSelectorTool(const std::string& myname);
29 
32 
33 public: // /** Gaudi Service
35  // Interface method
36  // implementations */
37  virtual StatusCode initialize() override; // virtual StatusCode finalize();
38 
39  // Main methods for IAsgSelectorTool interface
40 
45  // virtual const asg::AcceptInfo& getAcceptInfo() const override; KM: inlined
46  // blow
47 
49  virtual asg::AcceptData accept(
50  const xAOD::IParticle* part) const override final;
51  virtual asg::AcceptData accept(
52  const EventContext& ctx,
53  const xAOD::IParticle* part) const override final;
54 
55  virtual asg::AcceptData accept(const EventContext& ctx,
56  const xAOD::Electron* eg) const override final
57  {
58  return accept(ctx, eg, -99); // mu = -99 as input will force accept to grab
59  // the pileup variable from the xAOD object
60  }
61 
62  virtual asg::AcceptData accept(const EventContext& ctx,
63  const xAOD::Egamma* eg) const override final
64  {
65  return accept(ctx, eg, -99); // mu = -99 as input will force accept to grab
66  // the pileup variable from the xAOD object
67  }
68 
70  virtual asg::AcceptData accept(const EventContext& ctx,
71  const xAOD::Electron* eg,
72  double mu) const override final;
73 
75  virtual asg::AcceptData accept(const EventContext& ctx,
76  const xAOD::Egamma* eg,
77  double mu) const override final;
78 
79  // Main methods for IAsgCalculatorTool interface
80 public:
82  virtual double calculate(const EventContext& ctx,
83  const xAOD::IParticle* part) const override final;
84 
85  virtual double calculate(const EventContext& ctx,
86  const xAOD::Electron* eg) const override final
87  {
88  return calculate(
89  ctx, eg, -99); // mu = -99 as input will force accept to grab the pileup
90  // variable from the xAOD object
91  }
92  virtual double calculate(const EventContext& ctx,
93  const xAOD::Egamma* eg) const override final
94  {
95  return calculate(
96  ctx, eg, -99); // mu = -99 as input will force accept to grab the pileup
97  // variable from the xAOD object
98  }
99 
101  virtual double calculate(const EventContext& ctx,
102  const xAOD::Electron* eg,
103  double mu) const override final;
104 
106  virtual double calculate(const EventContext& ctx,
107  const xAOD::Egamma* eg,
108  double mu) const override final;
109 
112  virtual std::vector<float> calculateMultipleOutputs(const EventContext &ctx,
113  const xAOD::Electron *eg,
114  double mu = -99) const override final
115  {
116  return {static_cast<float>(calculate(ctx, eg, mu))};
117  }
118 
119  //===========================================================================================
120  // same until here
121  inline virtual std::string getOperatingPointName() const override final
122  {
123  return m_WorkingPoint;
124  };
125 
126  inline virtual const asg::AcceptInfo& getAcceptInfo() const override final
127  {
128  return m_acceptInfo;
129  };
130 
131  // Private methods
132 private:
134  unsigned int getNPrimVertices(const EventContext& ctx) const;
135 
136  // BDT instances for different ID operating points (Tight, Medium, Loose) and
137  // the vector corresponds to n-fold
138  std::vector<MVAUtils::BDT*> m_v_bdts;
139 
140  TString m_pid_name;
141  float m_cutOnBDT;
142 
145 
146  // Private member variables
147 private:
149  std::string m_WorkingPoint;
150 
153 
155  unsigned int m_nPVdefault;
156 
159  this,
160  "primaryVertexContainer",
161  "PrimaryVertices",
162  "The primary vertex container name"
163  };
164 
166  std::string m_trainingFile;
167 
168  // BDT input variables
169  std::vector<std::string> m_inputVars;
170 
171 }; // End: class definition
172 
173 #endif
174 
LArG4FSStartPointFilter.part
part
Definition: LArG4FSStartPointFilter.py:21
AsgElectronLikelihoodTool.h
AsgElectronChargeIDSelectorTool::m_cutPosition_bdt
int m_cutPosition_bdt
Definition: AsgElectronChargeIDSelectorTool.h:143
asg::AsgTool
Base class for the dual-use tool implementation classes.
Definition: AsgTool.h:47
AsgElectronChargeIDSelectorTool::m_nPVdefault
unsigned int m_nPVdefault
defualt nPV (when not using PVCont)
Definition: AsgElectronChargeIDSelectorTool.h:155
ParticleTest.eg
eg
Definition: ParticleTest.py:29
ASG_TOOL_CLASS2
#define ASG_TOOL_CLASS2(CLASSNAME, INT1, INT2)
Definition: AsgToolMacros.h:77
AsgElectronChargeIDSelectorTool::getNPrimVertices
unsigned int getNPrimVertices(const EventContext &ctx) const
Get the number of primary vertices.
Definition: AsgElectronChargeIDSelectorTool.cxx:648
xAOD::Egamma_v1
Definition: Egamma_v1.h:56
AsgElectronChargeIDSelectorTool::m_WorkingPoint
std::string m_WorkingPoint
Working Point.
Definition: AsgElectronChargeIDSelectorTool.h:149
const
bool const RAWDATA *ch2 const
Definition: LArRodBlockPhysicsV0.cxx:562
SG::ReadHandleKey
Property holding a SG store/key/clid from which a ReadHandle is made.
Definition: StoreGate/StoreGate/ReadHandleKey.h:39
AsgElectronChargeIDSelectorTool::accept
virtual asg::AcceptData accept(const EventContext &ctx, const xAOD::Electron *eg) const override final
accept method with pointer to electron
Definition: AsgElectronChargeIDSelectorTool.h:55
IAsgSelectionTool
Definition: IAsgSelectionTool.h:28
xAOD::IParticle
Class providing the definition of the 4-vector interface.
Definition: Event/xAOD/xAODBase/xAODBase/IParticle.h:40
AsgElectronChargeIDSelectorTool::m_acceptInfo
asg::AcceptInfo m_acceptInfo
Definition: AsgElectronChargeIDSelectorTool.h:144
AsgElectronChargeIDSelectorTool::calculate
virtual double calculate(const EventContext &ctx, const xAOD::Egamma *eg) const override final
calculate method: for pointer to egamma
Definition: AsgElectronChargeIDSelectorTool.h:92
IAsgElectronLikelihoodTool.h
AsgElectronChargeIDSelectorTool::m_trainingFile
std::string m_trainingFile
The input ROOT file name that holds the PDFs.
Definition: AsgElectronChargeIDSelectorTool.h:166
AsgElectronChargeIDSelectorTool::~AsgElectronChargeIDSelectorTool
virtual ASG_TOOL_CLASS2(AsgElectronChargeIDSelectorTool, IAsgElectronLikelihoodTool, IAsgSelectionTool) public ~AsgElectronChargeIDSelectorTool()
Standard constructor.
Definition: AsgElectronChargeIDSelectorTool.cxx:70
AsgElectronChargeIDSelectorTool::initialize
virtual StatusCode initialize() override
Gaudi Service Interface method implementations.
Definition: AsgElectronChargeIDSelectorTool.cxx:81
asg::AcceptInfo
Definition: AcceptInfo.h:28
AsgElectronChargeIDSelectorTool::calculateMultipleOutputs
virtual std::vector< float > calculateMultipleOutputs(const EventContext &ctx, const xAOD::Electron *eg, double mu=-99) const override final
The result method for multiple outputs: only one output is used so return vector of that output.
Definition: AsgElectronChargeIDSelectorTool.h:112
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
ReadHandleKey.h
Property holding a SG store/key/clid from which a ReadHandle is made.
AsgElectronChargeIDSelectorTool::m_primVtxContKey
SG::ReadHandleKey< xAOD::VertexContainer > m_primVtxContKey
The primary vertex container name.
Definition: AsgElectronChargeIDSelectorTool.h:158
AsgElectronChargeIDSelectorTool::accept
virtual asg::AcceptData accept(const xAOD::IParticle *part) const override final
Method to get the plain AcceptInfo.
Definition: AsgElectronChargeIDSelectorTool.cxx:614
BDT.h
AcceptData.h
AsgElectronChargeIDSelectorTool::accept
virtual asg::AcceptData accept(const EventContext &ctx, const xAOD::Egamma *eg) const override final
accept method with pointer to egamma
Definition: AsgElectronChargeIDSelectorTool.h:62
AsgElectronChargeIDSelectorTool::calculate
virtual double calculate(const EventContext &ctx, const xAOD::Electron *eg) const override final
calculate method: for pointer to electron
Definition: AsgElectronChargeIDSelectorTool.h:85
AsgElectronChargeIDSelectorTool::m_inputVars
std::vector< std::string > m_inputVars
Definition: AsgElectronChargeIDSelectorTool.h:169
xAOD::Electron_v1
Definition: Electron_v1.h:34
AsgElectronChargeIDSelectorTool::calculate
virtual double calculate(const EventContext &ctx, const xAOD::IParticle *part) const override final
The main result method: the actual likelihood is calculated here.
Definition: AsgElectronChargeIDSelectorTool.cxx:632
AsgElectronChargeIDSelectorTool::getOperatingPointName
virtual std::string getOperatingPointName() const override final
Method to get the operating point.
Definition: AsgElectronChargeIDSelectorTool.h:121
IAsgElectronLikelihoodTool
Interface to tool to select electrons.
Definition: IAsgElectronLikelihoodTool.h:27
AsgElectronChargeIDSelectorTool::getAcceptInfo
virtual const asg::AcceptInfo & getAcceptInfo() const override final
Declare the interface ID for this pure-virtual interface class to the Athena framework.
Definition: AsgElectronChargeIDSelectorTool.h:126
AsgElectronChargeIDSelectorTool
Electron selector tool to select objects in Asgena using an underlying pure ROOT tool.
Definition: AsgElectronChargeIDSelectorTool.h:21
AsgElectronChargeIDSelectorTool::m_usePVCont
bool m_usePVCont
Whether to use the PV (not available for trigger)
Definition: AsgElectronChargeIDSelectorTool.h:152
AsgElectronChargeIDSelectorTool::m_pid_name
TString m_pid_name
Definition: AsgElectronChargeIDSelectorTool.h:140
AsgElectronChargeIDSelectorTool::m_v_bdts
std::vector< MVAUtils::BDT * > m_v_bdts
Definition: AsgElectronChargeIDSelectorTool.h:138
AsgTool.h
asg::AcceptData
Definition: AcceptData.h:30
AsgElectronChargeIDSelectorTool::m_cutOnBDT
float m_cutOnBDT
Definition: AsgElectronChargeIDSelectorTool.h:141
CaloNoise_fillDB.mu
mu
Definition: CaloNoise_fillDB.py:53