The Gaudi Framework  master (37c0b60a)
legacy_examples.cpp
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 #include <GaudiExamples/Counter.h>
12 #include <GaudiExamples/Event.h>
13 #include <GaudiExamples/MyTrack.h>
14 #include <GaudiExamples/MyVertex.h>
15 
16 using namespace Gaudi::Examples;
17 
18 Counter::Counter() : DataObject(), m_counter( 0 ) {}
19 
21  // m_collisions(this);
22 }
23 
24 namespace {
25  struct TrkInstanceCount {
26  long count;
27  TrkInstanceCount() : count( 0 ) {}
28  ~TrkInstanceCount() {
29  if ( count ) std::cout << "Number of MyTrack instances:" << count << std::endl;
30  }
31  };
32 } // namespace
33 static TrkInstanceCount s_trk_instances;
34 
36 MyTrack::MyTrack() : m_px( 0.0 ), m_py( 0.0 ), m_pz( 0.0 ) {
37  // m_event(this);
38  // m_originVertex(this);
39  // m_decayVertices(this);
40  s_trk_instances.count++;
41 }
42 
44 MyTrack::MyTrack( float x, float y, float z ) : m_px( x ), m_py( y ), m_pz( z ) {
45  // m_event(this);
46  // m_originVertex(this);
47  // m_decayVertices(this);
48  s_trk_instances.count++;
49 }
50 
51 MyTrack::MyTrack( const MyTrack& t ) : KeyedObject<int>( t.key() ), m_px( t.m_px ), m_py( t.m_py ), m_pz( t.m_pz ) {
52  s_trk_instances.count++;
53 }
54 
56 MyTrack::~MyTrack() { s_trk_instances.count--; }
57 
58 namespace {
59  struct VtxInstanceCount {
60  long count;
61  VtxInstanceCount() : count( 0 ) {}
62  ~VtxInstanceCount() {
63  if ( count ) std::cout << "Number of MyVertex instances:" << count << std::endl;
64  }
65  };
66 } // namespace
67 static VtxInstanceCount s_vtx_instances;
68 
70 MyVertex::MyVertex() : m_x( 0.0 ), m_y( 0.0 ), m_z( 0.0 ) { s_vtx_instances.count++; }
71 
73 MyVertex::MyVertex( float x, float y, float z ) : m_x( x ), m_y( y ), m_z( z ) { s_vtx_instances.count++; }
74 
76 MyVertex::~MyVertex() { s_vtx_instances.count--; }
77 
81  s << m_motherParticle( this );
82  s << m_decayParticles( this );
83  s << m_event( this );
84  s << m_collisions( this );
85  s << m_x << m_y << m_z;
86  return s;
87 }
88 
92  s >> m_motherParticle( this );
93  s >> m_decayParticles( this );
94  s >> m_event( this );
95  s >> m_collisions( this );
96  s >> m_x >> m_y >> m_z;
97  return s;
98 }
MyVertex.h
KeyedObject::serialize
StreamBuffer & serialize(StreamBuffer &s) const override
Serialize the object for writing.
Definition: KeyedObject.h:143
Counter.h
gaudirun.s
string s
Definition: gaudirun.py:346
Gaudi::Examples::MyVertex::m_z
float m_z
Definition: MyVertex.h:39
Gaudi::Examples::MyVertex::serialize
StreamBuffer & serialize(StreamBuffer &s) const override
Serialize the object for writing.
Definition: legacy_examples.cpp:79
Gaudi::Examples::Counter::Counter
Counter()
Constructors.
Definition: legacy_examples.cpp:18
Gaudi::Examples::MyVertex::m_motherParticle
SmartRef< MyTrack > m_motherParticle
Link to mother track.
Definition: MyVertex.h:43
MyTrack.h
StreamBuffer
Definition: StreamBuffer.h:52
Gaudi::Examples::MyVertex::m_decayParticles
SmartRefVector< MyTrack > m_decayParticles
Links to all daughter particles.
Definition: MyVertex.h:45
bug_34121.t
t
Definition: bug_34121.py:31
Gaudi::Examples::MyTrack::~MyTrack
~MyTrack() override
Standard Destructor.
Definition: legacy_examples.cpp:56
Gaudi::Examples
Definition: Collision.h:20
Gaudi::Examples::MyVertex::m_collisions
SmartRefVector< Collision > m_collisions
Vector of collisions this object belongs to.
Definition: MyVertex.h:47
std::cout
Gaudi::Examples::MyVertex::~MyVertex
~MyVertex() override
Standard Destructor.
Definition: legacy_examples.cpp:76
Gaudi::Examples::MyVertex::MyVertex
MyVertex()
Standard constructor.
Definition: legacy_examples.cpp:70
Gaudi::Examples::Event::Event
Event()
Constructors.
Definition: legacy_examples.cpp:20
KeyedObject
Definition of the templated KeyedObject class.
Definition: KeyedObject.h:39
Gaudi::Examples::MyVertex::m_x
float m_x
The vertex location.
Definition: MyVertex.h:39
Event.h
std::endl
T endl(T... args)
Gaudi::Examples::MyTrack
Definition: MyTrack.h:53
Gaudi::Examples::MyVertex::m_y
float m_y
Definition: MyVertex.h:39
DataObject
Definition: DataObject.h:36
Gaudi::Examples::MyVertex::m_event
SmartRef< Event > m_event
Link to Top level event.
Definition: MyVertex.h:41
Gaudi::Examples::MyTrack::MyTrack
MyTrack()
Standard constructor.
Definition: legacy_examples.cpp:36
ProduceConsume.key
key
Definition: ProduceConsume.py:84