Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2022-05-06 00:35:19

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 TestIndexIntoFile : public CppUnit::TestFixture {
0020   CPPUNIT_TEST_SUITE(TestIndexIntoFile);
0021   CPPUNIT_TEST(testIterEndWithLumi);
0022   CPPUNIT_TEST(testIterEndWithRun);
0023   CPPUNIT_TEST(testIterLastLumiRangeNoEvents);
0024   CPPUNIT_TEST(testEmptyIndex);
0025   CPPUNIT_TEST(testSkip);
0026   CPPUNIT_TEST(testSkip2);
0027   CPPUNIT_TEST(testSkip3);
0028   CPPUNIT_TEST(testEndWithRun);
0029   CPPUNIT_TEST(testRunsNoEvents);
0030   CPPUNIT_TEST(testLumisNoEvents);
0031   CPPUNIT_TEST_SUITE_END();
0032 
0033 public:
0034   static const IndexIntoFile::EntryType kRun = IndexIntoFile::kRun;
0035   static const IndexIntoFile::EntryType kLumi = IndexIntoFile::kLumi;
0036   static const IndexIntoFile::EntryType kEvent = IndexIntoFile::kEvent;
0037   static const IndexIntoFile::EntryType kEnd = IndexIntoFile::kEnd;
0038 
0039   class Skipped {
0040   public:
0041     Skipped() : phIndexOfSkippedEvent_(0), runOfSkippedEvent_(0), lumiOfSkippedEvent_(0), skippedEventEntry_(0) {}
0042     int phIndexOfSkippedEvent_;
0043     RunNumber_t runOfSkippedEvent_;
0044     LuminosityBlockNumber_t lumiOfSkippedEvent_;
0045     IndexIntoFile::EntryNumber_t skippedEventEntry_;
0046   };
0047 
0048   Skipped skipped_;
0049 
0050   void setUp() {
0051     // Make some fake processHistoryID's to work with
0052     nullPHID = ProcessHistoryID();
0053 
0054     ProcessConfiguration pc;
0055     auto processHistory1 = std::make_unique<ProcessHistory>();
0056     ProcessHistory& ph1 = *processHistory1;
0057     processHistory1->push_back(pc);
0058     fakePHID1 = ph1.id();
0059 
0060     auto processHistory2 = std::make_unique<ProcessHistory>();
0061     ProcessHistory& ph2 = *processHistory2;
0062     processHistory2->push_back(pc);
0063     processHistory2->push_back(pc);
0064     fakePHID2 = ph2.id();
0065 
0066     auto processHistory3 = std::make_unique<ProcessHistory>();
0067     ProcessHistory& ph3 = *processHistory3;
0068     processHistory3->push_back(pc);
0069     processHistory3->push_back(pc);
0070     processHistory3->push_back(pc);
0071     fakePHID3 = ph3.id();
0072   }
0073 
0074   void tearDown() {}
0075 
0076   void testIterEndWithLumi();
0077   void testIterEndWithRun();
0078   void testIterLastLumiRangeNoEvents();
0079   void testEmptyIndex();
0080   void testSkip();
0081   void testSkip2();
0082   void testSkip3();
0083   void testEndWithRun();
0084   void testReduce();
0085   void testRunsNoEvents();
0086   void testLumisNoEvents();
0087 
0088   ProcessHistoryID nullPHID;
0089   ProcessHistoryID fakePHID1;
0090   ProcessHistoryID fakePHID2;
0091   ProcessHistoryID fakePHID3;
0092 
0093   void check(edm::IndexIntoFile::IndexIntoFileItr const& iter,
0094              IndexIntoFile::EntryType type,
0095              int indexToRun,
0096              int indexToLumi,
0097              int indexToEventRange,
0098              long long indexToEvent,
0099              long long nEvents);
0100 
0101   void skipEventForward(edm::IndexIntoFile::IndexIntoFileItr& iter);
0102   void skipEventBackward(edm::IndexIntoFile::IndexIntoFileItr& iter);
0103   void checkSkipped(int phIndexOfSkippedEvent,
0104                     RunNumber_t runOfSkippedEvent,
0105                     LuminosityBlockNumber_t lumiOfSkippedEvent,
0106                     IndexIntoFile::EntryNumber_t skippedEventEntry);
0107 };
0108 
0109 ///registration of the test so that the runner can find it
0110 CPPUNIT_TEST_SUITE_REGISTRATION(TestIndexIntoFile);
0111 
0112 void TestIndexIntoFile::check(edm::IndexIntoFile::IndexIntoFileItr const& iter,
0113                               IndexIntoFile::EntryType type,
0114                               int indexToRun,
0115                               int indexToLumi,
0116                               int indexToEventRange,
0117                               long long indexToEvent,
0118                               long long nEvents) {
0119   bool theyMatch = iter.getEntryType() == type && iter.type() == type && iter.indexToRun() == indexToRun &&
0120                    iter.indexToLumi() == indexToLumi && iter.indexToEventRange() == indexToEventRange &&
0121                    iter.indexToEvent() == indexToEvent && iter.nEvents() == nEvents;
0122   if (!theyMatch) {
0123     std::cout << "\nExpected        " << type << "  " << indexToRun << "  " << indexToLumi << "  " << indexToEventRange
0124               << "  " << indexToEvent << "  " << nEvents << std::endl;
0125     std::cout << "Iterator values " << iter.type() << "  " << iter.indexToRun() << "  " << iter.indexToLumi() << "  "
0126               << iter.indexToEventRange() << "  " << iter.indexToEvent() << "  " << iter.nEvents() << std::endl;
0127   }
0128   CPPUNIT_ASSERT(theyMatch);
0129 }
0130 
0131 void TestIndexIntoFile::checkSkipped(int phIndexOfSkippedEvent,
0132                                      RunNumber_t runOfSkippedEvent,
0133                                      LuminosityBlockNumber_t lumiOfSkippedEvent,
0134                                      IndexIntoFile::EntryNumber_t skippedEventEntry) {
0135   bool theyMatch =
0136       skipped_.phIndexOfSkippedEvent_ == phIndexOfSkippedEvent && skipped_.runOfSkippedEvent_ == runOfSkippedEvent &&
0137       skipped_.lumiOfSkippedEvent_ == lumiOfSkippedEvent && skipped_.skippedEventEntry_ == skippedEventEntry;
0138 
0139   if (!theyMatch) {
0140     std::cout << "\nExpected        " << phIndexOfSkippedEvent << "  " << runOfSkippedEvent << "  "
0141               << lumiOfSkippedEvent << "  " << skippedEventEntry << "\n";
0142     std::cout << "Actual          " << skipped_.phIndexOfSkippedEvent_ << "  " << skipped_.runOfSkippedEvent_ << "  "
0143               << skipped_.lumiOfSkippedEvent_ << "  " << skipped_.skippedEventEntry_ << "\n";
0144   }
0145   CPPUNIT_ASSERT(theyMatch);
0146 }
0147 
0148 void TestIndexIntoFile::skipEventForward(edm::IndexIntoFile::IndexIntoFileItr& iter) {
0149   iter.skipEventForward(skipped_.phIndexOfSkippedEvent_,
0150                         skipped_.runOfSkippedEvent_,
0151                         skipped_.lumiOfSkippedEvent_,
0152                         skipped_.skippedEventEntry_);
0153 }
0154 
0155 void TestIndexIntoFile::skipEventBackward(edm::IndexIntoFile::IndexIntoFileItr& iter) {
0156   iter.skipEventBackward(skipped_.phIndexOfSkippedEvent_,
0157                          skipped_.runOfSkippedEvent_,
0158                          skipped_.lumiOfSkippedEvent_,
0159                          skipped_.skippedEventEntry_);
0160 }
0161 
0162 void TestIndexIntoFile::testEmptyIndex() {
0163   edm::IndexIntoFile indexIntoFile;
0164 
0165   edm::IndexIntoFile::IndexIntoFileItr iterNumEnd = indexIntoFile.end(IndexIntoFile::numericalOrder);
0166   CPPUNIT_ASSERT(iterNumEnd.indexIntoFile() == &indexIntoFile);
0167   CPPUNIT_ASSERT(iterNumEnd.size() == 0);
0168   CPPUNIT_ASSERT(iterNumEnd.type() == kEnd);
0169   CPPUNIT_ASSERT(iterNumEnd.indexToRun() == IndexIntoFile::invalidIndex);
0170   CPPUNIT_ASSERT(iterNumEnd.indexToLumi() == IndexIntoFile::invalidIndex);
0171   CPPUNIT_ASSERT(iterNumEnd.indexToEventRange() == IndexIntoFile::invalidIndex);
0172   CPPUNIT_ASSERT(iterNumEnd.indexToEvent() == 0);
0173   CPPUNIT_ASSERT(iterNumEnd.nEvents() == 0);
0174 
0175   edm::IndexIntoFile::IndexIntoFileItr iterFirstEnd = indexIntoFile.end(IndexIntoFile::firstAppearanceOrder);
0176   CPPUNIT_ASSERT(iterFirstEnd.indexIntoFile() == &indexIntoFile);
0177   CPPUNIT_ASSERT(iterFirstEnd.size() == 0);
0178   CPPUNIT_ASSERT(iterFirstEnd.type() == kEnd);
0179   CPPUNIT_ASSERT(iterFirstEnd.indexToRun() == IndexIntoFile::invalidIndex);
0180   CPPUNIT_ASSERT(iterFirstEnd.indexToLumi() == IndexIntoFile::invalidIndex);
0181   CPPUNIT_ASSERT(iterFirstEnd.indexToEventRange() == IndexIntoFile::invalidIndex);
0182   CPPUNIT_ASSERT(iterFirstEnd.indexToEvent() == 0);
0183   CPPUNIT_ASSERT(iterFirstEnd.nEvents() == 0);
0184 
0185   edm::IndexIntoFile::IndexIntoFileItr iterEntryEnd = indexIntoFile.end(IndexIntoFile::entryOrder);
0186   CPPUNIT_ASSERT(iterEntryEnd.indexIntoFile() == &indexIntoFile);
0187   CPPUNIT_ASSERT(iterEntryEnd.size() == 0);
0188   CPPUNIT_ASSERT(iterEntryEnd.type() == kEnd);
0189   CPPUNIT_ASSERT(iterEntryEnd.indexToRun() == IndexIntoFile::invalidIndex);
0190   CPPUNIT_ASSERT(iterEntryEnd.indexToLumi() == IndexIntoFile::invalidIndex);
0191   CPPUNIT_ASSERT(iterEntryEnd.indexToEventRange() == IndexIntoFile::invalidIndex);
0192   CPPUNIT_ASSERT(iterEntryEnd.indexToEvent() == 0);
0193   CPPUNIT_ASSERT(iterEntryEnd.nEvents() == 0);
0194 
0195   edm::IndexIntoFile::IndexIntoFileItr iterNum = indexIntoFile.begin(IndexIntoFile::numericalOrder);
0196   CPPUNIT_ASSERT(iterNum == iterNumEnd);
0197 
0198   skipEventBackward(iterNum);
0199   checkSkipped(-1, 0, 0, -1);
0200   check(iterNum, kEnd, -1, -1, -1, 0, 0);
0201 
0202   edm::IndexIntoFile::IndexIntoFileItr iterFirst = indexIntoFile.begin(IndexIntoFile::firstAppearanceOrder);
0203   CPPUNIT_ASSERT(iterFirst == iterFirstEnd);
0204 
0205   skipEventBackward(iterFirst);
0206   checkSkipped(-1, 0, 0, -1);
0207   check(iterFirst, kEnd, -1, -1, -1, 0, 0);
0208 
0209   {
0210     auto iterEntry = indexIntoFile.begin(IndexIntoFile::entryOrder);
0211     CPPUNIT_ASSERT(iterEntry == iterEntryEnd);
0212 
0213     skipEventBackward(iterEntry);
0214     checkSkipped(-1, 0, 0, -1);
0215     check(iterEntry, kEnd, -1, -1, -1, 0, 0);
0216   }
0217 }
0218 
0219 void TestIndexIntoFile::testIterEndWithLumi() {
0220   edm::IndexIntoFile indexIntoFile;
0221   indexIntoFile.addEntry(fakePHID1, 11, 101, 0, 0);  // Lumi
0222   indexIntoFile.addEntry(fakePHID1, 11, 0, 0, 0);    // Run
0223   indexIntoFile.addEntry(fakePHID1, 12, 101, 0, 1);  // Lumi
0224   indexIntoFile.addEntry(fakePHID1, 12, 101, 0, 2);  // Lumi
0225   indexIntoFile.addEntry(fakePHID1, 12, 0, 0, 1);    // Run
0226   indexIntoFile.sortVector_Run_Or_Lumi_Entries();
0227 
0228   edm::IndexIntoFile::IndexIntoFileItr iterFirst = indexIntoFile.begin(IndexIntoFile::firstAppearanceOrder);
0229   edm::IndexIntoFile::IndexIntoFileItr iterFirstEnd = indexIntoFile.end(IndexIntoFile::firstAppearanceOrder);
0230   int i = 0;
0231   for (i = 0; iterFirst != iterFirstEnd; ++iterFirst, ++i) {
0232     if (i == 0)
0233       check(iterFirst, kRun, 0, 1, -1, 0, 0);
0234     else if (i == 1)
0235       check(iterFirst, kLumi, 0, 1, -1, 0, 0);
0236     else if (i == 2)
0237       check(iterFirst, kRun, 2, 3, -1, 0, 0);
0238     else if (i == 3)
0239       check(iterFirst, kLumi, 2, 3, -1, 0, 0);
0240     else if (i == 4)
0241       check(iterFirst, kLumi, 2, 4, -1, 0, 0);
0242     else
0243       CPPUNIT_ASSERT(false);
0244 
0245     CPPUNIT_ASSERT(iterFirst.firstEventEntryThisRun() == IndexIntoFile::invalidEntry);
0246     CPPUNIT_ASSERT(iterFirst.firstEventEntryThisLumi() == IndexIntoFile::invalidEntry);
0247   }
0248   CPPUNIT_ASSERT(i == 5);
0249 
0250   // Now repeat the above tests for the sorted iteration
0251 
0252   edm::IndexIntoFile::IndexIntoFileItr iterNum = indexIntoFile.begin(IndexIntoFile::numericalOrder);
0253   edm::IndexIntoFile::IndexIntoFileItr iterNumEnd = indexIntoFile.end(IndexIntoFile::numericalOrder);
0254   for (i = 0; iterNum != iterNumEnd; ++iterNum, ++i) {
0255     if (i == 0)
0256       check(iterNum, kRun, 0, 1, -1, 0, 0);
0257     else if (i == 1)
0258       check(iterNum, kLumi, 0, 1, -1, 0, 0);
0259     else if (i == 2)
0260       check(iterNum, kRun, 2, 3, -1, 0, 0);
0261     else if (i == 3)
0262       check(iterNum, kLumi, 2, 3, -1, 0, 0);
0263     else if (i == 4)
0264       check(iterNum, kLumi, 2, 4, -1, 0, 0);
0265     else
0266       CPPUNIT_ASSERT(false);
0267 
0268     CPPUNIT_ASSERT(iterNum.firstEventEntryThisRun() == IndexIntoFile::invalidEntry);
0269     CPPUNIT_ASSERT(iterNum.firstEventEntryThisLumi() == IndexIntoFile::invalidEntry);
0270   }
0271   CPPUNIT_ASSERT(i == 5);
0272 
0273   // Now repeat the above tests for the entry iteration
0274 
0275   edm::IndexIntoFile::IndexIntoFileItr iterEntry = indexIntoFile.begin(IndexIntoFile::entryOrder);
0276   edm::IndexIntoFile::IndexIntoFileItr iterEntryEnd = indexIntoFile.end(IndexIntoFile::entryOrder);
0277   for (i = 0; iterEntry != iterEntryEnd; ++iterEntry, ++i) {
0278     if (i == 0)
0279       check(iterEntry, kRun, 0, 1, -1, 0, 0);
0280     else if (i == 1)
0281       check(iterEntry, kLumi, 0, 1, -1, 0, 0);
0282     else if (i == 2)
0283       check(iterEntry, kRun, 2, 3, -1, 0, 0);
0284     else if (i == 3)
0285       check(iterEntry, kLumi, 2, 3, -1, 0, 0);
0286     else if (i == 4)
0287       check(iterEntry, kLumi, 2, 4, -1, 0, 0);
0288     else
0289       CPPUNIT_ASSERT(false);
0290 
0291     CPPUNIT_ASSERT(iterEntry.firstEventEntryThisRun() == IndexIntoFile::invalidEntry);
0292     CPPUNIT_ASSERT(iterEntry.firstEventEntryThisLumi() == IndexIntoFile::invalidEntry);
0293   }
0294   CPPUNIT_ASSERT(i == 5);
0295 
0296   iterFirst = indexIntoFile.begin(IndexIntoFile::firstAppearanceOrder);
0297 
0298   skipEventForward(iterFirst);
0299   checkSkipped(-1, 0, 0, -1);
0300   check(iterFirst, kEnd, -1, -1, -1, 0, 0);
0301 
0302   iterNum = indexIntoFile.begin(IndexIntoFile::numericalOrder);
0303 
0304   skipEventForward(iterNum);
0305   checkSkipped(-1, 0, 0, -1);
0306   check(iterNum, kEnd, -1, -1, -1, 0, 0);
0307 
0308   iterEntry = indexIntoFile.begin(IndexIntoFile::entryOrder);
0309 
0310   skipEventForward(iterEntry);
0311   checkSkipped(-1, 0, 0, -1);
0312   check(iterEntry, kEnd, -1, -1, -1, 0, 0);
0313 }
0314 
0315 void TestIndexIntoFile::testIterEndWithRun() {
0316   edm::IndexIntoFile indexIntoFile;
0317   indexIntoFile.addEntry(fakePHID1, 1, 0, 0, 0);  // Run
0318   indexIntoFile.addEntry(fakePHID1, 1, 0, 0, 1);  // Run
0319   indexIntoFile.addEntry(fakePHID1, 2, 0, 0, 2);  // Run
0320   indexIntoFile.addEntry(fakePHID1, 3, 0, 0, 3);  // Run
0321   indexIntoFile.sortVector_Run_Or_Lumi_Entries();
0322 
0323   edm::IndexIntoFile::IndexIntoFileItr iterFirst = indexIntoFile.begin(IndexIntoFile::firstAppearanceOrder);
0324   edm::IndexIntoFile::IndexIntoFileItr iterFirstEnd = indexIntoFile.end(IndexIntoFile::firstAppearanceOrder);
0325   int i = 0;
0326   for (; iterFirst != iterFirstEnd; ++iterFirst, ++i) {
0327     if (i == 0)
0328       check(iterFirst, kRun, 0, -1, -1, 0, 0);
0329     else if (i == 1)
0330       check(iterFirst, kRun, 1, -1, -1, 0, 0);
0331     else if (i == 2)
0332       check(iterFirst, kRun, 2, -1, -1, 0, 0);
0333     else if (i == 3)
0334       check(iterFirst, kRun, 3, -1, -1, 0, 0);
0335     else
0336       CPPUNIT_ASSERT(false);
0337 
0338     CPPUNIT_ASSERT(iterFirst.firstEventEntryThisRun() == IndexIntoFile::invalidEntry);
0339     CPPUNIT_ASSERT(iterFirst.firstEventEntryThisLumi() == IndexIntoFile::invalidEntry);
0340   }
0341   CPPUNIT_ASSERT(i == 4);
0342 
0343   // Now repeat the above tests for the sorted iteration
0344 
0345   edm::IndexIntoFile::IndexIntoFileItr iterNum = indexIntoFile.begin(IndexIntoFile::numericalOrder);
0346   edm::IndexIntoFile::IndexIntoFileItr iterNumEnd = indexIntoFile.end(IndexIntoFile::numericalOrder);
0347   i = 0;
0348   for (; iterNum != iterNumEnd; ++iterNum, ++i) {
0349     if (i == 0)
0350       check(iterNum, kRun, 0, -1, -1, 0, 0);
0351     else if (i == 1)
0352       check(iterNum, kRun, 1, -1, -1, 0, 0);
0353     else if (i == 2)
0354       check(iterNum, kRun, 2, -1, -1, 0, 0);
0355     else if (i == 3)
0356       check(iterNum, kRun, 3, -1, -1, 0, 0);
0357     else
0358       CPPUNIT_ASSERT(false);
0359 
0360     CPPUNIT_ASSERT(iterNum.firstEventEntryThisRun() == IndexIntoFile::invalidEntry);
0361     CPPUNIT_ASSERT(iterNum.firstEventEntryThisLumi() == IndexIntoFile::invalidEntry);
0362   }
0363   CPPUNIT_ASSERT(i == 4);
0364 
0365   // Now repeat the above tests for the entry iteration
0366 
0367   edm::IndexIntoFile::IndexIntoFileItr iterEntry = indexIntoFile.begin(IndexIntoFile::entryOrder);
0368   edm::IndexIntoFile::IndexIntoFileItr iterEntryEnd = indexIntoFile.end(IndexIntoFile::entryOrder);
0369   i = 0;
0370   for (; iterEntry != iterEntryEnd; ++iterEntry, ++i) {
0371     if (i == 0)
0372       check(iterEntry, kRun, 0, -1, -1, 0, 0);
0373     else if (i == 1)
0374       check(iterEntry, kRun, 1, -1, -1, 0, 0);
0375     else if (i == 2)
0376       check(iterEntry, kRun, 2, -1, -1, 0, 0);
0377     else if (i == 3)
0378       check(iterEntry, kRun, 3, -1, -1, 0, 0);
0379     else
0380       CPPUNIT_ASSERT(false);
0381 
0382     CPPUNIT_ASSERT(iterEntry.firstEventEntryThisRun() == IndexIntoFile::invalidEntry);
0383     CPPUNIT_ASSERT(iterEntry.firstEventEntryThisLumi() == IndexIntoFile::invalidEntry);
0384   }
0385   CPPUNIT_ASSERT(i == 4);
0386 
0387   iterFirst = indexIntoFile.begin(IndexIntoFile::firstAppearanceOrder);
0388 
0389   skipEventForward(iterFirst);
0390   checkSkipped(-1, 0, 0, -1);
0391   check(iterFirst, kEnd, -1, -1, -1, 0, 0);
0392 
0393   iterFirst = indexIntoFile.begin(IndexIntoFile::firstAppearanceOrder);
0394   iterFirst.advanceToNextLumiOrRun();
0395   check(iterFirst, kRun, 2, -1, -1, 0, 0);
0396   ++iterFirst;
0397   check(iterFirst, kRun, 3, -1, -1, 0, 0);
0398   iterFirst.advanceToNextLumiOrRun();
0399   check(iterFirst, kEnd, -1, -1, -1, 0, 0);
0400 
0401   iterNum = indexIntoFile.begin(IndexIntoFile::numericalOrder);
0402 
0403   skipEventForward(iterNum);
0404   checkSkipped(-1, 0, 0, -1);
0405   check(iterNum, kEnd, -1, -1, -1, 0, 0);
0406 
0407   iterNum = indexIntoFile.begin(IndexIntoFile::numericalOrder);
0408   iterNum.advanceToNextLumiOrRun();
0409   check(iterNum, kRun, 2, -1, -1, 0, 0);
0410   ++iterNum;
0411   check(iterNum, kRun, 3, -1, -1, 0, 0);
0412   iterNum.advanceToNextLumiOrRun();
0413   check(iterNum, kEnd, -1, -1, -1, 0, 0);
0414 
0415   iterEntry = indexIntoFile.begin(IndexIntoFile::entryOrder);
0416 
0417   skipEventForward(iterEntry);
0418   checkSkipped(-1, 0, 0, -1);
0419   check(iterEntry, kEnd, -1, -1, -1, 0, 0);
0420 
0421   iterEntry = indexIntoFile.begin(IndexIntoFile::entryOrder);
0422   iterEntry.advanceToNextLumiOrRun();
0423   check(iterEntry, kRun, 2, -1, -1, 0, 0);
0424   ++iterEntry;
0425   check(iterEntry, kRun, 3, -1, -1, 0, 0);
0426   iterEntry.advanceToNextLumiOrRun();
0427   check(iterEntry, kEnd, -1, -1, -1, 0, 0);
0428 }
0429 
0430 void TestIndexIntoFile::testIterLastLumiRangeNoEvents() {
0431   edm::IndexIntoFile indexIntoFile;
0432   indexIntoFile.addEntry(fakePHID1, 1, 101, 5, 0);  // Event
0433   indexIntoFile.addEntry(fakePHID1, 1, 101, 0, 0);  // Lumi
0434   indexIntoFile.addEntry(fakePHID1, 1, 101, 0, 1);  // Lumi
0435   indexIntoFile.addEntry(fakePHID1, 1, 102, 6, 1);  // Event
0436   indexIntoFile.addEntry(fakePHID1, 1, 102, 0, 2);  // Lumi
0437   indexIntoFile.addEntry(fakePHID1, 1, 102, 0, 3);  // Lumi
0438   indexIntoFile.addEntry(fakePHID1, 1, 0, 0, 0);    // Run
0439   indexIntoFile.addEntry(fakePHID1, 2, 101, 7, 2);  // Event
0440   indexIntoFile.addEntry(fakePHID1, 2, 101, 0, 4);  // Lumi
0441   indexIntoFile.addEntry(fakePHID1, 2, 101, 0, 5);  // Lumi
0442   indexIntoFile.addEntry(fakePHID1, 2, 0, 0, 1);    // Run
0443   indexIntoFile.sortVector_Run_Or_Lumi_Entries();
0444 
0445   edm::IndexIntoFile::IndexIntoFileItr iterFirst = indexIntoFile.begin(IndexIntoFile::firstAppearanceOrder);
0446   edm::IndexIntoFile::IndexIntoFileItr iterFirstEnd = indexIntoFile.end(IndexIntoFile::firstAppearanceOrder);
0447   int i = 0;
0448   for (i = 0; iterFirst != iterFirstEnd; ++iterFirst, ++i) {
0449     if (i == 0)
0450       check(iterFirst, kRun, 0, 1, 1, 0, 1);
0451     else if (i == 1)
0452       check(iterFirst, kLumi, 0, 1, 1, 0, 1);
0453     else if (i == 2)
0454       check(iterFirst, kLumi, 0, 2, 1, 0, 1);
0455     else if (i == 3)
0456       check(iterFirst, kEvent, 0, 2, 1, 0, 1);
0457     else if (i == 4)
0458       check(iterFirst, kLumi, 0, 3, 3, 0, 1);
0459     else if (i == 5)
0460       check(iterFirst, kLumi, 0, 4, 3, 0, 1);
0461     else if (i == 6)
0462       check(iterFirst, kEvent, 0, 4, 3, 0, 1);
0463     else if (i == 7)
0464       check(iterFirst, kRun, 5, 6, 6, 0, 1);
0465     else if (i == 8)
0466       check(iterFirst, kLumi, 5, 6, 6, 0, 1);
0467     else if (i == 9)
0468       check(iterFirst, kLumi, 5, 7, 6, 0, 1);
0469     else if (i == 10)
0470       check(iterFirst, kEvent, 5, 7, 6, 0, 1);
0471     else
0472       CPPUNIT_ASSERT(false);
0473   }
0474   CPPUNIT_ASSERT(i == 11);
0475 
0476   std::vector<IndexIntoFile::EventEntry>& eventEntries = indexIntoFile.eventEntries();
0477   eventEntries.emplace_back(5, 0);
0478   eventEntries.emplace_back(6, 1);
0479   eventEntries.emplace_back(7, 2);
0480   indexIntoFile.sortEventEntries();
0481 
0482   edm::IndexIntoFile::IndexIntoFileItr iterNum = indexIntoFile.begin(IndexIntoFile::numericalOrder);
0483   edm::IndexIntoFile::IndexIntoFileItr iterNumEnd = indexIntoFile.end(IndexIntoFile::numericalOrder);
0484   i = 0;
0485   for (; iterNum != iterNumEnd; ++iterNum, ++i) {
0486     if (i == 0)
0487       check(iterNum, kRun, 0, 1, 1, 0, 1);
0488     else if (i == 1)
0489       check(iterNum, kLumi, 0, 1, 1, 0, 1);
0490     else if (i == 2)
0491       check(iterNum, kLumi, 0, 2, 1, 0, 1);
0492     else if (i == 3)
0493       check(iterNum, kEvent, 0, 2, 1, 0, 1);
0494     else if (i == 4)
0495       check(iterNum, kLumi, 0, 3, 3, 0, 1);
0496     else if (i == 5)
0497       check(iterNum, kLumi, 0, 4, 3, 0, 1);
0498     else if (i == 6)
0499       check(iterNum, kEvent, 0, 4, 3, 0, 1);
0500     else if (i == 7)
0501       check(iterNum, kRun, 5, 6, 6, 0, 1);
0502     else if (i == 8)
0503       check(iterNum, kLumi, 5, 6, 6, 0, 1);
0504     else if (i == 9)
0505       check(iterNum, kLumi, 5, 7, 6, 0, 1);
0506     else if (i == 10)
0507       check(iterNum, kEvent, 5, 7, 6, 0, 1);
0508     else
0509       CPPUNIT_ASSERT(false);
0510   }
0511   CPPUNIT_ASSERT(i == 11);
0512 
0513   edm::IndexIntoFile::IndexIntoFileItr iterEntry = indexIntoFile.begin(IndexIntoFile::entryOrder);
0514   edm::IndexIntoFile::IndexIntoFileItr iterEntryEnd = indexIntoFile.end(IndexIntoFile::entryOrder);
0515   i = 0;
0516   for (; iterEntry != iterEntryEnd; ++iterEntry, ++i) {
0517     if (i == 0)
0518       check(iterEntry, kRun, 0, 1, 1, 0, 1);
0519     else if (i == 1)
0520       check(iterEntry, kLumi, 0, 1, 1, 0, 1);
0521     else if (i == 2)
0522       check(iterEntry, kLumi, 0, 2, 1, 0, 1);
0523     else if (i == 3)
0524       check(iterEntry, kEvent, 0, 2, 1, 0, 1);
0525     else if (i == 4)
0526       check(iterEntry, kLumi, 0, 3, 3, 0, 1);
0527     else if (i == 5)
0528       check(iterEntry, kLumi, 0, 4, 3, 0, 1);
0529     else if (i == 6)
0530       check(iterEntry, kEvent, 0, 4, 3, 0, 1);
0531     else if (i == 7)
0532       check(iterEntry, kRun, 5, 6, 6, 0, 1);
0533     else if (i == 8)
0534       check(iterEntry, kLumi, 5, 6, 6, 0, 1);
0535     else if (i == 9)
0536       check(iterEntry, kLumi, 5, 7, 6, 0, 1);
0537     else if (i == 10)
0538       check(iterEntry, kEvent, 5, 7, 6, 0, 1);
0539     else
0540       CPPUNIT_ASSERT(false);
0541   }
0542   CPPUNIT_ASSERT(i == 11);
0543 
0544   skipEventBackward(iterEntry);
0545   checkSkipped(0, 2, 101, 2);
0546 }
0547 
0548 void TestIndexIntoFile::testSkip() {
0549   edm::IndexIntoFile indexIntoFile;
0550   indexIntoFile.addEntry(fakePHID1, 1, 101, 1001, 0);  // Event
0551   indexIntoFile.addEntry(fakePHID1, 1, 101, 0, 0);     // Lumi
0552   indexIntoFile.addEntry(fakePHID1, 1, 101, 0, 1);     // Lumi
0553   indexIntoFile.addEntry(fakePHID1, 1, 102, 0, 2);     // Lumi
0554   indexIntoFile.addEntry(fakePHID1, 1, 0, 0, 0);       // Run
0555   indexIntoFile.sortVector_Run_Or_Lumi_Entries();
0556 
0557   edm::IndexIntoFile::IndexIntoFileItr iterFirst = indexIntoFile.begin(IndexIntoFile::firstAppearanceOrder);
0558 
0559   skipEventForward(iterFirst);
0560   checkSkipped(0, 1, 101, 0);
0561   check(iterFirst, kRun, 0, 3, -1, 0, 0);
0562 
0563   skipEventForward(iterFirst);
0564   checkSkipped(-1, 0, 0, -1);
0565   check(iterFirst, kEnd, -1, -1, -1, 0, 0);
0566 
0567   skipEventBackward(iterFirst);
0568   checkSkipped(0, 1, 101, 0);
0569   check(iterFirst, kRun, 0, 1, 1, 0, 1);
0570 
0571   skipEventBackward(iterFirst);
0572   checkSkipped(-1, 0, 0, -1);
0573   check(iterFirst, kRun, 0, 1, 1, 0, 1);
0574 
0575   iterFirst = indexIntoFile.begin(IndexIntoFile::firstAppearanceOrder);
0576   ++iterFirst;
0577   skipEventForward(iterFirst);
0578   checkSkipped(0, 1, 101, 0);
0579   check(iterFirst, kLumi, 0, 3, -1, 0, 0);
0580 
0581   skipEventForward(iterFirst);
0582   checkSkipped(-1, 0, 0, -1);
0583   check(iterFirst, kEnd, -1, -1, -1, 0, 0);
0584 
0585   std::vector<IndexIntoFile::EventEntry>& eventEntries = indexIntoFile.eventEntries();
0586   eventEntries.emplace_back(1001, 0);
0587   indexIntoFile.sortEventEntries();
0588 
0589   edm::IndexIntoFile::IndexIntoFileItr iterNum = indexIntoFile.begin(IndexIntoFile::numericalOrder);
0590 
0591   skipEventForward(iterNum);
0592   checkSkipped(0, 1, 101, 0);
0593   check(iterNum, kRun, 0, 3, -1, 0, 0);
0594 
0595   skipEventForward(iterNum);
0596   checkSkipped(-1, 0, 0, -1);
0597   check(iterNum, kEnd, -1, -1, -1, 0, 0);
0598 
0599   skipEventBackward(iterNum);
0600   checkSkipped(0, 1, 101, 0);
0601   check(iterNum, kRun, 0, 1, 1, 0, 1);
0602 
0603   skipEventBackward(iterNum);
0604   checkSkipped(-1, 0, 0, -1);
0605   check(iterNum, kRun, 0, 1, 1, 0, 1);
0606 
0607   iterNum = indexIntoFile.begin(IndexIntoFile::numericalOrder);
0608   ++iterNum;
0609   skipEventForward(iterNum);
0610   checkSkipped(0, 1, 101, 0);
0611   check(iterNum, kLumi, 0, 3, -1, 0, 0);
0612 
0613   skipEventForward(iterNum);
0614   checkSkipped(-1, 0, 0, -1);
0615   check(iterNum, kEnd, -1, -1, -1, 0, 0);
0616   {
0617     edm::IndexIntoFile::IndexIntoFileItr iterEntry = indexIntoFile.begin(IndexIntoFile::entryOrder);
0618 
0619     skipEventForward(iterEntry);
0620     checkSkipped(0, 1, 101, 0);
0621     check(iterEntry, kRun, 0, 3, -1, 0, 0);
0622 
0623     skipEventForward(iterEntry);
0624     checkSkipped(-1, 0, 0, -1);
0625     check(iterEntry, kEnd, -1, -1, -1, 0, 0);
0626 
0627     skipEventBackward(iterEntry);
0628     checkSkipped(0, 1, 101, 0);
0629     check(iterEntry, kRun, 0, 1, 1, 0, 1);
0630 
0631     skipEventBackward(iterEntry);
0632     checkSkipped(-1, 0, 0, -1);
0633     check(iterEntry, kRun, 0, 1, 1, 0, 1);
0634 
0635     iterEntry = indexIntoFile.begin(IndexIntoFile::entryOrder);
0636     ++iterEntry;
0637     skipEventForward(iterEntry);
0638     checkSkipped(0, 1, 101, 0);
0639     check(iterEntry, kLumi, 0, 3, -1, 0, 0);
0640 
0641     skipEventForward(iterEntry);
0642     checkSkipped(-1, 0, 0, -1);
0643     check(iterEntry, kEnd, -1, -1, -1, 0, 0);
0644   }
0645 }
0646 
0647 void TestIndexIntoFile::testSkip2() {
0648   edm::IndexIntoFile indexIntoFile;
0649   indexIntoFile.addEntry(fakePHID1, 1, 101, 1001, 0);  // Event
0650   indexIntoFile.addEntry(fakePHID1, 1, 101, 0, 0);     // Lumi
0651   indexIntoFile.addEntry(fakePHID1, 1, 101, 0, 1);     // Lumi
0652   indexIntoFile.addEntry(fakePHID1, 1, 102, 0, 2);     // Lumi
0653   indexIntoFile.addEntry(fakePHID1, 1, 0, 0, 0);       // Run
0654   indexIntoFile.addEntry(fakePHID1, 2, 101, 1001, 1);  // Event
0655   indexIntoFile.addEntry(fakePHID1, 2, 101, 0, 3);     // Lumi
0656   indexIntoFile.addEntry(fakePHID1, 2, 101, 0, 4);     // Lumi
0657   indexIntoFile.addEntry(fakePHID1, 2, 102, 0, 5);     // Lumi
0658   indexIntoFile.addEntry(fakePHID1, 2, 0, 0, 1);       // Run
0659   indexIntoFile.sortVector_Run_Or_Lumi_Entries();
0660 
0661   edm::IndexIntoFile::IndexIntoFileItr iterFirst = indexIntoFile.begin(IndexIntoFile::firstAppearanceOrder);
0662 
0663   skipEventForward(iterFirst);
0664   checkSkipped(0, 1, 101, 0);
0665   check(iterFirst, kRun, 0, 3, -1, 0, 0);
0666 
0667   skipEventForward(iterFirst);
0668   checkSkipped(0, 2, 101, 1);
0669   check(iterFirst, kRun, 4, 7, -1, 0, 0);
0670 
0671   skipEventForward(iterFirst);
0672   checkSkipped(-1, 0, 0, -1);
0673   check(iterFirst, kEnd, -1, -1, -1, 0, 0);
0674 
0675   skipEventBackward(iterFirst);
0676   checkSkipped(0, 2, 101, 1);
0677   check(iterFirst, kRun, 4, 5, 5, 0, 1);
0678 
0679   skipEventBackward(iterFirst);
0680   checkSkipped(0, 1, 101, 0);
0681   check(iterFirst, kRun, 0, 1, 1, 0, 1);
0682 
0683   iterFirst = indexIntoFile.begin(IndexIntoFile::firstAppearanceOrder);
0684   ++iterFirst;
0685   skipEventForward(iterFirst);
0686   checkSkipped(0, 1, 101, 0);
0687   check(iterFirst, kLumi, 0, 3, -1, 0, 0);
0688 
0689   skipEventForward(iterFirst);
0690   checkSkipped(0, 2, 101, 1);
0691   check(iterFirst, kRun, 4, 7, -1, 0, 0);
0692 
0693   std::vector<IndexIntoFile::EventEntry>& eventEntries = indexIntoFile.eventEntries();
0694   eventEntries.emplace_back(1001, 0);
0695   eventEntries.emplace_back(1001, 1);
0696   indexIntoFile.sortEventEntries();
0697 
0698   edm::IndexIntoFile::IndexIntoFileItr iterNum = indexIntoFile.begin(IndexIntoFile::numericalOrder);
0699 
0700   skipEventForward(iterNum);
0701   checkSkipped(0, 1, 101, 0);
0702   check(iterNum, kRun, 0, 3, -1, 0, 0);
0703 
0704   skipEventForward(iterNum);
0705   checkSkipped(0, 2, 101, 1);
0706   check(iterNum, kRun, 4, 7, -1, 0, 0);
0707 
0708   skipEventForward(iterNum);
0709   checkSkipped(-1, 0, 0, -1);
0710   check(iterNum, kEnd, -1, -1, -1, 0, 0);
0711 
0712   skipEventBackward(iterNum);
0713   checkSkipped(0, 2, 101, 1);
0714   check(iterNum, kRun, 4, 5, 5, 0, 1);
0715 
0716   skipEventBackward(iterNum);
0717   checkSkipped(0, 1, 101, 0);
0718   check(iterNum, kRun, 0, 1, 1, 0, 1);
0719 
0720   iterNum = indexIntoFile.begin(IndexIntoFile::numericalOrder);
0721   ++iterNum;
0722   skipEventForward(iterNum);
0723   checkSkipped(0, 1, 101, 0);
0724   check(iterNum, kLumi, 0, 3, -1, 0, 0);
0725 
0726   skipEventForward(iterNum);
0727   checkSkipped(0, 2, 101, 1);
0728   check(iterNum, kRun, 4, 7, -1, 0, 0);
0729 
0730   {
0731     edm::IndexIntoFile::IndexIntoFileItr iterEntry = indexIntoFile.begin(IndexIntoFile::entryOrder);
0732 
0733     skipEventForward(iterEntry);
0734     checkSkipped(0, 1, 101, 0);
0735     check(iterEntry, kRun, 0, 3, -1, 0, 0);
0736 
0737     skipEventForward(iterEntry);
0738     checkSkipped(0, 2, 101, 1);
0739     check(iterEntry, kRun, 4, 7, -1, 0, 0);
0740 
0741     skipEventForward(iterEntry);
0742     checkSkipped(-1, 0, 0, -1);
0743     check(iterEntry, kEnd, -1, -1, -1, 0, 0);
0744 
0745     skipEventBackward(iterEntry);
0746     checkSkipped(0, 2, 101, 1);
0747     check(iterEntry, kRun, 4, 5, 5, 0, 1);
0748 
0749     skipEventBackward(iterEntry);
0750     checkSkipped(0, 1, 101, 0);
0751     check(iterEntry, kRun, 0, 1, 1, 0, 1);
0752 
0753     iterEntry = indexIntoFile.begin(IndexIntoFile::entryOrder);
0754     ++iterEntry;
0755     skipEventForward(iterEntry);
0756     checkSkipped(0, 1, 101, 0);
0757     check(iterEntry, kLumi, 0, 3, -1, 0, 0);
0758 
0759     skipEventForward(iterEntry);
0760     checkSkipped(0, 2, 101, 1);
0761     check(iterEntry, kRun, 4, 7, -1, 0, 0);
0762   }
0763 }
0764 
0765 void TestIndexIntoFile::testSkip3() {
0766   edm::IndexIntoFile indexIntoFile;
0767   indexIntoFile.addEntry(fakePHID1, 1, 1, 0, 0);       // Lumi
0768   indexIntoFile.addEntry(fakePHID1, 1, 0, 0, 0);       // Run
0769   indexIntoFile.addEntry(fakePHID1, 2, 101, 0, 1);     // Lumi
0770   indexIntoFile.addEntry(fakePHID1, 2, 101, 0, 2);     // Lumi
0771   indexIntoFile.addEntry(fakePHID1, 2, 102, 1001, 0);  // Event
0772   indexIntoFile.addEntry(fakePHID1, 2, 102, 0, 3);     // Lumi
0773   indexIntoFile.addEntry(fakePHID1, 2, 103, 0, 4);     // Lumi
0774   indexIntoFile.addEntry(fakePHID1, 2, 0, 0, 1);       // Run
0775   indexIntoFile.sortVector_Run_Or_Lumi_Entries();
0776 
0777   edm::IndexIntoFile::IndexIntoFileItr iterFirst = indexIntoFile.begin(IndexIntoFile::firstAppearanceOrder);
0778 
0779   skipEventForward(iterFirst);
0780   checkSkipped(0, 2, 102, 0);
0781   check(iterFirst, kRun, 2, 6, -1, 0, 0);
0782 
0783   std::vector<IndexIntoFile::EventEntry>& eventEntries = indexIntoFile.eventEntries();
0784   eventEntries.emplace_back(1001, 0);
0785   indexIntoFile.sortEventEntries();
0786 
0787   edm::IndexIntoFile::IndexIntoFileItr iterNum = indexIntoFile.begin(IndexIntoFile::numericalOrder);
0788 
0789   skipEventForward(iterNum);
0790   checkSkipped(0, 2, 102, 0);
0791   check(iterNum, kRun, 2, 6, -1, 0, 0);
0792 
0793   {
0794     edm::IndexIntoFile::IndexIntoFileItr iterEntry = indexIntoFile.begin(IndexIntoFile::entryOrder);
0795 
0796     skipEventForward(iterEntry);
0797     checkSkipped(0, 2, 102, 0);
0798     check(iterEntry, kRun, 2, 6, -1, 0, 0);
0799   }
0800 }
0801 
0802 void TestIndexIntoFile::testEndWithRun() {
0803   edm::IndexIntoFile indexIntoFile;
0804   indexIntoFile.addEntry(fakePHID1, 1, 0, 0, 0);  // Run
0805 
0806   indexIntoFile.sortVector_Run_Or_Lumi_Entries();
0807 
0808   edm::IndexIntoFile::IndexIntoFileItr iterFirst = indexIntoFile.begin(IndexIntoFile::firstAppearanceOrder);
0809   check(iterFirst, kRun, 0, -1, -1, 0, 0);
0810   ++iterFirst;
0811   check(iterFirst, kEnd, -1, -1, -1, 0, 0);
0812 
0813   edm::IndexIntoFile::IndexIntoFileItr iterNum = indexIntoFile.begin(IndexIntoFile::numericalOrder);
0814   check(iterNum, kRun, 0, -1, -1, 0, 0);
0815   ++iterNum;
0816   check(iterNum, kEnd, -1, -1, -1, 0, 0);
0817 
0818   {
0819     edm::IndexIntoFile::IndexIntoFileItr iterEntry = indexIntoFile.begin(IndexIntoFile::entryOrder);
0820     check(iterEntry, kRun, 0, -1, -1, 0, 0);
0821     ++iterEntry;
0822     check(iterEntry, kEnd, -1, -1, -1, 0, 0);
0823   }
0824 }
0825 
0826 void TestIndexIntoFile::testReduce() {
0827   // This test is implemented in FWCore/Integration/test/ProcessHistory_t.cpp
0828   // because of dependency issues.
0829 }
0830 
0831 void TestIndexIntoFile::testRunsNoEvents() {
0832   edm::IndexIntoFile indexIntoFile;
0833   indexIntoFile.addEntry(fakePHID1, 8, 1, 0, 0);  // Lumi
0834   indexIntoFile.addEntry(fakePHID1, 5, 1, 0, 1);  // Lumi
0835   indexIntoFile.addEntry(fakePHID1, 1, 1, 0, 2);  // Lumi
0836   indexIntoFile.addEntry(fakePHID1, 3, 1, 1, 0);  // Event
0837   indexIntoFile.addEntry(fakePHID1, 3, 1, 0, 3);  // Lumi
0838 
0839   indexIntoFile.addEntry(fakePHID1, 4, 1, 1, 1);   // Event
0840   indexIntoFile.addEntry(fakePHID1, 4, 1, 0, 4);   // Lumi
0841   indexIntoFile.addEntry(fakePHID1, 7, 1, 0, 5);   // Lumi
0842   indexIntoFile.addEntry(fakePHID1, 7, 2, 0, 6);   // Lumi
0843   indexIntoFile.addEntry(fakePHID1, 7, 3, 1, 2);   // Event
0844   indexIntoFile.addEntry(fakePHID1, 7, 3, 0, 7);   // Lumi
0845   indexIntoFile.addEntry(fakePHID1, 7, 4, 0, 8);   // Lumi
0846   indexIntoFile.addEntry(fakePHID1, 7, 5, 0, 9);   // Lumi
0847   indexIntoFile.addEntry(fakePHID1, 7, 6, 1, 3);   // Event
0848   indexIntoFile.addEntry(fakePHID1, 7, 6, 0, 10);  // Lumi
0849   indexIntoFile.addEntry(fakePHID1, 7, 7, 1, 4);   // Event
0850   indexIntoFile.addEntry(fakePHID1, 7, 7, 0, 11);  // Lumi
0851   indexIntoFile.addEntry(fakePHID1, 7, 8, 0, 12);  // Lumi
0852   indexIntoFile.addEntry(fakePHID1, 7, 9, 0, 13);  // Lumi
0853 
0854   indexIntoFile.addEntry(fakePHID1, 1, 0, 0, 0);  // Run
0855   indexIntoFile.addEntry(fakePHID1, 2, 0, 0, 1);  // Run
0856   indexIntoFile.addEntry(fakePHID1, 3, 0, 0, 2);  // Run
0857   indexIntoFile.addEntry(fakePHID1, 4, 0, 0, 3);  // Run
0858   indexIntoFile.addEntry(fakePHID1, 5, 0, 0, 4);  // Run
0859   indexIntoFile.addEntry(fakePHID1, 6, 0, 0, 5);  // Run
0860   indexIntoFile.addEntry(fakePHID1, 7, 0, 0, 6);  // Run
0861   indexIntoFile.addEntry(fakePHID1, 8, 0, 0, 7);  // Run
0862   indexIntoFile.addEntry(fakePHID1, 9, 0, 0, 8);  // Run
0863 
0864   indexIntoFile.addEntry(fakePHID1, 8, 0, 0, 9);   // Run
0865   indexIntoFile.addEntry(fakePHID1, 5, 0, 0, 10);  // Run
0866   indexIntoFile.addEntry(fakePHID1, 4, 0, 0, 11);  // Run
0867   indexIntoFile.addEntry(fakePHID1, 4, 0, 0, 12);  // Run
0868   indexIntoFile.addEntry(fakePHID1, 4, 0, 0, 13);  // Run
0869   indexIntoFile.addEntry(fakePHID1, 2, 0, 0, 14);  // Run
0870   indexIntoFile.addEntry(fakePHID1, 2, 0, 0, 15);  // Run
0871 
0872   indexIntoFile.sortVector_Run_Or_Lumi_Entries();
0873 
0874   edm::IndexIntoFile::IndexIntoFileItr iterEntry = indexIntoFile.begin(IndexIntoFile::entryOrder);
0875   edm::IndexIntoFile::IndexIntoFileItr iterEntryEnd = indexIntoFile.end(IndexIntoFile::entryOrder);
0876   int i = 0;
0877   for (; iterEntry != iterEntryEnd; ++iterEntry, ++i) {
0878     if (i == 0) {
0879       check(iterEntry, kRun, 0, 1, -1, 0, 0);
0880       CPPUNIT_ASSERT(iterEntry.run() == 1 && iterEntry.lumi() == IndexIntoFile::invalidLumi);
0881       CPPUNIT_ASSERT(iterEntry.shouldProcessRun());
0882     } else if (i == 1) {
0883       check(iterEntry, kLumi, 0, 1, -1, 0, 0);
0884       CPPUNIT_ASSERT(iterEntry.run() == 1 && iterEntry.lumi() == 1);
0885     } else if (i == 2) {
0886       check(iterEntry, kRun, 2, -1, -1, 0, 0);
0887       CPPUNIT_ASSERT(iterEntry.run() == 2 && iterEntry.lumi() == IndexIntoFile::invalidLumi);
0888     } else if (i == 3) {
0889       check(iterEntry, kRun, 3, -1, -1, 0, 0);
0890       CPPUNIT_ASSERT(iterEntry.run() == 2 && iterEntry.lumi() == IndexIntoFile::invalidLumi);
0891     } else if (i == 4) {
0892       check(iterEntry, kRun, 4, -1, -1, 0, 0);
0893       CPPUNIT_ASSERT(iterEntry.run() == 2 && iterEntry.lumi() == IndexIntoFile::invalidLumi);
0894     } else if (i == 5) {
0895       check(iterEntry, kRun, 5, 6, 6, 0, 1);
0896       CPPUNIT_ASSERT(iterEntry.run() == 3 && iterEntry.lumi() == IndexIntoFile::invalidLumi);
0897     } else if (i == 6) {
0898       check(iterEntry, kLumi, 5, 6, 6, 0, 1);
0899       CPPUNIT_ASSERT(iterEntry.run() == 3 && iterEntry.lumi() == 1);
0900     } else if (i == 7) {
0901       check(iterEntry, kEvent, 5, 6, 6, 0, 1);
0902       CPPUNIT_ASSERT(iterEntry.run() == 3 && iterEntry.lumi() == 1);
0903     } else if (i == 8) {
0904       check(iterEntry, kRun, 7, 11, 11, 0, 1);
0905       CPPUNIT_ASSERT(iterEntry.run() == 4 && iterEntry.lumi() == IndexIntoFile::invalidLumi);
0906     } else if (i == 9) {
0907       check(iterEntry, kRun, 8, 11, 11, 0, 1);
0908       CPPUNIT_ASSERT(iterEntry.run() == 4 && iterEntry.lumi() == IndexIntoFile::invalidLumi);
0909     } else if (i == 10) {
0910       check(iterEntry, kRun, 9, 11, 11, 0, 1);
0911       CPPUNIT_ASSERT(iterEntry.run() == 4 && iterEntry.lumi() == IndexIntoFile::invalidLumi);
0912     } else if (i == 11) {
0913       check(iterEntry, kRun, 10, 11, 11, 0, 1);
0914       CPPUNIT_ASSERT(iterEntry.run() == 4 && iterEntry.lumi() == IndexIntoFile::invalidLumi);
0915     } else if (i == 12) {
0916       check(iterEntry, kLumi, 10, 11, 11, 0, 1);
0917       CPPUNIT_ASSERT(iterEntry.run() == 4 && iterEntry.lumi() == 1);
0918     } else if (i == 13) {
0919       check(iterEntry, kEvent, 10, 11, 11, 0, 1);
0920       CPPUNIT_ASSERT(iterEntry.run() == 4 && iterEntry.lumi() == 1);
0921     } else if (i == 14) {
0922       check(iterEntry, kRun, 12, 14, -1, 0, 0);
0923       CPPUNIT_ASSERT(iterEntry.run() == 5 && iterEntry.lumi() == IndexIntoFile::invalidLumi);
0924     } else if (i == 15) {
0925       check(iterEntry, kRun, 13, 14, -1, 0, 0);
0926       CPPUNIT_ASSERT(iterEntry.run() == 5 && iterEntry.lumi() == IndexIntoFile::invalidLumi);
0927     } else if (i == 16) {
0928       check(iterEntry, kLumi, 13, 14, -1, 0, 0);
0929       CPPUNIT_ASSERT(iterEntry.run() == 5 && iterEntry.lumi() == 1);
0930     } else if (i == 17) {
0931       check(iterEntry, kRun, 15, -1, -1, 0, 0);
0932       CPPUNIT_ASSERT(iterEntry.run() == 6 && iterEntry.lumi() == IndexIntoFile::invalidLumi);
0933     } else if (i == 18) {
0934       check(iterEntry, kRun, 16, 17, -1, 0, 0);
0935       CPPUNIT_ASSERT(iterEntry.run() == 7 && iterEntry.lumi() == IndexIntoFile::invalidLumi);
0936     } else if (i == 19) {
0937       check(iterEntry, kLumi, 16, 17, -1, 0, 0);
0938       CPPUNIT_ASSERT(iterEntry.run() == 7 && iterEntry.lumi() == 1);
0939     } else if (i == 20) {
0940       check(iterEntry, kLumi, 16, 18, -1, 0, 0);
0941       CPPUNIT_ASSERT(iterEntry.run() == 7 && iterEntry.lumi() == 2);
0942     } else if (i == 21) {
0943       check(iterEntry, kLumi, 16, 19, 19, 0, 1);
0944       CPPUNIT_ASSERT(iterEntry.run() == 7 && iterEntry.lumi() == 3);
0945     } else if (i == 22) {
0946       check(iterEntry, kEvent, 16, 19, 19, 0, 1);
0947       CPPUNIT_ASSERT(iterEntry.run() == 7 && iterEntry.lumi() == 3);
0948     } else if (i == 23) {
0949       check(iterEntry, kLumi, 16, 20, -1, 0, 0);
0950       CPPUNIT_ASSERT(iterEntry.run() == 7 && iterEntry.lumi() == 4);
0951     } else if (i == 24) {
0952       check(iterEntry, kLumi, 16, 21, -1, 0, 0);
0953       CPPUNIT_ASSERT(iterEntry.run() == 7 && iterEntry.lumi() == 5);
0954     } else if (i == 25) {
0955       check(iterEntry, kLumi, 16, 22, 22, 0, 1);
0956       CPPUNIT_ASSERT(iterEntry.run() == 7 && iterEntry.lumi() == 6);
0957     } else if (i == 26) {
0958       check(iterEntry, kEvent, 16, 22, 22, 0, 1);
0959       CPPUNIT_ASSERT(iterEntry.run() == 7 && iterEntry.lumi() == 6);
0960     } else if (i == 27) {
0961       check(iterEntry, kLumi, 16, 23, 23, 0, 1);
0962       CPPUNIT_ASSERT(iterEntry.run() == 7 && iterEntry.lumi() == 7);
0963     } else if (i == 28) {
0964       check(iterEntry, kEvent, 16, 23, 23, 0, 1);
0965       CPPUNIT_ASSERT(iterEntry.run() == 7 && iterEntry.lumi() == 7);
0966     } else if (i == 29) {
0967       check(iterEntry, kLumi, 16, 24, -1, 0, 0);
0968       CPPUNIT_ASSERT(iterEntry.run() == 7 && iterEntry.lumi() == 8);
0969     } else if (i == 30) {
0970       check(iterEntry, kLumi, 16, 25, -1, 0, 0);
0971       CPPUNIT_ASSERT(iterEntry.run() == 7 && iterEntry.lumi() == 9);
0972     } else if (i == 31) {
0973       check(iterEntry, kRun, 26, 28, -1, 0, 0);
0974       CPPUNIT_ASSERT(iterEntry.run() == 8 && iterEntry.lumi() == IndexIntoFile::invalidLumi);
0975     } else if (i == 32) {
0976       check(iterEntry, kRun, 27, 28, -1, 0, 0);
0977       CPPUNIT_ASSERT(iterEntry.run() == 8 && iterEntry.lumi() == IndexIntoFile::invalidLumi);
0978     } else if (i == 33) {
0979       check(iterEntry, kLumi, 27, 28, -1, 0, 0);
0980       CPPUNIT_ASSERT(iterEntry.run() == 8 && iterEntry.lumi() == 1);
0981     } else if (i == 34) {
0982       check(iterEntry, kRun, 29, -1, -1, 0, 0);
0983       CPPUNIT_ASSERT(iterEntry.run() == 9 && iterEntry.lumi() == IndexIntoFile::invalidLumi);
0984     } else
0985       CPPUNIT_ASSERT(false);
0986   }
0987   CPPUNIT_ASSERT(i == 35);
0988 }
0989 
0990 void TestIndexIntoFile::testLumisNoEvents() {
0991   edm::IndexIntoFile indexIntoFile;
0992   indexIntoFile.addEntry(fakePHID1, 2, 7, 1, 0);  // Event 2:7:1
0993   indexIntoFile.addEntry(fakePHID1, 2, 8, 1, 1);  // Event 2:8:1
0994 
0995   indexIntoFile.addEntry(fakePHID1, 1, 1, 1, 2);  // Event 1:1:1
0996   indexIntoFile.addEntry(fakePHID1, 1, 1, 0, 0);  // Lumi  1:1
0997   indexIntoFile.addEntry(fakePHID1, 1, 0, 0, 0);  // Run   1
0998 
0999   indexIntoFile.addEntry(fakePHID1, 2, 7, 2, 3);  // Event 2:7:2
1000 
1001   indexIntoFile.addEntry(fakePHID1, 2, 1, 1, 4);  // Event 2:1:1
1002   indexIntoFile.addEntry(fakePHID1, 2, 1, 0, 1);  // Lumi  2:1
1003   indexIntoFile.addEntry(fakePHID1, 2, 2, 0, 2);  // Lumi  2:2
1004   indexIntoFile.addEntry(fakePHID1, 2, 3, 0, 3);  // Lumi  2:3
1005   indexIntoFile.addEntry(fakePHID1, 2, 4, 0, 4);  // Lumi  2:4
1006   indexIntoFile.addEntry(fakePHID1, 2, 5, 1, 5);  // Event 2:5:1
1007   indexIntoFile.addEntry(fakePHID1, 2, 5, 0, 5);  // Lumi  2:5
1008   indexIntoFile.addEntry(fakePHID1, 2, 6, 0, 6);  // Lumi  2:6
1009   indexIntoFile.addEntry(fakePHID1, 2, 7, 3, 6);  // Event 2:7:3
1010   indexIntoFile.addEntry(fakePHID1, 2, 7, 0, 7);  // Lumi  2:7
1011   indexIntoFile.addEntry(fakePHID1, 2, 8, 1, 7);  // Event 2:8:1
1012   indexIntoFile.addEntry(fakePHID1, 2, 8, 0, 8);  // Lumi  2:8
1013   indexIntoFile.addEntry(fakePHID1, 2, 9, 0, 9);  // Lumi  2:9
1014   indexIntoFile.addEntry(fakePHID1, 2, 0, 0, 1);  // Run   2
1015 
1016   indexIntoFile.addEntry(fakePHID1, 3, 1, 1, 8);   // Event 3:1:1
1017   indexIntoFile.addEntry(fakePHID1, 3, 1, 0, 10);  // Lumi  3:1
1018   indexIntoFile.addEntry(fakePHID1, 3, 0, 0, 2);   // Run   3
1019 
1020   indexIntoFile.addEntry(fakePHID1, 2, 4, 1, 9);    // Event 2:4:1
1021   indexIntoFile.addEntry(fakePHID1, 2, 7, 4, 10);   // Event 2:7:4
1022   indexIntoFile.addEntry(fakePHID1, 2, 7, 5, 11);   // Event 2:7:5
1023   indexIntoFile.addEntry(fakePHID1, 2, 7, 0, 11);   // Lumi  2:7
1024   indexIntoFile.addEntry(fakePHID1, 2, 3, 1, 12);   // Event 2:3:1
1025   indexIntoFile.addEntry(fakePHID1, 2, 3, 0, 12);   // Lumi  2:3
1026   indexIntoFile.addEntry(fakePHID1, 2, 4, 2, 13);   // Event 2:4:1
1027   indexIntoFile.addEntry(fakePHID1, 2, 4, 0, 13);   // Lumi  2:4
1028   indexIntoFile.addEntry(fakePHID1, 2, 7, 6, 14);   // Event 2:7:6
1029   indexIntoFile.addEntry(fakePHID1, 2, 7, 0, 14);   // Lumi  2:7
1030   indexIntoFile.addEntry(fakePHID1, 2, 7, 7, 15);   // Event 2:7:7
1031   indexIntoFile.addEntry(fakePHID1, 2, 7, 8, 16);   // Event 2:7:8
1032   indexIntoFile.addEntry(fakePHID1, 2, 3, 0, 15);   // Lumi  2:3
1033   indexIntoFile.addEntry(fakePHID1, 2, 7, 9, 17);   // Event 2:7:9
1034   indexIntoFile.addEntry(fakePHID1, 2, 7, 10, 18);  // Event 2:7:10
1035   indexIntoFile.addEntry(fakePHID1, 2, 7, 0, 16);   // Lumi  2:7
1036   indexIntoFile.addEntry(fakePHID1, 2, 7, 0, 17);   // Lumi  2:7
1037   indexIntoFile.addEntry(fakePHID1, 2, 7, 0, 18);   // Lumi  2:7
1038   indexIntoFile.addEntry(fakePHID1, 2, 0, 0, 3);    // Run   2
1039   indexIntoFile.addEntry(fakePHID1, 2, 0, 0, 4);    // Run   2
1040   indexIntoFile.sortVector_Run_Or_Lumi_Entries();
1041 
1042   edm::IndexIntoFile::IndexIntoFileItr iterEntry = indexIntoFile.begin(IndexIntoFile::entryOrder);
1043   edm::IndexIntoFile::IndexIntoFileItr iterEntryEnd = indexIntoFile.end(IndexIntoFile::entryOrder);
1044   int i = 0;
1045   for (; iterEntry != iterEntryEnd; ++iterEntry, ++i) {
1046     if (i == 0) {
1047       check(iterEntry, kRun, 0, 1, 1, 0, 1);
1048       CPPUNIT_ASSERT(iterEntry.run() == 2 && iterEntry.lumi() == IndexIntoFile::invalidLumi);
1049       CPPUNIT_ASSERT(!iterEntry.shouldProcessRun());
1050       CPPUNIT_ASSERT(iterEntry.entry() == 1);
1051     } else if (i == 1) {
1052       check(iterEntry, kLumi, 0, 1, 1, 0, 1);
1053       CPPUNIT_ASSERT(iterEntry.run() == 2 && iterEntry.lumi() == 7);
1054       CPPUNIT_ASSERT(!iterEntry.shouldProcessLumi());
1055       CPPUNIT_ASSERT(iterEntry.entry() == 7);
1056     } else if (i == 2) {
1057       check(iterEntry, kEvent, 0, 1, 1, 0, 1);
1058       CPPUNIT_ASSERT(iterEntry.run() == 2 && iterEntry.lumi() == 7);
1059       CPPUNIT_ASSERT(iterEntry.entry() == 0);
1060     } else if (i == 3) {
1061       check(iterEntry, kLumi, 0, 2, 2, 0, 1);
1062       CPPUNIT_ASSERT(iterEntry.run() == 2 && iterEntry.lumi() == 8);
1063       CPPUNIT_ASSERT(!iterEntry.shouldProcessLumi());
1064       CPPUNIT_ASSERT(iterEntry.entry() == 8);
1065     } else if (i == 4) {
1066       check(iterEntry, kEvent, 0, 2, 2, 0, 1);
1067       CPPUNIT_ASSERT(iterEntry.run() == 2 && iterEntry.lumi() == 8);
1068       CPPUNIT_ASSERT(iterEntry.entry() == 1);
1069     } else if (i == 5) {
1070       check(iterEntry, kRun, 3, 4, 4, 0, 1);
1071       CPPUNIT_ASSERT(iterEntry.run() == 1 && iterEntry.lumi() == IndexIntoFile::invalidLumi);
1072       CPPUNIT_ASSERT(iterEntry.shouldProcessRun());
1073       CPPUNIT_ASSERT(iterEntry.entry() == 0);
1074     } else if (i == 6) {
1075       check(iterEntry, kLumi, 3, 4, 4, 0, 1);
1076       CPPUNIT_ASSERT(iterEntry.run() == 1 && iterEntry.lumi() == 1);
1077       CPPUNIT_ASSERT(iterEntry.shouldProcessLumi());
1078       CPPUNIT_ASSERT(iterEntry.entry() == 0);
1079     } else if (i == 7) {
1080       check(iterEntry, kEvent, 3, 4, 4, 0, 1);
1081       CPPUNIT_ASSERT(iterEntry.run() == 1 && iterEntry.lumi() == 1);
1082       CPPUNIT_ASSERT(iterEntry.entry() == 2);
1083     } else if (i == 8) {
1084       check(iterEntry, kRun, 5, 6, 6, 0, 1);
1085       CPPUNIT_ASSERT(iterEntry.run() == 2 && iterEntry.lumi() == IndexIntoFile::invalidLumi);
1086       CPPUNIT_ASSERT(!iterEntry.shouldProcessRun());
1087       CPPUNIT_ASSERT(iterEntry.entry() == 1);
1088     } else if (i == 9) {
1089       check(iterEntry, kLumi, 5, 6, 6, 0, 1);
1090       CPPUNIT_ASSERT(iterEntry.run() == 2 && iterEntry.lumi() == 7);
1091       CPPUNIT_ASSERT(!iterEntry.shouldProcessLumi());
1092       CPPUNIT_ASSERT(iterEntry.entry() == 7);
1093     } else if (i == 10) {
1094       check(iterEntry, kEvent, 5, 6, 6, 0, 1);
1095       CPPUNIT_ASSERT(iterEntry.run() == 2 && iterEntry.lumi() == 7);
1096       CPPUNIT_ASSERT(iterEntry.entry() == 3);
1097     } else if (i == 11) {
1098       check(iterEntry, kLumi, 5, 7, 7, 0, 1);
1099       CPPUNIT_ASSERT(iterEntry.run() == 2 && iterEntry.lumi() == 1);
1100       CPPUNIT_ASSERT(!iterEntry.shouldProcessLumi());
1101       CPPUNIT_ASSERT(iterEntry.entry() == 1);
1102     } else if (i == 12) {
1103       check(iterEntry, kEvent, 5, 7, 7, 0, 1);
1104       CPPUNIT_ASSERT(iterEntry.run() == 2 && iterEntry.lumi() == 1);
1105       CPPUNIT_ASSERT(iterEntry.entry() == 4);
1106     } else if (i == 13) {
1107       check(iterEntry, kLumi, 5, 8, 8, 0, 1);
1108       CPPUNIT_ASSERT(iterEntry.run() == 2 && iterEntry.lumi() == 5);
1109       CPPUNIT_ASSERT(!iterEntry.shouldProcessLumi());
1110       CPPUNIT_ASSERT(iterEntry.entry() == 5);
1111     } else if (i == 14) {
1112       check(iterEntry, kEvent, 5, 8, 8, 0, 1);
1113       CPPUNIT_ASSERT(iterEntry.run() == 2 && iterEntry.lumi() == 5);
1114       CPPUNIT_ASSERT(iterEntry.entry() == 5);
1115     } else if (i == 15) {
1116       check(iterEntry, kLumi, 5, 9, 9, 0, 1);
1117       CPPUNIT_ASSERT(iterEntry.run() == 2 && iterEntry.lumi() == 7);
1118       CPPUNIT_ASSERT(!iterEntry.shouldProcessLumi());
1119       CPPUNIT_ASSERT(iterEntry.entry() == 7);
1120     } else if (i == 16) {
1121       check(iterEntry, kEvent, 5, 9, 9, 0, 1);
1122       CPPUNIT_ASSERT(iterEntry.run() == 2 && iterEntry.lumi() == 7);
1123       CPPUNIT_ASSERT(iterEntry.entry() == 6);
1124     } else if (i == 17) {
1125       check(iterEntry, kLumi, 5, 10, 10, 0, 1);
1126       CPPUNIT_ASSERT(iterEntry.run() == 2 && iterEntry.lumi() == 8);
1127       CPPUNIT_ASSERT(!iterEntry.shouldProcessLumi());
1128       CPPUNIT_ASSERT(iterEntry.entry() == 8);
1129     } else if (i == 18) {
1130       check(iterEntry, kEvent, 5, 10, 10, 0, 1);
1131       CPPUNIT_ASSERT(iterEntry.run() == 2 && iterEntry.lumi() == 8);
1132       CPPUNIT_ASSERT(iterEntry.entry() == 7);
1133     } else if (i == 19) {
1134       check(iterEntry, kRun, 11, 12, 12, 0, 1);
1135       CPPUNIT_ASSERT(iterEntry.run() == 3 && iterEntry.lumi() == IndexIntoFile::invalidLumi);
1136       CPPUNIT_ASSERT(iterEntry.shouldProcessRun());
1137       CPPUNIT_ASSERT(iterEntry.entry() == 2);
1138     } else if (i == 20) {
1139       check(iterEntry, kLumi, 11, 12, 12, 0, 1);
1140       CPPUNIT_ASSERT(iterEntry.run() == 3 && iterEntry.lumi() == 1);
1141       CPPUNIT_ASSERT(iterEntry.shouldProcessLumi());
1142       CPPUNIT_ASSERT(iterEntry.entry() == 10);
1143     } else if (i == 21) {
1144       check(iterEntry, kEvent, 11, 12, 12, 0, 1);
1145       CPPUNIT_ASSERT(iterEntry.run() == 3 && iterEntry.lumi() == 1);
1146       CPPUNIT_ASSERT(iterEntry.entry() == 8);
1147     } else if (i == 22) {
1148       check(iterEntry, kRun, 13, 16, 16, 0, 1);
1149       CPPUNIT_ASSERT(iterEntry.run() == 2 && iterEntry.lumi() == IndexIntoFile::invalidLumi);
1150       CPPUNIT_ASSERT(iterEntry.shouldProcessRun());
1151       CPPUNIT_ASSERT(iterEntry.entry() == 1);
1152     } else if (i == 23) {
1153       check(iterEntry, kRun, 14, 16, 16, 0, 1);
1154       CPPUNIT_ASSERT(iterEntry.run() == 2 && iterEntry.lumi() == IndexIntoFile::invalidLumi);
1155       CPPUNIT_ASSERT(iterEntry.shouldProcessRun());
1156       CPPUNIT_ASSERT(iterEntry.entry() == 3);
1157     } else if (i == 24) {
1158       check(iterEntry, kRun, 15, 16, 16, 0, 1);
1159       CPPUNIT_ASSERT(iterEntry.run() == 2 && iterEntry.lumi() == IndexIntoFile::invalidLumi);
1160       CPPUNIT_ASSERT(iterEntry.shouldProcessRun());
1161       CPPUNIT_ASSERT(iterEntry.entry() == 4);
1162     } else if (i == 25) {
1163       check(iterEntry, kLumi, 15, 16, 16, 0, 1);
1164       CPPUNIT_ASSERT(iterEntry.run() == 2 && iterEntry.lumi() == 4);
1165       CPPUNIT_ASSERT(!iterEntry.shouldProcessLumi());
1166       CPPUNIT_ASSERT(iterEntry.entry() == 4);
1167     } else if (i == 26) {
1168       check(iterEntry, kEvent, 15, 16, 16, 0, 1);
1169       CPPUNIT_ASSERT(iterEntry.run() == 2 && iterEntry.lumi() == 4);
1170       CPPUNIT_ASSERT(iterEntry.entry() == 9);
1171     } else if (i == 27) {
1172       check(iterEntry, kLumi, 15, 17, 17, 0, 2);
1173       CPPUNIT_ASSERT(iterEntry.run() == 2 && iterEntry.lumi() == 7);
1174       CPPUNIT_ASSERT(!iterEntry.shouldProcessLumi());
1175       CPPUNIT_ASSERT(iterEntry.entry() == 11);
1176     } else if (i == 28) {
1177       check(iterEntry, kEvent, 15, 17, 17, 0, 2);
1178       CPPUNIT_ASSERT(iterEntry.run() == 2 && iterEntry.lumi() == 7);
1179       CPPUNIT_ASSERT(iterEntry.entry() == 10);
1180     } else if (i == 29) {
1181       check(iterEntry, kEvent, 15, 17, 17, 1, 2);
1182       CPPUNIT_ASSERT(iterEntry.run() == 2 && iterEntry.lumi() == 7);
1183       CPPUNIT_ASSERT(iterEntry.entry() == 11);
1184     } else if (i == 30) {
1185       check(iterEntry, kLumi, 15, 18, -1, 0, 0);
1186       CPPUNIT_ASSERT(iterEntry.run() == 2 && iterEntry.lumi() == 1);
1187       CPPUNIT_ASSERT(iterEntry.shouldProcessLumi());
1188       CPPUNIT_ASSERT(iterEntry.entry() == 1);
1189     } else if (i == 31) {
1190       check(iterEntry, kLumi, 15, 19, -1, 0, 0);
1191       CPPUNIT_ASSERT(iterEntry.run() == 2 && iterEntry.lumi() == 2);
1192       CPPUNIT_ASSERT(iterEntry.shouldProcessLumi());
1193       CPPUNIT_ASSERT(iterEntry.entry() == 2);
1194     } else if (i == 32) {
1195       check(iterEntry, kLumi, 15, 20, 21, 0, 1);
1196       CPPUNIT_ASSERT(iterEntry.run() == 2 && iterEntry.lumi() == 3);
1197       CPPUNIT_ASSERT(iterEntry.shouldProcessLumi());
1198       CPPUNIT_ASSERT(iterEntry.entry() == 3);
1199     } else if (i == 33) {
1200       check(iterEntry, kLumi, 15, 21, 21, 0, 1);
1201       CPPUNIT_ASSERT(iterEntry.run() == 2 && iterEntry.lumi() == 3);
1202       CPPUNIT_ASSERT(iterEntry.shouldProcessLumi());
1203       CPPUNIT_ASSERT(iterEntry.entry() == 12);
1204     } else if (i == 34) {
1205       check(iterEntry, kLumi, 15, 22, 21, 0, 1);
1206       CPPUNIT_ASSERT(iterEntry.run() == 2 && iterEntry.lumi() == 3);
1207       CPPUNIT_ASSERT(iterEntry.shouldProcessLumi());
1208       CPPUNIT_ASSERT(iterEntry.entry() == 15);
1209     } else if (i == 35) {
1210       check(iterEntry, kEvent, 15, 22, 21, 0, 1);
1211       CPPUNIT_ASSERT(iterEntry.run() == 2 && iterEntry.lumi() == 3);
1212       CPPUNIT_ASSERT(iterEntry.entry() == 12);
1213     } else if (i == 36) {
1214       check(iterEntry, kLumi, 15, 23, 24, 0, 1);
1215       CPPUNIT_ASSERT(iterEntry.run() == 2 && iterEntry.lumi() == 4);
1216       CPPUNIT_ASSERT(iterEntry.shouldProcessLumi());
1217       CPPUNIT_ASSERT(iterEntry.entry() == 4);
1218     } else if (i == 37) {
1219       check(iterEntry, kLumi, 15, 24, 24, 0, 1);
1220       CPPUNIT_ASSERT(iterEntry.run() == 2 && iterEntry.lumi() == 4);
1221       CPPUNIT_ASSERT(iterEntry.shouldProcessLumi());
1222       CPPUNIT_ASSERT(iterEntry.entry() == 13);
1223     } else if (i == 38) {
1224       check(iterEntry, kEvent, 15, 24, 24, 0, 1);
1225       CPPUNIT_ASSERT(iterEntry.run() == 2 && iterEntry.lumi() == 4);
1226       CPPUNIT_ASSERT(iterEntry.entry() == 13);
1227     } else if (i == 39) {
1228       check(iterEntry, kLumi, 15, 25, -1, 0, 0);
1229       CPPUNIT_ASSERT(iterEntry.run() == 2 && iterEntry.lumi() == 5);
1230       CPPUNIT_ASSERT(iterEntry.shouldProcessLumi());
1231       CPPUNIT_ASSERT(iterEntry.entry() == 5);
1232     } else if (i == 40) {
1233       check(iterEntry, kLumi, 15, 26, -1, 0, 0);
1234       CPPUNIT_ASSERT(iterEntry.run() == 2 && iterEntry.lumi() == 6);
1235       CPPUNIT_ASSERT(iterEntry.shouldProcessLumi());
1236       CPPUNIT_ASSERT(iterEntry.entry() == 6);
1237     } else if (i == 41) {
1238       check(iterEntry, kLumi, 15, 27, 29, 0, 1);
1239       CPPUNIT_ASSERT(iterEntry.run() == 2 && iterEntry.lumi() == 7);
1240       CPPUNIT_ASSERT(iterEntry.shouldProcessLumi());
1241       CPPUNIT_ASSERT(iterEntry.entry() == 7);
1242     } else if (i == 42) {
1243       check(iterEntry, kLumi, 15, 28, 29, 0, 1);
1244       CPPUNIT_ASSERT(iterEntry.run() == 2 && iterEntry.lumi() == 7);
1245       CPPUNIT_ASSERT(iterEntry.shouldProcessLumi());
1246       CPPUNIT_ASSERT(iterEntry.entry() == 11);
1247     } else if (i == 43) {
1248       check(iterEntry, kLumi, 15, 29, 29, 0, 1);
1249       CPPUNIT_ASSERT(iterEntry.run() == 2 && iterEntry.lumi() == 7);
1250       CPPUNIT_ASSERT(iterEntry.shouldProcessLumi());
1251       CPPUNIT_ASSERT(iterEntry.entry() == 14);
1252     } else if (i == 44) {
1253       check(iterEntry, kLumi, 15, 30, 29, 0, 1);
1254       CPPUNIT_ASSERT(iterEntry.run() == 2 && iterEntry.lumi() == 7);
1255       CPPUNIT_ASSERT(!iterEntry.shouldProcessLumi());
1256       CPPUNIT_ASSERT(iterEntry.entry() == 16);
1257     } else if (i == 45) {
1258       check(iterEntry, kLumi, 15, 31, 29, 0, 1);
1259       CPPUNIT_ASSERT(iterEntry.run() == 2 && iterEntry.lumi() == 7);
1260       CPPUNIT_ASSERT(iterEntry.shouldProcessLumi());
1261       CPPUNIT_ASSERT(iterEntry.entry() == 16);
1262     } else if (i == 46) {
1263       check(iterEntry, kLumi, 15, 32, 29, 0, 1);
1264       CPPUNIT_ASSERT(iterEntry.run() == 2 && iterEntry.lumi() == 7);
1265       CPPUNIT_ASSERT(iterEntry.shouldProcessLumi());
1266       CPPUNIT_ASSERT(iterEntry.entry() == 17);
1267     } else if (i == 47) {
1268       check(iterEntry, kLumi, 15, 33, 29, 0, 1);
1269       CPPUNIT_ASSERT(iterEntry.run() == 2 && iterEntry.lumi() == 7);
1270       CPPUNIT_ASSERT(iterEntry.shouldProcessLumi());
1271       CPPUNIT_ASSERT(iterEntry.entry() == 18);
1272     } else if (i == 48) {
1273       check(iterEntry, kEvent, 15, 33, 29, 0, 1);
1274       CPPUNIT_ASSERT(iterEntry.run() == 2 && iterEntry.lumi() == 7);
1275       CPPUNIT_ASSERT(iterEntry.entry() == 14);
1276     } else if (i == 49) {
1277       check(iterEntry, kEvent, 15, 33, 30, 0, 2);
1278       CPPUNIT_ASSERT(iterEntry.run() == 2 && iterEntry.lumi() == 7);
1279       CPPUNIT_ASSERT(iterEntry.entry() == 15);
1280     } else if (i == 50) {
1281       check(iterEntry, kEvent, 15, 33, 30, 1, 2);
1282       CPPUNIT_ASSERT(iterEntry.run() == 2 && iterEntry.lumi() == 7);
1283       CPPUNIT_ASSERT(iterEntry.entry() == 16);
1284     } else if (i == 51) {
1285       check(iterEntry, kEvent, 15, 33, 31, 0, 2);
1286       CPPUNIT_ASSERT(iterEntry.run() == 2 && iterEntry.lumi() == 7);
1287       CPPUNIT_ASSERT(iterEntry.entry() == 17);
1288     } else if (i == 52) {
1289       check(iterEntry, kEvent, 15, 33, 31, 1, 2);
1290       CPPUNIT_ASSERT(iterEntry.run() == 2 && iterEntry.lumi() == 7);
1291       CPPUNIT_ASSERT(iterEntry.entry() == 18);
1292     } else if (i == 53) {
1293       check(iterEntry, kLumi, 15, 34, -1, 0, 0);
1294       CPPUNIT_ASSERT(iterEntry.run() == 2 && iterEntry.lumi() == 8);
1295       CPPUNIT_ASSERT(iterEntry.shouldProcessLumi());
1296       CPPUNIT_ASSERT(iterEntry.entry() == 8);
1297     } else if (i == 54) {
1298       check(iterEntry, kLumi, 15, 35, -1, 0, 0);
1299       CPPUNIT_ASSERT(iterEntry.run() == 2 && iterEntry.lumi() == 9);
1300       CPPUNIT_ASSERT(iterEntry.shouldProcessLumi());
1301       CPPUNIT_ASSERT(iterEntry.entry() == 9);
1302     } else
1303       CPPUNIT_ASSERT(false);
1304   }
1305   CPPUNIT_ASSERT(iterEntry.entry() == IndexIntoFile::invalidEntry);
1306   CPPUNIT_ASSERT(i == 55);
1307 
1308   skipEventBackward(iterEntry);
1309   checkSkipped(0, 2, 7, 18);
1310   check(iterEntry, kRun, 13, 27, 31, 1, 2);
1311 }