1 from builtins
import range
15 return id(self)==
id(other)
17 return id(self)!=
id(other)
21 if hasattr(container,
'GetEntries'):
23 entries = container.GetEntries()
24 for entry
in range(entries):
27 raise cmserror(
"Looping of %s failed" %container)
29 elif hasattr(container,
'size'):
31 if hasattr(container,
'ids'):
32 container = container.ids()
34 entries = container.size()
35 for entry
in range(entries):
36 yield container[entry]
54 logging.debug(__name__ +
": __init__")
78 if not id(object)
in self._edmChildrenObjects.keys():
80 if levels>1
and id(object)
in self._edmChildren.keys():
82 if not self.
isRead(child, levels-1):
87 """ Get children of an object """ 88 if id(object)
in self._edmChildren.keys()
and self.
isRead(object):
94 """ Get children of an object """ 95 if id(object)
in self._edmChildren.keys()
and self.
isRead(object):
101 """ Get motherRelations of an object """ 102 if id(object)
in self._edmMotherRelations.keys():
108 """ Get daughterRelations of an object """ 109 if id(object)
in self._edmDaughterRelations.keys():
118 if id(object)
in self._edmLabel.keys():
120 return splitlabel[len(splitlabel)-1]
129 return ".".
join(splitlabel[1:-1])
132 typ=
str(object.__class__)
134 typ=typ.split(
"\'")[1]
136 typ=typ.split(
".")[len(typ.split(
"."))-1]
137 return typ.strip(
" ")
145 while id(entry)
in self._edmParent.keys()
and self.
_edmParent[
id(entry)]!=
None:
152 while id(entry)
in self._edmParent.keys()
and self.
_edmParent[
id(entry)]!=
None:
158 """ get all method properties of an object """ 160 for attr
in dir(object):
161 prop=getattr(object,attr)
162 if not attr.startswith(
"__")
and (self.
_underscore or attr.strip(
"_")==attr):
163 objects+=[(attr,prop)]
167 """ get object and resolve references """ 169 ref_types=[
"edm::Ref",
"edm::RefProd",
"edm::RefToBase",
"edm::RefToBaseProd",
"edm::Ptr"]
172 if typshort
in ref_types:
174 if hasattr(object,
"isNull")
and object.isNull():
175 value=
"ERROR: "+self.
getType(object)+
" object is null" 176 elif hasattr(object,
"isAvailable")
and not object.isAvailable():
177 value=
"ERROR: "+self.
getType(object)+
" object is not available" 180 if isinstance(value, type(
None)):
181 value=
"ERROR: Could not get "+self.
getType(object)
184 except Exception
as message:
185 value=
"ERROR: "+
str(message)
189 """ get string value of a method """ 190 if not callable(object):
194 if not object.__doc__
or str(object.__doc__)==
"":
195 return "ERROR: Empty __doc__ string" 196 docs=
str(object.__doc__).
split(
"\n")
199 for p
in doc[doc.find(
"(")+1:doc.find(
")")].
split(
","):
200 if p!=
"" and not "=" in p:
202 if len(parameters)!=0:
204 typestring=doc[:doc.find(
"(")]
205 split_typestring=typestring.split(
" ")
208 for i
in reversed(
list(range(len(split_typestring)))):
209 templates+=split_typestring[i].
count(
"<")
210 templates-=split_typestring[i].
count(
">")
214 typ=
" ".
join(split_typestring[:end_typestring])
215 hidden_types=[
"iterator",
"Iterator"]
216 root_types=[
"ROOT::"]
217 if typ==
"" or "void" in typ
or True in [t
in typ
for t
in hidden_types]:
219 from ROOT
import TClass
220 if True in [t
in typ
for t
in root_types]
and TClass.GetClass(typ)==
None:
221 return "ERROR: Cannot display object of type "+typ
225 except Exception
as message:
226 value=
"ERROR: "+
str(message)
227 if "Buffer" in str(type(value)):
228 return "ERROR: Cannot display object of type "+typ
234 return typ==
"list" or typ[-6:].lower()==
"vector" or typ[-3:].lower()==
"map" or typ[-10:].lower()==
"collection" or hasattr(object,
"size")
238 if hasattr(a,
"px")
and hasattr(a,
"py")
and hasattr(a,
"pz")
and hasattr(a,
"energy")
and \
239 hasattr(b,
"px")
and hasattr(b,
"py")
and hasattr(b,
"pz")
and hasattr(b,
"energy"):
240 same=a.px()==b.px()
and a.py()==b.py()
and a.pz()==b.pz()
and a.energy()==b.energy()
244 """ get list of daughter objects from properties """ 248 hidden_attr=[
"front",
"back",
"IsA",
"clone",
"masterClone",
"masterClonePtr",
"mother",
"motherRef",
"motherPtr",
"daughter",
"daughterRef",
"daughterPtr",
"is_back_safe"]
251 if attr1
in hidden_attr:
253 elif attr1
in broken_attr:
254 objectdict[attr1]=(
"ERROR: Cannot read property",
False)
258 objectdict[attr1]=(value,ref)
259 for name
in sorted(objectdict.keys()):
260 objects+=[(name,objectdict[name][0],objectdict[name][1],self.
_propertyType(objectdict[name][0]))]
264 for o
in all(object):
269 elif "GenParticle" in str(value):
270 name=defaultParticleDataList.getNameFromId(value.pdgId())
273 objects+=[(name,value,ref,typ)]
276 for name,mother,ref,propertyType
in objects:
277 if hasattr(mother,
"numberOfDaughters")
and hasattr(mother,
"daughter"):
279 for n
in range(mother.numberOfDaughters()):
280 daughter=mother.daughter(n)
282 for na,da,re,st
in objects:
286 if not id(mother)
in self._edmDaughterRelations.keys():
289 if not id(daughter)
in self._edmMotherRelations.keys():
292 except Exception
as message:
293 logging.error(
"Cannot read candidate relations: "+
str(message))
297 if type(value)
in (bool,):
299 elif type(value)
in (int, long):
301 elif type(value)
in (float,):
303 elif type(value)
in (complex,str,unicode):
309 """ Make list of all properties """ 310 logging.debug(__name__ +
": properties: "+self.
label(object))
314 objectproperties_sorted=[]
315 if id(object)
in self._edmChildrenObjects.keys():
317 if propertyType!=
None:
318 objectproperties[name]=(value,propertyType)
319 objectproperties_sorted+=[name]
321 properties+=[(
"Category",
"Object info",
"")]
323 properties+=[(
"String",
"label",shortlabel)]
324 properties+=[(
"String",
"type",self.
getType(object))]
327 properties+=[(
"String",
"object",objectlabel)]
329 if shortlabel.strip(
".")!=branchlabel.strip(
"."):
330 properties+=[(
"String",
"branch",branchlabel)]
332 properties+=[(
"Category",
"Branch info",
"")]
333 properties+=[(
"String",
"Type",branchlabel.split(
"_")[0])]
334 properties+=[(
"String",
"Label",branchlabel.split(
"_")[1])]
335 properties+=[(
"String",
"Product",branchlabel.split(
"_")[2])]
336 properties+=[(
"String",
"Process",branchlabel.split(
"_")[3])]
338 for property
in [
"pdgId",
"charge",
"status"]:
339 if property
in objectproperties.keys():
340 properties+=[(objectproperties[property][1],property,objectproperties[property][0])]
341 del objectproperties[property]
343 if "px" in objectproperties.keys():
344 properties+=[(
"Category",
"Vector",
"")]
345 for property
in [
"energy",
"px",
"py",
"pz",
"mass",
"pt",
"eta",
"phi",
"p",
"theta",
"y",
"rapidity",
"et",
"mt",
"mtSqr",
"massSqr"]:
346 if property
in objectproperties.keys():
347 properties+=[(objectproperties[property][1],property,objectproperties[property][0])]
348 del objectproperties[property]
350 if "x" in objectproperties.keys():
351 properties+=[(
"Category",
"Vector",
"")]
352 for property
in [
"x",
"y",
"z"]:
353 if property
in objectproperties.keys():
354 properties+=[(objectproperties[property][1],property,objectproperties[property][0])]
355 del objectproperties[property]
357 if False in [
str(value[0]).startswith(
"ERROR")
for value
in objectproperties.values()]:
358 properties+=[(
"Category",
"Values",
"")]
359 for property
in objectproperties_sorted:
360 if property
in objectproperties.keys():
361 if not str(objectproperties[property][0]).startswith(
"ERROR"):
362 properties+=[(objectproperties[property][1],property,objectproperties[property][0])]
363 del objectproperties[property]
365 if len(objectproperties)>0:
366 properties+=[(
"Category",
"Errors",
"")]
367 for property
in objectproperties_sorted:
368 if property
in objectproperties.keys():
369 properties+=[(objectproperties[property][1],property,objectproperties[property][0])]
371 return tuple(properties)
374 """ read edm objects recursive """ 375 logging.debug(__name__ +
": readObjectsRecursive (levels="+
str(levels)+
"): "+label)
377 if not id(edmobject)
in self._edmLabel.keys():
378 if not isinstance(edmobject,(int,float,long,complex,str,unicode,bool)):
381 type(edmobject).__eq__=eq
382 type(edmobject).__ne__=ne
388 if not id(mother)
in self._edmChildren.keys():
393 return [edmobject],
True 399 """ read daughter objects of an edmobject """ 400 logging.debug(__name__ +
": readDaughtersRecursive (levels="+
str(levels)+
"): "+
str(edmobject))
402 if not id(edmobject)
in self._edmChildrenObjects.keys():
408 for name,daughter,ref,propertyType
in daughters:
410 if propertyType==
None:
415 if id(edmobject)
in self._edmLabel.keys()
and self.
_edmLabel[
id(edmobject)]!=
"":
421 logging.warning(
"Did not read all daughter objects. Maximum is set to "+
str(self.
maxDaughters)+
".")
425 def read(self,object,levels=1):
426 """ reads contents of a branch """ 427 logging.debug(__name__ +
": read")
428 if isinstance(object,BranchDummy):
429 if hasattr(object,
"product"):
430 return object.product
434 self._events.getByLabel(object.branchtuple[2],object.branchtuple[3],object.branchtuple[4],object.branchtuple[1])
435 if object.branchtuple[1].isValid():
436 product=object.branchtuple[1].product()
437 if not isinstance(product,(int,float,long,complex,str,unicode,bool)):
440 type(product).__eq__=eq
441 type(product).__ne__=ne
444 self._dataObjects.insert(self._dataObjects.index(object),product)
445 self._dataObjects.remove(object)
447 object.product=product
451 logging.info(
"Branch is not valid: "+object.branchtuple[0]+
".")
454 except Exception
as e:
456 object.unreadable=
True 457 logging.warning(
"Unable to read branch "+object.branchtuple[0]+
" : "+
exception_traceback())
459 if self.
isRead(object,levels):
466 """ Goto event number index in file. 499 """ Open edm file and show first event """ 502 if os.path.splitext(filename)[1].lower()==
".txt":
503 file =
open(filename)
504 for line
in file.readlines():
506 linecontent=[l.strip(
" \n").rstrip(
".")
for l
in line.split(
"\"")]
507 self.
_branches+=[(linecontent[0]+
"_"+linecontent[1]+
"_"+linecontent[3]+
"_"+linecontent[5],
None,linecontent[1],linecontent[3],linecontent[5])]
509 linecontent=line.strip(
"\n").
split(
" ")[0].
split(
"_")
510 if len(linecontent)>3:
511 self.
_branches+=[(linecontent[0]+
"_"+linecontent[1]+
"_"+linecontent[2]+
"_"+linecontent[3],
None,linecontent[1],linecontent[2],linecontent[3])]
512 elif os.path.splitext(filename)[1].lower()==
".root":
513 from DataFormats.FWLite
import Events, Handle
516 branches=self._events.object().getBranchDescriptions()
517 for branch
in branches:
519 branchname=branch.friendlyClassName()+
"_"+branch.moduleLabel()+
"_"+branch.productInstanceName()+
"_"+branch.processName()
520 handle=
Handle(branch.fullClassName())
521 self.
_branches+=[(branchname,handle,branch.moduleLabel(),branch.productInstanceName(),branch.processName())]
522 except Exception
as e:
523 logging.warning(
"Cannot read branch "+branchname+
":"+
str(e))
524 self._branches.sort(
lambda x, y: cmp(x[0], y[0]))
529 charge=self.
property(object,
"pdgId")
538 return defaultParticleDataList.isQuarkId(particleId)
544 return defaultParticleDataList.isLeptonId(particleId)
550 return defaultParticleDataList.isGluonId(particleId)
556 return defaultParticleDataList.isBosonId(particleId)
562 if not hasattr(defaultParticleDataList,
"isPhotonId"):
564 return defaultParticleDataList.isPhotonId(particleId)
570 if not hasattr(defaultParticleDataList,
"isHiggsId"):
572 return defaultParticleDataList.isHiggsId(particleId)
576 if hasattr(defaultParticleDataList,
"isPhotonId")
and defaultParticleDataList.isPhotonId(particleId):
577 return self.LINE_STYLE_WAVE
578 elif defaultParticleDataList.isGluonId(particleId):
579 return self.LINE_STYLE_SPIRAL
580 elif defaultParticleDataList.isBosonId(particleId):
581 return self.LINE_STYLE_DASH
582 return self.LINE_STYLE_SOLID
586 if defaultParticleDataList.isLeptonId(particleId):
587 return QColor(244, 164, 96)
588 elif defaultParticleDataList.isQuarkId(particleId):
589 return QColor(0, 100, 0)
590 elif hasattr(defaultParticleDataList,
"isHiggsId")
and defaultParticleDataList.isHiggsId(particleId):
591 return QColor(247, 77, 251)
592 elif defaultParticleDataList.isBosonId(particleId):
593 return QColor(253, 74, 74)
594 return QColor(176, 179, 177)
597 charge=self.
property(object,
"charge")
609 return self._underscore
623 result=self.
read(branch,0)
624 if isinstance(result,BranchDummy):
625 self._dataObjects.remove(result)
626 if hasattr(result,
"invalid"):
627 self._filteredBranches.remove(result.branchtuple)
def daughterRelations(self, object)
def getShortType(self, object)
def getObjectRef(self, object)
def properties(self, object)
def isBoson(self, object)
def getDaughterObjects(self, object)
def isPhoton(self, object)
def getShortLabel(self, object)
def children(self, object)
def isRead(self, object, levels=1)
def isContainer(self, object)
def getObjectProperties(self, object)
def underscoreProperties(self)
def exception_traceback()
def readObjectsRecursive(self, mother, label, edmobject, levels=1)
def getObjectContent(self, object)
def isVectorObject(self, object)
def lineStyle(self, object)
def linkDaughter(self, object, daughter)
def setFilterBranches(self, check)
def topLevelObjects(self)
def getObjectLabel(self, object)
def isGluon(self, object)
def __init__(self, branchtuple)
def readDaughtersRecursive(self, edmobject, objects, levels=1)
def getDepth(self, object)
def linkMother(self, object, mother)
def getType(self, object)
def getBranch(self, object)
def open(self, filename=None)
def property(self, object, name)
def isHiggs(self, object)
def particleId(self, object)
def compareObjects(self, a, b)
static std::string join(char **cmd)
def setUnderscoreProperties(self, check)
def getShortLabelWithType(self, object)
def isQuark(self, object)
def motherRelations(self, object)
def _propertyType(self, value)
def read(self, object, levels=1)
def isLepton(self, object)
def filteredBranches(self)
How EventSelector::AcceptEvent() decides whether to accept an event for output otherwise it is excluding the probing of A single or multiple positive and the trigger will pass if any such matching triggers are PASS or EXCEPTION[A criterion thatmatches no triggers at all is detected and causes a throw.] A single negative with an expectation of appropriate bit checking in the decision and the trigger will pass if any such matching triggers are FAIL or EXCEPTION A wildcarded negative criterion that matches more than one trigger in the trigger list("!*","!HLTx*"if it matches 2 triggers or more) will accept the event if all the matching triggers are FAIL.It will reject the event if any of the triggers are PASS or EXCEPTION(this matches the behavior of"!*"before the partial wildcard feature was incorporated).Triggers which are in the READY state are completely ignored.(READY should never be returned since the trigger paths have been run