Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 13:28:30

0001 #include "DataFormats/Provenance/interface/ProcessHistory.h"
0002 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0003 #include "DataFormats/Provenance/interface/IndexIntoFile.h"
0004 #include "DataFormats/Provenance/interface/ParameterSetID.h"
0005 #include "DataFormats/Provenance/interface/ProcessConfiguration.h"
0006 #include "DataFormats/Provenance/interface/ProcessHistoryID.h"
0007 #include "DataFormats/Provenance/interface/ProcessHistoryRegistry.h"
0008 #include "FWCore/Utilities/interface/Exception.h"
0009 #include "FWCore/Utilities/interface/GetPassID.h"
0010 #include "FWCore/Version/interface/GetReleaseVersion.h"
0011 
0012 #include <cassert>
0013 #include <string>
0014 #include <iostream>
0015 
0016 bool checkRunOrLumiEntry(edm::IndexIntoFile::RunOrLumiEntry const& rl,
0017                          edm::IndexIntoFile::EntryNumber_t orderPHIDRun,
0018                          edm::IndexIntoFile::EntryNumber_t orderPHIDRunLumi,
0019                          edm::IndexIntoFile::EntryNumber_t entry,
0020                          int processHistoryIDIndex,
0021                          edm::RunNumber_t run,
0022                          edm::LuminosityBlockNumber_t lumi,
0023                          edm::IndexIntoFile::EntryNumber_t beginEvents,
0024                          edm::IndexIntoFile::EntryNumber_t endEvents) {
0025   if (rl.orderPHIDRun() != orderPHIDRun)
0026     return false;
0027   if (rl.orderPHIDRunLumi() != orderPHIDRunLumi)
0028     return false;
0029   if (rl.entry() != entry)
0030     return false;
0031   if (rl.processHistoryIDIndex() != processHistoryIDIndex)
0032     return false;
0033   if (rl.run() != run)
0034     return false;
0035   if (rl.lumi() != lumi)
0036     return false;
0037   if (rl.beginEvents() != beginEvents)
0038     return false;
0039   if (rl.endEvents() != endEvents)
0040     return false;
0041   return true;
0042 }
0043 
0044 int main() try {
0045   edm::ProcessHistoryRegistry processHistoryRegistry;
0046   edm::ParameterSet dummyPset;
0047   edm::ParameterSetID psetID;
0048   dummyPset.registerIt();
0049   psetID = dummyPset.id();
0050 
0051   edm::ProcessHistory pnl1;
0052   assert(pnl1 == pnl1);
0053   edm::ProcessHistory pnl2;
0054   assert(pnl1 == pnl2);
0055   edm::ProcessConfiguration iHLT(std::string("HLT"), psetID, std::string("CMSSW_5_100_40"), edm::getPassID());
0056   edm::ProcessConfiguration iRECO(std::string("RECO"), psetID, std::string("5_100_42patch100"), edm::getPassID());
0057   pnl2.push_back(iHLT);
0058   assert(pnl1 != pnl2);
0059   edm::ProcessHistory pnl3;
0060   pnl3.push_back(iHLT);
0061   pnl3.push_back(iRECO);
0062 
0063   edm::ProcessHistoryID id1 = pnl1.setProcessHistoryID();
0064   edm::ProcessHistoryID id2 = pnl2.setProcessHistoryID();
0065   edm::ProcessHistoryID id3 = pnl3.setProcessHistoryID();
0066 
0067   assert(id1 != id2);
0068   assert(id2 != id3);
0069   assert(id3 != id1);
0070 
0071   edm::ProcessHistory pnl4;
0072   pnl4.push_back(iHLT);
0073   edm::ProcessHistoryID id4 = pnl4.setProcessHistoryID();
0074   assert(pnl4 == pnl2);
0075   assert(id4 == id2);
0076 
0077   edm::ProcessHistory pnl5;
0078   pnl5 = pnl3;
0079   assert(pnl5 == pnl3);
0080   assert(pnl5.id() == pnl3.id());
0081 
0082   {
0083     edm::ProcessConfiguration pc1(std::string("HLT"), psetID, std::string(""), edm::getPassID());
0084     edm::ProcessConfiguration pc2(std::string("HLT"), psetID, std::string("a"), edm::getPassID());
0085     edm::ProcessConfiguration pc3(std::string("HLT"), psetID, std::string("1"), edm::getPassID());
0086     edm::ProcessConfiguration pc4(std::string("HLT"), psetID, std::string("ccc500yz"), edm::getPassID());
0087     edm::ProcessConfiguration pc5(std::string("HLT"), psetID, std::string("500yz872"), edm::getPassID());
0088     edm::ProcessConfiguration pc6(std::string("HLT"), psetID, std::string("500yz872djk999patch10"), edm::getPassID());
0089     edm::ProcessConfiguration pc7(std::string("HLT"), psetID, std::string("xb500yz872djk999patch10"), edm::getPassID());
0090     edm::ProcessConfiguration pc8(std::string("HLT"), psetID, std::string("CMSSW_4_4_0_pre5"), edm::getPassID());
0091 
0092     pc1.setProcessConfigurationID();
0093     pc2.setProcessConfigurationID();
0094     pc3.setProcessConfigurationID();
0095     pc4.setProcessConfigurationID();
0096     pc5.setProcessConfigurationID();
0097     pc6.setProcessConfigurationID();
0098     pc7.setProcessConfigurationID();
0099     pc8.setProcessConfigurationID();
0100 
0101     pc1.reduce();
0102     pc2.reduce();
0103     pc3.reduce();
0104     pc4.reduce();
0105     pc5.reduce();
0106     pc6.reduce();
0107     pc7.reduce();
0108     pc8.reduce();
0109 
0110     edm::ProcessConfiguration pc1expected(std::string("HLT"), psetID, std::string(""), edm::getPassID());
0111     edm::ProcessConfiguration pc2expected(std::string("HLT"), psetID, std::string("a"), edm::getPassID());
0112     edm::ProcessConfiguration pc3expected(std::string("HLT"), psetID, std::string("1"), edm::getPassID());
0113     edm::ProcessConfiguration pc4expected(std::string("HLT"), psetID, std::string("ccc500yz"), edm::getPassID());
0114     edm::ProcessConfiguration pc5expected(std::string("HLT"), psetID, std::string("500yz872"), edm::getPassID());
0115     edm::ProcessConfiguration pc6expected(std::string("HLT"), psetID, std::string("500yz872"), edm::getPassID());
0116     edm::ProcessConfiguration pc7expected(std::string("HLT"), psetID, std::string("xb500yz872"), edm::getPassID());
0117     edm::ProcessConfiguration pc8expected(std::string("HLT"), psetID, std::string("CMSSW_4_4"), edm::getPassID());
0118 
0119     assert(pc1 == pc1expected);
0120     assert(pc2 == pc2expected);
0121     assert(pc3 == pc3expected);
0122     assert(pc4 == pc4expected);
0123     assert(pc5 == pc5expected);
0124     assert(pc6 == pc6expected);
0125     assert(pc7 == pc7expected);
0126     assert(pc8 == pc8expected);
0127 
0128     assert(pc1.id() == pc1expected.id());
0129     assert(pc2.id() == pc2expected.id());
0130     assert(pc3.id() == pc3expected.id());
0131     assert(pc4.id() == pc4expected.id());
0132     assert(pc5.id() == pc5expected.id());
0133     assert(pc6.id() == pc6expected.id());
0134     assert(pc7.id() == pc7expected.id());
0135     assert(pc8.id() == pc8expected.id());
0136 
0137     assert(pc7.id() != pc8expected.id());
0138   }
0139 
0140   edm::ProcessConfiguration iHLTreduced(std::string("HLT"), psetID, std::string("CMSSW_5_100"), edm::getPassID());
0141   edm::ProcessConfiguration iRECOreduced(std::string("RECO"), psetID, std::string("5_100"), edm::getPassID());
0142   edm::ProcessHistory phTestExpected;
0143   phTestExpected.push_back(iHLTreduced);
0144   phTestExpected.push_back(iRECOreduced);
0145 
0146   edm::ProcessHistory phTest = pnl3;
0147   phTest.setProcessHistoryID();
0148   phTest.reduce();
0149   assert(phTest == phTestExpected);
0150   assert(phTest.id() == phTestExpected.id());
0151   assert(phTest.id() != pnl3.id());
0152 
0153   processHistoryRegistry.registerProcessHistory(pnl3);
0154   edm::ProcessHistoryID reducedPHID = processHistoryRegistry.reducedProcessHistoryID(pnl3.id());
0155   assert(reducedPHID == phTest.id());
0156 
0157   processHistoryRegistry.registerProcessHistory(pnl2);
0158   reducedPHID = processHistoryRegistry.reducedProcessHistoryID(pnl2.id());
0159   pnl2.reduce();
0160   assert(reducedPHID == pnl2.id());
0161 
0162   {
0163     edm::ProcessHistory ph1;
0164     edm::ProcessHistory ph1a;
0165     edm::ProcessHistory ph1b;
0166     edm::ProcessHistory ph2;
0167     edm::ProcessHistory ph2a;
0168     edm::ProcessHistory ph2b;
0169     edm::ProcessHistory ph3;
0170     edm::ProcessHistory ph4;
0171 
0172     edm::ProcessConfiguration pc1(std::string("HLT"), psetID, std::string("CMSSW_5_1_40"), std::string(""));
0173     edm::ProcessConfiguration pc1a(std::string("HLT"), psetID, std::string("CMSSW_5_1_40patch1"), std::string(""));
0174     edm::ProcessConfiguration pc1b(std::string("HLT"), psetID, std::string("CMSSW_5_1_40patch2"), std::string(""));
0175     edm::ProcessConfiguration pc2(std::string("HLT"), psetID, std::string("CMSSW_5_2_40"), std::string(""));
0176     edm::ProcessConfiguration pc2a(std::string("HLT"), psetID, std::string("CMSSW_5_2_40patch1"), std::string(""));
0177     edm::ProcessConfiguration pc2b(std::string("HLT"), psetID, std::string("CMSSW_5_2_40patch2"), std::string(""));
0178     edm::ProcessConfiguration pc3(std::string("HLT"), psetID, std::string("CMSSW_5_3_40"), std::string(""));
0179     edm::ProcessConfiguration pc4(std::string("HLT"), psetID, std::string("CMSSW_5_4_40"), std::string(""));
0180 
0181     ph1.push_back(pc1);
0182     ph1a.push_back(pc1a);
0183     ph1b.push_back(pc1b);
0184     ph2.push_back(pc2);
0185     ph2a.push_back(pc2a);
0186     ph2b.push_back(pc2b);
0187     ph3.push_back(pc3);
0188     ph4.push_back(pc4);
0189 
0190     edm::ProcessHistoryID phid1 = ph1.setProcessHistoryID();
0191     edm::ProcessHistoryID phid1a = ph1a.setProcessHistoryID();
0192     edm::ProcessHistoryID phid1b = ph1b.setProcessHistoryID();
0193     edm::ProcessHistoryID phid2 = ph2.setProcessHistoryID();
0194     edm::ProcessHistoryID phid2a = ph2a.setProcessHistoryID();
0195     edm::ProcessHistoryID phid2b = ph2b.setProcessHistoryID();
0196     edm::ProcessHistoryID phid3 = ph3.setProcessHistoryID();
0197     edm::ProcessHistoryID phid4 = ph4.setProcessHistoryID();
0198 
0199     processHistoryRegistry.registerProcessHistory(ph1);
0200     processHistoryRegistry.registerProcessHistory(ph1a);
0201     processHistoryRegistry.registerProcessHistory(ph1b);
0202     processHistoryRegistry.registerProcessHistory(ph2);
0203     processHistoryRegistry.registerProcessHistory(ph2a);
0204     processHistoryRegistry.registerProcessHistory(ph2b);
0205     processHistoryRegistry.registerProcessHistory(ph3);
0206     processHistoryRegistry.registerProcessHistory(ph4);
0207 
0208     edm::IndexIntoFile indexIntoFile;
0209     indexIntoFile.addEntry(phid1, 1, 0, 0, 0);
0210     indexIntoFile.addEntry(phid2, 2, 0, 0, 1);
0211     indexIntoFile.addEntry(phid3, 3, 0, 0, 2);
0212     indexIntoFile.addEntry(phid4, 4, 0, 0, 3);
0213 
0214     indexIntoFile.sortVector_Run_Or_Lumi_Entries();
0215 
0216     indexIntoFile.reduceProcessHistoryIDs(processHistoryRegistry);
0217 
0218     edm::ProcessHistory rph1 = ph1;
0219     edm::ProcessHistory rph1a = ph1a;
0220     edm::ProcessHistory rph1b = ph1b;
0221     edm::ProcessHistory rph2 = ph2;
0222     edm::ProcessHistory rph2a = ph2a;
0223     edm::ProcessHistory rph2b = ph2b;
0224     edm::ProcessHistory rph3 = ph3;
0225     edm::ProcessHistory rph4 = ph4;
0226     rph1.reduce();
0227     rph1a.reduce();
0228     rph1b.reduce();
0229     rph2.reduce();
0230     rph2a.reduce();
0231     rph2b.reduce();
0232     rph3.reduce();
0233     rph4.reduce();
0234 
0235     std::vector<edm::ProcessHistoryID> const& v = indexIntoFile.processHistoryIDs();
0236     assert(v[0] == rph1.id());
0237     assert(v[1] == rph2.id());
0238     assert(v[2] == rph3.id());
0239     assert(v[3] == rph4.id());
0240 
0241     edm::IndexIntoFile indexIntoFile1;
0242     indexIntoFile1.addEntry(phid1, 1, 11, 0, 0);
0243     indexIntoFile1.addEntry(phid1, 1, 12, 0, 1);
0244     indexIntoFile1.addEntry(phid1, 1, 0, 0, 0);
0245     indexIntoFile1.addEntry(phid2, 2, 11, 0, 2);
0246     indexIntoFile1.addEntry(phid2, 2, 12, 0, 3);
0247     indexIntoFile1.addEntry(phid2, 2, 0, 0, 1);
0248     indexIntoFile1.addEntry(phid1a, 1, 11, 1, 0);
0249     indexIntoFile1.addEntry(phid1a, 1, 11, 2, 1);
0250     indexIntoFile1.addEntry(phid1a, 1, 11, 0, 4);
0251     indexIntoFile1.addEntry(phid1a, 1, 12, 1, 2);
0252     indexIntoFile1.addEntry(phid1a, 1, 12, 2, 3);
0253     indexIntoFile1.addEntry(phid1a, 1, 12, 0, 5);
0254     indexIntoFile1.addEntry(phid1a, 1, 0, 0, 2);
0255     indexIntoFile1.addEntry(phid3, 3, 0, 0, 3);
0256     indexIntoFile1.addEntry(phid2a, 2, 0, 0, 4);
0257     indexIntoFile1.addEntry(phid2b, 2, 0, 0, 5);
0258     indexIntoFile1.addEntry(phid4, 4, 0, 0, 6);
0259     indexIntoFile1.addEntry(phid1b, 1, 0, 0, 7);
0260     indexIntoFile1.addEntry(phid1, 5, 11, 0, 6);
0261     indexIntoFile1.addEntry(phid1, 5, 0, 0, 8);
0262     indexIntoFile1.addEntry(phid4, 1, 11, 0, 7);
0263     indexIntoFile1.addEntry(phid4, 1, 0, 0, 9);
0264 
0265     indexIntoFile1.sortVector_Run_Or_Lumi_Entries();
0266 
0267     std::vector<edm::ProcessHistoryID> const& v1 = indexIntoFile1.processHistoryIDs();
0268     assert(v1.size() == 8U);
0269 
0270     indexIntoFile1.reduceProcessHistoryIDs(processHistoryRegistry);
0271 
0272     std::vector<edm::ProcessHistoryID> const& rv1 = indexIntoFile1.processHistoryIDs();
0273     assert(rv1.size() == 4U);
0274     assert(rv1[0] == rph1.id());
0275     assert(rv1[1] == rph2.id());
0276     assert(rv1[2] == rph3.id());
0277     assert(rv1[3] == rph4.id());
0278 
0279     std::vector<edm::IndexIntoFile::RunOrLumiEntry>& runOrLumiEntries = indexIntoFile1.setRunOrLumiEntries();
0280 
0281     assert(runOrLumiEntries.size() == 18U);
0282 
0283     /*
0284     std::cout << rv1[0] << "  " << rph1 << "\n";
0285     std::cout << rv1[1] << "  " << rph2 << "\n";
0286     std::cout << rv1[2] << "  " << rph3 << "\n";
0287     std::cout << rv1[3] << "  " << rph4 << "\n";
0288 
0289     for (auto const& item : runOrLumiEntries) {
0290       std::cout << item.orderPHIDRun() << "  "
0291                 << item.orderPHIDRunLumi() << "  "
0292                 << item.entry() << "  "
0293                 << item.processHistoryIDIndex() << "  "
0294                 << item.run() << "  "
0295                 << item.lumi() << "  "
0296                 << item.beginEvents() << "  "
0297                 << item.endEvents() << "\n";
0298 
0299     }
0300     */
0301 
0302     assert(checkRunOrLumiEntry(runOrLumiEntries.at(0), 0, -1, 0, 0, 1, 0, -1, -1));
0303     assert(checkRunOrLumiEntry(runOrLumiEntries.at(1), 0, -1, 2, 0, 1, 0, -1, -1));
0304     assert(checkRunOrLumiEntry(runOrLumiEntries.at(2), 0, -1, 7, 0, 1, 0, -1, -1));
0305     assert(checkRunOrLumiEntry(runOrLumiEntries.at(3), 0, 0, 0, 0, 1, 11, -1, -1));
0306     assert(checkRunOrLumiEntry(runOrLumiEntries.at(4), 0, 0, 4, 0, 1, 11, 0, 2));
0307     assert(checkRunOrLumiEntry(runOrLumiEntries.at(5), 0, 1, 1, 0, 1, 12, -1, -1));
0308     assert(checkRunOrLumiEntry(runOrLumiEntries.at(6), 0, 1, 5, 0, 1, 12, 2, 4));
0309     assert(checkRunOrLumiEntry(runOrLumiEntries.at(7), 1, -1, 1, 1, 2, 0, -1, -1));
0310     assert(checkRunOrLumiEntry(runOrLumiEntries.at(8), 1, -1, 4, 1, 2, 0, -1, -1));
0311     assert(checkRunOrLumiEntry(runOrLumiEntries.at(9), 1, -1, 5, 1, 2, 0, -1, -1));
0312     assert(checkRunOrLumiEntry(runOrLumiEntries.at(10), 1, 2, 2, 1, 2, 11, -1, -1));
0313     assert(checkRunOrLumiEntry(runOrLumiEntries.at(11), 1, 3, 3, 1, 2, 12, -1, -1));
0314     assert(checkRunOrLumiEntry(runOrLumiEntries.at(12), 3, -1, 3, 2, 3, 0, -1, -1));
0315     assert(checkRunOrLumiEntry(runOrLumiEntries.at(13), 6, -1, 6, 3, 4, 0, -1, -1));
0316     assert(checkRunOrLumiEntry(runOrLumiEntries.at(14), 8, -1, 8, 0, 5, 0, -1, -1));
0317     assert(checkRunOrLumiEntry(runOrLumiEntries.at(15), 8, 6, 6, 0, 5, 11, -1, -1));
0318     assert(checkRunOrLumiEntry(runOrLumiEntries.at(16), 9, -1, 9, 3, 1, 0, -1, -1));
0319     assert(checkRunOrLumiEntry(runOrLumiEntries.at(17), 9, 7, 7, 3, 1, 11, -1, -1));
0320   }
0321   return 0;
0322 } catch (cms::Exception const& e) {
0323   std::cerr << e.explainSelf() << std::endl;
0324   return 1;
0325 } catch (std::exception const& e) {
0326   std::cerr << e.what() << std::endl;
0327   return 1;
0328 }