CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
Functions | Variables
useReflexToDescribeForGenObject Namespace Reference

Functions

def genObjectDef
 
def genObjNameDef
 
def getObjectList
 

Variables

string action = 'store_true'
 
tuple alphaRE = re.compile(r'(\w+)')
 
tuple colonRE = re.compile(r':')
 
string default = ''
 
dictionary defsDict
 
string defTemplate
 
tuple dotRE = re.compile(r'\.')
 
tuple goName = options.goNameorcolonRE.sub('', objectName)
 
string help = 'GenObject name'
 
tuple nonAlphaRE = re.compile(r'\W')
 
tuple objectName = GenObject.decodeNonAlphanumerics(args[0])
 
string outputFile = options.outputorgoName+'.txt'
 
 parser = optparse.OptionParser\
 
dictionary root2GOtypeDict
 
string startString
 
tuple targetFile = open(outputFile, 'w')
 
tuple vetoedTypes = set()
 

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.

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

Definition at line 150 of file useReflexToDescribeForGenObject.py.

151 def genObjNameDef (line):
152  """Returns GenObject name and ntuple definition function"""
153  words = dotRE.split (line)[1:]
154  func = ".".join (words)
155  name = "_".join (words)
156  name = nonAlphaRE.sub ('', name)
157  return name, func
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.

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

Variable Documentation

string useReflexToDescribeForGenObject.action = 'store_true'

Definition at line 209 of file useReflexToDescribeForGenObject.py.

tuple useReflexToDescribeForGenObject.alphaRE = re.compile(r'(\w+)')

Definition at line 60 of file useReflexToDescribeForGenObject.py.

tuple useReflexToDescribeForGenObject.colonRE = re.compile(r':')

Definition at line 57 of file useReflexToDescribeForGenObject.py.

string useReflexToDescribeForGenObject.default = ''

Definition at line 195 of file useReflexToDescribeForGenObject.py.

dictionary useReflexToDescribeForGenObject.defsDict
Initial value:
1 = {
2  'int' : '%-40s : form=%%%%8d type=int',
3  'float' : '%-40s : form=%%%%7.2f prec=',
4  'str' : '%-40s : form=%%%%20s type=string',
5  'long' : '%-40s : form=%%%%10d type=long',
6  }

Definition at line 10 of file useReflexToDescribeForGenObject.py.

string useReflexToDescribeForGenObject.defTemplate
Initial value:
1 = """
2 #####################
3 ## %(OBJS)s Definition ##
4 #####################
5 
6 # Nickname and Tree
7 [%(objs)s:FWLite]
8 
9 # 'reco'-tupe 'runevent' 'tofill' information
10 [runevent:%(objs)s:EventAuxiliary shortcut=eventAuxiliary()]
11 run: run()
12 event: event()
13 
14 """

Definition at line 42 of file useReflexToDescribeForGenObject.py.

tuple useReflexToDescribeForGenObject.dotRE = re.compile(r'\.')

Definition at line 58 of file useReflexToDescribeForGenObject.py.

tuple useReflexToDescribeForGenObject.goName = options.goNameorcolonRE.sub('', objectName)

Definition at line 227 of file useReflexToDescribeForGenObject.py.

string useReflexToDescribeForGenObject.help = 'GenObject name'

Definition at line 196 of file useReflexToDescribeForGenObject.py.

tuple useReflexToDescribeForGenObject.nonAlphaRE = re.compile(r'\W')

Definition at line 59 of file useReflexToDescribeForGenObject.py.

tuple useReflexToDescribeForGenObject.objectName = GenObject.decodeNonAlphanumerics(args[0])

Definition at line 226 of file useReflexToDescribeForGenObject.py.

string useReflexToDescribeForGenObject.outputFile = options.outputorgoName+'.txt'

Definition at line 228 of file useReflexToDescribeForGenObject.py.

useReflexToDescribeForGenObject.parser = optparse.OptionParser\

Definition at line 191 of file useReflexToDescribeForGenObject.py.

dictionary useReflexToDescribeForGenObject.root2GOtypeDict
Initial value:
1 = {
2  'int' : 'int',
3  'float' : 'float',
4  'double' : 'float',
5  'long' : 'long',
6  'long int' : 'long',
7  'unsigned int' : 'int',
8  'bool' : 'int',
9  'string' : 'str',
10  'std::basic_string<char>' : 'str',
11  }

Definition at line 17 of file useReflexToDescribeForGenObject.py.

string useReflexToDescribeForGenObject.startString
Initial value:
1 = """
2 # -*- sh -*- For Font lock mode
3 
4 ###########################
5 ## GenObject Definitions ##
6 ###########################
7 
8 # GenObject 'event' definition
9 [runevent singleton]
10 run: type=int
11 event: type=int
12 """

Definition at line 29 of file useReflexToDescribeForGenObject.py.

tuple useReflexToDescribeForGenObject.targetFile = open(outputFile, 'w')

Definition at line 240 of file useReflexToDescribeForGenObject.py.

tuple useReflexToDescribeForGenObject.vetoedTypes = set()

Definition at line 61 of file useReflexToDescribeForGenObject.py.