The Gaudi Framework  master (37c0b60a)
Event.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 
13 #include <GaudiKernel/DataObject.h>
14 #include <GaudiKernel/Kernel.h>
17 #include <GaudiKernel/Time.h>
18 #include <iostream>
19 
20 namespace Gaudi {
21  namespace TestSuite {
22 
23  class Collision;
24 
25  // CLID definition
26  static const CLID& CLID_Event = 1110;
27 
37  class GAUDI_API Event : public DataObject {
38 
39  public:
41  Event();
42 
44  const CLID& clID() const override { return classID(); }
45  static const CLID& classID() { return CLID_Event; }
46 
48  int event() const { return m_event; }
50  void setEvent( int value ) { m_event = value; }
51 
53  int run() const { return m_run; }
55  void setRun( int value ) { m_run = value; }
56 
58  const Gaudi::Time& time() const { return m_time; }
60  void setTime( const Gaudi::Time& value ) { m_time = value; }
61 
63  const SmartRefVector<Collision>& collisions() const;
64 
66  void addCollision( Collision* vtx );
67 
69  void removeCollision( Collision* vtx );
70 
72  virtual StreamBuffer& serialize( StreamBuffer& s ) const;
74  virtual StreamBuffer& serialize( StreamBuffer& s );
75 
77  std::ostream& fillStream( std::ostream& s ) const override;
78 
79  private:
81  int m_event{ 0 };
83  int m_run{ 0 };
86 
89  };
90  } // namespace TestSuite
91 } // namespace Gaudi
92 
93 #include "Collision.h"
94 
95 namespace Gaudi {
96  namespace TestSuite {
97 
98  //
99  // Inline code must be outside the class definition
100  //
101 
104  return s << m_event << m_run << m_time << m_collisions( this );
105  }
106 
109  return s >> m_event >> m_run >> m_time >> m_collisions( this );
110  }
111 
114  return s << "class Event :"
115  << "\n Event number = " << std::setw( 12 ) << m_event << "\n Run number = " << std::setw( 12 )
116  << m_run << "\n Time = " << m_time;
117  }
118 
120  inline const SmartRefVector<Collision>& Event::collisions() const { return m_collisions; }
121 
123  inline void Event::addCollision( Collision* c ) { m_collisions.push_back( SmartRef<Collision>( c ) ); }
124 
127  for ( auto i = m_collisions.begin(); i != m_collisions.end(); ++i ) {
128  if ( i->target() == c ) {
129  m_collisions.erase( i );
130  return;
131  }
132  }
133  }
134 
136  inline std::ostream& operator<<( std::ostream& s, const Event& obj ) { return obj.fillStream( s ); }
137  } // namespace TestSuite
138 } // namespace Gaudi
Gaudi::TestSuite::Event::addCollision
void addCollision(Collision *vtx)
Add collision.
Definition: Event.h:123
Gaudi::TestSuite::Event::collisions
const SmartRefVector< Collision > & collisions() const
Access to collisions.
Definition: Event.h:120
Collision.h
Gaudi::TestSuite::Event::setRun
void setRun(int value)
Update run number.
Definition: Event.h:55
SmartRefVector
Kernel objects: SmartRefVector.
Definition: SmartRefVector.h:79
Gaudi::TestSuite::Event::fillStream
std::ostream & fillStream(std::ostream &s) const override
Fill the output stream (ASCII)
Definition: Event.h:113
Gaudi::TestSuite::Event::setTime
void setTime(const Gaudi::Time &value)
Update reference to event time stamp.
Definition: Event.h:60
Gaudi::TestSuite::Event::clID
const CLID & clID() const override
Retrieve reference to class definition structure.
Definition: Event.h:44
gaudirun.s
string s
Definition: gaudirun.py:346
TestSuite
#define TestSuite
Definition: MakeAndConsume.cpp:658
Gaudi::TestSuite::Event::classID
static const CLID & classID()
Definition: Event.h:45
SmartRefVector.h
Gaudi::TestSuite::Event::removeCollision
void removeCollision(Collision *vtx)
Remove collision.
Definition: Event.h:126
gaudirun.c
c
Definition: gaudirun.py:525
StreamBuffer.h
Gaudi::TestSuite::Collision
Definition: Collision.h:26
Gaudi::TestSuite::Event
Definition: Event.h:37
Gaudi::TestSuite::Event::run
int run() const
Retrieve run number.
Definition: Event.h:53
StreamBuffer
Definition: StreamBuffer.h:52
Gaudi::Time
Definition: Time.h:241
std::ostream
STL class.
Gaudi::TestSuite::Event::time
const Gaudi::Time & time() const
Retrieve reference to event time stamp.
Definition: Event.h:58
Gaudi::TestSuite::Event::m_event
int m_event
Event number.
Definition: Event.h:81
CLID
unsigned int CLID
Class ID definition.
Definition: ClassID.h:18
Gaudi
This file provides a Grammar for the type Gaudi::Accumulators::Axis It allows to use that type from p...
Definition: __init__.py:1
Gaudi::TestSuite::Event::serialize
virtual StreamBuffer & serialize(StreamBuffer &s) const
Serialize the object for writing.
Definition: Event.h:103
DataObject.h
Time.h
Gaudi::TestSuite::Event::m_time
Gaudi::Time m_time
Time stamp.
Definition: Event.h:85
Kernel.h
DataObject
Definition: DataObject.h:36
Gaudi::TestSuite::operator<<
std::ostream & operator<<(std::ostream &s, const Event &obj)
Output operator (ASCII)
Definition: Event.h:136
Gaudi::TestSuite::Event::event
int event() const
Retrieve event number.
Definition: Event.h:48
SmartRef
Kernel objects: SmartRef.
Definition: SmartRef.h:76
Gaudi::TestSuite::Event::m_collisions
SmartRefVector< Collision > m_collisions
Vector of collisions this object belongs to.
Definition: Event.h:88
std::setw
T setw(T... args)
Gaudi::TestSuite::Event::m_run
int m_run
Run number.
Definition: Event.h:83
GAUDI_API
#define GAUDI_API
Definition: Kernel.h:81
Gaudi::TestSuite::Event::setEvent
void setEvent(int value)
Update event number.
Definition: Event.h:50