Skip to content

Commit b0972e1

Browse files
committed
Implement persistence for ProcessBlock products
1 parent 094dae7 commit b0972e1

File tree

224 files changed

+9964
-1094
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

224 files changed

+9964
-1094
lines changed

DQMServices/FwkIO/plugins/DQMRootSource.cc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -325,7 +325,7 @@ class DQMRootSource : public edm::PuttableSourceBase, DQMTTreeIO {
325325

326326
edm::InputSource::ItemType getNextItemType() override;
327327

328-
std::unique_ptr<edm::FileBlock> readFile_() override;
328+
std::shared_ptr<edm::FileBlock> readFile_() override;
329329
std::shared_ptr<edm::RunAuxiliary> readRunAuxiliary_() override;
330330
std::shared_ptr<edm::LuminosityBlockAuxiliary> readLuminosityBlockAuxiliary_() override;
331331
void readRun_(edm::RunPrincipal& rpCache) override;
@@ -465,7 +465,7 @@ DQMRootSource::~DQMRootSource() {
465465
edm::InputSource::ItemType DQMRootSource::getNextItemType() { return m_nextItemType; }
466466

467467
// We will read the metadata of all files and fill m_fileMetadatas vector
468-
std::unique_ptr<edm::FileBlock> DQMRootSource::readFile_() {
468+
std::shared_ptr<edm::FileBlock> DQMRootSource::readFile_() {
469469
const int numFiles = m_catalog.fileNames(0).size();
470470
m_openFiles.reserve(numFiles);
471471

@@ -601,7 +601,7 @@ std::unique_ptr<edm::FileBlock> DQMRootSource::readFile_() {
601601
m_nextItemType = edm::InputSource::IsRun;
602602

603603
// We have to return something but not sure why
604-
return std::make_unique<edm::FileBlock>();
604+
return std::make_shared<edm::FileBlock>();
605605
}
606606

607607
std::shared_ptr<edm::RunAuxiliary> DQMRootSource::readRunAuxiliary_() {

DataFormats/Provenance/interface/BranchType.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,12 @@
99
#include "FWCore/Utilities/interface/BranchType.h"
1010

1111
namespace edm {
12+
1213
std::string const& BranchTypeToString(BranchType const& branchType);
1314

15+
constexpr unsigned int numberOfRunLumiEventProductTrees = 3;
1416
std::string const& BranchTypeToProductTreeName(BranchType const& branchType);
17+
std::string BranchTypeToProductTreeName(BranchType const& branchType, std::string const& processName);
1518

1619
std::string const& BranchTypeToMetaDataTreeName(BranchType const& branchType);
1720

@@ -49,6 +52,7 @@ namespace edm {
4952
// Other branches on Events Tree
5053
std::string const& eventSelectionsBranchName();
5154
std::string const& branchListIndexesBranchName();
55+
std::string const& eventToProcessBlockIndexesBranchName();
5256

5357
//------------------------------------------------------------------
5458
//------------------------------------------------------------------
@@ -70,6 +74,7 @@ namespace edm {
7074
std::string const& fileIndexBranchName(); // backward compatibility
7175
std::string const& indexIntoFileBranchName();
7276
std::string const& mergeableRunProductMetadataBranchName();
77+
std::string const& processBlockHelperBranchName();
7378

7479
// Event History Tree // backward compatibility
7580
std::string const& eventHistoryTreeName(); // backward compatibility
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#ifndef DataFormats_Provenance_EventToProcessBlockIndexes_h
2+
#define DataFormats_Provenance_EventToProcessBlockIndexes_h
3+
4+
/**
5+
6+
\author W. David Dagenhart, created 5 January, 2021
7+
8+
*/
9+
10+
namespace edm {
11+
12+
class EventToProcessBlockIndexes {
13+
public:
14+
EventToProcessBlockIndexes() {}
15+
16+
unsigned int index() const { return index_; }
17+
void setIndex(unsigned int value) { index_ = value; }
18+
19+
private:
20+
unsigned int index_ = 0;
21+
};
22+
23+
} // namespace edm
24+
#endif

DataFormats/Provenance/interface/ProvenanceFwd.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ namespace edm {
1212
class ProductProvenance;
1313
class EventAuxiliary;
1414
class EventID;
15+
class EventToProcessBlockIndexes;
1516
class LuminosityBlockAuxiliary;
1617
class LuminosityBlockID;
1718
class ModuleDescription;
@@ -24,6 +25,7 @@ namespace edm {
2425
class RunAuxiliary;
2526
class RunID;
2627
class StableProvenance;
28+
class StoredProcessBlockHelper;
2729
class Timestamp;
2830
class ProductProvenanceLookup;
2931
} // namespace edm
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
#ifndef DataFormats_Provenance_StoredProcessBlockHelper_h
2+
#define DataFormats_Provenance_StoredProcessBlockHelper_h
3+
4+
/** \class edm::StoredProcessBlockHelper
5+
6+
This contains the information from the ProcessBlockHelper
7+
that is persistent. The processBlockCacheIndices_ data
8+
member is a flattened version of the vector of vectors
9+
in the ProcessBlockHelper. It is flattened mainly for
10+
I/O performance reasons. This is intended to be directly
11+
used only by the IOPool code responsible for reading
12+
and writing the persistent files. Everything else should
13+
interact with the ProcessBlockHelper.
14+
15+
\author W. David Dagenhart, created 1 Oct, 2020
16+
17+
*/
18+
19+
#include <string>
20+
#include <vector>
21+
22+
namespace edm {
23+
24+
class StoredProcessBlockHelper {
25+
public:
26+
// This constructor exists for ROOT I/O
27+
StoredProcessBlockHelper();
28+
29+
StoredProcessBlockHelper(std::vector<std::string> const& processesWithProcessBlockProducts);
30+
31+
std::vector<std::string> const& processesWithProcessBlockProducts() const {
32+
return processesWithProcessBlockProducts_;
33+
}
34+
35+
std::vector<std::string>& processesWithProcessBlockProducts() { return processesWithProcessBlockProducts_; }
36+
37+
std::vector<unsigned int> const& processBlockCacheIndices() const { return processBlockCacheIndices_; }
38+
39+
std::vector<unsigned int>& processBlockCacheIndices() { return processBlockCacheIndices_; }
40+
41+
static constexpr unsigned int invalidCacheIndex() { return 0xffffffff; }
42+
static constexpr unsigned int invalidProcessIndex() { return 0xffffffff; }
43+
44+
private:
45+
std::vector<std::string> processesWithProcessBlockProducts_;
46+
47+
std::vector<unsigned int> processBlockCacheIndices_;
48+
};
49+
} // namespace edm
50+
#endif

DataFormats/Provenance/src/BranchType.cc

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,11 +78,13 @@ namespace edm {
7878
std::string const fileIndex = "FileIndex";
7979
std::string const indexIntoFile = "IndexIntoFile";
8080
std::string const mergeableRunProductMetadata = "MergeableRunProductMetadata";
81+
std::string const processBlockHelper = "ProcessBlockHelper";
8182
std::string const eventHistory = "EventHistory";
8283
std::string const eventBranchMapper = "EventBranchMapper";
8384

8485
std::string const eventSelections = "EventSelections";
8586
std::string const branchListIndexes = "BranchListIndexes";
87+
std::string const eventToProcessBlockIndexes = "EventToProcessBlockIndexes";
8688

8789
std::string const parameterSetsTree = "ParameterSets";
8890
std::string const idToParameterSetBlobsBranch = "IdToParameterSetsBlobs";
@@ -95,6 +97,11 @@ namespace edm {
9597
return treeNames[branchType];
9698
}
9799

100+
std::string BranchTypeToProductTreeName(BranchType const& branchType, std::string const& processName) {
101+
assert(branchType == InProcess);
102+
return branchTypeNames[InProcess] + "s" + processName;
103+
}
104+
98105
std::string const& BranchTypeToMetaDataTreeName(BranchType const& branchType) {
99106
assert(branchType < eventLumiRunSize);
100107
return metaTreeNames[branchType];
@@ -193,6 +200,9 @@ namespace edm {
193200
// Branch on MetaData Tree
194201
std::string const& mergeableRunProductMetadataBranchName() { return mergeableRunProductMetadata; }
195202

203+
// Branch on MetaData Tree
204+
std::string const& processBlockHelperBranchName() { return processBlockHelper; }
205+
196206
// Branch on Event History Tree
197207
std::string const& eventHistoryBranchName() { return eventHistory; }
198208

@@ -201,6 +211,8 @@ namespace edm {
201211

202212
std::string const& branchListIndexesBranchName() { return branchListIndexes; }
203213

214+
std::string const& eventToProcessBlockIndexesBranchName() { return eventToProcessBlockIndexes; }
215+
204216
std::string const& parameterSetsTreeName() { return parameterSetsTree; }
205217
// Branch on ParameterSets Tree
206218
std::string const& idToParameterSetBlobsBranchName() { return idToParameterSetBlobsBranch; }

DataFormats/Provenance/src/ProductRegistry.cc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,8 @@ namespace edm {
273273
}
274274
++i;
275275
} else if (i == e || (j != s && j->first < i->first)) {
276-
if (j->second.present() && branchesMustMatch == BranchDescription::Strict) {
276+
if (j->second.present() &&
277+
(branchesMustMatch == BranchDescription::Strict || j->second.branchType() == InProcess)) {
277278
differences << "Branch '" << j->second.branchName() << "' is in previous files\n";
278279
differences << " but not in file '" << fileName << "'.\n";
279280
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#include "DataFormats/Provenance/interface/StoredProcessBlockHelper.h"
2+
3+
namespace edm {
4+
5+
StoredProcessBlockHelper::StoredProcessBlockHelper() {}
6+
7+
StoredProcessBlockHelper::StoredProcessBlockHelper(std::vector<std::string> const& processesWithProcessBlockProducts)
8+
: processesWithProcessBlockProducts_(processesWithProcessBlockProducts) {}
9+
10+
} // namespace edm

DataFormats/Provenance/src/classes.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
#include "DataFormats/Provenance/interface/ElementID.h"
66
#include "DataFormats/Provenance/interface/EventAuxiliary.h"
77
#include "DataFormats/Provenance/interface/EventID.h"
8+
#include "DataFormats/Provenance/interface/EventToProcessBlockIndexes.h"
89
#include "DataFormats/Provenance/interface/FileFormatVersion.h"
910
#include "DataFormats/Provenance/interface/FileID.h"
1011
#include "DataFormats/Provenance/interface/FileIndex.h"
@@ -27,6 +28,7 @@
2728
#include "DataFormats/Provenance/interface/ProductID.h"
2829
#include "DataFormats/Provenance/interface/ProductProvenance.h"
2930
#include "DataFormats/Provenance/interface/StoredMergeableRunProductMetadata.h"
31+
#include "DataFormats/Provenance/interface/StoredProcessBlockHelper.h"
3032
#include "DataFormats/Provenance/interface/StoredProductProvenance.h"
3133
#include "DataFormats/Provenance/interface/ProductRegistry.h"
3234
#include "DataFormats/Provenance/interface/RunAuxiliary.h"

DataFormats/Provenance/src/classes_def.xml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,9 @@
147147
<class name="edm::StoredMergeableRunProductMetadata" ClassVersion="3">
148148
<version ClassVersion="3" checksum="2293482595"/>
149149
</class>
150+
<class name="edm::StoredProcessBlockHelper" ClassVersion="3">
151+
<version ClassVersion="3" checksum="3443065706"/>
152+
</class>
150153
<class name="edm::ProcessHistoryID"/>
151154
<class name="std::set<edm::ProcessHistoryID >"/>
152155
<class name="std::vector<edm::ProcessHistory>"/>
@@ -217,6 +220,10 @@
217220
<class name="edm::ThinnedAssociationsHelper" ClassVersion="10">
218221
<version ClassVersion="10" checksum="3444973106"/>
219222
</class>
223+
<class name="edm::EventToProcessBlockIndexes" ClassVersion="3">
224+
<version ClassVersion="3" checksum="1281389788"/>
225+
</class>
226+
220227
<ioread sourceClass="edm::ProductRegistry" targetClass="edm::ProductRegistry" version="[1-]" source="" target="transient_">
221228
<![CDATA[
222229
newObj->initializeTransients();

0 commit comments

Comments
 (0)