CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros 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.
36  explicit GetProductCheckerOutputModule(ParameterSet const& pset);
38  static void fillDescriptions(ConfigurationDescriptions& descriptions);
39 
40  private:
41  virtual void write(EventPrincipal const& e, edm::ModuleCallingContext const*) override;
42  virtual void writeLuminosityBlock(LuminosityBlockPrincipal const&, edm::ModuleCallingContext const*) override;
43  virtual void writeRun(RunPrincipal const&, edm::ModuleCallingContext const*) override;
44  };
45 
46 //
47 // constants, enums and typedefs
48 //
49 
50 //
51 // static data member definitions
52 //
53 
54 //
55 // constructors and destructor
56 //
58  OutputModule(iPSet) {
59  }
60 
61 // GetProductCheckerOutputModule::GetProductCheckerOutputModule(GetProductCheckerOutputModule const& rhs) {
62 // // do actual copying here;
63 // }
64 
66  }
67 
68 //
69 // assignment operators
70 //
71 // GetProductCheckerOutputModule const& GetProductCheckerOutputModule::operator=(GetProductCheckerOutputModule const& rhs) {
72 // //An exception safe implementation is
73 // GetProductCheckerOutputModule temp(rhs);
74 // swap(rhs);
75 //
76 // return *this;
77 // }
78 
79 //
80 // member functions
81 //
82  static void check(Principal const& p, std::string const& id, edm::ModuleCallingContext const* mcc) {
83  for(Principal::const_iterator it = p.begin(), itEnd = p.end();
84  it != itEnd;
85  ++it) {
86  if(*it) {
87  if (!(*it)->singleProduct()) continue;
88 
89  BranchID branchID = (*it)->branchDescription().branchID();
90  OutputHandle const oh = p.getForOutput(branchID, false, mcc);
91 
92  if(0 != oh.desc() && oh.desc()->branchID() != branchID) {
93  throw cms::Exception("BranchIDMissMatch") << "While processing " << id << " request for BranchID " << branchID << " returned BranchID " << oh.desc()->branchID() << "\n";
94  }
95 
96  TypeID const& tid((*it)->branchDescription().unwrappedTypeID());
98  (*it)->branchDescription().moduleLabel(),
99  (*it)->branchDescription().productInstanceName(),
100  (*it)->branchDescription().processName(),
101  nullptr, mcc);
102 
103  /*This doesn't appear to be an error, it just means the Product isn't available, which can be legitimate
104  if(!bh.product()) {
105  throw cms::Exception("GetByLabelFailure") << "While processing " << id << " getByLabel request for " << (*it)->productDescription().moduleLabel()
106  << " '" << (*it)->productDescription().productInstanceName() << "' " << (*it)->productDescription().processName() << " failed\n.";
107  }*/
108  if(0 != bh.provenance() && bh.provenance()->branchDescription().branchID() != branchID) {
109  throw cms::Exception("BranchIDMissMatch") << "While processing " << id << " getByLabel request for " << (*it)->branchDescription().moduleLabel()
110  << " '" << (*it)->branchDescription().productInstanceName() << "' " << (*it)->branchDescription().processName()
111  << "\n should have returned BranchID " << branchID << " but returned BranchID " << bh.provenance()->branchDescription().branchID() << "\n";
112  }
113  }
114  }
115  }
117  std::ostringstream str;
118  str << e.id();
119  check(e, str.str(), mcc);
120  }
122  std::ostringstream str;
123  str << l.id();
124  check(l, str.str(), mcc);
125  }
127  std::ostringstream str;
128  str << r.id();
129  check(r, str.str(), mcc);
130  }
131 
132 //
133 // const member functions
134 //
135 
136 //
137 // static member functions
138 //
139 
140  void
144  descriptions.add("productChecker", desc);
145  }
146 }
147 
virtual void write(EventPrincipal const &e, edm::ModuleCallingContext const *) override
virtual void writeLuminosityBlock(LuminosityBlockPrincipal const &, edm::ModuleCallingContext const *) override
const_iterator end() const
Definition: Principal.h:158
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
virtual void writeRun(RunPrincipal const &, edm::ModuleCallingContext const *) override
EventID const & id() const
BranchID const & branchID() const
RunID const & id() const
Definition: RunPrincipal.h:69
static void check(Principal const &p, std::string const &id, edm::ModuleCallingContext const *mcc)
OutputHandle getForOutput(BranchID const &bid, bool getProd, ModuleCallingContext const *mcc) const
Definition: Principal.cc:736
const_iterator begin() const
Definition: Principal.h:157
void add(std::string const &label, ParameterSetDescription const &psetDescription)
static void fillDescriptions(ConfigurationDescriptions &descriptions)
static void fillDescription(ParameterSetDescription &desc)
boost::filter_iterator< FilledProductPtr, ProductHolderCollection::const_iterator > const_iterator
Definition: Principal.h:56
BasicHandle getByLabel(KindOfType kindOfType, TypeID const &typeID, InputTag const &inputTag, EDConsumerBase const *consumes, ModuleCallingContext const *mcc) const
Definition: Principal.cc:465
BranchDescription const * desc() const
Definition: OutputHandle.h:101
GetProductCheckerOutputModule(ParameterSet const &pset)