SigHists2mu2e = {} for ds in sampleSig: events_ = MyEvents(files=sigDS_2mu2e[ds], type='MC') events_.setScale(sigSCALE_2mu2e[ds]) for hinfo in histCollection: events_.bookHisto( '2mu2e/{}'.format(hinfo['name']), ROOT.Hist(*hinfo['binning'], name='{}__2mu2e__{}'.format(ds, hinfo['name']), title=hinfo['title'], drawstyle='hist', legendstyle='L')) events_.process() SigHists2mu2e[ds] = events_.histos log.info('signal MC done') from rootpy.io import root_open import os outname = os.path.join( os.getenv('CMSSW_BASE'), 'src/FireROOT/Analysis/python/outputs/rootfiles/{}.root'.format( __file__.split('.')[0])) log.info('saving to {}'.format(outname)) f = root_open(outname, 'recreate') for hs in SigHists4mu.values(): for h in hs.values(): h.Write() for hs in SigHists2mu2e.values():
for f in sigDS_4mu[ds]: packages.append( (ds, [f], sigSCALE_4mu[ds], args.maxevents, [ '4mu', ])) for res in tqdm(pool.imap_unordered(dofill, packages), total=len(packages)): historesult.append(res[1]) pool.close() pool.join() hists = historesult.pop() for k in hists: for res in historesult: hists[k].Add(res[k]) SigHists4mu[ds] = hists log.info('channel 4mu filling done') ### signal 2mu2e if '2mu2e' in args.channel: sigDS_2mu2e_inc, sigSCALE_2mu2e_inc = sdml.fetch('2mu2e') if args.update_signalsample: sigDS_2mu2e_inc = json.load(open(args.update_signalsample)) # if args.update_signalsample: sigDS_2mu2e_inc.update( json.load(open(args.update_signalsample)) ) sigDS_2mu2e, sigSCALE_2mu2e = {}, {} for t in sampleSig: for k in sigDS_2mu2e_inc: if not k.startswith(t): continue sigDS_2mu2e[t] = sigDS_2mu2e_inc[k] for k in sigSCALE_2mu2e_inc: if not k.startswith(t): continue
SigHists4mu = {} for ds in sampleSig: # events_ = MyEvents(files=_files, type='MC') events_ = MyEvents(files=sigDS_4mu[ds], type='MC') events_.setScale(sigSCALE_4mu[ds]) for hinfo in histCollection: events_.bookHisto( '4mu/{}'.format(hinfo['name']), ROOT.Hist(*hinfo['binning'], name='{}__4mu__{}'.format(ds, hinfo['name']), title=hinfo['title'], drawstyle='hist', legendstyle='L')) events_.process() SigHists4mu[ds] = events_.histos log.info('signal 4mu done') SigHists2mu2e = {} for ds in sampleSig: events_ = MyEvents(files=sigDS_2mu2e[ds], type='MC') events_.setScale(sigSCALE_2mu2e[ds]) for hinfo in histCollection: events_.bookHisto( '2mu2e/{}'.format(hinfo['name']), ROOT.Hist(*hinfo['binning'], name='{}__2mu2e__{}'.format(ds, hinfo['name']), title=hinfo['title'], drawstyle='hist', legendstyle='L')) events_.process() SigHists2mu2e[ds] = events_.histos
events_.bookHisto( 'dphi-{}-{}'.format(cr, chan), ROOT.Hist( 20, 0, ROOT.Math.Pi(), title= 'Lepton-jet pair #Delta#phi;#Delta#phi_{lj0, lj1};counts/20', drawstyle='hist', legendstyle='F', fillstyle='solid', linewidth=0)) events_.process() BkgHists[ds] = events_.histos log.info('background MC done') # ________________________________________________________ sampleSig = 'mXX-150_mA-0p25_lxy-300|mXX-500_mA-1p2_lxy-300|mXX-800_mA-5_lxy-300'.split( '|') # sampleSig = 'mXX-100_mA-5_lxy-0p3|mXX-1000_mA-0p25_lxy-0p3'.split('|') ### signal 4mu SigHists4mu = {} for ds in sampleSig: events_ = MyEvents(files=sigDS_4mu[ds], type='MC') events_.setScale(sigSCALE_4mu[ds]) for cr in ['CosmicCR', 'IsoCR', 'FakeCR']: events_.bookHisto( 'dphi-{}-4mu'.format(cr), ROOT.Hist(20,
for ds, files in bkgDS.items(): events_ = MyEvents(files=files, type='MC') events_.setScale(bkgSCALE[ds]) for chan in ['2mu2e', '4mu']: for hinfo in histCollection: events_.bookHisto( '{}/{}'.format(chan, hinfo['name']), ROOT.Hist(*hinfo['binning'], title=hinfo['title'], drawstyle='hist', fillstyle='solid', linewidth=0, legendstyle='F')) events_.process() BkgHists[ds] = events_.histos log.info('background MC done') # ________________________________________________________ sampleSig = 'mXX-150_mA-0p25_lxy-300|mXX-500_mA-1p2_lxy-300|mXX-800_mA-5_lxy-300'.split( '|') sampleSig.extend('mXX-100_mA-5_lxy-0p3|mXX-1000_mA-0p25_lxy-0p3'.split('|')) ### signal 4mu SigHists4mu = {} for ds in sampleSig: events_ = MyEvents(files=sigDS_4mu[ds], type='MC') events_.setScale(sigSCALE_4mu[ds]) for hinfo in histCollection: events_.bookHisto( '4mu/{}'.format(hinfo['name']), ROOT.Hist(*hinfo['binning'],
### signal 4mu if '4mu' in args.channel: packages = [] SigHists4mu = [] pool = Pool(processes=12) for i, ds in enumerate(sampleSig, start=1): if ds not in sigDS_4mu or not sigDS_4mu[ds]: continue packages.append((ds, sigDS_4mu[ds], sigSCALE_4mu[ds], args.maxevents, ['4mu',])) for res in tqdm.tqdm(pool.imap_unordered(dofill, packages), total=len(packages)): SigHists4mu.append(res) pool.close() pool.join() SigHists4mu = dict(SigHists4mu) log.info('channel 4mu filling done') ### signal 2mu2e if '2mu2e' in args.channel: packages = [] SigHists2mu2e = [] pool = Pool(processes=12) for i, ds in enumerate(sampleSig, start=1): if ds not in sigDS_2mu2e or not sigDS_2mu2e[ds]: continue packages.append((ds, sigDS_2mu2e[ds], sigSCALE_2mu2e[ds], args.maxevents, ['2mu2e',])) for res in tqdm.tqdm(pool.imap_unordered(dofill, packages), total=len(packages)): SigHists2mu2e.append(res) pool.close() pool.join()