CMS 3D CMS Logo

/data/doxygen/doxygen-1.7.3/gen/CMSSW_4_2_8/src/DataFormats/FWLite/src/EventBase.cc

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 //
00003 // Package:     FWLite
00004 // Class  :     EventBase
00005 // 
00006 // Implementation:
00007 //     <Notes on implementation>
00008 //
00009 // Original Author:  Charles Plager
00010 //         Created:  
00011 //
00012 
00013 // system include files
00014 #include <iostream>
00015 
00016 // user include files
00017 #include "DataFormats/FWLite/interface/EventBase.h"
00018 #include "FWCore/Utilities/interface/EDMException.h"
00019 #include "FWCore/Utilities/interface/TypeID.h"
00020 
00021 namespace {
00022    //This is used by the shared_ptr required to be passed to BasicHandle to keep the shared_ptr from doing the delete
00023    struct null_deleter
00024    {
00025       void operator()(void *) const
00026       {
00027       }
00028    };
00029 }
00030 
00031 static const edm::ProductID s_id;
00032 static edm::ConstBranchDescription s_branch = edm::ConstBranchDescription( edm::BranchDescription() );
00033 static const edm::Provenance s_prov(boost::shared_ptr<edm::ConstBranchDescription>(&s_branch, null_deleter()) ,s_id);
00034 
00035 
00036 
00037 namespace fwlite
00038 {
00039    EventBase::EventBase()
00040    {
00041    }
00042 
00043    EventBase::~EventBase()
00044    {
00045    }
00046 
00047    edm::BasicHandle 
00048    EventBase::getByLabelImpl(const std::type_info& iWrapperInfo, const std::type_info& /*iProductInfo*/, const edm::InputTag& iTag) const 
00049    {
00050       edm::EDProduct* prod=0;
00051       void* prodPtr = &prod;
00052       getByLabel(iWrapperInfo, 
00053                  iTag.label().c_str(), 
00054                  iTag.instance().empty()?static_cast<const char*>(0):iTag.instance().c_str(),
00055                  iTag.process().empty()?static_cast<const char*> (0):iTag.process().c_str(),
00056                  prodPtr);
00057       if(0==prod) {
00058          edm::TypeID productType(iWrapperInfo);
00059          boost::shared_ptr<cms::Exception> whyFailed(new edm::Exception(edm::errors::ProductNotFound));
00060          *whyFailed
00061          << "getByLabel: Found zero products matching all criteria\n"
00062          << "Looking for type: " << productType << "\n"
00063          << "Looking for module label: " << iTag.label() << "\n"
00064          << "Looking for productInstanceName: " << iTag.instance() << "\n"
00065          << (iTag.process().empty() ? "" : "Looking for process: ") << iTag.process() << "\n";
00066          
00067          edm::BasicHandle failed(whyFailed);
00068          return failed;
00069       }
00070       if(!prod->isPresent()) {
00071          edm::TypeID productType(iWrapperInfo);
00072          boost::shared_ptr<cms::Exception> whyFailed(new edm::Exception(edm::errors::ProductNotFound));
00073          *whyFailed
00074          << "getByLabel: Found zero products matching all criteria\n"
00075          << "Looking for type: " << productType << "\n"
00076          << "Looking for module label: " << iTag.label() << "\n"
00077          << "Looking for productInstanceName: " << iTag.instance() << "\n"
00078          << (iTag.process().empty() ? "" : "Looking for process: ") << iTag.process() << "\n"
00079          << "The data is registered in the file but is not available for this event\n";
00080          edm::BasicHandle failed(whyFailed);
00081          return failed;
00082       }
00083       edm::BasicHandle value(boost::shared_ptr<edm::EDProduct>(prod,null_deleter()),&s_prov);
00084       return value;
00085    }
00086 }