How to use bg method in fMBT

Best Python code snippet using fMBT_python

WprimeHistosForLimits_wScale.py

Source:WprimeHistosForLimits_wScale.py Github

copy

Full Screen

1import ROOT, sys, os, re, string2from ROOT import *3from array import array4import copy5import math6import os.path7indir = "Run2016BCD_Jul27_Slim/"8os.system('mkdir -p '+indir+'RootFiles_For2DLimits_scale')9lumi = 232.55810REBIN = 111######################################################12RootFiles = {}13Histos = {}14HistosPre = {}15SystScale = {}16SampScale = {}17FullSyst = ['_','_jsp_','_jsm_','_jrp_','_jrm_','_btp_','_btm_','_pup_','_pum_','_tpp_','_tpm_','_wjp_','_wjm_','_mup_','_mum_','_tqp_','_tqm_','_mtp_','_mtm_','_msp_','_msm_','_mrp_','_mrm_']18#SystScaling = [1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.]19SystScaling = [0.0656,0.0656,0.0656,0.0656,0.0656,0.0656,0.0656,0.0656,0.5,0.5,0.5,0.5,0.5,0.5,0.5,0.5,0.0656,0.0656,1.,1.,1.,1.]20for i in range(len(SystScaling)):21 SystScale[FullSyst[i+1][1:-1]] = SystScaling[i]22Backgrounds = ['WJets_HT100to200','WJets_HT200to400','WJets_HT400to600','WJets_HT600to800','WJets_HT800to1200','WJets_HT1200to2500','WJets_HT2500toInf','TTbar','ZJets','T_t','Tbar_t','T_tW','Tbar_tW','T_s','WW','WZ','ZZ']23BackScaling = [1.082,1.082,1.082,1.082,1.082,1.082,1.082,1.183,1.085,1.138,1.152,1.177,1.177,1.044,1.110,1.115,1.114]24for i in range(len(BackScaling)):25 SampScale[Backgrounds[i]] = BackScaling[i]26#Backgrounds = ['WJets','TTbar']27masses = ['1000','1100','1200','1300','1400','1500','1600','1700','1800','1900','2000','2100','2200','2300','2400','2500','2600','2700','2800','2900','3000','3100','3200','3300','3400','3500','3600','3700','3800','3900','4000']28SigScaling = [1.157,1.167,1.172,1.183,1.193,1.203,1.212,1.222,1.232,1.242,1.255,1.268,1.276,1.290,1.299,1.312,1.323,1.339,1.352,1.360,1.377,1.390,1.399,1.414,1.426,1.435,1.447,1.457,1.464,1.470,1.477]29for i in range(len(SigScaling)):30 #SampScale['Wprime'+masses[i]+'Right'] = SigScaling[i]31 SampScale['Wprime'+masses[i]+'Right'] = 1.32Channels = ['El','Mu']33BTags = ['GE1BTags','Ex1BTags','Ex2BTags']34Systematics = ['_','_jsp_','_jsm_','_jrp_','_jrm_','_btp_','_btm_','_pup_','_pum_','_tpp_','_tpm_','_wjp_','_wjm_','_mup_','_mum_','_tqp_','_tqm_','_mtp_','_mtm_']35#Systematics = ['_']36#Systematics = FullSyst37RootFiles['Base'] = TFile(indir+"outFile.root")38for chk in FullSyst:39 if (chk=='_'): continue40 if (os.path.isfile(indir+"outFile_"+chk.replace('_','')+".root")):41 RootFiles[chk.replace('_','')] = TFile(indir+"outFile_"+chk.replace('_','')+".root")42 else:43 RootFiles[chk.replace('_','')] = TFile(indir+"outFile.root")44def loadHistos(opt):45 for chan in Channels:46 for btag in BTags:47 if (btag == 'GE1BTags'): btaglabel = 'ge1b'48 if (btag == 'Ex1BTags'): btaglabel = 'ex1b'49 if (btag == 'Ex2BTags'): btaglabel = 'ex2b'50 if (chan=='El'): Histos['Data_'+btaglabel+'_el'] = RootFiles['Base'].Get(btag+opt+'/'+chan+'/mWprime_Limits_'+btag+opt+'_'+'Data'+'_'+chan)51 if (chan=='Mu'): Histos['Data_'+btaglabel+'_mu'] = RootFiles['Base'].Get(btag+opt+'/'+chan+'/mWprime_Limits_'+btag+opt+'_'+'Data'+'_'+chan)52 53 for bg in Backgrounds:54 Histos[bg+'_'+btaglabel+'_'+chan] = RootFiles['Base'].Get(btag+opt+'/'+chan+'/mWprime_Limits_'+btag+opt+'_'+bg+'_'+chan)55 Histos[bg+'_jsp_'+btaglabel+'_'+chan] = RootFiles['jsp'].Get(btag+opt+'/'+chan+'/mWprime_Limits_'+btag+opt+'_'+bg+'_'+chan)56 if (Histos[bg+'_jsp_'+btaglabel+'_'+chan].Integral() != 0.): Histos[bg+'_jsp_'+btaglabel+'_'+chan].Scale((Histos[bg+'_'+btaglabel+'_'+chan].Integral()+(Histos[bg+'_jsp_'+btaglabel+'_'+chan].Integral()-Histos[bg+'_'+btaglabel+'_'+chan].Integral())*SystScale['jsp'])/Histos[bg+'_jsp_'+btaglabel+'_'+chan].Integral())57 Histos[bg+'_jsm_'+btaglabel+'_'+chan] = RootFiles['jsm'].Get(btag+opt+'/'+chan+'/mWprime_Limits_'+btag+opt+'_'+bg+'_'+chan)58 if (Histos[bg+'_jsm_'+btaglabel+'_'+chan].Integral() != 0.): Histos[bg+'_jsm_'+btaglabel+'_'+chan].Scale((Histos[bg+'_'+btaglabel+'_'+chan].Integral()+(Histos[bg+'_jsm_'+btaglabel+'_'+chan].Integral()-Histos[bg+'_'+btaglabel+'_'+chan].Integral())*SystScale['jsm'])/Histos[bg+'_jsm_'+btaglabel+'_'+chan].Integral())59 Histos[bg+'_jrp_'+btaglabel+'_'+chan] = RootFiles['jrp'].Get(btag+opt+'/'+chan+'/mWprime_Limits_'+btag+opt+'_'+bg+'_'+chan)60 if (Histos[bg+'_jrp_'+btaglabel+'_'+chan].Integral() != 0.): Histos[bg+'_jrp_'+btaglabel+'_'+chan].Scale((Histos[bg+'_'+btaglabel+'_'+chan].Integral()+(Histos[bg+'_jrp_'+btaglabel+'_'+chan].Integral()-Histos[bg+'_'+btaglabel+'_'+chan].Integral())*SystScale['jrp'])/Histos[bg+'_jrp_'+btaglabel+'_'+chan].Integral())61 Histos[bg+'_jrm_'+btaglabel+'_'+chan] = RootFiles['jrm'].Get(btag+opt+'/'+chan+'/mWprime_Limits_'+btag+opt+'_'+bg+'_'+chan)62 if (Histos[bg+'_jrm_'+btaglabel+'_'+chan].Integral() != 0.): Histos[bg+'_jrm_'+btaglabel+'_'+chan].Scale((Histos[bg+'_'+btaglabel+'_'+chan].Integral()+(Histos[bg+'_jrm_'+btaglabel+'_'+chan].Integral()-Histos[bg+'_'+btaglabel+'_'+chan].Integral())*SystScale['jrm'])/Histos[bg+'_jrm_'+btaglabel+'_'+chan].Integral())63 Histos[bg+'_mup_'+btaglabel+'_'+chan] = RootFiles['mup'].Get(btag+opt+'/'+chan+'/mWprime_Limits_'+btag+opt+'_'+bg+'_'+chan)64 if (Histos[bg+'_mup_'+btaglabel+'_'+chan].Integral() != 0.): Histos[bg+'_mup_'+btaglabel+'_'+chan].Scale((Histos[bg+'_'+btaglabel+'_'+chan].Integral()+(Histos[bg+'_mup_'+btaglabel+'_'+chan].Integral()-Histos[bg+'_'+btaglabel+'_'+chan].Integral())*SystScale['mup'])/Histos[bg+'_mup_'+btaglabel+'_'+chan].Integral())65 Histos[bg+'_mum_'+btaglabel+'_'+chan] = RootFiles['mum'].Get(btag+opt+'/'+chan+'/mWprime_Limits_'+btag+opt+'_'+bg+'_'+chan)66 if (Histos[bg+'_mum_'+btaglabel+'_'+chan].Integral() != 0.): Histos[bg+'_mum_'+btaglabel+'_'+chan].Scale((Histos[bg+'_'+btaglabel+'_'+chan].Integral()+(Histos[bg+'_mum_'+btaglabel+'_'+chan].Integral()-Histos[bg+'_'+btaglabel+'_'+chan].Integral())*SystScale['mum'])/Histos[bg+'_mum_'+btaglabel+'_'+chan].Integral())67 Histos[bg+'_pup_'+btaglabel+'_'+chan] = RootFiles['pup'].Get(btag+opt+'/'+chan+'/mWprime_Limits_'+btag+opt+'_'+bg+'_'+chan)68 if (Histos[bg+'_pup_'+btaglabel+'_'+chan].Integral() != 0.): Histos[bg+'_pup_'+btaglabel+'_'+chan].Scale((Histos[bg+'_'+btaglabel+'_'+chan].Integral()+(Histos[bg+'_pup_'+btaglabel+'_'+chan].Integral()-Histos[bg+'_'+btaglabel+'_'+chan].Integral())*SystScale['pup'])/Histos[bg+'_pup_'+btaglabel+'_'+chan].Integral())69 Histos[bg+'_pum_'+btaglabel+'_'+chan] = RootFiles['pum'].Get(btag+opt+'/'+chan+'/mWprime_Limits_'+btag+opt+'_'+bg+'_'+chan)70 if (Histos[bg+'_pum_'+btaglabel+'_'+chan].Integral() != 0.): Histos[bg+'_pum_'+btaglabel+'_'+chan].Scale((Histos[bg+'_'+btaglabel+'_'+chan].Integral()+(Histos[bg+'_pum_'+btaglabel+'_'+chan].Integral()-Histos[bg+'_'+btaglabel+'_'+chan].Integral())*SystScale['pum'])/Histos[bg+'_pum_'+btaglabel+'_'+chan].Integral())71 Histos[bg+'_tpp_'+btaglabel+'_'+chan] = RootFiles['tpp'].Get(btag+opt+'/'+chan+'/mWprime_Limits_'+btag+opt+'_'+bg+'_'+chan)72 if (Histos[bg+'_tpp_'+btaglabel+'_'+chan].Integral() != 0.): Histos[bg+'_tpp_'+btaglabel+'_'+chan].Scale((Histos[bg+'_'+btaglabel+'_'+chan].Integral()+(Histos[bg+'_tpp_'+btaglabel+'_'+chan].Integral()-Histos[bg+'_'+btaglabel+'_'+chan].Integral())*SystScale['tpp'])/Histos[bg+'_tpp_'+btaglabel+'_'+chan].Integral())73 Histos[bg+'_tpm_'+btaglabel+'_'+chan] = RootFiles['tpm'].Get(btag+opt+'/'+chan+'/mWprime_Limits_'+btag+opt+'_'+bg+'_'+chan)74 if (Histos[bg+'_tpm_'+btaglabel+'_'+chan].Integral() != 0.): Histos[bg+'_tpm_'+btaglabel+'_'+chan].Scale((Histos[bg+'_'+btaglabel+'_'+chan].Integral()+(Histos[bg+'_tpm_'+btaglabel+'_'+chan].Integral()-Histos[bg+'_'+btaglabel+'_'+chan].Integral())*SystScale['tpm'])/Histos[bg+'_tpm_'+btaglabel+'_'+chan].Integral())75 Histos[bg+'_btp_'+btaglabel+'_'+chan] = RootFiles['btp'].Get(btag+opt+'/'+chan+'/mWprime_Limits_'+btag+opt+'_'+bg+'_'+chan)76 if (Histos[bg+'_btp_'+btaglabel+'_'+chan].Integral() != 0.): Histos[bg+'_btp_'+btaglabel+'_'+chan].Scale((Histos[bg+'_'+btaglabel+'_'+chan].Integral()+(Histos[bg+'_btp_'+btaglabel+'_'+chan].Integral()-Histos[bg+'_'+btaglabel+'_'+chan].Integral())*SystScale['btp'])/Histos[bg+'_btp_'+btaglabel+'_'+chan].Integral())77 Histos[bg+'_btm_'+btaglabel+'_'+chan] = RootFiles['btm'].Get(btag+opt+'/'+chan+'/mWprime_Limits_'+btag+opt+'_'+bg+'_'+chan)78 if (Histos[bg+'_btm_'+btaglabel+'_'+chan].Integral() != 0.): Histos[bg+'_btm_'+btaglabel+'_'+chan].Scale((Histos[bg+'_'+btaglabel+'_'+chan].Integral()+(Histos[bg+'_btm_'+btaglabel+'_'+chan].Integral()-Histos[bg+'_'+btaglabel+'_'+chan].Integral())*SystScale['btm'])/Histos[bg+'_btm_'+btaglabel+'_'+chan].Integral())79 Histos[bg+'_mtp_'+btaglabel+'_'+chan] = RootFiles['mtp'].Get(btag+opt+'/'+chan+'/mWprime_Limits_'+btag+opt+'_'+bg+'_'+chan)80 if (Histos[bg+'_mtp_'+btaglabel+'_'+chan].Integral() != 0.): Histos[bg+'_mtp_'+btaglabel+'_'+chan].Scale((Histos[bg+'_'+btaglabel+'_'+chan].Integral()+(Histos[bg+'_mtp_'+btaglabel+'_'+chan].Integral()-Histos[bg+'_'+btaglabel+'_'+chan].Integral())*SystScale['mtp'])/Histos[bg+'_mtp_'+btaglabel+'_'+chan].Integral())81 Histos[bg+'_mtm_'+btaglabel+'_'+chan] = RootFiles['mtm'].Get(btag+opt+'/'+chan+'/mWprime_Limits_'+btag+opt+'_'+bg+'_'+chan)82 if (Histos[bg+'_mtm_'+btaglabel+'_'+chan].Integral() != 0.): Histos[bg+'_mtm_'+btaglabel+'_'+chan].Scale((Histos[bg+'_'+btaglabel+'_'+chan].Integral()+(Histos[bg+'_mtm_'+btaglabel+'_'+chan].Integral()-Histos[bg+'_'+btaglabel+'_'+chan].Integral())*SystScale['mtm'])/Histos[bg+'_mtm_'+btaglabel+'_'+chan].Integral())83 Histos[bg+'_wjp_'+btaglabel+'_'+chan] = RootFiles['wjp'].Get(btag+opt+'/'+chan+'/mWprime_Limits_'+btag+opt+'_'+bg+'_'+chan)84 if (Histos[bg+'_wjp_'+btaglabel+'_'+chan].Integral() != 0.): Histos[bg+'_wjp_'+btaglabel+'_'+chan].Scale((Histos[bg+'_'+btaglabel+'_'+chan].Integral()+(Histos[bg+'_wjp_'+btaglabel+'_'+chan].Integral()-Histos[bg+'_'+btaglabel+'_'+chan].Integral())*SystScale['wjp'])/Histos[bg+'_wjp_'+btaglabel+'_'+chan].Integral())85 Histos[bg+'_wjm_'+btaglabel+'_'+chan] = RootFiles['wjm'].Get(btag+opt+'/'+chan+'/mWprime_Limits_'+btag+opt+'_'+bg+'_'+chan)86 if (Histos[bg+'_wjm_'+btaglabel+'_'+chan].Integral() != 0.): Histos[bg+'_wjm_'+btaglabel+'_'+chan].Scale((Histos[bg+'_'+btaglabel+'_'+chan].Integral()+(Histos[bg+'_wjm_'+btaglabel+'_'+chan].Integral()-Histos[bg+'_'+btaglabel+'_'+chan].Integral())*SystScale['wjm'])/Histos[bg+'_wjm_'+btaglabel+'_'+chan].Integral())87 Histos[bg+'_msp_'+btaglabel+'_'+chan] = RootFiles['msp'].Get(btag+opt+'/'+chan+'/mWprime_Limits_'+btag+opt+'_'+bg+'_'+chan)88 if (Histos[bg+'_msp_'+btaglabel+'_'+chan].Integral() != 0.): Histos[bg+'_msp_'+btaglabel+'_'+chan].Scale((Histos[bg+'_'+btaglabel+'_'+chan].Integral()+(Histos[bg+'_msp_'+btaglabel+'_'+chan].Integral()-Histos[bg+'_'+btaglabel+'_'+chan].Integral())*SystScale['msp'])/Histos[bg+'_msp_'+btaglabel+'_'+chan].Integral())89 Histos[bg+'_msm_'+btaglabel+'_'+chan] = RootFiles['msm'].Get(btag+opt+'/'+chan+'/mWprime_Limits_'+btag+opt+'_'+bg+'_'+chan)90 if (Histos[bg+'_msm_'+btaglabel+'_'+chan].Integral() != 0.): Histos[bg+'_msm_'+btaglabel+'_'+chan].Scale((Histos[bg+'_'+btaglabel+'_'+chan].Integral()+(Histos[bg+'_msm_'+btaglabel+'_'+chan].Integral()-Histos[bg+'_'+btaglabel+'_'+chan].Integral())*SystScale['msm'])/Histos[bg+'_msm_'+btaglabel+'_'+chan].Integral())91 Histos[bg+'_mrp_'+btaglabel+'_'+chan] = RootFiles['mrp'].Get(btag+opt+'/'+chan+'/mWprime_Limits_'+btag+opt+'_'+bg+'_'+chan)92 if (Histos[bg+'_mrp_'+btaglabel+'_'+chan].Integral() != 0.): Histos[bg+'_mrp_'+btaglabel+'_'+chan].Scale((Histos[bg+'_'+btaglabel+'_'+chan].Integral()+(Histos[bg+'_mrp_'+btaglabel+'_'+chan].Integral()-Histos[bg+'_'+btaglabel+'_'+chan].Integral())*SystScale['mrp'])/Histos[bg+'_mrp_'+btaglabel+'_'+chan].Integral())93 Histos[bg+'_mrm_'+btaglabel+'_'+chan] = RootFiles['mrm'].Get(btag+opt+'/'+chan+'/mWprime_Limits_'+btag+opt+'_'+bg+'_'+chan)94 if (Histos[bg+'_mrm_'+btaglabel+'_'+chan].Integral() != 0.): Histos[bg+'_mrm_'+btaglabel+'_'+chan].Scale((Histos[bg+'_'+btaglabel+'_'+chan].Integral()+(Histos[bg+'_mrm_'+btaglabel+'_'+chan].Integral()-Histos[bg+'_'+btaglabel+'_'+chan].Integral())*SystScale['mrm'])/Histos[bg+'_mrm_'+btaglabel+'_'+chan].Integral())95 if (bg=='TTbar'):96 Histos[bg+'_tqp_'+btaglabel+'_'+chan] = RootFiles['tqp'].Get(btag+opt+'/'+chan+'/mWprime_Limits_'+btag+opt+'_'+bg+'_scaleup_'+chan)97 if (Histos[bg+'_tqp_'+btaglabel+'_'+chan].Integral() != 0.): Histos[bg+'_tqp_'+btaglabel+'_'+chan].Scale((Histos[bg+'_'+btaglabel+'_'+chan].Integral()+(Histos[bg+'_tqp_'+btaglabel+'_'+chan].Integral()-Histos[bg+'_'+btaglabel+'_'+chan].Integral())*SystScale['tqp'])/Histos[bg+'_tqp_'+btaglabel+'_'+chan].Integral())98 Histos[bg+'_tqm_'+btaglabel+'_'+chan] = RootFiles['tqm'].Get(btag+opt+'/'+chan+'/mWprime_Limits_'+btag+opt+'_'+bg+'_scaledown_'+chan)99 if (Histos[bg+'_tqm_'+btaglabel+'_'+chan].Integral() != 0.): Histos[bg+'_tqm_'+btaglabel+'_'+chan].Scale((Histos[bg+'_'+btaglabel+'_'+chan].Integral()+(Histos[bg+'_tqm_'+btaglabel+'_'+chan].Integral()-Histos[bg+'_'+btaglabel+'_'+chan].Integral())*SystScale['tqm'])/Histos[bg+'_tqm_'+btaglabel+'_'+chan].Integral())100 else:101 Histos[bg+'_tqp_'+btaglabel+'_'+chan] = RootFiles['tqp'].Get(btag+opt+'/'+chan+'/mWprime_Limits_'+btag+opt+'_'+bg+'_'+chan)102 if (Histos[bg+'_tqp_'+btaglabel+'_'+chan].Integral() != 0.): Histos[bg+'_tqp_'+btaglabel+'_'+chan].Scale((Histos[bg+'_'+btaglabel+'_'+chan].Integral()+(Histos[bg+'_tqp_'+btaglabel+'_'+chan].Integral()-Histos[bg+'_'+btaglabel+'_'+chan].Integral())*SystScale['tqp'])/Histos[bg+'_tqp_'+btaglabel+'_'+chan].Integral())103 Histos[bg+'_tqm_'+btaglabel+'_'+chan] = RootFiles['tqm'].Get(btag+opt+'/'+chan+'/mWprime_Limits_'+btag+opt+'_'+bg+'_'+chan)104 if (Histos[bg+'_tqm_'+btaglabel+'_'+chan].Integral() != 0.): Histos[bg+'_tqm_'+btaglabel+'_'+chan].Scale((Histos[bg+'_'+btaglabel+'_'+chan].Integral()+(Histos[bg+'_tqm_'+btaglabel+'_'+chan].Integral()-Histos[bg+'_'+btaglabel+'_'+chan].Integral())*SystScale['tqm'])/Histos[bg+'_tqm_'+btaglabel+'_'+chan].Integral())105 106 if (not bg.startswith('T') and not bg.startswith('QCD')):107 HistosPre[bg+'_'+chan] = RootFiles['Base'].Get('GE0BTags'+opt+'/'+chan+'/mWprime_Limits_GE0BTags'+opt+'_'+bg+'_'+chan)108 HistosPre[bg+'_jsp_'+chan] = RootFiles['jsp'].Get('GE0BTags'+opt+'/'+chan+'/mWprime_Limits_GE0BTags'+opt+'_'+bg+'_'+chan)109 if (HistosPre[bg+'_jsp_'+chan].Integral() != 0.): HistosPre[bg+'_jsp_'+chan].Scale((HistosPre[bg+'_'+chan].Integral()+(HistosPre[bg+'_jsp_'+chan].Integral()-HistosPre[bg+'_'+chan].Integral())*SystScale['jsp'])/HistosPre[bg+'_jsp_'+chan].Integral())110 HistosPre[bg+'_jsm_'+chan] = RootFiles['jsm'].Get('GE0BTags'+opt+'/'+chan+'/mWprime_Limits_GE0BTags'+opt+'_'+bg+'_'+chan)111 if (HistosPre[bg+'_jsm_'+chan].Integral() != 0.): HistosPre[bg+'_jsm_'+chan].Scale((HistosPre[bg+'_'+chan].Integral()+(HistosPre[bg+'_jsm_'+chan].Integral()-HistosPre[bg+'_'+chan].Integral())*SystScale['jsm'])/HistosPre[bg+'_jsm_'+chan].Integral())112 HistosPre[bg+'_jrp_'+chan] = RootFiles['jrp'].Get('GE0BTags'+opt+'/'+chan+'/mWprime_Limits_GE0BTags'+opt+'_'+bg+'_'+chan)113 if (HistosPre[bg+'_jrp_'+chan].Integral() != 0.): HistosPre[bg+'_jrp_'+chan].Scale((HistosPre[bg+'_'+chan].Integral()+(HistosPre[bg+'_jrp_'+chan].Integral()-HistosPre[bg+'_'+chan].Integral())*SystScale['jrp'])/HistosPre[bg+'_jrp_'+chan].Integral())114 HistosPre[bg+'_jrm_'+chan] = RootFiles['jrm'].Get('GE0BTags'+opt+'/'+chan+'/mWprime_Limits_GE0BTags'+opt+'_'+bg+'_'+chan)115 if (HistosPre[bg+'_jrm_'+chan].Integral() != 0.): HistosPre[bg+'_jrm_'+chan].Scale((HistosPre[bg+'_'+chan].Integral()+(HistosPre[bg+'_jrm_'+chan].Integral()-HistosPre[bg+'_'+chan].Integral())*SystScale['jrm'])/HistosPre[bg+'_jrm_'+chan].Integral())116 HistosPre[bg+'_mup_'+chan] = RootFiles['mup'].Get('GE0BTags'+opt+'/'+chan+'/mWprime_Limits_GE0BTags'+opt+'_'+bg+'_'+chan)117 if (HistosPre[bg+'_mup_'+chan].Integral() != 0.): HistosPre[bg+'_mup_'+chan].Scale((HistosPre[bg+'_'+chan].Integral()+(HistosPre[bg+'_mup_'+chan].Integral()-HistosPre[bg+'_'+chan].Integral())*SystScale['mup'])/HistosPre[bg+'_mup_'+chan].Integral())118 HistosPre[bg+'_mum_'+chan] = RootFiles['mum'].Get('GE0BTags'+opt+'/'+chan+'/mWprime_Limits_GE0BTags'+opt+'_'+bg+'_'+chan)119 if (HistosPre[bg+'_mum_'+chan].Integral() != 0.): HistosPre[bg+'_mum_'+chan].Scale((HistosPre[bg+'_'+chan].Integral()+(HistosPre[bg+'_mum_'+chan].Integral()-HistosPre[bg+'_'+chan].Integral())*SystScale['mum'])/HistosPre[bg+'_mum_'+chan].Integral())120 HistosPre[bg+'_pup_'+chan] = RootFiles['pup'].Get('GE0BTags'+opt+'/'+chan+'/mWprime_Limits_GE0BTags'+opt+'_'+bg+'_'+chan)121 if (HistosPre[bg+'_pup_'+chan].Integral() != 0.): HistosPre[bg+'_pup_'+chan].Scale((HistosPre[bg+'_'+chan].Integral()+(HistosPre[bg+'_pup_'+chan].Integral()-HistosPre[bg+'_'+chan].Integral())*SystScale['pup'])/HistosPre[bg+'_pup_'+chan].Integral())122 HistosPre[bg+'_pum_'+chan] = RootFiles['pum'].Get('GE0BTags'+opt+'/'+chan+'/mWprime_Limits_GE0BTags'+opt+'_'+bg+'_'+chan)123 if (HistosPre[bg+'_pum_'+chan].Integral() != 0.): HistosPre[bg+'_pum_'+chan].Scale((HistosPre[bg+'_'+chan].Integral()+(HistosPre[bg+'_pum_'+chan].Integral()-HistosPre[bg+'_'+chan].Integral())*SystScale['pum'])/HistosPre[bg+'_pum_'+chan].Integral())124 HistosPre[bg+'_tpp_'+chan] = RootFiles['tpp'].Get('GE0BTags'+opt+'/'+chan+'/mWprime_Limits_GE0BTags'+opt+'_'+bg+'_'+chan)125 if (HistosPre[bg+'_tpp_'+chan].Integral() != 0.): HistosPre[bg+'_tpp_'+chan].Scale((HistosPre[bg+'_'+chan].Integral()+(HistosPre[bg+'_tpp_'+chan].Integral()-HistosPre[bg+'_'+chan].Integral())*SystScale['tpp'])/HistosPre[bg+'_tpp_'+chan].Integral())126 HistosPre[bg+'_tpm_'+chan] = RootFiles['tpm'].Get('GE0BTags'+opt+'/'+chan+'/mWprime_Limits_GE0BTags'+opt+'_'+bg+'_'+chan)127 if (HistosPre[bg+'_tpm_'+chan].Integral() != 0.): HistosPre[bg+'_tpm_'+chan].Scale((HistosPre[bg+'_'+chan].Integral()+(HistosPre[bg+'_tpm_'+chan].Integral()-HistosPre[bg+'_'+chan].Integral())*SystScale['tpm'])/HistosPre[bg+'_tpm_'+chan].Integral())128 HistosPre[bg+'_btp_'+chan] = RootFiles['btp'].Get('GE0BTags'+opt+'/'+chan+'/mWprime_Limits_GE0BTags'+opt+'_'+bg+'_'+chan)129 if (HistosPre[bg+'_btp_'+chan].Integral() != 0.): HistosPre[bg+'_btp_'+chan].Scale((HistosPre[bg+'_'+chan].Integral()+(HistosPre[bg+'_btp_'+chan].Integral()-HistosPre[bg+'_'+chan].Integral())*SystScale['btp'])/HistosPre[bg+'_btp_'+chan].Integral())130 HistosPre[bg+'_btm_'+chan] = RootFiles['btm'].Get('GE0BTags'+opt+'/'+chan+'/mWprime_Limits_GE0BTags'+opt+'_'+bg+'_'+chan)131 if (HistosPre[bg+'_btm_'+chan].Integral() != 0.): HistosPre[bg+'_btm_'+chan].Scale((HistosPre[bg+'_'+chan].Integral()+(HistosPre[bg+'_btm_'+chan].Integral()-HistosPre[bg+'_'+chan].Integral())*SystScale['btm'])/HistosPre[bg+'_btm_'+chan].Integral())132 HistosPre[bg+'_mtp_'+chan] = RootFiles['mtp'].Get('GE0BTags'+opt+'/'+chan+'/mWprime_Limits_GE0BTags'+opt+'_'+bg+'_'+chan)133 if (HistosPre[bg+'_mtp_'+chan].Integral() != 0.): HistosPre[bg+'_mtp_'+chan].Scale((HistosPre[bg+'_'+chan].Integral()+(HistosPre[bg+'_mtp_'+chan].Integral()-HistosPre[bg+'_'+chan].Integral())*SystScale['mtp'])/HistosPre[bg+'_mtp_'+chan].Integral())134 HistosPre[bg+'_mtm_'+chan] = RootFiles['mtm'].Get('GE0BTags'+opt+'/'+chan+'/mWprime_Limits_GE0BTags'+opt+'_'+bg+'_'+chan)135 if (HistosPre[bg+'_mtm_'+chan].Integral() != 0.): HistosPre[bg+'_mtm_'+chan].Scale((HistosPre[bg+'_'+chan].Integral()+(HistosPre[bg+'_mtm_'+chan].Integral()-HistosPre[bg+'_'+chan].Integral())*SystScale['mtm'])/HistosPre[bg+'_mtm_'+chan].Integral())136 HistosPre[bg+'_wjp_'+chan] = RootFiles['wjp'].Get('GE0BTags'+opt+'/'+chan+'/mWprime_Limits_GE0BTags'+opt+'_'+bg+'_'+chan)137 if (HistosPre[bg+'_wjp_'+chan].Integral() != 0.): HistosPre[bg+'_wjp_'+chan].Scale((HistosPre[bg+'_'+chan].Integral()+(HistosPre[bg+'_wjp_'+chan].Integral()-HistosPre[bg+'_'+chan].Integral())*SystScale['wjp'])/HistosPre[bg+'_wjp_'+chan].Integral())138 HistosPre[bg+'_wjm_'+chan] = RootFiles['wjm'].Get('GE0BTags'+opt+'/'+chan+'/mWprime_Limits_GE0BTags'+opt+'_'+bg+'_'+chan)139 if (HistosPre[bg+'_wjm_'+chan].Integral() != 0.): HistosPre[bg+'_wjm_'+chan].Scale((HistosPre[bg+'_'+chan].Integral()+(HistosPre[bg+'_wjm_'+chan].Integral()-HistosPre[bg+'_'+chan].Integral())*SystScale['wjm'])/HistosPre[bg+'_wjm_'+chan].Integral())140 HistosPre[bg+'_msp_'+chan] = RootFiles['msp'].Get('GE0BTags'+opt+'/'+chan+'/mWprime_Limits_GE0BTags'+opt+'_'+bg+'_'+chan)141 if (HistosPre[bg+'_msp_'+chan].Integral() != 0.): HistosPre[bg+'_msp_'+chan].Scale((HistosPre[bg+'_'+chan].Integral()+(HistosPre[bg+'_msp_'+chan].Integral()-HistosPre[bg+'_'+chan].Integral())*SystScale['msp'])/HistosPre[bg+'_msp_'+chan].Integral())142 HistosPre[bg+'_msm_'+chan] = RootFiles['msm'].Get('GE0BTags'+opt+'/'+chan+'/mWprime_Limits_GE0BTags'+opt+'_'+bg+'_'+chan)143 if (HistosPre[bg+'_msm_'+chan].Integral() != 0.): HistosPre[bg+'_msm_'+chan].Scale((HistosPre[bg+'_'+chan].Integral()+(HistosPre[bg+'_msm_'+chan].Integral()-HistosPre[bg+'_'+chan].Integral())*SystScale['msm'])/HistosPre[bg+'_msm_'+chan].Integral())144 HistosPre[bg+'_mrm_'+chan] = RootFiles['mrm'].Get('GE0BTags'+opt+'/'+chan+'/mWprime_Limits_GE0BTags'+opt+'_'+bg+'_'+chan)145 if (HistosPre[bg+'_mrm_'+chan].Integral() != 0.): HistosPre[bg+'_mrm_'+chan].Scale((HistosPre[bg+'_'+chan].Integral()+(HistosPre[bg+'_mrm_'+chan].Integral()-HistosPre[bg+'_'+chan].Integral())*SystScale['mrm'])/HistosPre[bg+'_mrm_'+chan].Integral())146 HistosPre[bg+'_tqp_'+chan] = RootFiles['tqp'].Get('GE0BTags'+opt+'/'+chan+'/mWprime_Limits_GE0BTags'+opt+'_'+bg+'_'+chan)147 if (HistosPre[bg+'_tqp_'+chan].Integral() != 0.): HistosPre[bg+'_tqp_'+chan].Scale((HistosPre[bg+'_'+chan].Integral()+(HistosPre[bg+'_tqp_'+chan].Integral()-HistosPre[bg+'_'+chan].Integral())*SystScale['tqp'])/HistosPre[bg+'_tqp_'+chan].Integral())148 HistosPre[bg+'_tqm_'+chan] = RootFiles['tqm'].Get('GE0BTags'+opt+'/'+chan+'/mWprime_Limits_GE0BTags'+opt+'_'+bg+'_'+chan)149 if (HistosPre[bg+'_tqm_'+chan].Integral() != 0.): HistosPre[bg+'_tqm_'+chan].Scale((HistosPre[bg+'_'+chan].Integral()+(HistosPre[bg+'_tqm_'+chan].Integral()-HistosPre[bg+'_'+chan].Integral())*SystScale['tqm'])/HistosPre[bg+'_tqm_'+chan].Integral())150 151 for mass in masses:152 #for coup in ['Right','Left','Mix']:153 for coup in ['Right']:154 155 Histos['Wprime'+mass+coup+'_'+btaglabel+'_'+chan] = RootFiles['Base'].Get(btag+opt+'/'+chan+'/mWprime_Limits_'+btag+opt+'_'+'Wprime'+mass+coup+'_'+chan)156 Histos['Wprime'+mass+coup+'_jsp_'+btaglabel+'_'+chan] = RootFiles['jsp'].Get(btag+opt+'/'+chan+'/mWprime_Limits_'+btag+opt+'_'+'Wprime'+mass+coup+'_'+chan)157 if (Histos['Wprime'+mass+coup+'_jsp_'+btaglabel+'_'+chan].Integral() != 0.): Histos['Wprime'+mass+coup+'_jsp_'+btaglabel+'_'+chan].Scale((Histos['Wprime'+mass+coup+'_'+btaglabel+'_'+chan].Integral()+(Histos['Wprime'+mass+coup+'_jsp_'+btaglabel+'_'+chan].Integral()-Histos['Wprime'+mass+coup+'_'+btaglabel+'_'+chan].Integral())*SystScale['jsp'])/Histos['Wprime'+mass+coup+'_jsp_'+btaglabel+'_'+chan].Integral())158 Histos['Wprime'+mass+coup+'_jsm_'+btaglabel+'_'+chan] = RootFiles['jsm'].Get(btag+opt+'/'+chan+'/mWprime_Limits_'+btag+opt+'_'+'Wprime'+mass+coup+'_'+chan)159 if (Histos['Wprime'+mass+coup+'_jsm_'+btaglabel+'_'+chan].Integral() != 0.): Histos['Wprime'+mass+coup+'_jsm_'+btaglabel+'_'+chan].Scale((Histos['Wprime'+mass+coup+'_'+btaglabel+'_'+chan].Integral()+(Histos['Wprime'+mass+coup+'_jsm_'+btaglabel+'_'+chan].Integral()-Histos['Wprime'+mass+coup+'_'+btaglabel+'_'+chan].Integral())*SystScale['jsm'])/Histos['Wprime'+mass+coup+'_jsm_'+btaglabel+'_'+chan].Integral())160 Histos['Wprime'+mass+coup+'_jrp_'+btaglabel+'_'+chan] = RootFiles['jrp'].Get(btag+opt+'/'+chan+'/mWprime_Limits_'+btag+opt+'_'+'Wprime'+mass+coup+'_'+chan)161 if (Histos['Wprime'+mass+coup+'_jrp_'+btaglabel+'_'+chan].Integral() != 0.): Histos['Wprime'+mass+coup+'_jrp_'+btaglabel+'_'+chan].Scale((Histos['Wprime'+mass+coup+'_'+btaglabel+'_'+chan].Integral()+(Histos['Wprime'+mass+coup+'_jrp_'+btaglabel+'_'+chan].Integral()-Histos['Wprime'+mass+coup+'_'+btaglabel+'_'+chan].Integral())*SystScale['jrp'])/Histos['Wprime'+mass+coup+'_jrp_'+btaglabel+'_'+chan].Integral())162 Histos['Wprime'+mass+coup+'_jrm_'+btaglabel+'_'+chan] = RootFiles['jrm'].Get(btag+opt+'/'+chan+'/mWprime_Limits_'+btag+opt+'_'+'Wprime'+mass+coup+'_'+chan)163 if (Histos['Wprime'+mass+coup+'_jrm_'+btaglabel+'_'+chan].Integral() != 0.): Histos['Wprime'+mass+coup+'_jrm_'+btaglabel+'_'+chan].Scale((Histos['Wprime'+mass+coup+'_'+btaglabel+'_'+chan].Integral()+(Histos['Wprime'+mass+coup+'_jrm_'+btaglabel+'_'+chan].Integral()-Histos['Wprime'+mass+coup+'_'+btaglabel+'_'+chan].Integral())*SystScale['jrm'])/Histos['Wprime'+mass+coup+'_jrm_'+btaglabel+'_'+chan].Integral())164 Histos['Wprime'+mass+coup+'_mup_'+btaglabel+'_'+chan] = RootFiles['mup'].Get(btag+opt+'/'+chan+'/mWprime_Limits_'+btag+opt+'_'+'Wprime'+mass+coup+'_'+chan)165 if (Histos['Wprime'+mass+coup+'_mup_'+btaglabel+'_'+chan].Integral() != 0.): Histos['Wprime'+mass+coup+'_mup_'+btaglabel+'_'+chan].Scale((Histos['Wprime'+mass+coup+'_'+btaglabel+'_'+chan].Integral()+(Histos['Wprime'+mass+coup+'_mup_'+btaglabel+'_'+chan].Integral()-Histos['Wprime'+mass+coup+'_'+btaglabel+'_'+chan].Integral())*SystScale['mup'])/Histos['Wprime'+mass+coup+'_mup_'+btaglabel+'_'+chan].Integral())166 Histos['Wprime'+mass+coup+'_mum_'+btaglabel+'_'+chan] = RootFiles['mum'].Get(btag+opt+'/'+chan+'/mWprime_Limits_'+btag+opt+'_'+'Wprime'+mass+coup+'_'+chan)167 if (Histos['Wprime'+mass+coup+'_mum_'+btaglabel+'_'+chan].Integral() != 0.): Histos['Wprime'+mass+coup+'_mum_'+btaglabel+'_'+chan].Scale((Histos['Wprime'+mass+coup+'_'+btaglabel+'_'+chan].Integral()+(Histos['Wprime'+mass+coup+'_mum_'+btaglabel+'_'+chan].Integral()-Histos['Wprime'+mass+coup+'_'+btaglabel+'_'+chan].Integral())*SystScale['mum'])/Histos['Wprime'+mass+coup+'_mum_'+btaglabel+'_'+chan].Integral())168 Histos['Wprime'+mass+coup+'_pup_'+btaglabel+'_'+chan] = RootFiles['pup'].Get(btag+opt+'/'+chan+'/mWprime_Limits_'+btag+opt+'_'+'Wprime'+mass+coup+'_'+chan)169 if (Histos['Wprime'+mass+coup+'_pup_'+btaglabel+'_'+chan].Integral() != 0.): Histos['Wprime'+mass+coup+'_pup_'+btaglabel+'_'+chan].Scale((Histos['Wprime'+mass+coup+'_'+btaglabel+'_'+chan].Integral()+(Histos['Wprime'+mass+coup+'_pup_'+btaglabel+'_'+chan].Integral()-Histos['Wprime'+mass+coup+'_'+btaglabel+'_'+chan].Integral())*SystScale['pup'])/Histos['Wprime'+mass+coup+'_pup_'+btaglabel+'_'+chan].Integral())170 Histos['Wprime'+mass+coup+'_pum_'+btaglabel+'_'+chan] = RootFiles['pum'].Get(btag+opt+'/'+chan+'/mWprime_Limits_'+btag+opt+'_'+'Wprime'+mass+coup+'_'+chan)171 if (Histos['Wprime'+mass+coup+'_pum_'+btaglabel+'_'+chan].Integral() != 0.): Histos['Wprime'+mass+coup+'_pum_'+btaglabel+'_'+chan].Scale((Histos['Wprime'+mass+coup+'_'+btaglabel+'_'+chan].Integral()+(Histos['Wprime'+mass+coup+'_pum_'+btaglabel+'_'+chan].Integral()-Histos['Wprime'+mass+coup+'_'+btaglabel+'_'+chan].Integral())*SystScale['pum'])/Histos['Wprime'+mass+coup+'_pum_'+btaglabel+'_'+chan].Integral())172 Histos['Wprime'+mass+coup+'_tpp_'+btaglabel+'_'+chan] = RootFiles['tpp'].Get(btag+opt+'/'+chan+'/mWprime_Limits_'+btag+opt+'_'+'Wprime'+mass+coup+'_'+chan)173 if (Histos['Wprime'+mass+coup+'_tpp_'+btaglabel+'_'+chan].Integral() != 0.): Histos['Wprime'+mass+coup+'_tpp_'+btaglabel+'_'+chan].Scale((Histos['Wprime'+mass+coup+'_'+btaglabel+'_'+chan].Integral()+(Histos['Wprime'+mass+coup+'_tpp_'+btaglabel+'_'+chan].Integral()-Histos['Wprime'+mass+coup+'_'+btaglabel+'_'+chan].Integral())*SystScale['tpp'])/Histos['Wprime'+mass+coup+'_tpp_'+btaglabel+'_'+chan].Integral())174 Histos['Wprime'+mass+coup+'_tpm_'+btaglabel+'_'+chan] = RootFiles['tpm'].Get(btag+opt+'/'+chan+'/mWprime_Limits_'+btag+opt+'_'+'Wprime'+mass+coup+'_'+chan)175 if (Histos['Wprime'+mass+coup+'_tpm_'+btaglabel+'_'+chan].Integral() != 0.): Histos['Wprime'+mass+coup+'_tpm_'+btaglabel+'_'+chan].Scale((Histos['Wprime'+mass+coup+'_'+btaglabel+'_'+chan].Integral()+(Histos['Wprime'+mass+coup+'_tpm_'+btaglabel+'_'+chan].Integral()-Histos['Wprime'+mass+coup+'_'+btaglabel+'_'+chan].Integral())*SystScale['tpm'])/Histos['Wprime'+mass+coup+'_tpm_'+btaglabel+'_'+chan].Integral())176 Histos['Wprime'+mass+coup+'_btp_'+btaglabel+'_'+chan] = RootFiles['btp'].Get(btag+opt+'/'+chan+'/mWprime_Limits_'+btag+opt+'_'+'Wprime'+mass+coup+'_'+chan)177 if (Histos['Wprime'+mass+coup+'_btp_'+btaglabel+'_'+chan].Integral() != 0.): Histos['Wprime'+mass+coup+'_btp_'+btaglabel+'_'+chan].Scale((Histos['Wprime'+mass+coup+'_'+btaglabel+'_'+chan].Integral()+(Histos['Wprime'+mass+coup+'_btp_'+btaglabel+'_'+chan].Integral()-Histos['Wprime'+mass+coup+'_'+btaglabel+'_'+chan].Integral())*SystScale['btp'])/Histos['Wprime'+mass+coup+'_btp_'+btaglabel+'_'+chan].Integral())178 Histos['Wprime'+mass+coup+'_btm_'+btaglabel+'_'+chan] = RootFiles['btm'].Get(btag+opt+'/'+chan+'/mWprime_Limits_'+btag+opt+'_'+'Wprime'+mass+coup+'_'+chan)179 if (Histos['Wprime'+mass+coup+'_btm_'+btaglabel+'_'+chan].Integral() != 0.): Histos['Wprime'+mass+coup+'_btm_'+btaglabel+'_'+chan].Scale((Histos['Wprime'+mass+coup+'_'+btaglabel+'_'+chan].Integral()+(Histos['Wprime'+mass+coup+'_btm_'+btaglabel+'_'+chan].Integral()-Histos['Wprime'+mass+coup+'_'+btaglabel+'_'+chan].Integral())*SystScale['btm'])/Histos['Wprime'+mass+coup+'_btm_'+btaglabel+'_'+chan].Integral())180 Histos['Wprime'+mass+coup+'_mtp_'+btaglabel+'_'+chan] = RootFiles['mtp'].Get(btag+opt+'/'+chan+'/mWprime_Limits_'+btag+opt+'_'+'Wprime'+mass+coup+'_'+chan)181 if (Histos['Wprime'+mass+coup+'_mtp_'+btaglabel+'_'+chan].Integral() != 0.): Histos['Wprime'+mass+coup+'_mtp_'+btaglabel+'_'+chan].Scale((Histos['Wprime'+mass+coup+'_'+btaglabel+'_'+chan].Integral()+(Histos['Wprime'+mass+coup+'_mtp_'+btaglabel+'_'+chan].Integral()-Histos['Wprime'+mass+coup+'_'+btaglabel+'_'+chan].Integral())*SystScale['mtp'])/Histos['Wprime'+mass+coup+'_mtp_'+btaglabel+'_'+chan].Integral())182 Histos['Wprime'+mass+coup+'_mtm_'+btaglabel+'_'+chan] = RootFiles['mtm'].Get(btag+opt+'/'+chan+'/mWprime_Limits_'+btag+opt+'_'+'Wprime'+mass+coup+'_'+chan)183 if (Histos['Wprime'+mass+coup+'_mtm_'+btaglabel+'_'+chan].Integral() != 0.): Histos['Wprime'+mass+coup+'_mtm_'+btaglabel+'_'+chan].Scale((Histos['Wprime'+mass+coup+'_'+btaglabel+'_'+chan].Integral()+(Histos['Wprime'+mass+coup+'_mtm_'+btaglabel+'_'+chan].Integral()-Histos['Wprime'+mass+coup+'_'+btaglabel+'_'+chan].Integral())*SystScale['mtm'])/Histos['Wprime'+mass+coup+'_mtm_'+btaglabel+'_'+chan].Integral())184 Histos['Wprime'+mass+coup+'_wjp_'+btaglabel+'_'+chan] = RootFiles['wjp'].Get(btag+opt+'/'+chan+'/mWprime_Limits_'+btag+opt+'_'+'Wprime'+mass+coup+'_'+chan)185 if (Histos['Wprime'+mass+coup+'_wjp_'+btaglabel+'_'+chan].Integral() != 0.): Histos['Wprime'+mass+coup+'_wjp_'+btaglabel+'_'+chan].Scale((Histos['Wprime'+mass+coup+'_'+btaglabel+'_'+chan].Integral()+(Histos['Wprime'+mass+coup+'_wjp_'+btaglabel+'_'+chan].Integral()-Histos['Wprime'+mass+coup+'_'+btaglabel+'_'+chan].Integral())*SystScale['wjp'])/Histos['Wprime'+mass+coup+'_wjp_'+btaglabel+'_'+chan].Integral())186 Histos['Wprime'+mass+coup+'_wjm_'+btaglabel+'_'+chan] = RootFiles['wjm'].Get(btag+opt+'/'+chan+'/mWprime_Limits_'+btag+opt+'_'+'Wprime'+mass+coup+'_'+chan)187 if (Histos['Wprime'+mass+coup+'_wjm_'+btaglabel+'_'+chan].Integral() != 0.): Histos['Wprime'+mass+coup+'_wjm_'+btaglabel+'_'+chan].Scale((Histos['Wprime'+mass+coup+'_'+btaglabel+'_'+chan].Integral()+(Histos['Wprime'+mass+coup+'_wjm_'+btaglabel+'_'+chan].Integral()-Histos['Wprime'+mass+coup+'_'+btaglabel+'_'+chan].Integral())*SystScale['wjm'])/Histos['Wprime'+mass+coup+'_wjm_'+btaglabel+'_'+chan].Integral())188 Histos['Wprime'+mass+coup+'_msp_'+btaglabel+'_'+chan] = RootFiles['msp'].Get(btag+opt+'/'+chan+'/mWprime_Limits_'+btag+opt+'_'+'Wprime'+mass+coup+'_'+chan)189 if (Histos['Wprime'+mass+coup+'_msp_'+btaglabel+'_'+chan].Integral() != 0.): Histos['Wprime'+mass+coup+'_msp_'+btaglabel+'_'+chan].Scale((Histos['Wprime'+mass+coup+'_'+btaglabel+'_'+chan].Integral()+(Histos['Wprime'+mass+coup+'_msp_'+btaglabel+'_'+chan].Integral()-Histos['Wprime'+mass+coup+'_'+btaglabel+'_'+chan].Integral())*SystScale['msp'])/Histos['Wprime'+mass+coup+'_msp_'+btaglabel+'_'+chan].Integral())190 Histos['Wprime'+mass+coup+'_msm_'+btaglabel+'_'+chan] = RootFiles['msm'].Get(btag+opt+'/'+chan+'/mWprime_Limits_'+btag+opt+'_'+'Wprime'+mass+coup+'_'+chan)191 if (Histos['Wprime'+mass+coup+'_msm_'+btaglabel+'_'+chan].Integral() != 0.): Histos['Wprime'+mass+coup+'_msm_'+btaglabel+'_'+chan].Scale((Histos['Wprime'+mass+coup+'_'+btaglabel+'_'+chan].Integral()+(Histos['Wprime'+mass+coup+'_msm_'+btaglabel+'_'+chan].Integral()-Histos['Wprime'+mass+coup+'_'+btaglabel+'_'+chan].Integral())*SystScale['msm'])/Histos['Wprime'+mass+coup+'_msm_'+btaglabel+'_'+chan].Integral())192 Histos['Wprime'+mass+coup+'_mrp_'+btaglabel+'_'+chan] = RootFiles['mrp'].Get(btag+opt+'/'+chan+'/mWprime_Limits_'+btag+opt+'_'+'Wprime'+mass+coup+'_'+chan)193 if (Histos['Wprime'+mass+coup+'_mrp_'+btaglabel+'_'+chan].Integral() != 0.): Histos['Wprime'+mass+coup+'_mrp_'+btaglabel+'_'+chan].Scale((Histos['Wprime'+mass+coup+'_'+btaglabel+'_'+chan].Integral()+(Histos['Wprime'+mass+coup+'_mrp_'+btaglabel+'_'+chan].Integral()-Histos['Wprime'+mass+coup+'_'+btaglabel+'_'+chan].Integral())*SystScale['mrp'])/Histos['Wprime'+mass+coup+'_mrp_'+btaglabel+'_'+chan].Integral())194 Histos['Wprime'+mass+coup+'_mrm_'+btaglabel+'_'+chan] = RootFiles['mrm'].Get(btag+opt+'/'+chan+'/mWprime_Limits_'+btag+opt+'_'+'Wprime'+mass+coup+'_'+chan)195 if (Histos['Wprime'+mass+coup+'_mrm_'+btaglabel+'_'+chan].Integral() != 0.): Histos['Wprime'+mass+coup+'_mrm_'+btaglabel+'_'+chan].Scale((Histos['Wprime'+mass+coup+'_'+btaglabel+'_'+chan].Integral()+(Histos['Wprime'+mass+coup+'_mrm_'+btaglabel+'_'+chan].Integral()-Histos['Wprime'+mass+coup+'_'+btaglabel+'_'+chan].Integral())*SystScale['mrm'])/Histos['Wprime'+mass+coup+'_mrm_'+btaglabel+'_'+chan].Integral())196 Histos['Wprime'+mass+coup+'_tqp_'+btaglabel+'_'+chan] = RootFiles['tqp'].Get(btag+opt+'/'+chan+'/mWprime_Limits_'+btag+opt+'_'+'Wprime'+mass+coup+'_'+chan)197 if (Histos['Wprime'+mass+coup+'_tqp_'+btaglabel+'_'+chan].Integral() != 0.): Histos['Wprime'+mass+coup+'_tqp_'+btaglabel+'_'+chan].Scale((Histos['Wprime'+mass+coup+'_'+btaglabel+'_'+chan].Integral()+(Histos['Wprime'+mass+coup+'_tqp_'+btaglabel+'_'+chan].Integral()-Histos['Wprime'+mass+coup+'_'+btaglabel+'_'+chan].Integral())*SystScale['tqp'])/Histos['Wprime'+mass+coup+'_tqp_'+btaglabel+'_'+chan].Integral())198 Histos['Wprime'+mass+coup+'_tqm_'+btaglabel+'_'+chan] = RootFiles['tqm'].Get(btag+opt+'/'+chan+'/mWprime_Limits_'+btag+opt+'_'+'Wprime'+mass+coup+'_'+chan)199 if (Histos['Wprime'+mass+coup+'_tqm_'+btaglabel+'_'+chan].Integral() != 0.): Histos['Wprime'+mass+coup+'_tqm_'+btaglabel+'_'+chan].Scale((Histos['Wprime'+mass+coup+'_'+btaglabel+'_'+chan].Integral()+(Histos['Wprime'+mass+coup+'_tqm_'+btaglabel+'_'+chan].Integral()-Histos['Wprime'+mass+coup+'_'+btaglabel+'_'+chan].Integral())*SystScale['tqm'])/Histos['Wprime'+mass+coup+'_tqm_'+btaglabel+'_'+chan].Integral())200List_DataEl = ['Data_ex1b_el','Data_ex2b_el','Data_ge1b_el']201List_DataMu = ['Data_ex1b_mu','Data_ex2b_mu','Data_ge1b_mu']202#List_Bg = ['WJets','TTbar','ZJets','T_t','Tbar_t','T_tW','Tbar_tW','T_s','Tbar_s']203#List_Bg = ['WJets','TTbar']204List_Bg = Backgrounds205List_Right = []206List_Right.extend(['Wprime' + s + 'Right' for s in masses])207def makeHistos(channel, save, wprime, btags, List_to_use):208 print wprime209 UseQCD = False210 211 if (btags == 'ge1btags'): btaglabel = 'ge1b'212 if (btags == 'ex1btags'): btaglabel = 'ex1b'213 if (btags == 'ex2btags'): btaglabel = 'ex2b'214 background = 0215 for Type in List_to_use:216 217 if (channel == 'electron'):218 Chan = 'El'219 if (channel == 'muon'):220 Chan = 'Mu'221 print Type222 ######################################### 223 ### Set 0 B.G. Bins to something !=0 224 #########################################225 if (not (Type.startswith('Data'))):226 for sys in Systematics:227 Histos[Type+sys+btaglabel+'_'+Chan].Scale(SampScale[Type]*lumi)228 if ( not Type.startswith('Wprime') ):229 for x in range(1,Histos[Type+sys+btaglabel+'_'+Chan].GetNbinsX()+1):230 if (Histos[Type+sys+btaglabel+'_'+Chan].GetBinContent(x) < 0.000001 ): 231 #print 'Setting ',Histos[Type+sys+btaglabel+'_'+Chan].GetBinContent(x),' to 10E-6 for bin ',x,' of ',Type232 Histos[Type+sys+btaglabel+'_'+Chan].SetBinContent(x,0.000001)233 234 #Histos[Type+sys+btaglabel+'_'+Chan].Scale(lumi)235 236 if (sys!='_'): continue237 print 'SCALED EVENTS FOR ',Type,sys,' = ',Histos[Type+sys+btaglabel+'_'+Chan].Integral()238 if ( (not Type.startswith('T')) and (not Type.startswith('Wprime')) ):239 if (scaleWJets):240 HistosPre[Type+sys+Chan].Scale(SampScale[Type]*lumi)241 print 'Pre EVENTS FOR ',Type,sys,' = ',HistosPre[Type+sys+Chan].Integral() 242 243 if ( (not Type.startswith('Data')) and (not Type.startswith('Wprime')) and (sys == '_')):244 background = background + Histos[Type+sys+btaglabel+'_'+Chan].Integral()245 if (channel == 'electron'):246 chan = 'elec_'247 Histos['Data_'+btaglabel+'_el'].SetName(chan+"invmass_"+btags+"__DATA")248 Histos['Data_'+btaglabel+'_el'].SetTitle(chan+"invmass_"+btags+"__DATA")249 Histos['Data_'+btaglabel+'_el'].Rebin(REBIN)250 Histos['Data_'+btaglabel+'_el'].Write()251 if (channel == 'muon'):252 chan = 'mu_'253 Histos['Data_'+btaglabel+'_mu'].SetName(chan+"invmass_"+btags+"__DATA")254 Histos['Data_'+btaglabel+'_mu'].SetTitle(chan+"invmass_"+btags+"__DATA")255 Histos['Data_'+btaglabel+'_mu'].Rebin(REBIN)256 Histos['Data_'+btaglabel+'_mu'].Write()257 for sys in Systematics:258 suffix = ''259 if (sys == '_jsp_'): suffix = '__jes__plus'260 if (sys == '_jsm_'): suffix = '__jes__minus'261 if (sys == '_jrp_'): suffix = '__jer__plus'262 if (sys == '_jrm_'): suffix = '__jer__minus'263 if (sys == '_msp_'): suffix = '__mues__plus'264 if (sys == '_msm_'): suffix = '__mues__minus'265 if (sys == '_mrp_'): suffix = '__muer__plus'266 if (sys == '_mrm_'): suffix = '__muer__minus'267 if (sys == '_btp_'): suffix = '__btag__plus'268 if (sys == '_btm_'): suffix = '__btag__minus'269 if (sys == '_mtp_'): suffix = '__mtag__plus'270 if (sys == '_mtm_'): suffix = '__mtag__minus'271 if (sys == '_wjp_'): suffix = '__wjhf__plus'272 if (sys == '_wjm_'): suffix = '__wjhf__minus'273 if (sys == '_mup_'): suffix = '__murmuf__plus'274 if (sys == '_mum_'): suffix = '__murmuf__minus'275 if (sys == '_pup_'): suffix = '__pileup__plus'276 if (sys == '_pum_'): suffix = '__pileup__minus'277 if (sys == '_tpp_'): suffix = '__toppt__plus'278 if (sys == '_tpm_'): suffix = '__toppt__minus'279 if (sys == '_tqp_'): suffix = '__q2scale__plus'280 if (sys == '_tqm_'): suffix = '__q2scale__minus'281 Histos['TTbar'+sys+btaglabel+'_'+Chan].SetName(chan+"invmass_"+btags+"__ttbar"+suffix)282 Histos['TTbar'+sys+btaglabel+'_'+Chan].SetTitle(chan+"invmass_"+btags+"__ttbar"+suffix)283 if ('T_t' in Backgrounds): Histos['TTbar'+sys+btaglabel+'_'+Chan].Add(Histos['T_t'+sys+btaglabel+'_'+Chan])284 if ('Tbar_t' in Backgrounds): Histos['TTbar'+sys+btaglabel+'_'+Chan].Add(Histos['Tbar_t'+sys+btaglabel+'_'+Chan])285 if ('T_tW' in Backgrounds): Histos['TTbar'+sys+btaglabel+'_'+Chan].Add(Histos['T_tW'+sys+btaglabel+'_'+Chan])286 if ('Tbar_tW' in Backgrounds): Histos['TTbar'+sys+btaglabel+'_'+Chan].Add(Histos['Tbar_tW'+sys+btaglabel+'_'+Chan])287 if (wprime == 'Left' or wprime == 'Mix'): 288 Histos['TTbar'+sys+btaglabel+'_'+Chan].Rebin(REBIN)289 Histos['TTbar'+sys+btaglabel+'_'+Chan].Write()290 else:291 if ( wprime == 'ModRight' ):292 Histos['TTbar'+sys+btaglabel+'_'+Chan].Rebin(REBIN)293 Histos['TTbar'+sys+btaglabel+'_'+Chan].Write()294 Histos['T_s'+sys+btaglabel+'_'+Chan].SetName(chan+"invmass_"+btags+"__topstb"+suffix)295 Histos['T_s'+sys+btaglabel+'_'+Chan].SetTitle(chan+"invmass_"+btags+"__topstb"+suffix)296 Histos['T_s'+sys+btaglabel+'_'+Chan].Rebin(REBIN)297 Histos['T_s'+sys+btaglabel+'_'+Chan].Write()298 elif (wprime == 'Right'):299 if ('T_s' in Backgrounds): Histos['TTbar'+sys+btaglabel+'_'+Chan].Add(Histos['T_s'+sys+btaglabel+'_'+Chan])300 Histos['TTbar'+sys+btaglabel+'_'+Chan].Rebin(REBIN)301 Histos['TTbar'+sys+btaglabel+'_'+Chan].Write()302 Histos['WJets'+sys+btaglabel+'_'+Chan] = Histos['WJets_HT100to200'+sys+btaglabel+'_'+Chan]303 Histos['WJets'+sys+btaglabel+'_'+Chan].Add(Histos['WJets_HT200to400'+sys+btaglabel+'_'+Chan])304 Histos['WJets'+sys+btaglabel+'_'+Chan].Add(Histos['WJets_HT400to600'+sys+btaglabel+'_'+Chan])305 Histos['WJets'+sys+btaglabel+'_'+Chan].Add(Histos['WJets_HT600to800'+sys+btaglabel+'_'+Chan])306 Histos['WJets'+sys+btaglabel+'_'+Chan].Add(Histos['WJets_HT800to1200'+sys+btaglabel+'_'+Chan])307 Histos['WJets'+sys+btaglabel+'_'+Chan].Add(Histos['WJets_HT1200to2500'+sys+btaglabel+'_'+Chan])308 Histos['WJets'+sys+btaglabel+'_'+Chan].Add(Histos['WJets_HT2500toInf'+sys+btaglabel+'_'+Chan])309 Histos['WJets'+sys+btaglabel+'_'+Chan].Add(Histos['ZJets'+sys+btaglabel+'_'+Chan])310 if ('WW' in Backgrounds): Histos['WJets'+sys+btaglabel+'_'+Chan].Add(Histos['WW'+sys+btaglabel+'_'+Chan])311 if ('WZ' in Backgrounds): Histos['WJets'+sys+btaglabel+'_'+Chan].Add(Histos['WZ'+sys+btaglabel+'_'+Chan])312 if ('ZZ' in Backgrounds): Histos['WJets'+sys+btaglabel+'_'+Chan].Add(Histos['ZZ'+sys+btaglabel+'_'+Chan])313 Histos['WJets'+sys+btaglabel+'_'+Chan].SetName(chan+"invmass_"+btags+"__wjets"+suffix)314 Histos['WJets'+sys+btaglabel+'_'+Chan].SetTitle(chan+"invmass_"+btags+"__wjets"+suffix)315 if (scaleWJets) :316 HistosPre['WJets'+sys+Chan] = HistosPre['WJets_HT100to200'+sys+Chan]317 HistosPre['WJets'+sys+Chan].Add(HistosPre['WJets_HT200to400'+sys+Chan])318 HistosPre['WJets'+sys+Chan].Add(HistosPre['WJets_HT400to600'+sys+Chan])319 HistosPre['WJets'+sys+Chan].Add(HistosPre['WJets_HT600to800'+sys+Chan])320 HistosPre['WJets'+sys+Chan].Add(HistosPre['WJets_HT800to1200'+sys+Chan])321 HistosPre['WJets'+sys+Chan].Add(HistosPre['WJets_HT1200to2500'+sys+Chan])322 HistosPre['WJets'+sys+Chan].Add(HistosPre['WJets_HT2500toInf'+sys+Chan])323 HistosPre['WJets'+sys+Chan].Add(HistosPre['ZJets'+sys+Chan])324 if ('WW' in Backgrounds): HistosPre['WJets'+sys+Chan].Add(HistosPre['WW'+sys+Chan])325 if ('WZ' in Backgrounds): HistosPre['WJets'+sys+Chan].Add(HistosPre['WZ'+sys+Chan])326 if ('ZZ' in Backgrounds): HistosPre['WJets'+sys+Chan].Add(HistosPre['ZZ'+sys+Chan])327 HistosPre['WJets'+sys+Chan].SetName(chan+"invmass_"+btags+"__wjets"+suffix)328 HistosPre['WJets'+sys+Chan].SetTitle(chan+"invmass_"+btags+"__wjets"+suffix)329 330 ######################################### 331 ### RESCALE W+Jets 332 #########################################333 #print 'WJets ge1/pre: ',Histos['WJets'+sys+btaglabel+'_'+Chan].Integral()/HistosPre['WJets'+sys+Chan].Integral()334 if (scaleWJets):335 HistosPre['WJets'+sys+Chan].Scale( Histos['WJets'+sys+btaglabel+'_'+Chan].Integral()/HistosPre['WJets'+sys+Chan].Integral() )336 else:337 HistosPre['WJets'+sys+Chan] = Histos['WJets'+sys+btaglabel+'_'+Chan]338 #print 'WJets after rescaling: ',HistosPre['WJets'+sys+Chan].Integral()339 #HistosPre['WJets'+sys+Chan].Rebin(REBIN)340 #HistosPre['WJets'+sys+Chan].Write()341 #Histos['WJets'+sys+btaglabel+'_'+Chan].SetName(chan+"invmass_"+btags+"__ge1bwjets"+suffix)342 #Histos['WJets'+sys+btaglabel+'_'+Chan].SetTitle(chan+"invmass_"+btags+"__ge1bwjets"+suffix)343 Histos['WJets'+sys+btaglabel+'_'+Chan].Rebin(REBIN)344 Histos['WJets'+sys+btaglabel+'_'+Chan].Write()345 if (UseQCD):346 Histos['QCD'+sys+btaglabel+'_'+Chan] = Histos['QCD_Pt_120to170'+sys+btaglabel+'_'+Chan]347 Histos['QCD'+sys+btaglabel+'_'+Chan].Add(Histos['QCD_Pt_170to300'+sys+btaglabel+'_'+Chan])348 Histos['QCD'+sys+btaglabel+'_'+Chan].Add(Histos['QCD_Pt_300to470'+sys+btaglabel+'_'+Chan])349 Histos['QCD'+sys+btaglabel+'_'+Chan].Add(Histos['QCD_Pt_470to600'+sys+btaglabel+'_'+Chan])350 Histos['QCD'+sys+btaglabel+'_'+Chan].Add(Histos['QCD_Pt_600to800'+sys+btaglabel+'_'+Chan])351 Histos['QCD'+sys+btaglabel+'_'+Chan].Add(Histos['QCD_Pt_800to1000'+sys+btaglabel+'_'+Chan])352 Histos['QCD'+sys+btaglabel+'_'+Chan].Add(Histos['QCD_Pt_1000to1400'+sys+btaglabel+'_'+Chan])353 Histos['QCD'+sys+btaglabel+'_'+Chan].SetName(chan+"invmass_"+btags+"__qcd"+suffix)354 Histos['QCD'+sys+btaglabel+'_'+Chan].SetTitle(chan+"invmass_"+btags+"__qcd"+suffix)355 Histos['QCD'+sys+btaglabel+'_'+Chan].Rebin(REBIN)356 Histos['QCD'+sys+btaglabel+'_'+Chan].Write()357 if (channel == 'electron'): ch = '_el' 358 if (channel == 'muon'): ch = '_mu' 359 print channel,' data = ', Histos['Data_'+btaglabel+ch].Integral()360 if (UseQCD):361 #print 'Total background = ', Histos['TTbar_'+btaglabel+'_'+Chan].Integral()+HistosPre['WJets_'+Chan].Integral()+Histos['QCD_'+btaglabel+'_'+Chan].Integral()362 print 'Total background = ', Histos['TTbar_'+btaglabel+'_'+Chan].Integral()+Histos['WJets_'+btaglabel+'_'+Chan].Integral()+Histos['QCD_'+btaglabel+'_'+Chan].Integral()363 else:364 #print 'Total background = ', Histos['TTbar_'+btaglabel+'_'+Chan].Integral()+HistosPre['WJets_'+Chan].Integral()365 print 'Total background = ', Histos['TTbar_'+btaglabel+'_'+Chan].Integral()+Histos['WJets_'+btaglabel+'_'+Chan].Integral()366 #print 'WJets ',HistosPre['WJets_'+Chan].Integral()367 print 'WJets ',Histos['WJets_'+btaglabel+'_'+Chan].Integral()368 print 'TTbar ',Histos['TTbar_'+btaglabel+'_'+Chan].Integral()369 if (UseQCD): print 'QCD ',Histos['QCD_'+btaglabel+'_'+Chan].Integral()370 print 'Data / Background = ', Histos['Data_'+btaglabel+ch].Integral()/(Histos['TTbar_'+btaglabel+'_'+Chan].Integral()+Histos['WJets_'+btaglabel+'_'+Chan].Integral())371 372 for sys in Systematics:373 suffix = ''374 if (sys == '_jsp_'): suffix = '__jes__plus'375 if (sys == '_jsm_'): suffix = '__jes__minus'376 if (sys == '_jrp_'): suffix = '__jer__plus'377 if (sys == '_jrm_'): suffix = '__jer__minus'378 if (sys == '_msp_'): suffix = '__mues__plus'379 if (sys == '_msm_'): suffix = '__mues__minus'380 if (sys == '_mrp_'): suffix = '__muer__plus'381 if (sys == '_mrm_'): suffix = '__muer__minus'382 if (sys == '_btp_'): suffix = '__btag__plus'383 if (sys == '_btm_'): suffix = '__btag__minus'384 if (sys == '_mtp_'): suffix = '__mtag__plus'385 if (sys == '_mtm_'): suffix = '__mtag__minus'386 if (sys == '_wjp_'): suffix = '__wjhf__plus'387 if (sys == '_wjm_'): suffix = '__wjhf__minus'388 if (sys == '_mup_'): suffix = '__murmuf__plus'389 if (sys == '_mum_'): suffix = '__murmuf__minus'390 if (sys == '_pup_'): suffix = '__pileup__plus'391 if (sys == '_pum_'): suffix = '__pileup__minus'392 if (sys == '_tpp_'): suffix = '__toppt__plus'393 if (sys == '_tpm_'): suffix = '__toppt__minus'394 if (sys == '_tqp_'): suffix = '__q2scale__plus'395 if (sys == '_tqm_'): suffix = '__q2scale__minus'396 if (wprime == 'Right'):397 masses = ['1000','1100','1200','1300','1400','1500','1600','1700','1800','1900','2000','2100','2200','2300','2400','2500','2600','2700','2800','2900','3000','3100','3200','3300','3400','3500','3600','3700','3800','3900','4000']398 else:399 masses = ['800','900','1000','1100','1200','1300','1400','1500','1600','1700','1800','1900','2000','2100','2200','2300','2400','2500','2700','2800','2900','3000','3100','3200','3300','3400','3500','3600','3700','3800','3900','4000']400 401 for mass in masses:402 if (wprime != 'ModRight'):403 Histos['Wprime' + mass + wprime+sys+btaglabel+'_'+Chan].SetName(chan+"invmass_"+btags+"__wp"+mass+suffix)404 Histos['Wprime' + mass + wprime+sys+btaglabel+'_'+Chan].SetTitle(chan+"invmass_"+btags+"__wp"+mass+suffix)405 Histos['Wprime' + mass + wprime+sys+btaglabel+'_'+Chan].Rebin(REBIN)406 Histos['Wprime' + mass + wprime+sys+btaglabel+'_'+Chan].Write()407 else:408 Histos['Wprime' + mass + 'Right'+sys+btaglabel+'_'+Chan].SetName(chan+"invmass_"+btags+"__wp"+mass+suffix)409 Histos['Wprime' + mass + 'Right'+sys+btaglabel+'_'+Chan].SetTitle(chan+"invmass_"+btags+"__wp"+mass+suffix)410 Histos['Wprime' + mass + 'Right'+sys+btaglabel+'_'+Chan].Rebin(REBIN)411 Histos['Wprime' + mass + 'Right'+sys+btaglabel+'_'+Chan].Write()412 413 414List_DataBgEl_RightWprime = copy.copy(List_DataEl) 415List_DataBgEl_RightWprime.extend(List_Bg) 416List_DataBgEl_RightWprime.extend(List_Right) 417List_DataBgMu_RightWprime = copy.copy(List_DataMu) 418List_DataBgMu_RightWprime.extend(List_Bg) 419List_DataBgMu_RightWprime.extend(List_Right) 420btaglist = ['ge1btags','ex1btags','ex2btags']421#btaglist = ['ge1btags']422#btaglist = ['ex1btags','ex2btags']423chanlist = ['muon','electron']424wprimelist = ['Right']425save = 'mWprime_Limits'426scaleWJets = False427options = ['_Final']428for opt in options:429 loadHistos(opt)430 for btags in btaglist:431 for channel in chanlist:432 for wprime in wprimelist:433 f = TFile(indir+"RootFiles_For2DLimits_scale/"+channel+"_"+save+"_Wprime"+wprime+opt+"_Histos-"+btags+".root","RECREATE")434 f.cd() 435 if (channel=='electron'): makeHistos(channel, save, wprime, btags, List_DataBgEl_RightWprime)436 if (channel=='muon'): makeHistos(channel, save, wprime, btags, List_DataBgMu_RightWprime)437 print '-------------------------------------'438 print '^^^^',439 print opt,440 print '^^^^',441 print btags,442 print '^^^^',443 print channel,444 print '^^^^',445 print wprime,446 print '^^^^'...

Full Screen

Full Screen

aboutDialog.py

Source:aboutDialog.py Github

copy

Full Screen

1"""About Dialog for IDLE2"""3from Tkinter import *4import os5from idlelib import textView6from idlelib import idlever7class AboutDialog(Toplevel):8 """Modal about dialog for idle9 """10 def __init__(self,parent,title):11 Toplevel.__init__(self, parent)12 self.configure(borderwidth=5)13 self.geometry("+%d+%d" % (parent.winfo_rootx()+30,14 parent.winfo_rooty()+30))15 self.bg = "#707070"16 self.fg = "#ffffff"17 self.CreateWidgets()18 self.resizable(height=FALSE, width=FALSE)19 self.title(title)20 self.transient(parent)21 self.grab_set()22 self.protocol("WM_DELETE_WINDOW", self.Ok)23 self.parent = parent24 self.buttonOk.focus_set()25 self.bind('<Return>',self.Ok) #dismiss dialog26 self.bind('<Escape>',self.Ok) #dismiss dialog27 self.wait_window()28 def CreateWidgets(self):29 frameMain = Frame(self, borderwidth=2, relief=SUNKEN)30 frameButtons = Frame(self)31 frameButtons.pack(side=BOTTOM, fill=X)32 frameMain.pack(side=TOP, expand=TRUE, fill=BOTH)33 self.buttonOk = Button(frameButtons, text='Close',34 command=self.Ok)35 self.buttonOk.pack(padx=5, pady=5)36 #self.picture = Image('photo', data=self.pictureData)37 frameBg = Frame(frameMain, bg=self.bg)38 frameBg.pack(expand=TRUE, fill=BOTH)39 labelTitle = Label(frameBg, text='IDLE', fg=self.fg, bg=self.bg,40 font=('courier', 24, 'bold'))41 labelTitle.grid(row=0, column=0, sticky=W, padx=10, pady=10)42 #labelPicture = Label(frameBg, text='[picture]')43 #image=self.picture, bg=self.bg)44 #labelPicture.grid(row=1, column=1, sticky=W, rowspan=2,45 # padx=0, pady=3)46 byline = "Python's Integrated DeveLopment Environment" + 5*'\n'47 labelDesc = Label(frameBg, text=byline, justify=LEFT,48 fg=self.fg, bg=self.bg)49 labelDesc.grid(row=2, column=0, sticky=W, columnspan=3, padx=10, pady=5)50 labelEmail = Label(frameBg, text='email: idle-dev@python.org',51 justify=LEFT, fg=self.fg, bg=self.bg)52 labelEmail.grid(row=6, column=0, columnspan=2,53 sticky=W, padx=10, pady=0)54 labelWWW = Label(frameBg, text='www: http://www.python.org/idle/',55 justify=LEFT, fg=self.fg, bg=self.bg)56 labelWWW.grid(row=7, column=0, columnspan=2, sticky=W, padx=10, pady=0)57 Frame(frameBg, borderwidth=1, relief=SUNKEN,58 height=2, bg=self.bg).grid(row=8, column=0, sticky=EW,59 columnspan=3, padx=5, pady=5)60 labelPythonVer = Label(frameBg, text='Python version: ' + \61 sys.version.split()[0], fg=self.fg, bg=self.bg)62 labelPythonVer.grid(row=9, column=0, sticky=W, padx=10, pady=0)63 tkVer = self.tk.call('info', 'patchlevel')64 labelTkVer = Label(frameBg, text='Tk version: '+65 tkVer, fg=self.fg, bg=self.bg)66 labelTkVer.grid(row=9, column=1, sticky=W, padx=2, pady=0)67 py_button_f = Frame(frameBg, bg=self.bg)68 py_button_f.grid(row=10, column=0, columnspan=2, sticky=NSEW)69 buttonLicense = Button(py_button_f, text='License', width=8,70 highlightbackground=self.bg,71 command=self.ShowLicense)72 buttonLicense.pack(side=LEFT, padx=10, pady=10)73 buttonCopyright = Button(py_button_f, text='Copyright', width=8,74 highlightbackground=self.bg,75 command=self.ShowCopyright)76 buttonCopyright.pack(side=LEFT, padx=10, pady=10)77 buttonCredits = Button(py_button_f, text='Credits', width=8,78 highlightbackground=self.bg,79 command=self.ShowPythonCredits)80 buttonCredits.pack(side=LEFT, padx=10, pady=10)81 Frame(frameBg, borderwidth=1, relief=SUNKEN,82 height=2, bg=self.bg).grid(row=11, column=0, sticky=EW,83 columnspan=3, padx=5, pady=5)84 idle_v = Label(frameBg, text='IDLE version: ' + idlever.IDLE_VERSION,85 fg=self.fg, bg=self.bg)86 idle_v.grid(row=12, column=0, sticky=W, padx=10, pady=0)87 idle_button_f = Frame(frameBg, bg=self.bg)88 idle_button_f.grid(row=13, column=0, columnspan=3, sticky=NSEW)89 idle_about_b = Button(idle_button_f, text='README', width=8,90 highlightbackground=self.bg,91 command=self.ShowIDLEAbout)92 idle_about_b.pack(side=LEFT, padx=10, pady=10)93 idle_news_b = Button(idle_button_f, text='NEWS', width=8,94 highlightbackground=self.bg,95 command=self.ShowIDLENEWS)96 idle_news_b.pack(side=LEFT, padx=10, pady=10)97 idle_credits_b = Button(idle_button_f, text='Credits', width=8,98 highlightbackground=self.bg,99 command=self.ShowIDLECredits)100 idle_credits_b.pack(side=LEFT, padx=10, pady=10)101 def ShowLicense(self):102 self.display_printer_text('About - License', license)103 def ShowCopyright(self):104 self.display_printer_text('About - Copyright', copyright)105 def ShowPythonCredits(self):106 self.display_printer_text('About - Python Credits', credits)107 def ShowIDLECredits(self):108 self.display_file_text('About - Credits', 'CREDITS.txt', 'iso-8859-1')109 def ShowIDLEAbout(self):110 self.display_file_text('About - Readme', 'README.txt')111 def ShowIDLENEWS(self):112 self.display_file_text('About - NEWS', 'NEWS.txt')113 def display_printer_text(self, title, printer):114 printer._Printer__setup()115 text = '\n'.join(printer._Printer__lines)116 textView.view_text(self, title, text)117 def display_file_text(self, title, filename, encoding=None):118 fn = os.path.join(os.path.abspath(os.path.dirname(__file__)), filename)119 textView.view_file(self, title, fn, encoding)120 def Ok(self, event=None):121 self.destroy()122if __name__ == '__main__':123 # test the dialog124 root = Tk()125 def run():126 from idlelib import aboutDialog127 aboutDialog.AboutDialog(root, 'About')128 Button(root, text='Dialog', command=run).pack()...

Full Screen

Full Screen

split_data.py

Source:split_data.py Github

copy

Full Screen

1import numpy as np2import random3import os4import sys5import shutil6from PIL import Image, ImageDraw7"""8划分数据集:训练集、验证集、测试集9数据的类型,所有做好标签的数据都在一个文件夹中,部分代码可以适用于一遍生成样本,一遍分类10步骤:11 首先要生成三个文件夹:train、val、test12 标签文件:train_label.txt val_label.txt test_label.txt13"""14def split_bg_data_3():15 """16 将背景图拆分成Train、Val、Test17 :return:18 """19 choices = {0: "train", 1: "val", 2: "test"}20 origin_path = r"F:\2.Dataset\Yellow\bg\background"21 # bg_linshi_path = r"F:\2.Dataset\Yellow\bg\bg_split" # 7 1.5 1.522 bg_linshi_path = r"F:\2.Dataset\Yellow\Minions_Test\bg" # 7 1.5 1.523 # 1.24 bg_img_list = []25 for i, bg_name in enumerate(os.listdir(origin_path)):26 # 拆分数据集27 bg_img_list.append(bg_name)28 print(len(bg_img_list))29 # res1 = random.sample(bg_img_list, int(len(bg_img_list) * 0.7))30 res1 = random.sample(bg_img_list, 1000)31 print(len(res1))32 for img_name in res1:33 shutil.move(os.path.join(origin_path, img_name), os.path.join(bg_linshi_path, choices[0], img_name))34 # 2.35 bg_img_list1 = []36 for i, bg_name in enumerate(os.listdir(origin_path)):37 # 拆分数据集38 bg_img_list1.append(bg_name)39 print(len(bg_img_list1))40 # res2 = random.sample(bg_img_list1, int(len(bg_img_list1) * 0.5))41 res2 = random.sample(bg_img_list1, 1000)42 print(bg_img_list1)43 for img_name in res2:44 shutil.move(os.path.join(origin_path, img_name), os.path.join(bg_linshi_path, choices[1], img_name))45 # 3.46 bg_img_list2 = []47 for i, bg_name in enumerate(os.listdir(origin_path)):48 # 拆分数据集49 bg_img_list2.append(bg_name)50 # res3 = random.sample(bg_img_list2, int(len(bg_img_list2)))51 res3 = random.sample(bg_img_list2, 1000)52 print(res3)53 for img_name in res3:54 shutil.move(os.path.join(origin_path, img_name), os.path.join(bg_linshi_path, choices[2], img_name))55def add_positive_negative():56 """57 将背景贴上小黄人,制作成positive和negative58 :return:59 """60 choices = {0: "train", 1: "val", 2: "test"}61 minions_path = r"F:\2.Dataset\Yellow\yellow"62 root = r"F:\2.Dataset\Yellow\Minions"63 for i in choices:64 if not os.path.exists(f"{root}/{choices[i]}"):65 os.mkdir(f"{root}/{choices[i]}")66 bg_path = fr"F:\2.Dataset\Yellow\bg\bg_split\{choices[i]}"67 # bg_split = fr"F:\2.Dataset\Yellow\bg\bg_split\{choices[0]}"68 save_path = f"{root}/{choices[i]}"69 label_path = fr"F:\2.Dataset\Yellow\Minions/{choices[i]}_label.txt"70 length = len(os.listdir(bg_path)) * len(os.listdir(minions_path))71 with open(label_path, "w") as f:72 count = 073 for bg_name in os.listdir(bg_path):74 # 1. 小黄人75 num = random.randint(1, 20)76 # print(num)77 image = Image.open(f"{minions_path}/{num}.png")78 # new_len = random.randint(100, 130)79 # image_resize = image.resize((new_len, new_len))80 # new_w, new_h = random.randint(100, 128), random.randint(100, 128)81 new_w, new_h = random.randint(60, 128), random.randint(60, 128)82 image_resize = image.resize((new_w, new_h))83 image_roate = image_resize.rotate(random.randint(-45, 45)) # 旋转84 # image_roate.show()85 # 2.背景图,先进行224的缩放,然后贴小黄人,这样坐标就统一了86 img_bg = Image.open(f"{bg_path}/{bg_name}")87 img_bg = img_bg.convert("RGBA")88 img_bg = img_bg.resize((224, 224))89 img_bg.save(f"{save_path}/{count}_bg.png") # 将图片进行保存90 f.write(f"{count}_bg.png {0} {0} {0} {0} {0}\n")91 f.flush()92 # r, g, b, a = image_roate.split() # 路径拆分93 # 3. 生成随机粘贴坐标94 paste_x, paste_y = random.randint(0, 224 - new_w), random.randint(0, 224 - new_h)95 # paste_x, paste_y = random.randint(0, 224 - new_len), random.randint(0, 224 - new_len)96 # print(paste_x, paste_y)97 img_bg.paste(image_roate, (paste_x, paste_y), mask=image_roate) # 把透明通道粘贴上98 # paste_x2 = paste_x + new_len99 # paste_y2 = paste_y + new_len100 paste_x2 = paste_x + new_w101 paste_y2 = paste_y + new_h102 img_bg.save(f"{save_path}/{count}.png")103 f.write(f"{count}.png {1} {paste_x} {paste_y} {paste_x2} {paste_y2}\n")104 f.flush()105 count += 1106 # 加入进度条107 sys.stdout.write("\r >> processing {}/{}".format((count), length))108 sys.stdout.flush()109 sys.stdout.write("\n")110 sys.stdout.flush()111if __name__ == '__main__':112 # 拆分背景图成Train、Val、Test113 # split_bg_data_3()114 # pass...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run fMBT automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful