15#include "GaudiKernel/ThreadLocalContext.h"
61 m_accessQuality = std::make_unique<SG::AuxElement::ConstAccessor<unsigned char> >(
"quality");
65 ATH_MSG_DEBUG(
"DecoratePromptLeptonRNN initialized successfully.");
67 return StatusCode::SUCCESS;
79 const EventContext& ctx = Gaudi::Hive::currentContext();
95 ATH_MSG_DEBUG(
"Size of LeptonContainer: " << h_leptons->size());
97 std::vector<decoratorFloatH_t> decors;
100 decors.emplace_back (k, ctx);
110 primaryVertex = vertex;
128 if(bestmatchedGSFElTrack) {
136 ATH_MSG_WARNING(
"execute - failed to find electron or muon: should never happen!");
144 if(!trackLep || !trackJet) {
152 std::vector<Prompt::VarHolder > select_tracks;
156 if(!
prepTrackObject(lepton_obj, *trackLep, *trackLep, *trackJet, *primaryVertex, *event_handle)) {
163 select_tracks.push_back(lepton_obj);
168 ATH_MSG_WARNING(
"Prompt::DecoratePromptLeptonRNN::execute - skip null track pointer - should never happen");
174 if(!
prepTrackObject(track_obj, *track, *trackLep, *trackJet, *primaryVertex, *event_handle)) {
179 select_tracks.push_back(track_obj);
181 ATH_MSG_DEBUG(
"Prompt::DecoratePromptLeptonRNN::execute - passed track pT= " << track->pt());
193 compScore(*lepton, select_tracks, decors);
195 ATH_MSG_DEBUG(
"DecoratePromptLeptonRNN::CompScore - " << std::endl
196 <<
"lepton pT= " << lepton->pt()
197 <<
", number of tracks: " << select_tracks.size());
200 return StatusCode::SUCCESS;
217 return StatusCode::SUCCESS;
226 if(muon->muonType() != xAOD::Muon::Combined || !muon->inDetTrackParticleLink().isValid()) {
230 const unsigned char quality = (*m_accessQuality)(*muon);
232 ATH_MSG_DEBUG(
"muon pT=" << muon->pt() <<
" quality=" <<
int(quality) <<
" medium=" <<
int(xAOD::Muon::Medium));
251 double currTrackJetDR = -1.0;
257 const double dr = particle->p4().DeltaR(
jet->p4());
259 if(currTrackJetDR < 0.0 || dr < currTrackJetDR) {
285 uint8_t numberOfPixelHits = 0;
286 uint8_t numberOfSCTHits = 0;
287 uint8_t numberOfPixelHoles = 0;
288 uint8_t numberOfSCTHoles = 0;
289 uint8_t numberOfPixelSharedHits = 0;
290 uint8_t numberOfSCTSharedHits = 0;
299 const uint8_t NSiHits = numberOfPixelHits + numberOfSCTHits;
300 const uint8_t NSiHoles = numberOfPixelHoles + numberOfSCTHoles;
301 const float NSiShHits = float(numberOfPixelSharedHits) + float(numberOfSCTSharedHits)/2.0;
315 double PtFrac = -99.;
317 if(track.pt() > 0.0 && trackJet.
pt() > 0.0) {
318 PtFrac = track.pt() / trackJet.
pt();
328 double d0_significance = -99.;
331 if(track.definingParametersCovMatrixVec().size() > 0 && track.definingParametersCovMatrixVec().at(0) > 0.0) {
333 event.beamPosSigmaX(),
334 event.beamPosSigmaY(),
335 event.beamPosSigmaXY());
338 const double deltaZ0 = track.z0() + track.vz() - priVtx.
z();
339 Z0Sin = deltaZ0*std::sin(track.theta());
376 const std::vector<Prompt::VarHolder> &tracks,
377 std::vector<decoratorFloatH_t>& decors)
382 ATH_MSG_DEBUG(
"compScore - number of tracks: " << tracks.size());
394 const std::map<std::string, double> results =
m_toolRNN->computeRNNOutput(tracks);
396 for(
const std::pair<const std::string, double>& v: results) {
401 ATH_MSG_DEBUG(
"DecoratePromptLeptonRNN compScore - " << v.first <<
" = " << v.second );
406 decors.at(dit->second)(particle) = v.second;
409 ATH_MSG_WARNING(
"CompScore - unknown output label=\"" << v.first <<
"\"");
413 std::map<std::string, TH1*>::iterator hit =
m_hists.find(v.first);
418 StatusCode hist_status =
makeHist(
h, v.first, 100, 0.0, 1.0);
419 if (hist_status != StatusCode::SUCCESS){
420 ATH_MSG_WARNING(
"DecoratePromptLeptonRNN compScore - failed to make hist");
423 hit =
m_hists.insert(std::map<std::string, TH1*>::value_type(v.first,
h)).first;
427 hit->second->Fill(v.second);
437 std::vector<decoratorFloatH_t>& decors)
const
442 for (
auto& d : decors) {
458 return StatusCode::SUCCESS;
461 const std::string hname = name() +
"_" + key;
464 h =
new TH1D(hname.c_str(), hname.c_str(), nbin,
xmin,
xmax);
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_WARNING(x)
Some common helper functions used by decoration handles.
AthAlgorithm(const std::string &name, ISvcLocator *pSvcLocator)
Constructor with parameters:
Header file for AthHistogramAlgorithm.
ServiceHandle< ITHistSvc > m_histSvc
virtual StatusCode finalize() override
SG::ReadHandleKey< xAOD::JetContainer > m_inputContainerTrackJetKey
Gaudi::Property< double > m_maxTrackEta
const xAOD::TrackParticle * findMuonTrack(const xAOD::Muon *muon)
bool compDummy(const xAOD::IParticle &particle, std::vector< decoratorFloatH_t > &decors) const
Gaudi::Property< unsigned > m_minTrackSiHits
std::map< std::string, TH1 * > m_hists
DecoratePromptLeptonRNN(const std::string &name, ISvcLocator *pSvcLocator)
Gaudi::Property< unsigned > m_maxTrackSiHoles
Gaudi::Property< bool > m_debug
StatusCode makeHist(TH1 *&h, const std::string &key, int nbin, double xmin, double xmax)
ToolHandle< IRNNTool > m_toolRNN
std::unordered_map< std::string, size_t > m_decorNameMap
Gaudi::Property< bool > m_printTime
Gaudi::Property< double > m_maxTrackLeptonDR
const xAOD::Jet * findClosestTrackJet(const xAOD::TrackParticle *particle, const xAOD::JetContainer &trackJets)
SG::ReadHandleKey< xAOD::IParticleContainer > m_inputContainerLeptonKey
Gaudi::Property< double > m_maxLepTrackJetDR
std::unique_ptr< SG::AuxElement::ConstAccessor< unsigned char > > m_accessQuality
bool passTrack(Prompt::VarHolder &p)
Gaudi::Property< double > m_maxTrackZ0Sin
virtual StatusCode initialize() override
SG::WriteDecorHandleKeyArray< xAOD::IParticleContainer > m_decorHandleKeys
SG::ReadHandleKey< xAOD::VertexContainer > m_inputContainerPrimaryVerticesKey
Gaudi::Property< std::string > m_decorationPrefixRNN
Gaudi::Property< std::string > m_outputStream
SG::ReadHandleKey< xAOD::TrackParticleContainer > m_inputContainerTrackKey
bool compScore(const xAOD::IParticle &particle, const std::vector< Prompt::VarHolder > &tracks, std::vector< decoratorFloatH_t > &decors)
virtual StatusCode execute() override
Gaudi::Property< double > m_maxTrackSharedSiHits
Gaudi::Property< unsigned > m_maxTrackPixHoles
SG::ReadHandleKey< xAOD::EventInfo > m_eventHandleKey
Gaudi::Property< double > m_minTrackLeptonDR
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)
Gaudi::Property< double > m_minTrackpT
Property holding a SG store/key/clid/attr name from which a WriteDecorHandle is made.
const xAOD::TrackParticle * trackParticle(size_t index=0) const
Pointer to the xAOD::TrackParticle/s that match the electron candidate.
Class providing the definition of the 4-vector interface.
virtual FourMom_t p4() const
The full 4-momentum of the particle.
virtual double pt() const
The transverse momentum ( ) of the particle.
virtual FourMom_t p4() const override final
The full 4-momentum of the particle.
float z() const
Returns the z position.
std::string label(const std::string &format, int i)
std::string PrintResetStopWatch(TStopwatch &watch)
std::string makeContDecorKey(const std::string &cont, const std::string &decor)
Make a StoreGate key from container and decoration name.
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...
double d0significance(const xAOD::TrackParticle *tp, double d0_uncert_beam_spot_2)
Jet_v1 Jet
Definition of the current "jet version".
EventInfo_v1 EventInfo
Definition of the latest event info 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:
JetContainer_v1 JetContainer
Definition of the current "jet container version".
@ 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].
Electron_v1 Electron
Definition of the current "egamma version".