2 from PhysicsTools.HeppyCore.framework.analyzer
import Analyzer
3 from PhysicsTools.Heppy.physicsobjects.Particle
import Particle
8 mass = {23: 91., 25: 125.}
11 '''Resonance decaying into 2 particles.
13 The interface of this class mimics the interface of the CMS Candidate class.
14 In this way Resonance objects or CMS Candidate objects can be processed
18 def __init__(self, leg1, leg2, pdgid, status=3):
20 Parameters (stored as attributes):
21 leg1,2 : first and second leg.
22 pdgid : pdg code of the resonance
23 status : status code of the resonance
27 self.
_p4 = leg1.p4() + leg2.p4()
28 self.
_charge = leg1.charge() + leg2.charge()
58 '''Builds resonances from an input collection of particles.
60 Example configuration:
62 from PhysicsTools.Heppy.analyzers.examples.ResonanceBuilder import ResonanceBuilder
63 dimuons = cfg.Analyzer(
66 leg_collection = 'muons', # input collection
67 filter_func = lambda x : True, # filtering function for input objects. here, take all.
68 pdgid = 23 # pdgid for the resonances, here Z
71 This analyzer puts one collection in the event:
72 event.dimuons : all resonances, sorted by their distance to the nominal mass
73 corresponding to the specified pdgid
76 legs = getattr(event, self.cfg_ana.leg_collection)
77 legs = [leg
for leg
in legs
if self.cfg_ana.filter_func(leg)]
79 for leg1, leg2
in itertools.combinations(legs,2):
80 resonances.append(
Resonance(leg1, leg2, self.cfg_ana.pdgid, 3) )
82 nominal_mass = mass[self.cfg_ana.pdgid]
83 resonances.sort(key=
lambda x:
abs(x.mass()-nominal_mass))
84 setattr(event, self.instance_label, resonances)