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
 
iterator begin ()
 
const_iterator begin () const
 
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
 
iterator end ()
 
const_iterator end () const
 
iterator erase (iterator begin, iterator end)
 
iterator erase (iterator pos)
 
 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

◆ const_iterator

Definition at line 49 of file FileIndex.h.

◆ EntryNumber_t

typedef long long edm::FileIndex::EntryNumber_t

Definition at line 23 of file FileIndex.h.

◆ iterator

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

Definition at line 51 of file FileIndex.h.

Member Enumeration Documentation

◆ EntryType

Enumerator
kRun 
kLumi 
kEvent 
kEnd 

Definition at line 30 of file FileIndex.h.

30 { kRun, kLumi, kEvent, kEnd };

◆ SortState

Enumerator
kNotSorted 
kSorted_Run_Lumi_Event 
kSorted_Run_Lumi_EventEntry 

Definition at line 103 of file FileIndex.h.

Constructor & Destructor Documentation

◆ FileIndex()

edm::FileIndex::FileIndex ( )

Definition at line 10 of file FileIndex.cc.

10 : entries_(), transient_() {}

◆ ~FileIndex()

edm::FileIndex::~FileIndex ( )
inline

Definition at line 26 of file FileIndex.h.

26 {}

Member Function Documentation

◆ addEntry()

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

Definition at line 28 of file FileIndex.cc.

28  {
29  entries_.emplace_back(run, lumi, event, entry);
30  resultCached() = false;
32  }

References entries_, mps_splice::entry, kNotSorted, resultCached(), writedatasetfile::run, and sortState().

◆ allEventsInEntryOrder()

bool edm::FileIndex::allEventsInEntryOrder ( ) const

Definition at line 46 of file FileIndex.cc.

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  }

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

◆ allInEntryOrder()

bool& edm::FileIndex::allInEntryOrder ( ) const
inlineprivate

Definition at line 116 of file FileIndex.h.

116 { return transient_.allInEntryOrder_; }

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

Referenced by allEventsInEntryOrder().

◆ begin() [1/2]

iterator edm::FileIndex::begin ( void  )
inline

Definition at line 89 of file FileIndex.h.

89 { return entries_.begin(); }

References entries_.

◆ begin() [2/2]

const_iterator edm::FileIndex::begin ( void  ) const
inline

Definition at line 85 of file FileIndex.h.

85 { return entries_.begin(); }

References entries_.

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

◆ containsEvent()

bool edm::FileIndex::containsEvent ( RunNumber_t  run,
LuminosityBlockNumber_t  lumi,
EventNumber_t  event 
) const
inline

Definition at line 75 of file FileIndex.h.

75  {
76  return findEventPosition(run, lumi, event) != entries_.end();
77  }

References entries_, findEventPosition(), and writedatasetfile::run.

Referenced by containsItem().

◆ containsItem()

bool edm::FileIndex::containsItem ( RunNumber_t  run,
LuminosityBlockNumber_t  lumi,
EventNumber_t  event 
) const
inline

Definition at line 71 of file FileIndex.h.

71  {
72  return (event != 0) ? containsEvent(run, lumi, event) : (lumi ? containsLumi(run, lumi) : containsRun(run));
73  }

References containsEvent(), containsLumi(), containsRun(), and writedatasetfile::run.

◆ containsLumi()

bool edm::FileIndex::containsLumi ( RunNumber_t  run,
LuminosityBlockNumber_t  lumi 
) const
inline

Definition at line 79 of file FileIndex.h.

79  {
80  return findLumiPosition(run, lumi) != entries_.end();
81  }

References entries_, findLumiPosition(), and writedatasetfile::run.

Referenced by containsItem().

◆ containsRun()

bool edm::FileIndex::containsRun ( RunNumber_t  run) const
inline

Definition at line 83 of file FileIndex.h.

83 { return findRunPosition(run) != entries_.end(); }

References entries_, findRunPosition(), and writedatasetfile::run.

Referenced by containsItem().

◆ empty()

bool edm::FileIndex::empty ( ) const
inline

Definition at line 99 of file FileIndex.h.

99 { return entries_.empty(); }

References entries_.

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

◆ end() [1/2]

iterator edm::FileIndex::end ( void  )
inline

Definition at line 91 of file FileIndex.h.

91 { return entries_.end(); }

References entries_.

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

◆ end() [2/2]

const_iterator edm::FileIndex::end ( void  ) const
inline

◆ erase() [1/2]

iterator edm::FileIndex::erase ( iterator  begin,
iterator  end 
)
inline

Definition at line 95 of file FileIndex.h.

95 { return entries_.erase(begin, end); }

References begin(), end(), and entries_.

◆ erase() [2/2]

iterator edm::FileIndex::erase ( iterator  pos)
inline

Definition at line 93 of file FileIndex.h.

93 { return entries_.erase(pos); }

References entries_.

◆ findEventEntryPosition()

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.

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  }

References cms::cuda::assert(), entries_, mps_splice::entry, findEventPosition(), kNotSorted, kSorted_Run_Lumi_EventEntry, edm::lower_bound_all(), writedatasetfile::run, sortState(), and mitigatedMETSequence_cff::U.

◆ findEventPosition()

FileIndex::const_iterator edm::FileIndex::findEventPosition ( RunNumber_t  run,
LuminosityBlockNumber_t  lumi,
EventNumber_t  event 
) const

Definition at line 91 of file FileIndex.cc.

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  }

References entries_, findPosition(), kEvent, kSorted_Run_Lumi_Event, writedatasetfile::run, and sortState().

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

◆ findLumiOrRunPosition()

FileIndex::const_iterator edm::FileIndex::findLumiOrRunPosition ( RunNumber_t  run,
LuminosityBlockNumber_t  lumi 
) const

Definition at line 150 of file FileIndex.cc.

150  {
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  }

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

◆ findLumiPosition()

FileIndex::const_iterator edm::FileIndex::findLumiPosition ( RunNumber_t  run,
LuminosityBlockNumber_t  lumi 
) const

Definition at line 120 of file FileIndex.cc.

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  }

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

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

◆ findPosition()

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.

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  }

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

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

◆ findRunPosition()

FileIndex::const_iterator edm::FileIndex::findRunPosition ( RunNumber_t  run) const

Definition at line 135 of file FileIndex.cc.

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  }

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

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

◆ initializeTransients()

void edm::FileIndex::initializeTransients ( ) const
inline

Definition at line 105 of file FileIndex.h.

105 { transient_.reset(); }

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

◆ resultCached()

bool& edm::FileIndex::resultCached ( ) const
inlineprivate

◆ size()

std::vector<Element>::size_type edm::FileIndex::size ( void  ) const
inline

Definition at line 97 of file FileIndex.h.

97 { return entries_.size(); }

References entries_.

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

◆ sortBy_Run_Lumi_Event()

void edm::FileIndex::sortBy_Run_Lumi_Event ( )

Definition at line 34 of file FileIndex.cc.

34  {
36  resultCached() = false;
38  }

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

◆ sortBy_Run_Lumi_EventEntry()

void edm::FileIndex::sortBy_Run_Lumi_EventEntry ( )

Definition at line 40 of file FileIndex.cc.

40  {
41  stable_sort_all(entries_, Compare_Run_Lumi_EventEntry());
42  resultCached() = false;
44  }

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

◆ sortState()

SortState& edm::FileIndex::sortState ( ) const
inlineprivate

Member Data Documentation

◆ entries_

std::vector<Element> edm::FileIndex::entries_
private

◆ transient_

Transients edm::FileIndex::transient_
mutableprivate

Definition at line 122 of file FileIndex.h.

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

edm::FileIndex::sortState
SortState & sortState() const
Definition: FileIndex.h:118
edm::FileIndex::findLumiPosition
const_iterator findLumiPosition(RunNumber_t run, LuminosityBlockNumber_t lumi) const
Definition: FileIndex.cc:120
edm::FileIndex::kRun
Definition: FileIndex.h:30
edm::FileIndex::findEventPosition
const_iterator findEventPosition(RunNumber_t run, LuminosityBlockNumber_t lumi, EventNumber_t event) const
Definition: FileIndex.cc:91
edm::FileIndex::resultCached
bool & resultCached() const
Definition: FileIndex.h:117
mps_splice.entry
entry
Definition: mps_splice.py:68
pos
Definition: PixelAliasList.h:18
edm::FileIndex::entries_
std::vector< Element > entries_
Definition: FileIndex.h:120
edm::FileIndex::kNotSorted
Definition: FileIndex.h:103
cms::cuda::assert
assert(be >=bs)
edm::FileIndex::kEnd
Definition: FileIndex.h:30
edm::FileIndex::kSorted_Run_Lumi_EventEntry
Definition: FileIndex.h:103
edm::FileIndex::begin
const_iterator begin() const
Definition: FileIndex.h:85
edm::FileIndex::Transients::reset
void reset()
Definition: FileIndex.cc:22
edm::FileIndex::containsLumi
bool containsLumi(RunNumber_t run, LuminosityBlockNumber_t lumi) const
Definition: FileIndex.h:79
edm::FileIndex::EntryNumber_t
long long EntryNumber_t
Definition: FileIndex.h:23
edm::FileIndex::end
const_iterator end() const
Definition: FileIndex.h:87
mitigatedMETSequence_cff.U
U
Definition: mitigatedMETSequence_cff.py:36
edm::FileIndex::const_iterator
std::vector< Element >::const_iterator const_iterator
Definition: FileIndex.h:49
edm::FileIndex::kLumi
Definition: FileIndex.h:30
edm::FileIndex::containsEvent
bool containsEvent(RunNumber_t run, LuminosityBlockNumber_t lumi, EventNumber_t event) const
Definition: FileIndex.h:75
edm::FileIndex::allInEntryOrder
bool & allInEntryOrder() const
Definition: FileIndex.h:116
edm::FileIndex::findPosition
const_iterator findPosition(RunNumber_t run, LuminosityBlockNumber_t lumi=0U, EventNumber_t event=0U) const
Definition: FileIndex.cc:66
edm::FileIndex::Transients::sortState_
SortState sortState_
Definition: FileIndex.h:112
edm::lower_bound_all
ForwardSequence::const_iterator lower_bound_all(ForwardSequence const &s, Datum const &d)
wrappers for std::lower_bound
Definition: Algorithms.h:69
edm::FileIndex::Element::invalidEntry
static const EntryNumber_t invalidEntry
Definition: FileIndex.h:34
edm::FileIndex::containsRun
bool containsRun(RunNumber_t run) const
Definition: FileIndex.h:83
writedatasetfile.run
run
Definition: writedatasetfile.py:27
edm::FileIndex::kSorted_Run_Lumi_Event
Definition: FileIndex.h:103
edm::FileIndex::findRunPosition
const_iterator findRunPosition(RunNumber_t run) const
Definition: FileIndex.cc:135
edm::FileIndex::kEvent
Definition: FileIndex.h:30
edm::stable_sort_all
void stable_sort_all(RandomAccessSequence &s)
wrappers for std::stable_sort
Definition: Algorithms.h:103
edm::FileIndex::transient_
Transients transient_
Definition: FileIndex.h:122
event
Definition: event.py:1
edm::FileIndex::Transients::allInEntryOrder_
bool allInEntryOrder_
Definition: FileIndex.h:110
edm::FileIndex::Transients::resultCached_
bool resultCached_
Definition: FileIndex.h:111
lumi
Definition: LumiSectionData.h:20