CMS 3D CMS Logo

List of all members | Public Member Functions
ResonanceBuilder.ResonanceBuilder Class Reference
Inheritance diagram for ResonanceBuilder.ResonanceBuilder:

Public Member Functions

def process (self, event)
 

Detailed Description

Builds resonances from an input collection of particles. 

Example configuration:

from PhysicsTools.Heppy.analyzers.examples.ResonanceBuilder import ResonanceBuilder
dimuons = cfg.Analyzer(
   ResonanceBuilder,
   'dimuons',                            
   leg_collection = 'muons',             # input collection
   filter_func = lambda x : True,        # filtering function for input objects. here, take all.
   pdgid = 23                            # pdgid for the resonances, here Z
   )

This analyzer puts one collection in the event:
event.dimuons : all resonances, sorted by their distance to the nominal mass
                corresponding to the specified pdgid

Definition at line 57 of file ResonanceBuilder.py.

Member Function Documentation

◆ process()

def ResonanceBuilder.ResonanceBuilder.process (   self,
  event 
)

Definition at line 75 of file ResonanceBuilder.py.

References funct.abs(), analyzer.Analyzer.cfg_ana, analyzer.Analyzer.instance_label, config.Analyzer.instance_label, and config.Service.instance_label.

75  def process(self, event):
76  legs = getattr(event, self.cfg_ana.leg_collection)
77  legs = [leg for leg in legs if self.cfg_ana.filter_func(leg)]
78  resonances = []
79  for leg1, leg2 in itertools.combinations(legs,2):
80  resonances.append( Resonance(leg1, leg2, self.cfg_ana.pdgid, 3) )
81  # sorting according to distance to nominal mass
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)
85 
86 
87 
Abs< T >::type abs(const T &t)
Definition: Abs.h:22