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 197 of file tauTools.py.
def tauTools::AddTauCollection::__init__ | ( | self | ) |
Definition at line 206 of file tauTools.py.
00207 : 00208 ConfigToolBase.__init__(self) 00209 self.addParameter(self._defaultParameters, 'tauCollection', 00210 self._defaultValue, 'Input tau collection', cms.InputTag) 00211 self.addParameter(self._defaultParameters, 'algoLabel', 00212 self._defaultValue, "label to indicate the tau algorithm (e.g.'hps')", str) 00213 self.addParameter(self._defaultParameters, 'typeLabel', 00214 self._defaultValue, "label to indicate the type of constituents (either 'PFTau' or 'Tau')", str) 00215 self.addParameter(self._defaultParameters, 'doPFIsoDeposits', 00216 True, "run sequence for computing particle-flow based IsoDeposits") 00217 self.addParameter(self._defaultParameters, 'standardAlgo', 00218 "hps", "standard algorithm label of the collection from which the clones " \ 00219 + "for the new tau collection will be taken from " \ 00220 + "(note that this tau collection has to be available in the event before hand)") 00221 self.addParameter(self._defaultParameters, 'standardType', 00222 "PFTau", "standard constituent type label of the collection from which the clones " \ 00223 + " for the new tau collection will be taken from "\ 00224 + "(note that this tau collection has to be available in the event before hand)") 00225 00226 self._parameters=copy.deepcopy(self._defaultParameters) 00227 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 231 of file tauTools.py.
00239 : 00240 00241 if tauCollection is None: 00242 tauCollection = self._defaultParameters['tauCollection'].value 00243 if algoLabel is None: 00244 algoLabel = self._defaultParameters['algoLabel'].value 00245 if typeLabel is None: 00246 typeLabel = self._defaultParameters['typeLabel'].value 00247 if doPFIsoDeposits is None: 00248 doPFIsoDeposits = self._defaultParameters['doPFIsoDeposits'].value 00249 if standardAlgo is None: 00250 standardAlgo = self._defaultParameters['standardAlgo'].value 00251 if standardType is None: 00252 standardType = self._defaultParameters['standardType'].value 00253 00254 self.setParameter('tauCollection', tauCollection) 00255 self.setParameter('algoLabel', algoLabel) 00256 self.setParameter('typeLabel', typeLabel) 00257 self.setParameter('doPFIsoDeposits', doPFIsoDeposits) 00258 self.setParameter('standardAlgo', standardAlgo) 00259 self.setParameter('standardType', standardType) 00260 00261 self.apply(process)
def tauTools::AddTauCollection::getDefaultParameters | ( | self | ) |
Definition at line 228 of file tauTools.py.
def tauTools::AddTauCollection::toolCode | ( | self, | |
process | |||
) |
Definition at line 262 of file tauTools.py.
00263 : 00264 tauCollection = self._parameters['tauCollection'].value 00265 algoLabel = self._parameters['algoLabel'].value 00266 typeLabel = self._parameters['typeLabel'].value 00267 doPFIsoDeposits = self._parameters['doPFIsoDeposits'].value 00268 standardAlgo = self._parameters['standardAlgo'].value 00269 standardType = self._parameters['standardType'].value 00270 00271 ## disable computation of particle-flow based IsoDeposits 00272 ## in case tau is of CaloTau type 00273 if typeLabel == 'Tau': 00274 print "NO PF Isolation will be computed for CaloTau (this could be improved later)" 00275 doPFIsoDeposits = False 00276 00277 ## create old module label from standardAlgo 00278 ## and standardType and return 00279 def oldLabel(prefix = ''): 00280 if prefix == '': 00281 return "patTaus" 00282 else: 00283 return prefix + "PatTaus" 00284 00285 ## capitalize first character of appended part 00286 ## when creating new module label 00287 ## (giving e.g. "patTausCaloRecoTau") 00288 def capitalize(label): 00289 return label[0].capitalize() + label[1:] 00290 00291 ## create new module label from old module 00292 ## label and return 00293 def newLabel(oldLabel): 00294 newLabel = oldLabel 00295 if ( oldLabel.find(standardAlgo) >= 0 and oldLabel.find(standardType) >= 0 ): 00296 oldLabel = oldLabel.replace(standardAlgo, algoLabel).replace(standardType, typeLabel) 00297 else: 00298 oldLabel = oldLabel + capitalize(algoLabel + typeLabel) 00299 return oldLabel 00300 00301 ## clone module and add it to the patDefaultSequence 00302 def addClone(hook, **replaceStatements): 00303 ## create a clone of the hook with corresponding 00304 ## parameter replacements 00305 newModule = getattr(process, hook).clone(**replaceStatements) 00306 00307 ## clone module for computing particle-flow IsoDeposits 00308 def addPFIsoDepositClone(hook, **replaceStatements): 00309 newModule = getattr(process, hook).clone(**replaceStatements) 00310 newModuleIsoDepositExtractor = getattr(newModule, "ExtractorPSet") 00311 setattr(newModuleIsoDepositExtractor, "tauSource", getattr(newModule, "src")) 00312 00313 ## add a clone of patTaus 00314 addClone(oldLabel(), tauSource = tauCollection) 00315 00316 ## add a clone of selectedPatTaus 00317 addClone(oldLabel('selected'), src = cms.InputTag(newLabel(oldLabel()))) 00318 00319 ## add a clone of cleanPatTaus 00320 addClone(oldLabel('clean'), src=cms.InputTag(newLabel(oldLabel('selected')))) 00321 00322 ## get attributes of new module 00323 newTaus = getattr(process, newLabel(oldLabel())) 00324 00325 ## add a clone of gen tau matching 00326 addClone('tauMatch', src = tauCollection) 00327 addClone('tauGenJetMatch', src = tauCollection) 00328 00329 ## add a clone of IsoDeposits computed based on particle-flow 00330 if doPFIsoDeposits: 00331 addPFIsoDepositClone('tauIsoDepositPFCandidates', src = tauCollection) 00332 addPFIsoDepositClone('tauIsoDepositPFChargedHadrons', src = tauCollection) 00333 addPFIsoDepositClone('tauIsoDepositPFNeutralHadrons', src = tauCollection) 00334 addPFIsoDepositClone('tauIsoDepositPFGammas', src = tauCollection) 00335 00336 ## fix label for input tag 00337 def fixInputTag(x): 00338 x.setModuleLabel(newLabel(x.moduleLabel)) 00339 00340 ## provide patTau inputs with individual labels 00341 fixInputTag(newTaus.genParticleMatch) 00342 fixInputTag(newTaus.genJetMatch) 00343 fixInputTag(newTaus.isoDeposits.pfAllParticles) 00344 fixInputTag(newTaus.isoDeposits.pfNeutralHadron) 00345 fixInputTag(newTaus.isoDeposits.pfChargedHadron) 00346 fixInputTag(newTaus.isoDeposits.pfGamma) 00347 fixInputTag(newTaus.userIsolation.pfAllParticles.src) 00348 fixInputTag(newTaus.userIsolation.pfNeutralHadron.src) 00349 fixInputTag(newTaus.userIsolation.pfChargedHadron.src) 00350 fixInputTag(newTaus.userIsolation.pfGamma.src) 00351 00352 ## set discriminators 00353 ## (using switchTauCollection functions) 00354 oldTaus = getattr(process, oldLabel()) 00355 if typeLabel == 'Tau': 00356 switchToCaloTau(process, 00357 tauSource = getattr(newTaus, "tauSource"), 00358 patTauLabel = capitalize(algoLabel + typeLabel)) 00359 else: 00360 switchToPFTauByType(process, pfTauType = algoLabel + typeLabel, 00361 tauSource = getattr(newTaus, "tauSource"), 00362 patTauLabel = capitalize(algoLabel + typeLabel)) 00363 00364 addTauCollection=AddTauCollection()
tauTools::AddTauCollection::_comment [private] |
Definition at line 206 of file tauTools.py.
tuple tauTools::AddTauCollection::_defaultParameters = dicttypes.SortedKeysDict() [static, private] |
Definition at line 205 of file tauTools.py.
string tauTools::AddTauCollection::_label = 'addTauCollection' [static, private] |
Definition at line 204 of file tauTools.py.
tauTools::AddTauCollection::_parameters [private] |
Definition at line 206 of file tauTools.py.