LCIO  02.17
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
RunEventMap.h
Go to the documentation of this file.
1 #ifndef SIO_RunEventMap_H
2 #define SIO_RunEventMap_H 1
3 
4 #include <ostream>
5 #include <map>
6 
7 namespace SIO {
8 
9  class RunEventMap ;
10 
14  struct RunEvent {
15  typedef long long long64 ;
16 
17  RunEvent() = default ;
18  ~RunEvent() = default ;
19  RunEvent(int run, int evt): RunNum( run ), EvtNum( evt ) {}
20  RunEvent(long64 runEvt): RunNum( (runEvt >> 32 ) & 0xffffffff ), EvtNum( runEvt & 0xffffffff ) {}
21  operator long64() const { return ( ( long64(RunNum) << 32) | ( long64(EvtNum) & 0xffffffff ) ) ; }
22 
23  int RunNum {0} ;
24  int EvtNum {0} ;
25  };
26 
27  std::ostream & operator<<(std::ostream& os, const RunEvent& re ) ;
28  bool operator < ( const RunEvent& r0, const RunEvent& other) ;
29  std::ostream & operator<<(std::ostream& os, const RunEventMap& rm ) ;
30 
31 
37  class RunEventMap {
38  typedef long long long64 ;
39  friend std::ostream & operator<<(std::ostream& os, const RunEventMap& rm ) ;
40 
41  public:
42  // traits
44  typedef map_type::iterator iterator ;
45  typedef map_type::const_iterator const_iterator ;
46  static constexpr const int npos = -1 ;
47 
48  public:
49  RunEventMap() = default ;
50  ~RunEventMap() = default ;
51 
54  void add(const RunEvent& re, long64 pos ) ;
55 
59  long64 getPosition(const RunEvent& re ) {
60  return getPosition( long64( re ) ) ;
61  }
62 
65  long64 getPosition( long64 re ) ;
66 
67 
68  /* Return the minimal run event object - (-1,-1) if empty.
69  */
70  RunEvent minRunEvent() const ;
71 
72  /* Return the maximum run event object - (-1,-1) if empty.
73  */
74  RunEvent maxRunEvent() const ;
75 
76 
77  int getNumberOfEventRecords() const { return _nEvt ; }
78 
79  int getNumberOfRunRecords() const { return _nRun ; }
80 
81  // map funcitons
82  size_t size() { return _map.size() ; }
83 
84  iterator begin() { return _map.begin() ; }
85  iterator end() { return _map.end() ; }
86  const_iterator begin() const { return _map.begin() ; }
87  const_iterator end() const { return _map.end() ; }
88  bool empty() const { return _map.empty() ; }
89 
90  template <class InputIterator>
91  void insert(InputIterator b, InputIterator e) { _map.insert( b , e ) ; }
92 
93  void clear() { _map.clear() ; _nRun=0 ; _nEvt =0 ; }
94 
95  protected:
97  int _nRun{0} ;
98  int _nEvt{0} ;
99  }; // class
100  } // namespace
101 
102 #endif /* ifndef SIO_RunEventMap_H */
RunEvent minRunEvent() const
Definition: RunEventMap.cc:61
T empty(T...args)
RunEvent(int run, int evt)
Definition: RunEventMap.h:19
iterator begin()
Definition: RunEventMap.h:84
const_iterator begin() const
Definition: RunEventMap.h:86
RunEvent()=default
~RunEventMap()=default
int getNumberOfRunRecords() const
Definition: RunEventMap.h:79
T end(T...args)
Helper struct that stores run and event positions in the file.
Definition: RunEventMap.h:14
long long long64
Definition: RunEventMap.h:38
Map that holds positions of Run and Event records.
Definition: RunEventMap.h:37
std::ostream & operator<<(std::ostream &os, const LCIORandomAccess &ra)
long64 getPosition(const RunEvent &re)
Return the position of the specified Event record or Run record respectively (if EventNum == -1 )...
Definition: RunEventMap.h:59
static constexpr const int npos
Definition: RunEventMap.h:46
int getNumberOfEventRecords() const
Definition: RunEventMap.h:77
bool empty() const
Definition: RunEventMap.h:88
void add(const RunEvent &re, long64 pos)
Add a new entry to the event map - if the RunEvent already exists the new position will be stored...
Definition: RunEventMap.cc:32
RunEventMap()=default
map_type::iterator iterator
Definition: RunEventMap.h:44
void insert(InputIterator b, InputIterator e)
Definition: RunEventMap.h:91
T clear(T...args)
friend std::ostream & operator<<(std::ostream &os, const RunEventMap &rm)
T insert(T...args)
const_iterator end() const
Definition: RunEventMap.h:87
T size(T...args)
long long long64
Definition: RunEventMap.h:15
iterator end()
Definition: RunEventMap.h:85
T begin(T...args)
std::map< RunEvent, long64 > map_type
Definition: RunEventMap.h:43
RunEvent maxRunEvent() const
Definition: RunEventMap.cc:70
RunEvent(long64 runEvt)
Definition: RunEventMap.h:20
map_type::const_iterator const_iterator
Definition: RunEventMap.h:45
~RunEvent()=default
STL class.
bool operator<(const LCIORandomAccess &ra0, const LCIORandomAccess &other)
EVENT::long64 long64
Definition: LCReader.cc:27