ATLAS Offline Software
Loading...
Searching...
No Matches
VertexRoiSelectionTool.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3*/
4
9
12
14#include "GaudiKernel/ISvcLocator.h"
15#include "GaudiKernel/Service.h"
16
20#include "TrackParametersHelper.h" // includes VertexParametersHelper.h
21
23#include <algorithm> // for std::find
24
25
30 const std::string& name ) :
31 asg::AsgTool( name ) { }
32
33
38
40
41 ATH_MSG_DEBUG( "Initializing " << name() );
42
44 not m_triggerVertexContainerName.key().empty() ) );
45
46 ATH_CHECK( m_trigDecTool.retrieve() );
47
48 return StatusCode::SUCCESS;
49}
50
51
55template< class V >
57 const V& v, const TrigRoiDescriptor* r ) const
58{
59 if( r==0 ) {
60 ATH_MSG_ERROR( "Called with null RoiDescriptor" );
61 return true;
62 }
63
64 if( r->composite() ) {
65 for( unsigned i=r->size() ; i-- ; )
66 if( accept( v, (const TrigRoiDescriptor*)r->at(i) ) ) {
67 return true;
68 }
69
70 } else {
71 if( r->isFullscan() ) return true;
72
73 bool contained_zed = posZ(v) >= r->zedMinus() and
74 posZ(v) <= r->zedPlus();
75
76 if( contained_zed ) return true;
77 }
78
79 return false;
80}
81
84 const xAOD::Vertex& v, const TrigRoiDescriptor* r ) const;
85
88 const xAOD::TruthVertex& v, const TrigRoiDescriptor* r ) const;
89
90
94template< class V >
96 const std::vector< const V* >& vvec,
97 const TrigRoiDescriptor* r ) const {
98
99 std::vector< const V* > selectedVertices;
100
101 for( const V* thisVertex : vvec ) {
102 if( accept<V>( *thisVertex, r ) ) {
103 selectedVertices.push_back( thisVertex );
104 }
105 }
106
107 return selectedVertices;
108}
109
111template std::vector< const xAOD::Vertex* >
112IDTPM:: VertexRoiSelectionTool::getVertices< xAOD::Vertex >(
113 const std::vector< const xAOD::Vertex* >& vvec,
114 const TrigRoiDescriptor* r ) const;
115
117template std::vector< const xAOD::TruthVertex* >
119 const std::vector< const xAOD::TruthVertex* >& vvec,
120 const TrigRoiDescriptor* r ) const;
121
122
126std::vector< const xAOD::Vertex* >
128 const std::vector< const xAOD::Vertex* >& vvec,
129 const ElementLink< TrigRoiDescriptorCollection >& roiLink ) const
130{
133
137 m_trigDecTool->associateToEventView( handle, roiLink );
138
140 std::vector< const xAOD::Vertex* > selectedTrigVertices;
142 for( vtxItr = trigVtxItrPair.first ; vtxItr != trigVtxItrPair.second ; ++vtxItr ) {
145 if( std::find( vvec.begin(), vvec.end(), *vtxItr ) == vvec.end() ) {
146 ATH_MSG_DEBUG( "Trigger vertex does not pass quality selection. Skipping." );
147 continue;
148 }
149 selectedTrigVertices.push_back( *vtxItr );
150 }
151
152 return selectedTrigVertices;
153}
154
155
160 TrackAnalysisCollections& trkAnaColls,
162
163 ATH_MSG_DEBUG( "Selecting vertices in RoI" );
164
166 ISvcLocator* svcLoc = Gaudi::svcLocator();
167 SmartIF< ITrackAnalysisDefinitionSvc > trkAnaDefSvc(
168 svcLoc->service( "TrkAnaDefSvc"+trkAnaColls.anaTag() ) );
169 ATH_CHECK( trkAnaDefSvc.isValid() );
170
171 const TrigRoiDescriptor* const* roi = roiLink.cptr();
172
175 if( not m_triggerVertexContainerName.key().empty() ) {
176 ATH_CHECK( trkAnaColls.fillTrigVertexVec(
179 roiLink ),
181 }
182
184 if( trkAnaDefSvc->useOffline() ) {
185 ATH_CHECK( trkAnaColls.fillOfflVertexVec(
188 *roi ),
190 }
191
193 if( trkAnaDefSvc->useTruth() ) {
194 ATH_CHECK( trkAnaColls.fillTruthVertexVec(
197 *roi ),
199 }
200
202 ATH_MSG_DEBUG( "Vertices after RoI selection: " <<
204
205 return StatusCode::SUCCESS;
206}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_ERROR(x)
#define ATH_MSG_DEBUG(x)
Class to hold for each event collections needed in the TrkAnalsis.
Utility methods to access track/truth particles parmeters in a consitent way in this package.
Tool to select reco and truth vertices in given RoI.
DataModel_detail::const_iterator< DataVector > const_iterator
Definition DataVector.h:838
const std::vector< const xAOD::Vertex * > & offlVertexVec(Stage stage=FULL)
StatusCode fillOfflVertexVec(const std::vector< const xAOD::Vertex * > &vec, Stage stage=FULL)
Offline tracks.
const std::string & anaTag()
— Getter methods —
const std::vector< const xAOD::TruthVertex * > & truthVertexVec(Stage stage=FULL)
get truth/offline/trigger vertex vector (TEST or REFERENCE)
StatusCode fillTruthVertexVec(const std::vector< const xAOD::TruthVertex * > &vec, Stage stage=FULL)
fill truth/offline/trigger vertex vector (TEST or REFERENCE)
StatusCode fillTrigVertexVec(const std::vector< const xAOD::Vertex * > &vec, Stage stage=FULL)
Trigger tracks.
const std::vector< const xAOD::Vertex * > & trigVertexVec(Stage stage=FULL)
std::string printVertexInfo(Stage stage=FULL) const
print information about vertices in the collection(s)
virtual StatusCode initialize() override
Initialize.
StatusCode selectVerticesInRoI(TrackAnalysisCollections &trkAnaColls, const ElementLink< TrigRoiDescriptorCollection > &roiLink)
Main Vertex selection method.
std::vector< const V * > getVertices(const std::vector< const V * > &vvec, const TrigRoiDescriptor *r) const
vertex getter function (for offline tracks or truth particles)
SG::ReadHandleKey< xAOD::VertexContainer > m_triggerVertexContainerName
Trigger vertex container's name.
bool accept(const V &v, const TrigRoiDescriptor *r) const
geometric RoI filters - for non-trigger veritices (e.g. offline, truth, etc.)
PublicToolHandle< Trig::TrigDecisionTool > m_trigDecTool
TrigDecTool.
std::vector< const xAOD::Vertex * > getTrigVertices(const std::vector< const xAOD::Vertex * > &vvec, const ElementLink< TrigRoiDescriptorCollection > &roiLink) const
TrigDecTool- and EventView-based getter function for trigger vertices.
VertexRoiSelectionTool(const std::string &name)
Constructor.
nope - should be used for standalone also, perhaps need to protect the class def bits ifndef XAOD_ANA...
AsgTool(const std::string &name)
Constructor specifying the tool instance's name.
Definition AsgTool.cxx:58
virtual StatusCode initialize()
Dummy implementation of the initialisation function.
Definition AsgTool.h:133
int r
Definition globals.cxx:22
float posZ(const V &v)
Accessor utility function for getting the value of vertex position z.
TruthVertex_v1 TruthVertex
Typedef to implementation.
Definition TruthVertex.h:15
Vertex_v1 Vertex
Define the latest version of the vertex class.