CMS 3D CMS Logo

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 20 of file FileIndex.h.

Member Typedef Documentation

Definition at line 53 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 55 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 116 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:134
Transients transient_
Definition: FileIndex.h:135
edm::FileIndex::~FileIndex ( )
inline

Definition at line 26 of file FileIndex.h.

References addEntry(), mps_splice::entry, and findQualityFiles::run.

26 {}

Member Function Documentation

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

Definition at line 29 of file FileIndex.cc.

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

Referenced by ~FileIndex().

29  {
30  entries_.emplace_back(run, lumi, event, entry);
31  resultCached() = false;
33  }
SortState & sortState() const
Definition: FileIndex.h:132
std::vector< Element > entries_
Definition: FileIndex.h:134
bool & resultCached() const
Definition: FileIndex.h:131
Definition: event.py:1
bool edm::FileIndex::allEventsInEntryOrder ( ) const

Definition at line 47 of file FileIndex.cc.

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

Referenced by empty().

47  {
48  if(!resultCached()) {
49  resultCached() = true;
51  for(std::vector<FileIndex::Element>::const_iterator it = entries_.begin(), itEnd = entries_.end(); it != itEnd; ++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:130
static EntryNumber_t const invalidEntry
Definition: FileIndex.h:34
long long EntryNumber_t
Definition: FileIndex.h:23
std::vector< Element > entries_
Definition: FileIndex.h:134
bool & resultCached() const
Definition: FileIndex.h:131
bool& edm::FileIndex::allInEntryOrder ( ) const
inlineprivate

Definition at line 130 of file FileIndex.h.

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

Referenced by allEventsInEntryOrder().

Transients transient_
Definition: FileIndex.h:135
const_iterator edm::FileIndex::begin ( void  ) const
inline

Definition at line 98 of file FileIndex.h.

References entries_.

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

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

Definition at line 102 of file FileIndex.h.

References entries_.

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

Definition at line 84 of file FileIndex.h.

References entries_, and findEventPosition().

Referenced by containsItem().

84  {
85  return findEventPosition(run, lumi, event) != entries_.end();
86  }
const_iterator findEventPosition(RunNumber_t run, LuminosityBlockNumber_t lumi, EventNumber_t event) const
Definition: FileIndex.cc:91
std::vector< Element > entries_
Definition: FileIndex.h:134
Definition: event.py:1
bool edm::FileIndex::containsItem ( RunNumber_t  run,
LuminosityBlockNumber_t  lumi,
EventNumber_t  event 
) const
inline

Definition at line 79 of file FileIndex.h.

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

79  {
80  return (event != 0) ? containsEvent(run, lumi, event) : (lumi ? containsLumi(run, lumi) : containsRun(run));
81  }
bool containsRun(RunNumber_t run) const
Definition: FileIndex.h:94
bool containsLumi(RunNumber_t run, LuminosityBlockNumber_t lumi) const
Definition: FileIndex.h:89
bool containsEvent(RunNumber_t run, LuminosityBlockNumber_t lumi, EventNumber_t event) const
Definition: FileIndex.h:84
Definition: event.py:1
bool edm::FileIndex::containsLumi ( RunNumber_t  run,
LuminosityBlockNumber_t  lumi 
) const
inline

Definition at line 89 of file FileIndex.h.

References entries_, and findLumiPosition().

Referenced by containsItem().

89  {
90  return findLumiPosition(run, lumi) != entries_.end();
91  }
const_iterator findLumiPosition(RunNumber_t run, LuminosityBlockNumber_t lumi) const
Definition: FileIndex.cc:120
std::vector< Element > entries_
Definition: FileIndex.h:134
bool edm::FileIndex::containsRun ( RunNumber_t  run) const
inline

Definition at line 94 of file FileIndex.h.

References entries_, and findRunPosition().

Referenced by containsItem().

94  {
95  return findRunPosition(run) != entries_.end();
96  }
const_iterator findRunPosition(RunNumber_t run) const
Definition: FileIndex.cc:136
std::vector< Element > entries_
Definition: FileIndex.h:134
bool edm::FileIndex::empty ( ) const
inline
const_iterator edm::FileIndex::end ( void  ) const
inline
iterator edm::FileIndex::end ( void  )
inline

Definition at line 104 of file FileIndex.h.

References entries_.

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

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

Definition at line 106 of file FileIndex.h.

References entries_.

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

Definition at line 108 of file FileIndex.h.

References entries_.

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

Definition at line 162 of file FileIndex.cc.

References entries_, findEventPosition(), kNotSorted, kSorted_Run_Lumi_EventEntry, edm::lower_bound_all(), sortState(), and mitigatedMETSequence_cff::U.

162  {
163  assert(sortState() != kNotSorted);
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) return itEnd;
177  if(lumi == 0) lumi = it->lumi_;
178  if(it->run_ != run || it->lumi_ != lumi || it->event_ != event || it->entry_ != entry) return itEnd;
179  return it;
180  }
ForwardSequence::const_iterator lower_bound_all(ForwardSequence const &s, Datum const &d)
wrappers for std::lower_bound
Definition: Algorithms.h:91
SortState & sortState() const
Definition: FileIndex.h:132
std::vector< Element >::const_iterator const_iterator
Definition: FileIndex.h:53
const_iterator findEventPosition(RunNumber_t run, LuminosityBlockNumber_t lumi, EventNumber_t event) const
Definition: FileIndex.cc:91
std::vector< Element > entries_
Definition: FileIndex.h:134
Definition: event.py:1
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().

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

Definition at line 152 of file FileIndex.cc.

References entries_, findPosition(), kLumi, kRun, and mitigatedMETSequence_cff::U.

152  {
154  const_iterator itEnd = entries_.end();
155  while(it != itEnd && it->getEntryType() != FileIndex::kLumi && it->getEntryType() != FileIndex::kRun) {
156  ++it;
157  }
158  return it;
159  }
std::vector< Element >::const_iterator const_iterator
Definition: FileIndex.h:53
std::vector< Element > entries_
Definition: FileIndex.h:134
const_iterator findPosition(RunNumber_t run, LuminosityBlockNumber_t lumi=0U, EventNumber_t event=0U) const
Definition: FileIndex.cc:67
FileIndex::const_iterator edm::FileIndex::findLumiPosition ( RunNumber_t  run,
LuminosityBlockNumber_t  lumi 
) const

Definition at line 120 of file FileIndex.cc.

References entries_, findPosition(), kLumi, and mitigatedMETSequence_cff::U.

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

120  {
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:53
std::vector< Element > entries_
Definition: FileIndex.h:134
const_iterator findPosition(RunNumber_t run, LuminosityBlockNumber_t lumi=0U, EventNumber_t event=0U) const
Definition: FileIndex.cc:67
FileIndex::const_iterator edm::FileIndex::findPosition ( RunNumber_t  run,
LuminosityBlockNumber_t  lumi = 0U,
EventNumber_t  event = 0U 
) const

Definition at line 67 of file FileIndex.cc.

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

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

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

Definition at line 136 of file FileIndex.cc.

References entries_, findPosition(), kRun, and mitigatedMETSequence_cff::U.

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

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

Definition at line 118 of file FileIndex.h.

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

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

Definition at line 110 of file FileIndex.h.

References entries_.

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

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

Definition at line 35 of file FileIndex.cc.

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

35  {
37  resultCached() = false;
39  }
SortState & sortState() const
Definition: FileIndex.h:132
void stable_sort_all(RandomAccessSequence &s)
wrappers for std::stable_sort
Definition: Algorithms.h:135
std::vector< Element > entries_
Definition: FileIndex.h:134
bool & resultCached() const
Definition: FileIndex.h:131
void edm::FileIndex::sortBy_Run_Lumi_EventEntry ( )

Definition at line 41 of file FileIndex.cc.

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

41  {
42  stable_sort_all(entries_, Compare_Run_Lumi_EventEntry());
43  resultCached() = false;
45  }
SortState & sortState() const
Definition: FileIndex.h:132
void stable_sort_all(RandomAccessSequence &s)
wrappers for std::stable_sort
Definition: Algorithms.h:135
std::vector< Element > entries_
Definition: FileIndex.h:134
bool & resultCached() const
Definition: FileIndex.h:131
SortState& edm::FileIndex::sortState ( ) const
inlineprivate

Member Data Documentation

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

Definition at line 135 of file FileIndex.h.

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