Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:23:27

0001 from PhysicsTools.Heppy.analyzers.core.Analyzer import Analyzer
0002 
0003 import PhysicsTools.HeppyCore.framework.config as cfg
0004 
0005         
0006 class HiggsDecayModeAnalyzer( Analyzer ):
0007     """Classify and filter events according to Higgs boson decays
0008 
0009        Reads:
0010          event.genHiggsBosons
0011 
0012        Creates in the event:
0013          event.genHiggsDecayMode =   0  for non-Higgs or multi-higgs
0014                                  15  for H -> tau tau
0015                                  23  for H -> Z Z
0016                                  24  for H -> W W
0017                                  xx  for H -> xx yy zzz 
0018        If filterHiggsDecays is set to a list of Higgs decay modes,
0019        it will filter events that have those decay modes.
0020        e.g. [0, 15, 23, 24] will keep data, non-Higgs MC and Higgs decays to (tau, Z, W) 
0021        but will drop Higgs decays to other particles (e.g. bb).
0022       
0023     """
0024     def __init__(self, cfg_ana, cfg_comp, looperName ):
0025         super(HiggsDecayModeAnalyzer,self).__init__(cfg_ana,cfg_comp,looperName)
0026     #---------------------------------------------
0027         
0028 
0029     def declareHandles(self):
0030         super(HiggsDecayModeAnalyzer, self).declareHandles()
0031 
0032     def beginLoop(self, setup):
0033         super(HiggsDecayModeAnalyzer,self).beginLoop(setup)
0034 
0035     def process(self, event):
0036         self.readCollections( event.input )
0037 
0038         # if not MC, nothing to do
0039         if not self.cfg_comp.isMC: 
0040             return True
0041 
0042         higgsBosons = event.genHiggsBosons
0043         if len(higgsBosons) != 1:
0044             event.genHiggsDecayMode = 0
0045             event.genHiggsBoson     = None
0046         else:
0047             event.genHiggsBoson = higgsBosons[0]
0048             event.genHiggsDecayMode = abs( event.genHiggsBoson.daughter(0).pdgId() )
0049 
0050         # if MC and filtering on the Higgs decay mode, 
0051         # them do filter events
0052         if self.cfg_ana.filterHiggsDecays:
0053             if event.genHiggsDecayMode not in self.cfg_ana.filterHiggsDecays:
0054                 return False
0055 
0056         return True
0057 
0058 setattr(HiggsDecayModeAnalyzer,"defaultConfig",
0059     cfg.Analyzer(HiggsDecayModeAnalyzer,
0060         filterHiggsDecays = False, 
0061     )
0062 )