Loading [MathJax]/extensions/tex2jax.js
ATLAS Offline Software
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
DecoratePromptLeptonRNN.h
Go to the documentation of this file.
1 // This is -*- c++ -*-
2 
3 /*
4  Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
5 */
6 
7 #ifndef DECORATELEPTONTAGGERRNN_H
8 #define DECORATELEPTONTAGGERRNN_H
9 
10 /**********************************************************************************
11  * @Package: PhysicsAnpProd
12  * @Class : DecoratePromptLeptonRNN
13  * @Author : Rustem Ospanov
14  * @Author : Fudong He
15  *
16  * @Brief : Algorithm to compute RNN score for electrons and muons
17  *
18  **********************************************************************************/
19 
20 // Local
21 #include "IRNNTool.h"
22 
23 // ROOT
24 #include "TStopwatch.h"
25 
26 // Gaudi
27 #include "GaudiKernel/ITHistSvc.h"
28 #include "GaudiKernel/ToolHandle.h"
29 
30 // Athena
33 #include "xAODJet/JetContainer.h"
34 #include "xAODMuon/MuonContainer.h"
41 #include <unordered_map>
42 
43 namespace Prompt
44 {
45  // Forward declaration
46  class VarHolder;
47 
48  // Main body
49 
50  class DecoratePromptLeptonRNN : public AthAlgorithm
51  {
52  /*
53  Select the ID tracks near to the lepton, and prepare the RNN inputs variables of those ID tracks to the VarHolder objects.
54  Then pass the VarHolder objects to RNNTool class to get the RNN prediction.
55  Decorate the lepton with the RNN predictions.
56 
57  */
58  public:
59 
60  DecoratePromptLeptonRNN(const std::string& name, ISvcLocator* pSvcLocator);
61 
62  virtual StatusCode initialize() override;
63  virtual StatusCode execute() override;
64  virtual StatusCode finalize() override;
65 
67 
68  const xAOD::TrackParticle* findMuonTrack(const xAOD::Muon *muon);
69 
70  const xAOD::Jet* findClosestTrackJet(const xAOD::TrackParticle *particle, const xAOD::JetContainer &trackJets);
71 
72  bool compDummy(const xAOD::IParticle &particle,
73  std::vector<decoratorFloatH_t>& decors) const;
74 
76  const xAOD::TrackParticle &track,
77  const xAOD::TrackParticle &lepton,
78  const xAOD::Jet &trackJet,
79  const xAOD::Vertex &priVtx,
80  const xAOD::EventInfo event);
81 
82  bool compScore(const xAOD::IParticle &particle,
83  const std::vector<Prompt::VarHolder> &tracks,
84  std::vector<decoratorFloatH_t>& decors);
85 
87 
88  StatusCode makeHist(TH1 *&h, const std::string &key, int nbin, double xmin, double xmax);
89 
90  // Properties:
91  Gaudi::Property<std::string> m_outputStream {this, "outputStream", "", "Path of the ROOT output directory of the histograms for RNN debug"};
92  Gaudi::Property<std::string> m_decorationPrefixRNN {this, "decorationPrefixRNN", "", "Prefix of the name for the decorator of RNN to the lepton"};
93 
94  Gaudi::Property<double> m_minTrackpT {this, "minTrackpT", 500.0, "pT cut config for the input tracks to RNN"};
95  Gaudi::Property<double> m_maxTrackEta {this, "maxTrackEta", 2.5, "abs(eta) cut config for the input tracks to RNN"};
96  Gaudi::Property<double> m_maxTrackZ0Sin {this, "maxTrackZ0Sin", 1.0, "Z0sin cut config for the input tracks to RNN"};
97 
98  Gaudi::Property<double> m_minTrackLeptonDR {this, "minTrackLeptonDR", 1.0e-6, "Delta R between lepton and track cut config for the input tracks to RNN"};
99  Gaudi::Property<double> m_maxTrackLeptonDR {this, "maxTrackLeptonDR", 0.4, "Delta R between lepton and track cut config for the input tracks to RNN"};
100  Gaudi::Property<double> m_maxLepTrackJetDR {this, "maxLepTrackJetDR", 0.4, "Maximum distance between lepton and track jet for track jet matching"};
101 
102  Gaudi::Property<double> m_maxTrackSharedSiHits {this, "maxTrackSharedSiHits", 1.5, "track shared si hits cut config for the input tracks to RNN"};
103  Gaudi::Property<unsigned> m_minTrackSiHits {this, "minTrackSiHits", 6.5, "track silicon detector hits cut config for the input tracks to RNN"};
104  Gaudi::Property<unsigned> m_maxTrackSiHoles {this, "maxTrackSiHoles", 2.5, "track holes cut config for the input tracks to RNN"};
105  Gaudi::Property<unsigned> m_maxTrackPixHoles {this, "maxTrackPixHoles", 1.5, "track pixel holes cut config for the input tracks to RNN"};
106 
107  Gaudi::Property<bool> m_debug {this, "debug", false, "debug statement"};
108  Gaudi::Property<bool> m_printTime {this, "printTime", false, "print running time, for debug"};
109 
110  // Tools and services:
111  ToolHandle<IRNNTool> m_toolRNN {
112  this, "toolRNN", "defaultToolRNN", "Dedicated tool for RNN prediction"
113  };
114 
116 
117  // Read/write handles:
119  this, "inputContainerLepton", "",
120  "Container's name of the lepton that you want to decorate"
121  };
123  this, "inputContainerTrack", "", "Track container name"
124  };
126  this, "inputContainerTrackJet", "", "Track Jet container name"
127  };
129  this, "inputContainerPrimaryVertices", "", "Primary vertex container name"
130  };
131 
133  this, "EventHandleKey", "EventInfo"
134  };
135 
136  // Variables:
137  TStopwatch m_timerEvent;
138  int m_countEvent;
139 
140  std::map<std::string, TH1*> m_hists;
141 
142  std::unique_ptr<SG::AuxElement::ConstAccessor<unsigned char> > m_accessQuality;
143 
145  { this, "DecorHandleKeys", {} };
146  std::unordered_map<std::string, size_t> m_decorNameMap;
147  };
148 }
149 
150 #endif
Prompt::DecoratePromptLeptonRNN::finalize
virtual StatusCode finalize() override
Definition: DecoratePromptLeptonRNN.cxx:204
Prompt
Definition: DecoratePLIT.h:29
Prompt::DecoratePromptLeptonRNN::m_decorHandleKeys
SG::WriteDecorHandleKeyArray< xAOD::IParticleContainer > m_decorHandleKeys
Definition: DecoratePromptLeptonRNN.h:153
Prompt::DecoratePromptLeptonRNN::m_decorNameMap
std::unordered_map< std::string, size_t > m_decorNameMap
Definition: DecoratePromptLeptonRNN.h:154
Prompt::DecoratePromptLeptonRNN::m_decorationPrefixRNN
Gaudi::Property< std::string > m_decorationPrefixRNN
Definition: DecoratePromptLeptonRNN.h:100
TrackParticlexAODHelpers.h
Prompt::DecoratePromptLeptonRNN::m_accessQuality
std::unique_ptr< SG::AuxElement::ConstAccessor< unsigned char > > m_accessQuality
Definition: DecoratePromptLeptonRNN.h:150
Prompt::DecoratePromptLeptonRNN::m_outputStream
Gaudi::Property< std::string > m_outputStream
Definition: DecoratePromptLeptonRNN.h:99
Prompt::DecoratePromptLeptonRNN::compDummy
bool compDummy(const xAOD::IParticle &particle, std::vector< decoratorFloatH_t > &decors) const
Definition: DecoratePromptLeptonRNN.cxx:436
Prompt::VarHolder
Definition: VarHolder.h:112
Prompt::DecoratePromptLeptonRNN::m_inputContainerTrackKey
SG::ReadHandleKey< xAOD::TrackParticleContainer > m_inputContainerTrackKey
Definition: DecoratePromptLeptonRNN.h:130
Prompt::DecoratePromptLeptonRNN::m_countEvent
int m_countEvent
Definition: DecoratePromptLeptonRNN.h:146
Prompt::DecoratePromptLeptonRNN::m_minTrackLeptonDR
Gaudi::Property< double > m_minTrackLeptonDR
Definition: DecoratePromptLeptonRNN.h:106
SG::HandleKeyArray
Definition: StoreGate/StoreGate/HandleKeyArray.h:38
Prompt::DecoratePromptLeptonRNN::m_minTrackSiHits
Gaudi::Property< unsigned > m_minTrackSiHits
Definition: DecoratePromptLeptonRNN.h:111
Prompt::DecoratePromptLeptonRNN::prepTrackObject
bool prepTrackObject(Prompt::VarHolder &p, const xAOD::TrackParticle &track, const xAOD::TrackParticle &lepton, const xAOD::Jet &trackJet, const xAOD::Vertex &priVtx, const xAOD::EventInfo event)
Definition: DecoratePromptLeptonRNN.cxx:273
Prompt::DecoratePromptLeptonRNN::findClosestTrackJet
const xAOD::Jet * findClosestTrackJet(const xAOD::TrackParticle *particle, const xAOD::JetContainer &trackJets)
Definition: DecoratePromptLeptonRNN.cxx:240
Prompt::DecoratePromptLeptonRNN::m_inputContainerTrackJetKey
SG::ReadHandleKey< xAOD::JetContainer > m_inputContainerTrackJetKey
Definition: DecoratePromptLeptonRNN.h:133
SG::ReadHandleKey
Property holding a SG store/key/clid from which a ReadHandle is made.
Definition: StoreGate/StoreGate/ReadHandleKey.h:39
xAOD::IParticle
Class providing the definition of the 4-vector interface.
Definition: Event/xAOD/xAODBase/xAODBase/IParticle.h:41
xAOD::Muon_v1
Class describing a Muon.
Definition: Muon_v1.h:38
Prompt::DecoratePromptLeptonRNN::m_maxTrackZ0Sin
Gaudi::Property< double > m_maxTrackZ0Sin
Definition: DecoratePromptLeptonRNN.h:104
Prompt::DecoratePromptLeptonRNN::makeHist
StatusCode makeHist(TH1 *&h, const std::string &key, int nbin, double xmin, double xmax)
Definition: DecoratePromptLeptonRNN.cxx:450
AthAlgorithm.h
python.utils.AtlRunQueryDQUtils.p
p
Definition: AtlRunQueryDQUtils.py:210
event
POOL::TEvent event(POOL::TEvent::kClassAccess)
ElectronContainer.h
Prompt::DecoratePromptLeptonRNN::m_eventHandleKey
SG::ReadHandleKey< xAOD::EventInfo > m_eventHandleKey
Definition: DecoratePromptLeptonRNN.h:140
xmin
double xmin
Definition: listroot.cxx:60
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
SG::WriteDecorHandle
Handle class for adding a decoration to an object.
Definition: StoreGate/StoreGate/WriteDecorHandle.h:100
WriteDecorHandle.h
Handle class for adding a decoration to an object.
Prompt::DecoratePromptLeptonRNN::m_histSvc
ServiceHandle< ITHistSvc > m_histSvc
Definition: DecoratePromptLeptonRNN.h:123
Prompt::DecoratePromptLeptonRNN::m_hists
std::map< std::string, TH1 * > m_hists
Definition: DecoratePromptLeptonRNN.h:148
Prompt::DecoratePromptLeptonRNN::m_printTime
Gaudi::Property< bool > m_printTime
Definition: DecoratePromptLeptonRNN.h:116
DataVector
Derived DataVector<T>.
Definition: DataVector.h:794
Prompt::DecoratePromptLeptonRNN::m_maxTrackPixHoles
Gaudi::Property< unsigned > m_maxTrackPixHoles
Definition: DecoratePromptLeptonRNN.h:113
AthAlgorithm
Definition: AthAlgorithm.h:47
Prompt::DecoratePromptLeptonRNN::m_inputContainerLeptonKey
SG::ReadHandleKey< xAOD::IParticleContainer > m_inputContainerLeptonKey
Definition: DecoratePromptLeptonRNN.h:126
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:240
IRNNTool.h
Prompt::DecoratePromptLeptonRNN::m_timerEvent
TStopwatch m_timerEvent
Definition: DecoratePromptLeptonRNN.h:145
EventInfo.h
xAOD::EventInfo_v1
Class describing the basic event information.
Definition: EventInfo_v1.h:43
MuonContainer.h
xAOD::Jet_v1
Class describing a jet.
Definition: Jet_v1.h:57
Prompt::DecoratePromptLeptonRNN::DecoratePromptLeptonRNN
DecoratePromptLeptonRNN(const std::string &name, ISvcLocator *pSvcLocator)
Definition: DecoratePromptLeptonRNN.cxx:21
VertexContainer.h
h
xAOD::Vertex_v1
Class describing a Vertex.
Definition: Vertex_v1.h:42
JetContainer.h
Prompt::DecoratePromptLeptonRNN::m_debug
Gaudi::Property< bool > m_debug
Definition: DecoratePromptLeptonRNN.h:115
WriteDecorHandleKeyArray.h
xmax
double xmax
Definition: listroot.cxx:61
Prompt::DecoratePromptLeptonRNN::compScore
bool compScore(const xAOD::IParticle &particle, const std::vector< Prompt::VarHolder > &tracks, std::vector< decoratorFloatH_t > &decors)
Definition: DecoratePromptLeptonRNN.cxx:375
Prompt::DecoratePromptLeptonRNN::findMuonTrack
const xAOD::TrackParticle * findMuonTrack(const xAOD::Muon *muon)
Definition: DecoratePromptLeptonRNN.cxx:221
Prompt::DecoratePromptLeptonRNN::m_inputContainerPrimaryVerticesKey
SG::ReadHandleKey< xAOD::VertexContainer > m_inputContainerPrimaryVerticesKey
Definition: DecoratePromptLeptonRNN.h:136
Prompt::DecoratePromptLeptonRNN::m_minTrackpT
Gaudi::Property< double > m_minTrackpT
Definition: DecoratePromptLeptonRNN.h:102
Prompt::DecoratePromptLeptonRNN::m_maxTrackSiHoles
Gaudi::Property< unsigned > m_maxTrackSiHoles
Definition: DecoratePromptLeptonRNN.h:112
Prompt::DecoratePromptLeptonRNN::m_maxTrackSharedSiHits
Gaudi::Property< double > m_maxTrackSharedSiHits
Definition: DecoratePromptLeptonRNN.h:110
xAOD::TrackParticle_v1
Class describing a TrackParticle.
Definition: TrackParticle_v1.h:43
Prompt::DecoratePromptLeptonRNN::m_toolRNN
ToolHandle< IRNNTool > m_toolRNN
Definition: DecoratePromptLeptonRNN.h:119
Prompt::DecoratePromptLeptonRNN::m_maxLepTrackJetDR
Gaudi::Property< double > m_maxLepTrackJetDR
Definition: DecoratePromptLeptonRNN.h:108
Prompt::DecoratePromptLeptonRNN::m_maxTrackEta
Gaudi::Property< double > m_maxTrackEta
Definition: DecoratePromptLeptonRNN.h:103
Prompt::DecoratePromptLeptonRNN::passTrack
bool passTrack(Prompt::VarHolder &p)
Definition: DecoratePromptLeptonRNN.cxx:348
TrackParticleContainer.h
Prompt::DecoratePromptLeptonRNN::m_maxTrackLeptonDR
Gaudi::Property< double > m_maxTrackLeptonDR
Definition: DecoratePromptLeptonRNN.h:107
Prompt::DecoratePromptLeptonRNN::execute
virtual StatusCode execute() override
Definition: DecoratePromptLeptonRNN.cxx:72
Prompt::DecoratePromptLeptonRNN::initialize
virtual StatusCode initialize() override
Definition: DecoratePromptLeptonRNN.cxx:28
ServiceHandle< ITHistSvc >
mapkey::key
key
Definition: TElectronEfficiencyCorrectionTool.cxx:37