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

◆ genObjectDef()

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

Definition at line 161 of file useReflexToDescribeForGenObject.py.

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

References print().

◆ genObjNameDef()

def useReflexToDescribeForGenObject.genObjNameDef (   line)
Returns GenObject name and ntuple definition function

Definition at line 152 of file useReflexToDescribeForGenObject.py.

152 def genObjNameDef (line):
153  """Returns GenObject name and ntuple definition function"""
154  words = dotRE.split (line)[1:]
155  func = ".".join (words)
156  name = "_".join (words)
157  name = nonAlphaRE.sub ('', name)
158  return name, func
159 
160 

◆ getObjectList()

def useReflexToDescribeForGenObject.getObjectList (   objectName,
  base,
  verbose = False,
  memberData = False 
)
Get a list of interesting things from this object

Definition at line 65 of file useReflexToDescribeForGenObject.py.

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

References print(), FastTimerService_cff.range, and str.

Variable Documentation

◆ action

useReflexToDescribeForGenObject.action

Definition at line 199 of file useReflexToDescribeForGenObject.py.

◆ alphaRE

useReflexToDescribeForGenObject.alphaRE

Definition at line 62 of file useReflexToDescribeForGenObject.py.

◆ args

useReflexToDescribeForGenObject.args

Definition at line 221 of file useReflexToDescribeForGenObject.py.

◆ colonRE

useReflexToDescribeForGenObject.colonRE

Definition at line 59 of file useReflexToDescribeForGenObject.py.

◆ default

useReflexToDescribeForGenObject.default

Definition at line 197 of file useReflexToDescribeForGenObject.py.

◆ defsDict

useReflexToDescribeForGenObject.defsDict

Definition at line 12 of file useReflexToDescribeForGenObject.py.

◆ defTemplate

useReflexToDescribeForGenObject.defTemplate

Definition at line 44 of file useReflexToDescribeForGenObject.py.

◆ dest

useReflexToDescribeForGenObject.dest

Definition at line 196 of file useReflexToDescribeForGenObject.py.

◆ dotRE

useReflexToDescribeForGenObject.dotRE

Definition at line 60 of file useReflexToDescribeForGenObject.py.

◆ etaPhiFound

useReflexToDescribeForGenObject.etaPhiFound

Definition at line 237 of file useReflexToDescribeForGenObject.py.

◆ genDef

useReflexToDescribeForGenObject.genDef

Definition at line 243 of file useReflexToDescribeForGenObject.py.

◆ goName

useReflexToDescribeForGenObject.goName

Definition at line 229 of file useReflexToDescribeForGenObject.py.

◆ help

useReflexToDescribeForGenObject.help

Definition at line 198 of file useReflexToDescribeForGenObject.py.

◆ mylist

useReflexToDescribeForGenObject.mylist

Definition at line 237 of file useReflexToDescribeForGenObject.py.

◆ nonAlphaRE

useReflexToDescribeForGenObject.nonAlphaRE

Definition at line 61 of file useReflexToDescribeForGenObject.py.

◆ objectName

useReflexToDescribeForGenObject.objectName

Definition at line 228 of file useReflexToDescribeForGenObject.py.

◆ options

useReflexToDescribeForGenObject.options

Definition at line 221 of file useReflexToDescribeForGenObject.py.

◆ outputFile

useReflexToDescribeForGenObject.outputFile

Definition at line 230 of file useReflexToDescribeForGenObject.py.

◆ parser

useReflexToDescribeForGenObject.parser

Definition at line 193 of file useReflexToDescribeForGenObject.py.

◆ root2GOtypeDict

useReflexToDescribeForGenObject.root2GOtypeDict

Definition at line 19 of file useReflexToDescribeForGenObject.py.

◆ startString

useReflexToDescribeForGenObject.startString

Definition at line 31 of file useReflexToDescribeForGenObject.py.

◆ targetFile

useReflexToDescribeForGenObject.targetFile

Definition at line 242 of file useReflexToDescribeForGenObject.py.

◆ tupleDef

useReflexToDescribeForGenObject.tupleDef

Definition at line 243 of file useReflexToDescribeForGenObject.py.

◆ type

useReflexToDescribeForGenObject.type

Definition at line 196 of file useReflexToDescribeForGenObject.py.

◆ vetoedTypes

useReflexToDescribeForGenObject.vetoedTypes

Definition at line 63 of file useReflexToDescribeForGenObject.py.

FastTimerService_cff.range
range
Definition: FastTimerService_cff.py:34
useReflexToDescribeForGenObject.getObjectList
def getObjectList(objectName, base, verbose=False, memberData=False)
Definition: useReflexToDescribeForGenObject.py:65
str
#define str(s)
Definition: TestProcessor.cc:52
useReflexToDescribeForGenObject.genObjectDef
def genObjectDef(mylist, tuple, alias, label, type, etaPhiFound)
Definition: useReflexToDescribeForGenObject.py:161
print
void print(TMatrixD &m, const char *label=nullptr, bool mathematicaFormat=false)
Definition: Utilities.cc:46
useReflexToDescribeForGenObject.genObjNameDef
def genObjNameDef(line)
Definition: useReflexToDescribeForGenObject.py:152