CMS 3D CMS Logo

metTools.py
Go to the documentation of this file.
2 
3 from PhysicsTools.PatAlgos.tools.helpers import getPatAlgosToolsTask, addToProcessAndTask
4 
6  """
7  Tool to add alternative MET collection(s) to your PAT Tuple
8  """
9  _label='addMETCollection'
10  _defaultParameters=dicttypes.SortedKeysDict()
11 
12  def __init__(self):
13  """
14  Initialize elements of the class. Note that the tool needs to be derived from ConfigToolBase
15  to be usable in the configEditor.
16  """
17 
18  ConfigToolBase.__init__(self)
19 
20  self.addParameter(self._defaultParameters,'labelName',self._defaultValue, "Label name of the new patMET collection.", str)
21  self.addParameter(self._defaultParameters,'metSource',self._defaultValue, "Label of the input collection from which the new patMet collection should be created.", str)
22 
23  self._parameters=copy.deepcopy(self._defaultParameters)
24 
25  self._comment = "Add alternative MET collections as PAT object to your PAT Tuple"
26 
28  """
29  Return default parameters of the class
30  """
31  return self._defaultParameters
32 
33  def __call__(self,process,labelName=None,metSource=None):
34  """
35  Function call wrapper. This will check the parameters and call the actual implementation that
36  can be found in toolCode via the base class function apply.
37  """
38  if labelName is None:
39  labelName=self._defaultParameters['labelName'].value
40  self.setParameter('labelName', labelName)
41  if metSource is None:
42  metSource=self._defaultParameters['metSource'].value
43  self.setParameter('metSource', metSource)
44  self.apply(process)
45 
46  def toolCode(self, process):
47  """
48  Tool code implementation
49  """
50 
51  labelName=self._parameters['labelName'].value
52  metSource=self._parameters['metSource'].value
53 
55 
56  task = getPatAlgosToolsTask(process)
57  addToProcessAndTask(labelName, patMETs.clone(metSource = metSource, addMuonCorrections=False), process, task)
58 
59 
60  if hasattr(process, "out"):
61  process.out.outputCommands+=["keep *_{LABEL_NAME}_*_*".format(LABEL_NAME=labelName)]
62 
63 addMETCollection=AddMETCollection()
helpers.getPatAlgosToolsTask
def getPatAlgosToolsTask(process)
Definition: helpers.py:13
metTools.AddMETCollection.getDefaultParameters
def getDefaultParameters(self)
Definition: metTools.py:27
metTools.AddMETCollection._defaultParameters
_defaultParameters
Definition: metTools.py:10
metTools.AddMETCollection._comment
_comment
add comments
Definition: metTools.py:25
metTools.AddMETCollection._parameters
_parameters
initialization of the base class
Definition: metTools.py:23
metTools.AddMETCollection.__call__
def __call__(self, process, labelName=None, metSource=None)
Definition: metTools.py:33
metTools.AddMETCollection
Definition: metTools.py:5
metTools.AddMETCollection.toolCode
def toolCode(self, process)
Definition: metTools.py:46
ConfigToolBase
Definition: ConfigToolBase.py:1
metProducer_cfi
helpers
format
metTools.AddMETCollection.__init__
def __init__(self)
Definition: metTools.py:12
helpers.addToProcessAndTask
def addToProcessAndTask(label, module, process, task)
Definition: helpers.py:28
ConfigToolBase