本文整理汇总了Python中DataFormats.FWLite.Events.object方法的典型用法代码示例。如果您正苦于以下问题:Python Events.object方法的具体用法?Python Events.object怎么用?Python Events.object使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DataFormats.FWLite.Events
的用法示例。
在下文中一共展示了Events.object方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: EdmDataAccessor
# 需要导入模块: from DataFormats.FWLite import Events [as 别名]
# 或者: from DataFormats.FWLite.Events import object [as 别名]
class EdmDataAccessor(BasicDataAccessor, RelativeDataAccessor, ParticleDataAccessor, EventFileAccessor):
def __init__(self):
logging.debug(__name__ + ": __init__")
self._dataObjects = []
self._edmLabel={}
self._edmParent={}
self._edmChildren={}
self._edmMotherRelations={}
self._edmDaughterRelations={}
self._edmChildrenObjects={}
self._eventIndex = 0
self._numEvents = 0
self._filename=""
self._branches=[]
self._filteredBranches=[]
self._events=None
self._readOnDemand=True
self._underscore=False
self._filterBranches=True
self.maxLevels=2
self.maxDaughters=1000
def isRead(self,object,levels=1):
if not id(object) in self._edmChildrenObjects.keys():
return False
if levels>1 and id(object) in self._edmChildren.keys():
for child in self._edmChildren[id(object)]:
if not self.isRead(child, levels-1):
return False
return True
def children(self,object):
""" Get children of an object """
if id(object) in self._edmChildren.keys() and self.isRead(object):
return self._edmChildren[id(object)]
else:
return ()
def isContainer(self,object):
""" Get children of an object """
if id(object) in self._edmChildren.keys() and self.isRead(object):
return len(self._edmChildren[id(object)])>0
else:
return True
def motherRelations(self,object):
""" Get motherRelations of an object """
if id(object) in self._edmMotherRelations.keys():
return self._edmMotherRelations[id(object)]
else:
return ()
def daughterRelations(self,object):
""" Get daughterRelations of an object """
if id(object) in self._edmDaughterRelations.keys():
return self._edmDaughterRelations[id(object)]
else:
return ()
def label(self,object):
return self.getShortLabel(object)
def getShortLabel(self,object):
if id(object) in self._edmLabel.keys():
splitlabel=self._edmLabel[id(object)].strip(".").split(".")
return splitlabel[len(splitlabel)-1]
else:
return ""
def getShortLabelWithType(self,object):
return self.getShortLabel(object)+" <"+self.getShortType(object)+">"
def getObjectLabel(self,object):
splitlabel=self._edmLabel[id(object)].strip(".").split(".")
return ".".join(splitlabel[1:-1])
def getType(self,object):
typ=str(object.__class__)
if "\'" in typ:
typ=typ.split("\'")[1]
if "." in typ:
typ=typ.split(".")[len(typ.split("."))-1]
return typ.strip(" ")
def getShortType(self,object):
typ=self.getType(object).split("<")[0].strip(" ")
return typ
def getBranch(self,object):
entry=object
while id(entry) in self._edmParent.keys() and self._edmParent[id(entry)]!=None:
entry=self._edmParent[id(entry)]
return entry
def getDepth(self,object):
entry=object
#.........这里部分代码省略.........
示例2: Events
# 需要导入模块: from DataFormats.FWLite import Events [as 别名]
# 或者: from DataFormats.FWLite.Events import object [as 别名]
eventsRef = Events('step3_'+ver+'.root')
tracksRef = Handle("std::vector<reco::Track>")
label = "generalTracks"
quality = "highPurity"
#quality = "tight"
#quality = "loose"
mvaRef = Handle("std::vector<float>")
mcMatchRef = Handle("std::vector<float>")
for i in range(0, eventsRef.size()):
#for i in range(0, 200):
a= eventsRef.to(i)
id = eventsRef.object().id()
evid = '{:d}:{:d}:{:d}'.format(int(id.run()),int(id.luminosityBlock()), int(id.event()))
print "Event", i , evid
a=eventsRef.getByLabel(label, tracksRef)
# a=eventsRef.getByLabel(label, 'MVAValues',mvaRef)
a=eventsRef.getByLabel("trackMCQuality",mcMatchRef)
# mcMatch = mcMatchRef.product()
# mva = mvaRef.product()
trVal = []
k = -1
for track in tracksRef.product():
k+=1
# if (track.phi()<0) : continue
# if (abs(track.eta())>2.3) : continue
# if (track.pt()<4) : continue
# if (track.quality(track.qualityByName(quality))) :