-
Notifications
You must be signed in to change notification settings - Fork 1
/
bias_old.py
executable file
·668 lines (629 loc) · 19.9 KB
/
bias_old.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
#!/bin/bash
###
### Macro to be used as executable in the HTCondor submission by submit_combine.py.
###
## fetiching global variables
main_dir='./' #to be replaced when submitted to HTCondor. Currently has to be on line 8 to be correctly replaced in submit_combine.py!
echo "main_dir = ${main_dir}"
combine_dir=$(${main_dir}global_paths.py -g COMBINEDIR)
echo "combine_dir = ${combine_dir}"
grid_cert=$(${main_dir}global_paths.py -g GRIDCERTIFICATE)
echo "grid_cert = ${grid_cert}"
bias_dir=$(${main_dir}global_paths.py -g BIASDIR)
echo "bias_dir = ${bias_dir}"
echo
echo
echo 'START---------------'
workdir=$(pwd)
echo "workdir = $workdir"
cd $combine_dir
eval `scram runtime -sh`
cd $workdir
export X509_USER_PROXY=$grid_cert
use_x509userproxy=true
#option=""
masses=(1600 1700 1800 1900 2000 2100 2200 2300 2400 2500 2600 2700 2800 2900 3000 3100 3200 3300 3400 3500 3600 3700 3800 3900 4000 4100 4200 4300 4400 4500 4600 4700 4800 4900 5000 5100 5200 5300 5400 5500 5600 5700 5800 5900 6000 6100 6200 6300 6400 6500 6600 6700 6800 6900 7000 7100 7200 7300 7400 7500 7600 7700 7800 7900 8000)
########## input arguments ##########
isMC=$1
year=$2
btagging=$3
mass_nr=$4
ntoys=$5
seed=$6
#####################################
if [[ $seed == "" ]]; then
seed=123456
fi
mass=${masses[${mass_nr}]}
if [[ $year == run2c ]]; then
echo "Combining the 2016-2018 fits separately into a single limit..."
year="run2"
combined=1
else
combined=0
fi
## varying signal injection depending on mass:
expectSignal=0
rmin=-30
rmax=70
####### use this for nice fits
#if [ $mass -eq 1600 ]; then
# #expectSignal=20
#elif [ $mass -eq 1700 ]; then
# #expectSignal=15
#elif [ $mass -eq 1800 ]; then
# #expectSignal=10
#elif [ $mass -eq 1900 ]; then
# #expectSignal=15
#elif [ $mass -eq 2000 ]; then
# #expectSignal=15
#elif [ $mass -eq 2100 ]; then
# #expectSignal=3
#elif [ $mass -eq 2200 ]; then
# #expectSignal=15
#elif [ $mass -eq 2300 ]; then
# #expectSignal=8
#elif [ $mass -eq 2400 ]; then
# #expectSignal=8
#elif [ $mass -eq 2500 ]; then
# #expectSignal=3
#elif [ $mass -eq 2600 ]; then
# #expectSignal=8
#elif [ $mass -eq 2700 ]; then
# #expectSignal=10
#elif [ $mass -eq 2800 ]; then
# #expectSignal=10
#elif [ $mass -eq 2900 ]; then
# #expectSignal=5
#elif [ $mass -eq 3000 ]; then
# #expectSignal=8
#elif [ $mass -eq 3100 ]; then
# #expectSignal=10
#elif [ $mass -eq 3200 ]; then
# #expectSignal=15
#elif [ $mass -eq 3300 ]; then
# #expectSignal=3
#elif [ $mass -eq 3400 ]; then
# #expectSignal=10
#elif [ $mass -eq 3500 ]; then
# #expectSignal=5
#elif [ $mass -eq 3600 ]; then
# #expectSignal=15
#elif [ $mass -eq 3700 ]; then
# #expectSignal=5
#elif [ $mass -eq 3800 ]; then
# #expectSignal=3
#elif [ $mass -eq 3900 ]; then
# #expectSignal=1
#elif [ $mass -eq 4000 ]; then
# #expectSignal=1
#elif [ $mass -eq 4100 ]; then
# #expectSignal=1
#elif [ $mass -eq 4200 ]; then
# #expectSignal=10
#elif [ $mass -eq 4300 ]; then
# #expectSignal=8
#elif [ $mass -eq 4400 ]; then
# #expectSignal=8
#elif [ $mass -eq 4500 ]; then
# #expectSignal=15
#elif [ $mass -eq 4600 ]; then
# #expectSignal=8
#elif [ $mass -eq 4700 ]; then
# #expectSignal=3
#elif [ $mass -eq 4800 ]; then
# #expectSignal=3
#elif [ $mass -eq 4900 ]; then
# #expectSignal=3
#elif [ $mass -eq 5000 ]; then
# #expectSignal=3
#elif [ $mass -eq 5100 ]; then
# #expectSignal=1
#elif [ $mass -eq 5200 ]; then
# #expectSignal=3
#elif [ $mass -eq 5300 ]; then
# #expectSignal=5
#elif [ $mass -eq 5400 ]; then
# #expectSignal=5
#elif [ $mass -eq 5500 ]; then
# #expectSignal=10
#elif [ $mass -eq 5600 ]; then
# #expectSignal=1
#elif [ $mass -eq 5700 ]; then
# #expectSignal=5
#elif [ $mass -eq 5800 ]; then
# #expectSignal=1
#elif [ $mass -eq 5900 ]; then
# #expectSignal=1
#elif [ $mass -eq 6000 ]; then
# #expectSignal=15
#elif [ $mass -eq 6100 ]; then
# #expectSignal=1
#elif [ $mass -eq 6200 ]; then
# #expectSignal=5
#elif [ $mass -eq 6300 ]; then
# #expectSignal=1
#elif [ $mass -eq 6400 ]; then
# #expectSignal=3
#elif [ $mass -eq 6500 ]; then
# #expectSignal=3
#elif [ $mass -eq 6600 ]; then
# #expectSignal=5
#elif [ $mass -eq 6700 ]; then
# #expectSignal=10
#elif [ $mass -eq 6800 ]; then
# #expectSignal=3
#elif [ $mass -eq 6900 ]; then
# #expectSignal=10
#elif [ $mass -eq 7000 ]; then
# #expectSignal=5
#elif [ $mass -eq 7100 ]; then
# #expectSignal=10
#elif [ $mass -eq 7200 ]; then
# #expectSignal=8
#elif [ $mass -eq 7300 ]; then
# #expectSignal=8
#elif [ $mass -eq 7400 ]; then
# #expectSignal=3
#elif [ $mass -eq 7500 ]; then
# #expectSignal=10
#elif [ $mass -eq 7600 ]; then
# #expectSignal=3
#elif [ $mass -eq 7700 ]; then
# #expectSignal=1
#elif [ $mass -eq 7800 ]; then
# #expectSignal=3
#elif [ $mass -eq 7900 ]; then
# #expectSignal=15
#elif [ $mass -eq 8000 ]; then
# #expectSignal=8
#else
# echo "mass point not recocnized"
#fi
####### use this for ~2sigma
### use putting some signal load into the datacards
#if [ $mass -eq 1600 ]; then
# expectSignal=21
#elif [ $mass -eq 1700 ]; then
# expectSignal=15
#elif [ $mass -eq 1800 ]; then
# expectSignal=10
#elif [ $mass -eq 1900 ]; then
# expectSignal=8
#elif [ $mass -eq 2000 ]; then
# expectSignal=7
#elif [ $mass -eq 2100 ]; then
# expectSignal=16
#elif [ $mass -eq 2200 ]; then
# expectSignal=14
#elif [ $mass -eq 2300 ]; then
# expectSignal=13
#elif [ $mass -eq 2400 ]; then
# expectSignal=12
#elif [ $mass -eq 2500 ]; then
# expectSignal=11
###
##if [ $mass -eq 1600 ]; then
## expectSignal=106
##elif [ $mass -eq 1700 ]; then
## expectSignal=77
##elif [ $mass -eq 1800 ]; then
## expectSignal=51
##elif [ $mass -eq 1900 ]; then
## expectSignal=41
##elif [ $mass -eq 2000 ]; then
## expectSignal=35
##elif [ $mass -eq 2100 ]; then
## expectSignal=32
##elif [ $mass -eq 2200 ]; then
## expectSignal=28
##elif [ $mass -eq 2300 ]; then
## expectSignal=26
##elif [ $mass -eq 2400 ]; then
## expectSignal=23
##elif [ $mass -eq 2500 ]; then
## expectSignal=21
#elif [ $mass -eq 2600 ]; then
# expectSignal=20
#elif [ $mass -eq 2700 ]; then
# expectSignal=18
#elif [ $mass -eq 2800 ]; then
# expectSignal=17
#elif [ $mass -eq 2900 ]; then
# expectSignal=15
#elif [ $mass -eq 3000 ]; then
# expectSignal=14
#elif [ $mass -eq 3100 ]; then
# expectSignal=13
#elif [ $mass -eq 3200 ]; then
# expectSignal=13
#elif [ $mass -eq 3300 ]; then
# expectSignal=12
#elif [ $mass -eq 3400 ]; then
# expectSignal=11
#elif [ $mass -eq 3500 ]; then
# expectSignal=11
#elif [ $mass -eq 3600 ]; then
# expectSignal=10
#elif [ $mass -eq 3700 ]; then
# expectSignal=9
#elif [ $mass -eq 3800 ]; then
# expectSignal=9
#elif [ $mass -eq 3900 ]; then
# expectSignal=8
#elif [ $mass -eq 4000 ]; then
# expectSignal=8
#elif [ $mass -eq 4100 ]; then
# expectSignal=7
#elif [ $mass -eq 4200 ]; then
# expectSignal=7
#elif [ $mass -eq 4300 ]; then
# expectSignal=6
#elif [ $mass -eq 4400 ]; then
# expectSignal=6
#elif [ $mass -eq 4500 ]; then
# expectSignal=6
#elif [ $mass -eq 4600 ]; then
# expectSignal=5
#elif [ $mass -eq 4700 ]; then
# expectSignal=5
#elif [ $mass -eq 4800 ]; then
# expectSignal=4
#elif [ $mass -eq 4900 ]; then
# expectSignal=4
#elif [ $mass -eq 5000 ]; then
# expectSignal=4
#elif [ $mass -eq 5100 ]; then
# expectSignal=4
#elif [ $mass -eq 5200 ]; then
# expectSignal=3
#elif [ $mass -eq 5300 ]; then
# expectSignal=3
#elif [ $mass -eq 5400 ]; then
# expectSignal=3
#elif [ $mass -eq 5500 ]; then
# expectSignal=3
#elif [ $mass -eq 5600 ]; then
# expectSignal=2
#elif [ $mass -eq 5700 ]; then
# expectSignal=2
#elif [ $mass -eq 5800 ]; then
# expectSignal=2
#elif [ $mass -eq 5900 ]; then
# expectSignal=2
#elif [ $mass -eq 6000 ]; then
# expectSignal=2
#elif [ $mass -eq 6100 ]; then
# expectSignal=2
#elif [ $mass -eq 6200 ]; then
# expectSignal=1
#elif [ $mass -eq 6300 ]; then
# expectSignal=1
#elif [ $mass -eq 6400 ]; then
# expectSignal=1
#elif [ $mass -eq 6500 ]; then
# expectSignal=1
#elif [ $mass -eq 6600 ]; then
# expectSignal=1
#elif [ $mass -eq 6700 ]; then
# expectSignal=1
#elif [ $mass -eq 6800 ]; then
# expectSignal=1
#elif [ $mass -eq 6900 ]; then
# expectSignal=1
#elif [ $mass -eq 7000 ]; then
# expectSignal=1
#elif [ $mass -eq 7100 ]; then
# expectSignal=1
#elif [ $mass -eq 7200 ]; then
# expectSignal=1
#elif [ $mass -eq 7300 ]; then
# expectSignal=1
#elif [ $mass -eq 7400 ]; then
# expectSignal=1
#elif [ $mass -eq 7500 ]; then
# expectSignal=1
#elif [ $mass -eq 7600 ]; then
# expectSignal=1
#elif [ $mass -eq 7700 ]; then
# expectSignal=1
#elif [ $mass -eq 7800 ]; then
# expectSignal=1
#elif [ $mass -eq 7900 ]; then
# expectSignal=1
#elif [ $mass -eq 8000 ]; then
# expectSignal=1
#else
# echo "mass point not recocnized"
#fi
###### use this for ~5sigma
## use putting some signal load into the datacards
if [ $mass -eq 1600 ]; then
expectSignal=11
elif [ $mass -eq 1700 ]; then
expectSignal=16
elif [ $mass -eq 1800 ]; then
expectSignal=8
elif [ $mass -eq 1900 ]; then
expectSignal=6
elif [ $mass -eq 2000 ]; then
expectSignal=8
elif [ $mass -eq 2100 ]; then
expectSignal=8
elif [ $mass -eq 2200 ]; then
expectSignal=7
elif [ $mass -eq 2300 ]; then
expectSignal=8
elif [ $mass -eq 2400 ]; then
expectSignal=3
elif [ $mass -eq 2500 ]; then
expectSignal=4
elif [ $mass -eq 2600 ]; then
expectSignal=7
elif [ $mass -eq 2700 ]; then
expectSignal=5
elif [ $mass -eq 2800 ]; then
expectSignal=6
elif [ $mass -eq 2900 ]; then
expectSignal=2
elif [ $mass -eq 3000 ]; then
expectSignal=6
elif [ $mass -eq 3100 ]; then
expectSignal=3
elif [ $mass -eq 3200 ]; then
expectSignal=1
elif [ $mass -eq 3300 ]; then
expectSignal=3
elif [ $mass -eq 3400 ]; then
expectSignal=4
elif [ $mass -eq 3500 ]; then
expectSignal=2
elif [ $mass -eq 3600 ]; then
expectSignal=5
elif [ $mass -eq 3700 ]; then
expectSignal=4
elif [ $mass -eq 3800 ]; then
expectSignal=1
elif [ $mass -eq 3900 ]; then
expectSignal=3
elif [ $mass -eq 4000 ]; then
expectSignal=2
##
#if [ $mass -eq 1600 ]; then
# expectSignal=264
#elif [ $mass -eq 1700 ]; then
# expectSignal=192
#elif [ $mass -eq 1800 ]; then
# expectSignal=128
#elif [ $mass -eq 1900 ]; then
# expectSignal=102
#elif [ $mass -eq 2000 ]; then
# expectSignal=88
#elif [ $mass -eq 2100 ]; then
# expectSignal=79
#elif [ $mass -eq 2200 ]; then
# expectSignal=71
#elif [ $mass -eq 2300 ]; then
# expectSignal=64
#elif [ $mass -eq 2400 ]; then
# expectSignal=58
#elif [ $mass -eq 2500 ]; then
# expectSignal=53
#elif [ $mass -eq 2600 ]; then
# expectSignal=49
#elif [ $mass -eq 2700 ]; then
# expectSignal=45
#elif [ $mass -eq 2800 ]; then
# expectSignal=41
#elif [ $mass -eq 2900 ]; then
# expectSignal=38
#elif [ $mass -eq 3000 ]; then
# expectSignal=36
#elif [ $mass -eq 3100 ]; then
# expectSignal=33
#elif [ $mass -eq 3200 ]; then
# expectSignal=31
#elif [ $mass -eq 3300 ]; then
# expectSignal=30
#elif [ $mass -eq 3400 ]; then
# expectSignal=28
#elif [ $mass -eq 3500 ]; then
# expectSignal=26
#elif [ $mass -eq 3600 ]; then
# expectSignal=25
#elif [ $mass -eq 3700 ]; then
# expectSignal=24
#elif [ $mass -eq 3800 ]; then
# expectSignal=23
#elif [ $mass -eq 3900 ]; then
# expectSignal=21
#elif [ $mass -eq 4000 ]; then
# expectSignal=20
elif [ $mass -eq 4100 ]; then
expectSignal=19
elif [ $mass -eq 4200 ]; then
expectSignal=17
elif [ $mass -eq 4300 ]; then
expectSignal=16
elif [ $mass -eq 4400 ]; then
expectSignal=15
elif [ $mass -eq 4500 ]; then
expectSignal=14
elif [ $mass -eq 4600 ]; then
expectSignal=13
elif [ $mass -eq 4700 ]; then
expectSignal=12
elif [ $mass -eq 4800 ]; then
expectSignal=11
elif [ $mass -eq 4900 ]; then
expectSignal=10
elif [ $mass -eq 5000 ]; then
expectSignal=9
elif [ $mass -eq 5100 ]; then
expectSignal=9
elif [ $mass -eq 5200 ]; then
expectSignal=8
elif [ $mass -eq 5300 ]; then
expectSignal=7
elif [ $mass -eq 5400 ]; then
expectSignal=7
elif [ $mass -eq 5500 ]; then
expectSignal=6
elif [ $mass -eq 5600 ]; then
expectSignal=6
elif [ $mass -eq 5700 ]; then
expectSignal=5
elif [ $mass -eq 5800 ]; then
expectSignal=5
elif [ $mass -eq 5900 ]; then
expectSignal=5
elif [ $mass -eq 6000 ]; then
expectSignal=4
elif [ $mass -eq 6100 ]; then
expectSignal=4
elif [ $mass -eq 6200 ]; then
expectSignal=4
elif [ $mass -eq 6300 ]; then
expectSignal=3
elif [ $mass -eq 6400 ]; then
expectSignal=3
elif [ $mass -eq 6500 ]; then
expectSignal=3
elif [ $mass -eq 6600 ]; then
expectSignal=3
elif [ $mass -eq 6700 ]; then
expectSignal=2
elif [ $mass -eq 6800 ]; then
expectSignal=2
elif [ $mass -eq 6900 ]; then
expectSignal=2
elif [ $mass -eq 7000 ]; then
expectSignal=2
elif [ $mass -eq 7100 ]; then
expectSignal=2
elif [ $mass -eq 7200 ]; then
expectSignal=2
elif [ $mass -eq 7300 ]; then
expectSignal=2
elif [ $mass -eq 7400 ]; then
expectSignal=2
elif [ $mass -eq 7500 ]; then
expectSignal=1
elif [ $mass -eq 7600 ]; then
expectSignal=1
elif [ $mass -eq 7700 ]; then
expectSignal=1
elif [ $mass -eq 7800 ]; then
expectSignal=1
elif [ $mass -eq 7900 ]; then
expectSignal=1
elif [ $mass -eq 8000 ]; then
expectSignal=1
else
echo "mass point not recocnized"
fi
echo "isMC = ${isMC}"
echo "year = ${year}"
echo "btagging = ${btagging}"
echo "mass_nr = ${mass_nr}"
echo "mass = ${mass}"
echo "combined = ${combined}"
echo "seed = ${seed}"
echo "expectSignal = ${expectSignal}"
echo "rmin = ${rmin}"
echo "rmax = ${rmax}"
if [[ $isMC -eq 1 ]]; then
echo "running purely on MC..."
suffix="_MC.txt"
prefix="MC_QCD_TTbar"
else
echo "running on real data..."
suffix=".txt"
prefix="data"
fi
## setting up a repository structure on the local working node:
mkdir datacards
mkdir datacards/${btagging}
mkdir datacards/${btagging}/bias
mkdir datacards/${btagging}/bias/combined
mkdir workspace
mkdir workspace/${btagging}
mkdir workspace/${btagging}/bias
if [[ $combined -eq 1 ]]; then
#cp ${main_dir}datacards/${btagging}/bias/combined/fully_combined_run2_M${mass}${suffix} datacards/${btagging}/bias/combined/
#cp ${main_dir}datacards/${btagging}/bias/combined_varying_rate_2sigma/fully_combined_run2_M${mass}${suffix} datacards/${btagging}/bias/combined/ ##FIXME FIXME
cp ${main_dir}datacards/${btagging}/bias/combined_varying_rate_5sigma/fully_combined_run2_M${mass}${suffix} datacards/${btagging}/bias/combined/ ##FIXME FIXME
cp ${main_dir}workspace/${btagging}/MC_signal_201* workspace/${btagging}/
cp ${main_dir}workspace/${btagging}/bias/${prefix}_201* workspace/${btagging}/bias/
else
cp ${main_dir}datacards/${btagging}/bias/combined/combined_${year}_M${mass}${suffix} datacards/${btagging}/bias/combined/
cp ${main_dir}workspace/${btagging}/MC_signal_${year}* workspace/${btagging}/
cp ${main_dir}workspace/${btagging}/bias/${prefix}_${year}* workspace/${btagging}/bias/
fi
echo "ls datacards/${btagging}/bias/combined/"
ls datacards/${btagging}/bias/combined/
echo "ls workspace/${btagging}/bias/"
ls workspace/${btagging}/bias/
if [[ $combined -eq 1 ]]; then
inputfile="datacards/${btagging}/bias/combined/fully_combined_${year}_M${mass}${suffix}"
outputfile="${bias_dir}${btagging}/combined_run2/fitDiagnostics_M${mass}_${seed}.root"
#tempfile=$(echo $inputfile | sed s:datacards/${btagging}/bias/combined/fully_combined_:${workdir}/:g)
tempfile="${bias_dir}logs/combined_run2_M${mass}_${seed}.log"
set_params1="index_Bkg_2016_bb=1,index_Bkg_2016_bq=1,index_Bkg_2016_mumu=1,index_Bkg_2017_bb=1,index_Bkg_2017_bq=1,index_Bkg_2017_mumu=1,index_Bkg_2018_bb=1,index_Bkg_2018_bq=1,index_Bkg_2018_mumu=1"
else
inputfile="datacards/${btagging}/bias/combined/combined_${year}_M${mass}${suffix}"
outputfile="${bias_dir}${btagging}/fitDiagnostics_M${mass}_${seed}.root"
#tempfile=$(echo $inputfile | sed s:datacards/${btagging}/bias/combined/combined_:${workdir}/:g)
tempfile="${bias_dir}logs/${year}_M${mass}_${seed}.log"
set_params1="index_Bkg_run2_bb=1,index_Bkg_run2_bq=1,index_Bkg_run2_mumu=1"
fi
echo "inputfile = ${inputfile}"
echo "outputfile = ${outputfile}"
echo "tempfile = ${tempfile}"
echo "starting to run main commands" > $tempfile
echo "inputfile = ${inputfile}" >> $tempfile
echo "outputfile = ${outputfile}" >> $tempfile
freeze_params=$(echo $set_params1 | sed s:"=1":"":g)
set_params0=$(echo $set_params1 | sed s:"=1":"=0":g)
shape0="CMS2016_bb_p2_1,CMS2016_bb_p2_2,CMS2016_bq_p2_1,CMS2016_bq_p2_2,CMS2016_mumu_p3_1,CMS2016_mumu_p3_2,CMS2016_mumu_p3_3,CMS2017_bb_p3_1,CMS2017_bb_p3_2,CMS2017_bb_p3_3,CMS2017_bq_p2_1,CMS2017_bq_p2_2,CMS2017_mumu_p2_1,CMS2017_mumu_p2_2,CMS2018_bb_p2_1,CMS2018_bb_p2_2,CMS2018_bq_p2_1,CMS2018_bq_p2_2,CMS2018_mumu_p2_1,CMS2018_mumu_p2_2"
shape1="CMS2016_bb_p3_1,CMS2016_bb_p3_2,CMS2016_bb_p3_3,CMS2016_bq_p3_1,CMS2016_bq_p3_2,CMS2016_bq_p3_3,CMS2016_mumu_p4_1,CMS2016_mumu_p4_2,CMS2016_mumu_p4_3,CMS2016_mumu_p4_4,CMS2017_bb_p4_1,CMS2017_bb_p4_2,CMS2017_bb_p4_3,CMS2017_bb_p4_4,CMS2017_bq_p3_1,CMS2017_bq_p3_2,CMS2017_bq_p3_3,CMS2017_mumu_p3_1,CMS2017_mumu_p3_2,CMS2017_mumu_p3_3,CMS2018_bb_p3_1,CMS2018_bb_p3_2,CMS2018_bb_p3_3,CMS2018_bq_p3_1,CMS2018_bq_p3_2,CMS2018_bq_p3_3,CMS2018_mumu_p3_1,CMS2018_mumu_p3_2,CMS2018_mumu_p3_3"
echo
echo " " >> $tempfile
echo "combine ${inputfile} -M GenerateOnly --setParameters ${set_params0} --toysFrequentist -t ${ntoys} --expectSignal=${expectSignal} --saveToys -s ${seed} -m ${mass} --freezeParameters ${freeze_params} >> ${tempfile}"
echo "combine ${inputfile} -M GenerateOnly --setParameters ${set_params0} --toysFrequentist -t ${ntoys} --expectSignal=${expectSignal} --saveToys -s ${seed} -m ${mass} --freezeParameters ${freeze_params} >> ${tempfile}" >> $tempfile
combine ${inputfile} -M GenerateOnly --setParameters ${set_params0} --toysFrequentist -t ${ntoys} --expectSignal=$expectSignal --saveToys -s ${seed} -m ${mass} --freezeParameters ${freeze_params} >> $tempfile
echo
echo
echo "++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++"
echo "combine toy generation output:"
echo "++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++"
echo
cat $tempfile
echo
echo "++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++"
echo
echo
echo " " >> $tempfile
echo "combine ${inputfile} -M FitDiagnostics --setParameters ${set_params1} --toysFile higgsCombineTest.GenerateOnly.mH${mass}.${seed}.root -s ${seed} -t ${ntoys} --rMin ${rmin} --rMax ${rmax} --freezeParameters ${freeze_params},${shape0} --cminDefaultMinimizerStrategy=0 --toysFrequentist --expectSignal=${expectSignal} >> ${tempfile}"
echo "combine ${inputfile} -M FitDiagnostics --setParameters ${set_params1} --toysFile higgsCombineTest.GenerateOnly.mH${mass}.${seed}.root -s ${seed} -t ${ntoys} --rMin ${rmin} --rMax ${rmax} --freezeParameters ${freeze_params},${shape0} --cminDefaultMinimizerStrategy=0 --toysFrequentist --expectSignal=${expectSignal} >> ${tempfile}" >> $tempfile
combine ${inputfile} -M FitDiagnostics --setParameters ${set_params1} --toysFile higgsCombineTest.GenerateOnly.mH${mass}.${seed}.root -s ${seed} -t ${ntoys} --rMin $rmin --rMax $rmax --freezeParameters ${freeze_params},${shape0} --cminDefaultMinimizerStrategy=0 --toysFrequentist --expectSignal=$expectSignal >> $tempfile
echo
echo
echo "++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++"
echo "combine toy fit output:"
echo "++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++"
echo
cat $tempfile
echo
echo "++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++"
echo
echo "cp fitDiagnostics.root ${outputfile}"
cp fitDiagnostics.root ${outputfile}
echo "output copied to afs"
rm *.root
echo "all clear"
echo
echo
echo 'END ----------------'
echo
echo