Skip to content

Commit 4052627

Browse files
committed
updated control plot script
1 parent 7a45dbe commit 4052627

File tree

1 file changed

+85
-29
lines changed

1 file changed

+85
-29
lines changed

src/cross_section_measurement/make_control_plots_fromTrees.py

Lines changed: 85 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,9 @@ def getPUWeights(histograms_to_draw, histogram_lables) :
3939
mcValues = list(mcHist.y())
4040

4141
weights = [ data / mc for data, mc in zip(dataValues, mcValues)]
42-
print 'PU weights'
43-
print 'Bin edges :',list(dataHist.xedges())
44-
print 'Weights : ',weights
42+
# print 'PU weights'
43+
# print 'Bin edges :',list(dataHist.xedges())
44+
# print 'Weights : ',weights
4545

4646
def make_plot( channel, x_axis_title, y_axis_title,
4747
signal_region_tree,
@@ -125,8 +125,9 @@ def make_plot( channel, x_axis_title, y_axis_title,
125125
selection = '1'
126126
if branchName == 'abs(lepton_eta)' :
127127
selection = 'lepton_eta > -10'
128+
else:
129+
selection = '%s >= 0' % branchName
128130
histograms = get_histograms_from_trees( trees = [signal_region_tree, control_region_tree], branch = branchName, weightBranch = weightBranchSignalRegion, files = histogram_files, nBins = nBins, xMin = x_limits[0], xMax = x_limits[-1], selection = selection )
129-
130131
histograms_QCDControlRegion = None
131132
if use_qcd_data_region:
132133
qcd_control_region = signal_region_tree.replace( 'Ref selection', qcd_data_region )
@@ -216,6 +217,14 @@ def make_plot( channel, x_axis_title, y_axis_title,
216217
histogram_lables = ['data', 'QCD', 'V+Jets', 'Single-Top', samples_latex['TTJet']]
217218
histogram_colors = [colours['data'], colours['QCD'], colours['V+Jets'], colours['Single-Top'], colours['TTJet'] ]
218219

220+
221+
print 'Normalisation after selection'
222+
print 'Data :',signal_region_hists['data'].integral(overflow=True)
223+
print 'TTJet :',signal_region_hists['TTJet'].integral(overflow=True)
224+
print 'Single Top :',signal_region_hists['SingleTop'].integral(overflow=True)
225+
print 'V+Jets :',signal_region_hists['V+Jets'].integral(overflow=True)
226+
print 'QCD :',qcd_from_data.integral(overflow=True)
227+
219228
histogram_properties = Histogram_properties()
220229
histogram_properties.name = name_prefix + b_tag_bin
221230
if category != 'central':
@@ -344,34 +353,36 @@ def make_plot( channel, x_axis_title, y_axis_title,
344353
norm_variable = 'MET'
345354
# comment out plots you don't want
346355
include_plots = [
347-
'HT',
348-
'MET',
349-
'METNoHF',
350-
'ST',
351-
'WPT',
352-
'NVertex',
353-
'NVertexNoWeight',
354-
'LeptonPt',
355-
'AbsLeptonEta',
356-
# # 'Mjj',
357-
# # 'M3',
358-
# # 'angle_bl',
356+
# 'HT',
357+
# 'MET',
358+
# 'METNoHF',
359+
# 'ST',
360+
# 'WPT',
361+
# 'NVertex',
362+
# 'NVertexNoWeight',
363+
# 'LeptonPt',
364+
# 'AbsLeptonEta',
365+
# # # 'Mjj',
366+
# # # 'M3',
367+
# # # 'angle_bl',
359368
'NJets',
360-
'NBJets',
361-
'NBJetsNoWeight'
369+
# 'NBJets',
370+
# 'NBJetsNoWeight',
362371
# 'JetPt',
363372
# 'AbsLeptonEta',
364373
# 'RelIso',
374+
# 'sigmaietaieta'
365375
]
366376

367377
additional_qcd_plots = [
368378
# 'QCDHT',
369-
'QCDMET',
370-
'QCDST',
371-
'QCDWPT',
372-
'QCDAbsLeptonEta',
373-
'QCDLeptonPt',
374-
'QCDNJets',
379+
# 'QCDMET',
380+
# 'QCDST',
381+
# 'QCDWPT',
382+
# 'QCDAbsLeptonEta',
383+
# 'QCDLeptonPt',
384+
# 'QCDNJets',
385+
# 'QCDsigmaietaieta',
375386
# 'QCDRelIso',
376387
# 'QCDHT_dataControl_mcSignal',
377388
]
@@ -753,7 +764,7 @@ def make_plot( channel, x_axis_title, y_axis_title,
753764
rebin = 1,
754765
legend_location = ( 0.95, 0.78 ),
755766
cms_logo_location = 'right',
756-
use_qcd_data_region = useQCDControl,
767+
use_qcd_data_region = False,
757768
)
758769

759770
###################################################
@@ -774,7 +785,7 @@ def make_plot( channel, x_axis_title, y_axis_title,
774785
rebin = 1,
775786
legend_location = ( 0.9, 0.88 ),
776787
cms_logo_location = 'left',
777-
use_qcd_data_region = useQCDControl,
788+
use_qcd_data_region = True,
778789
)
779790

780791
###################################################
@@ -801,20 +812,42 @@ def make_plot( channel, x_axis_title, y_axis_title,
801812
legend_location = ( 0.95, 0.78 ),
802813
cms_logo_location = 'right',
803814
)
815+
###################################################
816+
# Sigma ieta ieta
817+
###################################################
818+
819+
norm_variable = 'sigmaietaieta'
820+
if 'sigmaietaieta' in include_plots and channel == 'electron':
821+
print '---> sigmaietaieta'
822+
make_plot( channel,
823+
x_axis_title = '$%s$' % variables_latex['sigmaietaieta'],
824+
y_axis_title = 'Events/(%i GeV)' % binWidth(control_plots_bins['sigmaietaieta']),
825+
signal_region_tree = 'TTbar_plus_X_analysis/%s/Ref selection/FitVariables' % label,
826+
control_region_tree = 'TTbar_plus_X_analysis/%s/Ref selection/FitVariables' % label,
827+
branchName = 'sigmaIetaIeta',
828+
name_prefix = '%s_sigmaIetaIeta_' % label,
829+
x_limits = control_plots_bins['sigmaietaieta'],
830+
nBins = len(control_plots_bins['sigmaietaieta'])-1,
831+
rebin = 1,
832+
legend_location = ( 0.9, 0.83 ),
833+
cms_logo_location = 'left',
834+
use_qcd_data_region = useQCDControl,
835+
)
804836

805837
###################################################
806838
# QCD Control Region
807839
###################################################
808840
for channel, label in {
809-
'electronQCDNonIso' : 'EPlusJets/QCD non iso e+jets',
810-
'electronQCDConversions' : 'EPlusJets/QCDConversions',
841+
# 'electronQCDNonIso' : 'EPlusJets/QCD non iso e+jets',
842+
# 'electronQCDConversions' : 'EPlusJets/QCDConversions',
811843
'muonQCDNonIso' : 'MuPlusJets/QCD iso > 0.3',
812844
'muonQCDNonIso2' : 'MuPlusJets/QCD 0.12 < iso <= 0.3',
813845
}.iteritems() :
814846
b_tag_bin = '0btag'
815847

816848
# Set folder for this batch of plots
817849
output_folder = output_folder_base + "QCDControl/Variables/%s/" % channel
850+
# output_folder = output_folder_base + "QCDControl/Variables/%s/TightElectron/" % channel
818851
make_folder_if_not_exists(output_folder)
819852

820853
print 'Control region :',label
@@ -928,7 +961,8 @@ def make_plot( channel, x_axis_title, y_axis_title,
928961
)
929962

930963
# Set folder for this batch of plots
931-
output_folder = output_folder_base + "QCDControl/Control/%s" % channel
964+
output_folder = output_folder_base + "QCDControl/Control/%s/" % channel
965+
# output_folder = output_folder_base + "QCDControl/Control/%s/TightElectron/" % channel
932966
make_folder_if_not_exists(output_folder)
933967
###################################################
934968
# Abs Lepton Eta
@@ -1019,4 +1053,26 @@ def make_plot( channel, x_axis_title, y_axis_title,
10191053
rebin = 1,
10201054
legend_location = ( 0.95, 0.78 ),
10211055
cms_logo_location = 'right',
1056+
)
1057+
1058+
###################################################
1059+
# Sigma ieta ieta
1060+
###################################################
1061+
1062+
norm_variable = 'sigmaietaieta'
1063+
if 'QCDsigmaietaieta' in include_plots and not 'MuPlusJets' in treeName:
1064+
print '---> sigmaietaieta'
1065+
make_plot( channel,
1066+
x_axis_title = '$%s$' % variables_latex['sigmaietaieta'],
1067+
y_axis_title = 'Events/(%i GeV)' % binWidth(control_plots_bins['sigmaietaieta']),
1068+
signal_region_tree = 'TTbar_plus_X_analysis/%s/FitVariables' % ( treeName ),
1069+
control_region_tree = 'TTbar_plus_X_analysis/%s/FitVariables' % ( treeName ),
1070+
branchName = 'sigmaIetaIeta',
1071+
name_prefix = '%s_sigmaIetaIeta_' % channel,
1072+
x_limits = control_plots_bins['sigmaietaieta'],
1073+
y_max_scale = 1.5,
1074+
nBins = len(control_plots_bins['sigmaietaieta'])-1,
1075+
rebin = 1,
1076+
legend_location = ( 0.95, 0.85 ),
1077+
cms_logo_location = 'left',
10221078
)

0 commit comments

Comments
 (0)