Inherits FWCore::GuiBrowsers::ConfigToolBase::ConfigToolBase.
Public Member Functions | |
def | __call__ |
def | __init__ |
def | getDefaultParameters |
def | toolCode |
Private Attributes | |
_comment | |
_parameters | |
self.addParameter(self._defaultParameters, 'jetCorrLabel', (pfTauJECpayloadMapping, ['L2Relative', 'L3Absolute']), "payload and list of new jet correction labels", tuple, acceptNoneValue = True) | |
Static Private Attributes | |
tuple | _defaultParameters = dicttypes.SortedKeysDict() |
string | _label = 'addTauCollection' |
Add a new collection of taus. Takes the configuration from the already configured standard tau collection as starting point; replaces before calling addTauCollection will also affect the new tau collections
Definition at line 348 of file tauTools.py.
def tauTools::AddTauCollection::__init__ | ( | self | ) |
Definition at line 357 of file tauTools.py.
00358 : 00359 ConfigToolBase.__init__(self) 00360 self.addParameter(self._defaultParameters, 'tauCollection', 00361 self._defaultValue, 'Input tau collection', cms.InputTag) 00362 self.addParameter(self._defaultParameters, 'algoLabel', 00363 self._defaultValue, "label to indicate the tau algorithm (e.g.'hps')", str) 00364 self.addParameter(self._defaultParameters, 'typeLabel', 00365 self._defaultValue, "label to indicate the type of constituents (either 'PFTau' or 'Tau')", str) 00366 self.addParameter(self._defaultParameters, 'doPFIsoDeposits', 00367 True, "run sequence for computing particle-flow based IsoDeposits") 00368 ##self.addParameter(self._defaultParameters, 'jetCorrLabel', 00369 ## (pfTauJECpayloadMapping, ['L2Relative', 'L3Absolute']), 00370 ## "payload and list of new jet correction labels", tuple, acceptNoneValue = True) 00371 self.addParameter(self._defaultParameters, 'jetCorrLabel', 00372 None, "payload and list of new jet correction labels", tuple, acceptNoneValue = True) 00373 self.addParameter(self._defaultParameters, 'standardAlgo', 00374 "hps", "standard algorithm label of the collection from which the clones " \ 00375 + "for the new tau collection will be taken from " \ 00376 + "(note that this tau collection has to be available in the event before hand)") 00377 self.addParameter(self._defaultParameters, 'standardType', 00378 "PFTau", "standard constituent type label of the collection from which the clones " \ 00379 + " for the new tau collection will be taken from "\ 00380 + "(note that this tau collection has to be available in the event before hand)") 00381 00382 self._parameters=copy.deepcopy(self._defaultParameters) 00383 self._comment = ""
def tauTools::AddTauCollection::__call__ | ( | self, | |
process, | |||
tauCollection = None , |
|||
algoLabel = None , |
|||
typeLabel = None , |
|||
doPFIsoDeposits = None , |
|||
jetCorrLabel = None , |
|||
standardAlgo = None , |
|||
standardType = None |
|||
) |
Definition at line 387 of file tauTools.py.
00395 : 00396 00397 if tauCollection is None: 00398 tauCollection = self._defaultParameters['tauCollection'].value 00399 if algoLabel is None: 00400 algoLabel = self._defaultParameters['algoLabel'].value 00401 if typeLabel is None: 00402 typeLabel = self._defaultParameters['typeLabel'].value 00403 if doPFIsoDeposits is None: 00404 doPFIsoDeposits = self._defaultParameters['doPFIsoDeposits'].value 00405 if jetCorrLabel is None: 00406 jetCorrLabel = self._defaultParameters['jetCorrLabel'].value 00407 if standardAlgo is None: 00408 standardAlgo = self._defaultParameters['standardAlgo'].value 00409 if standardType is None: 00410 standardType = self._defaultParameters['standardType'].value 00411 00412 self.setParameter('tauCollection', tauCollection) 00413 self.setParameter('algoLabel', algoLabel) 00414 self.setParameter('typeLabel', typeLabel) 00415 self.setParameter('doPFIsoDeposits', doPFIsoDeposits) 00416 self.setParameter('jetCorrLabel', jetCorrLabel) 00417 self.setParameter('standardAlgo', standardAlgo) 00418 self.setParameter('standardType', standardType) 00419 00420 self.apply(process)
def tauTools::AddTauCollection::getDefaultParameters | ( | self | ) |
Definition at line 384 of file tauTools.py.
def tauTools::AddTauCollection::toolCode | ( | self, | |
process | |||
) |
Definition at line 421 of file tauTools.py.
00422 : 00423 tauCollection = self._parameters['tauCollection'].value 00424 algoLabel = self._parameters['algoLabel'].value 00425 typeLabel = self._parameters['typeLabel'].value 00426 doPFIsoDeposits = self._parameters['doPFIsoDeposits'].value 00427 jetCorrLabel = self._parameters['jetCorrLabel'].value 00428 standardAlgo = self._parameters['standardAlgo'].value 00429 standardType = self._parameters['standardType'].value 00430 00431 ## disable computation of particle-flow based IsoDeposits 00432 ## in case tau is of CaloTau type 00433 if typeLabel == 'Tau': 00434 # print "NO PF Isolation will be computed for CaloTau (this could be improved later)" 00435 doPFIsoDeposits = False 00436 00437 ## create old module label from standardAlgo 00438 ## and standardType and return 00439 def oldLabel(prefix = ''): 00440 if prefix == '': 00441 return "patTaus" 00442 else: 00443 return prefix + "PatTaus" 00444 00445 ## capitalize first character of appended part 00446 ## when creating new module label 00447 ## (giving e.g. "patTausCaloRecoTau") 00448 def capitalize(label): 00449 return label[0].capitalize() + label[1:] 00450 00451 ## create new module label from old module 00452 ## label and return 00453 def newLabel(oldLabel): 00454 newLabel = oldLabel 00455 if ( oldLabel.find(standardAlgo) >= 0 and oldLabel.find(standardType) >= 0 ): 00456 oldLabel = oldLabel.replace(standardAlgo, algoLabel).replace(standardType, typeLabel) 00457 else: 00458 oldLabel = oldLabel + capitalize(algoLabel + typeLabel) 00459 return oldLabel 00460 00461 ## clone module and add it to the patDefaultSequence 00462 def addClone(hook, **replaceStatements): 00463 ## create a clone of the hook with corresponding 00464 ## parameter replacements 00465 newModule = getattr(process, hook).clone(**replaceStatements) 00466 ## add the module to the sequence 00467 addModuleToSequence(hook, newModule) 00468 00469 ## clone module for computing particle-flow IsoDeposits 00470 def addPFIsoDepositClone(hook, **replaceStatements): 00471 newModule = getattr(process, hook).clone(**replaceStatements) 00472 newModuleIsoDepositExtractor = getattr(newModule, "ExtractorPSet") 00473 setattr(newModuleIsoDepositExtractor, "tauSource", getattr(newModule, "src")) 00474 addModuleToSequence(hook, newModule) 00475 00476 ## add module to the patDefaultSequence 00477 def addModuleToSequence(hook, newModule): 00478 hookModule = getattr(process, hook) 00479 ## add the new module with standardAlgo & 00480 ## standardType replaced in module label 00481 setattr(process, newLabel(hook), newModule) 00482 ## add new module to default sequence 00483 ## just behind the hookModule 00484 process.patDefaultSequence.replace( hookModule, hookModule*newModule ) 00485 00486 ## add a clone of patTaus 00487 addClone(oldLabel(), tauSource = tauCollection) 00488 00489 ## add a clone of selectedPatTaus 00490 addClone(oldLabel('selected'), src = cms.InputTag(newLabel(oldLabel()))) 00491 00492 ## add a clone of cleanPatTaus 00493 addClone(oldLabel('clean'), src=cms.InputTag(newLabel(oldLabel('selected')))) 00494 00495 ## get attributes of new module 00496 newTaus = getattr(process, newLabel(oldLabel())) 00497 00498 ## add a clone of gen tau matching 00499 addClone('tauMatch', src = tauCollection) 00500 addClone('tauGenJetMatch', src = tauCollection) 00501 00502 ## add a clone of IsoDeposits computed based on particle-flow 00503 if doPFIsoDeposits: 00504 addPFIsoDepositClone('tauIsoDepositPFCandidates', src = tauCollection) 00505 addPFIsoDepositClone('tauIsoDepositPFChargedHadrons', src = tauCollection) 00506 addPFIsoDepositClone('tauIsoDepositPFNeutralHadrons', src = tauCollection) 00507 addPFIsoDepositClone('tauIsoDepositPFGammas', src = tauCollection) 00508 00509 if jetCorrLabel: 00510 addClone('patTauJetCorrFactors', src = tauCollection) 00511 getattr(process,newLabel('patTauJetCorrFactors')).payload = jetCorrLabel[0] 00512 getattr(process,newLabel('patTauJetCorrFactors')).levels = jetCorrLabel[1] 00513 getattr(process, newLabel('patTaus')).tauJetCorrFactorsSource = cms.VInputTag(cms.InputTag(newLabel('patTauJetCorrFactors'))) 00514 00515 ## fix label for input tag 00516 def fixInputTag(x): x.setModuleLabel(newLabel(x.moduleLabel)) 00517 00518 ## provide patTau inputs with individual labels 00519 fixInputTag(newTaus.genParticleMatch) 00520 fixInputTag(newTaus.genJetMatch) 00521 fixInputTag(newTaus.isoDeposits.pfAllParticles) 00522 fixInputTag(newTaus.isoDeposits.pfNeutralHadron) 00523 fixInputTag(newTaus.isoDeposits.pfChargedHadron) 00524 fixInputTag(newTaus.isoDeposits.pfGamma) 00525 fixInputTag(newTaus.userIsolation.pfAllParticles.src) 00526 fixInputTag(newTaus.userIsolation.pfNeutralHadron.src) 00527 fixInputTag(newTaus.userIsolation.pfChargedHadron.src) 00528 fixInputTag(newTaus.userIsolation.pfGamma.src) 00529 00530 ## set discriminators 00531 ## (using switchTauCollection functions) 00532 oldTaus = getattr(process, oldLabel()) 00533 # if typeLabel == 'Tau': 00534 # switchToCaloTau(process, 00535 # pfTauLabel = getattr(oldTaus, "tauSource"), 00536 # caloTauLabel = getattr(newTaus, "tauSource"), 00537 # patTauLabel = capitalize(algoLabel + typeLabel)) 00538 # else: 00539 switchToPFTauByType(process, pfTauType = algoLabel + typeLabel, 00540 pfTauLabelNew = getattr(newTaus, "tauSource"), 00541 pfTauLabelOld = getattr(oldTaus, "tauSource"), 00542 patTauLabel = capitalize(algoLabel + typeLabel)) 00543 addTauCollection=AddTauCollection()
tauTools::AddTauCollection::_comment [private] |
Definition at line 360 of file tauTools.py.
tuple tauTools::AddTauCollection::_defaultParameters = dicttypes.SortedKeysDict() [static, private] |
Definition at line 356 of file tauTools.py.
string tauTools::AddTauCollection::_label = 'addTauCollection' [static, private] |
Definition at line 355 of file tauTools.py.
tauTools::AddTauCollection::_parameters [private] |
self.addParameter(self._defaultParameters, 'jetCorrLabel', (pfTauJECpayloadMapping, ['L2Relative', 'L3Absolute']), "payload and list of new jet correction labels", tuple, acceptNoneValue = True)
Definition at line 360 of file tauTools.py.