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): 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)
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)
def process(ievent, fastjet=False): jet_clusterizer.clear() event = Event(sh['events'][ievent], ['particles', 'rec', 'gen']) if fastjet: for p4 in event['particles'][1]: jet_clusterizer.add_p4(p4) jet_clusterizer.make_exclusive_jets(2) jets = [] fj_positions = [] antikt = list() for jeti in range(jet_clusterizer.n_jets()): jet = Jet(jet_clusterizer.jet(jeti)) jets.append(jet) fj_positions.append((jet.theta(), jet.phi())) antikt.append( (jet.theta(), jet.phi(), jet.e()) ) fj_positions = np.array(fj_positions) event.add_collection('antikt', antikt) return event
def process(ievent, display=True): jet_clusterizer.clear() event = sh['events'][ievent] outevent = copy.deepcopy(event) ptc_positions, ptc_p4s = read_collection(event, 'particles') rec_positions, rec_p4s = read_collection(event, 'rec') gen_positions, gen_p4s = read_collection(event, 'gen') for p4 in ptc_p4s: jet_clusterizer.add_p4(p4) jet_clusterizer.make_exclusive_jets(2) jets = [] fj_positions = [] for jeti in range(jet_clusterizer.n_jets()): jet = Jet(jet_clusterizer.jet(jeti)) jets.append(jet) fj_positions.append((jet.theta(), jet.phi())) outevent.setdefault('antikt', []).append((jet.theta(), jet.phi(), jet.e())) fj_positions = np.array(fj_positions) outevents.append(outevent) if display: plt.clf() plt.xlim(-math.pi/2., math.pi/2.) plt.ylim(-math.pi, math.pi) plt.plot(ptc_positions[:,0], ptc_positions[:,1], 'wo') plt.plot(rec_positions[:,0], rec_positions[:,1], 'yo') plt.plot(gen_positions[:,0], gen_positions[:,1], 'ro') plt.plot(fj_positions[:,0], fj_positions[:,1], 'b.') print event.keys() print ievent print gen_positions print rec_positions print fj_positions print jets print gen_p4s[0].E() + gen_p4s[1].E() print rec_p4s[0].E() + rec_p4s[1].E() print jets[0].e() + jets[1].e()