def __init__(self, cfg_ana, cfg_comp, looperName): super(JetAnalyzer,self).__init__(cfg_ana, cfg_comp, looperName) mcGT = cfg_ana.mcGT if hasattr(cfg_ana,'mcGT') else "PHYS14_25_V2" dataGT = cfg_ana.dataGT if hasattr(cfg_ana,'dataGT') else "GR_70_V2_AN1" self.shiftJEC = self.cfg_ana.shiftJEC if hasattr(self.cfg_ana, 'shiftJEC') else 0 self.recalibrateJets = self.cfg_ana.recalibrateJets self.addJECShifts = self.cfg_ana.addJECShifts if self.recalibrateJets == "MC" : self.recalibrateJets = self.cfg_comp.isMC elif self.recalibrateJets == "Data": self.recalibrateJets = not self.cfg_comp.isMC elif self.recalibrateJets not in [True,False]: raise RuntimeError, "recalibrateJets must be any of { True, False, 'MC', 'Data' }, while it is %r " % self.recalibrateJets self.doJEC = self.recalibrateJets or (self.shiftJEC != 0) or self.addJECShifts if self.doJEC: doResidual = getattr(cfg_ana, 'applyL2L3Residual', 'Data') if doResidual == "MC": doResidual = self.cfg_comp.isMC elif doResidual == "Data": doResidual = not self.cfg_comp.isMC elif doResidual not in [True,False]: raise RuntimeError, "If specified, applyL2L3Residual must be any of { True, False, 'MC', 'Data'(default)}" if self.cfg_comp.isMC: self.jetReCalibrator = JetReCalibrator(mcGT,self.cfg_ana.recalibrationType, doResidual, cfg_ana.jecPath, calculateSeparateCorrections=getattr(cfg_ana,"calculateSeparateCorrections",False)) else: self.jetReCalibrator = JetReCalibrator(dataGT,self.cfg_ana.recalibrationType, doResidual, cfg_ana.jecPath, calculateSeparateCorrections=getattr(cfg_ana,"calculateSeparateCorrections",False)) self.doPuId = getattr(self.cfg_ana, 'doPuId', True) self.jetLepDR = getattr(self.cfg_ana, 'jetLepDR', 0.4) self.jetLepArbitration = getattr(self.cfg_ana, 'jetLepArbitration', lambda jet,lepton: lepton) self.lepPtMin = getattr(self.cfg_ana, 'minLepPt', -1) self.lepSelCut = getattr(self.cfg_ana, 'lepSelCut', lambda lep : True) self.jetGammaDR = getattr(self.cfg_ana, 'jetGammaDR', 0.4) if(self.cfg_ana.doQG): qgdefname="{CMSSW_BASE}/src/PhysicsTools/Heppy/data/pdfQG_AK4chs_antib_13TeV_v1.root" self.qglcalc = QGLikelihoodCalculator(getattr(self.cfg_ana,"QGpath",qgdefname).format(CMSSW_BASE= os.environ['CMSSW_BASE'])) if not hasattr(self.cfg_ana ,"collectionPostFix"):self.cfg_ana.collectionPostFix=""
def __init__(self, cfg_ana, cfg_comp, looperName): super(JetAnalyzer, self).__init__(cfg_ana, cfg_comp, looperName) mcGT = cfg_ana.mcGT if hasattr(cfg_ana, 'mcGT') else "PHYS14_25_V2" dataGT = cfg_ana.dataGT if hasattr(cfg_ana, 'dataGT') else "GR_70_V2_AN1" self.shiftJEC = self.cfg_ana.shiftJEC if hasattr( self.cfg_ana, 'shiftJEC') else 0 self.recalibrateJets = self.cfg_ana.recalibrateJets if self.recalibrateJets == "MC": self.recalibrateJets = self.cfg_comp.isMC elif self.recalibrateJets == "Data": self.recalibrateJets = not self.cfg_comp.isMC elif self.recalibrateJets not in [True, False]: raise RuntimeError, "recalibrateJets must be any of { True, False, 'MC', 'Data' }, while it is %r " % self.recalibrateJets self.doJEC = self.recalibrateJets or (self.shiftJEC != 0) if self.doJEC: if self.cfg_comp.isMC: self.jetReCalibrator = JetReCalibrator(mcGT, "AK4PFchs", False, cfg_ana.jecPath) else: self.jetReCalibrator = JetReCalibrator(dataGT, "AK4PFchs", True, cfg_ana.jecPath) self.doPuId = getattr(self.cfg_ana, 'doPuId', True) self.jetLepDR = getattr(self.cfg_ana, 'jetLepDR', 0.4) self.jetLepArbitration = getattr(self.cfg_ana, 'jetLepArbitration', lambda jet, lepton: lepton) self.lepPtMin = getattr(self.cfg_ana, 'minLepPt', -1) self.jetGammaDR = getattr(self.cfg_ana, 'jetGammaDR', 0.4) if (self.cfg_ana.doQG): self.qglcalc = QGLikelihoodCalculator( "/afs/cern.ch/user/t/tomc/public/qgTagger/QGLikelihoodDBFiles/QGL_v1a/pdfQG_AK4chs_antib_13TeV_v1.root" )
def __init__(self, cfg_ana, cfg_comp, looperName): super(JetAnalyzer, self).__init__(cfg_ana, cfg_comp, looperName) mcGT = cfg_ana.mcGT if hasattr(cfg_ana, 'mcGT') else "PHYS14_25_V2" dataGT = cfg_ana.dataGT if hasattr(cfg_ana, 'dataGT') else "GR_70_V2_AN1" self.shiftJEC = self.cfg_ana.shiftJEC if hasattr( self.cfg_ana, 'shiftJEC') else 0 self.recalibrateJets = self.cfg_ana.recalibrateJets if self.recalibrateJets == "MC": self.recalibrateJets = self.cfg_comp.isMC elif self.recalibrateJets == "Data": self.recalibrateJets = not self.cfg_comp.isMC elif self.recalibrateJets not in [True, False]: raise RuntimeError, "recalibrateJets must be any of { True, False, 'MC', 'Data' }, while it is %r " % self.recalibrateJets self.doJEC = self.recalibrateJets or (self.shiftJEC != 0) if self.doJEC: if self.cfg_comp.isMC: self.jetReCalibrator = JetReCalibrator(mcGT, "AK4PFchs", False, cfg_ana.jecPath) else: self.jetReCalibrator = JetReCalibrator(dataGT, "AK4PFchs", True, cfg_ana.jecPath) self.doPuId = self.cfg_ana.doPuId if hasattr(self.cfg_ana, 'doPuId') else True self.jetLepDR = self.cfg_ana.jetLepDR if hasattr( self.cfg_ana, 'jetLepDR') else 0.5 self.lepPtMin = self.cfg_ana.minLepPt if hasattr( self.cfg_ana, 'minLepPt') else -1 self.jetGammaDR = self.cfg_ana.jetGammaDR if hasattr( self.cfg_ana, 'jetGammaDR') else 0.4 if (self.cfg_ana.doQG): self.qglcalc = QGLikelihoodCalculator( "/afs/cern.ch/user/t/tomc/public/QG_pdfs_13TeV_2014-10-12/pdfQG_AK4chs_antib_NoQC_13TeV.root" )
def __init__(self, cfg_ana, cfg_comp, looperName): super(JetAnalyzer,self).__init__(cfg_ana, cfg_comp, looperName) mcGT = cfg_ana.mcGT if hasattr(cfg_ana,'mcGT') else [[-1,"PHYS14_25_V2"]] dataGT = cfg_ana.dataGT if hasattr(cfg_ana,'dataGT') else [[-1,"GR_70_V2_AN1"]] self.shiftJEC = self.cfg_ana.shiftJEC if hasattr(self.cfg_ana, 'shiftJEC') else 0 self.recalibrateJets = self.cfg_ana.recalibrateJets self.jetPtOrUpOrDnSelection = getattr(self.cfg_ana,'jetPtOrUpOrDnSelection',False) self.addJECShifts = getattr(self.cfg_ana, 'addJECShifts',False) or self.jetPtOrUpOrDnSelection if self.recalibrateJets == "MC" : self.recalibrateJets = self.cfg_comp.isMC elif self.recalibrateJets == "Data": self.recalibrateJets = not self.cfg_comp.isMC elif self.recalibrateJets not in [True,False]: raise RuntimeError, "recalibrateJets must be any of { True, False, 'MC', 'Data' }, while it is %r " % self.recalibrateJets calculateSeparateCorrections = getattr(cfg_ana,"calculateSeparateCorrections", False); calculateType1METCorrection = getattr(cfg_ana,"calculateType1METCorrection", False); self.doJEC = self.recalibrateJets or (self.shiftJEC != 0) or self.addJECShifts or calculateSeparateCorrections or calculateType1METCorrection if self.doJEC: doResidual = getattr(cfg_ana, 'applyL2L3Residual', 'Data') if doResidual == "MC": doResidual = self.cfg_comp.isMC elif doResidual == "Data": doResidual = not self.cfg_comp.isMC elif doResidual not in [True,False]: raise RuntimeError, "If specified, applyL2L3Residual must be any of { True, False, 'MC', 'Data'(default)}" GTs = getattr(cfg_comp, 'jecGT', mcGT if self.cfg_comp.isMC else dataGT) if type(GTs) == str: GTs = [ (-1, GTs) ] # Now take care of the optional arguments kwargs = { 'calculateSeparateCorrections':calculateSeparateCorrections, 'calculateType1METCorrection' :calculateType1METCorrection, } if kwargs['calculateType1METCorrection']: kwargs['type1METParams'] = cfg_ana.type1METParams # instantiate the jet re-calibrator self.jetReCalibrators=[] self.runsGT=[] for (run,GT) in GTs: self.jetReCalibrators.append(JetReCalibrator(GT, cfg_ana.recalibrationType, doResidual, cfg_ana.jecPath, **kwargs) ) self.runsGT.append(run) self.doPuId = getattr(self.cfg_ana, 'doPuId', True) self.matchJetsWithThreshold = getattr(self.cfg_ana, 'matchJetsWithThreshold', False) self.jetLepDR = getattr(self.cfg_ana, 'jetLepDR', 0.4) self.jetLepArbitration = getattr(self.cfg_ana, 'jetLepArbitration', lambda jet,lepton: lepton) self.lepPtMin = getattr(self.cfg_ana, 'minLepPt', -1) self.lepSelCut = getattr(self.cfg_ana, 'lepSelCut', lambda lep : True) self.jetGammaDR = getattr(self.cfg_ana, 'jetGammaDR', 0.4) self.jetGammaLepDR = getattr(self.cfg_ana, 'jetGammaLepDR', 0.4) self.cleanFromLepAndGammaSimultaneously = getattr(self.cfg_ana, 'cleanFromLepAndGammaSimultaneously', False) if self.cleanFromLepAndGammaSimultaneously: if hasattr(self.cfg_ana, 'jetGammaLepDR'): self.jetGammaLepDR = self.jetGammaLepDR elif (self.jetGammaDR == self.jetLepDR): self.jetGammaLepDR = self.jetGammaDR else: raise RuntimeError, "DR for simultaneous cleaning of jets from leptons and photons is not defined, and dR(gamma, jet)!=dR(lep, jet)" if(self.cfg_ana.doQG): qgdefname="{CMSSW_BASE}/src/PhysicsTools/Heppy/data/pdfQG_AK4chs_13TeV_cmssw8020_v2.root" self.qglcalc = QGLikelihoodCalculator(getattr(self.cfg_ana,"QGpath",qgdefname).format(CMSSW_BASE= os.environ['CMSSW_BASE'])) if not hasattr(self.cfg_ana ,"collectionPostFix"):self.cfg_ana.collectionPostFix=""
def __init__(self, cfg_ana, cfg_comp, looperName): super(JetAnalyzer, self).__init__(cfg_ana, cfg_comp, looperName) mcGT = cfg_ana.mcGT if hasattr(cfg_ana, 'mcGT') else "PHYS14_25_V2" dataGT = cfg_ana.dataGT if hasattr(cfg_ana, 'dataGT') else "GR_70_V2_AN1" self.shiftJEC = self.cfg_ana.shiftJEC if hasattr( self.cfg_ana, 'shiftJEC') else 0 self.recalibrateJets = self.cfg_ana.recalibrateJets if self.recalibrateJets == "MC": self.recalibrateJets = self.cfg_comp.isMC elif self.recalibrateJets == "Data": self.recalibrateJets = not self.cfg_comp.isMC elif self.recalibrateJets not in [True, False]: raise RuntimeError( "recalibrateJets must be any of { True, False, 'MC', 'Data' }, while it is %r " % self.recalibrateJets) self.doJEC = self.recalibrateJets or (self.shiftJEC != 0) if self.doJEC: if self.cfg_comp.isMC: self.jetReCalibrator = JetReCalibrator( mcGT, self.cfg_ana.recalibrationType, False, cfg_ana.jecPath) else: self.jetReCalibrator = JetReCalibrator( dataGT, self.cfg_ana.recalibrationType, True, cfg_ana.jecPath) self.doPuId = getattr(self.cfg_ana, 'doPuId', True) self.jetLepDR = getattr(self.cfg_ana, 'jetLepDR', 0.4) self.jetLepArbitration = getattr(self.cfg_ana, 'jetLepArbitration', lambda jet, lepton: lepton) self.lepPtMin = getattr(self.cfg_ana, 'minLepPt', -1) self.lepSelCut = getattr(self.cfg_ana, 'lepSelCut', lambda lep: True) self.jetGammaDR = getattr(self.cfg_ana, 'jetGammaDR', 0.4) if (self.cfg_ana.doQG): self.qglcalc = QGLikelihoodCalculator( "%s/src/PhysicsTools/Heppy/data/pdfQG_AK4chs_antib_13TeV_v1.root" % os.environ['CMSSW_BASE']) if not hasattr(self.cfg_ana, "collectionPostFix"): self.cfg_ana.collectionPostFix = ""
def __init__(self, cfg_ana, cfg_comp, looperName): self.debug = getattr(cfg_ana, 'debug', False) super(JetAnalyzer, self).__init__(cfg_ana, cfg_comp, looperName) mcGT = cfg_ana.mcGT if hasattr(cfg_ana, 'mcGT') else "PHYS14_25_V2" dataGT = cfg_ana.dataGT if hasattr(cfg_ana, 'dataGT') else "GR_70_V2_AN1" mcGT_jer = cfg_ana.mcGT_jer if hasattr( cfg_ana, 'mcGT_jer') else "Summer15_25nsV6_MC" dataGT_jer = cfg_ana.dataGT_jer if hasattr( cfg_ana, 'dataGT_jer') else "Summer15_25nsV6_DATA" self.shiftJEC = self.cfg_ana.shiftJEC if hasattr( self.cfg_ana, 'shiftJEC') else 0 self.recalibrateJets = self.cfg_ana.recalibrateJets self.addJECShifts = self.cfg_ana.addJECShifts if hasattr( self.cfg_ana, 'addJECShifts') else 0 if self.recalibrateJets == "MC": self.recalibrateJets = self.cfg_comp.isMC elif self.recalibrateJets == "Data": self.recalibrateJets = not self.cfg_comp.isMC elif self.recalibrateJets not in [True, False]: raise RuntimeError, "recalibrateJets must be any of { True, False, 'MC', 'Data' }, while it is %r " % self.recalibrateJets calculateSeparateCorrections = getattr(cfg_ana, "calculateSeparateCorrections", False) calculateType1METCorrection = getattr(cfg_ana, "calculateType1METCorrection", False) self.doJEC = self.recalibrateJets or ( self.shiftJEC != 0 ) or self.addJECShifts or calculateSeparateCorrections or calculateType1METCorrection if self.doJEC: if self.debug: print "[Debug] I am doing Jet energy calibration :D" doResidual = getattr(cfg_ana, 'applyL2L3Residual', 'Data') if doResidual == "MC": doResidual = self.cfg_comp.isMC elif doResidual == "Data": doResidual = not self.cfg_comp.isMC elif doResidual not in [True, False]: raise RuntimeError, "If specified, applyL2L3Residual must be any of { True, False, 'MC', 'Data'(default)}" GT = getattr(cfg_comp, 'jecGT', mcGT if self.cfg_comp.isMC else dataGT) GT_jer = getattr(cfg_comp, 'jerGT', mcGT_jer if self.cfg_comp.isMC else dataGT_jer) # Now take care of the optional arguments kwargs = { 'calculateSeparateCorrections': calculateSeparateCorrections, 'calculateType1METCorrection': calculateType1METCorrection, } if kwargs['calculateType1METCorrection']: kwargs['type1METParams'] = cfg_ana.type1METParams # instantiate the jet re-calibrator if self.debug: print "[Debug] check input for jetReCalibrator: tell me if it is MC -- %r; tell me the doResidual is %r\n" % ( self.cfg_comp.isMC, doResidual) self.jetReCalibrator = JetReCalibrator(GT, cfg_ana.recalibrationType, doResidual, cfg_ana.jecPath, **kwargs) self.smearJets = getattr(self.cfg_ana, 'smearJets', False) if self.smearJets: self.jetResolution = JetResolution(GT_jer, cfg_ana.recalibrationType, cfg_ana.jerPath) self.doPuId = getattr(self.cfg_ana, 'doPuId', True) self.jetLepDR = getattr(self.cfg_ana, 'jetLepDR', 0.4) self.jetLepArbitration = getattr(self.cfg_ana, 'jetLepArbitration', lambda jet, lepton: lepton) self.lepPtMin = getattr(self.cfg_ana, 'minLepPt', -1) self.lepSelCut = getattr(self.cfg_ana, 'lepSelCut', lambda lep: True) self.jetGammaDR = getattr(self.cfg_ana, 'jetGammaDR', 0.4) if (self.cfg_ana.doQG): qgdefname = "{CMSSW_BASE}/src/PhysicsTools/Heppy/data/pdfQG_AK4chs_13TeV_v2b.root" self.qglcalc = QGLikelihoodCalculator( getattr(self.cfg_ana, "QGpath", qgdefname).format(CMSSW_BASE=os.environ['CMSSW_BASE'])) if not hasattr(self.cfg_ana, "collectionPostFix"): self.cfg_ana.collectionPostFix = ""