if '*' in sample or '?' in sample: samples = [] for s, ds in SampleFiles.keys(): if ds == dataset and fnmatch(s, sample): samples.append(s) else: samples = [sample] samples.sort() infos = [] for sample in samples: if verbosity >= 1: print sample fns = SampleFiles.get_fns(sample, dataset) fns = random.sample(fns, nfiles) total_size = 0 total_size_in_events = 0 for fn in fns: assert fn.endswith('.root') if verbosity >= 2: print fn if not eos.exists(fn): raise IOError('does not exist on eos: %r' % fn) bn = os.path.basename(fn) if not fnmatch(bn, pattern): continue
import sys, os from math import ceil from JMTucker.Tools.ROOTTools import * from JMTucker.Tools import SampleFiles as sf used_half_mc = False target_nevents = 50000 # the number of presel events that make it to the vertexer per job print '%30s %12s/%12s = %10s -> %10s (%10s)' % ('sample','npresel','nmcstat','frac','targnfns','evsfromtgt') for fn in sys.argv[1:]: sname = os.path.basename(fn).replace('.root','') f = ROOT.TFile(fn) mcstat = f.Get('mcStat/h_sums').GetBinContent(1) if used_half_mc and not sname.startswith('JetHT'): mcstat /= 2 npresjet = f.Get('mfvEventHistosJetPreSel/h_npv').GetEntries() #npreslep = f.Get('mfvEventHistosLeptonPreSel/h_npv').GetEntries() nfns = len(sf.get_fns(sname, 'miniaod')) if sf.has(sname, 'miniaod') else -1 tfns = min(int(ceil(target_nevents / npresjet * nfns)), 50) evsfromtfns = (2 if used_half_mc else 1) * mcstat * tfns / nfns print '%30s %12.0f/%12.0f = %10.6f -> %4i/%5i (%10i)' % (sname, npresjet, mcstat, npresjet/mcstat, tfns, nfns, evsfromtfns) #(lep %12.0f -> %10.6f)' % (, npreslep, npreslep/mcstat)
# on (MINI)AOD use e.g. dasgo "file,lumi dataset="$(samples ds qcdht1000_2017 miniaod) | grep 833, # run with | egrep -v '^File </tmp/tmp' import sys, os from pprint import pprint from JMTucker.Tools import eos, SampleFiles from JMTucker.Tools.ROOTTools import ROOT, detree if len(sys.argv) < 6: sys.exit('usage: %s dataset sample run lumi event\n where dataset and sample are as registered in SampleFiles. sample can be "*" to mean all samples having the dataset.' % sys.argv[0]) dataset = sys.argv[1] sample = sys.argv[2] rle = int(sys.argv[3]), int(sys.argv[4]), int(sys.argv[5]) fns = SampleFiles.get_fns(sample, dataset) nfound = 0 for fn in fns: assert fn.endswith('.root') if not eos.exists(fn): raise IOError('does not exist on eos: %r' % fn) f = ROOT.TFile.Open(eos.canon(fn)) t = f.Get('Events') for x in sorted(detree(t, 'EventAuxiliary.id().run():EventAuxiliary.luminosityBlock():EventAuxiliary.id().event()', xform=int)): if x == rle: print fn nfound += 1 if nfound != 1:
import sys, os from math import ceil from JMTucker.Tools.ROOTTools import * from JMTucker.Tools import SampleFiles as sf used_half_mc = False target_nevents = 50000 # the number of presel events that make it to the vertexer per job print '%30s %12s/%12s = %10s -> %10s (%10s)' % ( 'sample', 'npresel', 'nmcstat', 'frac', 'targnfns', 'evsfromtgt') for fn in sys.argv[1:]: sname = os.path.basename(fn).replace('.root', '') f = ROOT.TFile(fn) mcstat = f.Get('mcStat/h_sums').GetBinContent(1) if used_half_mc and not sname.startswith('JetHT'): mcstat /= 2 npresjet = f.Get('mfvEventHistosJetPreSel/h_npv').GetEntries() #npreslep = f.Get('mfvEventHistosLeptonPreSel/h_npv').GetEntries() nfns = len(sf.get_fns(sname, 'miniaod')) if sf.has(sname, 'miniaod') else -1 tfns = min(int(ceil(target_nevents / npresjet * nfns)), 50) evsfromtfns = (2 if used_half_mc else 1) * mcstat * tfns / nfns print '%30s %12.0f/%12.0f = %10.6f -> %4i/%5i (%10i)' % ( sname, npresjet, mcstat, npresjet / mcstat, tfns, nfns, evsfromtfns ) #(lep %12.0f -> %10.6f)' % (, npreslep, npreslep/mcstat)