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/ParameterSet/interface/ConfigurationDescriptions.h"
00026 #include "FWCore/ParameterSet/interface/ParameterSetDescription.h"
00027
00028 namespace edm {
00029 class ParameterSet;
00030 class GetProductCheckerOutputModule : public OutputModule {
00031 public:
00032
00033 explicit GetProductCheckerOutputModule(ParameterSet const& pset);
00034 virtual ~GetProductCheckerOutputModule();
00035 static void fillDescriptions(ConfigurationDescriptions& descriptions);
00036
00037 private:
00038 virtual void write(EventPrincipal const& e);
00039 virtual void writeLuminosityBlock(LuminosityBlockPrincipal const&);
00040 virtual void writeRun(RunPrincipal const&);
00041 };
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054 GetProductCheckerOutputModule::GetProductCheckerOutputModule(ParameterSet const& iPSet):
00055 OutputModule(iPSet) {
00056 }
00057
00058
00059
00060
00061
00062 GetProductCheckerOutputModule::~GetProductCheckerOutputModule() {
00063 }
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079 static void check(Principal const& p, std::string const& id) {
00080 for(Principal::const_iterator it = p.begin(), itEnd = p.end();
00081 it != itEnd;
00082 ++it) {
00083 if(*it) {
00084 BranchID branchID = (*it)->branchDescription().branchID();
00085 OutputHandle const oh = p.getForOutput(branchID, false);
00086
00087 if(0 != oh.desc() && oh.desc()->branchID() != branchID) {
00088 throw cms::Exception("BranchIDMissMatch") << "While processing " << id << " request for BranchID " << branchID << " returned BranchID " << oh.desc()->branchID() << "\n";
00089 }
00090
00091 TypeID tid((*it)->branchDescription().type().TypeInfo());
00092 size_t temp = 0;
00093 int tempCount = -1;
00094 BasicHandle bh = p.getByLabel(tid,
00095 (*it)->branchDescription().moduleLabel(),
00096 (*it)->branchDescription().productInstanceName(),
00097 (*it)->branchDescription().processName(),
00098 temp, tempCount);
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);