Back to home page

Project CMSSW displayed by LXR

 
 

    


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

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 TestIndexIntoFile2 : public CppUnit::TestFixture {
0020   CPPUNIT_TEST_SUITE(TestIndexIntoFile2);
0021   CPPUNIT_TEST(testAddEntryAndFixAndSort);
0022   CPPUNIT_TEST(testAddEntryAndFixAndSort2);
0023   CPPUNIT_TEST_SUITE_END();
0024 
0025 public:
0026   static const IndexIntoFile::EntryType kRun = IndexIntoFile::kRun;
0027   static const IndexIntoFile::EntryType kLumi = IndexIntoFile::kLumi;
0028   static const IndexIntoFile::EntryType kEvent = IndexIntoFile::kEvent;
0029   static const IndexIntoFile::EntryType kEnd = IndexIntoFile::kEnd;
0030 
0031   void setUp() {
0032     // Make some fake processHistoryID's to work with
0033     nullPHID = ProcessHistoryID();
0034 
0035     ProcessConfiguration pc;
0036     auto processHistory1 = std::make_unique<ProcessHistory>();
0037     ProcessHistory& ph1 = *processHistory1;
0038     processHistory1->push_back(pc);
0039     fakePHID1 = ph1.id();
0040 
0041     auto processHistory2 = std::make_unique<ProcessHistory>();
0042     ProcessHistory& ph2 = *processHistory2;
0043     processHistory2->push_back(pc);
0044     processHistory2->push_back(pc);
0045     fakePHID2 = ph2.id();
0046 
0047     auto processHistory3 = std::make_unique<ProcessHistory>();
0048     ProcessHistory& ph3 = *processHistory3;
0049     processHistory3->push_back(pc);
0050     processHistory3->push_back(pc);
0051     processHistory3->push_back(pc);
0052     fakePHID3 = ph3.id();
0053   }
0054 
0055   void tearDown() {}
0056 
0057   void testAddEntryAndFixAndSort();
0058   void testAddEntryAndFixAndSort2();
0059 
0060   ProcessHistoryID nullPHID;
0061   ProcessHistoryID fakePHID1;
0062   ProcessHistoryID fakePHID2;
0063   ProcessHistoryID fakePHID3;
0064 
0065   bool check(edm::IndexIntoFile::IndexIntoFileItr const& iter,
0066              IndexIntoFile::EntryType type,
0067              int indexToRun,
0068              int indexToLumi,
0069              int indexToEventRange,
0070              long long indexToEvent,
0071              long long nEvents);
0072 
0073   // This is a helper class for IndexIntoFile.
0074   class TestEventFinder : public IndexIntoFile::EventFinder {
0075   public:
0076     explicit TestEventFinder() {}
0077     virtual ~TestEventFinder() {}
0078     virtual EventNumber_t getEventNumberOfEntry(IndexIntoFile::EntryNumber_t entry) const {
0079       return testData_.at(entry);
0080     }
0081     void push_back(EventNumber_t e) { testData_.push_back(e); }
0082 
0083   private:
0084     std::vector<EventNumber_t> testData_;
0085   };
0086 };
0087 
0088 ///registration of the test so that the runner can find it
0089 CPPUNIT_TEST_SUITE_REGISTRATION(TestIndexIntoFile2);
0090 
0091 bool TestIndexIntoFile2::check(edm::IndexIntoFile::IndexIntoFileItr const& iter,
0092                                IndexIntoFile::EntryType type,
0093                                int indexToRun,
0094                                int indexToLumi,
0095                                int indexToEventRange,
0096                                long long indexToEvent,
0097                                long long nEvents) {
0098   bool theyMatch = iter.getEntryType() == type && iter.type() == type && iter.indexToRun() == indexToRun &&
0099                    iter.indexToLumi() == indexToLumi && iter.indexToEventRange() == indexToEventRange &&
0100                    iter.indexToEvent() == indexToEvent && iter.nEvents() == nEvents;
0101   if (!theyMatch) {
0102     std::cout << "\nExpected        " << type << "  " << indexToRun << "  " << indexToLumi << "  " << indexToEventRange
0103               << "  " << indexToEvent << "  " << nEvents << "\n";
0104     std::cout << "Iterator values " << iter.type() << "  " << iter.indexToRun() << "  " << iter.indexToLumi() << "  "
0105               << iter.indexToEventRange() << "  " << iter.indexToEvent() << "  " << iter.nEvents() << "\n";
0106   }
0107   return theyMatch;
0108 }
0109 
0110 void TestIndexIntoFile2::testAddEntryAndFixAndSort() {
0111   edm::IndexIntoFile indexIntoFile;
0112   indexIntoFile.fillEventNumbersOrEntries(true, true);  // Should do nothing, it is empty at this point
0113 
0114   indexIntoFile.addEntry(fakePHID1, 11, 12, 7, 0);  // Event
0115   indexIntoFile.addEntry(fakePHID1, 11, 12, 6, 1);  // Event
0116   indexIntoFile.addEntry(fakePHID1, 11, 12, 0, 0);  // Lumi
0117   CPPUNIT_ASSERT(indexIntoFile.runOrLumiEntries().size() == 1);
0118   CPPUNIT_ASSERT(indexIntoFile.runOrLumiEntries()[0].processHistoryIDIndex() == 0);
0119   CPPUNIT_ASSERT(indexIntoFile.processHistoryIDs().size() == 1);
0120   CPPUNIT_ASSERT(indexIntoFile.processHistoryIDs()[0] == fakePHID1);
0121   CPPUNIT_ASSERT(indexIntoFile.runOrLumiEntries()[0].orderPHIDRun() == IndexIntoFile::invalidEntry);
0122   CPPUNIT_ASSERT(indexIntoFile.runOrLumiEntries()[0].orderPHIDRunLumi() == 0);
0123   CPPUNIT_ASSERT(indexIntoFile.runOrLumiEntries()[0].beginEvents() == 0);
0124   CPPUNIT_ASSERT(indexIntoFile.runOrLumiEntries()[0].endEvents() == 2);
0125 
0126   indexIntoFile.addEntry(fakePHID1, 11, 0, 0, 0);  // Run
0127   CPPUNIT_ASSERT(indexIntoFile.runOrLumiEntries().size() == 2);
0128   CPPUNIT_ASSERT(indexIntoFile.runOrLumiEntries()[1].processHistoryIDIndex() == 0);
0129   CPPUNIT_ASSERT(indexIntoFile.processHistoryIDs().size() == 1);
0130   CPPUNIT_ASSERT(indexIntoFile.processHistoryIDs()[0] == fakePHID1);
0131   CPPUNIT_ASSERT(indexIntoFile.runOrLumiEntries()[1].orderPHIDRun() == 0);
0132   CPPUNIT_ASSERT(indexIntoFile.runOrLumiEntries()[1].orderPHIDRunLumi() == IndexIntoFile::invalidEntry);
0133   CPPUNIT_ASSERT(indexIntoFile.runOrLumiEntries()[1].beginEvents() == IndexIntoFile::invalidEntry);
0134   CPPUNIT_ASSERT(indexIntoFile.runOrLumiEntries()[1].endEvents() == IndexIntoFile::invalidEntry);
0135 
0136   indexIntoFile.addEntry(fakePHID2, 11, 12, 10, 2);  // Event
0137   indexIntoFile.addEntry(fakePHID2, 11, 12, 9, 3);   // Event
0138   indexIntoFile.addEntry(fakePHID2, 11, 12, 0, 1);   // Lumi
0139   CPPUNIT_ASSERT(indexIntoFile.runOrLumiEntries().size() == 3);
0140   CPPUNIT_ASSERT(indexIntoFile.runOrLumiEntries()[2].processHistoryIDIndex() == 1);
0141   CPPUNIT_ASSERT(indexIntoFile.processHistoryIDs().size() == 2);
0142   CPPUNIT_ASSERT(indexIntoFile.processHistoryIDs()[1] == fakePHID2);
0143   CPPUNIT_ASSERT(indexIntoFile.runOrLumiEntries()[2].orderPHIDRun() == IndexIntoFile::invalidEntry);
0144   CPPUNIT_ASSERT(indexIntoFile.setRunOrLumiEntries()[2].orderPHIDRunLumi() == 1);
0145   CPPUNIT_ASSERT(indexIntoFile.setRunOrLumiEntries()[2].beginEvents() == 2);
0146   CPPUNIT_ASSERT(indexIntoFile.setRunOrLumiEntries()[2].endEvents() == 4);
0147 
0148   indexIntoFile.addEntry(fakePHID2, 11, 0, 0, 1);  // Run
0149   CPPUNIT_ASSERT(indexIntoFile.runOrLumiEntries().size() == 4);
0150   CPPUNIT_ASSERT(indexIntoFile.runOrLumiEntries()[3].processHistoryIDIndex() == 1);
0151   CPPUNIT_ASSERT(indexIntoFile.processHistoryIDs().size() == 2);
0152   CPPUNIT_ASSERT(indexIntoFile.processHistoryIDs()[1] == fakePHID2);
0153   CPPUNIT_ASSERT(indexIntoFile.runOrLumiEntries()[3].orderPHIDRun() == 1);
0154   CPPUNIT_ASSERT(indexIntoFile.runOrLumiEntries()[3].orderPHIDRunLumi() == IndexIntoFile::invalidEntry);
0155   CPPUNIT_ASSERT(indexIntoFile.runOrLumiEntries()[3].beginEvents() == IndexIntoFile::invalidEntry);
0156   CPPUNIT_ASSERT(indexIntoFile.runOrLumiEntries()[3].endEvents() == IndexIntoFile::invalidEntry);
0157 
0158   indexIntoFile.addEntry(fakePHID1, 11, 12, 5, 4);  // Event
0159   indexIntoFile.addEntry(fakePHID1, 11, 12, 4, 5);  // Event
0160   indexIntoFile.addEntry(fakePHID1, 11, 12, 0, 2);  // Lumi
0161   CPPUNIT_ASSERT(indexIntoFile.runOrLumiEntries().size() == 5);
0162   CPPUNIT_ASSERT(indexIntoFile.runOrLumiEntries()[4].processHistoryIDIndex() == 0);
0163   CPPUNIT_ASSERT(indexIntoFile.processHistoryIDs().size() == 2);
0164   CPPUNIT_ASSERT(indexIntoFile.processHistoryIDs()[0] == fakePHID1);
0165   CPPUNIT_ASSERT(indexIntoFile.runOrLumiEntries()[4].orderPHIDRun() == IndexIntoFile::invalidEntry);
0166   CPPUNIT_ASSERT(indexIntoFile.runOrLumiEntries()[4].orderPHIDRunLumi() == 0);
0167   CPPUNIT_ASSERT(indexIntoFile.runOrLumiEntries()[4].beginEvents() == 4);
0168   CPPUNIT_ASSERT(indexIntoFile.runOrLumiEntries()[4].endEvents() == 6);
0169   CPPUNIT_ASSERT(indexIntoFile.runOrLumiEntries()[4].entry() == 2);
0170   CPPUNIT_ASSERT(indexIntoFile.runOrLumiEntries()[4].run() == 11);
0171   CPPUNIT_ASSERT(indexIntoFile.runOrLumiEntries()[4].lumi() == 12);
0172 
0173   indexIntoFile.addEntry(fakePHID1, 11, 0, 0, 2);  // Run
0174   CPPUNIT_ASSERT(indexIntoFile.runOrLumiEntries().size() == 6);
0175   CPPUNIT_ASSERT(indexIntoFile.processHistoryIDs().size() == 2);
0176   CPPUNIT_ASSERT(indexIntoFile.processHistoryIDs()[0] == fakePHID1);
0177   IndexIntoFile::RunOrLumiEntry const& runOrLumiEntry = indexIntoFile.runOrLumiEntries()[5];
0178   CPPUNIT_ASSERT(runOrLumiEntry.processHistoryIDIndex() == 0);
0179   CPPUNIT_ASSERT(runOrLumiEntry.orderPHIDRun() == 0);
0180   CPPUNIT_ASSERT(runOrLumiEntry.orderPHIDRunLumi() == IndexIntoFile::invalidEntry);
0181   CPPUNIT_ASSERT(runOrLumiEntry.beginEvents() == IndexIntoFile::invalidEntry);
0182   CPPUNIT_ASSERT(runOrLumiEntry.endEvents() == IndexIntoFile::invalidEntry);
0183   CPPUNIT_ASSERT(runOrLumiEntry.entry() == 2);
0184   CPPUNIT_ASSERT(runOrLumiEntry.run() == 11);
0185   CPPUNIT_ASSERT(runOrLumiEntry.lumi() == IndexIntoFile::invalidLumi);
0186 
0187   indexIntoFile.addEntry(fakePHID1, 1, 3, 0, 3);  // Lumi
0188   indexIntoFile.addEntry(fakePHID1, 1, 2, 8, 6);  // Event
0189   indexIntoFile.addEntry(fakePHID1, 1, 2, 0, 4);  // Lumi
0190   indexIntoFile.addEntry(fakePHID1, 1, 2, 0, 5);  // Lumi
0191   indexIntoFile.addEntry(fakePHID1, 1, 0, 0, 3);  // Run
0192 
0193   indexIntoFile.sortVector_Run_Or_Lumi_Entries();
0194 
0195   CPPUNIT_ASSERT(indexIntoFile.runOrLumiEntries()[0].orderPHIDRun() == 0);
0196   CPPUNIT_ASSERT(indexIntoFile.runOrLumiEntries()[1].orderPHIDRun() == 0);
0197   CPPUNIT_ASSERT(indexIntoFile.runOrLumiEntries()[2].orderPHIDRun() == 0);
0198   CPPUNIT_ASSERT(indexIntoFile.runOrLumiEntries()[3].orderPHIDRun() == 0);
0199   CPPUNIT_ASSERT(indexIntoFile.runOrLumiEntries()[4].orderPHIDRun() == 1);
0200   CPPUNIT_ASSERT(indexIntoFile.runOrLumiEntries()[5].orderPHIDRun() == 1);
0201   CPPUNIT_ASSERT(indexIntoFile.runOrLumiEntries()[6].orderPHIDRun() == 2);
0202   CPPUNIT_ASSERT(indexIntoFile.runOrLumiEntries()[7].orderPHIDRun() == 2);
0203   CPPUNIT_ASSERT(indexIntoFile.runOrLumiEntries()[8].orderPHIDRun() == 2);
0204   CPPUNIT_ASSERT(indexIntoFile.runOrLumiEntries()[9].orderPHIDRun() == 2);
0205 
0206   CPPUNIT_ASSERT(indexIntoFile.runOrLumiEntries()[0].orderPHIDRunLumi() == IndexIntoFile::invalidEntry);
0207   CPPUNIT_ASSERT(indexIntoFile.runOrLumiEntries()[1].orderPHIDRunLumi() == IndexIntoFile::invalidEntry);
0208   CPPUNIT_ASSERT(indexIntoFile.runOrLumiEntries()[2].orderPHIDRunLumi() == 0);
0209   CPPUNIT_ASSERT(indexIntoFile.runOrLumiEntries()[3].orderPHIDRunLumi() == 0);
0210   CPPUNIT_ASSERT(indexIntoFile.runOrLumiEntries()[4].orderPHIDRunLumi() == IndexIntoFile::invalidEntry);
0211   CPPUNIT_ASSERT(indexIntoFile.runOrLumiEntries()[5].orderPHIDRunLumi() == 1);
0212   CPPUNIT_ASSERT(indexIntoFile.runOrLumiEntries()[6].orderPHIDRunLumi() == IndexIntoFile::invalidEntry);
0213   CPPUNIT_ASSERT(indexIntoFile.runOrLumiEntries()[7].orderPHIDRunLumi() == 2);
0214   CPPUNIT_ASSERT(indexIntoFile.runOrLumiEntries()[8].orderPHIDRunLumi() == 3);
0215   CPPUNIT_ASSERT(indexIntoFile.runOrLumiEntries()[9].orderPHIDRunLumi() == 3);
0216 
0217   CPPUNIT_ASSERT(indexIntoFile.runOrLumiEntries()[0].entry() == 0);
0218   CPPUNIT_ASSERT(indexIntoFile.runOrLumiEntries()[1].entry() == 2);
0219   CPPUNIT_ASSERT(indexIntoFile.runOrLumiEntries()[2].entry() == 0);
0220   CPPUNIT_ASSERT(indexIntoFile.runOrLumiEntries()[3].entry() == 2);
0221   CPPUNIT_ASSERT(indexIntoFile.runOrLumiEntries()[4].entry() == 1);
0222   CPPUNIT_ASSERT(indexIntoFile.runOrLumiEntries()[5].entry() == 1);
0223   CPPUNIT_ASSERT(indexIntoFile.runOrLumiEntries()[6].entry() == 3);
0224   CPPUNIT_ASSERT(indexIntoFile.runOrLumiEntries()[7].entry() == 3);
0225   CPPUNIT_ASSERT(indexIntoFile.runOrLumiEntries()[8].entry() == 4);
0226   CPPUNIT_ASSERT(indexIntoFile.runOrLumiEntries()[9].entry() == 5);
0227 
0228   CPPUNIT_ASSERT(indexIntoFile.processHistoryID(0) == fakePHID1);
0229   CPPUNIT_ASSERT(indexIntoFile.processHistoryID(1) == fakePHID2);
0230 
0231   CPPUNIT_ASSERT(indexIntoFile.processHistoryIDs()[0] == fakePHID1);
0232   CPPUNIT_ASSERT(indexIntoFile.processHistoryIDs()[1] == fakePHID2);
0233 
0234   std::vector<ProcessHistoryID> sourcePHIDs;
0235   sourcePHIDs.push_back(fakePHID3);
0236   sourcePHIDs.push_back(fakePHID2);
0237 
0238   indexIntoFile.fixIndexes(sourcePHIDs);
0239 
0240   CPPUNIT_ASSERT(sourcePHIDs.size() == 3);
0241   CPPUNIT_ASSERT(sourcePHIDs[0] == fakePHID3);
0242   CPPUNIT_ASSERT(sourcePHIDs[1] == fakePHID2);
0243   CPPUNIT_ASSERT(sourcePHIDs[2] == fakePHID1);
0244   CPPUNIT_ASSERT(sourcePHIDs == indexIntoFile.processHistoryIDs());
0245 
0246   CPPUNIT_ASSERT(indexIntoFile.runOrLumiEntries()[0].processHistoryIDIndex() == 2);
0247   CPPUNIT_ASSERT(indexIntoFile.runOrLumiEntries()[1].processHistoryIDIndex() == 2);
0248   CPPUNIT_ASSERT(indexIntoFile.runOrLumiEntries()[2].processHistoryIDIndex() == 2);
0249   CPPUNIT_ASSERT(indexIntoFile.runOrLumiEntries()[3].processHistoryIDIndex() == 2);
0250   CPPUNIT_ASSERT(indexIntoFile.runOrLumiEntries()[4].processHistoryIDIndex() == 1);
0251   CPPUNIT_ASSERT(indexIntoFile.runOrLumiEntries()[5].processHistoryIDIndex() == 1);
0252   CPPUNIT_ASSERT(indexIntoFile.runOrLumiEntries()[6].processHistoryIDIndex() == 2);
0253   CPPUNIT_ASSERT(indexIntoFile.runOrLumiEntries()[7].processHistoryIDIndex() == 2);
0254   CPPUNIT_ASSERT(indexIntoFile.runOrLumiEntries()[8].processHistoryIDIndex() == 2);
0255   CPPUNIT_ASSERT(indexIntoFile.runOrLumiEntries()[9].processHistoryIDIndex() == 2);
0256 
0257   std::vector<ProcessHistoryID>& phids = indexIntoFile.setProcessHistoryIDs();
0258   phids.push_back(nullPHID);
0259   CPPUNIT_ASSERT(nullPHID == indexIntoFile.processHistoryID(3));
0260 
0261   unsigned count = 0;
0262   IndexIntoFile::SortedRunOrLumiItr runOrLumi = indexIntoFile.beginRunOrLumi();
0263   for (IndexIntoFile::SortedRunOrLumiItr endRunOrLumi = indexIntoFile.endRunOrLumi(); runOrLumi != endRunOrLumi;
0264        ++runOrLumi, ++count) {
0265     IndexIntoFile::RunOrLumiIndexes const& indexes = runOrLumi.runOrLumiIndexes();
0266     switch (count) {
0267       case 0:
0268         CPPUNIT_ASSERT(indexes.indexToGetEntry() == 4);
0269         CPPUNIT_ASSERT(indexes.beginEventNumbers() == -1);
0270         CPPUNIT_ASSERT(indexes.endEventNumbers() == -1);
0271         break;
0272       case 1:
0273         CPPUNIT_ASSERT(indexes.indexToGetEntry() == 5);
0274         CPPUNIT_ASSERT(indexes.beginEventNumbers() == 0);
0275         CPPUNIT_ASSERT(indexes.endEventNumbers() == 2);
0276         break;
0277       case 2:
0278         CPPUNIT_ASSERT(indexes.indexToGetEntry() == 6);
0279         CPPUNIT_ASSERT(indexes.beginEventNumbers() == -1);
0280         CPPUNIT_ASSERT(indexes.endEventNumbers() == -1);
0281         break;
0282       case 3:
0283         CPPUNIT_ASSERT(indexes.indexToGetEntry() == 8);
0284         CPPUNIT_ASSERT(indexes.beginEventNumbers() == 2);
0285         CPPUNIT_ASSERT(indexes.endEventNumbers() == 3);
0286         break;
0287       case 4:
0288         CPPUNIT_ASSERT(indexes.indexToGetEntry() == 9);
0289         CPPUNIT_ASSERT(indexes.beginEventNumbers() == 2);
0290         CPPUNIT_ASSERT(indexes.endEventNumbers() == 3);
0291         break;
0292       case 5:
0293         CPPUNIT_ASSERT(indexes.indexToGetEntry() == 7);
0294         CPPUNIT_ASSERT(indexes.beginEventNumbers() == 3);
0295         CPPUNIT_ASSERT(indexes.endEventNumbers() == 3);
0296         break;
0297       case 6:
0298         CPPUNIT_ASSERT(indexes.indexToGetEntry() == 0);
0299         CPPUNIT_ASSERT(indexes.beginEventNumbers() == -1);
0300         CPPUNIT_ASSERT(indexes.endEventNumbers() == -1);
0301         break;
0302       case 7:
0303         CPPUNIT_ASSERT(indexes.indexToGetEntry() == 1);
0304         CPPUNIT_ASSERT(indexes.beginEventNumbers() == -1);
0305         CPPUNIT_ASSERT(indexes.endEventNumbers() == -1);
0306         break;
0307       case 8:
0308         CPPUNIT_ASSERT(indexes.indexToGetEntry() == 2);
0309         CPPUNIT_ASSERT(indexes.beginEventNumbers() == 3);
0310         CPPUNIT_ASSERT(indexes.endEventNumbers() == 7);
0311         break;
0312       case 9:
0313         CPPUNIT_ASSERT(indexes.indexToGetEntry() == 3);
0314         CPPUNIT_ASSERT(indexes.beginEventNumbers() == 3);
0315         CPPUNIT_ASSERT(indexes.endEventNumbers() == 7);
0316         break;
0317     }
0318   }
0319 
0320   std::vector<EventNumber_t>& eventNumbers = indexIntoFile.eventNumbers();
0321 
0322   eventNumbers.push_back(10);
0323   eventNumbers.push_back(9);
0324   eventNumbers.push_back(8);
0325   eventNumbers.push_back(7);
0326   eventNumbers.push_back(6);
0327   eventNumbers.push_back(5);
0328   eventNumbers.push_back(4);
0329   indexIntoFile.sortEvents();
0330 
0331   CPPUNIT_ASSERT(eventNumbers[0] == 9);
0332   CPPUNIT_ASSERT(eventNumbers[1] == 10);
0333   CPPUNIT_ASSERT(eventNumbers[2] == 8);
0334   CPPUNIT_ASSERT(eventNumbers[3] == 4);
0335   CPPUNIT_ASSERT(eventNumbers[4] == 5);
0336   CPPUNIT_ASSERT(eventNumbers[5] == 6);
0337   CPPUNIT_ASSERT(eventNumbers[6] == 7);
0338 
0339   std::vector<IndexIntoFile::EventEntry>& eventEntries = indexIntoFile.eventEntries();
0340 
0341   eventEntries.emplace_back(10, 2);
0342   eventEntries.emplace_back(9, 3);
0343   eventEntries.emplace_back(8, 6);
0344   eventEntries.emplace_back(7, 0);
0345   eventEntries.emplace_back(6, 1);
0346   eventEntries.emplace_back(5, 4);
0347   eventEntries.emplace_back(4, 5);
0348   indexIntoFile.sortEventEntries();
0349 
0350   CPPUNIT_ASSERT(eventEntries[0].event() == 9);
0351   CPPUNIT_ASSERT(eventEntries[1].event() == 10);
0352   CPPUNIT_ASSERT(eventEntries[2].event() == 8);
0353   CPPUNIT_ASSERT(eventEntries[3].event() == 4);
0354   CPPUNIT_ASSERT(eventEntries[4].event() == 5);
0355   CPPUNIT_ASSERT(eventEntries[5].event() == 6);
0356   CPPUNIT_ASSERT(eventEntries[6].event() == 7);
0357 
0358   std::vector<EventNumber_t>().swap(eventNumbers);
0359   std::vector<IndexIntoFile::EventEntry>().swap(eventEntries);
0360 
0361   CPPUNIT_ASSERT(indexIntoFile.numberOfEvents() == 7);
0362 
0363   TestEventFinder* ptr(new TestEventFinder);
0364   ptr->push_back(7);
0365   ptr->push_back(6);
0366   ptr->push_back(10);
0367   ptr->push_back(9);
0368   ptr->push_back(5);
0369   ptr->push_back(4);
0370   ptr->push_back(8);
0371 
0372   std::shared_ptr<IndexIntoFile::EventFinder> shptr(ptr);
0373   indexIntoFile.setEventFinder(shptr);
0374 
0375   indexIntoFile.fillEventNumbers();
0376   CPPUNIT_ASSERT(eventNumbers[0] == 9);
0377   CPPUNIT_ASSERT(eventNumbers[1] == 10);
0378   CPPUNIT_ASSERT(eventNumbers[2] == 8);
0379   CPPUNIT_ASSERT(eventNumbers[3] == 4);
0380   CPPUNIT_ASSERT(eventNumbers[4] == 5);
0381   CPPUNIT_ASSERT(eventNumbers[5] == 6);
0382   CPPUNIT_ASSERT(eventNumbers[6] == 7);
0383 
0384   indexIntoFile.fillEventEntries();
0385   CPPUNIT_ASSERT(eventEntries[0].event() == 9);
0386   CPPUNIT_ASSERT(eventEntries[1].event() == 10);
0387   CPPUNIT_ASSERT(eventEntries[2].event() == 8);
0388   CPPUNIT_ASSERT(eventEntries[3].event() == 4);
0389   CPPUNIT_ASSERT(eventEntries[4].event() == 5);
0390   CPPUNIT_ASSERT(eventEntries[5].event() == 6);
0391   CPPUNIT_ASSERT(eventEntries[6].event() == 7);
0392 
0393   std::vector<EventNumber_t>().swap(eventNumbers);
0394   std::vector<IndexIntoFile::EventEntry>().swap(eventEntries);
0395 
0396   indexIntoFile.fillEventEntries();
0397   CPPUNIT_ASSERT(eventEntries[0].event() == 9);
0398   CPPUNIT_ASSERT(eventEntries[1].event() == 10);
0399   CPPUNIT_ASSERT(eventEntries[2].event() == 8);
0400   CPPUNIT_ASSERT(eventEntries[3].event() == 4);
0401   CPPUNIT_ASSERT(eventEntries[4].event() == 5);
0402   CPPUNIT_ASSERT(eventEntries[5].event() == 6);
0403   CPPUNIT_ASSERT(eventEntries[6].event() == 7);
0404 
0405   indexIntoFile.fillEventNumbers();
0406   CPPUNIT_ASSERT(eventNumbers[0] == 9);
0407   CPPUNIT_ASSERT(eventNumbers[1] == 10);
0408   CPPUNIT_ASSERT(eventNumbers[2] == 8);
0409   CPPUNIT_ASSERT(eventNumbers[3] == 4);
0410   CPPUNIT_ASSERT(eventNumbers[4] == 5);
0411   CPPUNIT_ASSERT(eventNumbers[5] == 6);
0412   CPPUNIT_ASSERT(eventNumbers[6] == 7);
0413 
0414   std::vector<EventNumber_t>().swap(eventNumbers);
0415   std::vector<IndexIntoFile::EventEntry>().swap(eventEntries);
0416 
0417   indexIntoFile.fillEventNumbersOrEntries(true, true);
0418   indexIntoFile.fillEventNumbersOrEntries(true, true);
0419 
0420   CPPUNIT_ASSERT(eventNumbers[0] == 9);
0421   CPPUNIT_ASSERT(eventNumbers[1] == 10);
0422   CPPUNIT_ASSERT(eventNumbers[2] == 8);
0423   CPPUNIT_ASSERT(eventNumbers[3] == 4);
0424   CPPUNIT_ASSERT(eventNumbers[4] == 5);
0425   CPPUNIT_ASSERT(eventNumbers[5] == 6);
0426   CPPUNIT_ASSERT(eventNumbers[6] == 7);
0427 
0428   CPPUNIT_ASSERT(eventEntries[0].event() == 9);
0429   CPPUNIT_ASSERT(eventEntries[1].event() == 10);
0430   CPPUNIT_ASSERT(eventEntries[2].event() == 8);
0431   CPPUNIT_ASSERT(eventEntries[3].event() == 4);
0432   CPPUNIT_ASSERT(eventEntries[4].event() == 5);
0433   CPPUNIT_ASSERT(eventEntries[5].event() == 6);
0434   CPPUNIT_ASSERT(eventEntries[6].event() == 7);
0435 
0436   std::vector<EventNumber_t>().swap(eventNumbers);
0437   std::vector<IndexIntoFile::EventEntry>().swap(eventEntries);
0438 
0439   std::vector<EventNumber_t>& unsortedEventNumbers = indexIntoFile.unsortedEventNumbers();
0440   CPPUNIT_ASSERT(!unsortedEventNumbers.empty());
0441   indexIntoFile.doneFileInitialization();
0442   CPPUNIT_ASSERT(unsortedEventNumbers.empty());
0443   CPPUNIT_ASSERT(unsortedEventNumbers.capacity() == 0);
0444   unsortedEventNumbers.push_back(7);
0445   unsortedEventNumbers.push_back(6);
0446   unsortedEventNumbers.push_back(10);
0447   unsortedEventNumbers.push_back(9);
0448   unsortedEventNumbers.push_back(5);
0449   unsortedEventNumbers.push_back(4);
0450   unsortedEventNumbers.push_back(8);
0451 
0452   indexIntoFile.fillEventNumbersOrEntries(true, true);
0453 
0454   CPPUNIT_ASSERT(eventNumbers[0] == 9);
0455   CPPUNIT_ASSERT(eventNumbers[1] == 10);
0456   CPPUNIT_ASSERT(eventNumbers[2] == 8);
0457   CPPUNIT_ASSERT(eventNumbers[3] == 4);
0458   CPPUNIT_ASSERT(eventNumbers[4] == 5);
0459   CPPUNIT_ASSERT(eventNumbers[5] == 6);
0460   CPPUNIT_ASSERT(eventNumbers[6] == 7);
0461 
0462   CPPUNIT_ASSERT(eventEntries[0].event() == 9);
0463   CPPUNIT_ASSERT(eventEntries[1].event() == 10);
0464   CPPUNIT_ASSERT(eventEntries[2].event() == 8);
0465   CPPUNIT_ASSERT(eventEntries[3].event() == 4);
0466   CPPUNIT_ASSERT(eventEntries[4].event() == 5);
0467   CPPUNIT_ASSERT(eventEntries[5].event() == 6);
0468   CPPUNIT_ASSERT(eventEntries[6].event() == 7);
0469 
0470   indexIntoFile.inputFileClosed();
0471   CPPUNIT_ASSERT(unsortedEventNumbers.empty());
0472   CPPUNIT_ASSERT(unsortedEventNumbers.capacity() == 0);
0473   CPPUNIT_ASSERT(eventEntries.capacity() == 0);
0474   CPPUNIT_ASSERT(eventEntries.empty());
0475   CPPUNIT_ASSERT(indexIntoFile.runOrLumiIndexes().capacity() == 0);
0476   CPPUNIT_ASSERT(indexIntoFile.runOrLumiIndexes().empty());
0477   CPPUNIT_ASSERT(indexIntoFile.transient_.eventFinder_.get() == 0);
0478 }
0479 void TestIndexIntoFile2::testAddEntryAndFixAndSort2() {
0480   // Similar to the last test, but this one focuses on the ordering
0481   // issues that can occur on boundaries between runs and boundaries
0482   // between lumis with concurrent lumis and concurrent runs.
0483   edm::IndexIntoFile indexIntoFile;
0484 
0485   indexIntoFile.addEntry(fakePHID1, 11, 1, 0, 0);  // Lumi
0486   CPPUNIT_ASSERT(indexIntoFile.runOrLumiEntries().size() == 1);
0487   CPPUNIT_ASSERT(indexIntoFile.runOrLumiEntries()[0].processHistoryIDIndex() == 0);
0488   CPPUNIT_ASSERT(indexIntoFile.processHistoryIDs().size() == 1);
0489   CPPUNIT_ASSERT(indexIntoFile.processHistoryIDs()[0] == fakePHID1);
0490   CPPUNIT_ASSERT(indexIntoFile.runOrLumiEntries()[0].orderPHIDRun() == IndexIntoFile::invalidEntry);
0491   CPPUNIT_ASSERT(indexIntoFile.runOrLumiEntries()[0].orderPHIDRunLumi() == 0);
0492   CPPUNIT_ASSERT(indexIntoFile.runOrLumiEntries()[0].entry() == 0);
0493   CPPUNIT_ASSERT(indexIntoFile.runOrLumiEntries()[0].run() == 11);
0494   CPPUNIT_ASSERT(indexIntoFile.runOrLumiEntries()[0].lumi() == 1);
0495   CPPUNIT_ASSERT(indexIntoFile.runOrLumiEntries()[0].beginEvents() == IndexIntoFile::invalidEntry);
0496   CPPUNIT_ASSERT(indexIntoFile.runOrLumiEntries()[0].endEvents() == IndexIntoFile::invalidEntry);
0497 
0498   indexIntoFile.addEntry(fakePHID1, 1, 1, 1, 0);  // Event
0499   indexIntoFile.addEntry(fakePHID2, 1, 1, 0, 1);  // Lumi
0500   CPPUNIT_ASSERT(indexIntoFile.runOrLumiEntries().size() == 3);
0501 
0502   CPPUNIT_ASSERT(indexIntoFile.runOrLumiEntries()[1].processHistoryIDIndex() == 0);
0503   CPPUNIT_ASSERT(indexIntoFile.processHistoryIDs().size() == 2);
0504   CPPUNIT_ASSERT(indexIntoFile.processHistoryIDs()[0] == fakePHID1);
0505   CPPUNIT_ASSERT(indexIntoFile.runOrLumiEntries()[1].orderPHIDRun() == IndexIntoFile::invalidEntry);
0506   CPPUNIT_ASSERT(indexIntoFile.runOrLumiEntries()[1].orderPHIDRunLumi() == 1);
0507   CPPUNIT_ASSERT(indexIntoFile.runOrLumiEntries()[1].entry() == IndexIntoFile::invalidEntry);
0508   CPPUNIT_ASSERT(indexIntoFile.runOrLumiEntries()[1].run() == 1);
0509   CPPUNIT_ASSERT(indexIntoFile.runOrLumiEntries()[1].lumi() == 1);
0510   CPPUNIT_ASSERT(indexIntoFile.runOrLumiEntries()[1].beginEvents() == 0);
0511   CPPUNIT_ASSERT(indexIntoFile.runOrLumiEntries()[1].endEvents() == 1);
0512 
0513   CPPUNIT_ASSERT(indexIntoFile.runOrLumiEntries()[2].processHistoryIDIndex() == 1);
0514   CPPUNIT_ASSERT(indexIntoFile.processHistoryIDs().size() == 2);
0515   CPPUNIT_ASSERT(indexIntoFile.processHistoryIDs()[1] == fakePHID2);
0516   CPPUNIT_ASSERT(indexIntoFile.runOrLumiEntries()[2].orderPHIDRun() == IndexIntoFile::invalidEntry);
0517   CPPUNIT_ASSERT(indexIntoFile.runOrLumiEntries()[2].orderPHIDRunLumi() == 2);
0518   CPPUNIT_ASSERT(indexIntoFile.runOrLumiEntries()[2].entry() == 1);
0519   CPPUNIT_ASSERT(indexIntoFile.runOrLumiEntries()[2].run() == 1);
0520   CPPUNIT_ASSERT(indexIntoFile.runOrLumiEntries()[2].lumi() == 1);
0521   CPPUNIT_ASSERT(indexIntoFile.runOrLumiEntries()[2].beginEvents() == IndexIntoFile::invalidEntry);
0522   CPPUNIT_ASSERT(indexIntoFile.runOrLumiEntries()[2].endEvents() == IndexIntoFile::invalidEntry);
0523 
0524   indexIntoFile.addEntry(fakePHID1, 1, 1, 2, 1);  // Event
0525   indexIntoFile.addEntry(fakePHID1, 2, 1, 0, 2);  // Lumi
0526 
0527   CPPUNIT_ASSERT(indexIntoFile.runOrLumiEntries().size() == 5);
0528   CPPUNIT_ASSERT(indexIntoFile.runOrLumiEntries()[3].processHistoryIDIndex() == 0);
0529   CPPUNIT_ASSERT(indexIntoFile.processHistoryIDs().size() == 2);
0530   CPPUNIT_ASSERT(indexIntoFile.processHistoryIDs()[0] == fakePHID1);
0531   CPPUNIT_ASSERT(indexIntoFile.runOrLumiEntries()[3].orderPHIDRun() == IndexIntoFile::invalidEntry);
0532   CPPUNIT_ASSERT(indexIntoFile.runOrLumiEntries()[3].orderPHIDRunLumi() == 1);
0533   CPPUNIT_ASSERT(indexIntoFile.runOrLumiEntries()[3].entry() == IndexIntoFile::invalidEntry);
0534   CPPUNIT_ASSERT(indexIntoFile.runOrLumiEntries()[3].run() == 1);
0535   CPPUNIT_ASSERT(indexIntoFile.runOrLumiEntries()[3].lumi() == 1);
0536   CPPUNIT_ASSERT(indexIntoFile.runOrLumiEntries()[3].beginEvents() == 1);
0537   CPPUNIT_ASSERT(indexIntoFile.runOrLumiEntries()[3].endEvents() == 2);
0538 
0539   CPPUNIT_ASSERT(indexIntoFile.runOrLumiEntries()[4].processHistoryIDIndex() == 0);
0540   CPPUNIT_ASSERT(indexIntoFile.processHistoryIDs().size() == 2);
0541   CPPUNIT_ASSERT(indexIntoFile.processHistoryIDs()[0] == fakePHID1);
0542   CPPUNIT_ASSERT(indexIntoFile.runOrLumiEntries()[4].orderPHIDRun() == IndexIntoFile::invalidEntry);
0543   CPPUNIT_ASSERT(indexIntoFile.runOrLumiEntries()[4].orderPHIDRunLumi() == 3);
0544   CPPUNIT_ASSERT(indexIntoFile.runOrLumiEntries()[4].entry() == 2);
0545   CPPUNIT_ASSERT(indexIntoFile.runOrLumiEntries()[4].run() == 2);
0546   CPPUNIT_ASSERT(indexIntoFile.runOrLumiEntries()[4].lumi() == 1);
0547   CPPUNIT_ASSERT(indexIntoFile.runOrLumiEntries()[4].beginEvents() == IndexIntoFile::invalidEntry);
0548   CPPUNIT_ASSERT(indexIntoFile.runOrLumiEntries()[4].endEvents() == IndexIntoFile::invalidEntry);
0549 
0550   indexIntoFile.addEntry(fakePHID1, 1, 1, 3, 2);  // Event
0551   indexIntoFile.addEntry(fakePHID1, 1, 2, 0, 3);  // Lumi
0552 
0553   CPPUNIT_ASSERT(indexIntoFile.runOrLumiEntries().size() == 7);
0554   CPPUNIT_ASSERT(indexIntoFile.runOrLumiEntries()[5].processHistoryIDIndex() == 0);
0555   CPPUNIT_ASSERT(indexIntoFile.processHistoryIDs().size() == 2);
0556   CPPUNIT_ASSERT(indexIntoFile.processHistoryIDs()[0] == fakePHID1);
0557   CPPUNIT_ASSERT(indexIntoFile.runOrLumiEntries()[5].orderPHIDRun() == IndexIntoFile::invalidEntry);
0558   CPPUNIT_ASSERT(indexIntoFile.runOrLumiEntries()[5].orderPHIDRunLumi() == 1);
0559   CPPUNIT_ASSERT(indexIntoFile.runOrLumiEntries()[5].entry() == IndexIntoFile::invalidEntry);
0560   CPPUNIT_ASSERT(indexIntoFile.runOrLumiEntries()[5].run() == 1);
0561   CPPUNIT_ASSERT(indexIntoFile.runOrLumiEntries()[5].lumi() == 1);
0562   CPPUNIT_ASSERT(indexIntoFile.runOrLumiEntries()[5].beginEvents() == 2);
0563   CPPUNIT_ASSERT(indexIntoFile.runOrLumiEntries()[5].endEvents() == 3);
0564 
0565   CPPUNIT_ASSERT(indexIntoFile.runOrLumiEntries()[6].processHistoryIDIndex() == 0);
0566   CPPUNIT_ASSERT(indexIntoFile.processHistoryIDs().size() == 2);
0567   CPPUNIT_ASSERT(indexIntoFile.processHistoryIDs()[0] == fakePHID1);
0568   CPPUNIT_ASSERT(indexIntoFile.runOrLumiEntries()[6].orderPHIDRun() == IndexIntoFile::invalidEntry);
0569   CPPUNIT_ASSERT(indexIntoFile.runOrLumiEntries()[6].orderPHIDRunLumi() == 4);
0570   CPPUNIT_ASSERT(indexIntoFile.runOrLumiEntries()[6].entry() == 3);
0571   CPPUNIT_ASSERT(indexIntoFile.runOrLumiEntries()[6].run() == 1);
0572   CPPUNIT_ASSERT(indexIntoFile.runOrLumiEntries()[6].lumi() == 2);
0573   CPPUNIT_ASSERT(indexIntoFile.runOrLumiEntries()[6].beginEvents() == IndexIntoFile::invalidEntry);
0574   CPPUNIT_ASSERT(indexIntoFile.runOrLumiEntries()[6].endEvents() == IndexIntoFile::invalidEntry);
0575 
0576   indexIntoFile.addEntry(fakePHID1, 1, 2, 0, 4);  // Lumi
0577 
0578   CPPUNIT_ASSERT(indexIntoFile.runOrLumiEntries().size() == 8);
0579   CPPUNIT_ASSERT(indexIntoFile.runOrLumiEntries()[7].processHistoryIDIndex() == 0);
0580   CPPUNIT_ASSERT(indexIntoFile.processHistoryIDs().size() == 2);
0581   CPPUNIT_ASSERT(indexIntoFile.processHistoryIDs()[0] == fakePHID1);
0582   CPPUNIT_ASSERT(indexIntoFile.runOrLumiEntries()[7].orderPHIDRun() == IndexIntoFile::invalidEntry);
0583   CPPUNIT_ASSERT(indexIntoFile.runOrLumiEntries()[7].orderPHIDRunLumi() == 4);
0584   CPPUNIT_ASSERT(indexIntoFile.runOrLumiEntries()[7].entry() == 4);
0585   CPPUNIT_ASSERT(indexIntoFile.runOrLumiEntries()[7].run() == 1);
0586   CPPUNIT_ASSERT(indexIntoFile.runOrLumiEntries()[7].lumi() == 2);
0587   CPPUNIT_ASSERT(indexIntoFile.runOrLumiEntries()[7].beginEvents() == IndexIntoFile::invalidEntry);
0588   CPPUNIT_ASSERT(indexIntoFile.runOrLumiEntries()[7].endEvents() == IndexIntoFile::invalidEntry);
0589 
0590   indexIntoFile.addEntry(fakePHID1, 1, 1, 4, 3);  // Event
0591   indexIntoFile.addEntry(fakePHID1, 3, 0, 0, 0);  // Run
0592   CPPUNIT_ASSERT(indexIntoFile.runOrLumiEntries().size() == 9);
0593   CPPUNIT_ASSERT(indexIntoFile.runOrLumiEntries()[8].processHistoryIDIndex() == 0);
0594   CPPUNIT_ASSERT(indexIntoFile.processHistoryIDs().size() == 2);
0595   CPPUNIT_ASSERT(indexIntoFile.processHistoryIDs()[0] == fakePHID1);
0596   CPPUNIT_ASSERT(indexIntoFile.runOrLumiEntries()[8].orderPHIDRun() == 4);
0597   CPPUNIT_ASSERT(indexIntoFile.runOrLumiEntries()[8].orderPHIDRunLumi() == IndexIntoFile::invalidEntry);
0598   CPPUNIT_ASSERT(indexIntoFile.runOrLumiEntries()[8].entry() == 0);
0599   CPPUNIT_ASSERT(indexIntoFile.runOrLumiEntries()[8].run() == 3);
0600   CPPUNIT_ASSERT(indexIntoFile.runOrLumiEntries()[8].lumi() == IndexIntoFile::invalidLumi);
0601   CPPUNIT_ASSERT(indexIntoFile.runOrLumiEntries()[8].beginEvents() == IndexIntoFile::invalidEntry);
0602   CPPUNIT_ASSERT(indexIntoFile.runOrLumiEntries()[8].endEvents() == IndexIntoFile::invalidEntry);
0603 
0604   indexIntoFile.addEntry(fakePHID2, 1, 1, 1, 4);  // Event
0605   CPPUNIT_ASSERT(indexIntoFile.runOrLumiEntries().size() == 10);
0606   CPPUNIT_ASSERT(indexIntoFile.runOrLumiEntries()[9].processHistoryIDIndex() == 0);
0607   CPPUNIT_ASSERT(indexIntoFile.processHistoryIDs().size() == 2);
0608   CPPUNIT_ASSERT(indexIntoFile.processHistoryIDs()[0] == fakePHID1);
0609   CPPUNIT_ASSERT(indexIntoFile.runOrLumiEntries()[9].orderPHIDRun() == IndexIntoFile::invalidEntry);
0610   CPPUNIT_ASSERT(indexIntoFile.runOrLumiEntries()[9].orderPHIDRunLumi() == 1);
0611   CPPUNIT_ASSERT(indexIntoFile.runOrLumiEntries()[9].entry() == IndexIntoFile::invalidEntry);
0612   CPPUNIT_ASSERT(indexIntoFile.runOrLumiEntries()[9].run() == 1);
0613   CPPUNIT_ASSERT(indexIntoFile.runOrLumiEntries()[9].lumi() == 1);
0614   CPPUNIT_ASSERT(indexIntoFile.runOrLumiEntries()[9].beginEvents() == 3);
0615   CPPUNIT_ASSERT(indexIntoFile.runOrLumiEntries()[9].endEvents() == 4);
0616 
0617   indexIntoFile.addEntry(fakePHID2, 2, 1, 5, 5);  // Event
0618   CPPUNIT_ASSERT(indexIntoFile.runOrLumiEntries().size() == 11);
0619   CPPUNIT_ASSERT(indexIntoFile.runOrLumiEntries()[10].processHistoryIDIndex() == 1);
0620   CPPUNIT_ASSERT(indexIntoFile.processHistoryIDs().size() == 2);
0621   CPPUNIT_ASSERT(indexIntoFile.processHistoryIDs()[1] == fakePHID2);
0622   CPPUNIT_ASSERT(indexIntoFile.runOrLumiEntries()[10].orderPHIDRun() == IndexIntoFile::invalidEntry);
0623   CPPUNIT_ASSERT(indexIntoFile.runOrLumiEntries()[10].orderPHIDRunLumi() == 2);
0624   CPPUNIT_ASSERT(indexIntoFile.runOrLumiEntries()[10].entry() == IndexIntoFile::invalidEntry);
0625   CPPUNIT_ASSERT(indexIntoFile.runOrLumiEntries()[10].run() == 1);
0626   CPPUNIT_ASSERT(indexIntoFile.runOrLumiEntries()[10].lumi() == 1);
0627   CPPUNIT_ASSERT(indexIntoFile.runOrLumiEntries()[10].beginEvents() == 4);
0628   CPPUNIT_ASSERT(indexIntoFile.runOrLumiEntries()[10].endEvents() == 5);
0629 
0630   indexIntoFile.addEntry(fakePHID2, 2, 2, 1, 6);  // Event
0631   CPPUNIT_ASSERT(indexIntoFile.runOrLumiEntries().size() == 12);
0632   CPPUNIT_ASSERT(indexIntoFile.runOrLumiEntries()[11].processHistoryIDIndex() == 1);
0633   CPPUNIT_ASSERT(indexIntoFile.processHistoryIDs().size() == 2);
0634   CPPUNIT_ASSERT(indexIntoFile.processHistoryIDs()[1] == fakePHID2);
0635   CPPUNIT_ASSERT(indexIntoFile.runOrLumiEntries()[11].orderPHIDRun() == IndexIntoFile::invalidEntry);
0636   CPPUNIT_ASSERT(indexIntoFile.runOrLumiEntries()[11].orderPHIDRunLumi() == 5);
0637   CPPUNIT_ASSERT(indexIntoFile.runOrLumiEntries()[11].entry() == IndexIntoFile::invalidEntry);
0638   CPPUNIT_ASSERT(indexIntoFile.runOrLumiEntries()[11].run() == 2);
0639   CPPUNIT_ASSERT(indexIntoFile.runOrLumiEntries()[11].lumi() == 1);
0640   CPPUNIT_ASSERT(indexIntoFile.runOrLumiEntries()[11].beginEvents() == 5);
0641   CPPUNIT_ASSERT(indexIntoFile.runOrLumiEntries()[11].endEvents() == 6);
0642 
0643   indexIntoFile.addEntry(fakePHID2, 2, 2, 2, 7);  // Event
0644   indexIntoFile.addEntry(fakePHID2, 2, 2, 0, 5);  // Lumi
0645   CPPUNIT_ASSERT(indexIntoFile.runOrLumiEntries().size() == 13);
0646   CPPUNIT_ASSERT(indexIntoFile.runOrLumiEntries()[12].processHistoryIDIndex() == 1);
0647   CPPUNIT_ASSERT(indexIntoFile.processHistoryIDs().size() == 2);
0648   CPPUNIT_ASSERT(indexIntoFile.processHistoryIDs()[1] == fakePHID2);
0649   CPPUNIT_ASSERT(indexIntoFile.runOrLumiEntries()[12].orderPHIDRun() == IndexIntoFile::invalidEntry);
0650   CPPUNIT_ASSERT(indexIntoFile.runOrLumiEntries()[12].orderPHIDRunLumi() == 6);
0651   CPPUNIT_ASSERT(indexIntoFile.runOrLumiEntries()[12].entry() == 5);
0652   CPPUNIT_ASSERT(indexIntoFile.runOrLumiEntries()[12].run() == 2);
0653   CPPUNIT_ASSERT(indexIntoFile.runOrLumiEntries()[12].lumi() == 2);
0654   CPPUNIT_ASSERT(indexIntoFile.runOrLumiEntries()[12].beginEvents() == 6);
0655   CPPUNIT_ASSERT(indexIntoFile.runOrLumiEntries()[12].endEvents() == 8);
0656 
0657   indexIntoFile.addEntry(fakePHID1, 1, 1, 0, 6);  // Lumi
0658   indexIntoFile.addEntry(fakePHID2, 1, 1, 0, 7);  // Lumi
0659   indexIntoFile.addEntry(fakePHID2, 2, 1, 0, 8);  // Lumi
0660 
0661   indexIntoFile.addEntry(fakePHID1, 11, 0, 0, 1);  // Run
0662   indexIntoFile.addEntry(fakePHID1, 1, 0, 0, 2);   // Run
0663   CPPUNIT_ASSERT(indexIntoFile.runOrLumiEntries()[17].orderPHIDRun() == 1);
0664   indexIntoFile.addEntry(fakePHID2, 1, 0, 0, 3);  // Run
0665 
0666   indexIntoFile.addEntry(fakePHID2, 2, 0, 0, 4);  // Run
0667   CPPUNIT_ASSERT(indexIntoFile.runOrLumiEntries().size() == 20);
0668   CPPUNIT_ASSERT(indexIntoFile.runOrLumiEntries()[19].processHistoryIDIndex() == 1);
0669   CPPUNIT_ASSERT(indexIntoFile.processHistoryIDs().size() == 2);
0670   CPPUNIT_ASSERT(indexIntoFile.processHistoryIDs()[1] == fakePHID2);
0671   CPPUNIT_ASSERT(indexIntoFile.runOrLumiEntries()[19].orderPHIDRun() == 5);
0672   CPPUNIT_ASSERT(indexIntoFile.runOrLumiEntries()[19].orderPHIDRunLumi() == IndexIntoFile::invalidEntry);
0673   CPPUNIT_ASSERT(indexIntoFile.runOrLumiEntries()[19].entry() == 4);
0674   CPPUNIT_ASSERT(indexIntoFile.runOrLumiEntries()[19].run() == 2);
0675   CPPUNIT_ASSERT(indexIntoFile.runOrLumiEntries()[19].lumi() == IndexIntoFile::invalidLumi);
0676   CPPUNIT_ASSERT(indexIntoFile.runOrLumiEntries()[19].beginEvents() == IndexIntoFile::invalidEntry);
0677   CPPUNIT_ASSERT(indexIntoFile.runOrLumiEntries()[19].endEvents() == IndexIntoFile::invalidEntry);
0678 
0679   indexIntoFile.addEntry(fakePHID1, 2, 0, 0, 5);  // Run
0680 
0681   indexIntoFile.sortVector_Run_Or_Lumi_Entries();
0682 
0683   int index = 0;
0684   for (auto const& entry : indexIntoFile.runOrLumiEntries()) {
0685     switch (index) {
0686       case 0:
0687         CPPUNIT_ASSERT(entry.orderPHIDRun() == 0);
0688         CPPUNIT_ASSERT(entry.orderPHIDRunLumi() == IndexIntoFile::invalidEntry);
0689         CPPUNIT_ASSERT(entry.entry() == 1);
0690         break;
0691       case 1:
0692         CPPUNIT_ASSERT(entry.orderPHIDRun() == 0);
0693         CPPUNIT_ASSERT(entry.orderPHIDRunLumi() == 0);
0694         CPPUNIT_ASSERT(entry.entry() == 0);
0695         break;
0696       case 2:
0697         CPPUNIT_ASSERT(entry.orderPHIDRun() == 1);
0698         CPPUNIT_ASSERT(entry.orderPHIDRunLumi() == IndexIntoFile::invalidEntry);
0699         CPPUNIT_ASSERT(entry.entry() == 2);
0700         break;
0701       case 3:
0702         CPPUNIT_ASSERT(entry.orderPHIDRun() == 1);
0703         CPPUNIT_ASSERT(entry.orderPHIDRunLumi() == 1);
0704         CPPUNIT_ASSERT(entry.entry() == IndexIntoFile::invalidEntry);
0705         break;
0706       case 4:
0707         CPPUNIT_ASSERT(entry.orderPHIDRun() == 1);
0708         CPPUNIT_ASSERT(entry.orderPHIDRunLumi() == 1);
0709         CPPUNIT_ASSERT(entry.entry() == IndexIntoFile::invalidEntry);
0710         break;
0711       case 5:
0712         CPPUNIT_ASSERT(entry.orderPHIDRun() == 1);
0713         CPPUNIT_ASSERT(entry.orderPHIDRunLumi() == 1);
0714         CPPUNIT_ASSERT(entry.entry() == IndexIntoFile::invalidEntry);
0715         break;
0716       case 6:
0717         CPPUNIT_ASSERT(entry.orderPHIDRun() == 1);
0718         CPPUNIT_ASSERT(entry.orderPHIDRunLumi() == 1);
0719         CPPUNIT_ASSERT(entry.entry() == IndexIntoFile::invalidEntry);
0720         break;
0721       case 7:
0722         CPPUNIT_ASSERT(entry.orderPHIDRun() == 1);
0723         CPPUNIT_ASSERT(entry.orderPHIDRunLumi() == 1);
0724         CPPUNIT_ASSERT(entry.entry() == 6);
0725         break;
0726       case 8:
0727         CPPUNIT_ASSERT(entry.orderPHIDRun() == 1);
0728         CPPUNIT_ASSERT(entry.orderPHIDRunLumi() == 4);
0729         CPPUNIT_ASSERT(entry.entry() == 3);
0730         break;
0731       case 9:
0732         CPPUNIT_ASSERT(entry.orderPHIDRun() == 1);
0733         CPPUNIT_ASSERT(entry.orderPHIDRunLumi() == 4);
0734         CPPUNIT_ASSERT(entry.entry() == 4);
0735         break;
0736       case 10:
0737         CPPUNIT_ASSERT(entry.orderPHIDRun() == 2);
0738         CPPUNIT_ASSERT(entry.orderPHIDRunLumi() == IndexIntoFile::invalidEntry);
0739         CPPUNIT_ASSERT(entry.entry() == 3);
0740         break;
0741       case 11:
0742         CPPUNIT_ASSERT(entry.orderPHIDRun() == 2);
0743         CPPUNIT_ASSERT(entry.orderPHIDRunLumi() == 2);
0744         CPPUNIT_ASSERT(entry.entry() == IndexIntoFile::invalidEntry);
0745         break;
0746       case 12:
0747         CPPUNIT_ASSERT(entry.orderPHIDRun() == 2);
0748         CPPUNIT_ASSERT(entry.orderPHIDRunLumi() == 2);
0749         CPPUNIT_ASSERT(entry.entry() == 1);
0750         break;
0751       case 13:
0752         CPPUNIT_ASSERT(entry.orderPHIDRun() == 2);
0753         CPPUNIT_ASSERT(entry.orderPHIDRunLumi() == 2);
0754         CPPUNIT_ASSERT(entry.entry() == 7);
0755         break;
0756       case 14:
0757         CPPUNIT_ASSERT(entry.orderPHIDRun() == 3);
0758         CPPUNIT_ASSERT(entry.orderPHIDRunLumi() == IndexIntoFile::invalidEntry);
0759         CPPUNIT_ASSERT(entry.entry() == 5);
0760         break;
0761       case 15:
0762         CPPUNIT_ASSERT(entry.orderPHIDRun() == 3);
0763         CPPUNIT_ASSERT(entry.orderPHIDRunLumi() == 3);
0764         CPPUNIT_ASSERT(entry.entry() == 2);
0765         break;
0766       case 16:
0767         CPPUNIT_ASSERT(entry.orderPHIDRun() == 4);
0768         CPPUNIT_ASSERT(entry.orderPHIDRunLumi() == IndexIntoFile::invalidEntry);
0769         CPPUNIT_ASSERT(entry.entry() == 0);
0770         break;
0771       case 17:
0772         CPPUNIT_ASSERT(entry.orderPHIDRun() == 5);
0773         CPPUNIT_ASSERT(entry.orderPHIDRunLumi() == IndexIntoFile::invalidEntry);
0774         CPPUNIT_ASSERT(entry.entry() == 4);
0775         break;
0776       case 18:
0777         CPPUNIT_ASSERT(entry.orderPHIDRun() == 5);
0778         CPPUNIT_ASSERT(entry.orderPHIDRunLumi() == 5);
0779         CPPUNIT_ASSERT(entry.entry() == IndexIntoFile::invalidEntry);
0780         break;
0781       case 19:
0782         CPPUNIT_ASSERT(entry.orderPHIDRun() == 5);
0783         CPPUNIT_ASSERT(entry.orderPHIDRunLumi() == 5);
0784         CPPUNIT_ASSERT(entry.entry() == 8);
0785         break;
0786       case 20:
0787         CPPUNIT_ASSERT(entry.orderPHIDRun() == 5);
0788         CPPUNIT_ASSERT(entry.orderPHIDRunLumi() == 6);
0789         CPPUNIT_ASSERT(entry.entry() == 5);
0790         break;
0791     }
0792     ++index;
0793   }
0794   edm::IndexIntoFile::IndexIntoFileItr iterEntry = indexIntoFile.begin(IndexIntoFile::entryOrder);
0795   edm::IndexIntoFile::IndexIntoFileItr iterEntryEnd = indexIntoFile.end(IndexIntoFile::entryOrder);
0796   int i = 0;
0797   for (; iterEntry != iterEntryEnd; ++iterEntry, ++i) {
0798     if (i == 0)  // PHID1:Run3
0799       CPPUNIT_ASSERT(check(iterEntry, kRun, 0, -1, -1, 0, 0));
0800     else if (i == 1)  // PHID1:Run11
0801       CPPUNIT_ASSERT(check(iterEntry, kRun, 1, 2, -1, 0, 0));
0802     else if (i == 2)
0803       CPPUNIT_ASSERT(check(iterEntry, kLumi, 1, 2, -1, 0, 0));
0804     else if (i == 3)  // PHID1:Run1
0805       CPPUNIT_ASSERT(check(iterEntry, kRun, 3, 4, -1, 0, 0));
0806     else if (i == 4)
0807       CPPUNIT_ASSERT(check(iterEntry, kLumi, 3, 4, -1, 0, 0));
0808     else if (i == 5)
0809       CPPUNIT_ASSERT(check(iterEntry, kLumi, 3, 5, -1, 0, 0));
0810     else if (i == 6)
0811       CPPUNIT_ASSERT(check(iterEntry, kLumi, 3, 10, 6, 0, 1));
0812     else if (i == 7)
0813       CPPUNIT_ASSERT(check(iterEntry, kEvent, 3, 10, 6, 0, 1));
0814     else if (i == 8)
0815       CPPUNIT_ASSERT(check(iterEntry, kEvent, 3, 10, 7, 0, 1));
0816     else if (i == 9)
0817       CPPUNIT_ASSERT(check(iterEntry, kEvent, 3, 10, 8, 0, 1));
0818     else if (i == 10)
0819       CPPUNIT_ASSERT(check(iterEntry, kEvent, 3, 10, 9, 0, 1));
0820     else if (i == 11)  // PHID2:Run1
0821       CPPUNIT_ASSERT(check(iterEntry, kRun, 11, 13, 12, 0, 1));
0822     else if (i == 12)
0823       CPPUNIT_ASSERT(check(iterEntry, kLumi, 11, 13, 12, 0, 1));
0824     else if (i == 13)
0825       CPPUNIT_ASSERT(check(iterEntry, kLumi, 11, 14, 12, 0, 1));
0826     else if (i == 14)
0827       CPPUNIT_ASSERT(check(iterEntry, kEvent, 11, 14, 12, 0, 1));
0828     else if (i == 15)  // PHID2:Run2
0829       CPPUNIT_ASSERT(check(iterEntry, kRun, 15, 17, 16, 0, 1));
0830     else if (i == 16)
0831       CPPUNIT_ASSERT(check(iterEntry, kLumi, 15, 17, 16, 0, 1));
0832     else if (i == 17)
0833       CPPUNIT_ASSERT(check(iterEntry, kEvent, 15, 17, 16, 0, 1));
0834     else if (i == 18)
0835       CPPUNIT_ASSERT(check(iterEntry, kLumi, 15, 18, 18, 0, 2));
0836     else if (i == 19)
0837       CPPUNIT_ASSERT(check(iterEntry, kEvent, 15, 18, 18, 0, 2));
0838     else if (i == 20)
0839       CPPUNIT_ASSERT(check(iterEntry, kEvent, 15, 18, 18, 1, 2));
0840     else if (i == 21)  // PHID1:Run2
0841       CPPUNIT_ASSERT(check(iterEntry, kRun, 19, 20, -1, 0, 0));
0842     else if (i == 22)
0843       CPPUNIT_ASSERT(check(iterEntry, kLumi, 19, 20, -1, 0, 0));
0844     else
0845       CPPUNIT_ASSERT(false);
0846   }
0847   CPPUNIT_ASSERT(i == 23);
0848 }