当前位置: 首页>>代码示例>>Python>>正文


Python Events.getByLabel方法代码示例

本文整理汇总了Python中DataFormats.FWLite.Events.getByLabel方法的典型用法代码示例。如果您正苦于以下问题:Python Events.getByLabel方法的具体用法?Python Events.getByLabel怎么用?Python Events.getByLabel使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在DataFormats.FWLite.Events的用法示例。


在下文中一共展示了Events.getByLabel方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: loop

# 需要导入模块: from DataFormats.FWLite import Events [as 别名]
# 或者: from DataFormats.FWLite.Events import getByLabel [as 别名]
def loop(fname) :
    mus = [Handle("vector<reco::Track> "), "generalTracks"]

    eventsRef = Events(fname)
    for i in range(0, eventsRef.size()):
        a= eventsRef.to(i)
        a=eventsRef.getByLabel(mus[1],mus[0])
        pmus = []
        for mu in mus[0].product() :
            if (mu.pt()<5) : continue
            if (not mu.innerOk()) : continue
            e = 1000*(mu.momentum().r()-mu.outerMomentum().r())
            if (e<0) : continue
            print e
            z = abs(mu.outerPosition().z())
            r = mu.outerPosition().rho()
	    #rhoH.Fill(mu.outerPosition().rho(),e)
            zH.Fill(mu.outerPosition().z(),e)
            etaH.Fill(mu.outerPosition().eta(),e)
            if (z>240) :
                xyeH.Fill(mu.outerPosition().x(),mu.outerPosition().y(),e)
                xyH.Fill(mu.outerPosition().x(),mu.outerPosition().y(),1)
                if (r<120) :phiH.Fill(mu.outerPosition().phi(),e)
                rhoH.Fill(r,e)


    c1 = TCanvas( 'c1', fname, 200, 10, 1000, 1400 )
    gStyle.SetOptStat(111111)
    gStyle.SetHistLineWidth(2)
    c1.Divide(2,3)
    c1.cd(1)
    rhoH.Draw()
    c1.cd(2)
    zH.Draw()
    c1.cd(3)
    xyH.Draw("COLZ")
    c1.cd(4)
    xyeH.Divide(xyH)
    xyeH.Draw("COLZ")
    c1.cd(5)
    etaH.Draw()
    c1.cd(6)
    phiH.Draw()

    c1.Print("eloss"+fname+".png")
开发者ID:VinInn,项目名称:pyTools,代码行数:47,代码来源:eloss.py

示例2: range

# 需要导入模块: from DataFormats.FWLite import Events [as 别名]
# 或者: from DataFormats.FWLite.Events import getByLabel [as 别名]
h = ROOT.TH2F("gamma","gamma",104,-5.2,5.2,50,0,25)

for i in range(nevents):
    events.to(i)
    
    eaux  = events.eventAuxiliary()
    
    # run/lumi/event
    run   = eaux.run()
    event = eaux.event()
    lumi  = eaux.luminosityBlock()
    
    #read all products as specifed in edmCollections
    products = {}
    for k, v in edmCollections.iteritems():
      events.getByLabel(v['label'], v['handle'])
      products[k] = v['handle'].product()
    
    if collection=='ph':
        photons = [ p for p in products['pf'] if p.pdgId()==22 ]
        for p in photons:
            h.Fill( p.eta(), p.energy() )
    elif collection=='rechits':
        rechits = [ p for p in products['rechits']  ]
        for p in rechits:
            o=ROOT.EEDetId(p.detid())

            ix = o.ix() - 50.5 # from https://github.com/cms-sw/cmssw/blob/CMSSW_8_0_X/DQMOffline/JetMET/src/ECALRecHitAnalyzer.cc#L253-L255
            iy = o.iy() - 50.5

            ir    = sqrt(ix**2 + iy**2)/50.5 # normalize to 1
开发者ID:schoef,项目名称:JetMET,代码行数:33,代码来源:PFEGM.py

示例3: Events

# 需要导入模块: from DataFormats.FWLite import Events [as 别名]
# 或者: from DataFormats.FWLite.Events import getByLabel [as 别名]
small=True

events = Events(['file:SMP-RunIIFall15DR76-00032.root'])
edmCollections = [ 
  # {'name':'pfRecHitsHBHE', 'label':("particleFlowRecHitHBHE"), 'edmType':"vector<reco::PFRecHit>"},
    {'name':'pfMet', 'label':('pfMet'), 'edmType':'vector<reco::PFMET>'},
   #{'name':'caloRecHits', 'label':("reducedHcalRecHits"), 'edmType':'edm::SortedCollection<HBHERecHit,edm::StrictWeakOrdering<HBHERecHit> >'},
    {'name':'pf', 'label':('particleFlow'), 'edmType':'vector<reco::PFCandidate>'}
   ]
handles={v['name']:Handle(v['edmType']) for v in edmCollections}

nevents = 1 if small else events.size()
for i in range(nevents):
  events.to(i)
  eaux=events.eventAuxiliary()
  run=eaux.run()
  event=eaux.event()
  lumi=eaux.luminosityBlock()

  #read all products
  products = {}
  for v in edmCollections:
    events.getByLabel(v['label'],handles[v['name']])
    products[v['name']] =handles[v['name']].product()

  print run,lumi,event#,"caloRecHits:",products["caloRecHits"].size()
  
  #find PFRecHits
#  for i, rh in enumerate(products["caloRecHits"]):
#    print "n %i E %3.2f"%(i, rh.energy())
开发者ID:schoef,项目名称:rerecoTools,代码行数:32,代码来源:ilyaCheck.py

示例4: Events

# 需要导入模块: from DataFormats.FWLite import Events [as 别名]
# 或者: from DataFormats.FWLite.Events import getByLabel [as 别名]
from DataFormats.FWLite import Handle, Events
from ROOT import gROOT, gStyle, TCanvas, TF1, TFile, TTree, gRandom, TH1F, TH2F
import os


eventsOri = Events("step3_ori.root")
eventsNew = Events("step3.root")

tracksOri = Handle("std::vector<reco::Track>")
tracksNew = Handle("std::vector<reco::Track>")
label = "generalTracks"
quality = "highPurity"


for i in range(0, eventsOri.size()):
  a= eventsOri.to(i)
  a= eventsNew.to(i)
#  print "Event", i 
  a=eventsOri.getByLabel(label, tracksOri)
  a=eventsNew.getByLabel(label, tracksNew)
  ntOri = tracksOri.product().size()
  ntNew	= tracksOri.product().size()
  if (ntOri != ntNew ) : print i, ntOri,ntNew


开发者ID:VinInn,项目名称:pyTools,代码行数:25,代码来源:tkcomp.py

示例5: str

# 需要导入模块: from DataFormats.FWLite import Events [as 别名]
# 或者: from DataFormats.FWLite.Events import getByLabel [as 别名]
    #hltvertex_label="offlinePrimaryVertices"
    hltvertex_label="hltPixelVertices"
    #hltvertex_label="hltPixelVertices3DbbPhi"
    #hltvertex_label="hltPrimaryVertices"
    #hltvertex_label="hltPrimaryVertices2"
    #hltvertex_label="vertexFromMuon"
    #hltvertex_label="vertexFromElectron"
    #hltvertex_label="verticesFromGsfTracks"
    #hltvertex_label="vertexFromTrack"

    event_count=0
    for event in events:
        event_count+=1
	if str(event_count).replace("0","") in ["1","3"]:
            print "Event:",event_count
        events.getByLabel(tau_label,tau_handle)
        taus=tau_handle.product()
        events.getByLabel(hlttau_label,hlttau_handle)
        hlttaus=hlttau_handle.product()
        #events.getByLabel(selhlttau_label,selhlttau_handle)
        #selhlttaus=selhlttau_handle.product()
        events.getByLabel(ele_label,ele_handle)
	#if len(hlttaus)==0 or hlttaus[0].pt()<20 or abs(hlttaus[0].eta())>2.5:
	#    continue
        eles=ele_handle.product()
	try:
            events.getByLabel(hltele_label,hltele_handle)
            hlteles=hltele_handle.product()
	except: hlteles=()
        #events.getByLabel(l1filter_label,l1filter_handle)
        #l1filter=l1filter_handle.product()selectionfilter
开发者ID:ahinzmann,项目名称:cmsusercode,代码行数:33,代码来源:triggerMatching.py

示例6: range

# 需要导入模块: from DataFormats.FWLite import Events [as 别名]
# 或者: from DataFormats.FWLite.Events import getByLabel [as 别名]
products={}
size=events.size() #if not small else 2000

missingCollections=[]
for nev in range(size):
  if nev%1000==0:print nev,'/',size
  events.to(nev)
  eaux=events.eventAuxiliary()
  run=eaux.run()
  if options.run>0 and not run==options.run:
#    print run, options.run
    continue

  for k in [ x for x in edmCollections.keys() if x not in missingCollections]:
    try:
      events.getByLabel(edmCollections[k][1:],handles[k])
      products[k]=handles[k].product()
    except:
      products[k]=None
      print "Not found:",k
      missingCollections.append(k)
  d={}
#  print "Event",nev,'size',products['pfCandidates'].size()
  assert products['pfCandidates'], "pfCandidates not found!"
  for p in range(products['pfCandidates'].size()):
    cand = products['pfCandidates'][p]
    candID = translatePdgIdToType(cand.pdgId()) if options.miniAOD else cand.particleId() 
    for p in plots[candID]:
      eta=cand.eta()
      if eta>p['etaBinning'][1] and eta<p['etaBinning'][2]:
        yVar = p['yVar'](cand)
开发者ID:easilar,项目名称:MetTools,代码行数:33,代码来源:occupancyPlotsFromFiles.py

示例7: createPlots

# 需要导入模块: from DataFormats.FWLite import Events [as 别名]
# 或者: from DataFormats.FWLite.Events import getByLabel [as 别名]
def createPlots(sample,prefix):
    plots=[]
    plots += [TH1F(prefix+'M(X)',';m(X) [GeV];N',40,920,1080)]
    plots += [TH1F(prefix+'M(Z1)',';m(Z1) [GeV];N',40,70,110)]
    plots += [TH1F(prefix+'M(Z2)',';m(Z2) [GeV];N',40,70,110)]
    plots += [TH1F(prefix+'#Delta #eta',';#Delta #eta;N',15,0,3)]
    plots += [TH1F(prefix+'cos(#theta_{1})',';cos(#theta_{1});N',15,-1,1)]
    plots += [TH1F(prefix+'cos(#theta_{2})',';cos(#theta_{2});N',15,-1,1)]
    plots += [TH1F(prefix+'#phi',';#phi;N',15,-3.1416,3.1416)]
    plots += [TH1F(prefix+'cos(#theta*)',';cos(#theta*);N',15,-1,1)]
    plots += [TH1F(prefix+'#phi_{1}*',';#phi_{1}*;N',15,-3.1416,3.1416)]
    plots += [TH1F(prefix+'#phi_{2}*',';#phi_{2}*;N',15,-3.1416,3.1416)]
    plots += [TH1F(prefix+'#phi_{1}',';#phi_{1};N',15,-3.1416,3.1416)]
    plots += [TH1F(prefix+'#phi_{2}',';#phi_{2};N',15,-3.1416,3.1416)]
    
    for plot in plots:
        plot.Sumw2()

    events=Events(sample[0])
    particles_handle=Handle("std::vector<reco::GenParticle>")
    particles_label="genParticlesStatus3"
    event_count=0
    for event in events:
        event_count+=1
	if event_count>1000:
	    break
	#print "Event:",event_count
        events.getByLabel(particles_label,particles_handle)
        particles=particles_handle.product()
	#for i_particle in range(len(particles)):
	#    print i_particle, particles[i_particle].pdgId()
        x=particles[sample[1]]
	z1=particles[sample[2]]
	z2=particles[sample[3]]
	assert(z1.pdgId()==23)
	assert(z2.pdgId()==23)
	assert(z1.mother(0)==x)
	assert(z2.mother(0)==x)
	q11=z1.daughter(0)
	q12=z1.daughter(1)
	q21=z2.daughter(0)
	q22=z2.daughter(1)
	if abs(q11.eta())>5.0: continue
	if abs(q12.eta())>5.0: continue
	if abs(q21.eta())>5.0: continue
	if abs(q22.eta())>5.0: continue
	if q11.pt()<10: continue
	if q12.pt()<10: continue
	if q21.pt()<10: continue
	if q22.pt()<10: continue
        plots[0].Fill(x.mass())		
        plots[1].Fill(z1.mass())		
        plots[2].Fill(z2.mass())
        plots[3].Fill(abs(z1.eta()-z2.eta()))
	angles=calculateAngles(lv(x),lv(z1),lv(q11),lv(q12),lv(z2),lv(q21),lv(q22))
        plots[4].Fill(angles[0])		
        plots[5].Fill(angles[1])		
        plots[6].Fill(angles[2])		
        plots[7].Fill(angles[3])		
        plots[8].Fill(angles[4])		
        plots[9].Fill(angles[5])		
        plots[10].Fill(angles[6])		
        plots[11].Fill(angles[7])
    for plot in plots:
        if plot.Integral()>0:
            plot.Scale(1./plot.Integral())
        plot.GetYaxis().SetRangeUser(0,plot.GetMaximum()*1.3)
    return plots
开发者ID:ahinzmann,项目名称:cmsusercode,代码行数:70,代码来源:genStudy.py

示例8: Handle

# 需要导入模块: from DataFormats.FWLite import Events [as 别名]
# 或者: from DataFormats.FWLite.Events import getByLabel [as 别名]
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)
  print "Event", i 
  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))) :
   writer.writerow([i,track.eta(), track.phi(), track.pt(),  
                   track.numberOfValidHits(), track.hitPattern().numberOfValidPixelHits(),
                   track.hitPattern().trackerLayersWithMeasurement(),
开发者ID:VinInn,项目名称:pyTools,代码行数:32,代码来源:Track2csv.py

示例9: loop

# 需要导入模块: from DataFormats.FWLite import Events [as 别名]
# 或者: from DataFormats.FWLite.Events import getByLabel [as 别名]
def loop(flist,fname,aod) :

    csvfile = open(fname+'.csv','wb')
    writer = csv.writer(csvfile)

    vertices = [Handle("vector<reco::Vertex>"), "offlineSlimmedPrimaryVertices" ]
    mus = [Handle("vector<pat::Muon>"), "slimmedMuons"]
    pfMETH  = [Handle('std::vector<pat::MET>'),"slimmedMETs"]
    if (aod) :
      vertices = [Handle("vector<reco::Vertex>"), "offlinePrimaryVertices" ]
      mus = [Handle("vector<pat::Muon>"),"cleanPatMuons"] 
      pfMETH  = [Handle('vector<pat::MET>'),"systematicsMET"]


    
    sip2d = TH1F("SIP2D","SIP2D",40,-10.,10.)
    sip3d = TH1F("SIP3D","SIP3D",40,-10.,10.)
    sipxy = TH1F("tk2d","TK SIPXY",40,-10.,10.)
    sipz = TH1F("tk3z","TK SIPZ",40,-10.,10.)

    recoilRawH = ROOT.TH1F("Raw MET","Raw MET",1000,0,1000)
    recoilH = ROOT.TH1F("Recoil","Recoil",100,-10,10)


    responsePt = ROOT.TProfile("responsePt","responsePt",20,0,100)
    resolutionPt = ROOT.TProfile("resolutionPt","resolutionPt",20,0,100)
    responsePU = ROOT.TProfile("responsePU","responsePU",20,0,40)
    resolutionPU = ROOT.TProfile("resolutionPU","resolutionPU",20,0,40)

    hmass = ROOT.TH1F("Z mass","Z mass",100,70,120)


    #
    eventsRef = Events(flist)
    nw=0
    nehpt=0
    nwhpt=0
    nech=0
    nwch=0
    #
    for i in range(0, eventsRef.size()):
        a= eventsRef.to(i)

        eventsRef.getByLabel(pfMETH[1],pfMETH[0])
        met = pfMETH[0].product()[0]
        recoilRawH.Fill(met.pt())

        if((i%5000)==0) : print "Event", i
        a=eventsRef.getByLabel(vertices[1],vertices[0])
        pv = vertices[0].product()[0]
        pvp = vertices[0].product()[0].position()
        nv = vertices[0].product().size()
        a=eventsRef.getByLabel(mus[1],mus[0])
        muons = mus[0].product()
        # print muons.size()
        for mu1,mu2 in itertools.combinations(muons,2):
          if not(mu1.pt()>15 and mu2.pt()>5): continue;
          if mu1.charge()+mu2.charge() !=0: continue;
          if not(mu1.isGlobalMuon() and mu2.isGlobalMuon()) : continue
#          print mu1.pt(),mu2.pt(),mu1.charge()+mu2.charge(), mu1.isGlobalMuon(), mu2.isGlobalMuon(), mu1.track().chi2(),mu1.track().ndof(),mu1.track().hitPattern().pixelLayersWithMeasurement()
          if (mu1.track().hitPattern().pixelLayersWithMeasurement()<1): continue
          if (mu2.track().hitPattern().pixelLayersWithMeasurement()<1):	continue
 
          mass = (mu1.p4()+mu2.p4()).M() 
          if not (mass>70 and mass<120): continue

          hmass.Fill(mass)

          diMu = mu1.p4()+mu2.p4()
          recoil = -(met.p4()+diMu)
        
          Z = diMu.Vect()
          R = recoil.Vect()
          Z.SetZ(0)
          R.SetZ(0)

          URSP = R.Dot(Z.Unit())
          URES = R.Dot(Z.Unit().Cross(ROOT.math.XYZVector(0,0,1)))

          writer.writerow([i,mass,diMu.pt(),URSP,URES,
          mu1.pt(),mu1.eta(),mu1.phi(),mu1.dB(2)/mu1.edB(2),mu1.dB(1)/mu1.edB(1),mu1.track().dxy(pvp)/mu1.track().dxyError(),mu1.track().dz(pvp)/mu1.track().dzError(),
          mu2.pt(),mu2.eta(),mu2.phi(),mu2.dB(2)/mu2.edB(2),mu2.dB(1)/mu2.edB(1),mu2.track().dxy(pvp)/mu2.track().dxyError(),mu2.track().dz(pvp)/mu2.track().dzError()])
          

          responsePt.Fill(diMu.pt(),URSP/diMu.Pt())
          resolutionPt.Fill(diMu.pt(),URES/diMu.Pt())
          if diMu.pt()>20.0:
            responsePU.Fill(nv,URSP/diMu.Pt())
            resolutionPU.Fill(nv,URES/diMu.Pt())
            recoilH.Fill( (URSP+diMu.Pt())/diMu.Pt())

          sip2d.Fill(mu1.dB(2)/mu1.edB(2))
          sip3d.Fill(mu1.dB(1)/mu1.edB(1))
          sipxy.Fill(mu1.track().dxy(pvp)/mu1.track().dxyError())
          sipz.Fill(mu1.track().dz(pvp)/mu1.track().dzError())

          sip2d.Fill(mu2.dB(2)/mu2.edB(2))
          sip3d.Fill(mu2.dB(1)/mu2.edB(1))
          sipxy.Fill(mu2.track().dxy(pvp)/mu2.track().dxyError())
          sipz.Fill(mu2.track().dz(pvp)/mu2.track().dzError())
#.........这里部分代码省略.........
开发者ID:VinInn,项目名称:pyTools,代码行数:103,代码来源:miniAOD_data.py

示例10: max

# 需要导入模块: from DataFormats.FWLite import Events [as 别名]
# 或者: from DataFormats.FWLite.Events import getByLabel [as 别名]
        continue

    # keep leptons with certain pt threshold in the event
    if options.lepType == 0 and muonPts[0] <= muonPtMin:
        continue
    if options.lepType == 1 and electronPts[0] <= electronPtMin:
        continue
    
    # Now get the MET
    event.getByLabel( metLabel, metHandle )
    metRaw = metHandle.product()[0]

    # Now get the PF isolation
    lepIso = -1.0
    if options.lepType == 0 and muonPts is not None :
        events.getByLabel( muonNhIsoLabel, muonNhIsoHandle )
        events.getByLabel( muonChIsoLabel, muonChIsoHandle )
        events.getByLabel( muonPhIsoLabel, muonPhIsoHandle )
        events.getByLabel( muonPuIsoLabel, muonPuIsoHandle )
        nhIso = muonNhIsoHandle.product()[0]
        chIso = muonChIsoHandle.product()[0]
        phIso = muonPhIsoHandle.product()[0] 
        puIso = muonPuIsoHandle.product()[0]  
        lepIso = (chIso + max(0.0, nhIso + phIso - 0.5*puIso)) / muonPts[0]
    if options.lepType == 1 and electronPts is not None :
        events.getByLabel( electronNhIsoLabel, electronNhIsoHandle )
        events.getByLabel( electronChIsoLabel, electronChIsoHandle )
        events.getByLabel( electronPhIsoLabel, electronPhIsoHandle )
        events.getByLabel( electronPuIsoLabel, electronPuIsoHandle )
        nhIso = electronNhIsoHandle.product()[0]
        chIso = electronChIsoHandle.product()[0]
开发者ID:TENorbert,项目名称:TopDAS,代码行数:33,代码来源:plotWJetsQuick.py

示例11: Events

# 需要导入模块: from DataFormats.FWLite import Events [as 别名]
# 或者: from DataFormats.FWLite.Events import getByLabel [as 别名]
# coding: utf-8

from DataFormats.FWLite import Handle, Events
events = Events("/data/kelong/DibosonGenAnalysisSamples/WZJJ_VBFNLO/gentest_WZ-fixGen.root")
handle = Handle("std::vector<reco::GenParticle>")
genParticles = []
for i,event in enumerate(events):
    events.getByLabel("genParticles", handle)
    genParticles = handle.product()
    j=0
    print "-"*20 + ("Event %i" % i) + "-"*20
    for part in genParticles:
        if part.isHardProcess() and part.pdgId() <= 5 and part.pdgId() >= -5:
        #if part.status() == 1 and part.pdgId() <= 5 and part.pdgId() >= -5:
            j += 1
            print "ME level parton %i in event %i" % (j, i)
            print " --> pdgId() == %i, pt == %f, eta == %f" % (part.pdgId(), part.pt(), part.eta())
开发者ID:kdlong,项目名称:GenNtuplizer,代码行数:19,代码来源:getGenParticles.py

示例12: Handle

# 需要导入模块: from DataFormats.FWLite import Events [as 别名]
# 或者: from DataFormats.FWLite.Events import getByLabel [as 别名]

clusRef = Handle("edmNew::DetSetVector<SiStripCluster>")
label =  "siStripClusters" 

vRef = Handle("vector<reco::Vertex>")
vl   = "offlinePrimaryVertices" 

clusHIP = [0,0,0,0,0,0,0,0,0]
nv=0
for i in range(0, eventsRef.size()):
#for i in range(0, 20):
  if (i%100 == 0) : print i
  a= eventsRef.to(i)
#  print "Event", i 
  a=eventsRef.getByLabel(label, clusRef)
  a=eventsRef.getByLabel(vl,vRef)
  nvtx = vRef.product().size()
  if (nvtx<2) : continue;
  nv+=nvtx
  clusters = clusRef.product().data()
  for ids in clusRef.product().ids() :
    for k  in range(0,ids.size):
      clus = clusters[ids.offset+k]
      if (clus.amplitudes().size()>6 and clus.charge()/clus.amplitudes().size()>250) : 
         clusHIP[(ids.id >>25)&0x7]+=1
#         print (ids.id >>25)&0x7


print 'nev, nvtx, nvtx/nev ',eventsRef.size(), nv, float(nv)/float(eventsRef.size())
print clusHIP
开发者ID:VinInn,项目名称:pyTools,代码行数:32,代码来源:dumpClusters.py

示例13:

# 需要导入模块: from DataFormats.FWLite import Events [as 别名]
# 或者: from DataFormats.FWLite.Events import getByLabel [as 别名]
    vertex_handle=Handle("std::vector<reco::Vertex>")
    vertex_label="offlinePrimaryVertices"

    hltvertex_handle=Handle("std::vector<reco::Vertex>")
    #hltvertex_label="offlinePrimaryVertices"
    hltvertex_label="hltPixelVertices"
    #hltvertex_label="hltPixelVertices3DbbPhi"
    #hltvertex_label="hltPrimaryVertices"
    #hltvertex_label="verticesFromMuons"
    #hltvertex_label="verticesFromElectrons"

    event_count=0
    for event in events:
        event_count+=1
	#print "Event:",event_count
        events.getByLabel(tau_label,tau_handle)
        taus=tau_handle.product()
        events.getByLabel(hlttau_label,hlttau_handle)
        hlttaus=hlttau_handle.product()
        events.getByLabel(l1filter_label,l1filter_handle)
        l1filter=l1filter_handle.product()
        events.getByLabel(elefilter_label,elefilter_handle)
        elefilter=elefilter_handle.product()
        events.getByLabel(isolationfilter_label,isolationfilter_handle)
        isolationfilter=isolationfilter_handle.product()
        events.getByLabel(isolation2filter_label,isolation2filter_handle)
        isolation2filter=isolation2filter_handle.product()
        events.getByLabel(isolation3filter_label,isolation3filter_handle)
        isolation3filter=isolation3filter_handle.product()
        events.getByLabel(isolation4filter_label,isolation4filter_handle)
        isolation4filter=isolation4filter_handle.product()
开发者ID:ahinzmann,项目名称:cmsusercode,代码行数:33,代码来源:triggerMatching2.py

示例14: hbheNoiseIsoFilter

# 需要导入模块: from DataFormats.FWLite import Events [as 别名]
# 或者: from DataFormats.FWLite.Events import getByLabel [as 别名]
    {"name": "pfCaloMet", "label": ("pfCaloMet", "", "SKIM"), "edmType": "vector<reco::PFMET>"},
    {"name": "HcalNoiseSummary", "label": ("hcalnoise"), "edmType": "HcalNoiseSummary"},
]
events.toBegin()


def hbheNoiseIsoFilter(products):
    return (
        products["HcalNoiseSummary"].numIsolatedNoiseChannels() < 10
        and products["HcalNoiseSummary"].isolatedNoiseSumE() < 50.0
        and products["HcalNoiseSummary"].isolatedNoiseSumEt() < 25.0
    )


handles = {v["name"]: Handle(v["edmType"]) for v in edmCollections}
for i in range(10):
    events.to(i)
    products = {}
    for v in edmCollections:
        events.getByLabel(v["label"], handles[v["name"]])
        products[v["name"]] = handles[v["name"]].product()

    if hbheNoiseIsoFilter(products):
        print "pfMet %f trkMet %f pfCaloMet %f" % (
            products["pfMet"][0].pt(),
            products["pfChMet"][0].pt(),
            products["pfCaloMet"][0].pt(),
        )
    else:
        print "Skip-> noise!"
开发者ID:kencall,项目名称:MetScanning,代码行数:32,代码来源:checkMETs_4T.py

示例15: format

# 需要导入模块: from DataFormats.FWLite import Events [as 别名]
# 或者: from DataFormats.FWLite.Events import getByLabel [as 别名]
label = "generalTracks"
#label = "globalMuons" 
quality = "highPurity"
#quality = "tight"
#quality = "loose"

def format(x) :
  return '{:.2f}'.format(x)


for i in range(0, eventsRef.size()):
#for i in range(0, 200):
  a= eventsRef.to(i)
  ev = eventsRef.eventAuxiliary().event()
#  print "Event", i 
  a=eventsRef.getByLabel(label, tracksRef)
  trVal = []
  for track in tracksRef.product():
#   if (track.phi()<0) : continue
#   if (track.eta()<0) : continue
    if (track.pt()<1) : continue
#    if (track.qoverpError()*track.p()>2) : continue
#    if (not track.quality(track.qualityByName(quality))) : continue
#    pattern = track.hitPattern()
#    if (pattern.numberOfValidHits() != (pattern.numberOfValidPixelHits()+pattern.numberOfValidStripHits())) :
#      print pattern.numberOfValidHits(),pattern.numberOfValidPixelHits(),pattern.numberOfValidStripHits(), pattern.numberOfValidPixelHits()+pattern.numberOfValidStripHits()
    trVal.append([i, ev, 10*int(100*track.eta())+track.phi(), ver, format(track.eta()), format(track.phi()), format(track.pt()), format(track.qoverpError()*track.p()),   
                  track.numberOfValidHits() , track.hitPattern().numberOfValidPixelHits(), 
                  track.numberOfLostHits(), format(track.validFraction()), track.ndof(),format(track.chi2()),track.algo()-4,track.originalAlgo()-4,track.quality(track.qualityByName("highPurity"))])

#  print tracksRef.product().size(), len(trVal)
开发者ID:VinInn,项目名称:pyTools,代码行数:33,代码来源:simpleDumpTracks.py


注:本文中的DataFormats.FWLite.Events.getByLabel方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。