The Gaudi Framework  master (ff829712)
Loading...
Searching...
No Matches
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
14#include <GaudiKernel/Kernel.h>
17#include <GaudiKernel/Time.h>
18#include <iostream>
19
20namespace Gaudi {
21 namespace TestSuite {
22
23 class Collision;
24
25 // CLID definition
26 static const CLID& CLID_Event = 1110;
27
36
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
95namespace 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
113 inline std::ostream& Event::fillStream( std::ostream& s ) const {
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
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
unsigned int CLID
Class ID definition.
Definition ClassID.h:16
#define GAUDI_API
Definition Kernel.h:49
DataObject()
Standard Constructor.
Essential information of the event used in examples It can be identified by "/Event".
Definition Event.h:37
void addCollision(Collision *vtx)
Add collision.
Definition Event.h:123
int m_run
Run number.
Definition Event.h:83
void setRun(int value)
Update run number.
Definition Event.h:55
const SmartRefVector< Collision > & collisions() const
Access to collisions.
Definition Event.h:120
const Gaudi::Time & time() const
Retrieve reference to event time stamp.
Definition Event.h:58
void setTime(const Gaudi::Time &value)
Update reference to event time stamp.
Definition Event.h:60
Gaudi::Time m_time
Time stamp.
Definition Event.h:85
Event()
Constructors.
Definition Event.cpp:15
SmartRefVector< Collision > m_collisions
Vector of collisions this object belongs to.
Definition Event.h:88
std::ostream & fillStream(std::ostream &s) const override
Fill the output stream (ASCII)
Definition Event.h:113
const CLID & clID() const override
Retrieve reference to class definition structure.
Definition Event.h:44
int event() const
Retrieve event number.
Definition Event.h:48
int run() const
Retrieve run number.
Definition Event.h:53
virtual StreamBuffer & serialize(StreamBuffer &s) const
Serialize the object for writing.
Definition Event.h:103
int m_event
Event number.
Definition Event.h:81
void removeCollision(Collision *vtx)
Remove collision.
Definition Event.h:126
void setEvent(int value)
Update event number.
Definition Event.h:50
static const CLID & classID()
Definition Event.h:45
Based on seal::Time.
Definition Time.h:235
Kernel objects: SmartRef.
Definition SmartRef.h:64
Kernel objects: SmartRefVector.
The stream buffer is a small object collecting object data.
std::ostream & operator<<(std::ostream &s, const Event &obj)
Output operator (ASCII)
Definition Event.h:136
This file provides a Grammar for the type Gaudi::Accumulators::Axis It allows to use that type from p...
Definition __init__.py:1