Line Code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67
// -*- C++ -*-
//
// Package:     DataFormats/FWLite
// Class  :     RunBase
//
/**\class RunBase RunBase.h DataFormats/FWLite/interface/RunBase.h

   Description: <one line class summary>

   Usage:
   <usage>

*/
//
// Original Author:  Eric Vaandering
//         Created:  Wed Jan  13 15:01:20 EDT 2007
//

// system include files
#include <iostream>

// user include files
#include "DataFormats/FWLite/interface/RunBase.h"
#include "DataFormats/Common/interface/FunctorHandleExceptionFactory.h"
#include "FWCore/Utilities/interface/do_nothing_deleter.h"
#include "FWCore/Utilities/interface/EDMException.h"
#include "FWCore/Utilities/interface/TypeID.h"

static const edm::ProductID s_id;
static edm::ProductDescription const s_branch = edm::ProductDescription(edm::ProductDescription());
static const edm::Provenance s_prov(std::shared_ptr<edm::ProductDescription const>(&s_branch,
                                                                                   edm::do_nothing_deleter()),
                                    s_id);

namespace fwlite {
  RunBase::RunBase() {}

  RunBase::~RunBase() {}

  edm::BasicHandle RunBase::getByLabelImpl(std::type_info const& iWrapperInfo,
                                           std::type_info const& /*iProductInfo*/,
                                           const edm::InputTag& iTag) const {
    edm::WrapperBase* prod = nullptr;
    void* prodPtr = &prod;
    getByLabel(iWrapperInfo,
               iTag.label().c_str(),
               iTag.instance().empty() ? static_cast<char const*>(nullptr) : iTag.instance().c_str(),
               iTag.process().empty() ? static_cast<char const*>(nullptr) : iTag.process().c_str(),
               prodPtr);
    if (prod == nullptr || !prod->isPresent()) {
      edm::TypeID productType(iWrapperInfo);

      edm::BasicHandle failed(edm::makeHandleExceptionFactory([=]() -> std::shared_ptr<cms::Exception> {
        std::shared_ptr<cms::Exception> whyFailed(std::make_shared<edm::Exception>(edm::errors::ProductNotFound));
        *whyFailed << "getByLabel: Found zero products matching all criteria\n"
                   << "Looking for type: " << productType << "\n"
                   << "Looking for module label: " << iTag.label() << "\n"
                   << "Looking for productInstanceName: " << iTag.instance() << "\n"
                   << (iTag.process().empty() ? "" : "Looking for process: ") << iTag.process() << "\n";
        return whyFailed;
      }));
      return failed;
    }
    edm::BasicHandle value(prod, &s_prov);
    return value;
  }
}  // namespace fwlite