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
edm::ProcessBlockHelper::nEntries
std::vector< std::vector< unsigned int > > const & nEntries() const final
Definition: ProcessBlockHelper.cc:24
ProvenanceFwd.h
edm::EventToProcessBlockIndexes
Definition: EventToProcessBlockIndexes.h:12
edm::ProcessBlockHelper::firstFileDropProcessesAndReorderStored
bool firstFileDropProcessesAndReorderStored(StoredProcessBlockHelper &storedProcessBlockHelper, std::set< std::string > const &processesToKeep, std::vector< unsigned int > const &nEntries, std::vector< unsigned int > &finalIndexToStoredIndex) const
Definition: ProcessBlockHelper.cc:47
edm
HLT enums.
Definition: AlignableModifier.h:19
edm::ProcessBlockHelper::initializedFromInput
bool initializedFromInput() const
Definition: ProcessBlockHelper.h:31
edm::ProcessBlockHelper::cacheEntriesPerFile
std::vector< unsigned int > const & cacheEntriesPerFile() const final
Definition: ProcessBlockHelper.cc:30
edm::ProcessBlockHelper::initializeFromPrimaryInput
void initializeFromPrimaryInput(StoredProcessBlockHelper const &storedProcessBlockHelper)
Definition: ProcessBlockHelper.cc:122
edm::ProcessBlockHelper::outerOffset
unsigned int outerOffset() const final
Definition: ProcessBlockHelper.cc:42
edm::ProcessBlockHelper
Definition: ProcessBlockHelper.h:19
edm::ProcessBlockHelper::cacheIndexOffset_
unsigned int cacheIndexOffset_
Definition: ProcessBlockHelper.h:114
edm::ProcessBlockHelper::fillFromPrimaryInputWhenNotEmpty
void fillFromPrimaryInputWhenNotEmpty(std::vector< std::string > const &storedProcesses, std::vector< unsigned int > const &storedCacheIndices, std::vector< unsigned int > const &nEntries)
Definition: ProcessBlockHelper.cc:224
edm::ProcessBlockHelper::processBlockCacheIndices
std::vector< std::vector< unsigned int > > const & processBlockCacheIndices() const final
Definition: ProcessBlockHelper.cc:20
edm::ProcessBlockHelperBase
Definition: ProcessBlockHelperBase.h:18
edm::ProcessBlockHelper::processBlockIndex
unsigned int processBlockIndex(std::string const &processName, EventToProcessBlockIndexes const &) const final
Definition: ProcessBlockHelper.cc:32
edm::ProcessBlockHelper::topProcessesWithProcessBlockProducts
std::vector< std::string > const & topProcessesWithProcessBlockProducts() const final
Definition: ProcessBlockHelper.cc:14
edm::ProcessBlockHelper::dropProcessesAndReorderStoredImpl
void dropProcessesAndReorderStoredImpl(StoredProcessBlockHelper &storedProcessBlockHelper, std::vector< std::string > &finalProcesses, std::vector< unsigned int > const &nEntries, std::vector< unsigned int > const &finalIndexToStoredIndex) const
Definition: ProcessBlockHelper.cc:170
edm::ProcessBlockHelper::outerOffset_
unsigned int outerOffset_
Definition: ProcessBlockHelper.h:110
edm::ProcessBlockHelper::fillFromPrimaryInput
void fillFromPrimaryInput(StoredProcessBlockHelper const &storedProcessBlockHelper, std::vector< unsigned int > const &nEntries)
Definition: ProcessBlockHelper.cc:132
edm::StoredProcessBlockHelper
Definition: StoredProcessBlockHelper.h:25
edm::ProcessBlockHelper::nProcessesInFirstFile_
unsigned int nProcessesInFirstFile_
Definition: ProcessBlockHelper.h:102
AlCaHLTBitMon_QueryRunRegistry.string
string string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
SimL1EmulatorRepack_CalouGT_cff.processName
processName
Definition: SimL1EmulatorRepack_CalouGT_cff.py:17
edm::ProcessBlockHelper::clearAfterOutputFilesClose
void clearAfterOutputFilesClose()
Definition: ProcessBlockHelper.cc:158
edm::ProcessBlockHelper::topProcessBlockHelper
ProcessBlockHelperBase const * topProcessBlockHelper() const final
Definition: ProcessBlockHelper.cc:12
edm::ProcessBlockHelper::processBlockCacheIndices_
std::vector< std::vector< unsigned int > > processBlockCacheIndices_
Definition: ProcessBlockHelper.h:87
edm::ProcessBlockHelper::cacheIndexVectorsPerFile
std::vector< unsigned int > const & cacheIndexVectorsPerFile() const final
Definition: ProcessBlockHelper.cc:26
edm::ProcessBlockHelper::nProcessesInFirstFile
unsigned int nProcessesInFirstFile() const final
Definition: ProcessBlockHelper.cc:18
edm::ProcessBlockHelper::dropProcessesAndReorderStored
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
Definition: ProcessBlockHelper.cc:83
edm::ProcessBlockHelper::fillEntriesFromPrimaryInput
void fillEntriesFromPrimaryInput(std::vector< unsigned int > nEntries)
Definition: ProcessBlockHelper.cc:271
edm::ProcessBlockHelper::cacheEntriesPerFile_
std::vector< unsigned int > cacheEntriesPerFile_
Definition: ProcessBlockHelper.h:100
ProcessBlockHelperBase.h
edm::ProcessBlockHelper::initializedFromInput_
bool initializedFromInput_
Definition: ProcessBlockHelper.h:104
edm::ProcessBlockHelper::nEntries_
std::vector< std::vector< unsigned int > > nEntries_
Definition: ProcessBlockHelper.h:94
edm::ProcessBlockHelper::cacheIndexVectorsPerFile_
std::vector< unsigned int > cacheIndexVectorsPerFile_
Definition: ProcessBlockHelper.h:99