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 | Static Public Attributes | Private Member Functions | Private Attributes | Friends
edm::IndexIntoFile Class Reference

#include <IndexIntoFile.h>

Classes

class  EventEntry
 
class  EventFinder
 
class  IndexIntoFileItr
 
class  IndexIntoFileItrEntryOrder
 
class  IndexIntoFileItrImpl
 
class  IndexIntoFileItrNoSort
 
class  IndexIntoFileItrSorted
 
class  IndexRunKey
 
class  IndexRunLumiEventKey
 
class  IndexRunLumiKey
 
class  RunOrLumiEntry
 
class  RunOrLumiIndexes
 
class  SortedRunOrLumiItr
 
struct  Transients
 

Public Types

using EntryNumber_t = long long
 
enum  EntryType { kRun, kLumi, kEvent, kEnd }
 
enum  SortOrder { numericalOrder, firstAppearanceOrder, entryOrder }
 

Public Member Functions

void addEntry (ProcessHistoryID const &processHistoryID, RunNumber_t run, LuminosityBlockNumber_t lumi, EventNumber_t event, EntryNumber_t entry)
 
void addLumi (int index, RunNumber_t run, LuminosityBlockNumber_t lumi, EntryNumber_t entry)
 
IndexIntoFileItr begin (SortOrder sortOrder) const
 
SortedRunOrLumiItr beginRunOrLumi () const
 
bool containsDuplicateEvents () const
 Returns true if the IndexIntoFile contains 2 events with the same ProcessHistoryID index, run number, lumi number and event number. More...
 
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
 
void doneFileInitialization ()
 Clears the temporary vector of event numbers to reduce memory usage. More...
 
bool empty () const
 True if no runs, lumis, or events are in the file. More...
 
IndexIntoFileItr end (SortOrder sortOrder) const
 Used to end an iteration over the Runs, Lumis, and Events in a file. More...
 
SortedRunOrLumiItr endRunOrLumi () const
 
void fillEventEntries () const
 
void fillEventNumbers () const
 
void fillEventNumbersOrEntries (bool needEventNumbers, bool needEventEntries) const
 
IndexIntoFileItr findEventPosition (RunNumber_t run, LuminosityBlockNumber_t lumi, EventNumber_t event) const
 
IndexIntoFileItr findLumiPosition (RunNumber_t run, LuminosityBlockNumber_t lumi) const
 
IndexIntoFileItr findPosition (RunNumber_t run, LuminosityBlockNumber_t lumi=0U, EventNumber_t event=0U) const
 
IndexIntoFileItr findPosition (SortOrder sortOrder, RunNumber_t run, LuminosityBlockNumber_t lumi=0U, EventNumber_t event=0U) const
 
IndexIntoFileItr findRunPosition (RunNumber_t run) const
 Same as findPosition. More...
 
void fixIndexes (std::vector< ProcessHistoryID > &processHistoryIDs)
 
 IndexIntoFile ()
 
void initializeTransients ()
 
void inputFileClosed ()
 
bool iterationWillBeInEntryOrder (SortOrder sortOrder) const
 Used to determine whether or not to disable fast cloning. More...
 
ProcessHistoryID const & processHistoryID (int i) const
 
std::vector< ProcessHistoryID >
const & 
processHistoryIDs () const
 
void reduceProcessHistoryIDs (ProcessHistoryRegistry const &processHistoryRegistry)
 
std::vector< RunOrLumiEntry >
const & 
runOrLumiEntries () const
 Used internally and for test purposes. More...
 
void set_intersection (IndexIntoFile const &indexIntoFile, std::set< IndexRunLumiEventKey > &intersection) const
 
void setEventFinder (std::shared_ptr< EventFinder > ptr)
 
void setNumberOfEvents (EntryNumber_t nevents)
 
std::vector< ProcessHistoryID > & setProcessHistoryIDs ()
 
std::vector< RunOrLumiEntry > & setRunOrLumiEntries ()
 
void sortVector_Run_Or_Lumi_Entries ()
 
std::vector< EventNumber_t > & unsortedEventNumbers ()
 
std::vector< EventNumber_t >
const & 
unsortedEventNumbers () const
 
 ~IndexIntoFile ()
 

Static Public Attributes

static constexpr EntryNumber_t continuedLumi = -2LL
 
static constexpr EntryNumber_t invalidEntry = -1LL
 
static constexpr EventNumber_t invalidEvent = 0U
 
static constexpr int invalidIndex = -1
 
static constexpr
LuminosityBlockNumber_t 
invalidLumi = 0U
 
static constexpr RunNumber_t invalidRun = 0U
 

Private Member Functions

EntryNumber_tbeginEvents () const
 
int & currentIndex () const
 
LuminosityBlockNumber_tcurrentLumi () const
 
RunNumber_tcurrentRun () const
 
EntryNumber_tendEvents () const
 
std::vector< EventEntry > & eventEntries () const
 
std::vector< EventNumber_t > & eventNumbers () const
 
void fillRunOrLumiIndexes () const
 
void fillUnsortedEventNumbers () const
 
EventNumber_t getEventNumberOfEntry (EntryNumber_t entry) const
 
std::map< IndexRunLumiKey,
EntryNumber_t > & 
lumiToOrder () const
 
size_t numberOfEvents () const
 
int & previousAddedIndex () const
 
void resetEventFinder () const
 
std::vector< RunOrLumiIndexes > & runOrLumiIndexes () const
 
std::map< IndexRunKey,
EntryNumber_t > & 
runToOrder () const
 
void sortEventEntries () const
 
void sortEvents () const
 
std::vector< EventNumber_t > & unsortedEventNumbersMutable () const
 

Private Attributes

std::vector< ProcessHistoryIDprocessHistoryIDs_
 
std::vector< RunOrLumiEntryrunOrLumiEntries_
 
Transients transient_
 

Friends

class ::TestIndexIntoFile
 
class ::TestIndexIntoFile1
 
class ::TestIndexIntoFile2
 
class ::TestIndexIntoFile3
 
class ::TestIndexIntoFile4
 
class ::TestIndexIntoFile5
 

Detailed Description

Used to quickly find the Events, Lumis, and Runs in a single ROOT format data file and step through them in the desired order.

A list of the most important functions that a client would use directly follows. There are detailed comments below with the declaration of each function.

The begin and end functions are used to start and stop an iteration loop. An argument to the iterator constructor determines the order of iteration.

The functions findPosition, findEventPosition, findRunPosition, and findLumiPosition are used to navigate directly to specific runs, lumis, and events.

The functions mentioned above return an object of type IndexIntoFileItr. The IndexIntoFileItr class has member functions which allow one to navigate forward and backward through the runs, lumis, and events in alternative ways. See more comments with the declaration of each public member function in IndexIntoFileItr.

The iterator will know what the current item is (as one would expect). This could be a run, lumi, or event. It knows more than that though, it knows all three as is explained below.

In the run state, IndexIntoFileItr knows which lumi will be processed next after the run and also which event will be processed after the lumi. These may not be the first ones in the run if the skip functions were used.

In the lumi state, the IndexIntoFileItr will always point at the last associated run and the next event to be processed after the lumi. This may not be the first event if the skip function was used.

In the event state, the IndexIntoFileItr will always point at the last corresponding run and also the last corresponding lumi.

There can be multiple run entries in a TTree associated with the same run number and ProcessHistoryID in a file. There can also be multiple lumi entries associated with the same lumi number, run number, and ProcessHistoryID. Both sorting orders will make these subgroups contiguous, but beyond that is up to the client (normally PoolSource, which passes them up to the EventProcessor) to deal with merging the multiple run (or lumi) entries together.

One final comment with regards to IndexIntoFileItr. This is not an STL iterator and it cannot be used with std:: algorithms. The data structures are complex and designed to optimize memory usage. It would be difficult or impossible implement an iterator that is STL compliant.

Here is a summary of the data structures in IndexIntoFile. The persistent data consists of two vectors.

processHistoryIDs_ is a std::vector<ProcessHistoryID> that contains the ProcessHistoryIDs with one element in the vector for each unique ProcessHistoryID. On output they are ordered as they first written out for each output file. On input they are ordered as they are first seen in each process. Note that each ProcessHistoryID is stored once in this separate vector. Everywhere else it is needed it stored as an index into this vector because the ProcessHistoryID itself is large and it would take more memory to store them repeatedly in the other vectors. Note that the ProcessHistoryID's referenced in this class are always the "reduced" ProcessHistoryID's, not the ProcessHistoryID of the full ProcessHistory. You cannot use them to directly access the ProcessHistory from the ProcessHistoryRegistry.

runOrLumiEntries_ is a std::vector<RunOrLumiEntry>. This vector holds one element per entry in the run TTree and one element per entry in the lumi TTree. When sorted, everything associated with a given run and ProcessHistoryID will be contiguous in the vector. These groups of elements will be sorted in the order they first appear in the input file. Within each of these groups the run entries come first in order, followed by the elements associated with the lumis. The lumis are also contiguous and sorted by first appearance in the input file. Within a lumi they are sorted by entry order. And each luminosity element corresponds to one contiguous sequence of Events in the Events TTree. Before we implemented concurrent processing of luminosity blocks that was the full story. After that it became more complicated because the sequence of events written to an output file that were associated with a particular luminosity block TTree entry might no longer be contiguous. Events from another concurrent luminosity block could get mixed in because with multiple events processing simultaneously, there is no longer any guarantee they will finish in the same order that they were read. This is handled by writing additional elements to the runOrLumiEntries_ vector, one for each contiguous block of events associated with a particular luminosity block. Only one of these vector elements will be associated with each entry in the luminosity block TTree and all the others will contain a TTree entry number that is invalid (note the one element with a valid entry might or might not be associated with a contiguous block of events). In the sort of elements related to a particular luminosity block, the entries with invalid entry numbers will come before the valid ones. (It has not happened yet as I am writing this, but a similar thing will likely occur for runs if/when we ever implement concurrent runs)

There are a number of transient data members also. The 3 most important of these are vectors. To save memory, these are only filled when needed.

runOrLumiIndexes_ is a std::vector<RunOrLumiIndexes>. There is a one to one correspondence between the elements of this vector and the elements of runOrLumiEntries_. The elements of this vector are sorted in numerical order using the ProcessHistoryID index, the run number, and the lumi number. This ordering allows iteration in numerical order and also fast lookup based on run number and lumi number. Each element also has indexes into the eventNumbers_ and eventEntries_ vectors which hold the information giving the event numbers and event entry numbers. Note this vector is initially formed in the identical order as runOrLumiEntries_ and then sorted with a stable sort. The fact that it is a stable sort means that within the subrange associated with a particular luminosity block the elements with an invalid TTree entry number come first and the later come the elements with a valid TTree entry number which are in order of TTree entry number.

eventNumbers_ is a std::vector containing EventNumber_t's. eventEntries_ is a std::vector containing EventEntry's. If filled, both vectors contain the same number of entries with identical event numbers sorted in the same order. The only difference is that one includes the entry numbers and thus takes more memory. Each element of runOrLumiIndexes_ associated with a luminosity block has the indexes necessary to find the range inside eventNumbers_ or eventEntries_ corresponding to its lumi. Within that range the elements are sorted by event number, which is used for the numerical order iteration and to find an event by the event number.

The details of the data structure are a little different when reading files written before release 3_8_0 (backward compatibility, see RootFile::fillIndexIntoFile for the details).

This data structure is optimized for low memory usage when there are large numbers of events. The optimal case would occur when there was was one run in a file, one luminosity block in that run and everything had the same ProcessHistoryID. If duplicate checking were off and the process simply iterated through the file in the default order, then only the persistent vectors would be filled. One vector would contain 2 elements, one for the run and the other for the lumi. The other vector would contain one element, the ProcessHistoryID. Even if there were a billion events, that would be all that would exist and take up memory. The data structure is not the optimal structure for a very sparse skim, but the overheads should be tolerable given the number of runs and luminosity blocks that should occur in CMS data.

Normally only the persistent parts of the data structure are filled in the output module. The output module fills them using two functions designed specifically for that purpose. The functions are addEntry and sortVector_Run_Or_Lumi_Entries.

There are some complexities associated with filling the data structure, mostly revolving around optimizations to minimize the per event memory usage. The client needs to know which parts of the data structure to fill. See the functions below named fixIndexes, setNumberOfEvents, setEventFinder, fillEventNumbers, fillEventEntries, and inputFileClosed.

Note that this class is not intended to be used directly by the average CMS user. PoolSource and PoolOutputModule are the main clients. Other executables that read ROOT format data files, but do not use PoolSource may also need to use it directly (FWLite, Fireworks, edmFileUtil ...). The interface is too complex for general use.

Author
W. David Dagenhart, created 19 May, 2010

Definition at line 225 of file IndexIntoFile.h.

Member Typedef Documentation

Definition at line 231 of file IndexIntoFile.h.

Member Enumeration Documentation

This enum is used to specify the order of iteration. In firstAppearanceOrder there are 3 sort criteria, in order of precedence these are:

  1. firstAppearance of the ProcessHistoryID and run number in the file
  2. firstAppearance of the ProcessHistoryID, run number and lumi number in the file
  3. entry number

In numerical order the criteria are in order of precedence are:

  1. processHistoryID index (which are normally in order of appearance in the process)
  2. run number
  3. lumi number
  4. event number
  5. entry number
Enumerator
numericalOrder 
firstAppearanceOrder 
entryOrder 

Definition at line 267 of file IndexIntoFile.h.

Constructor & Destructor Documentation

edm::IndexIntoFile::IndexIntoFile ( )

Definition at line 51 of file IndexIntoFile.cc.

std::vector< RunOrLumiEntry > runOrLumiEntries_
std::vector< ProcessHistoryID > processHistoryIDs_
edm::IndexIntoFile::~IndexIntoFile ( )

Definition at line 53 of file IndexIntoFile.cc.

53 {}

Member Function Documentation

void edm::IndexIntoFile::addEntry ( ProcessHistoryID const &  processHistoryID,
RunNumber_t  run,
LuminosityBlockNumber_t  lumi,
EventNumber_t  event,
EntryNumber_t  entry 
)

Used by RootOutputModule to fill the persistent data. This will not work properly if entries are not added in the same order as in RootOutputModule

Definition at line 75 of file IndexIntoFile.cc.

References addLumi(), cms::cuda::assert(), beginEvents(), currentIndex(), currentLumi(), currentRun(), endEvents(), mps_splice::entry, Exception, invalidEntry, invalidEvent, invalidIndex, invalidLumi, invalidRun, edm::errors::LogicError, dqmdumpme::lumi, numberOfEvents(), previousAddedIndex(), processHistoryIDs_, submitPVValidationJobs::run, runOrLumiEntries_, runToOrder(), and setNumberOfEvents().

Referenced by edm::RootOutputFile::writeLuminosityBlock(), edm::RootOutputFile::writeOne(), and edm::RootOutputFile::writeRun().

79  {
80  int index = 0;
81  // First see if the ProcessHistoryID is the same as the previous one.
82  // This is just a performance optimization. We expect to usually get
83  // many in a row that are the same.
85  index = previousAddedIndex();
86  } else {
87  // If it was not the same as the previous one then search through the
88  // entire vector. If it is not there, it needs to be added at the
89  // end.
90  index = 0;
91  while (index < static_cast<int>(processHistoryIDs_.size()) && processHistoryIDs_[index] != processHistoryID) {
92  ++index;
93  }
94  if (index == static_cast<int>(processHistoryIDs_.size())) {
96  }
97  }
99 
100  assert((currentRun() == run && currentIndex() == index) || currentRun() == invalidRun);
101  if (lumi == invalidLumi) {
102  if (currentLumi() != invalidLumi) {
104  << "In IndexIntoFile::addEntry. Entries were added in illegal order.\n"
105  << "This means the IndexIntoFile product in the output file will be corrupted.\n"
106  << "The output file will be unusable for most purposes.\n"
107  << "If this occurs after an unrelated exception was thrown in\n"
108  << "endLuminosityBlock or endRun then ignore this exception and fix\n"
109  << "the primary exception. This is an expected side effect.\n"
110  << "Otherwise please report this to the core framework developers\n";
111  }
115  // assign each run an order value when first seen (using entry but any increasing value would work)
116  std::pair<IndexRunKey, EntryNumber_t> keyAndOrder(IndexRunKey(index, run), entry);
117  runToOrder().insert(keyAndOrder); // Does nothing if this key was already inserted
118  runOrLumiEntries_.emplace_back(
119  runToOrder()[IndexRunKey(index, run)], invalidEntry, entry, index, run, lumi, invalidEntry, invalidEntry);
120  } else {
121  if (currentRun() == invalidRun) {
122  currentRun() = run;
123  currentIndex() = index;
124  }
125  if (event == invalidEvent) {
126  if (currentLumi() != lumi and currentLumi() != invalidLumi) {
127  //we have overlapping lumis so must inject a placeholder
128  addLumi(index, run, currentLumi(), invalidEntry);
129  }
131  addLumi(index, run, lumi, entry);
132  } else {
133  if (currentLumi() != lumi and currentLumi() != invalidLumi) {
134  //We have overlapping lumis so need to inject a placeholder
135  addLumi(index, run, currentLumi(), invalidEntry);
136  }
138  if (beginEvents() == invalidEntry) {
139  currentLumi() = lumi;
140  beginEvents() = entry;
141  endEvents() = beginEvents() + 1;
142  } else {
143  assert(currentLumi() == lumi);
144  assert(entry == endEvents());
145  ++endEvents();
146  }
147  }
148  }
149  }
RunNumber_t & currentRun() const
static constexpr int invalidIndex
void addLumi(int index, RunNumber_t run, LuminosityBlockNumber_t lumi, EntryNumber_t entry)
LuminosityBlockNumber_t & currentLumi() const
assert(be >=bs)
static constexpr EventNumber_t invalidEvent
int & previousAddedIndex() const
void setNumberOfEvents(EntryNumber_t nevents)
size_t numberOfEvents() const
int & currentIndex() const
static constexpr RunNumber_t invalidRun
std::vector< RunOrLumiEntry > runOrLumiEntries_
std::vector< ProcessHistoryID > processHistoryIDs_
list lumi
Definition: dqmdumpme.py:53
static constexpr EntryNumber_t invalidEntry
static constexpr LuminosityBlockNumber_t invalidLumi
ProcessHistoryID const & processHistoryID(int i) const
std::map< IndexRunKey, EntryNumber_t > & runToOrder() const
list entry
Definition: mps_splice.py:68
EntryNumber_t & endEvents() const
EntryNumber_t & beginEvents() const
void edm::IndexIntoFile::addLumi ( int  index,
RunNumber_t  run,
LuminosityBlockNumber_t  lumi,
EntryNumber_t  entry 
)

Definition at line 59 of file IndexIntoFile.cc.

References beginEvents(), endEvents(), invalidEntry, lumiToOrder(), runOrLumiEntries_, and findQualityFiles::size.

Referenced by addEntry().

59  {
60  // assign each lumi an order value sequentially when first seen
61  std::pair<IndexRunLumiKey, EntryNumber_t> keyAndOrder(IndexRunLumiKey(index, run, lumi), lumiToOrder().size());
62  lumiToOrder().insert(keyAndOrder); // does nothing if this key already was inserted
63  runOrLumiEntries_.emplace_back(invalidEntry,
64  lumiToOrder()[IndexRunLumiKey(index, run, lumi)],
65  entry,
66  index,
67  run,
68  lumi,
69  beginEvents(),
70  endEvents());
73  }
std::map< IndexRunLumiKey, EntryNumber_t > & lumiToOrder() const
std::vector< RunOrLumiEntry > runOrLumiEntries_
list lumi
Definition: dqmdumpme.py:53
static constexpr EntryNumber_t invalidEntry
list entry
Definition: mps_splice.py:68
EntryNumber_t & endEvents() const
EntryNumber_t & beginEvents() const
tuple size
Write out results.
IndexIntoFile::IndexIntoFileItr edm::IndexIntoFile::begin ( SortOrder  sortOrder) const

Used to start an iteration over the Runs, Lumis, and Events in a file. Note the argument specifies the order

Definition at line 461 of file IndexIntoFile.cc.

References empty(), end(), edm::IndexIntoFile::IndexIntoFileItr::initializeRun(), invalidIndex, and kRun.

Referenced by containsDuplicateEvents(), findPosition(), iterationWillBeInEntryOrder(), edm::postIndexIntoFilePrintEventLists(), edm::postIndexIntoFilePrintEventsInLumis(), edm::RootFile::RootFile(), set_intersection(), sortEventEntries(), and sortEvents().

461  {
462  if (empty()) {
463  return end(sortOrder);
464  }
465  IndexIntoFileItr iter(this, sortOrder, kRun, 0, invalidIndex, invalidIndex, 0, 0);
466  iter.initializeRun();
467  return iter;
468  }
static constexpr int invalidIndex
bool empty() const
True if no runs, lumis, or events are in the file.
IndexIntoFileItr end(SortOrder sortOrder) const
Used to end an iteration over the Runs, Lumis, and Events in a file.
EntryNumber_t& edm::IndexIntoFile::beginEvents ( ) const
inlineprivate
IndexIntoFile::SortedRunOrLumiItr edm::IndexIntoFile::beginRunOrLumi ( ) const

Definition at line 710 of file IndexIntoFile.cc.

Referenced by containsDuplicateEvents(), fillEventNumbersOrEntries(), and set_intersection().

710 { return SortedRunOrLumiItr(this, 0); }
bool edm::IndexIntoFile::containsDuplicateEvents ( ) const

Returns true if the IndexIntoFile contains 2 events with the same ProcessHistoryID index, run number, lumi number and event number.

Definition at line 818 of file IndexIntoFile.cc.

References begin(), edm::IndexIntoFile::RunOrLumiIndexes::beginEventNumbers(), beginRunOrLumi(), empty(), edm::IndexIntoFile::RunOrLumiIndexes::endEventNumbers(), endRunOrLumi(), eventEntries(), eventNumbers(), fillEventNumbers(), edm::IndexIntoFile::RunOrLumiIndexes::isRun(), and dqmdumpme::last.

Referenced by edm::DuplicateChecker::inputFileOpened().

818  {
819  RunOrLumiIndexes const* previousIndexes = nullptr;
820 
821  for (SortedRunOrLumiItr iter = beginRunOrLumi(), iEnd = endRunOrLumi(); iter != iEnd; ++iter) {
822  RunOrLumiIndexes const& indexes = iter.runOrLumiIndexes();
823 
824  // Skip it if it is a run or the same lumi
825  if (indexes.isRun() || (previousIndexes && !(*previousIndexes < indexes))) {
826  continue;
827  }
828  previousIndexes = &indexes;
829 
830  long long beginEventNumbers = indexes.beginEventNumbers();
831  long long endEventNumbers = indexes.endEventNumbers();
832 
833  // there must be more than 1 event in the lumi for there to be any duplicates
834  if (beginEventNumbers + 1 >= endEventNumbers)
835  continue;
836 
837  if (!eventEntries().empty()) {
838  std::vector<EventEntry>::iterator last = eventEntries().begin() + endEventNumbers;
839  if (std::adjacent_find(eventEntries().begin() + beginEventNumbers, last) != last) {
840  return true;
841  }
842  } else {
844  std::vector<EventNumber_t>::iterator last = eventNumbers().begin() + endEventNumbers;
845  if (std::adjacent_find(eventNumbers().begin() + beginEventNumbers, last) != last) {
846  return true;
847  }
848  }
849  }
850  return false;
851  }
std::vector< EventEntry > & eventEntries() const
SortedRunOrLumiItr beginRunOrLumi() const
bool empty() const
True if no runs, lumis, or events are in the file.
IndexIntoFileItr begin(SortOrder sortOrder) const
void fillEventNumbers() const
std::vector< EventNumber_t > & eventNumbers() const
SortedRunOrLumiItr endRunOrLumi() const
tuple last
Definition: dqmdumpme.py:56
bool edm::IndexIntoFile::containsEvent ( RunNumber_t  run,
LuminosityBlockNumber_t  lumi,
EventNumber_t  event 
) const

Definition at line 700 of file IndexIntoFile.cc.

References findEventPosition(), edm::IndexIntoFile::IndexIntoFileItr::getEntryType(), and kEnd.

Referenced by containsItem().

700  {
702  }
list lumi
Definition: dqmdumpme.py:53
IndexIntoFileItr findEventPosition(RunNumber_t run, LuminosityBlockNumber_t lumi, EventNumber_t event) const
bool edm::IndexIntoFile::containsItem ( RunNumber_t  run,
LuminosityBlockNumber_t  lumi,
EventNumber_t  event 
) const

Definition at line 696 of file IndexIntoFile.cc.

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

Referenced by edm::RootFile::containsItem().

696  {
697  return (event != 0) ? containsEvent(run, lumi, event) : (lumi ? containsLumi(run, lumi) : containsRun(run));
698  }
list lumi
Definition: dqmdumpme.py:53
bool containsLumi(RunNumber_t run, LuminosityBlockNumber_t lumi) const
bool containsEvent(RunNumber_t run, LuminosityBlockNumber_t lumi, EventNumber_t event) const
bool containsRun(RunNumber_t run) const
bool edm::IndexIntoFile::containsLumi ( RunNumber_t  run,
LuminosityBlockNumber_t  lumi 
) const

Definition at line 704 of file IndexIntoFile.cc.

References findLumiPosition(), edm::IndexIntoFile::IndexIntoFileItr::getEntryType(), and kEnd.

Referenced by containsItem().

704  {
705  return findLumiPosition(run, lumi).getEntryType() != kEnd;
706  }
list lumi
Definition: dqmdumpme.py:53
IndexIntoFileItr findLumiPosition(RunNumber_t run, LuminosityBlockNumber_t lumi) const
bool edm::IndexIntoFile::containsRun ( RunNumber_t  run) const

Definition at line 708 of file IndexIntoFile.cc.

References findRunPosition(), edm::IndexIntoFile::IndexIntoFileItr::getEntryType(), and kEnd.

Referenced by containsItem().

708 { return findRunPosition(run).getEntryType() != kEnd; }
IndexIntoFileItr findRunPosition(RunNumber_t run) const
Same as findPosition.
int& edm::IndexIntoFile::currentIndex ( ) const
inlineprivate

Definition at line 1118 of file IndexIntoFile.h.

References edm::IndexIntoFile::Transients::currentIndex_, and transient_.

Referenced by addEntry().

LuminosityBlockNumber_t& edm::IndexIntoFile::currentLumi ( ) const
inlineprivate

Definition at line 1120 of file IndexIntoFile.h.

References edm::IndexIntoFile::Transients::currentLumi_, and transient_.

Referenced by addEntry().

1120 { return transient_.currentLumi_; }
LuminosityBlockNumber_t currentLumi_
RunNumber_t& edm::IndexIntoFile::currentRun ( ) const
inlineprivate

Definition at line 1119 of file IndexIntoFile.h.

References edm::IndexIntoFile::Transients::currentRun_, and transient_.

Referenced by addEntry().

1119 { return transient_.currentRun_; }
void edm::IndexIntoFile::doneFileInitialization ( )

Clears the temporary vector of event numbers to reduce memory usage.

Definition at line 306 of file IndexIntoFile.cc.

References edm::swap(), and unsortedEventNumbers().

Referenced by edm::RootFile::RootFile().

306 { std::vector<EventNumber_t>().swap(unsortedEventNumbers()); }
void swap(Association< C > &lhs, Association< C > &rhs)
Definition: Association.h:117
std::vector< EventNumber_t > & unsortedEventNumbers()
bool edm::IndexIntoFile::empty ( ) const

True if no runs, lumis, or events are in the file.

Definition at line 487 of file IndexIntoFile.cc.

References runOrLumiEntries().

Referenced by begin(), containsDuplicateEvents(), fwlite::EntryFinder::empty(), fillEventNumbersOrEntries(), fillUnsortedEventNumbers(), fwlite::EntryFinder::findEvent(), fwlite::EntryFinder::findLumi(), findPosition(), fwlite::EntryFinder::findRun(), set_intersection(), and edm::RootFile::validateFile().

487 { return runOrLumiEntries().empty(); }
std::vector< RunOrLumiEntry > const & runOrLumiEntries() const
Used internally and for test purposes.
IndexIntoFile::IndexIntoFileItr edm::IndexIntoFile::end ( SortOrder  sortOrder) const
EntryNumber_t& edm::IndexIntoFile::endEvents ( ) const
inlineprivate
IndexIntoFile::SortedRunOrLumiItr edm::IndexIntoFile::endRunOrLumi ( ) const

Definition at line 712 of file IndexIntoFile.cc.

References runOrLumiEntries(), and findQualityFiles::size.

Referenced by containsDuplicateEvents(), fillEventNumbersOrEntries(), and set_intersection().

712  {
713  return SortedRunOrLumiItr(this, runOrLumiEntries().size());
714  }
std::vector< RunOrLumiEntry > const & runOrLumiEntries() const
Used internally and for test purposes.
tuple size
Write out results.
std::vector<EventEntry>& edm::IndexIntoFile::eventEntries ( ) const
inlineprivate
std::vector<EventNumber_t>& edm::IndexIntoFile::eventNumbers ( ) const
inlineprivate
void edm::IndexIntoFile::fillEventEntries ( ) const

Fills a vector of objects that contain an event number and the corresponding TTree entry number for the event. Not filling it reduces the memory used by IndexIntoFile. As long as the event finder is still pointing at an open file this will automatically be called on demand (when the event numbers and entries are are needed). It makes sense for the client to fill this explicitly in advance if it is known that it will be needed, because in some cases this will prevent the event numbers vector from being unnecessarily filled (wasting memory). This vector will be needed when iterating over events in numerical order or looking up specific events. The entry numbers are needed if the events are actually read from the input file.

Definition at line 200 of file IndexIntoFile.cc.

References fillEventNumbersOrEntries().

200 { fillEventNumbersOrEntries(false, true); }
void fillEventNumbersOrEntries(bool needEventNumbers, bool needEventEntries) const
void edm::IndexIntoFile::fillEventNumbers ( ) const

Fills a vector of event numbers. Not filling it reduces the memory used by IndexIntoFile. As long as the event finder is still pointing at an open file this will automatically be called on demand (when the event numbers are are needed). In cases, where the input file may be closed when the need arises, the client code must call this explicitly and fill the vector before the file is closed. In PoolSource, this is necessary when duplicate checking across all files and when doing lookups to see if an event is in a previously opened file. Either this vector or the one that also contains event entry numbers can be used when looking for duplicate events within the same file or looking up events in in the current file without reading them.

Definition at line 198 of file IndexIntoFile.cc.

References fillEventNumbersOrEntries().

Referenced by containsDuplicateEvents(), findPosition(), edm::RootFile::goToEvent(), and set_intersection().

198 { fillEventNumbersOrEntries(true, false); }
void fillEventNumbersOrEntries(bool needEventNumbers, bool needEventEntries) const
void edm::IndexIntoFile::fillEventNumbersOrEntries ( bool  needEventNumbers,
bool  needEventEntries 
) const

If needEventNumbers is true then this function does the same thing as fillEventNumbers. If NeedEventEntries is true, then this function does the same thing as fillEventEntries. If both are true, it fills both within the same loop and it uses less CPU than calling those two functions separately.

Definition at line 202 of file IndexIntoFile.cc.

References cms::cuda::assert(), beginRunOrLumi(), empty(), endRunOrLumi(), mps_splice::entry, edmPickEvents::event, eventEntries(), eventNumbers(), fillUnsortedEventNumbers(), invalidEntry, invalidEvent, numberOfEvents(), hltrates_dqm_sourceclient-live_cfg::offset, findQualityFiles::size, sortEventEntries(), sortEvents(), and unsortedEventNumbers().

Referenced by fillEventEntries(), fillEventNumbers(), and edm::RootFile::validateFile().

202  {
203  if (numberOfEvents() == 0) {
204  return;
205  }
206 
207  if (needEventNumbers && !eventNumbers().empty()) {
208  needEventNumbers = false;
209  }
210 
211  if (needEventEntries && !eventEntries().empty()) {
212  needEventEntries = false;
213  }
214 
215  if (needEventNumbers && !eventEntries().empty()) {
217  eventNumbers().reserve(eventEntries().size());
219  eventNumbers().push_back(eventEntries()[entry].event());
220  }
221  return;
222  }
223 
224  if (!needEventNumbers && !needEventEntries) {
225  return;
226  }
227 
229 
230  if (needEventNumbers) {
232  }
233  if (needEventEntries) {
234  eventEntries().resize(numberOfEvents());
235  }
236 
237  long long offset = 0;
238  long long previousBeginEventNumbers = -1LL;
239 
240  for (SortedRunOrLumiItr runOrLumi = beginRunOrLumi(), runOrLumiEnd = endRunOrLumi(); runOrLumi != runOrLumiEnd;
241  ++runOrLumi) {
242  if (runOrLumi.isRun())
243  continue;
244 
245  long long beginEventNumbers = 0;
246  long long endEventNumbers = 0;
247  EntryNumber_t beginEventEntry = invalidEntry;
248  EntryNumber_t endEventEntry = invalidEntry;
249  runOrLumi.getRange(beginEventNumbers, endEventNumbers, beginEventEntry, endEventEntry);
250 
251  // This is true each time one hits a new lumi section (except if the previous lumi had
252  // no events, in which case the offset is still 0 anyway)
253  if (beginEventNumbers != previousBeginEventNumbers)
254  offset = 0;
255 
256  for (EntryNumber_t entry = beginEventEntry; entry != endEventEntry; ++entry) {
257  if (needEventNumbers) {
258  eventNumbers().at((entry - beginEventEntry) + offset + beginEventNumbers) = unsortedEventNumbers().at(entry);
259  }
260  if (needEventEntries) {
261  eventEntries().at((entry - beginEventEntry) + offset + beginEventNumbers) =
262  EventEntry(unsortedEventNumbers().at(entry), entry);
263  }
264  }
265 
266  previousBeginEventNumbers = beginEventNumbers;
267  offset += endEventEntry - beginEventEntry;
268  }
269  if (needEventNumbers) {
270  sortEvents();
272  }
273  if (needEventEntries) {
276  }
277  }
std::vector< EventEntry > & eventEntries() const
SortedRunOrLumiItr beginRunOrLumi() const
bool empty() const
True if no runs, lumis, or events are in the file.
void sortEvents() const
void fillUnsortedEventNumbers() const
assert(be >=bs)
uint16_t size_type
static constexpr EventNumber_t invalidEvent
size_t numberOfEvents() const
long long EntryNumber_t
void sortEventEntries() const
static constexpr EntryNumber_t invalidEntry
std::vector< EventNumber_t > & unsortedEventNumbers()
list entry
Definition: mps_splice.py:68
std::vector< EventNumber_t > & eventNumbers() const
SortedRunOrLumiItr endRunOrLumi() const
tuple size
Write out results.
void edm::IndexIntoFile::fillRunOrLumiIndexes ( ) const
private

This function will automatically get called when needed. It depends only on the fact that the persistent data has been filled already.

Definition at line 151 of file IndexIntoFile.cc.

References cms::cuda::assert(), invalidEntry, B2GTnPMonitor_cfi::item, submitPVValidationJobs::nEvents, runOrLumiEntries_, runOrLumiIndexes(), findQualityFiles::size, and edm::stable_sort_all().

Referenced by findPosition(), edm::IndexIntoFile::IndexIntoFileItrSorted::IndexIntoFileItrSorted(), set_intersection(), edm::IndexIntoFile::SortedRunOrLumiItr::SortedRunOrLumiItr(), sortEventEntries(), and sortEvents().

151  {
152  if (runOrLumiEntries_.empty() || !runOrLumiIndexes().empty()) {
153  return;
154  }
155  runOrLumiIndexes().reserve(runOrLumiEntries_.size());
156 
157  int index = 0;
158  for (RunOrLumiEntry const& item : runOrLumiEntries_) {
159  runOrLumiIndexes().emplace_back(item.processHistoryIDIndex(), item.run(), item.lumi(), index);
160  ++index;
161  }
163 
164  long long beginEventNumbers = 0;
165 
166  std::vector<RunOrLumiIndexes>::iterator beginOfLumi = runOrLumiIndexes().begin();
167  std::vector<RunOrLumiIndexes>::iterator endOfLumi = beginOfLumi;
168  std::vector<RunOrLumiIndexes>::iterator iEnd = runOrLumiIndexes().end();
169  while (true) {
170  while (beginOfLumi != iEnd && beginOfLumi->isRun()) {
171  ++beginOfLumi;
172  }
173  if (beginOfLumi == iEnd)
174  break;
175 
176  endOfLumi = beginOfLumi + 1;
177  while (endOfLumi != iEnd && beginOfLumi->processHistoryIDIndex() == endOfLumi->processHistoryIDIndex() &&
178  beginOfLumi->run() == endOfLumi->run() && beginOfLumi->lumi() == endOfLumi->lumi()) {
179  ++endOfLumi;
180  }
181  int nEvents = 0;
182  for (std::vector<RunOrLumiIndexes>::iterator iter = beginOfLumi; iter != endOfLumi; ++iter) {
183  if (runOrLumiEntries_[iter->indexToGetEntry()].beginEvents() != invalidEntry) {
184  nEvents += runOrLumiEntries_[iter->indexToGetEntry()].endEvents() -
185  runOrLumiEntries_[iter->indexToGetEntry()].beginEvents();
186  }
187  }
188  for (std::vector<RunOrLumiIndexes>::iterator iter = beginOfLumi; iter != endOfLumi; ++iter) {
189  iter->setBeginEventNumbers(beginEventNumbers);
190  iter->setEndEventNumbers(beginEventNumbers + nEvents);
191  }
192  beginEventNumbers += nEvents;
193  beginOfLumi = endOfLumi;
194  }
195  assert(runOrLumiIndexes().size() == runOrLumiEntries_.size());
196  }
std::vector< RunOrLumiIndexes > & runOrLumiIndexes() const
void stable_sort_all(RandomAccessSequence &s)
wrappers for std::stable_sort
Definition: Algorithms.h:103
assert(be >=bs)
std::vector< RunOrLumiEntry > runOrLumiEntries_
static constexpr EntryNumber_t invalidEntry
tuple size
Write out results.
void edm::IndexIntoFile::fillUnsortedEventNumbers ( ) const
private

Definition at line 279 of file IndexIntoFile.cc.

References empty(), mps_splice::entry, getEventNumberOfEntry(), numberOfEvents(), unsortedEventNumbers(), and unsortedEventNumbersMutable().

Referenced by fillEventNumbersOrEntries().

279  {
280  if (numberOfEvents() == 0 || !unsortedEventNumbers().empty()) {
281  return;
282  }
284 
285  // The main purpose for the existence of the unsortedEventNumbers
286  // vector is that it can easily be filled by reading through
287  // the EventAuxiliary branch in the same order as the TTree
288  // entries. fillEventNumbersOrEntries can then use this information
289  // instead of using getEventNumberOfEntry directly and reading
290  // the branch in a different order.
293  }
294  }
bool empty() const
True if no runs, lumis, or events are in the file.
uint16_t size_type
size_t numberOfEvents() const
std::vector< EventNumber_t > & unsortedEventNumbers()
EventNumber_t getEventNumberOfEntry(EntryNumber_t entry) const
list entry
Definition: mps_splice.py:68
std::vector< EventNumber_t > & unsortedEventNumbersMutable() const
IndexIntoFile::IndexIntoFileItr edm::IndexIntoFile::findEventPosition ( RunNumber_t  run,
LuminosityBlockNumber_t  lumi,
EventNumber_t  event 
) const

Same as findPosition,except the entry type of the returned iterator will be kEvent or kEnd and the event argument must be nonzero. This means the next thing to be processed will be the event if it is found.

Definition at line 676 of file IndexIntoFile.cc.

References edm::IndexIntoFile::IndexIntoFileItr::advanceToEvent(), cms::cuda::assert(), findPosition(), and invalidEvent.

Referenced by containsEvent(), fwlite::EntryFinder::findEvent(), and edm::RootFile::setEntryAtEvent().

678  {
680  IndexIntoFileItr iter = findPosition(run, lumi, event);
681  iter.advanceToEvent();
682  return iter;
683  }
assert(be >=bs)
static constexpr EventNumber_t invalidEvent
IndexIntoFileItr findPosition(RunNumber_t run, LuminosityBlockNumber_t lumi=0U, EventNumber_t event=0U) const
list lumi
Definition: dqmdumpme.py:53
IndexIntoFile::IndexIntoFileItr edm::IndexIntoFile::findLumiPosition ( RunNumber_t  run,
LuminosityBlockNumber_t  lumi 
) const

Same as findPosition,except the entry type of the returned iterator will be kLumi or kEnd and the lumi argument must be nonzero. This means the next thing to be processed will be the lumi if it is found.

Definition at line 685 of file IndexIntoFile.cc.

References edm::IndexIntoFile::IndexIntoFileItr::advanceToLumi(), cms::cuda::assert(), findPosition(), and invalidLumi.

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

685  {
686  assert(lumi != invalidLumi);
687  IndexIntoFileItr iter = findPosition(run, lumi, 0U);
688  iter.advanceToLumi();
689  return iter;
690  }
assert(be >=bs)
IndexIntoFileItr findPosition(RunNumber_t run, LuminosityBlockNumber_t lumi=0U, EventNumber_t event=0U) const
list lumi
Definition: dqmdumpme.py:53
static constexpr LuminosityBlockNumber_t invalidLumi
IndexIntoFile::IndexIntoFileItr edm::IndexIntoFile::findPosition ( RunNumber_t  run,
LuminosityBlockNumber_t  lumi = 0U,
EventNumber_t  event = 0U 
) const

Find a run, lumi, or event. Returns an iterator pointing at it. The iterator will always be in numericalOrder mode. If it is not found the entry type of the iterator will be kEnd. If it is found the entry type of the iterator will always be kRun so the next thing to be processed is the run containing the desired lumi or event or if looking for a run, the run itself. If the lumi and event arguments are 0 (invalid), then it will find a run. If only the event argument is 0 (invalid), then it will find a lumi. If will look for an event if all three arguments are nonzero or if only the lumi argument is 0 (invalid). Note that it will find the first match only so if there is more than one match then the others cannot be found with this method. The order of the search is by processHistoryID index, then run number, then lumi number, then event entry. If searching for a lumi the iterator will advance directly to the desired lumi after the run even if it is not the first lumi in the run. If searching for an event, the iterator will advance to the lumi containing the run and then the requested event after run even if there are other lumis earlier in that run and other events earlier in that lumi.

Definition at line 489 of file IndexIntoFile.cc.

References cms::cuda::assert(), begin(), empty(), mps_splice::entry, edmPickEvents::event, eventEntries(), eventNumbers(), fillEventNumbers(), fillRunOrLumiIndexes(), edm::IndexIntoFile::IndexIntoFileItr::initializeLumi(), edm::IndexIntoFile::IndexIntoFileItr::initializeRun(), invalidEntry, invalidEvent, invalidIndex, invalidLumi, kEnd, kRun, cuda_std::lower_bound(), dqmdumpme::lumi, numericalOrder, submitPVValidationJobs::run, runOrLumiEntries_, runOrLumiIndexes(), and cuda_std::upper_bound().

Referenced by findEventPosition(), findLumiPosition(), findPosition(), findRunPosition(), and edm::RootFile::goToEvent().

491  {
493 
494  bool lumiMissing = (lumi == 0 && event != 0);
495 
496  std::vector<RunOrLumiIndexes>::const_iterator iEnd = runOrLumiIndexes().end();
497  std::vector<RunOrLumiIndexes>::const_iterator phEnd;
498 
499  // Loop over ranges of entries with the same ProcessHistoryID
500  for (std::vector<RunOrLumiIndexes>::const_iterator phBegin = runOrLumiIndexes().begin(); phBegin != iEnd;
501  phBegin = phEnd) {
502  RunOrLumiIndexes el(phBegin->processHistoryIDIndex(), run, lumi, 0);
503  phEnd = std::upper_bound(phBegin, iEnd, el, Compare_Index());
504 
505  std::vector<RunOrLumiIndexes>::const_iterator iRun = std::lower_bound(phBegin, phEnd, el, Compare_Index_Run());
506 
507  if (iRun == phEnd || iRun->run() != run)
508  continue;
509 
510  if (lumi == invalidLumi && event == invalidEvent) {
511  IndexIntoFileItr indexItr(
513  indexItr.initializeRun();
514  return indexItr;
515  }
516 
517  std::vector<RunOrLumiIndexes>::const_iterator iRunEnd = std::upper_bound(iRun, phEnd, el, Compare_Index_Run());
518  if (!lumiMissing) {
519  std::vector<RunOrLumiIndexes>::const_iterator iLumi = std::lower_bound(iRun, iRunEnd, el);
520  if (iLumi == iRunEnd || iLumi->lumi() != lumi)
521  continue;
522 
523  if (event == invalidEvent) {
524  IndexIntoFileItr indexItr(this,
526  kRun,
527  iRun - runOrLumiIndexes().begin(),
528  iLumi - runOrLumiIndexes().begin(),
529  invalidIndex,
530  0,
531  0);
532  indexItr.initializeLumi();
533  return indexItr;
534  }
535 
536  long long beginEventNumbers = iLumi->beginEventNumbers();
537  long long endEventNumbers = iLumi->endEventNumbers();
538  if (beginEventNumbers >= endEventNumbers)
539  continue;
540 
541  long long indexToEvent = 0;
542  if (!eventEntries().empty()) {
543  std::vector<EventEntry>::const_iterator eventIter =
544  std::lower_bound(eventEntries().begin() + beginEventNumbers,
545  eventEntries().begin() + endEventNumbers,
546  EventEntry(event, invalidEntry));
547  if (eventIter == (eventEntries().begin() + endEventNumbers) || eventIter->event() != event)
548  continue;
549 
550  indexToEvent = eventIter - eventEntries().begin() - beginEventNumbers;
551  } else {
553  std::vector<EventNumber_t>::const_iterator eventIter = std::lower_bound(
554  eventNumbers().begin() + beginEventNumbers, eventNumbers().begin() + endEventNumbers, event);
555  if (eventIter == (eventNumbers().begin() + endEventNumbers) || *eventIter != event)
556  continue;
557 
558  indexToEvent = eventIter - eventNumbers().begin() - beginEventNumbers;
559  }
560 
561  int newIndexToLumi = iLumi - runOrLumiIndexes().begin();
562  while (runOrLumiEntries_[runOrLumiIndexes()[newIndexToLumi].indexToGetEntry()].entry() == invalidEntry) {
563  ++newIndexToLumi;
564  assert(static_cast<unsigned>(newIndexToLumi) < runOrLumiEntries_.size());
565  assert(runOrLumiIndexes()[newIndexToLumi].lumi() == lumi);
566  }
567 
568  return IndexIntoFileItr(this,
570  kRun,
571  iRun - runOrLumiIndexes().begin(),
572  newIndexToLumi,
573  iLumi - runOrLumiIndexes().begin(),
574  indexToEvent,
575  endEventNumbers - beginEventNumbers);
576  }
577  if (lumiMissing) {
578  std::vector<RunOrLumiIndexes>::const_iterator iLumi = iRun;
579  while (iLumi != iRunEnd && iLumi->lumi() == invalidLumi) {
580  ++iLumi;
581  }
582  if (iLumi == iRunEnd)
583  continue;
584 
585  std::vector<RunOrLumiIndexes>::const_iterator lumiEnd;
586  for (; iLumi != iRunEnd; iLumi = lumiEnd) {
587  RunOrLumiIndexes elWithLumi(phBegin->processHistoryIDIndex(), run, iLumi->lumi(), 0);
588  lumiEnd = std::upper_bound(iLumi, iRunEnd, elWithLumi);
589 
590  long long beginEventNumbers = iLumi->beginEventNumbers();
591  long long endEventNumbers = iLumi->endEventNumbers();
592  if (beginEventNumbers >= endEventNumbers)
593  continue;
594 
595  long long indexToEvent = 0;
596  if (!eventEntries().empty()) {
597  std::vector<EventEntry>::const_iterator eventIter =
598  std::lower_bound(eventEntries().begin() + beginEventNumbers,
599  eventEntries().begin() + endEventNumbers,
600  EventEntry(event, invalidEntry));
601  if (eventIter == (eventEntries().begin() + endEventNumbers) || eventIter->event() != event)
602  continue;
603  indexToEvent = eventIter - eventEntries().begin() - beginEventNumbers;
604  } else {
606  std::vector<EventNumber_t>::const_iterator eventIter = std::lower_bound(
607  eventNumbers().begin() + beginEventNumbers, eventNumbers().begin() + endEventNumbers, event);
608  if (eventIter == (eventNumbers().begin() + endEventNumbers) || *eventIter != event)
609  continue;
610  indexToEvent = eventIter - eventNumbers().begin() - beginEventNumbers;
611  }
612 
613  int newIndexToLumi = iLumi - runOrLumiIndexes().begin();
614  while (runOrLumiEntries_[runOrLumiIndexes()[newIndexToLumi].indexToGetEntry()].entry() == invalidEntry) {
615  ++newIndexToLumi;
616  assert(static_cast<unsigned>(newIndexToLumi) < runOrLumiEntries_.size());
617  assert(runOrLumiIndexes()[newIndexToLumi].lumi() == iLumi->lumi());
618  }
619 
620  return IndexIntoFileItr(this,
622  kRun,
623  iRun - runOrLumiIndexes().begin(),
624  newIndexToLumi,
625  iLumi - runOrLumiIndexes().begin(),
626  indexToEvent,
627  endEventNumbers - beginEventNumbers);
628  }
629  }
630  } // Loop over ProcessHistoryIDs
631 
632  return IndexIntoFileItr(this, numericalOrder, kEnd, invalidIndex, invalidIndex, invalidIndex, 0, 0);
633  }
static constexpr int invalidIndex
std::vector< EventEntry > & eventEntries() const
bool empty() const
True if no runs, lumis, or events are in the file.
std::vector< RunOrLumiIndexes > & runOrLumiIndexes() const
__host__ __device__ constexpr RandomIt upper_bound(RandomIt first, RandomIt last, const T &value, Compare comp={})
IndexIntoFileItr begin(SortOrder sortOrder) const
assert(be >=bs)
static constexpr EventNumber_t invalidEvent
std::vector< RunOrLumiEntry > runOrLumiEntries_
void fillRunOrLumiIndexes() const
list lumi
Definition: dqmdumpme.py:53
static constexpr EntryNumber_t invalidEntry
static constexpr LuminosityBlockNumber_t invalidLumi
__host__ __device__ constexpr RandomIt lower_bound(RandomIt first, RandomIt last, const T &value, Compare comp={})
void fillEventNumbers() const
list entry
Definition: mps_splice.py:68
std::vector< EventNumber_t > & eventNumbers() const
IndexIntoFile::IndexIntoFileItr edm::IndexIntoFile::findPosition ( SortOrder  sortOrder,
RunNumber_t  run,
LuminosityBlockNumber_t  lumi = 0U,
EventNumber_t  event = 0U 
) const

Definition at line 635 of file IndexIntoFile.cc.

References edm::IndexIntoFile::IndexIntoFileItr::advanceToNextRun(), begin(), end(), findPosition(), getEventNumberOfEntry(), invalidEvent, invalidLumi, dqmdumpme::lumi, numericalOrder, edm::IndexIntoFile::IndexIntoFileItr::peekAheadAtEventEntry(), edm::IndexIntoFile::IndexIntoFileItr::peekAheadAtLumi(), submitPVValidationJobs::run, edm::IndexIntoFile::IndexIntoFileItr::run(), edm::IndexIntoFile::IndexIntoFileItr::skipLumiInRun(), and edm::IndexIntoFile::IndexIntoFileItr::skipToNextEventInLumi().

638  {
639  if (sortOrder == IndexIntoFile::numericalOrder) {
640  return findPosition(run, lumi, event); // a faster algorithm
641  }
642  IndexIntoFileItr itr = begin(sortOrder);
643  IndexIntoFileItr itrEnd = end(sortOrder);
644 
645  while (itr != itrEnd) {
646  if (itr.run() != run) {
647  itr.advanceToNextRun();
648  } else {
649  if (lumi == invalidLumi && event == invalidEvent) {
650  return itr;
651  } else if (lumi != invalidLumi && itr.peekAheadAtLumi() != lumi) {
652  if (!itr.skipLumiInRun()) {
653  itr.advanceToNextRun();
654  }
655  } else {
656  if (event == invalidEvent) {
657  return itr;
658  } else {
659  EventNumber_t eventNumber = getEventNumberOfEntry(itr.peekAheadAtEventEntry());
660  if (eventNumber == event) {
661  return itr;
662  } else {
663  if (!itr.skipToNextEventInLumi()) {
664  if (!itr.skipLumiInRun()) {
665  itr.advanceToNextRun();
666  }
667  }
668  }
669  }
670  }
671  }
672  }
673  return itrEnd;
674  }
unsigned long long EventNumber_t
IndexIntoFileItr begin(SortOrder sortOrder) const
static constexpr EventNumber_t invalidEvent
IndexIntoFileItr findPosition(RunNumber_t run, LuminosityBlockNumber_t lumi=0U, EventNumber_t event=0U) const
IndexIntoFileItr end(SortOrder sortOrder) const
Used to end an iteration over the Runs, Lumis, and Events in a file.
list lumi
Definition: dqmdumpme.py:53
static constexpr LuminosityBlockNumber_t invalidLumi
EventNumber_t getEventNumberOfEntry(EntryNumber_t entry) const
IndexIntoFile::IndexIntoFileItr edm::IndexIntoFile::findRunPosition ( RunNumber_t  run) const

Same as findPosition.

Definition at line 692 of file IndexIntoFile.cc.

References findPosition().

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

692  {
693  return findPosition(run, 0U, 0U);
694  }
IndexIntoFileItr findPosition(RunNumber_t run, LuminosityBlockNumber_t lumi=0U, EventNumber_t event=0U) const
void edm::IndexIntoFile::fixIndexes ( std::vector< ProcessHistoryID > &  processHistoryIDs)

Used by PoolSource to force the ProcessHistoryID indexes to be consistent across all input files. Currently this consistency is important when duplicate checking across all input files. It may be important for other reasons in the future. It is important this be called immediately after reading in the object from the input file, before filling the transient data members or using the indexes in any way.

Definition at line 370 of file IndexIntoFile.cc.

References spr::find(), B2GTnPMonitor_cfi::item, processHistoryIDs(), processHistoryIDs_, and runOrLumiEntries_.

Referenced by edm::RootFile::validateFile().

370  {
371  std::map<int, int> oldToNewIndex;
372  for (std::vector<ProcessHistoryID>::const_iterator iter = processHistoryIDs_.begin(),
373  iEnd = processHistoryIDs_.end();
374  iter != iEnd;
375  ++iter) {
376  std::vector<ProcessHistoryID>::const_iterator iterExisting =
377  std::find(processHistoryIDs.begin(), processHistoryIDs.end(), *iter);
378  if (iterExisting == processHistoryIDs.end()) {
379  oldToNewIndex[iter - processHistoryIDs_.begin()] = processHistoryIDs.size();
380  processHistoryIDs.push_back(*iter);
381  } else {
382  oldToNewIndex[iter - processHistoryIDs_.begin()] = iterExisting - processHistoryIDs.begin();
383  }
384  }
386 
387  for (RunOrLumiEntry& item : runOrLumiEntries_) {
388  item.setProcessHistoryIDIndex(oldToNewIndex[item.processHistoryIDIndex()]);
389  }
390  }
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:19
std::vector< ProcessHistoryID > const & processHistoryIDs() const
std::vector< RunOrLumiEntry > runOrLumiEntries_
std::vector< ProcessHistoryID > processHistoryIDs_
EventNumber_t edm::IndexIntoFile::getEventNumberOfEntry ( EntryNumber_t  entry) const
inlineprivate

Definition at line 1123 of file IndexIntoFile.h.

References edm::IndexIntoFile::Transients::eventFinder_, and transient_.

Referenced by fillUnsortedEventNumbers(), and findPosition().

1123  {
1124  return transient_.eventFinder_->getEventNumberOfEntry(entry);
1125  }
list entry
Definition: mps_splice.py:68
edm::propagate_const< std::shared_ptr< EventFinder > > eventFinder_
void edm::IndexIntoFile::initializeTransients ( )
inline
void edm::IndexIntoFile::inputFileClosed ( )

Clear some vectors and eventFinder when an input file is closed. This reduces the memory used by IndexIntoFile

Definition at line 299 of file IndexIntoFile.cc.

References eventEntries(), resetEventFinder(), runOrLumiIndexes(), edm::swap(), and unsortedEventNumbers().

299  {
300  std::vector<EventEntry>().swap(eventEntries());
301  std::vector<RunOrLumiIndexes>().swap(runOrLumiIndexes());
302  std::vector<EventNumber_t>().swap(unsortedEventNumbers());
304  }
std::vector< EventEntry > & eventEntries() const
std::vector< RunOrLumiIndexes > & runOrLumiIndexes() const
void swap(Association< C > &lhs, Association< C > &rhs)
Definition: Association.h:117
void resetEventFinder() const
std::vector< EventNumber_t > & unsortedEventNumbers()
bool edm::IndexIntoFile::iterationWillBeInEntryOrder ( SortOrder  sortOrder) const

Used to determine whether or not to disable fast cloning.

Definition at line 474 of file IndexIntoFile.cc.

References begin(), end(), invalidEntry, and kEvent.

Referenced by edm::postIndexIntoFilePrintEventLists(), and edm::RootFile::setIfFastClonable().

474  {
475  EntryNumber_t maxEntry = invalidEntry;
476  for (IndexIntoFileItr it = begin(sortOrder), itEnd = end(sortOrder); it != itEnd; ++it) {
477  if (it.getEntryType() == kEvent) {
478  if (it.entry() < maxEntry) {
479  return false;
480  }
481  maxEntry = it.entry();
482  }
483  }
484  return true;
485  }
IndexIntoFileItr begin(SortOrder sortOrder) const
long long EntryNumber_t
IndexIntoFileItr end(SortOrder sortOrder) const
Used to end an iteration over the Runs, Lumis, and Events in a file.
static constexpr EntryNumber_t invalidEntry
std::map<IndexRunLumiKey, EntryNumber_t>& edm::IndexIntoFile::lumiToOrder ( ) const
inlineprivate

Definition at line 1115 of file IndexIntoFile.h.

References edm::IndexIntoFile::Transients::lumiToOrder_, and transient_.

Referenced by addLumi().

1115 { return transient_.lumiToOrder_; }
std::map< IndexRunLumiKey, EntryNumber_t > lumiToOrder_
size_t edm::IndexIntoFile::numberOfEvents ( ) const
inlineprivate
int& edm::IndexIntoFile::previousAddedIndex ( ) const
inlineprivate
ProcessHistoryID const & edm::IndexIntoFile::processHistoryID ( int  i) const

Definition at line 55 of file IndexIntoFile.cc.

References processHistoryIDs_.

Referenced by edm::RootFile::readCurrentEvent().

55 { return processHistoryIDs_.at(i); }
std::vector< ProcessHistoryID > processHistoryIDs_
std::vector< ProcessHistoryID > const & edm::IndexIntoFile::processHistoryIDs ( ) const

Definition at line 57 of file IndexIntoFile.cc.

References processHistoryIDs_.

Referenced by fixIndexes().

57 { return processHistoryIDs_; }
std::vector< ProcessHistoryID > processHistoryIDs_
void edm::IndexIntoFile::reduceProcessHistoryIDs ( ProcessHistoryRegistry const &  processHistoryRegistry)

Used for backward compatibility to convert objects created with releases that used the full ProcessHistoryID in IndexIntoFile to use the reduced ProcessHistoryID.

Definition at line 308 of file IndexIntoFile.cc.

References B2GTnPMonitor_cfi::item, processHistoryIDs_, edm::ProcessHistoryRegistry::reducedProcessHistoryID(), runOrLumiEntries_, and edm::Hash< I >::swap().

Referenced by edm::RootFile::validateFile().

308  {
309  std::vector<ProcessHistoryID> reducedPHIDs;
310 
311  std::map<ProcessHistoryID, int> reducedPHIDToIndex;
312  std::pair<ProcessHistoryID, int> mapEntry(ProcessHistoryID(), 0);
313  std::pair<std::map<ProcessHistoryID, int>::iterator, bool> insertResult;
314 
315  std::vector<int> phidIndexConverter;
316  for (auto const& phid : processHistoryIDs_) {
317  ProcessHistoryID const& reducedPHID = processHistoryRegistry.reducedProcessHistoryID(phid);
318  mapEntry.first = reducedPHID;
319  insertResult = reducedPHIDToIndex.insert(mapEntry);
320 
321  if (insertResult.second) {
322  insertResult.first->second = reducedPHIDs.size();
323  reducedPHIDs.push_back(reducedPHID);
324  }
325  phidIndexConverter.push_back(insertResult.first->second);
326  }
327  processHistoryIDs_.swap(reducedPHIDs);
328 
329  // If the size of the vector of IDs does not change
330  // then their indexes and the ordering of the Runs and
331  // and Lumis does not change, so we are done.
332  if (processHistoryIDs_.size() == reducedPHIDs.size()) {
333  return;
334  }
335 
336  std::map<IndexIntoFile::IndexRunKey, int> runOrderMap;
337  std::pair<std::map<IndexIntoFile::IndexRunKey, int>::iterator, bool> runInsertResult;
338 
339  std::map<IndexIntoFile::IndexRunLumiKey, int> lumiOrderMap;
340  std::pair<std::map<IndexIntoFile::IndexRunLumiKey, int>::iterator, bool> lumiInsertResult;
341 
342  // loop over all the RunOrLumiEntry's
343  for (auto& item : runOrLumiEntries_) {
344  // Convert the process history index so it points into the new vector of reduced IDs
345  item.setProcessHistoryIDIndex(phidIndexConverter.at(item.processHistoryIDIndex()));
346 
347  // Convert the phid-run order
348  IndexIntoFile::IndexRunKey runKey(item.processHistoryIDIndex(), item.run());
349  runInsertResult = runOrderMap.insert(std::pair<IndexIntoFile::IndexRunKey, int>(runKey, 0));
350  if (runInsertResult.second) {
351  runInsertResult.first->second = item.orderPHIDRun();
352  } else {
353  item.setOrderPHIDRun(runInsertResult.first->second);
354  }
355 
356  // Convert the phid-run-lumi order for the lumi entries
357  if (item.lumi() != 0) {
358  IndexIntoFile::IndexRunLumiKey lumiKey(item.processHistoryIDIndex(), item.run(), item.lumi());
359  lumiInsertResult = lumiOrderMap.insert(std::pair<IndexIntoFile::IndexRunLumiKey, int>(lumiKey, 0));
360  if (lumiInsertResult.second) {
361  lumiInsertResult.first->second = item.orderPHIDRunLumi();
362  } else {
363  item.setOrderPHIDRunLumi(lumiInsertResult.first->second);
364  }
365  }
366  }
367  std::stable_sort(runOrLumiEntries_.begin(), runOrLumiEntries_.end());
368  }
void swap(Hash< I > &other)
Definition: Hash.h:181
std::vector< RunOrLumiEntry > runOrLumiEntries_
std::vector< ProcessHistoryID > processHistoryIDs_
Hash< ProcessHistoryType > ProcessHistoryID
void edm::IndexIntoFile::resetEventFinder ( ) const
inlineprivate

Definition at line 1108 of file IndexIntoFile.h.

References edm::IndexIntoFile::Transients::eventFinder_, and transient_.

Referenced by inputFileClosed().

1108 { transient_.eventFinder_ = nullptr; } // propagate_const<T> has no reset() function
edm::propagate_const< std::shared_ptr< EventFinder > > eventFinder_
std::vector<RunOrLumiEntry> const& edm::IndexIntoFile::runOrLumiEntries ( ) const
inline
std::vector<RunOrLumiIndexes>& edm::IndexIntoFile::runOrLumiIndexes ( ) const
inlineprivate
std::map<IndexRunKey, EntryNumber_t>& edm::IndexIntoFile::runToOrder ( ) const
inlineprivate

Definition at line 1114 of file IndexIntoFile.h.

References edm::IndexIntoFile::Transients::runToOrder_, and transient_.

Referenced by addEntry(), and sortVector_Run_Or_Lumi_Entries().

1114 { return transient_.runToOrder_; }
std::map< IndexRunKey, EntryNumber_t > runToOrder_
void edm::IndexIntoFile::set_intersection ( IndexIntoFile const &  indexIntoFile,
std::set< IndexRunLumiEventKey > &  intersection 
) const

The intersection argument will be filled with an entry for each event in both IndexIntoFile objects. To be added the event must have the same ProcessHistoryID index, run number, lumi number and event number.

Definition at line 716 of file IndexIntoFile.cc.

References begin(), edm::IndexIntoFile::RunOrLumiIndexes::beginEventNumbers(), beginRunOrLumi(), empty(), edm::IndexIntoFile::RunOrLumiIndexes::endEventNumbers(), endRunOrLumi(), mps_splice::entry, eventEntries(), eventNumbers(), fillEventNumbers(), fillRunOrLumiIndexes(), edm::IndexIntoFile::RunOrLumiIndexes::isRun(), edm::IndexIntoFile::SortedRunOrLumiItr::isRun(), edm::IndexIntoFile::RunOrLumiIndexes::lumi(), edm::IndexIntoFile::RunOrLumiIndexes::processHistoryIDIndex(), edm::IndexIntoFile::RunOrLumiIndexes::run(), edm::IndexIntoFile::SortedRunOrLumiItr::runOrLumiIndexes(), runOrLumiIndexes(), and DBoxMetadataHelper::set_intersection().

Referenced by edm::DuplicateChecker::inputFileOpened().

717  {
718  if (empty() || indexIntoFile.empty())
719  return;
721  indexIntoFile.fillRunOrLumiIndexes();
722  RunOrLumiIndexes const& back1 = runOrLumiIndexes().back();
723  RunOrLumiIndexes const& back2 = indexIntoFile.runOrLumiIndexes().back();
724 
725  // Very quick decision if the run ranges in the two files do not overlap
726  if (back2 < runOrLumiIndexes().front())
727  return;
728  if (back1 < indexIntoFile.runOrLumiIndexes().front())
729  return;
730 
731  SortedRunOrLumiItr iter1 = beginRunOrLumi();
732  SortedRunOrLumiItr iEnd1 = endRunOrLumi();
733 
734  SortedRunOrLumiItr iter2 = indexIntoFile.beginRunOrLumi();
735  SortedRunOrLumiItr iEnd2 = indexIntoFile.endRunOrLumi();
736 
737  // Quick decision if the lumi ranges in the two files do not overlap
738  while (iter1 != iEnd1 && iter1.isRun())
739  ++iter1;
740  if (iter1 == iEnd1)
741  return;
742  if (back2 < iter1.runOrLumiIndexes())
743  return;
744 
745  while (iter2 != iEnd2 && iter2.isRun())
746  ++iter2;
747  if (iter2 == iEnd2)
748  return;
749  if (back1 < iter2.runOrLumiIndexes())
750  return;
751 
752  RunOrLumiIndexes const* previousIndexes = nullptr;
753 
754  // Loop through the both IndexIntoFile objects and look for matching lumis
755  while (iter1 != iEnd1 && iter2 != iEnd2) {
756  RunOrLumiIndexes const& indexes1 = iter1.runOrLumiIndexes();
757  RunOrLumiIndexes const& indexes2 = iter2.runOrLumiIndexes();
758  if (indexes1 < indexes2) {
759  ++iter1;
760  } else if (indexes2 < indexes1) {
761  ++iter2;
762  } else { // they are equal
763 
764  // Skip them if it is a run or the same lumi
765  if (indexes1.isRun() || (previousIndexes && !(*previousIndexes < indexes1))) {
766  ++iter1;
767  ++iter2;
768  } else {
769  previousIndexes = &indexes1;
770 
771  // Found a matching lumi, now look for matching events
772 
773  long long beginEventNumbers1 = indexes1.beginEventNumbers();
774  long long endEventNumbers1 = indexes1.endEventNumbers();
775 
776  long long beginEventNumbers2 = indexes2.beginEventNumbers();
777  long long endEventNumbers2 = indexes2.endEventNumbers();
778 
779  // there must be at least 1 event in each lumi for there to be any matches
780  if ((beginEventNumbers1 >= endEventNumbers1) || (beginEventNumbers2 >= endEventNumbers2)) {
781  ++iter1;
782  ++iter2;
783  continue;
784  }
785 
786  if (!eventEntries().empty() && !indexIntoFile.eventEntries().empty()) {
787  std::vector<EventEntry> matchingEvents;
788  std::insert_iterator<std::vector<EventEntry> > insertIter(matchingEvents, matchingEvents.begin());
789  std::set_intersection(eventEntries().begin() + beginEventNumbers1,
790  eventEntries().begin() + endEventNumbers1,
791  indexIntoFile.eventEntries().begin() + beginEventNumbers2,
792  indexIntoFile.eventEntries().begin() + endEventNumbers2,
793  insertIter);
794  for (EventEntry const& entry : matchingEvents) {
795  intersection.insert(IndexRunLumiEventKey(
796  indexes1.processHistoryIDIndex(), indexes1.run(), indexes1.lumi(), entry.event()));
797  }
798  } else {
800  indexIntoFile.fillEventNumbers();
801  std::vector<EventNumber_t> matchingEvents;
802  std::insert_iterator<std::vector<EventNumber_t> > insertIter(matchingEvents, matchingEvents.begin());
803  std::set_intersection(eventNumbers().begin() + beginEventNumbers1,
804  eventNumbers().begin() + endEventNumbers1,
805  indexIntoFile.eventNumbers().begin() + beginEventNumbers2,
806  indexIntoFile.eventNumbers().begin() + endEventNumbers2,
807  insertIter);
808  for (EventNumber_t const& eventNumber : matchingEvents) {
809  intersection.insert(
810  IndexRunLumiEventKey(indexes1.processHistoryIDIndex(), indexes1.run(), indexes1.lumi(), eventNumber));
811  }
812  }
813  }
814  }
815  }
816  }
std::vector< EventEntry > & eventEntries() const
SortedRunOrLumiItr beginRunOrLumi() const
bool empty() const
True if no runs, lumis, or events are in the file.
unsigned long long EventNumber_t
std::vector< RunOrLumiIndexes > & runOrLumiIndexes() const
IndexIntoFileItr begin(SortOrder sortOrder) const
void fillRunOrLumiIndexes() const
void fillEventNumbers() const
list entry
Definition: mps_splice.py:68
std::vector< EventNumber_t > & eventNumbers() const
SortedRunOrLumiItr endRunOrLumi() const
std::vector< std::string > set_intersection(std::vector< std::string > const &v1, std::vector< std::string > const &v2)
void edm::IndexIntoFile::setEventFinder ( std::shared_ptr< EventFinder ptr)
inline

Calling this enables the functions that fill the event vectors to get the event numbers. It needs to be called before filling the events vectors This implies the client needs to define a class that inherits from EventFinder and then create one. This function is used to pass in a pointer to its base class.

Definition at line 996 of file IndexIntoFile.h.

References edm::IndexIntoFile::Transients::eventFinder_, and transient_.

Referenced by fwlite::EntryFinder::fillIndex(), and edm::RootFile::validateFile().

996 { transient_.eventFinder_ = ptr; }
edm::propagate_const< std::shared_ptr< EventFinder > > eventFinder_
void edm::IndexIntoFile::setNumberOfEvents ( EntryNumber_t  nevents)
inline

The number of events needs to be set before filling the transient event vectors. It is used to resize them.

Definition at line 989 of file IndexIntoFile.h.

References cmsHarvester::nevents, edm::IndexIntoFile::Transients::numberOfEvents_, and transient_.

Referenced by addEntry(), fwlite::EntryFinder::fillIndex(), and edm::RootFile::validateFile().

std::vector<ProcessHistoryID>& edm::IndexIntoFile::setProcessHistoryIDs ( )
inline

Used for backward compatibility and tests. RootFile::fillIndexIntoFile uses this to deal with input files created with releases before 3_8_0 which do not contain an IndexIntoFile.

Definition at line 1056 of file IndexIntoFile.h.

References processHistoryIDs_.

Referenced by edm::RootFile::fillIndexIntoFile(), and edm::RootFile::validateFile().

1056 { return processHistoryIDs_; }
std::vector< ProcessHistoryID > processHistoryIDs_
std::vector<RunOrLumiEntry>& edm::IndexIntoFile::setRunOrLumiEntries ( )
inline

Used for backward compatibility and tests. RootFile::fillIndexIntoFile uses this to deal with input files created with releases before 3_8_0 which do not contain an IndexIntoFile.

Definition at line 1051 of file IndexIntoFile.h.

References runOrLumiEntries_.

Referenced by edm::RootFile::fillIndexIntoFile().

1051 { return runOrLumiEntries_; }
std::vector< RunOrLumiEntry > runOrLumiEntries_
void edm::IndexIntoFile::sortEventEntries ( ) const
private

Definition at line 436 of file IndexIntoFile.cc.

References cms::cuda::assert(), begin(), eventEntries(), fillRunOrLumiIndexes(), and runOrLumiIndexes().

Referenced by fillEventNumbersOrEntries().

436  {
438  std::vector<RunOrLumiIndexes>::iterator beginOfLumi = runOrLumiIndexes().begin();
439  std::vector<RunOrLumiIndexes>::iterator endOfLumi = beginOfLumi;
440  std::vector<RunOrLumiIndexes>::iterator iEnd = runOrLumiIndexes().end();
441  while (true) {
442  while (beginOfLumi != iEnd && beginOfLumi->isRun()) {
443  ++beginOfLumi;
444  }
445  if (beginOfLumi == iEnd)
446  break;
447 
448  endOfLumi = beginOfLumi + 1;
449  while (endOfLumi != iEnd && beginOfLumi->processHistoryIDIndex() == endOfLumi->processHistoryIDIndex() &&
450  beginOfLumi->run() == endOfLumi->run() && beginOfLumi->lumi() == endOfLumi->lumi()) {
451  ++endOfLumi;
452  }
453  assert(beginOfLumi->endEventNumbers() >= 0);
454  assert(beginOfLumi->endEventNumbers() <= static_cast<long long>(eventEntries().size()));
455  std::sort(eventEntries().begin() + beginOfLumi->beginEventNumbers(),
456  eventEntries().begin() + beginOfLumi->endEventNumbers());
457  beginOfLumi = endOfLumi;
458  }
459  }
std::vector< EventEntry > & eventEntries() const
std::vector< RunOrLumiIndexes > & runOrLumiIndexes() const
IndexIntoFileItr begin(SortOrder sortOrder) const
assert(be >=bs)
void fillRunOrLumiIndexes() const
void edm::IndexIntoFile::sortEvents ( ) const
private

Definition at line 411 of file IndexIntoFile.cc.

References cms::cuda::assert(), begin(), eventNumbers(), fillRunOrLumiIndexes(), and runOrLumiIndexes().

Referenced by fillEventNumbersOrEntries().

411  {
413  std::vector<RunOrLumiIndexes>::iterator beginOfLumi = runOrLumiIndexes().begin();
414  std::vector<RunOrLumiIndexes>::iterator endOfLumi = beginOfLumi;
415  std::vector<RunOrLumiIndexes>::iterator iEnd = runOrLumiIndexes().end();
416  while (true) {
417  while (beginOfLumi != iEnd && beginOfLumi->isRun()) {
418  ++beginOfLumi;
419  }
420  if (beginOfLumi == iEnd)
421  break;
422 
423  endOfLumi = beginOfLumi + 1;
424  while (endOfLumi != iEnd && beginOfLumi->processHistoryIDIndex() == endOfLumi->processHistoryIDIndex() &&
425  beginOfLumi->run() == endOfLumi->run() && beginOfLumi->lumi() == endOfLumi->lumi()) {
426  ++endOfLumi;
427  }
428  assert(beginOfLumi->endEventNumbers() >= 0);
429  assert(beginOfLumi->endEventNumbers() <= static_cast<long long>(eventNumbers().size()));
430  std::sort(eventNumbers().begin() + beginOfLumi->beginEventNumbers(),
431  eventNumbers().begin() + beginOfLumi->endEventNumbers());
432  beginOfLumi = endOfLumi;
433  }
434  }
std::vector< RunOrLumiIndexes > & runOrLumiIndexes() const
IndexIntoFileItr begin(SortOrder sortOrder) const
assert(be >=bs)
void fillRunOrLumiIndexes() const
std::vector< EventNumber_t > & eventNumbers() const
void edm::IndexIntoFile::sortVector_Run_Or_Lumi_Entries ( )

Used by RootOutputModule after all entries have been added. This only works after the correct sequence of addEntry calls, because it makes some corrections before sorting. A std::stable_sort works in cases where those corrections are not needed.

Definition at line 392 of file IndexIntoFile.cc.

References Exception, B2GTnPMonitor_cfi::item, edm::errors::LogicError, runOrLumiEntries_, runToOrder(), and edm::stable_sort_all().

Referenced by edm::RootOutputFile::writeIndexIntoFile().

392  {
393  for (RunOrLumiEntry& item : runOrLumiEntries_) {
394  std::map<IndexRunKey, EntryNumber_t>::const_iterator keyAndOrder =
395  runToOrder().find(IndexRunKey(item.processHistoryIDIndex(), item.run()));
396  if (keyAndOrder == runToOrder().end()) {
398  << "In IndexIntoFile::sortVector_Run_Or_Lumi_Entries. A run entry is missing.\n"
399  << "This means the IndexIntoFile product in the output file will be corrupted.\n"
400  << "The output file will be unusable for most purposes.\n"
401  << "If this occurs after an unrelated exception was thrown in\n"
402  << "endLuminosityBlock or endRun then ignore this exception and fix\n"
403  << "the primary exception. This is an expected side effect.\n"
404  << "Otherwise please report this to the core framework developers\n";
405  }
406  item.setOrderPHIDRun(keyAndOrder->second);
407  }
408  stable_sort_all(runOrLumiEntries_);
409  }
void stable_sort_all(RandomAccessSequence &s)
wrappers for std::stable_sort
Definition: Algorithms.h:103
std::vector< RunOrLumiEntry > runOrLumiEntries_
std::map< IndexRunKey, EntryNumber_t > & runToOrder() const
std::vector<EventNumber_t>& edm::IndexIntoFile::unsortedEventNumbers ( )
inline

If something external to IndexIntoFile is reading through the EventAuxiliary then it could use this to fill in the event numbers so that IndexIntoFile will not read through it again.

Definition at line 1038 of file IndexIntoFile.h.

References transient_, and edm::IndexIntoFile::Transients::unsortedEventNumbers_.

Referenced by doneFileInitialization(), fillEventNumbersOrEntries(), edm::RootFile::fillIndexIntoFile(), fillUnsortedEventNumbers(), and inputFileClosed().

std::vector< EventNumber_t > unsortedEventNumbers_
std::vector<EventNumber_t> const& edm::IndexIntoFile::unsortedEventNumbers ( ) const
inline

Definition at line 1039 of file IndexIntoFile.h.

References transient_, and edm::IndexIntoFile::Transients::unsortedEventNumbers_.

std::vector< EventNumber_t > unsortedEventNumbers_
std::vector<EventNumber_t>& edm::IndexIntoFile::unsortedEventNumbersMutable ( ) const
inlineprivate

Definition at line 1106 of file IndexIntoFile.h.

References transient_, and edm::IndexIntoFile::Transients::unsortedEventNumbers_.

Referenced by fillUnsortedEventNumbers().

std::vector< EventNumber_t > unsortedEventNumbers_

Friends And Related Function Documentation

friend class ::TestIndexIntoFile
friend

Definition at line 1095 of file IndexIntoFile.h.

friend class ::TestIndexIntoFile1
friend

Definition at line 1096 of file IndexIntoFile.h.

friend class ::TestIndexIntoFile2
friend

Definition at line 1097 of file IndexIntoFile.h.

friend class ::TestIndexIntoFile3
friend

Definition at line 1098 of file IndexIntoFile.h.

friend class ::TestIndexIntoFile4
friend

Definition at line 1099 of file IndexIntoFile.h.

friend class ::TestIndexIntoFile5
friend

Definition at line 1100 of file IndexIntoFile.h.

Member Data Documentation

constexpr EntryNumber_t edm::IndexIntoFile::continuedLumi = -2LL
static
IndexIntoFile::EntryNumber_t const edm::IndexIntoFile::invalidEntry = -1LL
static

Definition at line 236 of file IndexIntoFile.h.

Referenced by addEntry(), addLumi(), edm::IndexIntoFile::IndexIntoFileItrNoSort::entry(), edm::IndexIntoFile::IndexIntoFileItrSorted::entry(), edm::IndexIntoFile::IndexIntoFileItrEntryOrder::entry(), edm::IndexIntoFile::IndexIntoFileItrEntryOrder::entryContinues(), fillEventNumbersOrEntries(), edm::RootFile::fillIndexIntoFile(), fillRunOrLumiIndexes(), findPosition(), edm::IndexIntoFile::IndexIntoFileItrImpl::firstEventEntryThisLumi(), edm::IndexIntoFile::IndexIntoFileItrImpl::firstEventEntryThisRun(), edm::IndexIntoFile::IndexIntoFileItrEntryOrder::IndexIntoFileItrEntryOrder(), edm::RootFile::initializeDuplicateChecker(), edm::RootFile::initializeFirstProcessBlockEntry(), edm::IndexIntoFile::IndexIntoFileItrNoSort::initializeLumi_(), edm::IndexIntoFile::IndexIntoFileItrEntryOrder::initializeLumi_(), iterationWillBeInEntryOrder(), edm::IndexIntoFile::IndexIntoFileItrNoSort::lumiEntryValid(), edm::IndexIntoFile::IndexIntoFileItrSorted::lumiEntryValid(), edm::IndexIntoFile::IndexIntoFileItrEntryOrder::lumiEntryValid(), edm::IndexIntoFile::IndexIntoFileItrNoSort::nextEventRange(), edm::IndexIntoFile::IndexIntoFileItrEntryOrder::nextEventRange(), edm::IndexIntoFile::IndexIntoFileItrNoSort::peekAheadAtEventEntry(), edm::IndexIntoFile::IndexIntoFileItrSorted::peekAheadAtEventEntry(), edm::IndexIntoFile::IndexIntoFileItrEntryOrder::peekAheadAtEventEntry(), edm::IndexIntoFile::IndexIntoFileItrNoSort::previousEventRange(), edm::IndexIntoFile::IndexIntoFileItrEntryOrder::previousEventRange(), edm::RootFile::readLuminosityBlockAuxiliary_(), edm::RootEmbeddedFileSequence::readOneSequential(), edm::RootFile::readRunAuxiliary_(), edm::IndexIntoFile::Transients::reset(), edm::RootTree::rewindToInvalid(), edm::RootEmbeddedFileSequence::RootEmbeddedFileSequence(), edm::IndexIntoFile::IndexIntoFileItrNoSort::setToLastEventInRange(), edm::IndexIntoFile::IndexIntoFileItrEntryOrder::setToLastEventInRange(), edm::RootEmbeddedFileSequence::skipEntries(), edm::IndexIntoFile::IndexIntoFileItrImpl::skipEventBackward(), edm::IndexIntoFile::IndexIntoFileItrImpl::skipEventForward(), edm::RootFile::skipEvents(), and edm::RootFile::wasFirstEventJustRead().

EventNumber_t const edm::IndexIntoFile::invalidEvent = 0U
static
int const edm::IndexIntoFile::invalidIndex = -1
static

Definition at line 232 of file IndexIntoFile.h.

Referenced by addEntry(), edm::IndexIntoFile::IndexIntoFileItrImpl::advanceToNextLumiOrRun(), begin(), end(), findPosition(), edm::IndexIntoFile::IndexIntoFileItrImpl::firstEventEntryThisLumi(), edm::IndexIntoFile::IndexIntoFileItrImpl::firstEventEntryThisRun(), edm::IndexIntoFile::IndexIntoFileItrNoSort::initializeLumi_(), edm::IndexIntoFile::IndexIntoFileItrSorted::initializeLumi_(), edm::IndexIntoFile::IndexIntoFileItrEntryOrder::initializeLumi_(), edm::IndexIntoFile::IndexIntoFileItrImpl::initializeRun(), edm::IndexIntoFile::IndexIntoFileItrNoSort::nextEventRange(), edm::IndexIntoFile::IndexIntoFileItrEntryOrder::nextEventRange(), edm::IndexIntoFile::IndexIntoFileItrNoSort::peekAheadAtEventEntry(), edm::IndexIntoFile::IndexIntoFileItrSorted::peekAheadAtEventEntry(), edm::IndexIntoFile::IndexIntoFileItrEntryOrder::peekAheadAtEventEntry(), edm::IndexIntoFile::IndexIntoFileItrNoSort::peekAheadAtLumi(), edm::IndexIntoFile::IndexIntoFileItrSorted::peekAheadAtLumi(), edm::IndexIntoFile::IndexIntoFileItrEntryOrder::peekAheadAtLumi(), edm::IndexIntoFile::IndexIntoFileItrNoSort::previousEventRange(), edm::IndexIntoFile::IndexIntoFileItrEntryOrder::previousEventRange(), edm::IndexIntoFile::IndexIntoFileItrImpl::previousLumiWithEvents(), edm::IndexIntoFile::IndexIntoFileItrNoSort::processHistoryIDIndex(), edm::IndexIntoFile::IndexIntoFileItrSorted::processHistoryIDIndex(), edm::IndexIntoFile::IndexIntoFileItrEntryOrder::processHistoryIDIndex(), edm::IndexIntoFile::Transients::reset(), edm::IndexIntoFile::IndexIntoFileItrImpl::setInvalid(), edm::IndexIntoFile::IndexIntoFileItrImpl::skipEventBackward(), edm::IndexIntoFile::IndexIntoFileItrImpl::skipEventForward(), edm::RootFile::skipEvents(), edm::IndexIntoFile::IndexIntoFileItrNoSort::skipLumiInRun(), edm::IndexIntoFile::IndexIntoFileItrSorted::skipLumiInRun(), and edm::IndexIntoFile::IndexIntoFileItrEntryOrder::skipLumiInRun().

LuminosityBlockNumber_t const edm::IndexIntoFile::invalidLumi = 0U
static
RunNumber_t const edm::IndexIntoFile::invalidRun = 0U
static
std::vector<ProcessHistoryID> edm::IndexIntoFile::processHistoryIDs_
private
std::vector<RunOrLumiEntry> edm::IndexIntoFile::runOrLumiEntries_
private
Transients edm::IndexIntoFile::transient_
mutableprivate