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 142 of file useReflexToDescribeForGenObject.py.

143 def genObjectDef (mylist, tuple, alias, label, type, etaPhiFound):
144  """Does something, but I can't remembrer what... """
145  print "tuple %s alias %s label %s type %s" % (tuple, alias, label, type)
146  # first get the name of the object
147  firstName = mylist[0][0]
148  match = alphaRE.match (firstName)
149  if not match:
150  raise RuntimeError, "firstName doesn't parse correctly. (%s)" \
151  % firstName
152  genName = match.group (1)
153  genDef = " ## GenObject %s Definition ##\n[%s]\n" % \
154  (genName, genName)
155  if options.index or not etaPhiFound:
156  # either we told it to always use index OR either eta or phi
157  # is missing.
158  genDef += "-equiv: index,0\n";
159  else:
160  genDef += "-equiv: eta,0.1 phi,0.1 index,100000\n";
161  tupleDef = '[%s:%s:%s label=%s type=%s]\n' % \
162  (genName, tuple, alias, label, type)
163 
164  for variable in mylist:
165  name, func = genObjNameDef (variable[0])
166  typeInfo = variable[1]
167  form = defsDict[ typeInfo ]
168  genDef += form % name + '\n'
169  tupleDef += "%-40s : %s\n" % (name, func)
170  return genDef, tupleDef
171 
def useReflexToDescribeForGenObject.genObjNameDef (   line)
Returns GenObject name and ntuple definition function

Definition at line 133 of file useReflexToDescribeForGenObject.py.

134 def genObjNameDef (line):
135  """Returns GenObject name and ntuple definition function"""
136  words = dotRE.split (line)[1:]
137  func = ".".join (words)
138  name = "_".join (words)
139  name = nonAlphaRE.sub ('', name)
140  return name, func
141 
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  rootObjConstructor = getattr (ROOT, objectName)
69  obj = rootObjConstructor()
70  alreadySeenFunction = set()
71  etaFound, phiFound = False, False
72  global vetoedTypes
73  retval = []
74  # Put the current class on the queue and start the while loop
75  reflexList = [ ROOT.Reflex.Type.ByName (objectName) ]
76  if verbose: print reflexList
77  while reflexList:
78  reflex = reflexList.pop (0) # get first element
79  print "Looking at %s" % reflex.Name (0xffffffff)
80  if verbose:
81  print "baseSize", reflex.BaseSize()
82  print "FunctionMemberSize", reflex.FunctionMemberSize()
83  for baseIndex in range( reflex.BaseSize() ) :
84  reflexList.append( reflex.BaseAt(baseIndex).ToType() )
85  for index in range( reflex.FunctionMemberSize() ):
86  funcMember = reflex.FunctionMemberAt (index)
87  # if we've already seen this, don't bother again
88  name = funcMember.Name()
89  if verbose:
90  print "name", name
91  if name == 'eta':
92  etaFound = True
93  elif name == 'phi':
94  phiFound = True
95  if name in alreadySeenFunction:
96  continue
97  # make sure this is an allowed return type
98  returnType = funcMember.TypeOf().ReturnType().Name (0xffffffff)
99  goType = root2GOtypeDict.get (returnType, None)
100  if verbose:
101  print " type", returnType, goType
102  if not goType:
103  vetoedTypes.add (returnType)
104  if verbose:
105  print " skipped"
106  continue
107  elif verbose:
108  print " good"
109  # only bother printout out lines where it is a const function
110  # and has no input parameters.
111  if funcMember.IsConst() and not funcMember.FunctionParameterSize():
112  retval.append( ("%s.%s()" % (base, name), goType))
113  alreadySeenFunction.add( name )
114  if verbose:
115  print " added"
116  elif verbose:
117  print " failed IsConst() and FunctionParameterSize()"
118  if not memberData:
119  continue
120  for index in range( reflex.DataMemberSize() ):
121  data = reflex.DataMemberAt( index );
122  name = data.Name()
123  dataType = data.MemberType().__class__.__name__
124  goType = root2GOtypeDict.get (dataType, None)
125  if not goType:
126  continue
127  if verbose:
128  print "name", name, "dataType", dataType, "goType", goType
129  retval.append ( ("%s.%s" % (base, name), goType) )
130  retval.sort()
131  return retval, etaFound and phiFound
132 

Variable Documentation

string useReflexToDescribeForGenObject.action = 'store_true'

Definition at line 192 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 178 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 210 of file useReflexToDescribeForGenObject.py.

string useReflexToDescribeForGenObject.help = 'GenObject name'

Definition at line 179 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 209 of file useReflexToDescribeForGenObject.py.

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

Definition at line 211 of file useReflexToDescribeForGenObject.py.

useReflexToDescribeForGenObject.parser = optparse.OptionParser\

Definition at line 174 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 223 of file useReflexToDescribeForGenObject.py.

tuple useReflexToDescribeForGenObject.vetoedTypes = set()

Definition at line 61 of file useReflexToDescribeForGenObject.py.