Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:05:05

0001 #include "DataFormats/Provenance/interface/StoredMergeableRunProductMetadata.h"
0002 
0003 namespace edm {
0004 
0005   StoredMergeableRunProductMetadata::StoredMergeableRunProductMetadata() : allValidAndUseIndexIntoFile_(true) {}
0006 
0007   StoredMergeableRunProductMetadata::StoredMergeableRunProductMetadata(
0008       std::vector<std::string> const& processesWithMergeableRunProducts)
0009       : processesWithMergeableRunProducts_(processesWithMergeableRunProducts), allValidAndUseIndexIntoFile_(true) {}
0010 
0011   StoredMergeableRunProductMetadata::SingleRunEntry::SingleRunEntry() : beginProcess_(0), endProcess_(0) {}
0012 
0013   StoredMergeableRunProductMetadata::SingleRunEntry::SingleRunEntry(unsigned long long iBeginProcess,
0014                                                                     unsigned long long iEndProcess)
0015       : beginProcess_(iBeginProcess), endProcess_(iEndProcess) {}
0016 
0017   StoredMergeableRunProductMetadata::SingleRunEntryAndProcess::SingleRunEntryAndProcess()
0018       : beginLumi_(0), endLumi_(0), process_(0), valid_(false), useIndexIntoFile_(false) {}
0019 
0020   StoredMergeableRunProductMetadata::SingleRunEntryAndProcess::SingleRunEntryAndProcess(unsigned long long iBeginLumi,
0021                                                                                         unsigned long long iEndLumi,
0022                                                                                         unsigned int iProcess,
0023                                                                                         bool iValid,
0024                                                                                         bool iUseIndexIntoFile)
0025       : beginLumi_(iBeginLumi),
0026         endLumi_(iEndLumi),
0027         process_(iProcess),
0028         valid_(iValid),
0029         useIndexIntoFile_(iUseIndexIntoFile) {}
0030 
0031   void StoredMergeableRunProductMetadata::optimizeBeforeWrite() {
0032     if (allValidAndUseIndexIntoFile_) {
0033       processesWithMergeableRunProducts_.clear();
0034       singleRunEntries_.clear();
0035       singleRunEntryAndProcesses_.clear();
0036       lumis_.clear();
0037     }
0038   }
0039 
0040   bool StoredMergeableRunProductMetadata::getLumiContent(
0041       unsigned long long runEntry,
0042       std::string const& process,
0043       bool& valid,
0044       std::vector<LuminosityBlockNumber_t>::const_iterator& lumisBegin,
0045       std::vector<LuminosityBlockNumber_t>::const_iterator& lumisEnd) const {
0046     valid = true;
0047     if (allValidAndUseIndexIntoFile_) {
0048       return false;
0049     }
0050 
0051     SingleRunEntry const& singleRunEntry = singleRunEntries_.at(runEntry);
0052     for (unsigned long long j = singleRunEntry.beginProcess(); j < singleRunEntry.endProcess(); ++j) {
0053       SingleRunEntryAndProcess const& singleRunEntryAndProcess = singleRunEntryAndProcesses_.at(j);
0054       // This string comparison could be optimized away by storing an index mapping in
0055       // MergeableRunProductMetadata that gets recalculated each time a new input
0056       // file is opened
0057       if (processesWithMergeableRunProducts_.at(singleRunEntryAndProcess.process()) == process) {
0058         valid = singleRunEntryAndProcess.valid();
0059         if (singleRunEntryAndProcess.useIndexIntoFile()) {
0060           return false;
0061         } else {
0062           lumisBegin = lumis_.begin() + singleRunEntryAndProcess.beginLumi();
0063           lumisEnd = lumis_.begin() + singleRunEntryAndProcess.endLumi();
0064           return true;
0065         }
0066       }
0067     }
0068     return false;
0069   }
0070 }  // namespace edm