CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
GetProductCheckerOutputModule.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: Modules
4 // Class : GetProductCheckerOutputModule
5 //
6 // Implementation:
7 // <Notes on implementation>
8 //
9 // Original Author:
10 // Created: Wed Oct 7 14:41:26 CDT 2009
11 //
12 
13 // system include files
14 #include <string>
15 #include <sstream>
16 
17 // user include files
28 
29 namespace edm {
30  class ModuleCallingContext;
31  class ParameterSet;
32 
34  public:
35  // We do not take ownership of passed stream.
38  static void fillDescriptions(ConfigurationDescriptions& descriptions);
39 
40  private:
41  void write(EventForOutput const& e) override;
42  void writeLuminosityBlock(LuminosityBlockForOutput const&) override;
43  void writeRun(RunForOutput const&) override;
44  const bool verbose_;
45  };
46 
47  //
48  // constants, enums and typedefs
49  //
50 
51  //
52  // static data member definitions
53  //
54 
55  //
56  // constructors and destructor
57  //
59  : one::OutputModuleBase(iPSet),
60  one::OutputModule<>(iPSet),
61  verbose_(iPSet.getUntrackedParameter<bool>("verbose")) {}
62 
63  // GetProductCheckerOutputModule::GetProductCheckerOutputModule(GetProductCheckerOutputModule const& rhs) {
64  // // do actual copying here;
65  // }
66 
68 
69  //
70  // assignment operators
71  //
72  // GetProductCheckerOutputModule const& GetProductCheckerOutputModule::operator=(GetProductCheckerOutputModule const& rhs) {
73  // //An exception safe implementation is
74  // GetProductCheckerOutputModule temp(rhs);
75  // swap(rhs);
76  //
77  // return *this;
78  // }
79 
80  //
81  // member functions
82  //
83  template <typename T>
84  static void check(T const& p, std::string const& id, SelectedProducts const& iProducts, bool iVerbose) {
85  for (auto const& product : iProducts) {
86  BranchDescription const* branchDescription = product.first;
87  TypeID const& tid = branchDescription->unwrappedTypeID();
88  EDGetToken const& token = product.second;
89  BasicHandle bh = p.getByToken(token, tid);
90  if (iVerbose) {
91  if (bh.isValid()) {
92  edm::LogInfo("FoundProduct") << "found " << branchDescription->moduleLabel() << " '"
93  << branchDescription->productInstanceName() << "' "
94  << branchDescription->processName();
95  } else {
96  edm::LogInfo("DidNotFindProduct")
97  << "did not find " << branchDescription->moduleLabel() << " '" << branchDescription->productInstanceName()
98  << "' " << branchDescription->processName();
99  }
100  }
101  if (nullptr != bh.provenance() &&
102  bh.provenance()->branchDescription().branchID() != branchDescription->branchID()) {
103  throw cms::Exception("BranchIDMissMatch")
104  << "While processing " << id << " getByToken request for " << branchDescription->moduleLabel() << " '"
105  << branchDescription->productInstanceName() << "' " << branchDescription->processName()
106  << "\n should have returned BranchID " << branchDescription->branchID() << " but returned BranchID "
107  << bh.provenance()->branchDescription().branchID() << "\n";
108  }
109  }
110  }
112  std::ostringstream str;
113  str << e.id();
114  check(e, str.str(), keptProducts()[InEvent], verbose_);
115  }
117  std::ostringstream str;
118  str << l.id();
119  check(l, str.str(), keptProducts()[InLumi], verbose_);
120  }
122  std::ostringstream str;
123  str << r.id();
124  check(r, str.str(), keptProducts()[InRun], verbose_);
125  }
126 
127  //
128  // const member functions
129  //
130 
131  //
132  // static member functions
133  //
134 
138  desc.addUntracked<bool>("verbose", false);
139  descriptions.add("productChecker", desc);
140  }
141 } // namespace edm
142 
EventID const & id() const
ParameterDescriptionBase * addUntracked(U const &iLabel, T const &value)
RunID const & id() const
Definition: RunForOutput.h:55
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
std::string const & processName() const
std::vector< std::pair< BranchDescription const *, EDGetToken > > SelectedProducts
std::string const & moduleLabel() const
std::string const & productInstanceName() const
TypeID unwrappedTypeID() const
BranchID const & branchID() const
bool isValid() const noexcept(true)
Definition: BasicHandle.h:69
Log< level::Info, false > LogInfo
void writeRun(RunForOutput const &) override
BranchDescription const & branchDescription() const
Definition: Provenance.h:45
void add(std::string const &label, ParameterSetDescription const &psetDescription)
static void fillDescriptions(ConfigurationDescriptions &descriptions)
static void check(T const &p, std::string const &id, SelectedProducts const &iProducts, bool iVerbose)
void writeLuminosityBlock(LuminosityBlockForOutput const &) override
SelectedProductsForBranchType const & keptProducts() const
LuminosityBlockID const & id() const
GetProductCheckerOutputModule(ParameterSet const &pset)
#define str(s)
long double T
Provenance const * provenance() const noexcept(true)
Definition: BasicHandle.h:75
static void fillDescription(ParameterSetDescription &desc, std::vector< std::string > const &iDefaultOutputCommands=ProductSelectorRules::defaultSelectionStrings())
void write(EventForOutput const &e) override