CMS 3D CMS Logo

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
27 
28 namespace edm {
29  class ModuleCallingContext;
30  class ParameterSet;
31 
33  public:
34  // We do not take ownership of passed stream.
37  static void fillDescriptions(ConfigurationDescriptions& descriptions);
38 
39  private:
40  void write(EventForOutput const& e) override;
41  void writeLuminosityBlock(LuminosityBlockForOutput const&) override;
42  void writeRun(RunForOutput const&) override;
43  };
44 
45  //
46  // constants, enums and typedefs
47  //
48 
49  //
50  // static data member definitions
51  //
52 
53  //
54  // constructors and destructor
55  //
57 
58  // GetProductCheckerOutputModule::GetProductCheckerOutputModule(GetProductCheckerOutputModule const& rhs) {
59  // // do actual copying here;
60  // }
61 
63 
64  //
65  // assignment operators
66  //
67  // GetProductCheckerOutputModule const& GetProductCheckerOutputModule::operator=(GetProductCheckerOutputModule const& rhs) {
68  // //An exception safe implementation is
69  // GetProductCheckerOutputModule temp(rhs);
70  // swap(rhs);
71  //
72  // return *this;
73  // }
74 
75  //
76  // member functions
77  //
78  template <typename T>
79  static void check(T const& p, std::string const& id, SelectedProducts const& iProducts) {
80  for (auto const& product : iProducts) {
81  BranchDescription const* branchDescription = product.first;
82  TypeID const& tid = branchDescription->unwrappedTypeID();
83  EDGetToken const& token = product.second;
84  BasicHandle bh = p.getByToken(token, tid);
85  if (nullptr != bh.provenance() &&
86  bh.provenance()->branchDescription().branchID() != branchDescription->branchID()) {
87  throw cms::Exception("BranchIDMissMatch")
88  << "While processing " << id << " getByToken request for " << branchDescription->moduleLabel() << " '"
89  << branchDescription->productInstanceName() << "' " << branchDescription->processName()
90  << "\n should have returned BranchID " << branchDescription->branchID() << " but returned BranchID "
91  << bh.provenance()->branchDescription().branchID() << "\n";
92  }
93  }
94  }
96  std::ostringstream str;
97  str << e.id();
98  check(e, str.str(), keptProducts()[InEvent]);
99  }
101  std::ostringstream str;
102  str << l.id();
103  check(l, str.str(), keptProducts()[InLumi]);
104  }
106  std::ostringstream str;
107  str << r.id();
108  check(r, str.str(), keptProducts()[InRun]);
109  }
110 
111  //
112  // const member functions
113  //
114 
115  //
116  // static member functions
117  //
118 
122  descriptions.add("productChecker", desc);
123  }
124 } // namespace edm
125 
EventID const & id() const
RunID const & id() const
Definition: RunForOutput.h:49
std::string const & processName() const
Provenance const * provenance() const (true)
Definition: BasicHandle.h:86
SelectedProductsForBranchType const & keptProducts() const
Definition: OutputModule.h:82
std::vector< std::pair< BranchDescription const *, EDGetToken > > SelectedProducts
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
std::string const & moduleLabel() const
std::string const & productInstanceName() const
static void fillDescription(ParameterSetDescription &desc, std::vector< std::string > const &iDefaultOutputCommands=ProductSelectorRules::defaultSelectionStrings())
TypeID unwrappedTypeID() const
BranchID const & branchID() const
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)
HLT enums.
void writeLuminosityBlock(LuminosityBlockForOutput const &) override
LuminosityBlockID const & id() const
GetProductCheckerOutputModule(ParameterSet const &pset)
#define str(s)
long double T
void write(EventForOutput const &e) override
static void check(T const &p, std::string const &id, SelectedProducts const &iProducts)