CMS 3D CMS Logo

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

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 () const
 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 () const
 
void inputFileClosed () const
 
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) const
 
void setNumberOfEvents (EntryNumber_t nevents) const
 
std::vector< ProcessHistoryID > & setProcessHistoryIDs ()
 
std::vector< RunOrLumiEntry > & setRunOrLumiEntries ()
 
void sortVector_Run_Or_Lumi_Entries ()
 
std::vector< EventNumber_t > & unsortedEventNumbers () const
 
 ~IndexIntoFile ()
 

Static Public Attributes

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
 

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 224 of file IndexIntoFile.h.

Member Typedef Documentation

Definition at line 230 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 

Definition at line 265 of file IndexIntoFile.h.

Constructor & Destructor Documentation

edm::IndexIntoFile::IndexIntoFile ( )

Definition at line 52 of file IndexIntoFile.cc.

52  : transient_(),
55  }
std::vector< RunOrLumiEntry > runOrLumiEntries_
std::vector< ProcessHistoryID > processHistoryIDs_
edm::IndexIntoFile::~IndexIntoFile ( )

Definition at line 57 of file IndexIntoFile.cc.

57  {
58  }

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 85 of file IndexIntoFile.cc.

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

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

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

Definition at line 69 of file IndexIntoFile.cc.

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

Referenced by addEntry(), and edm::IndexIntoFile::EventFinder::~EventFinder().

69  {
70  // assign each lumi an order value sequentially when first seen
71  std::pair<IndexRunLumiKey, EntryNumber_t> keyAndOrder(IndexRunLumiKey(index, run, lumi), lumiToOrder().size());
72  lumiToOrder().insert(keyAndOrder); // does nothing if this key already was inserted
73  runOrLumiEntries_.emplace_back(
75  lumiToOrder()[IndexRunLumiKey(index, run, lumi)],
76  entry, index,
77  run, lumi,
78  beginEvents(), endEvents());
81 
82  }
size
Write out results.
std::map< IndexRunLumiKey, EntryNumber_t > & lumiToOrder() const
std::vector< RunOrLumiEntry > runOrLumiEntries_
static constexpr EntryNumber_t invalidEntry
EntryNumber_t & endEvents() const
EntryNumber_t & beginEvents() const
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 500 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().

500  {
501  if(empty()) {
502  return end(sortOrder);
503  }
504  IndexIntoFileItr iter(this,
505  sortOrder,
506  kRun,
507  0,
508  invalidIndex,
509  invalidIndex,
510  0,
511  0);
512  iter.initializeRun();
513  return iter;
514  }
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 786 of file IndexIntoFile.cc.

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

786  {
787  return SortedRunOrLumiItr(this, 0);
788  }
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 895 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 plotBeamSpotDB::last.

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

895  {
896 
897  RunOrLumiIndexes const* previousIndexes = nullptr;
898 
899  for(SortedRunOrLumiItr iter = beginRunOrLumi(),
900  iEnd = endRunOrLumi();
901  iter != iEnd; ++iter) {
902 
903  RunOrLumiIndexes const& indexes = iter.runOrLumiIndexes();
904 
905  // Skip it if it is a run or the same lumi
906  if(indexes.isRun() ||
907  (previousIndexes && !(*previousIndexes < indexes))) {
908  continue;
909  }
910  previousIndexes = &indexes;
911 
912  long long beginEventNumbers = indexes.beginEventNumbers();
913  long long endEventNumbers = indexes.endEventNumbers();
914 
915  // there must be more than 1 event in the lumi for there to be any duplicates
916  if(beginEventNumbers + 1 >= endEventNumbers) continue;
917 
918  if(!eventEntries().empty()) {
919  std::vector<EventEntry>::iterator last = eventEntries().begin() + endEventNumbers;
920  if(std::adjacent_find(eventEntries().begin() + beginEventNumbers, last) != last) {
921  return true;
922  }
923  } else {
925  std::vector<EventNumber_t>::iterator last = eventNumbers().begin() + endEventNumbers;
926  if(std::adjacent_find(eventNumbers().begin() + beginEventNumbers, last) != last) {
927  return true;
928  }
929  }
930  }
931  return false;
932  }
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
bool edm::IndexIntoFile::containsEvent ( RunNumber_t  run,
LuminosityBlockNumber_t  lumi,
EventNumber_t  event 
) const

Definition at line 772 of file IndexIntoFile.cc.

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

Referenced by containsItem().

772  {
774  }
IndexIntoFileItr findEventPosition(RunNumber_t run, LuminosityBlockNumber_t lumi, EventNumber_t event) const
Definition: event.py:1
bool edm::IndexIntoFile::containsItem ( RunNumber_t  run,
LuminosityBlockNumber_t  lumi,
EventNumber_t  event 
) const

Definition at line 767 of file IndexIntoFile.cc.

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

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

767  {
768  return (event != 0) ? containsEvent(run, lumi, event) : (lumi ? containsLumi(run, lumi) : containsRun(run));
769  }
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
Definition: event.py:1
bool edm::IndexIntoFile::containsLumi ( RunNumber_t  run,
LuminosityBlockNumber_t  lumi 
) const

Definition at line 777 of file IndexIntoFile.cc.

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

Referenced by containsItem().

777  {
778  return findLumiPosition(run, lumi).getEntryType() != kEnd;
779  }
IndexIntoFileItr findLumiPosition(RunNumber_t run, LuminosityBlockNumber_t lumi) const
bool edm::IndexIntoFile::containsRun ( RunNumber_t  run) const

Definition at line 782 of file IndexIntoFile.cc.

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

Referenced by containsItem().

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

Definition at line 1110 of file IndexIntoFile.h.

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

Referenced by addEntry().

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

Definition at line 1109 of file IndexIntoFile.h.

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

Referenced by addEntry().

void edm::IndexIntoFile::doneFileInitialization ( ) const

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

Definition at line 335 of file IndexIntoFile.cc.

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

Referenced by edm::RootFile::RootFile(), and unsortedEventNumbers().

335  {
336  std::vector<EventNumber_t>().swap(unsortedEventNumbers());
337  }
void swap(Association< C > &lhs, Association< C > &rhs)
Definition: Association.h:116
std::vector< EventNumber_t > & unsortedEventNumbers() const
bool edm::IndexIntoFile::empty ( ) const
IndexIntoFile::IndexIntoFileItr edm::IndexIntoFile::end ( SortOrder  sortOrder) const

Used to end an iteration over the Runs, Lumis, and Events in a file.

Definition at line 516 of file IndexIntoFile.cc.

References invalidIndex, and kEnd.

Referenced by begin(), Types.LuminosityBlockRange::cppID(), Types.EventRange::cppID(), fwlite::EntryFinder::findEvent(), fwlite::EntryFinder::findLumi(), findPosition(), fwlite::EntryFinder::findRun(), edm::RootFile::goToEvent(), iterationWillBeInEntryOrder(), edm::postIndexIntoFilePrintEventLists(), edm::postIndexIntoFilePrintEventsInLumis(), and edm::RootFile::RootFile().

516  {
517  return IndexIntoFileItr(this,
518  sortOrder,
519  kEnd,
520  invalidIndex,
521  invalidIndex,
522  invalidIndex,
523  0,
524  0);
525  }
static constexpr int invalidIndex
EntryNumber_t& edm::IndexIntoFile::endEvents ( ) const
inlineprivate
IndexIntoFile::SortedRunOrLumiItr edm::IndexIntoFile::endRunOrLumi ( ) const

Definition at line 790 of file IndexIntoFile.cc.

References runOrLumiEntries(), and findQualityFiles::size.

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

790  {
791  return SortedRunOrLumiItr(this, runOrLumiEntries().size());
792  }
size
Write out results.
std::vector< RunOrLumiEntry > const & runOrLumiEntries() const
Used internally and for test purposes.
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 224 of file IndexIntoFile.cc.

References fillEventNumbersOrEntries().

Referenced by edm::IndexIntoFile::IndexIntoFileItrSorted::entry(), edm::IndexIntoFile::IndexIntoFileItrSorted::peekAheadAtEventEntry(), and setEventFinder().

224  {
225  fillEventNumbersOrEntries(false, true);
226  }
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 219 of file IndexIntoFile.cc.

References fillEventNumbersOrEntries().

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

219  {
220  fillEventNumbersOrEntries(true, false);
221  }
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 229 of file IndexIntoFile.cc.

References beginRunOrLumi(), empty(), endRunOrLumi(), mps_splice::entry, event(), eventEntries(), eventNumbers(), fillUnsortedEventNumbers(), invalidEntry, numberOfEvents(), PFRecoTauDiscriminationByIsolation_cfi::offset, findQualityFiles::size, sortEventEntries(), sortEvents(), mitigatedMETSequence_cff::U, and unsortedEventNumbers().

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

229  {
230  if(numberOfEvents() == 0) {
231  return;
232  }
233 
234  if(needEventNumbers && !eventNumbers().empty()) {
235  needEventNumbers = false;
236  }
237 
238  if(needEventEntries && !eventEntries().empty()) {
239  needEventEntries = false;
240  }
241 
242  if(needEventNumbers && !eventEntries().empty()) {
243  assert(numberOfEvents() == eventEntries().size());
244  eventNumbers().reserve(eventEntries().size());
246  eventNumbers().push_back(eventEntries()[entry].event());
247  }
248  return;
249  }
250 
251  if(!needEventNumbers && !needEventEntries) {
252  return;
253  }
254 
256 
257  if(needEventNumbers) {
259  }
260  if(needEventEntries) {
261  eventEntries().resize(numberOfEvents());
262  }
263 
264  long long offset = 0;
265  long long previousBeginEventNumbers = -1LL;
266 
267  for(SortedRunOrLumiItr runOrLumi = beginRunOrLumi(), runOrLumiEnd = endRunOrLumi();
268  runOrLumi != runOrLumiEnd; ++runOrLumi) {
269 
270  if(runOrLumi.isRun()) continue;
271 
272  long long beginEventNumbers = 0;
273  long long endEventNumbers = 0;
274  EntryNumber_t beginEventEntry = invalidEntry;
275  EntryNumber_t endEventEntry = invalidEntry;
276  runOrLumi.getRange(beginEventNumbers, endEventNumbers, beginEventEntry, endEventEntry);
277 
278  // This is true each time one hits a new lumi section (except if the previous lumi had
279  // no events, in which case the offset is still 0 anyway)
280  if(beginEventNumbers != previousBeginEventNumbers) offset = 0;
281 
282  for(EntryNumber_t entry = beginEventEntry; entry != endEventEntry; ++entry) {
283  if(needEventNumbers) {
284  eventNumbers().at((entry - beginEventEntry) + offset + beginEventNumbers) = unsortedEventNumbers().at(entry);
285  }
286  if(needEventEntries) {
287  eventEntries().at((entry - beginEventEntry) + offset + beginEventNumbers) =
288  EventEntry(unsortedEventNumbers().at(entry), entry);
289  }
290  }
291 
292  previousBeginEventNumbers = beginEventNumbers;
293  offset += endEventEntry - beginEventEntry;
294  }
295  if(needEventNumbers) {
296  sortEvents();
297  assert(numberOfEvents() == eventNumbers().size());
298  }
299  if(needEventEntries) {
301  assert(numberOfEvents() == eventEntries().size());
302  }
303  }
size
Write out results.
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
uint16_t size_type
static constexpr EventNumber_t invalidEvent
size_t numberOfEvents() const
long long EntryNumber_t
How EventSelector::AcceptEvent() decides whether to accept an event for output otherwise it is excluding the probing of A single or multiple positive and the trigger will pass if any such matching triggers are PASS or EXCEPTION[A criterion thatmatches no triggers at all is detected and causes a throw.] A single negative with an expectation of appropriate bit checking in the decision and the trigger will pass if any such matching triggers are FAIL or EXCEPTION A wildcarded negative criterion that matches more than one trigger in the trigger but the state exists so we define the behavior If all triggers are the negative crieriion will lead to accepting the event(this again matches the behavior of"!*"before the partial wildcard feature was incorporated).The per-event"cost"of each negative criterion with multiple relevant triggers is about the same as!*was in the past
void sortEventEntries() const
std::vector< EventNumber_t > & unsortedEventNumbers() const
static constexpr EntryNumber_t invalidEntry
std::vector< EventNumber_t > & eventNumbers() const
SortedRunOrLumiItr endRunOrLumi() const
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 163 of file IndexIntoFile.cc.

References invalidEntry, 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().

163  {
164  if(runOrLumiEntries_.empty() || !runOrLumiIndexes().empty()) {
165  return;
166  }
167  runOrLumiIndexes().reserve(runOrLumiEntries_.size());
168 
169  int index = 0;
170  for(RunOrLumiEntry const& item : runOrLumiEntries_) {
171  runOrLumiIndexes().emplace_back(item.processHistoryIDIndex(),
172  item.run(),
173  item.lumi(),
174  index);
175  ++index;
176  }
178 
179  long long beginEventNumbers = 0;
180 
181  std::vector<RunOrLumiIndexes>::iterator beginOfLumi = runOrLumiIndexes().begin();
182  std::vector<RunOrLumiIndexes>::iterator endOfLumi = beginOfLumi;
183  std::vector<RunOrLumiIndexes>::iterator iEnd = runOrLumiIndexes().end();
184  while(true) {
185  while(beginOfLumi != iEnd && beginOfLumi->isRun()) {
186  ++beginOfLumi;
187  }
188  if(beginOfLumi == iEnd) break;
189 
190  endOfLumi = beginOfLumi + 1;
191  while(endOfLumi != iEnd &&
192  beginOfLumi->processHistoryIDIndex() == endOfLumi->processHistoryIDIndex() &&
193  beginOfLumi->run() == endOfLumi->run() &&
194  beginOfLumi->lumi() == endOfLumi->lumi()) {
195  ++endOfLumi;
196  }
197  int nEvents = 0;
198  for(std::vector<RunOrLumiIndexes>::iterator iter = beginOfLumi;
199  iter != endOfLumi;
200  ++iter) {
201  if(runOrLumiEntries_[iter->indexToGetEntry()].beginEvents() != invalidEntry) {
202  nEvents += runOrLumiEntries_[iter->indexToGetEntry()].endEvents() -
203  runOrLumiEntries_[iter->indexToGetEntry()].beginEvents();
204  }
205  }
206  for(std::vector<RunOrLumiIndexes>::iterator iter = beginOfLumi;
207  iter != endOfLumi;
208  ++iter) {
209  iter->setBeginEventNumbers(beginEventNumbers);
210  iter->setEndEventNumbers(beginEventNumbers + nEvents);
211  }
212  beginEventNumbers += nEvents;
213  beginOfLumi = endOfLumi;
214  }
215  assert(runOrLumiIndexes().size() == runOrLumiEntries_.size());
216  }
size
Write out results.
std::vector< RunOrLumiIndexes > & runOrLumiIndexes() const
void stable_sort_all(RandomAccessSequence &s)
wrappers for std::stable_sort
Definition: Algorithms.h:103
std::vector< RunOrLumiEntry > runOrLumiEntries_
static constexpr EntryNumber_t invalidEntry
UInt_t nEvents
Definition: hcalCalib.cc:41
void edm::IndexIntoFile::fillUnsortedEventNumbers ( ) const
private

Definition at line 306 of file IndexIntoFile.cc.

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

Referenced by fillEventNumbersOrEntries().

306  {
307  if(numberOfEvents() == 0 || !unsortedEventNumbers().empty()) {
308  return;
309  }
311 
312  // The main purpose for the existence of the unsortedEventNumbers
313  // vector is that it can easily be filled by reading through
314  // the EventAuxiliary branch in the same order as the TTree
315  // entries. fillEventNumbersOrEntries can then use this information
316  // instead of using getEventNumberOfEntry directly and reading
317  // the branch in a different order.
320  }
321  }
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() const
EventNumber_t getEventNumberOfEntry(EntryNumber_t entry) 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 746 of file IndexIntoFile.cc.

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

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

746  {
747  assert(event != invalidEvent);
748  IndexIntoFileItr iter = findPosition(run, lumi, event);
749  iter.advanceToEvent();
750  return iter;
751  }
static constexpr EventNumber_t invalidEvent
IndexIntoFileItr findPosition(RunNumber_t run, LuminosityBlockNumber_t lumi=0U, EventNumber_t event=0U) const
Definition: event.py:1
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 754 of file IndexIntoFile.cc.

References edm::IndexIntoFile::IndexIntoFileItr::advanceToLumi(), findPosition(), invalidLumi, and mitigatedMETSequence_cff::U.

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

754  {
755  assert(lumi != invalidLumi);
756  IndexIntoFileItr iter = findPosition(run, lumi, 0U);
757  iter.advanceToLumi();
758  return iter;
759  }
IndexIntoFileItr findPosition(RunNumber_t run, LuminosityBlockNumber_t lumi=0U, EventNumber_t event=0U) const
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 545 of file IndexIntoFile.cc.

References begin(), empty(), mps_splice::entry, event(), eventEntries(), eventNumbers(), fillEventNumbers(), fillRunOrLumiIndexes(), edm::IndexIntoFile::IndexIntoFileItr::initializeLumi(), edm::IndexIntoFile::IndexIntoFileItr::initializeRun(), invalidEntry, invalidEvent, invalidIndex, invalidLumi, kEnd, kRun, csvLumiCalc::lumi, numericalOrder, writedatasetfile::run, runOrLumiEntries_, and runOrLumiIndexes().

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

545  {
547 
548  bool lumiMissing = (lumi == 0 && event != 0);
549 
550  std::vector<RunOrLumiIndexes>::const_iterator iEnd = runOrLumiIndexes().end();
551  std::vector<RunOrLumiIndexes>::const_iterator phEnd;
552 
553  // Loop over ranges of entries with the same ProcessHistoryID
554  for(std::vector<RunOrLumiIndexes>::const_iterator phBegin = runOrLumiIndexes().begin();
555  phBegin != iEnd;
556  phBegin = phEnd) {
557 
558  RunOrLumiIndexes el(phBegin->processHistoryIDIndex(), run, lumi, 0);
559  phEnd = std::upper_bound(phBegin, iEnd, el, Compare_Index());
560 
561  std::vector<RunOrLumiIndexes>::const_iterator iRun = std::lower_bound(phBegin, phEnd, el, Compare_Index_Run());
562 
563  if(iRun == phEnd || iRun->run() != run) continue;
564 
565  if(lumi == invalidLumi && event == invalidEvent) {
566  IndexIntoFileItr indexItr(this,
568  kRun,
569  iRun - runOrLumiIndexes().begin(),
570  invalidIndex,
571  invalidIndex,
572  0,
573  0);
574  indexItr.initializeRun();
575  return indexItr;
576  }
577 
578  std::vector<RunOrLumiIndexes>::const_iterator iRunEnd = std::upper_bound(iRun, phEnd, el, Compare_Index_Run());
579  if(!lumiMissing) {
580 
581  std::vector<RunOrLumiIndexes>::const_iterator iLumi = std::lower_bound(iRun, iRunEnd, el);
582  if(iLumi == iRunEnd || iLumi->lumi() != lumi) continue;
583 
584  if(event == invalidEvent) {
585  IndexIntoFileItr indexItr(this,
587  kRun,
588  iRun - runOrLumiIndexes().begin(),
589  iLumi - runOrLumiIndexes().begin(),
590  invalidIndex,
591  0,
592  0);
593  indexItr.initializeLumi();
594  return indexItr;
595  }
596 
597  long long beginEventNumbers = iLumi->beginEventNumbers();
598  long long endEventNumbers = iLumi->endEventNumbers();
599  if(beginEventNumbers >= endEventNumbers) continue;
600 
601 
602  long long indexToEvent = 0;
603  if(!eventEntries().empty()) {
604  std::vector<EventEntry>::const_iterator eventIter = std::lower_bound(eventEntries().begin() + beginEventNumbers,
605  eventEntries().begin() + endEventNumbers,
606  EventEntry(event, invalidEntry));
607  if(eventIter == (eventEntries().begin() + endEventNumbers) ||
608  eventIter->event() != event) continue;
609 
610  indexToEvent = eventIter - eventEntries().begin() - beginEventNumbers;
611  } else {
613  std::vector<EventNumber_t>::const_iterator eventIter = std::lower_bound(eventNumbers().begin() + beginEventNumbers,
614  eventNumbers().begin() + endEventNumbers,
615  event);
616  if(eventIter == (eventNumbers().begin() + endEventNumbers) ||
617  *eventIter != event) continue;
618 
619  indexToEvent = eventIter - eventNumbers().begin() - beginEventNumbers;
620  }
621 
622  int newIndexToLumi = iLumi - runOrLumiIndexes().begin();
623  while (runOrLumiEntries_[runOrLumiIndexes()[newIndexToLumi].indexToGetEntry()].entry() == invalidEntry) {
624  ++newIndexToLumi;
625  assert(static_cast<unsigned>(newIndexToLumi) < runOrLumiEntries_.size());
626  assert(runOrLumiIndexes()[newIndexToLumi].lumi() == lumi);
627  }
628 
629  return IndexIntoFileItr(this,
631  kRun,
632  iRun - runOrLumiIndexes().begin(),
633  newIndexToLumi,
634  iLumi - runOrLumiIndexes().begin(),
635  indexToEvent,
636  endEventNumbers - beginEventNumbers);
637  }
638  if(lumiMissing) {
639 
640  std::vector<RunOrLumiIndexes>::const_iterator iLumi = iRun;
641  while(iLumi != iRunEnd && iLumi->lumi() == invalidLumi) {
642  ++iLumi;
643  }
644  if(iLumi == iRunEnd) continue;
645 
646  std::vector<RunOrLumiIndexes>::const_iterator lumiEnd;
647  for( ;
648  iLumi != iRunEnd;
649  iLumi = lumiEnd) {
650 
651  RunOrLumiIndexes elWithLumi(phBegin->processHistoryIDIndex(), run, iLumi->lumi(), 0);
652  lumiEnd = std::upper_bound(iLumi, iRunEnd, elWithLumi);
653 
654  long long beginEventNumbers = iLumi->beginEventNumbers();
655  long long endEventNumbers = iLumi->endEventNumbers();
656  if(beginEventNumbers >= endEventNumbers) continue;
657 
658  long long indexToEvent = 0;
659  if(!eventEntries().empty()) {
660  std::vector<EventEntry>::const_iterator eventIter = std::lower_bound(eventEntries().begin() + beginEventNumbers,
661  eventEntries().begin() + endEventNumbers,
662  EventEntry(event, invalidEntry));
663  if(eventIter == (eventEntries().begin() + endEventNumbers) ||
664  eventIter->event() != event) continue;
665  indexToEvent = eventIter - eventEntries().begin() - beginEventNumbers;
666  } else {
668  std::vector<EventNumber_t>::const_iterator eventIter = std::lower_bound(eventNumbers().begin() + beginEventNumbers,
669  eventNumbers().begin() + endEventNumbers,
670  event);
671  if(eventIter == (eventNumbers().begin() + endEventNumbers) ||
672  *eventIter != event) continue;
673  indexToEvent = eventIter - eventNumbers().begin() - beginEventNumbers;
674  }
675 
676  int newIndexToLumi = iLumi - runOrLumiIndexes().begin();
677  while (runOrLumiEntries_[runOrLumiIndexes()[newIndexToLumi].indexToGetEntry()].entry() == invalidEntry) {
678  ++newIndexToLumi;
679  assert(static_cast<unsigned>(newIndexToLumi) < runOrLumiEntries_.size());
680  assert(runOrLumiIndexes()[newIndexToLumi].lumi() == iLumi->lumi());
681  }
682 
683  return IndexIntoFileItr(this,
685  kRun,
686  iRun - runOrLumiIndexes().begin(),
687  newIndexToLumi,
688  iLumi - runOrLumiIndexes().begin(),
689  indexToEvent,
690  endEventNumbers - beginEventNumbers);
691  }
692  }
693  } // Loop over ProcessHistoryIDs
694 
695  return IndexIntoFileItr(this,
697  kEnd,
698  invalidIndex,
699  invalidIndex,
700  invalidIndex,
701  0,
702  0);
703 
704  }
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
IndexIntoFileItr begin(SortOrder sortOrder) const
static constexpr EventNumber_t invalidEvent
std::vector< RunOrLumiEntry > runOrLumiEntries_
void fillRunOrLumiIndexes() const
How EventSelector::AcceptEvent() decides whether to accept an event for output otherwise it is excluding the probing of A single or multiple positive and the trigger will pass if any such matching triggers are PASS or EXCEPTION[A criterion thatmatches no triggers at all is detected and causes a throw.] A single negative with an expectation of appropriate bit checking in the decision and the trigger will pass if any such matching triggers are FAIL or EXCEPTION A wildcarded negative criterion that matches more than one trigger in the trigger but the state exists so we define the behavior If all triggers are the negative crieriion will lead to accepting the event(this again matches the behavior of"!*"before the partial wildcard feature was incorporated).The per-event"cost"of each negative criterion with multiple relevant triggers is about the same as!*was in the past
static constexpr EntryNumber_t invalidEntry
static constexpr LuminosityBlockNumber_t invalidLumi
void fillEventNumbers() const
std::vector< EventNumber_t > & eventNumbers() const
Definition: event.py:1
IndexIntoFile::IndexIntoFileItr edm::IndexIntoFile::findPosition ( SortOrder  sortOrder,
RunNumber_t  run,
LuminosityBlockNumber_t  lumi = 0U,
EventNumber_t  event = 0U 
) const

Definition at line 707 of file IndexIntoFile.cc.

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

707  {
708  if(sortOrder == IndexIntoFile::numericalOrder) {
709  return findPosition(run, lumi, event); // a faster algorithm
710  }
711  IndexIntoFileItr itr = begin(sortOrder);
712  IndexIntoFileItr itrEnd = end(sortOrder);
713 
714  while(itr != itrEnd) {
715  if(itr.run() != run) {
716  itr.advanceToNextRun();
717  } else {
718  if(lumi == invalidLumi && event == invalidEvent) {
719  return itr;
720  } else if(lumi != invalidLumi && itr.peekAheadAtLumi() != lumi) {
721  if(!itr.skipLumiInRun()) {
722  itr.advanceToNextRun();
723  }
724  } else {
725  if(event == invalidEvent) {
726  return itr;
727  } else {
728  EventNumber_t eventNumber = getEventNumberOfEntry(itr.peekAheadAtEventEntry());
729  if(eventNumber == event) {
730  return itr;
731  } else {
732  if(!itr.skipToNextEventInLumi()) {
733  if(!itr.skipLumiInRun()) {
734  itr.advanceToNextRun();
735  }
736  }
737  }
738  }
739  }
740  }
741  }
742  return itrEnd;
743  }
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.
static constexpr LuminosityBlockNumber_t invalidLumi
EventNumber_t getEventNumberOfEntry(EntryNumber_t entry) const
Definition: event.py:1
IndexIntoFile::IndexIntoFileItr edm::IndexIntoFile::findRunPosition ( RunNumber_t  run) const

Same as findPosition.

Definition at line 762 of file IndexIntoFile.cc.

References findPosition(), and mitigatedMETSequence_cff::U.

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

762  {
763  return findPosition(run, 0U, 0U);
764  }
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 406 of file IndexIntoFile.cc.

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

Referenced by edm::RootFile::validateFile(), and edm::IndexIntoFile::EventFinder::~EventFinder().

406  {
407 
408  std::map<int, int> oldToNewIndex;
409  for(std::vector<ProcessHistoryID>::const_iterator iter = processHistoryIDs_.begin(),
410  iEnd = processHistoryIDs_.end();
411  iter != iEnd;
412  ++iter) {
413  std::vector<ProcessHistoryID>::const_iterator iterExisting =
414  std::find(processHistoryIDs.begin(), processHistoryIDs.end(), *iter);
415  if(iterExisting == processHistoryIDs.end()) {
416  oldToNewIndex[iter - processHistoryIDs_.begin()] = processHistoryIDs.size();
417  processHistoryIDs.push_back(*iter);
418  } else {
419  oldToNewIndex[iter - processHistoryIDs_.begin()] = iterExisting - processHistoryIDs.begin();
420  }
421  }
423 
424  for(RunOrLumiEntry& item : runOrLumiEntries_) {
425  item.setProcessHistoryIDIndex(oldToNewIndex[item.processHistoryIDIndex()]);
426  }
427  }
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:20
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 1113 of file IndexIntoFile.h.

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

Referenced by fillUnsortedEventNumbers(), findPosition(), and edm::IndexIntoFile::EventFinder::~EventFinder().

1113  {
1114  return transient_.eventFinder_->getEventNumberOfEntry(entry);
1115  }
edm::propagate_const< std::shared_ptr< EventFinder > > eventFinder_
void edm::IndexIntoFile::initializeTransients ( ) const
inline
void edm::IndexIntoFile::inputFileClosed ( ) const

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

Definition at line 327 of file IndexIntoFile.cc.

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

Referenced by unsortedEventNumbers().

327  {
328  std::vector<EventEntry>().swap(eventEntries());
329  std::vector<RunOrLumiIndexes>().swap(runOrLumiIndexes());
330  std::vector<EventNumber_t>().swap(unsortedEventNumbers());
332  }
std::vector< EventEntry > & eventEntries() const
std::vector< RunOrLumiIndexes > & runOrLumiIndexes() const
void swap(Association< C > &lhs, Association< C > &rhs)
Definition: Association.h:116
void resetEventFinder() const
std::vector< EventNumber_t > & unsortedEventNumbers() const
bool edm::IndexIntoFile::iterationWillBeInEntryOrder ( SortOrder  sortOrder) const

Used to determine whether or not to disable fast cloning.

Definition at line 527 of file IndexIntoFile.cc.

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

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

527  {
528  EntryNumber_t maxEntry = invalidEntry;
529  for(IndexIntoFileItr it = begin(sortOrder), itEnd = end(sortOrder); it != itEnd; ++it) {
530  if(it.getEntryType() == kEvent) {
531  if(it.entry() < maxEntry) {
532  return false;
533  }
534  maxEntry = it.entry();
535  }
536  }
537  return true;
538  }
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 1105 of file IndexIntoFile.h.

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

Referenced by addLumi().

1105 {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 60 of file IndexIntoFile.cc.

References processHistoryIDs_.

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

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

Definition at line 64 of file IndexIntoFile.cc.

References processHistoryIDs_.

Referenced by fixIndexes().

64  {
65  return processHistoryIDs_;
66  }
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 340 of file IndexIntoFile.cc.

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

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

340  {
341 
342  std::vector<ProcessHistoryID> reducedPHIDs;
343 
344  std::map<ProcessHistoryID, int> reducedPHIDToIndex;
345  std::pair<ProcessHistoryID, int> mapEntry(ProcessHistoryID(), 0);
346  std::pair<std::map<ProcessHistoryID, int>::iterator, bool> insertResult;
347 
348  std::vector<int> phidIndexConverter;
349  for(auto const& phid : processHistoryIDs_) {
350 
351  ProcessHistoryID const& reducedPHID = processHistoryRegistry.reducedProcessHistoryID(phid);
352  mapEntry.first = reducedPHID;
353  insertResult = reducedPHIDToIndex.insert(mapEntry);
354 
355  if(insertResult.second) {
356  insertResult.first->second = reducedPHIDs.size();
357  reducedPHIDs.push_back(reducedPHID);
358  }
359  phidIndexConverter.push_back(insertResult.first->second);
360  }
361  processHistoryIDs_.swap(reducedPHIDs);
362 
363  // If the size of the vector of IDs does not change
364  // then their indexes and the ordering of the Runs and
365  // and Lumis does not change, so we are done.
366  if(processHistoryIDs_.size() == reducedPHIDs.size()) {
367  return;
368  }
369 
370  std::map<IndexIntoFile::IndexRunKey, int> runOrderMap;
371  std::pair<std::map<IndexIntoFile::IndexRunKey, int>::iterator, bool> runInsertResult;
372 
373  std::map<IndexIntoFile::IndexRunLumiKey, int> lumiOrderMap;
374  std::pair<std::map<IndexIntoFile::IndexRunLumiKey, int>::iterator, bool> lumiInsertResult;
375 
376  // loop over all the RunOrLumiEntry's
377  for(auto& item : runOrLumiEntries_) {
378 
379  // Convert the process history index so it points into the new vector of reduced IDs
380  item.setProcessHistoryIDIndex(phidIndexConverter.at(item.processHistoryIDIndex()));
381 
382  // Convert the phid-run order
383  IndexIntoFile::IndexRunKey runKey(item.processHistoryIDIndex(), item.run());
384  runInsertResult = runOrderMap.insert(std::pair<IndexIntoFile::IndexRunKey, int>(runKey,0));
385  if(runInsertResult.second) {
386  runInsertResult.first->second = item.orderPHIDRun();
387  } else {
388  item.setOrderPHIDRun(runInsertResult.first->second);
389  }
390 
391  // Convert the phid-run-lumi order for the lumi entries
392  if(item.lumi() != 0) {
393  IndexIntoFile::IndexRunLumiKey lumiKey(item.processHistoryIDIndex(), item.run(), item.lumi());
394  lumiInsertResult = lumiOrderMap.insert(std::pair<IndexIntoFile::IndexRunLumiKey, int>(lumiKey,0));
395  if(lumiInsertResult.second) {
396  lumiInsertResult.first->second = item.orderPHIDRunLumi();
397  } else {
398  item.setOrderPHIDRunLumi(lumiInsertResult.first->second);
399  }
400  }
401  }
402  std::stable_sort(runOrLumiEntries_.begin(), runOrLumiEntries_.end());
403  }
void swap(Hash< I > &other)
Definition: Hash.h:210
std::vector< RunOrLumiEntry > runOrLumiEntries_
std::vector< ProcessHistoryID > processHistoryIDs_
Hash< ProcessHistoryType > ProcessHistoryID
void edm::IndexIntoFile::resetEventFinder ( ) const
inlineprivate

Definition at line 1098 of file IndexIntoFile.h.

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

Referenced by inputFileClosed().

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

Definition at line 1111 of file IndexIntoFile.h.

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

Referenced by edm::IndexIntoFile::IndexIntoFileItrSorted::entry(), fillRunOrLumiIndexes(), findPosition(), edm::IndexIntoFile::SortedRunOrLumiItr::getRange(), edm::IndexIntoFile::IndexIntoFileItrSorted::getRunOrLumiEntryType(), edm::IndexIntoFile::IndexIntoFileItrSorted::initializeLumi_(), inputFileClosed(), edm::IndexIntoFile::SortedRunOrLumiItr::isRun(), edm::IndexIntoFile::IndexIntoFileItrSorted::isSameLumi(), edm::IndexIntoFile::IndexIntoFileItrSorted::isSameRun(), edm::IndexIntoFile::IndexIntoFileItrSorted::lumi(), edm::IndexIntoFile::IndexIntoFileItrSorted::lumiEntryValid(), edm::IndexIntoFile::IndexIntoFileItrSorted::peekAheadAtEventEntry(), edm::IndexIntoFile::IndexIntoFileItrSorted::peekAheadAtLumi(), edm::IndexIntoFile::IndexIntoFileItrSorted::processHistoryIDIndex(), edm::IndexIntoFile::IndexIntoFileItrSorted::run(), edm::IndexIntoFile::SortedRunOrLumiItr::runOrLumi(), edm::IndexIntoFile::SortedRunOrLumiItr::runOrLumiIndexes(), set_intersection(), edm::IndexIntoFile::IndexIntoFileItrSorted::setToLastEventInRange(), edm::IndexIntoFile::IndexIntoFileItrSorted::skipLumiInRun(), sortEventEntries(), and sortEvents().

1111 {return transient_.runOrLumiIndexes_;}
std::vector< RunOrLumiIndexes > runOrLumiIndexes_
std::map<IndexRunKey, EntryNumber_t>& edm::IndexIntoFile::runToOrder ( ) const
inlineprivate

Definition at line 1104 of file IndexIntoFile.h.

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

Referenced by addEntry(), and sortVector_Run_Or_Lumi_Entries().

1104 {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 794 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(), and runOrLumiIndexes().

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

795  {
796 
797  if(empty() || indexIntoFile.empty()) return;
799  indexIntoFile.fillRunOrLumiIndexes();
800  RunOrLumiIndexes const& back1 = runOrLumiIndexes().back();
801  RunOrLumiIndexes const& back2 = indexIntoFile.runOrLumiIndexes().back();
802 
803  // Very quick decision if the run ranges in the two files do not overlap
804  if(back2 < runOrLumiIndexes().front()) return;
805  if(back1 < indexIntoFile.runOrLumiIndexes().front()) return;
806 
807  SortedRunOrLumiItr iter1 = beginRunOrLumi();
808  SortedRunOrLumiItr iEnd1 = endRunOrLumi();
809 
810  SortedRunOrLumiItr iter2 = indexIntoFile.beginRunOrLumi();
811  SortedRunOrLumiItr iEnd2 = indexIntoFile.endRunOrLumi();
812 
813  // Quick decision if the lumi ranges in the two files do not overlap
814  while(iter1 != iEnd1 && iter1.isRun()) ++iter1;
815  if(iter1 == iEnd1) return;
816  if(back2 < iter1.runOrLumiIndexes()) return;
817 
818  while(iter2 != iEnd2 && iter2.isRun()) ++iter2;
819  if(iter2 == iEnd2) return;
820  if(back1 < iter2.runOrLumiIndexes()) return;
821 
822  RunOrLumiIndexes const* previousIndexes = nullptr;
823 
824  // Loop through the both IndexIntoFile objects and look for matching lumis
825  while(iter1 != iEnd1 && iter2 != iEnd2) {
826 
827  RunOrLumiIndexes const& indexes1 = iter1.runOrLumiIndexes();
828  RunOrLumiIndexes const& indexes2 = iter2.runOrLumiIndexes();
829  if(indexes1 < indexes2) {
830  ++iter1;
831  } else if(indexes2 < indexes1) {
832  ++iter2;
833  } else { // they are equal
834 
835  // Skip them if it is a run or the same lumi
836  if(indexes1.isRun() ||
837  (previousIndexes && !(*previousIndexes < indexes1))) {
838  ++iter1;
839  ++iter2;
840  } else {
841  previousIndexes = &indexes1;
842 
843  // Found a matching lumi, now look for matching events
844 
845  long long beginEventNumbers1 = indexes1.beginEventNumbers();
846  long long endEventNumbers1 = indexes1.endEventNumbers();
847 
848  long long beginEventNumbers2 = indexes2.beginEventNumbers();
849  long long endEventNumbers2 = indexes2.endEventNumbers();
850 
851  // there must be at least 1 event in each lumi for there to be any matches
852  if((beginEventNumbers1 >= endEventNumbers1) ||
853  (beginEventNumbers2 >= endEventNumbers2)) {
854  ++iter1;
855  ++iter2;
856  continue;
857  }
858 
859  if(!eventEntries().empty() && !indexIntoFile.eventEntries().empty()) {
860  std::vector<EventEntry> matchingEvents;
861  std::insert_iterator<std::vector<EventEntry> > insertIter(matchingEvents, matchingEvents.begin());
862  std::set_intersection(eventEntries().begin() + beginEventNumbers1,
863  eventEntries().begin() + endEventNumbers1,
864  indexIntoFile.eventEntries().begin() + beginEventNumbers2,
865  indexIntoFile.eventEntries().begin() + endEventNumbers2,
866  insertIter);
867  for(EventEntry const& entry : matchingEvents) {
868  intersection.insert(IndexRunLumiEventKey(indexes1.processHistoryIDIndex(),
869  indexes1.run(),
870  indexes1.lumi(),
871  entry.event()));
872  }
873  } else {
875  indexIntoFile.fillEventNumbers();
876  std::vector<EventNumber_t> matchingEvents;
877  std::insert_iterator<std::vector<EventNumber_t> > insertIter(matchingEvents, matchingEvents.begin());
878  std::set_intersection(eventNumbers().begin() + beginEventNumbers1,
879  eventNumbers().begin() + endEventNumbers1,
880  indexIntoFile.eventNumbers().begin() + beginEventNumbers2,
881  indexIntoFile.eventNumbers().begin() + endEventNumbers2,
882  insertIter);
883  for(EventNumber_t const& eventNumber : matchingEvents) {
884  intersection.insert(IndexRunLumiEventKey(indexes1.processHistoryIDIndex(),
885  indexes1.run(),
886  indexes1.lumi(),
887  eventNumber));
888  }
889  }
890  }
891  }
892  }
893  }
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
std::vector< EventNumber_t > & eventNumbers() const
SortedRunOrLumiItr endRunOrLumi() const
void edm::IndexIntoFile::setEventFinder ( std::shared_ptr< EventFinder ptr) const
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 987 of file IndexIntoFile.h.

References edm::IndexIntoFile::Transients::eventFinder_, fillEventEntries(), fillEventNumbers(), fillEventNumbersOrEntries(), and transient_.

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

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

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

Definition at line 978 of file IndexIntoFile.h.

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

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

978  {
979  transient_.numberOfEvents_ = nevents;
980  }
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 1046 of file IndexIntoFile.h.

References processHistoryIDs_, and reduceProcessHistoryIDs().

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

1046 {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 1041 of file IndexIntoFile.h.

References runOrLumiEntries_.

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

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

Definition at line 474 of file IndexIntoFile.cc.

References begin(), eventEntries(), fillRunOrLumiIndexes(), and runOrLumiIndexes().

Referenced by eventNumbers(), and fillEventNumbersOrEntries().

474  {
476  std::vector<RunOrLumiIndexes>::iterator beginOfLumi = runOrLumiIndexes().begin();
477  std::vector<RunOrLumiIndexes>::iterator endOfLumi = beginOfLumi;
478  std::vector<RunOrLumiIndexes>::iterator iEnd = runOrLumiIndexes().end();
479  while(true) {
480  while(beginOfLumi != iEnd && beginOfLumi->isRun()) {
481  ++beginOfLumi;
482  }
483  if(beginOfLumi == iEnd) break;
484 
485  endOfLumi = beginOfLumi + 1;
486  while(endOfLumi != iEnd &&
487  beginOfLumi->processHistoryIDIndex() == endOfLumi->processHistoryIDIndex() &&
488  beginOfLumi->run() == endOfLumi->run() &&
489  beginOfLumi->lumi() == endOfLumi->lumi()) {
490  ++endOfLumi;
491  }
492  assert(beginOfLumi->endEventNumbers() >= 0);
493  assert(beginOfLumi->endEventNumbers() <= static_cast<long long>(eventEntries().size()));
494  std::sort(eventEntries().begin() + beginOfLumi->beginEventNumbers(),
495  eventEntries().begin() + beginOfLumi->endEventNumbers());
496  beginOfLumi = endOfLumi;
497  }
498  }
std::vector< EventEntry > & eventEntries() const
std::vector< RunOrLumiIndexes > & runOrLumiIndexes() const
IndexIntoFileItr begin(SortOrder sortOrder) const
void fillRunOrLumiIndexes() const
void edm::IndexIntoFile::sortEvents ( ) const
private

Definition at line 448 of file IndexIntoFile.cc.

References begin(), eventNumbers(), fillRunOrLumiIndexes(), and runOrLumiIndexes().

Referenced by eventNumbers(), and fillEventNumbersOrEntries().

448  {
450  std::vector<RunOrLumiIndexes>::iterator beginOfLumi = runOrLumiIndexes().begin();
451  std::vector<RunOrLumiIndexes>::iterator endOfLumi = beginOfLumi;
452  std::vector<RunOrLumiIndexes>::iterator iEnd = runOrLumiIndexes().end();
453  while(true) {
454  while(beginOfLumi != iEnd && beginOfLumi->isRun()) {
455  ++beginOfLumi;
456  }
457  if(beginOfLumi == iEnd) break;
458 
459  endOfLumi = beginOfLumi + 1;
460  while(endOfLumi != iEnd &&
461  beginOfLumi->processHistoryIDIndex() == endOfLumi->processHistoryIDIndex() &&
462  beginOfLumi->run() == endOfLumi->run() &&
463  beginOfLumi->lumi() == endOfLumi->lumi()) {
464  ++endOfLumi;
465  }
466  assert(beginOfLumi->endEventNumbers() >= 0);
467  assert(beginOfLumi->endEventNumbers() <= static_cast<long long>(eventNumbers().size()));
468  std::sort(eventNumbers().begin() + beginOfLumi->beginEventNumbers(),
469  eventNumbers().begin() + beginOfLumi->endEventNumbers());
470  beginOfLumi = endOfLumi;
471  }
472  }
std::vector< RunOrLumiIndexes > & runOrLumiIndexes() const
IndexIntoFileItr begin(SortOrder sortOrder) const
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 429 of file IndexIntoFile.cc.

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

Referenced by edm::RootOutputFile::writeIndexIntoFile(), and edm::IndexIntoFile::EventFinder::~EventFinder().

429  {
430  for(RunOrLumiEntry& item : runOrLumiEntries_) {
431  std::map<IndexRunKey, EntryNumber_t>::const_iterator keyAndOrder =
432  runToOrder().find(IndexRunKey(item.processHistoryIDIndex(), item.run()));
433  if(keyAndOrder == runToOrder().end()) {
435  << "In IndexIntoFile::sortVector_Run_Or_Lumi_Entries. A run entry is missing.\n"
436  << "This means the IndexIntoFile product in the output file will be corrupted.\n"
437  << "The output file will be unusable for most purposes.\n"
438  << "If this occurs after an unrelated exception was thrown in\n"
439  << "endLuminosityBlock or endRun then ignore this exception and fix\n"
440  << "the primary exception. This is an expected side effect.\n"
441  << "Otherwise please report this to the core framework developers\n";
442  }
443  item.setOrderPHIDRun(keyAndOrder->second);
444  }
445  stable_sort_all(runOrLumiEntries_);
446  }
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 ( ) const
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 1029 of file IndexIntoFile.h.

References doneFileInitialization(), inputFileClosed(), transient_, and edm::IndexIntoFile::Transients::unsortedEventNumbers_.

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

std::vector< EventNumber_t > unsortedEventNumbers_

Friends And Related Function Documentation

friend class ::TestIndexIntoFile
friend

Definition at line 1086 of file IndexIntoFile.h.

friend class ::TestIndexIntoFile1
friend

Definition at line 1087 of file IndexIntoFile.h.

friend class ::TestIndexIntoFile2
friend

Definition at line 1088 of file IndexIntoFile.h.

friend class ::TestIndexIntoFile3
friend

Definition at line 1089 of file IndexIntoFile.h.

friend class ::TestIndexIntoFile4
friend

Definition at line 1090 of file IndexIntoFile.h.

friend class ::TestIndexIntoFile5
friend

Definition at line 1091 of file IndexIntoFile.h.

Member Data Documentation

IndexIntoFile::EntryNumber_t const edm::IndexIntoFile::invalidEntry = -1LL
static

Definition at line 235 of file IndexIntoFile.h.

Referenced by addEntry(), addLumi(), edm::IndexIntoFile::IndexIntoFileItrNoSort::entry(), edm::IndexIntoFile::IndexIntoFileItrSorted::entry(), fillEventNumbersOrEntries(), edm::RootFile::fillIndexIntoFile(), fillRunOrLumiIndexes(), findPosition(), edm::IndexIntoFile::IndexIntoFileItrImpl::firstEventEntryThisLumi(), edm::IndexIntoFile::IndexIntoFileItrImpl::firstEventEntryThisRun(), edm::RootFile::initializeDuplicateChecker(), edm::IndexIntoFile::IndexIntoFileItrNoSort::initializeLumi_(), iterationWillBeInEntryOrder(), edm::IndexIntoFile::IndexIntoFileItrNoSort::lumiEntryValid(), edm::IndexIntoFile::IndexIntoFileItrSorted::lumiEntryValid(), edm::IndexIntoFile::IndexIntoFileItrNoSort::nextEventRange(), edm::IndexIntoFile::IndexIntoFileItrNoSort::peekAheadAtEventEntry(), edm::IndexIntoFile::IndexIntoFileItrSorted::peekAheadAtEventEntry(), edm::IndexIntoFile::IndexIntoFileItrNoSort::previousEventRange(), edm::RootFile::readLuminosityBlockAuxiliary_(), edm::RootEmbeddedFileSequence::readOneSequential(), edm::RootFile::readRunAuxiliary_(), edm::IndexIntoFile::Transients::reset(), edm::RootEmbeddedFileSequence::RootEmbeddedFileSequence(), edm::IndexIntoFile::IndexIntoFileItrNoSort::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
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