ATLAS Offline Software
Loading...
Searching...
No Matches
Prompt::DecoratePromptLeptonRNN Class Reference

#include <DecoratePromptLeptonRNN.h>

Inheritance diagram for Prompt::DecoratePromptLeptonRNN:

Public Types

using decoratorFloatH_t = SG::WriteDecorHandle<xAOD::IParticleContainer, float>

Public Member Functions

 DecoratePromptLeptonRNN (const std::string &name, ISvcLocator *pSvcLocator)
virtual StatusCode initialize () override
virtual StatusCode execute () override
 Execute method without EventContext (deprecated).
virtual StatusCode finalize () override
const xAOD::TrackParticlefindMuonTrack (const xAOD::Muon *muon)
const xAOD::JetfindClosestTrackJet (const xAOD::TrackParticle *particle, const xAOD::JetContainer &trackJets)
bool compDummy (const xAOD::IParticle &particle, std::vector< decoratorFloatH_t > &decors) const
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)
bool compScore (const xAOD::IParticle &particle, const std::vector< Prompt::VarHolder > &tracks, std::vector< decoratorFloatH_t > &decors)
bool passTrack (Prompt::VarHolder &p)
StatusCode makeHist (TH1 *&h, const std::string &key, int nbin, double xmin, double xmax)
virtual StatusCode sysInitialize () override
 Override sysInitialize.
virtual StatusCode execute (const EventContext &)
 Execute method with EventContext.
virtual const DataObjIDColl & extraOutputDeps () const override
 Return the list of extra output dependencies.
ServiceHandle< StoreGateSvc > & evtStore ()
 The standard StoreGateSvc (event store) Returns (kind of) a pointer to the StoreGateSvc.
const ServiceHandle< StoreGateSvc > & detStore () const
 The standard StoreGateSvc/DetectorStore Returns (kind of) a pointer to the StoreGateSvc.
virtual StatusCode sysStart () override
 Handle START transition.
virtual std::vector< Gaudi::DataHandle * > inputHandles () const override
 Return this algorithm's input handles.
virtual std::vector< Gaudi::DataHandle * > outputHandles () const override
 Return this algorithm's output handles.
Gaudi::Details::PropertyBase & declareProperty (Gaudi::Property< T, V, H > &t)
void updateVHKA (Gaudi::Details::PropertyBase &)
MsgStream & msg () const
bool msgLvl (const MSG::Level lvl) const
const EventContext & getContext () const
 Deprecated methods (use the ones with EventContext).
bool filterPassed () const
void setFilterPassed (bool state) const

Public Attributes

Gaudi::Property< std::string > m_outputStream {this, "outputStream", "", "Path of the ROOT output directory of the histograms for RNN debug"}
Gaudi::Property< std::string > m_decorationPrefixRNN {this, "decorationPrefixRNN", "", "Prefix of the name for the decorator of RNN to the lepton"}
Gaudi::Property< double > m_minTrackpT {this, "minTrackpT", 500.0, "pT cut config for the input tracks to RNN"}
Gaudi::Property< double > m_maxTrackEta {this, "maxTrackEta", 2.5, "abs(eta) cut config for the input tracks to RNN"}
Gaudi::Property< double > m_maxTrackZ0Sin {this, "maxTrackZ0Sin", 1.0, "Z0sin cut config for the input tracks to RNN"}
Gaudi::Property< double > m_minTrackLeptonDR {this, "minTrackLeptonDR", 1.0e-6, "Delta R between lepton and track cut config for the input tracks to RNN"}
Gaudi::Property< double > m_maxTrackLeptonDR {this, "maxTrackLeptonDR", 0.4, "Delta R between lepton and track cut config for the input tracks to RNN"}
Gaudi::Property< double > m_maxLepTrackJetDR {this, "maxLepTrackJetDR", 0.4, "Maximum distance between lepton and track jet for track jet matching"}
Gaudi::Property< double > m_maxTrackSharedSiHits {this, "maxTrackSharedSiHits", 1.5, "track shared si hits cut config for the input tracks to RNN"}
Gaudi::Property< unsigned > m_minTrackSiHits {this, "minTrackSiHits", 6.5, "track silicon detector hits cut config for the input tracks to RNN"}
Gaudi::Property< unsigned > m_maxTrackSiHoles {this, "maxTrackSiHoles", 2.5, "track holes cut config for the input tracks to RNN"}
Gaudi::Property< unsigned > m_maxTrackPixHoles {this, "maxTrackPixHoles", 1.5, "track pixel holes cut config for the input tracks to RNN"}
Gaudi::Property< bool > m_debug {this, "debug", false, "debug statement"}
Gaudi::Property< bool > m_printTime {this, "printTime", false, "print running time, for debug"}
ToolHandle< IRNNToolm_toolRNN
ServiceHandle< ITHistSvc > m_histSvc
SG::ReadHandleKey< xAOD::IParticleContainerm_inputContainerLeptonKey
SG::ReadHandleKey< xAOD::TrackParticleContainerm_inputContainerTrackKey
SG::ReadHandleKey< xAOD::JetContainerm_inputContainerTrackJetKey
SG::ReadHandleKey< xAOD::VertexContainerm_inputContainerPrimaryVerticesKey
SG::ReadHandleKey< xAOD::EventInfom_eventHandleKey
TStopwatch m_timerEvent
int m_countEvent
std::map< std::string, TH1 * > m_hists
SG::WriteDecorHandleKeyArray< xAOD::IParticleContainerm_decorHandleKeys { this, "DecorHandleKeys", {} }
std::unordered_map< std::string, size_t > m_decorNameMap

Protected Member Functions

virtual bool isReEntrant () const override final
 Legacy algorithms are not thread-safe.
void renounceArray (SG::VarHandleKeyArray &handlesArray)
 remove all handles from I/O resolution
std::enable_if_t< std::is_void_v< std::result_of_t< decltype(&T::renounce)(T)> > &&!std::is_base_of_v< SG::VarHandleKeyArray, T > &&std::is_base_of_v< Gaudi::DataHandle, T >, void > renounce (T &h)
void extraDeps_update_handler (Gaudi::Details::PropertyBase &ExtraDeps)
 Add StoreName to extra input/output deps as needed.

Private Types

typedef ServiceHandle< StoreGateSvcStoreGateSvc_t

Private Member Functions

Gaudi::Details::PropertyBase & declareGaudiProperty (Gaudi::Property< T, V, H > &hndl, const SG::VarHandleKeyType &)
 specialization for handling Gaudi::Property<SG::VarHandleKey>

Private Attributes

DataObjIDColl m_extendedExtraObjects
StoreGateSvc_t m_evtStore
 Pointer to StoreGate (event store by default).
StoreGateSvc_t m_detStore
 Pointer to StoreGate (detector store by default).
std::vector< SG::VarHandleKeyArray * > m_vhka
bool m_varHandleArraysDeclared

Detailed Description

Definition at line 50 of file DecoratePromptLeptonRNN.h.

Member Typedef Documentation

◆ decoratorFloatH_t

◆ StoreGateSvc_t

typedef ServiceHandle<StoreGateSvc> AthCommonDataStore< AthCommonMsg< Gaudi::Algorithm > >::StoreGateSvc_t
privateinherited

Definition at line 388 of file AthCommonDataStore.h.

Constructor & Destructor Documentation

◆ DecoratePromptLeptonRNN()

Prompt::DecoratePromptLeptonRNN::DecoratePromptLeptonRNN ( const std::string & name,
ISvcLocator * pSvcLocator )

Definition at line 21 of file DecoratePromptLeptonRNN.cxx.

21 :
22 AthAlgorithm(name, pSvcLocator),
23 m_histSvc ("THistSvc/THistSvc", name),
25{}
AthAlgorithm(const std::string &name, ISvcLocator *pSvcLocator)
Constructor with parameters:

Member Function Documentation

◆ compDummy()

bool Prompt::DecoratePromptLeptonRNN::compDummy ( const xAOD::IParticle & particle,
std::vector< decoratorFloatH_t > & decors ) const

Definition at line 427 of file DecoratePromptLeptonRNN.cxx.

429{
430 //
431 // Fill dummy values for RNN outputs
432 //
433 for (auto& d : decors) {
434 d(particle) = -1.0;
435 }
436
437 return true;
438}

◆ compScore()

bool Prompt::DecoratePromptLeptonRNN::compScore ( const xAOD::IParticle & particle,
const std::vector< Prompt::VarHolder > & tracks,
std::vector< decoratorFloatH_t > & decors )

Definition at line 366 of file DecoratePromptLeptonRNN.cxx.

369{
370 //
371 // Call the RNN tool to get the RNN prediction for the leptons and decorate the lepton with those RNN scores.
372 //
373 ATH_MSG_DEBUG("compScore - number of tracks: " << tracks.size());
374
375 for(const Prompt::VarHolder &o: tracks) {
376 ATH_MSG_DEBUG("compScore - track: LepTrackDR = " << o.getVar(Def::LepTrackDR)
377 << ", TrackJetDR = " << o.getVar(Def::TrackJetDR)
378 << ", D0Sig = " << o.getVar(Def::D0Sig)
379 << ", Z0Sin = " << o.getVar(Def::Z0Sin)
380 << ", NumberOfPIXHits = " << o.getVar(Def::NumberOfPIXHits)
381 << ", NumberOfSCTHits = " << o.getVar(Def::NumberOfSCTHits)
382 << ", PtFrac = " << o.getVar(Def::TrackPtOverTrackJetPt) );
383 }
384
385 const std::map<std::string, double> results = m_toolRNN->computeRNNOutput(tracks);
386
387 for(const std::pair<const std::string, double>& v: results) {
388 //
389 // Decorate muon
390 //
391
392 ATH_MSG_DEBUG("DecoratePromptLeptonRNN compScore - " << v.first << " = " << v.second );
393
394 auto dit = m_decorNameMap.find (v.first);
395
396 if(dit != m_decorNameMap.end()) {
397 decors.at(dit->second)(particle) = v.second;
398 }
399 else {
400 ATH_MSG_WARNING("CompScore - unknown output label=\"" << v.first << "\"");
401 }
402
403 if(m_debug) {
404 std::map<std::string, TH1*>::iterator hit = m_hists.find(v.first);
405
406 if(hit == m_hists.end()) {
407 TH1* h = 0;
408
409 StatusCode hist_status = makeHist(h, v.first, 100, 0.0, 1.0);
410 if (hist_status != StatusCode::SUCCESS){
411 ATH_MSG_WARNING("DecoratePromptLeptonRNN compScore - failed to make hist");
412 }
413
414 hit = m_hists.insert(std::map<std::string, TH1*>::value_type(v.first, h)).first;
415 }
416
417 if(hit->second) {
418 hit->second->Fill(v.second);
419 }
420 }
421 }
422
423 return true;
424}
#define ATH_MSG_WARNING(x)
#define ATH_MSG_DEBUG(x)
std::map< std::string, TH1 * > m_hists
StatusCode makeHist(TH1 *&h, const std::string &key, int nbin, double xmin, double xmax)
std::unordered_map< std::string, size_t > m_decorNameMap
::StatusCode StatusCode
StatusCode definition for legacy code.
@ NumberOfPIXHits
Definition VarHolder.h:48
@ NumberOfSCTHits
Definition VarHolder.h:49
@ TrackPtOverTrackJetPt
Definition VarHolder.h:55
constexpr ParticleHypothesis particle[PARTICLEHYPOTHESES]
the array of masses

◆ declareGaudiProperty()

Gaudi::Details::PropertyBase & AthCommonDataStore< AthCommonMsg< Gaudi::Algorithm > >::declareGaudiProperty ( Gaudi::Property< T, V, H > & hndl,
const SG::VarHandleKeyType &  )
inlineprivateinherited

specialization for handling Gaudi::Property<SG::VarHandleKey>

Definition at line 156 of file AthCommonDataStore.h.

158 {
160 hndl.value(),
161 hndl.documentation());
162
163 }
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)

◆ declareProperty()

Gaudi::Details::PropertyBase & AthCommonDataStore< AthCommonMsg< Gaudi::Algorithm > >::declareProperty ( Gaudi::Property< T, V, H > & t)
inlineinherited

Definition at line 145 of file AthCommonDataStore.h.

145 {
146 typedef typename SG::HandleClassifier<T>::type htype;
148 }
Gaudi::Details::PropertyBase & declareGaudiProperty(Gaudi::Property< T, V, H > &hndl, const SG::VarHandleKeyType &)
specialization for handling Gaudi::Property<SG::VarHandleKey>

◆ detStore()

const ServiceHandle< StoreGateSvc > & AthCommonDataStore< AthCommonMsg< Gaudi::Algorithm > >::detStore ( ) const
inlineinherited

The standard StoreGateSvc/DetectorStore Returns (kind of) a pointer to the StoreGateSvc.

Definition at line 95 of file AthCommonDataStore.h.

◆ evtStore()

ServiceHandle< StoreGateSvc > & AthCommonDataStore< AthCommonMsg< Gaudi::Algorithm > >::evtStore ( )
inlineinherited

The standard StoreGateSvc (event store) Returns (kind of) a pointer to the StoreGateSvc.

Definition at line 85 of file AthCommonDataStore.h.

◆ execute() [1/2]

virtual StatusCode AthAlgorithm::execute ( const EventContext & )
inlinevirtualinherited

Execute method with EventContext.

Override this method if acccess to the EventContext is needed.

Definition at line 85 of file AthAlgorithm.h.

85 {
86 return execute();
87 }
virtual StatusCode execute()
Execute method without EventContext (deprecated).

◆ execute() [2/2]

StatusCode Prompt::DecoratePromptLeptonRNN::execute ( void )
overridevirtual

Execute method without EventContext (deprecated).

Override this method if the EventContext is not needed.

Reimplemented from AthAlgorithm.

Definition at line 71 of file DecoratePromptLeptonRNN.cxx.

72{
73 //
74 // Process current event
75 //
76 TimerScopeHelper timer(m_timerEvent);
77
78 const EventContext& ctx = Gaudi::Hive::currentContext();
79
80 ATH_MSG_DEBUG("execute() - begin...");
81
83
84 //
85 // Retrieve object containers and event info
86 //
87 SG::ReadHandle<xAOD::IParticleContainer> h_leptons (m_inputContainerLeptonKey, ctx);
88 SG::ReadHandle<xAOD::TrackParticleContainer> h_tracks (m_inputContainerTrackKey, ctx);
89 SG::ReadHandle<xAOD::JetContainer> h_trackJets (m_inputContainerTrackJetKey, ctx);
90 SG::ReadHandle<xAOD::VertexContainer> h_vertices (m_inputContainerPrimaryVerticesKey, ctx);
91
92 SG::ReadHandle<xAOD::EventInfo> event_handle (m_eventHandleKey, ctx);
93
94 ATH_MSG_DEBUG("Size of LeptonContainer: " << h_leptons->size());
95
96 std::vector<decoratorFloatH_t> decors;
97 decors.reserve (m_decorHandleKeys.size());
98 for (const SG::WriteDecorHandleKey<xAOD::IParticleContainer>& k : m_decorHandleKeys) {
99 decors.emplace_back (k, ctx);
100 }
101
102 //
103 // Find default Primary Vertex
104 //
105 const xAOD::Vertex *primaryVertex = nullptr;
106
107 for(const xAOD::Vertex *vertex: *h_vertices) {
108 if(vertex->vertexType() == xAOD::VxType::PriVtx) {
109 primaryVertex = vertex;
110 break;
111 }
112 }
113
114 //
115 // Collect tracks
116 //
117 for(const xAOD::IParticle *lepton: *h_leptons) {
118 //
119 // Select lepton track
120 //
121 const xAOD::TrackParticle *trackLep = nullptr;
122 const xAOD::Electron *elec = dynamic_cast<const xAOD::Electron*>(lepton);
123 const xAOD::Muon *muon = dynamic_cast<const xAOD::Muon *>(lepton);
124
125 if(elec) {
126 const xAOD::TrackParticle *bestmatchedGSFElTrack = elec->trackParticle(0);
127 if(bestmatchedGSFElTrack) {
128 trackLep = xAOD::EgammaHelpers::getOriginalTrackParticleFromGSF(bestmatchedGSFElTrack);
129 }
130 }
131 else if (muon) {
132 trackLep = findMuonTrack(muon);
133 }
134 else {
135 ATH_MSG_WARNING("execute - failed to find electron or muon: should never happen!");
136 }
137
138 //
139 // Find closest track jet
140 //
141 const xAOD::Jet *trackJet = findClosestTrackJet(trackLep, *h_trackJets);
142
143 if(!trackLep || !trackJet) {
144 compDummy(*lepton, decors);
145 continue;
146 }
147
148 //
149 // Select tracks within cone around lepton track.
150 //
151 std::vector<Prompt::VarHolder > select_tracks;
152
153 Prompt::VarHolder lepton_obj;
154
155 if(!prepTrackObject(lepton_obj, *trackLep, *trackLep, *trackJet, *primaryVertex, *event_handle)) {
156 continue;
157 }
158
159 //
160 // Add lepton track as one of the cone tracks.
161 //
162 select_tracks.push_back(lepton_obj);
163
164 for(const xAOD::TrackParticle *track: *h_tracks) {
165
166 if(!track) {
167 ATH_MSG_WARNING("Prompt::DecoratePromptLeptonRNN::execute - skip null track pointer - should never happen");
168 continue;
169 }
170
171 Prompt::VarHolder track_obj;
172
173 if(!prepTrackObject(track_obj, *track, *trackLep, *trackJet, *primaryVertex, *event_handle)) {
174 continue;
175 }
176
177 if(passTrack(track_obj)) {
178 select_tracks.push_back(track_obj);
179
180 ATH_MSG_DEBUG("Prompt::DecoratePromptLeptonRNN::execute - passed track pT= " << track->pt());
181 }
182 }
183
184 //
185 // Sort tracks by DR distance to lepton
186 //
187 std::sort(select_tracks.begin(), select_tracks.end(), Prompt::SortObjectByVar(Def::LepTrackDR, msg()));
188
189 //
190 // Compute RNN
191 //
192 compScore(*lepton, select_tracks, decors);
193
194 ATH_MSG_DEBUG("DecoratePromptLeptonRNN::CompScore - " << std::endl
195 << "lepton pT= " << lepton->pt()
196 << ", number of tracks: " << select_tracks.size());
197 }
198
199 return StatusCode::SUCCESS;
200}
SG::ReadHandleKey< xAOD::JetContainer > m_inputContainerTrackJetKey
const xAOD::TrackParticle * findMuonTrack(const xAOD::Muon *muon)
bool compDummy(const xAOD::IParticle &particle, std::vector< decoratorFloatH_t > &decors) const
const xAOD::Jet * findClosestTrackJet(const xAOD::TrackParticle *particle, const xAOD::JetContainer &trackJets)
SG::ReadHandleKey< xAOD::IParticleContainer > m_inputContainerLeptonKey
SG::WriteDecorHandleKeyArray< xAOD::IParticleContainer > m_decorHandleKeys
SG::ReadHandleKey< xAOD::VertexContainer > m_inputContainerPrimaryVerticesKey
SG::ReadHandleKey< xAOD::TrackParticleContainer > m_inputContainerTrackKey
bool compScore(const xAOD::IParticle &particle, const std::vector< Prompt::VarHolder > &tracks, std::vector< decoratorFloatH_t > &decors)
SG::ReadHandleKey< xAOD::EventInfo > m_eventHandleKey
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)
const xAOD::TrackParticle * trackParticle(size_t index=0) const
Pointer to the xAOD::TrackParticle/s that match the electron candidate.
timer(name, disabled=False)
void sort(typename DataModel_detail::iterator< DVL > beg, typename DataModel_detail::iterator< DVL > end)
Specialization of sort for DataVector/List.
const xAOD::TrackParticle * getOriginalTrackParticleFromGSF(const xAOD::TrackParticle *trkPar)
Helper function for getting the "Original" Track Particle (i.e before GSF) via the GSF Track Particle...
@ PriVtx
Primary vertex.
Jet_v1 Jet
Definition of the current "jet version".
TrackParticle_v1 TrackParticle
Reference the current persistent version:
Vertex_v1 Vertex
Define the latest version of the vertex class.
Muon_v1 Muon
Reference the current persistent version:
Electron_v1 Electron
Definition of the current "egamma version".

◆ extraDeps_update_handler()

void AthCommonDataStore< AthCommonMsg< Gaudi::Algorithm > >::extraDeps_update_handler ( Gaudi::Details::PropertyBase & ExtraDeps)
protectedinherited

Add StoreName to extra input/output deps as needed.

use the logic of the VarHandleKey to parse the DataObjID keys supplied via the ExtraInputs and ExtraOuputs Properties to add the StoreName if it's not explicitly given

◆ extraOutputDeps()

const DataObjIDColl & AthAlgorithm::extraOutputDeps ( ) const
overridevirtualinherited

Return the list of extra output dependencies.

This list is extended to include symlinks implied by inheritance relations.

Definition at line 50 of file AthAlgorithm.cxx.

51{
52 // If we didn't find any symlinks to add, just return the collection
53 // from the base class. Otherwise, return the extended collection.
54 if (!m_extendedExtraObjects.empty()) {
56 }
57 return Algorithm::extraOutputDeps();
58}
DataObjIDColl m_extendedExtraObjects

◆ filterPassed()

bool AthAlgorithm::filterPassed ( ) const
inherited

Definition at line 94 of file AthAlgorithm.cxx.

94 {
95 return execState( Gaudi::Hive::currentContext() ).filterPassed();
96}

◆ finalize()

StatusCode Prompt::DecoratePromptLeptonRNN::finalize ( )
overridevirtual

Definition at line 203 of file DecoratePromptLeptonRNN.cxx.

204{
205 //
206 // Finalize output
207 //
208 if(m_printTime) {
209 //
210 // Print full time stopwatch
211 //
212 ATH_MSG_INFO("DecoratePromptLeptonRNN - total time: " << PrintResetStopWatch(m_timerEvent));
213 ATH_MSG_INFO("DecoratePromptLeptonRNN - processed " << m_countEvent << " events.");
214 }
215
216 return StatusCode::SUCCESS;
217}
#define ATH_MSG_INFO(x)
std::string PrintResetStopWatch(TStopwatch &watch)

◆ findClosestTrackJet()

const xAOD::Jet * Prompt::DecoratePromptLeptonRNN::findClosestTrackJet ( const xAOD::TrackParticle * particle,
const xAOD::JetContainer & trackJets )

Definition at line 231 of file DecoratePromptLeptonRNN.cxx.

233{
234 //
235 // Find track jet closest to IParticle and within fixed cone
236 //
237 if(!particle) {
238 return 0;
239 }
240
241 const xAOD::Jet *trackJet = 0;
242 double currTrackJetDR = -1.0;
243
244 //
245 // Select track jet within cone around muon
246 //
247 for(const xAOD::Jet *jet: trackJets) {
248 const double dr = particle->p4().DeltaR(jet->p4());
249
250 if(currTrackJetDR < 0.0 || dr < currTrackJetDR) {
251 trackJet = jet;
252 currTrackJetDR = dr;
253 }
254 }
255
256 if(trackJet && currTrackJetDR < m_maxLepTrackJetDR) {
257 return trackJet;
258 }
259
260 return 0;
261}
Gaudi::Property< double > m_maxLepTrackJetDR

◆ findMuonTrack()

const xAOD::TrackParticle * Prompt::DecoratePromptLeptonRNN::findMuonTrack ( const xAOD::Muon * muon)

Definition at line 220 of file DecoratePromptLeptonRNN.cxx.

220 {
221 //
222 // Process muon - return true if all information present for RNN
223 //
224 ATH_MSG_DEBUG("muon pT=" << muon->pt() << " quality=" << muon->quality());
225
226 return muon->muonType() == xAOD::Muon::MuonType::Combined ?
227 muon->trackParticle(xAOD::Muon::TrackParticleType::InnerDetectorTrackParticle) : nullptr;
228 }

◆ getContext()

const EventContext & AthAlgorithm::getContext ( ) const
inherited

Deprecated methods (use the ones with EventContext).

Definition at line 90 of file AthAlgorithm.cxx.

90 {
91 return Gaudi::Hive::currentContext();
92}

◆ initialize()

StatusCode Prompt::DecoratePromptLeptonRNN::initialize ( )
overridevirtual

Definition at line 28 of file DecoratePromptLeptonRNN.cxx.

29{
30 ATH_MSG_DEBUG("Initializing DecoratePromptLeptonRNN...");
31
32 // Initialize read/write handles
37
38 ATH_CHECK(m_eventHandleKey.initialize());
39
40 //
41 // Initialize tools and services
42 //
43 ATH_CHECK( m_histSvc.retrieve() );
44
45 m_decorHandleKeys.clear();
46 for(const std::string &label: m_toolRNN->getOutputLabels()) {
47 const std::string key = m_decorationPrefixRNN + label;
48
49 ATH_MSG_DEBUG("Add output RNN label: \"" << key << "\"");
50
51 m_decorNameMap.try_emplace (label, m_decorHandleKeys.size());
53 }
54 ATH_CHECK(m_decorHandleKeys.initialize());
55
56 ATH_MSG_DEBUG("inputContainerMuon=\"" << m_inputContainerLeptonKey << "\"");
57
58 //
59 // Instantiate Muon quality accessors
60 //
61
62 m_timerEvent.Reset();
63
64 ATH_MSG_DEBUG("DecoratePromptLeptonRNN initialized successfully.");
65
66 return StatusCode::SUCCESS;
67
68}
#define ATH_CHECK
Evaluate an expression and check for errors.
Gaudi::Property< std::string > m_decorationPrefixRNN
std::string label(const std::string &format, int i)
Definition label.h:19
std::string makeContDecorKey(const std::string &cont, const std::string &decor)
Make a StoreGate key from container and decoration name.

◆ inputHandles()

virtual std::vector< Gaudi::DataHandle * > AthCommonDataStore< AthCommonMsg< Gaudi::Algorithm > >::inputHandles ( ) const
overridevirtualinherited

Return this algorithm's input handles.

We override this to include handle instances from key arrays if they have not yet been declared. See comments on updateVHKA.

◆ isReEntrant()

virtual bool AthAlgorithm::isReEntrant ( ) const
inlinefinaloverrideprotectedvirtualinherited

Legacy algorithms are not thread-safe.

Definition at line 118 of file AthAlgorithm.h.

118{ return false; }

◆ makeHist()

StatusCode Prompt::DecoratePromptLeptonRNN::makeHist ( TH1 *& h,
const std::string & key,
int nbin,
double xmin,
double xmax )

Definition at line 441 of file DecoratePromptLeptonRNN.cxx.

442{
443 //
444 // Initiliase histogram pointer. If configured to run in validation mode, then create and register histogram
445 //
446 h = 0;
447
448 if(m_outputStream.empty() || key.empty()) {
449 return StatusCode::SUCCESS;
450 }
451
452 const std::string hname = name() + "_" + key;
453 const std::string hist_key = "/"+m_outputStream+"/"+hname;
454
455 h = new TH1D(hname.c_str(), hname.c_str(), nbin, xmin, xmax);
456 h->SetDirectory(0);
457
458 return m_histSvc->regHist(hist_key, h);
459}
Gaudi::Property< std::string > m_outputStream
double xmax
Definition listroot.cxx:61
double xmin
Definition listroot.cxx:60

◆ msg()

MsgStream & AthCommonMsg< Gaudi::Algorithm >::msg ( ) const
inlineinherited

Definition at line 24 of file AthCommonMsg.h.

24 {
25 return this->msgStream();
26 }

◆ msgLvl()

bool AthCommonMsg< Gaudi::Algorithm >::msgLvl ( const MSG::Level lvl) const
inlineinherited

Definition at line 30 of file AthCommonMsg.h.

30 {
31 return this->msgLevel(lvl);
32 }

◆ outputHandles()

virtual std::vector< Gaudi::DataHandle * > AthCommonDataStore< AthCommonMsg< Gaudi::Algorithm > >::outputHandles ( ) const
overridevirtualinherited

Return this algorithm's output handles.

We override this to include handle instances from key arrays if they have not yet been declared. See comments on updateVHKA.

◆ passTrack()

bool Prompt::DecoratePromptLeptonRNN::passTrack ( Prompt::VarHolder & p)

Definition at line 339 of file DecoratePromptLeptonRNN.cxx.

340{
341 //
342 // Select cone tracks
343 //
344 if(p.getVar(Def::LepTrackDR) < m_minTrackLeptonDR) return false;
345 if(p.getVar(Def::LepTrackDR) > m_maxTrackLeptonDR) return false;
346
347 //
348 // Kinematic track selection
349 //
350 if(p.getVar(Def::Pt) < m_minTrackpT) return false;
351 if(p.getVar(Def::AbsEta) > m_maxTrackEta) return false;
352 if(std::fabs(p.getVar(Def::Z0Sin)) > m_maxTrackZ0Sin) return false;
353
354 //
355 // Hit quality track selection
356 //
357 if(p.getVar(Def::NumberOfSiHits) < m_minTrackSiHits) return false;
358 if(p.getVar(Def::NumberOfSharedSiHits) > m_maxTrackSharedSiHits) return false;
359 if(p.getVar(Def::NumberOfSiHoles) > m_maxTrackSiHoles) return false;
360 if(p.getVar(Def::NumberOfPixelHoles) > m_maxTrackPixHoles) return false;
361
362 return true;
363}
Gaudi::Property< double > m_maxTrackEta
Gaudi::Property< unsigned > m_minTrackSiHits
Gaudi::Property< unsigned > m_maxTrackSiHoles
Gaudi::Property< double > m_maxTrackLeptonDR
Gaudi::Property< double > m_maxTrackZ0Sin
Gaudi::Property< double > m_maxTrackSharedSiHits
Gaudi::Property< unsigned > m_maxTrackPixHoles
Gaudi::Property< double > m_minTrackLeptonDR
Gaudi::Property< double > m_minTrackpT
@ NumberOfPixelHoles
Definition VarHolder.h:53
@ NumberOfSharedSiHits
Definition VarHolder.h:51
@ NumberOfSiHoles
Definition VarHolder.h:52

◆ prepTrackObject()

bool Prompt::DecoratePromptLeptonRNN::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 at line 264 of file DecoratePromptLeptonRNN.cxx.

272{
273 //
274 // Add xAOD::TrackParticle variables to the track object VarHolder
275 //
282
283 if(!(track.summaryValue(numberOfPixelHits, xAOD::numberOfPixelHits))) return false;
284 if(!(track.summaryValue(numberOfSCTHits, xAOD::numberOfSCTHits))) return false;
285 if(!(track.summaryValue(numberOfPixelHoles, xAOD::numberOfPixelHoles))) return false;
286 if(!(track.summaryValue(numberOfSCTHoles, xAOD::numberOfSCTHoles))) return false;
287 if(!(track.summaryValue(numberOfPixelSharedHits, xAOD::numberOfPixelSharedHits))) return false;
288 if(!(track.summaryValue(numberOfSCTSharedHits, xAOD::numberOfSCTSharedHits))) return false;
289
290 const uint8_t NSiHits = numberOfPixelHits + numberOfSCTHits;
292 const float NSiShHits = float(numberOfPixelSharedHits) + float(numberOfSCTSharedHits)/2.0;
293
294 p.addVar(Def::Pt, track.pt());
295 p.addVar(Def::AbsEta, std::fabs(track.eta()));
296 p.addVar(Def::NumberOfPIXHits, numberOfPixelHits);
297 p.addVar(Def::NumberOfSCTHits, numberOfSCTHits);
298 p.addVar(Def::NumberOfSiHits, NSiHits);
299 p.addVar(Def::NumberOfSharedSiHits, NSiShHits);
300 p.addVar(Def::NumberOfSiHoles, NSiHoles);
301 p.addVar(Def::NumberOfPixelHoles, numberOfPixelHoles);
302
303 //
304 // Add lepton - jet variables to VarHolder
305 //
306 double PtFrac = -99.;
307
308 if(track.pt() > 0.0 && trackJet.pt() > 0.0) {
309 PtFrac = track.pt() / trackJet.pt();
310 }
311
312 p.addVar(Def::TrackPtOverTrackJetPt, PtFrac);
313 p.addVar(Def::TrackJetDR, track.p4().DeltaR(trackJet.p4()));
314 p.addVar(Def::LepTrackDR, track.p4().DeltaR(lepton.p4()));
315
316 //
317 // Add Impact Parameters
318 //
319 double d0_significance = -99.;
320 double Z0Sin = 0.0;
321
322 if(track.definingParametersCovMatrixVec().size() > 0 && track.definingParametersCovMatrixVec().at(0) > 0.0) {
323 d0_significance = xAOD::TrackingHelpers::d0significance(&track,
324 event.beamPosSigmaX(),
325 event.beamPosSigmaY(),
326 event.beamPosSigmaXY());
327 }
328
329 const double deltaZ0 = track.z0() + track.vz() - priVtx.z();
330 Z0Sin = deltaZ0*std::sin(track.theta());
331
332 p.addVar(Def::Z0Sin, Z0Sin);
333 p.addVar(Def::D0Sig, d0_significance);
334
335 return true;
336}
virtual FourMom_t p4() const
The full 4-momentum of the particle.
Definition Jet_v1.cxx:71
virtual double pt() const
The transverse momentum ( ) of the particle.
Definition Jet_v1.cxx:44
virtual FourMom_t p4() const override final
The full 4-momentum of the particle.
float z() const
Returns the z position.
double d0significance(const xAOD::TrackParticle *tp, double d0_uncert_beam_spot_2)
@ numberOfPixelHoles
number of pixel layers on track with absence of hits [unit8_t].
@ numberOfSCTHits
number of hits in SCT [unit8_t].
@ numberOfPixelHits
these are the pixel hits, including the b-layer [unit8_t].
@ numberOfPixelSharedHits
number of Pixel all-layer hits shared by several tracks [unit8_t].
@ numberOfSCTSharedHits
number of SCT hits shared by several tracks [unit8_t].
@ numberOfSCTHoles
number of SCT holes [unit8_t].

◆ renounce()

std::enable_if_t< std::is_void_v< std::result_of_t< decltype(&T::renounce)(T)> > &&!std::is_base_of_v< SG::VarHandleKeyArray, T > &&std::is_base_of_v< Gaudi::DataHandle, T >, void > AthCommonDataStore< AthCommonMsg< Gaudi::Algorithm > >::renounce ( T & h)
inlineprotectedinherited

Definition at line 380 of file AthCommonDataStore.h.

381 {
382 h.renounce();
384 }
std::enable_if_t< std::is_void_v< std::result_of_t< decltype(&T::renounce)(T)> > &&!std::is_base_of_v< SG::VarHandleKeyArray, T > &&std::is_base_of_v< Gaudi::DataHandle, T >, void > renounce(T &h)

◆ renounceArray()

void AthCommonDataStore< AthCommonMsg< Gaudi::Algorithm > >::renounceArray ( SG::VarHandleKeyArray & handlesArray)
inlineprotectedinherited

remove all handles from I/O resolution

Definition at line 364 of file AthCommonDataStore.h.

364 {
366 }

◆ setFilterPassed()

void AthAlgorithm::setFilterPassed ( bool state) const
inherited

Definition at line 98 of file AthAlgorithm.cxx.

98 {
99 execState( Gaudi::Hive::currentContext() ).setFilterPassed(state);
100}

◆ sysInitialize()

StatusCode AthAlgorithm::sysInitialize ( )
overridevirtualinherited

Override sysInitialize.

Override sysInitialize from the base class.

Loop through all output handles, and if they're WriteCondHandles, automatically register them and this Algorithm with the CondSvc.

Scan through all outputHandles, and if they're WriteCondHandles, register them with the CondSvc

Reimplemented from AthCommonDataStore< AthCommonMsg< Gaudi::Algorithm > >.

Reimplemented in AthAnalysisAlgorithm, AthFilterAlgorithm, AthHistogramAlgorithm, and PyAthena::Alg.

Definition at line 66 of file AthAlgorithm.cxx.

66 {
68
69 if (sc.isFailure()) {
70 return sc;
71 }
72 ServiceHandle<ICondSvc> cs("CondSvc",name());
73 for (auto h : outputHandles()) {
74 if (h->isCondition() && h->mode() == Gaudi::DataHandle::Writer) {
75 // do this inside the loop so we don't create the CondSvc until needed
76 if ( cs.retrieve().isFailure() ) {
77 ATH_MSG_WARNING("no CondSvc found: won't autoreg WriteCondHandles");
78 return StatusCode::SUCCESS;
79 }
80 if (cs->regHandle(this,*h).isFailure()) {
81 sc = StatusCode::FAILURE;
82 ATH_MSG_ERROR("unable to register WriteCondHandle " << h->fullKey()
83 << " with CondSvc");
84 }
85 }
86 }
87 return sc;
88}
#define ATH_MSG_ERROR(x)
static Double_t sc
virtual StatusCode sysInitialize() override
Override sysInitialize.
AthCommonDataStore(const std::string &name, T... args)
virtual std::vector< Gaudi::DataHandle * > outputHandles() const override

◆ sysStart()

virtual StatusCode AthCommonDataStore< AthCommonMsg< Gaudi::Algorithm > >::sysStart ( )
overridevirtualinherited

Handle START transition.

We override this in order to make sure that conditions handle keys can cache a pointer to the conditions container.

◆ updateVHKA()

void AthCommonDataStore< AthCommonMsg< Gaudi::Algorithm > >::updateVHKA ( Gaudi::Details::PropertyBase & )
inlineinherited

Definition at line 308 of file AthCommonDataStore.h.

308 {
309 // debug() << "updateVHKA for property " << p.name() << " " << p.toString()
310 // << " size: " << m_vhka.size() << endmsg;
311 for (auto &a : m_vhka) {
313 for (auto k : keys) {
314 k->setOwner(this);
315 }
316 }
317 }

Member Data Documentation

◆ m_countEvent

int Prompt::DecoratePromptLeptonRNN::m_countEvent

Definition at line 138 of file DecoratePromptLeptonRNN.h.

◆ m_debug

Gaudi::Property<bool> Prompt::DecoratePromptLeptonRNN::m_debug {this, "debug", false, "debug statement"}

Definition at line 107 of file DecoratePromptLeptonRNN.h.

107{this, "debug", false, "debug statement"};

◆ m_decorationPrefixRNN

Gaudi::Property<std::string> Prompt::DecoratePromptLeptonRNN::m_decorationPrefixRNN {this, "decorationPrefixRNN", "", "Prefix of the name for the decorator of RNN to the lepton"}

Definition at line 92 of file DecoratePromptLeptonRNN.h.

92{this, "decorationPrefixRNN", "", "Prefix of the name for the decorator of RNN to the lepton"};

◆ m_decorHandleKeys

SG::WriteDecorHandleKeyArray<xAOD::IParticleContainer> Prompt::DecoratePromptLeptonRNN::m_decorHandleKeys { this, "DecorHandleKeys", {} }

Definition at line 143 of file DecoratePromptLeptonRNN.h.

144{ this, "DecorHandleKeys", {} };

◆ m_decorNameMap

std::unordered_map<std::string, size_t> Prompt::DecoratePromptLeptonRNN::m_decorNameMap

Definition at line 145 of file DecoratePromptLeptonRNN.h.

◆ m_detStore

StoreGateSvc_t AthCommonDataStore< AthCommonMsg< Gaudi::Algorithm > >::m_detStore
privateinherited

Pointer to StoreGate (detector store by default).

Definition at line 393 of file AthCommonDataStore.h.

◆ m_eventHandleKey

SG::ReadHandleKey<xAOD::EventInfo> Prompt::DecoratePromptLeptonRNN::m_eventHandleKey
Initial value:
{
this, "EventHandleKey", "EventInfo"
}

Definition at line 132 of file DecoratePromptLeptonRNN.h.

132 {
133 this, "EventHandleKey", "EventInfo"
134 };

◆ m_evtStore

StoreGateSvc_t AthCommonDataStore< AthCommonMsg< Gaudi::Algorithm > >::m_evtStore
privateinherited

Pointer to StoreGate (event store by default).

Definition at line 390 of file AthCommonDataStore.h.

◆ m_extendedExtraObjects

DataObjIDColl AthAlgorithm::m_extendedExtraObjects
privateinherited

Definition at line 121 of file AthAlgorithm.h.

◆ m_hists

std::map<std::string, TH1*> Prompt::DecoratePromptLeptonRNN::m_hists

Definition at line 140 of file DecoratePromptLeptonRNN.h.

◆ m_histSvc

ServiceHandle<ITHistSvc> Prompt::DecoratePromptLeptonRNN::m_histSvc

Definition at line 115 of file DecoratePromptLeptonRNN.h.

◆ m_inputContainerLeptonKey

SG::ReadHandleKey<xAOD::IParticleContainer> Prompt::DecoratePromptLeptonRNN::m_inputContainerLeptonKey
Initial value:
{
this, "inputContainerLepton", "",
"Container's name of the lepton that you want to decorate"
}

Definition at line 118 of file DecoratePromptLeptonRNN.h.

118 {
119 this, "inputContainerLepton", "",
120 "Container's name of the lepton that you want to decorate"
121 };

◆ m_inputContainerPrimaryVerticesKey

SG::ReadHandleKey<xAOD::VertexContainer> Prompt::DecoratePromptLeptonRNN::m_inputContainerPrimaryVerticesKey
Initial value:
{
this, "inputContainerPrimaryVertices", "", "Primary vertex container name"
}

Definition at line 128 of file DecoratePromptLeptonRNN.h.

128 {
129 this, "inputContainerPrimaryVertices", "", "Primary vertex container name"
130 };

◆ m_inputContainerTrackJetKey

SG::ReadHandleKey<xAOD::JetContainer> Prompt::DecoratePromptLeptonRNN::m_inputContainerTrackJetKey
Initial value:
{
this, "inputContainerTrackJet", "", "Track Jet container name"
}

Definition at line 125 of file DecoratePromptLeptonRNN.h.

125 {
126 this, "inputContainerTrackJet", "", "Track Jet container name"
127 };

◆ m_inputContainerTrackKey

SG::ReadHandleKey<xAOD::TrackParticleContainer> Prompt::DecoratePromptLeptonRNN::m_inputContainerTrackKey
Initial value:
{
this, "inputContainerTrack", "", "Track container name"
}

Definition at line 122 of file DecoratePromptLeptonRNN.h.

122 {
123 this, "inputContainerTrack", "", "Track container name"
124 };

◆ m_maxLepTrackJetDR

Gaudi::Property<double> Prompt::DecoratePromptLeptonRNN::m_maxLepTrackJetDR {this, "maxLepTrackJetDR", 0.4, "Maximum distance between lepton and track jet for track jet matching"}

Definition at line 100 of file DecoratePromptLeptonRNN.h.

100{this, "maxLepTrackJetDR", 0.4, "Maximum distance between lepton and track jet for track jet matching"};

◆ m_maxTrackEta

Gaudi::Property<double> Prompt::DecoratePromptLeptonRNN::m_maxTrackEta {this, "maxTrackEta", 2.5, "abs(eta) cut config for the input tracks to RNN"}

Definition at line 95 of file DecoratePromptLeptonRNN.h.

95{this, "maxTrackEta", 2.5, "abs(eta) cut config for the input tracks to RNN"};

◆ m_maxTrackLeptonDR

Gaudi::Property<double> Prompt::DecoratePromptLeptonRNN::m_maxTrackLeptonDR {this, "maxTrackLeptonDR", 0.4, "Delta R between lepton and track cut config for the input tracks to RNN"}

Definition at line 99 of file DecoratePromptLeptonRNN.h.

99{this, "maxTrackLeptonDR", 0.4, "Delta R between lepton and track cut config for the input tracks to RNN"};

◆ m_maxTrackPixHoles

Gaudi::Property<unsigned> Prompt::DecoratePromptLeptonRNN::m_maxTrackPixHoles {this, "maxTrackPixHoles", 1.5, "track pixel holes cut config for the input tracks to RNN"}

Definition at line 105 of file DecoratePromptLeptonRNN.h.

105{this, "maxTrackPixHoles", 1.5, "track pixel holes cut config for the input tracks to RNN"};

◆ m_maxTrackSharedSiHits

Gaudi::Property<double> Prompt::DecoratePromptLeptonRNN::m_maxTrackSharedSiHits {this, "maxTrackSharedSiHits", 1.5, "track shared si hits cut config for the input tracks to RNN"}

Definition at line 102 of file DecoratePromptLeptonRNN.h.

102{this, "maxTrackSharedSiHits", 1.5, "track shared si hits cut config for the input tracks to RNN"};

◆ m_maxTrackSiHoles

Gaudi::Property<unsigned> Prompt::DecoratePromptLeptonRNN::m_maxTrackSiHoles {this, "maxTrackSiHoles", 2.5, "track holes cut config for the input tracks to RNN"}

Definition at line 104 of file DecoratePromptLeptonRNN.h.

104{this, "maxTrackSiHoles", 2.5, "track holes cut config for the input tracks to RNN"};

◆ m_maxTrackZ0Sin

Gaudi::Property<double> Prompt::DecoratePromptLeptonRNN::m_maxTrackZ0Sin {this, "maxTrackZ0Sin", 1.0, "Z0sin cut config for the input tracks to RNN"}

Definition at line 96 of file DecoratePromptLeptonRNN.h.

96{this, "maxTrackZ0Sin", 1.0, "Z0sin cut config for the input tracks to RNN"};

◆ m_minTrackLeptonDR

Gaudi::Property<double> Prompt::DecoratePromptLeptonRNN::m_minTrackLeptonDR {this, "minTrackLeptonDR", 1.0e-6, "Delta R between lepton and track cut config for the input tracks to RNN"}

Definition at line 98 of file DecoratePromptLeptonRNN.h.

98{this, "minTrackLeptonDR", 1.0e-6, "Delta R between lepton and track cut config for the input tracks to RNN"};

◆ m_minTrackpT

Gaudi::Property<double> Prompt::DecoratePromptLeptonRNN::m_minTrackpT {this, "minTrackpT", 500.0, "pT cut config for the input tracks to RNN"}

Definition at line 94 of file DecoratePromptLeptonRNN.h.

94{this, "minTrackpT", 500.0, "pT cut config for the input tracks to RNN"};

◆ m_minTrackSiHits

Gaudi::Property<unsigned> Prompt::DecoratePromptLeptonRNN::m_minTrackSiHits {this, "minTrackSiHits", 6.5, "track silicon detector hits cut config for the input tracks to RNN"}

Definition at line 103 of file DecoratePromptLeptonRNN.h.

103{this, "minTrackSiHits", 6.5, "track silicon detector hits cut config for the input tracks to RNN"};

◆ m_outputStream

Gaudi::Property<std::string> Prompt::DecoratePromptLeptonRNN::m_outputStream {this, "outputStream", "", "Path of the ROOT output directory of the histograms for RNN debug"}

Definition at line 91 of file DecoratePromptLeptonRNN.h.

91{this, "outputStream", "", "Path of the ROOT output directory of the histograms for RNN debug"};

◆ m_printTime

Gaudi::Property<bool> Prompt::DecoratePromptLeptonRNN::m_printTime {this, "printTime", false, "print running time, for debug"}

Definition at line 108 of file DecoratePromptLeptonRNN.h.

108{this, "printTime", false, "print running time, for debug"};

◆ m_timerEvent

TStopwatch Prompt::DecoratePromptLeptonRNN::m_timerEvent

Definition at line 137 of file DecoratePromptLeptonRNN.h.

◆ m_toolRNN

ToolHandle<IRNNTool> Prompt::DecoratePromptLeptonRNN::m_toolRNN
Initial value:
{
this, "toolRNN", "defaultToolRNN", "Dedicated tool for RNN prediction"
}

Definition at line 111 of file DecoratePromptLeptonRNN.h.

111 {
112 this, "toolRNN", "defaultToolRNN", "Dedicated tool for RNN prediction"
113 };

◆ m_varHandleArraysDeclared

bool AthCommonDataStore< AthCommonMsg< Gaudi::Algorithm > >::m_varHandleArraysDeclared
privateinherited

Definition at line 399 of file AthCommonDataStore.h.

◆ m_vhka

std::vector<SG::VarHandleKeyArray*> AthCommonDataStore< AthCommonMsg< Gaudi::Algorithm > >::m_vhka
privateinherited

Definition at line 398 of file AthCommonDataStore.h.


The documentation for this class was generated from the following files: