ATLAS Offline Software
Loading...
Searching...
No Matches
OfflineObjectDecorHelper.h
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3*/
4
5#ifndef INDETTRACKPERFMON_OFFLINEOBJECTDECORHELPER_H
6#define INDETTRACKPERFMON_OFFLINEOBJECTDECORHELPER_H
7
15
18#include "xAODTracking/Vertex.h"
25
27
28
30#include <string>
31
32
33namespace IDTPM {
34
36 template < typename container_t >
38 const std::string& decoName ) {
39 using elementLink_t = ElementLink< container_t >;
40 const SG::ConstAccessor< elementLink_t > acc( decoName );
41 return ( not acc.isAvailable( track ) );
42 }
43
45 template < typename container_t >
46 typename container_t::const_value_type getLinkedObject(
47 const xAOD::TrackParticle& track,
48 const std::string& decoName )
49 {
50 using elementLink_t = ElementLink< container_t >;
51
52 if( isUnlinkedObject< container_t >( track, decoName ) ) return nullptr;
53
54 const SG::ConstAccessor< elementLink_t > acc( decoName );
55 elementLink_t eleLink = acc( track );
56
57 if( not eleLink.isValid() ) return nullptr;
58
59 return *eleLink;
60 }
61
65 const std::string& quality="All" );
66
68 const xAOD::Muon* getLinkedMuon( const xAOD::TrackParticle& track,
69 const std::string& quality="All" );
70
73 const int requiredNtracks,
74 const std::string& type="RNN",
75 const std::string& quality="" );
76
78 const xAOD::Jet* getLinkedJet( const xAOD::TrackParticle& track,
79 const std::string& quality="DRtruthJet" );
80
81 float getD0TrackInJet( const xAOD::TrackParticle& track,
82 const std::string& quality="DRtruthJet" );
83
85 const std::string& ="" ) { return nullptr; }; // dummy - to avoid compilation errors
86
88 const std::string& ="" ) { return -999.; }; // dummy - to avoid compilation errors
89
91 bool isUnlinkedTruth( const xAOD::TrackParticle& track );
92 inline bool isUnlinkedTruth( const xAOD::TruthParticle& ) { return false; }; // dummy - to avoid compilation errors
93
94 float getTruthMatchProb( const xAOD::TrackParticle& track );
95 inline float getTruthMatchProb( const xAOD::TruthParticle& ) { return -1.; }; // dummy - to avoid compilation errors
96
98 const float truthProbCut=0. );
100 const xAOD::TruthParticle&, const float ) { return nullptr; }; // dummy - to avoid compilation errors
101
102 template< typename PARTICLE >
103 unsigned int getEtaBin( const PARTICLE& p,
104 const std::vector< float >& etaBins );
105
106 template< typename PARTICLE >
107 inline bool nHitsSelVec( const PARTICLE& p,
108 const std::vector< unsigned int >& minHits,
109 const std::vector< float >& etaBins) {return nSiHits(p) >= minHits.at( getEtaBin( p, etaBins ) );};
110
112 const std::vector< unsigned int >& minHits,
113 const std::vector< float >& etaBins );
115 const std::vector< unsigned int >& minHits,
116 const std::vector< float >& etaBins );
117
118 inline bool minPtSelVec( const xAOD::TrackParticle& track,
119 const std::vector< float >& minPt,
120 const std::vector< float >& etaBins) { return pT(track) >= minPt.at( getEtaBin( track, etaBins ) );};
121 inline bool minPtSelVec( const xAOD::TruthParticle& ,
122 const std::vector< float >& ,
123 const std::vector< float >& ) { return false; }; // dummy - to avoid compilation errors;
124
125 inline bool maxD0SelVec( const xAOD::TrackParticle& track,
126 const std::vector< float >& maxD0,
127 const std::vector< float >& etaBins) { return std::fabs( d0(track) ) <= maxD0.at( getEtaBin( track, etaBins ) );};
128 inline bool maxD0SelVec( const xAOD::TruthParticle& ,
129 const std::vector< float >& ,
130 const std::vector< float >& ) { return false; }; // dummy - to avoid compilation errors;
131
132 inline bool maxZ0SelVec( const xAOD::TrackParticle& track,
133 const std::vector< float >& maxZ0,
134 const std::vector< float >& etaBins) { return std::fabs( z0(track) ) <= maxZ0.at( getEtaBin( track, etaBins ) );};
135 inline bool maxZ0SelVec( const xAOD::TruthParticle& ,
136 const std::vector< float >& ,
137 const std::vector< float >& ) { return false; }; // dummy - to avoid compilation errors;
138
142 std::vector< const xAOD::TrackParticle* >& vtxTracks,
143 std::vector< float >& vtxTrackWeights,
144 const std::vector< const xAOD::TrackParticle* >& selTracks = {},
145 bool useSelected = false );
147 std::vector< const xAOD::TruthParticle* >&,
148 std::vector< float >&,
149 const std::vector< const xAOD::TruthParticle* >& /*selTracks*/ = {},
150 bool /*useSelected*/ = false ) { return true; } // TODO: Change to get (outgoing?) truth particles
151
152} // namespace IDTPM
153
154#endif // > ! INDETTRACKPERFMON_OFFLINEOBJECTDECORHELPER_H
Utility methods to access track/truth particles parmeters in a consitent way in this package.
Helper class to provide constant type-safe access to aux data.
Athena include(s).
float getD0TrackInJet(const xAOD::TrackParticle &track, const std::string &quality)
recompute d0 projecting in jet direction w.r.t. origin
template bool nHitsSelVec< xAOD::TruthParticle >(const xAOD::TruthParticle &truth, const std::vector< unsigned int > &minHits, const std::vector< float > &etaBins)
unsigned int getEtaBin(const PARTICLE &p, const std::vector< float > &etaBins)
bool maxZ0SelVec(const xAOD::TrackParticle &track, const std::vector< float > &maxZ0, const std::vector< float > &etaBins)
float pT(const U &p)
Accessor utility function for getting the value of pT.
bool minPtSelVec(const xAOD::TrackParticle &track, const std::vector< float > &minPt, const std::vector< float > &etaBins)
const xAOD::Jet * getLinkedJet(const xAOD::TrackParticle &track, const std::string &quality)
getLinkedJet
template bool nHitsSelVec< xAOD::TrackParticle >(const xAOD::TrackParticle &track, const std::vector< unsigned int > &minHits, const std::vector< float > &etaBins)
const xAOD::Muon * getLinkedMuon(const xAOD::TrackParticle &track, const std::string &quality)
getLinkedMuon
bool nHitsSelVec(const PARTICLE &p, const std::vector< unsigned int > &minHits, const std::vector< float > &etaBins)
float getTruthMatchProb(const xAOD::TrackParticle &track)
getTruthMatchProb
container_t::const_value_type getLinkedObject(const xAOD::TrackParticle &track, const std::string &decoName)
Templated method to retrieve object linked to a track.
float z0(const U &p)
bool getVertexTracksAndWeights(const xAOD::Vertex &vtx, std::vector< const xAOD::TrackParticle * > &vtxTracks, std::vector< float > &vtxTrackWeights, const std::vector< const xAOD::TrackParticle * > &selTracks, bool useSelected)
getVertexTracksAndWeights
const xAOD::Electron * getLinkedElectron(const xAOD::TrackParticle &track, const std::string &quality)
getLinkedElectron
const xAOD::TruthParticle * getLinkedTruth(const xAOD::TrackParticle &track, const float truthProbCut)
getLinkedTruth
bool isUnlinkedTruth(const xAOD::TrackParticle &track)
isUnlinkedTruth
float d0(const U &p)
const xAOD::TauJet * getLinkedTau(const xAOD::TrackParticle &track, const int requiredNtracks, const std::string &type, const std::string &quality)
getLinkedTau
float nSiHits(const U &p)
bool maxD0SelVec(const xAOD::TrackParticle &track, const std::vector< float > &maxD0, const std::vector< float > &etaBins)
bool isUnlinkedObject(const xAOD::TrackParticle &track, const std::string &decoName)
Templated method to check if a track is not linked to an object.
Jet_v1 Jet
Definition of the current "jet version".
TruthVertex_v1 TruthVertex
Typedef to implementation.
Definition TruthVertex.h:15
TrackParticle_v1 TrackParticle
Reference the current persistent version:
Vertex_v1 Vertex
Define the latest version of the vertex class.
TauJet_v3 TauJet
Definition of the current "tau version".
TruthParticle_v1 TruthParticle
Typedef to implementation.
Muon_v1 Muon
Reference the current persistent version:
Electron_v1 Electron
Definition of the current "egamma version".