Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 12:53:26

0001 // -*- C++ -*-
0002 //
0003 // Package:     DataFormats/FWLite
0004 // Class  :     RunBase
0005 //
0006 /**\class RunBase RunBase.h DataFormats/FWLite/interface/RunBase.h
0007 
0008    Description: <one line class summary>
0009 
0010    Usage:
0011    <usage>
0012 
0013 */
0014 //
0015 // Original Author:  Eric Vaandering
0016 //         Created:  Wed Jan  13 15:01:20 EDT 2007
0017 //
0018 
0019 // system include files
0020 #include <iostream>
0021 
0022 // user include files
0023 #include "DataFormats/FWLite/interface/RunBase.h"
0024 #include "DataFormats/Common/interface/FunctorHandleExceptionFactory.h"
0025 #include "FWCore/Utilities/interface/do_nothing_deleter.h"
0026 #include "FWCore/Utilities/interface/EDMException.h"
0027 #include "FWCore/Utilities/interface/TypeID.h"
0028 
0029 static const edm::ProductID s_id;
0030 static edm::BranchDescription const s_branch = edm::BranchDescription(edm::BranchDescription());
0031 static const edm::Provenance s_prov(std::shared_ptr<edm::BranchDescription const>(&s_branch, edm::do_nothing_deleter()),
0032                                     s_id);
0033 
0034 namespace fwlite {
0035   RunBase::RunBase() {}
0036 
0037   RunBase::~RunBase() {}
0038 
0039   edm::BasicHandle RunBase::getByLabelImpl(std::type_info const& iWrapperInfo,
0040                                            std::type_info const& /*iProductInfo*/,
0041                                            const edm::InputTag& iTag) const {
0042     edm::WrapperBase* prod = nullptr;
0043     void* prodPtr = &prod;
0044     getByLabel(iWrapperInfo,
0045                iTag.label().c_str(),
0046                iTag.instance().empty() ? static_cast<char const*>(nullptr) : iTag.instance().c_str(),
0047                iTag.process().empty() ? static_cast<char const*>(nullptr) : iTag.process().c_str(),
0048                prodPtr);
0049     if (prod == nullptr || !prod->isPresent()) {
0050       edm::TypeID productType(iWrapperInfo);
0051 
0052       edm::BasicHandle failed(edm::makeHandleExceptionFactory([=]() -> std::shared_ptr<cms::Exception> {
0053         std::shared_ptr<cms::Exception> whyFailed(std::make_shared<edm::Exception>(edm::errors::ProductNotFound));
0054         *whyFailed << "getByLabel: Found zero products matching all criteria\n"
0055                    << "Looking for type: " << productType << "\n"
0056                    << "Looking for module label: " << iTag.label() << "\n"
0057                    << "Looking for productInstanceName: " << iTag.instance() << "\n"
0058                    << (iTag.process().empty() ? "" : "Looking for process: ") << iTag.process() << "\n";
0059         return whyFailed;
0060       }));
0061       return failed;
0062     }
0063     edm::BasicHandle value(prod, &s_prov);
0064     return value;
0065   }
0066 }  // namespace fwlite