![]() |
![]() |
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 = '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 280 of file tauTools.py.
def tauTools::AddTauCollection::__init__ | ( | self | ) |
Definition at line 289 of file tauTools.py.
00290 : 00291 ConfigToolBase.__init__(self) 00292 self.addParameter(self._defaultParameters, 'tauCollection', 00293 self._defaultValue, 'Input tau collection', cms.InputTag) 00294 self.addParameter(self._defaultParameters, 'algoLabel', 00295 self._defaultValue, "label to indicate the tau algorithm (e.g.'shrinkingCone')", str) 00296 self.addParameter(self._defaultParameters, 'typeLabel', 00297 self._defaultValue, "label to indicate the type of constituents (either 'PFTau' or 'Tau')", str) 00298 self.addParameter(self._defaultParameters, 'doPFIsoDeposits', 00299 True, "run sequence for computing particle-flow based IsoDeposits") 00300 self.addParameter(self._defaultParameters, 'standardAlgo', 00301 "shrinkingCone", "standard algorithm label of the collection from which the clones " \ 00302 + "for the new tau collection will be taken from " \ 00303 + "(note that this tau collection has to be available in the event before hand)") 00304 self.addParameter(self._defaultParameters, 'standardType', 00305 "PFTau", "standard constituent type label of the collection from which the clones " \ 00306 + " for the new tau collection will be taken from "\ 00307 + "(note that this tau collection has to be available in the event before hand)") 00308 00309 self._parameters=copy.deepcopy(self._defaultParameters) 00310 self._comment = ""
def tauTools::AddTauCollection::__call__ | ( | self, | |
process, | |||
tauCollection = None , |
|||
algoLabel = None , |
|||
typeLabel = None , |
|||
doPFIsoDeposits = None , |
|||
standardAlgo = None , |
|||
standardType = None |
|||
) |
Definition at line 314 of file tauTools.py.
00321 : 00322 00323 if tauCollection is None: 00324 tauCollection = self._defaultParameters['tauCollection'].value 00325 if algoLabel is None: 00326 algoLabel = self._defaultParameters['algoLabel'].value 00327 if typeLabel is None: 00328 typeLabel = self._defaultParameters['typeLabel'].value 00329 if doPFIsoDeposits is None: 00330 doPFIsoDeposits = self._defaultParameters['doPFIsoDeposits'].value 00331 if standardAlgo is None: 00332 standardAlgo = self._defaultParameters['standardAlgo'].value 00333 if standardType is None: 00334 standardType = self._defaultParameters['standardType'].value 00335 00336 self.setParameter('tauCollection', tauCollection) 00337 self.setParameter('algoLabel', algoLabel) 00338 self.setParameter('typeLabel', typeLabel) 00339 self.setParameter('doPFIsoDeposits', doPFIsoDeposits) 00340 self.setParameter('standardAlgo', standardAlgo) 00341 self.setParameter('standardType', standardType) 00342 00343 self.apply(process)
def tauTools::AddTauCollection::getDefaultParameters | ( | self | ) |
Definition at line 311 of file tauTools.py.
def tauTools::AddTauCollection::toolCode | ( | self, | |
process | |||
) |
Definition at line 344 of file tauTools.py.
00344 : 00345 tauCollection = self._parameters['tauCollection'].value 00346 algoLabel = self._parameters['algoLabel'].value 00347 typeLabel = self._parameters['typeLabel'].value 00348 doPFIsoDeposits = self._parameters['doPFIsoDeposits'].value 00349 standardAlgo = self._parameters['standardAlgo'].value 00350 standardType = self._parameters['standardType'].value 00351 00352 ## disable computation of particle-flow based IsoDeposits 00353 ## in case tau is of CaloTau type 00354 if typeLabel == 'Tau': 00355 # print "NO PF Isolation will be computed for CaloTau (this could be improved later)" 00356 doPFIsoDeposits = False 00357 00358 ## create old module label from standardAlgo 00359 ## and standardType and return 00360 def oldLabel(prefix = ''): 00361 if prefix == '': 00362 return "patTaus" 00363 else: 00364 return prefix + "PatTaus" 00365 00366 ## capitalize first character of appended part 00367 ## when creating new module label 00368 ## (giving e.g. "patTausCaloRecoTau") 00369 def capitalize(label): 00370 return label[0].capitalize() + label[1:] 00371 00372 ## create new module label from old module 00373 ## label and return 00374 def newLabel(oldLabel): 00375 newLabel = oldLabel 00376 if ( oldLabel.find(standardAlgo) >= 0 and oldLabel.find(standardType) >= 0 ): 00377 oldLabel = oldLabel.replace(standardAlgo, algoLabel).replace(standardType, typeLabel) 00378 else: 00379 oldLabel = oldLabel + capitalize(algoLabel + typeLabel) 00380 return oldLabel 00381 00382 ## clone module and add it to the patDefaultSequence 00383 def addClone(hook, **replaceStatements): 00384 ## create a clone of the hook with corresponding 00385 ## parameter replacements 00386 newModule = getattr(process, hook).clone(**replaceStatements) 00387 ## add the module to the sequence 00388 addModuleToSequence(hook, newModule) 00389 00390 ## clone module for computing particle-flow IsoDeposits 00391 def addPFIsoDepositClone(hook, **replaceStatements): 00392 newModule = getattr(process, hook).clone(**replaceStatements) 00393 newModuleIsoDepositExtractor = getattr(newModule, "ExtractorPSet") 00394 setattr(newModuleIsoDepositExtractor, "tauSource", getattr(newModule, "src")) 00395 addModuleToSequence(hook, newModule) 00396 00397 ## add module to the patDefaultSequence 00398 def addModuleToSequence(hook, newModule): 00399 hookModule = getattr(process, hook) 00400 ## add the new module with standardAlgo & 00401 ## standardType replaced in module label 00402 setattr(process, newLabel(hook), newModule) 00403 ## add new module to default sequence 00404 ## just behind the hookModule 00405 process.patDefaultSequence.replace( hookModule, hookModule*newModule ) 00406 00407 ## add a clone of patTaus 00408 addClone(oldLabel(), tauSource = tauCollection) 00409 00410 ## add a clone of selectedPatTaus 00411 addClone(oldLabel('selected'), src = cms.InputTag(newLabel(oldLabel()))) 00412 00413 ## add a clone of cleanPatTaus 00414 addClone(oldLabel('clean'), src=cms.InputTag(newLabel(oldLabel('selected')))) 00415 00416 ## get attributes of new module 00417 newTaus = getattr(process, newLabel(oldLabel())) 00418 00419 ## add a clone of gen tau matching 00420 addClone('tauMatch', src = tauCollection) 00421 addClone('tauGenJetMatch', src = tauCollection) 00422 00423 ## add a clone of IsoDeposits computed based on particle-flow 00424 if doPFIsoDeposits: 00425 addPFIsoDepositClone('tauIsoDepositPFCandidates', src = tauCollection) 00426 addPFIsoDepositClone('tauIsoDepositPFChargedHadrons', src = tauCollection) 00427 addPFIsoDepositClone('tauIsoDepositPFNeutralHadrons', src = tauCollection) 00428 addPFIsoDepositClone('tauIsoDepositPFGammas', src = tauCollection) 00429 00430 ## fix label for input tag 00431 def fixInputTag(x): x.setModuleLabel(newLabel(x.moduleLabel)) 00432 00433 ## provide patTau inputs with individual labels 00434 fixInputTag(newTaus.genParticleMatch) 00435 fixInputTag(newTaus.genJetMatch) 00436 fixInputTag(newTaus.isoDeposits.pfAllParticles) 00437 fixInputTag(newTaus.isoDeposits.pfNeutralHadron) 00438 fixInputTag(newTaus.isoDeposits.pfChargedHadron) 00439 fixInputTag(newTaus.isoDeposits.pfGamma) 00440 fixInputTag(newTaus.userIsolation.pfAllParticles.src) 00441 fixInputTag(newTaus.userIsolation.pfNeutralHadron.src) 00442 fixInputTag(newTaus.userIsolation.pfChargedHadron.src) 00443 fixInputTag(newTaus.userIsolation.pfGamma.src) 00444 00445 ## set discriminators 00446 ## (using switchTauCollection functions) 00447 oldTaus = getattr(process, oldLabel()) 00448 # if typeLabel == 'Tau': 00449 # switchToCaloTau(process, 00450 # pfTauLabel = getattr(oldTaus, "tauSource"), 00451 # caloTauLabel = getattr(newTaus, "tauSource"), 00452 # patTauLabel = capitalize(algoLabel + typeLabel)) 00453 # else: 00454 switchToPFTauByType(process, pfTauType = algoLabel + typeLabel, 00455 pfTauLabelNew = getattr(newTaus, "tauSource"), 00456 pfTauLabelOld = getattr(oldTaus, "tauSource"), 00457 patTauLabel = capitalize(algoLabel + typeLabel)) 00458 00459 addTauCollection=AddTauCollection() 00460
tauTools::AddTauCollection::_comment [private] |
Definition at line 289 of file tauTools.py.
tuple tauTools::AddTauCollection::_defaultParameters = dicttypes.SortedKeysDict() [static, private] |
Definition at line 288 of file tauTools.py.
string tauTools::AddTauCollection::_label = 'addTauCollection' [static, private] |
Definition at line 287 of file tauTools.py.
tauTools::AddTauCollection::_parameters [private] |
Definition at line 289 of file tauTools.py.