Skip to content

Commit

Permalink
Added verbose option to GetProductCheckerOutputModule
Browse files Browse the repository at this point in the history
  • Loading branch information
Dr15Jones committed Dec 7, 2021
1 parent 7663d51 commit a303839
Showing 1 changed file with 21 additions and 5 deletions.
26 changes: 21 additions & 5 deletions FWCore/Modules/src/GetProductCheckerOutputModule.cc
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
#include "FWCore/Utilities/interface/ProductKindOfType.h"
#include "FWCore/ParameterSet/interface/ConfigurationDescriptions.h"
#include "FWCore/ParameterSet/interface/ParameterSetDescription.h"
#include "FWCore/MessageLogger/interface/MessageLogger.h"

namespace edm {
class ModuleCallingContext;
Expand All @@ -40,6 +41,7 @@ namespace edm {
void write(EventForOutput const& e) override;
void writeLuminosityBlock(LuminosityBlockForOutput const&) override;
void writeRun(RunForOutput const&) override;
const bool verbose_;
};

//
Expand All @@ -54,7 +56,9 @@ namespace edm {
// constructors and destructor
//
GetProductCheckerOutputModule::GetProductCheckerOutputModule(ParameterSet const& iPSet)
: one::OutputModuleBase(iPSet), one::OutputModule<>(iPSet) {}
: one::OutputModuleBase(iPSet),
one::OutputModule<>(iPSet),
verbose_(iPSet.getUntrackedParameter<bool>("verbose")) {}

// GetProductCheckerOutputModule::GetProductCheckerOutputModule(GetProductCheckerOutputModule const& rhs) {
// // do actual copying here;
Expand All @@ -77,12 +81,23 @@ namespace edm {
// member functions
//
template <typename T>
static void check(T const& p, std::string const& id, SelectedProducts const& iProducts) {
static void check(T const& p, std::string const& id, SelectedProducts const& iProducts, bool iVerbose) {
for (auto const& product : iProducts) {
BranchDescription const* branchDescription = product.first;
TypeID const& tid = branchDescription->unwrappedTypeID();
EDGetToken const& token = product.second;
BasicHandle bh = p.getByToken(token, tid);
if (iVerbose) {
if (bh.isValid()) {
edm::LogInfo("FoundProduct") << "found " << branchDescription->moduleLabel() << " '"
<< branchDescription->productInstanceName() << "' "
<< branchDescription->processName();
} else {
edm::LogInfo("DidNotFindProduct")
<< "did not find " << branchDescription->moduleLabel() << " '" << branchDescription->productInstanceName()
<< "' " << branchDescription->processName();
}
}
if (nullptr != bh.provenance() &&
bh.provenance()->branchDescription().branchID() != branchDescription->branchID()) {
throw cms::Exception("BranchIDMissMatch")
Expand All @@ -96,17 +111,17 @@ namespace edm {
void GetProductCheckerOutputModule::write(EventForOutput const& e) {
std::ostringstream str;
str << e.id();
check(e, str.str(), keptProducts()[InEvent]);
check(e, str.str(), keptProducts()[InEvent], verbose_);
}
void GetProductCheckerOutputModule::writeLuminosityBlock(LuminosityBlockForOutput const& l) {
std::ostringstream str;
str << l.id();
check(l, str.str(), keptProducts()[InLumi]);
check(l, str.str(), keptProducts()[InLumi], verbose_);
}
void GetProductCheckerOutputModule::writeRun(RunForOutput const& r) {
std::ostringstream str;
str << r.id();
check(r, str.str(), keptProducts()[InRun]);
check(r, str.str(), keptProducts()[InRun], verbose_);
}

//
Expand All @@ -120,6 +135,7 @@ namespace edm {
void GetProductCheckerOutputModule::fillDescriptions(ConfigurationDescriptions& descriptions) {
ParameterSetDescription desc;
one::OutputModule<>::fillDescription(desc);
desc.addUntracked<bool>("verbose", false);
descriptions.add("productChecker", desc);
}
} // namespace edm
Expand Down

0 comments on commit a303839

Please sign in to comment.