def calculate_cls(self, workspace_name): """ returns a dictionary of CLs values """ from scharmfit import utils utils.load_susyfit() from ROOT import Util from ROOT import RooStats if not isfile(workspace_name): raise OSError("can't find workspace {}".format(workspace_name)) workspace = Util.GetWorkspaceFromFile(workspace_name, 'combined') Util.SetInterpolationCode(workspace,4) # NOTE: We're completely silencing the fitter. Add an empty string # to the accept_strings to get all output. with OutputFilter(accept_strings={}): limit = RooStats.get_Pvalue( workspace, True, # doUL 1, # n_toys 2, # asymtotic calculator 3, # test type (3 is atlas standard) ) return dict( cls=limit.GetCLs(), cls_exp=limit.GetCLsexp(), cls_up_1_sigma=limit.GetCLsu1S(), cls_down_1_sigma=limit.GetCLsd1S(), cls_up_2_sigma=limit.GetCLsu2S(), cls_down_2_sigma=limit.GetCLsd2S())
def calculate_cls(self, workspace_name): """ returns a dictionary of CLs values """ from scharmfit import utils utils.load_susyfit() from ROOT import Util from ROOT import RooStats if not isfile(workspace_name): raise OSError("can't find workspace {}".format(workspace_name)) workspace = Util.GetWorkspaceFromFile(workspace_name, 'combined') Util.SetInterpolationCode(workspace,4) # NOTE: We're completely silencing the fitter. Add an empty string # to the accept_strings to get all output. with OutputFilter(accept_strings={}): limit = RooStats.get_Pvalue( workspace, True, # doUL 1, # n_toys 2, # asymtotic calculator 3, # test type (3 is atlas standard) ) ws_type = workspace_name.rsplit('_',1)[1].split('.')[0] if ws_type == self.nominal: return { 'obs':limit.GetCLs(), 'exp':limit.GetCLsexp(), 'exp_u1s':limit.GetCLsu1S(), 'exp_d1s':limit.GetCLsd1S(), } elif ws_type == self.up1s: return {'obs_u1s':limit.GetCLs()} elif ws_type == self.down1s: return {'obs_d1s':limit.GetCLs()} # should never get here raise ValueError('can\'t classify {} as type of limit'.format( workspace_name))