ATLAS Offline Software
Loading...
Searching...
No Matches
TauVertexFinder Class Reference

Associate a vertex (origin) to the tau candidate. More...

#include <TauVertexFinder.h>

Inheritance diagram for TauVertexFinder:
Collaboration diagram for TauVertexFinder:

Public Member Functions

 TauVertexFinder (const std::string &name)
 Constructor and Destructor.
 ASG_TOOL_CLASS2 (TauVertexFinder, TauRecToolBase, ITauToolBase)
 ~TauVertexFinder ()
StatusCode initialize () override
 Tool functions.
StatusCode executeTool (xAOD::TauJet &pTau, const EventContext &ctx) const override
 Execute - called for each tau candidate.
StatusCode executeTool (xAOD::TauJet &pTau, const EventContext &ctx, const xAOD::VertexContainer *vertexContainer) const override
virtual StatusCode executeTool (xAOD::TauJet &, const EventContext &, CaloConstCellContainer &, boost::dynamic_bitset<> &) const override
virtual StatusCode executeTool (xAOD::TauJet &, const EventContext &, xAOD::VertexContainer &) const override
virtual StatusCode executeTool (xAOD::TauJet &, const EventContext &, xAOD::TauTrackContainer &) const override
virtual StatusCode executeTool (xAOD::TauJet &, const EventContext &, xAOD::CaloClusterContainer &, xAOD::PFOContainer &) const override
virtual StatusCode executeTool (xAOD::TauJet &, const EventContext &, xAOD::PFOContainer &, xAOD::PFOContainer &, const xAOD::CaloClusterContainer &) const override
virtual StatusCode executeTool (xAOD::TauJet &, const EventContext &, xAOD::PFOContainer &, xAOD::PFOContainer &) const override
virtual StatusCode executeTool (xAOD::TauJet &, const EventContext &, xAOD::PFOContainer &) const override
virtual StatusCode executeTool (xAOD::TauJet &, const EventContext &, xAOD::ParticleContainer &, xAOD::PFOContainer &) const override
virtual StatusCode eventInitialize () override
 Event initializer - called at the beginning of each event.
virtual StatusCode eventFinalize () override
 Event finalizer - called at the end of each event.
virtual StatusCode finalize () override
 Finalizer.
std::string find_file (const std::string &fname) const
virtual void print () const
 Print the state of the tool.
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 sysInitialize () override
 Perform system initialization for an algorithm.
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
Additional helper functions, not directly mimicking Athena
template<class T>
const T * getProperty (const std::string &name) const
 Get one of the tool's properties.
const std::string & msg_level_name () const __attribute__((deprecated))
 A deprecated function for getting the message level's name.
const std::string & getName (const void *ptr) const
 Get the name of an object that is / should be in the event store.
SG::sgkey_t getKey (const void *ptr) const
 Get the (hashed) key of an object that is in the event store.

Protected Member Functions

bool inTrigger () const
bool inAOD () const
bool inEleRM () const
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.

Protected Attributes

Gaudi::Property< bool > m_in_trigger {this, "inTrigger", false, "Indicate if the tool is running on trigger"}
Gaudi::Property< bool > m_in_AOD {this, "inAOD", false, "Indicate if the tool is running on AOD"}
Gaudi::Property< bool > m_in_EleRM {this, "inEleRM", false, "Indicate if the tool is running on EleRM routine"}
Gaudi::Property< std::string > m_tauRecToolsTag {this, "calibFolder", "tauRecTools/R22_preprod", "CVMFS path to the tau calibration folder"}

Private Types

typedef ServiceHandle< StoreGateSvc > StoreGateSvc_t

Private Member Functions

ElementLink< xAOD::VertexContainer > getPV_TJVA (const xAOD::TauJet &tauJet, const xAOD::VertexContainer &vertices, float &maxJVF) const
std::pair< float, float > getVertexScores (const std::vector< const xAOD::TrackParticle * > &tracks, float vx_z) const
Gaudi::Details::PropertyBase & declareGaudiProperty (Gaudi::Property< T, V, H > &hndl, const SG::VarHandleKeyType &)
 specialization for handling Gaudi::Property<SG::VarHandleKey>

Private Attributes

Gaudi::Property< bool > m_useTJVA {this, "UseTJVA", true}
Gaudi::Property< double > m_dDeltaRMax { this, "DeltaRMax", 0.2, "Maximum DeltaR to consider tracks for TJVA"}
Gaudi::Property< std::string > m_assocTracksName {this, "AssociatedTracks", ""}
ToolHandle< InDet::IInDetTrackSelectionTool > m_TrackSelectionToolForTJVA {this, "InDetTrackSelectionToolForTJVA", ""}
ToolHandle< CP::ITrackVertexAssociationTool > m_trkVertexAssocTool {this, "TVATool", "Tau track-vertex association tool"}
SG::ReadHandleKey< xAOD::VertexContainer > m_vertexInputContainer {this,"Key_vertexInputContainer", "PrimaryVertices", "input vertex container key"}
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

Associate a vertex (origin) to the tau candidate.

The vertex has to be consistent with the origin of tau jet seed. The vertex is determined in the following order: TJVA -> first PV in vertex container -> 0 Attention: all downstream tau variables will be calculated to the vertex set here!

Author
KG Tan Kong..nosp@m.Guan.nosp@m..Tan@.nosp@m.cern.nosp@m..ch
Felix Friedrich Felix.nosp@m..Fri.nosp@m.edric.nosp@m.h@ce.nosp@m.rn.ch

Definition at line 29 of file TauVertexFinder.h.

Member Typedef Documentation

◆ StoreGateSvc_t

typedef ServiceHandle<StoreGateSvc> AthCommonDataStore< AthCommonMsg< AlgTool > >::StoreGateSvc_t
privateinherited

Definition at line 376 of file AthCommonDataStore.h.

Constructor & Destructor Documentation

◆ TauVertexFinder()

TauVertexFinder::TauVertexFinder ( const std::string & name)

Constructor and Destructor.

Definition at line 8 of file TauVertexFinder.cxx.

8 :
9 TauRecToolBase(name) {}
TauRecToolBase(const std::string &name)

◆ ~TauVertexFinder()

TauVertexFinder::~TauVertexFinder ( )

Definition at line 11 of file TauVertexFinder.cxx.

11{}

Member Function Documentation

◆ ASG_TOOL_CLASS2()

TauVertexFinder::ASG_TOOL_CLASS2 ( TauVertexFinder ,
TauRecToolBase ,
ITauToolBase  )

◆ declareGaudiProperty()

Gaudi::Details::PropertyBase & AthCommonDataStore< AthCommonMsg< AlgTool > >::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< AlgTool > >::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< AlgTool > >::detStore ( ) const
inlineinherited

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

Definition at line 95 of file AthCommonDataStore.h.

◆ eventFinalize()

StatusCode TauRecToolBase::eventFinalize ( )
overridevirtualinherited

Event finalizer - called at the end of each event.

Implements ITauToolBase.

Definition at line 123 of file TauRecToolBase.cxx.

123 {
124 return StatusCode::SUCCESS;
125}

◆ eventInitialize()

StatusCode TauRecToolBase::eventInitialize ( )
overridevirtualinherited

Event initializer - called at the beginning of each event.

Implements ITauToolBase.

Definition at line 36 of file TauRecToolBase.cxx.

36 {
37 return StatusCode::SUCCESS;
38}

◆ evtStore()

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

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

Definition at line 85 of file AthCommonDataStore.h.

◆ executeTool() [1/10]

StatusCode TauRecToolBase::executeTool ( xAOD::TauJet & ,
const EventContext & ,
CaloConstCellContainer & ,
boost::dynamic_bitset<> &  ) const
overridevirtual

Reimplemented from TauRecToolBase.

Definition at line 49 of file TauRecToolBase.cxx.

56 {
57 ATH_MSG_ERROR("function not implemented");
58 return StatusCode::FAILURE;
59}
#define ATH_MSG_ERROR(x,...)

◆ executeTool() [2/10]

StatusCode TauRecToolBase::executeTool ( xAOD::TauJet & ,
const EventContext & ,
xAOD::CaloClusterContainer & ,
xAOD::PFOContainer &  ) const
overridevirtual

Reimplemented from TauRecToolBase.

Definition at line 66 of file TauRecToolBase.cxx.

86 {
87 ATH_MSG_ERROR("function not implemented");
88 return StatusCode::FAILURE;
89}

◆ executeTool() [3/10]

StatusCode TauRecToolBase::executeTool ( xAOD::TauJet & ,
const EventContext & ,
xAOD::ParticleContainer & ,
xAOD::PFOContainer &  ) const
overridevirtual

Reimplemented from TauRecToolBase.

Definition at line 86 of file TauRecToolBase.cxx.

118 {
119 ATH_MSG_ERROR("function not implemented");
120 return StatusCode::FAILURE;
121}

◆ executeTool() [4/10]

StatusCode TauRecToolBase::executeTool ( xAOD::TauJet & ,
const EventContext & ,
xAOD::PFOContainer &  ) const
overridevirtual

Reimplemented from TauRecToolBase.

Definition at line 82 of file TauRecToolBase.cxx.

110 {
111 ATH_MSG_ERROR("function not implemented");
112 return StatusCode::FAILURE;
113}

◆ executeTool() [5/10]

StatusCode TauRecToolBase::executeTool ( xAOD::TauJet & ,
const EventContext & ,
xAOD::PFOContainer & ,
xAOD::PFOContainer &  ) const
overridevirtual

Reimplemented from TauRecToolBase.

Definition at line 77 of file TauRecToolBase.cxx.

103 {
104 ATH_MSG_ERROR("function not implemented");
105 return StatusCode::FAILURE;
106}

◆ executeTool() [6/10]

StatusCode TauRecToolBase::executeTool ( xAOD::TauJet & ,
const EventContext & ,
xAOD::PFOContainer & ,
xAOD::PFOContainer & ,
const xAOD::CaloClusterContainer &  ) const
overridevirtual

Reimplemented from TauRecToolBase.

Definition at line 71 of file TauRecToolBase.cxx.

95 {
96 ATH_MSG_ERROR("function not implemented");
97 return StatusCode::FAILURE;
98}

◆ executeTool() [7/10]

StatusCode TauRecToolBase::executeTool ( xAOD::TauJet & ,
const EventContext & ,
xAOD::TauTrackContainer &  ) const
overridevirtual

Reimplemented from TauRecToolBase.

Definition at line 62 of file TauRecToolBase.cxx.

78 {
79 ATH_MSG_ERROR("function not implemented");
80 return StatusCode::FAILURE;
81}

◆ executeTool() [8/10]

StatusCode TauRecToolBase::executeTool ( xAOD::TauJet & ,
const EventContext & ,
xAOD::VertexContainer &  ) const
overridevirtual

Reimplemented from TauRecToolBase.

Definition at line 58 of file TauRecToolBase.cxx.

71 {
72 ATH_MSG_ERROR("function not implemented");
73 return StatusCode::FAILURE;
74}

◆ executeTool() [9/10]

StatusCode TauVertexFinder::executeTool ( xAOD::TauJet & pTau,
const EventContext & ctx ) const
overridevirtual

Execute - called for each tau candidate.

Reimplemented from TauRecToolBase.

Definition at line 27 of file TauVertexFinder.cxx.

29{
30 const xAOD::VertexContainer* vertexContainer = nullptr;
31 return executeTool(pTau, ctx, vertexContainer);
32}
StatusCode executeTool(xAOD::TauJet &pTau, const EventContext &ctx) const override
Execute - called for each tau candidate.
VertexContainer_v1 VertexContainer
Definition of the current "Vertex container version".

◆ executeTool() [10/10]

StatusCode TauVertexFinder::executeTool ( xAOD::TauJet & pTau,
const EventContext & ctx,
const xAOD::VertexContainer * vertexContainer ) const
overridevirtual

Reimplemented from TauRecToolBase.

Definition at line 35 of file TauVertexFinder.cxx.

38{
39 const xAOD::VertexContainer * vxContainer = nullptr;
40
41 if (!m_vertexInputContainer.empty()) {
42 SG::ReadHandle<xAOD::VertexContainer> vertexInHandle( m_vertexInputContainer, ctx );
43 if (!vertexInHandle.isValid()) {
44 ATH_MSG_ERROR ("Could not retrieve HiveDataObj with key " << vertexInHandle.key());
45 return StatusCode::FAILURE;
46 }
47 vxContainer = vertexInHandle.cptr();
48 }
49 else {
50 if (vertexContainer != nullptr) {
51 vxContainer = vertexContainer;
52 }
53 else {
54 ATH_MSG_WARNING ("No Vertex Container in trigger");
55 return StatusCode::FAILURE;
56 }
57 }
58
59 ATH_MSG_VERBOSE("size of VxPrimaryContainer is: " << vxContainer->size() );
60 if (vxContainer->empty()) return StatusCode::SUCCESS;
61
62 // find default PrimaryVertex (needed if TJVA is switched off or fails)
63 const xAOD::Vertex* primaryVertex = nullptr;
64 if (inTrigger()) { // trigger: find default PrimaryVertex (highest sum pt^2)
65 primaryVertex = (*vxContainer)[0];
66 }
67 else { // offline: the first and only primary vertex candidate is picked
68 for (const auto* vertex : *vxContainer) {
69 if (vertex->vertexType() == xAOD::VxType::PriVtx) {
70 primaryVertex = vertex;
71 break;
72 }
73 }
74 }
75
76 // associate vertex to tau
77 if (primaryVertex) pTau.setVertex(vxContainer, primaryVertex);
78
79 //stop here if TJVA is disabled
80 if (!m_useTJVA) return StatusCode::SUCCESS;
81
82 // additional protection in case TJVA is run online - not supported for Run3
83 if ( m_useTJVA && inTrigger()){
84 ATH_MSG_ERROR("TJVA not available for online");
85 return StatusCode::FAILURE;
86 }
87
88 // try to find new PV with TJVA
89 ATH_MSG_DEBUG("TJVA enabled -> try to find new PV for the tau candidate");
90
91 float maxJVF = -100.;
92 ElementLink<xAOD::VertexContainer> newPrimaryVertexLink = getPV_TJVA(pTau, *vxContainer, maxJVF );
93 if (newPrimaryVertexLink.isValid()) {
94 // set new primary vertex
95 // will overwrite default one which was set above
96 pTau.setVertexLink(newPrimaryVertexLink);
97 // save highest JVF value
98 pTau.setDetail(xAOD::TauJetParameters::TauJetVtxFraction,static_cast<float>(maxJVF));
99 ATH_MSG_DEBUG("TJVA vertex found and set");
100 }
101 else {
102 ATH_MSG_WARNING("couldn't find new PV for TJVA");
103 }
104
105 return StatusCode::SUCCESS;
106}
#define ATH_MSG_DEBUG(x,...)
#define ATH_MSG_WARNING(x,...)
#define ATH_MSG_VERBOSE(x,...)
size_type size() const noexcept
Returns the number of elements in the collection.
bool empty() const noexcept
Returns true if the collection is empty.
bool inTrigger() const
ElementLink< xAOD::VertexContainer > getPV_TJVA(const xAOD::TauJet &tauJet, const xAOD::VertexContainer &vertices, float &maxJVF) const
Gaudi::Property< bool > m_useTJVA
SG::ReadHandleKey< xAOD::VertexContainer > m_vertexInputContainer
void setVertexLink(const VertexLink_t &vertexLink)
void setDetail(TauJetParameters::Detail detail, int value)
void setVertex(const xAOD::VertexContainer *cont, const xAOD::Vertex *vertex)
@ TauJetVtxFraction
@Tau Jet Vertex Fraction
Definition TauDefs.h:262
@ PriVtx
Primary vertex.
Vertex_v1 Vertex
Define the latest version of the vertex class.

◆ extraDeps_update_handler()

void AthCommonDataStore< AthCommonMsg< AlgTool > >::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

◆ finalize()

StatusCode TauRecToolBase::finalize ( )
overridevirtualinherited

Finalizer.

Implements ITauToolBase.

Reimplemented in PanTau::PanTauProcessor.

Definition at line 127 of file TauRecToolBase.cxx.

127 {
128 return StatusCode::SUCCESS;
129}

◆ find_file()

std::string TauRecToolBase::find_file ( const std::string & fname) const
inherited

Definition at line 19 of file TauRecToolBase.cxx.

19 {
20 std::string full_path;
21 //offline calib files are in GroupData
22 //online calib files are in release
23 full_path = PathResolverFindCalibFile(m_tauRecToolsTag+"/"+fname);
24 if(full_path.empty()) full_path = PathResolverFindCalibFile(fname);
25 return full_path;
26}
std::string PathResolverFindCalibFile(const std::string &logical_file_name)
Gaudi::Property< std::string > m_tauRecToolsTag

◆ getKey()

SG::sgkey_t asg::AsgTool::getKey ( const void * ptr) const
inherited

Get the (hashed) key of an object that is in the event store.

This is a bit of a special one. StoreGateSvc and xAOD::Event both provide ways for getting the SG::sgkey_t key for an object that is in the store, based on a bare pointer. But they provide different interfaces for doing so.

In order to allow tools to efficiently perform this operation, they can use this helper function.

See also
asg::AsgTool::getName
Parameters
ptrThe bare pointer to the object that the event store should know about
Returns
The hashed key of the object in the store. If not found, an invalid (zero) key.

Definition at line 119 of file AsgTool.cxx.

119 {
120
121#ifdef XAOD_STANDALONE
122 // In case we use @c xAOD::Event, we have a direct function call
123 // for this.
124 return evtStore()->event()->getKey( ptr );
125#else
126 const SG::DataProxy* proxy = evtStore()->proxy( ptr );
127 return ( proxy == nullptr ? 0 : proxy->sgkey() );
128#endif // XAOD_STANDALONE
129 }
ServiceHandle< StoreGateSvc > & evtStore()

◆ getName()

const std::string & asg::AsgTool::getName ( const void * ptr) const
inherited

Get the name of an object that is / should be in the event store.

This is a bit of a special one. StoreGateSvc and xAOD::Event both provide ways for getting the std::string name for an object that is in the store, based on a bare pointer. But they provide different interfaces for doing so.

In order to allow tools to efficiently perform this operation, they can use this helper function.

See also
asg::AsgTool::getKey
Parameters
ptrThe bare pointer to the object that the event store should know about
Returns
The string name of the object in the store. If not found, an empty string.

Definition at line 106 of file AsgTool.cxx.

106 {
107
108#ifdef XAOD_STANDALONE
109 // In case we use @c xAOD::Event, we have a direct function call
110 // for this.
111 return evtStore()->event()->getName( ptr );
112#else
113 const SG::DataProxy* proxy = evtStore()->proxy( ptr );
114 static const std::string dummy = "";
115 return ( proxy == nullptr ? dummy : proxy->name() );
116#endif // XAOD_STANDALONE
117 }

◆ getProperty()

template<class T>
const T * asg::AsgTool::getProperty ( const std::string & name) const
inherited

Get one of the tool's properties.

◆ getPV_TJVA()

ElementLink< xAOD::VertexContainer > TauVertexFinder::getPV_TJVA ( const xAOD::TauJet & tauJet,
const xAOD::VertexContainer & vertices,
float & maxJVF ) const
private

Definition at line 110 of file TauVertexFinder.cxx.

113{
114 const xAOD::Jet* pJetSeed = pTau.jet();
115 std::vector<const xAOD::TrackParticle*> tracksForTJVA;
116
117 // the implementation follows closely the example given in modifyJet(...) in JetVertexFractionTool
118
119 std::vector<const xAOD::TrackParticle*> assocTracks;
120 if (! pJetSeed->getAssociatedObjects(m_assocTracksName, assocTracks)) {
121 ATH_MSG_ERROR("Could not retrieve the AssociatedObjects named \""<< m_assocTracksName <<"\" from jet");
122 return ElementLink<xAOD::VertexContainer>();
123 }
124
125 // Store tracks that meet TJVA track selection criteria and are between deltaR of 0.2 with the jet seed
126 // To be included in the TJVA calculation
127 // Maybe not as efficient as deleting unwanted tracks from assocTrack but quicker and safer for now.
128 float sumTrackAll = 0.0;
129 for ( auto xTrack : assocTracks ) {
130 if ( (xTrack->p4().DeltaR(pJetSeed->p4())<m_dDeltaRMax) && m_TrackSelectionToolForTJVA->accept(*xTrack) ) {
131 if (!inEleRM()) {
132 tracksForTJVA.push_back(xTrack);
133 }
134 else {
135 static const SG::ConstAccessor<ElementLink<xAOD::TrackParticleContainer>> acc_originalTrack("ERMOriginalTrack");
136 if (!acc_originalTrack.isAvailable(*xTrack)) {
137 ATH_MSG_WARNING("Original ERM track link is not available, skipping track");
138 continue;
139 }
140 auto original_id_track_link = acc_originalTrack(*xTrack);
141 if (!original_id_track_link.isValid()) {
142 ATH_MSG_WARNING("Original ERM track link is not valid, skipping track");
143 continue;
144 }
145 tracksForTJVA.push_back(*original_id_track_link);
146 }
147 sumTrackAll += xTrack->pt();
148 }
149 }
150
151 if (this->msgLevel() <= MSG::DEBUG){
152 ATH_MSG_DEBUG("tracksForTJVA # = " << tracksForTJVA.size() << ", sum pT = " << sumTrackAll);
153
154 for (uint i = 0; i < tracksForTJVA.size(); i++){
155 ATH_MSG_DEBUG("tracksForTJVA[" << i << "].pt = " << tracksForTJVA[i]->pt());
156 }
157 }
158
160
161 // Get track vertex map
162 std::vector<const xAOD::Vertex*> vertVec;
163 for (const xAOD::Vertex* vert : vertices) {
164 vertVec.push_back(vert);
165 }
166
167 if (this->msgLevel() <= MSG::DEBUG){
168 ATH_MSG_DEBUG("Vertex # = " << vertVec.size());
169 for (uint i = 0; i < vertVec.size(); i++){
170 ATH_MSG_DEBUG("vertVec[" << i << "].z = " << vertVec[i]->z());
171 }
172 }
173
174 // Tool returns map between vertex and tracks associated to that vertex (based on selection criteria set in config)
175 trktovxmap = m_trkVertexAssocTool->getMatchMap(tracksForTJVA, vertVec);
176
177 if (this->msgLevel() <= MSG::DEBUG){
178 for (const auto& [vtx, trks] : trktovxmap){
179 std::stringstream ss;
180 for (auto ass_trk : trks){
181 for (uint i=0; i < tracksForTJVA.size(); i++){
182 if (ass_trk->p4() == tracksForTJVA[i]->p4()) {
183 ss << i << ", ";
184 break;
185 }
186 }
187 }
188 ATH_MSG_DEBUG("Vtx[" << vtx->index() << "] associated with trks [" << ss.str() << "]");
189 }
190 }
191
192 // Get the highest JVF vertex and store maxJVF for later use
193 // Note: the official JetMomentTools/JetVertexFractionTool doesn't provide any possibility to access the JVF value, but just the vertex.
194 maxJVF=-100.;
195 // Store sum(deltaz(track-vertex)) and jet vertex fraction scores
196 std::vector<float> sumDz;
197 std::vector<float> v_jvf;
198 size_t maxIndex = 0;
199 for (const xAOD::Vertex* vert : vertices) {
200 float jvf = 0.0;
201 std::vector<const xAOD::TrackParticle*> tracks = trktovxmap[vert];
202 // get jet vertex fraction and sumdeltaZ scores
203 std::pair<float, float> spair = getVertexScores(tracks, vert->z());
204 jvf = (sumTrackAll!=0. ? spair.first/sumTrackAll : 0.);
205 v_jvf.push_back(jvf);
206 sumDz.push_back(spair.second);
207
208 if (jvf > maxJVF) {
209 maxJVF = jvf;
210 maxIndex = vert->index();
211 }
212 }
213
214 ATH_MSG_DEBUG("First TJVA");
215 ATH_MSG_DEBUG("TJVA vtx found at z: " << vertices.at(maxIndex)->z() << " i_vtx = " << maxIndex << "jvf = " << maxJVF);
216 ATH_MSG_DEBUG("highest pt vtx found at z (i=0): " << vertices.at(0)->z());
217
218 float min_sumDz = 99999999.;
219 for (const xAOD::Vertex* vert : vertices) {
220 ATH_MSG_DEBUG("i_vtx=" << vert->index() << ", z=" << vert->z() << ", JVF=" << v_jvf[vert->index()] << ", sumDz=" << sumDz[vert->index()]);
221 if ( v_jvf[vert->index()] == maxJVF ){
222 // in case of 0 tracks, first vertex will have sumDz=0, and be selected
223 if (sumDz[vert->index()] < min_sumDz){
224 min_sumDz = sumDz[vert->index()];
225 maxIndex = vert->index();
226 }
227 }
228 }
229
230
231 ATH_MSG_DEBUG("Final TJVA");
232 ATH_MSG_DEBUG("TJVA vtx found at z: " << vertices.at(maxIndex)->z() << " i_vtx = " << maxIndex);
233
234 return ElementLink<xAOD::VertexContainer> (vertices, maxIndex);
235}
unsigned int uint
static Double_t ss
#define z
bool inEleRM() const
std::pair< float, float > getVertexScores(const std::vector< const xAOD::TrackParticle * > &tracks, float vx_z) const
ToolHandle< CP::ITrackVertexAssociationTool > m_trkVertexAssocTool
Gaudi::Property< std::string > m_assocTracksName
Gaudi::Property< double > m_dDeltaRMax
ToolHandle< InDet::IInDetTrackSelectionTool > m_TrackSelectionToolForTJVA
virtual FourMom_t p4() const
The full 4-momentum of the particle.
Definition Jet_v1.cxx:71
std::vector< const T * > getAssociatedObjects(const std::string &name) const
get associated objects as a vector<object> this compact form throws an exception if the object is not...
SG::ConstAccessor< T, ALLOC > ConstAccessor
Definition AuxElement.h:570
Jet_v1 Jet
Definition of the current "jet version".
std::map< const xAOD::Vertex *, xAOD::TrackVertexAssociationList > TrackVertexAssociationMap

◆ getVertexScores()

std::pair< float, float > TauVertexFinder::getVertexScores ( const std::vector< const xAOD::TrackParticle * > & tracks,
float vx_z ) const
private

Definition at line 239 of file TauVertexFinder.cxx.

239 {
240
241 float sumTrackPV = 0.;
242 float sumDeltaZ = 0.;
243 for (const auto* trk : tracks){
244 sumTrackPV += trk->pt();
245 sumDeltaZ += std::abs(trk->z0() - vx_z + trk->vz());
246 }
247
248 return std::make_pair(sumTrackPV, sumDeltaZ);
249}

◆ inAOD()

bool TauRecToolBase::inAOD ( ) const
inlineprotectedinherited

Definition at line 116 of file TauRecToolBase.h.

116{ return m_in_AOD; }
Gaudi::Property< bool > m_in_AOD

◆ inEleRM()

bool TauRecToolBase::inEleRM ( ) const
inlineprotectedinherited

Definition at line 117 of file TauRecToolBase.h.

117{ return m_in_EleRM; }
Gaudi::Property< bool > m_in_EleRM

◆ initialize()

StatusCode TauVertexFinder::initialize ( void )
overridevirtual

Tool functions.

Reimplemented from TauRecToolBase.

Definition at line 14 of file TauVertexFinder.cxx.

14 {
16
17 if( m_useTJVA) {
18 ATH_MSG_INFO("using TJVA to determine tau vertex");
20 ATH_CHECK( m_trkVertexAssocTool.retrieve() );
21 }
22
23 return StatusCode::SUCCESS;
24}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_INFO(x,...)

◆ inputHandles()

virtual std::vector< Gaudi::DataHandle * > AthCommonDataStore< AthCommonMsg< AlgTool > >::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.

◆ inTrigger()

bool TauRecToolBase::inTrigger ( ) const
inlineprotectedinherited

Definition at line 115 of file TauRecToolBase.h.

115{ return m_in_trigger; }
Gaudi::Property< bool > m_in_trigger

◆ msg()

MsgStream & AthCommonMsg< AlgTool >::msg ( ) const
inlineinherited

Definition at line 24 of file AthCommonMsg.h.

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

◆ msg_level_name()

const std::string & asg::AsgTool::msg_level_name ( ) const
inherited

A deprecated function for getting the message level's name.

Instead of using this, weirdly named function, user code should get the string name of the current minimum message level (in case they really need it...), with:

MSG::name( msg().level() )

This function's name doesn't follow the ATLAS coding rules, and as such will be removed in the not too distant future.

Returns
The string name of the current minimum message level that's printed

Definition at line 101 of file AsgTool.cxx.

101 {
102
103 return MSG::name( msg().level() );
104 }
MsgStream & msg() const
const std::string & name(Level lvl)
Convenience function for translating message levels to strings.
Definition MsgLevel.cxx:19

◆ msgLvl()

bool AthCommonMsg< AlgTool >::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< AlgTool > >::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.

◆ print()

◆ 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< AlgTool > >::renounce ( T & h)
inlineprotectedinherited

Definition at line 368 of file AthCommonDataStore.h.

369 {
370 h.renounce();
372 }
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< AlgTool > >::renounceArray ( SG::VarHandleKeyArray & handlesArray)
inlineprotectedinherited

remove all handles from I/O resolution

Definition at line 352 of file AthCommonDataStore.h.

352 {
354 }

◆ sysInitialize()

virtual StatusCode AthCommonDataStore< AthCommonMsg< AlgTool > >::sysInitialize ( )
overridevirtualinherited

Perform system initialization for an algorithm.

We override this to declare all the elements of handle key arrays at the end of initialization. See comments on updateVHKA.

Reimplemented in asg::AsgMetadataTool, AthCheckedComponent< AthAlgTool >, and AthCheckedComponent<::AthAlgTool >.

◆ sysStart()

virtual StatusCode AthCommonDataStore< AthCommonMsg< AlgTool > >::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< AlgTool > >::updateVHKA ( Gaudi::Details::PropertyBase & )
inlineinherited

Definition at line 298 of file AthCommonDataStore.h.

298 {
299 for (auto &a : m_vhka) {
301 for (auto k : keys) {
302 k->setOwner(this);
303 }
304 }
305 }
std::vector< SG::VarHandleKeyArray * > m_vhka

Member Data Documentation

◆ m_assocTracksName

Gaudi::Property<std::string> TauVertexFinder::m_assocTracksName {this, "AssociatedTracks", ""}
private

Definition at line 63 of file TauVertexFinder.h.

63{this, "AssociatedTracks", ""};

◆ m_dDeltaRMax

Gaudi::Property<double> TauVertexFinder::m_dDeltaRMax { this, "DeltaRMax", 0.2, "Maximum DeltaR to consider tracks for TJVA"}
private

Definition at line 62 of file TauVertexFinder.h.

62{ this, "DeltaRMax", 0.2, "Maximum DeltaR to consider tracks for TJVA"};

◆ m_detStore

StoreGateSvc_t AthCommonDataStore< AthCommonMsg< AlgTool > >::m_detStore
privateinherited

Pointer to StoreGate (detector store by default).

Definition at line 381 of file AthCommonDataStore.h.

◆ m_evtStore

StoreGateSvc_t AthCommonDataStore< AthCommonMsg< AlgTool > >::m_evtStore
privateinherited

Pointer to StoreGate (event store by default).

Definition at line 378 of file AthCommonDataStore.h.

◆ m_in_AOD

Gaudi::Property<bool> TauRecToolBase::m_in_AOD {this, "inAOD", false, "Indicate if the tool is running on AOD"}
protectedinherited

Definition at line 105 of file TauRecToolBase.h.

105{this, "inAOD", false, "Indicate if the tool is running on AOD"};

◆ m_in_EleRM

Gaudi::Property<bool> TauRecToolBase::m_in_EleRM {this, "inEleRM", false, "Indicate if the tool is running on EleRM routine"}
protectedinherited

Definition at line 106 of file TauRecToolBase.h.

106{this, "inEleRM", false, "Indicate if the tool is running on EleRM routine"};

◆ m_in_trigger

Gaudi::Property<bool> TauRecToolBase::m_in_trigger {this, "inTrigger", false, "Indicate if the tool is running on trigger"}
protectedinherited

Definition at line 104 of file TauRecToolBase.h.

104{this, "inTrigger", false, "Indicate if the tool is running on trigger"};

◆ m_tauRecToolsTag

Gaudi::Property<std::string> TauRecToolBase::m_tauRecToolsTag {this, "calibFolder", "tauRecTools/R22_preprod", "CVMFS path to the tau calibration folder"}
protectedinherited

Definition at line 107 of file TauRecToolBase.h.

107{this, "calibFolder", "tauRecTools/R22_preprod", "CVMFS path to the tau calibration folder"};

◆ m_TrackSelectionToolForTJVA

ToolHandle< InDet::IInDetTrackSelectionTool > TauVertexFinder::m_TrackSelectionToolForTJVA {this, "InDetTrackSelectionToolForTJVA", ""}
private

Definition at line 65 of file TauVertexFinder.h.

65{this, "InDetTrackSelectionToolForTJVA", ""};

◆ m_trkVertexAssocTool

ToolHandle<CP::ITrackVertexAssociationTool> TauVertexFinder::m_trkVertexAssocTool {this, "TVATool", "Tau track-vertex association tool"}
private

Definition at line 66 of file TauVertexFinder.h.

66{this, "TVATool", "Tau track-vertex association tool"};

◆ m_useTJVA

Gaudi::Property<bool> TauVertexFinder::m_useTJVA {this, "UseTJVA", true}
private

Definition at line 61 of file TauVertexFinder.h.

61{this, "UseTJVA", true};

◆ m_varHandleArraysDeclared

bool AthCommonDataStore< AthCommonMsg< AlgTool > >::m_varHandleArraysDeclared
privateinherited

Definition at line 387 of file AthCommonDataStore.h.

◆ m_vertexInputContainer

SG::ReadHandleKey<xAOD::VertexContainer> TauVertexFinder::m_vertexInputContainer {this,"Key_vertexInputContainer", "PrimaryVertices", "input vertex container key"}
private

Definition at line 68 of file TauVertexFinder.h.

68{this,"Key_vertexInputContainer", "PrimaryVertices", "input vertex container key"};

◆ m_vhka

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

Definition at line 386 of file AthCommonDataStore.h.


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