CMS 3D CMS Logo

Functions | Variables
useReflexToDescribeForGenObject Namespace Reference

Functions

def genObjectDef (mylist, tuple, alias, label, type, etaPhiFound)
 
def genObjNameDef (line)
 
def getObjectList (objectName, base, verbose=False, memberData=False)
 

Variables

 action
 
 alphaRE
 
 args
 
 colonRE
 
 default
 
 defsDict
 
 defTemplate
 
 dest
 
 dotRE
 
 etaPhiFound
 
 genDef
 
 goName
 
 help
 
 mylist
 
 nonAlphaRE
 
 objectName
 
 options
 
 outputFile
 
 parser
 
 root2GOtypeDict
 
 startString
 
 targetFile
 
 tupleDef
 
 type
 
 vetoedTypes
 

Function Documentation

def useReflexToDescribeForGenObject.genObjectDef (   mylist,
  tuple,
  alias,
  label,
  type,
  etaPhiFound 
)
Does something, but I can't remembrer what... 

Definition at line 159 of file useReflexToDescribeForGenObject.py.

159 def genObjectDef (mylist, tuple, alias, label, type, etaPhiFound):
160  """Does something, but I can't remembrer what... """
161  print "tuple %s alias %s label %s type %s" % (tuple, alias, label, type)
162  # first get the name of the object
163  firstName = mylist[0][0]
164  match = alphaRE.match (firstName)
165  if not match:
166  raise RuntimeError("firstName doesn't parse correctly. (%s)" \
167  % firstName)
168  genName = match.group (1)
169  genDef = " ## GenObject %s Definition ##\n[%s]\n" % \
170  (genName, genName)
171  if options.index or not etaPhiFound:
172  # either we told it to always use index OR either eta or phi
173  # is missing.
174  genDef += "-equiv: index,0\n";
175  else:
176  genDef += "-equiv: eta,0.1 phi,0.1 index,100000\n";
177  tupleDef = '[%s:%s:%s label=%s type=%s]\n' % \
178  (genName, tuple, alias, label, type)
179 
180  for variable in mylist:
181  name, func = genObjNameDef (variable[0])
182  typeInfo = variable[1]
183  form = defsDict[ typeInfo ]
184  genDef += form % name + '\n'
185  tupleDef += "%-40s : %s\n" % (name, func)
186  return genDef, tupleDef
187 
188 
def genObjectDef(mylist, tuple, alias, label, type, etaPhiFound)
def useReflexToDescribeForGenObject.genObjNameDef (   line)
Returns GenObject name and ntuple definition function

Definition at line 150 of file useReflexToDescribeForGenObject.py.

150 def genObjNameDef (line):
151  """Returns GenObject name and ntuple definition function"""
152  words = dotRE.split (line)[1:]
153  func = ".".join (words)
154  name = "_".join (words)
155  name = nonAlphaRE.sub ('', name)
156  return name, func
157 
158 
def useReflexToDescribeForGenObject.getObjectList (   objectName,
  base,
  verbose = False,
  memberData = False 
)
Get a list of interesting things from this object

Definition at line 63 of file useReflexToDescribeForGenObject.py.

References str.

63 def getObjectList (objectName, base, verbose = False, memberData = False):
64  """Get a list of interesting things from this object"""
65  # The autoloader needs an object before it loads its dictionary.
66  # So let's give it one.
67  try:
68  rootObjConstructor = getattr (ROOT, objectName)
69  except AttributeError as missingAttr:
70  if str(missingAttr) in ['double', 'int']:
71  print "Do not need to describe doubles or ints"
72  sys.exit(0)
73  else:
74  raise
75 
76  obj = rootObjConstructor()
77  alreadySeenFunction = set()
78  vetoedFunction = set()
79  etaFound, phiFound = False, False
80  global vetoedTypes
81  retval = []
82  # Put the current class on the queue and start the while loop
83  classList = [ ROOT.TClass.GetClass(objectName) ]
84  if verbose: print classList
85  # Uses while because reflixList is really a stack
86  while classList:
87  alreadySeenFunction.update(vetoedFunction) # skip functions hidden by derived class
88  vetoedFunction.clear()
89  oneclass = classList.pop (0) # get first element
90  print "Looking at %s" % oneclass.GetName ()
91  bases = oneclass.GetListOfBases()
92  funcs = oneclass.GetListOfMethods()
93  if verbose:
94  print "baseSize", bases.GetSize()
95  print "FunctionMemberSize", funcs.GetSize()
96  for baseIndex in range( bases.GetSize() ) :
97  classList.append( bases.At(baseIndex).GetClassPointer() )
98  for index in range( funcs.GetSize() ):
99  funcMember = funcs.At (index)
100  # if we've already seen this, don't bother again
101  name = funcMember.GetName()
102  if verbose:
103  print "name", name
104  if name == 'eta':
105  etaFound = True
106  elif name == 'phi':
107  phiFound = True
108  if name in alreadySeenFunction:
109  continue
110  # make sure this is an allowed return type
111  returnType = funcMember.GetReturnTypeName()
112  goType = root2GOtypeDict.get (returnType, None)
113  if verbose:
114  print " type", returnType, goType
115  if not goType:
116  vetoedTypes.add (returnType)
117  if verbose:
118  print " skipped"
119  continue
120  elif verbose:
121  print " good"
122  # only bother printout out lines where it is a const function
123  # and has no input parameters.
124  if funcMember.Property() & ROOT.kIsConstMethod and not funcMember.GetNargs():
125  retval.append( ("%s.%s()" % (base, name), goType))
126  alreadySeenFunction.add( name )
127  if verbose:
128  print " added"
129  else :
130  vetoedFunction.add( name )
131  if verbose:
132  print " failed IsConst() and GetNargs()"
133  if not memberData:
134  continue
135  dataList = oneclass.GetListOfDataMembers()
136  for index in range( dataList.GetSize() ):
137  data = dataList.At( index );
138  name = data.GetName()
139  dataType = data.GetTypeName()
140  goType = root2GOtypeDict.get (dataType, None)
141  if not goType:
142  continue
143  if verbose:
144  print "name", name, "dataType", dataType, "goType", goType
145  retval.append ( ("%s.%s" % (base, name), goType) )
146  retval.sort()
147  return retval, etaFound and phiFound
148 
149 
#define str(s)
def getObjectList(objectName, base, verbose=False, memberData=False)

Variable Documentation

useReflexToDescribeForGenObject.action

Definition at line 197 of file useReflexToDescribeForGenObject.py.

useReflexToDescribeForGenObject.alphaRE

Definition at line 60 of file useReflexToDescribeForGenObject.py.

useReflexToDescribeForGenObject.args

Definition at line 219 of file useReflexToDescribeForGenObject.py.

useReflexToDescribeForGenObject.colonRE

Definition at line 57 of file useReflexToDescribeForGenObject.py.

useReflexToDescribeForGenObject.default

Definition at line 195 of file useReflexToDescribeForGenObject.py.

useReflexToDescribeForGenObject.defsDict

Definition at line 10 of file useReflexToDescribeForGenObject.py.

useReflexToDescribeForGenObject.defTemplate

Definition at line 42 of file useReflexToDescribeForGenObject.py.

useReflexToDescribeForGenObject.dest

Definition at line 194 of file useReflexToDescribeForGenObject.py.

useReflexToDescribeForGenObject.dotRE

Definition at line 58 of file useReflexToDescribeForGenObject.py.

useReflexToDescribeForGenObject.etaPhiFound

Definition at line 235 of file useReflexToDescribeForGenObject.py.

useReflexToDescribeForGenObject.genDef

Definition at line 241 of file useReflexToDescribeForGenObject.py.

useReflexToDescribeForGenObject.goName

Definition at line 227 of file useReflexToDescribeForGenObject.py.

useReflexToDescribeForGenObject.help

Definition at line 196 of file useReflexToDescribeForGenObject.py.

useReflexToDescribeForGenObject.mylist

Definition at line 235 of file useReflexToDescribeForGenObject.py.

useReflexToDescribeForGenObject.nonAlphaRE

Definition at line 59 of file useReflexToDescribeForGenObject.py.

useReflexToDescribeForGenObject.objectName

Definition at line 226 of file useReflexToDescribeForGenObject.py.

useReflexToDescribeForGenObject.options

Definition at line 219 of file useReflexToDescribeForGenObject.py.

useReflexToDescribeForGenObject.outputFile

Definition at line 228 of file useReflexToDescribeForGenObject.py.

useReflexToDescribeForGenObject.parser

Definition at line 191 of file useReflexToDescribeForGenObject.py.

useReflexToDescribeForGenObject.root2GOtypeDict

Definition at line 17 of file useReflexToDescribeForGenObject.py.

useReflexToDescribeForGenObject.startString

Definition at line 29 of file useReflexToDescribeForGenObject.py.

useReflexToDescribeForGenObject.targetFile

Definition at line 240 of file useReflexToDescribeForGenObject.py.

useReflexToDescribeForGenObject.tupleDef

Definition at line 241 of file useReflexToDescribeForGenObject.py.

useReflexToDescribeForGenObject.type

Definition at line 194 of file useReflexToDescribeForGenObject.py.

useReflexToDescribeForGenObject.vetoedTypes

Definition at line 61 of file useReflexToDescribeForGenObject.py.