CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions
ResonanceBuilder.ResonanceBuilder Class Reference
Inheritance diagram for ResonanceBuilder.ResonanceBuilder:

Public Member Functions

def process
 

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

def ResonanceBuilder.ResonanceBuilder.process (   self,
  event 
)

Definition at line 75 of file ResonanceBuilder.py.

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

Referenced by ConfigBuilder.ConfigBuilder.addExtraStream(), ConfigBuilder.ConfigBuilder.completeInputCommand(), ConfigBuilder.ConfigBuilder.doNotInlineEventContent(), ConfigBuilder.ConfigBuilder.PrintAllModules.leave(), ConfigBuilder.ConfigBuilder.prepare_HLT(), ConfigBuilder.ConfigBuilder.prepare_LHE(), ConfigBuilder.ConfigBuilder.prepare_PATFILTER(), ConfigBuilder.ConfigBuilder.prepare_VALIDATION(), ConfigBuilder.ConfigBuilder.renameHLTprocessInSequence(), ConfigBuilder.ConfigBuilder.renameInputTagsInSequence(), and ConfigBuilder.ConfigBuilder.scheduleSequence().

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