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 ()
 
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 convert the ProcessHistoryID of a full ProcessHistory to the ProcessHistoryID of the corresponding reduced ProcessHistory.

Includes optimizations to cache the result so the same conversion need not be repeated many times.

The ProcessHistoryRegistry includes an instance of this class as its "extra" data member. That instance should be used. It would be a waste of memory and cpu to instantiate other instances of this class. The syntax should look something like the following:

edm::ProcessHistoryID reducedPHID = edm::ProcessHistoryRegistry::instance()->extra().reduceProcessHistoryID(fullID);

Note that the above function will throw an exception if the full ProcessHistory is not already in the ProcessHistoryRegistry. We expect that the reduced ProcessHistory will not ever be in the registry (although there is nothing prevents that).

Author
W. David Dagenhart, created 2 August, 2011

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

Member Typedef Documentation

Definition at line 189 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 226 of file IndexIntoFile.h.

Constructor & Destructor Documentation

edm::IndexIntoFile::IndexIntoFile ( )

Definition at line 53 of file IndexIntoFile.cc.

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

Definition at line 58 of file IndexIntoFile.cc.

58  {
59  }

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

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

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

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

769  {
770  return SortedRunOrLumiItr(this, 0);
771  }
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 882 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().

882  {
883 
884  RunOrLumiIndexes const* previousIndexes = 0;
885 
886  for(SortedRunOrLumiItr iter = beginRunOrLumi(),
887  iEnd = endRunOrLumi();
888  iter != iEnd; ++iter) {
889 
890  RunOrLumiIndexes const& indexes = iter.runOrLumiIndexes();
891 
892  // Skip it if it is a run or the same lumi
893  if(indexes.isRun() ||
894  (previousIndexes && !(*previousIndexes < indexes))) {
895  continue;
896  }
897  previousIndexes = &indexes;
898 
899  long long beginEventNumbers = indexes.beginEventNumbers();
900  long long endEventNumbers = indexes.endEventNumbers();
901 
902  // there must be more than 1 event in the lumi for there to be any duplicates
903  if(beginEventNumbers + 1 >= endEventNumbers) continue;
904 
905  if(!eventEntries().empty()) {
906  std::vector<EventEntry>::iterator last = eventEntries().begin() + endEventNumbers;
907  if(std::adjacent_find(eventEntries().begin() + beginEventNumbers, last) != last) {
908  return true;
909  }
910  } else {
912  std::vector<EventNumber_t>::iterator last = eventNumbers().begin() + endEventNumbers;
913  if(std::adjacent_find(eventNumbers().begin() + beginEventNumbers, last) != last) {
914  return true;
915  }
916  }
917  }
918  return false;
919  }
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 755 of file IndexIntoFile.cc.

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

Referenced by containsItem().

755  {
757  }
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 750 of file IndexIntoFile.cc.

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

750  {
751  return event ? containsEvent(run, lumi, event) : (lumi ? containsLumi(run, lumi) : containsRun(run));
752  }
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 760 of file IndexIntoFile.cc.

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

Referenced by containsItem().

760  {
761  return findLumiPosition(run, lumi).getEntryType() != kEnd;
762  }
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 765 of file IndexIntoFile.cc.

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

Referenced by containsItem().

765  {
766  return findRunPosition(run).getEntryType() != kEnd;
767  }
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 1037 of file IndexIntoFile.h.

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

Referenced by addEntry().

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

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

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

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

321  {
322  std::vector<EventNumber_t>().swap(unsortedEventNumbers());
323  }
void swap(Association< C > &lhs, Association< C > &rhs)
Definition: Association.h:117
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 514 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().

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

Definition at line 773 of file IndexIntoFile.cc.

References runOrLumiEntries(), and findQualityFiles::size.

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

773  {
774  return SortedRunOrLumiItr(this, runOrLumiEntries().size());
775  }
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 210 of file IndexIntoFile.cc.

References fillEventNumbersOrEntries().

210  {
211  fillEventNumbersOrEntries(false, true);
212  }
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 205 of file IndexIntoFile.cc.

References fillEventNumbersOrEntries().

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

205  {
206  fillEventNumbersOrEntries(true, false);
207  }
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 215 of file IndexIntoFile.cc.

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

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

215  {
216  if(numberOfEvents() == 0) {
217  return;
218  }
219 
220  if(needEventNumbers && !eventNumbers().empty()) {
221  needEventNumbers = false;
222  }
223 
224  if(needEventEntries && !eventEntries().empty()) {
225  needEventEntries = false;
226  }
227 
228  if(needEventNumbers && !eventEntries().empty()) {
229  assert(numberOfEvents() == eventEntries().size());
230  eventNumbers().reserve(eventEntries().size());
232  eventNumbers().push_back(eventEntries()[entry].event());
233  }
234  return;
235  }
236 
237  if(!needEventNumbers && !needEventEntries) {
238  return;
239  }
240 
242 
243  if(needEventNumbers) {
245  }
246  if(needEventEntries) {
247  eventEntries().resize(numberOfEvents());
248  }
249 
250  long long offset = 0;
251  long long previousBeginEventNumbers = -1LL;
252 
253  for(SortedRunOrLumiItr runOrLumi = beginRunOrLumi(), runOrLumiEnd = endRunOrLumi();
254  runOrLumi != runOrLumiEnd; ++runOrLumi) {
255 
256  if(runOrLumi.isRun()) continue;
257 
258  long long beginEventNumbers = 0;
259  long long endEventNumbers = 0;
260  EntryNumber_t beginEventEntry = -1LL;
261  EntryNumber_t endEventEntry = -1LL;
262  runOrLumi.getRange(beginEventNumbers, endEventNumbers, beginEventEntry, endEventEntry);
263 
264  // This is true each time one hits a new lumi section (except if the previous lumi had
265  // no events, in which case the offset is still 0 anyway)
266  if(beginEventNumbers != previousBeginEventNumbers) offset = 0;
267 
268  for(EntryNumber_t entry = beginEventEntry; entry != endEventEntry; ++entry) {
269  if(needEventNumbers) {
270  eventNumbers().at((entry - beginEventEntry) + offset + beginEventNumbers) = unsortedEventNumbers().at(entry);
271  }
272  if(needEventEntries) {
273  eventEntries().at((entry - beginEventEntry) + offset + beginEventNumbers) =
274  EventEntry(unsortedEventNumbers().at(entry), entry);
275  }
276  }
277 
278  previousBeginEventNumbers = beginEventNumbers;
279  offset += endEventEntry - beginEventEntry;
280  }
281  if(needEventNumbers) {
282  sortEvents();
283  assert(numberOfEvents() == eventNumbers().size());
284  }
285  if(needEventEntries) {
287  assert(numberOfEvents() == eventEntries().size());
288  }
289  }
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
std::pair< std::string, MonitorElement * > entry
Definition: ME_MAP.h:8
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
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 147 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().

147  {
148  if(runOrLumiEntries_.empty() || !runOrLumiIndexes().empty()) {
149  return;
150  }
151  runOrLumiIndexes().reserve(runOrLumiEntries_.size());
152 
153  int index = 0;
154  for(std::vector<RunOrLumiEntry>::const_iterator iter = runOrLumiEntries_.begin(),
155  iEnd = runOrLumiEntries_.end();
156  iter != iEnd;
157  ++iter, ++index) {
158  runOrLumiIndexes().push_back(RunOrLumiIndexes(iter->processHistoryIDIndex(),
159  iter->run(),
160  iter->lumi(),
161  index));
162  }
164 
165  long long beginEventNumbers = 0;
166 
167  std::vector<RunOrLumiIndexes>::iterator beginOfLumi = runOrLumiIndexes().begin();
168  std::vector<RunOrLumiIndexes>::iterator endOfLumi = beginOfLumi;
169  std::vector<RunOrLumiIndexes>::iterator iEnd = runOrLumiIndexes().end();
170  while(true) {
171  while(beginOfLumi != iEnd && beginOfLumi->isRun()) {
172  ++beginOfLumi;
173  }
174  if(beginOfLumi == iEnd) break;
175 
176  endOfLumi = beginOfLumi + 1;
177  while(endOfLumi != iEnd &&
178  beginOfLumi->processHistoryIDIndex() == endOfLumi->processHistoryIDIndex() &&
179  beginOfLumi->run() == endOfLumi->run() &&
180  beginOfLumi->lumi() == endOfLumi->lumi()) {
181  ++endOfLumi;
182  }
183  int nEvents = 0;
184  for(std::vector<RunOrLumiIndexes>::iterator iter = beginOfLumi;
185  iter != endOfLumi;
186  ++iter) {
187  if(runOrLumiEntries_[iter->indexToGetEntry()].beginEvents() != invalidEntry) {
188  nEvents += runOrLumiEntries_[iter->indexToGetEntry()].endEvents() -
189  runOrLumiEntries_[iter->indexToGetEntry()].beginEvents();
190  }
191  }
192  for(std::vector<RunOrLumiIndexes>::iterator iter = beginOfLumi;
193  iter != endOfLumi;
194  ++iter) {
195  iter->setBeginEventNumbers(beginEventNumbers);
196  iter->setEndEventNumbers(beginEventNumbers + nEvents);
197  }
198  beginEventNumbers += nEvents;
199  beginOfLumi = endOfLumi;
200  }
201  assert(runOrLumiIndexes().size() == runOrLumiEntries_.size());
202  }
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:43
tuple size
Write out results.
void edm::IndexIntoFile::fillUnsortedEventNumbers ( ) const
private

Definition at line 292 of file IndexIntoFile.cc.

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

Referenced by fillEventNumbersOrEntries().

292  {
293  if(numberOfEvents() == 0 || !unsortedEventNumbers().empty()) {
294  return;
295  }
297 
298  // The main purpose for the existence of the unsortedEventNumbers
299  // vector is that it can easily be filled by reading through
300  // the EventAuxiliary branch in the same order as the TTree
301  // entries. fillEventNumbersOrEntries can then use this information
302  // instead of using getEventNumberOfEntry directly and reading
303  // the branch in a different order.
306  }
307  }
bool empty() const
True if no runs, lumis, or events are in the file.
uint16_t size_type
size_t numberOfEvents() const
std::pair< std::string, MonitorElement * > entry
Definition: ME_MAP.h:8
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 729 of file IndexIntoFile.cc.

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

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

729  {
730  assert(event != invalidEvent);
731  IndexIntoFileItr iter = findPosition(run, lumi, event);
732  iter.advanceToEvent();
733  return iter;
734  }
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 737 of file IndexIntoFile.cc.

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

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

737  {
738  assert(lumi != invalidLumi);
739  IndexIntoFileItr iter = findPosition(run, lumi, 0U);
740  iter.advanceToLumi();
741  return iter;
742  }
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 543 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().

543  {
545 
546  bool lumiMissing = (lumi == 0 && event != 0);
547 
548  std::vector<RunOrLumiIndexes>::const_iterator it;
549  std::vector<RunOrLumiIndexes>::const_iterator iEnd = runOrLumiIndexes().end();
550  std::vector<RunOrLumiIndexes>::const_iterator phEnd;
551 
552  // Loop over ranges of entries with the same ProcessHistoryID
553  for(std::vector<RunOrLumiIndexes>::const_iterator phBegin = runOrLumiIndexes().begin();
554  phBegin != iEnd;
555  phBegin = phEnd) {
556 
557  RunOrLumiIndexes el(phBegin->processHistoryIDIndex(), run, lumi, 0);
558  phEnd = std::upper_bound(phBegin, iEnd, el, Compare_Index());
559 
560  std::vector<RunOrLumiIndexes>::const_iterator iRun = std::lower_bound(phBegin, phEnd, el, Compare_Index_Run());
561 
562  if(iRun == phEnd || iRun->run() != run) continue;
563 
564  if(lumi == invalidLumi && event == invalidEvent) {
565  IndexIntoFileItr indexItr(this,
567  kRun,
568  iRun - runOrLumiIndexes().begin(),
569  invalidIndex,
570  invalidIndex,
571  0,
572  0);
573  indexItr.initializeRun();
574  return indexItr;
575  }
576 
577  std::vector<RunOrLumiIndexes>::const_iterator iRunEnd = std::upper_bound(iRun, phEnd, el, Compare_Index_Run());
578  if(!lumiMissing) {
579 
580  std::vector<RunOrLumiIndexes>::const_iterator iLumi = std::lower_bound(iRun, iRunEnd, el);
581  if(iLumi == iRunEnd || iLumi->lumi() != lumi) continue;
582 
583  if(event == invalidEvent) {
584  IndexIntoFileItr indexItr(this,
586  kRun,
587  iRun - runOrLumiIndexes().begin(),
588  iLumi - runOrLumiIndexes().begin(),
589  invalidIndex,
590  0,
591  0);
592  indexItr.initializeLumi();
593  return indexItr;
594  }
595 
596  long long beginEventNumbers = iLumi->beginEventNumbers();
597  long long endEventNumbers = iLumi->endEventNumbers();
598  if(beginEventNumbers >= endEventNumbers) continue;
599 
600 
601  long long indexToEvent = 0;
602  if(!eventEntries().empty()) {
603  std::vector<EventEntry>::const_iterator eventIter = std::lower_bound(eventEntries().begin() + beginEventNumbers,
604  eventEntries().begin() + endEventNumbers,
605  EventEntry(event, invalidEntry));
606  if(eventIter == (eventEntries().begin() + endEventNumbers) ||
607  eventIter->event() != event) continue;
608 
609  indexToEvent = eventIter - eventEntries().begin() - beginEventNumbers;
610  } else {
612  std::vector<EventNumber_t>::const_iterator eventIter = std::lower_bound(eventNumbers().begin() + beginEventNumbers,
613  eventNumbers().begin() + endEventNumbers,
614  event);
615  if(eventIter == (eventNumbers().begin() + endEventNumbers) ||
616  *eventIter != event) continue;
617 
618  indexToEvent = eventIter - eventNumbers().begin() - beginEventNumbers;
619  }
620  return IndexIntoFileItr(this,
622  kRun,
623  iRun - runOrLumiIndexes().begin(),
624  iLumi - runOrLumiIndexes().begin(),
625  iLumi - runOrLumiIndexes().begin(),
626  indexToEvent,
627  endEventNumbers - beginEventNumbers);
628  }
629  if(lumiMissing) {
630 
631  std::vector<RunOrLumiIndexes>::const_iterator iLumi = iRun;
632  while(iLumi != iRunEnd && iLumi->lumi() == invalidLumi) {
633  ++iLumi;
634  }
635  if(iLumi == iRunEnd) continue;
636 
637  std::vector<RunOrLumiIndexes>::const_iterator lumiEnd;
638  for( ;
639  iLumi != iRunEnd;
640  iLumi = lumiEnd) {
641 
642  RunOrLumiIndexes elWithLumi(phBegin->processHistoryIDIndex(), run, iLumi->lumi(), 0);
643  lumiEnd = std::upper_bound(iLumi, iRunEnd, elWithLumi);
644 
645  long long beginEventNumbers = iLumi->beginEventNumbers();
646  long long endEventNumbers = iLumi->endEventNumbers();
647  if(beginEventNumbers >= endEventNumbers) continue;
648 
649  long long indexToEvent = 0;
650  if(!eventEntries().empty()) {
651  std::vector<EventEntry>::const_iterator eventIter = std::lower_bound(eventEntries().begin() + beginEventNumbers,
652  eventEntries().begin() + endEventNumbers,
653  EventEntry(event, invalidEntry));
654  if(eventIter == (eventEntries().begin() + endEventNumbers) ||
655  eventIter->event() != event) continue;
656  indexToEvent = eventIter - eventEntries().begin() - beginEventNumbers;
657  } else {
659  std::vector<EventNumber_t>::const_iterator eventIter = std::lower_bound(eventNumbers().begin() + beginEventNumbers,
660  eventNumbers().begin() + endEventNumbers,
661  event);
662  if(eventIter == (eventNumbers().begin() + endEventNumbers) ||
663  *eventIter != event) continue;
664  indexToEvent = eventIter - eventNumbers().begin() - beginEventNumbers;
665  }
666  return IndexIntoFileItr(this,
668  kRun,
669  iRun - runOrLumiIndexes().begin(),
670  iLumi - runOrLumiIndexes().begin(),
671  iLumi - runOrLumiIndexes().begin(),
672  indexToEvent,
673  endEventNumbers - beginEventNumbers);
674  }
675  }
676  } // Loop over ProcessHistoryIDs
677 
678  return IndexIntoFileItr(this,
680  kEnd,
681  invalidIndex,
682  invalidIndex,
683  invalidIndex,
684  0,
685  0);
686 
687  }
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 690 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().

690  {
691  if(sortOrder == IndexIntoFile::numericalOrder) {
692  return findPosition(run, lumi, event); // a faster algorithm
693  }
694  IndexIntoFileItr itr = begin(sortOrder);
695  IndexIntoFileItr itrEnd = end(sortOrder);
696 
697  while(itr != itrEnd) {
698  if(itr.run() != run) {
699  itr.advanceToNextRun();
700  } else {
701  if(lumi == invalidLumi && event == invalidEvent) {
702  return itr;
703  } else if(lumi != invalidLumi && itr.peekAheadAtLumi() != lumi) {
704  if(!itr.skipLumiInRun()) {
705  itr.advanceToNextRun();
706  }
707  } else {
708  if(event == invalidEvent) {
709  return itr;
710  } else {
711  EventNumber_t eventNumber = getEventNumberOfEntry(itr.peekAheadAtEventEntry());
712  if(eventNumber == event) {
713  return itr;
714  } else {
715  if(!itr.skipToNextEventInLumi()) {
716  if(!itr.skipLumiInRun()) {
717  itr.advanceToNextRun();
718  }
719  }
720  }
721  }
722  }
723  }
724  }
725  return itrEnd;
726  }
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 745 of file IndexIntoFile.cc.

References findPosition().

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

745  {
746  return findPosition(run, 0U, 0U);
747  }
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 398 of file IndexIntoFile.cc.

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

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

398  {
399 
400  std::map<int, int> oldToNewIndex;
401  for(std::vector<ProcessHistoryID>::const_iterator iter = processHistoryIDs_.begin(),
402  iEnd = processHistoryIDs_.end();
403  iter != iEnd;
404  ++iter) {
405  std::vector<ProcessHistoryID>::const_iterator iterExisting =
406  std::find(processHistoryIDs.begin(), processHistoryIDs.end(), *iter);
407  if(iterExisting == processHistoryIDs.end()) {
408  oldToNewIndex[iter - processHistoryIDs_.begin()] = processHistoryIDs.size();
409  processHistoryIDs.push_back(*iter);
410  } else {
411  oldToNewIndex[iter - processHistoryIDs_.begin()] = iterExisting - processHistoryIDs.begin();
412  }
413  }
415 
416  for(std::vector<RunOrLumiEntry>::iterator iter = runOrLumiEntries_.begin(),
417  iEnd = runOrLumiEntries_.end();
418  iter != iEnd;
419  ++iter) {
420  iter->setProcessHistoryIDIndex(oldToNewIndex[iter->processHistoryIDIndex()]);
421  }
422  }
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 1040 of file IndexIntoFile.h.

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

Referenced by fillUnsortedEventNumbers(), and findPosition().

1040  {
1041  return transient_.eventFinder_->getEventNumberOfEntry(entry);
1042  }
boost::shared_ptr< EventFinder > eventFinder_
std::pair< std::string, MonitorElement * > entry
Definition: ME_MAP.h:8
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 313 of file IndexIntoFile.cc.

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

313  {
314  std::vector<EventEntry>().swap(eventEntries());
315  std::vector<RunOrLumiIndexes>().swap(runOrLumiIndexes());
316  std::vector<EventNumber_t>().swap(unsortedEventNumbers());
318  }
std::vector< EventEntry > & eventEntries() const
std::vector< RunOrLumiIndexes > & runOrLumiIndexes() const
void swap(Association< C > &lhs, Association< C > &rhs)
Definition: Association.h:117
void resetEventFinder() const
std::vector< EventNumber_t > & unsortedEventNumbers() const
bool edm::IndexIntoFile::iterationWillBeInEntryOrder ( SortOrder  sortOrder) const

Used to determine whether or not to disable fast cloning.

Definition at line 525 of file IndexIntoFile.cc.

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

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

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

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

Referenced by addEntry().

1032 {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 61 of file IndexIntoFile.cc.

References processHistoryIDs_.

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

61  {
62  return processHistoryIDs_.at(i);
63  }
int i
Definition: DBlmapReader.cc:9
std::vector< ProcessHistoryID > processHistoryIDs_
std::vector< ProcessHistoryID > const & edm::IndexIntoFile::processHistoryIDs ( ) const

Definition at line 65 of file IndexIntoFile.cc.

References processHistoryIDs_.

Referenced by fixIndexes().

65  {
66  return processHistoryIDs_;
67  }
std::vector< ProcessHistoryID > processHistoryIDs_
void edm::IndexIntoFile::reduceProcessHistoryIDs ( )

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

References i, edm::detail::ThreadSafeRegistry< KEY, T, E >::instance(), processHistoryIDs_, edm::FullHistoryToReducedHistoryMap::reduceProcessHistoryID(), and runOrLumiEntries_.

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

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

Definition at line 1025 of file IndexIntoFile.h.

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

Referenced by inputFileClosed().

1025 {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 1031 of file IndexIntoFile.h.

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

Referenced by addEntry(), and sortVector_Run_Or_Lumi_Entries().

1031 {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 777 of file IndexIntoFile.cc.

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

778  {
779 
780  if(empty() || indexIntoFile.empty()) return;
782  indexIntoFile.fillRunOrLumiIndexes();
783  RunOrLumiIndexes const& back1 = runOrLumiIndexes().back();
784  RunOrLumiIndexes const& back2 = indexIntoFile.runOrLumiIndexes().back();
785 
786  // Very quick decision if the run ranges in the two files do not overlap
787  if(back2 < runOrLumiIndexes().front()) return;
788  if(back1 < indexIntoFile.runOrLumiIndexes().front()) return;
789 
790  SortedRunOrLumiItr iter1 = beginRunOrLumi();
791  SortedRunOrLumiItr iEnd1 = endRunOrLumi();
792 
793  SortedRunOrLumiItr iter2 = indexIntoFile.beginRunOrLumi();
794  SortedRunOrLumiItr iEnd2 = indexIntoFile.endRunOrLumi();
795 
796  // Quick decision if the lumi ranges in the two files do not overlap
797  while(iter1 != iEnd1 && iter1.isRun()) ++iter1;
798  if(iter1 == iEnd1) return;
799  if(back2 < iter1.runOrLumiIndexes()) return;
800 
801  while(iter2 != iEnd2 && iter2.isRun()) ++iter2;
802  if(iter2 == iEnd2) return;
803  if(back1 < iter2.runOrLumiIndexes()) return;
804 
805  RunOrLumiIndexes const* previousIndexes = 0;
806 
807  // Loop through the both IndexIntoFile objects and look for matching lumis
808  while(iter1 != iEnd1 && iter2 != iEnd2) {
809 
810  RunOrLumiIndexes const& indexes1 = iter1.runOrLumiIndexes();
811  RunOrLumiIndexes const& indexes2 = iter2.runOrLumiIndexes();
812  if(indexes1 < indexes2) {
813  ++iter1;
814  } else if(indexes2 < indexes1) {
815  ++iter2;
816  } else { // they are equal
817 
818  // Skip them if it is a run or the same lumi
819  if(indexes1.isRun() ||
820  (previousIndexes && !(*previousIndexes < indexes1))) {
821  ++iter1;
822  ++iter2;
823  } else {
824  previousIndexes = &indexes1;
825 
826  // Found a matching lumi, now look for matching events
827 
828  long long beginEventNumbers1 = indexes1.beginEventNumbers();
829  long long endEventNumbers1 = indexes1.endEventNumbers();
830 
831  long long beginEventNumbers2 = indexes2.beginEventNumbers();
832  long long endEventNumbers2 = indexes2.endEventNumbers();
833 
834  // there must be at least 1 event in each lumi for there to be any matches
835  if((beginEventNumbers1 >= endEventNumbers1) ||
836  (beginEventNumbers2 >= endEventNumbers2)) {
837  ++iter1;
838  ++iter2;
839  continue;
840  }
841 
842  if(!eventEntries().empty() && !indexIntoFile.eventEntries().empty()) {
843  std::vector<EventEntry> matchingEvents;
844  std::insert_iterator<std::vector<EventEntry> > insertIter(matchingEvents, matchingEvents.begin());
845  std::set_intersection(eventEntries().begin() + beginEventNumbers1,
846  eventEntries().begin() + endEventNumbers1,
847  indexIntoFile.eventEntries().begin() + beginEventNumbers2,
848  indexIntoFile.eventEntries().begin() + endEventNumbers2,
849  insertIter);
850  for(std::vector<EventEntry>::const_iterator iEvent = matchingEvents.begin(),
851  iEnd = matchingEvents.end();
852  iEvent != iEnd; ++iEvent) {
853  intersection.insert(IndexRunLumiEventKey(indexes1.processHistoryIDIndex(),
854  indexes1.run(),
855  indexes1.lumi(),
856  iEvent->event()));
857  }
858  } else {
860  indexIntoFile.fillEventNumbers();
861  std::vector<EventNumber_t> matchingEvents;
862  std::insert_iterator<std::vector<EventNumber_t> > insertIter(matchingEvents, matchingEvents.begin());
863  std::set_intersection(eventNumbers().begin() + beginEventNumbers1,
864  eventNumbers().begin() + endEventNumbers1,
865  indexIntoFile.eventNumbers().begin() + beginEventNumbers2,
866  indexIntoFile.eventNumbers().begin() + endEventNumbers2,
867  insertIter);
868  for(std::vector<EventNumber_t>::const_iterator iEvent = matchingEvents.begin(),
869  iEnd = matchingEvents.end();
870  iEvent != iEnd; ++iEvent) {
871  intersection.insert(IndexRunLumiEventKey(indexes1.processHistoryIDIndex(),
872  indexes1.run(),
873  indexes1.lumi(),
874  *iEvent));
875  }
876  }
877  }
878  }
879  }
880  }
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
int iEvent
Definition: GenABIO.cc:243
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 922 of file IndexIntoFile.h.

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

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

922 {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 913 of file IndexIntoFile.h.

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

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

913  {
915  }
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 981 of file IndexIntoFile.h.

References processHistoryIDs_.

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

981 {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 976 of file IndexIntoFile.h.

References runOrLumiEntries_.

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

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

Definition at line 472 of file IndexIntoFile.cc.

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

Referenced by fillEventNumbersOrEntries().

472  {
474  std::vector<RunOrLumiIndexes>::iterator beginOfLumi = runOrLumiIndexes().begin();
475  std::vector<RunOrLumiIndexes>::iterator endOfLumi = beginOfLumi;
476  std::vector<RunOrLumiIndexes>::iterator iEnd = runOrLumiIndexes().end();
477  while(true) {
478  while(beginOfLumi != iEnd && beginOfLumi->isRun()) {
479  ++beginOfLumi;
480  }
481  if(beginOfLumi == iEnd) break;
482 
483  endOfLumi = beginOfLumi + 1;
484  while(endOfLumi != iEnd &&
485  beginOfLumi->processHistoryIDIndex() == endOfLumi->processHistoryIDIndex() &&
486  beginOfLumi->run() == endOfLumi->run() &&
487  beginOfLumi->lumi() == endOfLumi->lumi()) {
488  ++endOfLumi;
489  }
490  assert(beginOfLumi->endEventNumbers() >= 0);
491  assert(beginOfLumi->endEventNumbers() <= static_cast<long long>(eventEntries().size()));
492  std::sort(eventEntries().begin() + beginOfLumi->beginEventNumbers(),
493  eventEntries().begin() + beginOfLumi->endEventNumbers());
494  beginOfLumi = endOfLumi;
495  }
496  }
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 446 of file IndexIntoFile.cc.

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

Referenced by fillEventNumbersOrEntries().

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

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

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

424  {
425  for(std::vector<RunOrLumiEntry>::iterator iter = runOrLumiEntries_.begin(),
426  iEnd = runOrLumiEntries_.end();
427  iter != iEnd;
428  ++iter) {
429  std::map<IndexRunKey, EntryNumber_t>::const_iterator firstRunEntry =
430  runToFirstEntry().find(IndexRunKey(iter->processHistoryIDIndex(), iter->run()));
431  if(firstRunEntry == runToFirstEntry().end()) {
433  << "In IndexIntoFile::sortVector_Run_Or_Lumi_Entries. A run entry is missing.\n"
434  << "This means the IndexIntoFile product in the output file will be corrupted.\n"
435  << "The output file will be unusable for most purposes.\n"
436  << "If this occurs after an unrelated exception was thrown in\n"
437  << "endLuminosityBlock or endRun then ignore this exception and fix\n"
438  << "the primary exception. This is an expected side effect.\n"
439  << "Otherwise please report this to the core framework developers\n";
440  }
441  iter->setOrderPHIDRun(firstRunEntry->second);
442  }
444  }
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 964 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