Skip to content

Commit 9cac0db

Browse files
authored
Merge pull request #350 from EmyrClement/Mor2017
Moriond 2017
2 parents 3e4924d + 8e9c1ae commit 9cac0db

17 files changed

+382
-258
lines changed

bin/x_05_all_vars

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,32 +4,33 @@ mkdir -p logs
44
mkdir -p plots
55
fit_var="M3,angle_bl"
66
nice_fit_var=`echo $fit_var | sed 's/,/_/g'`
7-
N_JOBS=1
7+
N_JOBS=4
88

99
echo "Using the fit variable(s): $fit_var"
1010
# input_folder=/hdfs/TopQuarkGroup/run2/dpsData/data/normalisation/background_subtraction/
1111
input_folder=data/normalisation/background_subtraction/
1212
output_folder=tables/background_subtraction/
1313
com=13
14-
typical_systematics="${output_folder}/${com}TeV/FullPS/typical_systematics_${com}TeV_combined.tex"
15-
typical_systematics_vis="${output_folder}/${com}TeV/VisiblePS/typical_systematics_${com}TeV_combined.tex"
16-
if [ -e $typical_systematics ];
17-
then
18-
echo "Cleaning up old typical systematics file for full phase space"
19-
rm $typical_systematics
20-
fi
14+
# typical_systematics="${output_folder}/${com}TeV/FullPS/typical_systematics_${com}TeV_combined.tex"
15+
# typical_systematics_vis="${output_folder}/${com}TeV/VisiblePS/typical_systematics_${com}TeV_combined.tex"
16+
# if [ -e $typical_systematics ];
17+
# then
18+
# echo "Cleaning up old typical systematics file for full phase space"
19+
# rm $typical_systematics
20+
# fi
2121

22-
if [ -e $typical_systematics_vis ];
23-
then
24-
echo "Cleaning up old typical systematics file for visible phase space"
25-
rm $typical_systematics_vis
26-
fi
22+
# if [ -e $typical_systematics_vis ];
23+
# then
24+
# echo "Cleaning up old typical systematics file for visible phase space"
25+
# rm $typical_systematics_vis
26+
# fi
2727

2828
echo "Visible phase space ..."
2929
i=0
3030
for var in MET HT ST WPT lepton_pt abs_lepton_eta NJets; do
3131
echo "Tabulating diff. x-section for distribution: $var"
32-
nohup time python dps/analysis/xsection/05_make_tables.py -v $var -c 13 -p $input_folder -o $output_folder -a --visiblePS &> logs/05_${var}_table_13TeV_vis.log &
32+
# nohup time python dps/analysis/xsection/05_make_tables.py -v $var -c 13 -p $input_folder -o $output_folder -a --visiblePS &> logs/05_${var}_table_13TeV_vis.log &
33+
nohup python dps/analysis/xsection/05_make_systematic_plots.py -v $var --visiblePS -p $input_folder -o $output_folder &> logs/05_${var}_systematics_13TeV_vis.log &
3334
let i+=1
3435
if (( $i % N_JOBS == 0 ))
3536
then

dps/analysis/BLTUnfold/produceUnfoldingHistograms.py

Lines changed: 32 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
from dps.config.variable_binning import bin_edges_vis, reco_bin_edges_vis
77
from dps.config.variableBranchNames import branchNames, genBranchNames_particle, genBranchNames_parton
88
from dps.utils.file_utilities import make_folder_if_not_exists
9-
from math import trunc
9+
from math import trunc, exp, sqrt
1010

1111
from scaleFactors import *
1212

@@ -38,6 +38,14 @@ def calculateTopPtWeight( lepTopPt, hadTopPt, whichWayToWeight = 1 ):
3838
else :
3939
return 1
4040

41+
def calculateTopPtSystematicWeight( lepTopPt, hadTopPt ):
42+
lepTopWeight = ptWeight( lepTopPt )
43+
hadTopWeight = ptWeight( hadTopPt )
44+
return sqrt( lepTopWeight * hadTopWeight )
45+
46+
def ptWeight( pt ):
47+
return exp( 0.0615 - 0.0005 * pt )
48+
4149
def getFileName( com, sample, measurementConfig ) :
4250

4351
fileNames = {
@@ -47,10 +55,16 @@ def getFileName( com, sample, measurementConfig ) :
4755
'madgraph' : measurementConfig.ttbar_madgraph_category_templates_trees,
4856
'powhegherwigpp' : measurementConfig.ttbar_powhegherwigpp_category_templates_trees,
4957
'amcatnloherwigpp' : measurementConfig.ttbar_amcatnloherwigpp_category_templates_trees,
50-
'scaleup' : measurementConfig.ttbar_scaleup_category_templates_trees,
51-
'scaledown' : measurementConfig.ttbar_scaledown_category_templates_trees,
5258
'massdown' : measurementConfig.ttbar_mtop1695_category_templates_trees,
5359
'massup' : measurementConfig.ttbar_mtop1755_category_templates_trees,
60+
'topPtSystematic' : measurementConfig.ttbar_category_templates_trees['central'],
61+
'fsrup' : measurementConfig.ttbar_fsrup_category_templates_trees,
62+
'fsrdown' : measurementConfig.ttbar_fsrdown_category_templates_trees,
63+
'isrup' : measurementConfig.ttbar_isrup_category_templates_trees,
64+
'isrdown' : measurementConfig.ttbar_isrdown_category_templates_trees,
65+
'ueup' : measurementConfig.ttbar_ueup_category_templates_trees,
66+
'uedown' : measurementConfig.ttbar_uedown_category_templates_trees,
67+
5468
'jesdown' : measurementConfig.ttbar_jesdown_category_templates_trees,
5569
'jesup' : measurementConfig.ttbar_jesup_category_templates_trees,
5670
'jerdown' : measurementConfig.ttbar_jerdown_category_templates_trees,
@@ -79,7 +93,7 @@ def getFileName( com, sample, measurementConfig ) :
7993
return fileNames[com][sample]
8094

8195
channels = [
82-
# channel( 'ePlusJets', 'rootTupleTreeEPlusJets', 'electron'),
96+
channel( 'ePlusJets', 'rootTupleTreeEPlusJets', 'electron'),
8397
channel( 'muPlusJets', 'rootTupleTreeMuPlusJets', 'muon')
8498
]
8599

@@ -91,7 +105,6 @@ def main():
91105
parser.add_option('-c', '--centreOfMassEnergy', dest='centreOfMassEnergy', type='int', default=13 )
92106
parser.add_option('--pdfWeight', type='int', dest='pdfWeight', default=-1 )
93107
parser.add_option('--muFmuRWeight', type='int', dest='muFmuRWeight', default=-1 )
94-
parser.add_option('--alphaSWeight', type='int', dest='alphaSWeight', default=-1 )
95108
parser.add_option('--nGeneratorWeights', type='int', dest='nGeneratorWeights', default=1 )
96109
parser.add_option('-s', '--sample', dest='sample', default='central')
97110
parser.add_option('-d', '--debug', action='store_true', dest='debug', default=False)
@@ -115,7 +128,6 @@ def main():
115128

116129
pdfWeight = options.pdfWeight
117130
muFmuRWeight = options.muFmuRWeight
118-
alphaSWeight = options.alphaSWeight
119131

120132
# Output file name
121133
outputFileName = 'crap.root'
@@ -134,10 +146,6 @@ def main():
134146
outputFileName = outputFileDir+'/unfolding_TTJets_%s_asymmetric_withTopPtReweighting_up.root' % energySuffix
135147
elif options.applyTopPtReweighting == -1:
136148
outputFileName = outputFileDir+'/unfolding_TTJets_%s_asymmetric_withTopPtReweighting_down.root' % energySuffix
137-
elif alphaSWeight == 0:
138-
outputFileName = outputFileDir+'/unfolding_TTJets_%s_asymmetric_alphaSDown.root' % ( energySuffix )
139-
elif alphaSWeight == 1:
140-
outputFileName = outputFileDir+'/unfolding_TTJets_%s_asymmetric_alphaSUp.root' % ( energySuffix )
141149
elif muFmuRWeight == 1:
142150
outputFileName = outputFileDir+'/unfolding_TTJets_%s_asymmetric_1muR2muF.root' % ( energySuffix )
143151
elif muFmuRWeight == 2:
@@ -160,7 +168,7 @@ def main():
160168
outputFileName = outputFileDir+'/unfolding_TTJets_%s_asymmetric.root' % energySuffix
161169

162170
with root_open( file_name, 'read' ) as f, root_open( outputFileName, 'recreate') as out:
163-
171+
164172
# Get the tree
165173
treeName = "TTbar_plus_X_analysis/Unfolding/Unfolding"
166174
if options.sample == "jesup":
@@ -325,7 +333,7 @@ def main():
325333
branch = event.__getattr__
326334
n+=1
327335
if not n%100000: print 'Processing event %.0f Progress : %.2g %%' % ( n, float(n)/nEntries*100 )
328-
# if n == 10000: break
336+
# if n == 100000: break
329337
# # #
330338
# # # Weights and selection
331339
# # #
@@ -364,10 +372,16 @@ def main():
364372
elif options.sample == "lightjetdown":
365373
bjetWeight = event.LightJetDownWeight
366374

375+
# Top pt systematic weight
376+
topPtSystematicWeight = 1
377+
if options.sample == 'topPtSystematic':
378+
topPtSystematicWeight = calculateTopPtSystematicWeight( branch('lepTopPt_parton'), branch('hadTopPt_parton'))
379+
367380
offlineWeight = event.EventWeight * measurement_config.luminosity_scale
368381
offlineWeight *= pileupWeight
369382
offlineWeight *= bjetWeight
370-
offlineWeight *= leptonWeight
383+
# offlineWeight *= leptonWeight
384+
offlineWeight *= topPtSystematicWeight
371385

372386
# Generator weight
373387
# Scale up/down, pdf
@@ -376,15 +390,16 @@ def main():
376390
offlineWeight *= branch('pdfWeight_%i' % pdfWeight)
377391
pass
378392

393+
379394
if muFmuRWeight >= 0:
380395
genWeight *= branch('muFmuRWeight_%i' % muFmuRWeight)
381396
offlineWeight *= branch('muFmuRWeight_%i' % muFmuRWeight)
382397
pass
383398

384-
if alphaSWeight >= 0:
385-
genWeight *= branch('alphaSWeight_%i' % alphaSWeight)
386-
offlineWeight *= branch('alphaSWeight_%i' % alphaSWeight)
387-
pass
399+
if options.applyTopPtReweighting != 0:
400+
ptWeight = calculateTopPtWeight( branch('lepTopPt_parton'), branch('hadTopPt_parton'), options.applyTopPtReweighting)
401+
offlineWeight *= ptWeight
402+
genWeight *= ptWeight
388403

389404
if options.applyTopPtReweighting != 0:
390405
ptWeight = calculateTopPtWeight( branch('lepTopPt_parton'), branch('hadTopPt_parton'), options.applyTopPtReweighting)

dps/analysis/BLTUnfold/runJobsCrab.py

Lines changed: 23 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -3,38 +3,44 @@
33
import os
44

55
jobs = [
6-
# # 13 TeV
6+
# 13 TeV
77
'--centreOfMassEnergy 13 -f',
88

99
'--centreOfMassEnergy 13 -s central',
10-
'--centreOfMassEnergy 13 -s central --topPtReweighting 1',
11-
'--centreOfMassEnergy 13 -s central --topPtReweighting -1',
1210

13-
'--centreOfMassEnergy 13 -s amcatnlo',
14-
'--centreOfMassEnergy 13 -s madgraph',
11+
# '--centreOfMassEnergy 13 -s amcatnlo',
12+
# '--centreOfMassEnergy 13 -s madgraph',
1513
'--centreOfMassEnergy 13 -s powhegherwigpp',
16-
# '--centreOfMassEnergy 13 -s amcatnloherwigpp',
14+
# # '--centreOfMassEnergy 13 -s amcatnloherwigpp',
1715

18-
# # PS scale samples
19-
# '--centreOfMassEnergy 13 -s scaleup',
20-
# '--centreOfMassEnergy 13 -s scaledown',
21-
22-
# ME scale weights
16+
# # ME scale weights
2317
'--centreOfMassEnergy 13 --muFmuRWeight 1',
2418
'--centreOfMassEnergy 13 --muFmuRWeight 2',
2519
'--centreOfMassEnergy 13 --muFmuRWeight 3',
2620
'--centreOfMassEnergy 13 --muFmuRWeight 4',
2721
'--centreOfMassEnergy 13 --muFmuRWeight 6',
2822
'--centreOfMassEnergy 13 --muFmuRWeight 8',
2923

30-
'--centreOfMassEnergy 13 --alphaSWeight 0',
31-
'--centreOfMassEnergy 13 --alphaSWeight 1',
32-
33-
# # Top mass
24+
# # # Top mass
3425
'--centreOfMassEnergy 13 -s massup',
3526
'--centreOfMassEnergy 13 -s massdown',
3627

37-
# # Experimental systematics
28+
# Top pt
29+
'--centreOfMassEnergy 13 -s topPtSystematic',
30+
31+
# Alpha s fsr
32+
'--centreOfMassEnergy 13 -s fsrup',
33+
'--centreOfMassEnergy 13 -s fsrdown',
34+
35+
# Alpha s isr
36+
'--centreOfMassEnergy 13 -s isrup',
37+
'--centreOfMassEnergy 13 -s isrdown',
38+
39+
# UE
40+
'--centreOfMassEnergy 13 -s ueup',
41+
'--centreOfMassEnergy 13 -s uedown',
42+
43+
# # # Experimental systematics
3844
'--centreOfMassEnergy 13 -s jesup',
3945
'--centreOfMassEnergy 13 -s jesdown',
4046

@@ -62,7 +68,7 @@
6268
'--centreOfMassEnergy 13 -s UnclusteredEnUp',
6369
'--centreOfMassEnergy 13 -s UnclusteredEnDown',
6470
]
65-
# # Add pdf variations to list of jobs
71+
# # # Add pdf variations to list of jobs
6672
nPDFPerJob = 1
6773
minPDF = 0
6874
maxPDF = 99

dps/analysis/BLTUnfold/submitBLTUnfold.description

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,4 @@ request_memory=500
1515
# use the ENV that is provided
1616
getenv = true
1717

18-
queue 137
18+
queue 138

dps/analysis/unfolding_tests/getBestTau.py

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -172,20 +172,20 @@ def main():
172172
df_chi2 = get_chi2s_of_tau_range(regularisation_settings, args)
173173
print df_chi2
174174

175-
# Have the dataframes now - albeit read to a file
176-
# Read in each one corresponding to their channel
177-
# Find the best tau and print to screen
178-
for channel in ['electron', 'muon', 'combined']:
179-
chi2_cut = 0.005
180-
path = regularisation_settings.outpath+'tbl_'+channel+'_tauscan.txt'
181-
df_chi2 = get_df_from_file(path)
182-
if df_chi2 is None: continue
183-
print '\n', "1 - P(Chi2|NDF)", '\n', df_chi2, '\n'
184-
185-
# cutoff to be changed to 0.001 when able to
186-
best_taus = interpolate_tau(chi2_cut, df_chi2)
187-
chi2_to_plots(df_chi2, regularisation_settings, chi2_cut, channel)
188-
print_results_to_screen(best_taus, channel)
175+
# Have the dataframes now - albeit read to a file
176+
# Read in each one corresponding to their channel
177+
# Find the best tau and print to screen
178+
for channel in ['electron', 'muon', 'combined']:
179+
chi2_cut = 0.005
180+
path = regularisation_settings.outpath+'tbl_'+channel+'_tauscan.txt'
181+
df_chi2 = get_df_from_file(path)
182+
if df_chi2 is None: continue
183+
print '\n', "1 - P(Chi2|NDF)", '\n', df_chi2, '\n'
184+
185+
# cutoff to be changed to 0.001 when able to
186+
best_taus = interpolate_tau(chi2_cut, df_chi2)
187+
chi2_to_plots(df_chi2, regularisation_settings, chi2_cut, channel)
188+
print_results_to_screen(best_taus, channel)
189189
return
190190

191191

0 commit comments

Comments
 (0)