CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
FWGenericHandle.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: Framework
4 // Class : FWGenericHandle
5 //
6 // Implementation:
7 // <Notes on implementation>
8 //
9 // Original Author: Chris Jones
10 // Created: Thu Mar 30 15:48:37 EST 2006
11 //
12 
13 // system include files
14 #include <iostream>
15 
16 // user include files
18 
19 namespace edm {
20 void convert_handle(BasicHandle const& orig,
22 {
23  if(orig.failedToGet()) {
24  result.setWhyFailed(orig.whyFailed());
25  return;
26  }
27 
28  WrapperHolder originalWrap = orig.wrapperHolder();
29  if(!originalWrap.isValid()) {
31  << "edm::BasicHandle has null pointer to Wrapper";
32  }
33 
34  edm::ObjectWithDict wrap(edm::TypeWithDict(originalWrap.wrappedTypeInfo()), const_cast<void*>(originalWrap.wrapper()));
35  assert(bool(wrap));
36 
37  edm::ObjectWithDict product(wrap.get("obj"));
38 
39  if(!product){
40  throw edm::Exception(edm::errors::LogicError)<<"FWGenericObject could not find 'obj' member";
41  }
42  if(product.typeOf()!=result.type()){
43  std::cerr << "FWGenericObject asked for "<<result.type().name()
44  <<" but was given a " << product.typeOf().name();
45  throw edm::Exception(edm::errors::LogicError)<<"FWGenericObject asked for "<<result.type().name()
46  <<" but was given a "<<product.typeOf().name();
47  }
48 
49  Handle<FWGenericObject> h(product, orig.provenance(), orig.id());
50  h.swap(result);
51 }
52 
54 template<>
55 bool
56 edm::EventBase::getByLabel<FWGenericObject>(edm::InputTag const& tag,
58 {
59  std::string dataTypeName = result.type().name();
60  if (dataTypeName[dataTypeName.size() -1] == '>')
61  dataTypeName += " ";
62  std::string wrapperName = "edm::Wrapper<" + dataTypeName + ">";
63 
64  edm::TypeWithDict wrapperType(edm::TypeWithDict::byName(wrapperName));
65 
66  BasicHandle bh = this->getByLabelImpl(wrapperType.typeInfo(),
67  result.type().typeInfo(),
68  tag);
69  convert_handle(bh, result); // throws on conversion error
70  if(bh.failedToGet())
71  return false;
72  return true;
73 }
74 
75 }
ProductID id() const
Definition: BasicHandle.h:122
void wrap(unsigned me1aValidp, unsigned me1aQp, unsigned me1aEtap, unsigned me1aPhip, unsigned me1aCSCidp, unsigned me1bValidp, unsigned me1bQp, unsigned me1bEtap, unsigned me1bPhip, unsigned me1bCSCidp, unsigned me1cValidp, unsigned me1cQp, unsigned me1cEtap, unsigned me1cPhip, unsigned me1cCSCidp, unsigned me1dValidp, unsigned me1dQp, unsigned me1dEtap, unsigned me1dPhip, unsigned me1dCSCidp, unsigned me1eValidp, unsigned me1eQp, unsigned me1eEtap, unsigned me1ePhip, unsigned me1eCSCidp, unsigned me1fValidp, unsigned me1fQp, unsigned me1fEtap, unsigned me1fPhip, unsigned me1fCSCidp, unsigned me2aValidp, unsigned me2aQp, unsigned me2aEtap, unsigned me2aPhip, unsigned me2bValidp, unsigned me2bQp, unsigned me2bEtap, unsigned me2bPhip, unsigned me2cValidp, unsigned me2cQp, unsigned me2cEtap, unsigned me2cPhip, unsigned me3aValidp, unsigned me3aQp, unsigned me3aEtap, unsigned me3aPhip, unsigned me3bValidp, unsigned me3bQp, unsigned me3bEtap, unsigned me3bPhip, unsigned me3cValidp, unsigned me3cQp, unsigned me3cEtap, unsigned me3cPhip, unsigned me4aValidp, unsigned me4aQp, unsigned me4aEtap, unsigned me4aPhip, unsigned me4bValidp, unsigned me4bQp, unsigned me4bEtap, unsigned me4bPhip, unsigned me4cValidp, unsigned me4cQp, unsigned me4cEtap, unsigned me4cPhip, unsigned mb1aValidp, unsigned mb1aQp, unsigned mb1aPhip, unsigned mb1bValidp, unsigned mb1bQp, unsigned mb1bPhip, unsigned mb1cValidp, unsigned mb1cQp, unsigned mb1cPhip, unsigned mb1dValidp, unsigned mb1dQp, unsigned mb1dPhip, unsigned &ptHp, unsigned &signHp, unsigned &modeMemHp, unsigned &etaPTHp, unsigned &FRHp, unsigned &phiHp, unsigned &ptMp, unsigned &signMp, unsigned &modeMemMp, unsigned &etaPTMp, unsigned &FRMp, unsigned &phiMp, unsigned &ptLp, unsigned &signLp, unsigned &modeMemLp, unsigned &etaPTLp, unsigned &FRLp, unsigned &phiLp, unsigned &me1idH, unsigned &me2idH, unsigned &me3idH, unsigned &me4idH, unsigned &mb1idH, unsigned &mb2idH, unsigned &me1idM, unsigned &me2idM, unsigned &me3idM, unsigned &me4idM, unsigned &mb1idM, unsigned &mb2idM, unsigned &me1idL, unsigned &me2idL, unsigned &me3idL, unsigned &me4idL, unsigned &mb1idL, unsigned &mb2idL, unsigned mneta12p, unsigned mneta13p, unsigned mneta23p, unsigned mneta24p, unsigned mneta34p, unsigned mneta12ovp, unsigned mneta12dtp, unsigned mneta14p, unsigned mxeta12p, unsigned mxeta13p, unsigned mxeta23p, unsigned mxeta24p, unsigned mxeta34p, unsigned mxeta12ovp, unsigned mxeta12dtp, unsigned mxeta14p, unsigned etawn12p, unsigned etawn13p, unsigned etawn23p, unsigned etawn24p, unsigned etawn34p, unsigned etawn12ovp, unsigned etawn14p, unsigned mindphip, unsigned mindetap, unsigned mindeta_halo12p, unsigned maxdeta_halo12p, unsigned maxdphi_halo12p, unsigned mindeta_halo13p, unsigned maxdeta_halo13p, unsigned maxdphi_halo13p, unsigned mindeta_halo112p, unsigned maxdeta_halo112p, unsigned maxdphi_halo112p, unsigned mindeta_halo113p, unsigned maxdeta_halo113p, unsigned maxdphi_halo113p, unsigned mindphi_halop, unsigned mindeta_halop, unsigned straightp, unsigned curvedp, unsigned mb1a_phi_offp, unsigned mb1b_phi_offp, unsigned controlp)
static TypeWithDict byName(std::string const &className)
std::shared_ptr< cms::Exception > whyFailed() const
Definition: BasicHandle.h:126
void setWhyFailed(std::shared_ptr< cms::Exception > const &iWhyFailed)
edm::TypeWithDict const & type() const
Provenance const * provenance() const
Definition: BasicHandle.h:118
std::string name() const
tuple result
Definition: query.py:137
std::type_info const & typeInfo() const
void convert_handle(BasicHandle &&bh, Handle< T > &result)
Definition: ConvertHandle.h:20
bool failedToGet() const
Definition: BasicHandle.h:102
The Signals That Services Can Subscribe To This is based on ActivityRegistry h
Helper function to determine trigger accepts.
Definition: Activities.doc:4
std::type_info const & wrappedTypeInfo() const
Definition: WrapperHolder.h:72
bool isValid() const
Definition: WrapperHolder.h:27
void const * wrapper() const
Definition: WrapperHolder.h:76
WrapperHolder wrapperHolder() const
Definition: BasicHandle.h:114
ObjectWithDict get(std::string const &memberName) const