File indexing completed on 2025-01-31 02:19:08
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014 #include <iostream>
0015 #include <memory>
0016
0017
0018 #include "DataFormats/FWLite/interface/EventBase.h"
0019 #include "DataFormats/Common/interface/BasicHandle.h"
0020 #include "DataFormats/Common/interface/FunctorHandleExceptionFactory.h"
0021 #include "DataFormats/Common/interface/WrapperBase.h"
0022 #include "DataFormats/Provenance/interface/ProductID.h"
0023 #include "FWCore/Utilities/interface/do_nothing_deleter.h"
0024 #include "FWCore/Utilities/interface/EDMException.h"
0025 #include "FWCore/Utilities/interface/TypeID.h"
0026
0027 static const edm::ProductID s_id;
0028 static edm::ProductDescription const s_branch = edm::ProductDescription(edm::ProductDescription());
0029 static const edm::Provenance s_prov(std::shared_ptr<edm::ProductDescription const>(&s_branch,
0030 edm::do_nothing_deleter()),
0031 s_id);
0032
0033 namespace fwlite {
0034 EventBase::EventBase() {}
0035
0036 EventBase::~EventBase() {}
0037
0038 edm::BasicHandle EventBase::getByLabelImpl(std::type_info const& iWrapperInfo,
0039 std::type_info const& ,
0040 const edm::InputTag& iTag) const {
0041 edm::WrapperBase const* prod = nullptr;
0042 void* prodPtr = ∏
0043 getByLabel(iWrapperInfo,
0044 iTag.label().c_str(),
0045 iTag.instance().empty() ? static_cast<char const*>(nullptr) : iTag.instance().c_str(),
0046 iTag.process().empty() ? static_cast<char const*>(nullptr) : iTag.process().c_str(),
0047 prodPtr);
0048 if (prod == nullptr || !prod->isPresent()) {
0049 edm::TypeID productType(iWrapperInfo);
0050
0051 edm::BasicHandle failed(edm::makeHandleExceptionFactory([=]() -> std::shared_ptr<cms::Exception> {
0052 std::shared_ptr<cms::Exception> whyFailed(std::make_shared<edm::Exception>(edm::errors::ProductNotFound));
0053 *whyFailed << "getByLabel: Found zero products matching all criteria\n"
0054 << "Looking for type: " << productType << "\n"
0055 << "Looking for module label: " << iTag.label() << "\n"
0056 << "Looking for productInstanceName: " << iTag.instance() << "\n"
0057 << (iTag.process().empty() ? "" : "Looking for process: ") << iTag.process() << "\n"
0058 << "The data is registered in the file but is not available for this event\n";
0059 return whyFailed;
0060 }));
0061 return failed;
0062 }
0063
0064 edm::BasicHandle value(prod, &s_prov);
0065 return value;
0066 }
0067
0068 edm::BasicHandle EventBase::getByTokenImpl(std::type_info const& iProdInfo, edm::EDGetToken iToken) const {
0069 edm::WrapperBase const* prod = nullptr;
0070 getByTokenImp(iToken, prod);
0071 if (prod == nullptr || !prod->isPresent()) {
0072 edm::TypeID productType(iProdInfo);
0073
0074 edm::BasicHandle failed(edm::makeHandleExceptionFactory([=]() -> std::shared_ptr<cms::Exception> {
0075 std::shared_ptr<cms::Exception> whyFailed(std::make_shared<edm::Exception>(edm::errors::ProductNotFound));
0076 *whyFailed << "getByToken: Found zero products matching all criteria\n"
0077 << "Looking for type: " << productType << "\n"
0078 << "The data is registered in the file but is not available for this event\n";
0079 return whyFailed;
0080 }));
0081 return failed;
0082 }
0083
0084 edm::BasicHandle value(prod, &s_prov);
0085 return value;
0086 }
0087
0088 edm::BasicHandle EventBase::getImpl(std::type_info const& iProductInfo, const edm::ProductID& pid) const {
0089 edm::WrapperBase const* prod = getByProductID(pid);
0090 if (prod == nullptr || !prod->isPresent()) {
0091 edm::TypeID productType(iProductInfo);
0092
0093 edm::BasicHandle failed(edm::makeHandleExceptionFactory([=]() -> std::shared_ptr<cms::Exception> {
0094 std::shared_ptr<cms::Exception> whyFailed(std::make_shared<edm::Exception>(edm::errors::ProductNotFound));
0095 *whyFailed << "EventBase::getImpl: getByProductID found no product with the\n"
0096 << "requested ProductID " << pid << "\n"
0097 << "Expected type: " << productType << "\n";
0098 return whyFailed;
0099 }));
0100 return failed;
0101 }
0102 edm::BasicHandle value(prod, &s_prov);
0103 return value;
0104 }
0105 }