forked from bonanomi/FiducialXSFWK
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathproducePlots.py
2999 lines (2656 loc) · 165 KB
/
producePlots.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
import sys, os, string, re, pwd, commands, ast, optparse, shlex, time
from array import array
from math import *
from decimal import *
#from sample_shortnames import *
def checkDir(folder_path):
isdir = os.path.isdir(folder_path)
if not isdir:
print('Directory {} does not exist. Creating it.' .format(folder_path))
os.mkdir(folder_path)
grootargs = []
def callback_rootargs(option, opt, value, parser):
grootargs.append(opt)
### Define function for parsing options
def parseOptions():
global opt, args, runAllSteps
usage = ('usage: %prog [options]\n'
+ '%prog -h for help')
parser = optparse.OptionParser(usage)
# input options
parser.add_option('-d', '--dir', dest='SOURCEDIR', type='string',default='./', help='run from the SOURCEDIR as working area, skip if SOURCEDIR is an empty string')
parser.add_option('', '--unfoldModel',dest='UNFOLD',type='string',default='SM_125', help='Name of the unfolding model for central value')
parser.add_option('', '--obsName',dest='OBSNAME', type='string',default='', help='Name of the observalbe, supported: "inclusive", "pT", "eta", "Njets"')
parser.add_option('', '--obsBins',dest='OBSBINS', type='string',default='', help='Bin boundaries for the diff. measurement separated by "|", e.g. as "|0|50|100|", use the defalut if empty string')
parser.add_option('', '--theoryMass',dest='THEORYMASS', type='string',default='125.38', help='Mass value for theory prediction')
parser.add_option('', '--fixFrac', action='store_true', dest='FIXFRAC', default=False, help='Use results from fixed fraction fit, default is False')
parser.add_option('', '--setLog', action='store_true', dest='SETLOG', default=False, help='set plot to log scale y, default is False')
parser.add_option('', '--unblind', action='store_true', dest='UNBLIND', default=False, help='Use real data')
parser.add_option('', '--lumiscale', type='string', dest='LUMISCALE', default='1.0', help='Scale yields')
parser.add_option('', '--year', dest='YEAR', type='string',default='', help='Year -> 2016 or 2017 or 2018 or Full')
parser.add_option("-l",action="callback",callback=callback_rootargs)
parser.add_option("-q",action="callback",callback=callback_rootargs)
parser.add_option("-b",action="callback",callback=callback_rootargs)
# store options and arguments as global variables
global opt, args
(opt, args) = parser.parse_args()
# parse the arguments and options
global opt, args, runAllSteps
parseOptions()
sys.argv = grootargs
if (not os.path.exists("plots")):
os.system("mkdir plots")
from ROOT import *
from tdrStyle import *
setTDRStyle()
datamodel = opt.UNFOLD
sys.path.append('./inputs')
sys.path.append('./LHScans')
def plotXS(obsName, obs_bins, obs_bins_boundaries = False):
_temp = __import__('inputs_sig_extrap_'+obsName+'_'+opt.YEAR, globals(), locals(), ['acc'], -1)
acc = _temp.acc
if(opt.YEAR=='Full'):
_temp = __import__('inputs_sig_extrap_'+obsName+'_NNLOPS_Full', globals(), locals(), ['acc'], -1)
acc_NNLOPS = _temp.acc
else:
_temp = __import__('inputs_sig_extrap_'+obsName+'_NNLOPS_'+opt.YEAR, globals(), locals(), ['acc'], -1)
acc_NNLOPS = _temp.acc
if(acFlag):
_temp = __import__('inputs_sig_ACggH_'+acSample+'_'+obsName+'_Full', globals(), locals(), ['acc'], -1)
acc_AC = _temp.acc
if(acFlagBis):
_temp = __import__('inputs_sig_ACggH_'+acSampleBis+'_'+obsName+'_Full', globals(), locals(), ['acc'], -1)
acc_ACbis = _temp.acc
_temp = __import__('higgs_xsbr_13TeV', globals(), locals(), ['higgs_xs','higgs4l_br'], -1)
higgs_xs = _temp.higgs_xs
higgs4l_br = _temp.higgs4l_br
if (opt.FIXFRAC): floatfix = '_fixfrac'
else: floatfix = ''
if (obsName.startswith("mass4l")):
if opt.UNBLIND: _temp = __import__('resultsXS_LHScan_observed_'+obsName+'_v3'+floatfix, globals(), locals(), ['resultsXS'], -1)
else: _temp = __import__('resultsXS_LHScan_expected_'+obsName+'_v3'+floatfix, globals(), locals(), ['resultsXS'], -1)
resultsXS = _temp.resultsXS
if opt.UNBLIND: _temp = __import__('resultsXS_LHScan_observed_'+obsName+'_v2'+floatfix, globals(), locals(), ['resultsXS'], -1)
else: _temp = __import__('resultsXS_LHScan_expected_'+obsName+'_v2'+floatfix, globals(), locals(), ['resultsXS'], -1)
resultsXS_v2 = _temp.resultsXS
else:
if (opt.UNBLIND): _temp = __import__('resultsXS_LHScan_observed_'+obsName+'_v3'+floatfix, globals(), locals(), ['resultsXS'], -1)
else: _temp = __import__('resultsXS_LHScan_expected_'+obsName+'_v3'+floatfix, globals(), locals(), ['resultsXS'], -1)
resultsXS = _temp.resultsXS
# Calculation of coefficients to scale ggH acceptances
if(acFlag):
accCorrFact = {}
for pmode in ['VBFH125', 'WH125', 'ZH125', 'ttH125']:
for fState in ['2e2mu', '4e', '4mu']:
for obsBin in range(len(obs_bins)-1):
# if opt.TUNEAC:
# accCorrFact[pmode+'_'+fState+'_genbin'+str(obsBin)] = acc[pmode+'_'+fState+'_'+obsName+'_genbin'+str(obsBin)+'_recobin0'] / acc['ggH125_'+fState+'_'+obsName+'_genbin'+str(obsBin)+'_recobin0']
# print pmode+'_'+fState+'_genbin'+str(obsBin), accCorrFact[pmode+'_'+fState+'_genbin'+str(obsBin)]
# else:
accCorrFact[pmode+'_'+fState+'_genbin'+str(obsBin)] = 1
#print _temp
#print resultsXS
# acc_ggH_powheg = {}
pdfunc_ggH_powheg = {}
qcdunc_ggH_powheg = {}
_temp = __import__('accUnc_'+obsName, globals(), locals(), ['pdfUncert','qcdUncert'], -1)
# acc_ggH_powheg = _temp.acc #AT Non viene mai usato
pdfunc_ggH_powheg = _temp.pdfUncert
qcdunc_ggH_powheg = _temp.qcdUncert
_temp = __import__('accUnc_aMCNLO_'+obsName, globals(), locals(), ['pdfUncert','qcdUncert'], -1)
# acc_ggH_powheg = _temp.acc #AT Non viene mai usato
pdfunc_ggH_aMC = _temp.pdfUncert
qcdunc_ggH_aMC = _temp.qcdUncert
if not acFlag:
_temp = __import__('accUnc_'+obsName+'_NNLOPS', globals(), locals(), ['pdfUncert','qcdUncert'], -1)
pdfunc_ggH_nnlops = _temp.pdfUncert
qcdunc_ggH_nnlops = _temp.qcdUncert
else:
#for discriminats open POWHEG. It will not be used. Just to
_temp = __import__('accUnc_'+obsName+'_NNLOPS', globals(), locals(), ['pdfUncert','qcdUncert'], -1)
pdfunc_ggH_nnlops = _temp.pdfUncert
qcdunc_ggH_nnlops = _temp.qcdUncert
# cross sections
ggH_powheg = []
ggH_powheg_unc_hi = []
ggH_powheg_unc_lo = []
ggH_minloHJ = []
ggH_minloHJ_unc_hi = []
ggH_minloHJ_unc_lo = []
ggH_aMC = []
ggH_aMC_unc_hi = []
ggH_aMC_unc_lo = []
# ggH_HRes = []
# ggH_HRes_unc_hi = []
# ggH_HRes_unc_lo = []
# NNLO theory unc
ggH_powheg_NNLOunc_hi = []
ggH_powheg_NNLOunc_lo = []
ggH_minloHJ_NNLOunc_hi = []
ggH_minloHJ_NNLOunc_lo = []
ggH_aMC_NNLOunc_hi = []
ggH_aMC_NNLOunc_lo = []
# ggH_HRes_NNLOunc_hi = []
# ggH_HRes_NNLOunc_lo = []
# NLO theory unc
ggH_powheg_NLOunc_hi = []
ggH_powheg_NLOunc_lo = []
ggH_minloHJ_NLOunc_hi = []
ggH_minloHJ_NLOunc_lo = []
ggH_aMC_NLOunc_hi = []
ggH_aMC_NLOunc_lo = []
# AC predictions
if(acFlag):
ggH_AC = []
ggH_AC_unc_hi = []
ggH_AC_unc_lo = []
ggH_AC_NNLOunc_hi = []
ggH_AC_NNLOunc_lo = []
ggH_AC_NLOunc_hi = []
ggH_AC_NLOunc_lo = []
XH_AC = []
XH_AC_unc = []
if(acFlagBis):
ggH_ACbis = []
ggH_ACbis_unc_hi = []
ggH_ACbis_unc_lo = []
ggH_ACbis_NNLOunc_hi = []
ggH_ACbis_NNLOunc_lo = []
ggH_ACbis_NLOunc_hi = []
ggH_ACbis_NLOunc_lo = []
XH_ACbis = []
XH_ACbis_unc = []
# XH unc
XH = []
XH_unc = []
# Data
data = []
data_hi = []
data_lo = []
data_hi2 = []
data_lo2 = []
asimovdata = []
# Systematic unc.
systematics_hi = []
systematics_lo = []
systematics_hi2 = []
systematics_lo2 = []
modeldep_hi = []
modeldep_lo = []
data_hi_allunc = []
data_lo_allunc = []
stat_hi = []
stat_lo = []
#process ggH qqH WH ZH ttH bkg_qqzz bkg_ggzz bkg_zjets
#pdf_gg lnN 1.0720 - - - 1.0780 - 1.0710 -
#pdf_qqbar lnN - 1.0270 1.0350 1.0350 - 1.0342 - -
#pdf_hzz4l_accept lnN 1.02 1.02 1.02 1.02 1.02 - - -
#QCDscale_ggH lnN 1.0750 - - - - - - -
#QCDscale_qqH lnN - 1.0020 - - - - - -
#QCDscale_VH lnN - - 1.0040 1.0155 - - - -
#QCDscale_ttH lnN - - - - 1.0655 - - -
#QCDscale_ggVV lnN - - - - - - 1.2435 -
#BRhiggs_hzz4l lnN 1.02 1.02 1.02 1.02 1.02 - - -
# unc_theory_ggH_hi = sqrt(0.072**2+0.075**2+0.02**2+0.02**2)
# unc_theory_ggH_lo = sqrt(0.078**2+0.069**2+0.02**2+0.02**2)
# unc_theory_XH_hi = sqrt(0.027**2+0.02**2+0.002**2+0.02**2)
# unc_theory_XH_lo = unc_theory_XH_hi
# unc_VBF = sqrt(0.027**2+0.02**2+0.002**2+0.02**2)
# unc_WH = sqrt(0.035**2+0.02**2+0.004**2+0.02**2)
# unc_ZH = sqrt(0.035**2+0.02**2+0.0155**2+0.02**2)
# unc_ttH = sqrt(0.078**2+0.02**2+0.0655**2+0.02**2)
unc_acc = 0.02
unc_br = 0.02
#unc_pdf_ggH_hi = 0.075
unc_pdf_ggH_hi = 0.032
unc_pdf_ggH_lo = 0.032
unc_pdf_VBF = 0.021
unc_pdf_WH = 0.023
unc_pdf_ZH = 0.025
unc_pdf_ttH = 0.081
#unc_qcd_ggH_hi = 0.072
unc_qcd_ggH_hi = 0.039
unc_qcd_ggH_lo = 0.039
unc_qcd_VBF = 0.002
unc_qcd_WH = 0.01
unc_qcd_ZH = 0.031
unc_qcd_ttH = 0.0655
nBins=len(obs_bins)
for obsBin in range(nBins-1):
# theory cross sections
ggH_powheg.append(0.0)
ggH_powheg_unc_hi.append(0.0)
ggH_powheg_unc_lo.append(0.0)
ggH_minloHJ.append(0.0)
ggH_minloHJ_unc_hi.append(0.0)
ggH_minloHJ_unc_lo.append(0.0)
ggH_aMC.append(0.0)
ggH_aMC_unc_hi.append(0.0)
ggH_aMC_unc_lo.append(0.0)
# ggH_HRes.append(0.0)
# ggH_HRes_unc_hi.append(0.0)
# ggH_HRes_unc_lo.append(0.0)
# NNLO theory unc
ggH_powheg_NNLOunc_hi.append(0.0)
ggH_powheg_NNLOunc_lo.append(0.0)
ggH_minloHJ_NNLOunc_hi.append(0.0)
ggH_minloHJ_NNLOunc_lo.append(0.0)
ggH_aMC_NNLOunc_hi.append(0.0)
ggH_aMC_NNLOunc_lo.append(0.0)
# ggH_HRes_NNLOunc_hi.append(0.0)
# ggH_HRes_NNLOunc_lo.append(0.0)
# NLO theory unc
ggH_powheg_NLOunc_hi.append(0.0)
ggH_powheg_NLOunc_lo.append(0.0)
ggH_minloHJ_NLOunc_hi.append(0.0)
ggH_minloHJ_NLOunc_lo.append(0.0)
ggH_aMC_NLOunc_hi.append(0.0)
ggH_aMC_NLOunc_lo.append(0.0)
# XH
XH.append(0.0)
XH_unc.append(0.0)
# AC
if(acFlag):
ggH_AC.append(0.0)
ggH_AC_unc_hi.append(0.0)
ggH_AC_unc_lo.append(0.0)
ggH_AC_NNLOunc_hi.append(0.0)
ggH_AC_NNLOunc_lo.append(0.0)
ggH_AC_NLOunc_hi.append(0.0)
ggH_AC_NLOunc_lo.append(0.0)
XH_AC.append(0.0)
XH_AC_unc.append(0.0)
if(acFlagBis):
ggH_ACbis.append(0.0)
ggH_ACbis_unc_hi.append(0.0)
ggH_ACbis_unc_lo.append(0.0)
ggH_ACbis_NNLOunc_hi.append(0.0)
ggH_ACbis_NNLOunc_lo.append(0.0)
ggH_ACbis_NLOunc_hi.append(0.0)
ggH_ACbis_NLOunc_lo.append(0.0)
XH_ACbis.append(0.0)
XH_ACbis_unc.append(0.0)
# Data
data.append(0.0)
data_hi.append(0.0)
data_lo.append(0.0)
data_hi2.append(0.0)
data_lo2.append(0.0)
asimovdata.append(0.0)
# Systematic unc
modeldep_hi.append(0.0)
modeldep_lo.append(0.0)
systematics_hi.append(0.0)
systematics_lo.append(0.0)
systematics_hi2.append(0.0)
systematics_lo2.append(0.0)
data_hi_allunc.append(0.0)
data_lo_allunc.append(0.0)
stat_hi.append(0.0)
stat_lo.append(0.0)
for channel in ['4e','4mu','2e2mu']:
XH_fs = higgs_xs['VBF_'+opt.THEORYMASS]*higgs4l_br[opt.THEORYMASS+'_'+channel]*acc['VBFH125_'+channel+'_'+obsName+'_genbin'+str(obsBin)+'_recobin'+str(obsBin)]
XH_fs += higgs_xs['WH_'+opt.THEORYMASS]*higgs4l_br[opt.THEORYMASS+'_'+channel]*acc['WH125_'+channel+'_'+obsName+'_genbin'+str(obsBin)+'_recobin'+str(obsBin)]
XH_fs += higgs_xs['ZH_'+opt.THEORYMASS]*higgs4l_br[opt.THEORYMASS+'_'+channel]*acc['ZH125_'+channel+'_'+obsName+'_genbin'+str(obsBin)+'_recobin'+str(obsBin)]
XH_fs += higgs_xs['ttH_'+opt.THEORYMASS]*higgs4l_br[opt.THEORYMASS+'_'+channel]*acc['ttH125_'+channel+'_'+obsName+'_genbin'+str(obsBin)+'_recobin'+str(obsBin)]
XH[obsBin]+=XH_fs
#XH_unc[obsBin]+= unc_ttH*higgs_xs['ttH_'+opt.THEORYMASS]*higgs4l_br[opt.THEORYMASS+'_'+channel]*acc['ttH_powheg_JHUgen_125_'+channel+'_'+obsName+'_genbin'+str(obsBin)+'_recobin'+str(obsBin)]
#XH_unc[obsBin]+= unc_VBF*higgs_xs['VBF_'+opt.THEORYMASS]*higgs4l_br[opt.THEORYMASS+'_'+channel]*acc['VBF_powheg_JHUgen_125_'+channel+'_'+obsName+'_genbin'+str(obsBin)+'_recobin'+str(obsBin)]
#XH_unc[obsBin]+= unc_WH*higgs_xs['WH_'+opt.THEORYMASS]*higgs4l_br[opt.THEORYMASS+'_'+channel]*acc['WH_powheg_JHUgen_125_'+channel+'_'+obsName+'_genbin'+str(obsBin)+'_recobin'+str(obsBin)]
#XH_unc[obsBin]+= unc_ZH*higgs_xs['ZH_'+opt.THEORYMASS]*higgs4l_br[opt.THEORYMASS+'_'+channel]*acc['ZH_powheg_JHUgen_125_'+channel+'_'+obsName+'_genbin'+str(obsBin)+'_recobin'+str(obsBin)]
# branching ratio uncertainty
XH_unc_fs = (unc_br*XH_fs)**2
# acceptance uncertainty
XH_unc_fs += (unc_acc*XH_fs)**2
# qcd scale
XH_qcdunc_fs = (unc_qcd_VBF*higgs_xs['VBF_'+opt.THEORYMASS]*higgs4l_br[opt.THEORYMASS+'_'+channel]*acc['VBFH125_'+channel+'_'+obsName+'_genbin'+str(obsBin)+'_recobin'+str(obsBin)])**2
XH_qcdunc_fs += (unc_qcd_WH*higgs_xs['WH_'+opt.THEORYMASS]*higgs4l_br[opt.THEORYMASS+'_'+channel]*acc['WH125_'+channel+'_'+obsName+'_genbin'+str(obsBin)+'_recobin'+str(obsBin)])**2
XH_qcdunc_fs += (unc_qcd_ZH*higgs_xs['ZH_'+opt.THEORYMASS]*higgs4l_br[opt.THEORYMASS+'_'+channel]*acc['ZH125_'+channel+'_'+obsName+'_genbin'+str(obsBin)+'_recobin'+str(obsBin)])**2
XH_qcdunc_fs += (unc_qcd_ttH*higgs_xs['ttH_'+opt.THEORYMASS]*higgs4l_br[opt.THEORYMASS+'_'+channel]*acc['ttH125_'+channel+'_'+obsName+'_genbin'+str(obsBin)+'_recobin'+str(obsBin)])**2
XH_unc_fs += XH_qcdunc_fs
# pdf
XH_qqpdfunc_fs = (unc_pdf_VBF*higgs_xs['VBF_'+opt.THEORYMASS]*higgs4l_br[opt.THEORYMASS+'_'+channel]*acc['VBFH125_'+channel+'_'+obsName+'_genbin'+str(obsBin)+'_recobin'+str(obsBin)]
+unc_pdf_WH*higgs_xs['WH_'+opt.THEORYMASS]*higgs4l_br[opt.THEORYMASS+'_'+channel]*acc['WH125_'+channel+'_'+obsName+'_genbin'+str(obsBin)+'_recobin'+str(obsBin)]
+unc_pdf_ZH*higgs_xs['ZH_'+opt.THEORYMASS]*higgs4l_br[opt.THEORYMASS+'_'+channel]*acc['ZH125_'+channel+'_'+obsName+'_genbin'+str(obsBin)+'_recobin'+str(obsBin)])**2
XH_unc_fs += XH_qqpdfunc_fs
# add pdf uncertainty for ttH to total XH uncertainty
XH_unc_fs += (unc_pdf_ttH*higgs_xs['ttH_'+opt.THEORYMASS]*higgs4l_br[opt.THEORYMASS+'_'+channel]*acc['ttH125_'+channel+'_'+obsName+'_genbin'+str(obsBin)+'_recobin'+str(obsBin)])**2
# total XH uncertainty
XH_unc[obsBin]+=sqrt(XH_unc_fs)
# AC
if(acFlag):
XH_AC_fs = higgs_xs['VBF_'+opt.THEORYMASS]*higgs4l_br[opt.THEORYMASS+'_'+channel]*accCorrFact['VBFH125_'+fState+'_genbin'+str(obsBin)]*acc_AC['ggH'+acSample+'_M125_'+channel+'_'+obsName+'_genbin'+str(obsBin)+'_recobin'+str(obsBin)]
XH_AC_fs += higgs_xs['WH_'+opt.THEORYMASS]*higgs4l_br[opt.THEORYMASS+'_'+channel]*accCorrFact['WH125_'+fState+'_genbin'+str(obsBin)]*acc_AC['ggH'+acSample+'_M125_'+channel+'_'+obsName+'_genbin'+str(obsBin)+'_recobin'+str(obsBin)]
XH_AC_fs += higgs_xs['ZH_'+opt.THEORYMASS]*higgs4l_br[opt.THEORYMASS+'_'+channel]*accCorrFact['ZH125_'+fState+'_genbin'+str(obsBin)]*acc_AC['ggH'+acSample+'_M125_'+channel+'_'+obsName+'_genbin'+str(obsBin)+'_recobin'+str(obsBin)]
XH_AC_fs += higgs_xs['ttH_'+opt.THEORYMASS]*higgs4l_br[opt.THEORYMASS+'_'+channel]*accCorrFact['ttH125_'+fState+'_genbin'+str(obsBin)]*acc_AC['ggH'+acSample+'_M125_'+channel+'_'+obsName+'_genbin'+str(obsBin)+'_recobin'+str(obsBin)]
XH_AC[obsBin]+=XH_AC_fs
# branching ratio uncertainty
XH_AC_unc_fs = (unc_br*XH_AC_fs)**2
# acceptance uncertainty
XH_AC_unc_fs += (unc_acc*XH_AC_fs)**2
XH_AC_qcdunc_fs = (unc_qcd_VBF*higgs_xs['VBF_'+opt.THEORYMASS]*higgs4l_br[opt.THEORYMASS+'_'+channel]*accCorrFact['VBFH125_'+fState+'_genbin'+str(obsBin)]*acc_AC['ggH'+acSample+'_M125_'+channel+'_'+obsName+'_genbin'+str(obsBin)+'_recobin'+str(obsBin)])**2
XH_AC_qcdunc_fs += (unc_qcd_WH*higgs_xs['WH_'+opt.THEORYMASS]*higgs4l_br[opt.THEORYMASS+'_'+channel]*accCorrFact['WH125_'+fState+'_genbin'+str(obsBin)]*acc_AC['ggH'+acSample+'_M125_'+channel+'_'+obsName+'_genbin'+str(obsBin)+'_recobin'+str(obsBin)])**2
XH_AC_qcdunc_fs += (unc_qcd_ZH*higgs_xs['ZH_'+opt.THEORYMASS]*higgs4l_br[opt.THEORYMASS+'_'+channel]*accCorrFact['ZH125_'+fState+'_genbin'+str(obsBin)]*acc_AC['ggH'+acSample+'_M125_'+channel+'_'+obsName+'_genbin'+str(obsBin)+'_recobin'+str(obsBin)])**2
XH_AC_qcdunc_fs += (unc_qcd_ttH*higgs_xs['ttH_'+opt.THEORYMASS]*higgs4l_br[opt.THEORYMASS+'_'+channel]*accCorrFact['ttH125_'+fState+'_genbin'+str(obsBin)]*acc_AC['ggH'+acSample+'_M125_'+channel+'_'+obsName+'_genbin'+str(obsBin)+'_recobin'+str(obsBin)])**2
XH_AC_unc_fs += XH_qcdunc_fs
# pdf
XH_AC_qqpdfunc_fs = (unc_pdf_VBF*higgs_xs['VBF_'+opt.THEORYMASS]*higgs4l_br[opt.THEORYMASS+'_'+channel]**accCorrFact['VBFH125_'+fState+'_genbin'+str(obsBin)]*acc_AC['ggH'+acSample+'_M125_'+channel+'_'+obsName+'_genbin'+str(obsBin)+'_recobin'+str(obsBin)]
+unc_pdf_WH*higgs_xs['WH_'+opt.THEORYMASS]*higgs4l_br[opt.THEORYMASS+'_'+channel]*accCorrFact['WH125_'+fState+'_genbin'+str(obsBin)]*acc_AC['ggH'+acSample+'_M125_'+channel+'_'+obsName+'_genbin'+str(obsBin)+'_recobin'+str(obsBin)]
+unc_pdf_ZH*higgs_xs['ZH_'+opt.THEORYMASS]*higgs4l_br[opt.THEORYMASS+'_'+channel]*accCorrFact['ZH125_'+fState+'_genbin'+str(obsBin)]*acc_AC['ggH'+acSample+'_M125_'+channel+'_'+obsName+'_genbin'+str(obsBin)+'_recobin'+str(obsBin)])**2
XH_AC_unc_fs += XH_qqpdfunc_fs
# add pdf uncertainty for ttH to total XH uncertainty
XH_AC_unc_fs += (unc_pdf_ttH*higgs_xs['ttH_'+opt.THEORYMASS]*higgs4l_br[opt.THEORYMASS+'_'+channel]*accCorrFact['ttH125_'+fState+'_genbin'+str(obsBin)]*acc_AC['ggH'+acSample+'_M125_'+channel+'_'+obsName+'_genbin'+str(obsBin)+'_recobin'+str(obsBin)])**2
# total XH uncertainty
XH_AC_unc[obsBin]+=sqrt(XH_AC_unc_fs)
if(acFlagBis):
XH_ACbis_fs = higgs_xs['VBF_'+opt.THEORYMASS]*higgs4l_br[opt.THEORYMASS+'_'+channel]*accCorrFact['VBFH125_'+fState+'_genbin'+str(obsBin)]*acc_ACbis['ggH'+acSampleBis+'_M125_'+channel+'_'+obsName+'_genbin'+str(obsBin)+'_recobin'+str(obsBin)]
XH_ACbis_fs += higgs_xs['WH_'+opt.THEORYMASS]*higgs4l_br[opt.THEORYMASS+'_'+channel]*accCorrFact['WH125_'+fState+'_genbin'+str(obsBin)]*acc_ACbis['ggH'+acSampleBis+'_M125_'+channel+'_'+obsName+'_genbin'+str(obsBin)+'_recobin'+str(obsBin)]
XH_ACbis_fs += higgs_xs['ZH_'+opt.THEORYMASS]*higgs4l_br[opt.THEORYMASS+'_'+channel]*accCorrFact['ZH125_'+fState+'_genbin'+str(obsBin)]*acc_ACbis['ggH'+acSampleBis+'_M125_'+channel+'_'+obsName+'_genbin'+str(obsBin)+'_recobin'+str(obsBin)]
XH_ACbis_fs += higgs_xs['ttH_'+opt.THEORYMASS]*higgs4l_br[opt.THEORYMASS+'_'+channel]*accCorrFact['ttH125_'+fState+'_genbin'+str(obsBin)]*acc_ACbis['ggH'+acSampleBis+'_M125_'+channel+'_'+obsName+'_genbin'+str(obsBin)+'_recobin'+str(obsBin)]
XH_ACbis[obsBin]+=XH_ACbis_fs
# branching ratio uncertainty
XH_ACbis_unc_fs = (unc_br*XH_ACbis_fs)**2
# acceptance uncertainty
XH_ACbis_unc_fs += (unc_acc*XH_ACbis_fs)**2
XH_ACbis_qcdunc_fs = (unc_qcd_VBF*higgs_xs['VBF_'+opt.THEORYMASS]*higgs4l_br[opt.THEORYMASS+'_'+channel]*accCorrFact['VBFH125_'+fState+'_genbin'+str(obsBin)]*acc_ACbis['ggH'+acSampleBis+'_M125_'+channel+'_'+obsName+'_genbin'+str(obsBin)+'_recobin'+str(obsBin)])**2
XH_ACbis_qcdunc_fs += (unc_qcd_WH*higgs_xs['WH_'+opt.THEORYMASS]*higgs4l_br[opt.THEORYMASS+'_'+channel]*accCorrFact['WH125_'+fState+'_genbin'+str(obsBin)]*acc_ACbis['ggH'+acSampleBis+'_M125_'+channel+'_'+obsName+'_genbin'+str(obsBin)+'_recobin'+str(obsBin)])**2
XH_ACbis_qcdunc_fs += (unc_qcd_ZH*higgs_xs['ZH_'+opt.THEORYMASS]*higgs4l_br[opt.THEORYMASS+'_'+channel]*accCorrFact['ZH125_'+fState+'_genbin'+str(obsBin)]*acc_ACbis['ggH'+acSampleBis+'_M125_'+channel+'_'+obsName+'_genbin'+str(obsBin)+'_recobin'+str(obsBin)])**2
XH_ACbis_qcdunc_fs += (unc_qcd_ttH*higgs_xs['ttH_'+opt.THEORYMASS]*higgs4l_br[opt.THEORYMASS+'_'+channel]*accCorrFact['ttH125_'+fState+'_genbin'+str(obsBin)]*acc_ACbis['ggH'+acSampleBis+'_M125_'+channel+'_'+obsName+'_genbin'+str(obsBin)+'_recobin'+str(obsBin)])**2
XH_ACbis_unc_fs += XH_qcdunc_fs
# pdf
XH_ACbis_qqpdfunc_fs = (unc_pdf_VBF*higgs_xs['VBF_'+opt.THEORYMASS]*higgs4l_br[opt.THEORYMASS+'_'+channel]**accCorrFact['VBFH125_'+fState+'_genbin'+str(obsBin)]*acc_ACbis['ggH'+acSampleBis+'_M125_'+channel+'_'+obsName+'_genbin'+str(obsBin)+'_recobin'+str(obsBin)]
+unc_pdf_WH*higgs_xs['WH_'+opt.THEORYMASS]*higgs4l_br[opt.THEORYMASS+'_'+channel]*accCorrFact['WH125_'+fState+'_genbin'+str(obsBin)]*acc_ACbis['ggH'+acSampleBis+'_M125_'+channel+'_'+obsName+'_genbin'+str(obsBin)+'_recobin'+str(obsBin)]
+unc_pdf_ZH*higgs_xs['ZH_'+opt.THEORYMASS]*higgs4l_br[opt.THEORYMASS+'_'+channel]*accCorrFact['ZH125_'+fState+'_genbin'+str(obsBin)]*acc_ACbis['ggH'+acSampleBis+'_M125_'+channel+'_'+obsName+'_genbin'+str(obsBin)+'_recobin'+str(obsBin)])**2
XH_ACbis_unc_fs += XH_qqpdfunc_fs
# add pdf uncertainty for ttH to total XH uncertainty
XH_ACbis_unc_fs += (unc_pdf_ttH*higgs_xs['ttH_'+opt.THEORYMASS]*higgs4l_br[opt.THEORYMASS+'_'+channel]*accCorrFact['ttH125_'+fState+'_genbin'+str(obsBin)]*acc_ACbis['ggH'+acSampleBis+'_M125_'+channel+'_'+obsName+'_genbin'+str(obsBin)+'_recobin'+str(obsBin)])**2
# total XH uncertainty
XH_ACbis_unc[obsBin]+=sqrt(XH_ACbis_unc_fs)
# ggH cross sections
ggH_xsBR = higgs_xs['ggH_'+opt.THEORYMASS]*higgs4l_br[opt.THEORYMASS+'_'+channel]
#print "ggH_xsBR",ggH_xsBR
#print "ggH_xsBR_emutau",higgs_xs['ggH_'+opt.THEORYMASS]*higgs4l_br[opt.THEORYMASS+'_emutau']
ggH_powheg[obsBin]+=ggH_xsBR*acc['ggH125_'+channel+'_'+obsName+'_genbin'+str(obsBin)+'_recobin'+str(obsBin)]
ggH_minloHJ[obsBin]+=ggH_xsBR*acc_NNLOPS['ggH125_NNLOPS_'+channel+'_'+obsName+'_genbin'+str(obsBin)+'_recobin'+str(obsBin)]
ggH_aMC[obsBin]+=ggH_xsBR*acc['ggH125_aMC_'+channel+'_'+obsName+'_genbin'+str(obsBin)+'_recobin'+str(obsBin)]
# AC
if(acFlag):
ggH_AC[obsBin]+=ggH_xsBR*acc_AC['ggH'+acSample+'_M125_'+channel+'_'+obsName+'_genbin'+str(obsBin)+'_recobin'+str(obsBin)]
if(acFlagBis):
ggH_ACbis[obsBin]+=ggH_xsBR*acc_ACbis['ggH'+acSampleBis+'_M125_'+channel+'_'+obsName+'_genbin'+str(obsBin)+'_recobin'+str(obsBin)]
# for total uncertainty, correlate br and acc uncertainties across all channels (XH+ggH)
total_NNLOunc_fs_powheg_hi = (unc_br*(XH_fs+ggH_xsBR*acc['ggH125_'+channel+'_'+obsName+'_genbin'+str(obsBin)+'_recobin'+str(obsBin)]))**2
total_NNLOunc_fs_powheg_lo = (unc_br*(XH_fs+ggH_xsBR*acc['ggH125_'+channel+'_'+obsName+'_genbin'+str(obsBin)+'_recobin'+str(obsBin)]))**2
total_NNLOunc_fs_powheg_hi += (unc_acc*(XH_fs+ggH_xsBR*acc['ggH125_'+channel+'_'+obsName+'_genbin'+str(obsBin)+'_recobin'+str(obsBin)]))**2
total_NNLOunc_fs_powheg_lo += (unc_acc*(XH_fs+ggH_xsBR*acc['ggH125_'+channel+'_'+obsName+'_genbin'+str(obsBin)+'_recobin'+str(obsBin)]))**2
total_NNLOunc_fs_minloHJ_hi = (unc_br*(XH_fs+ggH_xsBR*acc_NNLOPS['ggH125_NNLOPS_'+channel+'_'+obsName+'_genbin'+str(obsBin)+'_recobin'+str(obsBin)]))**2
total_NNLOunc_fs_minloHJ_lo = (unc_br*(XH_fs+ggH_xsBR*acc_NNLOPS['ggH125_NNLOPS_'+channel+'_'+obsName+'_genbin'+str(obsBin)+'_recobin'+str(obsBin)]))**2
total_NNLOunc_fs_minloHJ_hi += (unc_acc*(XH_fs+ggH_xsBR*acc_NNLOPS['ggH125_NNLOPS_'+channel+'_'+obsName+'_genbin'+str(obsBin)+'_recobin'+str(obsBin)]))**2
total_NNLOunc_fs_minloHJ_lo += (unc_acc*(XH_fs+ggH_xsBR*acc_NNLOPS['ggH125_NNLOPS_'+channel+'_'+obsName+'_genbin'+str(obsBin)+'_recobin'+str(obsBin)]))**2
total_NNLOunc_fs_aMC_hi = (unc_br*(XH_fs+ggH_xsBR*acc['ggH125_aMC_'+channel+'_'+obsName+'_genbin'+str(obsBin)+'_recobin'+str(obsBin)]))**2
total_NNLOunc_fs_aMC_lo = (unc_br*(XH_fs+ggH_xsBR*acc['ggH125_aMC_'+channel+'_'+obsName+'_genbin'+str(obsBin)+'_recobin'+str(obsBin)]))**2
total_NNLOunc_fs_aMC_hi += (unc_acc*(XH_fs+ggH_xsBR*acc['ggH125_aMC_'+channel+'_'+obsName+'_genbin'+str(obsBin)+'_recobin'+str(obsBin)]))**2
total_NNLOunc_fs_aMC_lo += (unc_acc*(XH_fs+ggH_xsBR*acc['ggH125_aMC_'+channel+'_'+obsName+'_genbin'+str(obsBin)+'_recobin'+str(obsBin)]))**2
# NLO and NNLO are the same at this point
total_NLOunc_fs_powheg_hi = total_NNLOunc_fs_powheg_hi
total_NLOunc_fs_powheg_lo = total_NNLOunc_fs_powheg_lo
if acFlag:
total_NLOunc_fs_AC_hi = (unc_br*(XH_AC_fs+ggH_xsBR*acc_AC['ggH'+acSample+'_M125_'+channel+'_'+obsName+'_genbin'+str(obsBin)+'_recobin'+str(obsBin)]))**2
total_NLOunc_fs_AC_lo = (unc_br*(XH_AC_fs+ggH_xsBR*acc_AC['ggH'+acSample+'_M125_'+channel+'_'+obsName+'_genbin'+str(obsBin)+'_recobin'+str(obsBin)]))**2
total_NLOunc_fs_AC_hi += (unc_acc*(XH_AC_fs+ggH_xsBR*acc_AC['ggH'+acSample+'_M125_'+channel+'_'+obsName+'_genbin'+str(obsBin)+'_recobin'+str(obsBin)]))**2
total_NLOunc_fs_AC_lo += (unc_acc*(XH_AC_fs+ggH_xsBR*acc_AC['ggH'+acSample+'_M125_'+channel+'_'+obsName+'_genbin'+str(obsBin)+'_recobin'+str(obsBin)]))**2
if acFlagBis:
total_NLOunc_fs_ACbis_hi = (unc_br*(XH_ACbis_fs+ggH_xsBR*acc_ACbis['ggH'+acSampleBis+'_M125_'+channel+'_'+obsName+'_genbin'+str(obsBin)+'_recobin'+str(obsBin)]))**2
total_NLOunc_fs_ACbis_lo = (unc_br*(XH_ACbis_fs+ggH_xsBR*acc_ACbis['ggH'+acSampleBis+'_M125_'+channel+'_'+obsName+'_genbin'+str(obsBin)+'_recobin'+str(obsBin)]))**2
total_NLOunc_fs_ACbis_hi += (unc_acc*(XH_ACbis_fs+ggH_xsBR*acc_ACbis['ggH'+acSampleBis+'_M125_'+channel+'_'+obsName+'_genbin'+str(obsBin)+'_recobin'+str(obsBin)]))**2
total_NLOunc_fs_ACbis_lo += (unc_acc*(XH_ACbis_fs+ggH_xsBR*acc_ACbis['ggH'+acSampleBis+'_M125_'+channel+'_'+obsName+'_genbin'+str(obsBin)+'_recobin'+str(obsBin)]))**2
#total_NLOunc_fs_powheg_hi = 0.0
#total_NLOunc_fs_powheg_lo = 0.0
total_NLOunc_fs_minloHJ_hi = total_NNLOunc_fs_minloHJ_hi
total_NLOunc_fs_minloHJ_lo = total_NNLOunc_fs_minloHJ_lo
total_NLOunc_fs_aMC_hi = total_NNLOunc_fs_aMC_hi
total_NLOunc_fs_aMC_lo = total_NNLOunc_fs_aMC_lo
# add ggH qcd uncertainties (uncorrelated with anything else)
#NNLO
total_NNLOunc_fs_powheg_hi += XH_qcdunc_fs
total_NNLOunc_fs_powheg_lo += XH_qcdunc_fs
total_NNLOunc_fs_powheg_hi += (unc_qcd_ggH_hi*ggH_xsBR*acc['ggH125_'+channel+'_'+obsName+'_genbin'+str(obsBin)+'_recobin'+str(obsBin)])**2
total_NNLOunc_fs_powheg_lo += (unc_qcd_ggH_lo*ggH_xsBR*acc['ggH125_'+channel+'_'+obsName+'_genbin'+str(obsBin)+'_recobin'+str(obsBin)])**2
total_NNLOunc_fs_minloHJ_hi += XH_qcdunc_fs
total_NNLOunc_fs_minloHJ_lo += XH_qcdunc_fs
total_NNLOunc_fs_aMC_hi += XH_qcdunc_fs
total_NNLOunc_fs_aMC_lo += XH_qcdunc_fs
if (obsName.startswith("mass4l")):
total_NNLOunc_fs_minloHJ_hi += (unc_qcd_ggH_hi
*ggH_xsBR*acc_NNLOPS['ggH125_NNLOPS_'+channel+'_'+obsName+'_genbin'+str(obsBin)+'_recobin'+str(obsBin)])**2
total_NNLOunc_fs_minloHJ_lo += (unc_qcd_ggH_lo
*ggH_xsBR*acc_NNLOPS['ggH125_NNLOPS_'+channel+'_'+obsName+'_genbin'+str(obsBin)+'_recobin'+str(obsBin)])**2
total_NNLOunc_fs_aMC_hi += (unc_qcd_ggH_hi
*ggH_xsBR*acc['ggH125_aMC_'+channel+'_'+obsName+'_genbin'+str(obsBin)+'_recobin'+str(obsBin)])**2
total_NNLOunc_fs_aMC_lo += (unc_qcd_ggH_lo
*ggH_xsBR*acc['ggH125_aMC_'+channel+'_'+obsName+'_genbin'+str(obsBin)+'_recobin'+str(obsBin)])**2
else:
total_NNLOunc_fs_minloHJ_hi += (qcdunc_ggH_nnlops["ggH125_NNLOPS_"+channel+"_"+obsName.replace('_reco','_gen')+"_genbin"+str(obsBin)]['uncerUp']
*ggH_xsBR*acc_NNLOPS['ggH125_NNLOPS_'+channel+'_'+obsName+'_genbin'+str(obsBin)+'_recobin'+str(obsBin)])**2
total_NNLOunc_fs_minloHJ_lo += (qcdunc_ggH_nnlops["ggH125_NNLOPS_"+channel+"_"+obsName.replace('_reco','_gen')+"_genbin"+str(obsBin)]['uncerDn']
*ggH_xsBR*acc_NNLOPS['ggH125_NNLOPS_'+channel+'_'+obsName+'_genbin'+str(obsBin)+'_recobin'+str(obsBin)])**2
total_NNLOunc_fs_aMC_hi += (qcdunc_ggH_aMC["ggH125_aMC_"+channel+"_"+obsName.replace('_reco','_gen')+"_genbin"+str(obsBin)]['uncerUp']
*ggH_xsBR*acc['ggH125_aMC_'+channel+'_'+obsName+'_genbin'+str(obsBin)+'_recobin'+str(obsBin)])**2
total_NNLOunc_fs_aMC_lo += (qcdunc_ggH_aMC["ggH125_aMC_"+channel+"_"+obsName.replace('_reco','_gen')+"_genbin"+str(obsBin)]['uncerDn']
*ggH_xsBR*acc['ggH125_aMC_'+channel+'_'+obsName+'_genbin'+str(obsBin)+'_recobin'+str(obsBin)])**2
#NLO
total_NLOunc_fs_powheg_hi += XH_qcdunc_fs
total_NLOunc_fs_powheg_lo += XH_qcdunc_fs
total_NLOunc_fs_powheg_hi += (qcdunc_ggH_powheg["ggH125_"+channel+"_"+obsName.replace('_reco','_gen')+"_genbin"+str(obsBin)]['uncerUp']
*ggH_xsBR*acc['ggH125_'+channel+'_'+obsName+'_genbin'+str(obsBin)+'_recobin'+str(obsBin)])**2
total_NLOunc_fs_powheg_lo += (qcdunc_ggH_powheg["ggH125_"+channel+"_"+obsName.replace('_reco','_gen')+"_genbin"+str(obsBin)]['uncerDn']
*ggH_xsBR*acc['ggH125_'+channel+'_'+obsName+'_genbin'+str(obsBin)+'_recobin'+str(obsBin)])**2
if acFlag:
total_NLOunc_fs_AC_hi += XH_AC_qcdunc_fs
total_NLOunc_fs_AC_hi += XH_AC_qcdunc_fs
total_NLOunc_fs_AC_hi += (qcdunc_ggH_powheg["ggH125_"+channel+"_"+obsName.replace('_reco','_gen')+"_genbin"+str(obsBin)]['uncerUp']
*ggH_xsBR*acc_AC['ggH'+acSample+'_M125_'+channel+'_'+obsName+'_genbin'+str(obsBin)+'_recobin'+str(obsBin)])**2
total_NLOunc_fs_AC_lo += (qcdunc_ggH_powheg["ggH125_"+channel+"_"+obsName.replace('_reco','_gen')+"_genbin"+str(obsBin)]['uncerDn']
*ggH_xsBR*acc_AC['ggH'+acSample+'_M125_'+channel+'_'+obsName+'_genbin'+str(obsBin)+'_recobin'+str(obsBin)])**2
if acFlagBis:
total_NLOunc_fs_ACbis_hi += XH_ACbis_qcdunc_fs
total_NLOunc_fs_ACbis_hi += XH_ACbis_qcdunc_fs
total_NLOunc_fs_ACbis_hi += (qcdunc_ggH_powheg["ggH125_"+channel+"_"+obsName.replace('_reco','_gen')+"_genbin"+str(obsBin)]['uncerUp']
*ggH_xsBR*acc_ACbis['ggH'+acSampleBis+'_M125_'+channel+'_'+obsName+'_genbin'+str(obsBin)+'_recobin'+str(obsBin)])**2
total_NLOunc_fs_ACbis_lo += (qcdunc_ggH_powheg["ggH125_"+channel+"_"+obsName.replace('_reco','_gen')+"_genbin"+str(obsBin)]['uncerDn']
*ggH_xsBR*acc_ACbis['ggH'+acSampleBis+'_M125_'+channel+'_'+obsName+'_genbin'+str(obsBin)+'_recobin'+str(obsBin)])**2
print channel,total_NLOunc_fs_powheg_hi
total_NLOunc_fs_minloHJ_hi += XH_qcdunc_fs
total_NLOunc_fs_minloHJ_lo += XH_qcdunc_fs
total_NLOunc_fs_minloHJ_hi += (qcdunc_ggH_nnlops["ggH125_NNLOPS_"+channel+"_"+obsName.replace('_reco','_gen')+"_genbin"+str(obsBin)]['uncerUp']
*ggH_xsBR*acc_NNLOPS['ggH125_NNLOPS_'+channel+'_'+obsName+'_genbin'+str(obsBin)+'_recobin'+str(obsBin)])**2
total_NLOunc_fs_minloHJ_lo += (qcdunc_ggH_nnlops["ggH125_NNLOPS_"+channel+"_"+obsName.replace('_reco','_gen')+"_genbin"+str(obsBin)]['uncerDn']
*ggH_xsBR*acc_NNLOPS['ggH125_NNLOPS_'+channel+'_'+obsName+'_genbin'+str(obsBin)+'_recobin'+str(obsBin)])**2
total_NLOunc_fs_aMC_hi += XH_qcdunc_fs
total_NLOunc_fs_aMC_lo += XH_qcdunc_fs
total_NLOunc_fs_aMC_hi += (qcdunc_ggH_aMC["ggH125_aMC_"+channel+"_"+obsName.replace('_reco','_gen')+"_genbin"+str(obsBin)]['uncerUp']
*ggH_xsBR*acc['ggH125_aMC_'+channel+'_'+obsName+'_genbin'+str(obsBin)+'_recobin'+str(obsBin)])**2
total_NLOunc_fs_aMC_lo += (qcdunc_ggH_aMC["ggH125_aMC_"+channel+"_"+obsName.replace('_reco','_gen')+"_genbin"+str(obsBin)]['uncerDn']
*ggH_xsBR*acc['ggH125_aMC_'+channel+'_'+obsName+'_genbin'+str(obsBin)+'_recobin'+str(obsBin)])**2
# add pdf unc, anti correlate ggH and ttH
#NNLO
if (obsName.startswith("mass4l")):
obsUnc_pdf_ggH_hi = unc_pdf_ggH_hi
obsUnc_pdf_ggH_lo = unc_pdf_ggH_lo
else:
obsUnc_pdf_ggH_hi = pdfunc_ggH_powheg["ggH125_"+channel+"_"+obsName.replace('_reco','_gen')+"_genbin"+str(obsBin)]['uncerUp']
obsUnc_pdf_ggH_lo = pdfunc_ggH_powheg["ggH125_"+channel+"_"+obsName.replace('_reco','_gen')+"_genbin"+str(obsBin)]['uncerUp']
total_NNLOunc_fs_powheg_hi += XH_qqpdfunc_fs
total_NNLOunc_fs_powheg_lo += XH_qqpdfunc_fs
total_NNLOunc_fs_powheg_hi += (obsUnc_pdf_ggH_hi*ggH_xsBR*acc['ggH125_'+channel+'_'+obsName+'_genbin'+str(obsBin)+'_recobin'+str(obsBin)]
-unc_pdf_ttH*higgs_xs['ttH_'+opt.THEORYMASS]*higgs4l_br[opt.THEORYMASS+'_'+channel]*acc['ttH125_'+channel+'_'+obsName+'_genbin'+str(obsBin)+'_recobin'+str(obsBin)])**2
total_NNLOunc_fs_powheg_lo += (obsUnc_pdf_ggH_lo*ggH_xsBR*acc['ggH125_'+channel+'_'+obsName+'_genbin'+str(obsBin)+'_recobin'+str(obsBin)]
-unc_pdf_ttH*higgs_xs['ttH_'+opt.THEORYMASS]*higgs4l_br[opt.THEORYMASS+'_'+channel]*acc['ttH125_'+channel+'_'+obsName+'_genbin'+str(obsBin)+'_recobin'+str(obsBin)])**2
total_NNLOunc_fs_minloHJ_hi += XH_qqpdfunc_fs
total_NNLOunc_fs_minloHJ_lo += XH_qqpdfunc_fs
total_NNLOunc_fs_minloHJ_hi += (obsUnc_pdf_ggH_hi*ggH_xsBR*acc_NNLOPS['ggH125_NNLOPS_'+channel+'_'+obsName+'_genbin'+str(obsBin)+'_recobin'+str(obsBin)]
-unc_pdf_ttH*higgs_xs['ttH_'+opt.THEORYMASS]*higgs4l_br[opt.THEORYMASS+'_'+channel]*acc['ttH125_'+channel+'_'+obsName+'_genbin'+str(obsBin)+'_recobin'+str(obsBin)])**2
total_NNLOunc_fs_minloHJ_lo += (obsUnc_pdf_ggH_lo*ggH_xsBR*acc_NNLOPS['ggH125_NNLOPS_'+channel+'_'+obsName+'_genbin'+str(obsBin)+'_recobin'+str(obsBin)]
-unc_pdf_ttH*higgs_xs['ttH_'+opt.THEORYMASS]*higgs4l_br[opt.THEORYMASS+'_'+channel]*acc['ttH125_'+channel+'_'+obsName+'_genbin'+str(obsBin)+'_recobin'+str(obsBin)])**2
total_NNLOunc_fs_aMC_hi += XH_qqpdfunc_fs
total_NNLOunc_fs_aMC_lo += XH_qqpdfunc_fs
total_NNLOunc_fs_aMC_hi += (obsUnc_pdf_ggH_hi*ggH_xsBR*acc['ggH125_aMC_'+channel+'_'+obsName+'_genbin'+str(obsBin)+'_recobin'+str(obsBin)]
-unc_pdf_ttH*higgs_xs['ttH_'+opt.THEORYMASS]*higgs4l_br[opt.THEORYMASS+'_'+channel]*acc['ttH125_'+channel+'_'+obsName+'_genbin'+str(obsBin)+'_recobin'+str(obsBin)])**2
total_NNLOunc_fs_aMC_lo += (obsUnc_pdf_ggH_lo*ggH_xsBR*acc['ggH125_aMC_'+channel+'_'+obsName+'_genbin'+str(obsBin)+'_recobin'+str(obsBin)]
-unc_pdf_ttH*higgs_xs['ttH_'+opt.THEORYMASS]*higgs4l_br[opt.THEORYMASS+'_'+channel]*acc['ttH125_'+channel+'_'+obsName+'_genbin'+str(obsBin)+'_recobin'+str(obsBin)])**2
#NLO
total_NLOunc_fs_powheg_hi += XH_qqpdfunc_fs
total_NLOunc_fs_powheg_lo += XH_qqpdfunc_fs
total_NLOunc_fs_powheg_hi += (pdfunc_ggH_powheg["ggH125_"+channel+"_"+obsName.replace('_reco','_gen')+"_genbin"+str(obsBin)]['uncerUp']
*ggH_xsBR*acc['ggH125_'+channel+'_'+obsName+'_genbin'+str(obsBin)+'_recobin'+str(obsBin)]
-unc_pdf_ttH*higgs_xs['ttH_'+opt.THEORYMASS]*higgs4l_br[opt.THEORYMASS+'_'+channel]*acc['ttH125_'+channel+'_'+obsName+'_genbin'+str(obsBin)+'_recobin'+str(obsBin)])**2
total_NLOunc_fs_powheg_lo += (pdfunc_ggH_powheg["ggH125_"+channel+"_"+obsName.replace('_reco','_gen')+"_genbin"+str(obsBin)]['uncerDn']
*ggH_xsBR*acc['ggH125_'+channel+'_'+obsName+'_genbin'+str(obsBin)+'_recobin'+str(obsBin)]
-unc_pdf_ttH*higgs_xs['ttH_'+opt.THEORYMASS]*higgs4l_br[opt.THEORYMASS+'_'+channel]*acc['ttH125_'+channel+'_'+obsName+'_genbin'+str(obsBin)+'_recobin'+str(obsBin)])**2
if acFlag:
total_NLOunc_fs_AC_hi += XH_AC_qqpdfunc_fs
total_NLOunc_fs_AC_lo += XH_AC_qqpdfunc_fs
total_NLOunc_fs_AC_hi += (pdfunc_ggH_powheg["ggH125_"+channel+"_"+obsName.replace('_reco','_gen')+"_genbin"+str(obsBin)]['uncerUp']
*ggH_xsBR*acc_AC['ggH'+acSample+'_M125_'+channel+'_'+obsName+'_genbin'+str(obsBin)+'_recobin'+str(obsBin)]
-unc_pdf_ttH*higgs_xs['ttH_'+opt.THEORYMASS]*higgs4l_br[opt.THEORYMASS+'_'+channel]*acc_AC['ggH'+acSample+'_M125_'+channel+'_'+obsName+'_genbin'+str(obsBin)+'_recobin'+str(obsBin)])**2
total_NLOunc_fs_AC_lo += (pdfunc_ggH_powheg["ggH125_"+channel+"_"+obsName.replace('_reco','_gen')+"_genbin"+str(obsBin)]['uncerDn']
*ggH_xsBR*acc_AC['ggH'+acSample+'_M125_'+channel+'_'+obsName+'_genbin'+str(obsBin)+'_recobin'+str(obsBin)]
-unc_pdf_ttH*higgs_xs['ttH_'+opt.THEORYMASS]*higgs4l_br[opt.THEORYMASS+'_'+channel]*acc_AC['ggH'+acSample+'_M125_'+channel+'_'+obsName+'_genbin'+str(obsBin)+'_recobin'+str(obsBin)])**2
if acFlagBis:
total_NLOunc_fs_ACbis_hi += XH_ACbis_qqpdfunc_fs
total_NLOunc_fs_ACbis_lo += XH_ACbis_qqpdfunc_fs
total_NLOunc_fs_ACbis_hi += (pdfunc_ggH_powheg["ggH125_"+channel+"_"+obsName.replace('_reco','_gen')+"_genbin"+str(obsBin)]['uncerUp']
*ggH_xsBR*acc_ACbis['ggH'+acSampleBis+'_M125_'+channel+'_'+obsName+'_genbin'+str(obsBin)+'_recobin'+str(obsBin)]
-unc_pdf_ttH*higgs_xs['ttH_'+opt.THEORYMASS]*higgs4l_br[opt.THEORYMASS+'_'+channel]*acc_ACbis['ggH'+acSampleBis+'_M125_'+channel+'_'+obsName+'_genbin'+str(obsBin)+'_recobin'+str(obsBin)])**2
total_NLOunc_fs_ACbis_lo += (pdfunc_ggH_powheg["ggH125_"+channel+"_"+obsName.replace('_reco','_gen')+"_genbin"+str(obsBin)]['uncerDn']
*ggH_xsBR*acc_ACbis['ggH'+acSampleBis+'_M125_'+channel+'_'+obsName+'_genbin'+str(obsBin)+'_recobin'+str(obsBin)]
-unc_pdf_ttH*higgs_xs['ttH_'+opt.THEORYMASS]*higgs4l_br[opt.THEORYMASS+'_'+channel]*acc_ACbis['ggH'+acSampleBis+'_M125_'+channel+'_'+obsName+'_genbin'+str(obsBin)+'_recobin'+str(obsBin)])**2
total_NLOunc_fs_minloHJ_hi += XH_qqpdfunc_fs
total_NLOunc_fs_minloHJ_lo += XH_qqpdfunc_fs
total_NLOunc_fs_minloHJ_hi += (pdfunc_ggH_nnlops["ggH125_NNLOPS_"+channel+"_"+obsName.replace('_reco','_gen')+"_genbin"+str(obsBin)]['uncerUp']
*ggH_xsBR*acc_NNLOPS['ggH125_NNLOPS_'+channel+'_'+obsName+'_genbin'+str(obsBin)+'_recobin'+str(obsBin)]
-unc_pdf_ttH*higgs_xs['ttH_'+opt.THEORYMASS]*higgs4l_br[opt.THEORYMASS+'_'+channel]*acc['ttH125_'+channel+'_'+obsName+'_genbin'+str(obsBin)+'_recobin'+str(obsBin)])**2
total_NLOunc_fs_minloHJ_lo += (pdfunc_ggH_nnlops["ggH125_NNLOPS_"+channel+"_"+obsName.replace('_reco','_gen')+"_genbin"+str(obsBin)]['uncerDn']
*ggH_xsBR*acc_NNLOPS['ggH125_NNLOPS_'+channel+'_'+obsName+'_genbin'+str(obsBin)+'_recobin'+str(obsBin)]
-unc_pdf_ttH*higgs_xs['ttH_'+opt.THEORYMASS]*higgs4l_br[opt.THEORYMASS+'_'+channel]*acc['ttH125_'+channel+'_'+obsName+'_genbin'+str(obsBin)+'_recobin'+str(obsBin)])**2
total_NLOunc_fs_aMC_hi += XH_qqpdfunc_fs
total_NLOunc_fs_aMC_lo += XH_qqpdfunc_fs
total_NLOunc_fs_aMC_hi += (pdfunc_ggH_aMC["ggH125_aMC_"+channel+"_"+obsName.replace('_reco','_gen')+"_genbin"+str(obsBin)]['uncerUp']
*ggH_xsBR*acc['ggH125_aMC_'+channel+'_'+obsName+'_genbin'+str(obsBin)+'_recobin'+str(obsBin)]
-unc_pdf_ttH*higgs_xs['ttH_'+opt.THEORYMASS]*higgs4l_br[opt.THEORYMASS+'_'+channel]*acc['ttH125_'+channel+'_'+obsName+'_genbin'+str(obsBin)+'_recobin'+str(obsBin)])**2
total_NLOunc_fs_aMC_lo += (pdfunc_ggH_aMC["ggH125_aMC_"+channel+"_"+obsName.replace('_reco','_gen')+"_genbin"+str(obsBin)]['uncerDn']
*ggH_xsBR*acc['ggH125_aMC_'+channel+'_'+obsName+'_genbin'+str(obsBin)+'_recobin'+str(obsBin)]
-unc_pdf_ttH*higgs_xs['ttH_'+opt.THEORYMASS]*higgs4l_br[opt.THEORYMASS+'_'+channel]*acc['ttH125_'+channel+'_'+obsName+'_genbin'+str(obsBin)+'_recobin'+str(obsBin)])**2
# finally total uncertainty (different final states are correlated)
# NNLO
ggH_powheg_NNLOunc_hi[obsBin]+=sqrt(total_NNLOunc_fs_powheg_hi)
ggH_powheg_NNLOunc_lo[obsBin]+=sqrt(total_NNLOunc_fs_powheg_lo)
ggH_minloHJ_NNLOunc_hi[obsBin]+=sqrt(total_NNLOunc_fs_minloHJ_hi)
ggH_minloHJ_NNLOunc_lo[obsBin]+=sqrt(total_NNLOunc_fs_minloHJ_lo)
ggH_aMC_NNLOunc_hi[obsBin]+=sqrt(total_NNLOunc_fs_aMC_hi)
ggH_aMC_NNLOunc_lo[obsBin]+=sqrt(total_NNLOunc_fs_aMC_lo)
# NLO
ggH_powheg_NLOunc_hi[obsBin]+=sqrt(total_NLOunc_fs_powheg_hi)
ggH_powheg_NLOunc_lo[obsBin]+=sqrt(total_NLOunc_fs_powheg_lo)
ggH_minloHJ_NLOunc_hi[obsBin]+=sqrt(total_NLOunc_fs_minloHJ_hi)
ggH_minloHJ_NLOunc_lo[obsBin]+=sqrt(total_NLOunc_fs_minloHJ_lo)
ggH_aMC_NLOunc_hi[obsBin]+=sqrt(total_NLOunc_fs_aMC_hi)
ggH_aMC_NLOunc_lo[obsBin]+=sqrt(total_NLOunc_fs_aMC_lo)
if(acFlag):
ggH_AC_NLOunc_hi[obsBin]+=sqrt(total_NLOunc_fs_AC_hi)
ggH_AC_NLOunc_lo[obsBin]+=sqrt(total_NLOunc_fs_AC_lo)
if(acFlagBis):
ggH_ACbis_NLOunc_hi[obsBin]+=sqrt(total_NLOunc_fs_ACbis_hi)
ggH_ACbis_NLOunc_lo[obsBin]+=sqrt(total_NLOunc_fs_ACbis_lo)
ggH_powheg[obsBin]+=XH[obsBin]
if(acFlag):
ggH_AC[obsBin]+=XH_AC[obsBin]
if(acFlagBis): ggH_ACbis[obsBin]+=XH_ACbis[obsBin]
ggH_minloHJ[obsBin]+=XH[obsBin]
ggH_aMC[obsBin]+=XH[obsBin]
if (opt.UNBLIND):
data[obsBin] = resultsXS[datamodel+"_"+obsName+"_genbin"+str(obsBin)]["central"]
data_hi[obsBin] = resultsXS[datamodel+"_"+obsName+"_genbin"+str(obsBin)]["uncerUp"]
data_lo[obsBin] = -1.0*resultsXS[datamodel+"_"+obsName+"_genbin"+str(obsBin)]["uncerDn"]
#data_hi[obsBin] = resultsXS_LHScan["SM_125_"+obsName+"_genbin"+str(obsBin)]["uncerUp"]
#data_lo[obsBin] = -1.0*resultsXS_LHScan["SM_125_"+obsName+"_genbin"+str(obsBin)]["uncerDn"]
else:
data[obsBin] = resultsXS["SM_125_"+obsName+"_genbin"+str(obsBin)]["central"]
data_hi[obsBin] = resultsXS["SM_125_"+obsName+"_genbin"+str(obsBin)]["uncerUp"]
data_lo[obsBin] = -1.0*resultsXS["SM_125_"+obsName+"_genbin"+str(obsBin)]["uncerDn"]
if (opt.UNBLIND):
# modeldep_hi[obsBin] = modelIndUncert["SM_125_"+obsName+"_genbin"+str(obsBin)]["uncerUp"]
# modeldep_lo[obsBin] = -1.0*modelIndUncert["SM_125_"+obsName+"_genbin"+str(obsBin)]["uncerDn"]
systematics_hi[obsBin] = sqrt(max(0.0,resultsXS["SM_125_"+obsName+"_genbin"+str(obsBin)]["uncerUp"]**2-resultsXS["SM_125_"+obsName+"_genbin"+str(obsBin)+'_statOnly']["uncerUp"]**2))
systematics_lo[obsBin] = sqrt(max(0.0,resultsXS["SM_125_"+obsName+"_genbin"+str(obsBin)]["uncerDn"]**2-resultsXS["SM_125_"+obsName+"_genbin"+str(obsBin)+'_statOnly']["uncerDn"]**2))
#systematics_hi[obsBin] = sqrt(max(0.0,resultsXS_LHScan["SM_125_"+obsName+"_genbin"+str(obsBin)]["uncerUp"]**2-resultsXS_LHScan["SM_125_"+obsName+"_genbin"+str(obsBin)+'_statOnly']["uncerUp"]**2))
#systematics_lo[obsBin] = sqrt(max(0.0,resultsXS_LHScan["SM_125_"+obsName+"_genbin"+str(obsBin)]["uncerDn"]**2-resultsXS_LHScan["SM_125_"+obsName+"_genbin"+str(obsBin)+'_statOnly']["uncerDn"]**2))
else:
# modeldep_hi[obsBin] = modelIndUncert["AsimovData_"+obsName+"_genbin"+str(obsBin)]["uncerUp"]
# modeldep_lo[obsBin] = -1.0*modelIndUncert["AsimovData_"+obsName+"_genbin"+str(obsBin)]["uncerDn"]
systematics_hi[obsBin] = sqrt(max(0.0,resultsXS["SM_125_"+obsName+"_genbin"+str(obsBin)]["uncerUp"]**2-resultsXS["SM_125_"+obsName+"_genbin"+str(obsBin)+'_statOnly']["uncerUp"]**2))
systematics_lo[obsBin] = sqrt(max(0.0,resultsXS["SM_125_"+obsName+"_genbin"+str(obsBin)]["uncerDn"]**2-resultsXS["SM_125_"+obsName+"_genbin"+str(obsBin)+'_statOnly']["uncerDn"]**2))
stat_hi[obsBin] = resultsXS["SM_125_"+obsName+"_genbin"+str(obsBin)+'_statOnly']["uncerUp"]
stat_lo[obsBin] = resultsXS["SM_125_"+obsName+"_genbin"+str(obsBin)+'_statOnly']["uncerDn"]
data_hi_allunc[obsBin] = sqrt(data_hi[obsBin]**2+modeldep_hi[obsBin]**2)
data_lo_allunc[obsBin] = sqrt(data_lo[obsBin]**2+modeldep_lo[obsBin]**2)
if (obsName.startswith("mass4l")):
for channel in ['2e2mu','4mu','4e']:
# theory cross sections
ggH_powheg.append(0.0)
ggH_powheg_unc_hi.append(0.0)
ggH_powheg_unc_lo.append(0.0)
ggH_minloHJ.append(0.0)
ggH_minloHJ_unc_hi.append(0.0)
ggH_minloHJ_unc_lo.append(0.0)
ggH_aMC.append(0.0)
ggH_aMC_unc_hi.append(0.0)
ggH_aMC_unc_lo.append(0.0)
#ggH_HRes.append(0.0)
#ggH_HRes_unc_hi.append(0.0)
#ggH_HRes_unc_lo.append(0.0)
# NNLO theory unc
ggH_powheg_NNLOunc_hi.append(0.0)
ggH_powheg_NNLOunc_lo.append(0.0)
ggH_minloHJ_NNLOunc_hi.append(0.0)
ggH_minloHJ_NNLOunc_lo.append(0.0)
ggH_aMC_NNLOunc_hi.append(0.0)
ggH_aMC_NNLOunc_lo.append(0.0)
#ggH_HRes_NNLOunc_hi.append(0.0)
#ggH_HRes_NNLOunc_lo.append(0.0)
# NLO theory unc
ggH_powheg_NLOunc_hi.append(0.0)
ggH_powheg_NLOunc_lo.append(0.0)
ggH_minloHJ_NLOunc_hi.append(0.0)
ggH_minloHJ_NLOunc_lo.append(0.0)
ggH_aMC_NLOunc_hi.append(0.0)
ggH_aMC_NLOunc_lo.append(0.0)
# XH
XH.append(0.0)
XH_unc.append(0.0)
# Data
data.append(0.0)
data_hi.append(0.0)
data_lo.append(0.0)
# Systematic unc
modeldep_hi.append(0.0)
modeldep_lo.append(0.0)
systematics_hi.append(0.0)
systematics_lo.append(0.0)
data_hi_allunc.append(0.0)
data_lo_allunc.append(0.0)
if (channel=='2e2mu'): bin = 1
if (channel=='4mu'): bin = 2
if (channel=='4e'): bin = 3
obsBin=0
print obsBin,acc
XH_fs = higgs_xs['VBF_'+opt.THEORYMASS]*higgs4l_br[opt.THEORYMASS+'_'+channel]*acc['VBFH125_'+channel+'_'+obsName+'_genbin0_recobin0']
XH_fs += higgs_xs['WH_'+opt.THEORYMASS]*higgs4l_br[opt.THEORYMASS+'_'+channel]*acc['WH125_'+channel+'_'+obsName+'_genbin0_recobin0']
XH_fs += higgs_xs['ZH_'+opt.THEORYMASS]*higgs4l_br[opt.THEORYMASS+'_'+channel]*acc['ZH125_'+channel+'_'+obsName+'_genbin0_recobin0']
XH_fs += higgs_xs['ttH_'+opt.THEORYMASS]*higgs4l_br[opt.THEORYMASS+'_'+channel]*acc['ttH125_'+channel+'_'+obsName+'_genbin0_recobin0']
XH[bin]+=XH_fs
#XH_unc[bin]+= unc_VBF*higgs_xs['VBF_'+opt.THEORYMASS]*higgs4l_br[opt.THEORYMASS+'_'+channel]*acc['VBF_powheg_125_'+channel+'_'+obsName+'_genbin0_recobin0']
#XH_unc[bin]+= unc_WH*higgs_xs['WH_'+opt.THEORYMASS]*higgs4l_br[opt.THEORYMASS+'_'+channel]*acc['WH_powheg_JHUgen_125_'+channel+'_'+obsName+'_genbin0_recobin0']
#XH_unc[bin]+= unc_ZH*higgs_xs['ZH_'+opt.THEORYMASS]*higgs4l_br[opt.THEORYMASS+'_'+channel]*acc['ZH_powheg_JHUgen_125_'+channel+'_'+obsName+'_genbin0_recobin0']
#XH_unc[bin]+= unc_ttH*higgs_xs['ttH_'+opt.THEORYMASS]*higgs4l_br[opt.THEORYMASS+'_'+channel]*acc['ttH_powheg_JHUgen_125_'+channel+'_'+obsName+'_genbin0_recobin0']
# branching ratio uncertainty
XH_unc_fs = (unc_br*XH_fs)**2
# acceptance uncertainty
XH_unc_fs += (unc_acc*XH_fs)**2
# qcd scale
XH_qcdunc_fs = (unc_qcd_VBF*higgs_xs['VBF_'+opt.THEORYMASS]*higgs4l_br[opt.THEORYMASS+'_'+channel]*acc['VBFH125_'+channel+'_'+obsName+'_genbin0_recobin0'])**2
XH_qcdunc_fs += (unc_qcd_WH*higgs_xs['WH_'+opt.THEORYMASS]*higgs4l_br[opt.THEORYMASS+'_'+channel]*acc['WH125_'+channel+'_'+obsName+'_genbin0_recobin0'])**2
XH_qcdunc_fs += (unc_qcd_ZH*higgs_xs['ZH_'+opt.THEORYMASS]*higgs4l_br[opt.THEORYMASS+'_'+channel]*acc['ZH125_'+channel+'_'+obsName+'_genbin0_recobin0'])**2
XH_qcdunc_fs += (unc_qcd_ttH*higgs_xs['ttH_'+opt.THEORYMASS]*higgs4l_br[opt.THEORYMASS+'_'+channel]*acc['ttH125_'+channel+'_'+obsName+'_genbin0_recobin0'])**2
XH_unc_fs += XH_qcdunc_fs
# pdf
XH_qqpdfunc_fs = (unc_pdf_VBF*higgs_xs['VBF_'+opt.THEORYMASS]*higgs4l_br[opt.THEORYMASS+'_'+channel]*acc['VBFH125_'+channel+'_'+obsName+'_genbin0_recobin0']
+unc_pdf_WH*higgs_xs['WH_'+opt.THEORYMASS]*higgs4l_br[opt.THEORYMASS+'_'+channel]*acc['WH125_'+channel+'_'+obsName+'_genbin0_recobin0']
+unc_pdf_ZH*higgs_xs['ZH_'+opt.THEORYMASS]*higgs4l_br[opt.THEORYMASS+'_'+channel]*acc['ZH125_'+channel+'_'+obsName+'_genbin0_recobin0'])**2
XH_unc_fs += XH_qqpdfunc_fs
# add pdf uncertainty for ttH to total XH uncertainty
XH_unc_fs += (unc_pdf_ttH*higgs_xs['ttH_'+opt.THEORYMASS]*higgs4l_br[opt.THEORYMASS+'_'+channel]*acc['ttH125_'+channel+'_'+obsName+'_genbin0_recobin0'])**2
# total XH uncertainty
XH_unc[bin]+=sqrt(XH_unc_fs)
# ggH cross sections
ggH_xsBR = higgs_xs['ggH_'+opt.THEORYMASS]*higgs4l_br[opt.THEORYMASS+'_'+channel]
ggH_powheg[bin]+=ggH_xsBR*acc['ggH125_'+channel+'_'+obsName+'_genbin'+str(obsBin)+'_recobin'+str(obsBin)]
ggH_minloHJ[bin]+=ggH_xsBR*acc_NNLOPS['ggH125_NNLOPS_'+channel+'_'+obsName+'_genbin'+str(obsBin)+'_recobin'+str(obsBin)]
ggH_aMC[bin]+=ggH_xsBR*acc['ggH125_aMC_'+channel+'_'+obsName+'_genbin'+str(obsBin)+'_recobin'+str(obsBin)]
# for total uncertainty, correlate br and acc uncertainties across all channels (XH+ggH)
total_NNLOunc_fs_powheg_hi = (unc_br*(XH_fs+ggH_xsBR*acc['ggH125_'+channel+'_'+obsName+'_genbin0_recobin0']))**2
total_NNLOunc_fs_powheg_lo = (unc_br*(XH_fs+ggH_xsBR*acc['ggH125_'+channel+'_'+obsName+'_genbin0_recobin0']))**2
total_NNLOunc_fs_powheg_hi += (unc_acc*(XH_fs+ggH_xsBR*acc['ggH125_'+channel+'_'+obsName+'_genbin0_recobin0']))**2
total_NNLOunc_fs_powheg_lo += (unc_acc*(XH_fs+ggH_xsBR*acc['ggH125_'+channel+'_'+obsName+'_genbin0_recobin0']))**2
total_NNLOunc_fs_minloHJ_hi = (unc_br*(XH_fs+ggH_xsBR*acc_NNLOPS['ggH125_NNLOPS_'+channel+'_'+obsName+'_genbin0_recobin0']))**2
total_NNLOunc_fs_minloHJ_lo = (unc_br*(XH_fs+ggH_xsBR*acc_NNLOPS['ggH125_NNLOPS_'+channel+'_'+obsName+'_genbin0_recobin0']))**2
total_NNLOunc_fs_minloHJ_hi += (unc_acc*(XH_fs+ggH_xsBR*acc_NNLOPS['ggH125_NNLOPS_'+channel+'_'+obsName+'_genbin0_recobin0']))**2
total_NNLOunc_fs_minloHJ_lo += (unc_acc*(XH_fs+ggH_xsBR*acc_NNLOPS['ggH125_NNLOPS_'+channel+'_'+obsName+'_genbin0_recobin0']))**2
total_NNLOunc_fs_aMC_hi = (unc_br*(XH_fs+ggH_xsBR*acc['ggH125_aMC_'+channel+'_'+obsName+'_genbin0_recobin0']))**2
total_NNLOunc_fs_aMC_lo = (unc_br*(XH_fs+ggH_xsBR*acc['ggH125_aMC_'+channel+'_'+obsName+'_genbin0_recobin0']))**2
total_NNLOunc_fs_aMC_hi += (unc_acc*(XH_fs+ggH_xsBR*acc['ggH125_aMC_'+channel+'_'+obsName+'_genbin0_recobin0']))**2
total_NNLOunc_fs_aMC_lo += (unc_acc*(XH_fs+ggH_xsBR*acc['ggH125_aMC_'+channel+'_'+obsName+'_genbin0_recobin0']))**2
# add ggH qcd uncertainties (uncorrelated with anything else)
#NNLO
total_NNLOunc_fs_powheg_hi += XH_qcdunc_fs
total_NNLOunc_fs_powheg_lo += XH_qcdunc_fs
total_NNLOunc_fs_powheg_hi += (unc_qcd_ggH_hi*ggH_xsBR*acc['ggH125_'+channel+'_'+obsName+'_genbin'+str(obsBin)+'_recobin'+str(obsBin)])**2
total_NNLOunc_fs_powheg_lo += (unc_qcd_ggH_lo*ggH_xsBR*acc['ggH125_'+channel+'_'+obsName+'_genbin'+str(obsBin)+'_recobin'+str(obsBin)])**2
total_NNLOunc_fs_minloHJ_hi += XH_qcdunc_fs
total_NNLOunc_fs_minloHJ_lo += XH_qcdunc_fs
total_NNLOunc_fs_minloHJ_hi += (unc_qcd_ggH_hi*ggH_xsBR*acc_NNLOPS['ggH125_NNLOPS_'+channel+'_'+obsName+'_genbin'+str(obsBin)+'_recobin'+str(obsBin)])**2
total_NNLOunc_fs_minloHJ_lo += (unc_qcd_ggH_lo*ggH_xsBR*acc_NNLOPS['ggH125_NNLOPS_'+channel+'_'+obsName+'_genbin'+str(obsBin)+'_recobin'+str(obsBin)])**2
total_NNLOunc_fs_aMC_hi += XH_qcdunc_fs
total_NNLOunc_fs_aMC_lo += XH_qcdunc_fs
total_NNLOunc_fs_aMC_hi += (unc_qcd_ggH_hi*ggH_xsBR*acc['ggH125_aMC_'+channel+'_'+obsName+'_genbin'+str(obsBin)+'_recobin'+str(obsBin)])**2
total_NNLOunc_fs_aMC_lo += (unc_qcd_ggH_lo*ggH_xsBR*acc['ggH125_aMC_'+channel+'_'+obsName+'_genbin'+str(obsBin)+'_recobin'+str(obsBin)])**2
# add pdf unc, anti correlate ggH and ttH
#NNLO
total_NNLOunc_fs_powheg_hi += XH_qqpdfunc_fs
total_NNLOunc_fs_powheg_lo += XH_qqpdfunc_fs
total_NNLOunc_fs_powheg_hi += (unc_pdf_ggH_hi*ggH_xsBR*acc['ggH125_'+channel+'_'+obsName+'_genbin'+str(obsBin)+'_recobin'+str(obsBin)]
-unc_pdf_ttH*higgs_xs['ttH_'+opt.THEORYMASS]*higgs4l_br[opt.THEORYMASS+'_'+channel]*acc['ttH125_'+channel+'_'+obsName+'_genbin'+str(obsBin)+'_recobin'+str(obsBin)])**2
total_NNLOunc_fs_powheg_lo += (unc_pdf_ggH_lo*ggH_xsBR*acc['ggH125_'+channel+'_'+obsName+'_genbin'+str(obsBin)+'_recobin'+str(obsBin)]
-unc_pdf_ttH*higgs_xs['ttH_'+opt.THEORYMASS]*higgs4l_br[opt.THEORYMASS+'_'+channel]*acc['ttH125_'+channel+'_'+obsName+'_genbin'+str(obsBin)+'_recobin'+str(obsBin)])**2
total_NNLOunc_fs_minloHJ_hi += XH_qqpdfunc_fs
total_NNLOunc_fs_minloHJ_lo += XH_qqpdfunc_fs
total_NNLOunc_fs_minloHJ_hi += (unc_pdf_ggH_hi*ggH_xsBR*acc_NNLOPS['ggH125_NNLOPS_'+channel+'_'+obsName+'_genbin'+str(obsBin)+'_recobin'+str(obsBin)]
-unc_pdf_ttH*higgs_xs['ttH_'+opt.THEORYMASS]*higgs4l_br[opt.THEORYMASS+'_'+channel]*acc['ttH125_'+channel+'_'+obsName+'_genbin'+str(obsBin)+'_recobin'+str(obsBin)])**2
total_NNLOunc_fs_minloHJ_lo += (unc_pdf_ggH_lo*ggH_xsBR*acc_NNLOPS['ggH125_NNLOPS_'+channel+'_'+obsName+'_genbin'+str(obsBin)+'_recobin'+str(obsBin)]
-unc_pdf_ttH*higgs_xs['ttH_'+opt.THEORYMASS]*higgs4l_br[opt.THEORYMASS+'_'+channel]*acc['ttH125_'+channel+'_'+obsName+'_genbin'+str(obsBin)+'_recobin'+str(obsBin)])**2
total_NNLOunc_fs_aMC_hi += XH_qqpdfunc_fs
total_NNLOunc_fs_aMC_lo += XH_qqpdfunc_fs
total_NNLOunc_fs_aMC_hi += (unc_pdf_ggH_hi*ggH_xsBR*acc['ggH125_aMC_'+channel+'_'+obsName+'_genbin'+str(obsBin)+'_recobin'+str(obsBin)]
-unc_pdf_ttH*higgs_xs['ttH_'+opt.THEORYMASS]*higgs4l_br[opt.THEORYMASS+'_'+channel]*acc['ttH125_'+channel+'_'+obsName+'_genbin'+str(obsBin)+'_recobin'+str(obsBin)])**2
total_NNLOunc_fs_aMC_lo += (unc_pdf_ggH_lo*ggH_xsBR*acc['ggH125_aMC_'+channel+'_'+obsName+'_genbin'+str(obsBin)+'_recobin'+str(obsBin)]
-unc_pdf_ttH*higgs_xs['ttH_'+opt.THEORYMASS]*higgs4l_br[opt.THEORYMASS+'_'+channel]*acc['ttH125_'+channel+'_'+obsName+'_genbin'+str(obsBin)+'_recobin'+str(obsBin)])**2
# finally total uncertainty (different final states are correlated)
# NNLO
ggH_powheg_NNLOunc_hi[bin]+=sqrt(total_NNLOunc_fs_powheg_hi)
ggH_powheg_NNLOunc_lo[bin]+=sqrt(total_NNLOunc_fs_powheg_lo)
ggH_minloHJ_NNLOunc_hi[bin]+=sqrt(total_NNLOunc_fs_minloHJ_hi)
ggH_minloHJ_NNLOunc_lo[bin]+=sqrt(total_NNLOunc_fs_minloHJ_lo)
ggH_aMC_NNLOunc_hi[bin]+=sqrt(total_NNLOunc_fs_aMC_hi)
ggH_aMC_NNLOunc_lo[bin]+=sqrt(total_NNLOunc_fs_aMC_lo)
ggH_powheg[bin]+=XH[bin]
ggH_minloHJ[bin]+=XH[bin]
ggH_aMC[bin]+=XH[bin]
data[bin] = resultsXS_v2[datamodel+"_"+obsName+"_"+channel+"_genbin"+str(obsBin)]["central"]
data_hi[bin] = resultsXS_v2[datamodel+"_"+obsName+"_"+channel+"_genbin"+str(obsBin)]["uncerUp"]
data_lo[bin] = -1.0*resultsXS_v2[datamodel+"_"+obsName+"_"+channel+"_genbin"+str(obsBin)]["uncerDn"]
if (opt.UNBLIND):
# modeldep_hi[bin] = modelIndUncert_v2["SM_125_"+obsName+"_"+channel+"_genbin"+str(obsBin)]["uncerUp"]
# modeldep_lo[bin] = -1.0*modelIndUncert_v2["SM_125_"+obsName+"_"+channel+"_genbin"+str(obsBin)]["uncerDn"]
systematics_hi[bin] = sqrt(resultsXS_v2["SM_125_"+obsName+"_"+channel+"_genbin"+str(obsBin)]["uncerUp"]**2-resultsXS_v2["SM_125_"+obsName+"_"+channel+"_genbin"+str(obsBin)+'_statOnly']["uncerUp"]**2)
systematics_lo[bin] = sqrt(resultsXS_v2["SM_125_"+obsName+"_"+channel+"_genbin"+str(obsBin)]["uncerDn"]**2-resultsXS_v2["SM_125_"+obsName+"_"+channel+"_genbin"+str(obsBin)+'_statOnly']["uncerDn"]**2)
else:
#modeldep_hi[bin] = modelIndUncert_v2["AsimovData_"+obsName+"_"+channel+"_genbin"+str(obsBin)]["uncerUp"]
#modeldep_lo[bin] = -1.0*modelIndUncert_v2["AsimovData_"+obsName+"_"+channel+"_genbin"+str(obsBin)]["uncerDn"]
#systematics_hi[bin] = sqrt(resultsXS_v2["AsimovData_"+obsName+"_"+channel+"_genbin"+str(obsBin)]["uncerUp"]**2-resultsXS_v2["AsimovData_"+obsName+"_"+channel+"_genbin"+str(obsBin)+'_statOnly']["uncerUp"]**2)
#systematics_lo[bin] = sqrt(resultsXS_v2["AsimovData_"+obsName+"_"+channel+"_genbin"+str(obsBin)]["uncerDn"]**2-resultsXS_v2["AsimovData_"+obsName+"_"+channel+"_genbin"+str(obsBin)+'_statOnly']["uncerDn"]**2)
if (obsName.startswith("mass4l")):
# modeldep_hi[bin] = modelIndUncert_v2["AsimovData_"+obsName+"_"+channel+"_genbin"+str(obsBin)]["uncerUp"]
# modeldep_lo[bin] = -1.0*modelIndUncert_v2["AsimovData_"+obsName+"_"+channel+"_genbin"+str(obsBin)]["uncerDn"]
systematics_hi[bin] = sqrt(resultsXS_v2[datamodel+"_"+obsName+"_"+channel+"_genbin"+str(obsBin)]["uncerUp"]**2-resultsXS_v2[datamodel+"_"+obsName+"_"+channel+"_genbin"+str(obsBin)+'_statOnly']["uncerUp"]**2)
systematics_lo[bin] = sqrt(resultsXS_v2[datamodel+"_"+obsName+"_"+channel+"_genbin"+str(obsBin)]["uncerDn"]**2-resultsXS_v2[datamodel+"_"+obsName+"_"+channel+"_genbin"+str(obsBin)+'_statOnly']["uncerDn"]**2)
else:
# modeldep_hi[bin] = modelIndUncert_v2["SM_125_"+obsName+"_"+channel+"_genbin"+str(obsBin)]["uncerUp"]
# modeldep_lo[bin] = -1.0*modelIndUncert_v2["SM_125_"+obsName+"_"+channel+"_genbin"+str(obsBin)]["uncerDn"]
#systematics_hi[bin] = sqrt(resultsXS_v2["SM_125_"+obsName+"_"+channel+"_genbin"+str(obsBin)]["uncerUp"]**2-resultsXS_v2["SM_125_"+obsName+"_"+channel+"_genbin"+str(obsBin)+'_statOnly']["uncerUp"]**2)
#systematics_lo[bin] = sqrt(resultsXS_v2["SM_125_"+obsName+"_"+channel+"_genbin"+str(obsBin)]["uncerDn"]**2-resultsXS_v2["SM_125_"+obsName+"_"+channel+"_genbin"+str(obsBin)+'_statOnly']["uncerDn"]**2)
systematics_hi[bin] = sqrt(resultsXS_v2[datamodel+"_"+obsName+"_"+channel+"_genbin"+str(obsBin)]["uncerUp"]**2-resultsXS_v2["SM_125_"+obsName+"_"+channel+"_genbin"+str(obsBin)+'_statOnly']["uncerUp"]**2)
systematics_lo[bin] = sqrt(resultsXS_v2[datamodel+"_"+obsName+"_"+channel+"_genbin"+str(obsBin)]["uncerDn"]**2-resultsXS_v2["SM_125_"+obsName+"_"+channel+"_genbin"+str(obsBin)+'_statOnly']["uncerDn"]**2)
data_hi_allunc[bin] = sqrt(data_hi[bin]**2+modeldep_hi[bin]**2)
data_lo_allunc[bin] = sqrt(data_lo[bin]**2+modeldep_lo[bin]**2)
print 'data',data
sumdata = 0.0
for i in range(len(data)):
sumdata+=data[i]
print obsName,'sum data',sumdata
print 'data_hi',data_hi
print 'data_lo',data_lo
#print 'ggH HRes + XH',ggH_HRes
#print 'NNLO ggH HRes + XH',ggH_HRes_NNLOunc_hi
#print 'NNLO ggH HRes + XH',ggH_HRes_NNLOunc_lo
print 'ggH_powheg',ggH_powheg
if acFlag:
print 'ggH_AC',ggH_AC
if acFlagBis:
print 'ggH_ACbis',ggH_ACbis
print 'NLO ggH_powheg_hi',ggH_powheg_NLOunc_hi
print 'NLO ggH_powheg_lo',ggH_powheg_NLOunc_lo
print 'NNLO ggH_powheg_hi',ggH_powheg_NNLOunc_hi
print 'NNLO ggH_powheg_lo',ggH_powheg_NNLOunc_lo
print 'OLD ggH_powheg_hi',ggH_powheg_unc_hi
print 'OLD ggH_powheg_lo',ggH_powheg_unc_lo
print 'ggH_minloHJ',ggH_minloHJ
print 'ggH_minloHJ_NNLOunc_hi',ggH_minloHJ_NNLOunc_hi
print 'ggH_minloHJ_NNLOunc_lo',ggH_minloHJ_NNLOunc_lo
print 'ggH_aMC',ggH_aMC
print 'ggH_aMC_NNLOunc_hi',ggH_aMC_NNLOunc_hi
print 'ggH_aMC_NNLOunc_lo',ggH_aMC_NNLOunc_lo
print 'XH',XH
print 'XH_unc',XH_unc
if acFlag:
print 'XH_AC',XH_AC
print 'XH_AC_unc',XH_AC_unc
print 'ggH_AC_NLOunc_hi', ggH_AC_NLOunc_hi
print 'ggH_AC_NLOunc_lo', ggH_AC_NLOunc_lo
if acFlagBis:
print 'XH_ACbis',XH_ACbis
print 'XH_ACbis_unc',XH_ACbis_unc
print 'ggH_ACbis_NLOunc_hi', ggH_ACbis_NLOunc_hi
print 'ggH_ACbis_NLOunc_lo', ggH_ACbis_NLOunc_lo
print 'modedlep_hi',modeldep_hi
print 'modeldep_lo',modeldep_lo
print 'systematics_hi',systematics_hi
print 'systematics_lo',systematics_lo
print 'stat_hi',stat_hi
print 'stat_lo',stat_lo
if (obsName.startswith("mass4l")):
a_observable = array('d',[0.5+i for i in range(0,4)])
v_observable = TVectorD(len(a_observable),a_observable)
a_dobservable = array('d',[0.5 for i in range(0,4)])
v_dobservable = TVectorD(len(a_dobservable),a_dobservable)
a_zeros = array('d',[0.0 for i in range(0,4)])
v_zeros = TVectorD(len(a_zeros),a_zeros)
a_twos = array('d',[0.2*a_dobservable[i] for i in range(0,4)])
v_twos = TVectorD(len(a_twos),a_twos)
a_observable_1 = array('d',[0.2+i for i in range(0,4)])
v_observable_1 = TVectorD(len(a_observable_1),a_observable_1)
a_dobservable_1 = array('d',[0.125 for i in range(0,4)])
v_dobservable_1 = TVectorD(len(a_dobservable_1),a_dobservable_1)
a_observable_2 = array('d',[0.5+i for i in range(0,4)])
v_observable_2 = TVectorD(len(a_observable_2),a_observable_2)
a_dobservable_2 = array('d',[0.125 for i in range(0,4)])
v_dobservable_2 = TVectorD(len(a_dobservable_2),a_dobservable_2)
a_observable_3 = array('d',[0.8+i for i in range(0,4)])
v_observable_3 = TVectorD(len(a_observable_3),a_observable_3)
a_dobservable_3 = array('d',[0.125 for i in range(0,4)])
v_dobservable_3 = TVectorD(len(a_dobservable_3),a_dobservable_3)
a_ggH_powheg = array('d',[ggH_powheg[i] for i in range(len(ggH_powheg))])
v_ggH_powheg = TVectorD(len(a_ggH_powheg),a_ggH_powheg)
a_ggH_powheg_unc_hi = array('d',[ggH_powheg_NNLOunc_hi[i] for i in range(len(ggH_powheg))])
a_ggH_powheg_unc_lo = array('d',[ggH_powheg_NNLOunc_lo[i] for i in range(len(ggH_powheg))])
v_ggH_powheg_unc_hi = TVectorD(len(a_ggH_powheg_unc_hi),a_ggH_powheg_unc_hi)
v_ggH_powheg_unc_lo = TVectorD(len(a_ggH_powheg_unc_lo),a_ggH_powheg_unc_lo)
print 'a_ggH_powheg_hi',a_ggH_powheg_unc_hi
print 'a_ggH_powheg_lo',a_ggH_powheg_unc_lo
a_ggH_minloHJ = array('d',[ggH_minloHJ[i] for i in range(len(ggH_minloHJ))])
v_ggH_minloHJ = TVectorD(len(a_ggH_minloHJ),a_ggH_minloHJ)
a_ggH_minloHJ_unc_hi = array('d',[ggH_minloHJ_NNLOunc_hi[i] for i in range(len(ggH_minloHJ_unc_hi))])
a_ggH_minloHJ_unc_lo = array('d',[ggH_minloHJ_NNLOunc_lo[i] for i in range(len(ggH_minloHJ_unc_lo))])
v_ggH_minloHJ_unc_hi = TVectorD(len(a_ggH_minloHJ_unc_hi),a_ggH_minloHJ_unc_hi)
v_ggH_minloHJ_unc_lo = TVectorD(len(a_ggH_minloHJ_unc_lo),a_ggH_minloHJ_unc_lo)
print 'a_ggH_minloHJ',a_ggH_minloHJ
print 'a_ggH_minloHJ_hi',a_ggH_minloHJ_unc_hi
print 'a_ggH_minloHJ_lo',a_ggH_minloHJ_unc_lo
a_ggH_aMC = array('d',[ggH_aMC[i] for i in range(len(ggH_aMC))])
v_ggH_aMC = TVectorD(len(a_ggH_aMC),a_ggH_aMC)
a_ggH_aMC_unc_hi = array('d',[ggH_aMC_NNLOunc_hi[i] for i in range(len(ggH_aMC_unc_hi))])
a_ggH_aMC_unc_lo = array('d',[ggH_aMC_NNLOunc_lo[i] for i in range(len(ggH_aMC_unc_lo))])
v_ggH_aMC_unc_hi = TVectorD(len(a_ggH_aMC_unc_hi),a_ggH_aMC_unc_hi)
v_ggH_aMC_unc_lo = TVectorD(len(a_ggH_aMC_unc_lo),a_ggH_aMC_unc_lo)
print 'a_ggH_aMC',a_ggH_aMC
print 'a_ggH_aMC_hi',a_ggH_aMC_unc_hi
print 'a_ggH_aMC_lo',a_ggH_aMC_unc_lo
'''
a_ggH_HRes = array('d',[ggH_HRes[i] for i in range(len(ggH_HRes))])
v_ggH_HRes = TVectorD(len(a_ggH_HRes),a_ggH_HRes)
a_ggH_HRes_unc_hi = array('d',[ggH_HRes_NNLOunc_hi[i] for i in range(len(ggH_HRes_unc_hi))])
a_ggH_HRes_unc_lo = array('d',[ggH_HRes_NNLOunc_lo[i] for i in range(len(ggH_HRes_unc_lo))])
v_ggH_HRes_unc_hi = TVectorD(len(a_ggH_HRes_unc_hi),a_ggH_HRes_unc_hi)
v_ggH_HRes_unc_lo = TVectorD(len(a_ggH_HRes_unc_lo),a_ggH_HRes_unc_lo)
print 'a_ggH_HRes',a_ggH_HRes
print 'a_ggH_HRes_hi',a_ggH_HRes_unc_hi
print 'a_ggH_HRes_lo',a_ggH_HRes_unc_lo
'''
a_XH = array('d',[XH[0],XH[1],XH[2],XH[3]])
v_XH = TVectorD(len(a_XH),a_XH)