From 3cfb9a1197071e69039e24390c4762577f901f7c Mon Sep 17 00:00:00 2001 From: Sonaina Undleeb Date: Wed, 12 Sep 2018 12:38:12 -0500 Subject: [PATCH 01/12] W constraints 0/1/2 btag --- W_constraints_monojet_0tag.py | 87 ++++++++++++++++++++++++++ W_constraints_monojet_1tag.py | 112 ++++++++++++++++++++++++++++++++++ W_constraints_monojet_2tag.py | 87 ++++++++++++++++++++++++++ 3 files changed, 286 insertions(+) create mode 100644 W_constraints_monojet_0tag.py create mode 100644 W_constraints_monojet_1tag.py create mode 100644 W_constraints_monojet_2tag.py diff --git a/W_constraints_monojet_0tag.py b/W_constraints_monojet_0tag.py new file mode 100644 index 0000000..c780fb4 --- /dev/null +++ b/W_constraints_monojet_0tag.py @@ -0,0 +1,87 @@ + import ROOT +from counting_experiment import * +# Define how a control region(s) transfer is made by defining cmodel provide, the calling pattern must be unchanged! +# First define simple string which will be used for the datacard +model = "wjets" +def cmodel(cid,nam,_f,_fOut, out_ws, diag): + + # Some setup + _fin = _f.Get("category_%s"%cid) + _wspace = _fin.Get("wspace_%s"%cid) + + + # ############################ USER DEFINED ########################################################### + # First define the nominal transfer factors (histograms of signal/control, usually MC + # note there are many tools available inside include/diagonalize.h for you to make + # special datasets/histograms representing these and systematic effects + # but for now this is just kept simple + processName = "WJets" # Give a name of the process being modelled + metname = "met" # Observable variable name + targetmc = _fin.Get("signal0tag_wjets") # define monimal (MC) of which process this config will model + controlmc = _fin.Get("singlemuon0tag_wjets") # defines in / out acceptance + controlmc_e = _fin.Get("singleelectron0tag_wjets") # defines in / out acceptance + + # Create the transfer factors and save them (not here you can also create systematic variations of these + # transfer factors (named with extention _sysname_Up/Down + WScales = targetmc.Clone(); WScales.SetName("wmn0tag_weights_%s"%cid) + WScales.Divide(controlmc); _fOut.WriteTObject(WScales) + + WScales_e = targetmc.Clone(); WScales_e.SetName("wen0tag_weights_%s"%cid) + WScales_e.Divide(controlmc_e); _fOut.WriteTObject(WScales_e) + + ####################################################################################################### + + _bins = [] # take bins from some histogram, can choose anything but this is easy + for b in range(targetmc.GetNbinsX()+1): + _bins.append(targetmc.GetBinLowEdge(b+1)) + + # Here is the important bit which "Builds" the control region, make a list of control regions which + # are constraining this process, each "Channel" is created with ... + # (name,_wspace,out_ws,cid+'_'+model,TRANSFERFACTORS) + # the second and third arguments can be left unchanged, the others instead must be set + # TRANSFERFACTORS are what is created above, eg WScales + + CRs = [ + Channel("singlemuon0tagModel",_wspace,out_ws,cid+'_'+model,WScales), + Channel("singleelectron0tagModel",_wspace,out_ws,cid+'_'+model,WScales_e), + ] + + # ############################ USER DEFINED ########################################################### + # Add systematics in the following, for normalisations use name, relative size (0.01 --> 1%) + # for shapes use add_nuisance_shape with (name,_fOut) + # note, the code will LOOK for something called NOMINAL_name_Up and NOMINAL_name_Down, where NOMINAL=WScales.GetName() + # these must be created and writted to the same dirctory as the nominal (fDir) + + #CRs[0].add_nuisance("SingleMuonEff",0.01) + #CRs[1].add_nuisance("SingleElEff",0.02) + + def addStatErrs(hx,cr,crname1,crname2): + for b in range(1,targetmc.GetNbinsX()+1): + err = hx.GetBinError(b) + if not hx.GetBinContent(b)>0: + continue + relerr = err/hx.GetBinContent(b) + if relerr<0.01: + continue + byb_u = hx.Clone(); byb_u.SetName('%s_weights_%s_%s_stat_error_%s_bin%d_Up'%(crname1,cid,cid,crname2,b-1)) + byb_u.SetBinContent(b,hx.GetBinContent(b)+err) + byb_d = hx.Clone(); byb_d.SetName('%s_weights_%s_%s_stat_error_%s_bin%d_Down'%(crname1,cid,cid,crname2,b-1)) + if errlv in signal is dependant on the Z->vv and then the W->mv is depenant on W->lv, then + # give the arguments model,channel name from the config which defines the Z->vv => W->lv map! + # Return of course + return cat diff --git a/W_constraints_monojet_1tag.py b/W_constraints_monojet_1tag.py new file mode 100644 index 0000000..ef400e0 --- /dev/null +++ b/W_constraints_monojet_1tag.py @@ -0,0 +1,112 @@ + import ROOT +from counting_experiment import * +# Define how a control region(s) transfer is made by defining cmodel provide, the calling pattern must be unchanged! +# First define simple string which will be used for the datacard +model = "wjets" +def cmodel(cid,nam,_f,_fOut, out_ws, diag): + + # Some setup + _fin = _f.Get("category_%s"%cid) + _wspace = _fin.Get("wspace_%s"%cid) + + + # ############################ USER DEFINED ########################################################### + # First define the nominal transfer factors (histograms of signal/control, usually MC + # note there are many tools available inside include/diagonalize.h for you to make + # special datasets/histograms representing these and systematic effects + # but for now this is just kept simple + processName = "WJets" # Give a name of the process being modelled + metname = "met" # Observable variable name + + controlmc0tag = _fin.Get("singlemuon0tag_wjets") # defines in / out acceptance + controlmc0tag_e = _fin.Get("singleelectron0tag_wjets") # defines in / out acceptance + targetmc1tag = _fin.Get("signal1tag_wjets") # define monimal (MC) of which process this config will model + controlmc1tag = _fin.Get("singlemuon1tag_wjets") # defines in / out acceptance + controlmc1tag_e = _fin.Get("singleelectron1tag_wjets") # defines in / out acceptance + controlmc2tag = _fin.Get("singlemuon2tag_wjets") # defines in / out acceptance + controlmc2tag_e = _fin.Get("singleelectron2tag_wjets") # defines in / out acceptance + + # Create the transfer factors and save them (not here you can also create systematic variations of these + # transfer factors (named with extention _sysname_Up/Down + + WScales1tag = targetmc1tag.Clone(); WScales1tag.SetName("wmn1tag_weights_%s"%cid) + WScales1tag.Divide(controlmc1tag); _fOut.WriteTObject(WScales1tag) + + WScales1tag_e = targetmc1tag.Clone(); WScales1tag_e.SetName("wen1tag_weights_%s"%cid) + WScales1tag_e.Divide(controlmc1tag_e); _fOut.WriteTObject(WScales1tag_e) + + WScales0tagTo1tag = targetmc1tag.Clone(); WScales0tagTo1tag.SetName("wmn0tagto1tag_weights_%s"%cid) + WScales0tagTo1tag.Divide(controlmc0tag); _fOut.WriteTObject(WScales0tagTo1tag) + + WScales0tagTo1tag_e = targetmc1tag.Clone(); WScales0tagTo1tag_e.SetName("wen0tagto1tag_weights_%s"%cid) + WScales0tagTo1tag_e.Divide(controlmc0tag_e); _fOut.WriteTObject(WScales0tagTo1tag_e) + + WScales2tagTo1tag = targetmc1tag.Clone(); WScales2tagTo1tag.SetName("wmn2tagto1tag_weights_%s"%cid) + WScales2tagTo1tag.Divide(controlmc2tag); _fOut.WriteTObject(WScales2tagTo1tag) + + WScales2tagTo1tag_e = targetmc1tag.Clone(); WScales2tagTo1tag_e.SetName("wen2tagto1tag_weights_%s"%cid) + WScales2tagTo1tag_e.Divide(controlmc2tag_e); _fOut.WriteTObject(WScales2tagTo1tag_e) + + ####################################################################################################### + + _bins = [] # take bins from some histogram, can choose anything but this is easy + for b in range(targetmc.GetNbinsX()+1): + _bins.append(targetmc.GetBinLowEdge(b+1)) + + # Here is the important bit which "Builds" the control region, make a list of control regions which + # are constraining this process, each "Channel" is created with ... + # (name,_wspace,out_ws,cid+'_'+model,TRANSFERFACTORS) + # the second and third arguments can be left unchanged, the others instead must be set + # TRANSFERFACTORS are what is created above, eg WScales + + CRs = [ + Channel("singlemuon1tagModel",_wspace,out_ws,cid+'_'+model,WScales1tag), + Channel("singleelectron1tagModel",_wspace,out_ws,cid+'_'+model,WScales1tag_e), + Channel("singlemuon0tagTo1tagModel",_wspace,out_ws,cid+'_'+model,WScales0tagTo1tag), + Channel("singleelectron0tagTo1tagModel",_wspace,out_ws,cid+'_'+model,WScales0tagTo1tag_e), + Channel("singlemuon2tagTo1tagModel",_wspace,out_ws,cid+'_'+model,WScales2tagTo1tag), + Channel("singleelectron2tagTo1tagModel",_wspace,out_ws,cid+'_'+model,WScales2tagTo1tag_e) + ] + + # ############################ USER DEFINED ########################################################### + # Add systematics in the following, for normalisations use name, relative size (0.01 --> 1%) + # for shapes use add_nuisance_shape with (name,_fOut) + # note, the code will LOOK for something called NOMINAL_name_Up and NOMINAL_name_Down, where NOMINAL=WScales.GetName() + # these must be created and writted to the same dirctory as the nominal (fDir) + + #CRs[0].add_nuisance("SingleMuonEff",0.01) + #CRs[1].add_nuisance("SingleElEff",0.02) + + def addStatErrs(hx,cr,crname1,crname2): + for b in range(1,targetmc.GetNbinsX()+1): + err = hx.GetBinError(b) + if not hx.GetBinContent(b)>0: + continue + relerr = err/hx.GetBinContent(b) + if relerr<0.01: + continue + byb_u = hx.Clone(); byb_u.SetName('%s_weights_%s_%s_stat_error_%s_bin%d_Up'%(crname1,cid,cid,crname2,b-1)) + byb_u.SetBinContent(b,hx.GetBinContent(b)+err) + byb_d = hx.Clone(); byb_d.SetName('%s_weights_%s_%s_stat_error_%s_bin%d_Down'%(crname1,cid,cid,crname2,b-1)) + if errlv in signal is dependant on the Z->vv and then the W->mv is depenant on W->lv, then + # give the arguments model,channel name from the config which defines the Z->vv => W->lv map! + # Return of course + return cat diff --git a/W_constraints_monojet_2tag.py b/W_constraints_monojet_2tag.py new file mode 100644 index 0000000..2138aca --- /dev/null +++ b/W_constraints_monojet_2tag.py @@ -0,0 +1,87 @@ + import ROOT +from counting_experiment import * +# Define how a control region(s) transfer is made by defining cmodel provide, the calling pattern must be unchanged! +# First define simple string which will be used for the datacard +model = "wjets" +def cmodel(cid,nam,_f,_fOut, out_ws, diag): + + # Some setup + _fin = _f.Get("category_%s"%cid) + _wspace = _fin.Get("wspace_%s"%cid) + + + # ############################ USER DEFINED ########################################################### + # First define the nominal transfer factors (histograms of signal/control, usually MC + # note there are many tools available inside include/diagonalize.h for you to make + # special datasets/histograms representing these and systematic effects + # but for now this is just kept simple + processName = "WJets" # Give a name of the process being modelled + metname = "met" # Observable variable name + targetmc = _fin.Get("signal2tag_wjets") # define monimal (MC) of which process this config will model + controlmc = _fin.Get("singlemuon2tag_wjets") # defines in / out acceptance + controlmc_e = _fin.Get("singleelectron2tag_wjets") # defines in / out acceptance + + # Create the transfer factors and save them (not here you can also create systematic variations of these + # transfer factors (named with extention _sysname_Up/Down + WScales = targetmc.Clone(); WScales.SetName("wmn2tag_weights_%s"%cid) + WScales.Divide(controlmc); _fOut.WriteTObject(WScales) + + WScales_e = targetmc.Clone(); WScales_e.SetName("wen2tag_weights_%s"%cid) + WScales_e.Divide(controlmc_e); _fOut.WriteTObject(WScales_e) + + ####################################################################################################### + + _bins = [] # take bins from some histogram, can choose anything but this is easy + for b in range(targetmc.GetNbinsX()+1): + _bins.append(targetmc.GetBinLowEdge(b+1)) + + # Here is the important bit which "Builds" the control region, make a list of control regions which + # are constraining this process, each "Channel" is created with ... + # (name,_wspace,out_ws,cid+'_'+model,TRANSFERFACTORS) + # the second and third arguments can be left unchanged, the others instead must be set + # TRANSFERFACTORS are what is created above, eg WScales + + CRs = [ + Channel("singlemuon2tagModel",_wspace,out_ws,cid+'_'+model,WScales), + Channel("singleelectron2tagModel",_wspace,out_ws,cid+'_'+model,WScales_e), + ] + + # ############################ USER DEFINED ########################################################### + # Add systematics in the following, for normalisations use name, relative size (0.01 --> 1%) + # for shapes use add_nuisance_shape with (name,_fOut) + # note, the code will LOOK for something called NOMINAL_name_Up and NOMINAL_name_Down, where NOMINAL=WScales.GetName() + # these must be created and writted to the same dirctory as the nominal (fDir) + + #CRs[0].add_nuisance("SingleMuonEff",0.01) + #CRs[1].add_nuisance("SingleElEff",0.02) + + def addStatErrs(hx,cr,crname1,crname2): + for b in range(1,targetmc.GetNbinsX()+1): + err = hx.GetBinError(b) + if not hx.GetBinContent(b)>0: + continue + relerr = err/hx.GetBinContent(b) + if relerr<0.01: + continue + byb_u = hx.Clone(); byb_u.SetName('%s_weights_%s_%s_stat_error_%s_bin%d_Up'%(crname1,cid,cid,crname2,b-1)) + byb_u.SetBinContent(b,hx.GetBinContent(b)+err) + byb_d = hx.Clone(); byb_d.SetName('%s_weights_%s_%s_stat_error_%s_bin%d_Down'%(crname1,cid,cid,crname2,b-1)) + if errlv in signal is dependant on the Z->vv and then the W->mv is depenant on W->lv, then + # give the arguments model,channel name from the config which defines the Z->vv => W->lv map! + # Return of course + return cat From 00959e859269a30ca4bc6d1c408121500a6df681 Mon Sep 17 00:00:00 2001 From: Sonaina Undleeb Date: Wed, 12 Sep 2018 12:40:05 -0500 Subject: [PATCH 02/12] monojet config fixed --- configs/monojet.py | 98 +++++++++++++++++----------------------------- 1 file changed, 37 insertions(+), 61 deletions(-) diff --git a/configs/monojet.py b/configs/monojet.py index 6ab164e..008aeea 100644 --- a/configs/monojet.py +++ b/configs/monojet.py @@ -27,7 +27,8 @@ monojet_category[s] = { 'name':"monojet_"+s #,'in_file_name':"/uscms_data/d1/shoh/panda/v_8029_DarkHiggs_v2/flat/limits/fittingForest_monojet_"+s+".root" - ,'in_file_name':"/uscms/home/naina25/nobackup/Panda_2018/Panda_Analysis/CMSSW_8_0_29/src/PandaAnalysis/SuperMonoJet/fitting/fittingForest_monojet_"+s+".root" + # ,'in_file_name':"/uscms/home/naina25/nobackup/Panda_2018/Panda_Analysis/CMSSW_8_0_29/src/PandaAnalysis/SuperMonoJet/fitting/fittingForest_monojet_"+s+".root" + ,'in_file_name':"/uscms_data/d3/naina25/panda/80X-v1.5-monojet/fittingForest_"+s+".root" ,"cutstring":"" ,"varstring":["min(999.9999,met)",250,1250] ,"weightname":"weight" @@ -37,79 +38,54 @@ ,"samples": { # Signal Region -# "VH_signal" :['signal'+s,'vh',1,0] - "Zvv_signal" :['signal'+s,'zjets',1,0] - ,"Zll_signal" :['signal'+s,'zll',1,0] - ,"Wlv_signal" :['signal'+s,'wjets',1,0] - ,"Diboson_signal" :['signal'+s,'dibosons',1,0] - ,"ttbar_signal" :['signal'+s,'ttbar',1,0] - ,"ST_signal" :['signal'+s,'stop',1,0] - ,"QCD_signal" :['signal'+s,'qcd',1,0] - ,"GJets_signal" :['signal'+s,'gjets',1,0] - ,"Data_signal" :['signal'+s,'data',0,0] +# "VH_signal_"+s :['signal'+s,'vh',1,0] + "Zvv_signal_"+s :['signal'+s,'zjets',1,0] + ,"Zll_signal_"+s :['signal'+s,'zll',1,0] + ,"Wlv_signal_"+s :['signal'+s,'wjets',1,0] + ,"Diboson_signal_"+s :['signal'+s,'dibosons',1,0] + ,"ttbar_signal_"+s :['signal'+s,'ttbar',1,0] + ,"ST_signal_"+s :['signal'+s,'stop',1,0] + ,"QCD_signal_"+s :['signal'+s,'qcd',1,0] + ,"Data_signal_"+s :['signal'+s,'data',0,0] # signals - ,"hsDM_1000_50_100_signal" :['signal'+s,'hsDM-1000-50-100_signal',1,1] - ,"hsDM_1000_50_200_signal" :['signal'+s,'hsDM-1000-50-200_signal',1,1] - ,"hsDM_1000_50_250_signal" :['signal'+s,'hsDM-1000-50-250_signal',1,1] - ,"hsDM_1000_50_300_signal" :['signal'+s,'hsDM-1000-50-300_signal',1,1] - - ,"ZpDM_1000_150_10_signal" :['signal'+s,'ZpDM-1000-150-10_signal',1,1] - ,"ZpDM_1000_50_10_signal" :['signal'+s,'ZpDM-1000-50-10_signal',1,1] - ,"ZpDM_100_150_10_signal" :['signal'+s,'ZpDM-100-150-10_signal',1,1] - ,"ZpDM_100_50_10_signal" :['signal'+s,'ZpDM-100-50-10_signal',1,1] - ,"ZpDM_1500_150_10_signal" :['signal'+s,'ZpDM-1500-150-10_signal',1,1] - ,"ZpDM_1500_50_10_signal" :['signal'+s,'ZpDM-1500-50-10_signal',1,1] - ,"ZpDM_2000_150_10_signal" :['signal'+s,'ZpDM-2000-150-10_signal',1,1] - ,"ZpDM_2000_50_10_signal" :['signal'+s,'ZpDM-2000-50-10_signal',1,1] - ,"ZpDM_2500_150_10_signal" :['signal'+s,'ZpDM-2500-150-10_signal',1,1] - ,"ZpDM_3000_150_10_signal" :['signal'+s,'ZpDM-3000-150-10_signal',1,1] - ,"ZpDM_3000_50_10_signal" :['signal'+s,'ZpDM-3000-50-10_signal',1,1] - ,"ZpDM_300_150_10_signal" :['signal'+s,'ZpDM-300-150-10_signal',1,1] # Di muon-Control -# ,"VH_zmm" :['dimuon'+s,'vh',1,0] - ,"Zll_zmm" :['dimuon'+s,'zll',1,1] - ,"Wlv_zmm" :['dimuon'+s,'wjets',1,0] - ,"Diboson_zmm" :['dimuon'+s,'dibosons',1,0] - ,"ttbar_zmm" :['dimuon'+s,'ttbar',1,0] - ,"ST_zmm" :['dimuon'+s,'stop',1,0] - ,"QCD_zmm" :['dimuon'+s,'qcd',1,0] - ,"Data_zmm" :['dimuon'+s,'data',0,0] +# ,"VH_zmm_"+s :['dimuon'+s,'vh',1,0] + ,"Zll_zmm_"+s :['dimuon'+s,'zll',1,1] + ,"Diboson_zmm_"+s :['dimuon'+s,'dibosons',1,0] + ,"ttbar_zmm_"+s :['dimuon'+s,'ttbar',1,0] + ,"Data_zmm_"+s :['dimuon'+s,'data',0,0] # Di electron-Control -# ,"VH_zee" :['dielectron'+s,'vh',1,0] - ,"Zll_zee" :['dielectron'+s,'zll',1,1] - ,"Wlv_zee" :['dielectron'+s,'wjets',1,0] - ,"Diboson_zee" :['dielectron'+s,'dibosons',1,0] - ,"ttbar_zee" :['dielectron'+s,'ttbar',1,0] - ,"ST_zee" :['dielectron'+s,'stop',1,0] - ,"QCD_zee" :['dielectron'+s,'qcd',1,0] - ,"Data_zee" :['dielectron'+s,'data',0,0] +# ,"VH_zee_"+s :['dielectron'+s,'vh',1,0] + ,"Zll_zee_"+s :['dielectron'+s,'zll',1,1] + ,"Diboson_zee_"+s :['dielectron'+s,'dibosons',1,0] + ,"ttbar_zee_"+s :['dielectron'+s,'ttbar',1,0] + ,"Data_zee_"+s :['dielectron'+s,'data',0,0] # Single muon (w) control # ,"VH_mn" :['singlemuon'+s,'vh',1,0] - ,"Zll_mn" :['singlemuon'+s,'zll',1,0] - ,"Wlv_mn" :['singlemuon'+s,'wjets',1,1] - ,"Diboson_mn" :['singlemuon'+s,'dibosons',1,0] - ,"ttbar_mn" :['singlemuon'+s,'ttbar',1,0] - ,"ST_mn" :['singlemuon'+s,'stop',1,0] - ,"QCD_mn" :['singlemuon'+s,'qcd',1,0] - ,"Data_mn" :['singlemuon'+s,'data',0,0] + ,"Zll_wmn_"+s :['singlemuon'+s,'zll',1,0] + ,"Wlv_wmn_"+s :['singlemuon'+s,'wjets',1,1] + ,"Diboson_wmn_"+s :['singlemuon'+s,'dibosons',1,0] + ,"ttbar_wmn_"+s :['singlemuon'+s,'ttbar',1,0] + ,"QCD_wmn_"+s :['singlemuon'+s,'qcd',1,0] + ,"Data_wmn_"+s :['singlemuon'+s,'data',0,0] # Single electron (w) control # ,"VH_en" :['singleelectron'+s,'vh',1,0] - ,"Zll_en" :['singleelectron'+s,'zll',1,0] - ,"Wlv_en" :['singleelectron'+s,'wjets',1,1] - ,"Diboson_en" :['singleelectron'+s,'dibosons',1,0] - ,"ttbar_en" :['singleelectron'+s,'ttbar',1,1] - ,"ST_en" :['singleelectron'+s,'stop',1,0] - ,"QCD_en" :['singleelectron'+s,'qcd',1,0] - ,"Data_en" :['singleelectron'+s,'data',0,0] + ,"Zll_wen_"+s :['singleelectron'+s,'zll',1,0] + ,"Wlv_wen_"+s :['singleelectron'+s,'wjets',1,1] + ,"Diboson_wen_"+s :['singleelectron'+s,'dibosons',1,0] + ,"ttbar_wen_"+s :['singleelectron'+s,'ttbar',1,1] + ,"ST_wen_"+s :['singleelectron'+s,'stop',1,0] + ,"QCD_wen_"+s :['singleelectron'+s,'qcd',1,0] + ,"Data_wen_"+s :['singleelectron'+s,'data',0,0] # Single photon control - ,"GJets_gjets" :['singlephoton'+s,'gjets',1,1] - ,"QCD_gjets" :['singlephoton'+s,'qcd',1,0] - ,"Data_gjets" :['singlephoton'+s,'data',0,0] + ,"Pho_pho_"+s :['singlephoton'+s,'gjets',1,1] + ,"QCD_pho_"+s :['singlephoton'+s,'qcd',1,0] + ,"Data_pho_"+s :['singlephoton'+s,'data',0,0] } } From be3ffed349b2767c8d8ff2942393bdcdbdc3b961 Mon Sep 17 00:00:00 2001 From: Sonaina Undleeb Date: Wed, 12 Sep 2018 12:48:29 -0500 Subject: [PATCH 03/12] monojet config fixed --- configs/monojet.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/configs/monojet.py b/configs/monojet.py index 008aeea..d511753 100644 --- a/configs/monojet.py +++ b/configs/monojet.py @@ -48,6 +48,23 @@ ,"QCD_signal_"+s :['signal'+s,'qcd',1,0] ,"Data_signal_"+s :['signal'+s,'data',0,0] # signals + ,"hsDM_1000_50_100_signal"+s :['signal'+s,'hsDM-1000-50-100_signal',1,1] + ,"hsDM_1000_50_200_signal"+s :['signal'+s,'hsDM-1000-50-200_signal',1,1] + ,"hsDM_1000_50_250_signal"+s :['signal'+s,'hsDM-1000-50-250_signal',1,1] + ,"hsDM_1000_50_300_signal"+s :['signal'+s,'hsDM-1000-50-300_signal',1,1] + + ,"ZpDM_1000_150_10_signal"+s :['signal'+s,'ZpDM-1000-150-10_signal',1,1] + ,"ZpDM_1000_50_10_signal"+s :['signal'+s,'ZpDM-1000-50-10_signal',1,1] + ,"ZpDM_100_150_10_signal"+s :['signal'+s,'ZpDM-100-150-10_signal',1,1] + ,"ZpDM_100_50_10_signal"+s :['signal'+s,'ZpDM-100-50-10_signal',1,1] + ,"ZpDM_1500_150_10_signal"+s :['signal'+s,'ZpDM-1500-150-10_signal',1,1] + ,"ZpDM_1500_50_10_signal"+s :['signal'+s,'ZpDM-1500-50-10_signal',1,1] + ,"ZpDM_2000_150_10_signal"+s :['signal'+s,'ZpDM-2000-150-10_signal',1,1] + ,"ZpDM_2000_50_10_signal"+s :['signal'+s,'ZpDM-2000-50-10_signal',1,1] + ,"ZpDM_2500_150_10_signal"+s :['signal'+s,'ZpDM-2500-150-10_signal',1,1] + ,"ZpDM_3000_150_10_signal"+s :['signal'+s,'ZpDM-3000-150-10_signal',1,1] + ,"ZpDM_3000_50_10_signal"+s :['signal'+s,'ZpDM-3000-50-10_signal',1,1] + ,"ZpDM_300_150_10_signal"+s :['signal'+s,'ZpDM-300-150-10_signal',1,1] # Di muon-Control # ,"VH_zmm_"+s :['dimuon'+s,'vh',1,0] From 877eca1891ac594cb01a924d862fa392c4e468a9 Mon Sep 17 00:00:00 2001 From: Sonaina Undleeb Date: Fri, 14 Sep 2018 18:09:35 -0500 Subject: [PATCH 04/12] btag systs added in W_constraints_1tag --- W_constraints_monojet_1tag.py | 127 +++++++++++++++++++--------------- 1 file changed, 70 insertions(+), 57 deletions(-) diff --git a/W_constraints_monojet_1tag.py b/W_constraints_monojet_1tag.py index ef400e0..a7e231d 100644 --- a/W_constraints_monojet_1tag.py +++ b/W_constraints_monojet_1tag.py @@ -2,14 +2,56 @@ from counting_experiment import * # Define how a control region(s) transfer is made by defining cmodel provide, the calling pattern must be unchanged! # First define simple string which will be used for the datacard + model = "wjets" + +### helper functions ### + +def makeW(cid,_fOut,newName,targetmc,controlmc,systs=None): + WScales = targetmc.Clone(); WScales.SetName(newName+"_weights_%s"%cid) + WScales.Divide(controlmc) + _fOut.WriteTObject(WScales) + + if not(systs==None): + WScalesUp = systs['targetmcbtagUp'].Clone(); + WScalesUp.SetName(newName+"_weights_%s_btag_Up"%cid) + WScalesUp.Divide(systs['controlmcbtagUp']) + + WScalesDown = systs['targetmcbtagDown'].Clone(); + WScalesDown.SetName(newName+"_weights_%s_Down"%cid) + WScalesDown.Divide(systs['controlmcbtagDown']) + + _fOut.WriteTObject(WScalesUp) + _fOut.WriteTObject(WScalesDown) + + return WScales + +def addWErrors(WScales,targetmc,newName,crName,_fOut,CRs,cid): + for b in range(1,targetmc.GetNbinsX()+1): + err = WScales.GetBinError(b) + if not WScales.GetBinContent(b)>0: + continue + relerr = err/WScales.GetBinContent(b) + if relerr<0.01: + continue + byb_u = WScales.Clone(); byb_u.SetName('%s_weights_%s_%s_stat_error_%s_bin%d_Up'%(newName,cid,cid,crName,b-1)) + byb_u.SetBinContent(b,WScales.GetBinContent(b)+err) + byb_d = WScales.Clone(); byb_d.SetName('%s_weights_%s_%s_stat_error_%s_bin%d_Down'%(newName,cid,cid,crName,b-1)) + if err0: - continue - relerr = err/hx.GetBinContent(b) - if relerr<0.01: - continue - byb_u = hx.Clone(); byb_u.SetName('%s_weights_%s_%s_stat_error_%s_bin%d_Up'%(crname1,cid,cid,crname2,b-1)) - byb_u.SetBinContent(b,hx.GetBinContent(b)+err) - byb_d = hx.Clone(); byb_d.SetName('%s_weights_%s_%s_stat_error_%s_bin%d_Down'%(crname1,cid,cid,crname2,b-1)) - if errlv in signal is dependant on the Z->vv and then the W->mv is depenant on W->lv, then # give the arguments model,channel name from the config which defines the Z->vv => W->lv map! From 563f8fe9ebffaf5b01a8f44fd0bbb80287cae69f Mon Sep 17 00:00:00 2001 From: Sonaina Undleeb Date: Sun, 30 Sep 2018 20:49:07 -0500 Subject: [PATCH 05/12] monojet updates --- configs/monojet.py | 42 ++++++++++++++++++++---------------------- 1 file changed, 20 insertions(+), 22 deletions(-) diff --git a/configs/monojet.py b/configs/monojet.py index d511753..189765f 100644 --- a/configs/monojet.py +++ b/configs/monojet.py @@ -28,7 +28,7 @@ 'name':"monojet_"+s #,'in_file_name':"/uscms_data/d1/shoh/panda/v_8029_DarkHiggs_v2/flat/limits/fittingForest_monojet_"+s+".root" # ,'in_file_name':"/uscms/home/naina25/nobackup/Panda_2018/Panda_Analysis/CMSSW_8_0_29/src/PandaAnalysis/SuperMonoJet/fitting/fittingForest_monojet_"+s+".root" - ,'in_file_name':"/uscms_data/d3/naina25/panda/80X-v1.5-monojet/fittingForest_"+s+".root" + ,'in_file_name':"/uscms/home/naina25/nobackup/Panda_2018/Panda_Analysis/CMSSW_8_0_29/src/PandaAnalysis/SuperMonoJet/fitting/monojet/fittingForest_"+s+".root" ,"cutstring":"" ,"varstring":["min(999.9999,met)",250,1250] ,"weightname":"weight" @@ -40,31 +40,29 @@ # Signal Region # "VH_signal_"+s :['signal'+s,'vh',1,0] "Zvv_signal_"+s :['signal'+s,'zjets',1,0] - ,"Zll_signal_"+s :['signal'+s,'zll',1,0] + ,"Zll_signal_"+s :['signal'+s,'zll',1,0] ,"Wlv_signal_"+s :['signal'+s,'wjets',1,0] - ,"Diboson_signal_"+s :['signal'+s,'dibosons',1,0] + ,"Diboson_signal_"+s :['signal'+s,'dibosons',1,0] ,"ttbar_signal_"+s :['signal'+s,'ttbar',1,0] - ,"ST_signal_"+s :['signal'+s,'stop',1,0] - ,"QCD_signal_"+s :['signal'+s,'qcd',1,0] + ,"ST_signal_"+s :['signal'+s,'stop',1,0] + ,"QCD_signal_"+s :['signal'+s,'qcd',1,0] ,"Data_signal_"+s :['signal'+s,'data',0,0] # signals - ,"hsDM_1000_50_100_signal"+s :['signal'+s,'hsDM-1000-50-100_signal',1,1] - ,"hsDM_1000_50_200_signal"+s :['signal'+s,'hsDM-1000-50-200_signal',1,1] - ,"hsDM_1000_50_250_signal"+s :['signal'+s,'hsDM-1000-50-250_signal',1,1] - ,"hsDM_1000_50_300_signal"+s :['signal'+s,'hsDM-1000-50-300_signal',1,1] - - ,"ZpDM_1000_150_10_signal"+s :['signal'+s,'ZpDM-1000-150-10_signal',1,1] - ,"ZpDM_1000_50_10_signal"+s :['signal'+s,'ZpDM-1000-50-10_signal',1,1] - ,"ZpDM_100_150_10_signal"+s :['signal'+s,'ZpDM-100-150-10_signal',1,1] - ,"ZpDM_100_50_10_signal"+s :['signal'+s,'ZpDM-100-50-10_signal',1,1] - ,"ZpDM_1500_150_10_signal"+s :['signal'+s,'ZpDM-1500-150-10_signal',1,1] - ,"ZpDM_1500_50_10_signal"+s :['signal'+s,'ZpDM-1500-50-10_signal',1,1] - ,"ZpDM_2000_150_10_signal"+s :['signal'+s,'ZpDM-2000-150-10_signal',1,1] - ,"ZpDM_2000_50_10_signal"+s :['signal'+s,'ZpDM-2000-50-10_signal',1,1] - ,"ZpDM_2500_150_10_signal"+s :['signal'+s,'ZpDM-2500-150-10_signal',1,1] - ,"ZpDM_3000_150_10_signal"+s :['signal'+s,'ZpDM-3000-150-10_signal',1,1] - ,"ZpDM_3000_50_10_signal"+s :['signal'+s,'ZpDM-3000-50-10_signal',1,1] - ,"ZpDM_300_150_10_signal"+s :['signal'+s,'ZpDM-300-150-10_signal',1,1] + ,"hsDM_1000_50_100_signal_"+s :['signal'+s,'hsDM-1000-50-100_signal',1,1] + ,"hsDM_1000_50_200_signal_"+s :['signal'+s,'hsDM-1000-50-200_signal',1,1] + ,"hsDM_1000_50_250_signal_"+s :['signal'+s,'hsDM-1000-50-250_signal',1,1] + ,"ZpDM_1000_150_10_signal_"+s :['signal'+s,'ZpDM-1000-150-10_signal',1,1] + ,"ZpDM_1000_50_10_signal_"+s :['signal'+s,'ZpDM-1000-50-10_signal',1,1] + ,"ZpDM_100_150_10_signal_"+s :['signal'+s,'ZpDM-100-150-10_signal',1,1] + ,"ZpDM_100_50_10_signal_"+s :['signal'+s,'ZpDM-100-50-10_signal',1,1] + ,"ZpDM_1500_150_10_signal_"+s :['signal'+s,'ZpDM-1500-150-10_signal',1,1] + ,"ZpDM_1500_50_10_signal_"+s :['signal'+s,'ZpDM-1500-50-10_signal',1,1] + ,"ZpDM_2000_150_10_signal_"+s :['signal'+s,'ZpDM-2000-150-10_signal',1,1] + ,"ZpDM_2000_50_10_signal_"+s :['signal'+s,'ZpDM-2000-50-10_signal',1,1] + ,"ZpDM_2500_150_10_signal_"+s :['signal'+s,'ZpDM-2500-150-10_signal',1,1] + ,"ZpDM_3000_150_10_signal_"+s :['signal'+s,'ZpDM-3000-150-10_signal',1,1] + ,"ZpDM_3000_50_10_signal_"+s :['signal'+s,'ZpDM-3000-50-10_signal',1,1] + ,"ZpDM_300_150_10_signal_"+s :['signal'+s,'ZpDM-300-150-10_signal',1,1] # Di muon-Control # ,"VH_zmm_"+s :['dimuon'+s,'vh',1,0] From dfbf3277ad4c10abeec77821c1d480fc6e7ead18 Mon Sep 17 00:00:00 2001 From: Sonaina Undleeb Date: Sun, 30 Sep 2018 22:34:31 -0500 Subject: [PATCH 06/12] removed W constraints for 2btag --- W_constraints_monojet_2tag.py | 87 ----------------------------------- 1 file changed, 87 deletions(-) delete mode 100644 W_constraints_monojet_2tag.py diff --git a/W_constraints_monojet_2tag.py b/W_constraints_monojet_2tag.py deleted file mode 100644 index 2138aca..0000000 --- a/W_constraints_monojet_2tag.py +++ /dev/null @@ -1,87 +0,0 @@ - import ROOT -from counting_experiment import * -# Define how a control region(s) transfer is made by defining cmodel provide, the calling pattern must be unchanged! -# First define simple string which will be used for the datacard -model = "wjets" -def cmodel(cid,nam,_f,_fOut, out_ws, diag): - - # Some setup - _fin = _f.Get("category_%s"%cid) - _wspace = _fin.Get("wspace_%s"%cid) - - - # ############################ USER DEFINED ########################################################### - # First define the nominal transfer factors (histograms of signal/control, usually MC - # note there are many tools available inside include/diagonalize.h for you to make - # special datasets/histograms representing these and systematic effects - # but for now this is just kept simple - processName = "WJets" # Give a name of the process being modelled - metname = "met" # Observable variable name - targetmc = _fin.Get("signal2tag_wjets") # define monimal (MC) of which process this config will model - controlmc = _fin.Get("singlemuon2tag_wjets") # defines in / out acceptance - controlmc_e = _fin.Get("singleelectron2tag_wjets") # defines in / out acceptance - - # Create the transfer factors and save them (not here you can also create systematic variations of these - # transfer factors (named with extention _sysname_Up/Down - WScales = targetmc.Clone(); WScales.SetName("wmn2tag_weights_%s"%cid) - WScales.Divide(controlmc); _fOut.WriteTObject(WScales) - - WScales_e = targetmc.Clone(); WScales_e.SetName("wen2tag_weights_%s"%cid) - WScales_e.Divide(controlmc_e); _fOut.WriteTObject(WScales_e) - - ####################################################################################################### - - _bins = [] # take bins from some histogram, can choose anything but this is easy - for b in range(targetmc.GetNbinsX()+1): - _bins.append(targetmc.GetBinLowEdge(b+1)) - - # Here is the important bit which "Builds" the control region, make a list of control regions which - # are constraining this process, each "Channel" is created with ... - # (name,_wspace,out_ws,cid+'_'+model,TRANSFERFACTORS) - # the second and third arguments can be left unchanged, the others instead must be set - # TRANSFERFACTORS are what is created above, eg WScales - - CRs = [ - Channel("singlemuon2tagModel",_wspace,out_ws,cid+'_'+model,WScales), - Channel("singleelectron2tagModel",_wspace,out_ws,cid+'_'+model,WScales_e), - ] - - # ############################ USER DEFINED ########################################################### - # Add systematics in the following, for normalisations use name, relative size (0.01 --> 1%) - # for shapes use add_nuisance_shape with (name,_fOut) - # note, the code will LOOK for something called NOMINAL_name_Up and NOMINAL_name_Down, where NOMINAL=WScales.GetName() - # these must be created and writted to the same dirctory as the nominal (fDir) - - #CRs[0].add_nuisance("SingleMuonEff",0.01) - #CRs[1].add_nuisance("SingleElEff",0.02) - - def addStatErrs(hx,cr,crname1,crname2): - for b in range(1,targetmc.GetNbinsX()+1): - err = hx.GetBinError(b) - if not hx.GetBinContent(b)>0: - continue - relerr = err/hx.GetBinContent(b) - if relerr<0.01: - continue - byb_u = hx.Clone(); byb_u.SetName('%s_weights_%s_%s_stat_error_%s_bin%d_Up'%(crname1,cid,cid,crname2,b-1)) - byb_u.SetBinContent(b,hx.GetBinContent(b)+err) - byb_d = hx.Clone(); byb_d.SetName('%s_weights_%s_%s_stat_error_%s_bin%d_Down'%(crname1,cid,cid,crname2,b-1)) - if errlv in signal is dependant on the Z->vv and then the W->mv is depenant on W->lv, then - # give the arguments model,channel name from the config which defines the Z->vv => W->lv map! - # Return of course - return cat From 0666fe050bb6c166a2de333951e87e74fcc74caf Mon Sep 17 00:00:00 2001 From: Sonaina Undleeb Date: Thu, 4 Oct 2018 00:30:56 -0500 Subject: [PATCH 07/12] updated top constraints for monojet --- Top_constraints_monojet_0tag.py | 91 +++++++++++++++++++++++ Top_constraints_monojet_1tag.py | 125 ++++++++++++++++++++++++++++++++ 2 files changed, 216 insertions(+) create mode 100644 Top_constraints_monojet_0tag.py create mode 100644 Top_constraints_monojet_1tag.py diff --git a/Top_constraints_monojet_0tag.py b/Top_constraints_monojet_0tag.py new file mode 100644 index 0000000..232f646 --- /dev/null +++ b/Top_constraints_monojet_0tag.py @@ -0,0 +1,91 @@ +import ROOT +from counting_experiment import * +# Define how a control region(s) transfer is made by defining cmodel provide, the calling pattern must be unchanged! +# First define simple string which will be used for the datacard +model = "ttbar" +convertHistograms = [] + +### helper functions ### + +def cmodel(cid,nam,_f,_fOut, out_ws, diag): + # Some setup + _fin = _f.Get("category_%s"%cid) + _wspace = _fin.Get("wspace_%s"%cid) + + # ############################ USER DEFINED ########################################################### + # First define the nominal transfer factors (histograms of signal/control, usually MC + # note there are many tools available inside include/diagonalize.h for you to make + # special datasets/histograms representing these and systematic effects + # but for now this is just kept simple + processName = "TTbar" # Give a name of the process being modelled + metname = "met" # Observable variable name + + targetmc = _fin.Get("signal0tag_ttbar") # define monimal (MC) of which process this config will model + controlmc_wm = _fin.Get("singlemuon0tag_ttbar") + controlmc_we = _fin.Get("singleelectron0tag_ttbar") + + + + # Create the transfer factors and save them (not here you can also create systematic variations of these + # transfer factors (named with extention _sysname_Up/Down + + TopScales_wm = targetmc.Clone(); TopScales_wm.SetName("topwm0tag_weights_%s"%cid) + TopScales_wm.Divide(controlmc_wm); _fOut.WriteTObject(TopScales_wm); + + TopScales_we = targetmc.Clone(); TopScales_we.SetName("topwe0tag_weights_%s"%cid) + TopScales_we.Divide(controlmc_we); _fOut.WriteTObject(TopScales_we); + ####################################################################################################### + + _bins = [] # take bins from some histogram, can choose anything but this is easy + for b in range(targetmc.GetNbinsX()+1): + _bins.append(targetmc.GetBinLowEdge(b+1)) + + # Here is the important bit which "Builds" the control region, make a list of control regions which + # are constraining this process, each "Channel" is created with ... + # (name,_wspace,out_ws,cid+'_'+model,TRANSFERFACTORS) + # the second and third arguments can be left unchanged, the others instead must be set + # TRANSFERFACTORS are what is created above, eg TopScales + + CRs = [ + Channel("singlemuonw0tagModel", _wspace,out_ws,cid+'_'+model,TopScales_wm), + Channel("singleelectronw0tagModel", _wspace,out_ws,cid+'_'+model,TopScales_we), + ] + + + # ############################ USER DEFINED ########################################################### + # Add systematics in the following, for normalisations use name, relative size (0.01 --> 1%) + # for shapes use add_nuisance_shape with (name,_fOut) + # note, the code will LOOK for something called NOMINAL_name_Up and NOMINAL_name_Down, where NOMINAL=TopScales.GetName() + # these must be created and writted to the same dirctory as the nominal (fDir) + + def addStatErrs(hx,cr,crname1,crname2): + for b in range(1,targetmc.GetNbinsX()+1): + err = hx.GetBinError(b) + if not hx.GetBinContent(b)>0: + continue + relerr = err/hx.GetBinContent(b) + if relerr<0.01: + continue + byb_u = hx.Clone(); byb_u.SetName('%s_weights_%s_%s_stat_error_%s_bin%d_Up'%(crname1,cid,cid,crname2,b-1)) + byb_u.SetBinContent(b,hx.GetBinContent(b)+err) + byb_d = hx.Clone(); byb_d.SetName('%s_weights_%s_%s_stat_error_%s_bin%d_Down'%(crname1,cid,cid,crname2,b-1)) + if errlv in signal is dependant on the Z->vv and then the W->mv is depenant on W->lv, then + # give the arguments model,channel name from the config which defines the Z->vv => W->lv map! + # Return of course + return cat + diff --git a/Top_constraints_monojet_1tag.py b/Top_constraints_monojet_1tag.py new file mode 100644 index 0000000..4f2ae1c --- /dev/null +++ b/Top_constraints_monojet_1tag.py @@ -0,0 +1,125 @@ +import ROOT +from counting_experiment import * +# Define how a control region(s) transfer is made by defining cmodel provide, the calling pattern must be unchanged! +# First define simple string which will be used for the datacard + +model = "ttbar" + +### helper functions ### + +def makeTop(cid,_fOut,newName,targetmc,controlmc,systs=None): + TopScales = targetmc.Clone(); TopScales.SetName(newName+"_weights_%s"%cid) + TopScales.Divide(controlmc) + _fOut.WriteTObject(TopScales) + + if not(systs==None): + TopScalesUp = systs['targetmcbtagUp'].Clone(); + TopScalesUp.SetName(newName+"_weights_%s_btag_Up"%cid) + TopScalesUp.Divide(systs['controlmcbtagUp']) + + TopScalesDown = systs['targetmcbtagDown'].Clone(); + TopScalesDown.SetName(newName+"_weights_%s_Down"%cid) + TopScalesDown.Divide(systs['controlmcbtagDown']) + + _fOut.WriteTObject(TopScalesUp) + _fOut.WriteTObject(TopScalesDown) + + return TopScales + +def addTopErrors(TopScales,targetmc,newName,crName,_fOut,CRs,cid): + for b in range(1,targetmc.GetNbinsX()+1): + err = TopScales.GetBinError(b) + if not TopScales.GetBinContent(b)>0: + continue + relerr = err/TopScales.GetBinContent(b) + if relerr<0.01: + continue + byb_u = TopScales.Clone(); byb_u.SetName('%s_weights_%s_%s_stat_error_%s_bin%d_Up'%(newName,cid,cid,crName,b-1)) + byb_u.SetBinContent(b,TopScales.GetBinContent(b)+err) + byb_d = TopScales.Clone(); byb_d.SetName('%s_weights_%s_%s_stat_error_%s_bin%d_Down'%(newName,cid,cid,crName,b-1)) + if err 1%) + # for shapes use add_nuisance_shape with (name,_fOut) + # note, the code will LOOK for something called NOMINAL_name_Up and NOMINAL_name_Down, where NOMINAL=TopScales.GetName() + # these must be created and writted to the same dirctory as the nominal (fDir) + + addTopErrors(TopScales, targetmc1tag, "topwmn", "singlemuon1tagModel", _fOut, CRs[0],cid) + addTopErrors(TopScales_e, targetmc1tag, "topwen", "singleelectron1tagModel", _fOut, CRs[1],cid) + addTopErrors(TopScales_2tagTo1tag, targetmc1tag, "topwmn_2tagTo1tag", "singlemuon2tagTo1tagModel", _fOut, CRs[2],cid) + addTopErrors(TopScales_e_2tagTo1tag,targetmc1tag, "topwen_2tagTo1tag", "singleelectron2tagTo1tagModel", _fOut, CRs[3],cid) + + ####################################################################################################### + + cat = Category(model,cid,nam,_fin,_fOut,_wspace,out_ws,_bins,metname,targetmc1tag.GetName(),CRs,diag) + # cat.setDependant("ttbar","ttbarsignal") # Can use this to state that the "BASE" of this is already dependant on another process + # EG if the W->lv in signal is dependant on the Z->vv and then the W->mv is depenant on W->lv, then + # give the arguments model,channel name from the config which defines the Z->vv => W->lv map! + # Return of course + return cat From bed8f7e2e9ad7e99d01f9ba91b24099e2f6e3a4f Mon Sep 17 00:00:00 2001 From: Sonaina Undleeb Date: Thu, 4 Oct 2018 00:40:34 -0500 Subject: [PATCH 08/12] updated top constraints for monojet --- Top_constraints_monojet_2tag.py | 91 +++++++++++++++++++++++++++++++++ 1 file changed, 91 insertions(+) create mode 100644 Top_constraints_monojet_2tag.py diff --git a/Top_constraints_monojet_2tag.py b/Top_constraints_monojet_2tag.py new file mode 100644 index 0000000..70137c8 --- /dev/null +++ b/Top_constraints_monojet_2tag.py @@ -0,0 +1,91 @@ +import ROOT +from counting_experiment import * +# Define how a control region(s) transfer is made by defining cmodel provide, the calling pattern must be unchanged! +# First define simple string which will be used for the datacard +model = "ttbar" +convertHistograms = [] + +### helper functions ### + +def cmodel(cid,nam,_f,_fOut, out_ws, diag): + # Some setup + _fin = _f.Get("category_%s"%cid) + _wspace = _fin.Get("wspace_%s"%cid) + + # ############################ USER DEFINED ########################################################### + # First define the nominal transfer factors (histograms of signal/control, usually MC + # note there are many tools available inside include/diagonalize.h for you to make + # special datasets/histograms representing these and systematic effects + # but for now this is just kept simple + processName = "TTbar" # Give a name of the process being modelled + metname = "met" # Observable variable name + + targetmc = _fin.Get("signal2tag_ttbar") # define monimal (MC) of which process this config will model + controlmc_wm = _fin.Get("singlemuon2tag_ttbar") + controlmc_we = _fin.Get("singleelectron2tag_ttbar") + + + + # Create the transfer factors and save them (not here you can also create systematic variations of these + # transfer factors (named with extention _sysname_Up/Down + + TopScales_wm = targetmc.Clone(); TopScales_wm.SetName("topwm2tag_weights_%s"%cid) + TopScales_wm.Divide(controlmc_wm); _fOut.WriteTObject(TopScales_wm); + + TopScales_we = targetmc.Clone(); TopScales_we.SetName("topwe2tag_weights_%s"%cid) + TopScales_we.Divide(controlmc_we); _fOut.WriteTObject(TopScales_we); + ####################################################################################################### + + _bins = [] # take bins from some histogram, can choose anything but this is easy + for b in range(targetmc.GetNbinsX()+1): + _bins.append(targetmc.GetBinLowEdge(b+1)) + + # Here is the important bit which "Builds" the control region, make a list of control regions which + # are constraining this process, each "Channel" is created with ... + # (name,_wspace,out_ws,cid+'_'+model,TRANSFERFACTORS) + # the second and third arguments can be left unchanged, the others instead must be set + # TRANSFERFACTORS are what is created above, eg TopScales + + CRs = [ + Channel("singlemuonw2tagModel", _wspace,out_ws,cid+'_'+model,TopScales_wm), + Channel("singleelectronw2tagModel", _wspace,out_ws,cid+'_'+model,TopScales_we), + ] + + + # ############################ USER DEFINED ########################################################### + # Add systematics in the following, for normalisations use name, relative size (0.01 --> 1%) + # for shapes use add_nuisance_shape with (name,_fOut) + # note, the code will LOOK for something called NOMINAL_name_Up and NOMINAL_name_Down, where NOMINAL=TopScales.GetName() + # these must be created and writted to the same dirctory as the nominal (fDir) + + def addStatErrs(hx,cr,crname1,crname2): + for b in range(1,targetmc.GetNbinsX()+1): + err = hx.GetBinError(b) + if not hx.GetBinContent(b)>0: + continue + relerr = err/hx.GetBinContent(b) + if relerr<0.01: + continue + byb_u = hx.Clone(); byb_u.SetName('%s_weights_%s_%s_stat_error_%s_bin%d_Up'%(crname1,cid,cid,crname2,b-1)) + byb_u.SetBinContent(b,hx.GetBinContent(b)+err) + byb_d = hx.Clone(); byb_d.SetName('%s_weights_%s_%s_stat_error_%s_bin%d_Down'%(crname1,cid,cid,crname2,b-1)) + if errlv in signal is dependant on the Z->vv and then the W->mv is depenant on W->lv, then + # give the arguments model,channel name from the config which defines the Z->vv => W->lv map! + # Return of course + return cat + From 2e8666ab280bc7a525864c432057c6eda1114fca Mon Sep 17 00:00:00 2001 From: Sonaina Undleeb Date: Thu, 4 Oct 2018 00:47:21 -0500 Subject: [PATCH 09/12] removed Top_constraints_monojet_0tag --- Top_constraints_monojet_0tag.py | 91 --------------------------------- 1 file changed, 91 deletions(-) delete mode 100644 Top_constraints_monojet_0tag.py diff --git a/Top_constraints_monojet_0tag.py b/Top_constraints_monojet_0tag.py deleted file mode 100644 index 232f646..0000000 --- a/Top_constraints_monojet_0tag.py +++ /dev/null @@ -1,91 +0,0 @@ -import ROOT -from counting_experiment import * -# Define how a control region(s) transfer is made by defining cmodel provide, the calling pattern must be unchanged! -# First define simple string which will be used for the datacard -model = "ttbar" -convertHistograms = [] - -### helper functions ### - -def cmodel(cid,nam,_f,_fOut, out_ws, diag): - # Some setup - _fin = _f.Get("category_%s"%cid) - _wspace = _fin.Get("wspace_%s"%cid) - - # ############################ USER DEFINED ########################################################### - # First define the nominal transfer factors (histograms of signal/control, usually MC - # note there are many tools available inside include/diagonalize.h for you to make - # special datasets/histograms representing these and systematic effects - # but for now this is just kept simple - processName = "TTbar" # Give a name of the process being modelled - metname = "met" # Observable variable name - - targetmc = _fin.Get("signal0tag_ttbar") # define monimal (MC) of which process this config will model - controlmc_wm = _fin.Get("singlemuon0tag_ttbar") - controlmc_we = _fin.Get("singleelectron0tag_ttbar") - - - - # Create the transfer factors and save them (not here you can also create systematic variations of these - # transfer factors (named with extention _sysname_Up/Down - - TopScales_wm = targetmc.Clone(); TopScales_wm.SetName("topwm0tag_weights_%s"%cid) - TopScales_wm.Divide(controlmc_wm); _fOut.WriteTObject(TopScales_wm); - - TopScales_we = targetmc.Clone(); TopScales_we.SetName("topwe0tag_weights_%s"%cid) - TopScales_we.Divide(controlmc_we); _fOut.WriteTObject(TopScales_we); - ####################################################################################################### - - _bins = [] # take bins from some histogram, can choose anything but this is easy - for b in range(targetmc.GetNbinsX()+1): - _bins.append(targetmc.GetBinLowEdge(b+1)) - - # Here is the important bit which "Builds" the control region, make a list of control regions which - # are constraining this process, each "Channel" is created with ... - # (name,_wspace,out_ws,cid+'_'+model,TRANSFERFACTORS) - # the second and third arguments can be left unchanged, the others instead must be set - # TRANSFERFACTORS are what is created above, eg TopScales - - CRs = [ - Channel("singlemuonw0tagModel", _wspace,out_ws,cid+'_'+model,TopScales_wm), - Channel("singleelectronw0tagModel", _wspace,out_ws,cid+'_'+model,TopScales_we), - ] - - - # ############################ USER DEFINED ########################################################### - # Add systematics in the following, for normalisations use name, relative size (0.01 --> 1%) - # for shapes use add_nuisance_shape with (name,_fOut) - # note, the code will LOOK for something called NOMINAL_name_Up and NOMINAL_name_Down, where NOMINAL=TopScales.GetName() - # these must be created and writted to the same dirctory as the nominal (fDir) - - def addStatErrs(hx,cr,crname1,crname2): - for b in range(1,targetmc.GetNbinsX()+1): - err = hx.GetBinError(b) - if not hx.GetBinContent(b)>0: - continue - relerr = err/hx.GetBinContent(b) - if relerr<0.01: - continue - byb_u = hx.Clone(); byb_u.SetName('%s_weights_%s_%s_stat_error_%s_bin%d_Up'%(crname1,cid,cid,crname2,b-1)) - byb_u.SetBinContent(b,hx.GetBinContent(b)+err) - byb_d = hx.Clone(); byb_d.SetName('%s_weights_%s_%s_stat_error_%s_bin%d_Down'%(crname1,cid,cid,crname2,b-1)) - if errlv in signal is dependant on the Z->vv and then the W->mv is depenant on W->lv, then - # give the arguments model,channel name from the config which defines the Z->vv => W->lv map! - # Return of course - return cat - From 7c7d5eb275e1ba36ea3656c0d10372828b35a1cb Mon Sep 17 00:00:00 2001 From: Sonaina Undleeb Date: Sat, 6 Oct 2018 02:59:30 -0500 Subject: [PATCH 10/12] updated monojet config --- configs/monojet.py | 142 ++++++++++++++++++++++----------------------- 1 file changed, 70 insertions(+), 72 deletions(-) diff --git a/configs/monojet.py b/configs/monojet.py index 189765f..6e6b4d5 100644 --- a/configs/monojet.py +++ b/configs/monojet.py @@ -17,17 +17,81 @@ # Can define anything useful here outside the catefory dictionary which may be common to several categories, eg binning in MET, systematics ecc # systematics will expect samples with sample_sys_Up/Down but will skip if not found +signals = {} +with open('../../../CMSSW_8_0_29/src/PandaAnalysis/LPC_T3/merging/signals.txt', 'r') as signal_file: + for line in signal_file: + name = line.rstrip() + signals[name+'_signal'] = ['signal',name+'_signal',1,1] + +samples = { + # Signal Region +# "VH_signal" :['signal','vh',1,0] + "Zvv_signal" :['signal','zjets',1,0] + ,"Zll_signal" :['signal','zll',1,0] + ,"Wlv_signal" :['signal','wjets',1,0] + ,"Diboson_signal" :['signal','dibosons',1,0] + ,"ttbar_signal" :['signal','ttbar',1,0] + ,"ST_signal" :['signal','stop',1,0] + ,"QCD_signal" :['signal','qcd',1,0] + ,"Data_signal" :['signal','data',0,0] + + # Di muon-Control +# ,"VH_zmm" :['dimuon','vh',1,0] + ,"Zll_zmm" :['dimuon','zll',1,1] + ,"Diboson_zmm" :['dimuon','dibosons',1,0] + ,"ttbar_zmm" :['dimuon','ttbar',1,0] + ,"Data_zmm" :['dimuon','data',0,0] + + # Di electron-Control +# ,"VH_zee" :['dielectron','vh',1,0] + ,"Zll_zee" :['dielectron','zll',1,1] + ,"Diboson_zee" :['dielectron','dibosons',1,0] + ,"ttbar_zee" :['dielectron','ttbar',1,0] + ,"Data_zee" :['dielectron','data',0,0] + + # Single muon (w) control +# ,"VH_mn" :['singlemuon','vh',1,0] + ,"Zll_mn" :['singlemuon','zll',1,0] + ,"Wlv_mn" :['singlemuon','wjets',1,1] + ,"Diboson_mn" :['singlemuon','dibosons',1,0] + ,"ttbar_mn" :['singlemuon','ttbar',1,0] + ,"QCD_mn" :['singlemuon','qcd',1,0] + ,"Data_mn" :['singlemuon','data',0,0] + + # Single electron (w) control +# ,"VH_en" :['singleelectron','vh',1,0] + ,"Zll_en" :['singleelectron','zll',1,0] + ,"Wlv_en" :['singleelectron','wjets',1,1] + ,"Diboson_en" :['singleelectron','dibosons',1,0] + ,"ttbar_en" :['singleelectron','ttbar',1,1] + ,"ST_en" :['singleelectron','stop',1,0] + ,"QCD_en" :['singleelectron','qcd',1,0] + ,"Data_en" :['singleelectron','data',0,0] + + # Single photon control + ,"Pho_pho" :['singlephoton','gjets',1,1] + ,"QCD_pho" :['singlephoton','qcd',1,0] + ,"Data_pho" :['singlephoton','data',0,0] + } + +samples.update(signals) +samples_0tag = {} +samples_1tag = {} +samples_2tag = {} +for sample in samples: + samples_0tag[sample+'_0tag'] = samples[sample] + samples_1tag[sample+'_1tag'] = samples[sample] + samples_2tag[sample+'_2tag'] = samples[sample] +samples_dict = {'0tag':samples_0tag,'1tag':samples_1tag, '2tag':samples_2tag} + bins = [250.0, 280.0, 310.0, 340.0, 370.0, 400.0, 430.0, 470.0, 510.0, 550.0, 590.0, 640.0, 690.0, 740.0, 790.0, 840.0, 900.0, 960.0, 1020.0, 1090.0, 1160.0, 1250.0] systematics=["btag","mistag"] monojet_category = {} out_file_name = 'monojet.root' categories = [] - for s in ['0tag','1tag', '2tag']: monojet_category[s] = { 'name':"monojet_"+s - #,'in_file_name':"/uscms_data/d1/shoh/panda/v_8029_DarkHiggs_v2/flat/limits/fittingForest_monojet_"+s+".root" - # ,'in_file_name':"/uscms/home/naina25/nobackup/Panda_2018/Panda_Analysis/CMSSW_8_0_29/src/PandaAnalysis/SuperMonoJet/fitting/fittingForest_monojet_"+s+".root" ,'in_file_name':"/uscms/home/naina25/nobackup/Panda_2018/Panda_Analysis/CMSSW_8_0_29/src/PandaAnalysis/SuperMonoJet/fitting/monojet/fittingForest_"+s+".root" ,"cutstring":"" ,"varstring":["min(999.9999,met)",250,1250] @@ -35,73 +99,7 @@ ,"bins":bins[:] ,"additionalvars":[] ,"pdfmodel":0 - ,"samples": - { - # Signal Region -# "VH_signal_"+s :['signal'+s,'vh',1,0] - "Zvv_signal_"+s :['signal'+s,'zjets',1,0] - ,"Zll_signal_"+s :['signal'+s,'zll',1,0] - ,"Wlv_signal_"+s :['signal'+s,'wjets',1,0] - ,"Diboson_signal_"+s :['signal'+s,'dibosons',1,0] - ,"ttbar_signal_"+s :['signal'+s,'ttbar',1,0] - ,"ST_signal_"+s :['signal'+s,'stop',1,0] - ,"QCD_signal_"+s :['signal'+s,'qcd',1,0] - ,"Data_signal_"+s :['signal'+s,'data',0,0] - # signals - ,"hsDM_1000_50_100_signal_"+s :['signal'+s,'hsDM-1000-50-100_signal',1,1] - ,"hsDM_1000_50_200_signal_"+s :['signal'+s,'hsDM-1000-50-200_signal',1,1] - ,"hsDM_1000_50_250_signal_"+s :['signal'+s,'hsDM-1000-50-250_signal',1,1] - ,"ZpDM_1000_150_10_signal_"+s :['signal'+s,'ZpDM-1000-150-10_signal',1,1] - ,"ZpDM_1000_50_10_signal_"+s :['signal'+s,'ZpDM-1000-50-10_signal',1,1] - ,"ZpDM_100_150_10_signal_"+s :['signal'+s,'ZpDM-100-150-10_signal',1,1] - ,"ZpDM_100_50_10_signal_"+s :['signal'+s,'ZpDM-100-50-10_signal',1,1] - ,"ZpDM_1500_150_10_signal_"+s :['signal'+s,'ZpDM-1500-150-10_signal',1,1] - ,"ZpDM_1500_50_10_signal_"+s :['signal'+s,'ZpDM-1500-50-10_signal',1,1] - ,"ZpDM_2000_150_10_signal_"+s :['signal'+s,'ZpDM-2000-150-10_signal',1,1] - ,"ZpDM_2000_50_10_signal_"+s :['signal'+s,'ZpDM-2000-50-10_signal',1,1] - ,"ZpDM_2500_150_10_signal_"+s :['signal'+s,'ZpDM-2500-150-10_signal',1,1] - ,"ZpDM_3000_150_10_signal_"+s :['signal'+s,'ZpDM-3000-150-10_signal',1,1] - ,"ZpDM_3000_50_10_signal_"+s :['signal'+s,'ZpDM-3000-50-10_signal',1,1] - ,"ZpDM_300_150_10_signal_"+s :['signal'+s,'ZpDM-300-150-10_signal',1,1] - - # Di muon-Control -# ,"VH_zmm_"+s :['dimuon'+s,'vh',1,0] - ,"Zll_zmm_"+s :['dimuon'+s,'zll',1,1] - ,"Diboson_zmm_"+s :['dimuon'+s,'dibosons',1,0] - ,"ttbar_zmm_"+s :['dimuon'+s,'ttbar',1,0] - ,"Data_zmm_"+s :['dimuon'+s,'data',0,0] - - # Di electron-Control -# ,"VH_zee_"+s :['dielectron'+s,'vh',1,0] - ,"Zll_zee_"+s :['dielectron'+s,'zll',1,1] - ,"Diboson_zee_"+s :['dielectron'+s,'dibosons',1,0] - ,"ttbar_zee_"+s :['dielectron'+s,'ttbar',1,0] - ,"Data_zee_"+s :['dielectron'+s,'data',0,0] - - # Single muon (w) control -# ,"VH_mn" :['singlemuon'+s,'vh',1,0] - ,"Zll_wmn_"+s :['singlemuon'+s,'zll',1,0] - ,"Wlv_wmn_"+s :['singlemuon'+s,'wjets',1,1] - ,"Diboson_wmn_"+s :['singlemuon'+s,'dibosons',1,0] - ,"ttbar_wmn_"+s :['singlemuon'+s,'ttbar',1,0] - ,"QCD_wmn_"+s :['singlemuon'+s,'qcd',1,0] - ,"Data_wmn_"+s :['singlemuon'+s,'data',0,0] - - # Single electron (w) control -# ,"VH_en" :['singleelectron'+s,'vh',1,0] - ,"Zll_wen_"+s :['singleelectron'+s,'zll',1,0] - ,"Wlv_wen_"+s :['singleelectron'+s,'wjets',1,1] - ,"Diboson_wen_"+s :['singleelectron'+s,'dibosons',1,0] - ,"ttbar_wen_"+s :['singleelectron'+s,'ttbar',1,1] - ,"ST_wen_"+s :['singleelectron'+s,'stop',1,0] - ,"QCD_wen_"+s :['singleelectron'+s,'qcd',1,0] - ,"Data_wen_"+s :['singleelectron'+s,'data',0,0] - - # Single photon control - ,"Pho_pho_"+s :['singlephoton'+s,'gjets',1,1] - ,"QCD_pho_"+s :['singlephoton'+s,'qcd',1,0] - ,"Data_pho_"+s :['singlephoton'+s,'data',0,0] - } - + ,"samples":samples_dict[s] } - categories.append(monojet_category[s]) + + categories.append(monojet_category[s]) From 474c00561efe628f752abd56b25584331d9e69b6 Mon Sep 17 00:00:00 2001 From: Sonaina Undleeb Date: Mon, 5 Nov 2018 18:05:03 -0600 Subject: [PATCH 11/12] fixing monojet config with cutstring=1 --- configs/monojet.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/configs/monojet.py b/configs/monojet.py index 6e6b4d5..c21f514 100644 --- a/configs/monojet.py +++ b/configs/monojet.py @@ -18,7 +18,7 @@ # systematics will expect samples with sample_sys_Up/Down but will skip if not found signals = {} -with open('../../../CMSSW_8_0_29/src/PandaAnalysis/LPC_T3/merging/signals.txt', 'r') as signal_file: +with open('../../../../Panda_Analysis/CMSSW_8_0_29/src/PandaAnalysis/LPC_T3/merging/signals.txt', 'r') as signal_file: for line in signal_file: name = line.rstrip() signals[name+'_signal'] = ['signal',name+'_signal',1,1] @@ -92,8 +92,8 @@ for s in ['0tag','1tag', '2tag']: monojet_category[s] = { 'name':"monojet_"+s - ,'in_file_name':"/uscms/home/naina25/nobackup/Panda_2018/Panda_Analysis/CMSSW_8_0_29/src/PandaAnalysis/SuperMonoJet/fitting/monojet/fittingForest_"+s+".root" - ,"cutstring":"" + ,'in_file_name':"/uscms_data/d3/naina25/panda/limits/fittingForest_"+s+".root" + ,"cutstring":"1" ,"varstring":["min(999.9999,met)",250,1250] ,"weightname":"weight" ,"bins":bins[:] @@ -102,4 +102,4 @@ ,"samples":samples_dict[s] } - categories.append(monojet_category[s]) + categories.append(monojet_category[s]) From 023be9283dc0091baa8cd9e847ebddf3da9c6790 Mon Sep 17 00:00:00 2001 From: Sonaina Undleeb Date: Tue, 4 Dec 2018 14:42:35 -0600 Subject: [PATCH 12/12] monojet config and runModel added --- configs/monojet.py | 8 ++------ runModel_monojet.py | 7 +++++-- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/configs/monojet.py b/configs/monojet.py index c21f514..5d9552f 100644 --- a/configs/monojet.py +++ b/configs/monojet.py @@ -76,20 +76,16 @@ samples.update(signals) samples_0tag = {} -samples_1tag = {} -samples_2tag = {} for sample in samples: samples_0tag[sample+'_0tag'] = samples[sample] - samples_1tag[sample+'_1tag'] = samples[sample] - samples_2tag[sample+'_2tag'] = samples[sample] -samples_dict = {'0tag':samples_0tag,'1tag':samples_1tag, '2tag':samples_2tag} +samples_dict = {'0tag':samples_0tag} bins = [250.0, 280.0, 310.0, 340.0, 370.0, 400.0, 430.0, 470.0, 510.0, 550.0, 590.0, 640.0, 690.0, 740.0, 790.0, 840.0, 900.0, 960.0, 1020.0, 1090.0, 1160.0, 1250.0] systematics=["btag","mistag"] monojet_category = {} out_file_name = 'monojet.root' categories = [] -for s in ['0tag','1tag', '2tag']: +for s in ['0tag']: monojet_category[s] = { 'name':"monojet_"+s ,'in_file_name':"/uscms_data/d3/naina25/panda/limits/fittingForest_"+s+".root" diff --git a/runModel_monojet.py b/runModel_monojet.py index db79b11..9ddf11a 100644 --- a/runModel_monojet.py +++ b/runModel_monojet.py @@ -3,9 +3,12 @@ fOutName = "combined_model_monojet.root" # --> Output file fName = "monojet.root" # --> input file (i.e output from previous) #fName = "mono-x-smoothed.root" # --> input file (i.e output from previous) -categories = ["monojet_tag0","monojet_tag1","monojet_tag2"] +#categories = ["monojet_0tag","monojet_1tag","monojet_2tag"] +#categories = ["monojet_0tag","monojet_1tag"] +categories = ["monojet_0tag"] #categories = ["monox_mass0","monox_mass0_fail","monox_mass1","monox_mass1_fail","monox_mass2","monox_mass2_fail","monox_mass3","monox_mass3_fail"] # --> Should be labeled as in original config -controlregions_def = ["Z_constraints_monojet","W_constraints_monojet","Top_constraints_monojet"] # --> configuration configs for control region fits. +#controlregions_def = ["Z_constraints_monojet","W_constraints_monojet_0tag","Top_constraints_monojet_0tag"] # --> configuration configs for control region fits. +controlregions_def = ["Z_constraints_monojet","W_constraints_monojet_0tag"] # --> configuration configs for control region fits. # Note if one conrol region def depends on another (i,e if setDependant() is called) it must come AFTER its # the one it depends on in this list! #--------------------------------------------------------------------------------------//