#print "drop due to failing mass:" , channel, valid_masses[channel][0], valid_masses[channel][1], ":", mass continue if channel == "vhbb" or channel == "hmm" or channel == "hbb": for category in categories[channel]: if options.verbose: print "copying datacards for:", period, channel, category, mass if options.analysis == "mssm": os.system( "cp {INPUT}/{CHN}/{CHN}.inputs-{ANA}-{PERIOD}-{MASSCAT}.root {OUTPUT}/common/{PRE}{CHN}.input_{PERIOD}-{MASSCAT}.root" .format(INPUT=input, ANA=options.analysis, CHN=channel, OUTPUT=options.out, PRE=prefix, PERIOD=period, MASSCAT=mass_category( mass, category, channel))) os.system( "cp {INPUT}/{CHN}/{CHN}_{CAT}_{PERIOD}-{MASS}.txt {OUTPUT}/{MASSDIR}/{PRE}{CHN}_{CAT}_{PERIOD}.txt" .format(INPUT=input, CHN=channel, CAT=category, PERIOD=period, MASS=mass, MASSDIR=massdir(mass), OUTPUT=options.out, PRE=prefix)) os.system( "perl -pi -e 's/{CHN}.inputs-{ANA}-{PERIOD}-{MASSCAT}.root/..\/common\/{PRE}{CHN}.input_{PERIOD}-{MASSCAT}.root/g' {OUTPUT}/{MASSDIR}/{PRE}{CHN}_{CAT}_{PERIOD}.txt" .format(CHN=channel, ANA=options.analysis, PRE=prefix,
## check validity of run period if not period in valid_periods[channel] : #print "drop due to failing period: ", channel, valid_periods[channel], period continue for category in categories[channel] : if options.verbose : print "copying datacards for:", period, channel, category, mass ## check validity of run period if not period in valid_periods[channel] : #print "drop due to failing period: ", channel, valid_periods[channel], period continue if options.analysis == "mssm" : add_mass("htt_{CHN}_{CAT}_{PERIOD}".format(CHN=channel, CAT=category, PERIOD=period), mass) if options.no_update: files = ' '.join(os.listdir("{OUTPUT}/common/".format(OUTPUT=options.out))) if not "htt_"+channel+'.inputs-mssm-'+period in files : os.system("cp {INPUT}/htt_{CHN}/htt_{CHN}.inputs-{ANA}-{PERIOD}-{MASSCAT}.root* {OUTPUT}/common/".format( INPUT=input, CHN=channel, ANA=options.analysis, PERIOD=period, OUTPUT=options.out, MASSCAT=mass_category(mass,category, channel))) else : pass #print "no update of files needed." else : os.system("cp {INPUT}/htt_{CHN}/htt_{CHN}.inputs-{ANA}-{PERIOD}-{MASSCAT}.root* {OUTPUT}/common/".format( INPUT=input, CHN=channel, ANA=options.analysis, PERIOD=period, OUTPUT=options.out, MASSCAT=mass_category(mass,category, channel))) os.system("cp {INPUT}/htt_{CHN}/htt_{CHN}_{CAT}_{PERIOD}-100.txt {OUTPUT}/{MASSDIR}/htt_{CHN}_{CAT}_{PERIOD}.txt".format( #mA=110 always for lowmH! INPUT=input, CHN=channel, CAT=category, PERIOD=period, MASSDIR=massdir(mass), OUTPUT=options.out)) os.system("perl -pi -e 's/htt_{CHN}.inputs/..\/common\/htt_{CHN}.inputs/g' {OUTPUT}/{MASSDIR}/htt_{CHN}_{CAT}_{PERIOD}.txt".format( CHN=channel, OUTPUT=options.out, MASS=mass, MASSDIR=massdir(mass), CAT=category, PERIOD=period)) else : print "options.analysis has to be 'mssm' for lowmH"
for channel in channels: for period in periods: for cat in ['0']: for mass in parseArgs(args): for process in ['ggH', 'bbH']: exe = "{CMSSW_BASE}/src/HiggsAnalysis/HiggsToTauTau/macros/rescaleSignal.C+".format( CMSSW_BASE=os.environ.get("CMSSW_BASE")) os.system( r"root -l -b -q {EXE}\(true,{SCALE},\"{PATH}/{CHN}/htt_{CHN}.inputs-mssm-{PER}-{MASSCAT}.root\",\"{PROCESS}\",0\)" .format(EXE=exe, PATH=source_path, SCALE=acceptance_correction( process, mass, period), CHN=channel, PER=period, MASSCAT=mass_category(mass, cat, 'htt_' + channel), PROCESS=process + str(mass))) if channel == "mm": os.system( r"root -l -b -q {EXE}\(true,{SCALE},\"{PATH}/{CHN}/htt_{CHN}.inputs-mssm-{PER}-{MASSCAT}-msv.root\",\"{PROCESS}\",0\)" .format(EXE=exe, PATH=source_path, SCALE=acceptance_correction( process, mass, period), CHN=channel, PER=period, MASSCAT=mass_category( mass, cat, 'htt_' + channel), PROCESS=process + str(mass)))
if options.analysis == "sm" and "mm" in channel : ## this has been removed since there is no problem anymore with morphed templates in SM mm / ee ##mass = closest_simulated_masspoint(mass) ##fudge_mm_datacards = float(fudge_mass)-float(mass)!=0 pass ## check validity of mass if (float(mass)< valid_masses[channel][0] or float(mass)> valid_masses[channel][1]) : #print "drop due to failing mass:" , channel, valid_masses[channel][0], valid_masses[channel][1], ":", mass continue print "creating datacard for:", options.analysis, period, channel, cat, fudge_mass if options.analysis == "mssm" : os.system("create-datacard.py -i {CHN}.inputs-{ANA}-{PER}-{MASSCAT}.root -o {CHN}_{CAT}_{PER}-{LABEL}.txt {MASS}".format( CHN=prefix+channel, ANA=options.analysis, PER=period, MASSCAT=mass_category(mass,cat,prefix+channel), CAT=cat, MASS='' if options.ignore_mass_argument else mass, LABEL='125' if options.ignore_mass_argument else mass )) if options.analysis == "sm" : if options.SM4 : print "rescaling signal cross sections accoring to SM4 cross sections" os.system(r"root -q -l -b {CMSSW_BASE}/src/HiggsAnalysis/HiggsToTauTau/macros/rescale2SM4.C+\(true,\"{CHN}.inputs-{per}.root\"\)".format( CMSSW_BASE=os.environ['CMSSW_BASE'], CHN=channel, per=period.lower() )) os.system("create-datacard.py -i {CHN}.inputs-{ANA}-{per}.root -o {CHN}_{CAT}_{PER}-{LABEL}.txt {MASS} {SM_HIGGS_BKG}".format( CHN=prefix+channel, ANA=options.analysis,
# print "drop due to failing mass:" , channel, valid_masses[channel][0], valid_masses[channel][1], ":", mass continue if channel == "vhbb" or channel == "hmm" or channel == "hbb": for category in categories[channel]: if options.verbose: print "copying datacards for:", period, channel, category, mass if options.analysis == "mssm": os.system( "cp {INPUT}/{CHN}/{PRE}{CHN}.inputs-{ANA}-{PERIOD}-{MASSCAT}.root* {OUTPUT}/common".format( INPUT=input, ANA=options.analysis, CHN=channel, OUTPUT=options.out, PRE=prefix, PERIOD=period, MASSCAT=mass_category(mass, category, channel), ) ) os.system( "cp {INPUT}/{CHN}/{CHN}_{CAT}_{PERIOD}-{MASS}.txt {OUTPUT}/{MASSDIR}/{PRE}{CHN}_{CAT}_{PERIOD}.txt".format( INPUT=input, CHN=channel, CAT=category, PERIOD=period, MASS=mass, MASSDIR=massdir(mass), OUTPUT=options.out, PRE=prefix, ) ) os.system(
channels = options.channels.split() for idx in range(len(channels)) : channels[idx] = channels[idx].rstrip(',') for channel in channels : for period in periods : print period for cat in ['0'] : for mass in parseArgs(args) : for process in ['ggH', 'bbH'] : exe = "{CMSSW_BASE}/src/HiggsAnalysis/HiggsToTauTau/macros/rescaleSignal.C+".format(CMSSW_BASE=os.environ.get("CMSSW_BASE")) os.system(r"root -l -b -q {EXE}\(true,{SCALE},\"{PATH}/{CHN}/htt_{CHN}.inputs-mssm-{PER}-{MASSCAT}.root\",\"{PROCESS}\",0\)".format( EXE=exe, PATH=source_path, SCALE=acceptance_correction(process, mass, period), CHN=channel, PER=period, MASSCAT=mass_category(mass,cat,'htt_'+channel), PROCESS=process+str(mass) )) if channel=="mm" : os.system(r"root -l -b -q {EXE}\(true,{SCALE},\"{PATH}/{CHN}/htt_{CHN}.inputs-mssm-{PER}-{MASSCAT}-msv.root\",\"{PROCESS}\",0\)".format( EXE=exe, PATH=source_path, SCALE=acceptance_correction(process, mass, period), CHN=channel, PER=period, MASSCAT=mass_category(mass,cat,'htt_'+channel), PROCESS=process+str(mass) ))
##fudge_mm_datacards = float(fudge_mass)-float(mass)!=0 pass ## check validity of mass if (float(mass) < valid_masses[channel][0] or float(mass) > valid_masses[channel][1]): #print "drop due to failing mass:" , channel, valid_masses[channel][0], valid_masses[channel][1], ":", mass continue print "creating datacard for:", options.analysis, period, channel, cat, fudge_mass if options.analysis == "mssm": os.system( "create-datacard.py -i {CHN}.inputs-{ANA}-{PER}-{MASSCAT}.root -o {CHN}_{CAT}_{PER}-{LABEL}.txt {MASS}" .format( CHN=prefix + channel, ANA=options.analysis, PER=period, MASSCAT=mass_category(mass, cat, prefix + channel), CAT=cat, MASS='' if options.ignore_mass_argument else mass, LABEL='125' if options.ignore_mass_argument else mass)) if options.analysis == "sm": if options.SM4: print "rescaling signal cross sections accoring to SM4 cross sections" os.system( r"root -q -l -b {CMSSW_BASE}/src/HiggsAnalysis/HiggsToTauTau/macros/rescale2SM4.C+\(true,\"{CHN}.inputs-{per}.root\"\)" .format(CMSSW_BASE=os.environ['CMSSW_BASE'], CHN=channel, per=period.lower())) os.system( "create-datacard.py -i {CHN}.inputs-{ANA}-{per}.root -o {CHN}_{CAT}_{PER}-{LABEL}.txt {MASS} {SM_HIGGS_BKG}" .format(
for mass in parseArgs(args) : ## check validity of run period if not period in valid_periods[channel] : #print "drop due to failing period: ", channel, valid_periods[channel], period continue ## check validity of mass if (float(mass)< valid_masses[channel][0] or float(mass)> valid_masses[channel][1]) : #print "drop due to failing mass:" , channel, valid_masses[channel][0], valid_masses[channel][1], ":", mass continue if channel == "vhbb" or channel == "hmm" or channel == "hbb" : for category in categories[channel] : if options.verbose : print "copying datacards for:", period, channel, category, mass if options.analysis == "mssm" : os.system("cp {INPUT}/{CHN}/{CHN}.inputs-{ANA}-{PERIOD}-{MASSCAT}.root {OUTPUT}/common/{PRE}{CHN}.input_{PERIOD}-{MASSCAT}.root".format( INPUT=input, ANA=options.analysis, CHN=channel, OUTPUT=options.out, PRE=prefix, PERIOD=period, MASSCAT=mass_category(mass,category, channel))) os.system("cp {INPUT}/{CHN}/{CHN}_{CAT}_{PERIOD}-{MASS}.txt {OUTPUT}/{MASSDIR}/{PRE}{CHN}_{CAT}_{PERIOD}.txt".format( INPUT=input, CHN=channel, CAT=category, PERIOD=period, MASS=mass, MASSDIR=massdir(mass), OUTPUT=options.out, PRE=prefix)) os.system("perl -pi -e 's/{CHN}.inputs-{ANA}-{PERIOD}-{MASSCAT}.root/..\/common\/{PRE}{CHN}.input_{PERIOD}-{MASSCAT}.root/g' {OUTPUT}/{MASSDIR}/{PRE}{CHN}_{CAT}_{PERIOD}.txt".format( CHN=channel, ANA=options.analysis, PRE=prefix, OUTPUT=options.out, MASS=mass, MASSDIR=massdir(mass), CAT=category, PERIOD=period, MASSCAT=mass_category(mass,category,channel))) else : os.system("cp {INPUT}/{CHN}/{CHN}.inputs-{ANA}-{PERIOD}.root {OUTPUT}/common/{PRE}{CHN}.input_{PERIOD}.root".format( INPUT=input, ANA=options.analysis, CHN=channel, OUTPUT=options.out, PRE=prefix, PERIOD=period)) os.system("cp {INPUT}/{CHN}/{CHN}_{CAT}_{PERIOD}-{MASS}.txt {OUTPUT}/{MASSDIR}/{PRE}{CHN}_{CAT}_{PERIOD}.txt".format( INPUT=input, CHN=channel, CAT=category, PERIOD=period, MASS=mass, MASSDIR=massdir(mass), OUTPUT=options.out, PRE=prefix)) os.system("perl -pi -e 's/{CHN}.inputs-{ANA}-{PERIOD}.root/..\/common\/{PRE}{CHN}.input_{PERIOD}.root/g' {OUTPUT}/{MASSDIR}/{PRE}{CHN}_{CAT}_{PERIOD}.txt".format( CHN=channel, ANA=options.analysis, PRE=prefix, OUTPUT=options.out, MASS=mass, MASSDIR=massdir(mass), CAT=category, PERIOD=period)) if options.analysis == "mssm" : add_mass("{CHN}_{CAT}_{PERIOD}".format(CHN=channel, CAT=category, PERIOD=period), mass) elif channel == "vhtt": for category in categories[channel] :
for cat in categories[channel] : ## here the normal workflow continues prefix = "" if (channel == "vhtt" or channel == "vhbb") else "htt_" os.chdir("{PWD}/{CHN}".format(CHN=prefix+channel, PWD=base)) ## check validity of run period if not period in valid_periods[channel] : #print "drop due to failing period: ", channel, valid_periods[channel], period continue os.system("datacard-project.py -i {PATH} -c {CHN} -e {ANA}-{PER}-0{CAT} {PER}-0{CAT}".format(PATH=os.path.abspath(options.input), CHN=channel, ANA=options.analysis, PER=period, CAT=cat)) os.chdir("{PWD}/{CHN}/{PER}-0{CAT}".format(CHN=prefix+channel, PER=period, PWD=base, CAT=cat)) for mass in parseArgs(args) : ## check validity of mass if (float(mass)< valid_masses[channel][0] or float(mass)> valid_masses[channel][1]) : #print "drop due to failing mass:" , channel, valid_masses[channel][0], valid_masses[channel][1], ":", mass continue print "creating datacard for:", options.analysis, period, channel, cat, mass if options.analysis == "mssm" : os.system("create-datacard.py -i {CHN}.inputs-{ana}-{PER}-{MASSCAT}.root -o {CHN}_{CAT}_{PER}-{MASS}.txt {MASS}".format( CHN=prefix+channel, ana=options.analysis, PER=period, MASSCAT=mass_category(mass), CAT=cat, MASS=mass)) if options.analysis == "sm" : if options.SM4 : print "rescaling signal cross sections accoring to SM4 cross sections" os.system(r"root -q -l -b {CMSSW_BASE}/src/HiggsAnalysis/HiggsToTauTau/macros/rescale2SM4.C+\(true,\"{CHN}.inputs-{per}.root\"\)".format( CMSSW_BASE=os.environ['CMSSW_BASE'], CHN=channel, per=period.lowe())) os.system("create-datacard.py -i {CHN}.inputs-{ANA}-{per}.root -o {CHN}_{CAT}_{PER}-{MASS}.txt {MASS}".format( CHN=prefix+channel, ANA=options.analysis, per=period, CAT=cat, PER=period, MASS=mass)) os.system("mv *.* ../") os.chdir("{PWD}/{CHN}".format(CHN=prefix+channel, PWD=base)) os.system("rm -r {PER}-0{CAT}".format(PER=period, CAT=cat)) os.system("rm -r cgs.* unc.*")
for mass in parseArgs(args) : ## check validity of run period if not period in valid_periods[channel] : #print "drop due to failing period: ", channel, valid_periods[channel], period continue ## check validity of mass if (float(mass)< valid_masses[channel][0] or float(mass)> valid_masses[channel][1]) : #print "drop due to failing mass:" , channel, valid_masses[channel][0], valid_masses[channel][1], ":", mass continue if channel == "vhbb" or channel == "hmm" or channel == "hbb" : for category in categories[channel] : if options.verbose : print "copying datacards for:", period, channel, category, mass if options.analysis == "mssm" : os.system("cp {INPUT}/{CHN}/{PRE}{CHN}.inputs-{ANA}-{PERIOD}-{MASSCAT}.root* {OUTPUT}/common".format( INPUT=input, ANA=options.analysis, CHN=channel, OUTPUT=options.out, PRE=prefix, PERIOD=period, MASSCAT=mass_category(mass,category, channel))) os.system("cp {INPUT}/{CHN}/{CHN}_{CAT}_{PERIOD}-{MASS}.txt {OUTPUT}/{MASSDIR}/{PRE}{CHN}_{CAT}_{PERIOD}.txt".format( INPUT=input, CHN=channel, CAT=category, PERIOD=period, MASS='100' if options.model=='lowmH' or options.model=='2HDM' else mass, MASSDIR=massdir(mass), OUTPUT=options.out, PRE=prefix)) os.system("perl -pi -e 's/{CHN}.inputs/..\/common\/{PRE}{CHN}.inputs/g' {OUTPUT}/{MASSDIR}/{PRE}{CHN}_{CAT}_{PERIOD}.txt".format( CHN=channel, ANA=options.analysis, PRE=prefix, OUTPUT=options.out, MASS=mass, MASSDIR=massdir(mass), CAT=category, PERIOD=period, MASSCAT=mass_category(mass,category,channel))) else : os.system("cp {INPUT}/{CHN}/{CHN}.inputs-{ANA}-{PERIOD}.root {OUTPUT}/common/{PRE}{CHN}.input_{PERIOD}.root".format( INPUT=input, ANA=options.analysis, CHN=channel, OUTPUT=options.out, PRE=prefix, PERIOD=period)) os.system("cp {INPUT}/{CHN}/{CHN}_{CAT}_{PERIOD}-{MASS}.txt {OUTPUT}/{MASSDIR}/{PRE}{CHN}_{CAT}_{PERIOD}.txt".format( INPUT=input, CHN=channel, CAT=category, PERIOD=period, MASS='300' if options.model=='lowmH' or options.model=='2HDM' else mass, MASSDIR=massdir(mass), OUTPUT=options.out, PRE=prefix)) os.system("perl -pi -e 's/{CHN}.inputs-{ANA}-{PERIOD}.root/..\/common\/{PRE}{CHN}.input_{PERIOD}.root/g' {OUTPUT}/{MASSDIR}/{PRE}{CHN}_{CAT}_{PERIOD}.txt".format( CHN=channel, ANA=options.analysis, PRE=prefix, OUTPUT=options.out, MASS=mass, MASSDIR=massdir(mass), CAT=category, PERIOD=period)) elif channel == "vhtt": for category in categories[channel] : if options.verbose : print "copying datacards for:", period, channel, category, mass
channels = options.channels.split() for idx in range(len(channels)) : channels[idx] = channels[idx].rstrip(',') for channel in channels : for period in periods : for cat in ['0'] : for mass in parseArgs(args) : for process in ['ggH', 'bbH'] : exe = "{CMSSW_BASE}/src/HiggsAnalysis/HiggsToTauTau/macros/rescaleSignal.C+".format(CMSSW_BASE=os.environ.get("CMSSW_BASE")) os.system(r"root -l -b -q {EXE}\(true,{SCALE},\"{PATH}/{CHN}/htt_{CHN}.inputs-{MSSM}-{PER}{MASSCAT}.root\",\"{PROCESS}\",0\)".format( EXE=exe, PATH=source_path, SCALE=acceptance_correction(process, mass, period), CHN=channel, MSSM="Hhh" if options.Hhh=="Hhh" else "mssm", PER=period, MASSCAT="-" + str(mass_category(mass,cat,'htt_'+channel)) if options.Hhh=="" else "", PROCESS=process+str(mass) )) if channel=="mm" : os.system(r"root -l -b -q {EXE}\(true,{SCALE},\"{PATH}/{CHN}/htt_{CHN}.inputs-mssm-{PER}-{MASSCAT}-msv.root\",\"{PROCESS}\",0\)".format( EXE=exe, PATH=source_path, SCALE=acceptance_correction(process, mass, period), CHN=channel, PER=period, MASSCAT=mass_category(mass,cat,'htt_'+channel), PROCESS=process+str(mass) ))