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(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(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()