Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 13:32:27

0001 import operator 
0002 import itertools
0003 import copy
0004 from math import *
0005 
0006 #from ROOT import TLorentzVector, TVectorD
0007 
0008 from PhysicsTools.HeppyCore.utils.deltar import deltaR, deltaPhi
0009 from PhysicsTools.Heppy.analyzers.core.Analyzer import Analyzer
0010 from PhysicsTools.HeppyCore.framework.event import Event
0011 from PhysicsTools.HeppyCore.statistics.counter import Counter, Counters
0012 from PhysicsTools.Heppy.analyzers.core.AutoHandle import AutoHandle
0013 
0014 # from PhysicsTools.Heppy.physicsobjects.PhysicsObjects import Lepton
0015 # from PhysicsTools.Heppy.physicsobjects.PhysicsObjects import Photon
0016 # from PhysicsTools.Heppy.physicsobjects.PhysicsObjects import Electron
0017 # from PhysicsTools.Heppy.physicsobjects.PhysicsObjects import Muon
0018 # from PhysicsTools.Heppy.physicsobjects.PhysicsObjects import Tau
0019 from PhysicsTools.Heppy.physicsobjects.PhysicsObjects import Jet
0020 
0021 import ROOT
0022 from ROOT.heppy import AlphaT
0023 
0024 
0025 import os
0026 
0027 class AlphaTAnalyzer( Analyzer ):
0028     def __init__(self, cfg_ana, cfg_comp, looperName ):
0029         super(AlphaTAnalyzer,self).__init__(cfg_ana,cfg_comp,looperName) 
0030 
0031     def declareHandles(self):
0032         super(AlphaTAnalyzer, self).declareHandles()
0033        #genJets                                                                                                                                                                     
0034         self.handles['genJets'] = AutoHandle( 'slimmedGenJets','std::vector<reco::GenJet>')
0035 
0036     def beginLoop(self,setup):
0037         super(AlphaTAnalyzer,self).beginLoop(setup)
0038         self.counters.addCounter('pairs')
0039         count = self.counters.counter('pairs')
0040         count.register('all events')
0041 
0042 
0043     # Calculate alphaT using jet ET
0044     def makeAlphaT(self, jets):
0045 
0046         if len(jets) == 0:
0047             return 0.
0048 
0049         px  = ROOT.std.vector('double')()
0050         py  = ROOT.std.vector('double')()
0051         et  = ROOT.std.vector('double')()
0052 
0053         #Make alphaT from lead 10 jets
0054         for jet in jets[:10]:
0055             px.push_back(jet.px())
0056             py.push_back(jet.py())
0057             et.push_back(jet.et())
0058 
0059         alphaTCalc   = AlphaT()
0060         return alphaTCalc.getAlphaT( et, px, py )
0061 
0062     def process(self, event):
0063         self.readCollections( event.input )
0064 
0065         event.alphaT = self.makeAlphaT(event.cleanJets)
0066 
0067         #Do the same with gen jets for MC
0068         if self.cfg_comp.isMC:
0069             event.genAlphaT = self.makeAlphaT(event.cleanGenJets)
0070 
0071         return True