本文整理汇总了Python中DataFormats.FWLite.Events类的典型用法代码示例。如果您正苦于以下问题:Python Events类的具体用法?Python Events怎么用?Python Events使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Events类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: setUp
def setUp(self):
self.exEvents = Events([options.expectedPath])
self.acEvents = Events([options.actualPath])
self.exHandleGenMETs = Handle("std::vector<reco::GenMET>")
self.exHandlePFMETs = Handle("std::vector<reco::PFMET>")
self.exHandleCaloMETs = Handle("std::vector<reco::CaloMET>")
self.exHandleMETs = Handle("std::vector<reco::MET>")
self.exHandlePFClusterMETs = Handle("std::vector<reco::PFClusterMET>")
self.acHandleGenMETs = Handle("std::vector<reco::GenMET>")
self.acHandlePFMETs = Handle("std::vector<reco::PFMET>")
self.acHandleCaloMETs = Handle("std::vector<reco::CaloMET>")
self.acHandleMETs = Handle("std::vector<reco::MET>")
self.acHandlePFClusterMETs = Handle("std::vector<reco::PFClusterMET>")
self.nameChangeMap = {
"caloType1CorrectedMet" : "caloMetT1",
"caloType1p2CorrectedMet" : "caloMetT1T2",
"pfType0CorrectedMet" : "pfMetT0rt",
"pfType0p1CorrectedMet" : "pfMetT0rtT1",
"pfType0p1p2CorrectedMet" : "pfMetT0rtT1T2",
"pfType0p2CorrectedMet" : "pfMetT0rtT2",
"pfType0pfcCorrectedMet" : "pfMetT0pc",
"pfType0pfcp1CorrectedMet" : "pfMetT0pcT1",
"pfType1CorrectedMet" : "pfMetT1",
"pfType1p2CorrectedMet" : "pfMetT1T2",
}
示例2: loopDatasets
def loopDatasets(dataS,silent=False):
plts = {}
for l,j in dataS.iteritems():
if not silent:
print "dataSet job ",l
crabJ = json.load(open(j["crabJson"]))
plts[l] = {'plots':{},'additive':[]};
if crabJ.has_key('sample') and crabJ['sample'].has_key('xSec'):
plts[l]['color'] = crabJ['sample']['color']
plts[l]['label'] = crabJ['sample']['label']
plts[l]['xSec'] = crabJ['sample']['xSec'];plts[l]['additive'].append('xSec')
plts[l]['inputEvents'] = j['EventsRead'];plts[l]['additive'].append('inputEvents')
if not silent:
print "adding additional information ","color ",crabJ['sample']['color']," label ",crabJ['sample']['label']," xSec ",crabJ['sample']['xSec']," inputEvts ",j['EventsRead']
if j['EventsRead'] != int(j['dasNeventsInput']):
print "warning ",l," input events differ ",j['EventsRead']," ",j['dasNeventsInput']
if j.has_key('crabIntLumi'):
plts[l]['intLumi'] = j['crabIntLumi']; plts[l]['additive'].append('intLumi')
mergedFile = str(crabJ['mergedFilename'])
if not silent:
print "mergedFile: ",mergedFile
events = Events(mergedFile)
if not silent:
print "events ",events.size()
dists = fillDistributions(events,l)
dists.loop()
plts[l]['plots'].update(copy.deepcopy(dists.plots))
return plts
示例3: __init__
def __init__(self, files, tree_name, options=None):
from DataFormats.FWLite import Events as FWLiteEvents
#TODO not sure we still need the stuff below
from ROOT import gROOT, gSystem, AutoLibraryLoader
print "Loading FW Lite"
gSystem.Load("libFWCoreFWLite");
gROOT.ProcessLine('FWLiteEnabler::enable();')
gSystem.Load("libFWCoreFWLite");
gSystem.Load("libDataFormatsPatCandidates");
from ROOT import gInterpreter
gInterpreter.ProcessLine("using namespace reco;")
gInterpreter.ProcessLine("using edm::refhelper::FindUsingAdvance;")
if options is not None :
if not hasattr(options,"inputFiles"):
options.inputFiles=files
if not hasattr(options,"maxEvents"):
options.maxEvents = 0
if not hasattr(options,"secondaryInputFiles"):
options.secondaryInputFiles = []
self.events = FWLiteEvents(options=options)
else :
self.events = FWLiteEvents(files)
示例4: event_iterator
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
示例5: __init__
def __init__(self, files, tree_name, options=None):
if options is not None :
if not hasattr(options,"inputFiles"):
options.inputFiles=files
if not hasattr(options,"maxEvents"):
options.maxEvents = 0
if not hasattr(options,"secondaryInputFiles"):
options.secondaryInputFiles = []
self.events = FWLiteEvents(options=options)
else :
self.events = FWLiteEvents(files)
示例6: getEventsLumisInFile
def getEventsLumisInFile(infile):
from DataFormats.FWLite import Lumis, Handle, Events
events = Events(infile)
lumis = Lumis(infile)
ret = {}
for lum in lumis:
run = lum.aux().run()
if not ret.has_key(run):
ret[run] = []
ret[run] += [lum.aux().id().luminosityBlock()]
return events.size(), ret
示例7: Events
class Events(object):
def __init__(self, files, tree_name):
self.events = FWLiteEvents(files)
def __len__(self):
return self.events.size()
def __getattr__(self, key):
return getattr(self.events, key)
def __getitem__(self, iEv):
self.events.to(iEv)
return self
示例8: __init__
def __init__(self, inputFiles = '', **kwargs):
"""Initialize the AnalysisEvent like a standard Event, plus additional features."""
# initialization of base functionalities
Events.__init__(self,inputFiles,**kwargs)
# additional features:
# 1. instrumentation for event weight
self._weightCache = {}
self._weightEngines = {}
# 2. a list of event products used in the analysis
self._collections = {}
# 3. a list of "producers" of analysis high-level quantities
self._producers = {}
# 4. volatile dictionary. User can add any quantity to the event and it will be
# properly erased in the iteration step.
self.__dict__["vardict"] = {}
示例9: setUp
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",
}
示例10: setUp
def setUp(self):
self.exEvents = Events([options.expectedPath])
self.acEvents = Events([options.actualPath])
self.exHandleGenMETs = Handle("std::vector<reco::GenMET>")
self.exHandlePFMETs = Handle("std::vector<reco::PFMET>")
self.exHandleCaloMETs = Handle("std::vector<reco::CaloMET>")
self.exHandleMETs = Handle("std::vector<reco::MET>")
self.exHandlePFClusterMETs = Handle("std::vector<reco::PFClusterMET>")
self.acHandleGenMETs = Handle("std::vector<reco::GenMET>")
self.acHandlePFMETs = Handle("std::vector<reco::PFMET>")
self.acHandleCaloMETs = Handle("std::vector<reco::CaloMET>")
self.acHandleMETs = Handle("std::vector<reco::MET>")
self.acHandlePFClusterMETs = Handle("std::vector<reco::PFClusterMET>")
示例11: __getitem__
def __getitem__(self, iEv):
if self._fileindex == -1 or not(self._files[self._fileindex][1] <= iEv and iEv < self._files[self._fileindex][2]):
self.events = None # so it's closed
if self._localCopy:
print "Removing local cache file %s" % self._localCopy
try:
os.remove(self._localCopy)
except:
pass
self._localCopy = None
for i,(fname,first,last) in enumerate(self._files):
if first <= iEv and iEv < last:
print "For event range [ %d, %d ) will use file %r " % (first,last,fname)
self._fileindex = i
if fname.startswith("root://eoscms") or (self.aggressive >= 2 and fname.startswith("root://")):
if not self.isLocal(fname):
tmpdir = os.environ['TMPDIR'] if 'TMPDIR' in os.environ else "/tmp"
rndchars = "".join([hex(ord(i))[2:] for i in os.urandom(8)])
localfile = "%s/%s-%s.root" % (tmpdir, os.path.basename(fname).replace(".root",""), rndchars)
try:
print "Filename %s is remote (geotag >= 9000), will do a copy to local path %s " % (fname,localfile)
start = timeit.default_timer()
subprocess.check_output(["xrdcp","-f","-N",fname,localfile])
print "Time used for transferring the file locally: %s s" % (timeit.default_timer() - start)
self._localCopy = localfile
fname = localfile
except:
print "Could not save file locally, will run from remote"
if os.path.exists(localfile): os.remove(localfile) # delete in case of incomplete transfer
print "Will run from "+fname
self.events = FWLiteEvents([fname])
break
self.events.to(iEv - self._files[self._fileindex][1])
return self
示例12: __init__
def __init__(self, name, component, cfg):
super( DiMuAnalyzer, self).__init__(component.fraction)
self.name = name
self.cmp = component
self.cfg = cfg
self.events = Events( glob.glob( self.cmp.files) )
self.triggerList = TriggerList( self.cmp.triggers )
## if self.cmp.isMC or self.cmp.isEmbed:
## self.trigEff = TriggerEfficiency()
## self.trigEff.tauEff = None
## self.trigEff.lepEff = None
## if self.cmp.tauEffWeight is not None:
## self.trigEff.tauEff = getattr( self.trigEff,
## self.cmp.tauEffWeight )
## if self.cmp.muEffWeight is not None:
## self.trigEff.lepEff = getattr( self.trigEff,
## self.cmp.muEffWeight )
# here create outputs
## self.regions = H2TauTauRegions( self.cfg.cuts )
## self.output = Output( self.name, self.regions )
## if self.cmp.name == 'DYJets':
## self.outputFakes = Output( self.name + '_Fakes', self.regions )
self.output = DiMuOutput( self.name )
self.counters = Counters()
self.averages = {}
self.InitHandles()
self.InitCounters()
self.logger = logging.getLogger(self.name)
self.logger.addHandler(logging.FileHandler('/'.join([self.output.name,
'log.txt'])))
示例13: __init__
def __init__(self ,
files ,
basic_histos ,
track_histos ,
vertex_histos ,
sorting_histos ,
index ,
onlineTauCollections = ['onlTausPixVtx2'] ,
keepAllTaus = False ) :
self.events = Events ( files )
self.declareHandles()
self.breakLoop = False
self.keepAllTaus = keepAllTaus
self.allEvents = 0
self.failinRecoHLT = 0
self.failinDMHLT = 0
self.failinIsoHLT = 0
self.hasNoOnlineTrk = 0
self.hasRegionJet = 0
self.hasRegionTrk = 0
self.hasRegion = 0
self.basic_histos = basic_histos
self.track_histos = track_histos
self.vertex_histos = vertex_histos
self.sorting_histos = sorting_histos
self.index = index
self.onlineTauCollections = onlineTauCollections
示例14: EventLooper
class EventLooper(object):
def __init__(self,sequence,inputPath=None):
self.sequence = sequence
if inputPath:
if type(inputPath) != list:
self.inputPath = [ inputPath ]
else:
inputPath = []
self.inputPath = inputPath
def loadEvents(self,nEvents = -1):
self.events = Events( self.inputPath )
def loop(self,nEvents = -1):
self.loadEvents(nEvents)
print "Total Number of events to be run: %s"%self.events.size()
for ana in self.sequence:
ana.beginJob()
for i,event in enumerate(self.events):
if (i+1) % 10000 == 0: print "Processed events: %s"%i
if (i > nEvents) and (nEvents != -1): break
for ana in self.sequence:
if not ana.applySelection(event): continue
ana.analyze(event)
for ana in self.sequence:
ana.endJob()
示例15: __init__
def __init__(self, name, component, cfg):
'''Build a loop object.
listOfFiles can be "*.root".
name will be used to make the output directory'''
self.name = name
self.cmp = component
self.cfg = cfg
self.events = Events( glob.glob( self.cmp.files) )
self.triggerList = TriggerList( self.cmp.triggers )
if self.cmp.isMC:
self.trigEff = TriggerEfficiency()
self.trigEff.tauEff = None
self.trigEff.lepEff = None
if self.cmp.tauEffWeight is not None:
self.trigEff.tauEff = getattr( self.trigEff,
self.cmp.tauEffWeight )
if self.cmp.muEffWeight is not None:
self.trigEff.lepEff = getattr( self.trigEff,
self.cmp.muEffWeight )
#self.cmp.turnOnCurve = None
#if self.cmp.isMC:
# if self.cmp.tauTriggerTOC is not None:
# self.cmp.turnOnCurve = TurnOnCurve( self.cmp.tauTriggerTOC )
self._MakeOutputDir()
self.counters = Counters()
self.averages = {}
# self.histograms = []
self.InitHandles()