CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Classes | Public Types | Public Member Functions | Static Public Attributes | Private Member Functions | Private Attributes
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

typedef long long EntryNumber_t
 
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)
 
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 (boost::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 EntryNumber_t const invalidEntry = -1LL
 
static EventNumber_t const invalidEvent = 0U
 
static int const invalidIndex = -1
 
static LuminosityBlockNumber_t
const 
invalidLumi = 0U
 
static RunNumber_t const 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 > & 
lumiToFirstEntry () const
 
size_t numberOfEvents () const
 
int & previousAddedIndex () const
 
void resetEventFinder () const
 
std::vector< RunOrLumiIndexes > & runOrLumiIndexes () const
 
std::map< IndexRunKey,
EntryNumber_t > & 
runToFirstEntry () const
 
void sortEventEntries () const
 
void sortEvents () const
 

Private Attributes

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

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 and EPStates) 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 entries will be put in the order they first appear in the input file. Within each of these groups the run entries come first in entry order, followed by the entries 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.

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.

eventNumbers_ is a std::vector containing EventNumber_t's. Each element is a 4 byte int. eventEntries_ is a std::vector containing EventEntry's. Each EventEntry contains a 4 byte event number and an 8 byte entry number. 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_ 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 the only the persistent part of the data structure is filled in the output module 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 186 of file IndexIntoFile.h.

Member Typedef Documentation

Definition at line 190 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 227 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 69 of file IndexIntoFile.cc.

References beginEvents(), currentIndex(), currentLumi(), currentRun(), endEvents(), edm::hlt::Exception, getHLTprescales::index, invalidEntry, invalidEvent, invalidIndex, invalidLumi, invalidRun, edm::errors::LogicError, fjr2json::lumi, lumiToFirstEntry(), numberOfEvents(), previousAddedIndex(), processHistoryIDs_, DTTTrigCorrFirst::run, runOrLumiEntries_, runToFirstEntry(), and setNumberOfEvents().

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

73  {
74  int index = 0;
75  // First see if the ProcessHistoryID is the same as the previous one.
76  // This is just a performance optimization. We expect to usually get
77  // many in a row that are the same.
80  index = previousAddedIndex();
81  } else {
82  // If it was not the same as the previous one then search through the
83  // entire vector. If it is not there, it needs to be added at the
84  // end.
85  index = 0;
86  while(index < static_cast<int>(processHistoryIDs_.size()) &&
88  ++index;
89  }
90  if(index == static_cast<int>(processHistoryIDs_.size())) {
92  }
93  }
95 
96  assert((currentRun() == run && currentIndex() == index) || currentRun() == invalidRun);
97  if(lumi == invalidLumi) {
98  if(currentLumi() != invalidLumi) {
100  << "In IndexIntoFile::addEntry. Entries were added in illegal order.\n"
101  << "This means the IndexIntoFile product in the output file will be corrupted.\n"
102  << "The output file will be unusable for most purposes.\n"
103  << "If this occurs after an unrelated exception was thrown in\n"
104  << "endLuminosityBlock or endRun then ignore this exception and fix\n"
105  << "the primary exception. This is an expected side effect.\n"
106  << "Otherwise please report this to the core framework developers\n";
107  }
111  std::pair<IndexRunKey, EntryNumber_t> firstRunEntry(IndexRunKey(index, run), entry);
112  runToFirstEntry().insert(firstRunEntry);
113  RunOrLumiEntry runEntry(runToFirstEntry()[IndexRunKey(index, run)], invalidEntry, entry, index, run, lumi, invalidEntry, invalidEntry);
114  runOrLumiEntries_.push_back(runEntry);
115  } else {
116  assert(currentLumi() == lumi || currentLumi() == invalidLumi);
117  if(currentRun() == invalidRun) {
118  currentRun() = run;
119  currentIndex() = index;
120  }
121  if(event == invalidEvent) {
123  std::pair<IndexRunLumiKey, EntryNumber_t> firstLumiEntry(IndexRunLumiKey(index, run, lumi), entry);
124  lumiToFirstEntry().insert(firstLumiEntry);
125  RunOrLumiEntry lumiEntry(invalidEntry, lumiToFirstEntry()[IndexRunLumiKey(index, run, lumi)],
126  entry, index, run, lumi, beginEvents(), endEvents());
127  runOrLumiEntries_.push_back(lumiEntry);
130  } else {
132  if(beginEvents() == invalidEntry) {
133  currentLumi() = lumi;
134  beginEvents() = entry;
135  endEvents() = beginEvents() + 1;
136  }
137  else {
138  assert(currentLumi() == lumi);
139  assert(entry == endEvents());
140  ++endEvents();
141  }
142  }
143  }
144  }
RunNumber_t & currentRun() const
static int const invalidIndex
tuple lumi
Definition: fjr2json.py:35
LuminosityBlockNumber_t & currentLumi() const
static EventNumber_t const invalidEvent
int & previousAddedIndex() const
size_t numberOfEvents() const
int & currentIndex() const
static RunNumber_t const invalidRun
std::vector< RunOrLumiEntry > runOrLumiEntries_
std::vector< ProcessHistoryID > processHistoryIDs_
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
std::map< IndexRunKey, EntryNumber_t > & runToFirstEntry() const
static EntryNumber_t const invalidEntry
static LuminosityBlockNumber_t const invalidLumi
ProcessHistoryID const & processHistoryID(int i) const
void setNumberOfEvents(EntryNumber_t nevents) const
std::map< IndexRunLumiKey, EntryNumber_t > & lumiToFirstEntry() const
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 483 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().

483  {
484  if(empty()) {
485  return end(sortOrder);
486  }
487  IndexIntoFileItr iter(this,
488  sortOrder,
489  kRun,
490  0,
491  invalidIndex,
492  invalidIndex,
493  0,
494  0);
495  iter.initializeRun();
496  return iter;
497  }
static int const 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 754 of file IndexIntoFile.cc.

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

754  {
755  return SortedRunOrLumiItr(this, 0);
756  }
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 863 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 prof2calltree::last.

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

863  {
864 
865  RunOrLumiIndexes const* previousIndexes = 0;
866 
867  for(SortedRunOrLumiItr iter = beginRunOrLumi(),
868  iEnd = endRunOrLumi();
869  iter != iEnd; ++iter) {
870 
871  RunOrLumiIndexes const& indexes = iter.runOrLumiIndexes();
872 
873  // Skip it if it is a run or the same lumi
874  if(indexes.isRun() ||
875  (previousIndexes && !(*previousIndexes < indexes))) {
876  continue;
877  }
878  previousIndexes = &indexes;
879 
880  long long beginEventNumbers = indexes.beginEventNumbers();
881  long long endEventNumbers = indexes.endEventNumbers();
882 
883  // there must be more than 1 event in the lumi for there to be any duplicates
884  if(beginEventNumbers + 1 >= endEventNumbers) continue;
885 
886  if(!eventEntries().empty()) {
887  std::vector<EventEntry>::iterator last = eventEntries().begin() + endEventNumbers;
888  if(std::adjacent_find(eventEntries().begin() + beginEventNumbers, last) != last) {
889  return true;
890  }
891  } else {
893  std::vector<EventNumber_t>::iterator last = eventNumbers().begin() + endEventNumbers;
894  if(std::adjacent_find(eventNumbers().begin() + beginEventNumbers, last) != last) {
895  return true;
896  }
897  }
898  }
899  return false;
900  }
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 740 of file IndexIntoFile.cc.

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

Referenced by containsItem().

740  {
742  }
tuple lumi
Definition: fjr2json.py:35
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
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 735 of file IndexIntoFile.cc.

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

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

735  {
736  return event ? containsEvent(run, lumi, event) : (lumi ? containsLumi(run, lumi) : containsRun(run));
737  }
tuple lumi
Definition: fjr2json.py:35
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
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 745 of file IndexIntoFile.cc.

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

Referenced by containsItem().

745  {
746  return findLumiPosition(run, lumi).getEntryType() != kEnd;
747  }
tuple lumi
Definition: fjr2json.py:35
IndexIntoFileItr findLumiPosition(RunNumber_t run, LuminosityBlockNumber_t lumi) const
bool edm::IndexIntoFile::containsRun ( RunNumber_t  run) const

Definition at line 750 of file IndexIntoFile.cc.

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

Referenced by containsItem().

750  {
751  return findRunPosition(run).getEntryType() != kEnd;
752  }
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 1038 of file IndexIntoFile.h.

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

Referenced by addEntry().

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

Definition at line 1037 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 318 of file IndexIntoFile.cc.

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

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

318  {
319  std::vector<EventNumber_t>().swap(unsortedEventNumbers());
320  }
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 499 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().

499  {
500  return IndexIntoFileItr(this,
501  sortOrder,
502  kEnd,
503  invalidIndex,
504  invalidIndex,
505  invalidIndex,
506  0,
507  0);
508  }
static int const invalidIndex
EntryNumber_t& edm::IndexIntoFile::endEvents ( ) const
inlineprivate
IndexIntoFile::SortedRunOrLumiItr edm::IndexIntoFile::endRunOrLumi ( ) const

Definition at line 758 of file IndexIntoFile.cc.

References runOrLumiEntries(), and findQualityFiles::size.

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

758  {
759  return SortedRunOrLumiItr(this, runOrLumiEntries().size());
760  }
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 a 4 byte event number and the corresponding TTree entry number (8 bytes) 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 207 of file IndexIntoFile.cc.

References fillEventNumbersOrEntries().

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

Fills a vector of 4 byte 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 202 of file IndexIntoFile.cc.

References fillEventNumbersOrEntries().

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

202  {
203  fillEventNumbersOrEntries(true, false);
204  }
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 212 of file IndexIntoFile.cc.

References asciidump::at, beginRunOrLumi(), empty(), endRunOrLumi(), event(), eventEntries(), eventNumbers(), fillUnsortedEventNumbers(), invalidEntry, invalidEvent, numberOfEvents(), evf::evtn::offset(), findQualityFiles::size, sortEventEntries(), sortEvents(), and unsortedEventNumbers().

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

212  {
213  if(numberOfEvents() == 0) {
214  return;
215  }
216 
217  if(needEventNumbers && !eventNumbers().empty()) {
218  needEventNumbers = false;
219  }
220 
221  if(needEventEntries && !eventEntries().empty()) {
222  needEventEntries = false;
223  }
224 
225  if(needEventNumbers && !eventEntries().empty()) {
226  assert(numberOfEvents() == eventEntries().size());
227  eventNumbers().reserve(eventEntries().size());
228  for(std::vector<EventNumber_t>::size_type entry = 0U; entry < numberOfEvents(); ++entry) {
229  eventNumbers().push_back(eventEntries()[entry].event());
230  }
231  return;
232  }
233 
234  if(!needEventNumbers && !needEventEntries) {
235  return;
236  }
237 
239 
240  if(needEventNumbers) {
242  }
243  if(needEventEntries) {
244  eventEntries().resize(numberOfEvents());
245  }
246 
247  long long offset = 0;
248  long long previousBeginEventNumbers = -1LL;
249 
250  for(SortedRunOrLumiItr runOrLumi = beginRunOrLumi(), runOrLumiEnd = endRunOrLumi();
251  runOrLumi != runOrLumiEnd; ++runOrLumi) {
252 
253  if(runOrLumi.isRun()) continue;
254 
255  long long beginEventNumbers = 0;
256  long long endEventNumbers = 0;
257  EntryNumber_t beginEventEntry = invalidEntry;
258  EntryNumber_t endEventEntry = invalidEntry;
259  runOrLumi.getRange(beginEventNumbers, endEventNumbers, beginEventEntry, endEventEntry);
260 
261  // This is true each time one hits a new lumi section (except if the previous lumi had
262  // no events, in which case the offset is still 0 anyway)
263  if(beginEventNumbers != previousBeginEventNumbers) offset = 0;
264 
265  for(EntryNumber_t entry = beginEventEntry; entry != endEventEntry; ++entry) {
266  if(needEventNumbers) {
267  eventNumbers().at((entry - beginEventEntry) + offset + beginEventNumbers) = unsortedEventNumbers().at(entry);
268  }
269  if(needEventEntries) {
270  eventEntries().at((entry - beginEventEntry) + offset + beginEventNumbers) =
271  EventEntry(unsortedEventNumbers().at(entry), entry);
272  }
273  }
274 
275  previousBeginEventNumbers = beginEventNumbers;
276  offset += endEventEntry - beginEventEntry;
277  }
278  if(needEventNumbers) {
279  sortEvents();
280  assert(numberOfEvents() == eventNumbers().size());
281  }
282  if(needEventEntries) {
284  assert(numberOfEvents() == eventEntries().size());
285  }
286  }
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
long long EntryNumber_t
static EventNumber_t const invalidEvent
size_t numberOfEvents() const
unsigned int offset(bool)
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 EntryNumber_t const invalidEntry
std::vector< EventNumber_t > & eventNumbers() const
SortedRunOrLumiItr endRunOrLumi() const
tuple size
Write out results.
list at
Definition: asciidump.py:428
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 146 of file IndexIntoFile.cc.

References getHLTprescales::index, 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().

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

Definition at line 289 of file IndexIntoFile.cc.

References empty(), getEventNumberOfEntry(), numberOfEvents(), and unsortedEventNumbers().

Referenced by fillEventNumbersOrEntries().

289  {
290  if(numberOfEvents() == 0 || !unsortedEventNumbers().empty()) {
291  return;
292  }
294 
295  // The main purpose for the existence of the unsortedEventNumbers
296  // vector is that it can easily be filled by reading through
297  // the EventAuxiliary branch in the same order as the TTree
298  // entries. fillEventNumbersOrEntries can then use this information
299  // instead of using getEventNumberOfEntry directly and reading
300  // the branch in a different order.
301  for(std::vector<EventNumber_t>::size_type entry = 0U; entry < numberOfEvents(); ++entry) {
302  unsortedEventNumbers().push_back(getEventNumberOfEntry(entry));
303  }
304  }
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 714 of file IndexIntoFile.cc.

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

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

714  {
715  assert(event != invalidEvent);
716  IndexIntoFileItr iter = findPosition(run, lumi, event);
717  iter.advanceToEvent();
718  return iter;
719  }
tuple lumi
Definition: fjr2json.py:35
static EventNumber_t const invalidEvent
IndexIntoFileItr findPosition(RunNumber_t run, LuminosityBlockNumber_t lumi=0U, EventNumber_t event=0U) 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
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 722 of file IndexIntoFile.cc.

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

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

722  {
723  assert(lumi != invalidLumi);
724  IndexIntoFileItr iter = findPosition(run, lumi, 0U);
725  iter.advanceToLumi();
726  return iter;
727  }
tuple lumi
Definition: fjr2json.py:35
IndexIntoFileItr findPosition(RunNumber_t run, LuminosityBlockNumber_t lumi=0U, EventNumber_t event=0U) const
static LuminosityBlockNumber_t const 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 528 of file IndexIntoFile.cc.

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

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

528  {
530 
531  bool lumiMissing = (lumi == 0 && event != 0);
532 
533  std::vector<RunOrLumiIndexes>::const_iterator it;
534  std::vector<RunOrLumiIndexes>::const_iterator iEnd = runOrLumiIndexes().end();
535  std::vector<RunOrLumiIndexes>::const_iterator phEnd;
536 
537  // Loop over ranges of entries with the same ProcessHistoryID
538  for(std::vector<RunOrLumiIndexes>::const_iterator phBegin = runOrLumiIndexes().begin();
539  phBegin != iEnd;
540  phBegin = phEnd) {
541 
542  RunOrLumiIndexes el(phBegin->processHistoryIDIndex(), run, lumi, 0);
543  phEnd = std::upper_bound(phBegin, iEnd, el, Compare_Index());
544 
545  std::vector<RunOrLumiIndexes>::const_iterator iRun = std::lower_bound(phBegin, phEnd, el, Compare_Index_Run());
546 
547  if(iRun == phEnd || iRun->run() != run) continue;
548 
549  if(lumi == invalidLumi && event == invalidEvent) {
550  IndexIntoFileItr indexItr(this,
552  kRun,
553  iRun - runOrLumiIndexes().begin(),
554  invalidIndex,
555  invalidIndex,
556  0,
557  0);
558  indexItr.initializeRun();
559  return indexItr;
560  }
561 
562  std::vector<RunOrLumiIndexes>::const_iterator iRunEnd = std::upper_bound(iRun, phEnd, el, Compare_Index_Run());
563  if(!lumiMissing) {
564 
565  std::vector<RunOrLumiIndexes>::const_iterator iLumi = std::lower_bound(iRun, iRunEnd, el);
566  if(iLumi == iRunEnd || iLumi->lumi() != lumi) continue;
567 
568  if(event == invalidEvent) {
569  IndexIntoFileItr indexItr(this,
571  kRun,
572  iRun - runOrLumiIndexes().begin(),
573  iLumi - runOrLumiIndexes().begin(),
574  invalidIndex,
575  0,
576  0);
577  indexItr.initializeLumi();
578  return indexItr;
579  }
580 
581  long long beginEventNumbers = iLumi->beginEventNumbers();
582  long long endEventNumbers = iLumi->endEventNumbers();
583  if(beginEventNumbers >= endEventNumbers) continue;
584 
585 
586  long long indexToEvent = 0;
587  if(!eventEntries().empty()) {
588  std::vector<EventEntry>::const_iterator eventIter = std::lower_bound(eventEntries().begin() + beginEventNumbers,
589  eventEntries().begin() + endEventNumbers,
590  EventEntry(event, invalidEntry));
591  if(eventIter == (eventEntries().begin() + endEventNumbers) ||
592  eventIter->event() != event) continue;
593 
594  indexToEvent = eventIter - eventEntries().begin() - beginEventNumbers;
595  } else {
597  std::vector<EventNumber_t>::const_iterator eventIter = std::lower_bound(eventNumbers().begin() + beginEventNumbers,
598  eventNumbers().begin() + endEventNumbers,
599  event);
600  if(eventIter == (eventNumbers().begin() + endEventNumbers) ||
601  *eventIter != event) continue;
602 
603  indexToEvent = eventIter - eventNumbers().begin() - beginEventNumbers;
604  }
605  return IndexIntoFileItr(this,
607  kRun,
608  iRun - runOrLumiIndexes().begin(),
609  iLumi - runOrLumiIndexes().begin(),
610  iLumi - runOrLumiIndexes().begin(),
611  indexToEvent,
612  endEventNumbers - beginEventNumbers);
613  }
614  if(lumiMissing) {
615 
616  std::vector<RunOrLumiIndexes>::const_iterator iLumi = iRun;
617  while(iLumi != iRunEnd && iLumi->lumi() == invalidLumi) {
618  ++iLumi;
619  }
620  if(iLumi == iRunEnd) continue;
621 
622  std::vector<RunOrLumiIndexes>::const_iterator lumiEnd;
623  for( ;
624  iLumi != iRunEnd;
625  iLumi = lumiEnd) {
626 
627  RunOrLumiIndexes elWithLumi(phBegin->processHistoryIDIndex(), run, iLumi->lumi(), 0);
628  lumiEnd = std::upper_bound(iLumi, iRunEnd, elWithLumi);
629 
630  long long beginEventNumbers = iLumi->beginEventNumbers();
631  long long endEventNumbers = iLumi->endEventNumbers();
632  if(beginEventNumbers >= endEventNumbers) continue;
633 
634  long long indexToEvent = 0;
635  if(!eventEntries().empty()) {
636  std::vector<EventEntry>::const_iterator eventIter = std::lower_bound(eventEntries().begin() + beginEventNumbers,
637  eventEntries().begin() + endEventNumbers,
638  EventEntry(event, invalidEntry));
639  if(eventIter == (eventEntries().begin() + endEventNumbers) ||
640  eventIter->event() != event) continue;
641  indexToEvent = eventIter - eventEntries().begin() - beginEventNumbers;
642  } else {
644  std::vector<EventNumber_t>::const_iterator eventIter = std::lower_bound(eventNumbers().begin() + beginEventNumbers,
645  eventNumbers().begin() + endEventNumbers,
646  event);
647  if(eventIter == (eventNumbers().begin() + endEventNumbers) ||
648  *eventIter != event) continue;
649  indexToEvent = eventIter - eventNumbers().begin() - beginEventNumbers;
650  }
651  return IndexIntoFileItr(this,
653  kRun,
654  iRun - runOrLumiIndexes().begin(),
655  iLumi - runOrLumiIndexes().begin(),
656  iLumi - runOrLumiIndexes().begin(),
657  indexToEvent,
658  endEventNumbers - beginEventNumbers);
659  }
660  }
661  } // Loop over ProcessHistoryIDs
662 
663  return IndexIntoFileItr(this,
665  kEnd,
666  invalidIndex,
667  invalidIndex,
668  invalidIndex,
669  0,
670  0);
671 
672  }
static int const invalidIndex
std::vector< EventEntry > & eventEntries() const
tuple lumi
Definition: fjr2json.py:35
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 EventNumber_t const invalidEvent
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 EntryNumber_t const invalidEntry
static LuminosityBlockNumber_t const invalidLumi
void fillEventNumbers() const
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 675 of file IndexIntoFile.cc.

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

675  {
676  if(sortOrder == IndexIntoFile::numericalOrder) {
677  return findPosition(run, lumi, event); // a faster algorithm
678  }
679  IndexIntoFileItr itr = begin(sortOrder);
680  IndexIntoFileItr itrEnd = end(sortOrder);
681 
682  while(itr != itrEnd) {
683  if(itr.run() != run) {
684  itr.advanceToNextRun();
685  } else {
686  if(lumi == invalidLumi && event == invalidEvent) {
687  return itr;
688  } else if(lumi != invalidLumi && itr.peekAheadAtLumi() != lumi) {
689  if(!itr.skipLumiInRun()) {
690  itr.advanceToNextRun();
691  }
692  } else {
693  if(event == invalidEvent) {
694  return itr;
695  } else {
696  EventNumber_t eventNumber = getEventNumberOfEntry(itr.peekAheadAtEventEntry());
697  if(eventNumber == event) {
698  return itr;
699  } else {
700  if(!itr.skipToNextEventInLumi()) {
701  if(!itr.skipLumiInRun()) {
702  itr.advanceToNextRun();
703  }
704  }
705  }
706  }
707  }
708  }
709  }
710  return itrEnd;
711  }
unsigned int EventNumber_t
Definition: EventID.h:30
tuple lumi
Definition: fjr2json.py:35
IndexIntoFileItr begin(SortOrder sortOrder) const
static EventNumber_t const 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.
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 LuminosityBlockNumber_t const invalidLumi
EventNumber_t getEventNumberOfEntry(EntryNumber_t entry) const
IndexIntoFile::IndexIntoFileItr edm::IndexIntoFile::findRunPosition ( RunNumber_t  run) const

Same as findPosition.

Definition at line 730 of file IndexIntoFile.cc.

References findPosition().

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

730  {
731  return findPosition(run, 0U, 0U);
732  }
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 389 of file IndexIntoFile.cc.

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

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

389  {
390 
391  std::map<int, int> oldToNewIndex;
392  for(std::vector<ProcessHistoryID>::const_iterator iter = processHistoryIDs_.begin(),
393  iEnd = processHistoryIDs_.end();
394  iter != iEnd;
395  ++iter) {
396  std::vector<ProcessHistoryID>::const_iterator iterExisting =
397  std::find(processHistoryIDs.begin(), processHistoryIDs.end(), *iter);
398  if(iterExisting == processHistoryIDs.end()) {
399  oldToNewIndex[iter - processHistoryIDs_.begin()] = processHistoryIDs.size();
400  processHistoryIDs.push_back(*iter);
401  } else {
402  oldToNewIndex[iter - processHistoryIDs_.begin()] = iterExisting - processHistoryIDs.begin();
403  }
404  }
406 
407  for(RunOrLumiEntry& item : runOrLumiEntries_) {
408  item.setProcessHistoryIDIndex(oldToNewIndex[item.processHistoryIDIndex()]);
409  }
410  }
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:7
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 1041 of file IndexIntoFile.h.

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

Referenced by fillUnsortedEventNumbers(), and findPosition().

1041  {
1042  return transient_.eventFinder_->getEventNumberOfEntry(entry);
1043  }
boost::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 310 of file IndexIntoFile.cc.

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

310  {
311  std::vector<EventEntry>().swap(eventEntries());
312  std::vector<RunOrLumiIndexes>().swap(runOrLumiIndexes());
313  std::vector<EventNumber_t>().swap(unsortedEventNumbers());
315  }
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 510 of file IndexIntoFile.cc.

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

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

510  {
511  EntryNumber_t maxEntry = invalidEntry;
512  for(IndexIntoFileItr it = begin(sortOrder), itEnd = end(sortOrder); it != itEnd; ++it) {
513  if(it.getEntryType() == kEvent) {
514  if(it.entry() < maxEntry) {
515  return false;
516  }
517  maxEntry = it.entry();
518  }
519  }
520  return true;
521  }
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 EntryNumber_t const invalidEntry
std::map<IndexRunLumiKey, EntryNumber_t>& edm::IndexIntoFile::lumiToFirstEntry ( ) const
inlineprivate

Definition at line 1033 of file IndexIntoFile.h.

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

Referenced by addEntry().

1033 {return transient_.lumiToFirstEntry_;}
std::map< IndexRunLumiKey, EntryNumber_t > lumiToFirstEntry_
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  }
int i
Definition: DBlmapReader.cc:9
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 323 of file IndexIntoFile.cc.

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

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

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

Definition at line 1026 of file IndexIntoFile.h.

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

Referenced by inputFileClosed().

1026 {transient_.eventFinder_.reset();}
boost::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::runToFirstEntry ( ) const
inlineprivate

Definition at line 1032 of file IndexIntoFile.h.

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

Referenced by addEntry(), and sortVector_Run_Or_Lumi_Entries().

1032 {return transient_.runToFirstEntry_;}
std::map< IndexRunKey, EntryNumber_t > runToFirstEntry_
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 762 of file IndexIntoFile.cc.

References begin(), edm::IndexIntoFile::RunOrLumiIndexes::beginEventNumbers(), beginRunOrLumi(), empty(), edm::IndexIntoFile::RunOrLumiIndexes::endEventNumbers(), endRunOrLumi(), eventEntries(), eventNumbers(), fillEventNumbers(), fillRunOrLumiIndexes(), prof2calltree::front, 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().

763  {
764 
765  if(empty() || indexIntoFile.empty()) return;
767  indexIntoFile.fillRunOrLumiIndexes();
768  RunOrLumiIndexes const& back1 = runOrLumiIndexes().back();
769  RunOrLumiIndexes const& back2 = indexIntoFile.runOrLumiIndexes().back();
770 
771  // Very quick decision if the run ranges in the two files do not overlap
772  if(back2 < runOrLumiIndexes().front()) return;
773  if(back1 < indexIntoFile.runOrLumiIndexes().front()) return;
774 
775  SortedRunOrLumiItr iter1 = beginRunOrLumi();
776  SortedRunOrLumiItr iEnd1 = endRunOrLumi();
777 
778  SortedRunOrLumiItr iter2 = indexIntoFile.beginRunOrLumi();
779  SortedRunOrLumiItr iEnd2 = indexIntoFile.endRunOrLumi();
780 
781  // Quick decision if the lumi ranges in the two files do not overlap
782  while(iter1 != iEnd1 && iter1.isRun()) ++iter1;
783  if(iter1 == iEnd1) return;
784  if(back2 < iter1.runOrLumiIndexes()) return;
785 
786  while(iter2 != iEnd2 && iter2.isRun()) ++iter2;
787  if(iter2 == iEnd2) return;
788  if(back1 < iter2.runOrLumiIndexes()) return;
789 
790  RunOrLumiIndexes const* previousIndexes = 0;
791 
792  // Loop through the both IndexIntoFile objects and look for matching lumis
793  while(iter1 != iEnd1 && iter2 != iEnd2) {
794 
795  RunOrLumiIndexes const& indexes1 = iter1.runOrLumiIndexes();
796  RunOrLumiIndexes const& indexes2 = iter2.runOrLumiIndexes();
797  if(indexes1 < indexes2) {
798  ++iter1;
799  } else if(indexes2 < indexes1) {
800  ++iter2;
801  } else { // they are equal
802 
803  // Skip them if it is a run or the same lumi
804  if(indexes1.isRun() ||
805  (previousIndexes && !(*previousIndexes < indexes1))) {
806  ++iter1;
807  ++iter2;
808  } else {
809  previousIndexes = &indexes1;
810 
811  // Found a matching lumi, now look for matching events
812 
813  long long beginEventNumbers1 = indexes1.beginEventNumbers();
814  long long endEventNumbers1 = indexes1.endEventNumbers();
815 
816  long long beginEventNumbers2 = indexes2.beginEventNumbers();
817  long long endEventNumbers2 = indexes2.endEventNumbers();
818 
819  // there must be at least 1 event in each lumi for there to be any matches
820  if((beginEventNumbers1 >= endEventNumbers1) ||
821  (beginEventNumbers2 >= endEventNumbers2)) {
822  ++iter1;
823  ++iter2;
824  continue;
825  }
826 
827  if(!eventEntries().empty() && !indexIntoFile.eventEntries().empty()) {
828  std::vector<EventEntry> matchingEvents;
829  std::insert_iterator<std::vector<EventEntry> > insertIter(matchingEvents, matchingEvents.begin());
830  std::set_intersection(eventEntries().begin() + beginEventNumbers1,
831  eventEntries().begin() + endEventNumbers1,
832  indexIntoFile.eventEntries().begin() + beginEventNumbers2,
833  indexIntoFile.eventEntries().begin() + endEventNumbers2,
834  insertIter);
835  for(EventEntry const& entry : matchingEvents) {
836  intersection.insert(IndexRunLumiEventKey(indexes1.processHistoryIDIndex(),
837  indexes1.run(),
838  indexes1.lumi(),
839  entry.event()));
840  }
841  } else {
843  indexIntoFile.fillEventNumbers();
844  std::vector<EventNumber_t> matchingEvents;
845  std::insert_iterator<std::vector<EventNumber_t> > insertIter(matchingEvents, matchingEvents.begin());
846  std::set_intersection(eventNumbers().begin() + beginEventNumbers1,
847  eventNumbers().begin() + endEventNumbers1,
848  indexIntoFile.eventNumbers().begin() + beginEventNumbers2,
849  indexIntoFile.eventNumbers().begin() + endEventNumbers2,
850  insertIter);
851  for(EventNumber_t const& eventNumber : matchingEvents) {
852  intersection.insert(IndexRunLumiEventKey(indexes1.processHistoryIDIndex(),
853  indexes1.run(),
854  indexes1.lumi(),
855  eventNumber));
856  }
857  }
858  }
859  }
860  }
861  }
unsigned int EventNumber_t
Definition: EventID.h:30
std::vector< EventEntry > & eventEntries() const
SortedRunOrLumiItr beginRunOrLumi() 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
void fillRunOrLumiIndexes() const
void fillEventNumbers() const
std::vector< EventNumber_t > & eventNumbers() const
SortedRunOrLumiItr endRunOrLumi() const
void edm::IndexIntoFile::setEventFinder ( boost::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 923 of file IndexIntoFile.h.

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

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

923 {transient_.eventFinder_ = ptr;}
boost::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 914 of file IndexIntoFile.h.

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

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

914  {
916  }
int nevents
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 982 of file IndexIntoFile.h.

References processHistoryIDs_.

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

982 {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 977 of file IndexIntoFile.h.

References runOrLumiEntries_.

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

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

Definition at line 457 of file IndexIntoFile.cc.

References begin(), eventEntries(), fillRunOrLumiIndexes(), runOrLumiIndexes(), and python.multivaluedict::sort().

Referenced by fillEventNumbersOrEntries().

457  {
459  std::vector<RunOrLumiIndexes>::iterator beginOfLumi = runOrLumiIndexes().begin();
460  std::vector<RunOrLumiIndexes>::iterator endOfLumi = beginOfLumi;
461  std::vector<RunOrLumiIndexes>::iterator iEnd = runOrLumiIndexes().end();
462  while(true) {
463  while(beginOfLumi != iEnd && beginOfLumi->isRun()) {
464  ++beginOfLumi;
465  }
466  if(beginOfLumi == iEnd) break;
467 
468  endOfLumi = beginOfLumi + 1;
469  while(endOfLumi != iEnd &&
470  beginOfLumi->processHistoryIDIndex() == endOfLumi->processHistoryIDIndex() &&
471  beginOfLumi->run() == endOfLumi->run() &&
472  beginOfLumi->lumi() == endOfLumi->lumi()) {
473  ++endOfLumi;
474  }
475  assert(beginOfLumi->endEventNumbers() >= 0);
476  assert(beginOfLumi->endEventNumbers() <= static_cast<long long>(eventEntries().size()));
477  std::sort(eventEntries().begin() + beginOfLumi->beginEventNumbers(),
478  eventEntries().begin() + beginOfLumi->endEventNumbers());
479  beginOfLumi = endOfLumi;
480  }
481  }
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 431 of file IndexIntoFile.cc.

References begin(), eventNumbers(), fillRunOrLumiIndexes(), runOrLumiIndexes(), and python.multivaluedict::sort().

Referenced by fillEventNumbersOrEntries().

431  {
433  std::vector<RunOrLumiIndexes>::iterator beginOfLumi = runOrLumiIndexes().begin();
434  std::vector<RunOrLumiIndexes>::iterator endOfLumi = beginOfLumi;
435  std::vector<RunOrLumiIndexes>::iterator iEnd = runOrLumiIndexes().end();
436  while(true) {
437  while(beginOfLumi != iEnd && beginOfLumi->isRun()) {
438  ++beginOfLumi;
439  }
440  if(beginOfLumi == iEnd) break;
441 
442  endOfLumi = beginOfLumi + 1;
443  while(endOfLumi != iEnd &&
444  beginOfLumi->processHistoryIDIndex() == endOfLumi->processHistoryIDIndex() &&
445  beginOfLumi->run() == endOfLumi->run() &&
446  beginOfLumi->lumi() == endOfLumi->lumi()) {
447  ++endOfLumi;
448  }
449  assert(beginOfLumi->endEventNumbers() >= 0);
450  assert(beginOfLumi->endEventNumbers() <= static_cast<long long>(eventNumbers().size()));
451  std::sort(eventNumbers().begin() + beginOfLumi->beginEventNumbers(),
452  eventNumbers().begin() + beginOfLumi->endEventNumbers());
453  beginOfLumi = endOfLumi;
454  }
455  }
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 412 of file IndexIntoFile.cc.

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

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

412  {
413  for(RunOrLumiEntry& item : runOrLumiEntries_) {
414  std::map<IndexRunKey, EntryNumber_t>::const_iterator firstRunEntry =
415  runToFirstEntry().find(IndexRunKey(item.processHistoryIDIndex(), item.run()));
416  if(firstRunEntry == runToFirstEntry().end()) {
418  << "In IndexIntoFile::sortVector_Run_Or_Lumi_Entries. A run entry is missing.\n"
419  << "This means the IndexIntoFile product in the output file will be corrupted.\n"
420  << "The output file will be unusable for most purposes.\n"
421  << "If this occurs after an unrelated exception was thrown in\n"
422  << "endLuminosityBlock or endRun then ignore this exception and fix\n"
423  << "the primary exception. This is an expected side effect.\n"
424  << "Otherwise please report this to the core framework developers\n";
425  }
426  item.setOrderPHIDRun(firstRunEntry->second);
427  }
428  stable_sort_all(runOrLumiEntries_);
429  }
void stable_sort_all(RandomAccessSequence &s)
wrappers for std::stable_sort
Definition: Algorithms.h:135
std::vector< RunOrLumiEntry > runOrLumiEntries_
std::map< IndexRunKey, EntryNumber_t > & runToFirstEntry() 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 965 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_

Member Data Documentation

IndexIntoFile::EntryNumber_t const edm::IndexIntoFile::invalidEntry = -1LL
static
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