Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 12:54:35

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 TestIndexIntoFile4 : public CppUnit::TestFixture {
0020   CPPUNIT_TEST_SUITE(TestIndexIntoFile4);
0021   CPPUNIT_TEST(testFind);
0022   CPPUNIT_TEST_SUITE_END();
0023 
0024 public:
0025   static const IndexIntoFile::EntryType kRun = IndexIntoFile::kRun;
0026   static const IndexIntoFile::EntryType kLumi = IndexIntoFile::kLumi;
0027   static const IndexIntoFile::EntryType kEvent = IndexIntoFile::kEvent;
0028   static const IndexIntoFile::EntryType kEnd = IndexIntoFile::kEnd;
0029 
0030   class Skipped {
0031   public:
0032     Skipped() : phIndexOfSkippedEvent_(0), runOfSkippedEvent_(0), lumiOfSkippedEvent_(0), skippedEventEntry_(0) {}
0033     int phIndexOfSkippedEvent_;
0034     RunNumber_t runOfSkippedEvent_;
0035     LuminosityBlockNumber_t lumiOfSkippedEvent_;
0036     IndexIntoFile::EntryNumber_t skippedEventEntry_;
0037   };
0038 
0039   Skipped skipped_;
0040 
0041   void setUp() {
0042     // Make some fake processHistoryID's to work with
0043     nullPHID = ProcessHistoryID();
0044 
0045     ProcessConfiguration pc;
0046     auto processHistory1 = std::make_unique<ProcessHistory>();
0047     ProcessHistory& ph1 = *processHistory1;
0048     processHistory1->push_back(pc);
0049     fakePHID1 = ph1.id();
0050 
0051     auto processHistory2 = std::make_unique<ProcessHistory>();
0052     ProcessHistory& ph2 = *processHistory2;
0053     processHistory2->push_back(pc);
0054     processHistory2->push_back(pc);
0055     fakePHID2 = ph2.id();
0056 
0057     auto processHistory3 = std::make_unique<ProcessHistory>();
0058     ProcessHistory& ph3 = *processHistory3;
0059     processHistory3->push_back(pc);
0060     processHistory3->push_back(pc);
0061     processHistory3->push_back(pc);
0062     fakePHID3 = ph3.id();
0063   }
0064 
0065   void tearDown() {}
0066 
0067   void testFind();
0068   void testReduce();
0069 
0070   ProcessHistoryID nullPHID;
0071   ProcessHistoryID fakePHID1;
0072   ProcessHistoryID fakePHID2;
0073   ProcessHistoryID fakePHID3;
0074 
0075   void check(edm::IndexIntoFile::IndexIntoFileItr const& iter,
0076              IndexIntoFile::EntryType type,
0077              int indexToRun,
0078              int indexToLumi,
0079              int indexToEventRange,
0080              long long indexToEvent,
0081              long long nEvents);
0082 
0083   void checkSkipped(int phIndexOfSkippedEvent,
0084                     RunNumber_t runOfSkippedEvent,
0085                     LuminosityBlockNumber_t lumiOfSkippedEvent,
0086                     IndexIntoFile::EntryNumber_t skippedEventEntry);
0087 
0088   void skipEventBackward(edm::IndexIntoFile::IndexIntoFileItr& iter);
0089 
0090   // This is a helper class for IndexIntoFile.
0091   class TestEventFinder : public IndexIntoFile::EventFinder {
0092   public:
0093     explicit TestEventFinder() {}
0094     virtual ~TestEventFinder() {}
0095     virtual EventNumber_t getEventNumberOfEntry(IndexIntoFile::EntryNumber_t entry) const {
0096       return testData_.at(entry);
0097     }
0098     void push_back(EventNumber_t e) { testData_.push_back(e); }
0099 
0100   private:
0101     std::vector<EventNumber_t> testData_;
0102   };
0103 };
0104 
0105 ///registration of the test so that the runner can find it
0106 CPPUNIT_TEST_SUITE_REGISTRATION(TestIndexIntoFile4);
0107 
0108 void TestIndexIntoFile4::check(edm::IndexIntoFile::IndexIntoFileItr const& iter,
0109                                IndexIntoFile::EntryType type,
0110                                int indexToRun,
0111                                int indexToLumi,
0112                                int indexToEventRange,
0113                                long long indexToEvent,
0114                                long long nEvents) {
0115   bool theyMatch = iter.getEntryType() == type && iter.type() == type && iter.indexToRun() == indexToRun &&
0116                    iter.indexToLumi() == indexToLumi && iter.indexToEventRange() == indexToEventRange &&
0117                    iter.indexToEvent() == indexToEvent && iter.nEvents() == nEvents;
0118   if (!theyMatch) {
0119     std::cout << "\nExpected        " << type << "  " << indexToRun << "  " << indexToLumi << "  " << indexToEventRange
0120               << "  " << indexToEvent << "  " << nEvents << "\n";
0121     std::cout << "Iterator values " << iter.type() << "  " << iter.indexToRun() << "  " << iter.indexToLumi() << "  "
0122               << iter.indexToEventRange() << "  " << iter.indexToEvent() << "  " << iter.nEvents() << "\n";
0123   }
0124   CPPUNIT_ASSERT(theyMatch);
0125 }
0126 
0127 void TestIndexIntoFile4::checkSkipped(int phIndexOfSkippedEvent,
0128                                       RunNumber_t runOfSkippedEvent,
0129                                       LuminosityBlockNumber_t lumiOfSkippedEvent,
0130                                       IndexIntoFile::EntryNumber_t skippedEventEntry) {
0131   bool theyMatch =
0132       skipped_.phIndexOfSkippedEvent_ == phIndexOfSkippedEvent && skipped_.runOfSkippedEvent_ == runOfSkippedEvent &&
0133       skipped_.lumiOfSkippedEvent_ == lumiOfSkippedEvent && skipped_.skippedEventEntry_ == skippedEventEntry;
0134 
0135   if (!theyMatch) {
0136     std::cout << "\nExpected        " << phIndexOfSkippedEvent << "  " << runOfSkippedEvent << "  "
0137               << lumiOfSkippedEvent << "  " << skippedEventEntry << "\n";
0138     std::cout << "Actual          " << skipped_.phIndexOfSkippedEvent_ << "  " << skipped_.runOfSkippedEvent_ << "  "
0139               << skipped_.lumiOfSkippedEvent_ << "  " << skipped_.skippedEventEntry_ << "\n";
0140   }
0141   CPPUNIT_ASSERT(theyMatch);
0142 }
0143 
0144 void TestIndexIntoFile4::skipEventBackward(edm::IndexIntoFile::IndexIntoFileItr& iter) {
0145   iter.skipEventBackward(skipped_.phIndexOfSkippedEvent_,
0146                          skipped_.runOfSkippedEvent_,
0147                          skipped_.lumiOfSkippedEvent_,
0148                          skipped_.skippedEventEntry_);
0149 }
0150 
0151 void TestIndexIntoFile4::testFind() {
0152   for (int j = 0; j < 2; ++j) {
0153     edm::IndexIntoFile indexIntoFile;
0154     indexIntoFile.addEntry(fakePHID1, 1, 0, 0, 0);    // Run
0155     indexIntoFile.addEntry(fakePHID1, 2, 12, 7, 0);   // Event
0156     indexIntoFile.addEntry(fakePHID1, 2, 12, 6, 1);   // Event
0157     indexIntoFile.addEntry(fakePHID1, 2, 12, 0, 0);   // Lumi
0158     indexIntoFile.addEntry(fakePHID1, 2, 12, 5, 2);   // Event
0159     indexIntoFile.addEntry(fakePHID1, 2, 12, 4, 3);   // Event
0160     indexIntoFile.addEntry(fakePHID1, 2, 12, 0, 1);   // Lumi
0161     indexIntoFile.addEntry(fakePHID1, 2, 0, 0, 1);    // Run
0162     indexIntoFile.addEntry(fakePHID2, 3, 0, 0, 2);    // Run
0163     indexIntoFile.addEntry(fakePHID2, 4, 12, 7, 4);   // Event
0164     indexIntoFile.addEntry(fakePHID2, 4, 12, 6, 5);   // Event
0165     indexIntoFile.addEntry(fakePHID2, 4, 12, 0, 2);   // Lumi
0166     indexIntoFile.addEntry(fakePHID2, 4, 12, 5, 6);   // Event
0167     indexIntoFile.addEntry(fakePHID2, 4, 12, 4, 7);   // Event
0168     indexIntoFile.addEntry(fakePHID2, 4, 12, 0, 3);   // Lumi
0169     indexIntoFile.addEntry(fakePHID2, 4, 0, 0, 3);    // Run
0170     indexIntoFile.addEntry(fakePHID3, 5, 0, 0, 4);    // Run
0171     indexIntoFile.addEntry(fakePHID3, 6, 12, 7, 8);   // Event
0172     indexIntoFile.addEntry(fakePHID3, 6, 12, 6, 9);   // Event
0173     indexIntoFile.addEntry(fakePHID3, 6, 12, 0, 4);   // Lumi
0174     indexIntoFile.addEntry(fakePHID3, 6, 100, 0, 5);  // Lumi
0175     indexIntoFile.addEntry(fakePHID3, 6, 0, 0, 5);    // Run
0176     indexIntoFile.sortVector_Run_Or_Lumi_Entries();
0177 
0178     if (j == 0) {
0179       std::vector<IndexIntoFile::EventEntry>& eventEntries = indexIntoFile.eventEntries();
0180       eventEntries.emplace_back(7, 0);
0181       eventEntries.emplace_back(6, 1);
0182       eventEntries.emplace_back(5, 2);
0183       eventEntries.emplace_back(4, 3);
0184       eventEntries.emplace_back(7, 4);
0185       eventEntries.emplace_back(6, 5);
0186       eventEntries.emplace_back(5, 6);
0187       eventEntries.emplace_back(4, 7);
0188       eventEntries.emplace_back(7, 8);
0189       eventEntries.emplace_back(6, 9);
0190       indexIntoFile.sortEventEntries();
0191     } else if (j == 1) {
0192       std::vector<EventNumber_t>& eventNumbers = indexIntoFile.eventNumbers();
0193       eventNumbers.push_back(7);
0194       eventNumbers.push_back(6);
0195       eventNumbers.push_back(5);
0196       eventNumbers.push_back(4);
0197       eventNumbers.push_back(7);
0198       eventNumbers.push_back(6);
0199       eventNumbers.push_back(5);
0200       eventNumbers.push_back(4);
0201       eventNumbers.push_back(7);
0202       eventNumbers.push_back(6);
0203       indexIntoFile.sortEvents();
0204     }
0205 
0206     TestEventFinder* ptr(new TestEventFinder);
0207     ptr->push_back(7);
0208     ptr->push_back(6);
0209     ptr->push_back(5);
0210     ptr->push_back(4);
0211     ptr->push_back(7);
0212     ptr->push_back(6);
0213     ptr->push_back(5);
0214     ptr->push_back(4);
0215     ptr->push_back(7);
0216     ptr->push_back(6);
0217     std::shared_ptr<IndexIntoFile::EventFinder> shptr(ptr);
0218     indexIntoFile.setEventFinder(shptr);
0219 
0220     edm::IndexIntoFile::IndexIntoFileItr iter = indexIntoFile.findPosition(1000, 0, 0);
0221     CPPUNIT_ASSERT(iter == indexIntoFile.end(IndexIntoFile::numericalOrder));
0222 
0223     iter = indexIntoFile.findPosition(2, 1, 0);
0224     CPPUNIT_ASSERT(iter == indexIntoFile.end(IndexIntoFile::numericalOrder));
0225 
0226     iter = indexIntoFile.findPosition(2, 100, 0);
0227     CPPUNIT_ASSERT(iter == indexIntoFile.end(IndexIntoFile::numericalOrder));
0228 
0229     iter = indexIntoFile.findPosition(6, 100, 1);
0230     CPPUNIT_ASSERT(iter == indexIntoFile.end(IndexIntoFile::numericalOrder));
0231 
0232     iter = indexIntoFile.findPosition(2, 12, 3);
0233     CPPUNIT_ASSERT(iter == indexIntoFile.end(IndexIntoFile::numericalOrder));
0234 
0235     iter = indexIntoFile.findPosition(2, 12, 8);
0236     CPPUNIT_ASSERT(iter == indexIntoFile.end(IndexIntoFile::numericalOrder));
0237 
0238     iter = indexIntoFile.findPosition(1, 0, 1);
0239     CPPUNIT_ASSERT(iter == indexIntoFile.end(IndexIntoFile::numericalOrder));
0240 
0241     iter = indexIntoFile.findPosition(6, 0, 100);
0242     CPPUNIT_ASSERT(iter == indexIntoFile.end(IndexIntoFile::numericalOrder));
0243 
0244     iter = indexIntoFile.findPosition(6, 100, 0);
0245     CPPUNIT_ASSERT(iter.type() == kRun);
0246     CPPUNIT_ASSERT(iter.indexToRun() == 9);
0247     CPPUNIT_ASSERT(iter.indexToLumi() == 11);
0248     CPPUNIT_ASSERT(iter.indexToEventRange() == IndexIntoFile::invalidIndex);
0249     CPPUNIT_ASSERT(iter.indexToEvent() == 0);
0250     CPPUNIT_ASSERT(iter.nEvents() == 0);
0251 
0252     iter = indexIntoFile.findPosition(1, 0, 0);
0253     edm::IndexIntoFile::IndexIntoFileItr iter1 = indexIntoFile.findPosition(1, 1, 0);
0254     edm::IndexIntoFile::IndexIntoFileItr iter2 = indexIntoFile.findPosition(1, 1, 1);
0255     CPPUNIT_ASSERT(iter1 == indexIntoFile.end(IndexIntoFile::numericalOrder));
0256     CPPUNIT_ASSERT(iter2 == indexIntoFile.end(IndexIntoFile::numericalOrder));
0257     CPPUNIT_ASSERT(iter.indexIntoFile() == &indexIntoFile);
0258     CPPUNIT_ASSERT(iter.size() == 12);
0259     CPPUNIT_ASSERT(iter.type() == kRun);
0260     CPPUNIT_ASSERT(iter.indexToRun() == 0);
0261     CPPUNIT_ASSERT(iter.indexToLumi() == IndexIntoFile::invalidIndex);
0262     CPPUNIT_ASSERT(iter.indexToEventRange() == IndexIntoFile::invalidIndex);
0263     CPPUNIT_ASSERT(iter.indexToEvent() == 0);
0264     CPPUNIT_ASSERT(iter.nEvents() == 0);
0265 
0266     iter = indexIntoFile.findPosition(2, 0, 0);
0267     iter1 = indexIntoFile.findPosition(2, 12, 0);
0268     iter2 = indexIntoFile.findPosition(2, 12, 4);
0269     edm::IndexIntoFile::IndexIntoFileItr iter3 = indexIntoFile.findPosition(2, 0, 4);
0270     edm::IndexIntoFile::IndexIntoFileItr iter4 = indexIntoFile.findRunPosition(2);
0271     CPPUNIT_ASSERT(indexIntoFile.containsItem(2, 0, 0));
0272     CPPUNIT_ASSERT(!indexIntoFile.containsItem(2000, 0, 0));
0273     CPPUNIT_ASSERT(iter == iter1);
0274     CPPUNIT_ASSERT(iter == iter2);
0275     CPPUNIT_ASSERT(iter == iter3);
0276     CPPUNIT_ASSERT(iter == iter4);
0277     CPPUNIT_ASSERT(iter.type() == kRun);
0278     CPPUNIT_ASSERT(iter.indexToRun() == 1);
0279     CPPUNIT_ASSERT(iter.indexToLumi() == 2);
0280     CPPUNIT_ASSERT(iter.indexToEventRange() == 2);
0281     CPPUNIT_ASSERT(iter.indexToEvent() == 0);
0282     CPPUNIT_ASSERT(iter.nEvents() == 4);
0283 
0284     iter = indexIntoFile.findPosition(3, 0, 0);
0285     iter1 = indexIntoFile.findPosition(3, 1, 0);
0286     iter2 = indexIntoFile.findPosition(3, 1, 1);
0287     CPPUNIT_ASSERT(iter1 == indexIntoFile.end(IndexIntoFile::numericalOrder));
0288     CPPUNIT_ASSERT(iter2 == indexIntoFile.end(IndexIntoFile::numericalOrder));
0289     CPPUNIT_ASSERT(iter.type() == kRun);
0290     CPPUNIT_ASSERT(iter.indexToRun() == 4);
0291     CPPUNIT_ASSERT(iter.indexToLumi() == IndexIntoFile::invalidIndex);
0292     CPPUNIT_ASSERT(iter.indexToEventRange() == IndexIntoFile::invalidIndex);
0293     CPPUNIT_ASSERT(iter.indexToEvent() == 0);
0294     CPPUNIT_ASSERT(iter.nEvents() == 0);
0295 
0296     iter = indexIntoFile.findPosition(4, 0, 0);
0297     iter1 = indexIntoFile.findPosition(4, 12, 0);
0298     iter2 = indexIntoFile.findPosition(4, 12, 4);
0299     CPPUNIT_ASSERT(iter == iter1);
0300     CPPUNIT_ASSERT(iter == iter2);
0301     CPPUNIT_ASSERT(iter.type() == kRun);
0302     CPPUNIT_ASSERT(iter.indexToRun() == 5);
0303     CPPUNIT_ASSERT(iter.indexToLumi() == 6);
0304     CPPUNIT_ASSERT(iter.indexToEventRange() == 6);
0305     CPPUNIT_ASSERT(iter.indexToEvent() == 0);
0306     CPPUNIT_ASSERT(iter.nEvents() == 4);
0307 
0308     iter = indexIntoFile.findPosition(5, 0, 0);
0309     iter1 = indexIntoFile.findPosition(5, 1, 0);
0310     iter2 = indexIntoFile.findPosition(5, 1, 1);
0311     CPPUNIT_ASSERT(iter1 == indexIntoFile.end(IndexIntoFile::numericalOrder));
0312     CPPUNIT_ASSERT(iter2 == indexIntoFile.end(IndexIntoFile::numericalOrder));
0313     CPPUNIT_ASSERT(iter.type() == kRun);
0314     CPPUNIT_ASSERT(iter.indexToRun() == 8);
0315     CPPUNIT_ASSERT(iter.indexToLumi() == IndexIntoFile::invalidIndex);
0316     CPPUNIT_ASSERT(iter.indexToEventRange() == IndexIntoFile::invalidIndex);
0317     CPPUNIT_ASSERT(iter.indexToEvent() == 0);
0318     CPPUNIT_ASSERT(iter.nEvents() == 0);
0319 
0320     iter = indexIntoFile.findPosition(6, 0, 0);
0321     iter1 = indexIntoFile.findPosition(6, 12, 0);
0322     iter2 = indexIntoFile.findPosition(6, 12, 6);
0323     CPPUNIT_ASSERT(iter == iter1);
0324     CPPUNIT_ASSERT(iter == iter2);
0325     CPPUNIT_ASSERT(iter.type() == kRun);
0326     CPPUNIT_ASSERT(iter.indexToRun() == 9);
0327     CPPUNIT_ASSERT(iter.indexToLumi() == 10);
0328     CPPUNIT_ASSERT(iter.indexToEventRange() == 10);
0329     CPPUNIT_ASSERT(iter.indexToEvent() == 0);
0330     CPPUNIT_ASSERT(iter.nEvents() == 2);
0331 
0332     iter = indexIntoFile.findPosition(2, 12, 5);
0333     iter1 = indexIntoFile.findPosition(2, 0, 5);
0334     iter2 = indexIntoFile.findPosition(IndexIntoFile::numericalOrder, 2, 0, 5);
0335     iter3 = indexIntoFile.findPosition(IndexIntoFile::firstAppearanceOrder, 2, 0, 5);
0336     CPPUNIT_ASSERT(iter == iter1);
0337     CPPUNIT_ASSERT(iter == iter2);
0338     CPPUNIT_ASSERT(iter != iter3);
0339     CPPUNIT_ASSERT(iter.type() == kRun);
0340     CPPUNIT_ASSERT(iter.indexToRun() == 1);
0341     CPPUNIT_ASSERT(iter.indexToLumi() == 2);
0342     CPPUNIT_ASSERT(iter.indexToEventRange() == 2);
0343     CPPUNIT_ASSERT(iter.indexToEvent() == 1);
0344     CPPUNIT_ASSERT(iter.nEvents() == 4);
0345     CPPUNIT_ASSERT(iter3.type() == kRun);
0346     CPPUNIT_ASSERT(iter3.indexToRun() == 1);
0347     CPPUNIT_ASSERT(iter3.indexToLumi() == 2);
0348     CPPUNIT_ASSERT(iter3.indexToEventRange() == 3);
0349     CPPUNIT_ASSERT(iter3.indexToEvent() == 0);
0350     CPPUNIT_ASSERT(iter3.nEvents() == 2);
0351 
0352     iter3 = indexIntoFile.findPosition(IndexIntoFile::firstAppearanceOrder, 2, 0, 0);
0353     CPPUNIT_ASSERT(iter3.type() == kRun);
0354     CPPUNIT_ASSERT(iter3.indexToRun() == 1);
0355     CPPUNIT_ASSERT(iter3.indexToLumi() == 2);
0356     CPPUNIT_ASSERT(iter3.indexToEventRange() == 2);
0357     CPPUNIT_ASSERT(iter3.indexToEvent() == 0);
0358     CPPUNIT_ASSERT(iter3.nEvents() == 2);
0359 
0360     iter3 = indexIntoFile.findPosition(IndexIntoFile::firstAppearanceOrder, 2, 12, 0);
0361     CPPUNIT_ASSERT(iter3.type() == kRun);
0362     CPPUNIT_ASSERT(iter3.indexToRun() == 1);
0363     CPPUNIT_ASSERT(iter3.indexToLumi() == 2);
0364     CPPUNIT_ASSERT(iter3.indexToEventRange() == 2);
0365     CPPUNIT_ASSERT(iter3.indexToEvent() == 0);
0366     CPPUNIT_ASSERT(iter3.nEvents() == 2);
0367 
0368     iter3 = indexIntoFile.findPosition(IndexIntoFile::firstAppearanceOrder, 2, 12, 4);
0369     CPPUNIT_ASSERT(iter3.type() == kRun);
0370     CPPUNIT_ASSERT(iter3.indexToRun() == 1);
0371     CPPUNIT_ASSERT(iter3.indexToLumi() == 2);
0372     CPPUNIT_ASSERT(iter3.indexToEventRange() == 3);
0373     CPPUNIT_ASSERT(iter3.indexToEvent() == 1);
0374     CPPUNIT_ASSERT(iter3.nEvents() == 2);
0375 
0376     iter = indexIntoFile.end(IndexIntoFile::firstAppearanceOrder);
0377     CPPUNIT_ASSERT(iter != iter3);
0378     iter.copyPosition(iter3);
0379     CPPUNIT_ASSERT(iter == iter3);
0380 
0381     iter3 = indexIntoFile.findPosition(IndexIntoFile::firstAppearanceOrder, 6, 100, 0);
0382     CPPUNIT_ASSERT(iter3.type() == kRun);
0383     CPPUNIT_ASSERT(iter3.indexToRun() == 9);
0384     CPPUNIT_ASSERT(iter3.indexToLumi() == 11);
0385     CPPUNIT_ASSERT(iter3.indexToEventRange() == -1);
0386     CPPUNIT_ASSERT(iter3.indexToEvent() == 0);
0387     CPPUNIT_ASSERT(iter3.nEvents() == 0);
0388 
0389     iter = indexIntoFile.findPosition(2, 12, 6);
0390     iter1 = indexIntoFile.findPosition(2, 0, 6);
0391     CPPUNIT_ASSERT(iter == iter1);
0392     CPPUNIT_ASSERT(iter.type() == kRun);
0393     CPPUNIT_ASSERT(iter.indexToRun() == 1);
0394     CPPUNIT_ASSERT(iter.indexToLumi() == 2);
0395     CPPUNIT_ASSERT(iter.indexToEventRange() == 2);
0396     CPPUNIT_ASSERT(iter.indexToEvent() == 2);
0397     CPPUNIT_ASSERT(iter.nEvents() == 4);
0398 
0399     iter = indexIntoFile.findPosition(2, 12, 7);
0400     iter1 = indexIntoFile.findPosition(2, 0, 7);
0401     CPPUNIT_ASSERT(iter == iter1);
0402     CPPUNIT_ASSERT(iter.type() == kRun);
0403     CPPUNIT_ASSERT(iter.indexToRun() == 1);
0404     CPPUNIT_ASSERT(iter.indexToLumi() == 2);
0405     CPPUNIT_ASSERT(iter.indexToEventRange() == 2);
0406     CPPUNIT_ASSERT(iter.indexToEvent() == 3);
0407     CPPUNIT_ASSERT(iter.nEvents() == 4);
0408 
0409     iter = indexIntoFile.findPosition(4, 12, 5);
0410     iter1 = indexIntoFile.findPosition(4, 0, 5);
0411     CPPUNIT_ASSERT(iter == iter1);
0412     CPPUNIT_ASSERT(iter.type() == kRun);
0413     CPPUNIT_ASSERT(iter.indexToRun() == 5);
0414     CPPUNIT_ASSERT(iter.indexToLumi() == 6);
0415     CPPUNIT_ASSERT(iter.indexToEventRange() == 6);
0416     CPPUNIT_ASSERT(iter.indexToEvent() == 1);
0417     CPPUNIT_ASSERT(iter.nEvents() == 4);
0418 
0419     iter = indexIntoFile.findPosition(4, 12, 6);
0420     iter1 = indexIntoFile.findPosition(4, 0, 6);
0421     CPPUNIT_ASSERT(iter == iter1);
0422     CPPUNIT_ASSERT(iter.type() == kRun);
0423     CPPUNIT_ASSERT(iter.indexToRun() == 5);
0424     CPPUNIT_ASSERT(iter.indexToLumi() == 6);
0425     CPPUNIT_ASSERT(iter.indexToEventRange() == 6);
0426     CPPUNIT_ASSERT(iter.indexToEvent() == 2);
0427     CPPUNIT_ASSERT(iter.nEvents() == 4);
0428 
0429     iter = indexIntoFile.findPosition(4, 12, 7);
0430     iter1 = indexIntoFile.findPosition(4, 0, 7);
0431     CPPUNIT_ASSERT(iter == iter1);
0432     CPPUNIT_ASSERT(iter.type() == kRun);
0433     CPPUNIT_ASSERT(iter.indexToRun() == 5);
0434     CPPUNIT_ASSERT(iter.indexToLumi() == 6);
0435     CPPUNIT_ASSERT(iter.indexToEventRange() == 6);
0436     CPPUNIT_ASSERT(iter.indexToEvent() == 3);
0437     CPPUNIT_ASSERT(iter.nEvents() == 4);
0438 
0439     iter = indexIntoFile.findPosition(6, 12, 7);
0440     iter1 = indexIntoFile.findPosition(6, 0, 7);
0441     CPPUNIT_ASSERT(iter == iter1);
0442     CPPUNIT_ASSERT(iter.type() == kRun);
0443     CPPUNIT_ASSERT(iter.indexToRun() == 9);
0444     CPPUNIT_ASSERT(iter.indexToLumi() == 10);
0445     CPPUNIT_ASSERT(iter.indexToEventRange() == 10);
0446     CPPUNIT_ASSERT(iter.indexToEvent() == 1);
0447     CPPUNIT_ASSERT(iter.nEvents() == 2);
0448 
0449     iter = indexIntoFile.findEventPosition(2, 12, 4);
0450     iter1 = indexIntoFile.findEventPosition(2, 0, 4);
0451     CPPUNIT_ASSERT(iter == iter1);
0452     CPPUNIT_ASSERT(iter.type() == kEvent);
0453     CPPUNIT_ASSERT(iter.indexToRun() == 1);
0454     CPPUNIT_ASSERT(iter.indexToLumi() == 3);
0455     CPPUNIT_ASSERT(iter.indexToEventRange() == 2);
0456     CPPUNIT_ASSERT(iter.indexToEvent() == 0);
0457     CPPUNIT_ASSERT(iter.nEvents() == 4);
0458 
0459     iter = indexIntoFile.findEventPosition(2, 12, 7);
0460     iter1 = indexIntoFile.findEventPosition(2, 0, 7);
0461     CPPUNIT_ASSERT(indexIntoFile.containsItem(2, 12, 7));
0462     CPPUNIT_ASSERT(!indexIntoFile.containsItem(2, 12, 100));
0463     CPPUNIT_ASSERT(iter == iter1);
0464     CPPUNIT_ASSERT(iter.type() == kEvent);
0465     CPPUNIT_ASSERT(iter.indexToRun() == 1);
0466     CPPUNIT_ASSERT(iter.indexToLumi() == 3);
0467     CPPUNIT_ASSERT(iter.indexToEventRange() == 2);
0468     CPPUNIT_ASSERT(iter.indexToEvent() == 3);
0469     CPPUNIT_ASSERT(iter.nEvents() == 4);
0470 
0471     iter = indexIntoFile.findEventPosition(2, 12, 100);
0472     iter1 = indexIntoFile.findEventPosition(2, 0, 100);
0473     CPPUNIT_ASSERT(iter == iter1);
0474     CPPUNIT_ASSERT(iter == indexIntoFile.end(IndexIntoFile::numericalOrder));
0475 
0476     iter = indexIntoFile.findLumiPosition(2, 12);
0477     CPPUNIT_ASSERT(iter.type() == kLumi);
0478     CPPUNIT_ASSERT(iter.indexToRun() == 1);
0479     CPPUNIT_ASSERT(iter.indexToLumi() == 2);
0480     CPPUNIT_ASSERT(iter.indexToEventRange() == 2);
0481     CPPUNIT_ASSERT(iter.indexToEvent() == 0);
0482     CPPUNIT_ASSERT(iter.nEvents() == 4);
0483 
0484     iter = indexIntoFile.findLumiPosition(2, 100);
0485     CPPUNIT_ASSERT(indexIntoFile.containsItem(2, 12, 0));
0486     CPPUNIT_ASSERT(!indexIntoFile.containsItem(2, 100, 0));
0487     CPPUNIT_ASSERT(iter == indexIntoFile.end(IndexIntoFile::numericalOrder));
0488 
0489     if (j == 0) {
0490       edm::IndexIntoFile::IndexIntoFileItr iterFirst = indexIntoFile.begin(IndexIntoFile::firstAppearanceOrder);
0491       iterFirst.advanceToNextRun();
0492       iterFirst.advanceToNextRun();
0493 
0494       skipEventBackward(iterFirst);
0495       checkSkipped(0, 2, 12, 3);
0496       check(iterFirst, kRun, 1, 2, 3, 1, 2);
0497 
0498       edm::IndexIntoFile::IndexIntoFileItr iterNum = indexIntoFile.begin(IndexIntoFile::numericalOrder);
0499       iterNum.advanceToNextRun();
0500       iterNum.advanceToNextRun();
0501 
0502       skipEventBackward(iterNum);
0503       checkSkipped(0, 2, 12, 0);
0504       check(iterNum, kRun, 1, 2, 2, 3, 4);
0505     }
0506   }
0507 }
0508 
0509 void TestIndexIntoFile4::testReduce() {
0510   // This test is implemented in FWCore/Integration/test/ProcessHistory_t.cpp
0511   // because of dependency issues.
0512 }