Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2022-05-10 05:40:51

0001 /*
0002  *  indexIntoFile_t.cppunit.cc
0003  */
0004 
0005 #include "cppunit/extensions/HelperMacros.h"
0006 
0007 #include "DataFormats/Provenance/interface/ProcessHistoryID.h"
0008 #include "DataFormats/Provenance/interface/ProcessConfiguration.h"
0009 #include "DataFormats/Provenance/interface/ProcessHistory.h"
0010 
0011 #include "DataFormats/Provenance/interface/IndexIntoFile.h"
0012 
0013 #include <string>
0014 #include <iostream>
0015 #include <memory>
0016 
0017 using namespace edm;
0018 
0019 class TestIndexIntoFile3 : public CppUnit::TestFixture {
0020   CPPUNIT_TEST_SUITE(TestIndexIntoFile3);
0021   CPPUNIT_TEST(testIterEndWithEvent);
0022   CPPUNIT_TEST(testOverlappingLumis);
0023   CPPUNIT_TEST(testOverlappingLumisMore);
0024   CPPUNIT_TEST(testOverlappingLumisOutOfOrderEvent);
0025   CPPUNIT_TEST(testOverlappingLumisWithEndWithEmptyLumi);
0026   CPPUNIT_TEST(testOverlappingLumisWithLumiEndOrderChanged);
0027   CPPUNIT_TEST(testNonContiguousRun);
0028   CPPUNIT_TEST(testNonValidLumiInsideValidLumis);
0029   CPPUNIT_TEST_SUITE_END();
0030 
0031 public:
0032   static const IndexIntoFile::EntryType kRun = IndexIntoFile::kRun;
0033   static const IndexIntoFile::EntryType kLumi = IndexIntoFile::kLumi;
0034   static const IndexIntoFile::EntryType kEvent = IndexIntoFile::kEvent;
0035   static const IndexIntoFile::EntryType kEnd = IndexIntoFile::kEnd;
0036 
0037   class Skipped {
0038   public:
0039     Skipped() : phIndexOfSkippedEvent_(0), runOfSkippedEvent_(0), lumiOfSkippedEvent_(0), skippedEventEntry_(0) {}
0040     int phIndexOfSkippedEvent_;
0041     RunNumber_t runOfSkippedEvent_;
0042     LuminosityBlockNumber_t lumiOfSkippedEvent_;
0043     IndexIntoFile::EntryNumber_t skippedEventEntry_;
0044   };
0045 
0046   Skipped skipped_;
0047 
0048   void setUp() {
0049     // Make some fake processHistoryID's to work with
0050     nullPHID = ProcessHistoryID();
0051 
0052     ProcessConfiguration pc;
0053     auto processHistory1 = std::make_unique<ProcessHistory>();
0054     ProcessHistory& ph1 = *processHistory1;
0055     processHistory1->push_back(pc);
0056     fakePHID1 = ph1.id();
0057 
0058     auto processHistory2 = std::make_unique<ProcessHistory>();
0059     ProcessHistory& ph2 = *processHistory2;
0060     processHistory2->push_back(pc);
0061     processHistory2->push_back(pc);
0062     fakePHID2 = ph2.id();
0063 
0064     auto processHistory3 = std::make_unique<ProcessHistory>();
0065     ProcessHistory& ph3 = *processHistory3;
0066     processHistory3->push_back(pc);
0067     processHistory3->push_back(pc);
0068     processHistory3->push_back(pc);
0069     fakePHID3 = ph3.id();
0070   }
0071 
0072   void tearDown() {}
0073 
0074   void testIterEndWithEvent();
0075   void testOverlappingLumis();
0076   void testOverlappingLumisMore();
0077   void testOverlappingLumisOutOfOrderEvent();
0078   void testOverlappingLumisWithEndWithEmptyLumi();
0079   void testOverlappingLumisWithLumiEndOrderChanged();
0080   void testNonContiguousRun();
0081   void testNonValidLumiInsideValidLumis();
0082 
0083   ProcessHistoryID nullPHID;
0084   ProcessHistoryID fakePHID1;
0085   ProcessHistoryID fakePHID2;
0086   ProcessHistoryID fakePHID3;
0087 
0088   bool check(edm::IndexIntoFile::IndexIntoFileItr const& iter,
0089              IndexIntoFile::EntryType type,
0090              int indexToRun,
0091              int indexToLumi,
0092              int indexToEventRange,
0093              long long indexToEvent,
0094              long long nEvents);
0095 
0096   void skipEventForward(edm::IndexIntoFile::IndexIntoFileItr& iter);
0097   void skipEventBackward(edm::IndexIntoFile::IndexIntoFileItr& iter);
0098   void checkSkipped(int phIndexOfSkippedEvent,
0099                     RunNumber_t runOfSkippedEvent,
0100                     LuminosityBlockNumber_t lumiOfSkippedEvent,
0101                     IndexIntoFile::EntryNumber_t skippedEventEntry);
0102 
0103   void checkIDRunLumiEntry(edm::IndexIntoFile::IndexIntoFileItr const& iter,
0104                            int phIndex,
0105                            RunNumber_t run,
0106                            LuminosityBlockNumber_t lumi,
0107                            IndexIntoFile::EntryNumber_t entry);
0108 };
0109 
0110 ///registration of the test so that the runner can find it
0111 CPPUNIT_TEST_SUITE_REGISTRATION(TestIndexIntoFile3);
0112 
0113 bool TestIndexIntoFile3::check(edm::IndexIntoFile::IndexIntoFileItr const& iter,
0114                                IndexIntoFile::EntryType type,
0115                                int indexToRun,
0116                                int indexToLumi,
0117                                int indexToEventRange,
0118                                long long indexToEvent,
0119                                long long nEvents) {
0120   bool theyMatch = iter.getEntryType() == type && iter.type() == type && iter.indexToRun() == indexToRun &&
0121                    iter.indexToLumi() == indexToLumi && iter.indexToEventRange() == indexToEventRange &&
0122                    iter.indexToEvent() == indexToEvent && iter.nEvents() == nEvents;
0123   if (!theyMatch) {
0124     std::cout << "\nExpected        " << type << "  " << indexToRun << "  " << indexToLumi << "  " << indexToEventRange
0125               << "  " << indexToEvent << "  " << nEvents << "\n";
0126     std::cout << "Iterator values " << iter.type() << "  " << iter.indexToRun() << "  " << iter.indexToLumi() << "  "
0127               << iter.indexToEventRange() << "  " << iter.indexToEvent() << "  " << iter.nEvents() << "\n";
0128   }
0129   return theyMatch;
0130 }
0131 
0132 void TestIndexIntoFile3::checkSkipped(int phIndexOfSkippedEvent,
0133                                       RunNumber_t runOfSkippedEvent,
0134                                       LuminosityBlockNumber_t lumiOfSkippedEvent,
0135                                       IndexIntoFile::EntryNumber_t skippedEventEntry) {
0136   bool theyMatch =
0137       skipped_.phIndexOfSkippedEvent_ == phIndexOfSkippedEvent && skipped_.runOfSkippedEvent_ == runOfSkippedEvent &&
0138       skipped_.lumiOfSkippedEvent_ == lumiOfSkippedEvent && skipped_.skippedEventEntry_ == skippedEventEntry;
0139 
0140   if (!theyMatch) {
0141     std::cout << "\nExpected        " << phIndexOfSkippedEvent << "  " << runOfSkippedEvent << "  "
0142               << lumiOfSkippedEvent << "  " << skippedEventEntry << "\n";
0143     std::cout << "Actual          " << skipped_.phIndexOfSkippedEvent_ << "  " << skipped_.runOfSkippedEvent_ << "  "
0144               << skipped_.lumiOfSkippedEvent_ << "  " << skipped_.skippedEventEntry_ << "\n";
0145   }
0146   CPPUNIT_ASSERT(theyMatch);
0147 }
0148 
0149 void TestIndexIntoFile3::checkIDRunLumiEntry(edm::IndexIntoFile::IndexIntoFileItr const& iter,
0150                                              int phIndex,
0151                                              RunNumber_t run,
0152                                              LuminosityBlockNumber_t lumi,
0153                                              IndexIntoFile::EntryNumber_t entry) {
0154   bool theyMatch =
0155       iter.processHistoryIDIndex() == phIndex && iter.run() == run && iter.lumi() == lumi && iter.entry() == entry;
0156 
0157   if (!theyMatch) {
0158     std::cout << "\nExpected        " << phIndex << "  " << run << "  " << lumi << "  " << entry << "\n";
0159     std::cout << "Actual          " << iter.processHistoryIDIndex() << "  " << iter.run() << "  " << iter.lumi() << "  "
0160               << iter.entry() << "\n";
0161   }
0162   CPPUNIT_ASSERT(theyMatch);
0163 }
0164 
0165 void TestIndexIntoFile3::skipEventForward(edm::IndexIntoFile::IndexIntoFileItr& iter) {
0166   iter.skipEventForward(skipped_.phIndexOfSkippedEvent_,
0167                         skipped_.runOfSkippedEvent_,
0168                         skipped_.lumiOfSkippedEvent_,
0169                         skipped_.skippedEventEntry_);
0170 }
0171 
0172 void TestIndexIntoFile3::skipEventBackward(edm::IndexIntoFile::IndexIntoFileItr& iter) {
0173   iter.skipEventBackward(skipped_.phIndexOfSkippedEvent_,
0174                          skipped_.runOfSkippedEvent_,
0175                          skipped_.lumiOfSkippedEvent_,
0176                          skipped_.skippedEventEntry_);
0177 }
0178 
0179 void TestIndexIntoFile3::testIterEndWithEvent() {
0180   edm::IndexIntoFile indexIntoFile;
0181   indexIntoFile.addEntry(fakePHID1, 11, 101, 7, 0);  // Event
0182   indexIntoFile.addEntry(fakePHID1, 11, 101, 6, 1);  // Event
0183   indexIntoFile.addEntry(fakePHID1, 11, 101, 0, 0);  // Lumi
0184   indexIntoFile.addEntry(fakePHID1, 11, 101, 0, 1);  // Lumi
0185   indexIntoFile.addEntry(fakePHID1, 11, 101, 5, 2);  // Event
0186   indexIntoFile.addEntry(fakePHID1, 11, 101, 4, 3);  // Event
0187   indexIntoFile.addEntry(fakePHID1, 11, 101, 0, 2);  // Lumi
0188   indexIntoFile.addEntry(fakePHID1, 11, 102, 5, 4);  // Event
0189   indexIntoFile.addEntry(fakePHID1, 11, 102, 4, 5);  // Event
0190   indexIntoFile.addEntry(fakePHID1, 11, 102, 0, 3);  // Lumi
0191   indexIntoFile.addEntry(fakePHID1, 11, 0, 0, 0);    // Run
0192   indexIntoFile.addEntry(fakePHID2, 11, 0, 0, 1);    // Run
0193   indexIntoFile.addEntry(fakePHID2, 11, 101, 0, 4);  // Lumi
0194   indexIntoFile.addEntry(fakePHID2, 11, 102, 0, 5);  // Lumi
0195   indexIntoFile.addEntry(fakePHID2, 11, 102, 4, 6);  // Event
0196   indexIntoFile.addEntry(fakePHID2, 11, 102, 0, 6);  // Lumi
0197   indexIntoFile.addEntry(fakePHID2, 11, 0, 0, 2);    // Run
0198   indexIntoFile.sortVector_Run_Or_Lumi_Entries();
0199 
0200   edm::IndexIntoFile::IndexIntoFileItr iter3(
0201       &indexIntoFile, IndexIntoFile::firstAppearanceOrder, IndexIntoFile::kEvent, 0, 3, 2, 1, 2);
0202   edm::IndexIntoFile::IndexIntoFileItr iter1(iter3);
0203 
0204   CPPUNIT_ASSERT(iter1 == iter3);
0205   CPPUNIT_ASSERT(iter1.indexIntoFile() == &indexIntoFile);
0206   CPPUNIT_ASSERT(iter1.size() == 10);
0207   CPPUNIT_ASSERT(iter1.type() == kEvent);
0208   CPPUNIT_ASSERT(iter1.indexToRun() == 0);
0209   CPPUNIT_ASSERT(iter1.indexToLumi() == 3);
0210   CPPUNIT_ASSERT(iter1.indexToEventRange() == 2);
0211   CPPUNIT_ASSERT(iter1.indexToEvent() == 1);
0212   CPPUNIT_ASSERT(iter1.nEvents() == 2);
0213 
0214   iter1 = ++iter3;
0215   CPPUNIT_ASSERT(iter1 == iter3);
0216 
0217   CPPUNIT_ASSERT(indexIntoFile.iterationWillBeInEntryOrder(IndexIntoFile::firstAppearanceOrder) == true);
0218 
0219   edm::IndexIntoFile::IndexIntoFileItr iterFirst = indexIntoFile.begin(IndexIntoFile::firstAppearanceOrder);
0220   edm::IndexIntoFile::IndexIntoFileItr iterFirstCopy = iterFirst;
0221   edm::IndexIntoFile::IndexIntoFileItr iterFirstCopy2 = iterFirst;
0222   edm::IndexIntoFile::IndexIntoFileItr iterFirstEnd = indexIntoFile.end(IndexIntoFile::firstAppearanceOrder);
0223   int i = 0;
0224   for (i = 0; iterFirst != iterFirstEnd; ++iterFirst, ++iterFirstCopy, ++i) {
0225     CPPUNIT_ASSERT(iterFirst == iterFirstCopy);
0226     iterFirstCopy2 = iterFirstCopy;
0227     CPPUNIT_ASSERT(iterFirst == iterFirstCopy2);
0228     if (i == 0) {
0229       CPPUNIT_ASSERT(check(iterFirst, kRun, 0, 1, 1, 0, 2));
0230       CPPUNIT_ASSERT(iterFirst.indexIntoFile() == &indexIntoFile);
0231       CPPUNIT_ASSERT(iterFirst.size() == 10);
0232       CPPUNIT_ASSERT(iterFirst.indexedSize() == 10);
0233       CPPUNIT_ASSERT(iterFirst.shouldProcessRun());
0234     } else if (i == 1) {
0235       CPPUNIT_ASSERT(check(iterFirst, kLumi, 0, 1, 1, 0, 2));
0236       CPPUNIT_ASSERT(iterFirst.shouldProcessLumi());
0237     } else if (i == 2)
0238       CPPUNIT_ASSERT(check(iterFirst, kLumi, 0, 2, 1, 0, 2));
0239     else if (i == 3)
0240       CPPUNIT_ASSERT(check(iterFirst, kLumi, 0, 3, 1, 0, 2));
0241     else if (i == 4)
0242       CPPUNIT_ASSERT(check(iterFirst, kEvent, 0, 3, 1, 0, 2));
0243     else if (i == 5)
0244       CPPUNIT_ASSERT(check(iterFirst, kEvent, 0, 3, 1, 1, 2));
0245     else if (i == 6)
0246       CPPUNIT_ASSERT(check(iterFirst, kEvent, 0, 3, 3, 0, 2));
0247     else if (i == 7)
0248       CPPUNIT_ASSERT(check(iterFirst, kEvent, 0, 3, 3, 1, 2));
0249     else if (i == 8)
0250       CPPUNIT_ASSERT(check(iterFirst, kLumi, 0, 4, 4, 0, 2));
0251     else if (i == 9)
0252       CPPUNIT_ASSERT(check(iterFirst, kEvent, 0, 4, 4, 0, 2));
0253     else if (i == 10)
0254       CPPUNIT_ASSERT(check(iterFirst, kEvent, 0, 4, 4, 1, 2));
0255     else if (i == 11)
0256       CPPUNIT_ASSERT(check(iterFirst, kRun, 5, 7, -1, 0, 0));
0257     else if (i == 12)
0258       CPPUNIT_ASSERT(check(iterFirst, kRun, 6, 7, -1, 0, 0));
0259     else if (i == 13)
0260       CPPUNIT_ASSERT(check(iterFirst, kLumi, 6, 7, -1, 0, 0));
0261     else if (i == 14)
0262       CPPUNIT_ASSERT(check(iterFirst, kLumi, 6, 8, 9, 0, 1));
0263     else if (i == 15)
0264       CPPUNIT_ASSERT(check(iterFirst, kLumi, 6, 9, 9, 0, 1));
0265     else if (i == 16)
0266       CPPUNIT_ASSERT(check(iterFirst, kEvent, 6, 9, 9, 0, 1));
0267     else
0268       CPPUNIT_ASSERT(false);
0269 
0270     switch (i) {
0271       case 0:
0272         CPPUNIT_ASSERT(iterFirst.firstEventEntryThisRun() == 0);
0273         break;
0274       case 10:
0275         CPPUNIT_ASSERT(iterFirst.firstEventEntryThisRun() == 0);
0276         break;
0277       case 12:
0278         CPPUNIT_ASSERT(iterFirst.firstEventEntryThisRun() == 6);
0279         break;
0280     }
0281 
0282     switch (i) {
0283       case 0:
0284         CPPUNIT_ASSERT(iterFirst.firstEventEntryThisLumi() == 0);
0285         break;
0286       case 1:
0287         CPPUNIT_ASSERT(iterFirst.firstEventEntryThisLumi() == 0);
0288         break;
0289       case 2:
0290         CPPUNIT_ASSERT(iterFirst.firstEventEntryThisLumi() == 0);
0291         break;
0292       case 3:
0293         CPPUNIT_ASSERT(iterFirst.firstEventEntryThisLumi() == 0);
0294         break;
0295       case 10:
0296         CPPUNIT_ASSERT(iterFirst.firstEventEntryThisLumi() == 4);
0297         break;
0298       case 12:
0299         CPPUNIT_ASSERT(iterFirst.firstEventEntryThisLumi() == IndexIntoFile::invalidIndex);
0300         break;
0301     }
0302   }
0303   CPPUNIT_ASSERT(i == 17);
0304 
0305   for (i = 0, iterFirst = indexIntoFile.begin(IndexIntoFile::firstAppearanceOrder); iterFirst != iterFirstEnd;
0306        ++iterFirst, ++i) {
0307     switch (i) {
0308       case 0:
0309         checkIDRunLumiEntry(iterFirst, 0, 11, 0, 0);  // Run
0310         break;
0311       case 1:
0312         checkIDRunLumiEntry(iterFirst, 0, 11, 101, 0);  // Lumi
0313         break;
0314       case 2:
0315         checkIDRunLumiEntry(iterFirst, 0, 11, 101, 1);  // Lumi
0316         break;
0317       case 3:
0318         checkIDRunLumiEntry(iterFirst, 0, 11, 101, 2);  // Lumi
0319         break;
0320       case 4:
0321         checkIDRunLumiEntry(iterFirst, 0, 11, 101, 0);  // Event
0322         break;
0323       case 5:
0324         checkIDRunLumiEntry(iterFirst, 0, 11, 101, 1);  // Event
0325         break;
0326       case 6:
0327         checkIDRunLumiEntry(iterFirst, 0, 11, 101, 2);  // Event
0328         break;
0329       case 7:
0330         checkIDRunLumiEntry(iterFirst, 0, 11, 101, 3);  // Event
0331         break;
0332       case 8:
0333         checkIDRunLumiEntry(iterFirst, 0, 11, 102, 3);  // Lumi
0334         break;
0335       case 9:
0336         checkIDRunLumiEntry(iterFirst, 0, 11, 102, 4);  // Event
0337         break;
0338       case 10:
0339         checkIDRunLumiEntry(iterFirst, 0, 11, 102, 5);  // Event
0340         break;
0341       case 11:
0342         checkIDRunLumiEntry(iterFirst, 1, 11, 0, 1);  // Run
0343         break;
0344       case 12:
0345         checkIDRunLumiEntry(iterFirst, 1, 11, 0, 2);  // Run
0346         break;
0347       case 13:
0348         checkIDRunLumiEntry(iterFirst, 1, 11, 101, 4);  // Lumi
0349         break;
0350       case 14:
0351         checkIDRunLumiEntry(iterFirst, 1, 11, 102, 5);  // Lumi
0352         break;
0353       case 15:
0354         checkIDRunLumiEntry(iterFirst, 1, 11, 102, 6);  // Lumi
0355         break;
0356       case 16:
0357         checkIDRunLumiEntry(iterFirst, 1, 11, 102, 6);  // Event
0358         break;
0359     }
0360   }
0361   checkIDRunLumiEntry(iterFirst, -1, 0, 0, -1);  // Event
0362 
0363   CPPUNIT_ASSERT(indexIntoFile.runOrLumiIndexes().empty());
0364 
0365   // Now repeat the above tests for the sorted iteration
0366 
0367   edm::IndexIntoFile::IndexIntoFileItr iter4(
0368       &indexIntoFile, IndexIntoFile::numericalOrder, IndexIntoFile::kEvent, 0, 3, 1, 3, 4);
0369   edm::IndexIntoFile::IndexIntoFileItr iter2(iter4);
0370 
0371   CPPUNIT_ASSERT(iter2 == iter4);
0372   CPPUNIT_ASSERT(iter2.indexIntoFile() == &indexIntoFile);
0373   CPPUNIT_ASSERT(iter2.size() == 10);
0374   CPPUNIT_ASSERT(iter2.type() == kEvent);
0375   CPPUNIT_ASSERT(iter2.indexToRun() == 0);
0376   CPPUNIT_ASSERT(iter2.indexToLumi() == 3);
0377   CPPUNIT_ASSERT(iter2.indexToEventRange() == 1);
0378   CPPUNIT_ASSERT(iter2.indexToEvent() == 3);
0379   CPPUNIT_ASSERT(iter2.nEvents() == 4);
0380 
0381   CPPUNIT_ASSERT(!indexIntoFile.runOrLumiIndexes().empty());
0382 
0383   std::vector<IndexIntoFile::EventEntry>& eventEntries = indexIntoFile.eventEntries();
0384   eventEntries.emplace_back(7, 0);
0385   eventEntries.emplace_back(6, 1);
0386   eventEntries.emplace_back(5, 2);
0387   eventEntries.emplace_back(4, 3);
0388   eventEntries.emplace_back(5, 4);
0389   eventEntries.emplace_back(4, 5);
0390   eventEntries.emplace_back(4, 6);
0391   indexIntoFile.sortEventEntries();
0392 
0393   CPPUNIT_ASSERT(indexIntoFile.iterationWillBeInEntryOrder(IndexIntoFile::numericalOrder) == false);
0394 
0395   edm::IndexIntoFile::IndexIntoFileItr iterNum = indexIntoFile.begin(IndexIntoFile::numericalOrder);
0396   edm::IndexIntoFile::IndexIntoFileItr iterNumCopy = iterNum;
0397   edm::IndexIntoFile::IndexIntoFileItr iterNumCopy2 = iterNum;
0398   edm::IndexIntoFile::IndexIntoFileItr iterNumEnd = indexIntoFile.end(IndexIntoFile::numericalOrder);
0399   i = 0;
0400   for (; iterNum != iterNumEnd; ++iterNum, ++iterNumCopy, ++i) {
0401     iterNumCopy2 = iterNumCopy;
0402     CPPUNIT_ASSERT(iterNum == iterNumCopy);
0403     CPPUNIT_ASSERT(iterNum == iterNumCopy2);
0404     if (i == 0) {
0405       CPPUNIT_ASSERT(check(iterNum, kRun, 0, 1, 1, 0, 4));
0406       CPPUNIT_ASSERT(iterNum.indexIntoFile() == &indexIntoFile);
0407       CPPUNIT_ASSERT(iterNum.size() == 10);
0408       CPPUNIT_ASSERT(iterNum.indexedSize() == 10);
0409       CPPUNIT_ASSERT(iterNum.shouldProcessRun());
0410     } else if (i == 1) {
0411       CPPUNIT_ASSERT(check(iterNum, kLumi, 0, 1, 1, 0, 4));
0412       CPPUNIT_ASSERT(iterNum.shouldProcessLumi());
0413     } else if (i == 2)
0414       CPPUNIT_ASSERT(check(iterNum, kLumi, 0, 2, 1, 0, 4));
0415     else if (i == 3)
0416       CPPUNIT_ASSERT(check(iterNum, kLumi, 0, 3, 1, 0, 4));
0417     else if (i == 4)
0418       CPPUNIT_ASSERT(check(iterNum, kEvent, 0, 3, 1, 0, 4));
0419     else if (i == 5)
0420       CPPUNIT_ASSERT(check(iterNum, kEvent, 0, 3, 1, 1, 4));
0421     else if (i == 6)
0422       CPPUNIT_ASSERT(check(iterNum, kEvent, 0, 3, 1, 2, 4));
0423     else if (i == 7)
0424       CPPUNIT_ASSERT(check(iterNum, kEvent, 0, 3, 1, 3, 4));
0425     else if (i == 8)
0426       CPPUNIT_ASSERT(check(iterNum, kLumi, 0, 4, 4, 0, 2));
0427     else if (i == 9)
0428       CPPUNIT_ASSERT(check(iterNum, kEvent, 0, 4, 4, 0, 2));
0429     else if (i == 10)
0430       CPPUNIT_ASSERT(check(iterNum, kEvent, 0, 4, 4, 1, 2));
0431     else if (i == 11)
0432       CPPUNIT_ASSERT(check(iterNum, kRun, 5, 7, -1, 0, 0));
0433     else if (i == 12)
0434       CPPUNIT_ASSERT(check(iterNum, kRun, 6, 7, -1, 0, 0));
0435     else if (i == 13)
0436       CPPUNIT_ASSERT(check(iterNum, kLumi, 6, 7, -1, 0, 0));
0437     else if (i == 14)
0438       CPPUNIT_ASSERT(check(iterNum, kLumi, 6, 8, 8, 0, 1));
0439     else if (i == 15)
0440       CPPUNIT_ASSERT(check(iterNum, kLumi, 6, 9, 8, 0, 1));
0441     else if (i == 16)
0442       CPPUNIT_ASSERT(check(iterNum, kEvent, 6, 9, 8, 0, 1));
0443     else
0444       CPPUNIT_ASSERT(false);
0445 
0446     switch (i) {
0447       case 0:
0448         CPPUNIT_ASSERT(iterNum.firstEventEntryThisRun() == 3);
0449         break;
0450       case 10:
0451         CPPUNIT_ASSERT(iterNum.firstEventEntryThisRun() == 3);
0452         break;
0453       case 12:
0454         CPPUNIT_ASSERT(iterNum.firstEventEntryThisRun() == 6);
0455         break;
0456     }
0457     switch (i) {
0458       case 0:
0459         CPPUNIT_ASSERT(iterNum.firstEventEntryThisLumi() == 3);
0460         break;
0461       case 1:
0462         CPPUNIT_ASSERT(iterNum.firstEventEntryThisLumi() == 3);
0463         break;
0464       case 2:
0465         CPPUNIT_ASSERT(iterNum.firstEventEntryThisLumi() == 3);
0466         break;
0467       case 3:
0468         CPPUNIT_ASSERT(iterNum.firstEventEntryThisLumi() == 3);
0469         break;
0470       case 10:
0471         CPPUNIT_ASSERT(iterNum.firstEventEntryThisLumi() == 5);
0472         break;
0473       case 12:
0474         CPPUNIT_ASSERT(iterNum.firstEventEntryThisLumi() == IndexIntoFile::invalidIndex);
0475         break;
0476     }
0477   }
0478   CPPUNIT_ASSERT(i == 17);
0479 
0480   for (i = 0, iterNum = indexIntoFile.begin(IndexIntoFile::numericalOrder); iterNum != iterNumEnd; ++iterNum, ++i) {
0481     switch (i) {
0482       case 0:
0483         checkIDRunLumiEntry(iterNum, 0, 11, 0, 0);  // Run
0484         break;
0485       case 1:
0486         checkIDRunLumiEntry(iterNum, 0, 11, 101, 0);  // Lumi
0487         break;
0488       case 2:
0489         checkIDRunLumiEntry(iterNum, 0, 11, 101, 1);  // Lumi
0490         break;
0491       case 3:
0492         checkIDRunLumiEntry(iterNum, 0, 11, 101, 2);  // Lumi
0493         break;
0494       case 4:
0495         checkIDRunLumiEntry(iterNum, 0, 11, 101, 3);  // Event
0496         break;
0497       case 5:
0498         checkIDRunLumiEntry(iterNum, 0, 11, 101, 2);  // Event
0499         break;
0500       case 6:
0501         checkIDRunLumiEntry(iterNum, 0, 11, 101, 1);  // Event
0502         break;
0503       case 7:
0504         checkIDRunLumiEntry(iterNum, 0, 11, 101, 0);  // Event
0505         break;
0506       case 8:
0507         checkIDRunLumiEntry(iterNum, 0, 11, 102, 3);  // Lumi
0508         break;
0509       case 9:
0510         checkIDRunLumiEntry(iterNum, 0, 11, 102, 5);  // Event
0511         break;
0512       case 10:
0513         checkIDRunLumiEntry(iterNum, 0, 11, 102, 4);  // Event
0514         break;
0515       case 11:
0516         checkIDRunLumiEntry(iterNum, 1, 11, 0, 1);  // Run
0517         break;
0518       case 12:
0519         checkIDRunLumiEntry(iterNum, 1, 11, 0, 2);  // Run
0520         break;
0521       case 13:
0522         checkIDRunLumiEntry(iterNum, 1, 11, 101, 4);  // Lumi
0523         break;
0524       case 14:
0525         checkIDRunLumiEntry(iterNum, 1, 11, 102, 5);  // Lumi
0526         break;
0527       case 15:
0528         checkIDRunLumiEntry(iterNum, 1, 11, 102, 6);  // Lumi
0529         break;
0530       case 16:
0531         checkIDRunLumiEntry(iterNum, 1, 11, 102, 6);  // Event
0532         break;
0533     }
0534   }
0535   checkIDRunLumiEntry(iterNum, -1, 0, 0, -1);  // Event
0536 
0537   {
0538     edm::IndexIntoFile::IndexIntoFileItr iter3(
0539         &indexIntoFile, IndexIntoFile::entryOrder, IndexIntoFile::kEvent, 0, 3, 2, 1, 2);
0540     edm::IndexIntoFile::IndexIntoFileItr iter1(iter3);
0541 
0542     CPPUNIT_ASSERT(iter1 == iter3);
0543     CPPUNIT_ASSERT(iter1.indexIntoFile() == &indexIntoFile);
0544     CPPUNIT_ASSERT(iter1.size() == 10);
0545     CPPUNIT_ASSERT(iter1.type() == kEvent);
0546     CPPUNIT_ASSERT(iter1.indexToRun() == 0);
0547     CPPUNIT_ASSERT(iter1.indexToLumi() == 3);
0548     CPPUNIT_ASSERT(iter1.indexToEventRange() == 2);
0549     CPPUNIT_ASSERT(iter1.indexToEvent() == 1);
0550     CPPUNIT_ASSERT(iter1.nEvents() == 2);
0551 
0552     iter1 = ++iter3;
0553     CPPUNIT_ASSERT(iter1 == iter3);
0554 
0555     CPPUNIT_ASSERT(indexIntoFile.iterationWillBeInEntryOrder(IndexIntoFile::entryOrder) == true);
0556 
0557     edm::IndexIntoFile::IndexIntoFileItr iterEntry = indexIntoFile.begin(IndexIntoFile::entryOrder);
0558     edm::IndexIntoFile::IndexIntoFileItr iterEntryCopy = iterEntry;
0559     edm::IndexIntoFile::IndexIntoFileItr iterEntryCopy2 = iterEntry;
0560     edm::IndexIntoFile::IndexIntoFileItr iterEntryEnd = indexIntoFile.end(IndexIntoFile::entryOrder);
0561     int i = 0;
0562     for (i = 0; iterEntry != iterEntryEnd; ++iterEntry, ++iterEntryCopy, ++i) {
0563       CPPUNIT_ASSERT(iterEntry == iterEntryCopy);
0564       iterEntryCopy2 = iterEntryCopy;
0565       CPPUNIT_ASSERT(iterEntry == iterEntryCopy2);
0566       if (i == 0) {
0567         CPPUNIT_ASSERT(check(iterEntry, kRun, 0, 1, 1, 0, 2));
0568         CPPUNIT_ASSERT(iterEntry.indexIntoFile() == &indexIntoFile);
0569         CPPUNIT_ASSERT(iterEntry.size() == 10);
0570       } else if (i == 1)
0571         CPPUNIT_ASSERT(check(iterEntry, kLumi, 0, 1, 1, 0, 2));
0572       else if (i == 2)
0573         CPPUNIT_ASSERT(check(iterEntry, kLumi, 0, 2, 1, 0, 2));
0574       else if (i == 3)
0575         CPPUNIT_ASSERT(check(iterEntry, kLumi, 0, 3, 1, 0, 2));
0576       else if (i == 4)
0577         CPPUNIT_ASSERT(check(iterEntry, kEvent, 0, 3, 1, 0, 2));
0578       else if (i == 5)
0579         CPPUNIT_ASSERT(check(iterEntry, kEvent, 0, 3, 1, 1, 2));
0580       else if (i == 6)
0581         CPPUNIT_ASSERT(check(iterEntry, kEvent, 0, 3, 3, 0, 2));
0582       else if (i == 7)
0583         CPPUNIT_ASSERT(check(iterEntry, kEvent, 0, 3, 3, 1, 2));
0584       else if (i == 8)
0585         CPPUNIT_ASSERT(check(iterEntry, kLumi, 0, 4, 4, 0, 2));
0586       else if (i == 9)
0587         CPPUNIT_ASSERT(check(iterEntry, kEvent, 0, 4, 4, 0, 2));
0588       else if (i == 10)
0589         CPPUNIT_ASSERT(check(iterEntry, kEvent, 0, 4, 4, 1, 2));
0590       else if (i == 11)
0591         CPPUNIT_ASSERT(check(iterEntry, kRun, 5, 7, -1, 0, 0));
0592       else if (i == 12)
0593         CPPUNIT_ASSERT(check(iterEntry, kRun, 6, 7, -1, 0, 0));
0594       else if (i == 13)
0595         CPPUNIT_ASSERT(check(iterEntry, kLumi, 6, 7, -1, 0, 0));
0596       else if (i == 14)
0597         CPPUNIT_ASSERT(check(iterEntry, kLumi, 6, 8, 9, 0, 1));
0598       else if (i == 15)
0599         CPPUNIT_ASSERT(check(iterEntry, kLumi, 6, 9, 9, 0, 1));
0600       else if (i == 16)
0601         CPPUNIT_ASSERT(check(iterEntry, kEvent, 6, 9, 9, 0, 1));
0602       else
0603         CPPUNIT_ASSERT(false);
0604 
0605       switch (i) {
0606         case 0:
0607           CPPUNIT_ASSERT(iterEntry.firstEventEntryThisRun() == 0);
0608           break;
0609         case 10:
0610           CPPUNIT_ASSERT(iterEntry.firstEventEntryThisRun() == 0);
0611           break;
0612         case 12:
0613           CPPUNIT_ASSERT(iterEntry.firstEventEntryThisRun() == 6);
0614           break;
0615       }
0616 
0617       switch (i) {
0618         case 0:
0619           CPPUNIT_ASSERT(iterEntry.firstEventEntryThisLumi() == 0);
0620           break;
0621         case 1:
0622           CPPUNIT_ASSERT(iterEntry.firstEventEntryThisLumi() == 0);
0623           break;
0624         case 2:
0625           CPPUNIT_ASSERT(iterEntry.firstEventEntryThisLumi() == 0);
0626           break;
0627         case 3:
0628           CPPUNIT_ASSERT(iterEntry.firstEventEntryThisLumi() == 0);
0629           break;
0630         case 10:
0631           CPPUNIT_ASSERT(iterEntry.firstEventEntryThisLumi() == 4);
0632           break;
0633         case 12:
0634           CPPUNIT_ASSERT(iterEntry.firstEventEntryThisLumi() == IndexIntoFile::invalidIndex);
0635           break;
0636       }
0637     }
0638     CPPUNIT_ASSERT(i == 17);
0639 
0640     for (i = 0, iterEntry = indexIntoFile.begin(IndexIntoFile::entryOrder); iterEntry != iterEntryEnd;
0641          ++iterEntry, ++i) {
0642       switch (i) {
0643         case 0:
0644           checkIDRunLumiEntry(iterEntry, 0, 11, 0, 0);  // Run
0645           break;
0646         case 1:
0647           checkIDRunLumiEntry(iterEntry, 0, 11, 101, 0);  // Lumi
0648           break;
0649         case 2:
0650           checkIDRunLumiEntry(iterEntry, 0, 11, 101, 1);  // Lumi
0651           break;
0652         case 3:
0653           checkIDRunLumiEntry(iterEntry, 0, 11, 101, 2);  // Lumi
0654           break;
0655         case 4:
0656           checkIDRunLumiEntry(iterEntry, 0, 11, 101, 0);  // Event
0657           break;
0658         case 5:
0659           checkIDRunLumiEntry(iterEntry, 0, 11, 101, 1);  // Event
0660           break;
0661         case 6:
0662           checkIDRunLumiEntry(iterEntry, 0, 11, 101, 2);  // Event
0663           break;
0664         case 7:
0665           checkIDRunLumiEntry(iterEntry, 0, 11, 101, 3);  // Event
0666           break;
0667         case 8:
0668           checkIDRunLumiEntry(iterEntry, 0, 11, 102, 3);  // Lumi
0669           break;
0670         case 9:
0671           checkIDRunLumiEntry(iterEntry, 0, 11, 102, 4);  // Event
0672           break;
0673         case 10:
0674           checkIDRunLumiEntry(iterEntry, 0, 11, 102, 5);  // Event
0675           break;
0676         case 11:
0677           checkIDRunLumiEntry(iterEntry, 1, 11, 0, 1);  // Run
0678           break;
0679         case 12:
0680           checkIDRunLumiEntry(iterEntry, 1, 11, 0, 2);  // Run
0681           break;
0682         case 13:
0683           checkIDRunLumiEntry(iterEntry, 1, 11, 101, 4);  // Lumi
0684           break;
0685         case 14:
0686           checkIDRunLumiEntry(iterEntry, 1, 11, 102, 5);  // Lumi
0687           break;
0688         case 15:
0689           checkIDRunLumiEntry(iterEntry, 1, 11, 102, 6);  // Lumi
0690           break;
0691         case 16:
0692           checkIDRunLumiEntry(iterEntry, 1, 11, 102, 6);  // Event
0693           break;
0694       }
0695     }
0696     checkIDRunLumiEntry(iterEntry, -1, 0, 0, -1);  // Event
0697   }
0698   iterFirst = indexIntoFile.begin(IndexIntoFile::firstAppearanceOrder);
0699   CPPUNIT_ASSERT(check(iterFirst, kRun, 0, 1, 1, 0, 2));
0700 
0701   skipEventForward(iterFirst);
0702   checkSkipped(0, 11, 101, 0);
0703   CPPUNIT_ASSERT(check(iterFirst, kRun, 0, 1, 1, 1, 2));
0704 
0705   skipEventForward(iterFirst);
0706   checkSkipped(0, 11, 101, 1);
0707   CPPUNIT_ASSERT(check(iterFirst, kRun, 0, 1, 3, 0, 2));
0708 
0709   skipEventForward(iterFirst);
0710   checkSkipped(0, 11, 101, 2);
0711   CPPUNIT_ASSERT(check(iterFirst, kRun, 0, 1, 3, 1, 2));
0712 
0713   skipEventForward(iterFirst);
0714   checkSkipped(0, 11, 101, 3);
0715   CPPUNIT_ASSERT(check(iterFirst, kRun, 0, 4, 4, 0, 2));
0716 
0717   skipEventForward(iterFirst);
0718   checkSkipped(0, 11, 102, 4);
0719   CPPUNIT_ASSERT(check(iterFirst, kRun, 0, 4, 4, 1, 2));
0720 
0721   skipEventForward(iterFirst);
0722   checkSkipped(0, 11, 102, 5);
0723   CPPUNIT_ASSERT(check(iterFirst, kRun, 5, 7, -1, 0, 0));
0724 
0725   skipEventForward(iterFirst);
0726   checkSkipped(1, 11, 102, 6);
0727   CPPUNIT_ASSERT(check(iterFirst, kEnd, -1, -1, -1, 0, 0));
0728 
0729   skipEventForward(iterFirst);
0730   checkSkipped(-1, 0, 0, -1);
0731   CPPUNIT_ASSERT(check(iterFirst, kEnd, -1, -1, -1, 0, 0));
0732 
0733   iterFirst = indexIntoFile.begin(IndexIntoFile::firstAppearanceOrder);
0734   ++iterFirst;
0735 
0736   skipEventForward(iterFirst);
0737   checkSkipped(0, 11, 101, 0);
0738   CPPUNIT_ASSERT(check(iterFirst, kLumi, 0, 1, 1, 1, 2));
0739 
0740   skipEventForward(iterFirst);
0741   checkSkipped(0, 11, 101, 1);
0742   CPPUNIT_ASSERT(check(iterFirst, kLumi, 0, 1, 3, 0, 2));
0743 
0744   skipEventForward(iterFirst);
0745   checkSkipped(0, 11, 101, 2);
0746   CPPUNIT_ASSERT(check(iterFirst, kLumi, 0, 1, 3, 1, 2));
0747 
0748   skipEventForward(iterFirst);
0749   checkSkipped(0, 11, 101, 3);
0750   CPPUNIT_ASSERT(check(iterFirst, kLumi, 0, 4, 4, 0, 2));
0751 
0752   skipEventForward(iterFirst);
0753   checkSkipped(0, 11, 102, 4);
0754   CPPUNIT_ASSERT(check(iterFirst, kLumi, 0, 4, 4, 1, 2));
0755 
0756   skipEventForward(iterFirst);
0757   checkSkipped(0, 11, 102, 5);
0758   CPPUNIT_ASSERT(check(iterFirst, kRun, 5, 7, -1, 0, 0));
0759 
0760   ++iterFirst;
0761   ++iterFirst;
0762   ++iterFirst;
0763   skipEventForward(iterFirst);
0764   checkSkipped(1, 11, 102, 6);
0765   CPPUNIT_ASSERT(check(iterFirst, kEnd, -1, -1, -1, 0, 0));
0766 
0767   iterFirst = indexIntoFile.begin(IndexIntoFile::firstAppearanceOrder);
0768   ++iterFirst;
0769   ++iterFirst;
0770   ++iterFirst;
0771   ++iterFirst;
0772 
0773   skipEventForward(iterFirst);
0774   checkSkipped(0, 11, 101, 0);
0775   CPPUNIT_ASSERT(check(iterFirst, kEvent, 0, 3, 1, 1, 2));
0776 
0777   skipEventForward(iterFirst);
0778   checkSkipped(0, 11, 101, 1);
0779   CPPUNIT_ASSERT(check(iterFirst, kEvent, 0, 3, 3, 0, 2));
0780 
0781   skipEventForward(iterFirst);
0782   checkSkipped(0, 11, 101, 2);
0783   CPPUNIT_ASSERT(check(iterFirst, kEvent, 0, 3, 3, 1, 2));
0784 
0785   skipEventForward(iterFirst);
0786   checkSkipped(0, 11, 101, 3);
0787   CPPUNIT_ASSERT(check(iterFirst, kLumi, 0, 4, 4, 0, 2));
0788 
0789   ++iterFirst;
0790   skipEventForward(iterFirst);
0791   checkSkipped(0, 11, 102, 4);
0792   CPPUNIT_ASSERT(check(iterFirst, kEvent, 0, 4, 4, 1, 2));
0793 
0794   skipEventForward(iterFirst);
0795   checkSkipped(0, 11, 102, 5);
0796   CPPUNIT_ASSERT(check(iterFirst, kRun, 5, 7, -1, 0, 0));
0797 
0798   iterFirst = indexIntoFile.begin(IndexIntoFile::firstAppearanceOrder);
0799   iterFirst.advanceToNextLumiOrRun();
0800   CPPUNIT_ASSERT(check(iterFirst, kLumi, 0, 1, 1, 0, 2));
0801   iterFirst.advanceToNextLumiOrRun();
0802   CPPUNIT_ASSERT(check(iterFirst, kLumi, 0, 4, 4, 0, 2));
0803   iterFirst.advanceToNextLumiOrRun();
0804   CPPUNIT_ASSERT(check(iterFirst, kRun, 5, 7, -1, 0, 0));
0805   iterFirst.advanceToNextLumiOrRun();
0806   CPPUNIT_ASSERT(check(iterFirst, kLumi, 6, 7, -1, 0, 0));
0807   iterFirst.advanceToNextLumiOrRun();
0808   CPPUNIT_ASSERT(check(iterFirst, kLumi, 6, 8, 9, 0, 1));
0809   iterFirst.advanceToNextLumiOrRun();
0810   CPPUNIT_ASSERT(check(iterFirst, kEnd, -1, -1, -1, 0, 0));
0811 
0812   iterFirst = indexIntoFile.begin(IndexIntoFile::firstAppearanceOrder);
0813   ++iterFirst;
0814   ++iterFirst;
0815   ++iterFirst;
0816   ++iterFirst;
0817   CPPUNIT_ASSERT(check(iterFirst, kEvent, 0, 3, 1, 0, 2));
0818   iterFirst.advanceToNextLumiOrRun();
0819   CPPUNIT_ASSERT(check(iterFirst, kLumi, 0, 4, 4, 0, 2));
0820   ++iterFirst;
0821   iterFirst.advanceToNextLumiOrRun();
0822   CPPUNIT_ASSERT(check(iterFirst, kRun, 5, 7, -1, 0, 0));
0823 
0824   iterFirst = indexIntoFile.begin(IndexIntoFile::firstAppearanceOrder);
0825   ++iterFirst;
0826   ++iterFirst;
0827   ++iterFirst;
0828   ++iterFirst;
0829   CPPUNIT_ASSERT(check(iterFirst, kEvent, 0, 3, 1, 0, 2));
0830   iterFirst.advanceToNextRun();
0831   CPPUNIT_ASSERT(check(iterFirst, kRun, 5, 7, -1, 0, 0));
0832 
0833   // Repeat skip tests with the other sort order
0834 
0835   iterNum = indexIntoFile.begin(IndexIntoFile::numericalOrder);
0836   CPPUNIT_ASSERT(check(iterNum, kRun, 0, 1, 1, 0, 4));
0837 
0838   skipEventForward(iterNum);
0839   checkSkipped(0, 11, 101, 3);
0840   CPPUNIT_ASSERT(check(iterNum, kRun, 0, 1, 1, 1, 4));
0841 
0842   skipEventForward(iterNum);
0843   checkSkipped(0, 11, 101, 2);
0844   CPPUNIT_ASSERT(check(iterNum, kRun, 0, 1, 1, 2, 4));
0845 
0846   skipEventForward(iterNum);
0847   checkSkipped(0, 11, 101, 1);
0848   CPPUNIT_ASSERT(check(iterNum, kRun, 0, 1, 1, 3, 4));
0849 
0850   skipEventForward(iterNum);
0851   checkSkipped(0, 11, 101, 0);
0852   CPPUNIT_ASSERT(check(iterNum, kRun, 0, 4, 4, 0, 2));
0853 
0854   skipEventForward(iterNum);
0855   checkSkipped(0, 11, 102, 5);
0856   CPPUNIT_ASSERT(check(iterNum, kRun, 0, 4, 4, 1, 2));
0857 
0858   skipEventForward(iterNum);
0859   checkSkipped(0, 11, 102, 4);
0860   CPPUNIT_ASSERT(check(iterNum, kRun, 5, 7, -1, 0, 0));
0861 
0862   skipEventForward(iterNum);
0863   checkSkipped(1, 11, 102, 6);
0864   CPPUNIT_ASSERT(check(iterNum, kEnd, -1, -1, -1, 0, 0));
0865 
0866   skipEventForward(iterNum);
0867   checkSkipped(-1, 0, 0, -1);
0868   CPPUNIT_ASSERT(check(iterNum, kEnd, -1, -1, -1, 0, 0));
0869 
0870   iterNum = indexIntoFile.begin(IndexIntoFile::numericalOrder);
0871   ++iterNum;
0872 
0873   skipEventForward(iterNum);
0874   checkSkipped(0, 11, 101, 3);
0875   CPPUNIT_ASSERT(check(iterNum, kLumi, 0, 1, 1, 1, 4));
0876 
0877   skipEventForward(iterNum);
0878   checkSkipped(0, 11, 101, 2);
0879   CPPUNIT_ASSERT(check(iterNum, kLumi, 0, 1, 1, 2, 4));
0880 
0881   skipEventForward(iterNum);
0882   checkSkipped(0, 11, 101, 1);
0883   CPPUNIT_ASSERT(check(iterNum, kLumi, 0, 1, 1, 3, 4));
0884 
0885   skipEventForward(iterNum);
0886   checkSkipped(0, 11, 101, 0);
0887   CPPUNIT_ASSERT(check(iterNum, kLumi, 0, 4, 4, 0, 2));
0888 
0889   skipEventForward(iterNum);
0890   checkSkipped(0, 11, 102, 5);
0891   CPPUNIT_ASSERT(check(iterNum, kLumi, 0, 4, 4, 1, 2));
0892 
0893   skipEventForward(iterNum);
0894   checkSkipped(0, 11, 102, 4);
0895   CPPUNIT_ASSERT(check(iterNum, kRun, 5, 7, -1, 0, 0));
0896 
0897   ++iterNum;
0898   ++iterNum;
0899   ++iterNum;
0900   CPPUNIT_ASSERT(check(iterNum, kLumi, 6, 8, 8, 0, 1));
0901   skipEventForward(iterNum);
0902   checkSkipped(1, 11, 102, 6);
0903   CPPUNIT_ASSERT(check(iterNum, kEnd, -1, -1, -1, 0, 0));
0904 
0905   iterNum = indexIntoFile.begin(IndexIntoFile::numericalOrder);
0906   ++iterNum;
0907   ++iterNum;
0908   ++iterNum;
0909   ++iterNum;
0910 
0911   skipEventForward(iterNum);
0912   checkSkipped(0, 11, 101, 3);
0913   CPPUNIT_ASSERT(check(iterNum, kEvent, 0, 3, 1, 1, 4));
0914 
0915   skipEventForward(iterNum);
0916   checkSkipped(0, 11, 101, 2);
0917   CPPUNIT_ASSERT(check(iterNum, kEvent, 0, 3, 1, 2, 4));
0918 
0919   skipEventForward(iterNum);
0920   checkSkipped(0, 11, 101, 1);
0921   CPPUNIT_ASSERT(check(iterNum, kEvent, 0, 3, 1, 3, 4));
0922 
0923   skipEventForward(iterNum);
0924   checkSkipped(0, 11, 101, 0);
0925   CPPUNIT_ASSERT(check(iterNum, kLumi, 0, 4, 4, 0, 2));
0926 
0927   ++iterNum;
0928   skipEventForward(iterNum);
0929   checkSkipped(0, 11, 102, 5);
0930   CPPUNIT_ASSERT(check(iterNum, kEvent, 0, 4, 4, 1, 2));
0931 
0932   skipEventForward(iterNum);
0933   checkSkipped(0, 11, 102, 4);
0934   CPPUNIT_ASSERT(check(iterNum, kRun, 5, 7, -1, 0, 0));
0935 
0936   iterNum = indexIntoFile.begin(IndexIntoFile::numericalOrder);
0937   iterNum.advanceToNextLumiOrRun();
0938   CPPUNIT_ASSERT(check(iterNum, kLumi, 0, 1, 1, 0, 4));
0939   iterNum.advanceToNextLumiOrRun();
0940   CPPUNIT_ASSERT(check(iterNum, kLumi, 0, 4, 4, 0, 2));
0941   iterNum.advanceToNextLumiOrRun();
0942   CPPUNIT_ASSERT(check(iterNum, kRun, 5, 7, -1, 0, 0));
0943   iterNum.advanceToNextLumiOrRun();
0944   CPPUNIT_ASSERT(check(iterNum, kLumi, 6, 7, -1, 0, 0));
0945   iterNum.advanceToNextLumiOrRun();
0946   CPPUNIT_ASSERT(check(iterNum, kLumi, 6, 8, 8, 0, 1));
0947   iterNum.advanceToNextLumiOrRun();
0948   CPPUNIT_ASSERT(check(iterNum, kEnd, -1, -1, -1, 0, 0));
0949 
0950   iterNum = indexIntoFile.begin(IndexIntoFile::numericalOrder);
0951   ++iterNum;
0952   ++iterNum;
0953   ++iterNum;
0954   ++iterNum;
0955   CPPUNIT_ASSERT(check(iterNum, kEvent, 0, 3, 1, 0, 4));
0956   iterNum.advanceToNextLumiOrRun();
0957   CPPUNIT_ASSERT(check(iterNum, kLumi, 0, 4, 4, 0, 2));
0958   ++iterNum;
0959   iterNum.advanceToNextLumiOrRun();
0960   CPPUNIT_ASSERT(check(iterNum, kRun, 5, 7, -1, 0, 0));
0961 
0962   iterNum = indexIntoFile.begin(IndexIntoFile::numericalOrder);
0963   ++iterNum;
0964   ++iterNum;
0965   ++iterNum;
0966   ++iterNum;
0967   CPPUNIT_ASSERT(check(iterNum, kEvent, 0, 3, 1, 0, 4));
0968   iterNum.advanceToNextRun();
0969   CPPUNIT_ASSERT(check(iterNum, kRun, 5, 7, -1, 0, 0));
0970 
0971   // Check backwards iteration
0972 
0973   iterFirst = indexIntoFile.end(IndexIntoFile::firstAppearanceOrder);
0974 
0975   skipEventBackward(iterFirst);
0976   checkSkipped(1, 11, 102, 6);
0977   CPPUNIT_ASSERT(check(iterFirst, kRun, 5, 8, 9, 0, 1));
0978 
0979   skipEventBackward(iterFirst);
0980   checkSkipped(0, 11, 102, 5);
0981   CPPUNIT_ASSERT(check(iterFirst, kRun, 0, 4, 4, 1, 2));
0982 
0983   skipEventBackward(iterFirst);
0984   checkSkipped(0, 11, 102, 4);
0985   CPPUNIT_ASSERT(check(iterFirst, kRun, 0, 4, 4, 0, 2));
0986 
0987   skipEventBackward(iterFirst);
0988   checkSkipped(0, 11, 101, 3);
0989   CPPUNIT_ASSERT(check(iterFirst, kRun, 0, 1, 3, 1, 2));
0990 
0991   skipEventBackward(iterFirst);
0992   checkSkipped(0, 11, 101, 2);
0993   CPPUNIT_ASSERT(check(iterFirst, kRun, 0, 1, 3, 0, 2));
0994 
0995   skipEventBackward(iterFirst);
0996   checkSkipped(0, 11, 101, 1);
0997   CPPUNIT_ASSERT(check(iterFirst, kRun, 0, 1, 1, 1, 2));
0998 
0999   skipEventBackward(iterFirst);
1000   checkSkipped(0, 11, 101, 0);
1001   CPPUNIT_ASSERT(check(iterFirst, kRun, 0, 1, 1, 0, 2));
1002 
1003   skipEventBackward(iterFirst);
1004   checkSkipped(-1, 0, 0, -1);
1005   CPPUNIT_ASSERT(check(iterFirst, kRun, 0, 1, 1, 0, 2));
1006 
1007   ++iterFirst;
1008   ++iterFirst;
1009   ++iterFirst;
1010   ++iterFirst;
1011   ++iterFirst;
1012   ++iterFirst;
1013   ++iterFirst;
1014   ++iterFirst;
1015   ++iterFirst;
1016   ++iterFirst;
1017   CPPUNIT_ASSERT(check(iterFirst, kEvent, 0, 4, 4, 1, 2));
1018 
1019   skipEventBackward(iterFirst);
1020   checkSkipped(0, 11, 102, 4);
1021   CPPUNIT_ASSERT(check(iterFirst, kEvent, 0, 4, 4, 0, 2));
1022 
1023   skipEventBackward(iterFirst);
1024   checkSkipped(0, 11, 101, 3);
1025   CPPUNIT_ASSERT(check(iterFirst, kLumi, 0, 1, 3, 1, 2));
1026 
1027   skipEventForward(iterFirst);
1028   skipEventForward(iterFirst);
1029   CPPUNIT_ASSERT(check(iterFirst, kLumi, 0, 4, 4, 1, 2));
1030 
1031   skipEventBackward(iterFirst);
1032   checkSkipped(0, 11, 102, 4);
1033   CPPUNIT_ASSERT(check(iterFirst, kLumi, 0, 4, 4, 0, 2));
1034 
1035   skipEventBackward(iterFirst);
1036   checkSkipped(0, 11, 101, 3);
1037   CPPUNIT_ASSERT(check(iterFirst, kLumi, 0, 1, 3, 1, 2));
1038 
1039   iterFirst.advanceToNextRun();
1040   iterFirst.advanceToEvent();
1041   CPPUNIT_ASSERT(check(iterFirst, kEvent, 6, 9, 9, 0, 1));
1042 
1043   skipEventBackward(iterFirst);
1044   checkSkipped(0, 11, 102, 5);
1045   CPPUNIT_ASSERT(check(iterFirst, kRun, 0, 4, 4, 1, 2));
1046 
1047   iterFirst.advanceToNextRun();
1048   ++iterFirst;
1049   ++iterFirst;
1050   ++iterFirst;
1051   CPPUNIT_ASSERT(check(iterFirst, kLumi, 6, 8, 9, 0, 1));
1052 
1053   skipEventBackward(iterFirst);
1054   checkSkipped(0, 11, 102, 5);
1055   CPPUNIT_ASSERT(check(iterFirst, kRun, 0, 4, 4, 1, 2));
1056 
1057   iterNum = indexIntoFile.end(IndexIntoFile::numericalOrder);
1058 
1059   skipEventBackward(iterNum);
1060   checkSkipped(1, 11, 102, 6);
1061   CPPUNIT_ASSERT(check(iterNum, kRun, 5, 8, 8, 0, 1));
1062 
1063   skipEventBackward(iterNum);
1064   checkSkipped(0, 11, 102, 4);
1065   CPPUNIT_ASSERT(check(iterNum, kRun, 0, 4, 4, 1, 2));
1066 
1067   skipEventBackward(iterNum);
1068   checkSkipped(0, 11, 102, 5);
1069   CPPUNIT_ASSERT(check(iterNum, kRun, 0, 4, 4, 0, 2));
1070 
1071   skipEventBackward(iterNum);
1072   checkSkipped(0, 11, 101, 0);
1073   CPPUNIT_ASSERT(check(iterNum, kRun, 0, 1, 1, 3, 4));
1074 
1075   skipEventBackward(iterNum);
1076   checkSkipped(0, 11, 101, 1);
1077   CPPUNIT_ASSERT(check(iterNum, kRun, 0, 1, 1, 2, 4));
1078 
1079   skipEventBackward(iterNum);
1080   checkSkipped(0, 11, 101, 2);
1081   CPPUNIT_ASSERT(check(iterNum, kRun, 0, 1, 1, 1, 4));
1082 
1083   skipEventBackward(iterNum);
1084   checkSkipped(0, 11, 101, 3);
1085   CPPUNIT_ASSERT(check(iterNum, kRun, 0, 1, 1, 0, 4));
1086 
1087   skipEventBackward(iterNum);
1088   checkSkipped(-1, 0, 0, -1);
1089   CPPUNIT_ASSERT(check(iterNum, kRun, 0, 1, 1, 0, 4));
1090 
1091   ++iterNum;
1092   ++iterNum;
1093   ++iterNum;
1094   ++iterNum;
1095   ++iterNum;
1096   ++iterNum;
1097   ++iterNum;
1098   ++iterNum;
1099   ++iterNum;
1100   ++iterNum;
1101   CPPUNIT_ASSERT(check(iterNum, kEvent, 0, 4, 4, 1, 2));
1102 
1103   skipEventBackward(iterNum);
1104   checkSkipped(0, 11, 102, 5);
1105   CPPUNIT_ASSERT(check(iterNum, kEvent, 0, 4, 4, 0, 2));
1106 
1107   skipEventBackward(iterNum);
1108   checkSkipped(0, 11, 101, 0);
1109   CPPUNIT_ASSERT(check(iterNum, kLumi, 0, 1, 1, 3, 4));
1110 
1111   skipEventForward(iterNum);
1112   skipEventForward(iterNum);
1113   CPPUNIT_ASSERT(check(iterNum, kLumi, 0, 4, 4, 1, 2));
1114 
1115   skipEventBackward(iterNum);
1116   checkSkipped(0, 11, 102, 5);
1117   CPPUNIT_ASSERT(check(iterNum, kLumi, 0, 4, 4, 0, 2));
1118 
1119   skipEventBackward(iterNum);
1120   checkSkipped(0, 11, 101, 0);
1121   CPPUNIT_ASSERT(check(iterNum, kLumi, 0, 1, 1, 3, 4));
1122 
1123   iterNum.advanceToNextRun();
1124   iterNum.advanceToEvent();
1125   CPPUNIT_ASSERT(check(iterNum, kEvent, 6, 9, 8, 0, 1));
1126 
1127   skipEventBackward(iterNum);
1128   checkSkipped(0, 11, 102, 4);
1129   CPPUNIT_ASSERT(check(iterNum, kRun, 0, 4, 4, 1, 2));
1130 
1131   iterNum.advanceToNextRun();
1132   ++iterNum;
1133   ++iterNum;
1134   ++iterNum;
1135   CPPUNIT_ASSERT(check(iterNum, kLumi, 6, 8, 8, 0, 1));
1136 
1137   skipEventBackward(iterNum);
1138   checkSkipped(0, 11, 102, 4);
1139   CPPUNIT_ASSERT(check(iterNum, kRun, 0, 4, 4, 1, 2));
1140 }
1141 
1142 void TestIndexIntoFile3::testOverlappingLumis() {
1143   edm::IndexIntoFile indexIntoFile;
1144   indexIntoFile.addEntry(fakePHID1, 11, 104, 0, 0);  // Lumi
1145   indexIntoFile.addEntry(fakePHID1, 11, 103, 7, 0);  // Event
1146   indexIntoFile.addEntry(fakePHID1, 11, 103, 6, 1);  // Event
1147   indexIntoFile.addEntry(fakePHID1, 11, 103, 5, 2);  // Event
1148   indexIntoFile.addEntry(fakePHID1, 11, 103, 4, 3);  // Event
1149   //Dummy Lumi gets added
1150   indexIntoFile.addEntry(fakePHID1, 11, 102, 5, 4);  // Event
1151   //Another dummy lumi gets added
1152   indexIntoFile.addEntry(fakePHID1, 11, 103, 0, 1);  // Lumi
1153 
1154   indexIntoFile.addEntry(fakePHID1, 11, 102, 4, 5);  // Event
1155   indexIntoFile.addEntry(fakePHID1, 11, 102, 0, 2);  // Lumi
1156   indexIntoFile.addEntry(fakePHID1, 11, 0, 0, 0);    // Run
1157   indexIntoFile.addEntry(fakePHID2, 11, 0, 0, 1);    // Run
1158   indexIntoFile.addEntry(fakePHID2, 11, 101, 0, 3);  // Lumi
1159   indexIntoFile.addEntry(fakePHID2, 11, 102, 0, 4);  // Lumi
1160   indexIntoFile.addEntry(fakePHID2, 11, 102, 4, 6);  // Event
1161   indexIntoFile.addEntry(fakePHID2, 11, 102, 0, 5);  // Lumi
1162   indexIntoFile.addEntry(fakePHID2, 11, 0, 0, 2);    // Run
1163   indexIntoFile.sortVector_Run_Or_Lumi_Entries();
1164 
1165   std::vector<IndexIntoFile::EventEntry>& eventEntries = indexIntoFile.eventEntries();
1166   eventEntries.emplace_back(5, 4);
1167   eventEntries.emplace_back(4, 5);
1168   eventEntries.emplace_back(7, 0);
1169   eventEntries.emplace_back(6, 1);
1170   eventEntries.emplace_back(5, 2);
1171   eventEntries.emplace_back(4, 3);
1172   eventEntries.emplace_back(4, 6);
1173   indexIntoFile.sortEventEntries();
1174 
1175   std::vector<LuminosityBlockNumber_t> lumis;
1176 
1177   {
1178     edm::IndexIntoFile::IndexIntoFileItr iterFirst = indexIntoFile.begin(IndexIntoFile::firstAppearanceOrder);
1179     edm::IndexIntoFile::IndexIntoFileItr iterFirstEnd = indexIntoFile.end(IndexIntoFile::firstAppearanceOrder);
1180     int i = 0;
1181     for (i = 0; iterFirst != iterFirstEnd; ++iterFirst, ++i) {
1182       if (i == 0) {
1183         CPPUNIT_ASSERT(check(iterFirst, kRun, 0, 1, -1, 0, 0));
1184         CPPUNIT_ASSERT(iterFirst.indexIntoFile() == &indexIntoFile);
1185         CPPUNIT_ASSERT(iterFirst.size() == 11);
1186       }
1187       //values are 'IndexIntoFile::EntryType' 'indexToRun' 'indexToLumi' 'indexToEventRange' 'indexToEvent' 'nEvents'
1188       else if (i == 1)
1189         CPPUNIT_ASSERT(check(iterFirst, kLumi, 0, 1, -1, 0, 0));
1190       else if (i == 2)
1191         CPPUNIT_ASSERT(check(iterFirst, kLumi, 0, 3, 2, 0, 4));
1192       else if (i == 3)
1193         CPPUNIT_ASSERT(check(iterFirst, kEvent, 0, 3, 2, 0, 4));
1194       else if (i == 4)
1195         CPPUNIT_ASSERT(check(iterFirst, kEvent, 0, 3, 2, 1, 4));
1196       else if (i == 5)
1197         CPPUNIT_ASSERT(check(iterFirst, kEvent, 0, 3, 2, 2, 4));
1198       else if (i == 6)
1199         CPPUNIT_ASSERT(check(iterFirst, kEvent, 0, 3, 2, 3, 4));
1200       else if (i == 7)
1201         CPPUNIT_ASSERT(check(iterFirst, kLumi, 0, 5, 4, 0, 1));
1202       else if (i == 8)
1203         CPPUNIT_ASSERT(check(iterFirst, kEvent, 0, 5, 4, 0, 1));
1204       else if (i == 9)
1205         CPPUNIT_ASSERT(check(iterFirst, kEvent, 0, 5, 5, 0, 1));
1206       else if (i == 10)
1207         CPPUNIT_ASSERT(check(iterFirst, kRun, 6, 8, -1, 0, 0));
1208       else if (i == 11)
1209         CPPUNIT_ASSERT(check(iterFirst, kRun, 7, 8, -1, 0, 0));
1210       else if (i == 12)
1211         CPPUNIT_ASSERT(check(iterFirst, kLumi, 7, 8, -1, 0, 0));
1212       else if (i == 13)
1213         CPPUNIT_ASSERT(check(iterFirst, kLumi, 7, 9, 10, 0, 1));
1214       else if (i == 14)
1215         CPPUNIT_ASSERT(check(iterFirst, kLumi, 7, 10, 10, 0, 1));
1216       else if (i == 15)
1217         CPPUNIT_ASSERT(check(iterFirst, kEvent, 7, 10, 10, 0, 1));
1218       else
1219         CPPUNIT_ASSERT(false);
1220 
1221       switch (i) {
1222         case 1:
1223           CPPUNIT_ASSERT(iterFirst.firstEventEntryThisRun() == 0);
1224           break;
1225         case 9:
1226           CPPUNIT_ASSERT(iterFirst.firstEventEntryThisRun() == 0);
1227           break;
1228         case 11:
1229           CPPUNIT_ASSERT(iterFirst.firstEventEntryThisRun() == 6);
1230           break;
1231       }
1232 
1233       switch (i) {
1234         case 2:
1235           CPPUNIT_ASSERT(iterFirst.firstEventEntryThisLumi() == 0);
1236           break;
1237         case 9:
1238           CPPUNIT_ASSERT(iterFirst.firstEventEntryThisLumi() == 4);
1239           break;
1240         case 11:
1241           CPPUNIT_ASSERT(iterFirst.firstEventEntryThisLumi() == IndexIntoFile::invalidIndex);
1242           break;
1243       }
1244     }
1245     CPPUNIT_ASSERT(i == 16);
1246   }
1247   {
1248     edm::IndexIntoFile::IndexIntoFileItr iterFirst = indexIntoFile.begin(IndexIntoFile::numericalOrder);
1249     edm::IndexIntoFile::IndexIntoFileItr iterFirstEnd = indexIntoFile.end(IndexIntoFile::numericalOrder);
1250     int i = 0;
1251     for (i = 0; iterFirst != iterFirstEnd; ++iterFirst, ++i) {
1252       //values are 'IndexIntoFile::EntryType' 'indexToRun' 'indexToLumi' 'indexToEventRange' 'indexToEvent' 'nEvents'
1253       if (i == 0) {
1254         CPPUNIT_ASSERT(check(iterFirst, kRun, 0, 2, 1, 0, 2));
1255 
1256         iterFirst.getLumisInRun(lumis);
1257         std::vector<LuminosityBlockNumber_t> expected{102, 103, 104};
1258         CPPUNIT_ASSERT(lumis == expected);
1259       } else if (i == 1)
1260         CPPUNIT_ASSERT(check(iterFirst, kLumi, 0, 2, 1, 0, 2));
1261       else if (i == 2)
1262         CPPUNIT_ASSERT(check(iterFirst, kEvent, 0, 2, 1, 0, 2));
1263       else if (i == 3)
1264         CPPUNIT_ASSERT(check(iterFirst, kEvent, 0, 2, 1, 1, 2));
1265       else if (i == 4)
1266         CPPUNIT_ASSERT(check(iterFirst, kLumi, 0, 4, 3, 0, 4));
1267       else if (i == 5)
1268         CPPUNIT_ASSERT(check(iterFirst, kEvent, 0, 4, 3, 0, 4));
1269       else if (i == 6)
1270         CPPUNIT_ASSERT(check(iterFirst, kEvent, 0, 4, 3, 1, 4));
1271       else if (i == 7)
1272         CPPUNIT_ASSERT(check(iterFirst, kEvent, 0, 4, 3, 2, 4));
1273       else if (i == 8)
1274         CPPUNIT_ASSERT(check(iterFirst, kEvent, 0, 4, 3, 3, 4));
1275       else if (i == 9)
1276         CPPUNIT_ASSERT(check(iterFirst, kLumi, 0, 5, -1, 0, 0));
1277       else if (i == 10)
1278         CPPUNIT_ASSERT(check(iterFirst, kRun, 6, 8, -1, 0, 0));
1279       else if (i == 11)
1280         CPPUNIT_ASSERT(check(iterFirst, kRun, 7, 8, -1, 0, 0));
1281       else if (i == 12)
1282         CPPUNIT_ASSERT(check(iterFirst, kLumi, 7, 8, -1, 0, 0));
1283       else if (i == 13)
1284         CPPUNIT_ASSERT(check(iterFirst, kLumi, 7, 9, 9, 0, 1));
1285       else if (i == 14)
1286         CPPUNIT_ASSERT(check(iterFirst, kLumi, 7, 10, 9, 0, 1));
1287       else if (i == 15)
1288         CPPUNIT_ASSERT(check(iterFirst, kEvent, 7, 10, 9, 0, 1));
1289       else
1290         CPPUNIT_ASSERT(false);
1291     }
1292     CPPUNIT_ASSERT(i == 16);
1293   }
1294   {
1295     edm::IndexIntoFile::IndexIntoFileItr iterFirst = indexIntoFile.begin(IndexIntoFile::entryOrder);
1296     edm::IndexIntoFile::IndexIntoFileItr iterFirstEnd = indexIntoFile.end(IndexIntoFile::entryOrder);
1297     int i = 0;
1298     for (i = 0; iterFirst != iterFirstEnd; ++iterFirst, ++i) {
1299       //values are 'IndexIntoFile::EntryType' 'indexToRun' 'indexToLumi' 'indexToEventRange' 'indexToEvent' 'nEvents'
1300       if (i == 0) {
1301         CPPUNIT_ASSERT(check(iterFirst, kRun, 0, 1, -1, 0, 0));
1302         CPPUNIT_ASSERT(iterFirst.indexIntoFile() == &indexIntoFile);
1303         CPPUNIT_ASSERT(iterFirst.size() == 11);
1304       }
1305       //values are 'IndexIntoFile::EntryType' 'indexToRun' 'indexToLumi' 'indexToEventRange' 'indexToEvent' 'nEvents'
1306       else if (i == 1)
1307         CPPUNIT_ASSERT(check(iterFirst, kLumi, 0, 1, -1, 0, 0));
1308       else if (i == 2)
1309         CPPUNIT_ASSERT(check(iterFirst, kLumi, 0, 3, 2, 0, 4));
1310       else if (i == 3)
1311         CPPUNIT_ASSERT(check(iterFirst, kEvent, 0, 3, 2, 0, 4));
1312       else if (i == 4)
1313         CPPUNIT_ASSERT(check(iterFirst, kEvent, 0, 3, 2, 1, 4));
1314       else if (i == 5)
1315         CPPUNIT_ASSERT(check(iterFirst, kEvent, 0, 3, 2, 2, 4));
1316       else if (i == 6)
1317         CPPUNIT_ASSERT(check(iterFirst, kEvent, 0, 3, 2, 3, 4));
1318       else if (i == 7)
1319         CPPUNIT_ASSERT(check(iterFirst, kLumi, 0, 5, 4, 0, 1));
1320       else if (i == 8)
1321         CPPUNIT_ASSERT(check(iterFirst, kEvent, 0, 5, 4, 0, 1));
1322       else if (i == 9)
1323         CPPUNIT_ASSERT(check(iterFirst, kEvent, 0, 5, 5, 0, 1));
1324       else if (i == 10)
1325         CPPUNIT_ASSERT(check(iterFirst, kRun, 6, 8, -1, 0, 0));
1326       else if (i == 11)
1327         CPPUNIT_ASSERT(check(iterFirst, kRun, 7, 8, -1, 0, 0));
1328       else if (i == 12)
1329         CPPUNIT_ASSERT(check(iterFirst, kLumi, 7, 8, -1, 0, 0));
1330       else if (i == 13)
1331         CPPUNIT_ASSERT(check(iterFirst, kLumi, 7, 9, 10, 0, 1));
1332       else if (i == 14)
1333         CPPUNIT_ASSERT(check(iterFirst, kLumi, 7, 10, 10, 0, 1));
1334       else if (i == 15)
1335         CPPUNIT_ASSERT(check(iterFirst, kEvent, 7, 10, 10, 0, 1));
1336       else
1337         CPPUNIT_ASSERT(false);
1338 
1339       switch (i) {
1340         case 1:
1341           CPPUNIT_ASSERT(iterFirst.firstEventEntryThisRun() == 0);
1342           break;
1343         case 9:
1344           CPPUNIT_ASSERT(iterFirst.firstEventEntryThisRun() == 0);
1345           break;
1346         case 11:
1347           CPPUNIT_ASSERT(iterFirst.firstEventEntryThisRun() == 6);
1348           break;
1349       }
1350 
1351       switch (i) {
1352         case 2:
1353           CPPUNIT_ASSERT(iterFirst.firstEventEntryThisLumi() == 0);
1354           break;
1355         case 9:
1356           CPPUNIT_ASSERT(iterFirst.firstEventEntryThisLumi() == 4);
1357           break;
1358         case 11:
1359           CPPUNIT_ASSERT(iterFirst.firstEventEntryThisLumi() == IndexIntoFile::invalidIndex);
1360           break;
1361       }
1362     }
1363     CPPUNIT_ASSERT(i == 16);
1364   }
1365 
1366   {
1367     edm::IndexIntoFile::IndexIntoFileItr testIter = indexIntoFile.findPosition(11, 103, 7);
1368     CPPUNIT_ASSERT(check(testIter, kRun, 0, 4, 3, 3, 4));
1369     ++testIter;
1370     CPPUNIT_ASSERT(check(testIter, kLumi, 0, 4, 3, 3, 4));
1371     ++testIter;
1372     CPPUNIT_ASSERT(check(testIter, kEvent, 0, 4, 3, 3, 4));
1373     ++testIter;
1374     CPPUNIT_ASSERT(check(testIter, kLumi, 0, 5, -1, 0, 0));
1375   }
1376   {
1377     edm::IndexIntoFile::IndexIntoFileItr testIter = indexIntoFile.findPosition(11, 0, 7);
1378     CPPUNIT_ASSERT(check(testIter, kRun, 0, 4, 3, 3, 4));
1379     ++testIter;
1380     CPPUNIT_ASSERT(check(testIter, kLumi, 0, 4, 3, 3, 4));
1381     ++testIter;
1382     CPPUNIT_ASSERT(check(testIter, kEvent, 0, 4, 3, 3, 4));
1383     ++testIter;
1384     CPPUNIT_ASSERT(check(testIter, kLumi, 0, 5, -1, 0, 0));
1385     skipEventBackward(testIter);
1386     CPPUNIT_ASSERT(check(testIter, kLumi, 0, 4, 3, 3, 4));
1387   }
1388 }
1389 
1390 void TestIndexIntoFile3::testOverlappingLumisMore() {
1391   edm::IndexIntoFile indexIntoFile;
1392   indexIntoFile.addEntry(fakePHID1, 11, 101, 7, 0);  // Event
1393   indexIntoFile.addEntry(fakePHID1, 11, 101, 6, 1);  // Event
1394   indexIntoFile.addEntry(fakePHID1, 11, 101, 5, 2);  // Event
1395   //Dummy Lumi gets added
1396   indexIntoFile.addEntry(fakePHID1, 11, 102, 5, 4);  // Event
1397   //Another dummy lumi gets added
1398   indexIntoFile.addEntry(fakePHID1, 11, 101, 4, 3);  // Event
1399   indexIntoFile.addEntry(fakePHID1, 11, 101, 0, 0);  // Lumi
1400 
1401   indexIntoFile.addEntry(fakePHID1, 11, 102, 4, 5);  // Event
1402   indexIntoFile.addEntry(fakePHID1, 11, 102, 0, 1);  // Lumi
1403   indexIntoFile.addEntry(fakePHID1, 11, 0, 0, 0);    // Run
1404   indexIntoFile.addEntry(fakePHID2, 11, 0, 0, 1);    // Run
1405   indexIntoFile.addEntry(fakePHID2, 11, 101, 0, 2);  // Lumi
1406   indexIntoFile.addEntry(fakePHID2, 11, 102, 0, 3);  // Lumi
1407   indexIntoFile.addEntry(fakePHID2, 11, 102, 4, 6);  // Event
1408   indexIntoFile.addEntry(fakePHID2, 11, 102, 0, 4);  // Lumi
1409   indexIntoFile.addEntry(fakePHID2, 11, 0, 0, 2);    // Run
1410   indexIntoFile.sortVector_Run_Or_Lumi_Entries();
1411 
1412   std::vector<LuminosityBlockNumber_t> lumis;
1413 
1414   {
1415     edm::IndexIntoFile::IndexIntoFileItr iterFirst = indexIntoFile.begin(IndexIntoFile::firstAppearanceOrder);
1416     edm::IndexIntoFile::IndexIntoFileItr iterFirstEnd = indexIntoFile.end(IndexIntoFile::firstAppearanceOrder);
1417     int i = 0;
1418     for (i = 0; iterFirst != iterFirstEnd; ++iterFirst, ++i) {
1419       switch (i) {
1420         case 0: {
1421           CPPUNIT_ASSERT(check(iterFirst, kRun, 0, 2, 1, 0, 3));
1422           CPPUNIT_ASSERT(iterFirst.indexIntoFile() == &indexIntoFile);
1423           CPPUNIT_ASSERT(iterFirst.size() == 10);
1424 
1425           iterFirst.getLumisInRun(lumis);
1426           std::vector<LuminosityBlockNumber_t> expected{101, 102};
1427           CPPUNIT_ASSERT(lumis == expected);
1428           break;
1429         }
1430           //values are 'IndexIntoFile::EntryType' 'indexToRun' 'indexToLumi' 'indexToEventRange' 'indexToEvent' 'nEvents'
1431         case 1: {
1432           CPPUNIT_ASSERT(check(iterFirst, kLumi, 0, 2, 1, 0, 3));
1433           break;
1434         }
1435         case 2: {
1436           CPPUNIT_ASSERT(check(iterFirst, kEvent, 0, 2, 1, 0, 3));
1437           break;
1438         }
1439         case 3: {
1440           CPPUNIT_ASSERT(check(iterFirst, kEvent, 0, 2, 1, 1, 3));
1441           break;
1442         }
1443         case 4: {
1444           CPPUNIT_ASSERT(check(iterFirst, kEvent, 0, 2, 1, 2, 3));
1445           break;
1446         }
1447         case 5: {
1448           CPPUNIT_ASSERT(check(iterFirst, kEvent, 0, 2, 2, 0, 1));
1449           break;
1450         }
1451         case 6: {
1452           CPPUNIT_ASSERT(check(iterFirst, kLumi, 0, 4, 3, 0, 1));
1453           break;
1454         }
1455         case 7: {
1456           CPPUNIT_ASSERT(check(iterFirst, kEvent, 0, 4, 3, 0, 1));
1457           break;
1458         }
1459         case 8: {
1460           CPPUNIT_ASSERT(check(iterFirst, kEvent, 0, 4, 4, 0, 1));
1461           break;
1462         }
1463         case 9: {
1464           CPPUNIT_ASSERT(check(iterFirst, kRun, 5, 7, -1, 0, 0));
1465 
1466           iterFirst.getLumisInRun(lumis);
1467           std::vector<LuminosityBlockNumber_t> expected{101, 102};
1468           CPPUNIT_ASSERT(lumis == expected);
1469           break;
1470         }
1471         case 10: {
1472           CPPUNIT_ASSERT(check(iterFirst, kRun, 6, 7, -1, 0, 0));
1473           break;
1474         }
1475         case 11: {
1476           CPPUNIT_ASSERT(check(iterFirst, kLumi, 6, 7, -1, 0, 0));
1477           break;
1478         }
1479         case 12: {
1480           CPPUNIT_ASSERT(check(iterFirst, kLumi, 6, 8, 9, 0, 1));
1481           break;
1482         }
1483         case 13: {
1484           CPPUNIT_ASSERT(check(iterFirst, kLumi, 6, 9, 9, 0, 1));
1485           break;
1486         }
1487         case 14: {
1488           CPPUNIT_ASSERT(check(iterFirst, kEvent, 6, 9, 9, 0, 1));
1489           break;
1490         }
1491         default: {
1492           CPPUNIT_ASSERT(false);
1493         }
1494       }
1495 
1496       switch (i) {
1497         case 0:
1498           CPPUNIT_ASSERT(iterFirst.firstEventEntryThisRun() == 0);
1499           break;
1500         case 8:
1501           CPPUNIT_ASSERT(iterFirst.firstEventEntryThisRun() == 0);
1502           break;
1503         case 10:
1504           CPPUNIT_ASSERT(iterFirst.firstEventEntryThisRun() == 6);
1505           break;
1506       }
1507 
1508       switch (i) {
1509         case 0:
1510           CPPUNIT_ASSERT(iterFirst.firstEventEntryThisLumi() == 0);
1511           break;
1512         case 8:
1513           CPPUNIT_ASSERT(iterFirst.firstEventEntryThisLumi() == 4);
1514           break;
1515         case 10:
1516           CPPUNIT_ASSERT(iterFirst.firstEventEntryThisLumi() == IndexIntoFile::invalidIndex);
1517           break;
1518       }
1519     }
1520     CPPUNIT_ASSERT(i == 15);
1521   }
1522 
1523   {
1524     edm::IndexIntoFile::IndexIntoFileItr iterFirst = indexIntoFile.begin(IndexIntoFile::entryOrder);
1525     edm::IndexIntoFile::IndexIntoFileItr iterFirstEnd = indexIntoFile.end(IndexIntoFile::entryOrder);
1526     int i = 0;
1527     for (i = 0; iterFirst != iterFirstEnd; ++iterFirst, ++i) {
1528       switch (i) {
1529         case 0: {
1530           CPPUNIT_ASSERT(check(iterFirst, kRun, 0, 2, 1, 0, 3));
1531           CPPUNIT_ASSERT(iterFirst.indexIntoFile() == &indexIntoFile);
1532           CPPUNIT_ASSERT(iterFirst.size() == 10);
1533 
1534           iterFirst.getLumisInRun(lumis);
1535           std::vector<LuminosityBlockNumber_t> expected{101, 102};
1536           CPPUNIT_ASSERT(lumis == expected);
1537           break;
1538         }
1539         //values are 'IndexIntoFile::EntryType' 'indexToRun' 'indexToLumi' 'indexToEventRange' 'indexToEvent' 'nEvents'
1540         case 1: {
1541           CPPUNIT_ASSERT(check(iterFirst, kLumi, 0, 2, 1, 0, 3));
1542           break;
1543         }
1544         case 2: {
1545           CPPUNIT_ASSERT(check(iterFirst, kEvent, 0, 2, 1, 0, 3));
1546           break;
1547         }
1548         case 3: {
1549           CPPUNIT_ASSERT(check(iterFirst, kEvent, 0, 2, 1, 1, 3));
1550           break;
1551         }
1552         case 4: {
1553           CPPUNIT_ASSERT(check(iterFirst, kEvent, 0, 2, 1, 2, 3));
1554           break;
1555         }
1556         case 5: {
1557           CPPUNIT_ASSERT(check(iterFirst, kEvent, 0, 2, 2, 0, 1));
1558           break;
1559         }
1560         case 6: {
1561           CPPUNIT_ASSERT(check(iterFirst, kLumi, 0, 4, 3, 0, 1));
1562           break;
1563         }
1564         case 7: {
1565           CPPUNIT_ASSERT(check(iterFirst, kEvent, 0, 4, 3, 0, 1));
1566           break;
1567         }
1568         case 8: {
1569           CPPUNIT_ASSERT(check(iterFirst, kEvent, 0, 4, 4, 0, 1));
1570           break;
1571         }
1572         case 9: {
1573           CPPUNIT_ASSERT(check(iterFirst, kRun, 5, 7, -1, 0, 0));
1574 
1575           iterFirst.getLumisInRun(lumis);
1576           std::vector<LuminosityBlockNumber_t> expected{101, 102};
1577           CPPUNIT_ASSERT(lumis == expected);
1578           break;
1579         }
1580         case 10: {
1581           CPPUNIT_ASSERT(check(iterFirst, kRun, 6, 7, -1, 0, 0));
1582           break;
1583         }
1584         case 11: {
1585           CPPUNIT_ASSERT(check(iterFirst, kLumi, 6, 7, -1, 0, 0));
1586           break;
1587         }
1588         case 12: {
1589           CPPUNIT_ASSERT(check(iterFirst, kLumi, 6, 8, 9, 0, 1));
1590           break;
1591         }
1592         case 13: {
1593           CPPUNIT_ASSERT(check(iterFirst, kLumi, 6, 9, 9, 0, 1));
1594           break;
1595         }
1596         case 14: {
1597           CPPUNIT_ASSERT(check(iterFirst, kEvent, 6, 9, 9, 0, 1));
1598           break;
1599         }
1600         default:
1601           CPPUNIT_ASSERT(false);
1602       }
1603 
1604       switch (i) {
1605         case 0:
1606           CPPUNIT_ASSERT(iterFirst.firstEventEntryThisRun() == 0);
1607           break;
1608         case 8:
1609           CPPUNIT_ASSERT(iterFirst.firstEventEntryThisRun() == 0);
1610           break;
1611         case 10:
1612           CPPUNIT_ASSERT(iterFirst.firstEventEntryThisRun() == 6);
1613           break;
1614       }
1615 
1616       switch (i) {
1617         case 0:
1618           CPPUNIT_ASSERT(iterFirst.firstEventEntryThisLumi() == 0);
1619           break;
1620         case 8:
1621           CPPUNIT_ASSERT(iterFirst.firstEventEntryThisLumi() == 4);
1622           break;
1623         case 10:
1624           CPPUNIT_ASSERT(iterFirst.firstEventEntryThisLumi() == IndexIntoFile::invalidIndex);
1625           break;
1626       }
1627     }
1628     CPPUNIT_ASSERT(i == 15);
1629   }
1630 }
1631 
1632 void TestIndexIntoFile3::testOverlappingLumisOutOfOrderEvent() {
1633   edm::IndexIntoFile indexIntoFile;
1634   indexIntoFile.addEntry(fakePHID1, 11, 101, 7, 0);  // Event
1635   indexIntoFile.addEntry(fakePHID1, 11, 101, 6, 1);  // Event
1636   indexIntoFile.addEntry(fakePHID1, 11, 101, 5, 2);  // Event
1637   // This test is a bit misnamed. The difference between this test and
1638   // the preceding one lies in the event entry numbers being swapped
1639   // in order. The order below is the expected order (it is NOT out of order).
1640   // I don't think the order of entry numbers in the preceding test is
1641   // possible, the event entry number is incremented as each event
1642   // is written and addEntry is called at that time. The event entry
1643   // number should always increment by one at each addEntry call for
1644   // an event. Possibly the preceding test should be deleted (although
1645   // IndexIntoFile works with that order also even if it will never
1646   // occur ...)
1647   //Dummy Lumi gets added
1648   indexIntoFile.addEntry(fakePHID1, 11, 102, 5, 3);  // Event
1649   //Another dummy lumi gets added
1650   indexIntoFile.addEntry(fakePHID1, 11, 101, 4, 4);  // Event
1651   indexIntoFile.addEntry(fakePHID1, 11, 101, 0, 0);  // Lumi
1652 
1653   indexIntoFile.addEntry(fakePHID1, 11, 102, 4, 5);  // Event
1654   indexIntoFile.addEntry(fakePHID1, 11, 102, 0, 1);  // Lumi
1655   indexIntoFile.addEntry(fakePHID1, 11, 0, 0, 0);    // Run
1656   indexIntoFile.addEntry(fakePHID2, 11, 0, 0, 1);    // Run
1657   indexIntoFile.addEntry(fakePHID2, 11, 101, 0, 2);  // Lumi
1658   indexIntoFile.addEntry(fakePHID2, 11, 102, 0, 3);  // Lumi
1659   indexIntoFile.addEntry(fakePHID2, 11, 102, 4, 6);  // Event
1660   indexIntoFile.addEntry(fakePHID2, 11, 102, 0, 4);  // Lumi
1661   indexIntoFile.addEntry(fakePHID2, 11, 0, 0, 2);    // Run
1662   indexIntoFile.sortVector_Run_Or_Lumi_Entries();
1663 
1664   std::vector<LuminosityBlockNumber_t> lumis;
1665 
1666   {
1667     edm::IndexIntoFile::IndexIntoFileItr iterFirst = indexIntoFile.begin(IndexIntoFile::firstAppearanceOrder);
1668     edm::IndexIntoFile::IndexIntoFileItr iterFirstEnd = indexIntoFile.end(IndexIntoFile::firstAppearanceOrder);
1669     int i = 0;
1670     for (i = 0; iterFirst != iterFirstEnd; ++iterFirst, ++i) {
1671       switch (i) {
1672         case 0: {
1673           CPPUNIT_ASSERT(check(iterFirst, kRun, 0, 2, 1, 0, 3));  // run 11
1674           CPPUNIT_ASSERT(iterFirst.indexIntoFile() == &indexIntoFile);
1675           CPPUNIT_ASSERT(iterFirst.size() == 10);
1676 
1677           iterFirst.getLumisInRun(lumis);
1678           std::vector<LuminosityBlockNumber_t> expected{101, 102};
1679           CPPUNIT_ASSERT(lumis == expected);
1680           CPPUNIT_ASSERT(iterFirst.firstEventEntryThisRun() == 0);
1681           CPPUNIT_ASSERT(iterFirst.firstEventEntryThisLumi() == 0);
1682           break;
1683         }
1684           //values are 'IndexIntoFile::EntryType' 'indexToRun' 'indexToLumi' 'indexToEventRange' 'indexToEvent' 'nEvents'
1685         case 1: {
1686           CPPUNIT_ASSERT(check(iterFirst, kLumi, 0, 2, 1, 0, 3));  // lumi 11/101
1687           break;
1688         }
1689         case 2: {
1690           CPPUNIT_ASSERT(check(iterFirst, kEvent, 0, 2, 1, 0, 3));  // event 11/101/7
1691           break;
1692         }
1693         case 3: {
1694           CPPUNIT_ASSERT(check(iterFirst, kEvent, 0, 2, 1, 1, 3));  // event 11/101/6
1695           break;
1696         }
1697         case 4: {
1698           CPPUNIT_ASSERT(check(iterFirst, kEvent, 0, 2, 1, 2, 3));  // event 11/101/5
1699           break;
1700         }
1701         case 5: {
1702           CPPUNIT_ASSERT(check(iterFirst, kEvent, 0, 2, 2, 0, 1));
1703           break;
1704         }
1705         case 6: {
1706           CPPUNIT_ASSERT(check(iterFirst, kLumi, 0, 4, 3, 0, 1));
1707           break;
1708         }
1709         case 7: {
1710           CPPUNIT_ASSERT(check(iterFirst, kEvent, 0, 4, 3, 0, 1));
1711           break;
1712         }
1713         case 8: {
1714           CPPUNIT_ASSERT(check(iterFirst, kEvent, 0, 4, 4, 0, 1));
1715           CPPUNIT_ASSERT(iterFirst.firstEventEntryThisRun() == 0);
1716           CPPUNIT_ASSERT(iterFirst.firstEventEntryThisLumi() == 3);
1717           break;
1718         }
1719         case 9: {
1720           CPPUNIT_ASSERT(check(iterFirst, kRun, 5, 7, -1, 0, 0));
1721 
1722           iterFirst.getLumisInRun(lumis);
1723           std::vector<LuminosityBlockNumber_t> expected{101, 102};
1724           CPPUNIT_ASSERT(lumis == expected);
1725           break;
1726         }
1727         case 10: {
1728           CPPUNIT_ASSERT(check(iterFirst, kRun, 6, 7, -1, 0, 0));
1729           CPPUNIT_ASSERT(iterFirst.firstEventEntryThisRun() == 6);
1730           CPPUNIT_ASSERT(iterFirst.firstEventEntryThisLumi() == IndexIntoFile::invalidIndex);
1731           break;
1732         }
1733         case 11: {
1734           CPPUNIT_ASSERT(check(iterFirst, kLumi, 6, 7, -1, 0, 0));
1735           break;
1736         }
1737         case 12: {
1738           CPPUNIT_ASSERT(check(iterFirst, kLumi, 6, 8, 9, 0, 1));
1739           break;
1740         }
1741         case 13: {
1742           CPPUNIT_ASSERT(check(iterFirst, kLumi, 6, 9, 9, 0, 1));
1743           break;
1744         }
1745         case 14: {
1746           CPPUNIT_ASSERT(check(iterFirst, kEvent, 6, 9, 9, 0, 1));
1747           break;
1748         }
1749         default: {
1750           CPPUNIT_ASSERT(false);
1751         }
1752       }
1753     }
1754     CPPUNIT_ASSERT(i == 15);
1755   }
1756 
1757   {
1758     edm::IndexIntoFile::IndexIntoFileItr iterFirst = indexIntoFile.begin(IndexIntoFile::entryOrder);
1759     edm::IndexIntoFile::IndexIntoFileItr iterFirstEnd = indexIntoFile.end(IndexIntoFile::entryOrder);
1760     int i = 0;
1761     for (i = 0; iterFirst != iterFirstEnd; ++iterFirst, ++i) {
1762       /*std::cout << "out of order run:" << iterFirst.run() << " lumi:" << iterFirst.lumi()
1763                 << " firstEventEntryThisRun:" << iterFirst.firstEventEntryThisRun()
1764                 << " firstEventEntryThisLumi:" << iterFirst.firstEventEntryThisLumi() << std::endl; */
1765       switch (i) {
1766         case 0: {
1767           CPPUNIT_ASSERT(check(iterFirst, kRun, 0, 1, 1, 0, 3));  // run 11
1768           CPPUNIT_ASSERT(iterFirst.processHistoryIDIndex() == 0);
1769           CPPUNIT_ASSERT(iterFirst.indexIntoFile() == &indexIntoFile);
1770           CPPUNIT_ASSERT(iterFirst.size() == 10);
1771           CPPUNIT_ASSERT(iterFirst.shouldProcessRun());
1772 
1773           iterFirst.getLumisInRun(lumis);
1774           std::vector<LuminosityBlockNumber_t> expected{101, 102};
1775           CPPUNIT_ASSERT(lumis == expected);
1776           CPPUNIT_ASSERT(iterFirst.firstEventEntryThisRun() == 0);
1777           CPPUNIT_ASSERT(iterFirst.firstEventEntryThisLumi() == 0);
1778           break;
1779         }
1780         //values are 'IndexIntoFile::EntryType' 'indexToRun' 'indexToLumi' 'indexToEventRange' 'indexToEvent' 'nEvents'
1781         case 1: {
1782           CPPUNIT_ASSERT(check(iterFirst, kLumi, 0, 1, 1, 0, 3));  // lumi 11/101
1783           CPPUNIT_ASSERT(iterFirst.processHistoryIDIndex() == 0);
1784           CPPUNIT_ASSERT(!iterFirst.shouldProcessLumi());
1785           break;
1786         }
1787         case 2: {
1788           CPPUNIT_ASSERT(check(iterFirst, kEvent, 0, 1, 1, 0, 3));  // event 11/101/7
1789           CPPUNIT_ASSERT(iterFirst.processHistoryIDIndex() == 0);
1790           break;
1791         }
1792         case 3: {
1793           CPPUNIT_ASSERT(check(iterFirst, kEvent, 0, 1, 1, 1, 3));  // event 11/101/6
1794           break;
1795         }
1796         case 4: {
1797           CPPUNIT_ASSERT(check(iterFirst, kEvent, 0, 1, 1, 2, 3));  // event 11/101/5
1798           break;
1799         }
1800         case 5: {
1801           CPPUNIT_ASSERT(check(iterFirst, kLumi, 0, 2, 2, 0, 1));  // lumi 11/102
1802           CPPUNIT_ASSERT(!iterFirst.shouldProcessLumi());
1803           break;
1804         }
1805         case 6: {
1806           CPPUNIT_ASSERT(check(iterFirst, kEvent, 0, 2, 2, 0, 1));  // event 11/102/3
1807           break;
1808         }
1809         case 7: {
1810           CPPUNIT_ASSERT(check(iterFirst, kLumi, 0, 3, 3, 0, 1));  // lumi 11/101
1811           CPPUNIT_ASSERT(iterFirst.shouldProcessLumi());
1812           break;
1813         }
1814         case 8: {
1815           CPPUNIT_ASSERT(check(iterFirst, kEvent, 0, 3, 3, 0, 1));  // event 11/101/4
1816           CPPUNIT_ASSERT(iterFirst.firstEventEntryThisRun() == 0);
1817           CPPUNIT_ASSERT(iterFirst.firstEventEntryThisLumi() == 4);
1818           break;
1819         }
1820         case 9: {
1821           CPPUNIT_ASSERT(check(iterFirst, kLumi, 0, 4, 4, 0, 1));  // lumi 11/102
1822           CPPUNIT_ASSERT(iterFirst.shouldProcessLumi());
1823           break;
1824         }
1825         case 10: {
1826           CPPUNIT_ASSERT(check(iterFirst, kEvent, 0, 4, 4, 0, 1));  // event 11/102/4
1827           CPPUNIT_ASSERT(iterFirst.processHistoryIDIndex() == 0);
1828           break;
1829         }
1830         case 11: {
1831           CPPUNIT_ASSERT(check(iterFirst, kRun, 5, 7, -1, 0, 0));  //Run Phid 2 11
1832           CPPUNIT_ASSERT(iterFirst.shouldProcessRun());
1833 
1834           iterFirst.getLumisInRun(lumis);
1835           std::vector<LuminosityBlockNumber_t> expected{101, 102};
1836           CPPUNIT_ASSERT(lumis == expected);
1837 
1838           CPPUNIT_ASSERT(iterFirst.firstEventEntryThisRun() == 6);
1839           CPPUNIT_ASSERT(iterFirst.firstEventEntryThisLumi() == IndexIntoFile::invalidIndex);
1840           break;
1841         }
1842         case 12: {
1843           CPPUNIT_ASSERT(check(iterFirst, kRun, 6, 7, -1, 0, 0));
1844           CPPUNIT_ASSERT(iterFirst.processHistoryIDIndex() == 1);
1845           CPPUNIT_ASSERT(iterFirst.shouldProcessRun());
1846           break;
1847         }
1848         case 13: {
1849           CPPUNIT_ASSERT(check(iterFirst, kLumi, 6, 7, -1, 0, 0));
1850           CPPUNIT_ASSERT(iterFirst.shouldProcessLumi());
1851           break;
1852         }
1853         case 14: {
1854           CPPUNIT_ASSERT(check(iterFirst, kLumi, 6, 8, 9, 0, 1));
1855           CPPUNIT_ASSERT(iterFirst.shouldProcessLumi());
1856           break;
1857         }
1858         case 15: {
1859           CPPUNIT_ASSERT(check(iterFirst, kLumi, 6, 9, 9, 0, 1));
1860           CPPUNIT_ASSERT(iterFirst.processHistoryIDIndex() == 1);
1861           CPPUNIT_ASSERT(iterFirst.shouldProcessLumi());
1862           break;
1863         }
1864         case 16: {
1865           CPPUNIT_ASSERT(check(iterFirst, kEvent, 6, 9, 9, 0, 1));
1866           CPPUNIT_ASSERT(iterFirst.processHistoryIDIndex() == 1);
1867           break;
1868         }
1869         default:
1870           CPPUNIT_ASSERT(false);
1871       }
1872     }
1873     CPPUNIT_ASSERT(i == 17);
1874   }
1875 }
1876 
1877 void TestIndexIntoFile3::testOverlappingLumisWithEndWithEmptyLumi() {
1878   // from a failed job
1879   edm::IndexIntoFile indexIntoFile;
1880   indexIntoFile.addEntry(fakePHID1, 1, 1, 2, 0);    // Event
1881   indexIntoFile.addEntry(fakePHID1, 1, 1, 5, 1);    // Event
1882   indexIntoFile.addEntry(fakePHID1, 1, 2, 8, 2);    // Event
1883   indexIntoFile.addEntry(fakePHID1, 1, 2, 6, 3);    // Event
1884   indexIntoFile.addEntry(fakePHID1, 1, 1, 3, 4);    // Event
1885   indexIntoFile.addEntry(fakePHID1, 1, 2, 9, 5);    // Event
1886   indexIntoFile.addEntry(fakePHID1, 1, 1, 4, 6);    // Event
1887   indexIntoFile.addEntry(fakePHID1, 1, 1, 1, 7);    // Event
1888   indexIntoFile.addEntry(fakePHID1, 1, 2, 7, 8);    // Event
1889   indexIntoFile.addEntry(fakePHID1, 1, 1, 0, 0);    // Lumi
1890   indexIntoFile.addEntry(fakePHID1, 1, 2, 10, 9);   // Event
1891   indexIntoFile.addEntry(fakePHID1, 1, 2, 0, 1);    // Lumi
1892   indexIntoFile.addEntry(fakePHID1, 1, 3, 12, 10);  // Event
1893   indexIntoFile.addEntry(fakePHID1, 1, 3, 11, 11);  // Event
1894   indexIntoFile.addEntry(fakePHID1, 1, 3, 15, 12);  // Event
1895   indexIntoFile.addEntry(fakePHID1, 1, 3, 14, 13);  // Event
1896   indexIntoFile.addEntry(fakePHID1, 1, 4, 18, 14);  // Event
1897   indexIntoFile.addEntry(fakePHID1, 1, 4, 17, 15);  // Event
1898   indexIntoFile.addEntry(fakePHID1, 1, 4, 20, 16);  // Event
1899   indexIntoFile.addEntry(fakePHID1, 1, 3, 13, 17);  // Event
1900   indexIntoFile.addEntry(fakePHID1, 1, 3, 0, 2);    // Lumi
1901   indexIntoFile.addEntry(fakePHID1, 1, 4, 19, 18);  // Event
1902   indexIntoFile.addEntry(fakePHID1, 1, 4, 16, 19);  // Event
1903   indexIntoFile.addEntry(fakePHID1, 1, 4, 0, 3);    // Lumi
1904   indexIntoFile.addEntry(fakePHID1, 1, 0, 0, 0);    // Run
1905   indexIntoFile.sortVector_Run_Or_Lumi_Entries();
1906 
1907   std::vector<LuminosityBlockNumber_t> lumis;
1908 
1909   {
1910     edm::IndexIntoFile::IndexIntoFileItr iterFirst = indexIntoFile.begin(IndexIntoFile::firstAppearanceOrder);
1911     edm::IndexIntoFile::IndexIntoFileItr iterFirstEnd = indexIntoFile.end(IndexIntoFile::firstAppearanceOrder);
1912     int i = 0;
1913     for (i = 0; iterFirst != iterFirstEnd; ++iterFirst, ++i) {
1914       //std::cout << "out of order run:" << iterFirst.run() << " lumi:" << iterFirst.lumi()
1915       //          << " firstEventEntryThisRun:" << iterFirst.firstEventEntryThisRun()
1916       //          << " firstEventEntryThisLumi:" << iterFirst.firstEventEntryThisLumi() << std::endl;
1917       switch (i) {
1918         case 0: {
1919           CPPUNIT_ASSERT(check(iterFirst, kRun, 0, 4, 1, 0, 2));  // run 1
1920           CPPUNIT_ASSERT(iterFirst.indexIntoFile() == &indexIntoFile);
1921           CPPUNIT_ASSERT(iterFirst.size() == 13);
1922           iterFirst.getLumisInRun(lumis);
1923           std::vector<LuminosityBlockNumber_t> expected{1, 2, 3, 4};
1924           CPPUNIT_ASSERT(lumis == expected);
1925           CPPUNIT_ASSERT(iterFirst.firstEventEntryThisRun() == 0);
1926           CPPUNIT_ASSERT(iterFirst.firstEventEntryThisLumi() == 0);
1927           break;
1928         }
1929           //values are 'IndexIntoFile::EntryType' 'indexToRun' 'indexToLumi' 'indexToEventRange' 'indexToEvent' 'nEvents'
1930         case 1: {
1931           CPPUNIT_ASSERT(check(iterFirst, kLumi, 0, 4, 1, 0, 2));  // lumi 1/1
1932           break;
1933         }
1934         case 2: {
1935           CPPUNIT_ASSERT(check(iterFirst, kEvent, 0, 4, 1, 0, 2));  // event 1/1/2
1936           break;
1937         }
1938         case 3: {
1939           CPPUNIT_ASSERT(check(iterFirst, kEvent, 0, 4, 1, 1, 2));  // event 1/1/5
1940           break;
1941         }
1942         case 4: {
1943           CPPUNIT_ASSERT(check(iterFirst, kEvent, 0, 4, 2, 0, 1));  // event 1/1/3
1944           break;
1945         }
1946         case 5: {
1947           CPPUNIT_ASSERT(check(iterFirst, kEvent, 0, 4, 3, 0, 2));  // event 1/1/4
1948           break;
1949         }
1950         case 6: {
1951           CPPUNIT_ASSERT(check(iterFirst, kEvent, 0, 4, 3, 1, 2));  // event 1/1/1
1952           break;
1953         }
1954         case 7: {
1955           CPPUNIT_ASSERT(check(iterFirst, kLumi, 0, 8, 5, 0, 2));  // lumi 1/2
1956           break;
1957         }
1958         case 8: {
1959           CPPUNIT_ASSERT(check(iterFirst, kEvent, 0, 8, 5, 0, 2));  // event 1/2/8
1960           CPPUNIT_ASSERT(iterFirst.firstEventEntryThisRun() == 0);
1961           CPPUNIT_ASSERT(iterFirst.firstEventEntryThisLumi() == 2);
1962           break;
1963         }
1964         case 9: {
1965           CPPUNIT_ASSERT(check(iterFirst, kEvent, 0, 8, 5, 1, 2));  // event 1/2/6
1966           break;
1967         }
1968         case 10: {
1969           CPPUNIT_ASSERT(check(iterFirst, kEvent, 0, 8, 6, 0, 1));  // event 1/2/9
1970           break;
1971         }
1972         case 11: {
1973           CPPUNIT_ASSERT(check(iterFirst, kEvent, 0, 8, 7, 0, 1));  // event 1/2/7
1974           break;
1975         }
1976         case 12: {
1977           CPPUNIT_ASSERT(check(iterFirst, kEvent, 0, 8, 8, 0, 1));  // event 1/2/10
1978           break;
1979         }
1980         case 13: {
1981           CPPUNIT_ASSERT(check(iterFirst, kLumi, 0, 10, 9, 0, 4));  // lumi 1/3
1982           break;
1983         }
1984         case 14: {
1985           CPPUNIT_ASSERT(check(iterFirst, kEvent, 0, 10, 9, 0, 4));  // event 1/3/12
1986           break;
1987         }
1988         case 15: {
1989           CPPUNIT_ASSERT(check(iterFirst, kEvent, 0, 10, 9, 1, 4));  // event 1/3/11
1990           break;
1991         }
1992         case 16: {
1993           CPPUNIT_ASSERT(check(iterFirst, kEvent, 0, 10, 9, 2, 4));  // event 1/3/15
1994           break;
1995         }
1996         case 17: {
1997           CPPUNIT_ASSERT(check(iterFirst, kEvent, 0, 10, 9, 3, 4));  // event 1/3/14
1998           break;
1999         }
2000         case 18: {
2001           CPPUNIT_ASSERT(check(iterFirst, kEvent, 0, 10, 10, 0, 1));  // event 1/3/13
2002           break;
2003         }
2004         case 19: {
2005           CPPUNIT_ASSERT(check(iterFirst, kLumi, 0, 12, 11, 0, 3));  // lumi 1/4
2006           break;
2007         }
2008         case 20: {
2009           CPPUNIT_ASSERT(check(iterFirst, kEvent, 0, 12, 11, 0, 3));  // event 1/4/18
2010           break;
2011         }
2012         case 21: {
2013           CPPUNIT_ASSERT(check(iterFirst, kEvent, 0, 12, 11, 1, 3));  // event 1/4/17
2014           break;
2015         }
2016         case 22: {
2017           CPPUNIT_ASSERT(check(iterFirst, kEvent, 0, 12, 11, 2, 3));  // event 1/4/20
2018           break;
2019         }
2020         case 23: {
2021           CPPUNIT_ASSERT(check(iterFirst, kEvent, 0, 12, 12, 0, 2));  // event 1/4/19
2022           break;
2023         }
2024         case 24: {
2025           CPPUNIT_ASSERT(check(iterFirst, kEvent, 0, 12, 12, 1, 2));  // event 1/4/16
2026           break;
2027         }
2028         default: {
2029           CPPUNIT_ASSERT(false);
2030         }
2031       }
2032     }
2033     CPPUNIT_ASSERT(i == 25);
2034   }
2035 
2036   {
2037     edm::IndexIntoFile::IndexIntoFileItr iterFirst = indexIntoFile.begin(IndexIntoFile::entryOrder);
2038     edm::IndexIntoFile::IndexIntoFileItr iterFirstEnd = indexIntoFile.end(IndexIntoFile::entryOrder);
2039     int i = 0;
2040     for (i = 0; iterFirst != iterFirstEnd; ++iterFirst, ++i) {
2041       //std::cout << "out of order run:" << iterFirst.run() << " lumi:" << iterFirst.lumi()
2042       //          << " firstEventEntryThisRun:" << iterFirst.firstEventEntryThisRun()
2043       //          << " firstEventEntryThisLumi:" << iterFirst.firstEventEntryThisLumi() << std::endl;
2044       switch (i) {
2045         case 0: {
2046           CPPUNIT_ASSERT(check(iterFirst, kRun, 0, 1, 1, 0, 2));  // run 1
2047           CPPUNIT_ASSERT(iterFirst.run() == 1);
2048           CPPUNIT_ASSERT(iterFirst.indexIntoFile() == &indexIntoFile);
2049           CPPUNIT_ASSERT(iterFirst.size() == 13);
2050           CPPUNIT_ASSERT(iterFirst.shouldProcessRun());
2051 
2052           iterFirst.getLumisInRun(lumis);
2053           std::vector<LuminosityBlockNumber_t> expected{1, 2, 3, 4};
2054           //CPPUNIT_ASSERT(lumis == expected);
2055           CPPUNIT_ASSERT(iterFirst.firstEventEntryThisRun() == 0);
2056           CPPUNIT_ASSERT(iterFirst.firstEventEntryThisLumi() == 0);
2057           break;
2058         }
2059         //values are 'IndexIntoFile::EntryType' 'indexToRun' 'indexToLumi' 'indexToEventRange' 'indexToEvent' 'nEvents'
2060         case 1: {
2061           CPPUNIT_ASSERT(check(iterFirst, kLumi, 0, 1, 1, 0, 2));  // lumi 1/1
2062           CPPUNIT_ASSERT(iterFirst.lumi() == 1);
2063           CPPUNIT_ASSERT(!iterFirst.shouldProcessLumi());
2064           break;
2065         }
2066         case 2: {
2067           CPPUNIT_ASSERT(check(iterFirst, kEvent, 0, 1, 1, 0, 2));  // event 1/1/2
2068           break;
2069         }
2070         case 3: {
2071           CPPUNIT_ASSERT(check(iterFirst, kEvent, 0, 1, 1, 1, 2));  // event 1/1/5
2072           break;
2073         }
2074         case 4: {
2075           CPPUNIT_ASSERT(check(iterFirst, kLumi, 0, 2, 2, 0, 2));  // lumi 1/2
2076           CPPUNIT_ASSERT(iterFirst.lumi() == 2);
2077           CPPUNIT_ASSERT(!iterFirst.shouldProcessLumi());
2078           break;
2079         }
2080         case 5: {
2081           CPPUNIT_ASSERT(check(iterFirst, kEvent, 0, 2, 2, 0, 2));  // event 1/2/8
2082           break;
2083         }
2084         case 6: {
2085           CPPUNIT_ASSERT(check(iterFirst, kEvent, 0, 2, 2, 1, 2));  // event 1/2/6
2086           break;
2087         }
2088         case 7: {
2089           CPPUNIT_ASSERT(check(iterFirst, kLumi, 0, 3, 3, 0, 1));  // lumi 1/1
2090           CPPUNIT_ASSERT(!iterFirst.shouldProcessLumi());
2091           CPPUNIT_ASSERT(iterFirst.lumi() == 1);
2092           break;
2093         }
2094         case 8: {
2095           CPPUNIT_ASSERT(check(iterFirst, kEvent, 0, 3, 3, 0, 1));  // event 1/1/3
2096           CPPUNIT_ASSERT(iterFirst.firstEventEntryThisRun() == 0);
2097           CPPUNIT_ASSERT(iterFirst.firstEventEntryThisLumi() == 4);
2098           break;
2099         }
2100         case 9: {
2101           CPPUNIT_ASSERT(check(iterFirst, kLumi, 0, 4, 4, 0, 1));  // lumi 1/2
2102           CPPUNIT_ASSERT(iterFirst.lumi() == 2);
2103           CPPUNIT_ASSERT(!iterFirst.shouldProcessLumi());
2104           break;
2105         }
2106         case 10: {
2107           CPPUNIT_ASSERT(check(iterFirst, kEvent, 0, 4, 4, 0, 1));  // event 1/2/9
2108           break;
2109         }
2110         case 11: {
2111           CPPUNIT_ASSERT(check(iterFirst, kLumi, 0, 6, 5, 0, 2));  // lumi 1/1   5
2112           CPPUNIT_ASSERT(iterFirst.lumi() == 1);
2113           CPPUNIT_ASSERT(iterFirst.shouldProcessLumi());
2114           break;
2115         }
2116         case 12: {
2117           CPPUNIT_ASSERT(check(iterFirst, kEvent, 0, 6, 5, 0, 2));  // event 1/1/4
2118           break;
2119         }
2120         case 13: {
2121           CPPUNIT_ASSERT(check(iterFirst, kEvent, 0, 6, 5, 1, 2));  // event 1/1/1
2122           break;
2123         }
2124         case 14: {
2125           CPPUNIT_ASSERT(check(iterFirst, kLumi, 0, 8, 7, 0, 1));  // lumi 1/2
2126           CPPUNIT_ASSERT(iterFirst.lumi() == 2);
2127           CPPUNIT_ASSERT(iterFirst.shouldProcessLumi());
2128           break;
2129         }
2130         case 15: {
2131           CPPUNIT_ASSERT(check(iterFirst, kEvent, 0, 8, 7, 0, 1));  // event 1/2/7
2132           break;
2133         }
2134         case 16: {
2135           CPPUNIT_ASSERT(check(iterFirst, kEvent, 0, 8, 8, 0, 1));  // event 1/2/10
2136           CPPUNIT_ASSERT(iterFirst.lumi() == 2);
2137           break;
2138         }
2139         case 17: {
2140           CPPUNIT_ASSERT(check(iterFirst, kLumi, 0, 9, 9, 0, 4));  // lumi 1/3
2141           CPPUNIT_ASSERT(iterFirst.lumi() == 3);
2142           CPPUNIT_ASSERT(!iterFirst.shouldProcessLumi());
2143           break;
2144         }
2145         case 18: {
2146           CPPUNIT_ASSERT(check(iterFirst, kEvent, 0, 9, 9, 0, 4));  // event 1/3/12
2147           break;
2148         }
2149         case 19: {
2150           CPPUNIT_ASSERT(check(iterFirst, kEvent, 0, 9, 9, 1, 4));  // event 1/3/11
2151           break;
2152         }
2153         case 20: {
2154           CPPUNIT_ASSERT(check(iterFirst, kEvent, 0, 9, 9, 2, 4));  // event 1/3/15
2155           break;
2156         }
2157         case 21: {
2158           CPPUNIT_ASSERT(check(iterFirst, kEvent, 0, 9, 9, 3, 4));  // event 1/3/14
2159           break;
2160         }
2161         case 22: {
2162           CPPUNIT_ASSERT(check(iterFirst, kLumi, 0, 10, 10, 0, 3));  // lumi 1/4
2163           CPPUNIT_ASSERT(iterFirst.lumi() == 4);
2164           CPPUNIT_ASSERT(!iterFirst.shouldProcessLumi());
2165           break;
2166         }
2167         case 23: {
2168           CPPUNIT_ASSERT(check(iterFirst, kEvent, 0, 10, 10, 0, 3));  // event 1/4/16
2169           break;
2170         }
2171         case 24: {
2172           CPPUNIT_ASSERT(check(iterFirst, kEvent, 0, 10, 10, 1, 3));  // event 1/4/17
2173           break;
2174         }
2175         case 25: {
2176           CPPUNIT_ASSERT(check(iterFirst, kEvent, 0, 10, 10, 2, 3));  // event 1/4/18
2177           break;
2178         }
2179         case 26: {
2180           CPPUNIT_ASSERT(check(iterFirst, kLumi, 0, 11, 11, 0, 1));  // lumi 1/3
2181           CPPUNIT_ASSERT(iterFirst.lumi() == 3);
2182           CPPUNIT_ASSERT(iterFirst.shouldProcessLumi());
2183           break;
2184         }
2185         case 27: {
2186           CPPUNIT_ASSERT(check(iterFirst, kEvent, 0, 11, 11, 0, 1));  // event 1/3/13
2187           break;
2188         }
2189         case 28: {
2190           CPPUNIT_ASSERT(check(iterFirst, kLumi, 0, 12, 12, 0, 2));  // lumi 1/4
2191           CPPUNIT_ASSERT(iterFirst.lumi() == 4);
2192           CPPUNIT_ASSERT(iterFirst.shouldProcessLumi());
2193           break;
2194         }
2195         case 29: {
2196           CPPUNIT_ASSERT(check(iterFirst, kEvent, 0, 12, 12, 0, 2));  // event 1/4/19
2197           break;
2198         }
2199         case 30: {
2200           CPPUNIT_ASSERT(check(iterFirst, kEvent, 0, 12, 12, 1, 2));  // event 1/4/16
2201           break;
2202         }
2203 
2204         default:
2205           CPPUNIT_ASSERT(false);
2206       }
2207     }
2208     CPPUNIT_ASSERT(i == 31);
2209   }
2210 }
2211 
2212 void TestIndexIntoFile3::testOverlappingLumisWithLumiEndOrderChanged() {
2213   // from a failed job
2214   edm::IndexIntoFile indexIntoFile;
2215   indexIntoFile.addEntry(fakePHID1, 1, 1, 2, 0);    // Event
2216   indexIntoFile.addEntry(fakePHID1, 1, 1, 5, 1);    // Event
2217   indexIntoFile.addEntry(fakePHID1, 1, 2, 8, 2);    // Event
2218   indexIntoFile.addEntry(fakePHID1, 1, 2, 6, 3);    // Event
2219   indexIntoFile.addEntry(fakePHID1, 1, 1, 3, 4);    // Event
2220   indexIntoFile.addEntry(fakePHID1, 1, 2, 9, 5);    // Event
2221   indexIntoFile.addEntry(fakePHID1, 1, 1, 4, 6);    // Event
2222   indexIntoFile.addEntry(fakePHID1, 1, 2, 7, 7);    // Event
2223   indexIntoFile.addEntry(fakePHID1, 1, 2, 10, 8);   // Event
2224   indexIntoFile.addEntry(fakePHID1, 1, 2, 0, 0);    // Lumi
2225   indexIntoFile.addEntry(fakePHID1, 1, 1, 1, 9);    // Event
2226   indexIntoFile.addEntry(fakePHID1, 1, 1, 0, 1);    // Lumi
2227   indexIntoFile.addEntry(fakePHID1, 1, 3, 12, 10);  // Event
2228   indexIntoFile.addEntry(fakePHID1, 1, 3, 11, 11);  // Event
2229   indexIntoFile.addEntry(fakePHID1, 1, 3, 15, 12);  // Event
2230   indexIntoFile.addEntry(fakePHID1, 1, 3, 14, 13);  // Event
2231   indexIntoFile.addEntry(fakePHID1, 1, 4, 18, 14);  // Event
2232   indexIntoFile.addEntry(fakePHID1, 1, 4, 17, 15);  // Event
2233   indexIntoFile.addEntry(fakePHID1, 1, 4, 20, 16);  // Event
2234   indexIntoFile.addEntry(fakePHID1, 1, 4, 19, 17);  // Event
2235   indexIntoFile.addEntry(fakePHID1, 1, 4, 16, 18);  // Event
2236   indexIntoFile.addEntry(fakePHID1, 1, 4, 0, 2);    // Lumi
2237   indexIntoFile.addEntry(fakePHID1, 1, 3, 13, 19);  // Event
2238   indexIntoFile.addEntry(fakePHID1, 1, 3, 0, 3);    // Lumi
2239   indexIntoFile.addEntry(fakePHID1, 1, 0, 0, 0);    // Run
2240   indexIntoFile.sortVector_Run_Or_Lumi_Entries();
2241 
2242   std::vector<LuminosityBlockNumber_t> lumis;
2243 
2244   {
2245     edm::IndexIntoFile::IndexIntoFileItr iterFirst = indexIntoFile.begin(IndexIntoFile::firstAppearanceOrder);
2246     edm::IndexIntoFile::IndexIntoFileItr iterFirstEnd = indexIntoFile.end(IndexIntoFile::firstAppearanceOrder);
2247     int i = 0;
2248     for (i = 0; iterFirst != iterFirstEnd; ++iterFirst, ++i) {
2249       //std::cout << "out of order run:" << iterFirst.run() << " lumi:" << iterFirst.lumi()
2250       //          << " firstEventEntryThisRun:" << iterFirst.firstEventEntryThisRun()
2251       //          << " firstEventEntryThisLumi:" << iterFirst.firstEventEntryThisLumi() << std::endl;
2252       switch (i) {
2253         case 0: {
2254           CPPUNIT_ASSERT(check(iterFirst, kRun, 0, 4, 1, 0, 2));  // run 1
2255           CPPUNIT_ASSERT(iterFirst.indexIntoFile() == &indexIntoFile);
2256           CPPUNIT_ASSERT(iterFirst.size() == 11);
2257           iterFirst.getLumisInRun(lumis);
2258           std::vector<LuminosityBlockNumber_t> expected{1, 2, 3, 4};
2259           CPPUNIT_ASSERT(lumis == expected);
2260           CPPUNIT_ASSERT(iterFirst.firstEventEntryThisRun() == 0);
2261           CPPUNIT_ASSERT(iterFirst.firstEventEntryThisLumi() == 0);
2262           break;
2263         }
2264           //values are 'IndexIntoFile::EntryType' 'indexToRun' 'indexToLumi' 'indexToEventRange' 'indexToEvent' 'nEvents'
2265         case 1: {
2266           CPPUNIT_ASSERT(check(iterFirst, kLumi, 0, 4, 1, 0, 2));  // lumi 1/1
2267           break;
2268         }
2269         case 2: {
2270           CPPUNIT_ASSERT(check(iterFirst, kEvent, 0, 4, 1, 0, 2));  // event 1/1/2
2271           break;
2272         }
2273         case 3: {
2274           CPPUNIT_ASSERT(check(iterFirst, kEvent, 0, 4, 1, 1, 2));  // event 1/1/5
2275           break;
2276         }
2277         case 4: {
2278           CPPUNIT_ASSERT(check(iterFirst, kEvent, 0, 4, 2, 0, 1));  // event 1/1/3
2279           break;
2280         }
2281         case 5: {
2282           CPPUNIT_ASSERT(check(iterFirst, kEvent, 0, 4, 3, 0, 1));  // event 1/1/4
2283           break;
2284         }
2285         case 6: {
2286           CPPUNIT_ASSERT(check(iterFirst, kEvent, 0, 4, 4, 0, 1));  // event 1/1/1
2287           break;
2288         }
2289         case 7: {
2290           CPPUNIT_ASSERT(check(iterFirst, kLumi, 0, 7, 5, 0, 2));  // lumi 1/2
2291           break;
2292         }
2293         case 8: {
2294           CPPUNIT_ASSERT(check(iterFirst, kEvent, 0, 7, 5, 0, 2));  // event 1/2/8
2295           CPPUNIT_ASSERT(iterFirst.firstEventEntryThisRun() == 0);
2296           CPPUNIT_ASSERT(iterFirst.firstEventEntryThisLumi() == 2);
2297           break;
2298         }
2299         case 9: {
2300           CPPUNIT_ASSERT(check(iterFirst, kEvent, 0, 7, 5, 1, 2));  // event 1/2/6
2301           break;
2302         }
2303         case 10: {
2304           CPPUNIT_ASSERT(check(iterFirst, kEvent, 0, 7, 6, 0, 1));  // event 1/2/9
2305           break;
2306         }
2307         case 11: {
2308           CPPUNIT_ASSERT(check(iterFirst, kEvent, 0, 7, 7, 0, 2));  // event 1/2/7
2309           break;
2310         }
2311         case 12: {
2312           CPPUNIT_ASSERT(check(iterFirst, kEvent, 0, 7, 7, 1, 2));  // event 1/2/10
2313           break;
2314         }
2315         case 13: {
2316           CPPUNIT_ASSERT(check(iterFirst, kLumi, 0, 9, 8, 0, 4));  // lumi 1/3
2317           break;
2318         }
2319         case 14: {
2320           CPPUNIT_ASSERT(check(iterFirst, kEvent, 0, 9, 8, 0, 4));  // event 1/3/12
2321           break;
2322         }
2323         case 15: {
2324           CPPUNIT_ASSERT(check(iterFirst, kEvent, 0, 9, 8, 1, 4));  // event 1/3/11
2325           break;
2326         }
2327         case 16: {
2328           CPPUNIT_ASSERT(check(iterFirst, kEvent, 0, 9, 8, 2, 4));  // event 1/3/15
2329           break;
2330         }
2331         case 17: {
2332           CPPUNIT_ASSERT(check(iterFirst, kEvent, 0, 9, 8, 3, 4));  // event 1/3/14
2333           break;
2334         }
2335         case 18: {
2336           CPPUNIT_ASSERT(check(iterFirst, kEvent, 0, 9, 9, 0, 1));  // event 1/3/13
2337           break;
2338         }
2339         case 19: {
2340           CPPUNIT_ASSERT(check(iterFirst, kLumi, 0, 10, 10, 0, 5));  // lumi 1/4
2341           break;
2342         }
2343         case 20: {
2344           CPPUNIT_ASSERT(check(iterFirst, kEvent, 0, 10, 10, 0, 5));  // event 1/4/18
2345           break;
2346         }
2347         case 21: {
2348           CPPUNIT_ASSERT(check(iterFirst, kEvent, 0, 10, 10, 1, 5));  // event 1/4/17
2349           break;
2350         }
2351         case 22: {
2352           CPPUNIT_ASSERT(check(iterFirst, kEvent, 0, 10, 10, 2, 5));  // event 1/4/20
2353           break;
2354         }
2355         case 23: {
2356           CPPUNIT_ASSERT(check(iterFirst, kEvent, 0, 10, 10, 3, 5));  // event 1/4/19
2357           break;
2358         }
2359         case 24: {
2360           CPPUNIT_ASSERT(check(iterFirst, kEvent, 0, 10, 10, 4, 5));  // event 1/4/16
2361           break;
2362         }
2363         default: {
2364           CPPUNIT_ASSERT(false);
2365         }
2366       }
2367     }
2368     CPPUNIT_ASSERT(i == 25);
2369   }
2370 
2371   {
2372     edm::IndexIntoFile::IndexIntoFileItr iterFirst = indexIntoFile.begin(IndexIntoFile::entryOrder);
2373     edm::IndexIntoFile::IndexIntoFileItr iterFirstEnd = indexIntoFile.end(IndexIntoFile::entryOrder);
2374     int i = 0;
2375     for (i = 0; iterFirst != iterFirstEnd; ++iterFirst, ++i) {
2376       //std::cout << "out of order run:" << iterFirst.run() << " lumi:" << iterFirst.lumi()
2377       //          << " firstEventEntryThisRun:" << iterFirst.firstEventEntryThisRun()
2378       //          << " firstEventEntryThisLumi:" << iterFirst.firstEventEntryThisLumi() << std::endl;
2379       switch (i) {
2380         case 0: {
2381           CPPUNIT_ASSERT(check(iterFirst, kRun, 0, 1, 1, 0, 2));  // run 1
2382           CPPUNIT_ASSERT(iterFirst.shouldProcessRun());
2383           CPPUNIT_ASSERT(iterFirst.run() == 1);
2384           CPPUNIT_ASSERT(iterFirst.indexIntoFile() == &indexIntoFile);
2385           CPPUNIT_ASSERT(iterFirst.size() == 11);
2386 
2387           iterFirst.getLumisInRun(lumis);
2388           std::vector<LuminosityBlockNumber_t> expected{1, 2, 3, 4};
2389           //CPPUNIT_ASSERT(lumis == expected);
2390           CPPUNIT_ASSERT(iterFirst.firstEventEntryThisRun() == 0);
2391           CPPUNIT_ASSERT(iterFirst.firstEventEntryThisLumi() == 0);
2392           break;
2393         }
2394         //values are 'IndexIntoFile::EntryType' 'indexToRun' 'indexToLumi' 'indexToEventRange' 'indexToEvent' 'nEvents'
2395         case 1: {
2396           CPPUNIT_ASSERT(check(iterFirst, kLumi, 0, 1, 1, 0, 2));  // lumi 1/1
2397           CPPUNIT_ASSERT(iterFirst.lumi() == 1);
2398           CPPUNIT_ASSERT(!iterFirst.shouldProcessLumi());
2399           break;
2400         }
2401         case 2: {
2402           CPPUNIT_ASSERT(check(iterFirst, kEvent, 0, 1, 1, 0, 2));  // event 1/1/2
2403           break;
2404         }
2405         case 3: {
2406           CPPUNIT_ASSERT(check(iterFirst, kEvent, 0, 1, 1, 1, 2));  // event 1/1/5
2407           break;
2408         }
2409         case 4: {
2410           CPPUNIT_ASSERT(check(iterFirst, kLumi, 0, 2, 2, 0, 2));  // lumi 1/2
2411           CPPUNIT_ASSERT(iterFirst.lumi() == 2);
2412           CPPUNIT_ASSERT(!iterFirst.shouldProcessLumi());
2413           break;
2414         }
2415         case 5: {
2416           CPPUNIT_ASSERT(check(iterFirst, kEvent, 0, 2, 2, 0, 2));  // event 1/2/8
2417           break;
2418         }
2419         case 6: {
2420           CPPUNIT_ASSERT(check(iterFirst, kEvent, 0, 2, 2, 1, 2));  // event 1/2/6
2421           break;
2422         }
2423         case 7: {
2424           CPPUNIT_ASSERT(check(iterFirst, kLumi, 0, 3, 3, 0, 1));  // lumi 1/1
2425           CPPUNIT_ASSERT(iterFirst.lumi() == 1);
2426           CPPUNIT_ASSERT(!iterFirst.shouldProcessLumi());
2427           break;
2428         }
2429         case 8: {
2430           CPPUNIT_ASSERT(check(iterFirst, kEvent, 0, 3, 3, 0, 1));  // event 1/1/3
2431           CPPUNIT_ASSERT(iterFirst.firstEventEntryThisRun() == 0);
2432           CPPUNIT_ASSERT(iterFirst.firstEventEntryThisLumi() == 4);
2433           break;
2434         }
2435         case 9: {
2436           CPPUNIT_ASSERT(check(iterFirst, kLumi, 0, 4, 4, 0, 1));  // lumi 1/2
2437           CPPUNIT_ASSERT(iterFirst.lumi() == 2);
2438           CPPUNIT_ASSERT(!iterFirst.shouldProcessLumi());
2439           break;
2440         }
2441         case 10: {
2442           CPPUNIT_ASSERT(check(iterFirst, kEvent, 0, 4, 4, 0, 1));  // event 1/2/9
2443           break;
2444         }
2445         case 11: {
2446           CPPUNIT_ASSERT(check(iterFirst, kLumi, 0, 5, 5, 0, 1));  // lumi 1/1   5
2447           CPPUNIT_ASSERT(iterFirst.lumi() == 1);
2448           CPPUNIT_ASSERT(!iterFirst.shouldProcessLumi());
2449           break;
2450         }
2451         case 12: {
2452           CPPUNIT_ASSERT(check(iterFirst, kEvent, 0, 5, 5, 0, 1));  // event 1/1/4
2453           break;
2454         }
2455         case 13: {
2456           CPPUNIT_ASSERT(check(iterFirst, kLumi, 0, 6, 6, 0, 2));  // lumi 1/2
2457           CPPUNIT_ASSERT(iterFirst.lumi() == 2);
2458           CPPUNIT_ASSERT(iterFirst.shouldProcessLumi());
2459           break;
2460         }
2461         case 14: {
2462           CPPUNIT_ASSERT(check(iterFirst, kEvent, 0, 6, 6, 0, 2));  // event 1/2/7
2463           break;
2464         }
2465         case 15: {
2466           CPPUNIT_ASSERT(check(iterFirst, kEvent, 0, 6, 6, 1, 2));  // event 1/2/10
2467           CPPUNIT_ASSERT(iterFirst.lumi() == 2);
2468           break;
2469         }
2470         case 16: {
2471           CPPUNIT_ASSERT(check(iterFirst, kLumi, 0, 7, 7, 0, 1));  // lumi 1/1
2472           CPPUNIT_ASSERT(iterFirst.lumi() == 1);
2473           CPPUNIT_ASSERT(iterFirst.shouldProcessLumi());
2474           break;
2475         }
2476         case 17: {
2477           CPPUNIT_ASSERT(check(iterFirst, kEvent, 0, 7, 7, 0, 1));  // event 1/1/1
2478           break;
2479         }
2480         case 18: {
2481           CPPUNIT_ASSERT(check(iterFirst, kLumi, 0, 8, 8, 0, 4));  // lumi 1/3
2482           CPPUNIT_ASSERT(iterFirst.lumi() == 3);
2483           CPPUNIT_ASSERT(!iterFirst.shouldProcessLumi());
2484           break;
2485         }
2486         case 19: {
2487           CPPUNIT_ASSERT(check(iterFirst, kEvent, 0, 8, 8, 0, 4));  // event 1/3/12
2488           break;
2489         }
2490         case 20: {
2491           CPPUNIT_ASSERT(check(iterFirst, kEvent, 0, 8, 8, 1, 4));  // event 1/3/11
2492           break;
2493         }
2494         case 21: {
2495           CPPUNIT_ASSERT(check(iterFirst, kEvent, 0, 8, 8, 2, 4));  // event 1/3/15
2496           break;
2497         }
2498         case 22: {
2499           CPPUNIT_ASSERT(check(iterFirst, kEvent, 0, 8, 8, 3, 4));  // event 1/3/14
2500           break;
2501         }
2502         case 23: {
2503           CPPUNIT_ASSERT(check(iterFirst, kLumi, 0, 9, 9, 0, 5));  // lumi 1/4
2504           CPPUNIT_ASSERT(iterFirst.lumi() == 4);
2505           CPPUNIT_ASSERT(iterFirst.shouldProcessLumi());
2506           break;
2507         }
2508         case 24: {
2509           CPPUNIT_ASSERT(check(iterFirst, kEvent, 0, 9, 9, 0, 5));  // event 1/4/16
2510           break;
2511         }
2512         case 25: {
2513           CPPUNIT_ASSERT(check(iterFirst, kEvent, 0, 9, 9, 1, 5));  // event 1/4/17
2514           break;
2515         }
2516         case 26: {
2517           CPPUNIT_ASSERT(check(iterFirst, kEvent, 0, 9, 9, 2, 5));  // event 1/4/18
2518           break;
2519         }
2520         case 27: {
2521           CPPUNIT_ASSERT(check(iterFirst, kEvent, 0, 9, 9, 3, 5));  // event 1/4/19
2522           break;
2523         }
2524         case 28: {
2525           CPPUNIT_ASSERT(check(iterFirst, kEvent, 0, 9, 9, 4, 5));  // event 1/4/16
2526           break;
2527         }
2528         case 29: {
2529           CPPUNIT_ASSERT(check(iterFirst, kLumi, 0, 10, 10, 0, 1));  // lumi 1/3
2530           CPPUNIT_ASSERT(iterFirst.lumi() == 3);
2531           CPPUNIT_ASSERT(iterFirst.shouldProcessLumi());
2532           break;
2533         }
2534         case 30: {
2535           CPPUNIT_ASSERT(check(iterFirst, kEvent, 0, 10, 10, 0, 1));  // event 1/3/13
2536           break;
2537         }
2538 
2539         default:
2540           CPPUNIT_ASSERT(false);
2541       }
2542     }
2543     CPPUNIT_ASSERT(i == 31);
2544   }
2545 }
2546 
2547 void TestIndexIntoFile3::testNonContiguousRun() {
2548   edm::IndexIntoFile indexIntoFile;
2549   indexIntoFile.addEntry(fakePHID1, 1, 1, 1, 0);  // Event
2550   indexIntoFile.addEntry(fakePHID1, 2, 1, 1, 1);  // Event
2551   indexIntoFile.addEntry(fakePHID1, 1, 1, 2, 2);  // Event
2552   indexIntoFile.addEntry(fakePHID1, 1, 1, 0, 0);  // Lumi
2553   indexIntoFile.addEntry(fakePHID1, 1, 0, 0, 0);  // Run
2554   indexIntoFile.addEntry(fakePHID1, 2, 1, 0, 1);  // Lumi
2555   indexIntoFile.addEntry(fakePHID1, 2, 0, 0, 1);  // Run
2556 
2557   indexIntoFile.addEntry(fakePHID1, 1, 1, 3, 3);  // Event
2558   indexIntoFile.addEntry(fakePHID1, 2, 1, 2, 4);  // Event
2559   indexIntoFile.addEntry(fakePHID1, 1, 1, 4, 5);  // Event
2560   indexIntoFile.addEntry(fakePHID1, 1, 1, 0, 2);  // Lumi
2561   indexIntoFile.addEntry(fakePHID1, 1, 0, 0, 2);  // Run
2562   indexIntoFile.addEntry(fakePHID1, 2, 1, 0, 3);  // Lumi
2563   indexIntoFile.addEntry(fakePHID1, 2, 0, 0, 3);  // Run
2564 
2565   indexIntoFile.sortVector_Run_Or_Lumi_Entries();
2566   {
2567     edm::IndexIntoFile::IndexIntoFileItr iter = indexIntoFile.begin(IndexIntoFile::entryOrder);
2568     edm::IndexIntoFile::IndexIntoFileItr iterEnd = indexIntoFile.end(IndexIntoFile::entryOrder);
2569     int i = 0;
2570     for (i = 0; iter != iterEnd; ++iter, ++i) {
2571       switch (i) {
2572         case 0: {
2573           CPPUNIT_ASSERT(check(iter, kRun, 0, 1, 1, 0, 1));  // run 1
2574           CPPUNIT_ASSERT(iter.size() == 12);
2575           CPPUNIT_ASSERT(iter.indexedSize() == 16);
2576           CPPUNIT_ASSERT(!iter.shouldProcessRun());
2577           CPPUNIT_ASSERT(iter.entry() == 0);
2578           break;
2579         }
2580         case 1: {
2581           CPPUNIT_ASSERT(check(iter, kLumi, 0, 1, 1, 0, 1));  // lumi 1:1
2582           CPPUNIT_ASSERT(!iter.shouldProcessLumi());
2583           // entry has special code in it to look for other entries if the
2584           // current RunOrLumiEntry has an invalid TTree entry number.
2585           CPPUNIT_ASSERT(iter.entry() == 0);
2586           break;
2587         }
2588         case 2: {
2589           CPPUNIT_ASSERT(check(iter, kEvent, 0, 1, 1, 0, 1));  // event 1:1:1
2590           CPPUNIT_ASSERT(iter.entry() == 0);
2591           break;
2592         }
2593         case 3: {
2594           CPPUNIT_ASSERT(check(iter, kRun, 2, 3, 3, 0, 1));  // run 2
2595           CPPUNIT_ASSERT(!iter.shouldProcessRun());
2596           CPPUNIT_ASSERT(iter.entry() == 1);
2597           break;
2598         }
2599         case 4: {
2600           CPPUNIT_ASSERT(check(iter, kLumi, 2, 3, 3, 0, 1));  // lumi 2:1
2601           CPPUNIT_ASSERT(!iter.shouldProcessLumi());
2602           CPPUNIT_ASSERT(iter.entry() == 1);
2603           break;
2604         }
2605         case 5: {
2606           CPPUNIT_ASSERT(check(iter, kEvent, 2, 3, 3, 0, 1));  // event 2:1:1
2607           CPPUNIT_ASSERT(iter.entry() == 1);
2608           break;
2609         }
2610         case 6: {
2611           CPPUNIT_ASSERT(check(iter, kRun, 4, 5, 5, 0, 1));  // run 1
2612           CPPUNIT_ASSERT(!iter.shouldProcessRun());
2613           CPPUNIT_ASSERT(iter.entry() == 0);
2614           break;
2615         }
2616         case 7: {
2617           CPPUNIT_ASSERT(check(iter, kLumi, 4, 5, 5, 0, 1));  // lumi 1:1
2618           CPPUNIT_ASSERT(!iter.shouldProcessLumi());
2619           CPPUNIT_ASSERT(iter.entry() == 0);
2620           break;
2621         }
2622         case 8: {
2623           CPPUNIT_ASSERT(check(iter, kLumi, 4, 6, 5, 0, 1));  // lumi 1:1
2624           CPPUNIT_ASSERT(!iter.shouldProcessLumi());
2625           CPPUNIT_ASSERT(iter.entry() == 0);
2626           break;
2627         }
2628         case 9: {
2629           CPPUNIT_ASSERT(check(iter, kEvent, 4, 6, 5, 0, 1));  // event 1:1:2
2630           CPPUNIT_ASSERT(iter.entry() == 2);
2631           break;
2632         }
2633         case 10: {
2634           CPPUNIT_ASSERT(check(iter, kEvent, 4, 6, 6, 0, 1));  // event 1:1:3
2635           CPPUNIT_ASSERT(iter.entry() == 3);
2636           break;
2637         }
2638         case 11: {
2639           CPPUNIT_ASSERT(check(iter, kRun, 7, 10, 9, 0, 1));  // run 2
2640           CPPUNIT_ASSERT(iter.shouldProcessRun());
2641           CPPUNIT_ASSERT(iter.entry() == 1);
2642           break;
2643         }
2644         case 12: {
2645           CPPUNIT_ASSERT(check(iter, kRun, 8, 10, 9, 0, 1));  // run 2
2646           CPPUNIT_ASSERT(iter.shouldProcessRun());
2647           CPPUNIT_ASSERT(iter.entry() == 3);
2648           break;
2649         }
2650         case 13: {
2651           CPPUNIT_ASSERT(check(iter, kLumi, 8, 10, 9, 0, 1));  // lumi 2:1
2652           CPPUNIT_ASSERT(iter.shouldProcessLumi());
2653           CPPUNIT_ASSERT(iter.entry() == 1);
2654           break;
2655         }
2656         case 14: {
2657           CPPUNIT_ASSERT(check(iter, kLumi, 8, 11, 9, 0, 1));  // lumi 2:1
2658           CPPUNIT_ASSERT(iter.shouldProcessLumi());
2659           CPPUNIT_ASSERT(iter.entry() == 3);
2660           break;
2661         }
2662         case 15: {
2663           CPPUNIT_ASSERT(check(iter, kEvent, 8, 11, 9, 0, 1));  // event 2:1:2
2664           CPPUNIT_ASSERT(iter.entry() == 4);
2665           break;
2666         }
2667         case 16: {
2668           CPPUNIT_ASSERT(check(iter, kRun, 12, 14, 15, 0, 1));  // run 1
2669           CPPUNIT_ASSERT(iter.shouldProcessRun());
2670           CPPUNIT_ASSERT(iter.entry() == 0);
2671           break;
2672         }
2673         case 17: {
2674           CPPUNIT_ASSERT(check(iter, kRun, 13, 14, 15, 0, 1));  // run 1
2675           CPPUNIT_ASSERT(iter.shouldProcessRun());
2676           CPPUNIT_ASSERT(iter.entry() == 2);
2677           break;
2678         }
2679         case 18: {
2680           CPPUNIT_ASSERT(check(iter, kLumi, 13, 14, 15, 0, 1));  // lumi 1:1
2681           CPPUNIT_ASSERT(iter.shouldProcessLumi());
2682           CPPUNIT_ASSERT(iter.entry() == 0);
2683           break;
2684         }
2685         case 19: {
2686           CPPUNIT_ASSERT(check(iter, kLumi, 13, 15, 15, 0, 1));  // lumi 1:1
2687           CPPUNIT_ASSERT(iter.shouldProcessLumi());
2688           CPPUNIT_ASSERT(iter.entry() == 2);
2689           break;
2690         }
2691         case 20: {
2692           CPPUNIT_ASSERT(check(iter, kEvent, 13, 15, 15, 0, 1));  // event 1:1:4
2693           CPPUNIT_ASSERT(iter.entry() == 5);
2694           break;
2695         }
2696         default:
2697           CPPUNIT_ASSERT(false);
2698       }
2699     }
2700     CPPUNIT_ASSERT(i == 21);
2701   }
2702 }
2703 
2704 void TestIndexIntoFile3::testNonValidLumiInsideValidLumis() {
2705   edm::IndexIntoFile indexIntoFile;
2706   indexIntoFile.addEntry(fakePHID1, 1, 1, 1, 0);  // Event
2707   indexIntoFile.addEntry(fakePHID1, 1, 2, 0, 0);  // Lumi
2708   indexIntoFile.addEntry(fakePHID1, 1, 1, 2, 1);  // Event
2709   indexIntoFile.addEntry(fakePHID1, 1, 1, 0, 1);  // Lumi
2710   indexIntoFile.addEntry(fakePHID1, 1, 2, 0, 2);  // Lumi
2711   indexIntoFile.addEntry(fakePHID1, 1, 1, 3, 2);  // Event
2712   indexIntoFile.addEntry(fakePHID1, 1, 2, 0, 3);  // Lumi
2713   indexIntoFile.addEntry(fakePHID1, 1, 1, 4, 3);  // Event
2714   indexIntoFile.addEntry(fakePHID1, 1, 1, 0, 4);  // Lumi
2715   indexIntoFile.addEntry(fakePHID1, 2, 1, 1, 4);  // Event
2716   indexIntoFile.addEntry(fakePHID1, 2, 1, 0, 5);  // Lumi
2717   indexIntoFile.addEntry(fakePHID1, 2, 0, 0, 0);  // Run
2718   indexIntoFile.addEntry(fakePHID1, 1, 1, 5, 5);  // Event
2719   indexIntoFile.addEntry(fakePHID1, 1, 1, 0, 6);  // Lumi
2720   indexIntoFile.addEntry(fakePHID1, 1, 0, 0, 1);  // Run
2721 
2722   indexIntoFile.sortVector_Run_Or_Lumi_Entries();
2723 
2724   {
2725     edm::IndexIntoFile::IndexIntoFileItr iter = indexIntoFile.begin(IndexIntoFile::entryOrder);
2726     edm::IndexIntoFile::IndexIntoFileItr iterEnd = indexIntoFile.end(IndexIntoFile::entryOrder);
2727     int i = 0;
2728     for (i = 0; iter != iterEnd; ++iter, ++i) {
2729       switch (i) {
2730         case 0: {
2731           CPPUNIT_ASSERT(check(iter, kRun, 0, 2, 1, 0, 1));  // run 1
2732           CPPUNIT_ASSERT(iter.size() == 11);
2733           CPPUNIT_ASSERT(iter.indexedSize() == 14);
2734           CPPUNIT_ASSERT(!iter.shouldProcessRun());
2735           break;
2736         }
2737         case 1: {
2738           CPPUNIT_ASSERT(check(iter, kLumi, 0, 2, 1, 0, 1));  // lumi 1:1
2739           CPPUNIT_ASSERT(!iter.shouldProcessLumi());
2740           CPPUNIT_ASSERT(iter.lumiIterationStartingIndex(2));
2741           break;
2742         }
2743         case 2: {
2744           CPPUNIT_ASSERT(check(iter, kLumi, 0, 3, 1, 0, 1));  // lumi 1:1
2745           CPPUNIT_ASSERT(!iter.shouldProcessLumi());
2746           CPPUNIT_ASSERT(!iter.lumiIterationStartingIndex(3));
2747           break;
2748         }
2749         case 3: {
2750           CPPUNIT_ASSERT(check(iter, kLumi, 0, 4, 1, 0, 1));  // lumi 1:1
2751           CPPUNIT_ASSERT(!iter.shouldProcessLumi());
2752           CPPUNIT_ASSERT(iter.lumiIterationStartingIndex(4));
2753           break;
2754         }
2755         case 4: {
2756           CPPUNIT_ASSERT(check(iter, kEvent, 0, 4, 1, 0, 1));  // event 1:1:1
2757           CPPUNIT_ASSERT(iter.entry() == 0);
2758           break;
2759         }
2760         case 5: {
2761           CPPUNIT_ASSERT(check(iter, kEvent, 0, 4, 2, 0, 1));  // event 1:1:2
2762           CPPUNIT_ASSERT(iter.entry() == 1);
2763           break;
2764         }
2765         case 6: {
2766           CPPUNIT_ASSERT(check(iter, kEvent, 0, 4, 3, 0, 1));  // event 1:1:3
2767           CPPUNIT_ASSERT(iter.entry() == 2);
2768           break;
2769         }
2770         case 7: {
2771           CPPUNIT_ASSERT(check(iter, kEvent, 0, 4, 4, 0, 1));  // event 1:1:4
2772           CPPUNIT_ASSERT(iter.entry() == 3);
2773           break;
2774         }
2775         case 8: {
2776           CPPUNIT_ASSERT(check(iter, kRun, 5, 6, 6, 0, 1));  // run 2
2777           CPPUNIT_ASSERT(iter.shouldProcessRun());
2778           break;
2779         }
2780         case 9: {
2781           CPPUNIT_ASSERT(check(iter, kLumi, 5, 6, 6, 0, 1));  // lumi 2:1
2782           CPPUNIT_ASSERT(iter.shouldProcessLumi());
2783           break;
2784         }
2785         case 10: {
2786           CPPUNIT_ASSERT(check(iter, kEvent, 5, 6, 6, 0, 1));  // event 2:1:1
2787           CPPUNIT_ASSERT(iter.entry() == 4);
2788           break;
2789         }
2790         case 11: {
2791           CPPUNIT_ASSERT(check(iter, kRun, 7, 8, -1, 0, 0));  // run 1
2792           CPPUNIT_ASSERT(iter.shouldProcessRun());
2793           break;
2794         }
2795         case 12: {
2796           CPPUNIT_ASSERT(check(iter, kLumi, 7, 8, -1, 0, 0));  // lumi 1:2
2797           CPPUNIT_ASSERT(iter.shouldProcessLumi());
2798           break;
2799         }
2800         case 13: {
2801           CPPUNIT_ASSERT(check(iter, kLumi, 7, 9, -1, 0, 0));  // lumi 1:2
2802           CPPUNIT_ASSERT(iter.shouldProcessLumi());
2803           break;
2804         }
2805         case 14: {
2806           CPPUNIT_ASSERT(check(iter, kLumi, 7, 10, -1, 0, 0));  // lumi 1:2
2807           CPPUNIT_ASSERT(iter.shouldProcessLumi());
2808           break;
2809         }
2810         case 15: {
2811           CPPUNIT_ASSERT(check(iter, kLumi, 7, 11, 13, 0, 1));  // lumi 1:1
2812           CPPUNIT_ASSERT(iter.shouldProcessLumi());
2813           CPPUNIT_ASSERT(iter.entry() == 1);
2814           break;
2815         }
2816         case 16: {
2817           CPPUNIT_ASSERT(check(iter, kLumi, 7, 12, 13, 0, 1));  // lumi 1:1
2818           CPPUNIT_ASSERT(iter.shouldProcessLumi());
2819           CPPUNIT_ASSERT(iter.entry() == 4);
2820           break;
2821         }
2822         case 17: {
2823           CPPUNIT_ASSERT(check(iter, kLumi, 7, 13, 13, 0, 1));  // lumi 1:1
2824           CPPUNIT_ASSERT(iter.shouldProcessLumi());
2825           CPPUNIT_ASSERT(iter.entry() == 6);
2826           break;
2827         }
2828         case 18: {
2829           CPPUNIT_ASSERT(check(iter, kEvent, 7, 13, 13, 0, 1));  // event 1:1:5
2830           CPPUNIT_ASSERT(iter.entry() == 5);
2831           break;
2832         }
2833       }
2834     }
2835     CPPUNIT_ASSERT(i == 19);
2836 
2837     skipEventBackward(iter);
2838     checkSkipped(0, 1, 1, 5);
2839     CPPUNIT_ASSERT(check(iter, kRun, 7, 11, 13, 0, 1));
2840 
2841     skipEventBackward(iter);
2842     checkSkipped(0, 2, 1, 4);
2843     CPPUNIT_ASSERT(check(iter, kRun, 5, 6, 6, 0, 1));
2844 
2845     skipEventBackward(iter);
2846     checkSkipped(0, 1, 1, 3);
2847     CPPUNIT_ASSERT(check(iter, kRun, 0, 2, 4, 0, 1));
2848 
2849     skipEventBackward(iter);
2850     checkSkipped(0, 1, 1, 2);
2851     CPPUNIT_ASSERT(check(iter, kRun, 0, 2, 3, 0, 1));
2852 
2853     skipEventBackward(iter);
2854     checkSkipped(0, 1, 1, 1);
2855     CPPUNIT_ASSERT(check(iter, kRun, 0, 2, 2, 0, 1));
2856 
2857     skipEventBackward(iter);
2858     checkSkipped(0, 1, 1, 0);
2859     CPPUNIT_ASSERT(check(iter, kRun, 0, 2, 1, 0, 1));
2860 
2861     skipEventBackward(iter);
2862     checkSkipped(-1, 0, 0, -1);
2863     CPPUNIT_ASSERT(check(iter, kRun, 0, 2, 1, 0, 1));
2864 
2865     iter.advanceToNextRun();
2866     CPPUNIT_ASSERT(check(iter, kRun, 5, 6, 6, 0, 1));  // run 2
2867     iter.advanceToNextRun();
2868     CPPUNIT_ASSERT(check(iter, kRun, 7, 8, -1, 0, 0));  // run 1
2869     iter.advanceToNextRun();
2870     CPPUNIT_ASSERT(check(iter, kEnd, -1, -1, -1, 0, 0));
2871 
2872     iter = indexIntoFile.begin(IndexIntoFile::entryOrder);
2873     iter.advanceToNextLumiOrRun();
2874     CPPUNIT_ASSERT(check(iter, kLumi, 0, 2, 1, 0, 1));  // lumi 1:1
2875     iter.advanceToNextLumiOrRun();
2876     CPPUNIT_ASSERT(check(iter, kRun, 5, 6, 6, 0, 1));  // run 2
2877     iter.advanceToNextLumiOrRun();
2878     CPPUNIT_ASSERT(check(iter, kLumi, 5, 6, 6, 0, 1));  // lumi 2:1
2879     iter.advanceToNextLumiOrRun();
2880     CPPUNIT_ASSERT(check(iter, kRun, 7, 8, -1, 0, 0));  // run 1
2881     iter.advanceToNextLumiOrRun();
2882     CPPUNIT_ASSERT(check(iter, kLumi, 7, 8, -1, 0, 0));  // lumi 1:2
2883     iter.advanceToNextLumiOrRun();
2884     CPPUNIT_ASSERT(check(iter, kLumi, 7, 11, 13, 0, 1));  // lumi 1:1
2885     iter.advanceToNextLumiOrRun();
2886     CPPUNIT_ASSERT(check(iter, kEnd, -1, -1, -1, 0, 0));
2887   }
2888 }