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