def setup_model(self, period, modelpath='mhmax-mu+200', modeltype='mssm_xsec'): """ Function to setup the model for the determination of crossection and brnachingratios arguments as period, modelpath and modeltype periode is one of '7TeV', '8TeV' modelpath corresponds to the file to be used for the model specified in modeltype - feyn_higgs_mssm : modelpath is the name of the model to be used (e.g. mhmax) - mssm_xsec_tools : modelpath is the name of the model to be used including uncerts (e.g mhmax-mu+200) modeltype can be 'mssm_xsec' or 'feyn_higgs' """ self.model = modeltype if modeltype == 'mssm_xsec': if float(self.tanb) < 1: tanbregion = 'tanbLow' else: tanbregion = 'tanbHigh' if not path.exists(getenv('CMSSW_BASE')+'/src/auxiliaries/models/out.'+modelpath+'-'+period+'-'+tanbregion+'-nnlo.root') : tanbregion = 'tanbAll' mssm_xsec_tools_path = getenv('CMSSW_BASE')+'/src/auxiliaries/models/out.'+modelpath+'-'+period+'-'+tanbregion+'-nnlo.root' scan = mssm_xsec_tools(mssm_xsec_tools_path) self.htt_query = scan.query(self.parameter1, self.tanb, self.ana_type) elif modeltype == 'hplus_xsec' : hplus_xsec_tools_path = getenv('CMSSW_BASE')+'/src/auxiliaries/models/hplus.'+modelpath+'-'+period+'-LHCHXSWG.root' scan = hplus_xsec_tools(hplus_xsec_tools_path) self.htt_query = scan.query(self.parameter1, self.tanb) elif modeltype == 'twohdm_xsec' : twohdm_xsec_tools_path = getenv('CMSSW_BASE')+'/src/auxiliaries/models/'+modelpath+'.root' scan = twohdm_xsec_tools(twohdm_xsec_tools_path) self.htt_query = scan.query(self.parameter1, self.tanb)
def mX_to_mA(card): match = re.compile( '(?P<CHN>[a-zA-Z0-9]+)_[a-zA-Z0-9]+_[0-9]+_(?P<PER>[a-zA-Z0-9]+)') for bin in card.list_of_bins(): ## a bin can be made up of different decay channels or different run periods. Pick decay channel (chn) and run period ## (per) either from bin or from from datacards name in case it is not accessible from bin. if match.match(bin): chn = match.match(bin).group('CHN') per = match.match(bin).group('PER') else: chn = match.match(path[path.rfind('/') + 1:]).group('CHN') per = match.match(path[path.rfind('/') + 1:]).group('PER') if options.ana_type == "Hhh": tanbregion = '' if options.modelname == "low-tb-high": tanbregion = 'tanbAll' else: if float(options.tanb) < 1: tanbregion = 'tanbLow' else: tanbregion = 'tanbHigh' mssm_xsec_tools_path = os.getenv( 'CMSSW_BASE' ) + '/src/auxiliaries/models/out.' + options.modelname + '-' + per + '-' + tanbregion + '-nnlo.root' prescan = mssm_xsec_tools(mssm_xsec_tools_path) Spline_input = ROOT.TGraph() k = 0 for mass in range(90, 1000): Spline_input.SetPoint( k, prescan.lookup_value(mass, float(options.tanb), "h_mH"), mass) k = k + 1 print "mH = ", options.parameter1, " / tanb = ", options.tanb, " => mA = ", Spline_input.Eval( float(options.parameter1)) return Spline_input.Eval(float(options.parameter1))
def mX_to_mA(card) : match = re.compile('(?P<CHN>[a-zA-Z0-9]+)_[a-zA-Z0-9]+_[0-9]+_(?P<PER>[a-zA-Z0-9]+)') for bin in card.list_of_bins() : ## a bin can be made up of different decay channels or different run periods. Pick decay channel (chn) and run period ## (per) either from bin or from from datacards name in case it is not accessible from bin. if match.match(bin) : chn = match.match(bin).group('CHN') per = match.match(bin).group('PER') else : chn = match.match(path[path.rfind('/')+1:]).group('CHN') per = match.match(path[path.rfind('/')+1:]).group('PER') if options.ana_type=="Hhh" : tanbregion = '' if float(options.tanb) < 1: tanbregion = 'tanbLow' else: tanbregion = 'tanbHigh' mssm_xsec_tools_path = os.getenv('CMSSW_BASE')+'/src/auxiliaries/models/out.'+options.modelname+'-'+per+'-'+tanbregion+'-nnlo.root' prescan = mssm_xsec_tools(mssm_xsec_tools_path) Spline_input = ROOT.TGraph() k=0 for mass in range(90, 1000) : Spline_input.SetPoint(k, prescan.lookup_value(mass, float(options.tanb), "h_mH"), mass) k=k+1 print "for mH = ", options.parameter1, " mA = ", Spline_input.Eval(float(options.parameter1)) return Spline_input.Eval(float(options.parameter1))
def setup_model(self, period, modelpath="mhmax-mu+200", modeltype="mssm_xsec"): """ Function to setup the model for the determination of crossection and brnachingratios arguments as period, modelpath and modeltype periode is one of '7TeV', '8TeV' modelpath corresponds to the file to be used for the model specified in modeltype - feyn_higgs_mssm : modelpath is the name of the model to be used (e.g. mhmax) - mssm_xsec_tools : modelpath is the name of the model to be used including uncerts (e.g mhmax-mu+200) modeltype can be 'mssm_xsec' or 'feyn_higgs' """ self.model = modeltype if modeltype == "mssm_xsec": if float(self.tanb) < 1: tanbregion = "tanbLow" else: tanbregion = "tanbHigh" mssm_xsec_tools_path = ( getenv("CMSSW_BASE") + "/src/auxiliaries/models/out." + modelpath + "-" + period + "-" + tanbregion + "-nnlo.root" ) scan = mssm_xsec_tools(mssm_xsec_tools_path) self.htt_query = scan.query(self.parameter1, self.tanb, self.ana_type) elif modeltype == "hplus_xsec": hplus_xsec_tools_path = ( getenv("CMSSW_BASE") + "/src/auxiliaries/models/hplus." + modelpath + "-" + period + "-LHCHXSWG.root" ) scan = hplus_xsec_tools(hplus_xsec_tools_path) self.htt_query = scan.query(self.parameter1, self.tanb)
def setup_model(self, period, modelpath='mhmax-mu+200', modeltype='mssm_xsec'): """ Function to setup the model for the determination of crossection and brnachingratios arguments as period, modelpath and modeltype periode is one of '7TeV', '8TeV' modelpath corresponds to the file to be used for the model specified in modeltype - mssm_xsec_tools : modelpath is the name of the model to be used including uncerts (e.g mhmax-mu+200) modeltype can be 'mssm_xsec' or 'twohdm_xsec' """ self.model = modeltype if modeltype == 'mssm_xsec': mssm_xsec_tools_path = getenv( 'CMSSW_BASE' ) + '/src/auxiliaries/models/' + modelpath + '_' + period + '.root' scan = mssm_xsec_tools(mssm_xsec_tools_path, 1, 0) self.htt_query = scan.query(self.parameter1, self.tanb, self.ana_type) elif modeltype == 'twohdm_xsec': twohdm_xsec_tools_path = getenv( 'CMSSW_BASE' ) + '/src/auxiliaries/models/' + modelpath + '.root' scan = twohdm_xsec_tools(twohdm_xsec_tools_path) self.htt_query = scan.query(self.parameter1, self.tanb) else: exit('ERROR: modeltype \'%s\' not supported' % modeltype)
def cross_section(process, mass, ecms) : """ Determine the SM cross section for given process, higgs boson mass and center of mass energy. For MSSM the mass will be accompanied by the tanb value in format ma:tanb, the MSSM BR is also expected to be of format BR:[AHh]tt. """ xs = 0. if options.analysis == "sm" : if process.find('+')>-1 : sub_channels = process.split('+') for sub_channel in sub_channels : xs += float(os.popen("xsec-sm {CHANNEL} {MA} {ECMS} | grep value".format( CHANNEL=sub_channel, MA=mass, ECMS=ecms)).read().split()[2]) else : xs += float(os.popen("xsec-sm {CHANNEL} {MA} {ECMS} | grep value".format( CHANNEL=process, MA=mass, ECMS=ecms)).read().split()[2]) else : period = '' if ecms == 7.0 : period = '7TeV' else : period = '8TeV' mssm_xsec_tools_path = os.environ.get('CMSSW_BASE')+'/src/auxiliaries/models/out.mhmax-mu+200-'+period+'-tanbHigh-nnlo.root' scan = mssm_xsec_tools(mssm_xsec_tools_path) xsquery = scan.query(float(mass[:mass.find(':')]), float(mass[mass.find(':')+1:])) if "BR" in process : xs = xsquery['higgses']['A']['BR'] else : if "bbA" in process : xs = xsquery['higgses']['A']['xsec']['santander'] elif "ggA" in process : xs = xsquery['higgses']['A']['xsec']['ggF'] return xs
def load_masses(mA, tanb) : """ Fill mh and mH depending on mA. These values are calculated from the htt tools. """ ## read cross section results for htt scan = mssm_xsec_tools("{CMSSW_BASE}/src/{path}".format(CMSSW_BASE=os.environ['CMSSW_BASE'], path="HiggsAnalysis/HiggsToTauTau/data/out.mhmax-mu+200-7-nnlo.root")) htt_query = scan.query(mA, tanb) mh = htt_query['higgses']['h']['mass'] mH = htt_query['higgses']['H']['mass'] return (mh, mH)
def load_masses(mA, tanb): """ Fill mh and mH depending on mA. These values are calculated from the htt tools. """ ## read cross section results for htt scan = mssm_xsec_tools("{CMSSW_BASE}/src/{path}".format( CMSSW_BASE=os.environ['CMSSW_BASE'], path="HiggsAnalysis/HiggsToTauTau/data/out.mhmax-mu+200-7-nnlo.root")) htt_query = scan.query(mA, tanb) mh = htt_query['higgses']['h']['mass'] mH = htt_query['higgses']['H']['mass'] return (mh, mH)
def cross_section(process, mass, ecms): """ Determine the SM cross section for given process, higgs boson mass and center of mass energy. For MSSM the mass will be accompanied by the tanb value in format ma:tanb, the MSSM BR is also expected to be of format BR:[AHh]tt. """ xs = 0.0 if options.analysis == "sm": if process.find("+") > -1: sub_channels = process.split("+") for sub_channel in sub_channels: xs += float( os.popen( "xsec-sm {CHANNEL} {MA} {ECMS} | grep value".format(CHANNEL=sub_channel, MA=mass, ECMS=ecms) ) .read() .split()[2] ) else: xs += float( os.popen("xsec-sm {CHANNEL} {MA} {ECMS} | grep value".format(CHANNEL=process, MA=mass, ECMS=ecms)) .read() .split()[2] ) else: period = "" if ecms == 7.0: period = "7TeV" else: period = "8TeV" mssm_xsec_tools_path = ( os.environ.get("CMSSW_BASE") + "/src/auxiliaries/models/out.mhmax-mu+200-" + period + "-tanbHigh-nnlo.root" ) scan = mssm_xsec_tools(mssm_xsec_tools_path) xsquery = scan.query(float(mass[: mass.find(":")]), float(mass[mass.find(":") + 1 :])) if "BR" in process: xs = xsquery["higgses"]["A"]["BR"] else: if "bbA" in process: xs = xsquery["higgses"]["A"]["xsec"]["santander"] elif "ggA" in process: xs = xsquery["higgses"]["A"]["xsec"]["ggF"] return xs
def setup_model(self, period, modelpath='mhmax-mu+200', modeltype='mssm_xsec'): """ Function to setup the model for the determination of crossection and brnachingratios arguments as period, modelpath and modeltype periode is one of '7TeV', '8TeV' modelpath corresponds to the file to be used for the model specified in modeltype - feyn_higgs_mssm : modelpath is the name of the model to be used (e.g. mhmax) - mssm_xsec_tools : modelpath is the name of the model to be used including uncerts (e.g mhmax-mu+200) modeltype can be 'mssm_xsec' or 'feyn_higgs' """ self.model = modeltype if modeltype == 'mssm_xsec': if float(self.tanb) < 1: tanbregion = 'tanbLow' else: tanbregion = 'tanbHigh' if not path.exists( getenv('CMSSW_BASE') + '/src/auxiliaries/models/out.' + modelpath + '-' + period + '-' + tanbregion + '-nnlo.root'): tanbregion = 'tanbAll' mssm_xsec_tools_path = getenv( 'CMSSW_BASE' ) + '/src/auxiliaries/models/out.' + modelpath + '-' + period + '-' + tanbregion + '-nnlo.root' scan = mssm_xsec_tools(mssm_xsec_tools_path) self.htt_query = scan.query(self.parameter1, self.tanb, self.ana_type) elif modeltype == 'hplus_xsec': hplus_xsec_tools_path = getenv( 'CMSSW_BASE' ) + '/src/auxiliaries/models/hplus.' + modelpath + '-' + period + '-LHCHXSWG.root' scan = hplus_xsec_tools(hplus_xsec_tools_path) self.htt_query = scan.query(self.parameter1, self.tanb) elif modeltype == 'twohdm_xsec': twohdm_xsec_tools_path = getenv( 'CMSSW_BASE' ) + '/src/auxiliaries/models/' + modelpath + '.root' scan = twohdm_xsec_tools(twohdm_xsec_tools_path) self.htt_query = scan.query(self.parameter1, self.tanb)
def setup_model(self, period, modelpath='mhmax-mu+200', modeltype='mssm_xsec'): """ Function to setup the model for the determination of crossection and brnachingratios arguments as period, modelpath and modeltype periode is one of '7TeV', '8TeV' modelpath corresponds to the file to be used for the model specified in modeltype - mssm_xsec_tools : modelpath is the name of the model to be used including uncerts (e.g mhmax-mu+200) modeltype can be 'mssm_xsec' or 'twohdm_xsec' """ self.model = modeltype if modeltype == 'mssm_xsec': mssm_xsec_tools_path = getenv('CMSSW_BASE')+'/src/auxiliaries/models/'+modelpath+'_'+period+'.root' scan = mssm_xsec_tools(mssm_xsec_tools_path, 1, 0) self.htt_query = scan.query(self.parameter1, self.tanb, self.ana_type) elif modeltype == 'twohdm_xsec' : twohdm_xsec_tools_path = getenv('CMSSW_BASE')+'/src/auxiliaries/models/'+modelpath+'.root' scan = twohdm_xsec_tools(twohdm_xsec_tools_path) self.htt_query = scan.query(self.parameter1, self.tanb) else : exit('ERROR: modeltype \'%s\' not supported'%modeltype)
def mX_to_mA(card): match = re.compile("(?P<CHN>[a-zA-Z0-9]+)_[a-zA-Z0-9]+_[0-9]+_(?P<PER>[a-zA-Z0-9]+)") for bin in card.list_of_bins(): ## a bin can be made up of different decay channels or different run periods. Pick decay channel (chn) and run period ## (per) either from bin or from from datacards name in case it is not accessible from bin. if match.match(bin): chn = match.match(bin).group("CHN") per = match.match(bin).group("PER") else: chn = match.match(path[path.rfind("/") + 1 :]).group("CHN") per = match.match(path[path.rfind("/") + 1 :]).group("PER") if options.ana_type == "Hhh": tanbregion = "" if options.modelname == "low-tb-high": tanbregion = "tanbAll" else: if float(options.tanb) < 1: tanbregion = "tanbLow" else: tanbregion = "tanbHigh" mssm_xsec_tools_path = ( os.getenv("CMSSW_BASE") + "/src/auxiliaries/models/out." + options.modelname + "-" + per + "-" + tanbregion + "-nnlo.root" ) prescan = mssm_xsec_tools(mssm_xsec_tools_path) Spline_input = ROOT.TGraph() k = 0 for mass in range(90, 1000): Spline_input.SetPoint(k, prescan.lookup_value(mass, float(options.tanb), "h_mH"), mass) k = k + 1 print "mH = ", options.parameter1, " / tanb = ", options.tanb, " => mA = ", Spline_input.Eval( float(options.parameter1) ) return Spline_input.Eval(float(options.parameter1))
def cross_section(process, mass, ecms): """ Determine the SM cross section for given process, higgs boson mass and center of mass energy. For MSSM the mass will be accompanied by the tanb value in format ma:tanb, the MSSM BR is also expected to be of format BR:[AHh]tt. """ xs = 0. if options.analysis == "sm": if process.find('+') > -1: sub_channels = process.split('+') for sub_channel in sub_channels: xs += float( os.popen( "xsec-sm {CHANNEL} {MA} {ECMS} | grep value".format( CHANNEL=sub_channel, MA=mass, ECMS=ecms)).read().split()[2]) else: xs += float( os.popen("xsec-sm {CHANNEL} {MA} {ECMS} | grep value".format( CHANNEL=process, MA=mass, ECMS=ecms)).read().split()[2]) else: period = '' if ecms == 7.0: period = '7TeV' else: period = '8TeV' mssm_xsec_tools_path = os.environ.get( 'CMSSW_BASE' ) + '/src/auxiliaries/models/out.mhmax-mu+200-' + period + '-tanbHigh-nnlo.root' scan = mssm_xsec_tools(mssm_xsec_tools_path) xsquery = scan.query(float(mass[:mass.find(':')]), float(mass[mass.find(':') + 1:])) if "BR" in process: xs = xsquery['higgses']['A']['BR'] else: if "bbA" in process: xs = xsquery['higgses']['A']['xsec']['santander'] elif "ggA" in process: xs = xsquery['higgses']['A']['xsec']['ggF'] return xs
def setup_model(self, period, modelpath='mhmax-mu+200', modeltype='mssm_xsec'): """ Function to setup the model for the determination of crossection and brnachingratios arguments as period, modelpath and modeltype periode is one of '7TeV', '8TeV' modelpath corresponds to the file to be used for the model specified in modeltype - feyn_higgs_mssm : modelpath is the name of the model to be used (e.g. mhmax) - mssm_xsec_tools : modelpath is the name of the model to be used including uncerts (e.g mhmax-mu+200) modeltype can be 'mssm_xsec' or 'feyn_higgs' or 'mssm_Hp_xsec' """ if modelpath == 'mssm_Hp_xsec' : modeltype = modelpath print "[ModelParams_BASE] Self: ", self print "[ModelParams_BASE] Period: ", period print "[ModelParams_BASE] Modelpath: ", modelpath print "[ModelParams_BASE] Modeltype: ", modeltype self.model = modeltype print "[ModelParams_BASE] self.model after: ", self.model if modeltype == 'mssm_xsec': if float(self.tanb) < 1: tanbregion = 'tanbLow' else: tanbregion = 'tanbHigh' mssm_xsec_tools_path = getenv('CMSSW_BASE')+'/src/auxiliaries/models/out.'+modelpath+'-'+period+'-'+tanbregion+'-nnlo.root' print "File opened: ", mssm_xsec_tools_path scan = mssm_xsec_tools(mssm_xsec_tools_path) self.htt_query = scan.query(self.mA, self.tanb) if modeltype == 'mssm_Hp_xsec': if float(self.tanb) < 1: exit('ERROR: Modeltype \'%s\' not supported for low tan(beta) values '%modeltype) else: tanbregion = 'tanbHigh' mssm_xsec_tools_path = getenv('CMSSW_BASE')+'/src/auxiliaries/models/out.'+modelpath+'-'+period+'-'+tanbregion+'-nlodbcorr.root' scan = mssm_Hp_xsec_tools(mssm_xsec_tools_path) # Let's call it htt_query for now. Must check if it's just historical name or if I should create another self.hp_query or so on self.htt_query = scan.query(self.mA, self.tanb)
os.system("combine-tanb.py %s --shape %s tmp.txt %s %s" % (opts, options.shape, options.min, options.max)) if not os.path.exists("debug") : os.system("mkdir debug") os.system("cp tmp*.txt debug") else : for tanb in points : neededParameter='' if options.model=='lowmH' : neededParameter='110' elif options.ana_type=='Hhh' : #only available for mhmodp if float(tanb) < 1: tanbregion = 'tanbLow' else: tanbregion = 'tanbHigh' mssm_xsec_tools_path = os.getenv('CMSSW_BASE')+'/src/auxiliaries/models/out.'+options.model+'-8TeV-'+tanbregion+'-nnlo.root' prescan = mssm_xsec_tools(mssm_xsec_tools_path) Spline_input = ROOT.TGraph() k=0 if 'mhmod' in options.model : #only available for mhmodp for m in range(90, 1000) : Spline_input.SetPoint(k, prescan.lookup_value(m, float(tanb), "h_mH"), m) k=k+1 neededParameter=str(Spline_input.Eval(float(masspoint))) else : neededParameter=str(masspoint) #print "translating tmp_{tanb}0.txt into workspace".format(tanb=tanb) if options.MSSMvsSM : os.system("text2workspace.py -m {mass} tmp_{tanb}0.txt -P HiggsAnalysis.HiggsToTauTau.PhysicsBSMModel:twoHypothesisHiggs -o fixedMu_{tanb}0.root".format( mass=str(neededParameter), tanb=tanb)) else : os.system("text2workspace.py -m {mass} tmp_{tanb}0.txt -o batch_{tanb}0.root".format(
help="Run in verbosity mode. [Default: False]") parser.add_option_group(cgroup) ## check number of arguments; in case print usage (options, args) = parser.parse_args() path = "auxiliaries/models/out.{MODEL}-8TeV-tanbHigh-nnlo.root".format( MODEL=options.model) #path = "auxiliaries/models/out.{MODEL}-8TeV-tanbAll-nnlo.root".format(MODEL=options.model) if options.model == "lowmH": for MUE in range(300, 3101, 20): file_name = "{CMSSW_BASE}/src/HiggsAnalysis/HiggsToTauTau/data/Higgs125/{MODEL}/higgs_{MASS}.dat".format( CMSSW_BASE=os.environ['CMSSW_BASE'], MODEL=options.model, MASS=MUE) print "writing file:", file_name file = open(file_name, 'w') for tanb in range(15, 96): mssm_scan = mssm_xsec_tools("{CMSSW_BASE}/src/{PATH}".format( CMSSW_BASE=os.environ['CMSSW_BASE'], PATH=path)) Htautau_query = mssm_scan.query(mA, tanb / 10., "Htautau") mh = Htautau_query['higgses']['h']['mass'] mH = Htautau_query['higgses']['H']['mass'] mA = Htautau_query['higgses']['A']['mass'] Htaunnu_query = mssm_scan.query(mA, tanb / 10., "Htaunu") mHp = Htaunu_query['higgses']['Hp']['mass'] if options.verbosity: print "%f \t%f \t%f \t%f \t%f \n" % (tanb / 10., mh, mA, mH, mHp) file.write("%f \t%f \t%f \t%f \t%f \n" % (tanb / 10., mh, mA, mH, mHp)) file.close() elif options.model == "low-tb-high": for mA in range(150, 501, 1): file_name = "{CMSSW_BASE}/src/HiggsAnalysis/HiggsToTauTau/data/Higgs125/{MODEL}/higgs_{MASS}.dat".format(
def run(self): """ Inserts the weights into the macros """ input_file = open(self.template_fname, 'r') output_file = open(self.output_fname, 'w') if (options.analysis == "mssm"): foundEnergy = "7TeV" if self.histfile.find("8TeV") > -1: foundEnergy = "8TeV" br = "BR" if self.histfile.find("hbb") > -1: br = "BR-hbb" path = "HiggsAnalysis/HiggsToTauTau/data/out.mhmax-mu+200-{ECMS}-{TANBINTERVALL}-nnlo.root".format( ECMS=foundEnergy, TANBINTERVALL="tanbHigh" if options.tanb >= 1.0 else "tanbLow") mssm_scan = mssm_xsec_tools("{CMSSW_BASE}/src/{PATH}".format( CMSSW_BASE=os.environ['CMSSW_BASE'], PATH=path)) mssm_xsec = mssm_scan.query(options.mA, options.tanb) bbH_xseff_A = mssm_xsec['higgses']['A']['xsec'][ 'santander'] * mssm_xsec['higgses']['A'][br] ggH_xseff_A = mssm_xsec['higgses']['A']['xsec']['ggF'] * mssm_xsec[ 'higgses']['A'][br] bbH_xseff_H = mssm_xsec['higgses']['H']['xsec'][ 'santander'] * mssm_xsec['higgses']['H'][br] ggH_xseff_H = mssm_xsec['higgses']['H']['xsec']['ggF'] * mssm_xsec[ 'higgses']['H'][br] bbH_xseff_h = mssm_xsec['higgses']['h']['xsec'][ 'santander'] * mssm_xsec['higgses']['h'][br] ggH_xseff_h = mssm_xsec['higgses']['h']['xsec']['ggF'] * mssm_xsec[ 'higgses']['h'][br] bbH_xseff_hH = bbH_xseff_H ggH_xseff_hH = ggH_xseff_H if options.mA == 130: bbH_xseff_hH = bbH_xseff_H + bbH_xseff_h ggH_xseff_hH = ggH_xseff_H + ggH_xseff_h if options.mA < 130: bbH_xseff_hH = bbH_xseff_h ggH_xseff_hH = ggH_xseff_h curr_name = "" for line in input_file: move_on = False template_name = self.template_fname[self.template_fname.find("/") + 1:self.template_fname. rfind("_template.C")] output_name = self.output_fname[:self.output_fname.rfind(".C")] ## prepare first lines of macro line = line.replace("$CMSSW_BASE", os.environ['CMSSW_BASE']) line = line.replace( "$DEFINE_MSSM", "#define MSSM" if self.analysis == "mssm" else "") line = line.replace( "$DEFINE_DROP_SIGNAL", "#define DROP_SIGNAL" if '0jet' in self.category else "") line = line.replace( "$DEFINE_EXTRA_SAMPLES", "#define EXTRA_SAMPLES" if self.high_stat_category(self.category) else "") line = line.replace(template_name, output_name) line = line.replace("$HISTFILE", self.histfile) line = line.replace("$CATEGORY", self.category) line = line.replace("$MSSM_SIGNAL_ggH_xseff_A", str(ggH_xseff_A)) line = line.replace("$MSSM_SIGNAL_ggH_xseff_hH", str(ggH_xseff_hH)) line = line.replace("$MSSM_SIGNAL_bbH_xseff_A", str(bbH_xseff_A)) line = line.replace("$MSSM_SIGNAL_bbH_xseff_hH", str(bbH_xseff_hH)) if options.uncertainties and (options.yields or options.shapes): line = line.replace("$DRAW_ERROR", 'if(scaled) errorBand->Draw("e2same");') line = line.replace( "$ERROR_LEGEND", 'if(scaled) leg->AddEntry(errorBand, "bkg. uncertainty" , "F" );' ) else: line = line.replace("$DRAW_ERROR", '') line = line.replace("$ERROR_LEGEND", '') word_arr = line.split("\n") uncertainties_set = [] for process_name in self.process_weight.keys(): if self.signal_process(process_name): cand_str = "${%s}%s" % (options.analysis.upper(), process_name) else: cand_str = "$%s" % process_name output_cand = "" if line.strip().startswith(cand_str): if options.verbose: print word_arr[0] curr_name = process_name move_on = True if options.yields: print_me = '''std::cout << "scaling by %(value)f %(name)s" << std::endl;''' % { "value": self.process_weight[curr_name], "name": curr_name } out_line = print_me + "hin->Scale(%f); \n" % self.process_weight[ curr_name] output_file.write(out_line) if options.verbose: print out_line if options.uncertainties: input = TFile("root/" + self.histfile) #print "file: ", input.GetName() for key in input.GetListOfKeys(): if self.category == "_".join( key.GetName().split("_")[1:]): remnant = cand_str.rstrip(process_name) histname = key.GetName( ) + "/" + word_arr[0][len(remnant) + 2:].strip().rstrip() hist = input.Get(histname) ## it can happen that histograms, which are present in SM ## are not present in MSSM; in this case just skip hist if not hist: continue #print histname, self.histfile for bin in range(1, hist.GetNbinsX() + 1): if not process_name + str( bin) in uncertainties_set: uncertainties_set += [ process_name + str(bin) ] uncertainty = math.sqrt( self.process_uncertainties[curr_name]) if uncertainty > 0: out_line = "hin->SetBinError(%(bin)i,hin->GetBinContent(%(bin)i)*%(uncertainty)f); \n" % { "bin": bin, "uncertainty": uncertainty } output_file.write(out_line) if options.verbose: print out_line elif options.verbose: print "WARNING: There is a zero yield uncertainty. Maybe you are missing uncertainties in the datacards which are in the fitresult in", self.analysis, self.category, ". Please check." if options.shapes: for process_name in self.process_shape_weight.keys(): if self.signal_process(process_name): cand_str = "${%s}%s" % (options.analysis.upper(), process_name) else: cand_str = "$%s" % process_name output_cand = "" if line.strip().startswith(cand_str): if options.verbose: print cand_str curr_name = process_name for shape_name in self.process_shape_weight[curr_name]: if options.verbose: print shape_name input = TFile("root/" + self.histfile) for key in input.GetListOfKeys(): if self.category == "_".join( key.GetName().split("_")[1:]): remnant = cand_str.rstrip(process_name) histname = key.GetName( ) + "/" + word_arr[0][len(remnant) + 2:].strip().rstrip() hist = input.Get(histname) hist_down = input.Get(histname + "_" + shape_name + "Down") hist_up = input.Get(histname + "_" + shape_name + "Up") if not hist or not hist_down or not hist_up: continue for bin in range(1, hist.GetNbinsX() + 1): shift = self.process_shape_weight[curr_name][ shape_name] out_line = '' value = 0 if shift > 0: value = (hist_up.GetBinContent(bin) - hist.GetBinContent(bin) ) / hist.GetBinWidth(bin) elif shift < 0: value = (hist.GetBinContent(bin) - hist_down.GetBinContent(bin) ) / hist.GetBinWidth(bin) if value != 0: print_me = '''std::cout << "scaling bin %(bin)i by %(shift)f %(name)s" << std::endl;''' % { "bin": bin, "shift": shift, "name": shape_name } out_line = print_me + "hin->SetBinContent(%(bin)i,hin->GetBinContent(%(bin)i)+%(value)f); \n" % { "bin": bin, "value": value * shift } if options.uncertainties: if self.process_shape_uncertainties[curr_name][ shape_name] > 0.99 and self.process_shape_weight[ curr_name][shape_name] == 0: if options.verbose: print "WARNING: Nuisance parameter not constrained (>99%)", shape_name uncertainty = self.process_shape_uncertainties[ curr_name][shape_name] * abs(value) if options.verbose and uncertainty > max( hist_down.GetBinContent(bin) / hist.GetBinWidth(bin), hist.GetBinContent(bin) / hist.GetBinWidth(bin), hist_up.GetBinContent(bin) / hist.GetBinWidth(bin)): print "WARNING: There is a bin-by-bin uncertainty larger than 100%. Make sure there is no problem with the bin-by-bin uncertainties in the root file", histfile, "in", self.analysis, self.category, ". Please check:", shape_name, "bin-down:", hist_down.GetBinContent( bin ), "bin-center:", hist.GetBinContent( bin ), "bin-up:", hist_up.GetBinContent( bin) if not process_name + str( bin) in uncertainties_set: uncertainties_set += [ process_name + str(bin) ] out_line += "hin->SetBinError(%(bin)i,%(uncertainty)f); \n" % { "bin": bin, "uncertainty": uncertainty } elif uncertainty != 0: out_line += "hin->SetBinError(%(bin)i,sqrt(pow(hin->GetBinError(%(bin)i),2)+pow(%(uncertainty)f,2))); \n" % { "bin": bin, "uncertainty": uncertainty } output_file.write(out_line) if options.verbose: if out_line: print out_line if not move_on: output_file.write(line) else: output_file.write("break; \n")
cgroup.add_option("--model", dest="model", default="mhmax-mu+200", type="string", help="The model for which you will look up the values. [Default: \"mhmax-mu+200\"]") cgroup.add_option("--verbosity", dest="verbosity", default=False, action="store_true", help="Run in verbosity mode. [Default: False]") parser.add_option_group(cgroup) ## check number of arguments; in case print usage (options, args) = parser.parse_args() path = "auxiliaries/models/out.{MODEL}-8TeV-tanbHigh-nnlo.root".format(MODEL=options.model) if options.model=="lowmH" : for MUE in range(300, 3101, 20) : file_name = "{CMSSW_BASE}/src/HiggsAnalysis/HiggsToTauTau/data/Higgs125/{MODEL}/higgs_{MASS}.dat".format(CMSSW_BASE=os.environ['CMSSW_BASE'],MODEL=options.model,MASS=MUE) print "writing file:", file_name file = open(file_name,'w') for tanb in range(15, 95) : mssm_scan = mssm_xsec_tools("{CMSSW_BASE}/src/{PATH}".format(CMSSW_BASE=os.environ['CMSSW_BASE'], PATH=path)) htt_query = mssm_scan.query(MUE, tanb/10.) ; mh = htt_query['higgses']['h']['mass'] ; mH = htt_query['higgses']['H']['mass'] ; mA = htt_query['higgses']['A']['mass'] if options.verbosity : print "%f \t%f \t%f \t%f \n" % (tanb/10., mh, mA, mH) ; file.write("%f \t%f \t%f \t%f \n" % (tanb/10., mh, mA, mH)) file.close() else: for mA in [90, 100, 120, 130, 140, 160, 180, 200, 250, 300, 350, 400, 450, 500, 600, 700, 800, 900, 1000] : file_name = "{CMSSW_BASE}/src/HiggsAnalysis/HiggsToTauTau/data/Higgs125/{MODEL}/higgs_{MASS}.dat".format(CMSSW_BASE=os.environ['CMSSW_BASE'],MODEL=options.model,MASS=mA) print "writing file:", file_name file = open(file_name,'w') for tanb in range(5, 600) : mssm_scan = mssm_xsec_tools("{CMSSW_BASE}/src/{PATH}".format(CMSSW_BASE=os.environ['CMSSW_BASE'], PATH=path)) htt_query = mssm_scan.query(mA, tanb/10.) ; mh = htt_query['higgses']['h']['mass'] ; mH = htt_query['higgses']['H']['mass'] if options.verbosity : print "%f \t%f \t%f \t%f \n" % (tanb/10., mh, mA, mH) ;
def run(self): """ Inserts the weights into the macros """ input_file = open(self.template_fname,'r') output_file = open(self.output_fname,'w') if(options.analysis=="mssm") : foundEnergy="7TeV" if self.histfile.find("8TeV")>-1 : foundEnergy="8TeV" br="BR" if self.histfile.find("hbb")>-1 : br="BR-hbb" path="HiggsAnalysis/HiggsToTauTau/data/out.mhmax-mu+200-{ECMS}-{TANBINTERVALL}-nnlo.root".format( ECMS=foundEnergy, TANBINTERVALL="tanbHigh" if options.tanb>=1.0 else "tanbLow" ) mssm_scan = mssm_xsec_tools("{CMSSW_BASE}/src/{PATH}".format(CMSSW_BASE=os.environ['CMSSW_BASE'], PATH=path)) mssm_xsec = mssm_scan.query(options.mA, options.tanb) bbH_xseff_A=mssm_xsec['higgses']['A']['xsec']['santander']*mssm_xsec['higgses']['A'][br] ggH_xseff_A=mssm_xsec['higgses']['A']['xsec']['ggF' ]*mssm_xsec['higgses']['A'][br] bbH_xseff_H=mssm_xsec['higgses']['H']['xsec']['santander']*mssm_xsec['higgses']['H'][br] ggH_xseff_H=mssm_xsec['higgses']['H']['xsec']['ggF' ]*mssm_xsec['higgses']['H'][br] bbH_xseff_h=mssm_xsec['higgses']['h']['xsec']['santander']*mssm_xsec['higgses']['h'][br] ggH_xseff_h=mssm_xsec['higgses']['h']['xsec']['ggF' ]*mssm_xsec['higgses']['h'][br] bbH_xseff_hH=bbH_xseff_H ggH_xseff_hH=ggH_xseff_H if options.mA==130 : bbH_xseff_hH=bbH_xseff_H+bbH_xseff_h ggH_xseff_hH=ggH_xseff_H+ggH_xseff_h if options.mA<130 : bbH_xseff_hH=bbH_xseff_h ggH_xseff_hH=ggH_xseff_h curr_name = "" for line in input_file: move_on = False template_name = self.template_fname[self.template_fname.find("/")+1:self.template_fname.rfind("_template.C")] output_name = self.output_fname[:self.output_fname.rfind(".C")] ## prepare first lines of macro line = line.replace("$CMSSW_BASE", os.environ['CMSSW_BASE']) line = line.replace("$DEFINE_MSSM", "#define MSSM" if self.analysis == "mssm" else "") line = line.replace("$DEFINE_DROP_SIGNAL", "#define DROP_SIGNAL" if '0jet' in self.category else "") line = line.replace("$DEFINE_EXTRA_SAMPLES", "#define EXTRA_SAMPLES" if self.high_stat_category(self.category) else "") line = line.replace(template_name, output_name) line = line.replace("$HISTFILE", self.histfile) line = line.replace("$CATEGORY", self.category) line = line.replace("$MSSM_SIGNAL_ggH_xseff_A" , str(ggH_xseff_A)) line = line.replace("$MSSM_SIGNAL_ggH_xseff_hH", str(ggH_xseff_hH)) line = line.replace("$MSSM_SIGNAL_bbH_xseff_A" , str(bbH_xseff_A)) line = line.replace("$MSSM_SIGNAL_bbH_xseff_hH", str(bbH_xseff_hH)) if options.uncertainties and (options.yields or options.shapes): line = line.replace("$DRAW_ERROR", 'if(scaled) errorBand->Draw("e2same");') line = line.replace("$ERROR_LEGEND", 'if(scaled) leg->AddEntry(errorBand, "bkg. uncertainty" , "F" );') else: line = line.replace("$DRAW_ERROR", '') line = line.replace("$ERROR_LEGEND", '') word_arr=line.split("\n") uncertainties_set=[] for process_name in self.process_weight.keys(): if self.signal_process(process_name) : cand_str = "${%s}%s" % (options.analysis.upper() , process_name) else : cand_str = "$%s" % process_name output_cand = "" if line.strip().startswith(cand_str): if options.verbose : print word_arr[0] curr_name = process_name move_on = True if options.yields: print_me = '''std::cout << "scaling by %(value)f %(name)s" << std::endl;''' % {"value":self.process_weight[curr_name],"name":curr_name} out_line = print_me+"hin->Scale(%f); \n" % self.process_weight[curr_name] output_file.write(out_line) if options.verbose : print out_line if options.uncertainties: input = TFile("root/"+self.histfile) #print "file: ", input.GetName() for key in input.GetListOfKeys(): if self.category=="_".join(key.GetName().split("_")[1:]): remnant = cand_str.rstrip(process_name) histname=key.GetName()+"/"+word_arr[0][len(remnant)+2:].strip().rstrip() hist = input.Get(histname) ## it can happen that histograms, which are present in SM ## are not present in MSSM; in this case just skip hist if not hist : continue #print histname, self.histfile for bin in range(1,hist.GetNbinsX()+1): if not process_name+str(bin) in uncertainties_set: uncertainties_set+=[process_name+str(bin)] uncertainty = math.sqrt(self.process_uncertainties[curr_name]) if uncertainty>0: out_line = "hin->SetBinError(%(bin)i,hin->GetBinContent(%(bin)i)*%(uncertainty)f); \n" % {"bin":bin, "uncertainty":uncertainty} output_file.write(out_line) if options.verbose : print out_line elif options.verbose: print "WARNING: There is a zero yield uncertainty. Maybe you are missing uncertainties in the datacards which are in the fitresult in",self.analysis,self.category,". Please check." if options.shapes: for process_name in self.process_shape_weight.keys(): if self.signal_process(process_name) : cand_str = "${%s}%s" % (options.analysis.upper() , process_name) else : cand_str = "$%s" % process_name output_cand = "" if line.strip().startswith(cand_str): if options.verbose: print cand_str curr_name = process_name for shape_name in self.process_shape_weight[curr_name]: if options.verbose: print shape_name input = TFile("root/"+self.histfile) for key in input.GetListOfKeys(): if self.category=="_".join(key.GetName().split("_")[1:]): remnant = cand_str.rstrip(process_name) histname=key.GetName()+"/"+word_arr[0][len(remnant)+2:].strip().rstrip() hist = input.Get(histname) hist_down = input.Get(histname+"_"+shape_name+"Down") hist_up = input.Get(histname+"_"+shape_name+"Up") if not hist or not hist_down or not hist_up : continue for bin in range(1,hist.GetNbinsX()+1): shift = self.process_shape_weight[curr_name][shape_name] out_line = '' value = 0 if shift>0: value = (hist_up.GetBinContent(bin)-hist.GetBinContent(bin))/hist.GetBinWidth(bin) elif shift<0: value = (hist.GetBinContent(bin)-hist_down.GetBinContent(bin))/hist.GetBinWidth(bin) if value!=0: print_me = '''std::cout << "scaling bin %(bin)i by %(shift)f %(name)s" << std::endl;''' % {"bin":bin, "shift":shift, "name":shape_name} out_line = print_me+"hin->SetBinContent(%(bin)i,hin->GetBinContent(%(bin)i)+%(value)f); \n" % {"bin":bin, "value":value*shift} if options.uncertainties: if self.process_shape_uncertainties[curr_name][shape_name]>0.99 and self.process_shape_weight[curr_name][shape_name]==0: if options.verbose: print "WARNING: Nuisance parameter not constrained (>99%)",shape_name uncertainty = self.process_shape_uncertainties[curr_name][shape_name]*abs(value) if options.verbose and uncertainty>max(hist_down.GetBinContent(bin)/hist.GetBinWidth(bin),hist.GetBinContent(bin)/hist.GetBinWidth(bin),hist_up.GetBinContent(bin)/hist.GetBinWidth(bin)): print "WARNING: There is a bin-by-bin uncertainty larger than 100%. Make sure there is no problem with the bin-by-bin uncertainties in the root file",histfile,"in",self.analysis,self.category,". Please check:",shape_name,"bin-down:",hist_down.GetBinContent(bin),"bin-center:",hist.GetBinContent(bin),"bin-up:",hist_up.GetBinContent(bin) if not process_name+str(bin) in uncertainties_set: uncertainties_set+=[process_name+str(bin)] out_line += "hin->SetBinError(%(bin)i,%(uncertainty)f); \n" % {"bin":bin, "uncertainty":uncertainty} elif uncertainty!=0: out_line += "hin->SetBinError(%(bin)i,sqrt(pow(hin->GetBinError(%(bin)i),2)+pow(%(uncertainty)f,2))); \n" % {"bin":bin, "uncertainty":uncertainty} output_file.write(out_line) if options.verbose : if out_line : print out_line if not move_on: output_file.write(line) else: output_file.write("break; \n")
_inclusion_ranges = { 'A' : lambda massA: True, 'H' : lambda massA: massA > 120, 'h' : lambda massA: massA < 140, } # Update higgs sample cross sections if _USE_BARI_XSEC: verbose = False #verbose = True if verbose: print "Updating samples to use Bari xsections" import os import re from HiggsAnalysis.HiggsToTauTau.tools.mssm_xsec_tools import mssm_xsec_tools _FILE_NAME = os.path.join(os.environ['CMSSW_BASE'], 'src/HiggsAnalysis/HiggsToTauTau/data', 'out.mhmax_7_nnlo.root') helper = mssm_xsec_tools(_FILE_NAME) matcher = re.compile(r"(?P<isBB>bb)*A(?P<massA>\d*)") higgs_samples = [ sample for sample in SAMPLES_TO_ANALYZE if matcher.match(sample) ] higgs_lookups = {} for sample in higgs_samples: match = matcher.match(sample) mass = int(match.group('massA')) if verbose: print "Updating cross section for sample %s - mA: %i" % ( sample, mass) # Lookup the XSec etc, if we haven't already mssm_info = higgs_lookups.setdefault( (mass, TAN_BETA), helper.query(mass, TAN_BETA)) # Determine if samples is bb or glu-glu production_mechanism = (match.group('isBB') and 'santander' or 'ggF')
import math import os from HiggsAnalysis.HiggsToTauTau.tools.mssm_xsec_tools import mssm_xsec_tools import ROOT ROOT.gROOT.SetBatch(True) ROOT.gROOT.SetStyle("Plain") _FILE_NAME = os.path.join(os.environ['CMSSW_BASE'], 'src/HiggsAnalysis/HiggsToTauTau/data', 'out.mhmax_7_nnlo.root') helper = mssm_xsec_tools(_FILE_NAME) def square(x): return x * x inclusion_ranges = { 'A': lambda massA: True, 'H': lambda massA: massA >= 130, 'h': lambda massA: massA <= 130, } def effective_cross_section(mA, tanB,