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


Python Events.__iter__方法代码示例

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


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

示例1: event_iterator

# 需要导入模块: from DataFormats.FWLite import Events [as 别名]
# 或者: from DataFormats.FWLite.Events import __iter__ [as 别名]
def event_iterator(filename, handles=None):
    """handles is a list of tuples: (varname, type, InputTag)"""
    events = Events(filename)
    if not handles: handles = []
    for evt in events.__iter__():
        for name,typ,inputtag in handles:
            handle = Handle(typ)
            evt.getByLabel(inputtag, handle)
            setattr(evt, "hndl_" + name, handle)
        yield evt
开发者ID:TillArndt,项目名称:MyPackage,代码行数:12,代码来源:eventTreeViewer.py

示例2: Events

# 需要导入模块: from DataFormats.FWLite import Events [as 别名]
# 或者: from DataFormats.FWLite.Events import __iter__ [as 别名]
#! /bin/env python

import ROOT
import pprint
from DataFormats.FWLite import Events, Handle
ROOT.gROOT.SetBatch()


events = Events('/hdfs/store/user/tapas/DoubleMu/Run2012D-16Jan2013-v2/AOD/2013-04-01-8TeV-53X-PatTuple_Master/patTuple_cfg-00A4899E-666B-E211-A2AC-E0CB4E29C50D.root')

evt = events.__iter__().next()
evt.getByLabel(label, handle)

handle = Handle('std::vector<pat::Tau>')
label  = "patTriggerEvent"
obj = handle.product()
algo_names = [i.name() for i in obj.paths()]
print filter(lambda x: 'Mu8_Ele17' in x, algo_names)


## handle = Handle('pat::TriggerEvent')
## label  = "patTriggerEvent"
## obj = handle.product()
## algo_names = [i.name() for i in obj.paths()]
## print filter(lambda x: 'Mu8_Ele17' in x, algo_names)
        
开发者ID:dabelknap,项目名称:UWHiggs,代码行数:27,代码来源:fwklite_dump_pat.py

示例3: ArgumentParser

# 需要导入模块: from DataFormats.FWLite import Events [as 别名]
# 或者: from DataFormats.FWLite.Events import __iter__ [as 别名]
import ROOT
import pprint
import sys
from DataFormats.FWLite import Events, Handle
ROOT.gROOT.SetBatch()
from argparse import ArgumentParser

parser = ArgumentParser()
parser.add_argument('file')
parser.add_argument('collections', default=['slimmedJets'], nargs='*')
args = parser.parse_args()

events = Events(args.file)
jet_labels = args.collections
tested_discriminators = ['pfCombinedCvsLJetTags', 'pfCombinedCvsBJetTags']

evt = next(events.__iter__())
handle = Handle('std::vector<pat::Jet>')
for label in jet_labels:
   evt.getByLabel(label, handle)
   jets = handle.product()
   jet = jets.at(0)
   available = set([i.first for i in jet.getPairDiscri()])
   for test in tested_discriminators:
      print "%s in %s: %s" % (test, label, test in available)
开发者ID:Andrej-CMS,项目名称:cmssw,代码行数:27,代码来源:test_discriminator_presence.py

示例4: METProducerTest

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

#.........这里部分代码省略.........
        self.assert_collection(label, exHandle, acHandle, candidateAssertMethods)

    def test_recoPFMETs_pfMetT1Txy(self):
        label = ("pfMetT1Txy", "", "TEST")
        exHandle = self.exHandlePFMETs
        acHandle = self.acHandlePFMETs
        candidateAssertMethods = ('assert_recoLeafCandidate', 'assert_recoMET', 'assert_recoPFMET')
        self.assert_collection(label, exHandle, acHandle, candidateAssertMethods)

    def test_recoPFMETs_pfMetT1T2Txy(self):
        label = ("pfMetT1T2Txy", "", "TEST")
        exHandle = self.exHandlePFMETs
        acHandle = self.acHandlePFMETs
        candidateAssertMethods = ('assert_recoLeafCandidate', 'assert_recoMET', 'assert_recoPFMET')
        self.assert_collection(label, exHandle, acHandle, candidateAssertMethods)

    def test_recoCaloMETs_caloMetT1(self):
        label = ("caloMetT1", "","TEST")
        exHandle = self.exHandleCaloMETs
        acHandle = self.exHandleCaloMETs
        candidateAssertMethods = ('assert_recoLeafCandidate', 'assert_recoMET', 'assert_recoCaloMET')
        self.assert_collection(label, exHandle, acHandle, candidateAssertMethods)

    def test_recoCaloMETs_caloMetT1T2(self):
        label = ("caloMetT1T2", "","TEST")
        exHandle = self.exHandleCaloMETs
        acHandle = self.exHandleCaloMETs
        candidateAssertMethods = ('assert_recoLeafCandidate', 'assert_recoMET', 'assert_recoCaloMET')
        self.assert_collection(label, exHandle, acHandle, candidateAssertMethods)


    def assert_collection(self, label, exHandle, acHandle, candidateAssertMethods):

        exEventIter = self.exEvents.__iter__()
        acEventIter = self.acEvents.__iter__()

        nevents = min(self.exEvents.size(), self.acEvents.size())
        for i in range(nevents):
            exEvent = exEventIter.next()
            acEvent = acEventIter.next()

            exEvent.getByLabel(label, exHandle)
            exMETs = exHandle.product()
            exMET = exMETs.front()

            acEvent.getByLabel(label, acHandle)
            acMETs = acHandle.product()

            self.assertEqual(acMETs.size(), 1)
            acMET = acMETs.front()

            for method in candidateAssertMethods:
                getattr(self, method)(acMET, exMET)

    def assert_recoPFMET(self, actual, expected):
        # double
        self.assertEqual(actual.photonEtFraction()        , expected.photonEtFraction()        )
        self.assertAlmostEqual(actual.photonEt()                , expected.photonEt()         , 12       )
        self.assertEqual(actual.neutralHadronEtFraction() , expected.neutralHadronEtFraction() )
        self.assertAlmostEqual(actual.neutralHadronEt()         , expected.neutralHadronEt()  , 12       )
        self.assertEqual(actual.electronEtFraction()      , expected.electronEtFraction()      )
        self.assertAlmostEqual(actual.electronEt()              , expected.electronEt()       , 12       )
        self.assertEqual(actual.chargedHadronEtFraction() , expected.chargedHadronEtFraction() )
        self.assertAlmostEqual(actual.chargedHadronEt()         , expected.chargedHadronEt()  , 12       )
        self.assertEqual(actual.muonEtFraction()          , expected.muonEtFraction()          )
        self.assertAlmostEqual(actual.muonEt()                  , expected.muonEt()           , 12       )
开发者ID:TaiSakuma,项目名称:metrecoat,代码行数:70,代码来源:corr_test_met.py

示例5: analyze

# 需要导入模块: from DataFormats.FWLite import Events [as 别名]
# 或者: from DataFormats.FWLite.Events import __iter__ [as 别名]
def analyze(deltaR, relPt, stNum):
    # deltaR: DeltaR of the matching cone
    # relPt: allowed relative pT deviation (1 = no deviation, 0 = infinit deviation)
    for file in fileList:
        event = [threading.Event(), threading.Event()]
        eventList.append(event)
    t = threading.Thread(target=downloadAll)
    t.start()
    
    ROOT.gROOT.SetStyle('Plain') # white background
    
    
    ##    PLOTS   ##
    # Only RECO working / L1 working
    qualityCodes = ROOT.TH1D("QualityCodes", "QualityCodes", 100, -1.5, 98.5)
    qualityCodes2d = ROOT.TH2D("Quality Codes 2D", "Quality Codes 2D", 20, -10.5, 9.5, 10, -5.5, 4.5)
    qualityCodes2dWrong = ROOT.TH2D("Quality Codes 2D Wrong", "Quality Codes 2D Wrong", 20, -10.5, 9.5, 10, -5.5, 4.5)
    realPtVsL1Pt = ROOT.TH2D("Real Pt vs L1 HO Pt", "Real Pt vs L1 HO Pt", 100, 0, 500, 100, 0, 500)
    realPhiVsL1Phi = ROOT.TH2D("Real Phi vs L1 HO Pt", "Real Phi vs L1 HO Pt", 100, -.5, .5, 100, -.5, .5)
    realEtaVsL1Eta = ROOT.TH2D("Real Eta vs L1 HO Pt", "Real Eta vs L1 HO Pt", 100, -.5, .5, 100, -.5, .5)
    recoPositionOfMuons = ROOT.TH2D("Reco Position", "Reco Position", 100, -.5, .5, 628, -1.*math.pi, math.pi)
    genPositionsOfRecMuons = ROOT.TH2D("Gen Position of reconstructed muons", "Gen Position of reconstructed muons", 100, -.5, .5, 628, -1.*math.pi, math.pi)
    

    
    numberOfFails = 0
    numberOfRecoveries = 0
    numberOfRecEvents = 0
    numberOfTooMany = 0

    
    for f in range(len(fileList)):
        
        eventList[f][0].wait()#warten auf beide events event.wait()
        eventList[f][1].wait()
        print 'Files ', fileList[f][0], ' and ', fileList[f][1], ' are ready... analyzing them'
        
        eventsBad = Events(fileList[f][1]) #sample with dead MB1
        eventsGood = Events(fileList[f][0])
    
        eventsBad.toBegin()
        eventsGood.toBegin()
    
        eventsGood_iter = eventsGood.__iter__()
        eventsBad_iter = eventsBad.__iter__()
    
        for i in xrange(MAX_NUMBER):
            # GET THE EVENTS
            badEvent = eventsBad_iter.next()
            goodEvent = eventsGood_iter.next()
        
            # GET THE HANDLES
            badEvent.getByLabel(label,badMuonsHandle)
            badRecoMuons = badMuonsHandle.product()
    
            goodEvent.getByLabel(labelGenParticles, genParticlesHandle)
            genParticles = genParticlesHandle.product()
        
            badEvent.getByLabel(labelL1, badL1MuonsHandle)
            badL1Muons = badL1MuonsHandle.product()
        
            goodEvent.getByLabel(label,goodMuonsHandle)
            goodRecoMuons = goodMuonsHandle.product()

            goodEvent.getByLabel(labelL1, goodL1MuonsHandle)
            goodL1Muons = goodL1MuonsHandle.product()
        
            badEvent.getByLabel(labelHoEntries, hoEntriesHandle)
            badHoEntries = hoEntriesHandle.product()
    
            badEvent.getByLabel(labelPhiContainer, phiContainerHandle)
            phiContainer = phiContainerHandle.product()
            #----- END GET THE HANDLES -----
            badEvent.getByLabel(labelPhiContainer, phiContainerHandle)
            phiContainer = phiContainerHandle.product()
            #----- END GET THE HANDLES -----
            phiDigis = phiContainer.getContainer()
        
        
            badEvent.getByLabel(labelThContainer, thContainerHandle)
            thContainer = thContainerHandle.product()
            #----- END GET THE HANDLES -----
            thDigis = thContainer.getContainer()
        
        
        
            l1MuonTuple = []
        
            recoMuon = 0
            matchingBadMuon = 1 #L1Muon
            matchingGoodMuon = 2 #L1Muon
        
            matchedToGenRecoMuon = Utils.getMatch(genParticles[0], goodRecoMuons, .1, .7)
            #print matchedToGenRecoMuon, " Matched to"
        
            for element in goodRecoMuons:
                if Utils.isInRange(element):
                    thisTuple = [element, Utils.getMatch(element, badL1Muons, deltaR, relPt), Utils.getMatch(element, goodL1Muons, deltaR, relPt)]
                    l1MuonTuple.append(thisTuple)
    
#.........这里部分代码省略.........
开发者ID:FlorianScheuch,项目名称:ComparePython,代码行数:103,代码来源:testRecovery.py

示例6: METProducerTest

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

#.........这里部分代码省略.........
        self.assert_collection(label, exHandle, acHandle, candidateAssertMethods)

    def test_recoCaloMETs_metOptNoHFHO(self):
        label = ("metOptNoHFHO", "" ,"METP")
        exHandle = self.exHandleCaloMETs
        acHandle = self.exHandleCaloMETs
        candidateAssertMethods = ('assert_recoLeafCandidate', 'assert_recoMET', 'assert_recoCaloMET')
        self.assert_collection(label, exHandle, acHandle, candidateAssertMethods)

    def test_recoCaloMETs_corMetGlobalMuons(self):
        label = ("corMetGlobalMuons", "" ,"METP")
        exHandle = self.exHandleCaloMETs
        acHandle = self.exHandleCaloMETs
        candidateAssertMethods = ('assert_recoLeafCandidate', 'assert_recoMET', 'assert_recoCaloMET')
        self.assert_collection(label, exHandle, acHandle, candidateAssertMethods)

    def test_recoPFClusterMETs_pfClusterMet(self):
        label = ("pfClusterMet", "", "METP")
        exHandle = self.exHandlePFClusterMETs
        acHandle = self.acHandlePFClusterMETs
        candidateAssertMethods = ('assert_recoLeafCandidate', 'assert_recoMET')
        self.assert_collection(label, exHandle, acHandle, candidateAssertMethods)

    def test_recoPFMETs_pfChargedMET(self):
        label = ("pfChargedMET" ,"" ,"METP")
        exHandle = self.exHandlePFMETs
        acHandle = self.acHandlePFMETs
        candidateAssertMethods = ('assert_recoLeafCandidate', 'assert_recoMET', 'assert_recoPFMET')
        self.assert_collection(label, exHandle, acHandle, candidateAssertMethods)


    def assert_collection(self, label, exHandle, acHandle, candidateAssertMethods):

        exEventIter = self.exEvents.__iter__()
        acEventIter = self.acEvents.__iter__()

        nevents = min(self.exEvents.size(), self.acEvents.size())
        for i in range(nevents):
            exEvent = exEventIter.next()
            acEvent = acEventIter.next()

            exEvent.getByLabel(label, exHandle)
            exMETs = exHandle.product()
            exMET = exMETs.front()

            acEvent.getByLabel(label, acHandle)
            acMETs = acHandle.product()

            self.assertEqual(acMETs.size(), 1)
            acMET = acMETs.front()

            for method in candidateAssertMethods:
                getattr(self, method)(acMET, exMET)

    def assert_recoPFMET(self, actual, expected):
        # double
        self.assertEqual(actual.photonEtFraction()        , expected.photonEtFraction()        )
        self.assertAlmostEqual(actual.photonEt()          , expected.photonEt()                , 10)
        self.assertEqual(actual.neutralHadronEtFraction() , expected.neutralHadronEtFraction() )
        self.assertAlmostEqual(actual.neutralHadronEt()   , expected.neutralHadronEt()         , 10)
        self.assertEqual(actual.electronEtFraction()      , expected.electronEtFraction()      )
        self.assertAlmostEqual(actual.electronEt()        , expected.electronEt()              , 10)
        self.assertEqual(actual.chargedHadronEtFraction() , expected.chargedHadronEtFraction() )
        self.assertAlmostEqual(actual.chargedHadronEt()   , expected.chargedHadronEt()         , 10)
        self.assertEqual(actual.muonEtFraction()          , expected.muonEtFraction()          )
        self.assertAlmostEqual(actual.muonEt()            , expected.muonEt()                  , 10)
开发者ID:TaiSakuma,项目名称:metrecoat,代码行数:70,代码来源:reco_test.py

示例7: __init__

# 需要导入模块: from DataFormats.FWLite import Events [as 别名]
# 或者: from DataFormats.FWLite.Events import __iter__ [as 别名]
class TBFileReader:
    def __init__(self, filename, **optional):
        
        if not os.path.exists(filename):
            sys.exit("** file not found: %s" % filename)

        # cache input variables 
        self.filename = filename

        # create options by scanning file
        print "reading file %s ..." % filename
        os.system("edmDumpEventContent %s >& .dumpevent" % filename)
        records = open(".dumpevent").readlines()
        for ii, record in enumerate(records):
            if record[:4] != "----":   continue
            records = records[ii+1:]
            break

        objects = {}
        for ii, record in enumerate(records):
            record = simplify.sub(">", strip(record))
            t = split(record)
            s = extract.findall(record)
            if len(s) > 0:
                name = s[0]
            else:
                name = t[0]
            objects[name] = (t[0], dequote.sub("",t[1]), dequote.sub("",t[2]))

        # create event buffer, get event iterator,
        # and create handles
        self.events = Events(filename)
        self.iter   = self.events.__iter__()
        self.event  = self.iter.next()
        self.numberOfEvents = self.event.size()
        print "\n  Number of events: %d" % self.numberOfEvents
        self.handles= {}

        print "  %-20s %s" % ("Key", "Type")
        print "-"*78
        keys = objects.keys()
        keys.sort()
        for key in keys:
            edmtype, label1, label2 = objects[key]
            h = Handle(edmtype)
            self.handles[key] = h
            print "  %-20s %s" % (key, edmtype)

        self.entry   = 0
        self.buffer  = {}
        self.objects = objects
        self.keys    = keys

    def __del__(self):
        pass

    # read event at specified index in TFile and 
    # cache requested objects
    def read(self, index):
        if index < 0: return False
        if index > self.numberOfEvents-1: return False
  
        self.event.to(index)

        for key in self.keys:
            handle = self.handles[key]
            if handle == None: continue
            edmtype, module, label = self.objects[key]
            self.event.getByLabel(module, label, handle)
            self.buffer[key] = handle.product()
        self.entry += 1
        return True

    # get next event and cache requested objects
    def next(self):
        try:
            self.event = self.iter.next()
        except StopIteration:
            return False

        for key in self.keys:
            handle = self.handles[key]
            if handle == None: continue
            edmtype, module, label = self.objects[key]
            self.event.getByLabel(module, label, handle)
            self.buffer[key] = handle.product()
        self.entry += 1
        return True

    # return object by key
    def __call__(self, key):
        try:
            return self.buffer[key]
        except:
            return None

    def entries(self):
        return self.numberOfEvents

    def names(self):
#.........这里部分代码省略.........
开发者ID:CMS-HGCAL,项目名称:TestBeam,代码行数:103,代码来源:TBFileReader.py

示例8: METProducerTest

# 需要导入模块: from DataFormats.FWLite import Events [as 别名]
# 或者: from DataFormats.FWLite.Events import __iter__ [as 别名]
class METProducerTest(unittest.TestCase):

    def setUp(self):
        self.exEvents = Events([options.expectedPath])
        self.acEvents = Events([options.actualPath])

        self.exHandleCorrMETData = Handle("CorrMETData") 
        self.acHandleCorrMETData = Handle("CorrMETData") 

        self.nameChangeMap = {
            "pfJetMETcorr"    : "corrPfMetType1",
            "pfMETcorrType0"  : "corrPfMetType0PfCand",
            "caloJetMETcorr"  : "corrCaloMetType1",
            "pfCandMETcorr"   : "pfCandMETcorr",
            "pfchsMETcorr"    : "pfchsMETcorr",
            "muonCaloMETcorr" : "muonCaloMETcorr",
            }


    def test_n_events(self):
        self.assertEqual(self.exEvents.size(), self.acEvents.size())

    def test_pfJetMETcorr_offset(self):
        label = ("pfJetMETcorr",    "offset", "CORR")
        self.assert_CorrMETData(label)

    def test_pfJetMETcorr_type1(self):
        label = ("pfJetMETcorr",    "type1",  "CORR")
        self.assert_CorrMETData(label)

    def test_pfJetMETcorr_type2(self):
        label = ("pfJetMETcorr",    "type2",  "CORR")
        self.assert_CorrMETData(label)

    def test_pfCandMETcorr(self):
        label = ("pfCandMETcorr",   "",       "CORR")
        self.assert_CorrMETData(label)

    def test_pfchsMETcorr_type0(self):
        label = ("pfchsMETcorr",    "type0",  "CORR")
        self.assert_CorrMETData(label)

    def test_pfMETcorrType0(self):
        label = ("pfMETcorrType0",  "",       "CORR")
        self.assert_CorrMETData(label)

    def test_muonCaloMETcorr(self):
        label = ("muonCaloMETcorr", "",       "CORR")
        self.assert_CorrMETData(label)

    def test_caloJetMETcorr_offset(self):
        label = ("caloJetMETcorr",  "offset", "CORR")
        self.assert_CorrMETData(label)

    def test_caloJetMETcorr_type1(self):
        label = ("caloJetMETcorr",  "type1",  "CORR")
        self.assert_CorrMETData(label)

    def test_caloJetMETcorr_type2(self):
        label = ("caloJetMETcorr",  "type2",  "CORR")
        self.assert_CorrMETData(label)

    def assert_CorrMETData(self, label):

        exHandle = self.exHandleCorrMETData
        acHandle = self.acHandleCorrMETData

        exEventIter = self.exEvents.__iter__()
        acEventIter = self.acEvents.__iter__()

        nevents = min(self.exEvents.size(), self.acEvents.size())
        for i in range(nevents):
            exEvent = exEventIter.next()
            acEvent = acEventIter.next()

            exEvent.getByLabel(label, exHandle)
            exCorr = exHandle.product()

            aclabel = list(label)
            aclabel[0] = self.nameChangeMap[aclabel[0]]
            acEvent.getByLabel(aclabel, acHandle)
            acCorr = acHandle.product()

            self.assertAlmostEqual(acCorr.mex, exCorr.mex, 12)
            self.assertAlmostEqual(acCorr.mey, exCorr.mey, 12)
            self.assertAlmostEqual(acCorr.sumet, exCorr.sumet, 12)
            self.assertAlmostEqual(acCorr.significance, exCorr.significance, 12)
开发者ID:TaiSakuma,项目名称:metrecoat,代码行数:89,代码来源:corr_test_terms_namechange.py


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