class Jet(BaseJet): def __init__(self, candidate): self.candidate = candidate self._pid = candidate.pdgId() self._tlv = TLorentzVector() p4 = candidate.p4() self._tlv.SetPtEtaPhiM(p4.pt(), p4.eta(), p4.phi(), p4.mass()) self.convert_constituents() def convert_constituents(self): constits = [] constits = map(Particle, self.getJetConstituents()) self.constituents = JetConstituents() for ptc in constits: self.constituents.append(ptc) def __getattr__(self, attr): return getattr(self.candidate, attr)
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.clusterizer.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.instance_label, jets)
def convert_constituents(self): constits = [] constits = map(Particle, self.getJetConstituents()) self.constituents = JetConstituents() for ptc in constits: self.constituents.append(ptc)