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