Skip to content

Commit

Permalink
Merge pull request #275 from alesaggio/addEtaPtCorrections
Browse files Browse the repository at this point in the history
Add scale factors for high eta and low pt events
  • Loading branch information
pieterdavid authored Feb 16, 2018
2 parents f5b8b8e + fe83e65 commit 203f07f
Show file tree
Hide file tree
Showing 8 changed files with 1,018 additions and 0 deletions.
901 changes: 901 additions & 0 deletions data/ScaleFactors/Electrons_highEtaCorrection.json

Large diffs are not rendered by default.

47 changes: 47 additions & 0 deletions data/ScaleFactors/Electrons_lowPtCorrection.json
Original file line number Diff line number Diff line change
@@ -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
]
}
}
5 changes: 5 additions & 0 deletions python/ElectronsProducer.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')
)
),
)
34 changes: 34 additions & 0 deletions scripts/create_highEtaCorr_ScaleFactor.py
Original file line number Diff line number Diff line change
@@ -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)

31 changes: 31 additions & 0 deletions scripts/create_lowPtCorr_ScaleFactor.py
Original file line number Diff line number Diff line change
@@ -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)

Binary file modified test/unit_tests_data_ref.root
Binary file not shown.
Binary file modified test/unit_tests_mc_ref.root
Binary file not shown.
Binary file modified test/unit_tests_mc_with_db_ref.root
Binary file not shown.

0 comments on commit 203f07f

Please sign in to comment.