def make_pileup(args): with open(args.samplejson) as fin: samplefiles = json.load(fin) sample = samplefiles[args.sample] filelist = [] for dataset, files in sample.items(): if dataset == 'JetHT' or dataset == 'SingleMuon': continue for file in files: filelist.append((dataset, file)) final_accumulator = processor.dict_accumulator({ 'pileup': processor.dict_accumulator(), 'sumw': processor.dict_accumulator(), }) processor.futures_executor(filelist, get_pileup, final_accumulator, workers=args.workers) save(final_accumulator['pileup'], 'correction_files/pileup_mc.coffea') save(final_accumulator['sumw'], 'correction_files/sumw_mc.coffea')
def smooth_bkg_templates(fnames_to_run): """ Function that writes linearized mtt vs costheta distributions to root file. """ if "3Jets" in njets_to_run: histo_dict_3j = processor.dict_accumulator({ "Muon": {}, "Electron": {} }) if "4PJets" in njets_to_run: histo_dict_4pj = processor.dict_accumulator({ "Muon": {}, "Electron": {} }) #set_trace() for bkg_file in fnames_to_run: hdict = load(bkg_file) jmult = "3Jets" if "3Jets" in os.path.basename(bkg_file) else "4PJets" for lep in hdict.keys(): for tname, orig_template in hdict[lep].items(): #set_trace() proc = tname.split( "_")[0] if not "data_obs" in tname else "data_obs" sys = sorted(filter(None, tname.split(f"{proc}_")))[0] #if sys == "nosys": continue print(lep, jmult, sys, proc) # perform smoothing smoothed_histo = hdict[lep][f"{proc}_nosys"].copy( ) if sys == "nosys" else Plotter.smoothing_mttbins( nosys=hdict[lep][f"{proc}_nosys"], systematic=orig_template, mtt_centers=mtt_centers, nbinsx=len(linearize_binning[0]) - 1, nbinsy=len(linearize_binning[1]) - 1) ## save template histos to coffea dict if jmult == "3Jets": histo_dict_3j[lep][tname] = smoothed_histo.copy() if jmult == "4PJets": histo_dict_4pj[lep][tname] = smoothed_histo.copy() #set_trace() if "3Jets" in njets_to_run: coffea_out_3j = os.path.join( input_dir, f"test_smoothed_templates_lj_3Jets_bkg_{args.year}_{jobid}.coffea") save(histo_dict_3j, coffea_out_3j) print(f"{coffea_out_3j} written") if "4PJets" in njets_to_run: coffea_out_4pj = os.path.join( input_dir, f"test_smoothed_templates_lj_4PJets_bkg_{args.year}_{jobid}.coffea" ) save(histo_dict_4pj, coffea_out_4pj) print(f"{coffea_out_4pj} written")
def test_accumulators(): a = processor.value_accumulator(float) a += 3.0 assert a.value == 3.0 assert a.identity().value == 0.0 a = processor.value_accumulator(partial(np.array, [2.0])) a += 3.0 assert np.array_equal(a.value, np.array([5.0])) assert np.array_equal(a.identity().value, np.array([2.0])) lacc = processor.list_accumulator(range(4)) lacc += [3] lacc += processor.list_accumulator([1, 2]) assert lacc == [0, 1, 2, 3, 3, 1, 2] b = processor.set_accumulator({"apples", "oranges"}) b += {"pears"} b += "grapes" assert b == {"apples", "oranges", "pears", "grapes"} c = processor.dict_accumulator({"num": a, "fruit": b}) c["num"] += 2.0 c += processor.dict_accumulator({ "num2": processor.value_accumulator(int), "fruit": processor.set_accumulator({"apples", "cherries"}), }) assert c["num2"].value == 0 assert np.array_equal(c["num"].value, np.array([7.0])) assert c["fruit"] == {"apples", "oranges", "pears", "grapes", "cherries"} d = processor.defaultdict_accumulator(float) d["x"] = 0.0 d["x"] += 4.0 d["y"] += 5.0 d["z"] += d["x"] d["x"] += d["y"] assert d["x"] == 9.0 assert d["y"] == 5.0 assert d["z"] == 4.0 assert d["w"] == 0.0 f = processor.defaultdict_accumulator(lambda: 2.0) f["x"] += 4.0 assert f["x"] == 6.0 f += f assert f["x"] == 12.0 assert f["y"] == 2.0 a = processor.column_accumulator(np.arange(6).reshape(2, 3)) b = processor.column_accumulator(np.arange(12).reshape(4, 3)) a += b assert a.value.sum() == 81
def test_accumulators(): a = processor.value_accumulator(float) a += 3. assert a.value == 3. assert a.identity().value == 0. a = processor.value_accumulator(partial(np.array, [2.])) a += 3. assert np.array_equal(a.value, np.array([5.])) assert np.array_equal(a.identity().value, np.array([2.])) l = processor.list_accumulator(range(4)) l += [3] l += processor.list_accumulator([1, 2]) assert l == [0, 1, 2, 3, 3, 1, 2] b = processor.set_accumulator({'apples', 'oranges'}) b += {'pears'} b += 'grapes' assert b == {'apples', 'oranges', 'pears', 'grapes'} c = processor.dict_accumulator({'num': a, 'fruit': b}) c['num'] += 2. c += processor.dict_accumulator({ 'num2': processor.value_accumulator(int), 'fruit': processor.set_accumulator({'apples', 'cherries'}), }) assert c['num2'].value == 0 assert np.array_equal(c['num'].value, np.array([7.])) assert c['fruit'] == {'apples', 'oranges', 'pears', 'grapes', 'cherries'} d = processor.defaultdict_accumulator(float) d['x'] = 0. d['x'] += 4. d['y'] += 5. d['z'] += d['x'] d['x'] += d['y'] assert d['x'] == 9. assert d['y'] == 5. assert d['z'] == 4. assert d['w'] == 0. e = d + c f = processor.defaultdict_accumulator(lambda: 2.) f['x'] += 4. assert f['x'] == 6. f += f assert f['x'] == 12. assert f['y'] == 2. a = processor.column_accumulator(np.arange(6).reshape(2,3)) b = processor.column_accumulator(np.arange(12).reshape(4,3)) a += b assert a.value.sum() == 81
def test_accumulators(): a = processor.accumulator(0.) a += 3. a += processor.accumulator(2) assert a.value == 5. assert a.identity().value == 0. a = processor.accumulator(np.array([0.])) a += 3. a += processor.accumulator(2) assert a.value == np.array([5.]) assert a.identity().value == np.array([0.]) b = processor.set_accumulator({'apples', 'oranges'}) b += {'pears'} b += 'grapes' assert b == {'apples', 'oranges', 'pears', 'grapes'} c = processor.dict_accumulator({'num': a, 'fruit': b}) c['num'] += 2. c += processor.dict_accumulator({ 'num2': processor.accumulator(0), 'fruit': processor.set_accumulator({'apples', 'cherries'}), }) assert c['num2'].value == 0 assert c['num'].value == 7. assert c['fruit'] == {'apples', 'oranges', 'pears', 'grapes', 'cherries'} d = processor.defaultdict_accumulator(lambda: processor.accumulator(0.)) d['x'] = processor.accumulator(0.) d['x'] += 4. d['y'] += 5. d['z'] += d['x'] d['x'] += d['y'] assert d['x'].value == 9. assert d['y'].value == 5. assert d['z'].value == 4. assert d['w'].value == 0. e = d + c f = processor.defaultdict_accumulator(lambda: 2.) f['x'] += 4. assert f['x'] == 6. f += f assert f['x'] == 12. assert f['y'] == 2.
def get_pileup(item): dataset, filename = item file = uproot.open(filename) puhist = file["Pu"] pileup = processor.value_accumulator(partial(np.zeros, puhist.values.size)) pileup += puhist.values sumwhist = file["SumWeights"] sumw = processor.value_accumulator(int) sumw += sumwhist.values[0] return processor.dict_accumulator({ 'pileup': processor.dict_accumulator({dataset: pileup}), 'sumw': processor.dict_accumulator({dataset: sumw}), })
def setupHistogram(self,cuts): histograms = {} for cutName,cut in cuts.items(): for histName,histDetail in variables.items(): histograms['h_{}{}'.format(histName,cutName)] = hist.Hist('h_{}{}'.format(histName,cutName), hist.Bin("val", histDetail[0], histDetail[1], histDetail[2], histDetail[3])) self._accumulator = processor.dict_accumulator(histograms) self.setupHistos = True
def __init__(self): # we can use a large number of bins and rebin later dataset_axis = hist.Cat("dataset", "Primary dataset") pt_axis = hist.Bin("pt", r"$p_{T}$ (GeV)", 600, 0, 1000) eta_axis = hist.Bin("eta", r"$\eta$", 60, -5.5, 5.5) multiplicity_axis = hist.Bin("multiplicity", r"N", 20, -0.5, 19.5) self._accumulator = processor.dict_accumulator({ "MET_pt" : hist.Hist("Counts", dataset_axis, pt_axis), "Jet_pt" : hist.Hist("Counts", dataset_axis, pt_axis), "Jet_pt_fwd" : hist.Hist("Counts", dataset_axis, pt_axis), "Jet_eta" : hist.Hist("Counts", dataset_axis, eta_axis), "GenJet_pt_fwd" : hist.Hist("Counts", dataset_axis, pt_axis), "Spectator_pt" : hist.Hist("Counts", dataset_axis, pt_axis), "Spectator_eta" : hist.Hist("Counts", dataset_axis, eta_axis), "W_pt_notFromTop" : hist.Hist("Counts", dataset_axis, pt_axis), "Top_pt" : hist.Hist("Counts", dataset_axis, pt_axis), "Top_eta" : hist.Hist("Counts", dataset_axis, eta_axis), "Antitop_pt" : hist.Hist("Counts", dataset_axis, pt_axis), "Antitop_eta" : hist.Hist("Counts", dataset_axis, eta_axis), "W_pt" : hist.Hist("Counts", dataset_axis, pt_axis), "W_eta" : hist.Hist("Counts", dataset_axis, eta_axis), "N_b" : hist.Hist("Counts", dataset_axis, multiplicity_axis), "N_jet" : hist.Hist("Counts", dataset_axis, multiplicity_axis), 'cutflow_bkg': processor.defaultdict_accumulator(int), 'cutflow_signal': processor.defaultdict_accumulator(int), })
def __init__(self, year=2016, variations=[], accumulator={}, debug=False): self.variations = variations self.year = year self.debug = debug self.btagSF = btag_scalefactor(year) self._accumulator = processor.dict_accumulator(accumulator)
def __init__(self): # Create the histograms self._accumulator = processor.dict_accumulator({ 'dummy': hist.Hist("Dummy", hist.Cat("sample", "sample"), hist.Bin("dummy", "Number of events", 1, 0, 1)), })
def __init__(self, era=2018): datasets_axis = hist.Cat("dataset", "Signal Model") category_axis = hist.Cat("region", "Lepton category") sys_axis = hist.Cat("syst", "systematic variation") MT1_axis = hist.Bin("MT1", r"$M_{T,1}$ [GeV]", 500, 0, 2000) MT2_axis = hist.Bin("MT2", r"$M_{T,2}$ [GeV]", 500, 0, 2000) MT3_axis = hist.Bin("MT3", r"$M_{T,3}$ [GeV]", 500, 0, 2000) ST1_axis = hist.Bin("ST1", r"$S_{T,1}$ [GeV]", 500, 0, 2000) MET_axis = hist.Bin("MET", r"$E_{T}^{miss}$ [GeV]", 500, 0, 2000) RT1_axis = hist.Bin("RT1", r"$R_{T}$", 500, 0, 200) self._accumulator = processor.dict_accumulator({ 'MET': hist.Hist("Events", datasets_axis, category_axis, MET_axis), 'MT1': hist.Hist("Events", datasets_axis, category_axis, MT1_axis), 'MT2': hist.Hist("Events", datasets_axis, category_axis, MT2_axis), 'MT3': hist.Hist("Events", datasets_axis, category_axis, MT3_axis), 'RT1': hist.Hist("Events", datasets_axis, category_axis, RT1_axis), 'cutflow': processor.defaultdict_accumulator(int), }) with open(f"{os.path.dirname(__file__)}/xsections_{era}.yaml") as stream: self.xsections = yaml.safe_load(stream) self.lumi = { 2016: 35.9, 2017: 41.5, 2018: 60.0 }[era]
def __init__(self): ## make binning for hists self.dataset_axis = hist.Cat("dataset", "Event Process") self.jetmult_axis = hist.Cat("jmult", "nJets") self.leptype_axis = hist.Cat("leptype", "Lepton Type") self.lepcat_axis = hist.Cat("lepcat", "Lepton Category") self.btag_axis = hist.Cat("btag", "btagging Category") self.lepIso_axis = hist.Bin("iso", "pfRelIso", 2000, 0., 20.) self.mtt_axis = hist.Bin("mtt", "m($t\overline{t}$) [GeV]", 180, 200, 2000) self.ctstar_axis = hist.Bin("ctstar", "cos($\\theta^{*}$)", 200, -1., 1.) ## make dictionary of hists histo_dict = {} ## make jet hists hists = self.make_hists() histo_dict.update(hists) histo_dict['cutflow'] = processor.defaultdict_accumulator(int) self._accumulator = processor.dict_accumulator(histo_dict) self.sample_name = '' self.corrections = corrections self.isData = True
def __init__(self): self._accumulator = processor.dict_accumulator({ "j1pt":processor.column_accumulator(np.array([])), "j1phi":processor.column_accumulator(np.array([])), "j1eta":processor.column_accumulator(np.array([])), "j1mass":processor.column_accumulator(np.array([])), "j2pt":processor.column_accumulator(np.array([])), "j2phi":processor.column_accumulator(np.array([])), "j2eta":processor.column_accumulator(np.array([])), "j2mass":processor.column_accumulator(np.array([])), "j3pt":processor.column_accumulator(np.array([])), "j3phi":processor.column_accumulator(np.array([])), "j3eta":processor.column_accumulator(np.array([])), "j3mass":processor.column_accumulator(np.array([])), "dR12":processor.column_accumulator(np.array([])), "dR13":processor.column_accumulator(np.array([])), "dR23":processor.column_accumulator(np.array([])), "j1btag":processor.column_accumulator(np.array([])), "j2btag":processor.column_accumulator(np.array([])), "j3btag":processor.column_accumulator(np.array([])), "j1area":processor.column_accumulator(np.array([])), "j2area":processor.column_accumulator(np.array([])), "j3area":processor.column_accumulator(np.array([])), "j12deta":processor.column_accumulator(np.array([])), "j23deta":processor.column_accumulator(np.array([])), "j13deta":processor.column_accumulator(np.array([])), "j12dphi":processor.column_accumulator(np.array([])), "j23dphi":processor.column_accumulator(np.array([])), "j13dphi":processor.column_accumulator(np.array([])), "j1j2mass":processor.column_accumulator(np.array([])), "j2j3mass":processor.column_accumulator(np.array([])), "j1j3mass":processor.column_accumulator(np.array([])), "event":processor.column_accumulator(np.array([])), "truth":processor.column_accumulator(np.array([])) }) print("done")
def __init__(self, isMC): self._isMC = isMC # Histograms dataset_axis = hist.Cat("dataset", "Primary dataset") selection_axis = hist.Cat("selection", "Selection name") self._accumulator = processor.dict_accumulator() self._accumulator["total_events"] = processor.defaultdict_accumulator( int) # Define histograms here self._accumulator["mjjj"] = hist.Hist( "Events", dataset_axis, selection_axis, hist.Bin("mjjj", r"$M_{jjj}$ [GeV]", dijet_binning), ) for pair in [(0, 1), (1, 2), (2, 0)]: self._accumulator[f"m{pair[0]}{pair[1]}"] = hist.Hist( "Events", dataset_axis, selection_axis, hist.Bin(f"m{pair[0]}{pair[1]}", f"$m_{{{pair[0]}{pair[1]}}}$ [GeV]", dijet_binning)) self._accumulator[f"dR{pair[0]}{pair[1]}"] = hist.Hist( "Events", dataset_axis, selection_axis, hist.Bin(f"dR{pair[0]}{pair[1]}", f"$\\Delta R_{{{pair[0]}{pair[1]}}}$ [GeV]", 100, 0., 4)) self._accumulator[f"dEta{pair[0]}{pair[1]}"] = hist.Hist( "Events", dataset_axis, selection_axis, hist.Bin(f"dEta{pair[0]}{pair[1]}", f"$\\Delta \\eta_{{{pair[0]}{pair[1]}}}$ [GeV]", 100, 0., 2)) self._accumulator[f"m{pair[0]}{pair[1]}overM"] = hist.Hist( "Events", dataset_axis, selection_axis, hist.Bin( f"m{pair[0]}{pair[1]}overM", r"$m_{{{pair0}{pair1}}}/M_{{jjj}}$".format(T="T", pair0=pair[0], pair1=pair[1], jjj="jjj"), 100, 0, 1)) for jet in [0, 1, 2]: self._accumulator[f"pt{jet}"] = hist.Hist( "Events", dataset_axis, selection_axis, hist.Bin(f"pt{jet}", r"$p^{T}_{jet}$ [GeV]".format(T="T", jet=jet), dijet_binning)) self._accumulator[f"eta{jet}"] = hist.Hist( "Events", dataset_axis, selection_axis, hist.Bin(f"eta{jet}", f"$\\eta_{jet}$", 100, -3, 3)) self._accumulator[f"ptoverM{jet}"] = hist.Hist( "Events", dataset_axis, selection_axis, hist.Bin( f"ptoverM{jet}", r"$p^{T}_{jet}/M_{{jjj}}$".format(T="T", jet=jet, jjj="jjj"), 100, 0, 2.5))
def get_accumulator(): dataset_ax = Cat("dataset", "Primary dataset") region_ax = Cat("region", "Selection region") mjj_ax = Bin("mjj", r"$M_{jj}$ (GeV)", 150, 0, 7500) jet_pt_ax = Bin("jetpt", r"$p_{T}$ (GeV)", 100, 0, 1000) jet_eta_ax = Bin("jeteta", r"$\eta$", 50, -5, 5) jet_phi_ax = Bin("jetphi", r"$\phi$", 50, -np.pi, np.pi) ht_ax = Bin("ht", r"$H_{T}$ (GeV)", 100, 0, 4000) items = {} items['sumw'] = processor.defaultdict_accumulator(float) items['sumw2'] = processor.defaultdict_accumulator(float) items["ak4_pt0"] = Hist("Counts", dataset_ax, region_ax, jet_pt_ax) items["ak4_eta0"] = Hist("Counts", dataset_ax, region_ax, jet_eta_ax) items["ak4_phi0"] = Hist("Counts", dataset_ax, region_ax, jet_phi_ax) items["ak4_pt1"] = Hist("Counts", dataset_ax, region_ax, jet_pt_ax) items["ak4_eta1"] = Hist("Counts", dataset_ax, region_ax, jet_eta_ax) items["ak4_phi1"] = Hist("Counts", dataset_ax, region_ax, jet_phi_ax) items["mjj"] = Hist("Counts", dataset_ax, region_ax, mjj_ax) items["ht"] = Hist("Counts", dataset_ax, region_ax, ht_ax) items["htmiss"] = Hist("Counts", dataset_ax, region_ax, ht_ax) return processor.dict_accumulator(items)
def __init__(self, data_type='data'): self.data_type = data_type self._accumulator = processor.dict_accumulator({ 'run_1': processor.column_accumulator(np.zeros(shape=(0, ))), 'lumi_1': processor.column_accumulator(np.zeros(shape=(0, ))), 'event_1': processor.column_accumulator(np.zeros(shape=(0, ))), 'run_2': processor.column_accumulator(np.zeros(shape=(0, ))), 'lumi_2': processor.column_accumulator(np.zeros(shape=(0, ))), 'event_2': processor.column_accumulator(np.zeros(shape=(0, ))), 'era_1': processor.column_accumulator(np.zeros(shape=(0, ))), 'era_2': processor.column_accumulator(np.zeros(shape=(0, ))), }) self.pucorrs = get_pu_weights_function() ## NOT applied for now self.nlo_w = get_nlo_weight_function('w') self.nlo_z = get_nlo_weight_function('z')
def __init__(self, region='SR', data_type='bkg'): self.region = region self.data_type = data_type dataset_axis = hist.Cat('dataset', 'dataset') pt_axis = hist.Bin('pt', '$p_T$ [GeV]', 100, 0, 200) invm_axis = hist.Bin('invm', 'mass [GeV]', 100, 0, 200) mass_axis = hist.Bin('mass', 'mass [GeV]', 100, 0, 200) channel_axis = hist.Bin('channel', 'channel', 3, 0, 3) self._accumulator = processor.dict_accumulator({ 'pt0': hist.Hist('Counts', dataset_axis, pt_axis, channel_axis), 'pt1': hist.Hist('Counts', dataset_axis, pt_axis, channel_axis), 'ptegm': hist.Hist('Counts', dataset_axis, pt_axis, channel_axis), # leading EGM-type for 2mu2e channel 'ptmu': hist.Hist('Counts', dataset_axis, pt_axis, channel_axis), # leading mu-type for 2mu2e channel 'invm': hist.Hist('Counts', dataset_axis, invm_axis, channel_axis), 'massmu': hist.Hist('Counts', dataset_axis, mass_axis, channel_axis), # mass of mu-type leptonjet }) self.pucorrs = get_pu_weights_function() ## NOT applied for now self.nlo_w = get_nlo_weight_function('w') self.nlo_z = get_nlo_weight_function('z')
def __init__(self, category='00'): self.category = category dataset_axis = hist.Cat('dataset', 'dataset') self._accumulator = processor.dict_accumulator({ 'dphi': processor.column_accumulator(np.zeros(shape=(0, ))), })
def __init__(self, year='2018', corrections={}): self._year = year self._corrections = corrections self._rochester = lookup_tools.rochester_lookup.rochester_lookup( corrections['rochester_data']) dataset_axis = hist.Cat("dataset", "Primary dataset") channel_axis = hist.Cat("channel", "Channel") zmass_axis = hist.Bin("mass", r"$m_{2\ell}$ [GeV]", 240, 0, 120) met_axis = hist.Bin("met", r"$E_{T}^{miss}$ [GeV]", 3000, 0, 3000) npvs_axis = hist.Bin("npvs", "Number of Vertices", 120, 0, 120) self._selections = ['massWindow'] hist.Hist.DEFAULT_DTYPE = 'f' # save some space by keeping float bin counts instead of double self._accumulator = processor.dict_accumulator() for sel in self._selections: self._accumulator[sel + '_zmass'] = hist.Hist( "Counts", dataset_axis, channel_axis, zmass_axis) self._accumulator[sel + '_met'] = hist.Hist( "Counts", dataset_axis, channel_axis, met_axis) self._accumulator[sel + '_pileup'] = hist.Hist( "Counts", dataset_axis, channel_axis, npvs_axis) self._accumulator['cutflow'] = processor.defaultdict_accumulator(int) self._accumulator['sumw'] = processor.defaultdict_accumulator(int)
def __init__(self, data_type='bkg', bothNeutral=True): dataset_axis = hist.Cat('dataset', 'dataset') sumpt_axis = hist.Bin('sumpt', '$\sum p_T$ [GeV]', 50, 0, 50) iso_axis = hist.Bin('iso', 'Isolation', np.arange(0, 1, 0.04)) channel_axis = hist.Bin('channel', 'channel', 3, 0, 3) self._accumulator = processor.dict_accumulator({ 'sumpt': hist.Hist('Counts', dataset_axis, sumpt_axis, channel_axis), 'pfiso': hist.Hist('Counts', dataset_axis, iso_axis, channel_axis), 'isodbeta': hist.Hist('Counts', dataset_axis, iso_axis, channel_axis), 'minpfiso': hist.Hist('Counts', dataset_axis, iso_axis, channel_axis), 'maxpfiso': hist.Hist('Counts', dataset_axis, iso_axis, channel_axis), 'lj0pfiso': hist.Hist('Counts', dataset_axis, iso_axis, channel_axis), }) self.pucorrs = get_pu_weights_function() ## NOT applied for now self.nlo_w = get_nlo_weight_function('w') self.nlo_z = get_nlo_weight_function('z') self.data_type = data_type self.bothNeutral = bothNeutral
def __init__(self): ## load b-tag SFs #self.btag_sf = BTagScaleFactor(os.path.expandvars("$TWHOME/data/DeepCSV_102XSF_V1.btag.csv.gz", "reshape") # we can use a large number of bins and rebin later dataset_axis = hist.Cat("dataset", "Primary dataset") pt_axis = hist.Bin("pt", r"$p_{T}$ (GeV)", 1000, 0, 1000) self._accumulator = processor.dict_accumulator({ 'diboson': processor.defaultdict_accumulator(int), 'ttbar': processor.defaultdict_accumulator(int), 'TTW': processor.defaultdict_accumulator(int), 'TTZ': processor.defaultdict_accumulator(int), 'TTH': processor.defaultdict_accumulator(int), 'TTTT': processor.defaultdict_accumulator(int), 'tW_scattering': processor.defaultdict_accumulator(int), 'DY': processor.defaultdict_accumulator(int), 'totalEvents': processor.defaultdict_accumulator(int), 'passedEvents': processor.defaultdict_accumulator(int), })
def __init__(self, year, ids, xsec, common): self._year = year self._lumi = 1000. * float(PhotonPurity.lumis[year]) self._xsec = xsec self._accumulator = processor.dict_accumulator({ 'sumw': hist.Hist('sumw', hist.Cat('dataset', 'Dataset'), hist.Bin('sumw', 'Weight value', [0.])), 'count': hist.Hist('Events', hist.Cat('dataset', 'Dataset'), hist.Cat('cat', 'Cat'), hist.Bin('pt', 'Photon pT', 50, 200, 1200), hist.Bin('sieie', 'sieie', 100, 0, 0.02)) }) self._singlephoton_triggers = { '2016': ['Photon175', 'Photon165_HE10'], '2017': ['Photon200'], '2018': ['Photon200'] } self._ids = ids self._common = common
def __init__(self, analyzer_name, analysis_type): self.analyzer_name = analyzer_name self.analysis_type = analysis_type self._accumulator = processor.dict_accumulator({ 'cutflow': processor.defaultdict_accumulator(int), })
def __init__(self): # dataset_axis = hist.Cat("dataset", "Primary dataset") # pt_axis = hist.Bin("pt", r"$p_{T}$ [GeV]", 40, 0, 3500) ntrack_axis = hist.Bin("ntracks", "Number of Tracks", 20, 0.0, 500.0) njet_axis = hist.Bin("njets", "Number of Jets", 20, 0.0, 20.0) ht_axis = hist.Bin("ht", "H_{T} (GeV)", 500, 0.0, 5000.0) st_axis = hist.Bin("st", "S_{T} (GeV)", 500, 0.0, 5000.0) met_axis = hist.Bin("MET", "E_{T}^{miss} (GeV)", 200, 0.0, 2000.0) self._accumulator = processor.dict_accumulator({ # 'jtpt':hist.Hist("Counts", dataset_axis, pt_axis), # 'jteta':hist.Hist("Counts",dataset_axis,eta_axis), 'h_ntracks': hist.Hist("h_ntracks", ntrack_axis), 'h_njets': hist.Hist("h_njets", njet_axis), 'h_ht': hist.Hist("h_ht", ht_axis), 'h_st': hist.Hist("h_st", st_axis), 'h_met': hist.Hist("h_met", met_axis), 'cutflow': processor.defaultdict_accumulator(int), 'trigger': processor.defaultdict_accumulator(int), })
def __init__(self, isMC, era=2017, sample="DY", do_syst=False, syst_var='', weight_syst=False, haddFileName=None, flag=False): self._flag = flag self.do_syst = do_syst self.era = era self.isMC = isMC self.sample = sample self.syst_var, self.syst_suffix = ( syst_var, f'_sys_{syst_var}') if do_syst and syst_var else ('', '') self.weight_syst = weight_syst self._accumulator = dict_accumulator({ name: Hist('Events', Bin(name=name, **axis)) for name, axis in ((self.naming_schema(hist['name'], region), hist['axis']) for _, hist in list(self.histograms.items()) for region in hist['region']) }) self.outfile = haddFileName
def __init__(self, samples, binning): self.binning = binning ## Scale Factors self._accumulator = processor.dict_accumulator({ s: accumulators.HistAccumulator(binning.shape[0] - 1) for s in samples })
def __init__(self, year): self._year = year self._trigger = { 2016: { "e": [ "Ele27_WPTight_Gsf", "Ele45_WPLoose_Gsf", "Ele25_eta2p1_WPTight_Gsf", "Ele115_CaloIdVT_GsfTrkIdT", "Ele15_IsoVVL_PFHT350", "Ele15_IsoVVVL_PFHT400", "Ele45_CaloIdVT_GsfTrkIdT_PFJet200_PFJet50", "Ele50_CaloIdVT_GsfTrkIdT_PFJet165", ], "mu": [ "IsoMu24", "IsoTkMu24", "Mu50", "TkMu50", "Mu15_IsoVVVL_PFHT400", "Mu15_IsoVVVL_PFHT350", ], } } self._trigger = self._trigger[int(self._year)] self._accumulator = processor.dict_accumulator({ 'sumw': processor.defaultdict_accumulator(float), 'cutflow': hist.Hist( 'Events', hist.Cat('dataset', 'Dataset'), hist.Cat('channel', 'Channel'), hist.Bin('cut', 'Cut index', 9, 0, 9), ), })
def __init__(self, year, wp): self._year = year self._btagWPs = wp self._accumulator = processor.dict_accumulator({ 'deepflav': hist.Hist( 'Events', hist.Cat('dataset', 'Dataset'), hist.Cat('wp', 'Working point'), hist.Cat('btag', 'BTag WP pass/fail'), hist.Bin('flavor', 'Jet hadronFlavour', [0, 4, 5, 6]), hist.Bin('pt', 'Jet pT', [20, 30, 50, 70, 100, 140, 200, 300, 600, 1000]), hist.Bin('abseta', 'Jet abseta', [0, 1.4, 2.0, 2.5]), ), 'deepcsv': hist.Hist( 'Events', hist.Cat('dataset', 'Dataset'), hist.Cat('wp', 'Working point'), hist.Cat('btag', 'BTag WP pass/fail'), hist.Bin('flavor', 'Jet hadronFlavour', [0, 4, 5, 6]), hist.Bin('pt', 'Jet pT', [20, 30, 50, 70, 100, 140, 200, 300, 600, 1000]), hist.Bin('abseta', 'Jet abseta', [0, 1.4, 2.0, 2.5]), ) })
def __init__(self, dphi_control=False, data_type='sig'): self.dphi_control = dphi_control self.data_type = data_type dataset_axis = hist.Cat('dataset', 'dataset') self._accumulator = processor.dict_accumulator({ 'all05': processor.column_accumulator(np.zeros(shape=(0, ))), 'nopu05': processor.column_accumulator(np.zeros(shape=(0, ))), 'dbeta': processor.column_accumulator(np.zeros(shape=(0, ))), 'all05w': processor.column_accumulator(np.zeros(shape=(0, ))), 'nopu05w': processor.column_accumulator(np.zeros(shape=(0, ))), 'dbetaw': processor.column_accumulator(np.zeros(shape=(0, ))), 'pt': processor.column_accumulator(np.zeros(shape=(0, ))), 'eta': processor.column_accumulator(np.zeros(shape=(0, ))), 'wgt': processor.column_accumulator(np.zeros(shape=(0, ))), 'ljtype': processor.column_accumulator(np.zeros(shape=(0, ))), 'channel': processor.column_accumulator(np.zeros(shape=(0, ))), }) self.pucorrs = get_pu_weights_function() ## NOT applied for now self.nlo_w = get_nlo_weight_function('w') self.nlo_z = get_nlo_weight_function('z')
def __init__(self): ## make binning for hists self.dataset_axis = hist.Cat("dataset", "Event Process") self.pu_nTrueInt_axis = hist.Bin("pu_nTrueInt", "nTrueInt", 100, 0, 100) self.pu_nPU_axis = hist.Bin("pu_nPU", "nPU", 100, 0, 100) ## make dictionary of hists histo_dict = {} histo_dict['PU_nTrueInt'] = hist.Hist("PU_nTrueInt", self.dataset_axis, self.pu_nTrueInt_axis) histo_dict['PU_nPU'] = hist.Hist("PU_nPU", self.dataset_axis, self.pu_nPU_axis) #set_trace() ## construct dictionary of dictionaries to hold meta info for each sample for sample in fileset.keys(): if 'Int' in sample: histo_dict['%s_pos' % sample] = processor.defaultdict_accumulator(int) histo_dict['%s_pos_runs_to_lumis' % sample] = processor.value_accumulator(list) histo_dict['%s_neg' % sample] = processor.defaultdict_accumulator(int) histo_dict['%s_neg_runs_to_lumis' % sample] = processor.value_accumulator(list) else: histo_dict[sample] = processor.defaultdict_accumulator(int) histo_dict['%s_runs_to_lumis' % sample] = processor.value_accumulator(list) self._accumulator = processor.dict_accumulator(histo_dict) self.sample_name = ''