Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 13:32:28

0001 import ROOT
0002 import os.path
0003 ROOT.gSystem.Load("libEgammaAnalysisElectronTools")
0004 
0005 class Run2ElectronCalibrator:
0006     def __init__(self, data, gbrForest, isMC, isSync=False):
0007         self.epCombinationTool = ROOT.EpCombinationTool()
0008         self.epCombinationTool.init(os.path.expandvars(gbrForest[0]), gbrForest[1]) 
0009         self.random = ROOT.TRandom3()
0010         self.random.SetSeed(0) # make it really random across different jobs
0011         self.electronEnergyCalibratorRun2 = ROOT.ElectronEnergyCalibratorRun2(self.epCombinationTool, isMC, isSync, data)
0012         self.electronEnergyCalibratorRun2.initPrivateRng(self.random)
0013  
0014     def correct(self,electron,run):
0015         if not electron.validCandidateP4Kind(): return False # these can't be calibrated
0016         electron.uncalibratedP4 = electron.p4()
0017         electron.uncalibratedP4Error = electron.p4Error(electron.candidateP4Kind())
0018         self.electronEnergyCalibratorRun2.calibrate(electron.physObj, int(run))
0019         return True
0020