CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_2_9/src/FWCore/Modules/src/GetProductCheckerOutputModule.cc

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 //
00003 // Package:     Modules
00004 // Class  :     GetProductCheckerOutputModule
00005 // 
00006 // Implementation:
00007 //     <Notes on implementation>
00008 //
00009 // Original Author:  
00010 //         Created:  Wed Oct  7 14:41:26 CDT 2009
00011 //
00012 
00013 // system include files
00014 #include <string>
00015 #include <sstream>
00016 
00017 // user include files
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       // We do not take ownership of passed stream.
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 // constants, enums and typedefs
00045 //
00046 
00047 //
00048 // static data member definitions
00049 //
00050 
00051 //
00052 // constructors and destructor
00053 //
00054    GetProductCheckerOutputModule::GetProductCheckerOutputModule(ParameterSet const& iPSet):
00055    OutputModule(iPSet) { 
00056    } 
00057 
00058 // GetProductCheckerOutputModule::GetProductCheckerOutputModule(GetProductCheckerOutputModule const& rhs) {
00059 //    // do actual copying here;
00060 // }
00061 
00062    GetProductCheckerOutputModule::~GetProductCheckerOutputModule() {
00063    }
00064 
00065 //
00066 // assignment operators
00067 //
00068 // GetProductCheckerOutputModule const& GetProductCheckerOutputModule::operator=(GetProductCheckerOutputModule const& rhs) {
00069 //   //An exception safe implementation is
00070 //   GetProductCheckerOutputModule temp(rhs);
00071 //   swap(rhs);
00072 //
00073 //   return *this;
00074 // }
00075 
00076 //
00077 // member functions
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 const& tid((*it)->branchDescription().typeID());
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             /*This doesn't appear to be an error, it just means the Product isn't available, which can be legitimate
00101             if(!bh.product()) {
00102                throw cms::Exception("GetByLabelFailure") << "While processing " << id << " getByLabel request for " << (*it)->productDescription().moduleLabel()
00103                   << " '" << (*it)->productDescription().productInstanceName() << "' " << (*it)->productDescription().processName() << " failed\n.";
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 // const member functions
00131 //
00132 
00133 //
00134 // static member functions
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);