![]() |
![]() |
Inherits FWCore::GuiBrowsers::ConfigToolBase::ConfigToolBase.
Public Member Functions | |
def | __call__ |
def | __init__ |
def | getDefaultParameters |
def | toolCode |
Private Attributes | |
_comment | |
_parameters | |
Static Private Attributes | |
tuple | _defaultParameters = dicttypes.SortedKeysDict() |
string | _label = 'addJetCollection' |
Add a new collection of jets. Takes the configuration from the already configured standard jet collection as starting point; replaces before calling addJetCollection will also affect the new jet collections
Definition at line 167 of file jetTools.py.
def jetTools::AddJetCollection::__init__ | ( | self | ) |
Definition at line 176 of file jetTools.py.
00177 : 00178 ConfigToolBase.__init__(self) 00179 self.addParameter(self._defaultParameters,'jetCollection',self._defaultValue,'Input jet collection', cms.InputTag) 00180 self.addParameter(self._defaultParameters,'algoLabel',self._defaultValue, "label to indicate the jet algorithm (e.g.'AK5')",str) 00181 self.addParameter(self._defaultParameters,'typeLabel',self._defaultValue, "label to indicate the type of constituents (e.g. 'Calo', 'Pflow', 'Jpt', ...)",str) 00182 self.addParameter(self._defaultParameters,'doJTA',True, "run b tagging sequence for new jet collection and add it to the new pat jet collection") 00183 self.addParameter(self._defaultParameters,'doBTagging',True, 'run JetTracksAssociation and JetCharge and add it to the new pat jet collection (will autom. be true if doBTagging is set to true)') 00184 self.addParameter(self._defaultParameters,'jetCorrLabel',None, "payload and list of new jet correction labels, such as (\'AK5Calo\',[\'L2Relative\', \'L3Absolute\'])", tuple,acceptNoneValue=True ) 00185 self.addParameter(self._defaultParameters,'doType1MET',True, "if jetCorrLabel is not 'None', set this to 'True' to redo the Type1 MET correction for the new jet colllection; at the moment it must be 'False' for non CaloJets otherwise the JetMET POG module crashes. ") 00186 self.addParameter(self._defaultParameters,'doL1Cleaning',True, "copy also the producer modules for cleanLayer1 will be set to 'True' automatically when doL1Counters is 'True'") 00187 self.addParameter(self._defaultParameters,'doL1Counters',False, "copy also the filter modules that accept/reject the event looking at the number of jets") 00188 self.addParameter(self._defaultParameters,'genJetCollection',cms.InputTag("ak5GenJets"), "GenJet collection to match to") 00189 self.addParameter(self._defaultParameters,'doJetID',True, "add jetId variables to the added jet collection?") 00190 self.addParameter(self._defaultParameters,'jetIdLabel',"ak5", " specify the label prefix of the xxxJetID object; in general it is the jet collection tag like ak5, kt4 sc5, aso. For more information have a look to SWGuidePATTools#add_JetCollection") 00191 self.addParameter(self._defaultParameters, 'outputModule', "out", "Output module label, empty label indicates no output, default: out") 00192 00193 self._parameters=copy.deepcopy(self._defaultParameters) 00194 self._comment = ""
def jetTools::AddJetCollection::__call__ | ( | self, | |
process, | |||
jetCollection = None , |
|||
algoLabel = None , |
|||
typeLabel = None , |
|||
doJTA = None , |
|||
doBTagging = None , |
|||
jetCorrLabel = None , |
|||
doType1MET = None , |
|||
doL1Cleaning = None , |
|||
doL1Counters = None , |
|||
genJetCollection = None , |
|||
doJetID = None , |
|||
jetIdLabel = None , |
|||
outputModule = None |
|||
) |
Definition at line 198 of file jetTools.py.
00212 : 00213 00214 if jetCollection is None: 00215 jetCollection=self._defaultParameters['jetCollection'].value 00216 if algoLabel is None: 00217 algoLabel=self._defaultParameters['algoLabel'].value 00218 if typeLabel is None: 00219 typeLabel=self._defaultParameters['typeLabel'].value 00220 if doJTA is None: 00221 doJTA=self._defaultParameters['doJTA'].value 00222 if doBTagging is None: 00223 doBTagging=self._defaultParameters['doBTagging'].value 00224 if jetCorrLabel is None: 00225 jetCorrLabel=self._defaultParameters['jetCorrLabel'].value 00226 if doType1MET is None: 00227 doType1MET=self._defaultParameters['doType1MET'].value 00228 if doL1Cleaning is None: 00229 doL1Cleaning=self._defaultParameters['doL1Cleaning'].value 00230 if doL1Counters is None: 00231 doL1Counters=self._defaultParameters['doL1Counters'].value 00232 if genJetCollection is None: 00233 genJetCollection=self._defaultParameters['genJetCollection'].value 00234 if doJetID is None: 00235 doJetID=self._defaultParameters['doJetID'].value 00236 if jetIdLabel is None: 00237 jetIdLabel=self._defaultParameters['jetIdLabel'].value 00238 if outputModule is None: 00239 outputModule=self._defaultParameters['outputModule'].value 00240 00241 self.setParameter('jetCollection',jetCollection) 00242 self.setParameter('algoLabel',algoLabel) 00243 self.setParameter('typeLabel',typeLabel) 00244 self.setParameter('doJTA',doJTA) 00245 self.setParameter('doBTagging',doBTagging) 00246 self.setParameter('jetCorrLabel',jetCorrLabel) 00247 self.setParameter('doType1MET',doType1MET) 00248 self.setParameter('doL1Cleaning',doL1Cleaning) 00249 self.setParameter('doL1Counters',doL1Counters) 00250 self.setParameter('genJetCollection',genJetCollection) 00251 self.setParameter('doJetID',doJetID) 00252 self.setParameter('jetIdLabel',jetIdLabel) 00253 self.setParameter('outputModule',outputModule) 00254 00255 self.apply(process)
def jetTools::AddJetCollection::getDefaultParameters | ( | self | ) |
Definition at line 195 of file jetTools.py.
def jetTools::AddJetCollection::toolCode | ( | self, | |
process | |||
) |
Definition at line 256 of file jetTools.py.
00256 : 00257 jetCollection=self._parameters['jetCollection'].value 00258 algoLabel=self._parameters['algoLabel'].value 00259 typeLabel=self._parameters['typeLabel'].value 00260 doJTA=self._parameters['doJTA'].value 00261 doBTagging=self._parameters['doBTagging'].value 00262 jetCorrLabel=self._parameters['jetCorrLabel'].value 00263 doType1MET =self._parameters['doType1MET'].value 00264 doL1Cleaning=self._parameters['doL1Cleaning'].value 00265 doL1Counters=self._parameters['doL1Counters'].value 00266 genJetCollection=self._parameters['genJetCollection'].value 00267 doJetID=self._parameters['doJetID'].value 00268 jetIdLabel=self._parameters['jetIdLabel'].value 00269 outputModule=self._parameters['outputModule'].value 00270 00271 ## create old module label from standardAlgo 00272 ## and standardType and return 00273 def oldLabel(prefix=''): 00274 return jetCollectionString(prefix, '', '') 00275 00276 ## create new module label from old module 00277 ## label and return 00278 def newLabel(oldLabel): 00279 newLabel=oldLabel 00280 oldLabel=oldLabel+algoLabel+typeLabel 00281 return oldLabel 00282 00283 ## clone module and add it to the patDefaultSequence 00284 def addClone(hook, **replaceStatements): 00285 ## create a clone of the hook with corresponding 00286 ## parameter replacements 00287 newModule = getattr(process, hook).clone(**replaceStatements) 00288 ## add the module to the sequence 00289 addModuleToSequence(hook, newModule) 00290 00291 ## add module to the patDefaultSequence 00292 def addModuleToSequence(hook, newModule): 00293 hookModule = getattr(process, hook) 00294 ## add the new module with standardAlgo & 00295 ## standardType replaced in module label 00296 setattr( process, newLabel(hook), newModule) 00297 ## add new module to default sequence 00298 ## just behind the hookModule 00299 process.patDefaultSequence.replace( hookModule, hookModule*newModule ) 00300 00301 ## add a clone of patJets 00302 addClone(oldLabel(), jetSource = jetCollection) 00303 ## add a clone of selectedPatJets 00304 addClone(oldLabel('selected'), src=cms.InputTag(newLabel(oldLabel()))) 00305 ## add a clone of cleanPatJets 00306 if( doL1Cleaning ): 00307 addClone(oldLabel('clean'), src=cms.InputTag(newLabel(oldLabel('selected')))) 00308 ## add a clone of countPatJets 00309 if( doL1Counters ): 00310 if( doL1Cleaning ): 00311 addClone(oldLabel('count'), src=cms.InputTag(newLabel(oldLabel('clean')))) 00312 else: 00313 addClone(oldLabel('count'), src=cms.InputTag(newLabel(oldLabel('selected')))) 00314 00315 ## get attributes of new module 00316 l1Jets = getattr(process, newLabel(oldLabel())) 00317 00318 ## add a clone of gen jet matching 00319 addClone('patJetPartonMatch', src = jetCollection) 00320 addClone('patJetGenJetMatch', src = jetCollection, matched = genJetCollection) 00321 00322 ## add a clone of parton and flavour associations 00323 addClone('patJetPartonAssociation', jets = jetCollection) 00324 addClone('patJetFlavourAssociation', srcByReference = cms.InputTag(newLabel('patJetPartonAssociation'))) 00325 00326 ## fix label for input tag 00327 def fixInputTag(x): x.setModuleLabel(newLabel(x.moduleLabel)) 00328 ## fix label for vector of input tags 00329 def fixVInputTag(x): x[0].setModuleLabel(newLabel(x[0].moduleLabel)) 00330 00331 ## provide allLayer1Jet inputs with individual labels 00332 fixInputTag(l1Jets.genJetMatch) 00333 fixInputTag(l1Jets.genPartonMatch) 00334 fixInputTag(l1Jets.JetPartonMapSource) 00335 00336 ## make VInputTag from strings 00337 def vit(*args) : return cms.VInputTag( *[ cms.InputTag(x) for x in args ] ) 00338 00339 if (doJTA or doBTagging): 00340 ## add clone of jet track association 00341 process.load("RecoJets.JetAssociationProducers.ak5JTA_cff") 00342 from RecoJets.JetAssociationProducers.ak5JTA_cff import ak5JetTracksAssociatorAtVertex 00343 ## add jet track association module to processes 00344 jtaLabel = 'jetTracksAssociatorAtVertex'+algoLabel+typeLabel 00345 setattr( process, jtaLabel, ak5JetTracksAssociatorAtVertex.clone(jets = jetCollection) ) 00346 process.patDefaultSequence.replace(process.patJetCharge, getattr(process,jtaLabel)+process.patJetCharge) 00347 l1Jets.trackAssociationSource = cms.InputTag(jtaLabel) 00348 addClone('patJetCharge', src=cms.InputTag(jtaLabel)), 00349 fixInputTag(l1Jets.jetChargeSource) 00350 else: 00351 ## switch embedding of track association and jet 00352 ## charge estimate to 'False' 00353 l1Jets.addAssociatedTracks = False 00354 l1Jets.addJetCharge = False 00355 00356 if (doBTagging): 00357 ## define postfixLabel 00358 postfixLabel=algoLabel+typeLabel 00359 ## add b tagging sequence 00360 (btagSeq, btagLabels) = runBTagging(process, jetCollection, postfixLabel) 00361 ## add b tagging sequence before running the allLayer1Jets modules 00362 process.patDefaultSequence.replace(getattr(process,jtaLabel), getattr(process,jtaLabel)+btagSeq) 00363 ## replace corresponding tags for pat jet production 00364 l1Jets.trackAssociationSource = cms.InputTag(btagLabels['jta']) 00365 l1Jets.tagInfoSources = cms.VInputTag( *[ cms.InputTag(x) for x in btagLabels['tagInfos'] ] ) 00366 l1Jets.discriminatorSources = cms.VInputTag( *[ cms.InputTag(x) for x in btagLabels['jetTags'] ] ) 00367 else: 00368 ## switch general b tagging info switch off 00369 l1Jets.addBTagInfo = False 00370 ## adjust output 00371 if outputModule is not '': 00372 getattr(process, outputModule).outputCommands.append("drop *_"+newLabel(oldLabel('selected'))+"_tagInfos_*") 00373 00374 if (doJetID): 00375 l1Jets.addJetID = cms.bool(True) 00376 jetIdLabelNew = jetIdLabel + 'JetID' 00377 l1Jets.jetIDMap = cms.InputTag( jetIdLabelNew ) 00378 else : 00379 l1Jets.addJetID = cms.bool(False) 00380 00381 if (jetCorrLabel != None): 00382 ## add clone of jet energy corrections; 00383 ## catch a couple of exceptions first 00384 if (jetCorrLabel == False ): 00385 raise ValueError, "In addJetCollection 'jetCorrLabel' must be set to 'None', not 'False'" 00386 if (jetCorrLabel == "None"): 00387 raise ValueError, "In addJetCollection 'jetCorrLabel' must be set to 'None' (without quotes)" 00388 ## check for the correct format 00389 if type(jetCorrLabel) != type(('AK5Calo',['L2Relative'])): 00390 raise ValueError, "In addJetCollection 'jetCorrLabel' must be 'None', or of type ('payload',['correction1', 'correction2'])" 00391 00392 ## add clone of jetCorrFactors 00393 addClone('patJetCorrFactors', src = jetCollection) 00394 switchJetCorrLevels(process, jetCorrLabel = jetCorrLabel, postfix=algoLabel+typeLabel) 00395 #getattr(process,newLabel('patJetCorrFactors')).payload = jetCorrLabel[0] 00396 #getattr(process,newLabel('patJetCorrFactors')).levels = jetCorrLabel[1] 00397 getattr(process, newLabel('patJets')).jetCorrFactorsSource = cms.VInputTag( cms.InputTag(newLabel('patJetCorrFactors')) ) 00398 00399 ## switch type1MET corrections off for PFJets or JPTJets 00400 if ( jetCollection.getModuleLabel().find('CaloJets')<0 ): 00401 print '=================================================' 00402 print 'Type1MET corrections are switched off for other ' 00403 print 'jet types but CaloJets. Users are recommened to ' 00404 print 'use pfMET together with PFJets & tcMET together ' 00405 print 'with JPT jets. ' 00406 print '=================================================' 00407 doType1MET=False 00408 00409 ## add a clone of the type1MET correction for the new jet collection 00410 if (doType1MET): 00411 ## in case there is no jet correction service in the paths add it 00412 ## as L2L3 if possible, as combined from L2 and L3 otherwise 00413 if not hasattr( process, '%sL2L3' % (jetCollection.getModuleLabel().replace("Jets", "")) ): 00414 setattr( process, '%sL2L3' % (jetCollection.getModuleLabel().replace("Jets", "")), 00415 cms.ESSource("JetCorrectionServiceChain", 00416 correctors = cms.vstring('%sL2Relative' % (jetCollection.getModuleLabel().replace("Jets", "")), 00417 '%sL3Absolute' % (jetCollection.getModuleLabel().replace("Jets", "")) 00418 ) 00419 ) 00420 ) 00421 ## add a clone of the type1MET correction 00422 ## and the following muonMET correction 00423 addClone('metJESCorAK5CaloJet', inputUncorJetsLabel = jetCollection.value(), 00424 corrector = cms.string('%sL2L3' % (jetCollection.getModuleLabel().replace("Jets", ""))) 00425 ) 00426 addClone('metJESCorAK5CaloJetMuons', uncorMETInputTag = cms.InputTag(newLabel('metJESCorAK5CaloJet'))) 00427 addClone('patMETs', metSource = cms.InputTag(newLabel('metJESCorAK5CaloJetMuons'))) 00428 l1MET = getattr(process, newLabel('patMETs')) 00429 ## add new met collections output to the pat summary 00430 process.patCandidateSummary.candidates += [ cms.InputTag(newLabel('patMETs')) ] 00431 else: 00432 ## switch jetCorrFactors off 00433 l1Jets.addJetCorrFactors = False 00434 00435 addJetCollection=AddJetCollection() 00436 00437
jetTools::AddJetCollection::_comment [private] |
Definition at line 176 of file jetTools.py.
tuple jetTools::AddJetCollection::_defaultParameters = dicttypes.SortedKeysDict() [static, private] |
Definition at line 175 of file jetTools.py.
string jetTools::AddJetCollection::_label = 'addJetCollection' [static, private] |
Definition at line 174 of file jetTools.py.
jetTools::AddJetCollection::_parameters [private] |
Definition at line 176 of file jetTools.py.