ATLAS Offline Software
DecoratePromptLeptonRNN.h
Go to the documentation of this file.
1 // This is -*- c++ -*-
2 
3 /*
4  Copyright (C) 2002-2023 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"
39 
40 namespace Prompt
41 {
42  // Forward declaration
43  class VarHolder;
44 
45  // Main body
46 
47  class DecoratePromptLeptonRNN : public AthAlgorithm
48  {
49  /*
50  Select the ID tracks near to the lepton, and prepare the RNN inputs variables of those ID tracks to the VarHolder objects.
51  Then pass the VarHolder objects to RNNTool class to get the RNN prediction.
52  Decorate the lepton with the RNN predictions.
53 
54  */
55  public:
56 
57  DecoratePromptLeptonRNN(const std::string& name, ISvcLocator* pSvcLocator);
58 
59  virtual StatusCode initialize() override;
60  virtual StatusCode execute() override;
61  virtual StatusCode finalize() override;
62 
64  typedef std::map<std::string, std::unique_ptr<decoratorFloat_t> > decoratorFloatMap_t;
65 
67 
69 
71  const std::string &prefix);
72 
75  const xAOD::TrackParticle &lepton,
76  const xAOD::Jet &trackJet,
77  const xAOD::Vertex &priVtx,
78  const xAOD::EventInfo event);
79 
81  const std::vector<Prompt::VarHolder> &tracks,
82  const std::string &prefix);
83 
85 
86  StatusCode makeHist(TH1 *&h, const std::string &key, int nbin, double xmin, double xmax);
87 
88  // Properties:
89  Gaudi::Property<std::string> m_outputStream {this, "outputStream", "", "Path of the ROOT output directory of the histograms for RNN debug"};
90  Gaudi::Property<std::string> m_decorationPrefixRNN {this, "decorationPrefixRNN", "", "Prefix of the name for the decorator of RNN to the lepton"};
91 
92  Gaudi::Property<double> m_minTrackpT {this, "minTrackpT", 500.0, "pT cut config for the input tracks to RNN"};
93  Gaudi::Property<double> m_maxTrackEta {this, "maxTrackEta", 2.5, "abs(eta) cut config for the input tracks to RNN"};
94  Gaudi::Property<double> m_maxTrackZ0Sin {this, "maxTrackZ0Sin", 1.0, "Z0sin cut config for the input tracks to RNN"};
95 
96  Gaudi::Property<double> m_minTrackLeptonDR {this, "minTrackLeptonDR", 1.0e-6, "Delta R between lepton and track cut config for the input tracks to RNN"};
97  Gaudi::Property<double> m_maxTrackLeptonDR {this, "maxTrackLeptonDR", 0.4, "Delta R between lepton and track cut config for the input tracks to RNN"};
98  Gaudi::Property<double> m_maxLepTrackJetDR {this, "maxLepTrackJetDR", 0.4, "Maximum distance between lepton and track jet for track jet matching"};
99 
100  Gaudi::Property<double> m_maxTrackSharedSiHits {this, "maxTrackSharedSiHits", 1.5, "track shared si hits cut config for the input tracks to RNN"};
101  Gaudi::Property<unsigned> m_minTrackSiHits {this, "minTrackSiHits", 6.5, "track silicon detector hits cut config for the input tracks to RNN"};
102  Gaudi::Property<unsigned> m_maxTrackSiHoles {this, "maxTrackSiHoles", 2.5, "track holes cut config for the input tracks to RNN"};
103  Gaudi::Property<unsigned> m_maxTrackPixHoles {this, "maxTrackPixHoles", 1.5, "track pixel holes cut config for the input tracks to RNN"};
104 
105  Gaudi::Property<bool> m_debug {this, "debug", false, "debug statement"};
106  Gaudi::Property<bool> m_printTime {this, "printTime", false, "print running time, for debug"};
107 
108  // Tools and services:
109  ToolHandle<IRNNTool> m_toolRNN {
110  this, "toolRNN", "defaultToolRNN", "Dedicated tool for RNN prediction"
111  };
112 
114 
115  // Read/write handles:
117  this, "inputContainerLepton", "",
118  "Container's name of the lepton that you want to decorate"
119  };
121  this, "inputContainerTrack", "", "Track container name"
122  };
124  this, "inputContainerTrackJet", "", "Track Jet container name"
125  };
127  this, "inputContainerPrimaryVertices", "", "Primary vertex container name"
128  };
129 
131  this, "EventHandleKey", "EventInfo"
132  };
133 
134  // Variables:
135  TStopwatch m_timerEvent;
136  int m_countEvent;
137 
139 
140  std::map<std::string, TH1*> m_hists;
141 
142  std::unique_ptr<SG::AuxElement::ConstAccessor<unsigned char> > m_accessQuality;
143  };
144 }
145 
146 #endif
xAOD::muon
@ muon
Definition: TrackingPrimitives.h:195
Prompt::DecoratePromptLeptonRNN::finalize
virtual StatusCode finalize() override
Definition: DecoratePromptLeptonRNN.cxx:191
Prompt
Definition: DecoratePromptLeptonImproved.h:45
Trk::ParticleSwitcher::particle
constexpr ParticleHypothesis particle[PARTICLEHYPOTHESES]
the array of masses
Definition: ParticleHypothesis.h:76
Prompt::DecoratePromptLeptonRNN::m_decorationPrefixRNN
Gaudi::Property< std::string > m_decorationPrefixRNN
Definition: DecoratePromptLeptonRNN.h:98
python.PerfMonSerializer.p
def p
Definition: PerfMonSerializer.py:743
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:97
Prompt::VarHolder
Definition: VarHolder.h:112
Prompt::DecoratePromptLeptonRNN::m_inputContainerTrackKey
SG::ReadHandleKey< xAOD::TrackParticleContainer > m_inputContainerTrackKey
Definition: DecoratePromptLeptonRNN.h:128
Prompt::DecoratePromptLeptonRNN::m_countEvent
int m_countEvent
Definition: DecoratePromptLeptonRNN.h:144
Prompt::DecoratePromptLeptonRNN::m_minTrackLeptonDR
Gaudi::Property< double > m_minTrackLeptonDR
Definition: DecoratePromptLeptonRNN.h:104
Prompt::DecoratePromptLeptonRNN::m_minTrackSiHits
Gaudi::Property< unsigned > m_minTrackSiHits
Definition: DecoratePromptLeptonRNN.h:109
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:260
Prompt::DecoratePromptLeptonRNN::findClosestTrackJet
const xAOD::Jet * findClosestTrackJet(const xAOD::TrackParticle *particle, const xAOD::JetContainer &trackJets)
Definition: DecoratePromptLeptonRNN.cxx:227
Prompt::DecoratePromptLeptonRNN::m_inputContainerTrackJetKey
SG::ReadHandleKey< xAOD::JetContainer > m_inputContainerTrackJetKey
Definition: DecoratePromptLeptonRNN.h:131
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:40
xAOD::Muon_v1
Class describing a Muon.
Definition: Muon_v1.h:38
Prompt::DecoratePromptLeptonRNN::m_maxTrackZ0Sin
Gaudi::Property< double > m_maxTrackZ0Sin
Definition: DecoratePromptLeptonRNN.h:102
Prompt::DecoratePromptLeptonRNN::decoratorFloat_t
SG::AuxElement::Decorator< float > decoratorFloat_t
Definition: DecoratePromptLeptonRNN.h:71
Prompt::DecoratePromptLeptonRNN::makeHist
StatusCode makeHist(TH1 *&h, const std::string &key, int nbin, double xmin, double xmax)
Definition: DecoratePromptLeptonRNN.cxx:445
AthAlgorithm.h
event
POOL::TEvent event(POOL::TEvent::kClassAccess)
SG::Decorator
Helper class to provide type-safe access to aux data.
Definition: Decorator.h:58
ElectronContainer.h
Prompt::DecoratePromptLeptonRNN::m_eventHandleKey
SG::ReadHandleKey< xAOD::EventInfo > m_eventHandleKey
Definition: DecoratePromptLeptonRNN.h:138
xmin
double xmin
Definition: listroot.cxx:60
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
Prompt::DecoratePromptLeptonRNN::m_histSvc
ServiceHandle< ITHistSvc > m_histSvc
Definition: DecoratePromptLeptonRNN.h:121
checkCorrelInHIST.prefix
dictionary prefix
Definition: checkCorrelInHIST.py:391
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:114
DataVector
Derived DataVector<T>.
Definition: DataVector.h:581
Prompt::DecoratePromptLeptonRNN::m_maxTrackPixHoles
Gaudi::Property< unsigned > m_maxTrackPixHoles
Definition: DecoratePromptLeptonRNN.h:111
AthAlgorithm
Definition: AthAlgorithm.h:47
Prompt::DecoratePromptLeptonRNN::compScore
bool compScore(const xAOD::IParticle &particle, const std::vector< Prompt::VarHolder > &tracks, const std::string &prefix)
Definition: DecoratePromptLeptonRNN.cxx:362
Prompt::DecoratePromptLeptonRNN::m_inputContainerLeptonKey
SG::ReadHandleKey< xAOD::IParticleContainer > m_inputContainerLeptonKey
Definition: DecoratePromptLeptonRNN.h:124
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:195
Prompt::DecoratePromptLeptonRNN::compDummy
bool compDummy(const xAOD::IParticle &particle, const std::string &prefix)
Definition: DecoratePromptLeptonRNN.cxx:426
IRNNTool.h
Prompt::DecoratePromptLeptonRNN::m_timerEvent
TStopwatch m_timerEvent
Definition: DecoratePromptLeptonRNN.h:143
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:19
VertexContainer.h
h
xAOD::Vertex_v1
Class describing a Vertex.
Definition: Vertex_v1.h:42
JetContainer.h
TH1
Definition: rootspy.cxx:268
Prompt::DecoratePromptLeptonRNN::m_debug
Gaudi::Property< bool > m_debug
Definition: DecoratePromptLeptonRNN.h:113
xmax
double xmax
Definition: listroot.cxx:61
Prompt::DecoratePromptLeptonRNN::m_decoratorMap
decoratorFloatMap_t m_decoratorMap
Definition: DecoratePromptLeptonRNN.h:146
Prompt::DecoratePromptLeptonRNN::findMuonTrack
const xAOD::TrackParticle * findMuonTrack(const xAOD::Muon *muon)
Definition: DecoratePromptLeptonRNN.cxx:208
Prompt::DecoratePromptLeptonRNN::m_inputContainerPrimaryVerticesKey
SG::ReadHandleKey< xAOD::VertexContainer > m_inputContainerPrimaryVerticesKey
Definition: DecoratePromptLeptonRNN.h:134
Prompt::DecoratePromptLeptonRNN::m_minTrackpT
Gaudi::Property< double > m_minTrackpT
Definition: DecoratePromptLeptonRNN.h:100
Prompt::DecoratePromptLeptonRNN::m_maxTrackSiHoles
Gaudi::Property< unsigned > m_maxTrackSiHoles
Definition: DecoratePromptLeptonRNN.h:110
Prompt::DecoratePromptLeptonRNN::m_maxTrackSharedSiHits
Gaudi::Property< double > m_maxTrackSharedSiHits
Definition: DecoratePromptLeptonRNN.h:108
xAOD::track
@ track
Definition: TrackingPrimitives.h:512
xAOD::TrackParticle_v1
Class describing a TrackParticle.
Definition: TrackParticle_v1.h:43
Prompt::DecoratePromptLeptonRNN::decoratorFloatMap_t
std::map< std::string, std::unique_ptr< decoratorFloat_t > > decoratorFloatMap_t
Definition: DecoratePromptLeptonRNN.h:72
Prompt::DecoratePromptLeptonRNN::m_toolRNN
ToolHandle< IRNNTool > m_toolRNN
Definition: DecoratePromptLeptonRNN.h:117
Prompt::DecoratePromptLeptonRNN::m_maxLepTrackJetDR
Gaudi::Property< double > m_maxLepTrackJetDR
Definition: DecoratePromptLeptonRNN.h:106
Prompt::DecoratePromptLeptonRNN::m_maxTrackEta
Gaudi::Property< double > m_maxTrackEta
Definition: DecoratePromptLeptonRNN.h:101
Prompt::DecoratePromptLeptonRNN::passTrack
bool passTrack(Prompt::VarHolder &p)
Definition: DecoratePromptLeptonRNN.cxx:335
TrackParticleContainer.h
Prompt::DecoratePromptLeptonRNN::m_maxTrackLeptonDR
Gaudi::Property< double > m_maxTrackLeptonDR
Definition: DecoratePromptLeptonRNN.h:105
Prompt::DecoratePromptLeptonRNN::execute
virtual StatusCode execute() override
Definition: DecoratePromptLeptonRNN.cxx:67
Prompt::DecoratePromptLeptonRNN::initialize
virtual StatusCode initialize() override
Definition: DecoratePromptLeptonRNN.cxx:26
ServiceHandle< ITHistSvc >
mapkey::key
key
Definition: TElectronEfficiencyCorrectionTool.cxx:37