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 419 of file tauTools.py.
def tauTools::AddTauCollection::__init__ | ( | self | ) |
Definition at line 428 of file tauTools.py.
00429 : 00430 ConfigToolBase.__init__(self) 00431 self.addParameter(self._defaultParameters, 'tauCollection', 00432 self._defaultValue, 'Input tau collection', cms.InputTag) 00433 self.addParameter(self._defaultParameters, 'algoLabel', 00434 self._defaultValue, "label to indicate the tau algorithm (e.g.'hps')", str) 00435 self.addParameter(self._defaultParameters, 'typeLabel', 00436 self._defaultValue, "label to indicate the type of constituents (either 'PFTau' or 'Tau')", str) 00437 self.addParameter(self._defaultParameters, 'doPFIsoDeposits', 00438 True, "run sequence for computing particle-flow based IsoDeposits") 00439 ##self.addParameter(self._defaultParameters, 'jetCorrLabel', 00440 ## (pfTauJECpayloadMapping, ['L2Relative', 'L3Absolute']), 00441 ## "payload and list of new jet correction labels", tuple, acceptNoneValue = True) 00442 self.addParameter(self._defaultParameters, 'jetCorrLabel', 00443 None, "payload and list of new jet correction labels", tuple, acceptNoneValue = True) 00444 self.addParameter(self._defaultParameters, 'standardAlgo', 00445 "hps", "standard algorithm label of the collection from which the clones " \ 00446 + "for the new tau collection will be taken from " \ 00447 + "(note that this tau collection has to be available in the event before hand)") 00448 self.addParameter(self._defaultParameters, 'standardType', 00449 "PFTau", "standard constituent type label of the collection from which the clones " \ 00450 + " for the new tau collection will be taken from "\ 00451 + "(note that this tau collection has to be available in the event before hand)") 00452 00453 self._parameters=copy.deepcopy(self._defaultParameters) 00454 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 458 of file tauTools.py.
00466 : 00467 00468 if tauCollection is None: 00469 tauCollection = self._defaultParameters['tauCollection'].value 00470 if algoLabel is None: 00471 algoLabel = self._defaultParameters['algoLabel'].value 00472 if typeLabel is None: 00473 typeLabel = self._defaultParameters['typeLabel'].value 00474 if doPFIsoDeposits is None: 00475 doPFIsoDeposits = self._defaultParameters['doPFIsoDeposits'].value 00476 if jetCorrLabel is None: 00477 jetCorrLabel = self._defaultParameters['jetCorrLabel'].value 00478 if standardAlgo is None: 00479 standardAlgo = self._defaultParameters['standardAlgo'].value 00480 if standardType is None: 00481 standardType = self._defaultParameters['standardType'].value 00482 00483 self.setParameter('tauCollection', tauCollection) 00484 self.setParameter('algoLabel', algoLabel) 00485 self.setParameter('typeLabel', typeLabel) 00486 self.setParameter('doPFIsoDeposits', doPFIsoDeposits) 00487 self.setParameter('jetCorrLabel', jetCorrLabel) 00488 self.setParameter('standardAlgo', standardAlgo) 00489 self.setParameter('standardType', standardType) 00490 00491 self.apply(process)
def tauTools::AddTauCollection::getDefaultParameters | ( | self | ) |
Definition at line 455 of file tauTools.py.
def tauTools::AddTauCollection::toolCode | ( | self, | |
process | |||
) |
Definition at line 492 of file tauTools.py.
00493 : 00494 tauCollection = self._parameters['tauCollection'].value 00495 algoLabel = self._parameters['algoLabel'].value 00496 typeLabel = self._parameters['typeLabel'].value 00497 doPFIsoDeposits = self._parameters['doPFIsoDeposits'].value 00498 jetCorrLabel = self._parameters['jetCorrLabel'].value 00499 standardAlgo = self._parameters['standardAlgo'].value 00500 standardType = self._parameters['standardType'].value 00501 00502 ## disable computation of particle-flow based IsoDeposits 00503 ## in case tau is of CaloTau type 00504 if typeLabel == 'Tau': 00505 # print "NO PF Isolation will be computed for CaloTau (this could be improved later)" 00506 doPFIsoDeposits = False 00507 00508 ## create old module label from standardAlgo 00509 ## and standardType and return 00510 def oldLabel(prefix = ''): 00511 if prefix == '': 00512 return "patTaus" 00513 else: 00514 return prefix + "PatTaus" 00515 00516 ## capitalize first character of appended part 00517 ## when creating new module label 00518 ## (giving e.g. "patTausCaloRecoTau") 00519 def capitalize(label): 00520 return label[0].capitalize() + label[1:] 00521 00522 ## create new module label from old module 00523 ## label and return 00524 def newLabel(oldLabel): 00525 newLabel = oldLabel 00526 if ( oldLabel.find(standardAlgo) >= 0 and oldLabel.find(standardType) >= 0 ): 00527 oldLabel = oldLabel.replace(standardAlgo, algoLabel).replace(standardType, typeLabel) 00528 else: 00529 oldLabel = oldLabel + capitalize(algoLabel + typeLabel) 00530 return oldLabel 00531 00532 ## clone module and add it to the patDefaultSequence 00533 def addClone(hook, **replaceStatements): 00534 ## create a clone of the hook with corresponding 00535 ## parameter replacements 00536 newModule = getattr(process, hook).clone(**replaceStatements) 00537 ## add the module to the sequence 00538 addModuleToSequence(hook, newModule) 00539 00540 ## clone module for computing particle-flow IsoDeposits 00541 def addPFIsoDepositClone(hook, **replaceStatements): 00542 newModule = getattr(process, hook).clone(**replaceStatements) 00543 newModuleIsoDepositExtractor = getattr(newModule, "ExtractorPSet") 00544 setattr(newModuleIsoDepositExtractor, "tauSource", getattr(newModule, "src")) 00545 addModuleToSequence(hook, newModule) 00546 00547 ## add module to the patDefaultSequence 00548 def addModuleToSequence(hook, newModule): 00549 hookModule = getattr(process, hook) 00550 ## add the new module with standardAlgo & 00551 ## standardType replaced in module label 00552 setattr(process, newLabel(hook), newModule) 00553 ## add new module to default sequence 00554 ## just behind the hookModule 00555 process.patDefaultSequence.replace( hookModule, hookModule*newModule ) 00556 00557 ## add a clone of patTaus 00558 addClone(oldLabel(), tauSource = tauCollection) 00559 00560 ## add a clone of selectedPatTaus 00561 addClone(oldLabel('selected'), src = cms.InputTag(newLabel(oldLabel()))) 00562 00563 ## add a clone of cleanPatTaus 00564 addClone(oldLabel('clean'), src=cms.InputTag(newLabel(oldLabel('selected')))) 00565 00566 ## get attributes of new module 00567 newTaus = getattr(process, newLabel(oldLabel())) 00568 00569 ## add a clone of gen tau matching 00570 addClone('tauMatch', src = tauCollection) 00571 addClone('tauGenJetMatch', src = tauCollection) 00572 00573 ## add a clone of IsoDeposits computed based on particle-flow 00574 if doPFIsoDeposits: 00575 addPFIsoDepositClone('tauIsoDepositPFCandidates', src = tauCollection) 00576 addPFIsoDepositClone('tauIsoDepositPFChargedHadrons', src = tauCollection) 00577 addPFIsoDepositClone('tauIsoDepositPFNeutralHadrons', src = tauCollection) 00578 addPFIsoDepositClone('tauIsoDepositPFGammas', src = tauCollection) 00579 00580 if jetCorrLabel: 00581 addClone('patTauJetCorrFactors', src = tauCollection) 00582 getattr(process,newLabel('patTauJetCorrFactors')).payload = jetCorrLabel[0] 00583 getattr(process,newLabel('patTauJetCorrFactors')).levels = jetCorrLabel[1] 00584 getattr(process, newLabel('patTaus')).tauJetCorrFactorsSource = cms.VInputTag(cms.InputTag(newLabel('patTauJetCorrFactors'))) 00585 00586 ## fix label for input tag 00587 def fixInputTag(x): x.setModuleLabel(newLabel(x.moduleLabel)) 00588 00589 ## provide patTau inputs with individual labels 00590 fixInputTag(newTaus.genParticleMatch) 00591 fixInputTag(newTaus.genJetMatch) 00592 fixInputTag(newTaus.isoDeposits.pfAllParticles) 00593 fixInputTag(newTaus.isoDeposits.pfNeutralHadron) 00594 fixInputTag(newTaus.isoDeposits.pfChargedHadron) 00595 fixInputTag(newTaus.isoDeposits.pfGamma) 00596 fixInputTag(newTaus.userIsolation.pfAllParticles.src) 00597 fixInputTag(newTaus.userIsolation.pfNeutralHadron.src) 00598 fixInputTag(newTaus.userIsolation.pfChargedHadron.src) 00599 fixInputTag(newTaus.userIsolation.pfGamma.src) 00600 00601 ## set discriminators 00602 ## (using switchTauCollection functions) 00603 oldTaus = getattr(process, oldLabel()) 00604 # if typeLabel == 'Tau': 00605 # switchToCaloTau(process, 00606 # pfTauLabel = getattr(oldTaus, "tauSource"), 00607 # caloTauLabel = getattr(newTaus, "tauSource"), 00608 # patTauLabel = capitalize(algoLabel + typeLabel)) 00609 # else: 00610 switchToPFTauByType(process, pfTauType = algoLabel + typeLabel, 00611 pfTauLabelNew = getattr(newTaus, "tauSource"), 00612 pfTauLabelOld = getattr(oldTaus, "tauSource"), 00613 patTauLabel = capitalize(algoLabel + typeLabel)) 00614 00615 addTauCollection=AddTauCollection()
tauTools::AddTauCollection::_comment [private] |
Definition at line 431 of file tauTools.py.
tuple tauTools::AddTauCollection::_defaultParameters = dicttypes.SortedKeysDict() [static, private] |
Definition at line 427 of file tauTools.py.
string tauTools::AddTauCollection::_label = 'addTauCollection' [static, private] |
Definition at line 426 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 431 of file tauTools.py.