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

Constructor & Destructor Documentation

◆ __init__()

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

Definition at line 55 of file __init__.py.

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

Member Function Documentation

◆ __str__()

def python.Handle.__str__ (   self)

Definition at line 91 of file __init__.py.

References PGeometricDet::Item._type, python.Handle._type, and MELaserPrim._type.

Referenced by edmStreamStallGrapher.Point.__repr__(), BeautifulSoup.Tag.__repr__(), BeautifulSoup.Tag.__unicode__(), and BeautifulSoup.Tag.prettify().

91  def __str__ (self):
92  return "%s" % (self._type)
93 
94 

◆ _addressOf()

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

Definition at line 114 of file __init__.py.

References python.Handle._wrapper.

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

◆ _resetWrapper()

def python.Handle._resetWrapper (   self)
private

Private member functions ##.

(Internal) reset the edm wrapper

Definition at line 97 of file __init__.py.

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

◆ _setStatus()

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

Definition at line 119 of file __init__.py.

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

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

◆ _typeInfoGetter()

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

Definition at line 109 of file __init__.py.

References python.Handle._typeInfo.

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

◆ isValid()

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

Definition at line 78 of file __init__.py.

References python.Handle._exception.

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

78  def isValid (self):
79  """Returns true if getByLabel call was successful and data is
80  present in handle."""
81  return not self._exception
82 
83 
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 84 of file __init__.py.

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

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

Member Data Documentation

◆ _exception

python.Handle._exception
private

◆ _nodel

python.Handle._nodel
private

Definition at line 60 of file __init__.py.

◆ _type

python.Handle._type
private

Definition at line 66 of file __init__.py.

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

◆ _typeInfo

python.Handle._typeInfo
private

Definition at line 100 of file __init__.py.

Referenced by python.Handle._typeInfoGetter().

◆ _wrapper

python.Handle._wrapper
private