CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Private Attributes | Static Private Attributes
tauTools.AddTauCollection Class Reference
Inheritance diagram for tauTools.AddTauCollection:

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.

References electronTools.AddElectronUserIsolation._defaultParameters, photonTools.AddPhotonUserIsolation._defaultParameters, python.editorTools.UserCodeTool._defaultParameters, muonTools.AddMuonUserIsolation._defaultParameters, metTools.AddTcMET._defaultParameters, heavyIonTools.ConfigureHeavyIons._defaultParameters, coreTools.RestrictInputToAOD._defaultParameters, jetTools.RunBTagging._defaultParameters, python.Vispa.Plugins.ConfigEditor.ToolDataAccessor.ImportTool._defaultParameters, heavyIonTools.ProductionDefaults._defaultParameters, python.editorTools.ChangeSource._defaultParameters, metTools.AddPfMET._defaultParameters, coreTools.RunOnData._defaultParameters, coreTools.RemoveMCMatching._defaultParameters, cmsswVersionTools.RunBTagging35X._defaultParameters, heavyIonTools.SelectionDefaults._defaultParameters, heavyIonTools.DisbaleMonteCarloDeps._defaultParameters, jetTools.AddJetCollection._defaultParameters, coreTools.RemoveAllPATObjectsBut._defaultParameters, coreTools.RemoveSpecificPATObjects._defaultParameters, cmsswVersionTools.AddJetCollection35X._defaultParameters, tauTools.AddTauCollection._defaultParameters, coreTools.RemoveCleaning._defaultParameters, coreTools.AddCleaning._defaultParameters, jetTools.SwitchJetCollection._defaultParameters, cmsswVersionTools.SwitchJetCollection35X._defaultParameters, jetTools.AddJetID._defaultParameters, jetTools.SetTagInfos._defaultParameters, cmsswVersionTools.PickRelValInputFiles._defaultParameters, python.ConfigToolBase.ConfigToolBase._defaultValue, GenObject.GenObject._defaultValue, root::helper::RootFunctionAdapter< F, args >.addParameter(), root::helper::RootFunctionHelper< F, args, Tag >.addParameter(), ParameterMgr.addParameter(), fit::RootMinuit< Function >.addParameter(), PythonParameterSet.addParameter(), LutXml.addParameter(), python.ConfigToolBase.ConfigToolBase.addParameter(), and edm::ParameterSet.addParameter().

284  def __init__(self):
285  ConfigToolBase.__init__(self)
286  self.addParameter(self._defaultParameters, 'tauCollection',
287  self._defaultValue, 'Input tau collection', cms.InputTag)
288  self.addParameter(self._defaultParameters, 'algoLabel',
289  self._defaultValue, "label to indicate the tau algorithm (e.g.'shrinkingCone')", str)
290  self.addParameter(self._defaultParameters, 'typeLabel',
291  self._defaultValue, "label to indicate the type of constituents (either 'PFTau' or 'Tau')", str)
292  self.addParameter(self._defaultParameters, 'doPFIsoDeposits',
293  True, "run sequence for computing particle-flow based IsoDeposits")
294  self.addParameter(self._defaultParameters, 'standardAlgo',
295  "shrinkingCone", "standard algorithm label of the collection from which the clones " \
296  + "for the new tau collection will be taken from " \
297  + "(note that this tau collection has to be available in the event before hand)")
298  self.addParameter(self._defaultParameters, 'standardType',
299  "PFTau", "standard constituent type label of the collection from which the clones " \
300  + " for the new tau collection will be taken from "\
301  + "(note that this tau collection has to be available in the event before hand)")
302 
303  self._parameters=copy.deepcopy(self._defaultParameters)
304  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 314 of file tauTools.py.

References electronTools.AddElectronUserIsolation._defaultParameters, photonTools.AddPhotonUserIsolation._defaultParameters, metTools.AddTcMET._defaultParameters, muonTools.AddMuonUserIsolation._defaultParameters, python.editorTools.UserCodeTool._defaultParameters, heavyIonTools.ConfigureHeavyIons._defaultParameters, coreTools.RestrictInputToAOD._defaultParameters, jetTools.RunBTagging._defaultParameters, python.Vispa.Plugins.ConfigEditor.ToolDataAccessor.ImportTool._defaultParameters, heavyIonTools.ProductionDefaults._defaultParameters, python.editorTools.ChangeSource._defaultParameters, metTools.AddPfMET._defaultParameters, coreTools.RunOnData._defaultParameters, coreTools.RemoveMCMatching._defaultParameters, cmsswVersionTools.RunBTagging35X._defaultParameters, heavyIonTools.SelectionDefaults._defaultParameters, heavyIonTools.DisbaleMonteCarloDeps._defaultParameters, jetTools.AddJetCollection._defaultParameters, coreTools.RemoveAllPATObjectsBut._defaultParameters, coreTools.RemoveSpecificPATObjects._defaultParameters, cmsswVersionTools.AddJetCollection35X._defaultParameters, tauTools.AddTauCollection._defaultParameters, coreTools.RemoveCleaning._defaultParameters, coreTools.AddCleaning._defaultParameters, jetTools.SwitchJetCollection._defaultParameters, cmsswVersionTools.SwitchJetCollection35X._defaultParameters, jetTools.AddJetID._defaultParameters, jetTools.SetTagInfos._defaultParameters, cmsswVersionTools.PickRelValInputFiles._defaultParameters, SignedImpactParameter3D.apply(), SignedTransverseImpactParameter.apply(), SignedDecayLength3D.apply(), SurveyParameters.apply(), gen::PhotosInterface.apply(), FWPSetCellEditor.apply(), FWGUIEventFilter.apply(), DeviationsFromFileSensor2D.apply(), jetTools.RunBTagging.apply(), BeamSpotAlignmentParameters.apply(), RigidBodyAlignmentParameters.apply(), python.ConfigToolBase.ConfigToolBase.apply(), AlignmentParameters.apply(), BowedSurfaceAlignmentParameters.apply(), python.Vispa.Plugins.ConfigEditor.ToolDataAccessor.ImportTool.apply(), python.Vispa.Plugins.ConfigEditor.ToolDataAccessor.ApplyTool.apply(), TwoBowedSurfacesAlignmentParameters.apply(), python.Vispa.Gui.BoxContentDialog.BoxContentDialog.apply(), reco::modules::TrackerTrackHitFilter::Rule.apply(), python.Vispa.Plugins.ConfigEditor.ToolDialog.ToolDialog.apply(), reco::Add< T >.apply(), reco::Sub< T >.apply(), reco::Mul< T >.apply(), reco::Div< T >.apply(), reco::And< bool >.apply(), cmsswVersionTools.RunBTagging35X.apply(), reco::Or< bool >.apply(), reco::Less< T >.apply(), reco::LessEqual< T >.apply(), reco::More< T >.apply(), reco::MoreEqual< T >.apply(), reco::Equal< T >.apply(), cmsswVersionTools.PickRelValInputFiles.apply(), PedeReader.setParameter(), fit::RootMinuit< Function >.setParameter(), and python.ConfigToolBase.ConfigToolBase.setParameter().

Referenced by tauTools.AddTauCollection.getDefaultParameters().

315  standardType = None):
316 
317  if tauCollection is None:
318  tauCollection = self._defaultParameters['tauCollection'].value
319  if algoLabel is None:
320  algoLabel = self._defaultParameters['algoLabel'].value
321  if typeLabel is None:
322  typeLabel = self._defaultParameters['typeLabel'].value
323  if doPFIsoDeposits is None:
324  doPFIsoDeposits = self._defaultParameters['doPFIsoDeposits'].value
325  if standardAlgo is None:
326  standardAlgo = self._defaultParameters['standardAlgo'].value
327  if standardType is None:
328  standardType = self._defaultParameters['standardType'].value
329 
330  self.setParameter('tauCollection', tauCollection)
331  self.setParameter('algoLabel', algoLabel)
332  self.setParameter('typeLabel', typeLabel)
333  self.setParameter('doPFIsoDeposits', doPFIsoDeposits)
334  self.setParameter('standardAlgo', standardAlgo)
335  self.setParameter('standardType', standardType)
336 
337  self.apply(process)
def tauTools.AddTauCollection.getDefaultParameters (   self)

Definition at line 305 of file tauTools.py.

References tauTools.AddTauCollection.__call__(), electronTools.AddElectronUserIsolation._defaultParameters, photonTools.AddPhotonUserIsolation._defaultParameters, metTools.AddTcMET._defaultParameters, muonTools.AddMuonUserIsolation._defaultParameters, python.editorTools.UserCodeTool._defaultParameters, heavyIonTools.ConfigureHeavyIons._defaultParameters, coreTools.RestrictInputToAOD._defaultParameters, jetTools.RunBTagging._defaultParameters, python.Vispa.Plugins.ConfigEditor.ToolDataAccessor.ImportTool._defaultParameters, heavyIonTools.ProductionDefaults._defaultParameters, python.editorTools.ChangeSource._defaultParameters, metTools.AddPfMET._defaultParameters, coreTools.RunOnData._defaultParameters, coreTools.RemoveMCMatching._defaultParameters, cmsswVersionTools.RunBTagging35X._defaultParameters, heavyIonTools.SelectionDefaults._defaultParameters, heavyIonTools.DisbaleMonteCarloDeps._defaultParameters, jetTools.AddJetCollection._defaultParameters, coreTools.RemoveAllPATObjectsBut._defaultParameters, coreTools.RemoveSpecificPATObjects._defaultParameters, cmsswVersionTools.AddJetCollection35X._defaultParameters, tauTools.AddTauCollection._defaultParameters, coreTools.RemoveCleaning._defaultParameters, coreTools.AddCleaning._defaultParameters, jetTools.SwitchJetCollection._defaultParameters, cmsswVersionTools.SwitchJetCollection35X._defaultParameters, jetTools.AddJetID._defaultParameters, jetTools.SetTagInfos._defaultParameters, and cmsswVersionTools.PickRelValInputFiles._defaultParameters.

Referenced by trigTools.SwitchOnTrigger.toolCode(), trigTools.SwitchOnTriggerStandAlone.toolCode(), trigTools.SwitchOnTriggerMatching.toolCode(), and trigTools.SwitchOnTriggerMatchingStandAlone.toolCode().

306  def getDefaultParameters(self):
307  return self._defaultParameters
def tauTools.AddTauCollection.toolCode (   self,
  process 
)

Definition at line 338 of file tauTools.py.

References python.editorTools.UserCodeTool._parameters, electronTools.AddElectronUserIsolation._parameters, photonTools.AddPhotonUserIsolation._parameters, heavyIonTools.ConfigureHeavyIons._parameters, metTools.AddTcMET._parameters, muonTools.AddMuonUserIsolation._parameters, coreTools.RestrictInputToAOD._parameters, python.Vispa.Plugins.ConfigEditor.ConfigDataAccessor.ConfigFolder._parameters, jetTools.RunBTagging._parameters, python.Vispa.Plugins.ConfigEditor.ToolDataAccessor.ImportTool._parameters, heavyIonTools.ProductionDefaults._parameters, python.ConfigToolBase.ConfigToolBase._parameters, python.editorTools.ChangeSource._parameters, TAbsFitConstraint._parameters, metTools.AddPfMET._parameters, TAbsFitParticle._parameters, coreTools.RunOnData._parameters, coreTools.RemoveMCMatching._parameters, cmsswVersionTools.RunBTagging35X._parameters, heavyIonTools.SelectionDefaults._parameters, heavyIonTools.DisbaleMonteCarloDeps._parameters, jetTools.AddJetCollection._parameters, coreTools.RemoveAllPATObjectsBut._parameters, coreTools.RemoveSpecificPATObjects._parameters, cmsswVersionTools.AddJetCollection35X._parameters, tauTools.AddTauCollection._parameters, coreTools.RemoveCleaning._parameters, coreTools.AddCleaning._parameters, jetTools.SwitchJetCollection._parameters, cmsswVersionTools.SwitchJetCollection35X._parameters, jetTools.AddJetID._parameters, jetTools.SetTagInfos._parameters, cmsswVersionTools.PickRelValInputFiles._parameters, clone(), linker.replace(), and tauTools.switchToPFTauByType().

339  def toolCode(self, process):
340  tauCollection = self._parameters['tauCollection'].value
341  algoLabel = self._parameters['algoLabel'].value
342  typeLabel = self._parameters['typeLabel'].value
343  doPFIsoDeposits = self._parameters['doPFIsoDeposits'].value
344  standardAlgo = self._parameters['standardAlgo'].value
345  standardType = self._parameters['standardType'].value
346 
347  ## disable computation of particle-flow based IsoDeposits
348  ## in case tau is of CaloTau type
349  if typeLabel == 'Tau':
350 # print "NO PF Isolation will be computed for CaloTau (this could be improved later)"
351  doPFIsoDeposits = False
352 
353  ## create old module label from standardAlgo
354  ## and standardType and return
355  def oldLabel(prefix = ''):
356  if prefix == '':
357  return "patTaus"
358  else:
359  return prefix + "PatTaus"
360 
361  ## capitalize first character of appended part
362  ## when creating new module label
363  ## (giving e.g. "patTausCaloRecoTau")
364  def capitalize(label):
365  return label[0].capitalize() + label[1:]
366 
367  ## create new module label from old module
368  ## label and return
369  def newLabel(oldLabel):
370  newLabel = oldLabel
371  if ( oldLabel.find(standardAlgo) >= 0 and oldLabel.find(standardType) >= 0 ):
372  oldLabel = oldLabel.replace(standardAlgo, algoLabel).replace(standardType, typeLabel)
373  else:
374  oldLabel = oldLabel + capitalize(algoLabel + typeLabel)
375  return oldLabel
376 
377  ## clone module and add it to the patDefaultSequence
378  def addClone(hook, **replaceStatements):
379  ## create a clone of the hook with corresponding
380  ## parameter replacements
381  newModule = getattr(process, hook).clone(**replaceStatements)
382  ## add the module to the sequence
383  addModuleToSequence(hook, newModule)
384 
385  ## clone module for computing particle-flow IsoDeposits
386  def addPFIsoDepositClone(hook, **replaceStatements):
387  newModule = getattr(process, hook).clone(**replaceStatements)
388  newModuleIsoDepositExtractor = getattr(newModule, "ExtractorPSet")
389  setattr(newModuleIsoDepositExtractor, "tauSource", getattr(newModule, "src"))
390  addModuleToSequence(hook, newModule)
391 
392  ## add module to the patDefaultSequence
393  def addModuleToSequence(hook, newModule):
394  hookModule = getattr(process, hook)
395  ## add the new module with standardAlgo &
396  ## standardType replaced in module label
397  setattr(process, newLabel(hook), newModule)
398  ## add new module to default sequence
399  ## just behind the hookModule
400  process.patDefaultSequence.replace( hookModule, hookModule*newModule )
401 
402  ## add a clone of patTaus
403  addClone(oldLabel(), tauSource = tauCollection)
404 
405  ## add a clone of selectedPatTaus
406  addClone(oldLabel('selected'), src = cms.InputTag(newLabel(oldLabel())))
407 
408  ## add a clone of cleanPatTaus
409  addClone(oldLabel('clean'), src=cms.InputTag(newLabel(oldLabel('selected'))))
410 
411  ## get attributes of new module
412  newTaus = getattr(process, newLabel(oldLabel()))
413 
414  ## add a clone of gen tau matching
415  addClone('tauMatch', src = tauCollection)
416  addClone('tauGenJetMatch', src = tauCollection)
417 
418  ## add a clone of IsoDeposits computed based on particle-flow
419  if doPFIsoDeposits:
420  addPFIsoDepositClone('tauIsoDepositPFCandidates', src = tauCollection)
421  addPFIsoDepositClone('tauIsoDepositPFChargedHadrons', src = tauCollection)
422  addPFIsoDepositClone('tauIsoDepositPFNeutralHadrons', src = tauCollection)
423  addPFIsoDepositClone('tauIsoDepositPFGammas', src = tauCollection)
424 
425  ## fix label for input tag
426  def fixInputTag(x): x.setModuleLabel(newLabel(x.moduleLabel))
427 
428  ## provide patTau inputs with individual labels
429  fixInputTag(newTaus.genParticleMatch)
430  fixInputTag(newTaus.genJetMatch)
431  fixInputTag(newTaus.isoDeposits.pfAllParticles)
432  fixInputTag(newTaus.isoDeposits.pfNeutralHadron)
433  fixInputTag(newTaus.isoDeposits.pfChargedHadron)
434  fixInputTag(newTaus.isoDeposits.pfGamma)
435  fixInputTag(newTaus.userIsolation.pfAllParticles.src)
436  fixInputTag(newTaus.userIsolation.pfNeutralHadron.src)
437  fixInputTag(newTaus.userIsolation.pfChargedHadron.src)
438  fixInputTag(newTaus.userIsolation.pfGamma.src)
439 
440  ## set discriminators
441  ## (using switchTauCollection functions)
442  oldTaus = getattr(process, oldLabel())
443 # if typeLabel == 'Tau':
444 # switchToCaloTau(process,
445 # pfTauLabel = getattr(oldTaus, "tauSource"),
446 # caloTauLabel = getattr(newTaus, "tauSource"),
447 # patTauLabel = capitalize(algoLabel + typeLabel))
448 # else:
449  switchToPFTauByType(process, pfTauType = algoLabel + typeLabel,
450  pfTauLabelNew = getattr(newTaus, "tauSource"),
451  pfTauLabelOld = getattr(oldTaus, "tauSource"),
452  patTauLabel = capitalize(algoLabel + typeLabel))
453 
454 addTauCollection=AddTauCollection()
def replace
Definition: linker.py:10
T * clone(const T *tp)
Definition: Ptr.h:42
def switchToPFTauByType
Definition: tauTools.py:260

Member Data Documentation

tauTools.AddTauCollection._comment
private

Definition at line 303 of file tauTools.py.

tuple tauTools.AddTauCollection._defaultParameters = dicttypes.SortedKeysDict()
staticprivate

Definition at line 282 of file tauTools.py.

Referenced by HiCoreTools.RestrictInputToAOD.__call__(), trackTools.MakeAODTrackCandidates.__call__(), HiCoreTools.RemoveMCMatching.__call__(), trackTools.MakePATTrackCandidates.__call__(), trigTools.SwitchOnTrigger.__call__(), HiCoreTools.RemoveAllPATObjectsBut.__call__(), HiCoreTools.RemoveSpecificPATObjects.__call__(), trigTools.SwitchOnTriggerStandAlone.__call__(), trackTools.MakeTrackCandidates.__call__(), tauTools.AddTauCollection.__call__(), trigTools.SwitchOnTriggerMatching.__call__(), HiCoreTools.RemoveCleaning.__call__(), HiCoreTools.AddCleaning.__call__(), trigTools.SwitchOnTriggerMatchingStandAlone.__call__(), trigTools.SwitchOnTriggerMatchEmbedding.__call__(), trigTools.RemoveCleaningFromTriggerMatching.__call__(), trackTools.MakeAODTrackCandidates.__init__(), HiCoreTools.RestrictInputToAOD.__init__(), HiCoreTools.RemoveMCMatching.__init__(), trackTools.MakePATTrackCandidates.__init__(), trigTools.SwitchOnTrigger.__init__(), HiCoreTools.RemoveAllPATObjectsBut.__init__(), HiCoreTools.RemoveSpecificPATObjects.__init__(), trigTools.SwitchOnTriggerStandAlone.__init__(), trackTools.MakeTrackCandidates.__init__(), tauTools.AddTauCollection.__init__(), trigTools.SwitchOnTriggerMatching.__init__(), HiCoreTools.RemoveCleaning.__init__(), HiCoreTools.AddCleaning.__init__(), trigTools.SwitchOnTriggerMatchingStandAlone.__init__(), trigTools.SwitchOnTriggerMatchEmbedding.__init__(), trigTools.RemoveCleaningFromTriggerMatching.__init__(), python.ConfigToolBase.ConfigToolBase.getAllowedValues(), HiCoreTools.RestrictInputToAOD.getDefaultParameters(), trackTools.MakeAODTrackCandidates.getDefaultParameters(), HiCoreTools.RemoveMCMatching.getDefaultParameters(), trackTools.MakePATTrackCandidates.getDefaultParameters(), trigTools.SwitchOnTrigger.getDefaultParameters(), HiCoreTools.RemoveAllPATObjectsBut.getDefaultParameters(), HiCoreTools.RemoveSpecificPATObjects.getDefaultParameters(), trigTools.SwitchOnTriggerStandAlone.getDefaultParameters(), trackTools.MakeTrackCandidates.getDefaultParameters(), tauTools.AddTauCollection.getDefaultParameters(), trigTools.SwitchOnTriggerMatching.getDefaultParameters(), HiCoreTools.RemoveCleaning.getDefaultParameters(), HiCoreTools.AddCleaning.getDefaultParameters(), trigTools.SwitchOnTriggerMatchingStandAlone.getDefaultParameters(), trigTools.SwitchOnTriggerMatchEmbedding.getDefaultParameters(), trigTools.RemoveCleaningFromTriggerMatching.getDefaultParameters(), python.ConfigToolBase.ConfigToolBase.reset(), and python.ConfigToolBase.ConfigToolBase.setParameter().

string tauTools.AddTauCollection._label = 'addTauCollection'
staticprivate

Definition at line 281 of file tauTools.py.

Referenced by trigTools.SwitchOnTrigger.toolCode(), trigTools.SwitchOnTriggerStandAlone.toolCode(), trigTools.SwitchOnTriggerMatching.toolCode(), trigTools.SwitchOnTriggerMatchingStandAlone.toolCode(), trigTools.SwitchOnTriggerMatchEmbedding.toolCode(), and trigTools.RemoveCleaningFromTriggerMatching.toolCode().

tauTools.AddTauCollection._parameters
private

Definition at line 302 of file tauTools.py.

Referenced by HiCoreTools.RestrictInputToAOD.toolCode(), trackTools.MakeAODTrackCandidates.toolCode(), HiCoreTools.RemoveMCMatching.toolCode(), trackTools.MakePATTrackCandidates.toolCode(), trigTools.SwitchOnTrigger.toolCode(), HiCoreTools.RemoveAllPATObjectsBut.toolCode(), HiCoreTools.RemoveSpecificPATObjects.toolCode(), trigTools.SwitchOnTriggerStandAlone.toolCode(), trackTools.MakeTrackCandidates.toolCode(), tauTools.AddTauCollection.toolCode(), HiCoreTools.RemoveCleaning.toolCode(), trigTools.SwitchOnTriggerMatching.toolCode(), HiCoreTools.AddCleaning.toolCode(), trigTools.SwitchOnTriggerMatchingStandAlone.toolCode(), trigTools.SwitchOnTriggerMatchEmbedding.toolCode(), and trigTools.RemoveCleaningFromTriggerMatching.toolCode().