CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
metTools.py
Go to the documentation of this file.
2 
4  """
5  Tool to add alternative MET collection(s) to your PAT Tuple
6  """
7  _label='addMETCollection'
8  _defaultParameters=dicttypes.SortedKeysDict()
9 
10  def __init__(self):
11  """
12  Initialize elements of the class. Note that the tool needs to be derived from ConfigToolBase
13  to be usable in the configEditor.
14  """
15  ## initialization of the base class
16  ConfigToolBase.__init__(self)
17  ## add all parameters that should be known to the class
18  self.addParameter(self._defaultParameters,'labelName',self._defaultValue, "Label name of the new patMET collection.", str)
19  self.addParameter(self._defaultParameters,'metSource',self._defaultValue, "Label of the input collection from which the new patMet collection should be created.", str)
20  ## set defaults
21  self._parameters=copy.deepcopy(self._defaultParameters)
22  ## add comments
23  self._comment = "Add alternative MET collections as PAT object to your PAT Tuple"
24 
26  """
27  Return default parameters of the class
28  """
29  return self._defaultParameters
30 
31  def __call__(self,process,labelName=None,metSource=None):
32  """
33  Function call wrapper. This will check the parameters and call the actual implementation that
34  can be found in toolCode via the base class function apply.
35  """
36  if labelName is None:
37  labelName=self._defaultParameters['labelName'].value
38  self.setParameter('labelName', labelName)
39  if metSource is None:
40  metSource=self._defaultParameters['metSource'].value
41  self.setParameter('metSource', metSource)
42  self.apply(process)
43 
44  def toolCode(self, process):
45  """
46  Tool code implementation
47  """
48  ## initialize parameters
49  labelName=self._parameters['labelName'].value
50  metSource=self._parameters['metSource'].value
51  ## do necessary imports
53  ## add module to the process
54  setattr(process, labelName, patMETs.clone(metSource = metSource, addMuonCorrections=False))
55  ## add module to output
56  if hasattr(process, "out"):
57  process.out.outputCommands+=["keep *_{LABEL_NAME}_*_*".format(LABEL_NAME=labelName)]
58 
59 addMETCollection=AddMETCollection()
_comment
add comments
Definition: metTools.py:23
_parameters
initialization of the base class
Definition: metTools.py:21