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