CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_2_7_hltpatch1/src/PhysicsTools/PatAlgos/python/tools/muonTools.py

Go to the documentation of this file.
00001 from FWCore.GuiBrowsers.ConfigToolBase import *
00002 
00003 
00004 class AddMuonUserIsolation(ConfigToolBase):
00005 
00006     """ add userIsolation to patMuon
00007     """
00008     _label='addMuonUserIsolation'    
00009     _defaultParameters=dicttypes.SortedKeysDict()
00010     
00011     def __init__(self):
00012         ConfigToolBase.__init__(self)
00013         self.addParameter(self._defaultParameters,'isolationTypes',['All'],'List of predefined userIsolation types to be added; possible values are [\'Tracker\',\'Ecal\',\'Hcal\'] or just [\'All\']', allowedValues=['Tracker','Ecal','Hcal','All'])
00014         self._parameters=copy.deepcopy(self._defaultParameters)
00015         self._comment = ''
00016 
00017     def getDefaultParameters(self):
00018         return self._defaultParameters
00019 
00020     def __call__(self,process,isolationTypes=None) :
00021         if  isolationTypes is None:
00022             isolationTypes=self._defaultParameters['isolationTypes'].value 
00023         self.setParameter('isolationTypes',isolationTypes)
00024         self.apply(process) 
00025         
00026     def toolCode(self, process):                
00027         isolationTypes=self._parameters['isolationTypes'].value
00028 
00029         # key to define the parameter sets
00030         isolationKey=0
00031         # add pre-requisits to the muon
00032         for obj in range(len(isolationTypes)):
00033             if ( isolationTypes[obj] == 'Tracker' or isolationTypes[obj] == 'All'):
00034                 print "adding predefined userIsolation to pat::Muon for Tracker"
00035                 print " -> to access this information call pat::Muon::userIsolation(pat::TrackIso) in your analysis code <-"
00036                 isolationKey=isolationKey+1
00037                 
00038             if ( isolationTypes[obj] == 'Ecal'    or isolationTypes[obj] == 'All'):
00039                 print "adding predefined userIsolation to pat::Muon for Ecal"
00040                 print " -> to access this information call pat::Muon::userIsolation(pat::EcalIso ) in your analysis code <-"
00041                 isolationKey=isolationKey+10
00042                 
00043             if ( isolationTypes[obj] == 'Hcal'    or isolationTypes[obj] == 'All'):
00044                 print "adding predefined userIsolation to pat::Muon for Hcal"
00045                 print " -> to access this information call pat::Muon::userIsolation(pat::HcalIso ) in your analysis code <-"
00046                 isolationKey=isolationKey+100
00047 
00048         # do the corresponding replacements in the pat muon
00049         if ( isolationKey ==   1 ):
00050             # tracker
00051             process.patMuons.isoDeposits = cms.PSet(
00052                 tracker = cms.InputTag("muIsoDepositTk"),
00053             )
00054             process.patMuons.userIsolation = cms.PSet(
00055                 tracker = cms.PSet(
00056                 src = cms.InputTag("muIsoDepositTk"),
00057                 deltaR = cms.double(0.3)
00058                 ),
00059             )
00060         if ( isolationKey ==  10 ):
00061             # ecal
00062             process.patMuons.isoDeposits = cms.PSet(
00063                 ecal    = cms.InputTag("muIsoDepositCalByAssociatorTowers","ecal"),
00064             )
00065             process.patMuons.userIsolation = cms.PSet(
00066                 ecal = cms.PSet(
00067                 src = cms.InputTag("muIsoDepositCalByAssociatorTowers","ecal"),
00068                 deltaR = cms.double(0.3)
00069                 ),
00070             )
00071         if ( isolationKey == 100 ):
00072             # hcal
00073             process.patMuons.isoDeposits = cms.PSet(
00074                 hcal    = cms.InputTag("muIsoDepositCalByAssociatorTowers","hcal"),
00075             )
00076             process.patMuons.userIsolation = cms.PSet(
00077                 hcal = cms.PSet(
00078                 src = cms.InputTag("muIsoDepositCalByAssociatorTowers","hcal"),
00079                 deltaR = cms.double(0.3)
00080                 ),
00081             )
00082         if ( isolationKey ==  11 ):
00083             # ecal + tracker
00084             process.patMuons.isoDeposits = cms.PSet(
00085                 tracker = cms.InputTag("muIsoDepositTk"),
00086                 ecal    = cms.InputTag("muIsoDepositCalByAssociatorTowers","ecal"),
00087             )
00088             process.patMuons.userIsolation = cms.PSet(
00089                 tracker = cms.PSet(
00090                 src = cms.InputTag("muIsoDepositTk"),
00091                 deltaR = cms.double(0.3)
00092                 ),
00093                 ecal = cms.PSet(
00094                 src = cms.InputTag("muIsoDepositCalByAssociatorTowers","ecal"),
00095                 deltaR = cms.double(0.3)
00096                 ),
00097             )
00098         if ( isolationKey == 101 ):
00099             # hcal + tracker
00100             process.patMuons.isoDeposits = cms.PSet(
00101                 tracker = cms.InputTag("muIsoDepositTk"),
00102                 hcal    = cms.InputTag("muIsoDepositCalByAssociatorTowers","hcal"),
00103             )
00104             process.patMuons.userIsolation = cms.PSet(
00105                 tracker = cms.PSet(
00106                 src = cms.InputTag("muIsoDepositTk"),
00107                 deltaR = cms.double(0.3)
00108                 ),
00109                 hcal = cms.PSet(
00110                 src = cms.InputTag("muIsoDepositCalByAssociatorTowers","hcal"),
00111                 deltaR = cms.double(0.3)
00112                 ),
00113             )
00114         if ( isolationKey == 110 ):
00115             # hcal + ecal
00116             process.patMuons.isoDeposits = cms.PSet(
00117                 ecal    = cms.InputTag("muIsoDepositCalByAssociatorTowers","ecal"),
00118                 hcal    = cms.InputTag("muIsoDepositCalByAssociatorTowers","hcal"),
00119             )
00120             process.patMuons.userIsolation = cms.PSet(
00121                 ecal = cms.PSet(
00122                 src = cms.InputTag("gamIsoFromDepsEcalFromHits"),
00123                 ),
00124                 hcal = cms.PSet(
00125                 src = cms.InputTag("gamIsoFromDepsHcalFromTowers"),
00126                 ),
00127             )
00128         if ( isolationKey == 111 ):
00129             # hcal + ecal + tracker
00130             process.patMuons.isoDeposits = cms.PSet(
00131                 tracker = cms.InputTag("muIsoDepositTk"),
00132                 ecal    = cms.InputTag("muIsoDepositCalByAssociatorTowers","ecal"),
00133                 hcal    = cms.InputTag("muIsoDepositCalByAssociatorTowers","hcal"),
00134             )
00135             process.patMuons.userIsolation = cms.PSet(
00136                 tracker = cms.PSet(
00137                 src = cms.InputTag("muIsoDepositTk"),
00138                 deltaR = cms.double(0.3)
00139                 ),
00140                 ecal = cms.PSet(
00141                 src = cms.InputTag("muIsoDepositCalByAssociatorTowers","ecal"),
00142                 deltaR = cms.double(0.3)
00143                 ),
00144                 hcal = cms.PSet(
00145                 src = cms.InputTag("muIsoDepositCalByAssociatorTowers","hcal"),
00146                 deltaR = cms.double(0.3)
00147                 ),
00148             )
00149 
00150 
00151 addMuonUserIsolation=AddMuonUserIsolation()