CMS 3D CMS Logo

EventBase.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: FWLite
4 // Class : EventBase
5 //
6 // Implementation:
7 // <Notes on implementation>
8 //
9 // Original Author: Charles Plager
10 // Created:
11 //
12 
13 // system include files
14 #include <iostream>
15 #include <memory>
16 
17 // user include files
26 
27 static const edm::ProductID s_id;
29 static const edm::Provenance s_prov(std::shared_ptr<edm::BranchDescription const>(&s_branch, edm::do_nothing_deleter()), s_id);
30 
31 namespace fwlite
32 {
34  {
35  }
36 
38  {
39  }
40 
42  EventBase::getByLabelImpl(std::type_info const& iWrapperInfo, std::type_info const& /*iProductInfo*/, const edm::InputTag& iTag) const {
43  edm::WrapperBase const* prod = nullptr;
44  void* prodPtr = &prod;
45  getByLabel(iWrapperInfo,
46  iTag.label().c_str(),
47  iTag.instance().empty() ? static_cast<char const*>(nullptr) : iTag.instance().c_str(),
48  iTag.process().empty() ? static_cast<char const*> (nullptr) : iTag.process().c_str(),
49  prodPtr);
50  if(prod == nullptr || !prod->isPresent()) {
51  edm::TypeID productType(iWrapperInfo);
52 
53  edm::BasicHandle failed(edm::makeHandleExceptionFactory([=]()->std::shared_ptr<cms::Exception>{
54  std::shared_ptr<cms::Exception> whyFailed(std::make_shared<edm::Exception>(edm::errors::ProductNotFound));
55  *whyFailed
56  << "getByLabel: Found zero products matching all criteria\n"
57  << "Looking for type: " << productType << "\n"
58  << "Looking for module label: " << iTag.label() << "\n"
59  << "Looking for productInstanceName: " << iTag.instance() << "\n"
60  << (iTag.process().empty() ? "" : "Looking for process: ") << iTag.process() << "\n"
61  << "The data is registered in the file but is not available for this event\n";
62  return whyFailed;
63  }));
64  return failed;
65  }
66 
68  return value;
69  }
70 
72  EventBase::getImpl(std::type_info const& iProductInfo, const edm::ProductID& pid) const {
73  edm::WrapperBase const* prod = getByProductID(pid);
74  if(prod == nullptr || !prod->isPresent()) {
75  edm::TypeID productType(iProductInfo);
76 
77  edm::BasicHandle failed(edm::makeHandleExceptionFactory([=]()->std::shared_ptr<cms::Exception>{
78  std::shared_ptr<cms::Exception> whyFailed(std::make_shared<edm::Exception>(edm::errors::ProductNotFound));
79  *whyFailed
80  << "EventBase::getImpl: getByProductID found no product with the\n"
81  << "requested ProductID " << pid << "\n"
82  << "Expected type: " << productType << "\n";
83  return whyFailed;
84  }));
85  return failed;
86  }
88  return value;
89  }
90 }
bool isPresent() const
Definition: WrapperBase.h:30
virtual bool getByLabel(std::type_info const &, char const *, char const *, char const *, void *) const =0
edm::BasicHandle getByLabelImpl(std::type_info const &, std::type_info const &, const edm::InputTag &) const override
Definition: EventBase.cc:42
static const edm::ProductID s_id
Definition: EventBase.cc:27
std::shared_ptr< HandleExceptionFactory > makeHandleExceptionFactory(T &&iFunctor)
virtual edm::WrapperBase const * getByProductID(edm::ProductID const &) const =0
static edm::BranchDescription const s_branch
Definition: EventBase.cc:28
static const edm::Provenance s_prov(std::shared_ptr< edm::BranchDescription const >(&s_branch, edm::do_nothing_deleter()), s_id)
~EventBase() override
Definition: EventBase.cc:37
std::string const & label() const
Definition: InputTag.h:36
std::string const & process() const
Definition: InputTag.h:40
edm::BasicHandle getImpl(std::type_info const &, edm::ProductID const &) const override
std::string const & instance() const
Definition: InputTag.h:37