Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014 #include <string>
00015 #include <sstream>
00016
00017
00018 #include "DataFormats/Common/interface/OutputHandle.h"
00019 #include "FWCore/Framework/interface/OutputModule.h"
00020 #include "FWCore/Framework/interface/MakerMacros.h"
00021 #include "FWCore/Framework/interface/EventPrincipal.h"
00022 #include "FWCore/Framework/interface/LuminosityBlockPrincipal.h"
00023 #include "FWCore/Framework/interface/RunPrincipal.h"
00024 #include "FWCore/Utilities/interface/Exception.h"
00025 #include "FWCore/Utilities/interface/ProductKindOfType.h"
00026 #include "FWCore/ParameterSet/interface/ConfigurationDescriptions.h"
00027 #include "FWCore/ParameterSet/interface/ParameterSetDescription.h"
00028
00029 namespace edm {
00030 class ParameterSet;
00031 class GetProductCheckerOutputModule : public OutputModule {
00032 public:
00033
00034 explicit GetProductCheckerOutputModule(ParameterSet const& pset);
00035 virtual ~GetProductCheckerOutputModule();
00036 static void fillDescriptions(ConfigurationDescriptions& descriptions);
00037
00038 private:
00039 virtual void write(EventPrincipal const& e);
00040 virtual void writeLuminosityBlock(LuminosityBlockPrincipal const&);
00041 virtual void writeRun(RunPrincipal const&);
00042 };
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055 GetProductCheckerOutputModule::GetProductCheckerOutputModule(ParameterSet const& iPSet):
00056 OutputModule(iPSet) {
00057 }
00058
00059
00060
00061
00062
00063 GetProductCheckerOutputModule::~GetProductCheckerOutputModule() {
00064 }
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080 static void check(Principal const& p, std::string const& id) {
00081 for(Principal::const_iterator it = p.begin(), itEnd = p.end();
00082 it != itEnd;
00083 ++it) {
00084 if(*it) {
00085 if (!(*it)->singleProduct()) continue;
00086
00087 BranchID branchID = (*it)->branchDescription().branchID();
00088 OutputHandle const oh = p.getForOutput(branchID, false);
00089
00090 if(0 != oh.desc() && oh.desc()->branchID() != branchID) {
00091 throw cms::Exception("BranchIDMissMatch") << "While processing " << id << " request for BranchID " << branchID << " returned BranchID " << oh.desc()->branchID() << "\n";
00092 }
00093
00094 TypeID const& tid((*it)->branchDescription().unwrappedTypeID());
00095 BasicHandle bh = p.getByLabel(PRODUCT_TYPE, tid,
00096 (*it)->branchDescription().moduleLabel(),
00097 (*it)->branchDescription().productInstanceName(),
00098 (*it)->branchDescription().processName());
00099
00100
00101
00102
00103
00104
00105 if(0 != bh.provenance() && bh.provenance()->branchDescription().branchID() != branchID) {
00106 throw cms::Exception("BranchIDMissMatch") << "While processing " << id << " getByLabel request for " << (*it)->branchDescription().moduleLabel()
00107 << " '" << (*it)->branchDescription().productInstanceName() << "' " << (*it)->branchDescription().processName()
00108 << "\n should have returned BranchID " << branchID << " but returned BranchID " << bh.provenance()->branchDescription().branchID() << "\n";
00109 }
00110 }
00111 }
00112 }
00113 void GetProductCheckerOutputModule::write(EventPrincipal const& e) {
00114 std::ostringstream str;
00115 str << e.id();
00116 check(e, str.str());
00117 }
00118 void GetProductCheckerOutputModule::writeLuminosityBlock(LuminosityBlockPrincipal const& l) {
00119 std::ostringstream str;
00120 str << l.id();
00121 check(l, str.str());
00122 }
00123 void GetProductCheckerOutputModule::writeRun(RunPrincipal const& r) {
00124 std::ostringstream str;
00125 str << r.id();
00126 check(r, str.str());
00127 }
00128
00129
00130
00131
00132
00133
00134
00135
00136
00137 void
00138 GetProductCheckerOutputModule::fillDescriptions(ConfigurationDescriptions& descriptions) {
00139 ParameterSetDescription desc;
00140 OutputModule::fillDescription(desc);
00141 descriptions.add("productChecker", desc);
00142 }
00143 }
00144
00145 using edm::GetProductCheckerOutputModule;
00146 DEFINE_FWK_MODULE(GetProductCheckerOutputModule);