CMS 3D CMS Logo

ProcessBlockHelper.h
Go to the documentation of this file.
1 #ifndef FWCore_Common_ProcessBlockHelper_h
2 #define FWCore_Common_ProcessBlockHelper_h
3 
12 
13 #include <set>
14 #include <string>
15 #include <vector>
16 
17 namespace edm {
18 
20  public:
21  ProcessBlockHelperBase const* topProcessBlockHelper() const final;
22  std::vector<std::string> const& topProcessesWithProcessBlockProducts() const final;
23  unsigned int nProcessesInFirstFile() const final;
24  std::vector<std::vector<unsigned int>> const& processBlockCacheIndices() const final;
25  std::vector<std::vector<unsigned int>> const& nEntries() const final;
26  std::vector<unsigned int> const& cacheIndexVectorsPerFile() const final;
27  std::vector<unsigned int> const& cacheEntriesPerFile() const final;
28  unsigned int processBlockIndex(std::string const& processName, EventToProcessBlockIndexes const&) const final;
29  unsigned int outerOffset() const final;
30 
32 
34  std::set<std::string> const& processesToKeep,
35  std::vector<unsigned int> const& nEntries,
36  std::vector<unsigned int>& finalIndexToStoredIndex) const;
37 
38  bool dropProcessesAndReorderStored(StoredProcessBlockHelper& storedProcessBlockHelper,
39  std::set<std::string> const& processesToKeep,
40  std::vector<unsigned int> const& nEntries,
41  std::vector<unsigned int>& finalIndexToStoredIndex,
42  std::vector<std::string> const& firstFileFinalProcesses) const;
43 
44  void initializeFromPrimaryInput(StoredProcessBlockHelper const& storedProcessBlockHelper);
45 
46  void fillFromPrimaryInput(StoredProcessBlockHelper const& storedProcessBlockHelper,
47  std::vector<unsigned int> const& nEntries);
48 
50 
51  private:
52  void dropProcessesAndReorderStoredImpl(StoredProcessBlockHelper& storedProcessBlockHelper,
53  std::vector<std::string>& finalProcesses,
54  std::vector<unsigned int> const& nEntries,
55  std::vector<unsigned int> const& finalIndexToStoredIndex) const;
56 
57  void fillFromPrimaryInputWhenNotEmpty(std::vector<std::string> const& storedProcesses,
58  std::vector<unsigned int> const& storedCacheIndices,
59  std::vector<unsigned int> const& nEntries);
60 
61  void fillEntriesFromPrimaryInput(std::vector<unsigned int> nEntries);
62 
63  // A general comment about this class and its data members.
64  // It was initially written to handle cases where all ProcessBlock
65  // products from some process were dropped in a file after
66  // the first input file but were present in the first input file.
67  // At the moment this comment is being written, the file merging
68  // rules do not allow this to happen and this situation never
69  // occurs. However, this class intentionally maintains support
70  // for this case, because we may find we need to change the file
71  // merging requirements in the future. So there is support for
72  // some indices to be invalid or other values to be zero even
73  // though at the moment this should never occur.
74 
75  // Events hold an index into the outer vector
76  // (an offset needs to added in the case of multiple input
77  // files). The elements of the inner vector correspond to the
78  // processes in processesWithProcessBlockProducts_ (exactly
79  // 1 to 1 in the same order except it only includes those processes
80  // from the input, if the current Process and/or SubProcesses are
81  // added, then they are added to the container of cache indices when
82  // the output module makes its modified copy). The values inside
83  // the inner vector are the cache indices into the cache vectors
84  // contained by user modules. This cache order is the same as the
85  // processing order of ProcessBlocks in the current process.
86  // It might contain invalid cache index values.
87  std::vector<std::vector<unsigned int>> processBlockCacheIndices_;
88 
89  // Number of entries per ProcessBlock TTree.
90  // The outer vector has an element for each input file.
91  // The inner vector elements correspond 1-to-1 with
92  // processesWithProcessBlockProducts_ and in the same
93  // order. This might contain zeroes.
94  std::vector<std::vector<unsigned int>> nEntries_;
95 
96  // The index into the next two vectors is the input file index
97  // which is based on the order input files are read
98  // These can contain zeroes.
99  std::vector<unsigned int> cacheIndexVectorsPerFile_;
100  std::vector<unsigned int> cacheEntriesPerFile_;
101 
102  unsigned int nProcessesInFirstFile_ = 0;
103 
104  bool initializedFromInput_ = false;
105 
106  // Index of the first outer vector element in the cache indices
107  // container that is associated with the current input file. If
108  // it points to the end, then there were no cache indices in the
109  // current input file.
110  unsigned int outerOffset_ = 0;
111 
112  // Offset for the cacheIndex, counts all entries in
113  // ProcessBlock TTree's in all input files seen so far.
114  unsigned int cacheIndexOffset_ = 0;
115  };
116 } // namespace edm
117 #endif
void initializeFromPrimaryInput(StoredProcessBlockHelper const &storedProcessBlockHelper)
std::vector< std::vector< unsigned int > > const & processBlockCacheIndices() const final
unsigned int outerOffset() const final
unsigned int processBlockIndex(std::string const &processName, EventToProcessBlockIndexes const &) const final
void dropProcessesAndReorderStoredImpl(StoredProcessBlockHelper &storedProcessBlockHelper, std::vector< std::string > &finalProcesses, std::vector< unsigned int > const &nEntries, std::vector< unsigned int > const &finalIndexToStoredIndex) const
void fillEntriesFromPrimaryInput(std::vector< unsigned int > nEntries)
std::vector< unsigned int > cacheEntriesPerFile_
std::vector< std::vector< unsigned int > > nEntries_
unsigned int nProcessesInFirstFile() const final
bool dropProcessesAndReorderStored(StoredProcessBlockHelper &storedProcessBlockHelper, std::set< std::string > const &processesToKeep, std::vector< unsigned int > const &nEntries, std::vector< unsigned int > &finalIndexToStoredIndex, std::vector< std::string > const &firstFileFinalProcesses) const
ProcessBlockHelperBase const * topProcessBlockHelper() const final
std::vector< unsigned int > cacheIndexVectorsPerFile_
std::vector< std::vector< unsigned int > > const & nEntries() const final
bool firstFileDropProcessesAndReorderStored(StoredProcessBlockHelper &storedProcessBlockHelper, std::set< std::string > const &processesToKeep, std::vector< unsigned int > const &nEntries, std::vector< unsigned int > &finalIndexToStoredIndex) const
std::vector< std::string > const & topProcessesWithProcessBlockProducts() const final
HLT enums.
void fillFromPrimaryInput(StoredProcessBlockHelper const &storedProcessBlockHelper, std::vector< unsigned int > const &nEntries)
std::vector< unsigned int > const & cacheEntriesPerFile() const final
std::vector< std::vector< unsigned int > > processBlockCacheIndices_
std::vector< unsigned int > const & cacheIndexVectorsPerFile() const final
void fillFromPrimaryInputWhenNotEmpty(std::vector< std::string > const &storedProcesses, std::vector< unsigned int > const &storedCacheIndices, std::vector< unsigned int > const &nEntries)