本文整理汇总了Python中DataFormats.FWLite.Events.size方法的典型用法代码示例。如果您正苦于以下问题:Python Events.size方法的具体用法?Python Events.size怎么用?Python Events.size使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DataFormats.FWLite.Events
的用法示例。
在下文中一共展示了Events.size方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: loopDatasets
# 需要导入模块: from DataFormats.FWLite import Events [as 别名]
# 或者: from DataFormats.FWLite.Events import size [as 别名]
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
示例2: EventLooper
# 需要导入模块: from DataFormats.FWLite import Events [as 别名]
# 或者: from DataFormats.FWLite.Events import size [as 别名]
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()
示例3: getEventsLumisInFile
# 需要导入模块: from DataFormats.FWLite import Events [as 别名]
# 或者: from DataFormats.FWLite.Events import size [as 别名]
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
示例4: Events
# 需要导入模块: from DataFormats.FWLite import Events [as 别名]
# 或者: from DataFormats.FWLite.Events import size [as 别名]
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
示例5: Events
# 需要导入模块: from DataFormats.FWLite import Events [as 别名]
# 或者: from DataFormats.FWLite.Events import size [as 别名]
class Events(object):
def __init__(self, dataset):
self._edmEvents = EDMEvents(dataset.files)
self.iEvent = -1
self.nEvents = self._edmEvents.size()
def __iter__(self):
it = iter(self._edmEvents)
while True:
try:
self.edm_event = next(it)
self.iEvent = self.edm_event._eventCounts
self.nEvents = self.edm_event.size()
yield self
except StopIteration:
break
示例6: loop
# 需要导入模块: from DataFormats.FWLite import Events [as 别名]
# 或者: from DataFormats.FWLite.Events import size [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")
示例7: Events
# 需要导入模块: from DataFormats.FWLite import Events [as 别名]
# 或者: from DataFormats.FWLite.Events import size [as 别名]
class Events(object):
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)
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: processSample
# 需要导入模块: from DataFormats.FWLite import Events [as 别名]
# 或者: from DataFormats.FWLite.Events import size [as 别名]
def processSample(self, sample, maxEv=-1):
print 'Processing Files'
print sample.files
events = Events(sample.files)
print "%s events available for processing" % events.size()
ts = time.time()
for N, event in enumerate(events):
if maxEv >= 0 and (N + 1) >= maxEv:
break
if N % 1000000 == 0:
t2 = time.time()
print "%s events processed in %s seconds" % (N + 1, t2 - ts)
weight = 1
box = EventBox()
self.readCollections(event, box)
if not self.analyze(box):
continue
self.addEvent(box)
self.fillHistos(box, sample.type, weight)
tf = time.time()
print "%s events processed in %s seconds" % (N + 1, tf - ts)
示例9: Events
# 需要导入模块: from DataFormats.FWLite import Events [as 别名]
# 或者: from DataFormats.FWLite.Events import size [as 别名]
class Events(object):
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)
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
示例10: Events
# 需要导入模块: from DataFormats.FWLite import Events [as 别名]
# 或者: from DataFormats.FWLite.Events import size [as 别名]
options.file2 = args[2]
# Parse object name and label out of Charles format
tName, objName, lName = options.label[0].split('^')
label = lName.split(',')
ROOT.gROOT.SetBatch()
ROOT.gSystem.Load("libFWCoreFWLite.so")
ROOT.gSystem.Load("libDataFormatsFWLite.so")
ROOT.FWLiteEnabler.enable()
chain1 = Events ([options.file1], forceEvent=True)
chain2 = Events ([options.file2], forceEvent=True)
if chain1.size() != chain1.size():
raise RuntimeError("Files have different #'s of events")
numEvents = min(options.numEvents, chain1.size())
# Parameters to this script are the same regardless if the
# product is double or vector<double> so have to try both
productsCompared = 0
totalCount = 0
mismatches = 0
for handleName in typeMap[objName]:
try:
chain1.toBegin()
chain2.toBegin()
logging.info("Testing identity for handle=%s, label=%s" % (handleName, label))
# Use itertools to iterate over lists in ||
for ev1, ev2, count in itertools.izip(chain1, chain2, range(numEvents)):
示例11: EdmDataAccessor
# 需要导入模块: from DataFormats.FWLite import Events [as 别名]
# 或者: from DataFormats.FWLite.Events import size [as 别名]
#.........这里部分代码省略.........
parameters+=[p]
if len(parameters)!=0:
continue
typestring=doc[:doc.find("(")]
split_typestring=typestring.split(" ")
templates=0
end_typestring=0
for i in reversed(range(len(split_typestring))):
templates+=split_typestring[i].count("<")
templates-=split_typestring[i].count(">")
if templates==0:
end_typestring=i
break
typ=" ".join(split_typestring[:end_typestring])
hidden_types=["iterator","Iterator"]
root_types=["ROOT::"]
if typ=="" or "void" in typ or True in [t in typ for t in hidden_types]:
return None
from ROOT import TClass
if True in [t in typ for t in root_types] and TClass.GetClass(typ)==None:
return "ERROR: Cannot display object of type "+typ
try:
object=object()
value=object
except Exception as message:
value="ERROR: "+str(message)
if "Buffer" in str(type(value)):
return "ERROR: Cannot display object of type "+typ
else:
return value
def isVectorObject(self,object):
typ=self.getShortType(object)
return typ=="list" or typ[-6:].lower()=="vector" or typ[-3:].lower()=="map" or typ[-10:].lower()=="collection" or hasattr(object,"size")
def compareObjects(self,a,b):
same=False
if hasattr(a,"px") and hasattr(a,"py") and hasattr(a,"pz") and hasattr(a,"energy") and \
hasattr(b,"px") and hasattr(b,"py") and hasattr(b,"pz") and hasattr(b,"energy"):
same=a.px()==b.px() and a.py()==b.py() and a.pz()==b.pz() and a.energy()==b.energy()
return same
def getDaughterObjects(self,object):
""" get list of daughter objects from properties """
objects=[]
# subobjects
objectdict={}
hidden_attr=["front","back","IsA","clone","masterClone","masterClonePtr","mother","motherRef","motherPtr","daughter","daughterRef","daughterPtr","is_back_safe"]
broken_attr=[]#["jtaRef"]
for attr1,property1 in self.getObjectProperties(object):
if attr1 in hidden_attr:
pass
elif attr1 in broken_attr:
objectdict[attr1]=("ERROR: Cannot read property",False)
else:
(value,ref)=self.getObjectRef(self.getObjectContent(property1))
if not isinstance(value,type(None)) and (not self.isVectorObject(object) or self._propertyType(value)!=None):
objectdict[attr1]=(value,ref)
for name in sorted(objectdict.keys()):
objects+=[(name,objectdict[name][0],objectdict[name][1],self._propertyType(objectdict[name][0]))]
# entries in vector
if self.isVectorObject(object):
n=0
for o in all(object):
(value,ref)=self.getObjectRef(o)
typ=self._propertyType(value)
示例12: Events
# 需要导入模块: from DataFormats.FWLite import Events [as 别名]
# 或者: from DataFormats.FWLite.Events import size [as 别名]
files.append(dirEos+dir+"00037C53-AAD1-E111-B1BE-003048D45F38.root");
elif nPU == 70 and nBx == 25:
dir = "GJet_Pt40_doubleEMEnriched_TuneZ2star_14TeV-pythia6--UpgradePhase1Age0DES_DR61SLHCx_PU70bx25_DES17_61_V5-v1/"
files.append(dirEos+dir+"0204D05E-F6EF-E211-B304-002354EF3BE1.root");
files.append(dirEos+dir+"047BA908-4AF0-E211-B9B4-002618943852.root");
files.append(dirEos+dir+"04C4DEEF-2FF0-E211-9C7A-00261894395C.root");
files.append(dirEos+dir+"04DB1901-3BF0-E211-9DCA-00248C55CC3C.root");
else:
print "invalid file settings...";
sys.exit();
events = Events( files );
# loop over events
count = 0
ntotal = events.size()
print "Nevents = "+str(ntotal)
print "Start looping"
photonHandle = Handle( "vector<reco::Photon>" );
photonLabel = "photons";
calojetHandle = Handle( "vector<reco::CaloJet>" );
calojetLabel = "ak5CaloJets";
pfjetHandle = Handle( "vector<reco::PFJet>" );
pfjetLabel = "ak5PFJets";
genjetHandle = Handle( "vector<reco::GenJet>" );
genjetLabel = "ak5GenJets";
示例13: TH1F
# 需要导入模块: from DataFormats.FWLite import Events [as 别名]
# 或者: from DataFormats.FWLite.Events import size [as 别名]
ptall = TH1F("pt all","pt all",100,-10.,10.)
ptmiss = TH1F("pt miss","pt miss",100,-10.,10.)
ptr = TH1F("pt ratio","pt ratio",100,-10.,10.)
d0all = TH1F("d0 all","d0 all",100,-5.,5.)
d0miss = TH1F("d0 miss","d0 miss",100,-5.,5.)
d0r = TH1F("d0 ratio","d0 ratio",100,-5.,5.)
dpall = TH1F("dp all","dp all",100,-0.5,0.5)
dpmiss = TH1F("dp miss","dp miss",100,-0.5,0.5)
dpr = TH1F("dp ratio","dp ratio",100,-0.5,0.5)
algoall = TH1F("algo all","algo all",20,0,20)
algomiss = TH1F("algo miss","algo miss",20,0,20)
algor = TH1F("algo ratio","algo ratio",20,0,20)
# for event in eventsRef:
for i in range(0, eventsRef.size()):
a= eventsRef.to(i)
a= eventsNew.to(i)
print "Event", i
a=eventsRef.getByLabel(label, tracksRef)
a=eventsNew.getByLabel(label, tracksNew)
trRef = []
j = 0
for track in tracksRef.product():
if (track.found()<8) : continue
if (track.quality(track.qualityByName(quality))) :
dp = track.outerPosition().phi()-track.outerMomentum().phi()
trRef.append((j,track.charge()*track.pt(), track.phi()+track.eta(),track.eta(),track.found(), track.hitPattern(), track.ndof(), track.chi2(), track.dxy(),dp, track.algo() ))
j += 1
a = trRef.sort(key=lambda tr: tr[2])
print j
示例14: METProducerTest
# 需要导入模块: from DataFormats.FWLite import Events [as 别名]
# 或者: from DataFormats.FWLite.Events import size [as 别名]
class METProducerTest(unittest.TestCase):
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>")
def test_n_events(self):
self.assertEqual(self.exEvents.size(), self.acEvents.size())
def test_recoPFMETs_pfMet(self):
label = ("pfMet" ,"" ,"METP")
exHandle = self.exHandlePFMETs
acHandle = self.acHandlePFMETs
candidateAssertMethods = ('assert_recoLeafCandidate', 'assert_recoMET', 'assert_recoPFMET')
self.assert_collection(label, exHandle, acHandle, candidateAssertMethods)
def test_recoGenMETs_genMetTrue(self):
label = ("genMetTrue" ,"" ,"METP")
exHandle = self.exHandleGenMETs
acHandle = self.acHandleGenMETs
candidateAssertMethods = ('assert_recoLeafCandidate', 'assert_recoMET', 'assert_recoGenMET')
self.assert_collection(label, exHandle, acHandle, candidateAssertMethods)
def test_recoGenMETs_genMetCalo(self):
label = ("genMetCalo" ,"" ,"METP")
exHandle = self.exHandleGenMETs
acHandle = self.acHandleGenMETs
candidateAssertMethods = ('assert_recoLeafCandidate', 'assert_recoMET', 'assert_recoGenMET')
self.assert_collection(label, exHandle, acHandle, candidateAssertMethods)
def test_recoGenMETs_genMetCaloAndNonPrompt(self):
label = ("genMetCaloAndNonPrompt" ,"" ,"METP")
exHandle = self.exHandleGenMETs
acHandle = self.acHandleGenMETs
candidateAssertMethods = ('assert_recoLeafCandidate', 'assert_recoMET', 'assert_recoGenMET')
self.assert_collection(label, exHandle, acHandle, candidateAssertMethods)
def test_recoMETs_genMetIC5GenJets(self):
label = ("genMetIC5GenJets", "", "METP")
exHandle = self.exHandleMETs
acHandle = self.acHandleMETs
candidateAssertMethods = ('assert_recoLeafCandidate', 'assert_recoMET')
self.assert_collection(label, exHandle, acHandle, candidateAssertMethods)
def test_recoMETs_tcMet(self):
label = ("tcMet", "", "METP")
exHandle = self.exHandleMETs
acHandle = self.acHandleMETs
candidateAssertMethods = ('assert_recoLeafCandidate', 'assert_recoMET')
self.assert_collection(label, exHandle, acHandle, candidateAssertMethods)
def test_recoMETs_tcMetCST(self):
label = ("tcMetCST", "", "METP")
exHandle = self.exHandleMETs
acHandle = self.acHandleMETs
candidateAssertMethods = ('assert_recoLeafCandidate', 'assert_recoMET')
self.assert_collection(label, exHandle, acHandle, candidateAssertMethods)
def test_recoMETs_tcMetRft2(self):
label = ("tcMetRft2", "", "METP")
exHandle = self.exHandleMETs
acHandle = self.acHandleMETs
candidateAssertMethods = ('assert_recoLeafCandidate', 'assert_recoMET')
self.assert_collection(label, exHandle, acHandle, candidateAssertMethods)
def test_recoMETs_tcMetVedu(self):
label = ("tcMetVedu", "", "METP")
exHandle = self.exHandleMETs
acHandle = self.acHandleMETs
candidateAssertMethods = ('assert_recoLeafCandidate', 'assert_recoMET')
self.assert_collection(label, exHandle, acHandle, candidateAssertMethods)
def test_recoMETs_tcMetWithPFclusters(self):
label = ("tcMetWithPFclusters", "", "METP")
exHandle = self.exHandleMETs
acHandle = self.acHandleMETs
candidateAssertMethods = ('assert_recoLeafCandidate', 'assert_recoMET')
self.assert_collection(label, exHandle, acHandle, candidateAssertMethods)
def test_recoMETs_htMetAK5(self):
label = ("htMetAK5", "", "METP")
exHandle = self.exHandleMETs
acHandle = self.acHandleMETs
candidateAssertMethods = ('assert_recoLeafCandidate', 'assert_recoMET')
self.assert_collection(label, exHandle, acHandle, candidateAssertMethods)
# def test_recoMETs_htMetAK7(self):
# label = ("htMetAK7", "", "METP")
#.........这里部分代码省略.........
示例15: Handle
# 需要导入模块: from DataFormats.FWLite import Events [as 别名]
# 或者: from DataFormats.FWLite.Events import size [as 别名]
'GENMC_08TeV/My_RunIIFall17GS_Lambdab_49.root',
'GENMC_08TeV/My_RunIIFall17GS_Lambdab_5.root',
'GENMC_08TeV/My_RunIIFall17GS_Lambdab_50.root',
'GENMC_08TeV/My_RunIIFall17GS_Lambdab_51.root',
'GENMC_08TeV/My_RunIIFall17GS_Lambdab_6.root',
'GENMC_08TeV/My_RunIIFall17GS_Lambdab_7.root',
'GENMC_08TeV/My_RunIIFall17GS_Lambdab_8.root',
'GENMC_08TeV/My_RunIIFall17GS_Lambdab_9.root'])
handleGen = Handle("std::vector<reco::GenParticle>")
labelGen = ("genParticles")
########################
# Loop over the events #
########################
print "Total number of events to analyze: ", events.size()
for it, event in enumerate(events):
if it%100 == 0:
print "Processed events: ", it
event.getByLabel(labelGen, handleGen)
gen_p = handleGen.product()
for br in branchNames:
branches[br] = -99.
b0 = TLorentzVector()
mum = TLorentzVector()
mup = TLorentzVector()
num = TLorentzVector()
nup = TLorentzVector()
kst = TLorentzVector()