Skip to content

Commit

Permalink
Add ProcessBlock feature to Framework
Browse files Browse the repository at this point in the history
This is only the first of a series of PRs implementing
this feature. Future PRs will add persistency and the ability
to access this information from Events, Runs, and Lumis.
  • Loading branch information
wddgit committed Jun 4, 2020
1 parent 5e9f035 commit 35ad468
Show file tree
Hide file tree
Showing 171 changed files with 6,787 additions and 433 deletions.
6 changes: 3 additions & 3 deletions DataFormats/Provenance/interface/BranchDescription.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ namespace edm {

BranchDescription(BranchDescription const& aliasForBranch,
std::string const& moduleLabelAlias,
std::string const& poruductInstanceAlias);
std::string const& productInstanceAlias);

~BranchDescription() {}

Expand Down Expand Up @@ -142,10 +142,10 @@ namespace edm {
// This is set if and only if produced_ is true.
std::string moduleName_;

// The branch name, which is currently derivable fron the other attributes.
// The branch name, which is currently derivable from the other attributes.
std::string branchName_;

// The wrapped class name, which is currently derivable fron the other attributes.
// The wrapped class name, which is currently derivable from the other attributes.
std::string wrappedName_;

// For SwitchProducer alias, the label of the aliased-for label; otherwise empty
Expand Down
4 changes: 0 additions & 4 deletions DataFormats/Provenance/interface/BranchType.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,6 @@ namespace edm {

std::string const& BranchTypeToProductProvenanceBranchName(BranchType const& BranchType);

std::string const& BranchTypeToMajorIndexName(BranchType const& branchType);

std::string const& BranchTypeToMinorIndexName(BranchType const& branchType);

std::ostream& operator<<(std::ostream& os, BranchType const& branchType);

namespace poolNames {
Expand Down
10 changes: 9 additions & 1 deletion DataFormats/Provenance/interface/ProductRegistry.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ namespace edm {

ProductRegistry();

// A constructor from the persistent data memebers from another product registry.
// A constructor from the persistent data members from another product registry.
// saves time by not copying the transient components.
// The constructed registry will be frozen by default.
explicit ProductRegistry(ProductList const& productList, bool toBeFrozen = true);
Expand Down Expand Up @@ -148,6 +148,12 @@ namespace edm {
return get_underlying_safe(runProductLookup_);
}
std::shared_ptr<ProductResolverIndexHelper>& runProductLookup() { return get_underlying_safe(runProductLookup_); }
std::shared_ptr<ProductResolverIndexHelper const> processProductLookup() const {
return get_underlying_safe(processProductLookup_);
}
std::shared_ptr<ProductResolverIndexHelper>& processProductLookup() {
return get_underlying_safe(processProductLookup_);
}

bool frozen_;
// Is at least one (run), (lumi), (event) persistent product produced this process?
Expand All @@ -157,10 +163,12 @@ namespace edm {
edm::propagate_const<std::shared_ptr<ProductResolverIndexHelper>> eventProductLookup_;
edm::propagate_const<std::shared_ptr<ProductResolverIndexHelper>> lumiProductLookup_;
edm::propagate_const<std::shared_ptr<ProductResolverIndexHelper>> runProductLookup_;
edm::propagate_const<std::shared_ptr<ProductResolverIndexHelper>> processProductLookup_;

ProductResolverIndex eventNextIndexValue_;
ProductResolverIndex lumiNextIndexValue_;
ProductResolverIndex runNextIndexValue_;
ProductResolverIndex processNextIndexValue_;

std::map<BranchID, ProductResolverIndex> branchIDToIndex_;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ namespace edm {
// the arguments or a set of matching indexes using the Matches
// class. A returned index can have a value that indicates that it
// is invalid or ambiguous and the client should check for these
// values before using the index (see ProductIndexHolder.h).
// values before using the index (see ProductResolverIndex.h).

// If no matches are found or the ProductResolverIndexHelper
// has not been frozen yet, then an invalid index or a Matches
Expand Down
57 changes: 38 additions & 19 deletions DataFormats/Provenance/src/BranchType.cc
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include "DataFormats/Provenance/interface/BranchType.h"
#include "FWCore/Utilities/interface/EDMException.h"
#include <iostream>

namespace edm {
Expand All @@ -17,6 +18,7 @@ namespace edm {
std::string const productProvenance = "ProductProvenance";

// Prefixes
std::string const process = "ProcessBlock";
std::string const run = "Run";
std::string const lumi = "LuminosityBlock";
std::string const event = "Event";
Expand Down Expand Up @@ -50,15 +52,6 @@ namespace edm {
std::string const lumiProductProvenance = lumi + productProvenance;
std::string const eventProductProvenance = event + productProvenance;

std::string const majorIndex = ".id_.run_";
std::string const runMajorIndex = runAuxiliary + majorIndex;
std::string const lumiMajorIndex = lumiAuxiliary + majorIndex;
std::string const eventMajorIndex = eventAuxiliary + majorIndex;

std::string const runMinorIndex; // empty
std::string const lumiMinorIndex = lumiAuxiliary + ".id_.luminosityBlock_";
std::string const eventMinorIndex = eventAuxiliary + ".id_.event_";

std::string const runAux = run + aux;
std::string const lumiAux = lumi + aux;
std::string const eventAux = event + aux;
Expand Down Expand Up @@ -96,54 +89,80 @@ namespace edm {
} // namespace

std::string const& BranchTypeToString(BranchType const& branchType) {
return ((branchType == InEvent) ? event : ((branchType == InRun) ? run : lumi));
return ((branchType == InEvent) ? event
: ((branchType == InRun) ? run : ((branchType == InLumi) ? lumi : process)));
}

std::string const& BranchTypeToProductTreeName(BranchType const& branchType) {
if (branchType >= InProcess) {
throw Exception(errors::LogicError,
"branchType argument out of legal range for the function BranchTypeToProductTreeName");
}
return ((branchType == InEvent) ? events : ((branchType == InRun) ? runs : lumis));
}

std::string const& BranchTypeToMetaDataTreeName(BranchType const& branchType) {
if (branchType >= InProcess) {
throw Exception(errors::LogicError,
"branchType argument out of legal range for the function BranchTypeToMetaDataTreeName");
}
return ((branchType == InEvent) ? eventMeta : ((branchType == InRun) ? runMeta : lumiMeta));
}

std::string const& BranchTypeToInfoTreeName(BranchType const& branchType) { // backward compatibility
if (branchType >= InProcess) {
throw Exception(errors::LogicError,
"branchType argument out of legal range for the function BranchTypeToInfoTreeName");
}
return ((branchType == InEvent) ? eventInfo
: ((branchType == InRun) ? runInfo : lumiInfo)); // backward compatibility
} // backward compatibility

std::string const& BranchTypeToAuxiliaryBranchName(BranchType const& branchType) {
if (branchType >= InProcess) {
throw Exception(errors::LogicError,
"branchType argument out of legal range for the function BranchTypeToAuxiliaryBranchName");
}
return ((branchType == InEvent) ? eventAuxiliary : ((branchType == InRun) ? runAuxiliary : lumiAuxiliary));
}

std::string const& BranchTypeToAuxBranchName(BranchType const& branchType) { // backward compatibility
std::string const& BranchTypeToAuxBranchName(BranchType const& branchType) { // backward compatibility
if (branchType >= InProcess) {
throw Exception(errors::LogicError,
"branchType argument out of legal range for the function BranchTypeToAuxBranchName");
}
return ((branchType == InEvent) ? eventAux : ((branchType == InRun) ? runAux : lumiAux)); // backward compatibility
} // backward compatibility

std::string const& BranchTypeToProductStatusBranchName(BranchType const& branchType) { // backward compatibility
if (branchType >= InProcess) {
throw Exception(errors::LogicError,
"branchType argument out of legal range for the function BranchTypeToProductStatusBranchName");
}
return ((branchType == InEvent)
? eventProductStatus
: ((branchType == InRun) ? runProductStatus : lumiProductStatus)); // backward compatibility
} // backward compatibility

std::string const& BranchTypeToBranchEntryInfoBranchName(BranchType const& branchType) {
if (branchType >= InProcess) {
throw Exception(errors::LogicError,
"branchType argument out of legal range for the function BranchTypeToBranchEntryInfoBranchName");
}
return ((branchType == InEvent) ? eventEventEntryInfo
: ((branchType == InRun) ? runEventEntryInfo : lumiEventEntryInfo));
}

std::string const& BranchTypeToProductProvenanceBranchName(BranchType const& branchType) {
if (branchType >= InProcess) {
throw Exception(
errors::LogicError,
"branchType argument out of legal range for the function BranchTypeToProductProvenanceBranchName");
}
return ((branchType == InEvent) ? eventProductProvenance
: ((branchType == InRun) ? runProductProvenance : lumiProductProvenance));
}

std::string const& BranchTypeToMajorIndexName(BranchType const& branchType) {
return ((branchType == InEvent) ? eventMajorIndex : ((branchType == InRun) ? runMajorIndex : lumiMajorIndex));
}

std::string const& BranchTypeToMinorIndexName(BranchType const& branchType) {
return ((branchType == InEvent) ? eventMinorIndex : ((branchType == InRun) ? runMinorIndex : lumiMinorIndex));
}

namespace poolNames {

// EntryDescription tree (1 entry per recorded distinct value of EntryDescription)
Expand Down
22 changes: 18 additions & 4 deletions DataFormats/Provenance/src/ProductRegistry.cc
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,11 @@ namespace edm {
eventProductLookup_(new ProductResolverIndexHelper),
lumiProductLookup_(new ProductResolverIndexHelper),
runProductLookup_(new ProductResolverIndexHelper),
processProductLookup_(new ProductResolverIndexHelper),
eventNextIndexValue_(0),
lumiNextIndexValue_(0),
runNextIndexValue_(0),
processNextIndexValue_(0),

branchIDToIndex_() {
for (bool& isProduced : productProduced_)
Expand All @@ -57,10 +59,12 @@ namespace edm {
eventProductLookup_ = std::make_unique<ProductResolverIndexHelper>();
lumiProductLookup_ = std::make_unique<ProductResolverIndexHelper>();
runProductLookup_ = std::make_unique<ProductResolverIndexHelper>();
processProductLookup_ = std::make_unique<ProductResolverIndexHelper>();

eventNextIndexValue_ = 0;
lumiNextIndexValue_ = 0;
runNextIndexValue_ = 0;
processNextIndexValue_ = 0;

branchIDToIndex_.clear();
}
Expand Down Expand Up @@ -151,15 +155,19 @@ namespace edm {
return transient_.eventProductLookup();
if (branchType == InLumi)
return transient_.lumiProductLookup();
return transient_.runProductLookup();
if (branchType == InRun)
return transient_.runProductLookup();
return transient_.processProductLookup();
}

std::shared_ptr<ProductResolverIndexHelper> ProductRegistry::productLookup(BranchType branchType) {
if (branchType == InEvent)
return transient_.eventProductLookup();
if (branchType == InLumi)
return transient_.lumiProductLookup();
return transient_.runProductLookup();
if (branchType == InRun)
return transient_.runProductLookup();
return transient_.processProductLookup();
}

void ProductRegistry::setFrozen(bool initializeLookupInfo) {
Expand Down Expand Up @@ -454,10 +462,12 @@ namespace edm {
productLookup(InEvent)->setFrozen();
productLookup(InLumi)->setFrozen();
productLookup(InRun)->setFrozen();
productLookup(InProcess)->setFrozen();

transient_.eventNextIndexValue_ = productLookup(InEvent)->nextIndexValue();
transient_.lumiNextIndexValue_ = productLookup(InLumi)->nextIndexValue();
transient_.runNextIndexValue_ = productLookup(InRun)->nextIndexValue();
transient_.processNextIndexValue_ = productLookup(InProcess)->nextIndexValue();

for (auto const& product : productList_) {
auto const& desc = product.second;
Expand Down Expand Up @@ -580,14 +590,18 @@ namespace edm {
return transient_.eventNextIndexValue_;
if (branchType == InLumi)
return transient_.lumiNextIndexValue_;
return transient_.runNextIndexValue_;
if (branchType == InRun)
return transient_.runNextIndexValue_;
return transient_.processNextIndexValue_;
}

ProductResolverIndex& ProductRegistry::nextIndexValue(BranchType branchType) {
if (branchType == InEvent)
return transient_.eventNextIndexValue_;
if (branchType == InLumi)
return transient_.lumiNextIndexValue_;
return transient_.runNextIndexValue_;
if (branchType == InRun)
return transient_.runNextIndexValue_;
return transient_.processNextIndexValue_;
}
} // namespace edm
5 changes: 3 additions & 2 deletions FWCore/Framework/interface/BranchActionType.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#define Framework_BranchActionType_h

/*----------------------------------------------------------------------
BranchActionType: BranchAction
----------------------------------------------------------------------*/
Expand All @@ -12,7 +12,8 @@ namespace edm {
BranchActionGlobalBegin = 0,
BranchActionStreamBegin = 1,
BranchActionStreamEnd = 2,
BranchActionGlobalEnd = 3
BranchActionGlobalEnd = 3,
BranchActionGlobalOther = 4
};
}
#endif
4 changes: 4 additions & 0 deletions FWCore/Framework/interface/EDAnalyzer.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ namespace edm {
// Warning: the returned moduleDescription will be invalid during construction
ModuleDescription const& moduleDescription() const { return moduleDescription_; }

static bool wantsProcessBlocks() { return false; }
static bool wantsGlobalRuns() { return true; }
static bool wantsGlobalLuminosityBlocks() { return true; }
static bool wantsStreamRuns() { return false; }
Expand All @@ -69,6 +70,9 @@ namespace edm {
void doPreallocate(PreallocationConfiguration const&) {}
void doBeginJob();
void doEndJob();
void doBeginProcessBlock(ProcessBlockPrincipal const&, ModuleCallingContext const*) {}
void doAccessInputProcessBlock(ProcessBlockPrincipal const&, ModuleCallingContext const*) {}
void doEndProcessBlock(ProcessBlockPrincipal const&, ModuleCallingContext const*) {}
bool doBeginRun(RunPrincipal const& rp, EventSetupImpl const& c, ModuleCallingContext const* mcc);
bool doEndRun(RunPrincipal const& rp, EventSetupImpl const& c, ModuleCallingContext const* mcc);
bool doBeginLuminosityBlock(LuminosityBlockPrincipal const& lbp,
Expand Down
14 changes: 9 additions & 5 deletions FWCore/Framework/interface/EDConsumerBase.h
Original file line number Diff line number Diff line change
Expand Up @@ -108,11 +108,14 @@ namespace edm {
std::vector<ConsumesInfo> consumesInfo() const;

ESProxyIndex const* esGetTokenIndices(edm::Transition iTrans) const {
auto const& v = esItemsToGetFromTransition_[static_cast<unsigned int>(iTrans)];
if (v.empty()) {
return nullptr;
if (iTrans < edm::Transition::NumberOfEventSetupTransitions) {
auto const& v = esItemsToGetFromTransition_[static_cast<unsigned int>(iTrans)];
if (v.empty()) {
return nullptr;
}
return &(esItemsToGetFromTransition_[static_cast<unsigned int>(iTrans)].front());
}
return &(esItemsToGetFromTransition_[static_cast<unsigned int>(iTrans)].front());
return nullptr;
}

protected:
Expand Down Expand Up @@ -194,6 +197,7 @@ namespace edm {
void throwBranchMismatch(BranchType, EDGetToken) const;
void throwBadToken(edm::TypeID const& iType, EDGetToken iToken) const;
void throwConsumesCallAfterFrozen(TypeToGet const&, InputTag const&) const;
void throwESConsumesInProcessBlock() const;

edm::InputTag const& checkIfEmpty(edm::InputTag const& tag);
// ---------- member data --------------------------------
Expand Down Expand Up @@ -245,7 +249,7 @@ namespace edm {
// inserts in the middle of the data structure.
enum { kESLookupInfo, kESProxyIndex };
edm::SoATuple<ESTokenLookupInfo, ESProxyIndex> m_esTokenInfo;
std::array<std::vector<ESProxyIndex>, static_cast<unsigned int>(edm::Transition::NumberOfTransitions)>
std::array<std::vector<ESProxyIndex>, static_cast<unsigned int>(edm::Transition::NumberOfEventSetupTransitions)>
esItemsToGetFromTransition_;
bool frozen_;
bool containsCurrentProcessAlias_;
Expand Down
4 changes: 4 additions & 0 deletions FWCore/Framework/interface/EDFilter.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ namespace edm {
// Warning: the returned moduleDescription will be invalid during construction
ModuleDescription const& moduleDescription() const { return moduleDescription_; }

static bool wantsProcessBlocks() { return false; }
static bool wantsGlobalRuns() { return true; }
static bool wantsGlobalLuminosityBlocks() { return true; }
static bool wantsStreamRuns() { return false; }
Expand All @@ -76,6 +77,9 @@ namespace edm {
void doPreallocate(PreallocationConfiguration const&) {}
void doBeginJob();
void doEndJob();
void doBeginProcessBlock(ProcessBlockPrincipal const&, ModuleCallingContext const*) {}
void doAccessInputProcessBlock(ProcessBlockPrincipal const&, ModuleCallingContext const*) {}
void doEndProcessBlock(ProcessBlockPrincipal const&, ModuleCallingContext const*) {}
void doBeginRun(RunPrincipal const& rp, EventSetupImpl const& c, ModuleCallingContext const* mcc);
void doEndRun(RunPrincipal const& rp, EventSetupImpl const& c, ModuleCallingContext const* mcc);
void doBeginLuminosityBlock(LuminosityBlockPrincipal const& lbp,
Expand Down
4 changes: 4 additions & 0 deletions FWCore/Framework/interface/EDProducer.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ namespace edm {
// Warning: the returned moduleDescription will be invalid during construction
ModuleDescription const& moduleDescription() const { return moduleDescription_; }

static bool wantsProcessBlocks() { return false; }
static bool wantsGlobalRuns() { return true; }
static bool wantsGlobalLuminosityBlocks() { return true; }
static bool wantsStreamRuns() { return false; }
Expand All @@ -72,6 +73,9 @@ namespace edm {
void doPreallocate(PreallocationConfiguration const&) {}
void doBeginJob();
void doEndJob();
void doBeginProcessBlock(ProcessBlockPrincipal const&, ModuleCallingContext const*) {}
void doAccessInputProcessBlock(ProcessBlockPrincipal const&, ModuleCallingContext const*) {}
void doEndProcessBlock(ProcessBlockPrincipal const&, ModuleCallingContext const*) {}
void doBeginRun(RunPrincipal const& rp, EventSetupImpl const& c, ModuleCallingContext const* mcc);
void doEndRun(RunPrincipal const& rp, EventSetupImpl const& c, ModuleCallingContext const* mcc);
void doBeginLuminosityBlock(LuminosityBlockPrincipal const& lbp,
Expand Down
Loading

0 comments on commit 35ad468

Please sign in to comment.