Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make AsciiOutputModule to print out alias branches, and extend EventContentAnalyzer to optionally print provenance information #25265

Merged
merged 2 commits into from Nov 19, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
46 changes: 38 additions & 8 deletions FWCore/Modules/src/AsciiOutputModule.cc
Expand Up @@ -14,6 +14,9 @@
#include "FWCore/ParameterSet/interface/ConfigurationDescriptions.h"
#include "FWCore/ParameterSet/interface/ParameterSetDescription.h"
#include "FWCore/MessageLogger/interface/MessageLogger.h"
#include "FWCore/ParameterSet/interface/Registry.h"
#include "FWCore/ServiceRegistry/interface/Service.h"
#include "FWCore/Framework/interface/ConstProductRegistry.h"

namespace edm {

Expand Down Expand Up @@ -69,13 +72,39 @@ namespace edm {
LogAbsolute("AsciiOut") << '\n' << e.id() << '\n';

// Loop over products, and write some output for each...

std::vector<Provenance const*> provs;
e.getAllProvenance(provs);
for(auto const& prov : provs) {
BranchDescription const& desc = prov->branchDescription();
if (selected(desc)) {
LogAbsolute("AsciiOut") << *prov << '\n';
Service<ConstProductRegistry> reg;
for(auto const& prod: reg->productList()) {
BranchDescription const& desc = prod.second;
if(selected(desc)) {
if(desc.isAlias()) {
LogAbsolute("AsciiOut") << "ModuleLabel " << desc.moduleLabel() << " is an alias for";
}

auto const& prov = e.getProvenance(desc.originalBranchID());
LogAbsolute("AsciiOut") << prov;

if(verbosity_ > 2) {
BranchDescription const& desc2 = prov.branchDescription();
std::string const& process = desc2.processName();
std::string const& label = desc2.moduleLabel();
ProcessHistory const* processHistory = prov.processHistoryPtr();

if (processHistory) {
for (ProcessConfiguration const& pc : *processHistory) {
if (pc.processName() == process) {
ParameterSetID const& psetID = pc.parameterSetID();
pset::Registry const* psetRegistry = pset::Registry::instance();
ParameterSet const* processPset = psetRegistry->getMapped(psetID);
if (processPset) {
if(desc.isAlias()) {
LogAbsolute("AsciiOut") << "Alias PSet\n" << processPset->getParameterSet(desc.moduleLabel());
}
LogAbsolute("AsciiOut") << processPset->getParameterSet(label) << "\n";
}
}
}
}
}
}
}
}
Expand All @@ -89,7 +118,8 @@ namespace edm {
desc.addUntracked("verbosity", 1U)
->setComment("0: no output\n"
"1: event ID and timestamp only\n"
">1: full output");
"2: provenance for each kept product\n"
">2: PSet and provenance for each kept product");
OutputModule::fillDescription(desc);
descriptions.add("asciiOutput", desc);
}
Expand Down
43 changes: 41 additions & 2 deletions FWCore/Modules/src/EventContentAnalyzer.cc
Expand Up @@ -32,6 +32,7 @@
#include "FWCore/Utilities/interface/ObjectWithDict.h"
#include "FWCore/Utilities/interface/TypeWithDict.h"
#include "FWCore/Utilities/interface/TypeToGet.h"
#include "FWCore/ParameterSet/interface/Registry.h"

// system include files
#include <algorithm>
Expand Down Expand Up @@ -281,6 +282,7 @@ namespace edm {
int evno_;
std::map<std::string, int> cumulates_;
bool listContent_;
bool listProvenance_;
};

//
Expand All @@ -294,7 +296,8 @@ namespace edm {
getModuleLabels_(iConfig.getUntrackedParameter("getDataForModuleLabels", std::vector<std::string>())),
getData_(iConfig.getUntrackedParameter("getData", false) || !getModuleLabels_.empty()),
evno_(1),
listContent_(iConfig.getUntrackedParameter("listContent", true))
listContent_(iConfig.getUntrackedParameter("listContent", true)),
listProvenance_(iConfig.getUntrackedParameter("listProvenance", false))
{
//now do what ever initialization is needed
sort_all(moduleLabels_);
Expand Down Expand Up @@ -378,8 +381,42 @@ namespace edm {
<< processName << "\""
<< " (productId = " << provenance->productID() << ")"
<< std::endl;
}

if(listProvenance_) {
auto const& prov = iEvent.getProvenance(provenance->branchID());
auto const *productProvenance = prov.productProvenance();
if(productProvenance) {
const bool isAlias = productProvenance->branchID() != provenance->branchID();
std::string aliasForModLabel;
LogAbsolute("EventContent") << prov;
if(isAlias) {
aliasForModLabel = iEvent.getProvenance(productProvenance->branchID()).moduleLabel();
LogAbsolute("EventContent") << "Is an alias for " << aliasForModLabel;
}
ProcessHistory const *processHistory = prov.processHistoryPtr();
if(processHistory) {
for(ProcessConfiguration const& pc: *processHistory) {
if(pc.processName() == prov.processName()) {
ParameterSetID const& psetID = pc.parameterSetID();
pset::Registry const* psetRegistry = pset::Registry::instance();
ParameterSet const* processPset = psetRegistry->getMapped(psetID);
if (processPset) {
if(processPset->existsAs<ParameterSet>(modLabel)) {
if(isAlias) {
LogAbsolute("EventContent") << "Alias PSet";
}
LogAbsolute("EventContent") << processPset->getParameterSet(modLabel);
}
if(isAlias and processPset->existsAs<ParameterSet>(aliasForModLabel)) {
LogAbsolute("EventContent") << processPset->getParameterSet(aliasForModLabel);
}
}
}
}
}
}
}
}
std::string key = friendlyName
+ std::string(" + \"") + modLabel
+ std::string("\" + \"") + instanceName + "\" \"" + processName + "\"";
Expand Down Expand Up @@ -472,6 +509,8 @@ namespace edm {
np = desc.addOptionalUntracked<bool>("listContent", true);
np->setComment("If true then print a list of all the event content.");

np = desc.addOptionalUntracked<bool>("listProvenance", false);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Dr15Jones Is there a good reason for these to be optional, given that all of them have default values? Now the defaults are specified twice.

np->setComment("If true, and if listContent or verbose is true, print provenance information for each product");

descriptions.add("printContent", desc);
}
Expand Down