Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ cd datacards/
text2workspace.py combined_2cat.txt --channel-masks
combine combined_2cat.root -M MaxLikelihoodFit --saveShapes --saveWithUncertainties --setPhysicsModelParameters mask_tight_sig=1,mask_loose_sig=1
```
Temporary fixes needed for running the fits:
```bash
There is a placeholder (XX-SIGNAL-XX) for the signal point in the datacards. While running the fits, please replace this the correct name of the signal point you want to look at. Its already fixed in the script when you run the limit scan (below).
```

## Running the limit scan

Expand Down
52 changes: 52 additions & 0 deletions Top_constraints.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,58 @@ def cmodel(cid,nam,_f,_fOut, out_ws, diag):
TopScales_w = makeTop(cid,_fOut,"topwmn",targetmc,controlmc_w,None,False)
TopScales_w_e = makeTop(cid,_fOut,"topwen",targetmc,controlmc_w_e,None,False)

### met trig ###
ftrig = r.TFile.Open('files/unc/fixtrig_monoh.root')
h_trig_down = ftrig.Get('trig_sys_down')
h_trig_up = ftrig.Get('trig_sys_up')

ttbar_ratio_trig_up = targetmc.Clone(); ttbar_ratio_trig_up.SetName('w_weights_%s_mettrig_Up'%cid)
for b in range(ttbar_ratio_trig_up.GetNbinsX()): ttbar_ratio_trig_up.SetBinContent(b+1,0)
diag.generateWeightedTemplate(ttbar_ratio_trig_up,h_trig_up,metname,metname,_wspace.data("signal_ttbar"))
ttbar_ratio_trig_up.Divide(controlmc)
_fOut.WriteTObject(ttbar_ratio_trig_up)

ttbar_ratio_trig_down = targetmc.Clone(); ttbar_ratio_trig_down.SetName('w_weights_%s_mettrig_Down'%cid)
for b in range(ttbar_ratio_trig_down.GetNbinsX()): ttbar_ratio_trig_down.SetBinContent(b+1,0)
diag.generateWeightedTemplate(ttbar_ratio_trig_down,h_trig_down,metname,metname,_wspace.data("signal_ttbar"))
ttbar_ratio_trig_down.Divide(controlmc)
_fOut.WriteTObject(ttbar_ratio_trig_down)

ttbar_e_ratio_trig_up = targetmc.Clone(); ttbar_e_ratio_trig_up.SetName('w_e_weights_%s_mettrig_Up'%cid)
for b in range(ttbar_e_ratio_trig_up.GetNbinsX()): ttbar_e_ratio_trig_up.SetBinContent(b+1,0)
diag.generateWeightedTemplate(ttbar_e_ratio_trig_up,h_trig_up,metname,metname,_wspace.data("signal_ttbar"))
ttbar_e_ratio_trig_up.Divide(controlmc_e)
_fOut.WriteTObject(ttbar_e_ratio_trig_up)

ttbar_e_ratio_trig_down = targetmc.Clone(); ttbar_e_ratio_trig_down.SetName('w_e_weights_%s_mettrig_Down'%cid)
for b in range(ttbar_e_ratio_trig_down.GetNbinsX()): ttbar_e_ratio_trig_down.SetBinContent(b+1,0)
diag.generateWeightedTemplate(ttbar_e_ratio_trig_down,h_trig_down,metname,metname,_wspace.data("signal_ttbar"))
ttbar_e_ratio_trig_down.Divide(controlmc_e)
_fOut.WriteTObject(ttbar_e_ratio_trig_down)

ttbar_w_ratio_trig_up = targetmc.Clone(); ttbar_w_ratio_trig_up.SetName('w_weights_%s_mettrig_Up'%cid)
for b in range(ttbar_w_ratio_trig_up.GetNbinsX()): ttbar_w_ratio_trig_up.SetBinContent(b+1,0)
diag.generateWeightedTemplate(ttbar_w_ratio_trig_up,h_trig_up,metname,metname,_wspace.data("signal_ttbar"))
ttbar_w_ratio_trig_up.Divide(controlmc)
_fOut.WriteTObject(ttbar_w_ratio_trig_up)

ttbar_w_ratio_trig_down = targetmc.Clone(); ttbar_w_ratio_trig_down.SetName('w_weights_%s_mettrig_Down'%cid)
for b in range(ttbar_w_ratio_trig_down.GetNbinsX()): ttbar_w_ratio_trig_down.SetBinContent(b+1,0)
diag.generateWeightedTemplate(ttbar_w_ratio_trig_down,h_trig_down,metname,metname,_wspace.data("signal_ttbar"))
ttbar_w_ratio_trig_down.Divide(controlmc)
_fOut.WriteTObject(ttbar_w_ratio_trig_down)

ttbar_w_e_ratio_trig_up = targetmc.Clone(); ttbar_w_e_ratio_trig_up.SetName('w_ttbar_e_weights_%s_mettrig_Up'%cid)
for b in range(ttbar_w_e_ratio_trig_up.GetNbinsX()): ttbar_w_e_ratio_trig_up.SetBinContent(b+1,0)
diag.generateWeightedTemplate(ttbar_w_e_ratio_trig_up,h_trig_up,metname,metname,_wspace.data("signal_ttbar"))
ttbar_w_e_ratio_trig_up.Divide(controlmc_e)
_fOut.WriteTObject(ttbar_w_e_ratio_trig_up)

ttbar_w_e_ratio_trig_down = targetmc.Clone(); ttbar_w_e_ratio_trig_down.SetName('w_ttbar_e_weights_%s_mettrig_Down'%cid)
for b in range(ttbar_w_e_ratio_trig_down.GetNbinsX()): ttbar_w_e_ratio_trig_down.SetBinContent(b+1,0)
diag.generateWeightedTemplate(ttbar_w_e_ratio_trig_down,h_trig_down,metname,metname,_wspace.data("signal_ttbar"))
ttbar_w_e_ratio_trig_down.Divide(controlmc_e)
_fOut.WriteTObject(ttbar_w_e_ratio_trig_down)

#######################################################################################################

Expand Down
53 changes: 53 additions & 0 deletions W_constraints.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,59 @@ def cmodel(cid,nam,_f,_fOut, out_ws, diag):
WScales_ttbar_e = targetmc.Clone(); WScales_ttbar_e.SetName("wtopen_weights_%s"%cid)
WScales_ttbar_e.Divide(controlmc_ttbar_e); _fOut.WriteTObject(WScales_ttbar_e);

### met trig ###
ftrig = r.TFile.Open('files/unc/fixtrig_monoh.root')
h_trig_down = ftrig.Get('trig_sys_down')
h_trig_up = ftrig.Get('trig_sys_up')

w_ratio_trig_up = targetmc.Clone(); w_ratio_trig_up.SetName('w_weights_%s_mettrig_Up'%cid)
for b in range(w_ratio_trig_up.GetNbinsX()): w_ratio_trig_up.SetBinContent(b+1,0)
diag.generateWeightedTemplate(w_ratio_trig_up,h_trig_up,metname,metname,_wspace.data("signal_wjets"))
w_ratio_trig_up.Divide(controlmc)
_fOut.WriteTObject(w_ratio_trig_up)

w_ratio_trig_down = targetmc.Clone(); w_ratio_trig_down.SetName('w_weights_%s_mettrig_Down'%cid)
for b in range(w_ratio_trig_down.GetNbinsX()): w_ratio_trig_down.SetBinContent(b+1,0)
diag.generateWeightedTemplate(w_ratio_trig_down,h_trig_down,metname,metname,_wspace.data("signal_wjets"))
w_ratio_trig_down.Divide(controlmc)
_fOut.WriteTObject(w_ratio_trig_down)

w_e_ratio_trig_up = targetmc.Clone(); w_e_ratio_trig_up.SetName('w_e_weights_%s_mettrig_Up'%cid)
for b in range(w_e_ratio_trig_up.GetNbinsX()): w_e_ratio_trig_up.SetBinContent(b+1,0)
diag.generateWeightedTemplate(w_e_ratio_trig_up,h_trig_up,metname,metname,_wspace.data("signal_wjets"))
w_e_ratio_trig_up.Divide(controlmc_e)
_fOut.WriteTObject(w_e_ratio_trig_up)

w_e_ratio_trig_down = targetmc.Clone(); w_e_ratio_trig_down.SetName('w_e_weights_%s_mettrig_Down'%cid)
for b in range(w_e_ratio_trig_down.GetNbinsX()): w_e_ratio_trig_down.SetBinContent(b+1,0)
diag.generateWeightedTemplate(w_e_ratio_trig_down,h_trig_down,metname,metname,_wspace.data("signal_wjets"))
w_e_ratio_trig_down.Divide(controlmc_e)
_fOut.WriteTObject(w_e_ratio_trig_down)

w_ttbar_ratio_trig_up = targetmc.Clone(); w_ttbar_ratio_trig_up.SetName('w_weights_%s_mettrig_Up'%cid)
for b in range(w_ttbar_ratio_trig_up.GetNbinsX()): w_ttbar_ratio_trig_up.SetBinContent(b+1,0)
diag.generateWeightedTemplate(w_ttbar_ratio_trig_up,h_trig_up,metname,metname,_wspace.data("signal_wjets"))
w_ttbar_ratio_trig_up.Divide(controlmc)
_fOut.WriteTObject(w_ttbar_ratio_trig_up)

w_ttbar_ratio_trig_down = targetmc.Clone(); w_ttbar_ratio_trig_down.SetName('w_weights_%s_mettrig_Down'%cid)
for b in range(w_ttbar_ratio_trig_down.GetNbinsX()): w_ttbar_ratio_trig_down.SetBinContent(b+1,0)
diag.generateWeightedTemplate(w_ttbar_ratio_trig_down,h_trig_down,metname,metname,_wspace.data("signal_wjets"))
w_ttbar_ratio_trig_down.Divide(controlmc)
_fOut.WriteTObject(w_ttbar_ratio_trig_down)

w_ttbar_e_ratio_trig_up = targetmc.Clone(); w_ttbar_e_ratio_trig_up.SetName('w_ttbar_e_weights_%s_mettrig_Up'%cid)
for b in range(w_ttbar_e_ratio_trig_up.GetNbinsX()): w_ttbar_e_ratio_trig_up.SetBinContent(b+1,0)
diag.generateWeightedTemplate(w_ttbar_e_ratio_trig_up,h_trig_up,metname,metname,_wspace.data("signal_wjets"))
w_ttbar_e_ratio_trig_up.Divide(controlmc_e)
_fOut.WriteTObject(w_ttbar_e_ratio_trig_up)

w_ttbar_e_ratio_trig_down = targetmc.Clone(); w_ttbar_e_ratio_trig_down.SetName('w_ttbar_e_weights_%s_mettrig_Down'%cid)
for b in range(w_ttbar_e_ratio_trig_down.GetNbinsX()): w_ttbar_e_ratio_trig_down.SetBinContent(b+1,0)
diag.generateWeightedTemplate(w_ttbar_e_ratio_trig_down,h_trig_down,metname,metname,_wspace.data("signal_wjets"))
w_ttbar_e_ratio_trig_down.Divide(controlmc_e)
_fOut.WriteTObject(w_ttbar_e_ratio_trig_down)

#######################################################################################################

_bins = [] # take bins from some histogram, can choose anything but this is easy
Expand Down
10 changes: 5 additions & 5 deletions Z_constraints.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def cmodel(cid,nam,_f,_fOut, out_ws, diag):
controlmc = _fin.Get("dimuon_zll") # defines Zmm MC of which process will be controlled by
controlmc_e = _fin.Get("dielectron_zll") # defines Zmm MC of which process will be controlled by
controlmc_w = _fin.Get("signal_wjets")
controlmc_photon = _fin.Get("singlephoton_gjets") # defines Gjets MC of which process will be controlled by
controlmc_photon = _fin.Get("photon_gjets") # defines Gjets MC of which process will be controlled by

# 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
Expand Down Expand Up @@ -162,7 +162,7 @@ def my_function(_wspace,_fin,_fOut,nam,diag):
_gjet_mcname = "photon_gjets"
GJet = _fin.Get("photon_gjets")

fztoa = r.TFile.Open("files/new/atoz_unc.root")
fztoa = r.TFile.Open("files/newKfactors/atoz_unc.root")

ztoa_renscale_up = fztoa.Get("znlo1_over_anlo1_renScaleUp")
ztoa_renscale_down = fztoa.Get("znlo1_over_anlo1_renScaleDown")
Expand Down Expand Up @@ -229,7 +229,7 @@ def my_function(_wspace,_fin,_fOut,nam,diag):


# fztoaewk = fztoa
fztoaewk = r.TFile.Open('files/new/atoz_unc.root')
fztoaewk = r.TFile.Open('files/newKfactors/atoz_unc.root')
ztoa_ewk_up = fztoaewk.Get("a_ewkcorr_overz_Upcommon")
ztoa_ewk_down = fztoaewk.Get("a_ewkcorr_overz_Downcommon")

Expand Down Expand Up @@ -264,7 +264,7 @@ def my_function(_wspace,_fin,_fOut,nam,diag):
### Now lets do the same thing for W

#fztow = r.TFile.Open("files/wtoz_unc.root")
fztow = r.TFile.Open("files/new/wtoz_unc.root")
fztow = r.TFile.Open("files/newKfactors/wtoz_unc.root")

ztow_renscale_up = fztow.Get("znlo1_over_wnlo1_renScaleUp")
ztow_renscale_down = fztow.Get("znlo1_over_wnlo1_renScaleDown")
Expand Down Expand Up @@ -323,7 +323,7 @@ def my_function(_wspace,_fin,_fOut,nam,diag):
_fOut.WriteTObject(wratio_pdf_down)

#fztowewk = r.TFile.Open("files/wtoz_ewkunc.root")
fztowewk = r.TFile.Open("files/new/wtoz_unc.root")
fztowewk = r.TFile.Open("files/newKfactors/wtoz_unc.root")
ztow_ewk_up = fztowewk.Get("w_ewkcorr_overz_Upcommon")
ztow_ewk_down = fztowewk.Get("w_ewkcorr_overz_Downcommon")

Expand Down
6 changes: 6 additions & 0 deletions configs/boosted.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
out_file_name = 'boosted.root'

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()
Expand Down Expand Up @@ -103,6 +104,11 @@
,"ST_wen" :['singleelectronw','stop',1,0]
,"QCD_wen" :['singleelectronw','qcd',1,0]
,"Data_wen" :['singleelectronw','data',0,0]

# Photon control
,"Pho_pho" :['photon','gjets',1,0]
,"QCD_pho" :['photon','qcd',1,0]
,"Data_pho" :['photon','data',0,0]
}

samples.update(signals)
Expand Down
13 changes: 10 additions & 3 deletions configs/resolved.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@
# 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('../../../CMSSW_8_0_29/src/PandaAnalysis/LPC_T3/merging/signals.txt', 'r') as signal_file:
with open('/uscms/home/ahall/nobackup/LPC-DM/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]
Expand Down Expand Up @@ -94,7 +95,12 @@
,"ST_wen" :['singleelectronw','stop',1,0]
,"QCD_wen" :['singleelectronw','qcd',1,0]
,"Data_wen" :['singleelectronw','data',0,0]
}

# Photon control
,"Pho_pho" :['photon','gjets',1,0]
,"QCD_pho" :['photon','qcd',1,0]
,"Data_pho" :['photon','data',0,0]
}
samples.update(signals)
samples_fail = {}
for sample in samples:
Expand All @@ -111,7 +117,8 @@
for s in ['pass','fail']:
resolved_category[s+str(mass)] = {
'name':"resolved_"+s+"_mass"+str(mass)
,'in_file_name':"/uscms_data/d3/matteoc/analysis/CMSSW_8_0_29/src/PandaAnalysis/SuperMonoJet/fitting/resolved/fittingForest_resolved_"+s+".root"
# ,'in_file_name':"/uscms_data/d3/matteoc/analysis/CMSSW_8_0_29/src/PandaAnalysis/SuperMonoJet/fitting/resolved/fittingForest_resolved_"+s+".root"
,'in_file_name':"/uscms/home/ahall/nobackup/LPC-DM/CMSSW_8_0_29/src/PandaAnalysis/SuperMonoJet/fitting/resolved/fittingForest_resolved_"+s+".root"
,"cutstring":cutstrings[mass]
,"varstring":["min(999.9999,met)",250,3000]
,"weightname":"weight"
Expand Down
38 changes: 38 additions & 0 deletions datacards/boosted_datacards/mass0/boosted_photon_control.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
Control Region Datacard -- boosted_doublebp_mass0_photon_control.txt

imax * number of bins
jmax * number of processes minus 1
kmax * number of nuisance parameters

-------------------------------------------------------------------------------------------------
shapes * pho ../../combined_model_boosted.root combinedws:boosted_doublebp_mass0_photon_$PROCESS combinedws:boosted_doublebp_mass0_photon_$PROCESS_$SYSTEMATIC
shapes data_obs pho ../../../combined_model_boosted.root combinedws:boosted_doublebp_mass0_photon_data
shapes gjets pho ../../../combined_model_boosted.root combinedws:boosted_doublebp_mass0_photonModel_zjets_model
-------------------------------------------------------------------------------------------------
bin pho
observation -1
--------------------------------------------------------------------------------------------------------------------------------------------------
bin pho pho
process gjets qcd
process 6 7
rate 1 -1
------------------------------------------
lumi lnN 1.023 1.023
btag shape - 1.0
ca15_jec lnN - 1.04
mistag shape - 1.0
veto_tau lnN 1.03 1.03
met lnN 1.05 1.05
pho_trig lnN 1.01 1.01
---------------------------------------------------------------
# Parametric uncertainties associated to control regions fits
boosted_doublebp_mass0_stat_error_photonModelCR_bin0 param 0.0 1
boosted_doublebp_mass0_stat_error_photonModelCR_bin1 param 0.0 1
boosted_doublebp_mass0_stat_error_photonModelCR_bin2 param 0.0 1
boosted_doublebp_mass0_stat_error_photonModelCR_bin3 param 0.0 1
gjetseff param 0.0346 0.00174
phoeffSF extArg 1.0 [0.0,10.0]
gjetspassphoton rateParam pho gjets (@0*1.0) phoeffSF
#mettrig param 0.0 1
btag param 0.0 1
mistag param 0.0 1
38 changes: 38 additions & 0 deletions datacards/boosted_datacards/mass0/boosted_photon_fail_control.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
Control Region Datacard -- boosted_doublebp_mass0_photon_fail_control.txt

imax * number of bins
jmax * number of processes minus 1
kmax * number of nuisance parameters

-------------------------------------------------------------------------------------------------
shapes * pho_fail ../../combined_model_boosted.root combinedws:boosted_doublebf_mass0_photon_$PROCESS combinedws:boosted_doublebf_mass0_photon_$PROCESS_$SYSTEMATIC
shapes data_obs pho_fail ../../../combined_model_boosted.root combinedws:boosted_doublebf_mass0_photon_data
shapes gjets pho_fail ../../../combined_model_boosted.root combinedws:boosted_doublebf_mass0_photonModel_zjets_model
-------------------------------------------------------------------------------------------------
bin pho_fail
observation -1
--------------------------------------------------------------------------------------------------------------------------------------------------
bin pho_fail pho_fail
process gjets qcd
process 6 7
rate 1 -1
------------------------------------------
lumi lnN 1.023 1.023
btag shape - 1.0
ak4_jec lnN - 1.04
mistag shape - 1.0
veto_tau lnN 1.03 1.03
met lnN 1.05 1.05
pho_trig lnN 1.01 1.01
---------------------------------------------------------------
# Parametric uncertainties associated to control regions fits
boosted_doublebp_mass0_stat_error_photonfailModelCR_bin0 param 0.0 1
boosted_doublebp_mass0_stat_error_photonfailModelCR_bin1 param 0.0 1
boosted_doublebp_mass0_stat_error_photonfailModelCR_bin2 param 0.0 1
boosted_doublebp_mass0_stat_error_photonfailModelCR_bin3 param 0.0 1
gjetseff param 0.0346 0.00174
phoeffSF extArg 1.0 [0.0,10.0]
gjetsfailphoton rateParam pho_fail gjets ((1.0-@0*@1)/(1.0-@1)) phoeffSF,gjetseff
#mettrig param 0.0 1
btag param 0.0 1
mistag param 0.0 1
38 changes: 38 additions & 0 deletions datacards/boosted_datacards/mass1/boosted_photon_control.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
Control Region Datacard -- boosted_doublebp_mass1_photon_control.txt

imax * number of bins
jmax * number of processes minus 1
kmax * number of nuisance parameters

-------------------------------------------------------------------------------------------------
shapes * pho ../../combined_model_boosted.root combinedws:boosted_doublebp_mass1_photon_$PROCESS combinedws:boosted_doublebp_mass1_photon_$PROCESS_$SYSTEMATIC
shapes data_obs pho ../../../combined_model_boosted.root combinedws:boosted_doublebp_mass1_photon_data
shapes gjets pho ../../../combined_model_boosted.root combinedws:boosted_doublebp_mass1_photonModel_zjets_model
-------------------------------------------------------------------------------------------------
bin pho
observation -1
--------------------------------------------------------------------------------------------------------------------------------------------------
bin pho pho
process gjets qcd
process 6 7
rate 1 -1
------------------------------------------
lumi lnN 1.023 1.023
btag shape - 1.0
ca15_jec lnN - 1.04
mistag shape - 1.0
veto_tau lnN 1.03 1.03
met lnN 1.05 1.05
pho_trig lnN 1.01 1.01
---------------------------------------------------------------
# Parametric uncertainties associated to control regions fits
boosted_doublebp_mass1_stat_error_photonModelCR_bin0 param 0.0 1
boosted_doublebp_mass1_stat_error_photonModelCR_bin1 param 0.0 1
boosted_doublebp_mass1_stat_error_photonModelCR_bin2 param 0.0 1
boosted_doublebp_mass1_stat_error_photonModelCR_bin3 param 0.0 1
gjetseff param 0.0346 0.00174
phoeffSF extArg 1.0 [0.0,10.0]
gjetspassphoton rateParam pho gjets (@0*1.0) phoeffSF
#mettrig param 0.0 1
btag param 0.0 1
mistag param 0.0 1
Loading