19 : previousAddedIndex_(invalidIndex),
22 beginEvents_(invalidEntry),
23 endEvents_(invalidEntry),
24 currentIndex_(invalidIndex),
25 currentRun_(invalidRun),
26 currentLumi_(invalidLumi),
32 unsortedEventNumbers_() {}
44 eventFinder_ =
nullptr;
45 runOrLumiIndexes_.clear();
46 eventNumbers_.clear();
47 eventEntries_.clear();
48 unsortedEventNumbers_.clear();
104 <<
"In IndexIntoFile::addEntry. Entries were added in illegal order.\n"
105 <<
"This means the IndexIntoFile product in the output file will be corrupted.\n"
106 <<
"The output file will be unusable for most purposes.\n"
107 <<
"If this occurs after an unrelated exception was thrown in\n"
108 <<
"endLuminosityBlock or endRun then ignore this exception and fix\n"
109 <<
"the primary exception. This is an expected side effect.\n"
110 <<
"Otherwise please report this to the core framework developers\n";
116 std::pair<IndexRunKey, EntryNumber_t> keyAndOrder(
IndexRunKey(index, run), entry);
131 addLumi(index, run, lumi, entry);
164 long long beginEventNumbers = 0;
166 std::vector<RunOrLumiIndexes>::iterator beginOfLumi =
runOrLumiIndexes().begin();
167 std::vector<RunOrLumiIndexes>::iterator endOfLumi = beginOfLumi;
170 while (beginOfLumi != iEnd && beginOfLumi->isRun()) {
173 if (beginOfLumi == iEnd)
176 endOfLumi = beginOfLumi + 1;
177 while (endOfLumi != iEnd && beginOfLumi->processHistoryIDIndex() == endOfLumi->processHistoryIDIndex() &&
178 beginOfLumi->run() == endOfLumi->run() && beginOfLumi->lumi() == endOfLumi->lumi()) {
182 for (std::vector<RunOrLumiIndexes>::iterator iter = beginOfLumi; iter != endOfLumi; ++iter) {
183 if (runOrLumiEntries_[iter->indexToGetEntry()].beginEvents() !=
invalidEntry) {
184 nEvents += runOrLumiEntries_[iter->indexToGetEntry()].endEvents() -
185 runOrLumiEntries_[iter->indexToGetEntry()].beginEvents();
188 for (std::vector<RunOrLumiIndexes>::iterator iter = beginOfLumi; iter != endOfLumi; ++iter) {
189 iter->setBeginEventNumbers(beginEventNumbers);
190 iter->setEndEventNumbers(beginEventNumbers + nEvents);
193 beginOfLumi = endOfLumi;
208 needEventNumbers =
false;
212 needEventEntries =
false;
224 if (!needEventNumbers && !needEventEntries) {
230 if (needEventNumbers) {
233 if (needEventEntries) {
238 long long previousBeginEventNumbers = -1LL;
242 if (runOrLumi.isRun())
245 long long beginEventNumbers = 0;
246 long long endEventNumbers = 0;
249 runOrLumi.getRange(beginEventNumbers, endEventNumbers, beginEventEntry, endEventEntry);
253 if (beginEventNumbers != previousBeginEventNumbers)
257 if (needEventNumbers) {
260 if (needEventEntries) {
266 previousBeginEventNumbers = beginEventNumbers;
267 offset += endEventEntry - beginEventEntry;
269 if (needEventNumbers) {
273 if (needEventEntries) {
309 std::vector<ProcessHistoryID> reducedPHIDs;
311 std::map<ProcessHistoryID, int> reducedPHIDToIndex;
313 std::pair<std::map<ProcessHistoryID, int>::iterator,
bool> insertResult;
315 std::vector<int> phidIndexConverter;
318 mapEntry.first = reducedPHID;
319 insertResult = reducedPHIDToIndex.insert(mapEntry);
321 if (insertResult.second) {
322 insertResult.first->second = reducedPHIDs.size();
323 reducedPHIDs.push_back(reducedPHID);
325 phidIndexConverter.push_back(insertResult.first->second);
327 processHistoryIDs_.
swap(reducedPHIDs);
332 if (processHistoryIDs_.size() == reducedPHIDs.size()) {
336 std::map<IndexIntoFile::IndexRunKey, int> runOrderMap;
337 std::pair<std::map<IndexIntoFile::IndexRunKey, int>::iterator,
bool> runInsertResult;
339 std::map<IndexIntoFile::IndexRunLumiKey, int> lumiOrderMap;
340 std::pair<std::map<IndexIntoFile::IndexRunLumiKey, int>::iterator,
bool> lumiInsertResult;
345 item.setProcessHistoryIDIndex(phidIndexConverter.at(
item.processHistoryIDIndex()));
349 runInsertResult = runOrderMap.insert(std::pair<IndexIntoFile::IndexRunKey, int>(runKey, 0));
350 if (runInsertResult.second) {
351 runInsertResult.first->second =
item.orderPHIDRun();
353 item.setOrderPHIDRun(runInsertResult.first->second);
357 if (
item.lumi() != 0) {
359 lumiInsertResult = lumiOrderMap.insert(std::pair<IndexIntoFile::IndexRunLumiKey, int>(lumiKey, 0));
360 if (lumiInsertResult.second) {
361 lumiInsertResult.first->second =
item.orderPHIDRunLumi();
363 item.setOrderPHIDRunLumi(lumiInsertResult.first->second);
367 std::stable_sort(runOrLumiEntries_.begin(), runOrLumiEntries_.end());
371 std::map<int, int> oldToNewIndex;
376 std::vector<ProcessHistoryID>::const_iterator iterExisting =
377 std::find(processHistoryIDs.begin(), processHistoryIDs.end(), *iter);
378 if (iterExisting == processHistoryIDs.end()) {
380 processHistoryIDs.push_back(*iter);
382 oldToNewIndex[iter -
processHistoryIDs_.begin()] = iterExisting - processHistoryIDs.begin();
388 item.setProcessHistoryIDIndex(oldToNewIndex[
item.processHistoryIDIndex()]);
394 std::map<IndexRunKey, EntryNumber_t>::const_iterator keyAndOrder =
398 <<
"In IndexIntoFile::sortVector_Run_Or_Lumi_Entries. A run entry is missing.\n"
399 <<
"This means the IndexIntoFile product in the output file will be corrupted.\n"
400 <<
"The output file will be unusable for most purposes.\n"
401 <<
"If this occurs after an unrelated exception was thrown in\n"
402 <<
"endLuminosityBlock or endRun then ignore this exception and fix\n"
403 <<
"the primary exception. This is an expected side effect.\n"
404 <<
"Otherwise please report this to the core framework developers\n";
406 item.setOrderPHIDRun(keyAndOrder->second);
413 std::vector<RunOrLumiIndexes>::iterator beginOfLumi =
runOrLumiIndexes().begin();
414 std::vector<RunOrLumiIndexes>::iterator endOfLumi = beginOfLumi;
417 while (beginOfLumi != iEnd && beginOfLumi->isRun()) {
420 if (beginOfLumi == iEnd)
423 endOfLumi = beginOfLumi + 1;
424 while (endOfLumi != iEnd && beginOfLumi->processHistoryIDIndex() == endOfLumi->processHistoryIDIndex() &&
425 beginOfLumi->run() == endOfLumi->run() && beginOfLumi->lumi() == endOfLumi->lumi()) {
428 assert(beginOfLumi->endEventNumbers() >= 0);
429 assert(beginOfLumi->endEventNumbers() <=
static_cast<long long>(
eventNumbers().size()));
431 eventNumbers().begin() + beginOfLumi->endEventNumbers());
432 beginOfLumi = endOfLumi;
438 std::vector<RunOrLumiIndexes>::iterator beginOfLumi =
runOrLumiIndexes().begin();
439 std::vector<RunOrLumiIndexes>::iterator endOfLumi = beginOfLumi;
442 while (beginOfLumi != iEnd && beginOfLumi->isRun()) {
445 if (beginOfLumi == iEnd)
448 endOfLumi = beginOfLumi + 1;
449 while (endOfLumi != iEnd && beginOfLumi->processHistoryIDIndex() == endOfLumi->processHistoryIDIndex() &&
450 beginOfLumi->run() == endOfLumi->run() && beginOfLumi->lumi() == endOfLumi->lumi()) {
453 assert(beginOfLumi->endEventNumbers() >= 0);
454 assert(beginOfLumi->endEventNumbers() <=
static_cast<long long>(
eventEntries().size()));
456 eventEntries().begin() + beginOfLumi->endEventNumbers());
457 beginOfLumi = endOfLumi;
463 return end(sortOrder);
477 if (it.getEntryType() ==
kEvent) {
478 if (it.entry() < maxEntry) {
481 maxEntry = it.entry();
494 bool lumiMissing = (lumi == 0 &&
event != 0);
496 std::vector<RunOrLumiIndexes>::const_iterator iEnd =
runOrLumiIndexes().end();
497 std::vector<RunOrLumiIndexes>::const_iterator phEnd;
500 for (std::vector<RunOrLumiIndexes>::const_iterator phBegin =
runOrLumiIndexes().
begin(); phBegin != iEnd;
507 if (iRun == phEnd || iRun->run() !=
run)
519 std::vector<RunOrLumiIndexes>::const_iterator iLumi =
std::lower_bound(iRun, iRunEnd, el);
520 if (iLumi == iRunEnd || iLumi->lumi() !=
lumi)
536 long long beginEventNumbers = iLumi->beginEventNumbers();
537 long long endEventNumbers = iLumi->endEventNumbers();
538 if (beginEventNumbers >= endEventNumbers)
541 long long indexToEvent = 0;
543 std::vector<EventEntry>::const_iterator eventIter =
550 indexToEvent = eventIter -
eventEntries().begin() - beginEventNumbers;
555 if (eventIter == (
eventNumbers().
begin() + endEventNumbers) || *eventIter != event)
558 indexToEvent = eventIter -
eventNumbers().begin() - beginEventNumbers;
575 endEventNumbers - beginEventNumbers);
578 std::vector<RunOrLumiIndexes>::const_iterator iLumi = iRun;
579 while (iLumi != iRunEnd && iLumi->lumi() ==
invalidLumi) {
582 if (iLumi == iRunEnd)
585 std::vector<RunOrLumiIndexes>::const_iterator lumiEnd;
586 for (; iLumi != iRunEnd; iLumi = lumiEnd) {
590 long long beginEventNumbers = iLumi->beginEventNumbers();
591 long long endEventNumbers = iLumi->endEventNumbers();
592 if (beginEventNumbers >= endEventNumbers)
595 long long indexToEvent = 0;
597 std::vector<EventEntry>::const_iterator eventIter =
603 indexToEvent = eventIter -
eventEntries().begin() - beginEventNumbers;
608 if (eventIter == (
eventNumbers().
begin() + endEventNumbers) || *eventIter != event)
610 indexToEvent = eventIter -
eventNumbers().begin() - beginEventNumbers;
627 endEventNumbers - beginEventNumbers);
645 while (itr != itrEnd) {
660 if (eventNumber == event) {
738 while (iter1 != iEnd1 && iter1.
isRun())
745 while (iter2 != iEnd2 && iter2.
isRun())
755 while (iter1 != iEnd1 && iter2 != iEnd2) {
758 if (indexes1 < indexes2) {
760 }
else if (indexes2 < indexes1) {
765 if (indexes1.
isRun() || (previousIndexes && !(*previousIndexes < indexes1))) {
769 previousIndexes = &indexes1;
780 if ((beginEventNumbers1 >= endEventNumbers1) || (beginEventNumbers2 >= endEventNumbers2)) {
787 std::vector<EventEntry> matchingEvents;
788 std::insert_iterator<std::vector<EventEntry> > insertIter(matchingEvents, matchingEvents.begin());
791 indexIntoFile.
eventEntries().begin() + beginEventNumbers2,
792 indexIntoFile.
eventEntries().begin() + endEventNumbers2,
801 std::vector<EventNumber_t> matchingEvents;
802 std::insert_iterator<std::vector<EventNumber_t> > insertIter(matchingEvents, matchingEvents.begin());
805 indexIntoFile.
eventNumbers().begin() + beginEventNumbers2,
806 indexIntoFile.
eventNumbers().begin() + endEventNumbers2,
825 if (indexes.
isRun() || (previousIndexes && !(*previousIndexes < indexes))) {
828 previousIndexes = &indexes;
834 if (beginEventNumbers + 1 >= endEventNumbers)
838 std::vector<EventEntry>::iterator
last =
eventEntries().begin() + endEventNumbers;
839 if (std::adjacent_find(
eventEntries().
begin() + beginEventNumbers, last) != last) {
844 std::vector<EventNumber_t>::iterator
last =
eventNumbers().begin() + endEventNumbers;
845 if (std::adjacent_find(
eventNumbers().
begin() + beginEventNumbers, last) != last) {
854 : orderPHIDRun_(invalidEntry),
855 orderPHIDRunLumi_(invalidEntry),
856 entry_(invalidEntry),
857 processHistoryIDIndex_(invalidIndex),
860 beginEvents_(invalidEntry),
861 endEvents_(invalidEntry) {}
866 int processHistoryIDIndex,
871 : orderPHIDRun_(orderPHIDRun),
872 orderPHIDRunLumi_(orderPHIDRunLumi),
874 processHistoryIDIndex_(processHistoryIDIndex),
877 beginEvents_(beginEvents),
878 endEvents_(endEvents) {}
884 : processHistoryIDIndex_(processHistoryIDIndex),
887 indexToGetEntry_(indexToGetEntry),
888 beginEventNumbers_(-1),
889 endEventNumbers_(-1) {}
892 : indexIntoFile_(indexIntoFile), runOrLumi_(runOrLumi) {
906 if (runOrLumi_ != indexIntoFile_->runOrLumiEntries().size()) {
913 return indexIntoFile_->runOrLumiIndexes().at(runOrLumi_).lumi() ==
invalidLumi;
917 long long& endEventNumbers,
920 beginEventNumbers = indexIntoFile_->runOrLumiIndexes().at(runOrLumi_).beginEventNumbers();
921 endEventNumbers = indexIntoFile_->runOrLumiIndexes().at(runOrLumi_).endEventNumbers();
923 int indexToGetEntry = indexIntoFile_->runOrLumiIndexes().at(runOrLumi_).indexToGetEntry();
924 beginEventEntry = indexIntoFile_->runOrLumiEntries_.at(indexToGetEntry).beginEvents();
925 endEventEntry = indexIntoFile_->runOrLumiEntries_.at(indexToGetEntry).endEvents();
929 return indexIntoFile_->runOrLumiIndexes().at(runOrLumi_);
936 int indexToEventRange,
937 long long indexToEvent,
939 : indexIntoFile_(indexIntoFile),
942 indexToRun_(indexToRun),
943 indexToLumi_(indexToLumi),
944 indexToEventRange_(indexToEventRange),
945 indexToEvent_(indexToEvent),
952 if ((indexToEvent_ + 1) < nEvents_) {
955 bool found = nextEventRange();
958 type_ = getRunOrLumiEntryType(indexToLumi_ + 1);
960 if (type_ ==
kLumi) {
963 }
else if (type_ ==
kRun) {
964 indexToRun_ = indexToLumi_ + 1;
971 }
else if (type_ ==
kLumi) {
972 if (indexToLumi_ + 1 == size_) {
973 if (indexToEvent_ < nEvents_) {
979 EntryType nextType = getRunOrLumiEntryType(indexToLumi_ + 1);
981 if (nextType ==
kLumi && isSameLumi(indexToLumi_, indexToLumi_ + 1)) {
983 }
else if (indexToEvent_ < nEvents_) {
985 }
else if (nextType ==
kRun) {
987 indexToRun_ = indexToLumi_ + 1;
994 }
else if (type_ ==
kRun) {
995 EntryType nextType = getRunOrLumiEntryType(indexToRun_ + 1);
996 bool sameRun = isSameRun(indexToRun_, indexToRun_ + 1);
997 if (nextType ==
kRun && sameRun) {
999 }
else if (nextType ==
kRun && !sameRun) {
1002 }
else if (nextType ==
kLumi) {
1014 if (indexToEvent_ < nEvents_) {
1015 phIndexOfSkippedEvent = processHistoryIDIndex();
1016 runOfSkippedEvent =
run();
1017 lumiOfSkippedEvent = peekAheadAtLumi();
1018 skippedEventEntry = peekAheadAtEventEntry();
1020 if ((indexToEvent_ + 1) < nEvents_) {
1023 }
else if (nextEventRange()) {
1025 }
else if (type_ ==
kRun || type_ ==
kLumi) {
1026 if (skipLumiInRun()) {
1029 }
else if (type_ ==
kEvent) {
1037 if (type_ ==
kRun) {
1038 while (skipLumiInRun()) {
1039 if (indexToEvent_ < nEvents_) {
1040 skipEventForward(phIndexOfSkippedEvent, runOfSkippedEvent, lumiOfSkippedEvent, skippedEventEntry);
1046 while (indexToEvent_ >= nEvents_ && type_ !=
kEnd) {
1047 while (skipLumiInRun()) {
1048 if (indexToEvent_ < nEvents_) {
1049 skipEventForward(phIndexOfSkippedEvent, runOfSkippedEvent, lumiOfSkippedEvent, skippedEventEntry);
1055 if (type_ ==
kEnd) {
1062 skipEventForward(phIndexOfSkippedEvent, runOfSkippedEvent, lumiOfSkippedEvent, skippedEventEntry);
1071 if (indexToEvent_ > 0) {
1073 }
else if (!previousEventRange()) {
1075 if (!previousLumiWithEvents()) {
1078 if (!indexIntoFile_->empty()) {
1095 phIndexOfEvent = processHistoryIDIndex();
1097 lumiOfEvent = peekAheadAtLumi();
1098 eventEntry = peekAheadAtEventEntry();
1103 int newLumi = indexToLumi();
1107 while (getRunOrLumiEntryType(newLumi - 1) ==
kLumi && isSameLumi(newLumi, newLumi - 1)) {
1116 for (; newLumi > 0; --newLumi) {
1117 if (getRunOrLumiEntryType(newLumi) ==
kRun) {
1120 if (setToLastEventInRange(newLumi)) {
1128 while (getRunOrLumiEntryType(newLumi - 1) ==
kLumi && isSameLumi(newLumi, newLumi - 1) &&
1129 lumiEntryValid(newLumi - 1)) {
1132 setIndexToLumi(newLumi);
1134 if (
type() !=
kEnd && isSameRun(newLumi, indexToRun())) {
1139 int newRun = newLumi;
1140 while (newRun > 0 && getRunOrLumiEntryType(newRun - 1) ==
kLumi) {
1144 assert(getRunOrLumiEntryType(newRun) ==
kRun);
1145 while (getRunOrLumiEntryType(newRun - 1) ==
kRun && isSameRun(newRun - 1, newLumi)) {
1148 indexToRun_ = newRun;
1157 int saveIndexToLumi = indexToLumi();
1158 int saveIndexToEventRange = indexToEventRange();
1159 long long saveIndexToEvent = indexToEvent();
1160 long long saveNEvents =
nEvents();
1167 if (indexToEvent() <
nEvents()) {
1168 returnValue = peekAheadAtEventEntry();
1171 }
while (skipLumiInRun());
1173 setIndexToLumi(saveIndexToLumi);
1174 setIndexToEventRange(saveIndexToEventRange);
1175 setIndexToEvent(saveIndexToEvent);
1176 setNEvents(saveNEvents);
1185 int saveIndexToLumi = indexToLumi();
1186 int saveIndexToEventRange = indexToEventRange();
1187 long long saveIndexToEvent = indexToEvent();
1188 long long saveNEvents =
nEvents();
1190 while (indexToLumi() - 1 > 0) {
1191 if (getRunOrLumiEntryType(indexToLumi() - 1) ==
kRun)
1193 if (!isSameLumi(indexToLumi(), indexToLumi() - 1))
1201 if (indexToEvent() <
nEvents()) {
1202 returnValue = peekAheadAtEventEntry();
1205 setIndexToLumi(saveIndexToLumi);
1206 setIndexToEventRange(saveIndexToEventRange);
1207 setIndexToEvent(saveIndexToEvent);
1208 setNEvents(saveNEvents);
1216 for (
int i = 1; indexToRun_ +
i < size_; ++
i) {
1217 if (getRunOrLumiEntryType(indexToRun_ +
i) ==
kRun) {
1218 if (!isSameRun(indexToRun_, indexToRun_ +
i)) {
1237 int startSearch = indexToRun_;
1238 for (
int i = 1; startSearch +
i < size_; ++
i) {
1239 if (getRunOrLumiEntryType(startSearch +
i) ==
kRun && isSameRun(indexToRun_, startSearch +
i)) {
1240 indexToRun_ = startSearch +
i;
1251 startSearch = indexToLumi_;
1253 startSearch = indexToRun_;
1254 for (
int i = 1; startSearch +
i < size_; ++
i) {
1255 if (getRunOrLumiEntryType(startSearch +
i) ==
kRun) {
1256 if (!isSameRun(indexToRun_, startSearch +
i)) {
1258 indexToRun_ = startSearch +
i;
1263 if (!isSameLumi(indexToLumi_, startSearch +
i)) {
1265 indexToLumi_ = startSearch +
i;
1275 if (indexToEvent_ >= nEvents_)
1277 if ((indexToEvent_ + 1) < nEvents_) {
1281 return nextEventRange();
1290 for (
int i = 1; (
i + indexToRun_) < size_; ++
i) {
1291 EntryType entryType = getRunOrLumiEntryType(indexToRun_ +
i);
1292 bool sameRun = isSameRun(indexToRun_, indexToRun_ +
i);
1294 if (entryType ==
kRun) {
1301 indexToLumi_ = indexToRun_ +
i;
1312 auto oldLumi =
lumi();
1313 while (not lumiEntryValid(indexToLumi_)) {
1327 type_ = position.
type_;
1343 for (
int i = 1; (
i + indexToRun_) < size_; ++
i) {
1344 int index =
i + indexToRun_;
1345 EntryType entryType = getRunOrLumiEntryType(index);
1347 if (entryType ==
kRun) {
1348 if (isSameRun(indexToRun_, index)) {
1355 if (luminosityBlock !=
invalidLumi && luminosityBlock != previousLumi) {
1356 lumis.push_back(luminosityBlock);
1357 previousLumi = luminosityBlock;
1361 std::sort(lumis.begin(), lumis.end());
1362 lumis.erase(
std::unique(lumis.begin(), lumis.end()), lumis.end());
1378 int indexToEventRange,
1379 long long indexToEvent,
1382 indexIntoFile, entryType, indexToRun, indexToLumi, indexToEventRange, indexToEvent, nEvents) {}
1391 return indexIntoFile()->runOrLumiEntries()[indexToRun()].processHistoryIDIndex();
1397 return indexIntoFile()->runOrLumiEntries()[indexToRun()].run();
1403 return indexIntoFile()->runOrLumiEntries()[indexToLumi()].lumi();
1410 return indexIntoFile()->runOrLumiEntries()[indexToRun()].entry();
1412 return indexIntoFile()->runOrLumiEntries()[indexToLumi()].entry();
1413 return indexIntoFile()->runOrLumiEntries()[indexToEventRange()].beginEvents() + indexToEvent();
1419 return indexIntoFile()->runOrLumiEntries()[indexToLumi()].lumi();
1425 if (indexToEvent() >=
nEvents())
1427 return indexIntoFile()->runOrLumiEntries()[indexToEventRange()].beginEvents() + indexToEvent();
1437 for (
int i = 0; indexToLumi() +
i <
size(); ++
i) {
1438 if (indexIntoFile()->runOrLumiEntries()[indexToLumi() +
i].isRun()) {
1440 }
else if (indexIntoFile()->runOrLumiEntries()[indexToLumi() +
i].lumi() ==
1441 indexIntoFile()->runOrLumiEntries()[indexToLumi()].lumi()) {
1442 if (indexIntoFile()->runOrLumiEntries()[indexToLumi() +
i].beginEvents() ==
invalidEntry) {
1445 setIndexToEventRange(indexToLumi() +
i);
1461 for (
int i = 1; indexToEventRange() +
i <
size(); ++
i) {
1462 if (indexIntoFile()->runOrLumiEntries()[indexToEventRange() +
i].isRun()) {
1464 }
else if (indexIntoFile()->runOrLumiEntries()[indexToEventRange() +
i].lumi() ==
1465 indexIntoFile()->runOrLumiEntries()[indexToEventRange()].lumi()) {
1466 if (indexIntoFile()->runOrLumiEntries()[indexToEventRange() +
i].beginEvents() ==
invalidEntry) {
1469 setIndexToEventRange(indexToEventRange() +
i);
1486 for (
int i = 1; indexToEventRange() -
i > 0; ++
i) {
1487 int newRange = indexToEventRange() -
i;
1490 }
else if (isSameLumi(newRange, indexToEventRange())) {
1494 setIndexToEventRange(newRange);
1497 setIndexToEvent(
nEvents() - 1);
1509 setIndexToEventRange(index);
1513 setIndexToEvent(
nEvents() - 1);
1520 for (
int i = 1; indexToLumi() +
i <
size(); ++
i) {
1521 int newLumi = indexToLumi() +
i;
1528 setIndexToLumi(newLumi);
1540 if (index < 0 || index >=
size()) {
1549 if (index1 < 0 || index1 >=
size() || index2 < 0 || index2 >=
size()) {
1552 return indexIntoFile()->runOrLumiEntries()[index1].lumi() == indexIntoFile()->runOrLumiEntries()[index2].lumi();
1556 if (index1 < 0 || index1 >=
size() || index2 < 0 || index2 >=
size()) {
1559 return indexIntoFile()->runOrLumiEntries()[index1].run() == indexIntoFile()->runOrLumiEntries()[index2].run() &&
1560 indexIntoFile()->runOrLumiEntries()[index1].processHistoryIDIndex() ==
1561 indexIntoFile()->runOrLumiEntries()[index2].processHistoryIDIndex();
1565 if (index < 0 || index >=
size()) {
1568 return indexIntoFile()->runOrLumiEntries()[
index].lumi();
1575 int indexToEventRange,
1576 long long indexToEvent,
1579 indexIntoFile, entryType, indexToRun, indexToLumi, indexToEventRange, indexToEvent, nEvents) {
1590 return indexIntoFile()->runOrLumiIndexes()[indexToRun()].processHistoryIDIndex();
1596 return indexIntoFile()->runOrLumiIndexes()[indexToRun()].run();
1602 return indexIntoFile()->runOrLumiIndexes()[indexToLumi()].lumi();
1609 int i = indexIntoFile()->runOrLumiIndexes()[indexToRun()].indexToGetEntry();
1610 return indexIntoFile()->runOrLumiEntries()[
i].entry();
1613 int i = indexIntoFile()->runOrLumiIndexes()[indexToLumi()].indexToGetEntry();
1614 return indexIntoFile()->runOrLumiEntries()[
i].entry();
1616 long long eventNumberIndex =
1617 indexIntoFile()->runOrLumiIndexes()[indexToEventRange()].beginEventNumbers() + indexToEvent();
1618 indexIntoFile()->fillEventEntries();
1619 return indexIntoFile()->eventEntries().at(eventNumberIndex).entry();
1625 return indexIntoFile()->runOrLumiIndexes()[indexToLumi()].lumi();
1631 if (indexToEvent() >=
nEvents())
1633 long long eventNumberIndex =
1634 indexIntoFile()->runOrLumiIndexes()[indexToEventRange()].beginEventNumbers() + indexToEvent();
1635 indexIntoFile()->fillEventEntries();
1636 return indexIntoFile()->eventEntries().at(eventNumberIndex).entry();
1641 setIndexToEventRange(indexToLumi());
1643 setNEvents(indexIntoFile()->
runOrLumiIndexes()[indexToLumi()].endEventNumbers() -
1655 long long nEventsInRange = indexIntoFile()->runOrLumiIndexes()[
index].endEventNumbers() -
1656 indexIntoFile()->runOrLumiIndexes()[
index].beginEventNumbers();
1657 if (nEventsInRange == 0) {
1660 while (index > 0 && !indexIntoFile()->
runOrLumiIndexes()[index - 1].isRun() && isSameLumi(index, index - 1)) {
1666 setIndexToEventRange(index);
1667 setNEvents(nEventsInRange);
1669 setIndexToEvent(nEventsInRange - 1);
1676 for (
int i = 1; indexToLumi() +
i <
size(); ++
i) {
1677 int newLumi = indexToLumi() +
i;
1684 setIndexToLumi(newLumi);
1692 return indexIntoFile()->runOrLumiEntries()[indexIntoFile()->runOrLumiIndexes()[
index].indexToGetEntry()].entry() !=
1697 if (index < 0 || index >=
size()) {
1706 if (index1 < 0 || index1 >=
size() || index2 < 0 || index2 >=
size()) {
1709 return indexIntoFile()->runOrLumiIndexes()[index1].lumi() == indexIntoFile()->runOrLumiIndexes()[index2].lumi();
1713 if (index1 < 0 || index1 >=
size() || index2 < 0 || index2 >=
size()) {
1716 return indexIntoFile()->runOrLumiIndexes()[index1].run() == indexIntoFile()->runOrLumiIndexes()[index2].run() &&
1717 indexIntoFile()->runOrLumiIndexes()[index1].processHistoryIDIndex() ==
1718 indexIntoFile()->runOrLumiIndexes()[index2].processHistoryIDIndex();
1722 if (index < 0 || index >=
size()) {
1725 return indexIntoFile()->runOrLumiIndexes()[
index].lumi();
1733 int indexToEventRange,
1734 long long indexToEvent,
1737 indexIntoFile, entryType, indexToRun, indexToLumi, indexToEventRange, indexToEvent, nEvents) {
1745 auto findFirstOpen = [](
auto const& entries) {
1746 return std::find(entries.begin(), entries.end(),
false) - entries.begin();
1752 auto const index = itPresentEntryToRunOrLumis - itBegin;
1753 if (usedEntry[index]) {
1754 ++itPresentEntryToRunOrLumis;
1758 if (itPresentEntryToRunOrLumis->isRun()) {
1761 usedEntry[
index] =
true;
1763 itPresentEntryToRunOrLumis = itRestartSearchAt;
1766 auto const beginEvents = itPresentEntryToRunOrLumis->beginEvents();
1769 if (
std::find(usedEntry.begin(), usedEntry.begin() +
index,
false) == usedEntry.begin() +
index) {
1771 usedEntry[
index] =
true;
1773 itPresentEntryToRunOrLumis = itRestartSearchAt;
1776 }
else if (
beginEvents == endOfContiguousEventEntry) {
1778 usedEntry[
index] =
true;
1779 endOfContiguousEventEntry = itPresentEntryToRunOrLumis->endEvents();
1781 itPresentEntryToRunOrLumis = itRestartSearchAt;
1784 ++itPresentEntryToRunOrLumis;
1795 return runOrLumisEntry(indexToRun()).processHistoryIDIndex();
1801 return runOrLumisEntry(indexToRun()).run();
1807 return runOrLumisEntry(indexToLumi()).lumi();
1814 return runOrLumisEntry(indexToRun()).entry();
1816 auto entry = runOrLumisEntry(indexToLumi()).entry();
1818 if (indexToLumi() + 1 <
size()) {
1819 if (runOrLumisEntry(indexToLumi()).
lumi() != runOrLumisEntry(indexToLumi() + 1).
lumi()) {
1821 auto const& runLumiEntry = runOrLumisEntry(indexToLumi());
1822 for (
auto nextIndex = indexToLumi() + 1; nextIndex <
size(); ++nextIndex) {
1823 auto const& nextRunLumiEntry = runOrLumisEntry(nextIndex);
1824 if (runLumiEntry.lumi() == nextRunLumiEntry.lumi() and runLumiEntry.run() == nextRunLumiEntry.run() and
1825 runLumiEntry.processHistoryIDIndex() == nextRunLumiEntry.processHistoryIDIndex()) {
1826 auto nextEntry = nextRunLumiEntry.entry();
1838 return runOrLumisEntry(indexToEventRange()).beginEvents() + indexToEvent();
1842 auto entry = runOrLumisEntry(indexToLumi()).entry();
1849 return runOrLumisEntry(indexToLumi()).lumi();
1855 if (indexToEvent() >=
nEvents())
1857 return runOrLumisEntry(indexToEventRange()).beginEvents() + indexToEvent();
1867 for (
int i = 0; indexToLumi() +
i <
size(); ++
i) {
1868 if (runOrLumisEntry(indexToLumi() +
i).isRun()) {
1870 }
else if (runOrLumisEntry(indexToLumi() +
i).lumi() == runOrLumisEntry(indexToLumi()).lumi()) {
1871 if (runOrLumisEntry(indexToLumi() +
i).beginEvents() ==
invalidEntry) {
1874 setIndexToEventRange(indexToLumi() +
i);
1876 setNEvents(runOrLumisEntry(indexToEventRange()).
endEvents() -
1877 runOrLumisEntry(indexToEventRange()).
beginEvents());
1890 for (
int i = 1; indexToEventRange() +
i <
size(); ++
i) {
1891 if (runOrLumisEntry(indexToEventRange() +
i).isRun()) {
1893 }
else if (runOrLumisEntry(indexToEventRange() +
i).lumi() == runOrLumisEntry(indexToEventRange()).lumi()) {
1894 if (runOrLumisEntry(indexToEventRange() +
i).beginEvents() ==
invalidEntry) {
1897 setIndexToEventRange(indexToEventRange() +
i);
1899 setNEvents(runOrLumisEntry(indexToEventRange()).
endEvents() -
1900 runOrLumisEntry(indexToEventRange()).
beginEvents());
1914 for (
int i = 1; indexToEventRange() -
i > 0; ++
i) {
1915 int newRange = indexToEventRange() -
i;
1916 if (runOrLumisEntry(newRange).isRun()) {
1918 }
else if (isSameLumi(newRange, indexToEventRange())) {
1922 setIndexToEventRange(newRange);
1923 setNEvents(runOrLumisEntry(indexToEventRange()).
endEvents() -
1924 runOrLumisEntry(indexToEventRange()).
beginEvents());
1925 setIndexToEvent(
nEvents() - 1);
1937 setIndexToEventRange(index);
1938 setNEvents(runOrLumisEntry(indexToEventRange()).
endEvents() - runOrLumisEntry(indexToEventRange()).
beginEvents());
1940 setIndexToEvent(
nEvents() - 1);
1947 for (
int i = 1; indexToLumi() +
i <
size(); ++
i) {
1948 int newLumi = indexToLumi() +
i;
1949 if (runOrLumisEntry(newLumi).isRun()) {
1951 }
else if (runOrLumisEntry(newLumi).
lumi() == runOrLumisEntry(indexToLumi()).
lumi()) {
1954 setIndexToLumi(newLumi);
1962 auto entry = runOrLumisEntry(index).entry();
1964 if (index + 1 <
size()) {
1965 if (runOrLumisEntry(index).
lumi() != runOrLumisEntry(index + 1).
lumi()) {
1974 if (index < 0 || index >=
size()) {
1976 }
else if (runOrLumisEntry(index).isRun()) {
1983 if (index1 < 0 || index1 >=
size() || index2 < 0 || index2 >=
size()) {
1986 return runOrLumisEntry(index1).lumi() == runOrLumisEntry(index2).lumi();
1990 if (index1 < 0 || index1 >=
size() || index2 < 0 || index2 >=
size()) {
1993 return runOrLumisEntry(index1).run() == runOrLumisEntry(index2).run() &&
1994 runOrLumisEntry(index1).processHistoryIDIndex() == runOrLumisEntry(index2).processHistoryIDIndex();
1998 if (index < 0 || index >=
size()) {
2001 return runOrLumisEntry(index).lumi();
2011 int indexToEventRange,
2012 long long indexToEvent,
2017 indexIntoFile, entryType, indexToRun, indexToLumi, indexToEventRange, indexToEvent, nEvents));
2021 indexIntoFile, entryType, indexToRun, indexToLumi, indexToEventRange, indexToEvent, nEvents));
2025 indexIntoFile, entryType, indexToRun, indexToLumi, indexToEventRange, indexToEvent, nEvents));
2031 for (
EntryType entryType = getEntryType(); entryType !=
kEnd && entryType !=
kEvent; entryType = getEntryType()) {
2037 for (
EntryType entryType = getEntryType(); entryType !=
kEnd && entryType !=
kLumi; entryType = getEntryType()) {
2043 impl_->copyPosition(*position.
impl_);
2049 return lh.
run() < rh.
run();
void initializeRun()
Should only be used internally and for tests.
void initializeLumi_() override
bool setToLastEventInRange(int index) override
void fillEventNumbersOrEntries(bool needEventNumbers, bool needEventEntries) const
RunNumber_t & currentRun() const
LuminosityBlockNumber_t peekAheadAtLumi() const override
int processHistoryIDIndex() const
EntryType getRunOrLumiEntryType(int index) const override
EntryNumber_t peekAheadAtEventEntry() const
static constexpr int invalidIndex
EntryNumber_t entry() const override
bool skipLumiInRun() override
IndexIntoFile const * indexIntoFile() const
bool isSameLumi(int index1, int index2) const override
IndexIntoFileItrEntryOrder(IndexIntoFile const *indexIntoFile, EntryType entryType, int indexToRun, int indexToLumi, int indexToEventRange, long long indexToEvent, long long nEvents)
bool skipToNextEventInLumi()
void addLumi(int index, RunNumber_t run, LuminosityBlockNumber_t lumi, EntryNumber_t entry)
std::vector< EventEntry > & eventEntries() const
int processHistoryIDIndex() const override
bool lumiEntryValid(int index) const override
IndexIntoFileItrImpl * clone() const override
void advanceToNextLumiOrRun()
int processHistoryIDIndex() const override
SortedRunOrLumiItr beginRunOrLumi() const
bool empty() const
True if no runs, lumis, or events are in the file.
LuminosityBlockNumber_t & currentLumi() const
EntryType getEntryType() const
bool nextEventRange() override
IndexIntoFile const * indexIntoFile_
bool entryContinues() const override
bool operator==(SortedRunOrLumiItr const &right) const
bool lumiEntryValid(int index) const override
unsigned long long EventNumber_t
std::vector< RunOrLumiIndexes > & runOrLumiIndexes() const
__host__ __device__ constexpr RandomIt upper_bound(RandomIt first, RandomIt last, const T &value, Compare comp={})
void fillUnsortedEventNumbers() const
EntryType getRunOrLumiEntryType(int index) const override
IndexIntoFileItr begin(SortOrder sortOrder) const
void initializeLumi_() override
bool previousEventRange() override
IndexIntoFile const * indexIntoFile_
void swap(Hash< I > &other)
LuminosityBlockNumber_t lumi() const
std::map< IndexRunLumiKey, EntryNumber_t > & lumiToOrder() const
std::vector< RunOrLumiEntry > const & runOrLumiEntries() const
Used internally and for test purposes.
void stable_sort_all(RandomAccessSequence &s)
wrappers for std::stable_sort
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
virtual ~IndexIntoFileItrImpl()
EntryNumber_t entry() const override
unsigned int LuminosityBlockNumber_t
IndexIntoFileItr findRunPosition(RunNumber_t run) const
Same as findPosition.
std::vector< ProcessHistoryID > const & processHistoryIDs() const
static constexpr EventNumber_t invalidEvent
void swap(Association< C > &lhs, Association< C > &rhs)
long long beginEventNumbers() const
RunNumber_t run() const override
IndexIntoFileItr findPosition(RunNumber_t run, LuminosityBlockNumber_t lumi=0U, EventNumber_t event=0U) const
int & previousAddedIndex() const
void sortVector_Run_Or_Lumi_Entries()
IndexIntoFileItrImpl * clone() const override
LuminosityBlockNumber_t lumi() const override
void setNumberOfEvents(EntryNumber_t nevents)
size_t numberOfEvents() const
void reduceProcessHistoryIDs(ProcessHistoryRegistry const &processHistoryRegistry)
IndexIntoFile const * indexIntoFile() const
bool skipLumiInRun() override
int & currentIndex() const
bool setToLastEventInRange(int index) override
IndexIntoFileItrImpl * clone() const override
RunOrLumiIndexes(int processHistoryIDIndex, RunNumber_t run, LuminosityBlockNumber_t lumi, int indexToGetEntry)
double intersection(double r12)
static constexpr EntryNumber_t continuedLumi
static constexpr RunNumber_t invalidRun
LuminosityBlockNumber_t peekAheadAtLumi() const override
void skipEventBackward(int &phIndexOfEvent, RunNumber_t &runOfEvent, LuminosityBlockNumber_t &lumiOfEvent, EntryNumber_t &eventEntry)
RunNumber_t run() const override
std::vector< RunOrLumiEntry > runOrLumiEntries_
LuminosityBlockNumber_t lumi() const override
void copyPosition(IndexIntoFileItr const &position)
Copy the position without modifying the pointer to the IndexIntoFile or size.
IndexIntoFileItr end(SortOrder sortOrder) const
Used to end an iteration over the Runs, Lumis, and Events in a file.
void skipEventForward(int &phIndexOfSkippedEvent, RunNumber_t &runOfSkippedEvent, LuminosityBlockNumber_t &lumiOfSkippedEvent, EntryNumber_t &skippedEventEntry)
std::vector< ProcessHistoryID > processHistoryIDs_
void fillEventEntries() const
IndexIntoFileItrImpl(IndexIntoFile const *indexIntoFile, EntryType entryType, int indexToRun, int indexToLumi, int indexToEventRange, long long indexToEvent, long long nEvents)
LuminosityBlockNumber_t peekAheadAtLumi() const override
void fillRunOrLumiIndexes() const
bool operator==(IndexIntoFileItrImpl const &right) const
bool previousLumiWithEvents()
void set_intersection(IndexIntoFile const &indexIntoFile, std::set< IndexRunLumiEventKey > &intersection) const
SortedRunOrLumiItr & operator++()
bool isSameRun(int index1, int index2) const override
bool iterationWillBeInEntryOrder(SortOrder sortOrder) const
Used to determine whether or not to disable fast cloning.
void getLumisInRun(std::vector< LuminosityBlockNumber_t > &lumis) const
ProcessHistoryID const & reducedProcessHistoryID(ProcessHistoryID const &fullID) const
EntryNumber_t peekAheadAtEventEntry() const override
bool isSameRun(int index1, int index2) const override
std::vector< EntryNumber_t > fileOrderRunOrLumiEntry_
bool operator()(IndexIntoFile::RunOrLumiIndexes const &lh, IndexIntoFile::RunOrLumiIndexes const &rh)
bool operator!=(SortedRunOrLumiItr const &right) const
void addEntry(ProcessHistoryID const &processHistoryID, RunNumber_t run, LuminosityBlockNumber_t lumi, EventNumber_t event, EntryNumber_t entry)
long long endEventNumbers() const
SortedRunOrLumiItr(IndexIntoFile const *indexIntoFile, unsigned runOrLumi)
EntryNumber_t firstEventEntryThisLumi()
Hash< ProcessHistoryType > ProcessHistoryID
void sortEventEntries() const
bool containsLumi(RunNumber_t run, LuminosityBlockNumber_t lumi) const
bool containsDuplicateEvents() const
Returns true if the IndexIntoFile contains 2 events with the same ProcessHistoryID index...
bool previousEventRange() override
bool containsItem(RunNumber_t run, LuminosityBlockNumber_t lumi, EventNumber_t event) const
void fixIndexes(std::vector< ProcessHistoryID > &processHistoryIDs)
EntryNumber_t peekAheadAtEventEntry() const override
bool setToLastEventInRange(int index) override
void resetEventFinder() const
bool nextEventRange() override
static constexpr EntryNumber_t invalidEntry
int processHistoryIDIndex() const override
IndexIntoFileItrSorted(IndexIntoFile const *indexIntoFile, EntryType entryType, int indexToRun, int indexToLumi, int indexToEventRange, long long indexToEvent, long long nEvents)
std::vector< EventNumber_t > & unsortedEventNumbers()
static constexpr LuminosityBlockNumber_t invalidLumi
IndexIntoFileItr findLumiPosition(RunNumber_t run, LuminosityBlockNumber_t lumi) const
unsigned runOrLumi() const
RunNumber_t run() const override
void initializeLumi()
Should only be used internally and for tests.
ProcessHistoryID const & processHistoryID(int i) const
std::map< IndexRunKey, EntryNumber_t > & runToOrder() const
EntryNumber_t firstEventEntryThisRun()
void copyPosition(IndexIntoFileItrImpl const &position)
LuminosityBlockNumber_t lumi() const override
void doneFileInitialization()
Clears the temporary vector of event numbers to reduce memory usage.
EntryType getRunOrLumiEntryType(int index) const override
EventNumber_t getEventNumberOfEntry(EntryNumber_t entry) const
__host__ __device__ constexpr RandomIt lower_bound(RandomIt first, RandomIt last, const T &value, Compare comp={})
void fillEventNumbers() const
static int position[264][3]
bool isSameLumi(int index1, int index2) const override
bool isSameRun(int index1, int index2) const override
bool isSameLumi(int index1, int index2) const override
bool lumiEntryValid(int index) const override
bool containsEvent(RunNumber_t run, LuminosityBlockNumber_t lumi, EventNumber_t event) const
std::vector< EventNumber_t > & eventNumbers() const
bool nextEventRange() override
IndexIntoFileItr(IndexIntoFile const *indexIntoFile, SortOrder sortOrder, EntryType entryType, int indexToRun, int indexToLumi, int indexToEventRange, long long indexToEvent, long long nEvents)
bool previousEventRange() override
SortedRunOrLumiItr endRunOrLumi() const
bool operator()(IndexIntoFile::RunOrLumiIndexes const &lh, IndexIntoFile::RunOrLumiIndexes const &rh)
EntryNumber_t entry() const override
std::vector< EventNumber_t > & unsortedEventNumbersMutable() const
bool skipToNextEventInLumi()
bool containsRun(RunNumber_t run) const
IndexIntoFileItr findEventPosition(RunNumber_t run, LuminosityBlockNumber_t lumi, EventNumber_t event) const
void getRange(long long &beginEventNumbers, long long &endEventNumbers, EntryNumber_t &beginEventEntry, EntryNumber_t &endEventEntry)
EntryNumber_t & endEvents() const
LuminosityBlockNumber_t peekAheadAtLumi() const
EntryNumber_t & beginEvents() const
value_ptr< IndexIntoFileItrImpl > impl_
tuple size
Write out results.
bool skipLumiInRun() override
IndexIntoFileItrNoSort(IndexIntoFile const *indexIntoFile, EntryType entryType, int indexToRun, int indexToLumi, int indexToEventRange, long long indexToEvent, long long nEvents)
void initializeLumi_() override
EntryNumber_t peekAheadAtEventEntry() const override
RunOrLumiIndexes const & runOrLumiIndexes() const