1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
|
#ifndef DataFormats_Provenance_FileIndex_h
#define DataFormats_Provenance_FileIndex_h
/*----------------------------------------------------------------------
FileIndex.h
// Obsolete: For Backward compatibility only.
----------------------------------------------------------------------*/
#include "DataFormats/Provenance/interface/RunID.h"
#include "DataFormats/Provenance/interface/EventID.h"
#include "FWCore/Utilities/interface/thread_safety_macros.h"
#include <cassert>
#include <iosfwd>
#include <vector>
namespace edm {
class FileIndex {
public:
typedef long long EntryNumber_t;
FileIndex();
~FileIndex() {}
void addEntry(RunNumber_t run, LuminosityBlockNumber_t lumi, EventNumber_t event, EntryNumber_t entry);
enum EntryType { kRun, kLumi, kEvent, kEnd };
class Element {
public:
static EntryNumber_t const invalidEntry = -1LL;
Element() : run_(0U), lumi_(0U), event_(0U), entry_(invalidEntry) {}
Element(RunNumber_t run, LuminosityBlockNumber_t lumi, EventNumber_t event, long long entry)
: run_(run), lumi_(lumi), event_(event), entry_(entry) {
assert(lumi_ != 0U || event_ == 0U);
}
Element(RunNumber_t run, LuminosityBlockNumber_t lumi, EventNumber_t event)
: run_(run), lumi_(lumi), event_(event), entry_(invalidEntry) {}
EntryType getEntryType() const { return lumi_ == 0U ? kRun : (event_ == 0U ? kLumi : kEvent); }
RunNumber_t run_;
LuminosityBlockNumber_t lumi_;
EventNumber_t event_;
EntryNumber_t entry_;
};
typedef std::vector<Element>::const_iterator const_iterator;
typedef std::vector<Element>::iterator iterator;
void sortBy_Run_Lumi_Event();
void sortBy_Run_Lumi_EventEntry();
const_iterator findPosition(RunNumber_t run, LuminosityBlockNumber_t lumi = 0U, EventNumber_t event = 0U) const;
const_iterator findEventPosition(RunNumber_t run, LuminosityBlockNumber_t lumi, EventNumber_t event) const;
const_iterator findEventEntryPosition(RunNumber_t run,
LuminosityBlockNumber_t lumi,
EventNumber_t event,
EntryNumber_t entry) const;
const_iterator findLumiPosition(RunNumber_t run, LuminosityBlockNumber_t lumi) const;
const_iterator findRunPosition(RunNumber_t run) const;
const_iterator findLumiOrRunPosition(RunNumber_t run, LuminosityBlockNumber_t lumi) const;
bool containsItem(RunNumber_t run, LuminosityBlockNumber_t lumi, EventNumber_t event) const {
return (event != 0) ? containsEvent(run, lumi, event) : (lumi ? containsLumi(run, lumi) : containsRun(run));
}
bool containsEvent(RunNumber_t run, LuminosityBlockNumber_t lumi, EventNumber_t event) const {
return findEventPosition(run, lumi, event) != entries_.end();
}
bool containsLumi(RunNumber_t run, LuminosityBlockNumber_t lumi) const {
return findLumiPosition(run, lumi) != entries_.end();
}
bool containsRun(RunNumber_t run) const { return findRunPosition(run) != entries_.end(); }
const_iterator begin() const { return entries_.begin(); }
const_iterator end() const { return entries_.end(); }
iterator begin() { return entries_.begin(); }
iterator end() { return entries_.end(); }
iterator erase(iterator pos) { return entries_.erase(pos); }
iterator erase(iterator begin, iterator end) { return entries_.erase(begin, end); }
std::vector<Element>::size_type size() const { return entries_.size(); }
bool empty() const { return entries_.empty(); }
bool allEventsInEntryOrder() const;
enum SortState { kNotSorted, kSorted_Run_Lumi_Event, kSorted_Run_Lumi_EventEntry };
void initializeTransients() const { transient_.reset(); }
struct Transients {
Transients();
void reset();
bool allInEntryOrder_;
bool resultCached_;
SortState sortState_;
};
private:
bool& allInEntryOrder() const { return transient_.allInEntryOrder_; }
bool& resultCached() const { return transient_.resultCached_; }
SortState& sortState() const { return transient_.sortState_; }
std::vector<Element> entries_;
//Only used within source's serial code
CMS_SA_ALLOW mutable Transients transient_;
};
bool operator<(FileIndex::Element const& lh, FileIndex::Element const& rh);
inline bool operator>(FileIndex::Element const& lh, FileIndex::Element const& rh) { return rh < lh; }
inline bool operator>=(FileIndex::Element const& lh, FileIndex::Element const& rh) { return !(lh < rh); }
inline bool operator<=(FileIndex::Element const& lh, FileIndex::Element const& rh) { return !(rh < lh); }
inline bool operator==(FileIndex::Element const& lh, FileIndex::Element const& rh) { return !(lh < rh || rh < lh); }
inline bool operator!=(FileIndex::Element const& lh, FileIndex::Element const& rh) { return lh < rh || rh < lh; }
class Compare_Run_Lumi_EventEntry {
public:
bool operator()(FileIndex::Element const& lh, FileIndex::Element const& rh);
};
std::ostream& operator<<(std::ostream& os, FileIndex const& fileIndex);
} // namespace edm
#endif
|