def __init__(self, year, passthrough=False, **kwargs): if not passthrough: if year == 2011: raise RuntimeWarning('TauIDScaleFactor 2011 is deprecated !') elif year == 2012: log.info("will apply 2012 ID SFs") from ROOT.TauAnalysisTools import TauEfficiencyCorrectionsTool # Medium id tool self.tool_medium = TauEfficiencyCorrectionsTool('tool_SF_med') self.tool_medium.setProperty('int')('IDLevel', 3) self.tool_medium.printConfig() self.tool_medium.initialize() # Tight id tool self.tool_tight = TauEfficiencyCorrectionsTool('tool_SF_tight') self.tool_tight.printConfig() self.tool_tight.initialize() self.passes = self.passes_2012 else: raise ValueError("No efficiency SFs for year %d" % year) super(TauIDScaleFactors, self).__init__( passthrough=passthrough, **kwargs)
def __init__(self, year, passthrough=False, **kwargs): if not passthrough: if year == 2011: raise RuntimeWarning('TauIDScaleFactor 2011 is deprecated !') elif year == 2012: log.info("will apply 2012 ID SFs") from ROOT.TauAnalysisTools import TauEfficiencyCorrectionsTool # Medium id tool self.tool_medium = TauEfficiencyCorrectionsTool('tool_SF_med') self.tool_medium.setProperty('int')('IDLevel', 3) self.tool_medium.printConfig() self.tool_medium.initialize() # Tight id tool self.tool_tight = TauEfficiencyCorrectionsTool('tool_SF_tight') self.tool_tight.printConfig() self.tool_tight.initialize() self.passes = self.passes_2012 else: raise ValueError("No efficiency SFs for year %d" % year) super(TauIDScaleFactors, self).__init__(passthrough=passthrough, **kwargs)
class TauIDScaleFactors(EventFilter): def __init__(self, year, passthrough=False, **kwargs): if not passthrough: if year == 2011: raise RuntimeWarning('TauIDScaleFactor 2011 is deprecated !') elif year == 2012: log.info("will apply 2012 ID SFs") from ROOT.TauAnalysisTools import TauEfficiencyCorrectionsTool # Medium id tool self.tool_medium = TauEfficiencyCorrectionsTool('tool_SF_med') self.tool_medium.setProperty('int')('IDLevel', 3) self.tool_medium.printConfig() self.tool_medium.initialize() # Tight id tool self.tool_tight = TauEfficiencyCorrectionsTool('tool_SF_tight') self.tool_tight.printConfig() self.tool_tight.initialize() self.passes = self.passes_2012 else: raise ValueError("No efficiency SFs for year %d" % year) super(TauIDScaleFactors, self).__init__( passthrough=passthrough, **kwargs) def get_id_2011(self, tau): raise ValueError("deprecated !") def get_id_tool(self, tau): if tau.id == IDLOOSE: raise RuntimeError('Need to instantiate the ID loose tool !') elif tau.id == IDMEDIUM: return self.tool_medium elif tau.id == IDTIGHT: return self.tool_tight raise ValueError("tau is not loose, medium, or tight") def passes_2011(self, event): raise RuntimeError('deprecated !') return True def passes_2012(self, event): for tau in event.taus: if not tau.matched: continue tool = self.get_id_tool(tau) tool.applyEfficiencyScaleFactor(tau) sf = tau.auxdataConst('double')('TauScaleFactorJetID') systs = tool.recommendedSystematics() sf_syst = {} for sys in systs: # Why do we have to use a systematic set ?? s_set = ROOT.CP.SystematicSet() s_set.insert(sys) sc = tool.applySystematicVariation(s_set) sc = tool.applyEfficiencyScaleFactor(tau) # print sc sf_syst[sys.name()] = tau.auxdataConst('double')('TauScaleFactorJetID') tau.id_sf = sf # tau.id_sf_high = sf # tau.id_sf_low = sf tau.id_sf_stat_high = sf_syst['TAUS_EFF_JETID_STAT__1up'] tau.id_sf_stat_low = sf_syst['TAUS_EFF_JETID_STAT__1down'] tau.id_sf_sys_high = sf_syst['TAUS_EFF_JETID_SYST__1up'] tau.id_sf_sys_low = sf_syst['TAUS_EFF_JETID_SYST__1down'] return True
class TauIDScaleFactors(EventFilter): def __init__(self, year, passthrough=False, **kwargs): if not passthrough: if year == 2011: raise RuntimeWarning('TauIDScaleFactor 2011 is deprecated !') elif year == 2012: log.info("will apply 2012 ID SFs") from ROOT.TauAnalysisTools import TauEfficiencyCorrectionsTool # Medium id tool self.tool_medium = TauEfficiencyCorrectionsTool('tool_SF_med') self.tool_medium.setProperty('int')('IDLevel', 3) self.tool_medium.printConfig() self.tool_medium.initialize() # Tight id tool self.tool_tight = TauEfficiencyCorrectionsTool('tool_SF_tight') self.tool_tight.printConfig() self.tool_tight.initialize() self.passes = self.passes_2012 else: raise ValueError("No efficiency SFs for year %d" % year) super(TauIDScaleFactors, self).__init__(passthrough=passthrough, **kwargs) def get_id_2011(self, tau): raise ValueError("deprecated !") def get_id_tool(self, tau): if tau.id == IDLOOSE: raise RuntimeError('Need to instantiate the ID loose tool !') elif tau.id == IDMEDIUM: return self.tool_medium elif tau.id == IDTIGHT: return self.tool_tight raise ValueError("tau is not loose, medium, or tight") def passes_2011(self, event): raise RuntimeError('deprecated !') return True def passes_2012(self, event): for tau in event.taus: if not tau.matched: continue tool = self.get_id_tool(tau) tool.applyEfficiencyScaleFactor(tau) sf = tau.auxdataConst('double')('TauScaleFactorJetID') systs = tool.recommendedSystematics() sf_syst = {} for sys in systs: # Why do we have to use a systematic set ?? s_set = ROOT.CP.SystematicSet() s_set.insert(sys) sc = tool.applySystematicVariation(s_set) sc = tool.applyEfficiencyScaleFactor(tau) # print sc sf_syst[sys.name()] = tau.auxdataConst('double')( 'TauScaleFactorJetID') tau.id_sf = sf # tau.id_sf_high = sf # tau.id_sf_low = sf tau.id_sf_stat_high = sf_syst['TAUS_EFF_JETID_STAT__1up'] tau.id_sf_stat_low = sf_syst['TAUS_EFF_JETID_STAT__1down'] tau.id_sf_sys_high = sf_syst['TAUS_EFF_JETID_SYST__1up'] tau.id_sf_sys_low = sf_syst['TAUS_EFF_JETID_SYST__1down'] return True