CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
ElectronCalibrator.py
Go to the documentation of this file.
1 from math import *
2 
4  def __init__(self,label="calib"):
5  self._label = label
6  def correct(self,cmgelectron,dummy):
7  ele = cmgelectron.sourcePtr().get()
8  if not ele.hasUserFloat("p_"+self._label):
9  raise RuntimeError("Electron does not have an embedded energy scale correction with label '%s'" % self._label)
10  kind_in = ele.candidateP4Kind()
11  p4_in = ele.p4(kind_in)
12  pCalib = ele.userFloat("p_"+self._label)
13  pErrCalib = ele.userFloat("pError_"+self._label)
14  pKindCalib = ele.userInt("pKind_"+self._label)
15  ecalCalib = ele.userFloat("ecalEnergy_"+self._label)
16  eErrCalib = ele.userFloat("ecalEnergyError_"+self._label)
17  ele.setCorrectedEcalEnergy( ecalCalib )
18  ele.setCorrectedEcalEnergyError( eErrCalib )
19  p4_out = p4_in * (pCalib/p4_in.P())
20  ele.setP4(pKindCalib, p4_out, pErrCalib, True)
21  cmgelectron.setP4(p4_out)
22 
T get(const Candidate &c)
Definition: component.h:55