CMS 3D CMS Logo

List of all members | Public Member Functions | Private Member Functions | Private Attributes
python.Handle Class Reference

## Handle

More...

Public Member Functions

def __init__ (self, typeString, kwargs)
 
def __str__ (self)
 
def isValid (self)
 
def product (self)
 

Private Member Functions

def _addressOf (self)
 
def _resetWrapper (self)
 Private member functions ##. More...
 
def _setStatus (self, getByLabelSuccess, labelString)
 
def _typeInfoGetter (self)
 

Private Attributes

 _exception
 
 _nodel
 
 _type
 
 _typeInfo
 
 _wrapper
 

Detailed Description

## Handle

Python interface to FWLite Handle class

Definition at line 49 of file __init__.py.

Constructor & Destructor Documentation

def python.Handle.__init__ (   self,
  typeString,
  kwargs 
)
Initialize python handle wrapper 

Definition at line 54 of file __init__.py.

54  **kwargs):
55  """Initialize python handle wrapper """
56  # turn off warnings
57  oldWarningLevel = ROOT.gErrorIgnoreLevel
58  ROOT.gErrorIgnoreLevel = ROOT.kError
59  self._nodel = False
60  if kwargs.get ('noDelete'):
61  print "Not deleting wrapper"
62  del kwargs['noDelete']
63  else:
64  self._nodel = True
65  self._type = typeString
66  self._resetWrapper()
67  self._exception = RuntimeError ("getByLabel not called for '%s'", self)
68  # restore warning state
69  ROOT.gErrorIgnoreLevel = oldWarningLevel
70  # Since we deleted the options as we used them, that means
71  # that kwargs should be empty. If it's not, that means that
72  # somebody passed in an argument that we're not using and we
73  # should complain.
74  if len (kwargs):
75  raise RuntimeError("Unknown arguments %s" % kwargs)
76 
def _resetWrapper(self)
Private member functions ##.
Definition: __init__.py:96

Member Function Documentation

def python.Handle.__str__ (   self)
def python.Handle._addressOf (   self)
private
(Internal) Return address of edm wrapper

Definition at line 113 of file __init__.py.

References python.Handle._wrapper.

113  def _addressOf (self):
114  """(Internal) Return address of edm wrapper"""
115  return ROOT.AddressOf (self._wrapper)
116 
117 
def _addressOf(self)
Definition: __init__.py:113
def python.Handle._resetWrapper (   self)
private

Private member functions ##.

(Internal) reset the edm wrapper

Definition at line 96 of file __init__.py.

96  def _resetWrapper (self):
97  """(Internal) reset the edm wrapper"""
98  self._wrapper = ROOT.edm.Wrapper (self._type)()
99  self._typeInfo = self._wrapper.typeInfo()
100  ROOT.SetOwnership (self._wrapper, False)
101  # O.k. This is a little weird. We want a pointer to an EDM
102  # wrapper, but we don't want the memory it is pointing to.
103  # So, we've created it and grabbed the type info. Since we
104  # don't want a memory leak, we destroy it.
105  if not self._nodel :
106  ROOT.TClass.GetClass("edm::Wrapper<"+self._type+">").Destructor( self._wrapper )
107 
def _resetWrapper(self)
Private member functions ##.
Definition: __init__.py:96
def python.Handle._setStatus (   self,
  getByLabelSuccess,
  labelString 
)
private
(Internal) To be called by Events.getByLabel

Definition at line 118 of file __init__.py.

References python.Handle._exception.

118  def _setStatus (self, getByLabelSuccess, labelString):
119  """(Internal) To be called by Events.getByLabel"""
120  if not getByLabelSuccess:
121  self._exception = RuntimeError ("getByLabel (%s, %s) failed" \
122  % (self, labelString))
123  return
124  if not self._wrapper.isPresent():
125  self._exception = RuntimeError ("getByLabel (%s, %s) not present this event" \
126  % (self, labelString))
127  return
128  # if we're still here, then everything is happy. Clear the exception
129  self._exception = None
130 
131 
def _setStatus(self, getByLabelSuccess, labelString)
Definition: __init__.py:118
def python.Handle._typeInfoGetter (   self)
private
(Internal) Return the type info

Definition at line 108 of file __init__.py.

References python.Handle._typeInfo.

108  def _typeInfoGetter (self):
109  """(Internal) Return the type info"""
110  return self._typeInfo
111 
112 
def _typeInfoGetter(self)
Definition: __init__.py:108
def python.Handle.isValid (   self)
Returns true if getByLabel call was successful and data is
present in handle.

Definition at line 77 of file __init__.py.

References python.Handle._exception.

Referenced by ntupleDataFormat._Object._checkIsValid(), and core.AutoHandle.AutoHandle.ReallyLoad().

77  def isValid (self):
78  """Returns true if getByLabel call was successful and data is
79  present in handle."""
80  return not self._exception
81 
82 
def isValid(self)
Definition: __init__.py:77
def python.Handle.product (   self)
Returns product stored in handle.

Definition at line 83 of file __init__.py.

References python.Handle._exception.

83  def product (self):
84  """Returns product stored in handle."""
85  if self._exception:
86  raise self._exception
87  return self._wrapper.product()
88 
89 
def product(self)
Definition: __init__.py:83

Member Data Documentation

python.Handle._exception
private
python.Handle._nodel
private

Definition at line 59 of file __init__.py.

python.Handle._type
private
python.Handle._typeInfo
private

Definition at line 99 of file __init__.py.

Referenced by python.Handle._typeInfoGetter().

python.Handle._wrapper
private

Definition at line 98 of file __init__.py.

Referenced by python.Handle._addressOf().