CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
List of all members | Classes | Public Types | Public Member Functions | Private Member Functions | Private Attributes
edm::FileIndex Class Reference

#include <FileIndex.h>

Classes

class  Element
 
struct  Transients
 

Public Types

typedef std::vector< Element >
::const_iterator 
const_iterator
 
typedef long long EntryNumber_t
 
enum  EntryType { kRun, kLumi, kEvent, kEnd }
 
typedef std::vector< Element >
::iterator 
iterator
 
enum  SortState { kNotSorted, kSorted_Run_Lumi_Event, kSorted_Run_Lumi_EventEntry }
 

Public Member Functions

void addEntry (RunNumber_t run, LuminosityBlockNumber_t lumi, EventNumber_t event, EntryNumber_t entry)
 
bool allEventsInEntryOrder () const
 
const_iterator begin () const
 
iterator begin ()
 
bool containsEvent (RunNumber_t run, LuminosityBlockNumber_t lumi, EventNumber_t event) const
 
bool containsItem (RunNumber_t run, LuminosityBlockNumber_t lumi, EventNumber_t event) const
 
bool containsLumi (RunNumber_t run, LuminosityBlockNumber_t lumi) const
 
bool containsRun (RunNumber_t run) const
 
bool empty () const
 
const_iterator end () const
 
iterator end ()
 
iterator erase (iterator pos)
 
iterator erase (iterator begin, iterator end)
 
 FileIndex ()
 
const_iterator findEventEntryPosition (RunNumber_t run, LuminosityBlockNumber_t lumi, EventNumber_t event, EntryNumber_t entry) const
 
const_iterator findEventPosition (RunNumber_t run, LuminosityBlockNumber_t lumi, EventNumber_t event) const
 
const_iterator findLumiOrRunPosition (RunNumber_t run, LuminosityBlockNumber_t lumi) const
 
const_iterator findLumiPosition (RunNumber_t run, LuminosityBlockNumber_t lumi) const
 
const_iterator findPosition (RunNumber_t run, LuminosityBlockNumber_t lumi=0U, EventNumber_t event=0U) const
 
const_iterator findRunPosition (RunNumber_t run) const
 
void initializeTransients () const
 
std::vector< Element >::size_type size () const
 
void sortBy_Run_Lumi_Event ()
 
void sortBy_Run_Lumi_EventEntry ()
 
 ~FileIndex ()
 

Private Member Functions

bool & allInEntryOrder () const
 
bool & resultCached () const
 
SortStatesortState () const
 

Private Attributes

std::vector< Elemententries_
 
Transients transient_
 

Detailed Description

Definition at line 21 of file FileIndex.h.

Member Typedef Documentation

Definition at line 49 of file FileIndex.h.

typedef long long edm::FileIndex::EntryNumber_t

Definition at line 23 of file FileIndex.h.

typedef std::vector<Element>::iterator edm::FileIndex::iterator

Definition at line 51 of file FileIndex.h.

Member Enumeration Documentation

Enumerator
kRun 
kLumi 
kEvent 
kEnd 

Definition at line 30 of file FileIndex.h.

Enumerator
kNotSorted 
kSorted_Run_Lumi_Event 
kSorted_Run_Lumi_EventEntry 

Definition at line 103 of file FileIndex.h.

Constructor & Destructor Documentation

edm::FileIndex::FileIndex ( )

Definition at line 10 of file FileIndex.cc.

10 : entries_(), transient_() {}
std::vector< Element > entries_
Definition: FileIndex.h:120
Transients transient_
Definition: FileIndex.h:122
edm::FileIndex::~FileIndex ( )
inline

Definition at line 26 of file FileIndex.h.

26 {}

Member Function Documentation

void edm::FileIndex::addEntry ( RunNumber_t  run,
LuminosityBlockNumber_t  lumi,
EventNumber_t  event,
EntryNumber_t  entry 
)

Definition at line 28 of file FileIndex.cc.

References entries_, kNotSorted, resultCached(), and sortState().

28  {
29  entries_.emplace_back(run, lumi, event, entry);
30  resultCached() = false;
32  }
SortState & sortState() const
Definition: FileIndex.h:118
list lumi
Definition: dqmdumpme.py:53
std::vector< Element > entries_
Definition: FileIndex.h:120
bool & resultCached() const
Definition: FileIndex.h:117
list entry
Definition: mps_splice.py:68
bool edm::FileIndex::allEventsInEntryOrder ( ) const

Definition at line 46 of file FileIndex.cc.

References allInEntryOrder(), entries_, edm::FileIndex::Element::invalidEntry, kEvent, and resultCached().

46  {
47  if (!resultCached()) {
48  resultCached() = true;
50  for (std::vector<FileIndex::Element>::const_iterator it = entries_.begin(), itEnd = entries_.end(); it != itEnd;
51  ++it) {
52  if (it->getEntryType() == kEvent) {
53  if (it->entry_ < maxEntry) {
54  allInEntryOrder() = false;
55  return false;
56  }
57  maxEntry = it->entry_;
58  }
59  }
60  allInEntryOrder() = true;
61  return true;
62  }
63  return allInEntryOrder();
64  }
bool & allInEntryOrder() const
Definition: FileIndex.h:116
static EntryNumber_t const invalidEntry
Definition: FileIndex.h:34
long long EntryNumber_t
Definition: FileIndex.h:23
std::vector< Element > entries_
Definition: FileIndex.h:120
bool & resultCached() const
Definition: FileIndex.h:117
bool& edm::FileIndex::allInEntryOrder ( ) const
inlineprivate

Definition at line 116 of file FileIndex.h.

References edm::FileIndex::Transients::allInEntryOrder_, and transient_.

Referenced by allEventsInEntryOrder().

116 { return transient_.allInEntryOrder_; }
Transients transient_
Definition: FileIndex.h:122
const_iterator edm::FileIndex::begin ( void  ) const
inline

Definition at line 85 of file FileIndex.h.

References entries_.

Referenced by edm::operator<<(), and edm::preIndexIntoFilePrintEventsInLumis().

85 { return entries_.begin(); }
std::vector< Element > entries_
Definition: FileIndex.h:120
iterator edm::FileIndex::begin ( void  )
inline

Definition at line 89 of file FileIndex.h.

References entries_.

89 { return entries_.begin(); }
std::vector< Element > entries_
Definition: FileIndex.h:120
bool edm::FileIndex::containsEvent ( RunNumber_t  run,
LuminosityBlockNumber_t  lumi,
EventNumber_t  event 
) const
inline

Definition at line 75 of file FileIndex.h.

References entries_, and findEventPosition().

Referenced by containsItem().

75  {
76  return findEventPosition(run, lumi, event) != entries_.end();
77  }
const_iterator findEventPosition(RunNumber_t run, LuminosityBlockNumber_t lumi, EventNumber_t event) const
Definition: FileIndex.cc:91
list lumi
Definition: dqmdumpme.py:53
std::vector< Element > entries_
Definition: FileIndex.h:120
bool edm::FileIndex::containsItem ( RunNumber_t  run,
LuminosityBlockNumber_t  lumi,
EventNumber_t  event 
) const
inline

Definition at line 71 of file FileIndex.h.

References containsEvent(), containsLumi(), and containsRun().

71  {
72  return (event != 0) ? containsEvent(run, lumi, event) : (lumi ? containsLumi(run, lumi) : containsRun(run));
73  }
bool containsRun(RunNumber_t run) const
Definition: FileIndex.h:83
bool containsLumi(RunNumber_t run, LuminosityBlockNumber_t lumi) const
Definition: FileIndex.h:79
list lumi
Definition: dqmdumpme.py:53
bool containsEvent(RunNumber_t run, LuminosityBlockNumber_t lumi, EventNumber_t event) const
Definition: FileIndex.h:75
bool edm::FileIndex::containsLumi ( RunNumber_t  run,
LuminosityBlockNumber_t  lumi 
) const
inline

Definition at line 79 of file FileIndex.h.

References entries_, and findLumiPosition().

Referenced by containsItem().

79  {
80  return findLumiPosition(run, lumi) != entries_.end();
81  }
list lumi
Definition: dqmdumpme.py:53
const_iterator findLumiPosition(RunNumber_t run, LuminosityBlockNumber_t lumi) const
Definition: FileIndex.cc:120
std::vector< Element > entries_
Definition: FileIndex.h:120
bool edm::FileIndex::containsRun ( RunNumber_t  run) const
inline

Definition at line 83 of file FileIndex.h.

References entries_, and findRunPosition().

Referenced by containsItem().

83 { return findRunPosition(run) != entries_.end(); }
const_iterator findRunPosition(RunNumber_t run) const
Definition: FileIndex.cc:135
std::vector< Element > entries_
Definition: FileIndex.h:120
bool edm::FileIndex::empty ( ) const
inline

Definition at line 99 of file FileIndex.h.

References entries_.

Referenced by fwlite::EntryFinder::empty().

99 { return entries_.empty(); }
std::vector< Element > entries_
Definition: FileIndex.h:120
const_iterator edm::FileIndex::end ( void  ) const
inline
iterator edm::FileIndex::end ( void  )
inline

Definition at line 91 of file FileIndex.h.

References entries_.

Referenced by Types.LuminosityBlockRange::cppID(), and Types.EventRange::cppID().

91 { return entries_.end(); }
std::vector< Element > entries_
Definition: FileIndex.h:120
iterator edm::FileIndex::erase ( iterator  pos)
inline

Definition at line 93 of file FileIndex.h.

References entries_.

93 { return entries_.erase(pos); }
std::vector< Element > entries_
Definition: FileIndex.h:120
iterator edm::FileIndex::erase ( iterator  begin,
iterator  end 
)
inline

Definition at line 95 of file FileIndex.h.

References entries_.

95 { return entries_.erase(begin, end); }
const_iterator end() const
Definition: FileIndex.h:87
std::vector< Element > entries_
Definition: FileIndex.h:120
const_iterator begin() const
Definition: FileIndex.h:85
FileIndex::const_iterator edm::FileIndex::findEventEntryPosition ( RunNumber_t  run,
LuminosityBlockNumber_t  lumi,
EventNumber_t  event,
EntryNumber_t  entry 
) const

Definition at line 159 of file FileIndex.cc.

References cms::cuda::assert(), entries_, findEventPosition(), kNotSorted, kSorted_Run_Lumi_EventEntry, edm::lower_bound_all(), and sortState().

162  {
164  const_iterator it;
165  const_iterator itEnd = entries_.end();
167  assert(lumi != 0U);
168  Element el(run, lumi, event, entry);
169  it = lower_bound_all(entries_, el, Compare_Run_Lumi_EventEntry());
170  } else {
172  while (it != itEnd && it->entry_ != entry && it->event_ == event) {
173  ++it;
174  }
175  }
176  if (it == itEnd)
177  return itEnd;
178  if (lumi == 0)
179  lumi = it->lumi_;
180  if (it->run_ != run || it->lumi_ != lumi || it->event_ != event || it->entry_ != entry)
181  return itEnd;
182  return it;
183  }
ForwardSequence::const_iterator lower_bound_all(ForwardSequence const &s, Datum const &d)
wrappers for std::lower_bound
Definition: Algorithms.h:69
SortState & sortState() const
Definition: FileIndex.h:118
assert(be >=bs)
std::vector< Element >::const_iterator const_iterator
Definition: FileIndex.h:49
const_iterator findEventPosition(RunNumber_t run, LuminosityBlockNumber_t lumi, EventNumber_t event) const
Definition: FileIndex.cc:91
list lumi
Definition: dqmdumpme.py:53
std::vector< Element > entries_
Definition: FileIndex.h:120
list entry
Definition: mps_splice.py:68
FileIndex::const_iterator edm::FileIndex::findEventPosition ( RunNumber_t  run,
LuminosityBlockNumber_t  lumi,
EventNumber_t  event 
) const

Definition at line 91 of file FileIndex.cc.

References entries_, findPosition(), kEvent, kSorted_Run_Lumi_Event, and sortState().

Referenced by containsEvent(), fwlite::EntryFinder::findEvent(), and findEventEntryPosition().

93  {
95  const_iterator itEnd = entries_.end();
96  while (it != itEnd && it->getEntryType() != FileIndex::kEvent) {
97  ++it;
98  }
99  if (it == itEnd) {
100  return itEnd;
101  }
102  if (lumi == 0) {
103  lumi = it->lumi_;
104  }
105  if (it->run_ != run || it->lumi_ != lumi || it->event_ != event) {
107  return itEnd;
108  }
109  // not sorted by event, so we need to do a linear search
110  while (it != itEnd && it->run_ == run && it->lumi_ == lumi && it->event_ != event) {
111  ++it;
112  }
113  if (it->run_ != run || it->lumi_ != lumi || it->event_ != event) {
114  return itEnd;
115  }
116  }
117  return it;
118  }
SortState & sortState() const
Definition: FileIndex.h:118
std::vector< Element >::const_iterator const_iterator
Definition: FileIndex.h:49
list lumi
Definition: dqmdumpme.py:53
std::vector< Element > entries_
Definition: FileIndex.h:120
const_iterator findPosition(RunNumber_t run, LuminosityBlockNumber_t lumi=0U, EventNumber_t event=0U) const
Definition: FileIndex.cc:66
FileIndex::const_iterator edm::FileIndex::findLumiOrRunPosition ( RunNumber_t  run,
LuminosityBlockNumber_t  lumi 
) const

Definition at line 150 of file FileIndex.cc.

References entries_, findPosition(), kLumi, and kRun.

150  {
151  const_iterator it = findPosition(run, lumi, 0U);
152  const_iterator itEnd = entries_.end();
153  while (it != itEnd && it->getEntryType() != FileIndex::kLumi && it->getEntryType() != FileIndex::kRun) {
154  ++it;
155  }
156  return it;
157  }
std::vector< Element >::const_iterator const_iterator
Definition: FileIndex.h:49
list lumi
Definition: dqmdumpme.py:53
std::vector< Element > entries_
Definition: FileIndex.h:120
const_iterator findPosition(RunNumber_t run, LuminosityBlockNumber_t lumi=0U, EventNumber_t event=0U) const
Definition: FileIndex.cc:66
FileIndex::const_iterator edm::FileIndex::findLumiPosition ( RunNumber_t  run,
LuminosityBlockNumber_t  lumi 
) const

Definition at line 120 of file FileIndex.cc.

References entries_, findPosition(), and kLumi.

Referenced by containsLumi(), and fwlite::EntryFinder::findLumi().

120  {
121  const_iterator it = findPosition(run, lumi, 0U);
122  const_iterator itEnd = entries_.end();
123  while (it != itEnd && it->getEntryType() != FileIndex::kLumi) {
124  ++it;
125  }
126  if (it == itEnd) {
127  return itEnd;
128  }
129  if (it->run_ != run || it->lumi_ != lumi) {
130  return itEnd;
131  }
132  return it;
133  }
std::vector< Element >::const_iterator const_iterator
Definition: FileIndex.h:49
list lumi
Definition: dqmdumpme.py:53
std::vector< Element > entries_
Definition: FileIndex.h:120
const_iterator findPosition(RunNumber_t run, LuminosityBlockNumber_t lumi=0U, EventNumber_t event=0U) const
Definition: FileIndex.cc:66
FileIndex::const_iterator edm::FileIndex::findPosition ( RunNumber_t  run,
LuminosityBlockNumber_t  lumi = 0U,
EventNumber_t  event = 0U 
) const

Definition at line 66 of file FileIndex.cc.

References cms::cuda::assert(), entries_, kNotSorted, kSorted_Run_Lumi_Event, edm::lower_bound_all(), and sortState().

Referenced by findEventPosition(), findLumiOrRunPosition(), findLumiPosition(), and findRunPosition().

68  {
70 
71  const_iterator itEnd = entries_.end();
72  const_iterator it;
73  Element el(run, lumi, event);
75  it = lower_bound_all(entries_, el);
76  bool lumiMissing = (lumi == 0 && event != 0);
77  if (lumiMissing) {
78  while (it != itEnd && it->run_ < run) {
79  ++it;
80  }
81  while (it != itEnd && (it->run_ == run && it->event_ < event)) {
82  ++it;
83  }
84  }
85  } else {
86  it = lower_bound_all(entries_, el, Compare_Run_Lumi_EventEntry());
87  }
88  return it;
89  }
ForwardSequence::const_iterator lower_bound_all(ForwardSequence const &s, Datum const &d)
wrappers for std::lower_bound
Definition: Algorithms.h:69
SortState & sortState() const
Definition: FileIndex.h:118
assert(be >=bs)
std::vector< Element >::const_iterator const_iterator
Definition: FileIndex.h:49
list lumi
Definition: dqmdumpme.py:53
std::vector< Element > entries_
Definition: FileIndex.h:120
FileIndex::const_iterator edm::FileIndex::findRunPosition ( RunNumber_t  run) const

Definition at line 135 of file FileIndex.cc.

References entries_, findPosition(), and kRun.

Referenced by containsRun(), and fwlite::EntryFinder::findRun().

135  {
136  const_iterator it = findPosition(run, 0U, 0U);
137  const_iterator itEnd = entries_.end();
138  while (it != itEnd && it->getEntryType() != FileIndex::kRun) {
139  ++it;
140  }
141  if (it == itEnd) {
142  return itEnd;
143  }
144  if (it->run_ != run) {
145  return itEnd;
146  }
147  return it;
148  }
std::vector< Element >::const_iterator const_iterator
Definition: FileIndex.h:49
std::vector< Element > entries_
Definition: FileIndex.h:120
const_iterator findPosition(RunNumber_t run, LuminosityBlockNumber_t lumi=0U, EventNumber_t event=0U) const
Definition: FileIndex.cc:66
void edm::FileIndex::initializeTransients ( ) const
inline

Definition at line 105 of file FileIndex.h.

References edm::FileIndex::Transients::reset(), and transient_.

105 { transient_.reset(); }
Transients transient_
Definition: FileIndex.h:122
bool& edm::FileIndex::resultCached ( ) const
inlineprivate
std::vector<Element>::size_type edm::FileIndex::size ( void  ) const
inline

Definition at line 97 of file FileIndex.h.

References entries_.

Referenced by ntupleDataFormat._Collection::__iter__(), and ntupleDataFormat._Collection::__len__().

97 { return entries_.size(); }
std::vector< Element > entries_
Definition: FileIndex.h:120
void edm::FileIndex::sortBy_Run_Lumi_Event ( )

Definition at line 34 of file FileIndex.cc.

References entries_, kSorted_Run_Lumi_Event, resultCached(), sortState(), and edm::stable_sort_all().

34  {
36  resultCached() = false;
38  }
SortState & sortState() const
Definition: FileIndex.h:118
void stable_sort_all(RandomAccessSequence &s)
wrappers for std::stable_sort
Definition: Algorithms.h:103
std::vector< Element > entries_
Definition: FileIndex.h:120
bool & resultCached() const
Definition: FileIndex.h:117
void edm::FileIndex::sortBy_Run_Lumi_EventEntry ( )

Definition at line 40 of file FileIndex.cc.

References entries_, kSorted_Run_Lumi_EventEntry, resultCached(), sortState(), and edm::stable_sort_all().

40  {
41  stable_sort_all(entries_, Compare_Run_Lumi_EventEntry());
42  resultCached() = false;
44  }
SortState & sortState() const
Definition: FileIndex.h:118
void stable_sort_all(RandomAccessSequence &s)
wrappers for std::stable_sort
Definition: Algorithms.h:103
std::vector< Element > entries_
Definition: FileIndex.h:120
bool & resultCached() const
Definition: FileIndex.h:117
SortState& edm::FileIndex::sortState ( ) const
inlineprivate

Member Data Documentation

std::vector<Element> edm::FileIndex::entries_
private
Transients edm::FileIndex::transient_
mutableprivate

Definition at line 122 of file FileIndex.h.

Referenced by allInEntryOrder(), initializeTransients(), resultCached(), and sortState().