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

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

Definition at line 142 of file useReflexToDescribeForGenObject.py.

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

Variable Documentation

string useReflexToDescribeForGenObject.action = 'store_true'

Definition at line 201 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 187 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 219 of file useReflexToDescribeForGenObject.py.

string useReflexToDescribeForGenObject.help = 'GenObject name'

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

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

Definition at line 220 of file useReflexToDescribeForGenObject.py.

useReflexToDescribeForGenObject.parser = optparse.OptionParser\

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

tuple useReflexToDescribeForGenObject.vetoedTypes = set()

Definition at line 61 of file useReflexToDescribeForGenObject.py.