def test_acoplanarity(self): '''test acoplanarity w/r to Patricks implementation ''' ptc1 = Particle(11, -1, TLorentzVector(1, 2, 3, 7)) ptc2 = Particle(-11, 1, TLorentzVector(2, 3, 4, 10)) reso = Resonance(ptc1, ptc2, 23) self.assertEqual(reso.cross(), acop_patrick(reso.leg1(), reso.leg2()))
def test_acoplanarity(self): '''test acoplanarity w/r to Patricks implementation ''' ptc1 = Particle(11, -1, TLorentzVector(1, 2, 3, 7)) ptc2 = Particle(-11, 1, TLorentzVector(2, 3, 4, 10)) reso = Resonance( ptc1, ptc2, 23 ) self.assertEqual(reso.cross(), acop_patrick(reso.leg1(), reso.leg2()))
def beta4_rescale(self): all_jets = list(self.jets2) all_jets.extend(self.taus) jets_rescaled = copy.deepcopy(all_jets) beta4(jets_rescaled, Collider.SQRTS) self.jets2_r = jets_rescaled[:2] self.taus_r = jets_rescaled[2:] self.zed2_r = Resonance2(self.jets2_r[0], self.jets2_r[1], 23, 1) self.higgs_r = Resonance2(self.taus_r[0], self.taus_r[1], 25, 1)
def __init__(self, hid, higgs_jets, zed_jets): self.hid = hid self.higgs_jets = higgs_jets self.zed_jets = zed_jets if self.higgs_jets[0].tags['bfrac'] > 0.05 and \ self.higgs_jets[1].tags['bfrac'] > 0.05: self.is_true = True else: self.is_true = False self.higgs = Resonance2(self.higgs_jets[0], self.higgs_jets[1], 25) self.zed = Resonance2(self.zed_jets[0], self.zed_jets[1], 23)
def process(self, event): zeds = getattr(event, self.cfg_ana.zeds) higgses = getattr(event, self.cfg_ana.higgses) zed = zeds[0] higgs = higgses[0] all_objects = list(zed.legs) all_objects.extend(higgs.legs) all_objects_rescaled = copy.deepcopy(all_objects) beta4(all_objects_rescaled, Collider.SQRTS) zed_legs_r = all_objects_rescaled[:2] higgs_legs_r = all_objects_rescaled[2:] zed_r = Resonance2(zed_legs_r[0], zed_legs_r[1], 23, 1) higgs_r = Resonance2(higgs_legs_r[0], higgs_legs_r[1], 25, 1) setattr(event, self.cfg_ana.zeds+'_r', [zed_r]) setattr(event, self.cfg_ana.higgses+'_r', [higgs_r])
def force_2_jets(self, particles): self.__class__.clusterizer.clear() other_particles = [] for ptc in particles: keep = True for tau in self.taus: if ptc in tau.constituents.particles: keep = False if keep: self.__class__.clusterizer.add_p4(ptc.p4()) other_particles.append(ptc) assert (len(other_particles) + len(self.taus[0].constituents.particles) + len(self.taus[1].constituents.particles) == len(particles)) njets = 2 if len(other_particles) < njets: return False self.__class__.clusterizer.make_exclusive_jets(njets) assert (self.__class__.clusterizer.n_jets() == njets) jets = [] for jeti in range(self.__class__.clusterizer.n_jets()): jet = Jet(self.__class__.clusterizer.jet(jeti)) jet.constituents = JetConstituents() for consti in range( self.__class__.clusterizer.n_constituents(jeti)): constituent_index = self.__class__.clusterizer.constituent_index( jeti, consti) constituent = particles[constituent_index] jet.constituents.append(constituent) jet.constituents.sort() jets.append(jet) self.jets2 = jets self.zed2 = Resonance2(jets[0], jets[1], 23, 1) return True
def __init__(self, taus, jets): qqjetsp = [jet for jet in jets if jet not in taus] # assert(len(qqjetsp) == 2) self.zed = Resonance(qqjetsp, 23, 1) self.higgs = Resonance2(taus[0], taus[1], 25, 1) self.taus = taus self.jets2 = qqjetsp self.zed2 = self.zed
def test_many(self): nzeds = 100 masses = np.linspace(80, 100, nzeds) boosts = np.linspace(1, 50, nzeds) thetas = np.linspace(1, math.pi, nzeds) for mass, boost, theta in zip(masses, boosts, thetas): energy = mass / 2. ptc1 = Particle(11, -1, TLorentzVector(0, energy, 0, energy)) ptc2 = Particle(11, 1, TLorentzVector(0, -energy, 0, energy)) resonance = Resonance(ptc1, ptc2, 23) p3_lab = TVector3() p3_lab.SetMagThetaPhi(boost, theta, 0.1) p4_lab = TLorentzVector() p4_lab.SetVectM(p3_lab, mass) bp4 = copy.deepcopy(resonance.p4()) boost_vector = p4_lab.BoostVector() bp4.Boost(boost_vector) places = 8 self.assertAlmostEqual(bp4.Vect().Mag(), boost, places) self.assertAlmostEqual(bp4.M(), mass, places) resonance.boost(boost_vector) self.assertAlmostEqual(bp4.E(), resonance.e(), places)
def process(self, event): jets = getattr(event, self.cfg_ana.jets) taus = getattr(event, self.cfg_ana.taus) self.counters['cutflow'].inc('All events') if len(taus) < 2: return False self.counters['cutflow'].inc('2 taus') if len(taus) == 3: self.counters['cutflow'].inc('3 taus') elif len(taus) == 4: self.counters['cutflow'].inc('4 taus') dmz = sys.float_info.max higgs = None zed = None besttaus = None bestjets = None first = True for tau1, tau2 in itertools.combinations(taus, 2): qqjetsp = [jet for jet in jets if jet not in [tau1, tau2]] assert (len(qqjetsp) == 2) zedp = Resonance2(qqjetsp[0], qqjetsp[1], 23, 1) dmzp = abs(zedp.m() - 91) if dmzp < dmz or first: first = False # the first flag ensures that the products are # calculated at least once. # rarely (~1 per mil), the rescaling goes completely # wrong and produce very high energy jets, hence # dmz much larger than the starting value dmz = dmzp higgs = Resonance2(tau1, tau2, 25, 1) zed = zedp besttaus = [tau1, tau2] bestjets = list(qqjetsp) setattr(event, 'bestjets', bestjets) setattr(event, 'besttaus', besttaus) setattr(event, 'zedqqs', [zed]) setattr(event, 'higgses', [higgs])
def process(self, event): self.tree.reset() gen_higgses = getattr(event, self.cfg_ana.gen_higgses) self.tree.fill('weight', event.weight) self.tree.fill('nh', len(gen_higgses)) gen_higgses.sort(key=lambda x: x.pt(), reverse=True) if len(gen_higgses) > 1: hh = Resonance(gen_higgses[0], gen_higgses[1], 25) if hh.pt() > 500.: fillParticle(self.tree, 'h1', gen_higgses[0]) fillParticle(self.tree, 'h2', gen_higgses[1]) fillParticle(self.tree, 'hh', hh) drhh = deltaR(gen_higgses[0], gen_higgses[1]) self.tree.fill('drhh', drhh) self.tree.tree.Fill()
def test_resonance(self): ptc1 = Particle(11, -1, TLorentzVector(1, 0, 0, 1)) ptc2 = Particle(-11, 1, TLorentzVector(2, 0, 0, 2)) reso = Resonance(ptc1, ptc2, 23) self.assertEqual(reso._pid, 23) self.assertEqual(reso.e(), 3) self.assertEqual(reso.leg1(), ptc1) self.assertEqual(reso.leg2(), ptc2) self.assertEqual(reso.q(), 0) self.assertEqual(reso.p4(), TLorentzVector(3, 0, 0, 3))
def test_resonance(self): ptc1 = Particle(11, -1, TLorentzVector(1, 0, 0, 1)) ptc2 = Particle(-11, 1, TLorentzVector(2, 0, 0, 2)) reso = Resonance( ptc1, ptc2, 23 ) self.assertEqual( reso._pid, 23 ) self.assertEqual( reso.e(), 3 ) self.assertEqual( reso.leg1(), ptc1 ) self.assertEqual( reso.leg2(), ptc2 ) self.assertEqual( reso.q(), 0 ) self.assertEqual( reso.p4(), TLorentzVector(3,0,0,3) )
def process(self, event): bosons = [ ptc for ptc in event.gen_particles if abs(ptc.pdgid()) in self.cfg_ana.pdgids and ptc.status() in self.cfg_ana.statuses ] if not hasattr(event, 'genbrowser'): event.genbrowser = GenBrowser(event.gen_particles, event.gen_vertices) output = [] for boson in bosons: daughters = event.genbrowser.decay_daughters(boson) assert (len(daughters) == 2) if hasattr(self.cfg_ana, 'decay_pdgids') and \ not ( abs(daughters[0].pdgid()) in self.cfg_ana.decay_pdgids and \ abs(daughters[1].pdgid()) in self.cfg_ana.decay_pdgids ): continue d0, d1 = daughters[0], daughters[1] # putting particle before anti particle if d1.pdgid() > d0.pdgid(): d0, d1 = d1, d0 # but if the 1st particle is neutral, put it at the end (W->lnu) if d0.q() == 0: d0, d1 = d1, d0 resonance = Resonance2(d0, d1, boson.pdgid(), boson.status()) output.append(resonance) output.sort(key=lambda x: x.pdgid()) idstring = '_'.join(map(str, self.cfg_ana.pdgids)) output_name = '_'.join(['gen_bosons', idstring]) # e.g. gen_bosons_23_25 if hasattr(self.cfg_ana, 'output'): output_name = self.cfg_ana.output setattr(event, output_name, output) if self.verbose: print self if not len(output): print 'no boson found' else: for gb in output: print gb pprint.pprint(gb.legs) print
def process(self, event): self.tree.reset() htatas = getattr(event, self.cfg_ana.htatas) hbbs = getattr(event, self.cfg_ana.hbbs) met = event.met htatas.sort(key=lambda x: abs(x.m() - 125.)) hbbs.sort(key=lambda x: abs(x.m() - 125.)) bs = event.selected_bs taus = event.selected_taus lights = event.selected_lights leptons = event.selected_leptons #print '-------------------' #print len(htatas), len(hbbs) #print len(taus), len(bs) #for tau in taus: # print tau.charge #print ROOT.return2() #f = Foo() #f.bar() #and you will see "Hello" on the screen ''' mVisA = 10.; # mass of visible object on side A. Must be >=0. pxA = 20.; # x momentum of visible object on side A. pyA = 30.; # y momentum of visible object on side A. mVisB = 10.; # mass of visible object on side B. Must be >=0. pxB = -20.; # x momentum of visible object on side B. pyB = -30.; # y momentum of visible object on side B. pxMiss = -5.; # x component of missing transverse momentum. pyMiss = -5.; # y component of missing transverse momentum. chiA = 4.; # hypothesised mass of invisible on side A. Must be >=0. chiB = 7.; # hypothesised mass of invisible on side B. Must be >=0. desiredPrecisionOnMt2 = 0.; # Must be >=0. If 0 alg aims for machine precision. if >0, MT2 computed to supplied absolute precision. useDeciSectionsInitially=True asymm_mt2 = asymm_mt2_lester_bisect() print '-----------------------------------------' MT2 = asymm_mt2.get_mT2( mVisA, pxA, pyA, mVisB, pxB, pyB, pxMiss, pyMiss, chiA, chiB, desiredPrecisionOnMt2, useDeciSectionsInitially) print 'MT2', MT2 ''' # fully hadronic selection if len(taus) > 1 and len(bs) > 1 and len(leptons) == 0: self.tree.fill('weight', event.weight) #print event.weight fillParticle(self.tree, 'ta1', taus[0]) fillParticle(self.tree, 'ta2', taus[1]) fillParticle(self.tree, 'b1', bs[0]) fillParticle(self.tree, 'b2', bs[1]) ''' def mTsq(bT, cT, mB, mC): eB = math.sqrt(mB*mB+ bT*bT) eC = math.sqrt(mC*mC+ cT*cT) return mB*mB+mC*mC+2*(eB*eC - bT*cT) def smT2(bt1, bt2): return max(math.sqrt(bt1),math.sqrt(bt2)) mTsq1 = mTsq(taus[0].p4().Vect().XYvector(), bs[0].p4().Vect().XYvector(), taus[0].p4().M(), bs[0].p4().M()) mTsq2 = mTsq(taus[1].p4().Vect().XYvector(), bs[1].p4().Vect().XYvector(), taus[1].p4().M(), bs[1].p4().M()) smTsq = smT2(mTsq1, mTsq2) #print mTsq1, mTsq2, smTsq ''' mVisA = bs[0].p4().M() # mass of visible object on side A. Must be >=0. pxA = bs[0].p4().Px() # x momentum of visible object on side A. pyA = bs[0].p4().Py() # y momentum of visible object on side A. mVisB = bs[1].p4().M() # mass of visible object on side A. Must be >=0. pxB = bs[1].p4().Px() # x momentum of visible object on side A. pyB = bs[1].p4().Py() # y momentum of visible object on side A. pxMiss = taus[0].p4().Px() + taus[1].p4().Px() + met.p4().Px( ) # x component of missing transverse momentum. pyMiss = taus[0].p4().Py() + taus[1].p4().Py() + met.p4().Py( ) # x component of missing transverse momentum. chiA = taus[0].p4().M() # hypothesised mass of invisible on side A. Must be >=0. chiB = taus[1].p4().M() # hypothesised mass of invisible on side B. Must be >=0. desiredPrecisionOnMt2 = 0. # Must be >=0. If 0 alg aims for machine precision. if >0, MT2 computed to supplied absolute precision. useDeciSectionsInitially = True asymm_mt2 = asymm_mt2_lester_bisect() MT2 = asymm_mt2.get_mT2(mVisA, pxA, pyA, mVisB, pxB, pyB, pxMiss, pyMiss, chiA, chiB, desiredPrecisionOnMt2, useDeciSectionsInitially) #print 'MT2', MT2 self.tree.fill('mT2', MT2) if len(lights) > 0: fillParticle(self.tree, 'j1', lights[0]) if len(lights) > 1: fillParticle(self.tree, 'j2', lights[1]) def computeMT(taup4, metp4): scalar_prod = taup4.Px() * metp4.Px() + taup4.Py() * metp4.Py() return math.sqrt(2 * (taup4.Pt() * metp4.Pt() - scalar_prod)) mt1 = computeMT(taus[0].p4(), met.p4()) mt2 = computeMT(taus[1].p4(), met.p4()) self.tree.fill('ta1_mt', mt1) self.tree.fill('ta2_mt', mt2) st = taus[0].p4().Pt() + taus[1].p4().Pt() + bs[0].p4().Pt( ) + bs[0].p4().Pt() + met.p4().Pt() self.tree.fill('sT', st) fillMet(self.tree, 'met', met) fillParticle(self.tree, 'htata', htatas[0]) fillParticle(self.tree, 'hbb', hbbs[0]) htata_metcorr_p4 = taus[0].p4() + taus[1].p4() + met.p4() htata_metcorr = Particle(25, 0, htata_metcorr_p4, 1) fillParticle(self.tree, 'htata_metcorr', htata_metcorr) hh = Resonance(htatas[0], hbbs[0], 25) hh_metcorr = Resonance(htata_metcorr, hbbs[0], 25) fillParticle(self.tree, 'hh', hh) fillParticle(self.tree, 'hh_metcorr', hh_metcorr) self.tree.fill('nbjets', len(event.selected_bs)) self.tree.fill('nljets', len(event.selected_lights)) self.tree.fill( 'njets', len(event.selected_lights) + len(event.selected_bs) + len(event.selected_taus)) self.tree.fill('nlep', len(event.selected_leptons)) self.tree.fill('ntajets', len(event.selected_taus)) drbb = deltaR(bs[0], bs[1]) drtata = deltaR(taus[0], taus[1]) self.tree.fill('drtata', drtata) self.tree.fill('drbb', drbb) # here fill all variables for BDT self.bdt_ta1_pt[0] = taus[0].p4().Pt() self.bdt_ta1_eta[0] = taus[0].p4().Eta() self.bdt_ta1_phi[0] = taus[0].p4().Phi() self.bdt_ta2_pt[0] = taus[1].p4().Pt() self.bdt_ta2_eta[0] = taus[1].p4().Eta() self.bdt_ta2_phi[0] = taus[1].p4().Phi() self.bdt_b1_pt[0] = bs[0].p4().Pt() self.bdt_b1_eta[0] = bs[0].p4().Eta() self.bdt_b1_phi[0] = bs[0].p4().Phi() self.bdt_b2_pt[0] = bs[1].p4().Pt() self.bdt_b2_eta[0] = bs[1].p4().Eta() self.bdt_b2_phi[0] = bs[1].p4().Phi() self.bdt_met_pt[0] = met.p4().Pt() self.bdt_met_phi[0] = met.p4().Phi() self.bdt_met_px[0] = met.p4().Px() self.bdt_met_py[0] = met.p4().Py() self.bdt_htata_pt[0] = htatas[0].p4().Pt() self.bdt_htata_eta[0] = htatas[0].p4().Eta() self.bdt_htata_phi[0] = htatas[0].p4().Phi() self.bdt_htata_m[0] = htatas[0].p4().M() self.bdt_hbb_pt[0] = hbbs[0].p4().Pt() self.bdt_hbb_eta[0] = hbbs[0].p4().Eta() self.bdt_hbb_phi[0] = hbbs[0].p4().Phi() self.bdt_hbb_m[0] = hbbs[0].p4().M() self.bdt_hh_pt[0] = hh.p4().Pt() self.bdt_hh_eta[0] = hh.p4().Eta() self.bdt_hh_phi[0] = hh.p4().Phi() self.bdt_hh_m[0] = hh.p4().M() self.bdt_ta1_mt[0] = mt1 self.bdt_ta2_mt[0] = mt2 self.bdt_mT2[0] = MT2 self.bdt_sT[0] = st self.bdt_njets[0] = len(event.selected_lights) + len( event.selected_bs) + len(event.selected_taus) self.bdt_nbjets[0] = len(event.selected_bs) self.bdt_ntajets[0] = len(event.selected_taus) #self.bdt_nlep [0] = len(event.selected_leptons) #print MT2, ",", s ,",", len(event.selected_lights) + len(event.selected_bs) + len(event.selected_taus), ",", len(event.selected_bs) ,",", len(event.selected_taus) ,",", len(event.selected_leptons)t mva_value = self.reader.EvaluateMVA("BDT") #print mva_value self.tree.fill('tmva_bdt', mva_value) self.tree.tree.Fill()
def process(self, event): self.tree.reset() haas = getattr(event, self.cfg_ana.haas) hbbs = getattr(event, self.cfg_ana.hbbs) haas.sort(key=lambda x: abs(x.m() - 125.)) hbbs.sort(key=lambda x: abs(x.m() - 125.)) if len(haas) > 0 and len(hbbs) > 0: self.tree.fill('weight', event.weight) # jet multiplicities self.tree.fill('nbjets', len(event.selected_bs)) self.tree.fill('nljets', len(event.selected_lights)) self.tree.fill('njets', len(event.selected_lights) + len(event.selected_bs)) self.tree.fill('nlep', len(event.selected_leptons)) # missing Et fillMet(self.tree, 'met', event.met) # Reco higgses photons = [] photons.append(haas[0].leg1()) photons.append(haas[0].leg2()) photons.sort(key=lambda x: x.pt(), reverse=True) bs = [] bs.append(hbbs[0].leg1()) bs.append(hbbs[0].leg2()) bs.sort(key=lambda x: x.pt(), reverse=True) hh = Resonance(haas[0], hbbs[0], 25) fillParticle(self.tree, 'hh', hh) fillParticle(self.tree, 'haa', haas[0]) fillParticle(self.tree, 'hbb', hbbs[0]) fillParticle(self.tree, 'a1', photons[0]) fillParticle(self.tree, 'a2', photons[1]) fillParticle(self.tree, 'b1', bs[0]) fillParticle(self.tree, 'b2', bs[1]) for kl in kl_list: # here fill all variables for BDT self.bdt_a1_pt['bdt_a1_pt_{}'.format( kl)][0] = photons[0].p4().Pt() self.bdt_a1_eta['bdt_a1_eta_{}'.format( kl)][0] = photons[0].p4().Eta() self.bdt_a1_phi['bdt_a1_phi_{}'.format( kl)][0] = photons[0].p4().Phi() self.bdt_a2_pt['bdt_a2_pt_{}'.format( kl)][0] = photons[1].p4().Pt() self.bdt_a2_eta['bdt_a2_eta_{}'.format( kl)][0] = photons[1].p4().Eta() self.bdt_a2_phi['bdt_a2_phi_{}'.format( kl)][0] = photons[1].p4().Phi() self.bdt_b1_pt['bdt_b1_pt_{}'.format(kl)][0] = bs[0].p4().Pt() self.bdt_b1_eta['bdt_b1_eta_{}'.format( kl)][0] = bs[0].p4().Eta() self.bdt_b1_phi['bdt_b1_phi_{}'.format( kl)][0] = bs[0].p4().Phi() self.bdt_b2_pt['bdt_b2_pt_{}'.format(kl)][0] = bs[1].p4().Pt() self.bdt_b2_eta['bdt_b2_eta_{}'.format( kl)][0] = bs[1].p4().Eta() self.bdt_b2_phi['bdt_b2_phi_{}'.format( kl)][0] = bs[1].p4().Phi() self.bdt_met_pt['bdt_met_pt_{}'.format( kl)][0] = event.met.p4().Pt() self.bdt_met_phi['bdt_met_phi_{}'.format( kl)][0] = event.met.p4().Phi() self.bdt_met_px['bdt_met_px_{}'.format( kl)][0] = event.met.p4().Px() self.bdt_met_py['bdt_met_py_{}'.format( kl)][0] = event.met.p4().Py() self.bdt_haa_pt['bdt_haa_pt_{}'.format( kl)][0] = haas[0].p4().Pt() self.bdt_haa_eta['bdt_haa_eta_{}'.format( kl)][0] = haas[0].p4().Eta() self.bdt_haa_phi['bdt_haa_phi_{}'.format( kl)][0] = haas[0].p4().Phi() self.bdt_haa_m['bdt_haa_m_{}'.format(kl)][0] = haas[0].p4().M() self.bdt_hbb_pt['bdt_hbb_pt_{}'.format( kl)][0] = hbbs[0].p4().Pt() self.bdt_hbb_eta['bdt_hbb_eta_{}'.format( kl)][0] = hbbs[0].p4().Eta() self.bdt_hbb_phi['bdt_hbb_phi_{}'.format( kl)][0] = hbbs[0].p4().Phi() self.bdt_hbb_m['bdt_hbb_m_{}'.format(kl)][0] = hbbs[0].p4().M() self.bdt_hh_pt['bdt_hh_pt_{}'.format(kl)][0] = hh.p4().Pt() self.bdt_hh_eta['bdt_hh_eta_{}'.format(kl)][0] = hh.p4().Eta() self.bdt_hh_phi['bdt_hh_phi_{}'.format(kl)][0] = hh.p4().Phi() self.bdt_hh_m['bdt_hh_m_{}'.format(kl)][0] = hh.p4().M() self.bdt_njets['bdt_njets_{}'.format(kl)][0] = len( event.selected_lights) + len(event.selected_bs) self.bdt_nbjets['bdt_nbjets_{}'.format(kl)][0] = len( event.selected_bs) self.bdt_nljets['bdt_nljets_{}'.format(kl)][0] = len( event.selected_lights) self.bdt2_a1_pt['bdt2_a1_pt_{}'.format( kl)][0] = photons[0].p4().Pt() self.bdt2_a1_eta['bdt2_a1_eta_{}'.format( kl)][0] = photons[0].p4().Eta() self.bdt2_a1_phi['bdt2_a1_phi_{}'.format( kl)][0] = photons[0].p4().Phi() self.bdt2_a2_pt['bdt2_a2_pt_{}'.format( kl)][0] = photons[1].p4().Pt() self.bdt2_a2_eta['bdt2_a2_eta_{}'.format( kl)][0] = photons[1].p4().Eta() self.bdt2_a2_phi['bdt2_a2_phi_{}'.format( kl)][0] = photons[1].p4().Phi() self.bdt2_b1_pt['bdt2_b1_pt_{}'.format( kl)][0] = bs[0].p4().Pt() self.bdt2_b1_eta['bdt2_b1_eta_{}'.format( kl)][0] = bs[0].p4().Eta() self.bdt2_b1_phi['bdt2_b1_phi_{}'.format( kl)][0] = bs[0].p4().Phi() self.bdt2_b2_pt['bdt2_b2_pt_{}'.format( kl)][0] = bs[1].p4().Pt() self.bdt2_b2_eta['bdt2_b2_eta_{}'.format( kl)][0] = bs[1].p4().Eta() self.bdt2_b2_phi['bdt2_b2_phi_{}'.format( kl)][0] = bs[1].p4().Phi() self.bdt2_met_pt['bdt2_met_pt_{}'.format( kl)][0] = event.met.p4().Pt() self.bdt2_met_phi['bdt2_met_phi_{}'.format( kl)][0] = event.met.p4().Phi() self.bdt2_met_px['bdt2_met_px_{}'.format( kl)][0] = event.met.p4().Px() self.bdt2_met_py['bdt2_met_py_{}'.format( kl)][0] = event.met.p4().Py() self.bdt2_haa_pt['bdt2_haa_pt_{}'.format( kl)][0] = haas[0].p4().Pt() self.bdt2_haa_eta['bdt2_haa_eta_{}'.format( kl)][0] = haas[0].p4().Eta() self.bdt2_haa_phi['bdt2_haa_phi_{}'.format( kl)][0] = haas[0].p4().Phi() self.bdt2_haa_m['bdt2_haa_m_{}'.format( kl)][0] = haas[0].p4().M() self.bdt2_hbb_pt['bdt2_hbb_pt_{}'.format( kl)][0] = hbbs[0].p4().Pt() self.bdt2_hbb_eta['bdt2_hbb_eta_{}'.format( kl)][0] = hbbs[0].p4().Eta() self.bdt2_hbb_phi['bdt2_hbb_phi_{}'.format( kl)][0] = hbbs[0].p4().Phi() self.bdt2_hbb_m['bdt2_hbb_m_{}'.format( kl)][0] = hbbs[0].p4().M() self.bdt2_hh_pt['bdt2_hh_pt_{}'.format(kl)][0] = hh.p4().Pt() self.bdt2_hh_eta['bdt2_hh_eta_{}'.format( kl)][0] = hh.p4().Eta() self.bdt2_hh_phi['bdt2_hh_phi_{}'.format( kl)][0] = hh.p4().Phi() self.bdt2_hh_m['bdt2_hh_m_{}'.format(kl)][0] = hh.p4().M() self.bdt2_njets['bdt2_njets_{}'.format(kl)][0] = len( event.selected_lights) + len(event.selected_bs) self.bdt2_nbjets['bdt2_nbjets_{}'.format(kl)][0] = len( event.selected_bs) self.bdt2_nljets['bdt2_nljets_{}'.format(kl)][0] = len( event.selected_lights) mva_value2 = self.reader2['reader2_{}'.format(kl)].EvaluateMVA( "BDT") #print mva_value2 self.tree.fill('tmva_bdt_singleh_{}'.format(kl), mva_value2) #print '--------------------------------------------' mva_value = self.reader['reader_{}'.format(kl)].EvaluateMVA( "BDT") #print mva_value self.tree.fill('tmva_bdt_qcd_{}'.format(kl), mva_value) #print kl, mva_value, mva_value2 self.tree.tree.Fill() '''
def process(self, event): self.tree.reset() gen_bs = getattr(event, self.cfg_ana.gen_bs) gen_higgses = getattr(event, self.cfg_ana.gen_higgses) gen_higgses.sort(key=lambda x: x.pt(), reverse=True) jets = getattr(event, self.cfg_ana.fatjets) if len(gen_higgses) > 1: hh_gen = Resonance(gen_higgses[0], gen_higgses[1], 25) bjets = [] ljets = [] # do b-tagging on the fly ... for jet in jets: is_light = True for b in gen_bs: drjb = deltaR(b, jet) if drjb < 0.8: is_light = False if is_light: ljets.append(jet) else: bjets.append(jet) bjets.sort(key=lambda x: x.pt(), reverse=True) ljets.sort(key=lambda x: x.pt(), reverse=True) #if (len(ljets)>0 and len(bjets)>1): if len(bjets) > 1: hh = Resonance(bjets[0], bjets[1], 25) if hh.pt() > 250.: #self.tree.fill('weight' , event.weight ) weight = (0.70**4) * event.weight self.tree.fill('weight', weight) self.tree.fill('nljets', len(ljets)) self.tree.fill('njets', len(jets)) self.tree.fill('nbjets', len(bjets)) fillParticle(self.tree, 'bJet1', bjets[0]) fillParticle(self.tree, 'bJet2', bjets[1]) fillParticle(self.tree, 'softDropped_bJet1', bjets[0].subjetsSoftDrop[0]) fillParticle(self.tree, 'softDropped_bJet2', bjets[1].subjetsSoftDrop[0]) fillParticle(self.tree, 'hh', hh) self.tree.fill('drhh', deltaR(bjets[0], bjets[1])) self.tree.fill('dPtRel', abs(bjets[0].pt() - bjets[1].pt()) / hh.pt()) if (bjets[0].tau1 != 0.0): self.tree.fill('bJet1_tau21', bjets[0].tau2 / bjets[0].tau1) else: self.tree.fill('bJet1_tau21', -99) if (bjets[1].tau1 != 0.0): self.tree.fill('bJet2_tau21', bjets[1].tau2 / bjets[1].tau1) else: self.tree.fill('bJet2_tau21', -99) if len(ljets) > 0: fillParticle(self.tree, 'lJet1', ljets[0]) fillParticle(self.tree, 'softDropped_lJet1', ljets[0].subjetsSoftDrop[0]) if (ljets[0].tau1 != 0.0): self.tree.fill('lJet1_tau21', ljets[0].tau2 / ljets[0].tau1) else: self.tree.fill('lJet1_tau21', -99) if len(bjets) > 2: fillParticle(self.tree, 'bJet3', bjets[2]) fillParticle(self.tree, 'softDropped_bJet3', bjets[2].subjetsSoftDrop[0]) if (bjets[2].tau1 != 0.0): self.tree.fill('bJet3_tau21', bjets[2].tau2 / bjets[2].tau1) else: self.tree.fill('bJet3_tau21', -99) if len(ljets) > 1: fillParticle(self.tree, 'lJet2', ljets[1]) fillParticle(self.tree, 'softDropped_lJet1', ljets[1].subjetsSoftDrop[0]) if (ljets[1].tau1 != 0.0): self.tree.fill('lJet2_tau21', ljets[1].tau2 / ljets[1].tau1) else: self.tree.fill('lJet2_tau21', -99) if len(gen_higgses) > 1: hh_gen = Resonance(gen_higgses[0], gen_higgses[1], 25) fillParticle(self.tree, 'hh_gen', hh_gen) self.tree.tree.Fill()
def __init__(self, hid, w_jets, wstar_jets): self.hid = hid self.w_jets = w_jets self.wstar_jets = wstar_jets self.w = Resonance2(self.w_jets[0], self.w_jets[1], 24) self.wstar = Resonance2(self.wstar_jets[0], self.wstar_jets[1], 24)
def process(self, event): self.tree.reset() ## these pairs contain overlap hbbs = getattr(event, self.cfg_ana.hbbs) bs = getattr(event, self.cfg_ana.bs) hbbs.sort(key=lambda x: abs(x.m() - 125.)) if len(bs) > 3: def bestHiggsPair(hbbs): higgs_pairs = [] for p in hbbs: p1 = p.leg1() p2 = p.leg2() for m in hbbs: m1 = m.leg1() m2 = m.leg2() if m1 == p1 or m1 == p2 or m2 == p1 or m2 == p2: continue fillpair = True for hp in higgs_pairs: if m in hp and p in hp: fillpair = False if fillpair: higgs_pairs.append((p, m)) higgs_pairs.sort(key=lambda x: abs(x[0].m() - x[1].m())) return higgs_pairs[0] higgs_pair = bestHiggsPair(hbbs) self.tree.fill('weight', event.weight) # jet multiplicities self.tree.fill('nbjets', len(event.selected_bs)) self.tree.fill('nljets', len(event.selected_lights)) self.tree.fill('njets', len(event.selected_lights) + len(event.selected_bs)) self.tree.fill('nlep', len(event.selected_leptons)) # missing Et fillMet(self.tree, 'met', event.met) #bs.sort(key=lambda x: x.pt(), reverse=True) hh = Resonance(higgs_pair[0], higgs_pair[1], 25) higgses = [higgs_pair[0], higgs_pair[1]] higgses.sort(key=lambda x: x.pt(), reverse=True) self.bdt_b1_pt[0] = bs[0].p4().Pt() self.bdt_b1_eta[0] = bs[0].p4().Eta() self.bdt_b1_phi[0] = bs[0].p4().Phi() self.bdt_b2_pt[0] = bs[1].p4().Pt() self.bdt_b2_eta[0] = bs[1].p4().Eta() self.bdt_b2_phi[0] = bs[1].p4().Phi() self.bdt_b3_pt[0] = bs[2].p4().Pt() self.bdt_b3_eta[0] = bs[2].p4().Eta() self.bdt_b3_phi[0] = bs[2].p4().Phi() self.bdt_b4_pt[0] = bs[3].p4().Pt() self.bdt_b4_eta[0] = bs[3].p4().Eta() self.bdt_b4_phi[0] = bs[3].p4().Phi() self.bdt_h1_pt[0] = higgses[0].p4().Pt() self.bdt_h1_eta[0] = higgses[0].p4().Eta() self.bdt_h1_phi[0] = higgses[0].p4().Phi() self.bdt_h1_m[0] = higgses[0].p4().M() self.bdt_h2_pt[0] = higgses[1].p4().Pt() self.bdt_h2_eta[0] = higgses[1].p4().Eta() self.bdt_h2_phi[0] = higgses[1].p4().Phi() self.bdt_h2_m[0] = higgses[1].p4().M() self.bdt_hh_pt[0] = hh.p4().Pt() self.bdt_hh_eta[0] = hh.p4().Eta() self.bdt_hh_phi[0] = hh.p4().Phi() self.bdt_hh_m[0] = hh.p4().M() mva_value = self.reader.EvaluateMVA("BDT") print mva_value fillParticle(self.tree, 'hh', hh) fillParticle(self.tree, 'h1', higgses[0]) fillParticle(self.tree, 'h2', higgses[1]) fillParticle(self.tree, 'b1', bs[0]) fillParticle(self.tree, 'b2', bs[1]) fillParticle(self.tree, 'b3', bs[2]) fillParticle(self.tree, 'b4', bs[3]) self.tree.fill('tmva_bdt', mva_value) self.tree.tree.Fill()