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

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
2 changes: 1 addition & 1 deletion mkShapesRDF/lib/search_files.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,4 +134,4 @@ def searchFilesDAS(
files = self.cached_list_of_files[process]

files = list(map(lambda k: redirector + k, files))
return files[1:]
return files
1,022 changes: 1,022 additions & 0 deletions mkShapesRDF/processor/data/TrigMaker_cfg.py

Large diffs are not rendered by default.

187 changes: 187 additions & 0 deletions mkShapesRDF/processor/data/trigger/AverageSF.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,187 @@
#!/usr/bin/env python

import json
import sys
from sys import exit
import ROOT
import optparse
import os.path
import string
import logging
import traceback
from array import array
from collections import OrderedDict
import math

import os




if __name__ == '__main__':
print '''
--------------------------------------------------------------------------------------------------

\ \ \ / |
_ \ \ \ / _ \ __| _` | _` | _ \ \ \ / _` | | | | _ \ __|
___ \ \ \ / __/ | ( | ( | __/ \ \ / ( | | | | __/ \__ \
_/ _\ \_/ \___| _| \__,_| \__, | \___| \_/ \__,_| _| \__,_| \___| ____/
|___/

--------------------------------------------------------------------------------------------------
'''

usage = 'usage: %prog [options]'
parser = optparse.OptionParser(usage)

parser.add_option('--outputFile' , dest='outputFile' , help='output file with averaged values' , default='test.txt')

# read default parsing options as well
#hwwtools.addOptions(parser)
#hwwtools.loadOptDefaults(parser)
(opt, args) = parser.parse_args()

sys.argv.append( '-b' )
ROOT.gROOT.SetBatch()


print " outputFile = ", opt.outputFile



print "list of trigger files"

files_names_trigger = {}

#files_names_trigger["ICHEP2016fullLumi/PartialRuns/HLT_DoubleMuLegLowPt_Run_274094_275000.txt"] = 2.916
#files_names_trigger["ICHEP2016fullLumi/PartialRuns/HLT_DoubleMuLegLowPt_Run_275001_275783.txt"] = 2.736
#files_names_trigger["ICHEP2016fullLumi/PartialRuns/HLT_DoubleMuLegLowPt_Run_275784_276500.txt"] = 3.426
#files_names_trigger["ICHEP2016fullLumi/PartialRuns/HLT_DoubleMuLegLowPt_Run_276501_276811.txt"] = 3.191
#opt.outputFile = "ICHEP2016fullLumi/HLT_DoubleMuLegLowPt.txt"


#files_names_trigger["ICHEP2016fullLumi/PartialRuns/HLT_EleMuLegLowPt_Run_274094_275000.txt"] = 3.426
#files_names_trigger["ICHEP2016fullLumi/PartialRuns/HLT_EleMuLegLowPt_Run_275001_275783.txt"] = 3.191
#files_names_trigger["ICHEP2016fullLumi/PartialRuns/HLT_EleMuLegLowPt_Run_275784_276500.txt"] = 3.191
#files_names_trigger["ICHEP2016fullLumi/PartialRuns/HLT_EleMuLegLowPt_Run_276501_276811.txt"] = 3.191
#opt.outputFile = "ICHEP2016fullLumi/HLT_EleMuLegLowPt.txt"


#files_names_trigger["ICHEP2016fullLumi/PartialRuns/HLT_MuSingle_Run_274094_275000.txt"] = 3.426
#files_names_trigger["ICHEP2016fullLumi/PartialRuns/HLT_MuSingle_Run_275001_275783.txt"] = 3.191
#files_names_trigger["ICHEP2016fullLumi/PartialRuns/HLT_MuSingle_Run_275784_276500.txt"] = 3.191
#files_names_trigger["ICHEP2016fullLumi/PartialRuns/HLT_MuSingle_Run_276501_276811.txt"] = 3.191
#opt.outputFile = "ICHEP2016fullLumi/HLT_MuSingle.txt"


#files_names_trigger["ICHEP2016fullLumi/PartialRuns/HLT_MuEleLegHigPt_Run_274094_275000.txt"] = 3.426
#files_names_trigger["ICHEP2016fullLumi/PartialRuns/HLT_MuEleLegHigPt_Run_275001_275783.txt"] = 3.191
#files_names_trigger["ICHEP2016fullLumi/PartialRuns/HLT_MuEleLegHigPt_Run_275784_276500.txt"] = 3.191
#files_names_trigger["ICHEP2016fullLumi/PartialRuns/HLT_MuEleLegHigPt_Run_276501_276811.txt"] = 3.191
#opt.outputFile = "ICHEP2016fullLumi/HLT_MuEleLegHigPt.txt"


files_names_trigger["ICHEP2016fullLumi/PartialRuns/HLT_DoubleMuLegHigPt_Run_274094_275000.txt"] = 3.426
files_names_trigger["ICHEP2016fullLumi/PartialRuns/HLT_DoubleMuLegHigPt_Run_275001_275783.txt"] = 3.191
files_names_trigger["ICHEP2016fullLumi/PartialRuns/HLT_DoubleMuLegHigPt_Run_275784_276500.txt"] = 3.191
files_names_trigger["ICHEP2016fullLumi/PartialRuns/HLT_DoubleMuLegHigPt_Run_276501_276811.txt"] = 3.191
opt.outputFile = "ICHEP2016fullLumi/HLT_DoubleMuLegHigPt.txt"





print " outputFile = ", opt.outputFile


print " files_names_trigger = ", files_names_trigger

files_trigger = {}
for names in files_names_trigger :
#print names
##print files_names_trigger[names]

files_trigger [names] = {
'file' : open (names),
'lumi' : files_names_trigger[names]
}



list_triggers = {}

for names in files_trigger :
list_triggers[names] = {
'values' : [line.rstrip().split() for line in files_trigger[names]['file'] if '#' not in line] ,
'lumi' : files_trigger[names]['lumi']
}





outFile = open(opt.outputFile, 'w')
outFile.write('# etamin etamax ptmin ptmax eff deff_high deff_low\n')

first_key = list_triggers.keys()[0]

for point in list_triggers[first_key]['values']:
outFile.write( ' {0:.2f} {1:.2f} {2:.2f} {3:.2f} '.format(float(point[0]), float(point[1]), float(point[2]), float(point[3])) )

eff = float(point[4])
error_eff = float(point[5])

error_eff_up = eff + error_eff
error_eff_lo = eff - error_eff

# muons and electrons have provided different formats!
if len(point) > 6 :
error_eff_lo = float(point[6])
error_eff_lo = eff - error_eff_lo

luminosity = list_triggers[first_key]['lumi']

all_lumi = luminosity
eff = eff * luminosity
error_eff_up = error_eff_up * luminosity
error_eff_lo = error_eff_lo * luminosity


for names in list_triggers :
if names != first_key:
for point_other in list_triggers[names]['values']:
if float(point_other[0]) == float(point[0]) \
and float(point_other[1]) == float(point[1]) \
and float(point_other[2]) == float(point[2]) \
and float(point_other[3]) == float(point[3]) :

new_eff = float(point_other[4])
new_error_eff = float(point_other[5])

new_error_eff_up = new_eff + new_error_eff
new_error_eff_lo = new_eff - new_error_eff

# muons and electrons have provided different formats!
if len(point_other) > 6 :
new_error_eff_lo = float(point_other[6])
new_error_eff_lo = new_eff - new_error_eff_lo


luminosity = list_triggers[names]['lumi']

all_lumi = all_lumi + luminosity
eff = eff + new_eff * luminosity
error_eff_up = error_eff_up + new_error_eff_up * luminosity
error_eff_lo = error_eff_lo + new_error_eff_lo * luminosity

eff = eff / all_lumi
error_eff_up = error_eff_up / all_lumi
error_eff_lo = error_eff_lo / all_lumi

outFile.write( ' {0:.4f} {1:.4f} {2:.4f} \n'.format(float(eff), float(error_eff_up - eff), float(eff-error_eff_lo)) )



print " outputFile = ", opt.outputFile


158 changes: 158 additions & 0 deletions mkShapesRDF/processor/data/trigger/DRll_SF_ee.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,158 @@
{
"schema_version": 2,
"corrections": [
{
"name": "TriggerEff",
"description": "Trigger efficiencies from txt files",
"version": 1,
"inputs": [
{
"name": "dRll",
"type": "real",
"description": "dRll"
},
{
"name": "systematic",
"type": "string",
"description": "Choose nominal efficiency or one of the uncertainties"
}
],
"output": {
"name": "weight",
"type": "real",
"description": "Output efficiency (nominal) or uncertainty"
},
"data": {
"nodetype": "binning",
"input": "dRll",
"edges": [
0.0,
0.25,
0.5,
1.0,
1.5,
2.0,
2.5,
3.0,
3.5,
4.0,
4.5,
20.0
],
"content": [
{
"nodetype": "category",
"input": "systematic",
"content": [
{
"key": "nominal",
"value": 0.019013
}
]
},
{
"nodetype": "category",
"input": "systematic",
"content": [
{
"key": "nominal",
"value": 0.903772
}
]
},
{
"nodetype": "category",
"input": "systematic",
"content": [
{
"key": "nominal",
"value": 0.996569
}
]
},
{
"nodetype": "category",
"input": "systematic",
"content": [
{
"key": "nominal",
"value": 0.996051
}
]
},
{
"nodetype": "category",
"input": "systematic",
"content": [
{
"key": "nominal",
"value": 0.997844
}
]
},
{
"nodetype": "category",
"input": "systematic",
"content": [
{
"key": "nominal",
"value": 0.99813
}
]
},
{
"nodetype": "category",
"input": "systematic",
"content": [
{
"key": "nominal",
"value": 0.998615
}
]
},
{
"nodetype": "category",
"input": "systematic",
"content": [
{
"key": "nominal",
"value": 0.99792
}
]
},
{
"nodetype": "category",
"input": "systematic",
"content": [
{
"key": "nominal",
"value": 0.997854
}
]
},
{
"nodetype": "category",
"input": "systematic",
"content": [
{
"key": "nominal",
"value": 1.001182
}
]
},
{
"nodetype": "category",
"input": "systematic",
"content": [
{
"key": "nominal",
"value": 0.994173
}
]
}
],
"flow": "error"
}
}
]
}
11 changes: 11 additions & 0 deletions mkShapesRDF/processor/data/trigger/DRll_SF_ee.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
0.00 0.25 0.019013
0.25 0.50 0.903772
0.50 1.00 0.996569
1.00 1.50 0.996051
1.50 2.00 0.997844
2.00 2.50 0.998130
2.50 3.00 0.998615
3.00 3.50 0.997920
3.50 4.00 0.997854
4.00 4.50 1.001182
4.50 20.0 0.994173
Loading