def printTracks(self, eventVars=None, params=None, coords=None, nMax=None, tracks=None, color=r.kBlack): self.prepareText(params, coords) self.printText(tracks) headers = " name pdgId pT eta phi" self.printText(headers) self.printText("-" * len(headers)) nTracks = utils.size(eventVars, tracks) for iTrack in range(nTracks): if nMax <= iTrack: self.printText("[%d more not listed]" % (nTracks - nMax)) break track = eventVars[tracks][iTrack] name = pdgLookup.pdgid_to_name(track.PID) if pdgLookupExists else "" self.printText("%6s %6d%5.0f %s %4.1f" % (name[-6:], track.PID, track.PT, utils.eta(track), track.Phi, ), color=color) return
def uponAcceptance (self,eventVars) : if self.quietMode : return self.sumP4.SetCoordinates(0.0,0.0,0.0,0.0) if self.extra : print "pthat: ",eventVars["genpthat"] mothers = set(eventVars["genMotherIndex"]) print "mothers: ",mothers print "-----------------------------------------------------------------------------------" print " i st mo id name E pt eta phi mass" print "-----------------------------------------------------------------------------------" size=len(eventVars["genP4"]) for iGen in range(size) : p4=eventVars["genP4"][iGen] if p4.pt()<self.minPt : continue status=eventVars["genStatus"][iGen] if status<self.minStatus : continue pdgId=eventVars["genPdgId"][iGen] outString="" outString+="%#2d"%iGen outString+=" %#3d"%status outString+=" %#4d"%eventVars["genMotherIndex"][iGen] outString+=" %#10d"%pdgId if pdgLookupExists : outString+=" "+pdgLookup.pdgid_to_name(pdgId).rjust(15) else : outString+="".rjust(16) outString+=" %#7.1f"%p4.E() outString+=" %#8.1f"%p4.pt() outString+=" %#8.1f"%p4.eta() outString+=" %#5.1f"%p4.phi() outString+=" %#6.1f"%p4.mass() #outString+=" %#5.1f"%p4.mass() if self.extra and not (iGen in mothers) : outString+=" non-mo" self.sumP4+=self.oneP4 #outString2="non-mo P4 sum".ljust(37) #outString2+=" %#7.1f"%self.sumP4.E() #outString2+=" %#8.1f"%self.sumP4.eta() #outString2+=" %#8.1f"%self.sumP4.pt() #outString2+=" %#5.1f"%self.sumP4.phi() #print outString2 print outString if self.extra : outString ="non-mo P4 sum".ljust(37) outString+=" %#7.1f"%self.sumP4.E() outString+=" %#8.1f"%self.sumP4.eta() outString+=" %#8.1f"%self.sumP4.pt() outString+=" %#5.1f"%self.sumP4.phi() print outString print
def printGenParticles(self, eventVars=None, params=None, coords=None, nMax=None, particles=None, color=r.kBlack): self.prepareText(params, coords) self.printText(particles) headers = " name pdgId pT eta phi st PU" self.printText(headers) self.printText("-" * len(headers)) nParticles = utils.size(eventVars, particles) for iParticle in range(nParticles): if nMax <= iParticle: self.printText("[%d more not listed]" % (nParticles - nMax)) break particle = eventVars[particles].At(iParticle) name = pdgLookup.pdgid_to_name(particle.PID) if pdgLookupExists else "" self.printText("%6s %6d%5.0f %s %4.1f %1d %1d" % (name[-6:], particle.PID, particle.PT, utils.eta(particle), particle.Phi, particle.Status, particle.IsPU, ), color=color) return
def printTracks(self, eventVars=None, params=None, coords=None, nMax=None, tracks=None, color=r.kBlack): self.prepareText(params, coords) self.printText(tracks) headers = " name pdgId pT eta phi" self.printText(headers) self.printText("-" * len(headers)) nTracks = utils.size(eventVars, tracks) for iTrack in range(nTracks): if nMax <= iTrack: self.printText("[%d more not listed]" % (nTracks - nMax)) break track = eventVars[tracks][iTrack] name = pdgLookup.pdgid_to_name( track.PID) if pdgLookupExists else "" self.printText("%6s %6d%5.0f %s %4.1f" % ( name[-6:], track.PID, track.PT, utils.eta(track), track.Phi, ), color=color) return
def printGenParticles(self, eventVars=None, params=None, coords=None, nMax=None, particles=None, color=r.kBlack): self.prepareText(params, coords) self.printText(particles) headers = " name pdgId pT eta phi st PU" self.printText(headers) self.printText("-" * len(headers)) nParticles = utils.size(eventVars, particles) for iParticle in range(nParticles): if nMax <= iParticle: self.printText("[%d more not listed]" % (nParticles - nMax)) break particle = eventVars[particles].At(iParticle) name = pdgLookup.pdgid_to_name( particle.PID) if pdgLookupExists else "" self.printText("%6s %6d%5.0f %s %4.1f %1d %1d" % ( name[-6:], particle.PID, particle.PT, utils.eta(particle), particle.Phi, particle.Status, particle.IsPU, ), color=color) return
def uponAcceptance(self, tree): pdgLookupExists = True pdgLookup = PdgLookup() mc_parent_index = tree.mc_parent_index parents = set([p for pp in mc_parent_index for p in pp]) #print "parents: ",parents print "-----------------------------------------------------------------------------------" print " i st par id name pt eta phi mass" print "-----------------------------------------------------------------------------------" size = tree.mc_n pts = tree.mc_pt etas = tree.mc_eta phis = tree.mc_phi pdgs = tree.mc_pdgId masses = tree.mc_m statuses = tree.mc_status maxPrintSize = 75 for iGen in range(min([maxPrintSize, size])): pt = pts[iGen] if pt < self.minPt: continue status = statuses[iGen] if status < self.minStatus: continue pars = [i for i in mc_parent_index[iGen]] pdgId = pdgs[iGen] outString = "" outString += "%#2d" % iGen outString += " %#3d" % status outString += str(pars).rjust(6) outString += " %#10d" % pdgId if pdgLookupExists: outString += " " + pdgLookup.pdgid_to_name(pdgId).rjust(15) else: outString += "".rjust(16) outString += " %#8.1f" % (pts[iGen] * MeV2GeV) outString += " %#8.1f" % etas[iGen] outString += " %#5.1f" % phis[iGen] outString += " %#6.1f" % (masses[iGen] * MeV2GeV) if not (iGen in parents): outString += " non-mo" print outString print
def uponAcceptance (self,tree) : pdgLookupExists = True pdgLookup = PdgLookup() mc_parent_index = tree.mc_parent_index parents=set([p for pp in mc_parent_index for p in pp]) #print "parents: ",parents print "-----------------------------------------------------------------------------------" print " i st par id name pt eta phi mass" print "-----------------------------------------------------------------------------------" size = tree.mc_n pts = tree.mc_pt etas = tree.mc_eta phis = tree.mc_phi pdgs = tree.mc_pdgId masses = tree.mc_m statuses = tree.mc_status maxPrintSize=75 for iGen in range(min([maxPrintSize,size])) : pt = pts[iGen] if pt < self.minPt : continue status = statuses[iGen] if status<self.minStatus : continue pars = [i for i in mc_parent_index[iGen]] pdgId= pdgs[iGen] outString="" outString+="%#2d"%iGen outString+=" %#3d"%status outString+= str(pars).rjust(6) outString+=" %#10d"%pdgId if pdgLookupExists : outString+=" "+pdgLookup.pdgid_to_name(pdgId).rjust(15) else : outString+="".rjust(16) outString+=" %#8.1f"%(pts[iGen]*MeV2GeV) outString+=" %#8.1f"%etas[iGen] outString+=" %#5.1f"%phis[iGen] outString+=" %#6.1f"%(masses[iGen]*MeV2GeV) if not (iGen in parents) : outString+=" non-mo" print outString print
def printGenParticles(self, eventVars, params, coords, nMax) : self.prepareText(params, coords) p4s = eventVars["genP4"] status = eventVars["genStatus"] ids = eventVars["genPdgId"] self.printText("Status 1 Gen Particles") self.printText(" name pdgId pT eta phi") self.printText("----------------------------") particles = reversed(sorted([(i, p4s[i]) for i in range(p4s.size())], key = lambda x:x[1].pt())) nStatus1 = sum([status[i]==1 for i in range(status.size())]) iPrint = 0 for iParticle,p4 in particles : if status.at(iParticle)!=1 : continue if nMax<=iPrint : self.printText("[%d more not listed]"%(nStatus1-nMax)) break pdgId = ids.at(iParticle) self.printText("%6s %6d%5.0f %4.1f %4.1f"%(pdgLookup.pdgid_to_name(pdgId) if pdgLookupExists else "", pdgId, p4.pt(), p4.eta(), p4.phi())) iPrint += 1 return
def uponAcceptance (self,eventVars) : pdgLookupExists = True pdgLookup = PdgLookup() self.sumP4.SetCoordinates(0.0,0.0,0.0,0.0) parents=set([p for pp in eventVars['mc_parent_index'] for p in pp]) #print "parents: ",parents print "-----------------------------------------------------------------------------------" print " i st par id name E pt eta phi mass" print "-----------------------------------------------------------------------------------" size=len(eventVars["genP4"]) maxPrintSize=50 indices = eventVars[self.indices] if self.indices else range(min([maxPrintSize,size])) for iGen in indices : p4=eventVars["genP4"][iGen] if p4.pt()<self.minPt : continue status=eventVars['mc_status'][iGen] if status<self.minStatus : continue pars = [i for i in eventVars['mc_parent_index'][iGen]] pdgId=eventVars['mc_pdgId'][iGen] outString="" outString+="%#2d"%iGen outString+=" %#3d"%status outString+= str(pars).rjust(6) outString+=" %#10d"%pdgId if pdgLookupExists : outString+=" "+pdgLookup.pdgid_to_name(pdgId).rjust(15) else : outString+="".rjust(16) outString+=" %#7.1f"%p4.E() outString+=" %#8.1f"%p4.pt() outString+=" %#8.1f"%p4.eta() outString+=" %#5.1f"%p4.phi() outString+=" %#6.1f"%p4.mass() if not (iGen in parents) : outString+=" non-mo" print outString print