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 process(self, event): '''Process event. The event must contain: - self.cfg_ana.particles: the list of particles to be clustered This method creates: - event.<self.cfg_ana.output>: the list of L{jets<heppy.particles.jet.Jet>}. ''' particles = getattr(event, self.cfg_ana.particles) # removing neutrinos particles = [ptc for ptc in particles if abs(ptc.pdgid()) not in [12,14,16]] self.clusterizer.clear(); for ptc in particles: self.clusterizer.add_p4( ptc.p4() ) self.clusterize() jets = [] for jeti in range(self.clusterizer.n_jets()): jet = Jet( self.clusterizer.jet(jeti) ) jet.constituents = JetConstituents() jets.append( jet ) for consti in range(self.clusterizer.n_constituents(jeti)): constituent_index = self.clusterizer.constituent_index(jeti, consti) constituent = particles[constituent_index] jet.constituents.append(constituent) jet.constituents.sort() self.validate(jet) setattr(event, self.cfg_ana.output, jets)
def process(self, event): '''Process event. The event must contain: - self.cfg_ana.particles: the list of particles to be clustered This method creates: - event.<self.cfg_ana.output>: the list of L{jets<heppy.particles.jet.Jet>}. ''' particles = getattr(event, self.cfg_ana.particles) # removing neutrinos particles = [ ptc for ptc in particles if abs(ptc.pdgid()) not in [12, 14, 16] ] self.clusterizer.clear() for ptc in particles: self.clusterizer.add_p4(ptc.p4()) self.clusterize() jets = [] for jeti in range(self.clusterizer.n_jets()): jet = Jet(self.clusterizer.jet(jeti)) jet.constituents = JetConstituents() jets.append(jet) for consti in range(self.clusterizer.n_constituents(jeti)): constituent_index = self.clusterizer.constituent_index( jeti, consti) constituent = particles[constituent_index] jet.constituents.append(constituent) jet.constituents.sort() self.validate(jet) setattr(event, self.cfg_ana.output, jets)
def process(self, event): ptcs = getattr(event, self.cfg_ana.particles) if ptcs: tlv = TLorentzVector() for ptc in ptcs: tlv += ptc.p4() jet = Jet(tlv) jet.constituents = JetConstituents() for ptc in ptcs: jet.constituents.append(ptc) jet.constituents.sort() setattr(event, self.cfg_ana.output, jet)
def process(self, event): '''Process event. The event must contain: - self.cfg_ana.particles: the list of particles to be clustered This method creates: - event.<self.cfg_ana.output>: the list of L{jets<heppy.particles.jet.Jet>}. ''' particles = getattr(event, self.cfg_ana.particles) # removing neutrinos particles = [ ptc for ptc in particles if abs(ptc.pdgid()) not in [12, 14, 16] ] if len(particles) < self.njets: if hasattr( self.cfg_ana, 'njets_required') and self.cfg_ana.njets_required == False: # not enough particles for the required number of jets, # making no jet setattr(event, self.cfg_ana.output, []) return True else: # njets_required not provided, or njets_required set to True err = 'Cannot make {} jets with {} particles -> Event discarded'.format( self.njets, len(particles)) self.mainLogger.error(err) # killing the sequence, as the user requests exactly njets return False # enough particles to make the required number of jets self.clusterizer.clear() for ptc in particles: self.clusterizer.add_p4(ptc.p4()) self.clusterize() jets = [] if self.cfg_ana.verbose: print self.clusterizer.n_jets(), 'jets:' for jeti in range(self.clusterizer.n_jets()): jet = Jet(self.clusterizer.jet(jeti)) jet.constituents = JetConstituents() jets.append(jet) for consti in range(self.clusterizer.n_constituents(jeti)): constituent_index = self.clusterizer.constituent_index( jeti, consti) constituent = particles[constituent_index] jet.constituents.append(constituent) jet.constituents.sort() self.validate(jet) if self.cfg_ana.verbose: print '\t', jet setattr(event, self.cfg_ana.output, jets)
def process(self, event): '''Process event. The event must contain: - self.cfg_ana.particles: the list of particles to be clustered This method creates: - event.<self.cfg_ana.output>: the list of L{jets<heppy.particles.jet.Jet>}. ''' particles = getattr(event, self.cfg_ana.particles) # removing neutrinos particles = [ptc for ptc in particles if abs(ptc.pdgid()) not in [12,14,16]] if len(particles) < self.njets: if hasattr(self.cfg_ana, 'njets_required') and self.cfg_ana.njets_required == False: # not enough particles for the required number of jets, # making no jet setattr(event, self.cfg_ana.output, []) return True else: # njets_required not provided, or njets_required set to True err = 'Cannot make {} jets with {} particles -> Event discarded'.format( self.njets, len(particles) ) self.mainLogger.error(err) # killing the sequence, as the user requests exactly njets return False # enough particles to make the required number of jets self.clusterizer.clear() for ptc in particles: self.clusterizer.add_p4( ptc.p4() ) self.clusterize() jets = [] if self.cfg_ana.verbose: print self.clusterizer.n_jets(), 'jets:' for jeti in range(self.clusterizer.n_jets()): jet = Jet( self.clusterizer.jet(jeti) ) jet.constituents = JetConstituents() jets.append( jet ) for consti in range(self.clusterizer.n_constituents(jeti)): constituent_index = self.clusterizer.constituent_index(jeti, consti) constituent = particles[constituent_index] jet.constituents.append(constituent) jet.constituents.sort() self.validate(jet) if self.cfg_ana.verbose: print '\t', jet setattr(event, self.cfg_ana.output, jets)
def process(self, event): p4 = TLorentzVector() charge = 0 pdgid = 0 ptcs = getattr(event, self.cfg_ana.particles) jet = Jet(p4) constituents = JetConstituents() for ptc in ptcs: p4 += ptc.p4() charge += ptc.q() constituents.append(ptc) sumptc = Particle(pdgid, charge, p4) jet = Jet(p4) jet.constituents = constituents jet.constituents.sort() setattr(event, self.cfg_ana.output, jet)
def process(self, event): gens = getattr(event, self.cfg_ana.gen_particles) gen_taus = [ gen for gen in gens if abs(gen.pdgid()) == 15 and gen.status() == 2 ] ## pprint.pprint(gen_taus) if not hasattr(event, 'genbrowser'): event.genbrowser = GenBrowser(event.gen_particles, event.gen_vertices) thetamax = 75. * math.pi / 180. acceptance = { 211: lambda ptc: ptc.pt() > 0.3 and abs(ptc.theta()) < thetamax, 11: lambda ptc: ptc.e() > 5 and abs(ptc.theta()) < thetamax, 13: lambda ptc: ptc.e() > 7.5 and abs(ptc.theta()) < thetamax, } acc_taus = [] gen_taus_decayed = [] for tau in gen_taus: ## print tau ncharged = 0 acc_charged = [] descendants = event.genbrowser.descendants(tau) stable_daugthers = [ desc for desc in descendants if desc.status() == 1 ] consts = JetConstituents() p4sum = TLorentzVector() for dau in stable_daugthers: assert (dau.status() == 1) ## print '\t', dau if abs(dau.pdgid()) in [12, 14, 16]: continue p4sum += dau.p4() consts.append(dau) pdgid = group_pdgid(dau) if dau.q() and acceptance[pdgid](dau): acc_charged.append(dau) gen_tau_decayed = GenTau(p4sum) gen_tau_decayed.constituents = consts gen_taus_decayed.append(gen_tau_decayed) if len(acc_charged) in [1, 3]: acc_taus.append(gen_tau_decayed) event.gen_taus = gen_taus_decayed event.gen_taus_acc = acc_taus
def process(self, event): jets = getattr(event, self.cfg_ana.input_jets) setattr(event, self.cfg_ana.n_jets, len(jets)) print jets print len(jets) for jet in jets: temp = self.validateMomenta(jet) return False if len(jets) < 4: return False while len(jets) > 4: pairs = [(a, b) for a, b in itertools.combinations(jets, 2)] pairs.sort(key=lambda x: (x[0].p4() + x[1].p4()) * (x[0].p4() + x[1].p4())) for a, b in pairs: print(a.p4() + b.p4()) * (a.p4() + b.p4()) print '//////////////////' # combine jets jet_a, jet_b = pairs[0] print jet_a, jet_b newjet = Jet((jet_a.p4() + jet_b.p4())) newjet.constituents = self.merge_constituents( [jet_a.constituents, jet_b.constituents]) newjet.constituents.validate(newjet.e()) self.validateMomenta(newjet) print newjet jets.remove(jet_a) jets.remove(jet_b) jets.append(newjet) jets.sort(key=lambda x: x.m()) print(jets) print ';;;;;;;;;;;;;\n\n' assert (len(jets) == 4) setattr(event, self.cfg_ana.output_jets, jets)
def process(self, event): particles = getattr(event, self.cfg_ana.particles) # removing neutrinos particles = [ptc for ptc in particles if abs(ptc.pdgid()) not in [12,14,16]] self.clusterizer.clear(); for ptc in particles: self.clusterizer.add_p4( ptc.p4() ) self.clusterize() jets = [] for jeti in range(self.clusterizer.n_jets()): jet = Jet( self.clusterizer.jet(jeti) ) jet.constituents = JetConstituents() jets.append( jet ) for consti in range(self.clusterizer.n_constituents(jeti)): constituent_index = self.clusterizer.constituent_index(jeti, consti) constituent = particles[constituent_index] jet.constituents.append(constituent) jet.constituents.sort() self.validate(jet) setattr(event, self.cfg_ana.output, jets)
def process(self, event): '''Process event. The event must contain: - self.cfg_ana.particles: the input collection of particles. ''' p4 = TLorentzVector() charge = 0 pdgid = 0 ptcs = getattr(event, self.cfg_ana.particles) jet = Jet(p4) constituents = JetConstituents() for ptc in ptcs: p4 += ptc.p4() charge += ptc.q() constituents.append(ptc) sumptc = Particle(pdgid, charge, p4) jet = Jet(p4) jet.constituents = constituents jet.constituents.sort() setattr(event, self.cfg_ana.output, jet)
def process(self, event): particles = getattr(event, self.cfg_ana.particles) # removing neutrinos particles = [ ptc for ptc in particles if abs(ptc.pdgid()) not in [12, 14, 16] ] self.clusterizer.clear() for ptc in particles: self.clusterizer.add_p4(ptc.p4()) self.clusterize() jets = [] for jeti in range(self.clusterizer.n_jets()): jet = Jet(self.clusterizer.jet(jeti)) jet.constituents = JetConstituents() jets.append(jet) for consti in range(self.clusterizer.n_constituents(jeti)): constituent_index = self.clusterizer.constituent_index( jeti, consti) constituent = particles[constituent_index] jet.constituents.append(constituent) jet.constituents.sort() self.validate(jet) setattr(event, self.cfg_ana.output, jets)