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