BOSS 8.0.0
BESIII Offline Software System
Loading...
Searching...
No Matches
EventID.h
Go to the documentation of this file.
1/***************************************************************************
2 EventInfo Package
3 -----------------------------------------
4 Copyright (C) 2000 by ATLAS Collaboration
5 ***************************************************************************/
6
7//<doc><file> $Id: EventID.h,v 1.1.1.1 2007/04/25 11:46:57 zoujh Exp $
8//<version> $Name: HltDataTypes-01-01-03 $
9
10#ifndef EVENTINFO_EVENTID_H
11#define EVENTINFO_EVENTID_H
12
13//<<<<<< INCLUDES >>>>>>
14//<<<<<< PUBLIC DEFINES >>>>>>
15//<<<<<< PUBLIC CONSTANTS >>>>>>
16//<<<<<< PUBLIC TYPES >>>>>>
17//<<<<<< PUBLIC VARIABLES >>>>>>
18//<<<<<< PUBLIC FUNCTIONS >>>>>>
19//<<<<<< CLASS DECLARATIONS >>>>>>
20
21#include <iostream>
22
23//
24// class EventID
25//
26// This class provides a unique identification for each event.
27//
28class EventID {
29public:
30 typedef unsigned int number_type;
31
32 EventID();
35 explicit EventID( const EventID& id );
36 virtual ~EventID();
37
38 number_type run_number( void ) const;
39 number_type event_number( void ) const;
40 number_type time_stamp( void ) const; // posix time in seconds from 1970
41
42 // Comparison operators
43 friend bool operator<( const EventID& lhs, const EventID& rhs );
44 friend bool operator>( const EventID& lhs, const EventID& rhs );
45 friend bool operator==( const EventID& lhs, const EventID& rhs );
46 friend bool operator!=( const EventID& lhs, const EventID& rhs );
47 friend bool operator<=( const EventID& lhs, const EventID& rhs );
48 friend bool operator>=( const EventID& lhs, const EventID& rhs );
49
50 // Insertion and extraction operators
51 friend std::istream& operator>>( std::istream& is, EventID& rhs );
52
53 template <class STR> friend STR& operator<<( STR& os, const EventID& rhs );
54
55private:
56 number_type m_run_number;
57 number_type m_event_number;
58
59 // posix time in seconds since 1970/01/01
60 number_type m_time_stamp;
61};
62
63//<<<<<< INLINE PUBLIC FUNCTIONS >>>>>>
64
65inline bool operator<( const EventID& lhs, const EventID& rhs ) {
66 // We are assuming that ALL events will have run and event numbers,
67 // and never just a time stamp.
68 return lhs.m_run_number < rhs.m_run_number ||
69 ( lhs.m_run_number == rhs.m_run_number && lhs.m_event_number < rhs.m_event_number );
70}
71inline bool operator==( const EventID& lhs, const EventID& rhs ) {
72 return lhs.m_run_number == rhs.m_run_number && lhs.m_event_number == rhs.m_event_number;
73}
74inline bool operator>( const EventID& lhs, const EventID& rhs ) {
75 return !( ( lhs < rhs ) || ( lhs == rhs ) );
76}
77inline bool operator!=( const EventID& lhs, const EventID& rhs ) { return !( lhs == rhs ); }
78inline bool operator<=( const EventID& lhs, const EventID& rhs ) { return !( lhs > rhs ); }
79inline bool operator>=( const EventID& lhs, const EventID& rhs ) { return !( lhs < rhs ); }
80
81template <class STR> inline STR& operator<<( STR& os, const EventID& rhs ) {
82 os << "[R,E] = [" << rhs.m_run_number << "," << rhs.m_event_number << "]";
83 return os;
84}
85
86inline std::istream& operator>>( std::istream& is, EventID& rhs ) {
87 is >> rhs.m_run_number >> rhs.m_event_number;
88 return is;
89}
90
91//<<<<<< INLINE MEMBER FUNCTIONS >>>>>>
92
93#endif // EVENTINFO_EVENTID_H
std::istream & operator>>(std::istream &is, EventID &rhs)
Definition EventID.h:86
bool operator==(const EventID &lhs, const EventID &rhs)
Definition EventID.h:71
bool operator<(const EventID &lhs, const EventID &rhs)
Definition EventID.h:65
bool operator>(const EventID &lhs, const EventID &rhs)
Definition EventID.h:74
bool operator>=(const EventID &lhs, const EventID &rhs)
Definition EventID.h:79
bool operator<=(const EventID &lhs, const EventID &rhs)
Definition EventID.h:78
STR & operator<<(STR &os, const EventID &rhs)
Definition EventID.h:81
bool operator!=(const EventID &lhs, const EventID &rhs)
Definition EventID.h:77
number_type run_number(void) const
Definition EventID.cxx:36
friend std::istream & operator>>(std::istream &is, EventID &rhs)
Definition EventID.h:86
friend bool operator==(const EventID &lhs, const EventID &rhs)
Definition EventID.h:71
friend bool operator<(const EventID &lhs, const EventID &rhs)
Definition EventID.h:65
virtual ~EventID()
Definition EventID.cxx:34
friend bool operator>(const EventID &lhs, const EventID &rhs)
Definition EventID.h:74
number_type time_stamp(void) const
Definition EventID.cxx:40
unsigned int number_type
Definition EventID.h:30
friend bool operator>=(const EventID &lhs, const EventID &rhs)
Definition EventID.h:79
EventID()
Definition EventID.cxx:21
number_type event_number(void) const
Definition EventID.cxx:38
friend bool operator<=(const EventID &lhs, const EventID &rhs)
Definition EventID.h:78
friend STR & operator<<(STR &os, const EventID &rhs)
Definition EventID.h:81
friend bool operator!=(const EventID &lhs, const EventID &rhs)
Definition EventID.h:77