def pfTools::adaptPFElectrons | ( | process, | |
module, | |||
postfix | |||
) |
Definition at line 135 of file pfTools.py.
00136 : 00137 # module.useParticleFlow = True 00138 print "Adapting PF Electrons " 00139 print "********************* " 00140 warningIsolation() 00141 print 00142 module.useParticleFlow = True 00143 module.pfElectronSource = cms.InputTag("pfIsolatedElectronsClones" + postfix) 00144 module.userIsolation = cms.PSet() 00145 module.isoDeposits = cms.PSet( 00146 pfChargedHadrons = cms.InputTag("elPFIsoDepositCharged" + postfix), 00147 pfChargedAll = cms.InputTag("elPFIsoDepositChargedAll" + postfix), 00148 pfPUChargedHadrons = cms.InputTag("elPFIsoDepositPU" + postfix), 00149 pfNeutralHadrons = cms.InputTag("elPFIsoDepositNeutral" + postfix), 00150 pfPhotons = cms.InputTag("elPFIsoDepositGamma" + postfix) 00151 ) 00152 module.isolationValues = cms.PSet( 00153 pfChargedHadrons = cms.InputTag("elPFIsoValueCharged04PFId"+ postfix), 00154 pfChargedAll = cms.InputTag("elPFIsoValueChargedAll04PFId"+ postfix), 00155 pfPUChargedHadrons = cms.InputTag("elPFIsoValuePU04PFId" + postfix), 00156 pfNeutralHadrons = cms.InputTag("elPFIsoValueNeutral04PFId" + postfix), 00157 pfPhotons = cms.InputTag("elPFIsoValueGamma04PFId" + postfix) 00158 ) 00159 00160 # COLIN: since we take the egamma momentum for pat Electrons, we must 00161 # match the egamma electron to the gen electrons, and not the PFElectron. 00162 # -> do not uncomment the line below. 00163 # process.electronMatch.src = module.pfElectronSource 00164 # COLIN: how do we depend on this matching choice? 00165 00166 print " PF electron source:", module.pfElectronSource 00167 print " isolation :" 00168 print module.isolationValues 00169 print " isodeposits: " 00170 print module.isoDeposits 00171 print 00172 00173 print "removing traditional isolation" 00174 00175 removeIfInSequence(process, "patElectronIsolation", "patDefaultSequence", postfix)
def pfTools::adaptPFIsoElectrons | ( | process, | |
module, | |||
postfix = "PFIso" , |
|||
dR = "04" |
|||
) |
Definition at line 48 of file pfTools.py.
00049 : 00050 #FIXME: adaptPFElectrons can use this function. 00051 module.isoDeposits = cms.PSet( 00052 pfChargedHadrons = cms.InputTag("elPFIsoDepositCharged" + postfix), 00053 pfChargedAll = cms.InputTag("elPFIsoDepositChargedAll" + postfix), 00054 pfPUChargedHadrons = cms.InputTag("elPFIsoDepositPU" + postfix), 00055 pfNeutralHadrons = cms.InputTag("elPFIsoDepositNeutral" + postfix), 00056 pfPhotons = cms.InputTag("elPFIsoDepositGamma" + postfix) 00057 ) 00058 module.isolationValues = cms.PSet( 00059 pfChargedHadrons = cms.InputTag("elPFIsoValueCharged"+dR+"PFId"+ postfix), 00060 pfChargedAll = cms.InputTag("elPFIsoValueChargedAll"+dR+"PFId"+ postfix), 00061 pfPUChargedHadrons = cms.InputTag("elPFIsoValuePU"+dR+"PFId" + postfix), 00062 pfNeutralHadrons = cms.InputTag("elPFIsoValueNeutral"+dR+"PFId" + postfix), 00063 pfPhotons = cms.InputTag("elPFIsoValueGamma"+dR+"PFId" + postfix) 00064 ) 00065 module.isolationValuesNoPFId = cms.PSet( 00066 pfChargedHadrons = cms.InputTag("elPFIsoValueCharged"+dR+"NoPFId"+ postfix), 00067 pfChargedAll = cms.InputTag("elPFIsoValueChargedAll"+dR+"NoPFId"+ postfix), 00068 pfPUChargedHadrons = cms.InputTag("elPFIsoValuePU"+dR+"NoPFId" + postfix), 00069 pfNeutralHadrons = cms.InputTag("elPFIsoValueNeutral"+dR+"NoPFId" + postfix), 00070 pfPhotons = cms.InputTag("elPFIsoValueGamma"+dR+"NoPFId" + postfix) 00071 )
def pfTools::adaptPFIsoMuons | ( | process, | |
module, | |||
postfix = "PFIso" , |
|||
dR = "04" |
|||
) |
Definition at line 72 of file pfTools.py.
00073 : 00074 #FIXME: adaptPFMuons can use this function. 00075 module.isoDeposits = cms.PSet( 00076 pfChargedHadrons = cms.InputTag("muPFIsoDepositCharged" + postfix), 00077 pfChargedAll = cms.InputTag("muPFIsoDepositChargedAll" + postfix), 00078 pfPUChargedHadrons = cms.InputTag("muPFIsoDepositPU" + postfix), 00079 pfNeutralHadrons = cms.InputTag("muPFIsoDepositNeutral" + postfix), 00080 pfPhotons = cms.InputTag("muPFIsoDepositGamma" + postfix) 00081 ) 00082 module.isolationValues = cms.PSet( 00083 pfChargedHadrons = cms.InputTag("muPFIsoValueCharged" + dR + postfix), 00084 pfChargedAll = cms.InputTag("muPFIsoValueChargedAll" + dR + postfix), 00085 pfPUChargedHadrons = cms.InputTag("muPFIsoValuePU" + dR + postfix), 00086 pfNeutralHadrons = cms.InputTag("muPFIsoValueNeutral" + dR + postfix), 00087 pfPhotons = cms.InputTag("muPFIsoValueGamma" + dR + postfix) 00088 )
def pfTools::adaptPFMuons | ( | process, | |
module, | |||
postfix = "" |
|||
) |
Definition at line 102 of file pfTools.py.
00103 : 00104 print "Adapting PF Muons " 00105 print "***************** " 00106 warningIsolation() 00107 print 00108 module.useParticleFlow = True 00109 module.pfMuonSource = cms.InputTag("pfIsolatedMuonsClones" + postfix) 00110 module.userIsolation = cms.PSet() 00111 module.isoDeposits = cms.PSet( 00112 pfChargedHadrons = cms.InputTag("muPFIsoDepositCharged" + postfix), 00113 pfChargedAll = cms.InputTag("muPFIsoDepositChargedAll" + postfix), 00114 pfPUChargedHadrons = cms.InputTag("muPFIsoDepositPU" + postfix), 00115 pfNeutralHadrons = cms.InputTag("muPFIsoDepositNeutral" + postfix), 00116 pfPhotons = cms.InputTag("muPFIsoDepositGamma" + postfix) 00117 ) 00118 module.isolationValues = cms.PSet( 00119 pfChargedHadrons = cms.InputTag("muPFIsoValueCharged04"+ postfix), 00120 pfChargedAll = cms.InputTag("muPFIsoValueChargedAll04"+ postfix), 00121 pfPUChargedHadrons = cms.InputTag("muPFIsoValuePU04" + postfix), 00122 pfNeutralHadrons = cms.InputTag("muPFIsoValueNeutral04" + postfix), 00123 pfPhotons = cms.InputTag("muPFIsoValueGamma04" + postfix) 00124 ) 00125 # matching the pfMuons, not the standard muons. 00126 applyPostfix(process,"muonMatch",postfix).src = module.pfMuonSource 00127 00128 print " muon source:", module.pfMuonSource 00129 print " isolation :", 00130 print module.isolationValues 00131 print " isodeposits: " 00132 print module.isoDeposits 00133 print 00134
def pfTools::adaptPFPhotons | ( | process, | |
module | |||
) |
Definition at line 176 of file pfTools.py.
def pfTools::adaptPFTaus | ( | process, | |
tauType = 'shrinkingConePFTau' , |
|||
postfix = "" |
|||
) |
Definition at line 322 of file pfTools.py.
00323 : 00324 # Set up the collection used as a preselection to use this tau type 00325 if tauType != 'hpsPFTau' : 00326 reconfigurePF2PATTaus(process, tauType, postfix=postfix) 00327 else: 00328 reconfigurePF2PATTaus(process, tauType, 00329 ["DiscriminationByLooseCombinedIsolationDBSumPtCorr"], 00330 ["DiscriminationByDecayModeFinding"], 00331 postfix=postfix) 00332 # new default use unselected taus (selected only for jet cleaning) 00333 if tauType != 'hpsPFTau' : 00334 applyPostfix(process,"patTaus", postfix).tauSource = cms.InputTag("pfTausBase"+postfix) 00335 else: 00336 applyPostfix(process,"patTaus", postfix).tauSource = cms.InputTag("hpsPFTauProducer"+postfix) 00337 # to use preselected collection (old default) uncomment line below 00338 #applyPostfix(process,"patTaus", postfix).tauSource = cms.InputTag("pfTaus"+postfix) 00339 00340 00341 redoPFTauDiscriminators(process, 00342 cms.InputTag(tauType+'Producer'), 00343 applyPostfix(process,"patTaus", postfix).tauSource, 00344 tauType, postfix=postfix) 00345 00346 switchToPFTauByType(process, pfTauType=tauType, 00347 pfTauLabelNew=applyPostfix(process,"patTaus", postfix).tauSource, 00348 pfTauLabelOld=cms.InputTag(tauType+'Producer'), 00349 postfix=postfix) 00350 00351 applyPostfix(process,"makePatTaus", postfix).remove( 00352 applyPostfix(process,"patPFCandidateIsoDepositSelection", postfix) 00353 ) 00354 #helper function for PAT on PF2PAT sample
def pfTools::adaptPVs | ( | process, | |
pvCollection = cms.InputTag('offlinePrimaryVertices') , |
|||
postfix = '' |
|||
) |
Definition at line 477 of file pfTools.py.
00478 : 00479 00480 print "Switching PV collection for PF2PAT:", pvCollection 00481 print "***********************************" 00482 00483 # PV sources to be exchanged: 00484 pvExchange = ['Vertices','vertices','pvSrc','primaryVertices','srcPVs'] 00485 # PV sources NOT to be exchanged: 00486 #noPvExchange = ['src','PVProducer','primaryVertexSrc','vertexSrc','primaryVertex'] 00487 00488 # find out all added jet collections (they don't belong to PF2PAT) 00489 interPostfixes = [] 00490 for m in getattr(process,'patPF2PATSequence'+postfix).moduleNames(): 00491 if m.startswith('patJets') and m.endswith(postfix) and not len(m)==len('patJets')+len(postfix): 00492 interPostfix = m.replace('patJets','') 00493 interPostfix = interPostfix.replace(postfix,'') 00494 interPostfixes.append(interPostfix) 00495 00496 # exchange the primary vertex source of all relevant modules 00497 for m in getattr(process,'patPF2PATSequence'+postfix).moduleNames(): 00498 modName = m.replace(postfix,'') 00499 # only if the module has a source with a relevant name 00500 for namePvSrc in pvExchange: 00501 if hasattr(getattr(process,m),namePvSrc): 00502 # only if the module is not coming from an added jet collection 00503 interPostFixFlag = False 00504 for pfix in interPostfixes: 00505 if modName.endswith(pfix): 00506 interPostFixFlag = True 00507 break 00508 if not interPostFixFlag: 00509 setattr(getattr(process,m),namePvSrc,deepcopy(pvCollection)) 00510
def pfTools::addPFCandidates | ( | process, | |
src, | |||
patLabel = 'PFParticles' , |
|||
cut = "" , |
|||
postfix = "" |
|||
) |
Definition at line 360 of file pfTools.py.
00361 : 00362 from PhysicsTools.PatAlgos.producersLayer1.pfParticleProducer_cfi import patPFParticles 00363 # make modules 00364 producer = patPFParticles.clone(pfCandidateSource = src) 00365 filter = cms.EDFilter("PATPFParticleSelector", 00366 src = cms.InputTag("pat" + patLabel), 00367 cut = cms.string(cut)) 00368 counter = cms.EDFilter("PATCandViewCountFilter", 00369 minNumber = cms.uint32(0), 00370 maxNumber = cms.uint32(999999), 00371 src = cms.InputTag("pat" + patLabel)) 00372 # add modules to process 00373 setattr(process, "pat" + patLabel, producer) 00374 setattr(process, "selectedPat" + patLabel, filter) 00375 setattr(process, "countPat" + patLabel, counter) 00376 # insert into sequence 00377 getattr(process, "patDefaultSequence"+postfix).replace( 00378 applyPostfix(process, "patCandidateSummary", postfix), 00379 producer+applyPostfix(process, "patCandidateSummary", postfix) 00380 ) 00381 getattr(process, "patDefaultSequence"+postfix).replace( 00382 applyPostfix(process, "selectedPatCandidateSummary", postfix), 00383 filter+applyPostfix(process, "selectedPatCandidateSummary", postfix) 00384 ) 00385 index = len( applyPostfix( process, "patDefaultSequence", postfix ).moduleNames() ) 00386 applyPostfix( process, "patDefaultSequence", postfix ).insert( index, counter ) 00387 # summary tables 00388 applyPostfix(process, "patCandidateSummary", postfix).candidates.append(cms.InputTag('pat' + patLabel)) 00389 applyPostfix(process, "selectedPatCandidateSummary", postfix).candidates.append(cms.InputTag('selectedPat' + patLabel)) 00390
def pfTools::reconfigurePF2PATTaus | ( | process, | |
tauType = 'shrinkingConePFTau' , |
|||
pf2patSelection = ["DiscriminationByIsolation" , |
|||
DiscriminationByLeadingPionPtCut, | |||
selectionDependsOn = ["DiscriminationByLeadingTrackFinding"] , |
|||
producerFromType = lambda producer: producer+"Producer" , |
|||
postfix = "" |
|||
) |
Definition at line 181 of file pfTools.py.
00185 : producer+"Producer", 00186 postfix = ""): 00187 print "patTaus will be produced from taus of type: %s that pass %s" \ 00188 % (tauType, pf2patSelection) 00189 00190 #get baseSequence 00191 baseSequence = getattr(process,"pfTausBaseSequence"+postfix) 00192 #clean baseSequence from old modules 00193 for oldBaseModuleName in baseSequence.moduleNames(): 00194 oldBaseModule = getattr(process,oldBaseModuleName) 00195 baseSequence.remove(oldBaseModule) 00196 00197 # Get the prototype of tau producer to make, i.e. fixedConePFTauProducer 00198 producerName = producerFromType(tauType) 00199 # Set as the source for the pf2pat taus (pfTaus) selector 00200 applyPostfix(process,"pfTaus", postfix).src = producerName+postfix 00201 # Start our pf2pat taus base sequence 00202 oldTauSansRefs = getattr(process,'pfTausProducerSansRefs'+postfix) 00203 oldTau = getattr(process,'pfTausProducer'+postfix) 00204 ## copy tau and setup it properly 00205 newTauSansRefs = None 00206 newTau = getattr(process,producerName).clone() 00207 ## adapted to new structure in RecoTauProducers PLEASE CHECK!!! 00208 if tauType=='shrinkingConePFTau': 00209 newTauSansRefs = getattr(process,producerName+"SansRefs").clone() 00210 newTauSansRefs.modifiers[1] = cms.PSet( 00211 pfTauTagInfoSrc = cms.InputTag("pfTauTagInfoProducer"+postfix), 00212 name = cms.string('pfTauTTIworkaround'+postfix), 00213 plugin = cms.string('RecoTauTagInfoWorkaroundModifer') 00214 ) 00215 newTau.modifiers[1] = newTauSansRefs.modifiers[1] 00216 newTauSansRefs.piZeroSrc = "pfJetsLegacyTaNCPiZeros"+postfix 00217 newTau.piZeroSrc = newTauSansRefs.piZeroSrc 00218 newTauSansRefs.builders[0].pfCandSrc = oldTauSansRefs.builders[0].pfCandSrc 00219 newTauSansRefs.jetRegionSrc = oldTauSansRefs.jetRegionSrc 00220 newTauSansRefs.jetSrc = oldTauSansRefs.jetSrc 00221 elif tauType=='fixedConePFTau': 00222 newTau.piZeroSrc = "pfJetsLegacyTaNCPiZeros"+postfix 00223 elif tauType=='hpsPFTau': 00224 newTau = process.combinatoricRecoTaus.clone() 00225 newTau.piZeroSrc="pfJetsLegacyHPSPiZeros"+postfix 00226 newTau.modifiers[3] = cms.PSet( 00227 pfTauTagInfoSrc = cms.InputTag("pfTauTagInfoProducer"+postfix), 00228 name = cms.string('pfTauTTIworkaround'+postfix), 00229 plugin = cms.string('RecoTauTagInfoWorkaroundModifer') 00230 ) 00231 from PhysicsTools.PatAlgos.tools.helpers import cloneProcessingSnippet 00232 cloneProcessingSnippet(process, process.produceHPSPFTaus, postfix) 00233 massSearchReplaceParam(getattr(process,"produceHPSPFTaus"+postfix), 00234 "PFTauProducer", 00235 cms.InputTag("combinatoricRecoTaus"), 00236 cms.InputTag("pfTausBase"+postfix) ) 00237 massSearchReplaceParam(getattr(process,"produceHPSPFTaus"+postfix), 00238 "src", 00239 cms.InputTag("combinatoricRecoTaus"), 00240 cms.InputTag("pfTausBase"+postfix) ) 00241 00242 newTau.builders[0].pfCandSrc = oldTau.builders[0].pfCandSrc 00243 newTau.jetRegionSrc = oldTau.jetRegionSrc 00244 newTau.jetSrc = oldTau.jetSrc 00245 00246 # replace old tau producer by new one put it into baseSequence 00247 setattr(process,"pfTausBase"+postfix,newTau) 00248 if tauType=='shrinkingConePFTau': 00249 setattr(process,"pfTausBaseSansRefs"+postfix,newTauSansRefs) 00250 getattr(process,"pfTausBase"+postfix).src = "pfTausBaseSansRefs"+postfix 00251 baseSequence += getattr(process,"pfTausBaseSansRefs"+postfix) 00252 baseSequence += getattr(process,"pfTausBase"+postfix) 00253 if tauType=='hpsPFTau': 00254 baseSequence += getattr(process,"produceHPSPFTaus"+postfix) 00255 #make custom mapper to take postfix into account (could have gone with lambda of lambda but... ) 00256 def producerIsTauTypeMapperWithPostfix(tauProducer): 00257 return lambda x: producerIsTauTypeMapper(tauProducer)+x.group(1)+postfix 00258 00259 def recoTauTypeMapperWithGroup(tauProducer): 00260 return "%s(.*)"%recoTauTypeMapper(tauProducer) 00261 00262 # Get our prediscriminants 00263 for predisc in selectionDependsOn: 00264 # Get the prototype 00265 originalName = tauType+predisc # i.e. fixedConePFTauProducerDiscriminationByLeadingTrackFinding 00266 clonedName = "pfTausBase"+predisc+postfix 00267 clonedDisc = getattr(process, originalName).clone() 00268 # Register in our process 00269 setattr(process, clonedName, clonedDisc) 00270 baseSequence += getattr(process, clonedName) 00271 00272 tauCollectionToSelect = None 00273 if tauType != 'hpsPFTau' : 00274 tauCollectionToSelect = "pfTausBase"+postfix 00275 #cms.InputTag(clonedDisc.PFTauProducer.value()+postfix) 00276 else: 00277 tauCollectionToSelect = "hpsPFTauProducer"+postfix 00278 # Adapt this discriminator for the cloned prediscriminators 00279 adaptTauDiscriminator(clonedDisc, newTauProducer="pfTausBase", 00280 oldTauTypeMapper=recoTauTypeMapperWithGroup, 00281 newTauTypeMapper=producerIsTauTypeMapperWithPostfix, 00282 preservePFTauProducer=True) 00283 clonedDisc.PFTauProducer = tauCollectionToSelect 00284 00285 # Reconfigure the pf2pat PFTau selector discrimination sources 00286 applyPostfix(process,"pfTaus", postfix).discriminators = cms.VPSet() 00287 for selection in pf2patSelection: 00288 # Get our discriminator that will be used to select pfTaus 00289 originalName = tauType+selection 00290 clonedName = "pfTausBase"+selection+postfix 00291 clonedDisc = getattr(process, originalName).clone() 00292 # Register in our process 00293 setattr(process, clonedName, clonedDisc) 00294 00295 tauCollectionToSelect = None 00296 00297 if tauType != 'hpsPFTau' : 00298 tauCollectionToSelect = cms.InputTag("pfTausBase"+postfix) 00299 #cms.InputTag(clonedDisc.PFTauProducer.value()+postfix) 00300 else: 00301 tauCollectionToSelect = cms.InputTag("hpsPFTauProducer"+postfix) 00302 #Adapt our cloned discriminator to the new prediscriminants 00303 adaptTauDiscriminator(clonedDisc, newTauProducer="pfTausBase", 00304 oldTauTypeMapper=recoTauTypeMapperWithGroup, 00305 newTauTypeMapper=producerIsTauTypeMapperWithPostfix, 00306 preservePFTauProducer=True) 00307 clonedDisc.PFTauProducer = tauCollectionToSelect 00308 baseSequence += clonedDisc 00309 # Add this selection to our pfTau selectors 00310 applyPostfix(process,"pfTaus", postfix).discriminators.append(cms.PSet( 00311 discriminator=cms.InputTag(clonedName), selectionCut=cms.double(0.5))) 00312 # Set the input of the final selector. 00313 if tauType != 'hpsPFTau': 00314 applyPostfix(process,"pfTaus", postfix).src = "pfTausBase"+postfix 00315 else: 00316 # If we are using HPS taus, we need to take the output of the clenaed 00317 # collection 00318 applyPostfix(process,"pfTaus", postfix).src = "hpsPFTauProducer"+postfix 00319 00320 00321
def pfTools::removeMCMatchingPF2PAT | ( | process, | |
postfix = "" , |
|||
outputModules = ['out'] |
|||
) |
Definition at line 471 of file pfTools.py.
def pfTools::switchToPFJets | ( | process, | |
input = cms.InputTag('pfNoTauClones') , |
|||
algo = 'AK5' , |
|||
postfix = "" , |
|||
jetCorrections = ('AK5PFchs', ['L1FastJet' , |
|||
L2Relative, | |||
L3Absolute, | |||
type1 = False , |
|||
outputModules = ['out'] |
|||
) |
Definition at line 408 of file pfTools.py.
00409 : 00410 00411 print "Switching to PFJets, ", algo 00412 print "************************ " 00413 print "input collection: ", input 00414 00415 if( algo == 'IC5' ): 00416 genJetCollection = cms.InputTag('iterativeCone5GenJetsNoNu') 00417 elif algo == 'AK5': 00418 genJetCollection = cms.InputTag('ak5GenJetsNoNu') 00419 elif algo == 'AK7': 00420 genJetCollection = cms.InputTag('ak7GenJetsNoNu') 00421 else: 00422 print 'bad jet algorithm:', algo, '! for now, only IC5, AK5 and AK7 are allowed. If you need other algorithms, please contact Colin' 00423 sys.exit(1) 00424 00425 # changing the jet collection in PF2PAT: 00426 from CommonTools.ParticleFlow.Tools.jetTools import jetAlgo 00427 inputCollection = getattr(process,"pfJets"+postfix).src 00428 setattr(process,"pfJets"+postfix,jetAlgo(algo)) # problem for cfgBrowser 00429 getattr(process,"pfJets"+postfix).src = inputCollection 00430 inputJetCorrLabel=jetCorrections 00431 switchJetCollection(process, 00432 input, 00433 jetIdLabel = algo, 00434 doJTA=True, 00435 doBTagging=True, 00436 jetCorrLabel=inputJetCorrLabel, 00437 doType1MET=type1, 00438 genJetCollection = genJetCollection, 00439 doJetID = True, 00440 postfix = postfix, 00441 outputModules = outputModules 00442 ) 00443 # check whether L1FastJet is in the list of correction levels or not 00444 applyPostfix(process, "patJetCorrFactors", postfix).useRho = False 00445 for corr in inputJetCorrLabel[1]: 00446 if corr == 'L1FastJet': 00447 applyPostfix(process, "patJetCorrFactors", postfix).useRho = True 00448 applyPostfix(process, "pfJets", postfix).doAreaFastjet = True 00449 # do correct treatment for TypeI MET corrections 00450 if type1: 00451 for mod in getattr(process,'patPF2PATSequence'+postfix).moduleNames(): 00452 if mod.startswith("kt6"): 00453 prefix = mod.replace(postfix,'') 00454 prefix = prefix.replace('kt6PFJets','') 00455 prefix = prefix.replace('kt6CaloJets','') 00456 prefix = getattr(process,'patJetCorrFactors'+prefix+postfix).payload.pythonValue().replace("'","") 00457 for essource in process.es_sources_().keys(): 00458 if essource == prefix+'L1FastJet': 00459 setattr(process,essource+postfix,getattr(process,essource).clone(srcRho=cms.InputTag(mod,'rho'))) 00460 setattr(process,prefix+'CombinedCorrector'+postfix,getattr(process,prefix+'CombinedCorrector').clone()) 00461 getattr(process,prefix+'CorMet'+postfix).corrector = prefix+'CombinedCorrector'+postfix 00462 for cor in getattr(process,prefix+'CombinedCorrector'+postfix).correctors: 00463 if cor == essource: 00464 idx = getattr(process,prefix+'CombinedCorrector'+postfix).correctors.index(essource); 00465 getattr(process,prefix+'CombinedCorrector'+postfix).correctors[idx] = essource+postfix 00466 00467 if hasattr( getattr( process, "patJets" + postfix), 'embedCaloTowers' ): # optional parameter, which defaults to 'False' anyway 00468 applyPostfix(process, "patJets", postfix).embedCaloTowers = False 00469 applyPostfix(process, "patJets", postfix).embedPFCandidates = True 00470 #-- Remove MC dependence ------------------------------------------------------
def pfTools::switchToPFMET | ( | process, | |
input = cms.InputTag('pfMET') , |
|||
type1 = False , |
|||
postfix = "" |
|||
) |
Definition at line 391 of file pfTools.py.
00392 : 00393 print 'MET: using ', input 00394 if( not type1 ): 00395 oldMETSource = applyPostfix(process, "patMETs",postfix).metSource 00396 applyPostfix(process, "patMETs",postfix).metSource = input 00397 applyPostfix(process, "patMETs",postfix).addMuonCorrections = False 00398 getattr(process, "patDefaultSequence"+postfix).remove(applyPostfix(process, "patMETCorrections",postfix)) 00399 else: 00400 # type1 corrected MET 00401 # name of corrected MET hardcoded in PAT and meaningless 00402 print 'Apply TypeI corrections for MET' 00403 getattr(process, "patDefaultSequence"+postfix).remove(applyPostfix(process, "patMETCorrections",postfix)) 00404 jecLabel = getattr(process,'patJetCorrFactors'+postfix).payload.pythonValue().replace("'","") 00405 getattr(process,jecLabel+'CorMet'+postfix).inputUncorMetLabel = input.getModuleLabel() 00406 getattr(process,'patMETs'+postfix).metSource = jecLabel+'CorMet'+postfix 00407 getattr(process,'patMETs'+postfix).addMuonCorrections = False
def pfTools::tauTypeInPF2PAT | ( | process, | |
tauType = 'shrinkingConePFTau' , |
|||
postfix = "" |
|||
) |
Definition at line 355 of file pfTools.py.
def pfTools::useGsfElectrons | ( | process, | |
postfix, | |||
dR = "04" |
|||
) |
Definition at line 34 of file pfTools.py.
00035 : 00036 print "using Gsf Electrons in PF2PAT" 00037 print "WARNING: this will destory the feature of top projection which solves the ambiguity between leptons and jets because" 00038 print "WARNING: there will be overlap between non-PF electrons and jets even though top projection is ON!" 00039 print "********************* " 00040 module = applyPostfix(process,"patElectrons",postfix) 00041 module.useParticleFlow = False 00042 print "Building particle-based isolation for GsfElectrons in PF2PAT(PFBRECO)" 00043 print "********************* " 00044 adaptPFIsoElectrons( process, module, postfix+"PFIso", dR ) 00045 getattr(process,'patDefaultSequence'+postfix).replace( getattr(process,"patElectrons"+postfix), 00046 setupPFElectronIso(process, 'gsfElectrons', "PFIso", postfix, runPF2PAT=True) + 00047 getattr(process,"patElectrons"+postfix) )
def pfTools::usePF2PAT | ( | process, | |
runPF2PAT = True , |
|||
jetAlgo = 'AK5' , |
|||
runOnMC = True , |
|||
postfix = "" , |
|||
jetCorrections = ('AK5PFchs', ['L1FastJet' , |
|||
L2Relative, | |||
L3Absolute, | |||
pvCollection = cms.InputTag('offlinePrimaryVertices') , |
|||
typeIMetCorrections = False , |
|||
outputModules = ['out'] |
|||
) |
Switch PAT to use PF2PAT instead of AOD sources. if 'runPF2PAT' is true, we'll also add PF2PAT in front of the PAT sequence
Definition at line 511 of file pfTools.py.
00512 : 00513 # PLEASE DO NOT CLOBBER THIS FUNCTION WITH CODE SPECIFIC TO A GIVEN PHYSICS OBJECT. 00514 # CREATE ADDITIONAL FUNCTIONS IF NEEDED. 00515 00516 """Switch PAT to use PF2PAT instead of AOD sources. if 'runPF2PAT' is true, we'll also add PF2PAT in front of the PAT sequence""" 00517 00518 # -------- CORE --------------- 00519 if runPF2PAT: 00520 process.load("CommonTools.ParticleFlow.PF2PAT_cff") 00521 #add Pf2PAT *before* cloning so that overlapping modules are cloned too 00522 #process.patDefaultSequence.replace( process.patCandidates, process.PF2PAT+process.patCandidates) 00523 #add clones of some stuff here 00524 process.patPFClones = cms.Sequence(process.pfNoJetClones+process.pfNoTauClones) 00525 process.patPF2PATSequence = cms.Sequence( process.PF2PAT + process.patPFClones + process.patDefaultSequence) 00526 else: 00527 process.patPF2PATSequence = cms.Sequence( process.patDefaultSequence ) 00528 00529 if not postfix == "": 00530 from PhysicsTools.PatAlgos.tools.helpers import cloneProcessingSnippet 00531 cloneProcessingSnippet(process, process.patPF2PATSequence, postfix) 00532 #delete everything pat PF2PAT modules! if you want to test the postfixing for completeness 00533 #from PhysicsTools.PatAlgos.tools.helpers import listModules,listSequences 00534 #for module in listModules(process.patDefaultSequence): 00535 # if not module.label() is None: process.__delattr__(module.label()) 00536 #for sequence in listSequences(process.patDefaultSequence): 00537 # if not sequence.label() is None: process.__delattr__(sequence.label()) 00538 #del process.patDefaultSequence 00539 00540 removeCleaning(process, postfix=postfix, outputModules=outputModules) 00541 00542 # -------- OBJECTS ------------ 00543 # Muons 00544 adaptPFMuons(process, 00545 applyPostfix(process,"patMuons",postfix), 00546 postfix) 00547 00548 # Electrons 00549 adaptPFElectrons(process, 00550 applyPostfix(process,"patElectrons",postfix), 00551 postfix) 00552 00553 # Photons 00554 print "Temporarily switching off photons completely" 00555 00556 removeSpecificPATObjects(process,names=['Photons'],outputModules=outputModules,postfix=postfix) 00557 removeIfInSequence(process,"patPhotonIsolation","patDefaultSequence",postfix) 00558 00559 # Jets 00560 if runOnMC : 00561 switchToPFJets( process, cms.InputTag('pfNoTauClones'+postfix), jetAlgo, postfix=postfix, 00562 jetCorrections=jetCorrections, type1=typeIMetCorrections, outputModules=outputModules ) 00563 applyPostfix(process,"patDefaultSequence",postfix).replace( 00564 applyPostfix(process,"patJetGenJetMatch",postfix), 00565 getattr(process,"genForPF2PATSequence") * 00566 applyPostfix(process,"patJetGenJetMatch",postfix) 00567 ) 00568 else : 00569 if not 'L2L3Residual' in jetCorrections[1]: 00570 print '#################################################' 00571 print 'WARNING! Not using L2L3Residual but this is data.' 00572 print 'If this is okay with you, disregard this message.' 00573 print '#################################################' 00574 switchToPFJets( process, cms.InputTag('pfNoTauClones'+postfix), jetAlgo, postfix=postfix, 00575 jetCorrections=jetCorrections, type1=typeIMetCorrections, outputModules=outputModules ) 00576 00577 # Taus 00578 #adaptPFTaus( process, tauType='shrinkingConePFTau', postfix=postfix ) 00579 #adaptPFTaus( process, tauType='fixedConePFTau', postfix=postfix ) 00580 adaptPFTaus( process, tauType='hpsPFTau', postfix=postfix ) 00581 00582 # MET 00583 switchToPFMET(process, cms.InputTag('pfMET'+postfix), type1=typeIMetCorrections, postfix=postfix) 00584 00585 # Unmasked PFCandidates 00586 addPFCandidates(process,cms.InputTag('pfNoJetClones'+postfix),patLabel='PFParticles'+postfix,cut="",postfix=postfix) 00587 00588 # adapt primary vertex collection 00589 adaptPVs(process, pvCollection=pvCollection, postfix=postfix) 00590 00591 if runOnMC: 00592 process.load("CommonTools.ParticleFlow.genForPF2PAT_cff") 00593 getattr(process, "patDefaultSequence"+postfix).replace( 00594 applyPostfix(process,"patCandidates",postfix), 00595 process.genForPF2PATSequence+applyPostfix(process,"patCandidates",postfix) 00596 ) 00597 else: 00598 removeMCMatchingPF2PAT(process,postfix=postfix,outputModules=outputModules) 00599 00600 print "Done: PF2PAT interfaced to PAT, postfix=", postfix
def pfTools::usePFIso | ( | process, | |
postfix = "PFIso" |
|||
) |
Definition at line 89 of file pfTools.py.
00090 : 00091 print "Building particle-based isolation " 00092 print "***************** " 00093 process.eleIsoSequence = setupPFElectronIso(process, 'gsfElectrons', postfix) 00094 process.muIsoSequence = setupPFMuonIso(process, 'muons', postfix) 00095 adaptPFIsoMuons( process, applyPostfix(process,"patMuons",""), postfix) 00096 adaptPFIsoElectrons( process, applyPostfix(process,"patElectrons",""), postfix) 00097 getattr(process,'patDefaultSequence').replace( getattr(process,"patCandidates"), 00098 process.pfParticleSelectionSequence + 00099 process.eleIsoSequence + 00100 process.muIsoSequence + 00101 getattr(process,"patCandidates") )
def pfTools::warningIsolation | ( | ) |
Definition at line 29 of file pfTools.py.