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

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

Definition at line 160 of file useReflexToDescribeForGenObject.py.

References edm.print().

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 
189 
S & print(S &os, JobReport::InputFile const &f)
Definition: JobReport.cc:65
def genObjectDef(mylist, tuple, alias, label, type, etaPhiFound)
def useReflexToDescribeForGenObject.genObjNameDef (   line)
Returns GenObject name and ntuple definition function

Definition at line 151 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 
159 
def useReflexToDescribeForGenObject.getObjectList (   objectName,
  base,
  verbose = False,
  memberData = False 
)
Get a list of interesting things from this object

Definition at line 64 of file useReflexToDescribeForGenObject.py.

References edm.print(), and str.

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 
150 
S & print(S &os, JobReport::InputFile const &f)
Definition: JobReport.cc:65
#define str(s)
def getObjectList(objectName, base, verbose=False, memberData=False)

Variable Documentation

useReflexToDescribeForGenObject.action

Definition at line 198 of file useReflexToDescribeForGenObject.py.

useReflexToDescribeForGenObject.alphaRE

Definition at line 61 of file useReflexToDescribeForGenObject.py.

useReflexToDescribeForGenObject.args

Definition at line 220 of file useReflexToDescribeForGenObject.py.

useReflexToDescribeForGenObject.colonRE

Definition at line 58 of file useReflexToDescribeForGenObject.py.

useReflexToDescribeForGenObject.default

Definition at line 196 of file useReflexToDescribeForGenObject.py.

useReflexToDescribeForGenObject.defsDict

Definition at line 11 of file useReflexToDescribeForGenObject.py.

useReflexToDescribeForGenObject.defTemplate

Definition at line 43 of file useReflexToDescribeForGenObject.py.

useReflexToDescribeForGenObject.dest

Definition at line 195 of file useReflexToDescribeForGenObject.py.

useReflexToDescribeForGenObject.dotRE

Definition at line 59 of file useReflexToDescribeForGenObject.py.

useReflexToDescribeForGenObject.etaPhiFound

Definition at line 236 of file useReflexToDescribeForGenObject.py.

useReflexToDescribeForGenObject.genDef

Definition at line 242 of file useReflexToDescribeForGenObject.py.

useReflexToDescribeForGenObject.goName

Definition at line 228 of file useReflexToDescribeForGenObject.py.

useReflexToDescribeForGenObject.help

Definition at line 197 of file useReflexToDescribeForGenObject.py.

useReflexToDescribeForGenObject.mylist

Definition at line 236 of file useReflexToDescribeForGenObject.py.

useReflexToDescribeForGenObject.nonAlphaRE

Definition at line 60 of file useReflexToDescribeForGenObject.py.

useReflexToDescribeForGenObject.objectName

Definition at line 227 of file useReflexToDescribeForGenObject.py.

useReflexToDescribeForGenObject.options

Definition at line 220 of file useReflexToDescribeForGenObject.py.

useReflexToDescribeForGenObject.outputFile

Definition at line 229 of file useReflexToDescribeForGenObject.py.

useReflexToDescribeForGenObject.parser

Definition at line 192 of file useReflexToDescribeForGenObject.py.

useReflexToDescribeForGenObject.root2GOtypeDict

Definition at line 18 of file useReflexToDescribeForGenObject.py.

useReflexToDescribeForGenObject.startString

Definition at line 30 of file useReflexToDescribeForGenObject.py.

useReflexToDescribeForGenObject.targetFile

Definition at line 241 of file useReflexToDescribeForGenObject.py.

useReflexToDescribeForGenObject.tupleDef

Definition at line 242 of file useReflexToDescribeForGenObject.py.

useReflexToDescribeForGenObject.type

Definition at line 195 of file useReflexToDescribeForGenObject.py.

useReflexToDescribeForGenObject.vetoedTypes

Definition at line 62 of file useReflexToDescribeForGenObject.py.