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 48 of file __init__.py.

Constructor & Destructor Documentation

◆ __init__()

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

Definition at line 53 of file __init__.py.

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

Member Function Documentation

◆ __str__()

def python.Handle.__str__ (   self)

◆ _addressOf()

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

Definition at line 112 of file __init__.py.

References python.Handle._wrapper.

112  def _addressOf (self):
113  """(Internal) Return address of edm wrapper"""
114  return ROOT.AddressOf (self._wrapper)
115 
116 

◆ _resetWrapper()

def python.Handle._resetWrapper (   self)
private

Private member functions ##.

(Internal) reset the edm wrapper

Definition at line 95 of file __init__.py.

95  def _resetWrapper (self):
96  """(Internal) reset the edm wrapper"""
97  self._wrapper = ROOT.edm.Wrapper (self._type)()
98  self._typeInfo = self._wrapper.typeInfo()
99  ROOT.SetOwnership (self._wrapper, False)
100  # O.k. This is a little weird. We want a pointer to an EDM
101  # wrapper, but we don't want the memory it is pointing to.
102  # So, we've created it and grabbed the type info. Since we
103  # don't want a memory leak, we destroy it.
104  if not self._nodel :
105  ROOT.TClass.GetClass("edm::Wrapper<"+self._type+">").Destructor( self._wrapper )
106 

◆ _setStatus()

def python.Handle._setStatus (   self,
  getByLabelSuccess,
  labelString 
)
private
(Internal) To be called by Events.getByLabel

Definition at line 117 of file __init__.py.

References python.Handle._exception, and python.Handle._wrapper.

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

◆ _typeInfoGetter()

def python.Handle._typeInfoGetter (   self)
private
(Internal) Return the type info

Definition at line 107 of file __init__.py.

References python.Handle._typeInfo.

107  def _typeInfoGetter (self):
108  """(Internal) Return the type info"""
109  return self._typeInfo
110 
111 

◆ isValid()

def python.Handle.isValid (   self)
Returns true if getByLabel call was successful and data is
present in handle.

Definition at line 76 of file __init__.py.

References python.Handle._exception.

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

76  def isValid (self):
77  """Returns true if getByLabel call was successful and data is
78  present in handle."""
79  return not self._exception
80 
81 
const bool isValid(const Frame &aFrame, const FrameQuality &aQuality, const uint16_t aExpectedPos)

◆ product()

def python.Handle.product (   self)
Returns product stored in handle.

Definition at line 82 of file __init__.py.

References python.Handle._exception, and python.Handle._wrapper.

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

Member Data Documentation

◆ _exception

python.Handle._exception
private

◆ _nodel

python.Handle._nodel
private

Definition at line 58 of file __init__.py.

◆ _type

python.Handle._type
private

Definition at line 64 of file __init__.py.

Referenced by python.Handle.__str__(), and SequenceTypes.ExpandVisitor.result().

◆ _typeInfo

python.Handle._typeInfo
private

Definition at line 98 of file __init__.py.

Referenced by python.Handle._typeInfoGetter().

◆ _wrapper

python.Handle._wrapper
private