File indexing completed on 2025-04-22 06:27:18
0001 #ifndef FWCore_Framework_MergeableRunProductMetadata_h
0002 #define FWCore_Framework_MergeableRunProductMetadata_h
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033
0034 #include "DataFormats/Provenance/interface/MergeableRunProductMetadataBase.h"
0035 #include "FWCore/Framework/interface/MergeableRunProductProcesses.h"
0036 #include "DataFormats/Provenance/interface/RunLumiEventNumber.h"
0037
0038 #include "oneapi/tbb/concurrent_vector.h"
0039
0040 #include <string>
0041 #include <vector>
0042
0043 namespace edm {
0044
0045 class IndexIntoFileItrHolder;
0046 class StoredMergeableRunProductMetadata;
0047
0048 class MergeableRunProductMetadata : public MergeableRunProductMetadataBase {
0049 public:
0050 enum MergeDecision { MERGE, REPLACE, IGNORE };
0051
0052 MergeableRunProductMetadata(MergeableRunProductProcesses const&);
0053
0054 ~MergeableRunProductMetadata() override;
0055
0056
0057 void preReadFile();
0058
0059
0060
0061
0062
0063 void readRun(long long inputRunEntry,
0064 StoredMergeableRunProductMetadata const& inputStoredMergeableRunProductMetadata,
0065 IndexIntoFileItrHolder const& inputIndexIntoFileItr);
0066
0067
0068 void writeLumi(LuminosityBlockNumber_t lumi);
0069
0070 void preWriteRun();
0071 void postWriteRun();
0072
0073 void addEntryToStoredMetadata(StoredMergeableRunProductMetadata&) const;
0074
0075 MergeDecision getMergeDecision(std::string const& processThatCreatedProduct) const;
0076
0077
0078
0079
0080
0081 bool knownImproperlyMerged(std::string const& processThatCreatedProduct) const override;
0082
0083 std::string const& getProcessName(unsigned int index) const {
0084 return mergeableRunProductProcesses_->getProcessName(index);
0085 }
0086
0087 class MetadataForProcess {
0088 public:
0089 MetadataForProcess() = default;
0090
0091 std::vector<LuminosityBlockNumber_t>& lumis() { return lumis_; }
0092 std::vector<LuminosityBlockNumber_t> const& lumis() const { return lumis_; }
0093
0094 MergeDecision mergeDecision() const { return mergeDecision_; }
0095 void setMergeDecision(MergeDecision v) { mergeDecision_ = v; }
0096
0097 bool valid() const { return valid_; }
0098 void setValid(bool v) { valid_ = v; }
0099
0100 bool useIndexIntoFile() const { return useIndexIntoFile_; }
0101 void setUseIndexIntoFile(bool v) { useIndexIntoFile_ = v; }
0102
0103 bool allLumisProcessed() const { return allLumisProcessed_; }
0104 void setAllLumisProcessed(bool v) { allLumisProcessed_ = v; }
0105
0106 void reset();
0107
0108 private:
0109 std::vector<LuminosityBlockNumber_t> lumis_;
0110 MergeDecision mergeDecision_ = MERGE;
0111 bool valid_ = true;
0112 bool useIndexIntoFile_ = false;
0113 bool allLumisProcessed_ = false;
0114 };
0115
0116 MetadataForProcess const* metadataForOneProcess(std::string const& processName) const;
0117
0118
0119 std::vector<MetadataForProcess> const& metadataForProcesses() const { return metadataForProcesses_; }
0120
0121 std::vector<LuminosityBlockNumber_t> const& lumisFromIndexIntoFile() const { return lumisFromIndexIntoFile_; }
0122
0123 bool gotLumisFromIndexIntoFile() const { return gotLumisFromIndexIntoFile_; }
0124
0125 oneapi::tbb::concurrent_vector<LuminosityBlockNumber_t> const& lumisProcessed() const { return lumisProcessed_; }
0126
0127 private:
0128 void mergeLumisFromIndexIntoFile();
0129
0130 bool addProcess(StoredMergeableRunProductMetadata& storedMetadata,
0131 MetadataForProcess const& metadataForProcess,
0132 unsigned int storedProcessIndex,
0133 unsigned long long beginProcess,
0134 unsigned long long endProcess) const;
0135
0136 MergeableRunProductProcesses const* mergeableRunProductProcesses_;
0137
0138
0139
0140
0141
0142 std::vector<MetadataForProcess> metadataForProcesses_;
0143
0144 std::vector<LuminosityBlockNumber_t> lumisFromIndexIntoFile_;
0145 bool gotLumisFromIndexIntoFile_ = false;
0146
0147 oneapi::tbb::concurrent_vector<LuminosityBlockNumber_t> lumisProcessed_;
0148 };
0149 }
0150 #endif