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 = '.txt' |
parser = optparse.OptionParser\ | |
dictionary | root2GOtypeDict |
string | startString |
tuple | targetFile = open(outputFile, 'w') |
tuple | vetoedTypes = set() |
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.
00152 : 00153 """Does something, but I can't remembrer what... """ 00154 print "tuple %s alias %s label %s type %s" % (tuple, alias, label, type) 00155 # first get the name of the object 00156 firstName = mylist[0][0] 00157 match = alphaRE.match (firstName) 00158 if not match: 00159 raise RuntimeError, "firstName doesn't parse correctly. (%s)" \ 00160 % firstName 00161 genName = match.group (1) 00162 genDef = " ## GenObject %s Definition ##\n[%s]\n" % \ 00163 (genName, genName) 00164 if options.index or not etaPhiFound: 00165 # either we told it to always use index OR either eta or phi 00166 # is missing. 00167 genDef += "-equiv: index,0\n"; 00168 else: 00169 genDef += "-equiv: eta,0.1 phi,0.1 index,100000\n"; 00170 tupleDef = '[%s:%s:%s label=%s type=%s]\n' % \ 00171 (genName, tuple, alias, label, type) 00172 00173 for variable in mylist: 00174 name, func = genObjNameDef (variable[0]) 00175 typeInfo = variable[1] 00176 form = defsDict[ typeInfo ] 00177 genDef += form % name + '\n' 00178 tupleDef += "%-40s : %s\n" % (name, func) 00179 return genDef, tupleDef 00180
def useReflexToDescribeForGenObject::genObjNameDef | ( | line | ) |
Returns GenObject name and ntuple definition function
Definition at line 142 of file useReflexToDescribeForGenObject.py.
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.
00064 : 00065 """Get a list of interesting things from this object""" 00066 # The autoloader needs an object before it loads its dictionary. 00067 # So let's give it one. 00068 try: 00069 rootObjConstructor = getattr (ROOT, objectName) 00070 except AttributeError as missingAttr: 00071 if str(missingAttr) in ['double', 'int']: 00072 print "Do not need to describe doubles or ints" 00073 sys.exit(0) 00074 else: 00075 raise 00076 00077 obj = rootObjConstructor() 00078 alreadySeenFunction = set() 00079 etaFound, phiFound = False, False 00080 global vetoedTypes 00081 retval = [] 00082 # Put the current class on the queue and start the while loop 00083 reflexList = [ ROOT.Reflex.Type.ByName (objectName) ] 00084 if verbose: print reflexList 00085 # Uses while because reflixList is really a stack 00086 while reflexList: 00087 reflex = reflexList.pop (0) # get first element 00088 print "Looking at %s" % reflex.Name (0xffffffff) 00089 if verbose: 00090 print "baseSize", reflex.BaseSize() 00091 print "FunctionMemberSize", reflex.FunctionMemberSize() 00092 for baseIndex in range( reflex.BaseSize() ) : 00093 reflexList.append( reflex.BaseAt(baseIndex).ToType() ) 00094 for index in range( reflex.FunctionMemberSize() ): 00095 funcMember = reflex.FunctionMemberAt (index) 00096 # if we've already seen this, don't bother again 00097 name = funcMember.Name() 00098 if verbose: 00099 print "name", name 00100 if name == 'eta': 00101 etaFound = True 00102 elif name == 'phi': 00103 phiFound = True 00104 if name in alreadySeenFunction: 00105 continue 00106 # make sure this is an allowed return type 00107 returnType = funcMember.TypeOf().ReturnType().Name (0xffffffff) 00108 goType = root2GOtypeDict.get (returnType, None) 00109 if verbose: 00110 print " type", returnType, goType 00111 if not goType: 00112 vetoedTypes.add (returnType) 00113 if verbose: 00114 print " skipped" 00115 continue 00116 elif verbose: 00117 print " good" 00118 # only bother printout out lines where it is a const function 00119 # and has no input parameters. 00120 if funcMember.IsConst() and not funcMember.FunctionParameterSize(): 00121 retval.append( ("%s.%s()" % (base, name), goType)) 00122 alreadySeenFunction.add( name ) 00123 if verbose: 00124 print " added" 00125 elif verbose: 00126 print " failed IsConst() and FunctionParameterSize()" 00127 if not memberData: 00128 continue 00129 for index in range( reflex.DataMemberSize() ): 00130 data = reflex.DataMemberAt( index ); 00131 name = data.Name() 00132 dataType = data.MemberType().__class__.__name__ 00133 goType = root2GOtypeDict.get (dataType, None) 00134 if not goType: 00135 continue 00136 if verbose: 00137 print "name", name, "dataType", dataType, "goType", goType 00138 retval.append ( ("%s.%s" % (base, name), goType) ) 00139 retval.sort() 00140 return retval, etaFound and phiFound 00141
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 |
00001 { 00002 'int' : '%-40s : form=%%%%8d type=int', 00003 'float' : '%-40s : form=%%%%7.2f prec=', 00004 'str' : '%-40s : form=%%%%20s type=string', 00005 'long' : '%-40s : form=%%%%10d type=long', 00006 }
Definition at line 10 of file useReflexToDescribeForGenObject.py.
00001 """ 00002 ##################### 00003 ## %(OBJS)s Definition ## 00004 ##################### 00005 00006 # Nickname and Tree 00007 [%(objs)s:FWLite] 00008 00009 # 'reco'-tupe 'runevent' 'tofill' information 00010 [runevent:%(objs)s:EventAuxiliary shortcut=eventAuxiliary()] 00011 run: run() 00012 event: event() 00013 00014 """
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 = '.txt' |
Definition at line 220 of file useReflexToDescribeForGenObject.py.
useReflexToDescribeForGenObject::parser = optparse.OptionParser\ |
Definition at line 183 of file useReflexToDescribeForGenObject.py.
00001 { 00002 'int' : 'int', 00003 'float' : 'float', 00004 'double' : 'float', 00005 'long' : 'long', 00006 'long int' : 'long', 00007 'unsigned int' : 'int', 00008 'bool' : 'int', 00009 'string' : 'str', 00010 'std::basic_string<char>' : 'str', 00011 }
Definition at line 17 of file useReflexToDescribeForGenObject.py.
00001 """ 00002 # -*- sh -*- For Font lock mode 00003 00004 ########################### 00005 ## GenObject Definitions ## 00006 ########################### 00007 00008 # GenObject 'event' definition 00009 [runevent singleton] 00010 run: type=int 00011 event: type=int 00012 """
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.