CMS 3D CMS Logo

Public Member Functions | Private Attributes | Static Private Attributes

tauTools::AddTauCollection Class Reference

Inherits FWCore::GuiBrowsers::ConfigToolBase::ConfigToolBase.

List of all members.

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'

Detailed Description

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 274 of file tauTools.py.


Constructor & Destructor Documentation

def tauTools::AddTauCollection::__init__ (   self)

Definition at line 283 of file tauTools.py.

00284                       :
00285         ConfigToolBase.__init__(self)
00286         self.addParameter(self._defaultParameters, 'tauCollection',
00287                           self._defaultValue, 'Input tau collection', cms.InputTag)
00288         self.addParameter(self._defaultParameters, 'algoLabel',
00289                           self._defaultValue, "label to indicate the tau algorithm (e.g.'shrinkingCone')", str)
00290         self.addParameter(self._defaultParameters, 'typeLabel',
00291                           self._defaultValue, "label to indicate the type of constituents (either 'PFTau' or 'Tau')", str)
00292         self.addParameter(self._defaultParameters, 'doPFIsoDeposits',
00293                           True, "run sequence for computing particle-flow based IsoDeposits")
00294         self.addParameter(self._defaultParameters, 'standardAlgo',
00295                           "shrinkingCone", "standard algorithm label of the collection from which the clones " \
00296                          + "for the new tau collection will be taken from " \
00297                          + "(note that this tau collection has to be available in the event before hand)")
00298         self.addParameter(self._defaultParameters, 'standardType',
00299                           "PFTau", "standard constituent type label of the collection from which the clones " \
00300                          + " for the new tau collection will be taken from "\
00301                          + "(note that this tau collection has to be available in the event before hand)")
00302         
00303         self._parameters=copy.deepcopy(self._defaultParameters)
00304         self._comment = ""
        

Member Function Documentation

def tauTools::AddTauCollection::__call__ (   self,
  process,
  tauCollection = None,
  algoLabel = None,
  typeLabel = None,
  doPFIsoDeposits = None,
  standardAlgo = None,
  standardType = None 
)

Definition at line 308 of file tauTools.py.

00315                                            :
00316 
00317         if tauCollection is None:
00318             tauCollection = self._defaultParameters['tauCollection'].value
00319         if algoLabel is None:
00320             algoLabel = self._defaultParameters['algoLabel'].value
00321         if typeLabel is None:
00322             typeLabel = self._defaultParameters['typeLabel'].value
00323         if doPFIsoDeposits is None:
00324             doPFIsoDeposits = self._defaultParameters['doPFIsoDeposits'].value
00325         if standardAlgo is None:
00326             standardAlgo = self._defaultParameters['standardAlgo'].value
00327         if standardType is None:
00328             standardType = self._defaultParameters['standardType'].value
00329 
00330         self.setParameter('tauCollection', tauCollection)
00331         self.setParameter('algoLabel', algoLabel)
00332         self.setParameter('typeLabel', typeLabel)
00333         self.setParameter('doPFIsoDeposits', doPFIsoDeposits)
00334         self.setParameter('standardAlgo', standardAlgo)
00335         self.setParameter('standardType', standardType)
00336    
00337         self.apply(process) 
        
def tauTools::AddTauCollection::getDefaultParameters (   self)

Definition at line 305 of file tauTools.py.

00306                                   :
00307         return self._defaultParameters

def tauTools::AddTauCollection::toolCode (   self,
  process 
)

Definition at line 338 of file tauTools.py.

00338                                :        
00339         tauCollection = self._parameters['tauCollection'].value
00340         algoLabel = self._parameters['algoLabel'].value
00341         typeLabel = self._parameters['typeLabel'].value
00342         doPFIsoDeposits = self._parameters['doPFIsoDeposits'].value
00343         standardAlgo = self._parameters['standardAlgo'].value
00344         standardType = self._parameters['standardType'].value
00345 
00346         ## disable computation of particle-flow based IsoDeposits
00347         ## in case tau is of CaloTau type
00348         if typeLabel == 'Tau':
00349 #            print "NO PF Isolation will be computed for CaloTau (this could be improved later)"
00350             doPFIsoDeposits = False
00351  
00352         ## create old module label from standardAlgo
00353         ## and standardType and return
00354         def oldLabel(prefix = ''):
00355             if prefix == '':
00356                 return "patTaus"
00357             else:
00358                 return prefix + "PatTaus"
00359 
00360         ## capitalize first character of appended part
00361         ## when creating new module label
00362         ## (giving e.g. "patTausCaloRecoTau")
00363         def capitalize(label):
00364             return label[0].capitalize() + label[1:]    
00365 
00366         ## create new module label from old module
00367         ## label and return
00368         def newLabel(oldLabel):
00369             newLabel = oldLabel
00370             if ( oldLabel.find(standardAlgo) >= 0 and oldLabel.find(standardType) >= 0 ):
00371                 oldLabel = oldLabel.replace(standardAlgo, algoLabel).replace(standardType, typeLabel)
00372             else:
00373                 oldLabel = oldLabel + capitalize(algoLabel + typeLabel)
00374             return oldLabel
00375 
00376         ## clone module and add it to the patDefaultSequence
00377         def addClone(hook, **replaceStatements):
00378             ## create a clone of the hook with corresponding
00379             ## parameter replacements
00380             newModule = getattr(process, hook).clone(**replaceStatements)
00381             ## add the module to the sequence
00382             addModuleToSequence(hook, newModule)
00383 
00384         ## clone module for computing particle-flow IsoDeposits
00385         def addPFIsoDepositClone(hook, **replaceStatements):
00386             newModule = getattr(process, hook).clone(**replaceStatements)
00387             newModuleIsoDepositExtractor = getattr(newModule, "ExtractorPSet")
00388             setattr(newModuleIsoDepositExtractor, "tauSource", getattr(newModule, "src"))
00389             addModuleToSequence(hook, newModule)
00390             
00391         ## add module to the patDefaultSequence
00392         def addModuleToSequence(hook, newModule):
00393             hookModule = getattr(process, hook)
00394             ## add the new module with standardAlgo &
00395             ## standardType replaced in module label
00396             setattr(process, newLabel(hook), newModule)
00397             ## add new module to default sequence
00398             ## just behind the hookModule
00399             process.patDefaultSequence.replace( hookModule, hookModule*newModule )        
00400 
00401         ## add a clone of patTaus
00402         addClone(oldLabel(), tauSource = tauCollection)
00403         
00404         ## add a clone of selectedPatTaus    
00405         addClone(oldLabel('selected'), src = cms.InputTag(newLabel(oldLabel())))
00406         
00407         ## add a clone of cleanPatTaus    
00408         addClone(oldLabel('clean'), src=cms.InputTag(newLabel(oldLabel('selected'))))
00409 
00410         ## get attributes of new module
00411         newTaus = getattr(process, newLabel(oldLabel()))
00412 
00413         ## add a clone of gen tau matching
00414         addClone('tauMatch', src = tauCollection)
00415         addClone('tauGenJetMatch', src = tauCollection)
00416 
00417         ## add a clone of IsoDeposits computed based on particle-flow
00418         if doPFIsoDeposits:
00419             addPFIsoDepositClone('tauIsoDepositPFCandidates', src = tauCollection)
00420             addPFIsoDepositClone('tauIsoDepositPFChargedHadrons', src = tauCollection)
00421             addPFIsoDepositClone('tauIsoDepositPFNeutralHadrons', src = tauCollection)
00422             addPFIsoDepositClone('tauIsoDepositPFGammas', src = tauCollection)
00423 
00424         ## fix label for input tag
00425         def fixInputTag(x): x.setModuleLabel(newLabel(x.moduleLabel))
00426 
00427         ## provide patTau inputs with individual labels
00428         fixInputTag(newTaus.genParticleMatch)
00429         fixInputTag(newTaus.genJetMatch)
00430         fixInputTag(newTaus.isoDeposits.pfAllParticles)
00431         fixInputTag(newTaus.isoDeposits.pfNeutralHadron)
00432         fixInputTag(newTaus.isoDeposits.pfChargedHadron)
00433         fixInputTag(newTaus.isoDeposits.pfGamma)
00434         fixInputTag(newTaus.userIsolation.pfAllParticles.src)
00435         fixInputTag(newTaus.userIsolation.pfNeutralHadron.src)
00436         fixInputTag(newTaus.userIsolation.pfChargedHadron.src)
00437         fixInputTag(newTaus.userIsolation.pfGamma.src)
00438         
00439         ## set discriminators
00440         ## (using switchTauCollection functions)
00441         oldTaus = getattr(process, oldLabel())
00442 #        if typeLabel == 'Tau':
00443 #            switchToCaloTau(process,
00444 #                            pfTauLabel = getattr(oldTaus, "tauSource"),
00445 #                            caloTauLabel = getattr(newTaus, "tauSource"),
00446 #                            patTauLabel = capitalize(algoLabel + typeLabel))
00447 #        else:
00448         switchToPFTauByType(process, pfTauType = algoLabel + typeLabel,
00449                                 pfTauLabelNew = getattr(newTaus, "tauSource"),
00450                                 pfTauLabelOld = getattr(oldTaus, "tauSource"),
00451                                 patTauLabel = capitalize(algoLabel + typeLabel))
00452        
00453 addTauCollection=AddTauCollection()
00454 

Member Data Documentation

Definition at line 283 of file tauTools.py.

tuple tauTools::AddTauCollection::_defaultParameters = dicttypes.SortedKeysDict() [static, private]

Definition at line 282 of file tauTools.py.

string tauTools::AddTauCollection::_label = 'addTauCollection' [static, private]

Definition at line 281 of file tauTools.py.

Definition at line 283 of file tauTools.py.