The Gaudi Framework  master (ff829712)
Loading...
Searching...
No Matches
MyTrack.h
Go to the documentation of this file.
1/***********************************************************************************\
2* (c) Copyright 1998-2024 CERN for the benefit of the LHCb and ATLAS collaborations *
3* *
4* This software is distributed under the terms of the Apache version 2 licence, *
5* copied verbatim in the file "LICENSE". *
6* *
7* In applying this licence, CERN does not waive the privileges and immunities *
8* granted to it by virtue of its status as an Intergovernmental Organization *
9* or submit itself to any jurisdiction. *
10\***********************************************************************************/
11#pragma once
12
19
20namespace Gaudi {
21 namespace TestSuite {
22
23 // Forward declarations
24 class MyVertex;
25 template <class T>
27
28 // CLID definition
29 static const CLID& CLID_MyTrack = 1355;
30
38 // class MyTrack : public ContainedObject {
40#ifdef __PLAIN_GAUDI
41 : public ContainedObject
42#else
43 : public KeyedObject<int>
44#endif
45 {
46 friend class GaudiObjectHandler<MyTrack>;
47
48 public:
49 // ======================================================================
51 typedef std::vector<MyTrack*> Vector;
53 typedef std::vector<const MyTrack*> ConstVector;
56#ifdef __PLAIN_GAUDI
59#else
62#endif
63 // ======================================================================
64 protected:
66 float m_px, m_py, m_pz;
73
74 public:
76 MyTrack();
78 MyTrack( float x, float y, float z );
79 MyTrack( const MyTrack& t );
81 ~MyTrack() override;
83 const CLID& clID() const override { return classID(); }
84 static const CLID& classID() { return CLID_MyTrack; }
86 float px() const { return m_px; }
88 float py() const { return m_py; }
90 float pz() const { return m_pz; }
92 void setPx( float px ) { m_px = px; }
94 void setPy( float py ) { m_py = py; }
96 void setPz( float pz ) { m_pz = pz; }
97
99 const Event* event() const { return m_event; }
101 void setEvent( Event* evt ) { m_event = evt; }
103 const MyVertex* originVertex() const;
104
106 void setOriginVertex( MyVertex* origin );
107
109 const SmartRefVector<MyVertex>& decayVertices() const;
110
112 void addDecayVertex( MyVertex* vtx );
113
115 void removeDecayVertex( MyVertex* vtx );
116
118 StreamBuffer& serialize( StreamBuffer& s ) const override;
120 StreamBuffer& serialize( StreamBuffer& s ) override;
121 };
122
123// Definition of all container types of MCParticle
124#ifdef __PLAIN_GAUDI
126#else
128#endif
129 } // namespace TestSuite
130} // namespace Gaudi
131
132#include "MyVertex.h"
133
134namespace Gaudi {
135 namespace TestSuite {
136
138 inline const MyVertex* MyTrack::originVertex() const { return m_originVertex; }
139
141 inline void MyTrack::setOriginVertex( MyVertex* origin ) { m_originVertex = origin; }
142
145
147 inline void MyTrack::addDecayVertex( MyVertex* vtx ) { m_decayVertices.push_back( SmartRef<MyVertex>( vtx ) ); }
148
151 SmartRefVector<MyVertex>::iterator i;
152 for ( i = m_decayVertices.begin(); i != m_decayVertices.end(); ++i ) {
153 if ( i->target() == vtx ) {
154 m_decayVertices.erase( i );
155 return;
156 }
157 }
158 }
159
162#ifdef __PLAIN_GAUDI
164#else
166#endif
167 return s << m_event( this ) << m_originVertex( this ) << m_decayVertices( this ) << m_px << m_py << m_pz;
168 }
169
172#ifdef __PLAIN_GAUDI
174#else
176#endif
177 return s >> m_event( this ) >> m_originVertex( this ) >> m_decayVertices( this ) >> m_px >> m_py >> m_pz;
178 }
179 } // namespace TestSuite
180} // namespace Gaudi
unsigned int CLID
Class ID definition.
Definition ClassID.h:16
#define GAUDI_API
Definition Kernel.h:49
ContainedObject()=default
Constructors.
virtual StreamBuffer & serialize(StreamBuffer &s) const
Serialize the object for writing.
Essential information of the event used in examples It can be identified by "/Event".
Definition Event.h:37
SharedObjectsContainer< MyTrack > Selection
the type of selection
Definition MyTrack.h:55
std::vector< MyTrack * > Vector
the type of plain vector
Definition MyTrack.h:51
const CLID & clID() const override
Retrieve pointer to class definition structure.
Definition MyTrack.h:83
SmartRefVector< MyVertex > m_decayVertices
Links to all decay vertices.
Definition MyTrack.h:72
SmartRef< Event > m_event
Link to Top level event.
Definition MyTrack.h:68
void removeDecayVertex(MyVertex *vtx)
Remove decay vertex.
Definition MyTrack.h:150
float m_px
The track momentum.
Definition MyTrack.h:66
KeyedContainer< MyTrack, Containers::HashMap > Container
the actual type of container in TES
Definition MyTrack.h:61
void addDecayVertex(MyVertex *vtx)
Add decay vertex.
Definition MyTrack.h:147
void setOriginVertex(MyVertex *origin)
Set origin vertex.
Definition MyTrack.h:141
float px() const
Accessors: Retrieve x-component of the track momentum.
Definition MyTrack.h:86
MyTrack()
Standard constructor.
Definition MyTrack.cpp:27
const Event * event() const
Access to the source track object (constant case)
Definition MyTrack.h:99
static const CLID & classID()
Definition MyTrack.h:84
void setPx(float px)
Accessors: Update x-component of the track momentum.
Definition MyTrack.h:92
float py() const
Accessors: Retrieve y-component of the track momentum.
Definition MyTrack.h:88
void setPy(float py)
Accessors: Update y-component of the track momentum.
Definition MyTrack.h:94
const SmartRefVector< MyVertex > & decayVertices() const
Access to decay vertices.
Definition MyTrack.h:144
SmartRef< MyVertex > m_originVertex
Link to origin vertex.
Definition MyTrack.h:70
StreamBuffer & serialize(StreamBuffer &s) const override
Serialize the object for writing.
Definition MyTrack.h:161
void setEvent(Event *evt)
Access to event object.
Definition MyTrack.h:101
float pz() const
Accessors: Retrieve z-component of the track momentum.
Definition MyTrack.h:90
const MyVertex * originVertex() const
Origin vertex.
Definition MyTrack.h:138
void setPz(float pz)
Accessors: Update z-component of the track momentum.
Definition MyTrack.h:96
std::vector< const MyTrack * > ConstVector
the type of vector of const-pointers
Definition MyTrack.h:53
Simple class that represents a vertex for testing purposes.
Definition MyVertex.h:33
template class KeyedContainer, KeyedContainer.h
KeyedObject()=default
StreamBuffer & serialize(StreamBuffer &s) const override
Serialize the object for writing.
ObjectVector is one of the basic Gaudi container classes capable of being registered in Data Stores.
Very simple class to represent the container of objects which are not owned by this container.
Kernel objects: SmartRef.
Definition SmartRef.h:64
Kernel objects: SmartRefVector.
The stream buffer is a small object collecting object data.
KeyedContainer< MyTrack > MyTrackVector
Definition MyTrack.h:127
This file provides a Grammar for the type Gaudi::Accumulators::Axis It allows to use that type from p...
Definition __init__.py:1