ATLAS Offline Software
Loading...
Searching...
No Matches
JiveXML::xAODVertexRetriever Class Reference

Retrieves the Vertex objects (PrimaryVertices etc.) More...

#include <xAODVertexRetriever.h>

Inheritance diagram for JiveXML::xAODVertexRetriever:
Collaboration diagram for JiveXML::xAODVertexRetriever:

Public Member Functions

 xAODVertexRetriever (const std::string &type, const std::string &name, const IInterface *parent)
 Standard Constructor.
virtual StatusCode retrieve (ToolHandle< IFormatTool > &FormatTool)
 For each Vertex collections retrieve basic parameters.
virtual StatusCode initialize ()
const DataMap getData (const xAOD::VertexContainer *)
 Puts the variables into a DataMap.
virtual std::string dataTypeName () const
 Return the name of the data type that is generated by this retriever.
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

Static Public Member Functions

static const InterfaceID & interfaceID ()
 Return the interface identifier.

Protected Member Functions

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

const std::string m_typeName = "RVx"
 The data type that is generated by this retriever.
SG::ReadHandleKeyArray< xAOD::VertexContainerm_keys {this,"VertexCollections", {"PrimaryVertices"}, "Name of the Vertex containers that will be written out to the JiveXML file"}
Gaudi::Property< std::string > m_tracksName {this, "TracksName", "InDetTrackParticles_xAOD", "Name of track container"}
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

Retrieves the Vertex objects (PrimaryVertices etc.)

  • Properties
  • VertexCollections
  • TracksName
  • Retrieved Data
    • Usual four-vectors: phi, eta, et etc.
    • Associations for clusters and tracks via ElementLink: key/index scheme

Definition at line 30 of file xAODVertexRetriever.h.

Member Typedef Documentation

◆ StoreGateSvc_t

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

Definition at line 388 of file AthCommonDataStore.h.

Constructor & Destructor Documentation

◆ xAODVertexRetriever()

JiveXML::xAODVertexRetriever::xAODVertexRetriever ( const std::string & type,
const std::string & name,
const IInterface * parent )

Standard Constructor.

This is the standard AthAlgTool constructor.

Parameters
typeAlgTool type name
nameAlgTool instance name
parentAlgTools parent owning this tool

Definition at line 24 of file xAODVertexRetriever.cxx.

24 :
25 AthAlgTool(type,name,parent){}
AthAlgTool()
Default constructor:

Member Function Documentation

◆ dataTypeName()

virtual std::string JiveXML::xAODVertexRetriever::dataTypeName ( ) const
inlinevirtual

Return the name of the data type that is generated by this retriever.

Implements JiveXML::IDataRetriever.

Definition at line 43 of file xAODVertexRetriever.h.

43{ return m_typeName; };
const std::string m_typeName
The data type that is generated by this retriever.

◆ 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.

◆ 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.

◆ 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

◆ getData()

const DataMap JiveXML::xAODVertexRetriever::getData ( const xAOD::VertexContainer * cont)

Puts the variables into a DataMap.

Retrieve basic parameters, mainly four-vectors, for each collection.

Also association with clusters and tracks (ElementLink).

Definition at line 64 of file xAODVertexRetriever.cxx.

64 {
65
66 ATH_MSG_DEBUG("in getData()");
67
68 float chi2val = 0.;
69
71
72 DataVect x;
73 DataVect y;
74 DataVect z;
77 DataVect primVxCand;
79 DataVect numTracks;
80 DataVect tracks;
82
83 //Get size of current container
85
86 x.reserve(x.size()+NVtx);
87 y.reserve(y.size()+NVtx);
88 z.reserve(z.size()+NVtx);
89 chi2.reserve(chi2.size()+NVtx);
90 vertexType.reserve(vertexType.size()+NVtx);
91 primVxCand.reserve(primVxCand.size()+NVtx);
92 covMatrix.reserve(covMatrix.size()+NVtx);
93 numTracks.reserve(numTracks.size()+NVtx);
94 tracks.reserve(tracks.size()+NVtx);
95 sgkey.reserve(sgkey.size()+NVtx);
96
97 int counter = 0;
98
99 //Loop over vertices
101 for ( ; VertexItr != cont->end(); ++VertexItr) {
102
103 ATH_MSG_DEBUG(" Vertex #" << counter++ << " : x = " << (*VertexItr)->x()/cm << ", y = "
104 << (*VertexItr)->y()/cm << ", z[GeV] = " << (*VertexItr)->z()/cm
105 << ", vertexType = " << (*VertexItr)->vertexType()
106 << ", chiSquared = " << (*VertexItr)->chiSquared()
107 << ", numberDoF = " << (*VertexItr)->numberDoF());
108
109 x.emplace_back(DataType((*VertexItr)->x()/cm));
110 y.emplace_back(DataType((*VertexItr)->y()/cm));
111 z.emplace_back(DataType((*VertexItr)->z()/cm));
112
113 vertexType.emplace_back( DataType((*VertexItr)->vertexType()));
114
115 if ((*VertexItr)->vertexType() == 1 ){
116 primVxCand.emplace_back( 1 );
117 }else{
118 primVxCand.emplace_back( 0 );
119 }
120 sgkey.emplace_back (m_tracksName.value());
121
123 covMatrix.emplace_back(DataType("2 -.1 .5 -.01 0.002 .01"));
124
125 //degrees of freedom might be zero - beware
126 if ( (*VertexItr)->numberDoF() != 0 ){
127 chi2val = (*VertexItr)->chiSquared()/(*VertexItr)->numberDoF() ;
128 }else{
129 chi2val = -1.;
130 }
131 chi2.emplace_back(DataType( chi2val ));
132
133 // track-vertex association code in xAOD from Nick Styles, Apr14:
134 // InnerDetector/InDetRecAlgs/InDetPriVxFinder/InDetVxLinksToTrackParticles
135
136 int trkCnt = 0;
137 const std::vector< ElementLink< xAOD::TrackParticleContainer > > tpLinks = (*VertexItr)->trackParticleLinks();
138
139 //iterating over the links
140 unsigned int tp_size = tpLinks.size();
141 numTracks.emplace_back(DataType( tp_size ));
142 if(tp_size){ // links exist
143 for(unsigned int tp = 0; tp<tp_size; ++tp)
144 {
145 ElementLink< xAOD::TrackParticleContainer > tpl = tpLinks.at(tp);
146
147 ATH_MSG_DEBUG(" Vertex #" << counter << " track association index: " << tpl.index()
148 << ", collection : " << tpl.key()
149 << ", Tracks : " << tp << " out of " << tp_size << ", own count: " << trkCnt++);
150
151 if ( tpl.index() < 1000 ){ // sanity check, this can be huge number
152 tracks.emplace_back(DataType( tpl.index() ));
153 }else{
154 tracks.emplace_back(DataType( 0 ));
155 }
156 } //links exist
157 }//end of track particle collection size check
158
159 } // end VertexIterator
160
161 // four-vectors
162 DataMap["x"] = x;
163 DataMap["y"] = y;
164 DataMap["z"] = z;
165 DataMap["chi2"] = chi2;
166 DataMap["vertexType"] = vertexType;
167 DataMap["primVxCand"] = primVxCand;
168 DataMap["covMatrix multiple=\"6\""] = covMatrix;
169 DataMap["numTracks"] = numTracks;
170 DataMap["sgkey"] = sgkey;
171
172 //This is needed once we know numTracks and associations:
173 //If there had been any tracks, add a tag
174 if ((numTracks.size()) != 0){
175 //Calculate average number of tracks per vertex
176 double NTracksPerVertex = tracks.size()*1./numTracks.size();
177 std::string tag = "tracks multiple=\"" +DataType(NTracksPerVertex).toString()+"\"";
178 DataMap[tag] = tracks;
179 }
180
181 ATH_MSG_DEBUG(dataTypeName() << " retrieved with " << x.size() << " entries");
182
183 return DataMap;
184
185 }
#define ATH_MSG_DEBUG(x)
OFFLINE_FRAGMENTS_NAMESPACE::PointerType DataType
#define y
#define x
#define z
DataModel_detail::const_iterator< DataVector > const_iterator
Definition DataVector.h:838
typename DataVectorBase< xAOD::Vertex_v1 >::Base::size_type size_type
Definition DataVector.h:814
const_iterator end() const noexcept
Return a const_iterator pointing past the end of the collection.
const_iterator begin() const noexcept
Return a const_iterator pointing at the beginning of the collection.
size_type size() const noexcept
Returns the number of elements in the collection.
virtual std::string dataTypeName() const
Return the name of the data type that is generated by this retriever.
Gaudi::Property< std::string > m_tracksName
double chi2(TH1 *h0, TH1 *h1)
std::map< std::string, DataVect > DataMap
Definition DataType.h:59
std::vector< DataType > DataVect
Defines a map with a key and a vector of DataType objects e.g.
Definition DataType.h:58
sgkey(tool)
Definition common.py:1027

◆ initialize()

StatusCode JiveXML::xAODVertexRetriever::initialize ( )
virtual

Definition at line 28 of file xAODVertexRetriever.cxx.

28 {
29 ATH_CHECK(m_keys.initialize());
30 return StatusCode::SUCCESS;
31 }
#define ATH_CHECK
Evaluate an expression and check for errors.
SG::ReadHandleKeyArray< xAOD::VertexContainer > m_keys

◆ 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.

◆ interfaceID()

const InterfaceID & JiveXML::IDataRetriever::interfaceID ( )
inlinestaticinherited

Return the interface identifier.

Definition at line 40 of file IDataRetriever.h.

40{ return IID_IDataRetriever; }
static const InterfaceID IID_IDataRetriever("JiveXML::IDataRetriever", 3, 0)

◆ msg()

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

Definition at line 24 of file AthCommonMsg.h.

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

◆ 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.

◆ 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 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< AlgTool > >::renounceArray ( SG::VarHandleKeyArray & handlesArray)
inlineprotectedinherited

remove all handles from I/O resolution

Definition at line 364 of file AthCommonDataStore.h.

364 {
366 }

◆ retrieve()

StatusCode JiveXML::xAODVertexRetriever::retrieve ( ToolHandle< IFormatTool > & FormatTool)
virtual

For each Vertex collections retrieve basic parameters.

Parameters
FormatToolthe tool that will create formated output from the DataMap

Implements JiveXML::IDataRetriever.

Definition at line 38 of file xAODVertexRetriever.cxx.

38 {
39
40 ATH_MSG_DEBUG("In retrieve()");
41
42 // Loop through the keys and retrieve the corresponding data
43 for (const auto& key : m_keys) {
44 SG::ReadHandle<xAOD::VertexContainer> cont(key);
45 if (cont.isValid()) {
46 DataMap data = getData(&(*cont));
47 if (FormatTool->AddToEvent(dataTypeName(), key.key() + "_xAOD", &data).isFailure()) {
48 ATH_MSG_WARNING("Failed to add collection " << key.key());
49 } else {
50 ATH_MSG_DEBUG(" (" << key.key() << ") retrieved");
51 }
52 } else {
53 ATH_MSG_WARNING("Collection " << key.key() << " not found in SG");
54 }
55 }
56
57 return StatusCode::SUCCESS;
58 }
#define ATH_MSG_WARNING(x)
char data[hepevt_bytes_allocation_ATLAS]
Definition HepEvt.cxx:11
const DataMap getData(const xAOD::VertexContainer *)
Puts the variables into a DataMap.

◆ 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 >, AthCheckedComponent<::AthAlgTool >, and DerivationFramework::CfAthAlgTool.

◆ 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 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 }
std::vector< SG::VarHandleKeyArray * > m_vhka

Member Data Documentation

◆ m_detStore

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

Pointer to StoreGate (detector store by default)

Definition at line 393 of file AthCommonDataStore.h.

◆ m_evtStore

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

Pointer to StoreGate (event store by default)

Definition at line 390 of file AthCommonDataStore.h.

◆ m_keys

SG::ReadHandleKeyArray<xAOD::VertexContainer> JiveXML::xAODVertexRetriever::m_keys {this,"VertexCollections", {"PrimaryVertices"}, "Name of the Vertex containers that will be written out to the JiveXML file"}
private

Definition at line 50 of file xAODVertexRetriever.h.

50{this,"VertexCollections", {"PrimaryVertices"}, "Name of the Vertex containers that will be written out to the JiveXML file"};

◆ m_tracksName

Gaudi::Property<std::string> JiveXML::xAODVertexRetriever::m_tracksName {this, "TracksName", "InDetTrackParticles_xAOD", "Name of track container"}
private

Definition at line 51 of file xAODVertexRetriever.h.

51{this, "TracksName", "InDetTrackParticles_xAOD", "Name of track container"};

◆ m_typeName

const std::string JiveXML::xAODVertexRetriever::m_typeName = "RVx"
private

The data type that is generated by this retriever.

Definition at line 48 of file xAODVertexRetriever.h.

◆ m_varHandleArraysDeclared

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

Definition at line 399 of file AthCommonDataStore.h.

◆ m_vhka

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

Definition at line 398 of file AthCommonDataStore.h.


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