CMS 3D CMS Logo

MergeableRunProductMetadata.h
Go to the documentation of this file.
1 #ifndef FWCore_Framework_MergeableRunProductMetadata_h
2 #define FWCore_Framework_MergeableRunProductMetadata_h
3 
40 
41 #include "oneapi/tbb/concurrent_vector.h"
42 
43 #include <string>
44 #include <vector>
45 
46 namespace edm {
47 
48  class IndexIntoFileItrHolder;
49  class StoredMergeableRunProductMetadata;
50 
52  public:
54 
56 
58 
59  // Called each time a new input file is opened
60  void preReadFile();
61 
62  // Called each time a run entry is read from an input file. This
63  // should be called before the run products themselves are read
64  // because it sets the decision whether to merge, replace, or ignore
65  // run products as they read.
66  void readRun(long long inputRunEntry,
67  StoredMergeableRunProductMetadata const& inputStoredMergeableRunProductMetadata,
68  IndexIntoFileItrHolder const& inputIndexIntoFileItr);
69 
70  // Called to record which lumis were processed by the current run
72 
73  void preWriteRun();
74  void postWriteRun();
75 
77 
78  MergeDecision getMergeDecision(std::string const& processThatCreatedProduct) const;
79 
80  // If Runs were split on lumi boundaries, but then the files were merged
81  // in a way that made it impossible to properly merge run products, this
82  // function will return true. The Framework usually does not know
83  // enough to detect other cases where there is a merging problem.
84  bool knownImproperlyMerged(std::string const& processThatCreatedProduct) const override;
85 
86  std::string const& getProcessName(unsigned int index) const {
88  }
89 
91  public:
92  MetadataForProcess() = default;
93 
94  std::vector<LuminosityBlockNumber_t>& lumis() { return lumis_; }
95  std::vector<LuminosityBlockNumber_t> const& lumis() const { return lumis_; }
96 
99 
100  bool valid() const { return valid_; }
101  void setValid(bool v) { valid_ = v; }
102 
103  bool useIndexIntoFile() const { return useIndexIntoFile_; }
105 
106  bool allLumisProcessed() const { return allLumisProcessed_; }
108 
109  void reset();
110 
111  private:
112  std::vector<LuminosityBlockNumber_t> lumis_;
114  bool valid_ = true;
115  bool useIndexIntoFile_ = false;
116  bool allLumisProcessed_ = false;
117  };
118 
120 
121  // The next few functions are only intended to be used in tests.
122  std::vector<MetadataForProcess> const& metadataForProcesses() const { return metadataForProcesses_; }
123 
124  std::vector<LuminosityBlockNumber_t> const& lumisFromIndexIntoFile() const { return lumisFromIndexIntoFile_; }
125 
127 
128  oneapi::tbb::concurrent_vector<LuminosityBlockNumber_t> const& lumisProcessed() const { return lumisProcessed_; }
129 
130  private:
132 
133  bool addProcess(StoredMergeableRunProductMetadata& storedMetadata,
134  MetadataForProcess const& metadataForProcess,
135  unsigned int storedProcessIndex,
136  unsigned long long beginProcess,
137  unsigned long long endProcess) const;
138 
140 
141  // This vector has an entry for each process that has a
142  // mergeable run product in the input. It has an exact one to
143  // correspondence with mergeableRunProductProcesses_ and
144  // is in the same order.
145  std::vector<MetadataForProcess> metadataForProcesses_;
146 
147  std::vector<LuminosityBlockNumber_t> lumisFromIndexIntoFile_;
149 
150  oneapi::tbb::concurrent_vector<LuminosityBlockNumber_t> lumisProcessed_;
151  };
152 } // namespace edm
153 #endif
std::vector< LuminosityBlockNumber_t > const & lumisFromIndexIntoFile() const
bool addProcess(StoredMergeableRunProductMetadata &storedMetadata, MetadataForProcess const &metadataForProcess, unsigned int storedProcessIndex, unsigned long long beginProcess, unsigned long long endProcess) const
std::vector< LuminosityBlockNumber_t > const & lumis() const
std::string const & getProcessName(unsigned int index) const
unsigned int LuminosityBlockNumber_t
MergeDecision getMergeDecision(std::string const &processThatCreatedProduct) const
MergeableRunProductProcesses const * mergeableRunProductProcesses_
std::vector< MetadataForProcess > metadataForProcesses_
MergeableRunProductMetadata(MergeableRunProductProcesses const &)
bool knownImproperlyMerged(std::string const &processThatCreatedProduct) const override
void writeLumi(LuminosityBlockNumber_t lumi)
std::vector< LuminosityBlockNumber_t > lumisFromIndexIntoFile_
oneapi::tbb::concurrent_vector< LuminosityBlockNumber_t > const & lumisProcessed() const
std::vector< MetadataForProcess > const & metadataForProcesses() const
void addEntryToStoredMetadata(StoredMergeableRunProductMetadata &) const
HLT enums.
std::string const & getProcessName(unsigned int index) const
oneapi::tbb::concurrent_vector< LuminosityBlockNumber_t > lumisProcessed_
void readRun(long long inputRunEntry, StoredMergeableRunProductMetadata const &inputStoredMergeableRunProductMetadata, IndexIntoFileItrHolder const &inputIndexIntoFileItr)
MetadataForProcess const * metadataForOneProcess(std::string const &processName) const