diff --git a/Configurations/HWWSemiLepHighMass/Gen2016_v7/aliases_medmass.py b/Configurations/HWWSemiLepHighMass/Gen2016_v7/aliases_medmass.py new file mode 100644 index 0000000000..46732e2d00 --- /dev/null +++ b/Configurations/HWWSemiLepHighMass/Gen2016_v7/aliases_medmass.py @@ -0,0 +1,1004 @@ +import os +import csv +import copy +import inspect +import numpy as np + +configurations = os.path.realpath(inspect.getfile(inspect.currentframe())) # this file +configurations = os.path.dirname(configurations) # Full2016v7 +configurations = os.path.dirname(configurations) # HM +configurations = os.path.dirname(configurations) # Configurations + +#aliases = {} + +# imported from samples.py: +# samples, signals + +mc = [skey for skey in samples if skey not in ('FAKE', 'DATA')] +mc_deep =[skey for skey in samples if skey not in ['DY', 'top', 'Wjets', 'Vg', 'VgS','VZ', 'FAKE', 'DATA', 'VVV', 'ZH_htt', 'WH_htt', 'ggH_htt', 'qqH_htt']] +wjets = [skey for skey in samples if skey.startswith('Wjets')] + +eleWP = 'mva_90p_Iso2016' +muWP = 'cut_Tight80x' + +aliases['DNN_isVBF_OTF'] = { + 'class': 'DNNprodSemi', + 'linesToAdd':[ + 'gSystem->Load("libLatinoAnalysisMultiDraw.so")', + 'gSystem->Load("libDNNEvaluator.so")', + '.L %s/src/PlotsConfigurations/Configurations/HighMass/DNN_prod_semi.cc+' % os.getenv('CMSSW_BASE'), + ], +} + +aliases['mjjGen_max'] = { + 'linesToAdd' : ['.L %s/patches/GetGenObservables.cc+' % configurations], + 'class' : 'GetGenObservables', + 'args': 'mjjmax', +} + +#aliases['btagJetPt_resolv'] = { + # 'linesToAdd': [ + # '.L %s/src/PlotsConfigurations/Configurations/HWWSemiLepHighMass/btagJetPt.cc+' % os.getenv('CMSSW_BASE') + # ], + # 'class': 'BtagJetPt', + # 'args': ('resolved', '2016') +#} +#aliases['btagJetPt_boost'] = { + # 'linesToAdd': [ + # '.L %s/src/PlotsConfigurations/Configurations/HWWSemiLepHighMass/btagJetPt.cc+' % os.getenv('CMSSW_BASE') + # ], + # 'class': 'BtagJetPt', + # 'args': ('boosted', '2016') +#} + +aliases['mjjGen_OTF'] = { + 'linesToAdd': ['.L %s/src/PlotsConfigurations/Configurations/HighMass/HMvars_mjjgen.cc+' % os.getenv('CMSSW_BASE')], + 'class': 'HMvarsmjjgen', + 'samples': [skey for skey in samples if "QQHSBI" in skey or skey in ['WW', 'qqWWqq', 'WW2J', 'DYveto']] +} + +aliases['bWP'] = { + 'expr': '0.2217' +} +aliases['tau21WP'] = { + 'expr': '0.4' +} +aliases['LepWPCut'] = { + 'expr': '(Lepton_isTightElectron_'+eleWP+'[0] > 0.5 \ + || Lepton_isTightMuon_'+muWP+'[0] > 0.5)' +} +aliases['Lep1WPCut'] = { + 'expr': '(Alt$(Lepton_isTightElectron_'+eleWP+'[1], 0) > 0.5 \ + || Alt$(Lepton_isTightMuon_'+muWP+'[1], 0) > 0.5)' +} +aliases['nTightLep'] = { + 'expr': '(Sum$(Lepton_isTightElectron_'+eleWP+') + Sum$(Lepton_isTightMuon_'+muWP+'))', +} + + +aliases['resolvHiggsMT'] = { + # 'expr': 'HM_Hlnjj_mt' + 'expr': 'TMath::Sqrt( 2*Lepton_pt[0]*PuppiMET_pt \ + *( 1-TMath::Cos(Lepton_phi[0]-PuppiMET_phi) ) )' +} + +aliases['HM_Hlnjj_MT'] = { + # 'expr': 'HM_Hlnjj_mt' + 'expr': 'TMath::Sqrt( 2*HM_Wlep_pt_Puppi*HM_Whad_pt \ + *( 1-TMath::Cos(HM_Wlep_phi_Puppi-HM_Whad_phi) ) )' +} + +#aliases['WptOvFat_nocut'] = { +# # 'expr': 'HM_Hlnjj_mt' +# 'expr': ' TMath::Sqrt( 2*HM_Wlep_pt_Puppi*HM_Whad_pt)' +#} +# +# +#aliases['WptOvHak4M_nocut'] = { +# 'expr': 'min(HM_Wlep_pt_Puppi,HM_Whad_pt)/Hlnjj_mass_HM' +#} +# + +aliases['idxCleanFatJetW'] = { + 'expr': '(HM_idxWfat_noTau21Cut*(HM_idxWfat_noTau21Cut>=0) + 999*(HM_idxWfat_noTau21Cut<0))' +} + +aliases['tau21Cut'] = { + 'expr': '(Alt$(CleanFatJet_tau21[0], 1) < tau21WP)' +} + +aliases['boosted'] = { + 'expr': 'PuppiMET_pt > 40 \ + && Alt$(HM_CleanFatJetPassMBoosted_pt[0], 0) > 200 \ + && Alt$(HM_CleanFatJetPassMBoosted_WptOvHfatM[0], 0) > 0.4 \ + && Alt$(HM_CleanFatJetPassMBoosted_tau21[0], 999) < tau21WP[0] \ + && Alt$(HM_CleanFatJetPassMBoosted_mass[0], 0) > 40 \ + && abs(Alt$(HM_CleanFatJetPassMBoosted_eta[0], 999)) < 2.4' +} +aliases['boostedNoTau21'] = { + 'expr': 'PuppiMET_pt > 40 \ + && idxCleanFatJetW != 999 \ + && Alt$(CleanFatJet_pt[idxCleanFatJetW], 0) > 200 \ + && Alt$(CleanFatJet_pt[idxCleanFatJetW], 0) / HM_HlnFatMass_noTau21Cut > 0.4 \ + && HM_HlnFatMass_noTau21Cut > 0 && HM_Wlep_pt_Puppi / HM_HlnFatMass_noTau21Cut > 0.4 \ + && Alt$(CleanFatJet_mass[idxCleanFatJetW], 0) > 40 \ + && Alt$(CleanFatJet_eta[idxCleanFatJetW], 999) < 2.4' +} + +aliases['resolved'] = { + 'expr': '!boosted[0] \ + && PuppiMET_pt > 30 \ + && HM_WptOvHak4M > 0.35 \ + && resolvHiggsMT > 60 \ + && HM_Whad_pt > 30' +} + +aliases['boostedSignalWMass'] = { + 'expr': '(65 < Alt$(CleanFatJet_mass[0], 0) \ + && Alt$(CleanFatJet_mass[0], 999) < 105)' +} +aliases['boostedSignalWMassNoTau21'] = { + 'expr': '(65 < Alt$(CleanFatJet_mass[idxCleanFatJetW], 0) \ + && Alt$(CleanFatJet_mass[idxCleanFatJetW], 999) < 105)' +} + +aliases['resolvedSignalWMass'] = { + 'expr': '(65 < HM_Whad_mass && HM_Whad_mass < 105)' +} + +aliases['boostedSidebandWMass'] = { + 'expr': '(40 < Alt$(CleanFatJet_mass[0], 0) \ + && Alt$(CleanFatJet_mass[0], 999) < 250)' +} +aliases['boostedSidebandWMassNoTau21'] = { + 'expr': '(40 < Alt$(CleanFatJet_mass[idxCleanFatJetW], 0) \ + && Alt$(CleanFatJet_mass[idxCleanFatJetW], 999) < 250)' +} + +aliases['lowBoostedSidebandWMass'] = { + 'expr': '(40 < Alt$(HM_CleanFatJetPassMBoosted_mass[0], 0) \ + && Alt$(HM_CleanFatJetPassMBoosted_mass[0], 999) < 65)' +} +aliases['highBoostedSidebandWMass'] = { + 'expr': '(105 < Alt$(HM_CleanFatJetPassMBoosted_mass[0], 0) \ + && Alt$(HM_CleanFatJetPassMBoosted_mass[0], 999) < 250)' +} + + +aliases['resolvedSidebandWMass'] = { + 'expr': '(40 < HM_Whad_mass && HM_Whad_mass < 250)' +} + +aliases['lowResolvedSidebandWMass'] = { + 'expr': '(40 < HM_Whad_mass && HM_Whad_mass < 65)' +} +aliases['highResolvedSidebandWMass'] = { + 'expr': '(105 < HM_Whad_mass && HM_Whad_mass < 250)' +} + + + + + + +aliases['resolvedQCDcr'] = { + 'expr': 'resolvedSignalWMass \ + && HM_Wlep_mt < 50 && 0 < resolvHiggsMT \ + && resolvHiggsMT < 60 && HM_WptOvHak4M < 0.35' +} +aliases['resolvedQCDSR'] = { + 'expr': '!boosted[0] \ + && resolvedSignalWMass \ + && PuppiMET_pt > 30 \ + && HM_WptOvHak4M > 0.35 \ + && resolvHiggsMT > 60 \ + && HM_Whad_pt > 30' +} +# boostedQCDcr not possible RN since boosted W candidate always fulfills WptOvHfatM > 0.4 + + +aliases['tau21DDT'] = { + 'expr': '( Alt$(CleanFatJet_tau21[idxCleanFatJetW], -999) + 0.080 * TMath::Log( Alt$(CleanFatJet_mass[idxCleanFatJetW]*CleanFatJet_mass[idxCleanFatJetW], 0) / Alt$(CleanFatJet_pt[idxCleanFatJetW], 1) ) )' +} +# smaller angle is: a-b - (a-b > 3.1416)*2*3.1416 + (a-b < -3.1416)*2*3.1416 +aliases['dPhi_WW_boosted'] = { + 'expr': '( HM_Wlep_phi_Puppi - Alt$(HM_CleanFatJetPassMBoosted_phi[0], 0)\ +- (HM_Wlep_phi_Puppi - Alt$(HM_CleanFatJetPassMBoosted_phi[0], 0) > 3.1416)*2*3.1416\ ++ (HM_Wlep_phi_Puppi - Alt$(HM_CleanFatJetPassMBoosted_phi[0], 0) < -3.1416)*2*3.1416 )', +} +aliases['dPhi_WW_resolved'] = { + 'expr': '( HM_Wlep_phi_Puppi - HM_Whad_phi\ + - (HM_Wlep_phi_Puppi - HM_Whad_phi > 3.1416)*2*3.1416 \ + + (HM_Wlep_phi_Puppi - HM_Whad_phi < -3.1416)*2*3.1416 )', +} +aliases['dPhi_LNu'] = { + 'expr': '( Lepton_phi[0] - PuppiMET_phi\ + - (Lepton_phi[0] - PuppiMET_phi > 3.1416)*2*3.1416 \ + + (Lepton_phi[0] - PuppiMET_phi < -3.1416)*2*3.1416 )', +} + +aliases['deltaR'] = { + 'expr' : 'TMath::Sqrt((HM_Whad_phi - Alt$(CleanFatJet_phi[0],0))*(HM_Whad_phi - Alt$(CleanFatJet_phi[0],0)) + (HM_Whad_eta - Alt$(CleanFatJet_eta[0],0))*(HM_Whad_eta - Alt$(CleanFatJet_eta[0],0))) ' +} + +aliases['mass_HIGGS_FAT'] = { + 'linesToAdd':['.L %s/src/PlotsConfigurations/Configurations/HWWSemiLepHighMass/getResBoo.cc+' % os.getenv('CMSSW_BASE')], + 'class': 'getResBoo', + 'args': 0 +} + +aliases['HvOverFat'] = { + 'linesToAdd':['.L %s/src/PlotsConfigurations/Configurations/HWWSemiLepHighMass/getResBoo.cc+' % os.getenv('CMSSW_BASE')], + 'class': 'getResBoo', + 'args': 1 +} + +aliases['mass_HIGGS_JJ'] = { + 'linesToAdd':['.L %s/src/PlotsConfigurations/Configurations/HWWSemiLepHighMass/getResBoo.cc+' % os.getenv('CMSSW_BASE')], + 'class': 'getResBoo', + 'args': 2 +} + +aliases['HvOverJJ'] = { + 'linesToAdd':['.L %s/src/PlotsConfigurations/Configurations/HWWSemiLepHighMass/getResBoo.cc+' % os.getenv('CMSSW_BASE')], + 'class': 'getResBoo', + 'args': 3 +} + +#aliases['DeltaR_jj'] = { +# 'linesToAdd':['.L %s/src/PlotsConfigurations/Configurations/HWWSemiLepHighMass/DeltaR_jj.cc+' % os.getenv('CMSSW_BASE')], +# 'class': 'DeltaR_jj', +#} + + +aliases['HvOverLEP'] = { + 'linesToAdd':['.L %s/src/PlotsConfigurations/Configurations/HWWSemiLepHighMass/getResBoo.cc+' % os.getenv('CMSSW_BASE')], + 'class': 'getResBoo', + 'args': 4 +} + +aliases['cohe_jet'] ={ + 'expr': 'deltaR < 1 \ + && nCleanFatJet >= 1 \ + && nCleanJet >= 2 \ + && CleanJet_pt[0] > 30 \ + && CleanJet_pt[1] > 30 \ + && PuppiMET_pt[0] > 40 \ + && Alt$(CleanFatJet_pt[idxCleanFatJetW], 0) > 200 \ + && Alt$(CleanFatJet_eta[idxCleanFatJetW], 999) < 2.4' +} + + +aliases['fat_jet'] ={ + 'expr': 'nCleanFatJet >= 1 ' +} + +#aliases['DeltaR_jj'] ={ +# 'expr' : 'TMath::Sqrt((Alt$(CleanJet_phi[HM_idx_j1], -1) - Alt$(CleanJet_phi[HM_idx_j2], -1))*(Alt$(CleanJet_phi[HM_idx_j1], -1) - Alt$(CleanJet_phi[HM_idx_j2], -1)) + (Alt$(CleanJet_eta[HM_idx_j1],-1) - Alt$(CleanJet_eta[HM_idx_j2], -1))*(Alt$(CleanJet_eta[HM_idx_j1], -1) - Alt$(CleanJet_eta[HM_idx_j2], -1)))' +#} +# +aliases['DeltaR_jj_Lpt'] ={ + 'expr' : 'TMath::Sqrt((CleanJet_phi[0] - CleanJet_phi[1])*(CleanJet_phi[0] - CleanJet_phi[1]) + (CleanJet_eta[0] - CleanJet_eta[1])*(CleanJet_eta[0] - CleanJet_eta[1]))' +} + + +#aliases['boosted_nocut_tau_up'] = { +# 'expr': 'PuppiMET_pt > 40 \ +# && Alt$(CleanFatJet_pt[0], 0) > 200 \ +# && FatJet_deepTag_WvsQCD[CleanFatJet_jetIdx[0]] > 0.960 \ +# && Alt$(CleanFatJet_eta[0], 999) < 2.4' +#} + +#aliases['boosted_nocut_tau_down'] = { +# 'expr': 'PuppiMET_pt > 40 \ +# && Alt$(CleanFatJet_pt[0], 0) > 200 \ +# && FatJet_deepTag_WvsQCD[CleanFatJet_jetIdx[0]] < 0.960 \ +# && Alt$(CleanFatJet_eta[0], 999) < 2.4' +#} + +aliases['boosted_nocut'] = { + 'expr': 'PuppiMET_pt > 40 \ + && Alt$(CleanFatJet_pt[0], 0) > 200 \ + && Alt$(CleanFatJet_eta[0], 999) < 2.4' +} + + #&& FatJet_deepTag_WvsQCD[CleanFatJet_jetIdx[0]] > 0.960 \ +#aliases['boosted_nocut_do'] = { +# 'expr': 'PuppiMET_pt > 40 \ +# && Alt$(CleanFatJet_pt[0], 0) > 200 \ +# && FatJet_deepTag_WvsQCD[CleanFatJet_jetIdx[0]] > 0.960 \ +# && HvOverFat < 0.3 \ +# && Alt$(CleanFatJet_eta[0], 999) < 2.4' +#} + +aliases['boosted_nocut_res'] = { + 'expr': 'PuppiMET_pt > 40 \ + && Alt$(CleanFatJet_pt[0], 0) > 200 \ + && FatJet_deepTag_WvsQCD[CleanFatJet_jetIdx[0]] > 0.960 \ + && Alt$(CleanFatJet_eta[0], 999) < 2.4' +} +aliases['resolved_nocut'] = { + 'expr': 'nCleanJet >= 2 \ + && HM_Whad_mass > 0 \ + && CleanJet_pt[0] > 30 \ + && PuppiMET_pt[0] > 30 \ + && CleanJet_pt[1] > 30' +} + + + +#aliases['boosted_fat_jet'] = { +# 'expr': 'PuppiMET_pt > 40 \ +# && Alt$(CleanFatJet_pt[0], 0) > 200 \ +# && FatJet_deepTag_WvsQCD[CleanFatJet_jetIdx[0]] > 0.960 \ +# && HvOverFat > 0.4 \ +# && Alt$(CleanFatJet_eta[0], 999) < 2.4' +#} + +aliases['two_jet_res'] ={ + 'expr': 'nCleanJet >= 2 \ + && HM_idx_j1 >= 0 \ + && !boosted_nocut_res[0] \ + && PuppiMET_pt[0] > 30 \ + && HM_idx_j2 >= 0 \ + && HM_Hlnjj_MT[0] > 60 \ + && HvOverJJ[0] > 0.4' +} + +aliases['LHEPartWlepPt'] = { + 'linesToAdd': ['.L %s/HWWSemiLepHighMass/LHEPartWlepPt.cc+' % configurations], + 'class': 'LHEPartWlepPt', + 'samples': 'Wjets' +} +data = np.genfromtxt(os.getenv('CMSSW_BASE')+'/src/LatinoAnalysis/Gardener/python/data/ewk/kewk_w.dat', skip_header=2, skip_footer=7) + +weight_string = "(" +uncert_string = "(" +for row in data: + low = row[0] + high = row[1] + weight = (1+row[2]) + ucert = row[3] + + weight_string+="({}0 && Gen_ZGstar_mass < 4 )', + 'samples': 'VgS' +} +aliases['gstarHigh'] = { + 'expr': '( Gen_ZGstar_mass <0 || Gen_ZGstar_mass > 4 )', + 'samples': 'VgS' +} + + + +aliases['GenLHE'] = { +'expr': '(Sum$(LHEPart_pdgId == 21) == 0)', +'samples': [x for x in samples if x in ['qqWWqq', 'WW'] or 'QQHSBI' in x] +} + + + + +#&& ((CleanJet_phi[CleanJet_jetIdx] - Alt$(CleanFatJet_phi[0],999))*(CleanJet_phi[CleanJet_jetIdx] - Alt$(CleanFatJet_phi[0],999)) + (CleanJet_eta[CleanJet_jetIdx] - Alt$(CleanFatJet_eta[0],999))*(CleanJet_eta[CleanJet_jetIdx] - Alt$(CleanFatJet_eta[0],999)))> 0.64\ +#&& ((CleanJet_phi[CleanJet_jetIdx] - Alt$(CleanFatJet_phi[0],999))*(CleanJet_phi[CleanJet_jetIdx] - Alt$(CleanFatJet_phi[0],999)) + (CleanJet_eta[CleanJet_jetIdx] - Alt$(CleanFatJet_eta[0],999))*(CleanJet_eta[CleanJet_jetIdx] - Alt$(CleanFatJet_eta[0],999)))> 0.64\ +#- Alt$(CleanFatJet_phi[0],999))*(CleanJet_phi[CleanJet_jetIdx] - Alt$(CleanFatJet_phi[0],0)) + (CleanJet_eta[CleanJet_jetIdx] - Alt$(CleanFatJet_eta[0]))*(CleanJet_eta[CleanJet_jetIdx] - Alt$(CleanFatJet_eta[0]))) > 0.8 \ +# # B-Stuff +vetoThreshold = 20 +reqThreshold = 30 +boostedJetBVetoCondition = '(\ +CleanJet_pt[CleanJetNotFat_jetIdx] > {threshold} \ +&& abs(CleanJet_eta[CleanJetNotFat_jetIdx]) < 2.5 \ +)' +resolvedJetBVetoCondition = '(\ +HM_idx_j1 >= 0 && HM_idx_j2 >= 0\ +&& CleanJet_pt > {threshold} && abs(CleanJet_eta) < 2.5 \ +&& CleanJet_jetIdx != CleanJet_jetIdx[HM_idx_j1] \ +&& CleanJet_jetIdx != CleanJet_jetIdx[HM_idx_j2] \ +)' + +bTagBoosted = '(Sum$(Jet_btagDeepB[CleanJet_jetIdx[CleanJetNotFat_jetIdx]] > bWP[0] \ + && {0}) == 0)'.format(boostedJetBVetoCondition) +bTagResolved = '(Sum$(Jet_btagDeepB[CleanJet_jetIdx] > bWP[0] && {0}) == 0)'\ + .format(resolvedJetBVetoCondition) + +#bTemplate = '((boosted_fat_jet[0]*{0}) || ( two_jet_res[0]*{1}))'.format(bTagBoosted, bTagResolved) +bTemplate = '((boosted_nocut_res[0]*{0}) || ( two_jet_res[0]*{1}))'.format(bTagBoosted, bTagResolved) + +aliases['bVeto'] = { + 'expr': bTemplate.format(threshold=vetoThreshold) +} +aliases['bReq'] = { + 'expr': '!'+bTemplate.format(threshold=reqThreshold) +} + +bSF = 'TMath::Exp(Sum$(TMath::Log( \ + {0} * Jet_btagSF_deepcsv_shape[CleanJet_jetIdx] + !{0} * 1 \ + )))'.format('(CleanJet_pt > {threshold} && abs(CleanJet_eta) < 2.5)') + +aliases['bVetoSF'] = { + 'expr': bSF.format(threshold=vetoThreshold), + 'samples': mc +} +aliases['bReqSF'] = { + 'expr': bSF.format(threshold=reqThreshold), + 'samples': mc +} + +aliases['btagSF'] = { + 'expr': 'bVeto*bVetoSF + bReq*bReqSF + (!bVeto && !bReq)', + 'samples': mc +} + +for shift in ['jes','lf','hf','lfstats1','lfstats2','hfstats1','hfstats2','cferr1','cferr2']: + + for targ in ['bVeto', 'bReq']: + alias = aliases['%sSF%sup' % (targ, shift)] = copy.deepcopy(aliases['%sSF' % targ]) + alias['expr'] = alias['expr'].replace('btagSF_deepcsv_shape', 'btagSF_deepcsv_shape_up_%s' % shift) + + alias = aliases['%sSF%sdown' % (targ, shift)] = copy.deepcopy(aliases['%sSF' % targ]) + alias['expr'] = alias['expr'].replace('btagSF_deepcsv_shape', 'btagSF_deepcsv_shape_down_%s' % shift) + + + aliases['btagSF%sup' % shift] = { + 'expr': 'bVeto*bVetoSF{shift}up + bReq*bReqSF{shift}up + (!bVeto && !bReq)'\ + .format(shift = shift), + 'samples': mc + } + aliases['btagSF%sdown' % shift] = { + 'expr': 'bVeto*bVetoSF{shift}down + bReq*bReqSF{shift}down + (!bVeto && !bReq)'\ + .format(shift = shift), + 'samples': mc + } + + + + + +# https://twiki.cern.ch/twiki/bin/viewauth/CMS/JetWtagging +aliases['WtagSF'] = { + 'expr': '(boostedNoTau21[0] * (1.0*tau21Cut[0] + 0.96*!tau21Cut[0]) + (1-boostedNoTau21[0]))', + 'samples': mc +} +aliases['SFWtagUp'] = { + 'expr': '(boostedNoTau21[0] * (1.06*tau21Cut[0] + 0.89*!tau21Cut[0]) + (1-boostedNoTau21[0]))', + 'samples': mc +} +aliases['SFWtagDown'] = { + 'expr': '(boostedNoTau21[0] * (0.94*tau21Cut[0] + 1.11*!tau21Cut[0]) + (1-boostedNoTau21[0]))', + 'samples': mc +} + + + + + + +aliases['LepWPSF'] = { + 'expr': '((Lepton_isTightElectron_'+eleWP+'[0] > 0.5) * Lepton_tightElectron_'+eleWP+'_TotSF[0] \ + + (Lepton_isTightMuon_'+muWP+'[0] > 0.5)*Lepton_tightMuon_'+muWP+'_TotSF[0])', + 'samples': mc +} +# # variations of tight lepton WP +aliases['SFweightEleUp'] = { + 'expr': '((TMath::Abs(Lepton_pdgId[0]) == 11)*(Lepton_tightElectron_'+eleWP+'_TotSF_Up[0]/Lepton_tightElectron_'+eleWP+'_TotSF[0]) + (TMath::Abs(Lepton_pdgId[0]) == 13))', + 'samples': mc +} +aliases['SFweightEleDown'] = { + 'expr': '((TMath::Abs(Lepton_pdgId[0]) == 11)*(Lepton_tightElectron_'+eleWP+'_TotSF_Down[0]/Lepton_tightElectron_'+eleWP+'_TotSF[0]) + (TMath::Abs(Lepton_pdgId[0]) == 13))', + 'samples': mc +} +aliases['SFweightMuUp'] = { + 'expr': '((TMath::Abs(Lepton_pdgId[0]) == 13)*(Lepton_tightMuon_'+muWP+'_TotSF_Up[0]/Lepton_tightMuon_'+muWP+'_TotSF[0]) + (TMath::Abs(Lepton_pdgId[0]) == 11))', + 'samples': mc +} +aliases['SFweightMuDown'] = { + 'expr': '((TMath::Abs(Lepton_pdgId[0]) == 13)*(Lepton_tightMuon_'+muWP+'_TotSF_Down[0]/Lepton_tightMuon_'+muWP+'_TotSF[0]) + (TMath::Abs(Lepton_pdgId[0]) == 11))', + 'samples': mc +} + + + + +# # PU jet Id SF +# puidSFSource = '%s/src/PlotsConfigurations/Configurations/patches/PUID_81XTraining_EffSFandUncties.root' % os.getenv('CMSSW_BASE') + +# aliases['PUJetIdSF'] = { +# 'linesToAdd': [ +# 'gSystem->AddIncludePath("-I%s/src");' % os.getenv('CMSSW_BASE'), +# '.L %s/src/PlotsConfigurations/Configurations/patches/pujetidsf_event_new.cc+' % os.getenv('CMSSW_BASE') +# ], +# 'class': 'PUJetIdEventSF', +# 'args': (puidSFSource, '2016', 'loose'), +# 'samples': mc +# } + + +aliases['PUJetIdSF'] = { + 'expr' : 'TMath::Exp(Sum$( \ + (Jet_jetId>=2 \ + && ( (Jet_electronIdx1 != Lepton_electronIdx[0]) || Jet_electronIdx1 < 0 ) \ + && ( (Jet_muonIdx1 != Lepton_muonIdx[0] ) || Jet_muonIdx1 < 0 ) \ + )*TMath::Log(Jet_PUIDSF_loose)\ + ))', + 'samples': mc +} + + + + +with open(configurations+'/HWWSemiLepHighMass/DeepAK8V2_W_SFs.csv') as csvfile: + reader = csv.DictReader(row for row in csvfile if not row.startswith('#')) + deepAK8Dict = dict() + for row in reader: + name = '{y}_{ver}_{mtr}_{pT_l}_{pT_h}'.format( + y = row['Year'], + ver = row['version'], + mtr = row['MistaggingRate[%]'], + pT_l = row['pT_low[GeV]'], + pT_h = row['pT_high[GeV]'] + ) + deepAK8Dict[name] = str(row['SF']) + deepAK8Dict[name+'_up'] = str(float(row['SF'])+float(row['SF_upperErr'])) + deepAK8Dict[name+'_down'] = str(float(row['SF'])+float(row['SF_lowerErr'])) +# 200 300 +# 300 400 +# 400 800 +year = '2016' +mtr = '0p5' +aliases['DeepAK8_SF'] = { + 'expr': "( 1 * !boosted_nocut[0] + boosted_nocut[0]*(" +\ + #'expr': "( 1 * two_jet_res[0] + !two_jet_res[0]*(" +\ + \ + deepAK8Dict[year+'_Nominal_'+mtr+'_200_300'] +\ + "* (100 < Alt$(CleanFatJet_pt[0],0) \ + && Alt$(CleanFatJet_pt[0],0) < 300) +" +\ + \ + deepAK8Dict[year+'_Nominal_'+mtr+'_300_400'] +\ + "* (300 < Alt$(CleanFatJet_pt[0],0) \ + && Alt$(CleanFatJet_pt[0],0) < 400) +" +\ + \ + deepAK8Dict[year+'_Nominal_'+mtr+'_400_800'] +\ + "* (400 < Alt$(CleanFatJet_pt[0],0)) ))", + 'samples': mc_deep +} + +aliases['DeepAK8_SF_up'] = { + #'expr': "( 1 * two_jet_res[0] + !two_jet_res[0]*(" +\ + 'expr': "( 1 * !boosted_nocut[0] + boosted_nocut[0]*(" +\ + \ + deepAK8Dict[year+'_Nominal_'+mtr+'_200_300_up'] +\ + "* (100 < Alt$(CleanFatJet_pt[0],0) \ + && Alt$(CleanFatJet_pt[0],0) < 300) +" +\ + \ + deepAK8Dict[year+'_Nominal_'+mtr+'_300_400_up'] +\ + "* (300 < Alt$(CleanFatJet_pt[0],0) \ + && Alt$(CleanFatJet_pt[0],0) < 400) +" +\ + \ + deepAK8Dict[year+'_Nominal_'+mtr+'_400_800_up'] +\ + "* (400 < Alt$(CleanFatJet_pt[0],0)) ))", + 'samples': mc_deep +} + +aliases['DeepAK8_SF_down'] = { + #'expr': "( 1 * two_jet_res[0] + !two_jet_res[0]*(" +\ + 'expr': "( 1 * !boosted_nocut[0] + boosted_nocut[0]*(" +\ + \ + deepAK8Dict[year+'_Nominal_'+mtr+'_200_300_down'] +\ + "* (100 < Alt$(CleanFatJet_pt[0],0) \ + && Alt$(CleanFatJet_pt[0],0) < 300) +" +\ + \ + deepAK8Dict[year+'_Nominal_'+mtr+'_300_400_down'] +\ + "* (300 < Alt$(CleanFatJet_pt[0],0) \ + && Alt$(CleanFatJet_pt[0],0) < 400) +" +\ + \ + deepAK8Dict[year+'_Nominal_'+mtr+'_400_800_down'] +\ + "* (400 < Alt$(CleanFatJet_pt[0],0)) ))", + 'samples': mc_deep +} + + + + +# Fix for single ele trigger eff in 2016 + +#eleTrigFile = '%s/src/PlotsConfigurations/Configurations/HWWSemiLepHighMass/EleTrigEffAndSF.root' % os.getenv('CMSSW_BASE') + +#aliases['EleTrigWeight2016'] = { +# 'linesToAdd': [ +# 'gSystem->AddIncludePath("-I%s/src");' % os.getenv('CMSSW_BASE'), +# '.L %s/src/PlotsConfigurations/Configurations/HWWSemiLepHighMass/weightReader.cc+' % os.getenv('CMSSW_BASE') +# ], +# 'class': 'WeightReader', +# 'args': (eleTrigFile,'eff_2016BCDEFGH'), +# 'samples': mc +#} + +aliases['passSingleElectronHLT']= { + 'expr':'HLT_Ele27_WPTight_Gsf' +} + +#aliases['EleTrigSF'] = { + # 'class': 'WeightReader', +# 'args': (eleTrigFile,'SF_2016BCDEFGH_SF'), +# 'samples': mc +#} + +#aliases['trigWeight'] = { +# 'expr' : 'TriggerEffWeight_1l*'+'(Lepton_isTightMuon_'+muWP+'[0]>0.5) +\ +# EleTrigSF*passSingleElectronHLT*(Lepton_isTightElectron_'+eleWP+'[0]>0.5)', +# 'samples':mc +#} + + + + + +# TODO: choice here between boosted W tagging with tau21 (WtagSF) +# or DeepAK8 (DeepAK8_SF) +# # data/MC scale factors +aliases['SFweight'] = { + #'expr': ' * '.join(['puWeight', 'TriggerEffWeight_1l', 'EMTFbug_veto', 'PrefireWeight', 'LepWPSF[0]', 'btagSF[0]', 'PUJetIdSF[0]']), + 'expr': ' * '.join(['puWeight', 'TriggerEffWeight_1l', 'EMTFbug_veto', 'PrefireWeight', 'LepWPSF[0]', 'btagSF[0]', 'PUJetIdSF[0]']), + #'expr': ' * '.join(['puWeight', 'TriggerEffWeight_1l', 'EMTFbug_veto', 'PrefireWeight', 'LepWPSF[0]', 'btagSF[0]', 'PUJetIdSF[0]', 'DeepAK8_SF[0]']), + #'expr': ' * '.join(['puWeight', 'TriggerEffWeight_1l', 'EMTFbug_veto', 'PrefireWeight', 'LepWPSF[0]', 'btagSF[0]', 'PUJetIdSF[0]', 'WtagSF[0]']), + #'expr': ' * '.join(['puWeight', 'trigWeight', 'EMTFbug_veto', 'PrefireWeight', 'LepWPSF[0]', 'btagSF[0]', 'PUJetIdSF[0]', 'DeepAK8_SF[0]']), + 'samples': mc +} + + +aliases['SFweight_deep'] = { + #'expr': ' * '.join(['puWeight', 'TriggerEffWeight_1l', 'EMTFbug_veto', 'PrefireWeight', 'LepWPSF[0]', 'btagSF[0]', 'PUJetIdSF[0]']), +# 'expr': ' * '.join(['puWeight', 'TriggerEffWeight_1l', 'EMTFbug_veto', 'PrefireWeight', 'LepWPSF[0]', 'btagSF[0]', 'PUJetIdSF[0]']), + 'expr': ' * '.join(['puWeight', 'TriggerEffWeight_1l', 'EMTFbug_veto', 'PrefireWeight', 'LepWPSF[0]', 'btagSF[0]', 'PUJetIdSF[0]', 'DeepAK8_SF[0]']), + #'expr': ' * '.join(['puWeight', 'TriggerEffWeight_1l', 'EMTFbug_veto', 'PrefireWeight', 'LepWPSF[0]', 'btagSF[0]', 'PUJetIdSF[0]', 'WtagSF[0]']), + #'expr': ' * '.join(['puWeight', 'trigWeight', 'EMTFbug_veto', 'PrefireWeight', 'LepWPSF[0]', 'btagSF[0]', 'PUJetIdSF[0]', 'DeepAK8_SF[0]']), + 'samples': mc_deep +} + + +# FIXME top stuff +# PostProcessing did not create (anti)topGenPt for ST samples with _ext1 +lastcopy = (1 << 13) + +aliases['isTTbar'] = { + 'expr': 'Sum$(TMath::Abs(GenPart_pdgId) == 6 && TMath::Odd(GenPart_statusFlags / %d)) == 2' % lastcopy, + 'samples': ['top', 'top_semi_redo',] +} +aliases['isSingleTop'] = { + 'expr': 'Sum$(TMath::Abs(GenPart_pdgId) == 6 && TMath::Odd(GenPart_statusFlags / %d)) == 1' % lastcopy, + 'samples': ['top','top_semi_redo',] +} + +aliases['topGenPtOTF'] = { + 'expr': 'Sum$((GenPart_pdgId == 6 && TMath::Odd(GenPart_statusFlags / %d)) * GenPart_pt)' % lastcopy, + 'samples': ['top','top_semi_redo',] +} +aliases['antitopGenPtOTF'] = { + 'expr': 'Sum$((GenPart_pdgId == -6 && TMath::Odd(GenPart_statusFlags / %d)) * GenPart_pt)' % lastcopy, + 'samples': ['top','top_semi_redo',] +} + + +aliases['DeepAK8_SF_top'] = { + #'expr': "( 1 * two_jet_res[0] + !two_jet_res[0]*(" +\ + 'expr': "(1*( topGenPtOTF * antitopGenPtOTF <= 0.) + (topGenPtOTF * antitopGenPtOTF > 0.)*( 1 * !boosted_nocut[0] + boosted_nocut[0]*(" +\ + \ + deepAK8Dict[year+'_Nominal_'+mtr+'_200_300'] +\ + "* (100 < Alt$(CleanFatJet_pt[0],0) \ + && Alt$(CleanFatJet_pt[0],0) < 300) +" +\ + \ + deepAK8Dict[year+'_Nominal_'+mtr+'_300_400'] +\ + "* (300 < Alt$(CleanFatJet_pt[0],0) \ + && Alt$(CleanFatJet_pt[0],0) < 400) +" +\ + \ + deepAK8Dict[year+'_Nominal_'+mtr+'_400_800'] +\ + "* (400 < Alt$(CleanFatJet_pt[0],0)) )))", + 'samples': ['top',] +} + +aliases['DeepAK8_SF_top_up'] = { + #'expr': "(1*( topGenPtOTF * antitopGenPtOTF <= 0.) + (topGenPtOTF * antitopGenPtOTF > 0.)*( 1 * two_jet_res[0] + !two_jet_res[0]*(" +\ + 'expr': "(1*( topGenPtOTF * antitopGenPtOTF <= 0.) + (topGenPtOTF * antitopGenPtOTF > 0.)*( 1 * !boosted_nocut[0] + boosted_nocut[0]*(" +\ + \ + deepAK8Dict[year+'_Nominal_'+mtr+'_200_300_up'] +\ + "* (100 < Alt$(CleanFatJet_pt[0],0) \ + && Alt$(CleanFatJet_pt[0],0) < 300) +" +\ + \ + deepAK8Dict[year+'_Nominal_'+mtr+'_300_400_up'] +\ + "* (300 < Alt$(CleanFatJet_pt[0],0) \ + && Alt$(CleanFatJet_pt[0],0) < 400) +" +\ + \ + deepAK8Dict[year+'_Nominal_'+mtr+'_400_800_up'] +\ + "* (400 < Alt$(CleanFatJet_pt[0],0)) )))", + 'samples': ['top',] +} + +aliases['DeepAK8_SF_top_down'] = { + #'expr': "(1*( topGenPtOTF * antitopGenPtOTF <= 0.) + (topGenPtOTF * antitopGenPtOTF > 0.)*(1 * two_jet_res[0] + !two_jet_res[0]*(" +\ + 'expr': "(1*( topGenPtOTF * antitopGenPtOTF <= 0.) + (topGenPtOTF * antitopGenPtOTF > 0.)*( 1 * !boosted_nocut[0] + boosted_nocut[0]*(" +\ + \ + deepAK8Dict[year+'_Nominal_'+mtr+'_200_300_down'] +\ + "* (100 < Alt$(CleanFatJet_pt[0],0) \ + && Alt$(CleanFatJet_pt[0],0) < 300) +" +\ + \ + deepAK8Dict[year+'_Nominal_'+mtr+'_300_400_down'] +\ + "* (300 < Alt$(CleanFatJet_pt[0],0) \ + && Alt$(CleanFatJet_pt[0],0) < 400) +" +\ + \ + deepAK8Dict[year+'_Nominal_'+mtr+'_400_800_down'] +\ + "* (400 < Alt$(CleanFatJet_pt[0],0)) )))", + 'samples': ['top',] +} + + +aliases['SFweight_top'] = { + #'expr': ' * '.join(['puWeight', 'TriggerEffWeight_1l', 'EMTFbug_veto', 'PrefireWeight', 'LepWPSF[0]', 'btagSF[0]', 'PUJetIdSF[0]']), + 'expr': ' * '.join(['puWeight', 'TriggerEffWeight_1l', 'EMTFbug_veto', 'PrefireWeight', 'LepWPSF[0]', 'btagSF[0]', 'PUJetIdSF[0]', 'DeepAK8_SF_top[0]']), + #'expr': ' * '.join(['puWeight', 'TriggerEffWeight_1l', 'EMTFbug_veto', 'PrefireWeight', 'LepWPSF[0]', 'btagSF[0]', 'PUJetIdSF[0]']), + #'expr': ' * '.join(['puWeight', 'TriggerEffWeight_1l', 'EMTFbug_veto', 'PrefireWeight', 'LepWPSF[0]', 'btagSF[0]', 'PUJetIdSF[0]', 'WtagSF[0]']), + #'expr': ' * '.join(['puWeight', 'trigWeight', 'EMTFbug_veto', 'PrefireWeight', 'LepWPSF[0]', 'btagSF[0]', 'PUJetIdSF[0]', 'DeepAK8_SF[0]']), + 'samples': ['top',] +} + +aliases['Top_pTrw'] = {# New Top PAG + 'expr': '(topGenPtOTF * antitopGenPtOTF > 0.) * (TMath::Sqrt((0.103*TMath::Exp(-0.0118*topGenPtOTF) - 0.000134*topGenPtOTF + 0.973) * (0.103*TMath::Exp(-0.0118*antitopGenPtOTF) - 0.000134*antitopGenPtOTF + 0.973))) * (TMath::Sqrt(TMath::Exp(1.61468e-03 + 3.46659e-06*topGenPtOTF - 8.90557e-08*topGenPtOTF*topGenPtOTF) * TMath::Exp(1.61468e-03 + 3.46659e-06*antitopGenPtOTF - 8.90557e-08*antitopGenPtOTF*antitopGenPtOTF))) + (topGenPtOTF * antitopGenPtOTF <= 0.)', # Same Reweighting as other years, but with additional fix for tune CUET -> CP5 + 'samples': ['top','top_semi_redo',] +} + + +aliases['nCleanGenJet'] = { + 'linesToAdd': ['.L %s/src/PlotsConfigurations/Configurations/Differential/ngenjet.cc+' % os.getenv('CMSSW_BASE')], + 'class': 'CountGenJet', + 'samples': mc +} + +##### DY Z pT reweighting +aliases['getGenZpt_OTF'] = { + 'linesToAdd':['.L %s/src/PlotsConfigurations/Configurations/patches/getGenZpt.cc+' % os.getenv('CMSSW_BASE')], + 'class': 'getGenZpt', + 'samples': ['DY'] +} +handle = open('%s/src/PlotsConfigurations/Configurations/patches/DYrew30.py' % os.getenv('CMSSW_BASE'),'r') +exec(handle) +handle.close() +aliases['DY_NLO_pTllrw'] = { + 'expr': '('+DYrew['2016']['NLO'].replace('x', 'getGenZpt_OTF')+')*(nCleanGenJet == 0)+1.0*(nCleanGenJet > 0)', + 'samples': ['DY'] +} +aliases['DY_LO_pTllrw'] = { + 'expr': '('+DYrew['2016']['LO'].replace('x', 'getGenZpt_OTF')+')*(nCleanGenJet == 0)+1.0*(nCleanGenJet > 0)', + 'samples': ['DY'] +} + + + + + +mc_sbi = [skey for skey in samples if "SBI" in skey] +aliases['CheckforSM'] = { + 'linesToAdd' : [ + 'gSystem->Load("libLatinoAnalysisMultiDraw.so")', + '.L %s/src/PlotsConfigurations/Configurations/HWWSemiLepHighMass/CheckForSM125.cc+' % os.getenv('CMSSW_BASE') + ], + 'expr': 'CheckforSM()', + 'samples': mc_sbi +} + +aliases['SBI_isSMggh'] = { + 'expr': '( abs(Xsec-1.091343e+00) < 1.0e-06 && CheckforSM )', # With protection against "HM" 125 sample + 'samples': mc_sbi +} +aliases['SBI_isSMVBF'] = { + 'expr': '( abs(Xsec-8.496211e-02) < 1.0e-08 && CheckforSM )', # With protection against "HM" 125 sample + 'samples': mc_sbi +} +aliases['SBI_isggWW'] = { + 'expr': '( abs(Xsec-6.387000e-02) < 1.0e-08 )', + 'samples': mc_sbi +} +aliases['SBI_isqqWWqq'] = { + 'expr': '( abs(Xsec-2.160000e+00) < 1.0e-06)', + 'samples': mc_sbi +} +aliases['SBI_isHM'] = { + 'expr': '( !SBI_isSMggh && !SBI_isSMVBF && !SBI_isggWW && !SBI_isqqWWqq )', + 'samples': mc_sbi +} + +aliases["nJetHigh2"]={ + 'linesToAdd':['.L %s/src/PlotsConfigurations/Configurations/HWWSemiLepHighMass/getNJet.cc+' % os.getenv('CMSSW_BASE')], + 'class': 'getNJet', +} + +aliases['kfact'] = { + 'linesToAdd': [ + 'gSystem->Load("%s/src/JHUGenMELA/MELA/data/%s/libmcfm_707.so","", kTRUE);'%(os.getenv('CMSSW_BASE'), os.getenv('SCRAM_ARCH')), + 'gSystem->Load("libJHUGenMELAMELA.so","", kTRUE);', + 'gSystem->AddIncludePath("-I%s/src");' % os.getenv('CMSSW_RELEASE_BASE'), + '.L %s/src/PlotsConfigurations/Configurations/HWWSemiLepHighMass/kFactorUnc2.cc+' % os.getenv('CMSSW_BASE') + ], + 'class': 'kFactorUnc2', + 'args': ('PlotsConfigurations/Configurations/HWWSemiLepHighMass/wjets_kfactor_DH/HT_to_NLO_QCD_k_factors3.root', 'k_factor_2016'), + 'samples': 'Wjets', +} + + +FR_dir = os.getenv('CMSSW_BASE') + "/src/PlotsConfigurations/Configurations/HWWSemiLepHighMass/FAKE_RW/FR/2016/" +PR_dir = os.getenv('CMSSW_BASE') + "/src/PlotsConfigurations/Configurations/HWWSemiLepHighMass/FAKE_RW/PR/2016/" +el_pr_file = PR_dir+"plot_ElCh_l1_etaVpt_ptel_2D_pr.root" +mu_pr_file = PR_dir+"plot_MuCh_l1_etaVpt_ptmu_2D_pr.root" +for lep in ['El', 'Mu']: + for dEt in [-10, 0, 10]: + if lep == 'El': + el_et = El_jetEt + dEt + mu_et = Mu_jetEt + elif lep == 'Mu': + el_et = El_jetEt + mu_et = Mu_jetEt + dEt + + el_fr_file = FR_dir+"plot_ElCh_JetEt"+str(el_et)+"_l1_etaVpt_ptel_fw_ewk_2D.root" + mu_fr_file = FR_dir+"plot_MuCh_JetEt"+str(mu_et)+"_l1_etaVpt_ptmu_fw_ewk_2D.root" + + aliases['FW_mu'+str(mu_et)+'_el'+str(el_et)] = { + 'linesToAdd' : [ + 'gSystem->Load("libLatinoAnalysisMultiDraw.so")', + #'.L %s/src/PlotsConfigurations/Configurations/HWWSemiLepHighMass/fakeweight_p1_OTF.cc+' % os.getenv('CMSSW_BASE') + '.L %s/src/PlotsConfigurations/Configurations/HWWSemiLepHighMass/fakeweight_OTF.cc+' % os.getenv('CMSSW_BASE') + ], + #'class': 'fakeWeight_p1_OTF', + 'class': 'fakeWeightOTF', + #'args': (eleWP, muWP, copy.deepcopy(el_fr_file), copy.deepcopy(mu_fr_file), False, False), + 'args': (eleWP, muWP, copy.deepcopy(el_fr_file), el_pr_file, copy.deepcopy(mu_fr_file), mu_pr_file, False, False), + 'samples': ["FAKE"] + } + aliases['FW_mu'+str(mu_et)+'_el'+str(el_et)+'_statUp'] = { + #'class': 'fakeWeight_p1_OTF', + 'class': 'fakeWeightOTF', + #'args': (eleWP, muWP, copy.deepcopy(el_fr_file), copy.deepcopy(mu_fr_file), True, False), + 'args': (eleWP, muWP, copy.deepcopy(el_fr_file), el_pr_file, copy.deepcopy(mu_fr_file), mu_pr_file, True, False), + 'samples': ["FAKE"] + } + aliases['FW_mu'+str(mu_et)+'_el'+str(el_et)+'_statDown'] = { + #'class': 'fakeWeight_p1_OTF', + 'class': 'fakeWeightOTF', + #'args': (eleWP, muWP, copy.deepcopy(el_fr_file), copy.deepcopy(mu_fr_file), False, True), + 'args': (eleWP, muWP, copy.deepcopy(el_fr_file), el_pr_file, copy.deepcopy(mu_fr_file), mu_pr_file, False, True), + 'samples': ["FAKE"] + } + +for var in ['Up', 'Down']: + for lep in ['El', 'Mu']: + el_et = El_jetEt + mu_et = Mu_jetEt + if var == 'Down': dEt = -10 + elif var == 'Up': dEt = 10 + if lep == 'El': + el_et = El_jetEt + dEt + is_lep = '(TMath::Abs(Lepton_pdgId[0]) == 11)' + no_lep = '(TMath::Abs(Lepton_pdgId[0]) == 13)' + elif lep == 'Mu': + mu_et = mu_et + dEt + is_lep = '(TMath::Abs(Lepton_pdgId[0]) == 13)' + no_lep = '(TMath::Abs(Lepton_pdgId[0]) == 11)' + + aliases['FW_mu'+str(Mu_jetEt)+'_el'+str(El_jetEt)+'_'+lep+var] = { + 'expr': '('+is_lep+'*(FW_mu'+str(mu_et)+'_el'+str(el_et)+'[0]/FW_mu'+str(Mu_jetEt)+'_el'+str(El_jetEt)+'[0]) + '+no_lep+')', + 'samples': ["FAKE"] + } + aliases['FW_mu'+str(Mu_jetEt)+'_el'+str(El_jetEt)+'_stat'+lep+var] = { + 'expr': '('+is_lep+'*(FW_mu'+str(Mu_jetEt)+'_el'+str(El_jetEt)+'_stat'+var+'[0]/FW_mu'+str(Mu_jetEt)+'_el'+str(El_jetEt)+'[0]) + '+no_lep+')', + 'samples': ["FAKE"] + } + +# +##aliases["MelaVBFvsGGH_boosted"]={ +## 'linesToAdd': [ +## 'gSystem->Load("%s/src/JHUGenMELA/MELA/data/%s/libmcfm_707.so","", kTRUE);'%(os.getenv('CMSSW_BASE'), os.getenv('SCRAM_ARCH')), +## 'gSystem->Load("libJHUGenMELAMELA.so","", kTRUE);', +## '.L %s/HWWSemiLepHighMass/MelaGGFvsVBF.cc+' % configurations], +## 'class': 'MelaGGFvsVBF', +## 'args': (0, "%s/HWWSemiLepHighMass/" % configurations) +##} +##aliases["MelaVBFvsGGH_resolved"]={ +## 'linesToAdd': [ +## 'gSystem->Load("%s/src/JHUGenMELA/MELA/data/%s/libmcfm_707.so","", kTRUE);'%(os.getenv('CMSSW_BASE'), os.getenv('SCRAM_ARCH')), +## 'gSystem->Load("libJHUGenMELAMELA.so","", kTRUE);', +## '.L %s/HWWSemiLepHighMass/MelaGGFvsVBF.cc+' % configurations], +## 'class': 'MelaGGFvsVBF', +## 'args': (1, "%s/HWWSemiLepHighMass/" % configurations) +##} +# +# +# +# +##aliases['kfactMjj'] = { +# 'linesToAdd': [ +# 'gSystem->AddIncludePath("-I%s/src");' % os.getenv('CMSSW_RELEASE_BASE'), +# '.L %s/src/PlotsConfigurations/Configurations/HWWSemiLepHighMass/k_factor_mjj_unc.cc+' % os.getenv('CMSSW_BASE') +# ], +# 'class': 'kFactorMjjUnc', +# #'args': ('PlotsConfigurations/Configurations/monoHWW/SemiLep/Wjets_kfactors/HT_to_NLO_QCD_k_factors_2016_mjj.root', 'k_factor_2016'), +# 'args': ('PlotsConfigurations/Configurations/HWWSemiLepHighMass/wjets_kfactor_DH/HT_to_NLO_QCD_k_factors_mjj.root', 'k_factor_2016'), +# 'samples': 'Wjets', +#} + + +#aliases['DNN_out_isVBF'] = { +# 'class': 'DNNprodSemiNew', +# 'linesToAdd':[ +# 'gSystem->Load("libLatinoAnalysisMultiDraw.so")', +# 'gSystem->Load("libDNNEvaluator.so")', +# '.L %s/src/PlotsConfigurations/Configurations/HWWSemiLepHighMass/DNN_prod_semi_new.cc+' % os.getenv('CMSSW_BASE'), +# ], +# 'args': 0, +#} +# +#aliases['DNN_out_isGGH'] = { +# 'class': 'DNNprodSemiNew', +# 'linesToAdd':[ +# 'gSystem->Load("libLatinoAnalysisMultiDraw.so")', +# 'gSystem->Load("libDNNEvaluator.so")', +# '.L %s/src/PlotsConfigurations/Configurations/HWWSemiLepHighMass/DNN_prod_semi_new.cc+' % os.getenv('CMSSW_BASE'), +# ], +# 'args': 1, +#} +# +#aliases['DNN_out_isBKG'] = { +# 'class': 'DNNprodSemiNew', +# 'linesToAdd':[ +# 'gSystem->Load("libLatinoAnalysisMultiDraw.so")', +# 'gSystem->Load("libDNNEvaluator.so")', +# '.L %s/src/PlotsConfigurations/Configurations/HWWSemiLepHighMass/DNN_prod_semi_new.cc+' % os.getenv('CMSSW_BASE'), +# ], +# 'args': 2, +#} + +#aliases['isVBF'] = { +# 'expr': 'DNN_out_isVBF[0] > DNN_out_isGGH[0] && DNN_out_isVBF[0] > DNN_out_isBKG[0] ', +#} + + +#aliases['SBI_isSMggh'] = { + # 'linesToAdd': ['.L %s/src/PlotsConfigurations/Configurations/HWWSemiLepHighMass/isSample.cc+' % os.getenv('CMSSW_BASE')], + # 'expr' : 'is_SMggh()', + # 'samples': mc_sbi +#} +#aliases['SBI_isSMVBF'] = { +# 'linesToAdd': ['.L %s/src/PlotsConfigurations/Configurations/HWWSemiLepHighMass/isSample.cc+' % os.getenv('CMSSW_BASE')], +# 'expr' : 'is_SMVBF()', +# 'samples': mc_sbi +#} +#aliases['SBI_isggWW'] = { + # 'linesToAdd': ['.L %s/src/PlotsConfigurations/Configurations/HWWSemiLepHighMass/isSample.cc+' % os.getenv('CMSSW_BASE')], + # 'expr' : 'is_ggWW()', + # 'samples': mc_sbi +#} +#aliases['SBI_isqqWWqq'] = { + # 'linesToAdd': ['.L %s/src/PlotsConfigurations/Configurations/HWWSemiLepHighMass/isSample.cc+' % os.getenv('CMSSW_BASE')], + # 'expr' : 'is_qqWWqq()', + # 'samples': mc_sbi +#} +#aliases['SBI_isHM'] = { +# 'expr': '( !SBI_isSMggh && !SBI_isSMVBF && !SBI_isggWW && !SBI_isqqWWqq )', +# 'samples': mc_sbi +#} diff --git a/Configurations/HWWSemiLepHighMass/Gen2016_v7/config_medmass.py b/Configurations/HWWSemiLepHighMass/Gen2016_v7/config_medmass.py new file mode 100644 index 0000000000..7dec78a2c7 --- /dev/null +++ b/Configurations/HWWSemiLepHighMass/Gen2016_v7/config_medmass.py @@ -0,0 +1,42 @@ +# Configuration file to produce initial root files + +treeName = 'Events' + +tag = 'hm_gen' + +# used by mkShape to define output directory for root files +outputDir = 'rootFile_vs' + +# file with TTree aliases +aliasesFile = 'aliases_medmass.py' + +# file with list of variables +variablesFile = 'variables_medmass.py' +# variablesFile = 'variablesPlot.py' +# variablesFile = 'variablesLimits.py' + +# file with list of cuts +cutsFile = 'cuts_medmass.py' + +# file with list of samples +samplesFile = 'samples_medmass.py' + +# file with list of samples +plotFile = 'plot_medmass.py' + +# luminosity to normalize to (in 1/fb) +lumi = 35.9 + +# used by mkPlot to define output directory for plots +# different from "outputDir" to do things more tidy +outputDirPlots = 'plot_last' + + +# used by mkDatacards to define output directory for datacards +outputDirDatacard = 'Datacards_last' + +# structure file for datacard +structureFile = 'structure_medmass.py' + +# nuisances file for mkDatacards and for mkShape +#nuisancesFile = 'nuisances_medmass.py' diff --git a/Configurations/HWWSemiLepHighMass/Gen2016_v7/cuts_medmass.py b/Configurations/HWWSemiLepHighMass/Gen2016_v7/cuts_medmass.py new file mode 100644 index 0000000000..dfaa2f5853 --- /dev/null +++ b/Configurations/HWWSemiLepHighMass/Gen2016_v7/cuts_medmass.py @@ -0,0 +1,39 @@ +# cuts +cuts = {} +# this should be checked in postprocessing, just to be sure +supercut = '\ + LeptonGen_pt[0]>25 \ +&& (Alt$(LeptonGen_pt[1],0)<=10 \ +&& abs(LeptonGen_eta[0])<2.5) \ +' +#&& GenEvtFlag>0 \ +''' +cuts['ggH'] = { + 'expr': 'mjjGen_max < 150.', + 'categories': { + 'boosted': 'GenEvtFlag==1', + 'resolved': 'GenEvtFlag==2' + } +} + +cuts['qqH'] = { + 'expr': 'mjjGen_max > 150.', + 'categories': { + 'boosted': 'GenEvtFlag==1', + 'resolved': 'GenEvtFlag==2' + } + +} + + +cuts['all'] = { + 'expr': '1.', + 'categories': { + 'boosted': 'GenEvtFlag==1', + 'resolved': 'GenEvtFlag==2' + } + +} +''' + +cuts['supercut'] = {'expr': '1.'} diff --git a/Configurations/HWWSemiLepHighMass/Gen2016_v7/massesAndModels.py b/Configurations/HWWSemiLepHighMass/Gen2016_v7/massesAndModels.py new file mode 100644 index 0000000000..d3fec8dc15 --- /dev/null +++ b/Configurations/HWWSemiLepHighMass/Gen2016_v7/massesAndModels.py @@ -0,0 +1,23 @@ +massggh = ['115', '120', '124', '125', '126', '130', '135', '140', '145', '150', '155', '160', '165', '170', '175', '180', '190', '200', '210', '230', '250', '270', '300', '350', '400', '450', '500', '550', '600', '650', '700', '750', '800', '900', '1000', '1500', '2000', '2500', '3000', '4000', '5000'] + +massvbf = ['115', '120', '124', '125', '126', '130', '135', '140', '145', '150', '155', '160', '165', '170', '175', '180', '190', '200', '210', '230', '250', '270', '300', '350', '400', '450', '500', '550', '600', '650', '700', '750', '800', '900', '1000', '1500', '2000', '2500', '3000', '4000', '5000'] + +massggh = ['500', '2000'] #'200', '300', '400', +massvbf = ['500', '2000'] #'200', '300', '400', +#massvbf = ['500'] +#massggh = ['500'] + +models = ['RelW10.0', 'RelW100.0'] +''' +model_name = '_'+model.replace('.','') +model_I = model+'_I' +model_I_H = model+'_I_Honly' +model_I_B = model+'_I_Bonly' +model_B = model+'_B' +model_H = model+'_H' +''' + +#plotmasses = ['500', '800', '1000', '1500' ,'2000', '3000'] +plotmasses = ['500'] +plotmodels = ['RelW1000'] +#plotmasses = ['500', '1000', '3000'] diff --git a/Configurations/HWWSemiLepHighMass/Gen2016_v7/nuisances_medmass.py b/Configurations/HWWSemiLepHighMass/Gen2016_v7/nuisances_medmass.py new file mode 100644 index 0000000000..8b8faf1e05 --- /dev/null +++ b/Configurations/HWWSemiLepHighMass/Gen2016_v7/nuisances_medmass.py @@ -0,0 +1,1032 @@ +# nuisances + +nuisances = {} + +# name of samples here must match keys in samples.py + +# imported from samples.py: +# samples, treeBaseDir, mcProduction, mcSteps +# imported from cuts.py +# cuts +import copy + +from LatinoAnalysis.Tools.commonTools import getSampleFiles, getBaseW, addSampleWeight + +def nanoGetSampleFiles(inputDir, Sample): + return getSampleFiles(inputDir, Sample, False, 'nanoLatino_') + +try: + mc = [skey for skey in samples if skey not in ('FAKE', 'DATA')] + mc_deep =[skey for skey in samples if skey not in ['DY', 'top', 'Wjets', 'Vg', 'VgS','VZ', 'FAKE', 'DATA', 'VVV', 'ZH_htt', 'WH_htt', 'ggH_htt', 'qqH_htt']] + sig_mc = [skey for skey in mc if ("GGH" in skey) or ("QQH" in skey) or (skey in ["ggWW", "ggH_hww", "qqWWqq", "qqH_hww"])] # ggWW is currently reweighted sig sample, while qqWWqq needs to be symlinked to the BWReweight! + +except NameError: + mc = [] + sig_mc = [] + cuts = {} + nuisances = {} + def makeMCDirectory(x=''): + return '' + +from LatinoAnalysis.Tools.HiggsXSection import HiggsXSection +HiggsXS = HiggsXSection() + + +cutdict = { + 'Ele' : set(x for x in cuts if 'ElCh' in x), + 'Muon' : set(x for x in cuts if 'MuCh' in x), + 'Wjets' : set(x for x in cuts if 'SB' in x), + 'resTOP' : 'incl_ResolvedTopCR_', #set(x for x in cuts if 'ResolvedTopCR' in x), + 'booTOP' : 'incl_BoostedTopCR_', #set(x for x in cuts if 'BoostedTopCR' in x), + 'resSR' : 'incl_ResolvedSR_', #set(x for x in cuts if 'ResolvedSR' in x), + 'resSB' : 'incl_ResolvedSB_', #set(x for x in cuts if 'ResolvedSB' in x), + 'booSR' : 'incl_BoostedSR_', #set(x for x in cuts if 'BoostedSR' in x), + 'booSB' : 'incl_BoostedSB_', #set(x for x in cuts if 'BoostedSB' in x), + 'resTOP_2J' : 'incl_ResolvedTopCR_2jets', #set(x for x in cuts if 'ResolvedTopCR' in x), + 'booTOP_2J' : 'incl_BoostedTopCR_2jets', #set(x for x in cuts if 'BoostedTopCR' in x), + 'resSR_2J' : 'incl_ResolvedSR_2jets', #set(x for x in cuts if 'ResolvedSR' in x), + 'resSB_2J' : 'incl_ResolvedSB_2jets', #set(x for x in cuts if 'ResolvedSB' in x), + 'booSR_2J' : 'incl_BoostedSR_2jets', #set(x for x in cuts if 'BoostedSR' in x), + 'booSB_2J' : 'incl_BoostedSB_2jets', #set(x for x in cuts if 'BoostedSB' in x), + 'resTOP_01J' : 'incl_ResolvedTopCR_0jets', #set(x for x in cuts if 'ResolvedTopCR' in x), + 'booTOP_01J' : 'incl_BoostedTopCR_0jets', #set(x for x in cuts if 'BoostedTopCR' in x), + 'resSR_01J' : 'incl_ResolvedSR_0jets', #set(x for x in cuts if 'ResolvedSR' in x), + 'resSB_01J' : 'incl_ResolvedSB_0jets', #set(x for x in cuts if 'ResolvedSB' in x), + 'booSR_01J' : 'incl_BoostedSR_0jets', #set(x for x in cuts if 'BoostedSR' in x), + 'booSB_01J' : 'incl_BoostedSB_0jets', #set(x for x in cuts if 'BoostedSB' in x), + 'booSR_up' : 'incl_BoostedSR_up', #set(x for x in cuts if 'BoostedSR' in x), + 'booCR' : 'incl_BoostedCR_', #set(x for x in cuts if 'BoostedSB' in x), + 'booCR_1' : 'incl_BoostedCR_notau', #set(x for x in cuts if 'BoostedSB' in x), + 'booCR_2' : 'incl_BoostedSB_notau', #set(x for x in cuts if 'BoostedSB' in x), + ##'Untag' : set(x for x in cuts if 'Untagged' in x), + #'Boost' : 'incl_Boosted_SB_' ,#set(x for x in cuts if 'Boosted' in x), + #'Resolv': 'incl_Resolved_SB_', #set(x for x in cuts if 'Resolved' in x), + #'HM' : set(x for x in cuts if 'HM' in x), +} + + +################################ EXPERIMENTAL UNCERTAINTIES ################################# + +#### Luminosity + +nuisances['lumi_Uncorrelated'] = { + 'name': 'lumi_13TeV_2016', + 'type': 'lnN', + 'samples': dict((skey, '1.022') for skey in mc if skey not in ['Wjets', 'top']) +} + +nuisances['lumi_XY'] = { + 'name': 'lumi_13TeV_XY', + 'type': 'lnN', + 'samples': dict((skey, '1.009') for skey in mc if skey not in ['Wjets', 'top']) +} + +nuisances['lumi_BBD'] = { + 'name': 'lumi_13TeV_BBD', + 'type': 'lnN', + 'samples': dict((skey, '1.004') for skey in mc if skey not in ['Wjets', 'top']) +} + +nuisances['lumi_DB'] = { + 'name': 'lumi_13TeV_DB', + 'type': 'lnN', + 'samples': dict((skey, '1.005') for skey in mc if skey not in ['Wjets', 'top']) +} + +nuisances['lumi_GS'] = { + 'name': 'lumi_13TeV_GS', + 'type': 'lnN', + 'samples': dict((skey, '1.004') for skey in mc if skey not in ['Wjets', 'top']) +} + + + +######## btag +#for shift in ['jes', 'lf', 'hf', 'hfstats1', 'hfstats2', 'lfstats1', 'lfstats2', 'cferr1', 'cferr2']: +# btag_syst = ['(btagSF%sup)/(btagSF)' % shift, '(btagSF%sdown)/(btagSF)' % shift] +# +# name = 'CMS_btag_%s' % shift +# if 'stats' in shift: +# name += '_2016' +# +# nuisances['btag_%s' % shift] = { +# 'name': name, +# 'kind': 'weight', +# 'type': 'shape', +# 'samples': dict((skey, btag_syst) for skey in mc), +# } +# +# +# +###### WtagSF +#useDeepAK8 = True +# +#if useDeepAK8 is False: +# nuisances['wtag'] = { +# 'name': 'CMS_wtag_eff', +# 'kind': 'weight', +# 'type': 'shape', +# 'samples': dict((skey, ['SFWtagUp', 'SFWtagDown']) for skey in mc), +# 'cuts' : [ +# cutdict['resTOP'], +# cutdict['booTOP'], +# cutdict['resSB'], +# cutdict['resSR'], +# cutdict['booSB'], +# cutdict['booSR'], +# ] +##'cuts': set.union(cutdict['Resolv'], cutdict['Boost']) +# } +#else: +# nuisances['wtag'] = { +# 'name': 'CMS_wtag_eff', +# 'kind': 'weight', +# 'type': 'shape', +# 'samples': dict((skey, ['DeepAK8_SF_up/DeepAK8_SF', 'DeepAK8_SF_down/DeepAK8_SF']) for skey in mc_deep), +# 'cuts' : [ +# cutdict['resTOP'], +# cutdict['booTOP'], +# cutdict['resSB'], +# cutdict['resSR'], +# cutdict['booSB'], +# cutdict['booSR'], +# cutdict['resTOP_2J'], +# cutdict['booTOP_2J'], +# cutdict['resSB_2J'], +# cutdict['resSR_2J'], +# cutdict['booSB_2J'], +# cutdict['booSR_2J'], +# cutdict['resTOP_01J'], +# cutdict['booTOP_01J'], +# cutdict['resSB_01J'], +# cutdict['resSR_01J'], +# cutdict['booSB_01J'], +# cutdict['booSR_01J'], +# cutdict['booCR'], +# cutdict['booCR_1'], +# cutdict['booCR_2'], +# ] +# # 'cuts': set.union(cutdict['Resolv'], cutdict['Boost']) +# } +# +#nuisances['wtag_top'] = { +# 'name': 'CMS_wtag_eff_top', +# 'kind' : 'weight', +# 'type' : 'shape', +# 'samples': { +# 'top': ['DeepAK8_SF_top_up/DeepAK8_SF_top', 'DeepAK8_SF_top_down/DeepAK8_SF_top'], +# }, +# 'cuts' : [ +# cutdict['resTOP'], +# cutdict['booTOP'], +# cutdict['resSB'], +# cutdict['resSR'], +# cutdict['booSB'], +# cutdict['booSR'], +# cutdict['resTOP_2J'], +# cutdict['booTOP_2J'], +# cutdict['resSB_2J'], +# cutdict['resSR_2J'], +# cutdict['booSB_2J'], +# cutdict['booSR_2J'], +# cutdict['resTOP_01J'], +# cutdict['booTOP_01J'], +# cutdict['resSB_01J'], +# cutdict['resSR_01J'], +# cutdict['booSB_01J'], +# cutdict['booSR_01J'], +# cutdict['booCR'], +# cutdict['booCR_1'], +# cutdict['booCR_2'], +# ] +#} +##nuisances['wtag_HM'] = { +## 'name': 'CMS_wtag_eff_HM', +## 'type': 'lnN', +## 'samples': dict((skey, '1.1') for skey in mc), +## 'cuts': cutdict['HM'] +##} +# +# +# +# +###### Trigger Efficiency +# +#trig_syst = ['((TriggerEffWeight_1l_u)/(TriggerEffWeight_1l))*(TriggerEffWeight_1l>0.02) + (TriggerEffWeight_1l<=0.02)', '(TriggerEffWeight_1l_d)/(TriggerEffWeight_1l)*(TriggerEffWeight_1l>0.02) + (TriggerEffWeight_1l<=0.02)'] +# +#nuisances['trigg'] = { +# 'name': 'CMS_eff_hwwtrigger_2016', +# 'kind': 'weight', +# 'type': 'shape', +# 'samples': dict((skey, trig_syst) for skey in mc) +#} +# +#prefire_syst = ['PrefireWeight_Up/PrefireWeight', 'PrefireWeight_Down/PrefireWeight'] +# +#nuisances['prefire'] = { +# 'name': 'CMS_eff_prefiring_2016', +# 'kind': 'weight', +# 'type': 'shape', +# 'samples': dict((skey, prefire_syst) for skey in mc) +#} +# +# +###### Electron Efficiency and energy scale +# +#nuisances['eff_e'] = { +# 'name': 'CMS_eff_e_2016', +# 'kind': 'weight', +# 'type': 'shape', +# 'samples': dict((skey, ['SFweightEleUp', 'SFweightEleDown']) for skey in mc) +#} +# +#nuisances['electronpt'] = { +# 'name' : 'CMS_scale_e_2016', +# 'kind' : 'suffix', +# 'type' : 'shape', +# 'mapUp' : 'ElepTup', +# 'mapDown': 'ElepTdo', +# 'samples': dict((skey, ['1', '1']) for skey in mc if skey not in sig_mc), +# 'folderUp' : makeMCDirectory('ElepTup'), +# 'folderDown': makeMCDirectory('ElepTdo'), +# 'AsLnN': '1' +#} +# +# +# +###### Muon Efficiency and energy scale +# +#nuisances['eff_m'] = { +# 'name': 'CMS_eff_m_2016', +# 'kind': 'weight', +# 'type': 'shape', +# 'samples': dict((skey, ['SFweightMuUp', 'SFweightMuDown']) for skey in mc) +#} +# +#nuisances['muonpt'] = { +# 'name' : 'CMS_scale_m_2016', +# 'kind' : 'suffix', +# 'type' : 'shape', +# 'mapUp' : 'MupTup', +# 'mapDown': 'MupTdo', +# 'samples': dict((skey, ['1', '1']) for skey in mc if skey not in sig_mc), +# 'folderUp' : makeMCDirectory('MupTup'), +# 'folderDown': makeMCDirectory('MupTdo'), +# 'AsLnN': '1' +#} +# +# +# +###### Jet energy scale +# +#jes_systs = ['JESAbsolute','JESAbsolute_2016','JESBBEC1','JESBBEC1_2016','JESEC2','JESEC2_2016','JESFlavorQCD','JESHF','JESHF_2016','JESRelativeBal','JESRelativeSample_2016'] +# +# +#for js in jes_systs: +# nuisances[js] = { +# 'name' : 'CMS_scale_'+js, +# 'kind' : 'suffix', +# 'type' : 'shape', +# 'mapUp' : js+'up', +# 'mapDown': js+'do', +# 'samples': dict((skey, ['1', '1']) for skey in mc if skey not in sig_mc), +# 'folderUp' : makeMCDirectory('JESup'), +# 'folderDown': makeMCDirectory('JESdo'), +# 'AsLnN': '1' +# } +# +# +# +###### FatJet scale and resolution +# +#nuisances['fatjet_jes'] = { +# 'name' : 'CMS_scale_fatj_2016', +# 'kind' : 'suffix', +# 'type' : 'shape', +# 'mapUp' : 'fatjetJESup', +# 'mapDown': 'fatjetJESdo', +# 'samples': dict((skey, ['1', '1']) for skey in mc if skey not in sig_mc), +# 'folderUp' : makeMCDirectory('fatjetJESup'), +# 'folderDown': makeMCDirectory('fatjetJESdo'), +## 'AsLnN': '1' +#} +#nuisances['fatjet_jer'] = { +# 'name' : 'CMS_res_fatjer_2016', +# 'kind' : 'suffix', +# 'type' : 'shape', +# 'mapUp' : 'fatjetJERup', +# 'mapDown': 'fatjetJERdo', +# 'samples': dict((skey, ['1', '1']) for skey in mc if skey not in sig_mc), +# 'folderUp' : makeMCDirectory('fatjetJERup'), +# 'folderDown': makeMCDirectory('fatjetJERdo'), +## 'AsLnN': '1' +#} +#nuisances['fatjet_jms'] = { +# 'name' : 'CMS_fatjms_2016', +# 'kind' : 'suffix', +# 'type' : 'shape', +# 'mapUp' : 'fatjetJMSup', +# 'mapDown': 'fatjetJMSdo', +# 'samples': dict((skey, ['1', '1']) for skey in mc if skey not in sig_mc), +# 'folderUp' : makeMCDirectory('fatjetJMSup'), +# 'folderDown': makeMCDirectory('fatjetJMSdo'), +## 'AsLnN': '1' +#} +#nuisances['fatjet_jmr'] = { +# 'name' : 'CMS_res_fatjmr_2016', +# 'kind' : 'suffix', +# 'type' : 'shape', +# 'mapUp' : 'fatjetJMRup', +# 'mapDown': 'fatjetJMRdo', +# 'samples': dict((skey, ['1', '1']) for skey in mc if skey not in sig_mc), +# 'folderUp' : makeMCDirectory('fatjetJMRup'), +# 'folderDown': makeMCDirectory('fatjetJMRdo'), +## 'AsLnN': '1' +#} +# +# +# +# +###### MET energy scale +# +#nuisances['met'] = { +# 'name' : 'CMS_scale_met_2016', +# 'kind' : 'suffix', +# 'type' : 'shape', +# 'mapUp' : 'METup', +# 'mapDown': 'METdo', +# 'samples': dict((skey, ['1', '1']) for skey in mc if skey not in sig_mc), +# 'folderUp' : makeMCDirectory('METup'), +# 'folderDown': makeMCDirectory('METdo'), +# 'AsLnN': '1' +#} +# +########## pile-up +# +#nuisances['PU'] = { +# 'name': 'CMS_PU_2016', +# 'kind': 'weight', +# 'type': 'shape', +# 'samples': { +# 'Wjets': ['0.998597321*(puWeightUp/puWeight)', '1.001420452*(puWeightDown/puWeight)'], +# 'DY': ['0.993259983266*(puWeightUp/puWeight)', '0.997656381501*(puWeightDown/puWeight)'], +# 'top': ['1.00331969187*(puWeightUp/puWeight)', '0.999199609528*(puWeightDown/puWeight)'], +# 'WW': ['1.0033022059*(puWeightUp/puWeight)', '0.997085330608*(puWeightDown/puWeight)'], +# 'ggH_hww': ['1.0036768006*(puWeightUp/puWeight)', '0.995996570285*(puWeightDown/puWeight)'], +# 'qqH_hww': ['1.00374694528*(puWeightUp/puWeight)', '0.995878596852*(puWeightDown/puWeight)'], +# }, +# 'AsLnN': '1', +#} +## High mass PU +##handle = open("../../HighMass/PUunc_Semi.py",'r') +#handle = open("../../../../PlotsConfigurations/Configurations/HighMass/PUunc_Semi.py",'r') +#exec(handle) +#handle.close() +# +#for m in massggh: +# PUup = PUunc['GGF'+m]['Up'] +# PUdn = PUunc['GGF'+m]['Down'] +# PUstring = [str(PUup)+'*(puWeightUp/puWeight)', str(PUdn)+'*(puWeightDown/puWeight)'] +# nuisances['PU']['samples'].update({'GGH_'+m+model_name: PUstring}) +# nuisances['PU']['samples'].update({'GGHINT_'+m+model_name: PUstring}) +#for m in massvbf: +# PUup = PUunc['VBF'+m]['Up'] +# PUdn = PUunc['VBF'+m]['Down'] +# PUstring = [str(PUup)+'*(puWeightUp/puWeight)', str(PUdn)+'*(puWeightDown/puWeight)'] +# nuisances['PU']['samples'].update({'QQH_'+m+model_name: PUstring}) +# nuisances['PU']['samples'].update({'QQHINT_'+m+model_name: PUstring}) +# +# +# +###### PS copied from ggH 2016 +## high mass PS +##handle = open("../../HighMass/PSunc_Semi.py",'r') +#handle = open("../../../../PlotsConfigurations/Configurations/HighMass/PSunc_Semi.py",'r') +#exec(handle) +#handle.close() +# +#nuisances['PS_ISR'] = { +# 'name': 'PS_ISR', +# 'kind': 'weight', +# 'type': 'shape', +# 'samples': { +# 'Wjets': ['0.997054474752*(nCleanGenJet==0) + 1.01491223907*(nCleanGenJet==1) + 1.00675986689*(nCleanGenJet==2) + 0.973889730523*(nCleanGenJet>=3)', '1.00439657406*(nCleanGenJet==0) + 0.98111895136*(nCleanGenJet==1) + 0.99317366464*(nCleanGenJet==2) + 1.03376665043*(nCleanGenJet>=3)'], +# 'Vg' : ['1.00227428567253*(nCleanGenJet==0) + 1.00572014989997*(nCleanGenJet==1) + 0.970824885256465*(nCleanGenJet==2) + 0.927346068071086*(nCleanGenJet>=3)', '0.996488506572636*(nCleanGenJet==0) + 0.993582795375765*(nCleanGenJet==1) + 1.03643678934568*(nCleanGenJet==2) + 1.09735277266955*(nCleanGenJet>=3)'], +# 'VgS' : ['1.0000536116408023*(nCleanGenJet==0) + 1.0100100693580492*(nCleanGenJet==1) + 0.959068359375*(nCleanGenJet==2) + 0.9117049260469496*(nCleanGenJet>=3)', '0.9999367833485968*(nCleanGenJet==0) + 0.9873682892005163*(nCleanGenJet==1) + 1.0492717737268518*(nCleanGenJet==2) + 1.1176958835210322*(nCleanGenJet>=3)'], +# 'ggWW' : ['1.040233912070831*(nCleanGenJet==0) + 0.9611236379290876*(nCleanGenJet==1) + 0.9014289294088699*(nCleanGenJet==2) + 0.864310738090035*(nCleanGenJet>=3)', '0.9510305474211223*(nCleanGenJet==0) + 1.0433432942960381*(nCleanGenJet==1) + 1.1271383507266095*(nCleanGenJet==2) + 1.1885756983901514*(nCleanGenJet>=3)'], +# 'WW' : ['1.0005237869294796*(nCleanGenJet==0) + 1.0157425373134328*(nCleanGenJet==1) + 0.9644598124510606*(nCleanGenJet==2) + 0.9271488926223369*(nCleanGenJet>=3)', '0.9993553300024391*(nCleanGenJet==0) + 0.9806102300995024*(nCleanGenJet==1) + 1.042603303739856*(nCleanGenJet==2) + 1.0950369125887705*(nCleanGenJet>=3)'], +# 'WWewk' : ['1.000046239608802*(nCleanGenJet==0) + 1.0133437345113673*(nCleanGenJet==1) + 1.0144565712441801*(nCleanGenJet==2) + 0.9633224709814209*(nCleanGenJet>=3)', '0.9972924400977996*(nCleanGenJet==0) + 0.9796025428294364*(nCleanGenJet==1) + 0.9785038122896787*(nCleanGenJet==2) + 1.043894692205412*(nCleanGenJet>=3)'], # From WpWmJJ_EWK_noTop +# 'qqWWqq' : ['1.031198192*(nCleanGenJet==0) + 1.029396447*(nCleanGenJet==1) + 1.008244787*(nCleanGenJet==2) + 0.958054424*(nCleanGenJet>=3)', '0.962541517*(nCleanGenJet==0) + 0.964149647*(nCleanGenJet==1) + 0.988864503*(nCleanGenJet==2) + 1.052819668*(nCleanGenJet>=3)'], # From WpWmJJ_QCD_noTop_ext1 +# 'WW2J' : ['1.031198192*(nCleanGenJet==0) + 1.029396447*(nCleanGenJet==1) + 1.008244787*(nCleanGenJet==2) + 0.958054424*(nCleanGenJet>=3)', '0.962541517*(nCleanGenJet==0) + 0.964149647*(nCleanGenJet==1) + 0.988864503*(nCleanGenJet==2) + 1.052819668*(nCleanGenJet>=3)'], # From WpWmJJ_QCD_noTop_ext1 +# 'top' : ['1.0020618369910668*(nCleanGenJet==0) + 1.0063081530771556*(nCleanGenJet==1) + 1.0094298425968304*(nCleanGenJet==2) + 0.9854207999040726*(nCleanGenJet>=3)', '0.9974340279269026*(nCleanGenJet==0) + 0.9920634820709106*(nCleanGenJet==1) + 0.988226385054923*(nCleanGenJet==2) + 1.017968568319235*(nCleanGenJet>=3)'], +# 'DY' : ['0.9998177685645392*(nCleanGenJet==0) + 1.0080838149428026*(nCleanGenJet==1) + 1.0057948912950987*(nCleanGenJet==2) + 0.9721358221196619*(nCleanGenJet>=3)', '1.0003244155266309*(nCleanGenJet==0) + 0.9897992135367016*(nCleanGenJet==1) + 0.9928782069009531*(nCleanGenJet==2) + 1.0348902921423981*(nCleanGenJet>=3)'], +# 'VVV' : ['1.0270826786253018*(nCleanGenJet==0) + 1.0198703447307862*(nCleanGenJet==1) + 1.0109191915514344*(nCleanGenJet==2) + 0.9838184220287978*(nCleanGenJet>=3)', '0.9661665482954546*(nCleanGenJet==0) + 0.9751744967838527*(nCleanGenJet==1) + 0.9859624782745712*(nCleanGenJet==2) + 1.0202995039288625*(nCleanGenJet>=3)'], +# 'VZ' : ['1.0005649495173758*(nCleanGenJet==0) + 1.0126108996187784*(nCleanGenJet==1) + 0.9655814439488959*(nCleanGenJet==2) + 0.9231853653899337*(nCleanGenJet>=3)', '0.9992093891493296*(nCleanGenJet==0) + 0.9843983411237471*(nCleanGenJet==1) + 1.0409271492937164*(nCleanGenJet==2) + 1.1001990664321764*(nCleanGenJet>=3)'], # From ZZTo2L2Nu_ext1 +# 'ggH_hww': ['1.0007510488273352*(nCleanGenJet==0) + 1.0152476349471342*(nCleanGenJet==1) + 0.9645590929269297*(nCleanGenJet==2) + 0.9189171704206691*(nCleanGenJet>=3)', '0.9989909143752528*(nCleanGenJet==0) + 0.9814978813068076*(nCleanGenJet==1) + 1.0416554335980368*(nCleanGenJet==2) + 1.1060543963750413*(nCleanGenJet>=3)'], +# 'qqH_hww': ['1.0008858084852863*(nCleanGenJet==0) + 1.001293920824975*(nCleanGenJet==1) + 1.0013304143711548*(nCleanGenJet==2) + 0.9875473532521144*(nCleanGenJet>=3)', '0.9987483211480337*(nCleanGenJet==0) + 0.9982952329209852*(nCleanGenJet==1) + 0.9983076740658964*(nCleanGenJet==2) + 1.016023412328836*(nCleanGenJet>=3)'], +# 'WH_hww' : ['1.0006979353025824*(nCleanGenJet==0) + 1.0014529360558138*(nCleanGenJet==1) + 1.0007920644457673*(nCleanGenJet==2) + 0.996814275350521*(nCleanGenJet>=3)', '0.9990367459746422*(nCleanGenJet==0) + 0.9980712824836634*(nCleanGenJet==1) + 0.9989875513096169*(nCleanGenJet==2) + 1.0039628146069568*(nCleanGenJet>=3)'], +# 'ZH_hww' : ['1.0008198940532742*(nCleanGenJet==0) + 1.001574300159756*(nCleanGenJet==1) + 1.0014892423703352*(nCleanGenJet==2) + 0.9982835923429388*(nCleanGenJet>=3)', '0.9991322211949244*(nCleanGenJet==0) + 0.9979828392772856*(nCleanGenJet==1) + 0.9980190791034156*(nCleanGenJet==2) + 1.0021025907582017*(nCleanGenJet>=3)'], +# 'ggH_htt' : ['1.0009206232135992*(nCleanGenJet==0) + 1.0169049400184142*(nCleanGenJet==1) + 0.9651882268657965*(nCleanGenJet==2) + 0.9207705642435241*(nCleanGenJet>=3)', '0.9987561139828172*(nCleanGenJet==0) + 0.9794201864664572*(nCleanGenJet==1) + 1.0412120487156962*(nCleanGenJet==2) + 1.1029538166275263*(nCleanGenJet>=3)'], # From GluGluHToTauTau_M125 +# 'qqH_htt' : ['1.0015936666002356*(nCleanGenJet==0) + 1.0009069467125817*(nCleanGenJet==1) + 1.0013415884915544*(nCleanGenJet==2) + 0.9899575000578329*(nCleanGenJet>=3)', '0.9977688532207473*(nCleanGenJet==0) + 0.9987106379579664*(nCleanGenJet==1) + 0.9982730482948471*(nCleanGenJet==2) + 1.0129212222112982*(nCleanGenJet>=3)'], # From VBFHToTauTau_M125 +# 'ZH_htt' : ['1.0011046590284958*(nCleanGenJet==0) + 1.0009827081230018*(nCleanGenJet==1) + 1.0014051098703878*(nCleanGenJet==2) + 0.9922466090234346*(nCleanGenJet>=3)', '0.9985385006421232*(nCleanGenJet==0) + 0.9987921714622244*(nCleanGenJet==1) + 0.9980838293358115*(nCleanGenJet==2) + 1.009751444450435*(nCleanGenJet>=3)'], # From HZJ_HToTauTau_M125 +# 'WH_htt' : ['1.000668369771863*(nCleanGenJet==0) + 1.0016815623453736*(nCleanGenJet==1) + 1.0013707389683542*(nCleanGenJet==2) + 0.9915138785231363*(nCleanGenJet>=3)', '0.9991668459690679*(nCleanGenJet==0) + 0.9978760956386513*(nCleanGenJet==1) + 0.9981171739879867*(nCleanGenJet==2) + 1.0105488300114145*(nCleanGenJet>=3)'], # From HWplusJ_HToTauTau_M125 +# }, +#} +##TODO: re-compute PS coefficient in VBF anf GGH signal (completely wrong 500-3000 GeV) GBardelli (check the others too) +#for m in massggh: +# PSup = PSunc['GGF'+m]['ISRup'] +# PSdn = PSunc['GGF'+m]['ISRdn'] +# PSstring = [str(PSup['0j'])+'*(nCleanGenJet==0) + '+str(PSup['1j'])+'*(nCleanGenJet==1) + '+str(PSup['2j'])+'*(nCleanGenJet==2) + '+str(PSup['3j'])+'*(nCleanGenJet>=3)', str(PSdn['0j'])+'*(nCleanGenJet==0) + '+str(PSdn['1j'])+'*(nCleanGenJet==1) + '+str(PSdn['2j'])+'*(nCleanGenJet==2) + '+str(PSdn['3j'])+'*(nCleanGenJet>=3)'] +# nuisances['PS_ISR']['samples'].update({'GGH_'+m+model_name: PSstring}) +# nuisances['PS_ISR']['samples'].update({'GGHINT_'+m+model_name: PSstring}) # Here and in the following: Don't put nuisances here for SBI; they're added automatically in a later step! +#for m in massvbf: +# PSup = PSunc['VBF'+m]['ISRup'] +# PSdn = PSunc['VBF'+m]['ISRdn'] +# PSstring = [str(PSup['0j'])+'*(nCleanGenJet==0) + '+str(PSup['1j'])+'*(nCleanGenJet==1) + '+str(PSup['2j'])+'*(nCleanGenJet==2) + '+str(PSup['3j'])+'*(nCleanGenJet>=3)', str(PSdn['0j'])+'*(nCleanGenJet==0) + '+str(PSdn['1j'])+'*(nCleanGenJet==1) + '+str(PSdn['2j'])+'*(nCleanGenJet==2) + '+str(PSdn['3j'])+'*(nCleanGenJet>=3)'] +# nuisances['PS_ISR']['samples'].update({'QQH_'+m+model_name: PSstring}) +# nuisances['PS_ISR']['samples'].update({'QQHINT_'+m+model_name: PSstring}) +# +# +#nuisances['PS_FSR'] = { +# 'name': 'PS_FSR', +# 'kind': 'weight', +# 'type': 'shape', +# 'samples': { +# 'Wjets': ['0.951581197919*(nCleanGenJet==0) + 0.997755474747*(nCleanGenJet==1) + 1.02983517401*(nCleanGenJet==2) + 1.01143623738*(nCleanGenJet>=3)', '1.08454892632*(nCleanGenJet==0) + 1.0003688082*(nCleanGenJet==1) + 0.980741215888*(nCleanGenJet==2) + 0.97189538569*(nCleanGenJet>=3)'], +# 'Vg' : ['0.999935529935028*(nCleanGenJet==0) + 0.997948255568351*(nCleanGenJet==1) + 1.00561645493085*(nCleanGenJet==2) + 1.0212896960035*(nCleanGenJet>=3)', '1.00757702771109*(nCleanGenJet==0) + 1.00256681166083*(nCleanGenJet==1) + 0.93676371569867*(nCleanGenJet==2) + 0.956448336052435*(nCleanGenJet>=3)'], +# 'VgS' : ['0.9976593177227735*(nCleanGenJet==0) + 1.0016125187585532*(nCleanGenJet==1) + 1.0049344618055556*(nCleanGenJet==2) + 1.0195631514301164*(nCleanGenJet>=3)', '1.0026951855766457*(nCleanGenJet==0) + 1.0008132148661049*(nCleanGenJet==1) + 1.003949291087963*(nCleanGenJet==2) + 0.9708160910230832*(nCleanGenJet>=3)'], +# 'ggWW' : ['0.9910563426395067*(nCleanGenJet==0) + 1.0069894351287263*(nCleanGenJet==1) + 1.016616376034912*(nCleanGenJet==2) + 1.015902717074592*(nCleanGenJet>=3)', '1.0147395976461193*(nCleanGenJet==0) + 0.9860219489006646*(nCleanGenJet==1) + 0.9694680606617647*(nCleanGenJet==2) + 0.9489845115821678*(nCleanGenJet>=3)'], +# 'WW' : ['0.995462478372054*(nCleanGenJet==0) + 1.0052129975124378*(nCleanGenJet==1) + 1.008836750560578*(nCleanGenJet==2) + 0.9984120564941189*(nCleanGenJet>=3)', '1.008927720738437*(nCleanGenJet==0) + 0.995163868159204*(nCleanGenJet==1) + 0.9911024228315418*(nCleanGenJet==2) + 0.9763787172658678*(nCleanGenJet>=3)'], +# 'WWewk' : ['0.9919173789731052*(nCleanGenJet==0) + 0.994273375713824*(nCleanGenJet==1) + 1.0009783801226202*(nCleanGenJet==2) + 1.0046943184676753*(nCleanGenJet>=3)', '1.0081780733496333*(nCleanGenJet==0) + 1.0052172826204072*(nCleanGenJet==1) + 0.9984786981975752*(nCleanGenJet==2) + 0.9881601609947174*(nCleanGenJet>=3)'], +# 'qqWWqq' : ['0.976538004*(nCleanGenJet==0) + 0.993524816*(nCleanGenJet==1) + 1.006678783*(nCleanGenJet==2) + 1.009760965*(nCleanGenJet>=3)', '1.035661107*(nCleanGenJet==0) + 1.007585153*(nCleanGenJet==1) + 0.989764669*(nCleanGenJet==2) + 0.98276492*(nCleanGenJet>=3)'], +# 'WW2J' : ['0.976538004*(nCleanGenJet==0) + 0.993524816*(nCleanGenJet==1) + 1.006678783*(nCleanGenJet==2) + 1.009760965*(nCleanGenJet>=3)', '1.035661107*(nCleanGenJet==0) + 1.007585153*(nCleanGenJet==1) + 0.989764669*(nCleanGenJet==2) + 0.98276492*(nCleanGenJet>=3)'], +# 'top' : ['0.9910899786333963*(nCleanGenJet==0) + 0.9990635702054794*(nCleanGenJet==1) + 1.002141744200183*(nCleanGenJet==2) + 1.0129742776372779*(nCleanGenJet>=3)', '1.0068843378231833*(nCleanGenJet==0) + 0.998988498438759*(nCleanGenJet==1) + 0.9952696584115224*(nCleanGenJet==2) + 0.9790955840673237*(nCleanGenJet>=3)'], +# 'DY' : ['0.9958763409773141*(nCleanGenJet==0) + 1.0041335498093422*(nCleanGenJet==1) + 1.0163363150953029*(nCleanGenJet==2) + 1.0296733670670226*(nCleanGenJet>=3)', '1.0066775262249232*(nCleanGenJet==0) + 0.9945601465681602*(nCleanGenJet==1) + 0.9662459619335311*(nCleanGenJet==2) + 0.9479423453563661*(nCleanGenJet>=3)'], +# 'VVV' : ['0.9809047855490748*(nCleanGenJet==0) + 0.9823641498350338*(nCleanGenJet==1) + 0.9976414629808243*(nCleanGenJet==2) + 1.0077953569413387*(nCleanGenJet>=3)', '1.035388723727876*(nCleanGenJet==0) + 1.0347339790465233*(nCleanGenJet==1) + 1.0017058788771533*(nCleanGenJet==2) + 0.9829344116371653*(nCleanGenJet>=3)'], +# 'VZ' : ['0.9969613063607379*(nCleanGenJet==0) + 1.0055822932729375*(nCleanGenJet==1) + 1.0115617769727228*(nCleanGenJet==2) + 1.003930218451846*(nCleanGenJet>=3)', '1.0044825167062181*(nCleanGenJet==0) + 0.9934087678296067*(nCleanGenJet==1) + 0.9816200440919792*(nCleanGenJet==2) + 0.9733590995315957*(nCleanGenJet>=3)'], +# 'ggH_hww': ['0.9936588910230489*(nCleanGenJet==0) + 1.0087564198432573*(nCleanGenJet==1) + 1.014636529653396*(nCleanGenJet==2) + 1.00399261707105*(nCleanGenJet>=3)','1.0125063182369591*(nCleanGenJet==0) + 0.9846168672324244*(nCleanGenJet==1) + 0.9778204449152542*(nCleanGenJet==2) + 1.0014057292097962*(nCleanGenJet>=3)'], +# 'qqH_hww': ['0.9902864012471768*(nCleanGenJet==0) + 0.9950165165635796*(nCleanGenJet==1) + 1.0024778632714528*(nCleanGenJet==2) + 1.0132965690130387*(nCleanGenJet>=3)', '1.0171041801597582*(nCleanGenJet==0) + 1.0088822239287307*(nCleanGenJet==1) + 0.9946938338710369*(nCleanGenJet==2) + 0.9782409053438381*(nCleanGenJet>=3)'], +# 'WH_hww' : ['0.9864466858859676*(nCleanGenJet==0) + 0.9911412676207558*(nCleanGenJet==1) + 1.0047988929561447*(nCleanGenJet==2) + 1.0135375714689319*(nCleanGenJet>=3)', '1.022768308571873*(nCleanGenJet==0) + 1.0147067259919833*(nCleanGenJet==1) + 0.9932121652658327*(nCleanGenJet==2) + 0.9807301742549035*(nCleanGenJet>=3)'], +# 'ZH_hww' : ['0.98702584755388*(nCleanGenJet==0) + 0.9881328970299905*(nCleanGenJet==1) + 1.0046199525397077*(nCleanGenJet==2) + 1.0091561054313662*(nCleanGenJet>=3)', '1.0236225630459734*(nCleanGenJet==0) + 1.0213677207764504*(nCleanGenJet==1) + 0.9933149152918336*(nCleanGenJet==2) + 0.978832627595614*(nCleanGenJet>=3)'], +# 'ggH_htt' : ['0.9943019952320858*(nCleanGenJet==0) + 1.0083325858201546*(nCleanGenJet==1) + 1.0201886103441544*(nCleanGenJet==2) + 0.9998286915341232*(nCleanGenJet>=3)', '1.0109237494149799*(nCleanGenJet==0) + 0.9873094123474508*(nCleanGenJet==1) + 0.9675289700468541*(nCleanGenJet==2) + 0.99986531610269*(nCleanGenJet>=3)'], +# 'qqH_htt' : ['0.9902403321260225*(nCleanGenJet==0) + 0.996767386750923*(nCleanGenJet==1) + 1.0040574219585203*(nCleanGenJet==2) + 1.0124888310238733*(nCleanGenJet>=3)', '1.0139721006126092*(nCleanGenJet==0) + 1.002858740414655*(nCleanGenJet==1) + 0.9961014338785547*(nCleanGenJet==2) + 0.978061636844175*(nCleanGenJet>=3)'], +# 'ZH_htt' : ['0.9936708956610235*(nCleanGenJet==0) + 0.9954883239735823*(nCleanGenJet==1) + 1.0074327384991346*(nCleanGenJet==2) + 1.0068065233897634*(nCleanGenJet>=3)', '1.0106252599791612*(nCleanGenJet==0) + 1.0109967871866061*(nCleanGenJet==1) + 0.9941765805699787*(nCleanGenJet==2) + 0.9967875439175832*(nCleanGenJet>=3)'], +# 'WH_htt' : ['0.9951849276795807*(nCleanGenJet==0) + 0.9971109709655758*(nCleanGenJet==1) + 1.0089023169085682*(nCleanGenJet==2) + 1.0177364980737993*(nCleanGenJet>=3)', '1.0080916898956942*(nCleanGenJet==0) + 1.003439195368276*(nCleanGenJet==1) + 0.9870860759068387*(nCleanGenJet==2) + 0.9778888209017473*(nCleanGenJet>=3)'], +# }, +#} +# +##TODO: re-compute PS coefficient in VBF anf GGH signal (completely wrong 500-3000 GeV) GBardelli +# +#for m in massggh: +# PSup = PSunc['GGF'+m]['FSRup'] +# PSdn = PSunc['GGF'+m]['FSRdn'] +# PSstring = [str(PSup['0j'])+'*(nCleanGenJet==0) + '+str(PSup['1j'])+'*(nCleanGenJet==1) + '+str(PSup['2j'])+'*(nCleanGenJet==2) + '+str(PSup['3j'])+'*(nCleanGenJet>=3)', str(PSdn['0j'])+'*(nCleanGenJet==0) + '+str(PSdn['1j'])+'*(nCleanGenJet==1) + '+str(PSdn['2j'])+'*(nCleanGenJet==2) + '+str(PSdn['3j'])+'*(nCleanGenJet>=3)'] +# nuisances['PS_FSR']['samples'].update({'GGH_'+m+model_name: PSstring}) +# nuisances['PS_FSR']['samples'].update({'GGHINT_'+m+model_name: PSstring}) +#for m in massvbf: +# PSup = PSunc['VBF'+m]['FSRup'] +# PSdn = PSunc['VBF'+m]['FSRdn'] +# PSstring = [str(PSup['0j'])+'*(nCleanGenJet==0) + '+str(PSup['1j'])+'*(nCleanGenJet==1) + '+str(PSup['2j'])+'*(nCleanGenJet==2) + '+str(PSup['3j'])+'*(nCleanGenJet>=3)', str(PSdn['0j'])+'*(nCleanGenJet==0) + '+str(PSdn['1j'])+'*(nCleanGenJet==1) + '+str(PSdn['2j'])+'*(nCleanGenJet==2) + '+str(PSdn['3j'])+'*(nCleanGenJet>=3)'] +# nuisances['PS_FSR']['samples'].update({'QQH_'+m+model_name: PSstring}) +# nuisances['PS_FSR']['samples'].update({'QQHINT_'+m+model_name: PSstring}) +# +# +# +# +## An overall 1.5% UE uncertainty will cover all the UEup/UEdo variations +## And we don't observe any dependency of UE variations on njet +#nuisances['UE'] = { +# 'name' : 'UE_CUET', +# 'skipCMS' : 1, +# 'type': 'lnN', +# 'samples': dict((skey, '1.015') for skey in mc), +#} +# +# +# +######## Generic "cross section uncertainties" +# +#apply_on = { +# 'top': [ +# '(topGenPtOTF * antitopGenPtOTF <= 0.) * 1.0816 + (topGenPtOTF * antitopGenPtOTF > 0.)', +# '(topGenPtOTF * antitopGenPtOTF <= 0.) * 0.9184 + (topGenPtOTF * antitopGenPtOTF > 0.)' +# ] +#} +# +#nuisances['singleTopToTTbar'] = { +# 'name': 'singleTopToTTbar', +# 'skipCMS': 1, +# 'kind': 'weight', +# 'type': 'shape', +# 'samples': apply_on +#} +# +# +#### Top pT reweighting uncertainty -> not needed if the DATA/MC agreement is within the uncertainties after reweighting +## currently replaced by QCD scale +## nuisances['TopPtRew'] = { +## 'name': 'CMS_topPtRew', # Theory uncertainty +## 'kind': 'weight', +## 'type': 'shape', +## 'samples': {'top': ["1.", "1./Top_pTrw"]}, +## 'symmetrize': True +## } +# +# +#nuisances['VgStar'] = { +# 'name': 'CMS_hww_VgStarScale', +# 'type': 'lnN', +# 'samples': { +# 'VgS_L': '1.25' +# } +#} +# +#nuisances['VZ'] = { +# 'name': 'CMS_hww_VZScale', +# 'type': 'lnN', +# 'samples': { +# 'VgS_H': '1.16' +# } +#} +# +# +# +####### pdf uncertainties +# +#valuesggh = HiggsXS.GetHiggsProdXSNP('YR4','13TeV','ggH', '125.09','pdf','sm') +#valuesggzh = HiggsXS.GetHiggsProdXSNP('YR4','13TeV','ggZH','125.09','pdf','sm') +#valuesbbh = HiggsXS.GetHiggsProdXSNP('YR4','13TeV','bbH', '125.09','pdf','sm') +# +#nuisances['pdf_Higgs_gg'] = { +# 'name': 'pdf_Higgs_gg', +# 'samples': { +# 'ggH_hww' : valuesggh, +# 'ggH_htt' : valuesggh, +# 'ggZH_hww': valuesggzh, +# 'bbH_hww' : valuesbbh +# }, +# 'type': 'lnN', +#} +#for m in massggh: +# values = HiggsXS.GetHiggsProdXSNP('YR4','13TeV','ggH',int(m),'pdf','bsm') +# nuisances['pdf_Higgs_gg']['samples'].update({'GGH_'+m+model_name: values}) +# nuisances['pdf_Higgs_gg']['samples'].update({'GGHINT_'+m+model_name: values}) +# +# +# +#valuesqqh = HiggsXS.GetHiggsProdXSNP('YR4','13TeV','vbfH','125.09','pdf','sm') +#valueswh = HiggsXS.GetHiggsProdXSNP('YR4','13TeV','WH','125.09','pdf','sm') +#valueszh = HiggsXS.GetHiggsProdXSNP('YR4','13TeV','ZH','125.09','pdf','sm') +# +#nuisances['pdf_Higgs_qqbar'] = { +# 'name': 'pdf_Higgs_qqbar', +# 'type': 'lnN', +# 'samples': { +# 'qqH_hww': valuesqqh, +# 'qqH_htt': valuesqqh, +# 'WH_hww': valueswh, +# 'WH_htt': valueswh, +# 'ZH_hww': valueszh, +# 'ZH_htt': valueszh +# }, +#} +#for m in massvbf: +# values = HiggsXS.GetHiggsProdXSNP('YR4','13TeV','vbfH',int(m),'bsm') +# nuisances['pdf_Higgs_qqbar']['samples'].update({'QQH_'+m+model_name: values}) +# nuisances['pdf_Higgs_qqbar']['samples'].update({'QQHINT_'+m+model_name: values}) +# +# +# +# +## Top, W+jets: Taken into account in rateParam, since these are all lnN anyway +## PDF for background: https://twiki.cern.ch/twiki/bin/view/CMS/StandardModelCrossSectionsat13TeV and https://twiki.cern.ch/twiki/bin/view/CMS/SummaryTable1G25ns +# +## W+W-: 0.0589 / 1.2804 = 0.046001 +## ZW+: 0.0064 / 0.1427 = 0.0448493 +## ZW-: 0.0039 / 0.0921 = 0.0423453 +## ZZ: 0.0027 / 0.0719 = 0.0375522 +## DY: 14.78 / 6077.22 = 0.0024320 +#nuisances['pdf_gg'] = { +# 'name' : 'pdf_gg', +# 'type' : 'lnN', +# 'samples' : { +# 'ggWW' : '1.05', +# }, +#} +# +#nuisances['pdf_qqbar'] = { +# 'name' : 'pdf_qqbar', +# 'type' : 'lnN', +# 'samples' : { +# 'Vg' : '1.04', +# 'VZ' : '1.04', +# 'VgS' : '1.04', +# 'qqWWqq' : '1.05', +# 'DY' : '1.002', +# }, +#} +# +# +#nuisances['pdf_Higgs_gg_ACCEPT'] = { +# 'name': 'pdf_Higgs_gg_ACCEPT', +# 'samples': { +# 'ggH_hww': '1.006', +# 'ggH_htt': '1.006', +# # 'ggZH_hww': '1.006', +# # 'bbH_hww': '1.006' +# }, +# 'type': 'lnN', +#} +## FIXME: values from dileptonic +#for m in massggh: +# pdfgg_weight = 1.0 + (-4.10343+1.19015e-03*int(m)-9.68156e-08*int(m)*int(m)+6.90171e+03/(int(m)+8.71935e+02)-8.94415e+05/((int(m)+4.72259e+02)*(int(m)+4.72259e+02)))/100.0 +# nuisances['pdf_Higgs_gg_ACCEPT']['samples'].update({'GGH_'+m+model_name: str(pdfgg_weight)}) +# nuisances['pdf_Higgs_gg_ACCEPT']['samples'].update({'GGHINT_'+m+model_name: str(pdfgg_weight)}) +# +# +# +#nuisances['pdf_Higgs_qqbar_ACCEPT'] = { +# 'name': 'pdf_Higgs_qqbar_ACCEPT', +# 'type': 'lnN', +# 'samples': { +# 'qqH_hww': '1.002', +# 'qqH_htt': '1.002', +# 'WH_hww': '1.003', +# 'WH_htt': '1.003', +# 'ZH_hww': '1.002', +# 'ZH_htt': '1.002', +# }, +#} +## FIXME: values from dileptonic +#for m in massvbf: +# pdfqq_weight = 1.0 + (1.46296e-01)/100.0 +# nuisances['pdf_Higgs_qqbar_ACCEPT']['samples'].update({'QQH_'+m+model_name: str(pdfqq_weight)}) +# nuisances['pdf_Higgs_qqbar_ACCEPT']['samples'].update({'QQHINT_'+m+model_name: str(pdfqq_weight)}) +# +# +# +# +#nuisances['pdf_gg_ACCEPT'] = { +# 'name': 'pdf_gg_ACCEPT', +# 'samples': { +# 'ggWW': '1.006', +# }, +# 'type': 'lnN', +#} +# +#nuisances['pdf_qqbar_ACCEPT'] = { +# 'name': 'pdf_qqbar_ACCEPT', +# 'type': 'lnN', +# 'samples': { +# 'qqWWqq': '1.001' +# }, +#} +# +###### Renormalization & factorization scales +# +### This should work for samples with either 8 or 9 LHE scale weights (Length$(LHEScaleWeight) == 8 or 9) +#variations = ['LHEScaleWeight[0]', 'LHEScaleWeight[1]', 'LHEScaleWeight[3]', 'LHEScaleWeight[Length$(LHEScaleWeight)-4]', 'LHEScaleWeight[Length$(LHEScaleWeight)-2]', 'LHEScaleWeight[Length$(LHEScaleWeight)-1]'] +# +#nuisances['QCDscale_V'] = { +# 'name': 'QCDscale_V', +# 'kind': 'weight_envelope', +# 'type': 'shape', +# 'samples': { +# 'DY': variations +# }, +#} +# +# +## Variations for all other samples are consistent. +## ...except in sample "WpWmJJ_QCD_noTop"! weights are NOT normalized! (2016 only) +#variations = ['LHEScaleWeight[%d]/LHEScaleWeight[4]' % i for i in [0, 1, 3, 5, 7, 8]] +#variations = ['LHEScaleWeight[0]', 'LHEScaleWeight[5]', 'LHEScaleWeight[15]', 'LHEScaleWeight[25]', 'LHEScaleWeight[35]', 'LHEScaleWeight[40]'] +# +#nuisances['QCDscale_WWJJ'] = { +# 'name' : 'QCDscale_VV', +# 'skipCMS' : 1, +# 'kind' : 'weight_envelope', +# 'type' : 'shape', +# 'samples' : { +# 'qqWWqq' : variations, +## 'WW2J' : variations, +# } +#} +# +# +#variations = ['LHEScaleWeight[%d]' % i for i in [0, 1, 3, 5, 7, 8]] +## FIXME: LHEScaleWeight missing +#nuisances['QCDscale_VV'] = { +# 'name': 'QCDscale_VV', +# 'kind': 'weight_envelope', +# 'type': 'shape', +# 'samples': { +# 'Vg': variations, +# # 'VZ': variations, #FIXME not all VZ have LHEScaleWeight +# 'VgS': variations +# } +#} +# +#topvars = variations +# +##variations = ['LHEScaleWeight[0]', 'LHEScaleWeight[1]', 'LHEScaleWeight[3]', 'LHEScaleWeight[Length$(LHEScaleWeight)-4]', 'LHEScaleWeight[Length$(LHEScaleWeight)-2]', 'LHEScaleWeight[Length$(LHEScaleWeight)-1]'] +#variations = ['Alt$(LHEScaleWeight[0],1)*(Sum$(abs(GenPart_pdgId)==6 && abs(GenPart_statusFlags>>7 & 1))>=2) + (Sum$(abs(GenPart_pdgId)==6 && abs(GenPart_statusFlags>>7 & 1))<2)','Alt$(LHEScaleWeight[1],1)*(Sum$(abs(GenPart_pdgId)==6 && abs(GenPart_statusFlags>>7 & 1))>=2) + (Sum$(abs(GenPart_pdgId)==6 && abs(GenPart_statusFlags>>7 & 1))<2)','Alt$(LHEScaleWeight[3],1)*(Sum$(abs(GenPart_pdgId)==6 && abs(GenPart_statusFlags>>7 & 1))>=2) + (Sum$(abs(GenPart_pdgId)==6 && abs(GenPart_statusFlags>>7 & 1))<2)','Alt$(LHEScaleWeight[5],1)*(Sum$(abs(GenPart_pdgId)==6 && abs(GenPart_statusFlags>>7 & 1))>=2) + (Sum$(abs(GenPart_pdgId)==6 && abs(GenPart_statusFlags>>7 & 1))<2)', 'Alt$(LHEScaleWeight[7],1)*(Sum$(abs(GenPart_pdgId)==6 && abs(GenPart_statusFlags>>7 & 1))>=2) + (Sum$(abs(GenPart_pdgId)==6 && abs(GenPart_statusFlags>>7 & 1))<2)', 'Alt$(LHEScaleWeight[8],1)*(Sum$(abs(GenPart_pdgId)==6 && abs(GenPart_statusFlags>>7 & 1))>=2) + (Sum$(abs(GenPart_pdgId)==6 && abs(GenPart_statusFlags>>7 & 1))<2)'] +## Normalize top QCD scale +## Normalize top QCD scale +#if True: +# topnorms = {"0j": [1.070761703863844, 1.0721982065714528, 1.0008829637654995, 1.002515087891841, 0.9270080603942781, 0.9270717138194097], "1j": [1.0846741444664376, 1.0806432359691847, 1.0079221754798773, 0.9960603215169435, 0.9198946095840594, 0.9129672863490275], "2j": [1.1209941307567444, 1.103222357530683, 1.0224795274718796, 0.9829374807746288, 0.9038880068177306, 0.8840173265167147]} +# for i,alpha in enumerate(topvars): +# topvars[i] = alpha+"*((Alt$(CleanJet_pt[0], 0) < 30.)/"+str(topnorms["0j"][i])+" + (Alt$(CleanJet_pt[0], 0) >= 30.)*(Alt$(CleanJet_pt[1], 0) < 30.)/"+str(topnorms["1j"][i])+" + (Alt$(CleanJet_pt[1], 0) >= 30.)/"+str(topnorms["2j"][i])+")" +# +#nuisances['QCDscale_ttbar'] = { +# 'name' : 'QCDscale_ttbar', +# 'skipCMS' : 1, +# 'kind' : 'weight_envelope', +# 'type' : 'shape', +# 'samples' : { +# 'top' : variations, +# } +#} +# +#nuisances['QCDscale_WWewk'] = { +# 'name' : 'QCDscale_VV', +# 'type' : 'lnN', +# 'samples' : { +# 'WWewk' : '1.11', +# }, +#} +# +#nuisances['QCDscale_ggVV'] = { +# 'name': 'QCDscale_ggVV', +# 'type': 'lnN', +# 'samples': { +# 'ggWW': '1.15', +# }, +#} +# +# +# +##### QCD scale uncertainties for Higgs +#values = HiggsXS.GetHiggsProdXSNP('YR4','13TeV','ggH','125.09','scale','sm') +#nuisances['QCDscale_ggH'] = { +# 'name': 'QCDscale_ggH', +# 'samples': { +# 'ggH_hww': values, +# 'ggH_htt': values +# }, +# 'type': 'lnN' +#} +#for m in massggh: +# values = HiggsXS.GetHiggsProdXSNP('YR4','13TeV','ggH',int(m),'scale','bsm') +# nuisances['QCDscale_ggH']['samples'].update({ +# 'GGH_'+m+model_name: values +# }) +# nuisances['QCDscale_ggH']['samples'].update({ +# 'GGHINT_'+m+model_name: values +# }) +# +# +#values = HiggsXS.GetHiggsProdXSNP('YR4','13TeV','vbfH','125.09','scale','sm') +#nuisances['QCDscale_qqH'] = { +# 'name': 'QCDscale_qqH', +# 'samples': { +# 'qqH_hww': values, +# 'qqH_htt': values +# }, +# 'type': 'lnN' +#} +#for m in massvbf: +# values = HiggsXS.GetHiggsProdXSNP('YR4','13TeV','vbfH',int(m),'scale','bsm') +# nuisances['QCDscale_qqH']['samples'].update({ +# 'QQH_'+m+model_name: values +# }) +# nuisances['QCDscale_qqH']['samples'].update({ +# 'QQHINT_'+m+model_name: values +# }) +# +# +# +#valueswh = HiggsXS.GetHiggsProdXSNP('YR4','13TeV','WH','125.09','scale','sm') +#valueszh = HiggsXS.GetHiggsProdXSNP('YR4','13TeV','ZH','125.09','scale','sm') +# +#nuisances['QCDscale_VH'] = { +# 'name': 'QCDscale_VH', +# 'samples': { +# 'WH_hww': valueswh, +# 'WH_htt': valueswh, +# 'ZH_hww': valueszh, +# 'ZH_htt': valueszh +# }, +# 'type': 'lnN', +#} +# +#values = HiggsXS.GetHiggsProdXSNP('YR4','13TeV','ggZH','125.09','scale','sm') +# +# +# +#nuisances['QCDscale_ggH_ACCEPT'] = { +# 'name': 'QCDscale_ggH_ACCEPT', +# 'type': 'lnN', +# 'samples': { +# 'ggH_hww': '1.012', +# 'ggH_htt': '1.012', +# 'ggZH_hww': '1.012', +# 'ggWW': '1.012', +# }, +#} +## FIXME: this is fit from dileptonic +#for m in massggh: +# scalegg_weight = 1.0 + (-5.53622e-02+6.73342e-05*int(m)+2.55597e+01/(int(m)-1.10009e+02))/100.0 +# nuisances['QCDscale_ggH_ACCEPT']['samples'].update({ +# 'GGH_'+m+model_name: str(scalegg_weight)}) +# nuisances['QCDscale_ggH_ACCEPT']['samples'].update({ +# 'GGHINT_'+m+model_name: str(scalegg_weight)}) +# +# +#nuisances['QCDscale_qqH_ACCEPT'] = { +# 'name': 'QCDscale_qqH_ACCEPT', +# 'type': 'lnN', +# 'samples': { +# 'qqH_hww': '1.003', +# 'qqH_htt': '1.003', +# 'qqWWqq' : '1.003', +# }, +#} +## FIXME: this is fit from dileptonic +#for m in massvbf: +# scaleqq_weight = 1.0 + (4.54513e-02+3.01227e-06*int(m)+4.72447/(int(m)-9.97821e+01))/100.0 +# nuisances['QCDscale_qqH_ACCEPT']['samples'].update({ +# 'QQH_'+m+model_name: str(scaleqq_weight)}) +# nuisances['QCDscale_qqH_ACCEPT']['samples'].update({ +# 'QQHINT_'+m+model_name: str(scaleqq_weight)}) +# +# +#nuisances['QCDscale_VH_ACCEPT'] = { +# 'name' : 'QCDscale_VH_ACCEPT', +# 'type' : 'lnN', +# 'samples' : { +# 'WH_htt': '1.010', +# 'WH_hww': '1.010', +# 'ZH_hww': '1.015', +# 'ZH_htt': '1.015', +# }, +#} +# +# +# +##### FAKES +##eleWP = 'mva_90p_Iso2016' +##muWP = 'cut_Tight80x' +##fakeW = 'fakeW_ele_'+eleWP+'_mu_'+muWP+'_1l_mu25_ele35' +## +#nuisances['fake_syst'] = { +# 'name': 'CMS_fake_syst', +# 'type': 'lnN', +# 'samples': { +# 'FAKE': '1.3' +# }, +#} +###nuisances['fake_ele'] = { +### 'name': 'CMS_fake_e_2016', +### 'kind': 'weight', +### 'type': 'shape', +### 'samples': { +### 'FAKE': [fakeW+'_ElUp/'+fakeW, fakeW+'_ElDown/'+fakeW], +### } +###} +###nuisances['fake_ele_stat'] = { +### 'name': 'CMS_fake_stat_e_2016', +### 'kind': 'weight', +### 'type': 'shape', +### 'samples': { +### 'FAKE': [fakeW+'_statElUp/'+fakeW, fakeW+'_statElDown/'+fakeW] +### } +###} +###nuisances['fake_mu'] = { +### 'name': 'CMS_fake_m_2016', +### 'kind': 'weight', +### 'type': 'shape', +### 'samples': { +### 'FAKE': [fakeW+'_MuUp/'+fakeW, fakeW+'_MuDown/'+fakeW], +### } +###} +###nuisances['fake_mu_stat'] = { +### 'name': 'CMS_fake_stat_m_2016', +### 'kind': 'weight', +### 'type': 'shape', +### 'samples': { +### 'FAKE': [fakeW+'_statMuUp/'+fakeW, fakeW+'_statMuDown/'+fakeW], +### } +###} +## +###nuisances['Wjets_BooReweight_stat'] = { +### 'name': 'Wjets_BooReweight_stat_2016', +### 'kind' : 'weight', +### 'type' : 'shape', +### 'samples': { +### 'Wjets': ['1/1.12388', '(2-1.12388)/1.12388'], +#### #'WjetsMjj': ['kfact[1]/kfact[0]', 'kfact[2]/kfact[0]'], +#### #'WjetsSP': ['kfactSP[1]/kfactSP[0]', 'kfactSP[2]/kfactSP[0]'], +### #'WjetsSP': ['kfact[1]/kfact[0]', 'kfact[2]/kfact[0]'], +## } +##} +# +#nuisances['Wjets_QCD_NLO_sf_stat'] = { +# 'name': 'Wjets_QCD_NLO_sf_stat_2016', +# 'kind' : 'weight', +# 'type' : 'shape', +# 'samples': { +# 'Wjets': ['kfact[1]/kfact[0]', 'kfact[2]/kfact[0]'], +## #'WjetsMjj': ['kfact[1]/kfact[0]', 'kfact[2]/kfact[0]'], +## #'WjetsSP': ['kfactSP[1]/kfactSP[0]', 'kfactSP[2]/kfactSP[0]'], +## #'WjetsSP': ['kfact[1]/kfact[0]', 'kfact[2]/kfact[0]'], +# } +#} +# +#el_et = El_jetEt +#mu_et = Mu_jetEt +#for syst in ['El', 'statEl', 'Mu', 'statMu']: +# name_tag = '' +# #if 'stat' in syst: name_tag += '_stat' +# #if 'El' in syst: name_tag += '_e' +# #else: name_tag += '_m' +# +# if 'El' in syst: name_tag += '_e' +# else: name_tag += '_m' +# if 'stat' in syst: name_tag += '_stat' +# else: name_tag += '_recoil' +# +# nuisances['fake_'+syst] = { +# 'name': 'CMS_fake'+name_tag+'_2016', +# 'kind': 'weight', +# 'type': 'shape', +# 'samples': { +# 'FAKE': ['FW_mu'+str(mu_et)+'_el'+str(el_et)+'_'+syst+'Up[0]', 'FW_mu'+str(mu_et)+'_el'+str(el_et)+'_'+syst+'Down[0]'], +# #'FAKE': ['FW_mu20_el35_'+syst+'Up[0]', 'FW_mu20_el35_'+syst+'Down[0]'], +# }, +# } + + +####################### rate parameter ########## + +#nuisances['wjets_res'] ={ +# 'name': 'Wjets_J2', +# 'samples': {'Wjets': '1.00'}, +# 'type': 'rateParam', +# 'cuts' : [ +# cutdict['resSB'], +# cutdict['resSR'], +# ] +## 'cuts': set.union(cutdict['resSR'], cutdict['resSB']), +#} +nuisances['wjets_CR'] ={ + 'name': 'Wjets_CR', + 'samples': {'Wjets': '1.00'}, + 'type': 'rateParam', + 'cuts' : [ + cutdict['booCR'], + cutdict['booSR'], + ] +# 'cuts': set.union(cutdict['resSR'], cutdict['resSB']), +} +nuisances['wjets_boo'] ={ + 'name': 'Wjets_FatJet', + 'samples': {'Wjets': '1.00'}, + 'type': 'rateParam', + 'cuts' : [ + cutdict['booSB'], + cutdict['booSR'], + ] +# 'cuts': set.union(cutdict['booSR'], cutdict['booSB']), +} +nuisances['top_res'] ={ + 'name': 'Top_J2', + 'samples': {'top': '1.00'}, + 'type': 'rateParam', + 'cuts' : [ + cutdict['resTOP'], + cutdict['resSR'], + ] +# 'cuts': set.union(cutdict['resSR'],cutdict['resTOP']), +} +nuisances['top_boo'] ={ + 'name': 'Top_FatJet', + 'samples': {'top': '1.00'}, + 'type': 'rateParam', + 'cuts' : [ + cutdict['booTOP'], + cutdict['booSR'], + ] +# 'cuts': set.union(cutdict['booSR'],cutdict['booTOP']), +} + + +######################### MC stat # +nuisances['stat'] = { + 'type': 'auto', + 'maxPoiss': '10', + 'includeSignal': '0', + # nuisance ['maxPoiss'] = Number of threshold events for Poisson modelling + # nuisance ['includeSignal'] = Include MC stat nuisances on signal processes (1=True, 0=False) + 'samples': {} +} diff --git a/Configurations/HWWSemiLepHighMass/Gen2016_v7/samples_medmass.py b/Configurations/HWWSemiLepHighMass/Gen2016_v7/samples_medmass.py new file mode 100644 index 0000000000..2e7f889007 --- /dev/null +++ b/Configurations/HWWSemiLepHighMass/Gen2016_v7/samples_medmass.py @@ -0,0 +1,359 @@ +import os +import inspect + +configurations = os.path.realpath(inspect.getfile(inspect.currentframe())) # this file +configurations = os.path.dirname(configurations) # Full2016v7 +configurations = os.path.dirname(configurations) # HWWSemiLepHighMass +configurations = os.path.dirname(configurations) # Configurations + +from LatinoAnalysis.Tools.commonTools import getSampleFiles, getBaseW, getBaseWnAOD, addSampleWeight + +from LatinoAnalysis.Tools.HiggsXSection import HiggsXSection +HiggsXS = HiggsXSection() + +def nanoGetSampleFiles(inputDir, sample): + try: + if _samples_noload: + return [] + except NameError: + pass + + return getSampleFiles(inputDir, sample, True, 'nanoLatino_') + +# samples + +try: + len(samples) +except NameError: + import collections + samples = collections.OrderedDict() + +################################################ +######### Higgs mass samples and models ######## +################################################ + +massesAndModelsFile = "massesAndModels.py" +if os.path.exists(massesAndModelsFile) : + handle = open(massesAndModelsFile,'r') + exec(handle) + handle.close() +else: + print "!!! ERROR file ", massesAndModelsFile, " does not exist." + + +################################################ +################# SKIMS ######################## +################################################ + +mcProduction = 'Summer16_102X_nAODv7_Full2016v7' + +dataReco = 'Run2016_102X_nAODv7_Full2016v7' + +mcSteps = 'MCl1loose2016v7__MCCorr2016v7__MCCombJJLNu2016{var}' + +dataSteps = 'DATAl1loose2016v7__DATACombJJLNu2016' +fakeSteps = 'DATAl1loose2016v7__DATACombJJLNu2016' + +############################################## +###### Tree base directory for the site ###### +############################################## + +SITE=os.uname()[1] +if 'cern' in SITE: + treeBaseDir = '/eos/cms/store/group/phys_higgs/cmshww/amassiro/HWWNano' + myEOSDir = '/eos/user/s/ssiebert/HWWNano' + + +def makeMCDirectory(var=''): + if var: + return os.path.join(treeBaseDir, mcProduction, mcSteps.format(var='_' + var)) + else: + return os.path.join(treeBaseDir, mcProduction, mcSteps.format(var='')) + +mcDirectory = '/eos/cms/store/group/phys_higgs/cmshww/amassiro/HWWNano/Summer16_102X_nAODv7_Full2016v7/MCl1loose2016v7__MCCorr2016v7__MCCombJJLNu2016__HMlnjjVarsGen' #makeMCDirectory() +signalMCDirectory = '/eos/cms/store/group/phys_higgs/cmshww/amassiro/HWWNano/Summer16_102X_nAODv7_Full2016v7/MCl1loose2016v7__MCCorr2016v7__MCCombJJLNu2016__HMlnjjVarsGen__BWReweight_test'#makeMCDirectory("_BWReweight") + +dataDirectory = os.path.join(treeBaseDir, dataReco, dataSteps) +fakeDirectory = os.path.join(treeBaseDir, dataReco, fakeSteps) + +myeosMC = os.path.join(myEOSDir, mcProduction, mcSteps.format(var='')) + +################################################ +############ DATA DECLARATION ################## +################################################ + +DataRun = [ + ['B','Run2016B-02Apr2020_ver2-v1'] , + ['C','Run2016C-02Apr2020-v1'] , + ['D','Run2016D-02Apr2020-v1'] , + ['E','Run2016E-02Apr2020-v1'] , + ['F','Run2016F-02Apr2020-v1'] , + ['G','Run2016G-02Apr2020-v1'] , + ['H','Run2016H-02Apr2020-v1'] , +] + +DataSets = [ + 'SingleMuon', + 'SingleElectron' +] + +DataTrig = { + 'SingleMuon' : 'Trigger_sngMu' , + # 'SingleElectron' : '!Trigger_sngMu && Trigger_sngEl' , + 'SingleElectron' : '!Trigger_sngMu && passSingleElectronHLT' , +} + + +############################################ +############ MORE MC STAT ################## +############################################ + +def CombineBaseW(directory, samples, proc, samplelist): + newbaseW = getBaseWnAOD(directory, mcProduction, samplelist) + for s in samplelist: + addSampleWeight(samples, proc, s, newbaseW+'/baseW') + + +######################################### +############ MC COMMON ################## +######################################### + +mcCommonWeight = 'XSWeight' +########################################### +############# BACKGROUNDS ############### +############################################# +###### WW ######## + +print("WW") + +# LENZIP: I'll stick the WW SS QCD samples in here. They are WW in the end +# LENZIP: I also put here whatever is left of the WWLNuQQ that is not included in qqWWqq +files = nanoGetSampleFiles(mcDirectory, 'WWToLNuQQ') +files += nanoGetSampleFiles(mcDirectory, 'WWToLNuQQ_ext1') +files += nanoGetSampleFiles(mcDirectory,'WmToLNu_WmTo2J_QCD') +files += nanoGetSampleFiles(mcDirectory,'WpToLNu_WpTo2J_QCD') + +samples['WW'] = { + 'name': files, + 'weight': mcCommonWeight, + 'FilesPerJob': 2 +} +CombineBaseW(mcDirectory, samples, 'WW', + ['WWToLNuQQ', 'WWToLNuQQ_ext1']) +addSampleWeight(samples, 'WW', 'WWToLNuQQ', '(!((mjjGen_max>150)*(GenLHE)))') +addSampleWeight(samples, 'WW', 'WWToLNuQQ_ext1', '(!((mjjGen_max>150)*(GenLHE)))') + +# LENZIP: do we need this? It is dileptonic +#samples['WWewk'] = { +# 'name': nanoGetSampleFiles(mcDirectory, 'WpWmJJ_EWK_noTop'), +# 'weight': mcCommonWeight + '*(Sum$(abs(GenPart_pdgId)==6 || GenPart_pdgId==25)==0)', +# #filter tops and Higgs +# 'FilesPerJob': 10 +#} + + +samples['ggWW'] = { + 'name' : nanoGetSampleFiles(mcDirectory, 'GluGluWWToLNuQQ'), + 'weight' : mcCommonWeight, + 'FilesPerJob': 8 +} + +model_B='RelW10.0_B' + +samples['ggWW_reweighted_from500'] = { + 'name' : nanoGetSampleFiles(signalMCDirectory, 'GluGluHToWWToLNuQQ_M500'), + 'weight' : mcCommonWeight+"*( {0}*({0}<10000) )".format(model_B), + 'FilesPerJob': 8 +} + +samples['ggWW_reweighted_from2000'] = { + 'name' : nanoGetSampleFiles(signalMCDirectory, 'GluGluHToWWToLNuQQ_M2000'), + 'weight' : mcCommonWeight+"*( {0}*({0}<1000) )".format(model_B), + 'FilesPerJob': 8 +} + + + +files = nanoGetSampleFiles(mcDirectory,'WpTo2J_WmToLNu_QCD') +files += nanoGetSampleFiles(mcDirectory,'WpToLNu_WmTo2J_QCD') +samples['qqWWqq'] = { + 'name' : files, + 'weight' : mcCommonWeight + "*(mjjGen_max>150)*(GenLHE)", ##it needs to have qq' initial state + 'FilesPerJob': 10 +} + +#LENZIP: included in WW +# nanoGetSampleFiles(signalMCDirectory,'WpWmJJ_QCD_noTop') , +#'weight': XSWeight+'*'+SFweight+'*'+METFilter_MC+'*'+GenLepMatch, +#mcCommonWeight+'*(mjjGen_OTF>=100)'+'*(GenLHE)', +#samples['WW2J'] = { +# 'name' : nanoGetSampleFiles(mcDirectory,'WpWmJJ_QCD_noTop') , +# 'weight' : mcCommonWeight+'*(mjjGen_OTF>=100)'+'*(!GenLHE)', +# 'FilesPerJob': 10 +#} + + +############## SM Higgs ############ +print("SM Higgs") + +############ ggF H->WW ############ +samples['ggH_hww'] = { + 'name': nanoGetSampleFiles('/eos/cms/store/group/phys_higgs/cmshww/amassiro/HWWNano/Summer16_102X_nAODv7_Full2016v7/MCl1loose2016v7__MCCorr2016v7__MCCombJJLNu2016__BWReweight__HMlnjjVarsGen', 'GluGluHToWWToLNuQQ_M125'), + 'weight': mcCommonWeight, + 'FilesPerJob': 10, +} + +############ VBF H->WW ############ +samples['qqH_hww'] = { + 'name': nanoGetSampleFiles('/eos/cms/store/group/phys_higgs/cmshww/amassiro/HWWNano/Summer16_102X_nAODv7_Full2016v7/MCl1loose2016v7__MCCorr2016v7__MCCombJJLNu2016__BWReweight__HMlnjjVarsGen', 'VBFHToWWToLNuQQ_M125'), + 'weight': mcCommonWeight, + 'FilesPerJob': 10 +} + +########################################## +############ SIGNALS ################## +######################################### +print("Signals") + +####### ggH -> WW ################# +for MX in massggh: + for model in models: + model_name = '_'+model.replace('.','') + model_I = model+'_I' + model_I_H = model+'_I_Honly' + model_I_B = model+'_I_Bonly' + model_B = model+'_B' + model_H = model+'_H' + # Model dependent -> Xsec*BR is applied in later step, so remove "SM"-Xsec*BR + # SMxsec = HiggsXS.GetHiggsXS4Sample('YR4','13TeV','GluGluHToWWToLNuQQ_M'+MX)['xs'] + + samples['GGH_'+MX+model_name] = { + 'name': nanoGetSampleFiles(signalMCDirectory, 'GluGluHToWWToLNuQQ_M'+MX), + 'weight': mcCommonWeight + '*( {0}*(abs({0})<50) )'.format(model), + 'FilesPerJob': 15, + } + + samples['GGHINT_'+MX+model_name] = { + 'name': nanoGetSampleFiles(signalMCDirectory, 'GluGluHToWWToLNuQQ_M'+MX), + 'weight': mcCommonWeight + '*( {0}*(abs({0})<50) )'.format(model_I), + 'FilesPerJob': 15, + } + + files = nanoGetSampleFiles(signalMCDirectory, 'GluGluHToWWToLNuQQ_M'+MX) # will be weighted to S+I + files += nanoGetSampleFiles(signalMCDirectory, 'GluGluHToWWToLNuQQ_M500') # just any mass, reweighted to HSM. But not the nominal 125 because that one has no off shell part + # CAUTION when processing the 500 GeV signal. We cannot have a sample with the same name weighted in two different ways + # One solution is to symlink the 500 GeV signal with a different name in the directory (e.g. appending _copybgk to the name) + # and weight the copy as the background. + files += nanoGetSampleFiles(mcDirectory, 'GluGluWWToLNuQQ') # no further weighting, is directly part of B + samples['GGHSBI_'+MX+model_name] = { + 'name': files, + 'weight': mcCommonWeight, + 'FilesPerJob': 10, + } + addSampleWeight(samples, 'GGHSBI_'+MX+model_name, 'GluGluHToWWToLNuQQ_M'+MX, + '( ({0}+{1})*(abs({0}+{1})<50) )'.format(model, model_I)) + addSampleWeight(samples, 'GGHSBI_'+MX+model_name, 'GluGluHToWWToLNuQQ_M500', + '( {0} )'.format(model_H)) + + samples['GGHINT_H_'+MX+model_name] = { + 'name': nanoGetSampleFiles(signalMCDirectory, 'GluGluHToWWToLNuQQ_M'+MX), + 'weight': mcCommonWeight + '*( {0}*(abs({0})<50) )'.format(model_I_H), + 'FilesPerJob': 15, + } + samples['GGHINT_B_'+MX+model_name] = { + 'name': nanoGetSampleFiles(signalMCDirectory, 'GluGluHToWWToLNuQQ_M'+MX), + 'weight': mcCommonWeight + '*( {0}*(abs({0})<50) )'.format(model_I_B), + 'FilesPerJob': 15, + } + samples['GGH_HSM_'+MX+model_name] = { + 'name': nanoGetSampleFiles(signalMCDirectory, 'GluGluHToWWToLNuQQ_M'+MX), + 'weight': mcCommonWeight + '*( {0} )'.format(model_H), + 'FilesPerJob': 15, + } + samples['GGH_B_'+MX+model_name] = { + 'name': nanoGetSampleFiles(signalMCDirectory, 'GluGluHToWWToLNuQQ_M'+MX), + 'weight': mcCommonWeight + '*( {0} )'.format(model_B), + 'FilesPerJob': 15, + } +# +# +# +# +############ VBF H->WW ############ +for MX in massvbf: + for model in models: + model_name = '_'+model.replace('.','') + model_I = model+'_I' + model_I_H = model+'_I_Honly' + model_I_B = model+'_I_Bonly' + model_B = model+'_B' + model_H = model+'_H' + # Model dependent -> Xsec*BR is applied in later step, so remove "SM"-Xsec*BR + # SMxsec = HiggsXS.GetHiggsXS4Sample('YR4','13TeV','VBFHToWWToLNuQQ_M'+MX)['xs'] + # noSMxsec = '(1.0/{})'.format(SMxsec) + + samples['QQH_'+MX+model_name] = { + 'name': nanoGetSampleFiles(signalMCDirectory, 'VBFHToWWToLNuQQ_M'+MX), + 'weight': mcCommonWeight + '*( {0}*(abs({0})<50) )'.format(model), + 'FilesPerJob': 15, + } + + samples['QQHINT_'+MX+model_name] = { + 'name': nanoGetSampleFiles(signalMCDirectory, 'VBFHToWWToLNuQQ_M'+MX), + 'weight': mcCommonWeight + '*( {0}*(abs({0})<50) )'.format(model_I), + 'FilesPerJob': 15, + } + + files = nanoGetSampleFiles(signalMCDirectory, 'VBFHToWWToLNuQQ_M'+MX) + files += nanoGetSampleFiles(signalMCDirectory, 'VBFHToWWToLNuQQ_M500') # just any mass, reweighted to HSM. But not the nominal 125 because that one has no off shell part + # CAUTION when processing the 500 GeV signal. We cannot have a sample with the same name weighted in two different ways + # One solution is to symlink the 500 GeV signal with a different name in the directory (e.g. appending _copybgk to the name) # and weight the copy as the background. + files += nanoGetSampleFiles(mcDirectory, 'WpTo2J_WmToLNu_QCD') # this is part of b with the same gen level selection as in qqWWqq + files += nanoGetSampleFiles(mcDirectory, 'WpToLNu_WmTo2J_QCD') # this is part of b with the same gen level selection as in qqWWqq + + samples['QQHSBI_'+MX+model_name] = { + 'name': files, + 'weight': mcCommonWeight, + 'FilesPerJob': 10, + } + addSampleWeight(samples, 'QQHSBI_'+MX+model_name, 'VBFHToWWToLNuQQ_M'+MX, + '( ({0}+{1})*(abs({0}+{1})<50) )'.format(model, model_I)) + addSampleWeight(samples, 'QQHSBI_'+MX+model_name, 'VBFHToWWToLNuQQ_M500', + '( {0} )'.format(model_H)) + addSampleWeight(samples, 'QQHSBI_'+MX+model_name, 'WpTo2J_WmToLNu_QCD', + '(mjjGen_max>=150)*(GenLHE)') + addSampleWeight(samples, 'QQHSBI_'+MX+model_name, 'WpToLNu_WmTo2J_QCD', + '(mjjGen_max>=150)*(GenLHE)') + + samples['QQHINT_H_'+MX+model_name] = { + 'name': nanoGetSampleFiles(signalMCDirectory, 'VBFHToWWToLNuQQ_M'+MX), + 'weight': mcCommonWeight+'*( {0}* (abs({0})<50) )'.format(model_I_H), + 'FilesPerJob': 15, + } + + samples['QQHINT_B_'+MX+model_name] = { + 'name': nanoGetSampleFiles(signalMCDirectory, 'VBFHToWWToLNuQQ_M'+MX), + 'weight': mcCommonWeight+'*( {0}* (abs({0})<50) )'.format(model_I_B), + 'FilesPerJob': 15, + } + + samples['QQH_HSM_'+MX+model_name] = { + 'name': nanoGetSampleFiles(signalMCDirectory, 'VBFHToWWToLNuQQ_M'+MX), + 'weight': mcCommonWeight +'*( {0} )'.format(model_H), + 'FilesPerJob': 15, + } + samples['QQH_B_'+MX+model_name] = { + 'name': nanoGetSampleFiles(signalMCDirectory, 'VBFHToWWToLNuQQ_M'+MX), + 'weight': mcCommonWeight +'*( {0} )'.format(model_B), + 'FilesPerJob': 15, + } + +# +# +# +# + +Mu_jetEt = 35 +El_jetEt = 35 +fakeW = 'FW_mu'+str(Mu_jetEt)+ '_el'+str(El_jetEt)+'[0]' + diff --git a/Configurations/HWWSemiLepHighMass/Gen2016_v7/structure_medmass.py b/Configurations/HWWSemiLepHighMass/Gen2016_v7/structure_medmass.py new file mode 100644 index 0000000000..f841ffae7d --- /dev/null +++ b/Configurations/HWWSemiLepHighMass/Gen2016_v7/structure_medmass.py @@ -0,0 +1,233 @@ +# structure configuration for datacard + +#structure = {} + +# keys here must match keys in samples.py +# + +massesAndModelsFile = "massesAndModels.py" +if os.path.exists(massesAndModelsFile) : + handle = open(massesAndModelsFile,'r') + exec(handle) + handle.close() +else: + print "!!! ERROR file ", massesAndModelsFile, " does not exist." + +structure['DY'] = { + 'isSignal' : 0, + 'isData' : 0 +} + + +structure['Wjets'] = { + 'isSignal' : 0, + 'isData' : 0 +} + +structure['top'] = { + 'isSignal' : 0, + 'isData' : 0 +} + + +structure['WW'] = { + 'isSignal' : 0, + 'isData' : 0 +} + +structure['WWewk'] = { + 'isSignal' : 0, + 'isData' : 0 +} + +structure['ggWW'] = { + 'isSignal' : 0, + 'isData' : 0 +} + +structure['qqWWqq'] = { + 'isSignal' : 0, + 'isData' : 0 +} + +structure['WW2J'] = { + 'isSignal' : 0, + 'isData' : 0 +} + +# structure['Wg'] = { +# 'isSignal' : 0, +# 'isData' : 0 +# } + +structure['Vg'] = { + 'isSignal' : 0, + 'isData' : 0 + } + +structure['VgS'] = { + 'isSignal' : 0, + 'isData' : 0 + } + +structure['VgS_L'] = { + 'isSignal' : 0, + 'isData' : 0 + } + +structure['VgS_H'] = { + 'isSignal' : 0, + 'isData' : 0 + } + +# structure['Zg'] = { +# 'isSignal' : 0, +# 'isData' : 0 +# } + +structure['VZ'] = { + 'isSignal' : 0, + 'isData' : 0 + } + + +structure['VVV'] = { + 'isSignal' : 0, + 'isData' : 0 + } + +#structure['QCD'] = { +# 'isSignal' : 0, +# 'isData' : 0 +##} + +structure['ggH_hww'] = { + 'isSignal' : 0, + 'isData' : 0 + } + +structure['qqH_hww'] = { + 'isSignal' : 0, + 'isData' : 0 + } + +structure['WH_hww'] = { + 'isSignal' : 0, + 'isData' : 0 + } + +structure['ZH_hww'] = { + 'isSignal' : 0, + 'isData' : 0 + } + +# structure['ggZH_hww'] = { +# 'isSignal' : 0, +# 'isData' : 0 +# } + +# structure['bbH_hww'] = { +# 'isSignal' : 0, +# 'isData' : 0 +# } + +# structure['ttH_hww'] = { +# 'isSignal' : 0, +# 'isData' : 0 +# } + +structure['ggH_htt'] = { + 'isSignal' : 0, + 'isData' : 0, + } + +structure['qqH_htt'] = { + 'isSignal' : 0, + 'isData' : 0, + } + +structure['WH_htt'] = { + 'isSignal' : 0, + 'isData' : 0, + } + +structure['ZH_htt'] = { + 'isSignal' : 0, + 'isData' : 0, + } + + +structure['FAKE'] = { + 'isSignal' : 0, + 'isData' : 0, + } + + +for MX in plotmasses: + xs_ggf = 2*HiggsXS.GetHiggsXS4Sample('YR4','13TeV','GluGluHToWWToLNuQQ_M{}'.format(MX))['xs'] + xs_vbf = 2*HiggsXS.GetHiggsXS4Sample('YR4','13TeV','VBFHToWWToLNuQQ_M{}'.format(MX))['xs'] + structure['GGH_'+MX+'_RelW002'] = { + 'isSignal': 1, + 'isData' : 0, + #'scaleSampleForDatacard' : {cut : xs_ggf for cut in cuts} + } + structure['GGHINT_'+MX+'_RelW002'] = { + 'isSignal': 1, + 'isData' : 0, + 'scaleSampleForDatacard' : {cut : xs_ggf for cut in cuts} + } + structure['GGHSBI_'+MX+'_RelW002'] = { + 'isSignal': 1, + 'isData' : 0, + #'scaleSampleForDatacard' : {cut : xs_ggf for cut in cuts} + } + print xs_ggf + + structure['QQH_'+MX+'_RelW002'] = { + 'isSignal': 1, + 'isData' : 0, + #'scaleSampleForDatacard' : {cut : xs_vbf for cut in cuts} + } + structure['QQHINT_'+MX+'_RelW002'] = { + 'isSignal': 1, + 'isData' : 0, + 'scaleSampleForDatacard' : {cut : xs_vbf for cut in cuts} + } + structure['QQHSBI_'+MX+'_RelW002'] = { + 'isSignal': 1, + 'isData' : 0, + #'scaleSampleForDatacard' : {cut : xs_vbf for cut in cuts} + } + + + +#for MX in ['500', '800', '1000','1500', '2000', '3000']: +# structure['QQH_'+MX+'_RelW002'] = { +# 'isSignal': 1, +# 'isData' : 0 +# } + + + + + +# data + + +structure['DATA'] = { + 'isSignal' : 0, + 'isData' : 1 + } + + + +# print "INSTRUCTURE" +# print cuts +# print nuisances['WWresum0j'] +# print "OK" + +for nuis in nuisances.itervalues(): + if 'cutspost' in nuis: + nuis['cuts'] = nuis['cutspost'](nuis, cuts) + + print nuis diff --git a/Configurations/HWWSemiLepHighMass/Gen2016_v7/variables_medmass.py b/Configurations/HWWSemiLepHighMass/Gen2016_v7/variables_medmass.py new file mode 100644 index 0000000000..7588607d72 --- /dev/null +++ b/Configurations/HWWSemiLepHighMass/Gen2016_v7/variables_medmass.py @@ -0,0 +1,38 @@ +# # variables +# +# variables = {} + +variables['events'] = { + 'name' : '1', + 'range': (1,0,2), + 'xaxis': 'events', + 'fold' : 3, +} + +variables['mjjGen_max'] = { + 'name' : 'mjjGen_max', + 'range': (20,0,400), + 'xaxis': 'events', + 'fold' : 3, +} + +variables['GenEvtFlag'] = { + 'name' : 'GenEvtFlag', + 'range': (3,0,3), + 'xaxis': 'events', + 'fold' : 3, +} + +variables['GenH_mass'] = { + 'name' : 'GenH_mass', + 'range': (100,0,5000), + 'xaxis': 'events', + 'fold' : 3, +} + +variables['GenH_mass_morebins'] = { + 'name' : 'GenH_mass', + 'range': (500,0,5000), + 'xaxis': 'events', + 'fold' : 3, +} diff --git a/Configurations/patches/GetGenObservables.cc b/Configurations/patches/GetGenObservables.cc new file mode 100644 index 0000000000..f87ce8c427 --- /dev/null +++ b/Configurations/patches/GetGenObservables.cc @@ -0,0 +1,268 @@ +#include "LatinoAnalysis/MultiDraw/interface/TTreeFunction.h" +#include "LatinoAnalysis/MultiDraw/interface/FunctionLibrary.h" + +#include +#include "TLorentzVector.h" + +#include "TVector2.h" +#include "Math/Vector4Dfwd.h" +#include "Math/GenVector/LorentzVector.h" +#include "Math/GenVector/PtEtaPhiM4D.h" + +#include + +class GetGenObservables : public multidraw::TTreeFunction { +public: + GetGenObservables( std::string observable_); + + char const* getName() const override { return "GetGenObservables"; } + TTreeFunction* clone() const override { return new GetGenObservables(observable); } + + unsigned getNdata() override { return 1; } + double evaluate(unsigned) override; + +protected: + void bindTree_(multidraw::FunctionLibrary&) override; + + UIntValueReader* nGenDressedLepton{}; + IntArrayReader* GenDressedLepton_pdgId{}; + FloatArrayReader* GenDressedLepton_pt{}; + FloatArrayReader* GenDressedLepton_eta{}; + FloatArrayReader* GenDressedLepton_phi{}; + FloatArrayReader* GenDressedLepton_mass{}; + UIntValueReader* nGenJet{}; + FloatArrayReader* GenJet_pt{}; + FloatArrayReader* GenJet_eta{}; + FloatArrayReader* GenJet_phi{}; + FloatArrayReader* GenJet_mass{}; + FloatValueReader* GenMET_pt{}; + IntArrayReader* GenJet_partonFlavour{}; + FloatValueReader* GenMET_phi{}; + std::string observable; +}; + +GetGenObservables::GetGenObservables(std::string observable_) : + TTreeFunction() +{ + observable=observable_; +} + +// The actual function begins here, above is C++ bloat <3 + +double GetGenObservables::evaluate(unsigned) +{ + float ptl_1{-999}, ptl_2{-999}, ptl_3{-999}, ptll_{-999}, mll_{-999}, ptj_1{-999}, ptj_2{-999}, mjj_{-999},mjjmax_{-999},mth_{1}, MET_{-999}, eta_l1{-999}, eta_l2{-999}, eta_j1{-999}, eta_j2{-999},pdgid_1{-999}, pdgid_2{-999}, dphijj{-999}, met_{-999}, mtw1_{-999}, mtw2_{-999}, nj_pt_30{0}, nj_pt_20{0}, detajj{-999}, dphill{-999}, mTi{-999}, dphillmet{-999}, drll{-999}, ht{0}, ctot{-999}, bjets{0}, phij1{-999}, phij2{-999}, phil1{-999}, phil2{-999}, ptww{-999}; + + unsigned nJ{*nGenJet->Get()}; + + unsigned nL{*nGenDressedLepton->Get()}; + + // If there are no prompt leptons don't bother checking and just count the jets w/ pt > 30 + // Why not returning default value? + + if (nL == 0) { + unsigned n{0}; + for (unsigned iJ{0}; iJ != nJ; ++iJ) { + if (GenJet_pt->At(iJ) > 30.){ + ++n; + } + } + //return n; + + } + + // Create prompt gen leptons 4-vectors + + std::vector dressedLeptons{}; + for (unsigned iL=0; iLAt(iL), + GenDressedLepton_eta->At(iL), + GenDressedLepton_phi->At(iL), + GenDressedLepton_mass->At(iL)); + } + + // Do the actual cleaning, hacked to stop at 2 + + // If there are less than 2 jets, return underflow value + + TLorentzVector j1{}; // clean gen jet 1 & 2 + TLorentzVector j2{}; + std::vector CleanJet_ids; + + // Loop opver prompt gen jets and check overlap with prompt gen leptons + // If there is no overlap, keep the jet (up to two jets kept) + + unsigned n{0}; + for (unsigned iJ{0}; iJ != nJ; ++iJ) { + if (GenJet_pt->At(iJ) < 30.) // FIXME!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + continue; + + bool overlap{false}; + for (auto& p4 : dressedLeptons) { + if (p4.pt() < 10.) + continue; + + double dEta{p4.eta() - GenJet_eta->At(iJ)}; + double dPhi{TVector2::Phi_mpi_pi(p4.phi() - GenJet_phi->At(iJ))}; + if (dEta * dEta + dPhi * dPhi < 0.16) { + overlap = true; + break; + } + } + if (!overlap) { + CleanJet_ids.push_back(iJ); + if (n == 0) { j1.SetPtEtaPhiM(GenJet_pt->At(iJ), GenJet_eta->At(iJ), GenJet_phi->At(iJ), GenJet_mass->At(iJ)); } + else if (n == 1){ j2.SetPtEtaPhiM(GenJet_pt->At(iJ), GenJet_eta->At(iJ), GenJet_phi->At(iJ), GenJet_mass->At(iJ)); } + ++n; + if (GenJet_pt->At(iJ) > 20.) { nj_pt_20++;} + if (GenJet_pt->At(iJ) > 30.) { + nj_pt_30++; + if (abs(GenJet_partonFlavour->At(iJ)) == 5) { + bjets++; + } + ht += GenJet_pt->At(iJ); + } + } + } + + TLorentzVector MET{}; + MET.SetPtEtaPhiM(*GenMET_pt->Get(), 0., *GenMET_phi->Get(), 0.); + met_=MET.Pt(); + +if (dressedLeptons.size() >0){ + ptl_1 = dressedLeptons[0].pt(); + eta_l1=dressedLeptons[0].eta(); + pdgid_1=(int)GenDressedLepton_pdgId->At(0); + phil1=dressedLeptons[0].phi(); + if (dressedLeptons.size() >1) { + TLorentzVector PTl1{}; + PTl1.SetPtEtaPhiM(dressedLeptons[0].pt(), dressedLeptons[0].eta(),dressedLeptons[0].phi(),dressedLeptons[0].M()); + TLorentzVector PTl2{}; + PTl2.SetPtEtaPhiM(dressedLeptons[1].pt(), dressedLeptons[1].eta(),dressedLeptons[1].phi(),dressedLeptons[1].M()); + ptl_2 = dressedLeptons[1].pt(); + ptll_= (dressedLeptons[0]+dressedLeptons[1]).pt(); + mll_=(dressedLeptons[0]+dressedLeptons[1]).M(); + eta_l2=dressedLeptons[1].eta(); + pdgid_2=(int)GenDressedLepton_pdgId->At(1); + phil2=dressedLeptons[1].phi(); + + ptww = (PTl1+PTl2+MET).Pt(); + + + dphill = PTl1.DeltaPhi(PTl2); + if (dphill > TMath::Pi()) dphill = dphill - 2*TMath::Pi(); + if (dphill < -TMath::Pi()) dphill = dphill + 2*TMath::Pi(); + + drll = PTl1.DeltaR(PTl2); + + mth_ = TMath::Sqrt(ptll_*MET.Pt()*2*(1-TMath::Cos((PTl1+PTl2).DeltaPhi(MET)))); + dphillmet = (PTl1+PTl2).DeltaPhi(MET); + mTi = (PTl1+PTl2+MET).M(); + mtw1_ = TMath::Sqrt(PTl1.Pt()*MET.Pt()*2*(1-TMath::Cos(PTl1.DeltaPhi(MET)))); + mtw2_ = TMath::Sqrt(PTl2.Pt()*MET.Pt()*2*(1-TMath::Cos(PTl2.DeltaPhi(MET)))); + + if (dressedLeptons.size() >2) ptl_3 = dressedLeptons[2].pt(); + } +} + + +if (n >0){ + ptj_1 = j1.Pt(); + eta_j1=j1.Eta(); + + if (n >1) { + ptj_2 = j2.Pt(); + mjj_=(j1+j2).M(); + eta_j2=j2.Eta(); + + detajj=TMath::Abs(eta_j1-eta_j2); + + phij1 = j1.Phi(); + phij2 = j2.Phi(); + if (eta_j1 > eta_j2) dphijj = phij1 - phij2; + else if (eta_j1 <= eta_j2) dphijj = phij2 - phij1; + if (dphijj > TMath::Pi()) dphijj = dphijj - 2*TMath::Pi(); + if (dphijj < -TMath::Pi()) dphijj = dphijj + 2*TMath::Pi(); + if (dressedLeptons.size() >1) { + ctot = TMath::Log((TMath::Abs(2*eta_l1-eta_j1-eta_j2)+TMath::Abs(2*eta_l2-eta_j1-eta_j2))/detajj); + } + } +} +if (CleanJet_ids.size()>=2){ + for (int ij1 = 0; ij1 < CleanJet_ids.size()-1; ++ij1){ + TLorentzVector j1_tmp{}; + TLorentzVector j2_tmp{}; + j1_tmp.SetPtEtaPhiM(GenJet_pt->At(ij1), GenJet_eta->At(ij1), GenJet_phi->At(ij1), GenJet_mass->At(ij1)); + for (int ij2 = ij1+1; ij2 < CleanJet_ids.size(); ++ij2){ + j2_tmp.SetPtEtaPhiM(GenJet_pt->At(ij2), GenJet_eta->At(ij2), GenJet_phi->At(ij2), GenJet_mass->At(ij2)); + } + double mjj_tmp = (j1_tmp+j2_tmp).M(); + if (mjj_tmp > mjjmax_){ mjjmax_ = mjj_tmp;} + } +} + + + + + + // Define additional useful variables (for fiducial region definition) +if (observable.compare("ptl1")==0) return ptl_1; +if (observable.compare("ptl2")==0) return ptl_2; +if (observable.compare("ptl3")==0) return ptl_3; +if (observable.compare("ptll")==0) return ptll_; +if (observable.compare("mll")==0) return mll_; +if (observable.compare("etal1")==0) return eta_l1; +if (observable.compare("etal2")==0) return eta_l2; +if (observable.compare("pdgid1")==0) return pdgid_1; +if (observable.compare("pdgid2")==0) return pdgid_2; +if (observable.compare("phil1")==0) return phil1; +if (observable.compare("phil2")==0) return phil2; +if (observable.compare("dphill")==0) return dphill; +if (observable.compare("drll")==0) return drll; +if (observable.compare("ptww")==0) return ptww; + +if (observable.compare("ptj1")==0) return ptj_1; +if (observable.compare("ptj2")==0) return ptj_2; +if (observable.compare("etaj1")==0) return eta_j1; +if (observable.compare("etaj2")==0) return eta_j2; +if (observable.compare("phij1")==0) return phij1; +if (observable.compare("phij2")==0) return phij2; +if (observable.compare("mjj")==0) return mjj_; +if (observable.compare("mjjmax")==0) return mjjmax_; +if (observable.compare("dphijj")==0) return dphijj; +if (observable.compare("detajj")==0) return detajj; +if (observable.compare("nj_pt_30")==0) return nj_pt_30; +if (observable.compare("nj_pt_20")==0) return nj_pt_20; +if (observable.compare("ht")==0) return ht; +if (observable.compare("ctot")==0) return ctot; +if (observable.compare("bjets")==0) return bjets; + +if (observable.compare("mth")==0) return mth_; +if (observable.compare("mti")==0) return mTi; +if (observable.compare("dphillmet")==0) return dphillmet; +if (observable.compare("met")==0) return met_; +if (observable.compare("mtw1")==0) return mtw1_; +if (observable.compare("mtw2")==0) return mtw2_; + + +return -300; +} + +void GetGenObservables::bindTree_(multidraw::FunctionLibrary& _library) +{ + _library.bindBranch(nGenDressedLepton, "nGenDressedLepton"); + _library.bindBranch(GenDressedLepton_pdgId, "GenDressedLepton_pdgId"); + _library.bindBranch(GenDressedLepton_pt, "GenDressedLepton_pt"); + _library.bindBranch(GenDressedLepton_eta, "GenDressedLepton_eta"); + _library.bindBranch(GenDressedLepton_phi, "GenDressedLepton_phi"); + _library.bindBranch(GenDressedLepton_mass, "GenDressedLepton_mass"); + _library.bindBranch(nGenJet, "nGenJet"); + _library.bindBranch(GenJet_pt, "GenJet_pt"); + _library.bindBranch(GenJet_eta, "GenJet_eta"); + _library.bindBranch(GenJet_phi, "GenJet_phi"); + _library.bindBranch(GenJet_partonFlavour, "GenJet_partonFlavour"); + _library.bindBranch(GenJet_mass, "GenJet_mass"); + _library.bindBranch(GenMET_pt, "GenMET_pt"); + _library.bindBranch(GenMET_phi, "GenMET_phi"); +}