ref_jet = c[0] if plan1RefJet else c[1] if ref_jet['eta'] > 1.1 and ref_jet['eta'] < 3.2: if ref_jet['phi'] > -1.07 and ref_jet['phi'] < -0.32: NHEF_HEP17.Fill(c[0]['j'].neutralHadronEnergyFraction()) else: NHEF_nonHEP17.Fill(c[0]['j'].neutralHadronEnergyFraction()) if ref_jet['eta'] > 1.1 and ref_jet['eta'] < 3.2 and ref_jet[ 'phi'] > -1.07 and ref_jet['phi'] < -0.32: resp_pt.Fill(ref_jet['pt'], r) else: resp_pt_ref.Fill(ref_jet['pt'], r) if not ref_jet['pt'] > pt_threshold: continue if not (helpers.jetID(c[0]['j']) and helpers.jetID(c[1]['j'])): continue # 2D eta, phi resp_eta_phi.Fill(ref_jet['eta'], ref_jet['phi'], r) # inclusive eta resp_eta.Fill(ref_jet['eta'], r) isHEP17 = (ref_jet['phi'] > phi_low and ref_jet['phi'] < phi_high) if isHEP17: resp_eta_HEP17.Fill(ref_jet['eta'], r) else: resp_eta_nonHEP17.Fill(ref_jet['eta'], r) for eta_th in eta_thresholds:
ref_jet = c[0] if plan1RefJet else c[1] if ref_jet['eta']>1.1 and ref_jet['eta']<3.2: if ref_jet['phi']>-1.07 and ref_jet['phi']<-0.32: NHEF_HEP17.Fill(c[0]['j'].neutralHadronEnergyFraction()) else: NHEF_nonHEP17.Fill(c[0]['j'].neutralHadronEnergyFraction()) if ref_jet['eta']>1.1 and ref_jet['eta']<3.2 and ref_jet['phi']>-1.07 and ref_jet['phi']<-0.32: resp_pt.Fill( ref_jet['pt'], r ) else: resp_pt_ref.Fill( ref_jet['pt'], r ) if not ref_jet['pt']>pt_threshold: continue if not ( helpers.jetID(c[0]['j']) and helpers.jetID(c[1]['j']) ): continue # 2D eta, phi resp_eta_phi.Fill( ref_jet['eta'], ref_jet['phi'], r ) # inclusive eta resp_eta.Fill( ref_jet['eta'], r ) isHEP17 = ( ref_jet['phi'] > phi_low and ref_jet['phi']<phi_high ) if isHEP17: resp_eta_HEP17.Fill( ref_jet['eta'], r ) else: resp_eta_nonHEP17.Fill( ref_jet['eta'], r ) for eta_th in eta_thresholds: if ref_jet['eta']>=eta_th[0] and ref_jet['eta']<eta_th[1]:
ref_jet = c[0] if plan1RefJet else c[1] if ref_jet['eta']>1.1 and ref_jet['eta']<3.2: if ref_jet['phi']>-1.07 and ref_jet['phi']<-0.32: NHEF_HEP17.Fill(c[0]['j'].neutralHadronEnergyFraction()) else: NHEF_nonHEP17.Fill(c[0]['j'].neutralHadronEnergyFraction()) if ref_jet['eta']>1.1 and ref_jet['eta']<3.2 and ref_jet['phi']>-1.07 and ref_jet['phi']<-0.32: resp_pt.Fill( ref_jet['pt'], r ) else: resp_pt_ref.Fill( ref_jet['pt'], r ) if not ref_jet['pt']>pt_threshold: continue if not ( helpers.jetID(c[0]['j']) and helpers.jetID(c[1]['j']) ): continue # 2D eta, phi resp_eta_phi.Fill( ref_jet['eta'], ref_jet['phi'], r ) # inclusive eta resp_eta.Fill( ref_jet['eta'], r ) isHEP17 = ( ref_jet['phi'] > phi_low and ref_jet['phi']<phi_high ) if isHEP17: resp_eta_HEP17.Fill( ref_jet['eta'], r ) else: resp_eta_nonHEP17.Fill( ref_jet['eta'], r ) for eta_th in eta_thresholds: if ref_jet['eta']>=eta_th[0] and ref_jet['eta']<eta_th[1]:
# Fast intersect intersec = set(position_r1.keys()).intersection(set(position_r2.keys())) positions = [(position_r1[i], position_r2[i]) for i in intersec] # Without sorting, there is a jump between files with almost every event -> extremly slow positions.sort() logger.info("Have %i events in common.", len(intersec)) #Looping over common events for i, p in enumerate(positions): p1,p2 = p r1.goToPosition(p1) r2.goToPosition(p2) if i%10000==0: logger.info("At %i/%i of common events.", i, len(positions)) jets1_ = [ j for j in r1.products['jets'] if helpers.jetID( j )] jets2_ = [ j for j in r2.products['jets'] if helpers.jetID( j )] jets1 = [{'pt':j.pt(), 'eta':j.eta(), 'phi':j.phi(), 'j':j} for j in jets1_] jets2 = [{'pt':j.pt(), 'eta':j.eta(), 'phi':j.phi(), 'j':j} for j in jets2_] for c in zip(jets1, jets2): if helpers.deltaR2(*c)<0.2**2: if not ( helpers.jetID(c[0]['j']) and helpers.jetID(c[1]['j']) ): continue for eta_th in reversed(eta_thresholds): if abs(c[0]['eta'])>eta_th: resp[eta_th].Fill( c[0]['pt'], c[0]['pt']/c[1]['pt'] ) break # Make plot profiles = [resp[t] for t in eta_thresholds] #profiles = [ jetResponse_NJC] prefix=preprefix+"_max_events_%s_"%max_events if max_events is not None and max_events>0 else ""
# 'pfClusters':{'type':"vector<reco::PFCluster>", 'label':("particleFlowClusterHBHE")}, # 'pfRecHits': {'type':"vector<reco::PFRecHit>", 'label':("particleFlowRecHitHBHE")}, } for sample in [spring16, moriond17]: r1 = sample.fwliteReader( products = products ) r1.start() i=0 while r1.run(): # pt_hat = r1.products['genInfo'].binningValues()[0] # if i%10000==0: logger.info("At %i", i) # if not (pt_hat > pt_hat_min and pt_hat <pt_hat_max): continue #id_jets = [ j.correctedJet("Uncorrected") for j in r1.products['jets'] if helpers.jetID( j )] id_jets = [ j for j in r1.products['jets'] if helpers.jetID( j )] for j in id_jets: gj = j.genJet() if gj: for eta_th in reversed(eta_thresholds): if abs(gj.eta())>eta_th: resp[sample.name][eta_th].Fill( gj.pt(), j.pt() / gj.pt() ) #print eta_th, gj.eta(), j.pt(), gj.pt() break i+=1 if i>max_events: break ## Make plot
for i_pt_bin, pt_bin in enumerate(pt_bins): njet[s.name][abs_eta_bin][pt_bin] = ROOT.TH1D("njet", "njet", 10,0,10 ) njet[s.name][abs_eta_bin][pt_bin].style = styles.lineStyle(colors[i_pt_bin], dashed = (s.name==sample_ZN.name), errors = True ) njet[s.name][abs_eta_bin][pt_bin].legendText = "%s %i #geq p_{T} < %i"% ( (s.name,) + pt_bin ) products = { 'jets': {'type':'vector<pat::Jet>', 'label':("slimmedJets")}, 'genInfo': {'type':' GenEventInfoProduct', 'label': "generator"}, } for sample in samples: r1 = sample.fwliteReader( products = products ) r1.start() i=0 while r1.run(): id_jets = [ j.correctedJet("Uncorrected") for j in r1.products['jets'] if helpers.jetID( j )] njet_counter={abs_eta_bin:{pt_bin:0 for pt_bin in pt_bins} for abs_eta_bin in abs_eta_bins} for j in id_jets: abseta = abs(j.eta()) pt = j.pt() for i_abs_eta_bin, abs_eta_bin in enumerate(abs_eta_bins): if abseta>abs_eta_bin[0] and abseta<=abs_eta_bin[1]: for i_pt_bin, pt_bin in enumerate(pt_bins): if pt>pt_bin[0] and pt<=pt_bin[1]: njet_counter[abs_eta_bin][pt_bin] +=1 for i_abs_eta_bin, abs_eta_bin in enumerate(abs_eta_bins): for i_pt_bin, pt_bin in enumerate(pt_bins): njet[sample.name][abs_eta_bin][pt_bin].Fill( njet_counter[abs_eta_bin][pt_bin] ) i+=1
products = { 'jets': {'type':'vector<pat::Jet>', 'label':("slimmedJets")}, 'genInfo': {'type':' GenEventInfoProduct', 'label': "generator"}, 'rho': {'type':'double', 'label':"fixedGridRhoFastjetAll"}, } r1 = sample.fwliteReader( products = products ) r1.start() i=0 while r1.run(): #pt_hat = r1.products['genInfo'].binningValues()[0] #if i%10000==0: logger.info("At %i", i) #if not (pt_hat > pt_hat_min and pt_hat <pt_hat_max): continue id_jets = [ j.correctedJet("Uncorrected") for j in r1.products['jets'] if helpers.jetID( j )] for j in id_jets: gj = j.genJet() if gj and helpers.deltaR2({'eta':gj.eta(), 'phi':gj.phi()}, {'eta':j.eta(), 'phi':j.phi()}) < 0.2**2: jet_corr_factor = jetCorrector_mc.correction( j.pt(), j.eta(), j.jetArea(), r1.products['rho'][0], 1 ) for eta_th in reversed(eta_thresholds): if abs(gj.eta())>eta_th: resp[eta_th].Fill( gj.pt(), j.pt()*jet_corr_factor / gj.pt() ) #print eta_th, gj.eta(), j.pt(), gj.pt() break i+=1 if i>max_events: break
# 'pfClusters':{'type':"vector<reco::PFCluster>", 'label':("particleFlowClusterHBHE")}, # 'pfRecHits': {'type':"vector<reco::PFRecHit>", 'label':("particleFlowRecHitHBHE")}, } for sample in [spring16, moriond17]: r1 = sample.fwliteReader(products=products) r1.start() i = 0 while r1.run(): # pt_hat = r1.products['genInfo'].binningValues()[0] # if i%10000==0: logger.info("At %i", i) # if not (pt_hat > pt_hat_min and pt_hat <pt_hat_max): continue #id_jets = [ j.correctedJet("Uncorrected") for j in r1.products['jets'] if helpers.jetID( j )] id_jets = [j for j in r1.products['jets'] if helpers.jetID(j)] for j in id_jets: gj = j.genJet() if gj: for eta_th in reversed(eta_thresholds): if abs(gj.eta()) > eta_th: resp[sample.name][eta_th].Fill(gj.pt(), j.pt() / gj.pt()) #print eta_th, gj.eta(), j.pt(), gj.pt() break i += 1 if i > max_events: break ## Make plot #profiles = [resp["spring16"][t] for t in eta_thresholds] + [resp["moriond17"][t] for t in eta_thresholds]
'label': "generator" }, } for sample in [new, old]: r1 = sample.fwliteReader(products=products) r1.start() i = 0 while r1.run(): #pt_hat = r1.products['genInfo'].binningValues()[0] #if i%10000==0: logger.info("At %i", i) #if not (pt_hat > pt_hat_min and pt_hat <pt_hat_max): continue id_jets = [ j.correctedJet("Uncorrected") for j in r1.products['jets'] if helpers.jetID(j) ] for j in id_jets: gj = j.genJet() if gj: for eta_th in reversed(eta_thresholds): if abs(gj.eta()) > eta_th: resp[sample.name][eta_th].Fill(gj.pt(), j.pt() / gj.pt()) #print eta_th, gj.eta(), j.pt(), gj.pt() break i += 1 if i > max_events: break # Make plot profiles = [resp["old"][t] for t in eta_thresholds