The Gaudi Framework  master (37c0b60a)
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 // ============================================================================
12 #ifndef GAUDIPOOLDB_TEST_MYTRACK_H
13 #define GAUDIPOOLDB_TEST_MYTRACK_H
14 // ============================================================================
15 // Include files
16 // ============================================================================
17 // GaudiKernel
18 // ============================================================================
24 // =============================================================================
25 #include <GaudiExamples/Event.h>
26 // ============================================================================
27 
28 namespace Gaudi {
29  namespace Examples {
30 
31  // Forward declarations
32  class MyVertex;
33  template <class T>
35 
36  // CLID definition
37  static const CLID& CLID_MyTrack = 355;
38 
46  // class MyTrack : public ContainedObject {
48 #ifdef __PLAIN_GAUDI
49  : public ContainedObject
50 #else
51  : public KeyedObject<int>
52 #endif
53  {
54  friend class GaudiObjectHandler<MyTrack>;
55 
56  public:
57  // ======================================================================
64 #ifdef __PLAIN_GAUDI
67 #else
70 #endif
71  // ======================================================================
72  protected:
74  float m_px, m_py, m_pz;
81 
82  public:
84  MyTrack();
86  MyTrack( float x, float y, float z );
87  MyTrack( const MyTrack& t );
89  ~MyTrack() override;
91  const CLID& clID() const override { return classID(); }
92  static const CLID& classID() { return CLID_MyTrack; }
94  float px() const { return m_px; }
96  float py() const { return m_py; }
98  float pz() const { return m_pz; }
100  void setPx( float px ) { m_px = px; }
102  void setPy( float py ) { m_py = py; }
104  void setPz( float pz ) { m_pz = pz; }
105 
107  const Event* event() const { return m_event; }
109  void setEvent( Event* evt ) { m_event = evt; }
111  const MyVertex* originVertex() const;
112 
114  void setOriginVertex( MyVertex* origin );
115 
117  const SmartRefVector<MyVertex>& decayVertices() const;
118 
120  void addDecayVertex( MyVertex* vtx );
121 
123  void removeDecayVertex( MyVertex* vtx );
124 
126  StreamBuffer& serialize( StreamBuffer& s ) const override;
128  StreamBuffer& serialize( StreamBuffer& s ) override;
129  };
130 
131 // Definition of all container types of MCParticle
132 #ifdef __PLAIN_GAUDI
134 #else
136 #endif
137  } // namespace Examples
138 } // namespace Gaudi
139 
140 #include "MyVertex.h"
141 
142 namespace Gaudi {
143  namespace Examples {
144 
146  inline const MyVertex* MyTrack::originVertex() const { return m_originVertex; }
147 
149  inline void MyTrack::setOriginVertex( MyVertex* origin ) { m_originVertex = origin; }
150 
153 
155  inline void MyTrack::addDecayVertex( MyVertex* vtx ) { m_decayVertices.push_back( SmartRef<MyVertex>( vtx ) ); }
156 
158  inline void MyTrack::removeDecayVertex( MyVertex* vtx ) {
160  for ( i = m_decayVertices.begin(); i != m_decayVertices.end(); ++i ) {
161  if ( i->target() == vtx ) {
162  m_decayVertices.erase( i );
163  return;
164  }
165  }
166  }
167 
170 #ifdef __PLAIN_GAUDI
172 #else
174 #endif
175  return s << m_event( this ) << m_originVertex( this ) << m_decayVertices( this ) << m_px << m_py << m_pz;
176  }
177 
180 #ifdef __PLAIN_GAUDI
182 #else
184 #endif
185  return s >> m_event( this ) >> m_originVertex( this ) >> m_decayVertices( this ) >> m_px >> m_py >> m_pz;
186  }
187  } // namespace Examples
188 } // namespace Gaudi
189 
190 #endif // GAUDIPOOLDB_TEST_MYTRACK_H
IOTest.evt
evt
Definition: IOTest.py:107
KeyedObject::serialize
StreamBuffer & serialize(StreamBuffer &s) const override
Serialize the object for writing.
Definition: KeyedObject.h:143
Gaudi::Examples::MyTrack::originVertex
const MyVertex * originVertex() const
Origin vertex.
Definition: MyTrack.h:146
Gaudi::Examples::MyTrack::m_px
float m_px
The track momentum.
Definition: MyTrack.h:74
ObjectVector
Definition: ContainedObject.h:22
SmartRefVector
Kernel objects: SmartRefVector.
Definition: SmartRefVector.h:79
Gaudi::Examples::MyTrack::event
const Event * event() const
Access to the source track object (constant case)
Definition: MyTrack.h:107
Gaudi::Examples::MyTrackVector
KeyedContainer< MyTrack > MyTrackVector
Definition: MyTrack.h:135
Gaudi::Examples::MyTrack::m_py
float m_py
Definition: MyTrack.h:74
gaudirun.s
string s
Definition: gaudirun.py:346
std::vector
STL class.
Gaudi::Examples::MyTrack::m_decayVertices
SmartRefVector< MyVertex > m_decayVertices
Links to all decay vertices.
Definition: MyTrack.h:80
Gaudi::Examples::MyTrack::decayVertices
const SmartRefVector< MyVertex > & decayVertices() const
Access to decay vertices.
Definition: MyTrack.h:152
Gaudi::Examples::MyTrack::m_event
SmartRef< Event > m_event
Link to Top level event.
Definition: MyTrack.h:76
SmartRefVector.h
Gaudi::Examples::MyTrack::pz
float pz() const
Accessors: Retrieve z-component of the track momentum.
Definition: MyTrack.h:98
KeyedContainer.h
StreamBuffer
Definition: StreamBuffer.h:52
bug_34121.t
t
Definition: bug_34121.py:31
Gaudi::Examples::MyTrack::setPz
void setPz(float pz)
Accessors: Update z-component of the track momentum.
Definition: MyTrack.h:104
Gaudi::Examples::MyTrack::classID
static const CLID & classID()
Definition: MyTrack.h:92
Gaudi::Examples::GaudiObjectHandler
Definition: MyTrack.h:34
Gaudi::Examples::MyTrack::serialize
StreamBuffer & serialize(StreamBuffer &s) const override
Serialize the object for writing.
Definition: MyTrack.h:169
ObjectVector.h
Gaudi::Examples::MyTrack::Selection
SharedObjectsContainer< MyTrack > Selection
the type of selection
Definition: MyTrack.h:63
Gaudi::Examples::Event
Definition: Event.h:39
Gaudi::Examples::MyTrack::m_pz
float m_pz
Definition: MyTrack.h:74
Gaudi::Examples::MyTrack::addDecayVertex
void addDecayVertex(MyVertex *vtx)
Add decay vertex.
Definition: MyTrack.h:155
SharedObjectsContainer
Definition: SharedObjectsContainer.h:39
KeyedContainer
template class KeyedContainer, KeyedContainer.h
Definition: KeyedContainer.h:74
CLID
unsigned int CLID
Class ID definition.
Definition: ClassID.h:18
KeyedObject
Definition of the templated KeyedObject class.
Definition: KeyedObject.h:39
Gaudi
This file provides a Grammar for the type Gaudi::Accumulators::Axis It allows to use that type from p...
Definition: __init__.py:1
SharedObjectsContainer.h
Event.h
Gaudi::Examples::MyTrack::removeDecayVertex
void removeDecayVertex(MyVertex *vtx)
Remove decay vertex.
Definition: MyTrack.h:158
Gaudi::Examples::MyTrack::setOriginVertex
void setOriginVertex(MyVertex *origin)
Set origin vertex.
Definition: MyTrack.h:149
Gaudi::Examples::MyTrack::setEvent
void setEvent(Event *evt)
Access to event object.
Definition: MyTrack.h:109
Gaudi::Examples::MyTrack::setPy
void setPy(float py)
Accessors: Update y-component of the track momentum.
Definition: MyTrack.h:102
Gaudi::Examples::MyTrack::setPx
void setPx(float px)
Accessors: Update x-component of the track momentum.
Definition: MyTrack.h:100
Gaudi::Examples::MyTrack::m_originVertex
SmartRef< MyVertex > m_originVertex
Link to origin vertex.
Definition: MyTrack.h:78
Gaudi::Examples::MyTrack
Definition: MyTrack.h:53
MyVertex.h
Gaudi::Examples::MyTrack::Vector
std::vector< MyTrack * > Vector
the type of plain vector
Definition: MyTrack.h:59
SmartRef
Kernel objects: SmartRef.
Definition: SmartRef.h:76
Gaudi::Examples::MyVertex
Definition: MyVertex.h:36
Gaudi::Examples::MyTrack::clID
const CLID & clID() const override
Retrieve pointer to class definition structure.
Definition: MyTrack.h:91
Gaudi::Examples::MyTrack::px
float px() const
Accessors: Retrieve x-component of the track momentum.
Definition: MyTrack.h:94
ContainedObject.h
Gaudi::Examples::MyTrack::py
float py() const
Accessors: Retrieve y-component of the track momentum.
Definition: MyTrack.h:96
Gaudi::Examples::MyTrack::ConstVector
std::vector< const MyTrack * > ConstVector
the type of vector of const-pointers
Definition: MyTrack.h:61
GAUDI_API
#define GAUDI_API
Definition: Kernel.h:81
ContainedObject
Definition: ContainedObject.h:41
ContainedObject::serialize
virtual StreamBuffer & serialize(StreamBuffer &s) const
Serialize the object for writing.
Definition: ContainedObject.h:70