diff --git a/data/ScaleFactors/Electrons_highEtaCorrection.json b/data/ScaleFactors/Electrons_highEtaCorrection.json new file mode 100644 index 0000000..5b1c0e2 --- /dev/null +++ b/data/ScaleFactors/Electrons_highEtaCorrection.json @@ -0,0 +1,901 @@ +{ + "variables": [ + "Eta", + "Pt" + ], + "error_type": "absolute", + "data": [ + { + "bin": [ + -2.5, + -2.3979591836734695 + ], + "values": [ + { + "bin": [ + 0.0, + 5000.0 + ], + "error_low": 0.9147010715224184, + "value": 0.9147010715224184, + "error_high": 1.0 + } + ] + }, + { + "bin": [ + -2.3979591836734695, + -2.295918367346939 + ], + "values": [ + { + "bin": [ + 0.0, + 5000.0 + ], + "error_low": 0.9209021212818064, + "value": 0.9209021212818064, + "error_high": 1.0 + } + ] + }, + { + "bin": [ + -2.295918367346939, + -2.193877551020408 + ], + "values": [ + { + "bin": [ + 0.0, + 5000.0 + ], + "error_low": 0.9288830988144062, + "value": 0.9288830988144062, + "error_high": 1.0 + } + ] + }, + { + "bin": [ + -2.193877551020408, + -2.0918367346938775 + ], + "values": [ + { + "bin": [ + 0.0, + 5000.0 + ], + "error_low": 0.9380740787469507, + "value": 0.9380740787469507, + "error_high": 1.0 + } + ] + }, + { + "bin": [ + -2.0918367346938775, + -1.989795918367347 + ], + "values": [ + { + "bin": [ + 0.0, + 5000.0 + ], + "error_low": 0.9479796300639068, + "value": 0.9479796300639068, + "error_high": 1.0 + } + ] + }, + { + "bin": [ + -1.989795918367347, + -1.8877551020408163 + ], + "values": [ + { + "bin": [ + 0.0, + 5000.0 + ], + "error_low": 0.9581746516895165, + "value": 0.9581746516895165, + "error_high": 1.0 + } + ] + }, + { + "bin": [ + -1.8877551020408163, + -1.7857142857142856 + ], + "values": [ + { + "bin": [ + 0.0, + 5000.0 + ], + "error_low": 0.9683002080698367, + "value": 0.9683002080698367, + "error_high": 1.0 + } + ] + }, + { + "bin": [ + -1.7857142857142856, + -1.683673469387755 + ], + "values": [ + { + "bin": [ + 0.0, + 5000.0 + ], + "error_low": 0.9780593647547806, + "value": 0.9780593647547806, + "error_high": 1.0 + } + ] + }, + { + "bin": [ + -1.683673469387755, + -1.5816326530612246 + ], + "values": [ + { + "bin": [ + 0.0, + 5000.0 + ], + "error_low": 0.9872130239801575, + "value": 0.9872130239801575, + "error_high": 1.0 + } + ] + }, + { + "bin": [ + -1.5816326530612246, + -1.4795918367346939 + ], + "values": [ + { + "bin": [ + 0.0, + 5000.0 + ], + "error_low": 0.9955757602497151, + "value": 0.9955757602497151, + "error_high": 1.0 + } + ] + }, + { + "bin": [ + -1.4795918367346939, + -1.3775510204081631 + ], + "values": [ + { + "bin": [ + 0.0, + 5000.0 + ], + "error_low": 1.0030116559171776, + "value": 1.0030116559171776, + "error_high": 1.0 + } + ] + }, + { + "bin": [ + -1.3775510204081631, + -1.2755102040816326 + ], + "values": [ + { + "bin": [ + 0.0, + 5000.0 + ], + "error_low": 1.0094301367682892, + "value": 1.0094301367682892, + "error_high": 1.0 + } + ] + }, + { + "bin": [ + -1.2755102040816326, + -1.1734693877551021 + ], + "values": [ + { + "bin": [ + 0.0, + 5000.0 + ], + "error_low": 1.014781807602853, + "value": 1.014781807602853, + "error_high": 1.0 + } + ] + }, + { + "bin": [ + -1.1734693877551021, + -1.0714285714285714 + ], + "values": [ + { + "bin": [ + 0.0, + 5000.0 + ], + "error_low": 1.0190542878167725, + "value": 1.0190542878167725, + "error_high": 1.0 + } + ] + }, + { + "bin": [ + -1.0714285714285714, + -0.9693877551020407 + ], + "values": [ + { + "bin": [ + 0.0, + 5000.0 + ], + "error_low": 1.0222680469840917, + "value": 1.0222680469840917, + "error_high": 1.0 + } + ] + }, + { + "bin": [ + -0.9693877551020407, + -0.8673469387755102 + ], + "values": [ + { + "bin": [ + 0.0, + 5000.0 + ], + "error_low": 1.0244722404390358, + "value": 1.0244722404390358, + "error_high": 1.0 + } + ] + }, + { + "bin": [ + -0.8673469387755102, + -0.7653061224489797 + ], + "values": [ + { + "bin": [ + 0.0, + 5000.0 + ], + "error_low": 1.0257405448580523, + "value": 1.0257405448580523, + "error_high": 1.0 + } + ] + }, + { + "bin": [ + -0.7653061224489797, + -0.6632653061224489 + ], + "values": [ + { + "bin": [ + 0.0, + 5000.0 + ], + "error_low": 1.0261669938418516, + "value": 1.0261669938418516, + "error_high": 1.0 + } + ] + }, + { + "bin": [ + -0.6632653061224489, + -0.5612244897959182 + ], + "values": [ + { + "bin": [ + 0.0, + 5000.0 + ], + "error_low": 1.0258618134974473, + "value": 1.0258618134974473, + "error_high": 1.0 + } + ] + }, + { + "bin": [ + -0.5612244897959182, + -0.4591836734693877 + ], + "values": [ + { + "bin": [ + 0.0, + 5000.0 + ], + "error_low": 1.0249472580201975, + "value": 1.0249472580201975, + "error_high": 1.0 + } + ] + }, + { + "bin": [ + -0.4591836734693877, + -0.3571428571428572 + ], + "values": [ + { + "bin": [ + 0.0, + 5000.0 + ], + "error_low": 1.0235534452758441, + "value": 1.0235534452758441, + "error_high": 1.0 + } + ] + }, + { + "bin": [ + -0.3571428571428572, + -0.25510204081632626 + ], + "values": [ + { + "bin": [ + 0.0, + 5000.0 + ], + "error_low": 1.0218141923825563, + "value": 1.0218141923825563, + "error_high": 1.0 + } + ] + }, + { + "bin": [ + -0.25510204081632626, + -0.15306122448979576 + ], + "values": [ + { + "bin": [ + 0.0, + 5000.0 + ], + "error_low": 1.019862851292968, + "value": 1.019862851292968, + "error_high": 1.0 + } + ] + }, + { + "bin": [ + -0.15306122448979576, + -0.05102040816326525 + ], + "values": [ + { + "bin": [ + 0.0, + 5000.0 + ], + "error_low": 1.0178281443762192, + "value": 1.0178281443762192, + "error_high": 1.0 + } + ] + }, + { + "bin": [ + -0.05102040816326525, + 0.05102040816326525 + ], + "values": [ + { + "bin": [ + 0.0, + 5000.0 + ], + "error_low": 1.01583, + "value": 1.01583, + "error_high": 1.0 + } + ] + }, + { + "bin": [ + 0.05102040816326525, + 0.15306122448979576 + ], + "values": [ + { + "bin": [ + 0.0, + 5000.0 + ], + "error_low": 1.0139753881125864, + "value": 1.0139753881125864, + "error_high": 1.0 + } + ] + }, + { + "bin": [ + 0.15306122448979576, + 0.2551020408163267 + ], + "values": [ + { + "bin": [ + 0.0, + 5000.0 + ], + "error_low": 1.0123541558248843, + "value": 1.0123541558248843, + "error_high": 1.0 + } + ] + }, + { + "bin": [ + 0.2551020408163267, + 0.3571428571428572 + ], + "values": [ + { + "bin": [ + 0.0, + 5000.0 + ], + "error_low": 1.0110348629924688, + "value": 1.0110348629924688, + "error_high": 1.0 + } + ] + }, + { + "bin": [ + 0.3571428571428572, + 0.4591836734693877 + ], + "values": [ + { + "bin": [ + 0.0, + 5000.0 + ], + "error_low": 1.010060617797625, + "value": 1.010060617797625, + "error_high": 1.0 + } + ] + }, + { + "bin": [ + 0.4591836734693877, + 0.5612244897959187 + ], + "values": [ + { + "bin": [ + 0.0, + 5000.0 + ], + "error_low": 1.0094449123313896, + "value": 1.0094449123313896, + "error_high": 1.0 + } + ] + }, + { + "bin": [ + 0.5612244897959187, + 0.6632653061224492 + ], + "values": [ + { + "bin": [ + 0.0, + 5000.0 + ], + "error_low": 1.0091674581755903, + "value": 1.0091674581755903, + "error_high": 1.0 + } + ] + }, + { + "bin": [ + 0.6632653061224492, + 0.7653061224489797 + ], + "values": [ + { + "bin": [ + 0.0, + 5000.0 + ], + "error_low": 1.0091700219848871, + "value": 1.0091700219848871, + "error_high": 1.0 + } + ] + }, + { + "bin": [ + 0.7653061224489797, + 0.8673469387755102 + ], + "values": [ + { + "bin": [ + 0.0, + 5000.0 + ], + "error_low": 1.009352261068813, + "value": 1.009352261068813, + "error_high": 1.0 + } + ] + }, + { + "bin": [ + 0.8673469387755102, + 0.9693877551020407 + ], + "values": [ + { + "bin": [ + 0.0, + 5000.0 + ], + "error_low": 1.009567558973815, + "value": 1.009567558973815, + "error_high": 1.0 + } + ] + }, + { + "bin": [ + 0.9693877551020407, + 1.0714285714285716 + ], + "values": [ + { + "bin": [ + 0.0, + 5000.0 + ], + "error_low": 1.009618861065293, + "value": 1.009618861065293, + "error_high": 1.0 + } + ] + }, + { + "bin": [ + 1.0714285714285716, + 1.1734693877551021 + ], + "values": [ + { + "bin": [ + 0.0, + 5000.0 + ], + "error_low": 1.0092545101096433, + "value": 1.0092545101096433, + "error_high": 1.0 + } + ] + }, + { + "bin": [ + 1.1734693877551021, + 1.2755102040816326 + ], + "values": [ + { + "bin": [ + 0.0, + 5000.0 + ], + "error_low": 1.0081640818562974, + "value": 1.0081640818562974, + "error_high": 1.0 + } + ] + }, + { + "bin": [ + 1.2755102040816326, + 1.3775510204081636 + ], + "values": [ + { + "bin": [ + 0.0, + 5000.0 + ], + "error_low": 1.005974220619763, + "value": 1.005974220619763, + "error_high": 1.0 + } + ] + }, + { + "bin": [ + 1.3775510204081636, + 1.479591836734694 + ], + "values": [ + { + "bin": [ + 0.0, + 5000.0 + ], + "error_low": 1.0022444748616646, + "value": 1.0022444748616646, + "error_high": 1.0 + } + ] + }, + { + "bin": [ + 1.479591836734694, + 1.5816326530612246 + ], + "values": [ + { + "bin": [ + 0.0, + 5000.0 + ], + "error_low": 0.9964631327727851, + "value": 0.9964631327727851, + "error_high": 1.0 + } + ] + }, + { + "bin": [ + 1.5816326530612246, + 1.683673469387755 + ], + "values": [ + { + "bin": [ + 0.0, + 5000.0 + ], + "error_low": 0.9880430578551044, + "value": 0.9880430578551044, + "error_high": 1.0 + } + ] + }, + { + "bin": [ + 1.683673469387755, + 1.7857142857142856 + ], + "values": [ + { + "bin": [ + 0.0, + 5000.0 + ], + "error_low": 0.9763175245038425, + "value": 0.9763175245038425, + "error_high": 1.0 + } + ] + }, + { + "bin": [ + 1.7857142857142856, + 1.887755102040816 + ], + "values": [ + { + "bin": [ + 0.0, + 5000.0 + ], + "error_low": 0.9605360535894987, + "value": 0.9605360535894987, + "error_high": 1.0 + } + ] + }, + { + "bin": [ + 1.887755102040816, + 1.9897959183673475 + ], + "values": [ + { + "bin": [ + 0.0, + 5000.0 + ], + "error_low": 0.9398602480398928, + "value": 0.9398602480398928, + "error_high": 1.0 + } + ] + }, + { + "bin": [ + 1.9897959183673475, + 2.091836734693878 + ], + "values": [ + { + "bin": [ + 0.0, + 5000.0 + ], + "error_low": 0.9133596284222054, + "value": 0.9133596284222054, + "error_high": 1.0 + } + ] + }, + { + "bin": [ + 2.091836734693878, + 2.1938775510204085 + ], + "values": [ + { + "bin": [ + 0.0, + 5000.0 + ], + "error_low": 0.880007468525019, + "value": 0.880007468525019, + "error_high": 1.0 + } + ] + }, + { + "bin": [ + 2.1938775510204085, + 2.295918367346939 + ], + "values": [ + { + "bin": [ + 0.0, + 5000.0 + ], + "error_low": 0.8386766309403586, + "value": 0.8386766309403586, + "error_high": 1.0 + } + ] + }, + { + "bin": [ + 2.295918367346939, + 2.3979591836734695 + ], + "values": [ + { + "bin": [ + 0.0, + 5000.0 + ], + "error_low": 0.7881354026457322, + "value": 0.7881354026457322, + "error_high": 1.0 + } + ] + }, + { + "bin": [ + 2.3979591836734695, + 2.5 + ], + "values": [ + { + "bin": [ + 0.0, + 5000.0 + ], + "error_low": 0.7270433305861712, + "value": 0.7270433305861712, + "error_high": 1.0 + } + ] + } + ], + "dimension": 2, + "binning": { + "y": [ + 0.0, + 5000.0 + ], + "x": [ + -2.5, + -2.3979591836734695, + -2.295918367346939, + -2.193877551020408, + -2.0918367346938775, + -1.989795918367347, + -1.8877551020408163, + -1.7857142857142856, + -1.683673469387755, + -1.5816326530612246, + -1.4795918367346939, + -1.3775510204081631, + -1.2755102040816326, + -1.1734693877551021, + -1.0714285714285714, + -0.9693877551020407, + -0.8673469387755102, + -0.7653061224489797, + -0.6632653061224489, + -0.5612244897959182, + -0.4591836734693877, + -0.3571428571428572, + -0.25510204081632626, + -0.15306122448979576, + -0.05102040816326525, + 0.05102040816326525, + 0.15306122448979576, + 0.2551020408163267, + 0.3571428571428572, + 0.4591836734693877, + 0.5612244897959187, + 0.6632653061224492, + 0.7653061224489797, + 0.8673469387755102, + 0.9693877551020407, + 1.0714285714285716, + 1.1734693877551021, + 1.2755102040816326, + 1.3775510204081636, + 1.479591836734694, + 1.5816326530612246, + 1.683673469387755, + 1.7857142857142856, + 1.887755102040816, + 1.9897959183673475, + 2.091836734693878, + 2.1938775510204085, + 2.295918367346939, + 2.3979591836734695, + 2.5 + ] + } +} \ No newline at end of file diff --git a/data/ScaleFactors/Electrons_lowPtCorrection.json b/data/ScaleFactors/Electrons_lowPtCorrection.json new file mode 100644 index 0000000..6df3230 --- /dev/null +++ b/data/ScaleFactors/Electrons_lowPtCorrection.json @@ -0,0 +1,47 @@ +{ + "variables": [ + "Eta", + "Pt" + ], + "error_type": "absolute", + "data": [ + { + "bin": [ + -2.5, + 2.5 + ], + "values": [ + { + "bin": [ + 0.0, + 25.0 + ], + "error_low": 0.9, + "value": 1.0, + "error_high": 1.1 + }, + { + "bin": [ + 25.0, + 5000.0 + ], + "error_low": 1.0, + "value": 1.0, + "error_high": 1.0 + } + ] + } + ], + "dimension": 2, + "binning": { + "y": [ + 0.0, + 25.0, + 5000.0 + ], + "x": [ + -2.5, + 2.5 + ] + } +} \ No newline at end of file diff --git a/python/ElectronsProducer.py b/python/ElectronsProducer.py index 1bd2a30..5c68da9 100644 --- a/python/ElectronsProducer.py +++ b/python/ElectronsProducer.py @@ -32,6 +32,11 @@ hww_wp = cms.untracked.FileInPath('cp3_llbb/Framework/data/ScaleFactors/Electron_Tight_Run2016_Run273726to276811_HWW_weighted.json'), hww_mva80_wp = cms.untracked.FileInPath('cp3_llbb/Framework/data/ScaleFactors/Electron_mva_80p_Iso2016_HWW_Full2016.json'), hww_mva90_wp = cms.untracked.FileInPath('cp3_llbb/Framework/data/ScaleFactors/Electron_mva_90p_Iso2016_HWW_Full2016.json'), + + # The following scale factors are corrections for events at high eta and low pT, coming from: + # https://github.com/latinos/LatinoAnalysis/blob/c62fa0d2fd603eed0001621eb9335afc6ca4cbcd/Gardener/python/variables/LeptonEtaPtCorrFactors.py#L132 + hww_highEta_corr = cms.untracked.FileInPath('cp3_llbb/Framework/data/ScaleFactors/Electrons_highEtaCorrection.json'), + hww_lowPt_corr = cms.untracked.FileInPath('cp3_llbb/Framework/data/ScaleFactors/Electrons_lowPtCorrection.json') ) ), ) diff --git a/scripts/create_highEtaCorr_ScaleFactor.py b/scripts/create_highEtaCorr_ScaleFactor.py new file mode 100644 index 0000000..27d1007 --- /dev/null +++ b/scripts/create_highEtaCorr_ScaleFactor.py @@ -0,0 +1,34 @@ +#! /bin/env python + +import math +import argparse +import ROOT +import os +import numpy as np + + +eta_bins_array = np.linspace(-2.5, 2.5, 50) +eta_bins = eta_bins_array.tolist() +pt_bins_array = np.array([0., 5000.]) +pt_bins = pt_bins_array.tolist() + +json_content = {'dimension': 2, 'variables': ['Eta', 'Pt'], 'binning': {'x': eta_bins, 'y': pt_bins}, 'data': [], 'error_type': 'absolute'} +json_content_data = json_content['data'] + +for i in range(0, len(eta_bins) - 1): + eta_bin = {'bin': [eta_bins[i], eta_bins[i + 1]], 'values': []} + eta_center = (eta_bins[i+1] - eta_bins[i]) / 2 + eta_bins[i] + eta_value = 1.01583 - 0.0190406*eta_center + 0.00696095*(math.pow(eta_center,2)) + 0.0156002*(math.pow(eta_center,3)) - 0.00658065*(math.pow(eta_center,4)) - 0.00313692*(math.pow(eta_center,5)) + eta_error_up = 1. + eta_error_down = eta_value + for j in range(0, len(pt_bins) - 1): + pt_bin = {'bin': [pt_bins[j], pt_bins[j + 1]], 'value': eta_value, 'error_low': eta_value, 'error_high': 1.0} + eta_bin['values'].append(pt_bin) + json_content_data.append(eta_bin) + +# Save JSON file +filename = 'Electrons_highEtaCorrection.json' +with open(filename, 'w') as j: + import json + json.dump(json_content, j, indent=2) + diff --git a/scripts/create_lowPtCorr_ScaleFactor.py b/scripts/create_lowPtCorr_ScaleFactor.py new file mode 100644 index 0000000..06cd337 --- /dev/null +++ b/scripts/create_lowPtCorr_ScaleFactor.py @@ -0,0 +1,31 @@ +#! /bin/env python + +import math +import argparse +import ROOT +import os +import numpy as np + + +eta_bins_array = np.array([-2.5, 2.5]) +eta_bins = eta_bins_array.tolist() +pt_bins_array = np.array([0., 25., 5000.]) +pt_bins = pt_bins_array.tolist() + +json_content = {'dimension': 2, 'variables': ['Eta', 'Pt'], 'binning': {'x': eta_bins, 'y': pt_bins}, 'data': [], 'error_type': 'absolute'} +json_content_data = json_content['data'] + +for i in range(0, len(eta_bins) - 1): + eta_bin = {'bin': [eta_bins[i], eta_bins[i + 1]], 'values': []} + eta_center = (eta_bins[i+1] - eta_bins[i]) / 2 + eta_bins[i] + for j in range(0, len(pt_bins) - 1): + pt_bin = {'bin': [pt_bins[j], pt_bins[j + 1]], 'value': 1., 'error_low': (0.9 if j == 0 else 1.), 'error_high': (1.1 if j == 0 else 1.)} + eta_bin['values'].append(pt_bin) + json_content_data.append(eta_bin) + +# Save JSON file +filename = 'Electrons_lowPtCorrection.json' +with open(filename, 'w') as j: + import json + json.dump(json_content, j, indent=2) + diff --git a/test/unit_tests_data_ref.root b/test/unit_tests_data_ref.root index b5d1f78..6120ed6 100644 Binary files a/test/unit_tests_data_ref.root and b/test/unit_tests_data_ref.root differ diff --git a/test/unit_tests_mc_ref.root b/test/unit_tests_mc_ref.root index 6d1d161..2243bdc 100644 Binary files a/test/unit_tests_mc_ref.root and b/test/unit_tests_mc_ref.root differ diff --git a/test/unit_tests_mc_with_db_ref.root b/test/unit_tests_mc_with_db_ref.root index faaffa3..c984306 100644 Binary files a/test/unit_tests_mc_with_db_ref.root and b/test/unit_tests_mc_with_db_ref.root differ