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 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.

◆ 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_() {}
std::vector< Element > entries_
Definition: FileIndex.h:120
Transients transient_
Definition: FileIndex.h:122

◆ ~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.

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

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

◆ allEventsInEntryOrder()

bool edm::FileIndex::allEventsInEntryOrder ( ) const

Definition at line 46 of file FileIndex.cc.

References allInEntryOrder(), entries_, edm::FileIndex::Element::invalidEntry, ALPAKA_ACCELERATOR_NAMESPACE::vertexFinder::it, 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 & resultCached() const
Definition: FileIndex.h:117
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 & allInEntryOrder() const
Definition: FileIndex.h:116

◆ allInEntryOrder()

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

◆ begin() [1/2]

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

Definition at line 85 of file FileIndex.h.

References entries_.

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

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

◆ begin() [2/2]

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

◆ containsEvent()

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_, findEventPosition(), and writedatasetfile::run.

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
std::vector< Element > entries_
Definition: FileIndex.h:120
Definition: event.py:1

◆ containsItem()

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(), containsRun(), and writedatasetfile::run.

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

◆ containsLumi()

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

Definition at line 79 of file FileIndex.h.

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

Referenced by containsItem().

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

◆ containsRun()

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

Definition at line 83 of file FileIndex.h.

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

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

◆ empty()

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

◆ end() [1/2]

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

◆ end() [2/2]

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

◆ erase() [1/2]

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

◆ erase() [2/2]

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

Definition at line 95 of file FileIndex.h.

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

95 { return entries_.erase(begin, end); }
const_iterator end() const
Definition: FileIndex.h:87
const_iterator begin() const
Definition: FileIndex.h:85
std::vector< Element > entries_
Definition: FileIndex.h:120

◆ 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.

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

162  {
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
const_iterator findEventPosition(RunNumber_t run, LuminosityBlockNumber_t lumi, EventNumber_t event) const
Definition: FileIndex.cc:91
assert(be >=bs)
std::vector< Element >::const_iterator const_iterator
Definition: FileIndex.h:49
std::vector< Element > entries_
Definition: FileIndex.h:120
SortState & sortState() const
Definition: FileIndex.h:118
Definition: event.py:1

◆ 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.

References entries_, findPosition(), ALPAKA_ACCELERATOR_NAMESPACE::vertexFinder::it, kEvent, kSorted_Run_Lumi_Event, writedatasetfile::run, 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  }
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
SortState & sortState() const
Definition: FileIndex.h:118
Definition: event.py:1

◆ findLumiOrRunPosition()

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

Definition at line 150 of file FileIndex.cc.

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

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

◆ findLumiPosition()

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

Definition at line 120 of file FileIndex.cc.

References entries_, findPosition(), ALPAKA_ACCELERATOR_NAMESPACE::vertexFinder::it, kLumi, writedatasetfile::run, 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: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

◆ 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.

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

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

68  {
70 
71  const_iterator itEnd = entries_.end();
73  Element el(run, lumi, event);
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
assert(be >=bs)
std::vector< Element >::const_iterator const_iterator
Definition: FileIndex.h:49
std::vector< Element > entries_
Definition: FileIndex.h:120
SortState & sortState() const
Definition: FileIndex.h:118
Definition: event.py:1

◆ findRunPosition()

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

Definition at line 135 of file FileIndex.cc.

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

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

135  {
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

◆ initializeTransients()

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

◆ 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.

References entries_.

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

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

◆ sortBy_Run_Lumi_Event()

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  }
bool & resultCached() const
Definition: FileIndex.h:117
void stable_sort_all(RandomAccessSequence &s)
wrappers for std::stable_sort
Definition: Algorithms.h:103
std::vector< Element > entries_
Definition: FileIndex.h:120
SortState & sortState() const
Definition: FileIndex.h:118

◆ sortBy_Run_Lumi_EventEntry()

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  }
bool & resultCached() const
Definition: FileIndex.h:117
void stable_sort_all(RandomAccessSequence &s)
wrappers for std::stable_sort
Definition: Algorithms.h:103
std::vector< Element > entries_
Definition: FileIndex.h:120
SortState & sortState() const
Definition: FileIndex.h:118

◆ 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().