-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathRAA_analyze.C
More file actions
1874 lines (1543 loc) · 88.5 KB
/
Copy pathRAA_analyze.C
File metadata and controls
1874 lines (1543 loc) · 88.5 KB
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
// Raghav Kunnawalkam Elayavalli
// June 10th 2014
// CERN
// raghav.k.e AT CERN DOT CH
// RAA - analyze macro. following the steps of having a separate macro to do the work.
// this will be taken mostly from Unfold_RAA_V0.C from MIT. Im just keeping it here so that it will be easier to run.
// important point in the code is that in the loops for pbpb, the array index corrsponding to nbins_cent represents the 0-100 centrality bin.
// PbPb and pp are separated here - as they should be.
// June 25th - add separate files for reading in data from pp and PbPb.
// - Run the full macro to check if it works.
// - Wooo Hoooo! Macro runs fully without any error and produces the histograms
// - Now to go ahead and check if they contain meaningful stuff.
// - obviously till i get the full dataset, i cant get the lumi normalization required to add the triggers.
// June 30th - changed the names of hitograms to match what they mean. especially the unfolded ones.
// - Ok there is a slight issue in the naming of histograms for the bayesian iteration unfolding.
// - the histograms are called [nbins_cent][iterations] while they are saved ad [iterations][nbins_cent]
// - Just be careful when loading the histograms, especially in the plotting macro
// July 19th - started adding in the radius loop and the eta bins loop.
// Aug 20th - continued editing the radius and eta bin loop.
// Nov 4th - have the unfolding closure test working.
// Nov 5th - working on the data bayesin closure using the fine bins technique.
// Jan 22nd - got the PbPb data. am going to unfold it for the management check to calculate the jet RAA now. first going to produce the unfolded data spectra and check if they are ok.
// Jan 23rd - do it only for the Jet 80 triggered spectra. see if we get back the old RAA.
// Feb 10th - get the MC from the trigger combined sample to check the trigger selection bias with data.
// Feb 20th - only running pp for the different eta bins to give the spectra to the Jet RpA analysis for interpolation
// April 19th - adding the necessary no of events which pass the event selection cuts
/*
PbPb:
Total number of events:
(const Double_t)2.2724146e+07
# of events passing pcollisionEventSelection
(const Double_t)2.2724146e+07
# of events passing HBHENoiseFilter
(const Double_t)2.2695568e+07
# of events passing vz < 15
(const Double_t)2.1970588e+07
# of events passing Super nova cut:
(const Double_t)2.1967032e+07
# of events passing Centrality - 0-90%
(const Double_t)2.1966046e+07
# of events having matched PF and Calo Jets
(const Double_t)1.041393e+07
# of events having unmatched PF jets only
(const Double_t)4.886594e+06
Total fraction of events studied = (# of events having matched + # of event having unmatched) / Total number of events
= 0.673
Therefore PbPb Luminosity scaling = 0.673 * 145.156 = 97.69
If we are only looking at the selection cuts (without the matching) , then scaling factor = 0.967
PP:
Total number of events:
(const Double_t)3.3224444e+07
# of events passing pPAcollisionEventSelectionPA
(const Double_t)3.2591536e+07
# of events passing HBHENoiseFilter
(const Double_t)3.250238e+07
# of events passing vz < 15
(const Double_t)3.210568e+07
# of events having matched PF and Calo Jets
(const Double_t)9.322065e+06
# of events having unmatched PF jets only
(const Double_t)2.06469e+05
Total fraction of events studied = (# of events having matched + # of event having unmatched) / Total number of events
= 0.28679
therefore pp luminosity scaling = 0.287 * 5.3 = 1.5211
If we are only looking at the selection cuts (without the matching), then scaling factor = 0.966
Need to implement these guys when we scale the numbers below:
*/
#include "../Headers/plot.h"
#include "../Headers/utilities.h"
void RAA_analyze(int radius = 3)
{
TStopwatch timer;
timer.Start();
TH1::SetDefaultSumw2();
TH2::SetDefaultSumw2();
int unfoldingCut = 20;
bool printDebug = true;
bool isFineBin = false;
bool dofakeremove=true;
// get the data and mc histograms from// the output of the read macro.
// int param1 = 1;
// int param2 = 1;
// if(param1 == 1) {
// etaWidth = "20_eta_20";
// deltaEta = 4.0;
// }
// if(param1 == 2) {
// etaWidth = "10_eta_10";
// deltaEta = 2.0;
// }
// if(param1 == 3) {
// etaWidth = "10_eta_18";
// deltaEta = 1.6;
// }
// if(param2 == 1) smear = "noSmear";
// if(param2 == 2) smear = "GenSmear";
// if(param2 == 3) smear = "RecoSmear";
// if(param2 == 4) smear = "BothSmear";
// if(param2 == 5) smear = "gen2pSmear";
TDatime date;//this is just here to get
// Pawan's files:
TFile * fPbPb_in = TFile::Open(Form("Pawan_TTree_PbPb_Data_MC_subid0_spectra_JetID_CutA_finebins_%s_R0p%d.root",etaWidth,radius));
TFile * fPbPb_MC_in = TFile::Open(Form("Pawan_TTree_PbPb_MC_subid0_spectra_JetID_CutA_%s_%s_R0p%d.root",ptbins,etaWidth,radius));
TFile * fPP_in = TFile::Open(Form("Pawan_TTree_PP_data_MC_spectra_residualFactor_finebins_%s_R0p%d.root",etaWidth, radius));
TFile * fPP_MC_in = TFile::Open(Form("Pawan_TTree_PP_MC_spectra_residualFactor_%s_%s_R0p%d.root",ptbins,etaWidth, radius));
TFile * fMinBias = TFile::Open(Form("Pawan_ntuple_PbPb_MinBiasData_spectra_JetID_CutA_finebins_CentralityWeightedMBwithoutHLT80_%s_R0p%d.root",etaWidth,radius)); //MinBias File
cout<<"after input file declaration"<<endl;
// histogram declarations with the following initial appendage: d - Data, m - MC, u- Unfolded
// for the MC closure test, ive kept separate
// setup the radius and the eta bin loop here later. not for the time being. Aug 20th. only run the -2 < eta < 2 with the differenent centrality bins
TH1F *dPbPb_TrgComb[nbins_cent+1], *dPbPb_Comb[nbins_cent+1], *dPbPb_Trg80[nbins_cent+1], *dPbPb_Trg65[nbins_cent+1], *dPbPb_Trg55[nbins_cent+1], *dPbPb_1[nbins_cent+1], *dPbPb_2[nbins_cent+1], *dPbPb_3[nbins_cent+1], *dPbPb_80[nbins_cent+1], *dPbPb_65[nbins_cent+1], *dPbPb_55[nbins_cent+1], *dPbPb_Smear_TrgComb[nbins_cent+1], *dPbPb_JEC_TrgComb[nbins_cent+1];
TH1F *mPbPb_Gen[nbins_cent+1], *mPbPb_Reco[nbins_cent+1];
TH2F *mPbPb_Matrix[nbins_cent+1], *mPbPb_Response[nbins_cent+1], *mPbPb_ResponseNorm[nbins_cent+1];
TH1F *mPbPb_mcclosure_data[nbins_cent+1];
TH2F *mPbPb_mcclosure_Matrix[nbins_cent+1],*mPbPb_mcclosure_Response[nbins_cent+1], *mPbPb_mcclosure_ResponseNorm[nbins_cent+1];
TH1F *mPbPb_mcclosure_gen[nbins_cent+1];
const int Iterations = 6; //for unfolding systematics.
const int BayesIter = 4;
TH1F *uPbPb_Bayes[nbins_cent+1], *uPbPb_BinByBin[nbins_cent+1], *uPbPb_SVD[nbins_cent+1], *uPbPb_JEC_Bayes[nbins_cent+1], *uPbPb_Smear_Bayes[nbins_cent+1];
TH1F *uPbPb_BayesianIter[nbins_cent+1][Iterations];
TH1F *dPP_1, *dPP_2, *dPP_3, *dPP_Comb;
TH1F *mPP_Gen, *mPP_Reco;
TH2F *mPP_Matrix, *mPP_Response,*mPP_ResponseNorm;
TH1F *mPP_mcclosure_data, *mPP_mcclosure_data_m, *mPP_mcclosure_data_um;
TH2F *mPP_mcclosure_Matrix, *mPP_mcclosure_Response,*mPP_mcclosure_ResponseNorm;
TH1F *mPP_mcclosure_gen, *mPP_mcclosure_gen_m, *mPP_mcclosure_gen_um;
TH1F *hMinBias[nbins_cent+1];
TH1F *uPP_Bayes, *uPP_BinByBin, *uPP_SVD;
TH1F *uPP_BayesianIter[Iterations];
// would be better to read in the histograms and rebin them. come to think of it, it would be better to have them already rebinned (and properly scaled - to the level of differential cross section in what ever barns (inverse micro barns) but keep it consistent) from the read macro.
if(radius == 2) unfoldingCut = unfoldingCut_R2;
if(radius == 3) unfoldingCut = unfoldingCut_R3;
if(radius == 4) unfoldingCut = unfoldingCut_R4;
TH1F * htest = new TH1F("htest","",501,0,501);
Int_t unfoldingCutBin = htest->FindBin(unfoldingCut);
// float cutarray[nbins_cent] = {0.0,0.0,0.0,0.0,0.0,0.0};
// if(radius == 2){
// cutarray[0] = 55;
// cutarray[1] = 50;
// cutarray[2] = 40;
// cutarray[3] = 30;
// cutarray[4] = 30;
// cutarray[5] = 30;
// }
// if(radius == 3){
// cutarray[0] = 65;
// cutarray[1] = 60;
// cutarray[2] = 50;
// cutarray[3] = 40;
// cutarray[4] = 40;
// cutarray[5] = 40;
// }
// if(radius == 4){
// cutarray[0] = 75;
// cutarray[1] = 70;
// cutarray[2] = 60;
// cutarray[3] = 50;
// cutarray[4] = 50;
// cutarray[5] = 50;
// }
// get PbPb data
for(int i = 0;i<nbins_cent;++i){
if(printDebug) cout<<"cent_"<<i<<endl;
// hMinBias[i] = (TH1F*)fMinBias->Get(Form("hpbpb_noTrg_R%d_%s_cent%d",radius,etaWidth,i)); //MinBias Histo
hMinBias[i] = (TH1F*)fMinBias->Get(Form("hpbpb_HLTComb_R%d_%s_cent%d",radius,etaWidth,i)); //MinBias Histo
hMinBias[i]->Print("base");
dPbPb_TrgComb[i] = (TH1F*)fPbPb_in->Get(Form("hpbpb_HLTComb_R%d_%s_cent%d",radius,etaWidth,i));
// //dPbPb_TrgComb[i]->Scale(4*145.156*1e6);
dPbPb_TrgComb[i]->Print("base");
dPbPb_JEC_TrgComb[i] = (TH1F*)fPbPb_in->Get(Form("hpbpb_JEC_HLTComb_R%d_%s_cent%d",radius,etaWidth,i));
// //dPbPb_TrgComb[i]->Scale(4*145.156*1e6);
dPbPb_JEC_TrgComb[i]->Print("base");
dPbPb_Smear_TrgComb[i] = (TH1F*)fPbPb_in->Get(Form("hpbpb_Smear_HLTComb_R%d_%s_cent%d",radius,etaWidth,i));
// //dPbPb_TrgComb[i]->Scale(4*145.156*1e6);
dPbPb_Smear_TrgComb[i]->Print("base");
dPbPb_Trg80[i] = (TH1F*)fPbPb_in->Get(Form("hpbpb_HLT80_R%d_%s_cent%d",radius,etaWidth,i));
//dPbPb_Trg80[i]->Scale(4*145.156*1e6);
dPbPb_Trg80[i]->Print("base");
dPbPb_Trg65[i] = (TH1F*)fPbPb_in->Get(Form("hpbpb_HLT65_R%d_%s_cent%d",radius,etaWidth,i));
//dPbPb_Trg65[i]->Scale(4*145.156*1e6);
dPbPb_Trg65[i]->Print("base");
dPbPb_Trg55[i] = (TH1F*)fPbPb_in->Get(Form("hpbpb_HLT55_R%d_%s_cent%d",radius,etaWidth,i));
//dPbPb_Trg55[i]->Scale(4*145.156*1e6);
dPbPb_Trg55[i]->Print("base");
//Lets do the subtraction here _Sevil
if(dofakeremove){
// Float_t bincon=cutarray[i];
// Int_t bincut= hMinBias[i]->FindBin(bincon);
// for(int k = bincut;k<=400;k++)
// { // cout<<"cent_ "<<i<<" pt "<< hMinBias[i]->FindBin(k)<<" bincontent "<<bincontent<<endl;
// hMinBias[i]->SetBinContent(k,0);
// hMinBias[i]->SetBinError(k,0);
// }
// for(int k = 1;k<=15;k++) { // cout<<"cent_ "<<i<<" pt "<< hMinBias[i]->FindBin(k)<<" bincontent "<<bincontent<<endl;
// hMinBias[i]->SetBinContent(k,0);
// hMinBias[i]->SetBinError(k,0);
// }
// this is just to adjust for the atlas pt bins.
TH1F * hMinBias_test = new TH1F("hMinBias_test","",501,0,501);
for(int j = 0; j<hMinBias[i]->GetNbinsX();++j){
hMinBias_test->SetBinContent(j+1, hMinBias[i]->GetBinContent(j+1));
hMinBias_test->SetBinError(j+1, hMinBias[i]->GetBinError(j+1));
}
hMinBias_test->Print("base");
hMinBias[i]->Print("base");
Float_t bin_no = dPbPb_TrgComb[i]->FindBin(15);
Float_t bin_end=dPbPb_TrgComb[i]->FindBin(25);
Float_t bin_nomb = hMinBias_test->FindBin(15);
Float_t bin_endmb=hMinBias_test->FindBin(25);
float scalerangeweight=dPbPb_TrgComb[i]->Integral(bin_no,bin_end)/hMinBias_test->Integral(bin_nomb,bin_endmb);
for(int j = 0; j<hMinBias_test->GetNbinsX(); ++j)
hMinBias_test->SetBinError(j+1,hMinBias_test->GetBinError(j+1)/scalerangeweight);
hMinBias_test->Scale(scalerangeweight);
hMinBias[i]->Scale(scalerangeweight);
dPbPb_TrgComb[i]->Add(hMinBias_test, -1);
dPbPb_JEC_TrgComb[i]->Add(hMinBias_test, -1);
dPbPb_Smear_TrgComb[i]->Add(hMinBias_test, -1);
delete hMinBias_test;
}
//dPbPb_TrgComb[i] = (TH1F*)dPbPb_Trg80[i]->Clone(Form("hpbpb_HLTComb_R%d_%s_cent%d",radius, i));
//dPbPb_JEC_TrgComb[i] = (TH1F*)fPbPb_in->Get(Form("hpbpb_JEC_HLT80_R%d_%s_cent%d",radius, i));
//dPbPb_Smear_TrgComb[i] = (TH1F*)fPbPb_in->Get(Form("hpbpb_Smear_HLT80_R%d_%s_cent%d",radius, i));
// dPbPb_MinBias[i] = (TH1F*)fPbPb_MB_in->Get(Form("hpbpb_HLTComb_R%d_%s_cent%d",radius,etaWidth,i));
// dPbPb_MinBias[i]->Print("base");
// //dPbPb_TrgComb[i]->Scale(1./145.156);
// //dPbPb_MinBias[i]->Scale(1./161.939);
// //dPbPb_TrgComb[i]->Add(dPbPb_MinBias[i]);
// dPbPb_JEC_MinBias[i] = (TH1F*)fPbPb_MB_in->Get(Form("hpbpb_JEC_HLTComb_R%d_%s_cent%d",radius,etaWidth,i));
// dPbPb_JEC_MinBias[i]->Print("base");
// //dPbPb_JEC_TrgComb[i]->Scale(1./145.156);
// //dPbPb_JEC_MinBias[i]->Scale(1./161.939);
// //dPbPb_JEC_TrgComb[i]->Add(dPbPb_JEC_MinBias[i]);
// dPbPb_Smear_MinBias[i] = (TH1F*)fPbPb_MB_in->Get(Form("hpbpb_Smear_HLTComb_R%d_%s_cent%d",radius,etaWidth,i));
// dPbPb_Smear_MinBias[i]->Print("base");
// //dPbPb_Smear_TrgComb[i]->Scale(1./145.156);
// //dPbPb_Smear_MinBias[i]->Scale(1./161.939);
// //dPbPb_Smear_TrgComb[i]->Add(dPbPb_Smear_MinBias[i]);
// if(etaWidth == "10_eta_10"){
// if(i == 0 && radius==2) unfoldingCutBin = htest->FindBin(30);
// if(i == 1 && radius==2) unfoldingCutBin = htest->FindBin(30);
// if(i == 2 && radius==2) unfoldingCutBin = htest->FindBin(30);
// if(i == 3 && radius==2) unfoldingCutBin = htest->FindBin(30);
// if(i == 4 && radius==2) unfoldingCutBin = htest->FindBin(30);
// if(i == 5 && radius==2) unfoldingCutBin = htest->FindBin(30);
// if(i == 0 && radius==3) unfoldingCutBin = htest->FindBin(40);
// if(i == 1 && radius==3) unfoldingCutBin = htest->FindBin(40);
// if(i == 2 && radius==3) unfoldingCutBin = htest->FindBin(40);
// if(i == 3 && radius==3) unfoldingCutBin = htest->FindBin(40);
// if(i == 4 && radius==3) unfoldingCutBin = htest->FindBin(40);
// if(i == 5 && radius==3) unfoldingCutBin = htest->FindBin(40);
// if(i == 0 && radius==4) unfoldingCutBin = htest->FindBin(50);
// if(i == 1 && radius==4) unfoldingCutBin = htest->FindBin(50);
// if(i == 2 && radius==4) unfoldingCutBin = htest->FindBin(50);
// if(i == 3 && radius==4) unfoldingCutBin = htest->FindBin(50);
// if(i == 4 && radius==4) unfoldingCutBin = htest->FindBin(50);
// if(i == 5 && radius==4) unfoldingCutBin = htest->FindBin(50);
// }
// if(etaWidth == "10_eta_18"){
// if(i == 0 && radius==2) unfoldingCutBin = htest->FindBin(30);
// if(i == 1 && radius==2) unfoldingCutBin = htest->FindBin(30);
// if(i == 2 && radius==2) unfoldingCutBin = htest->FindBin(30);
// if(i == 3 && radius==2) unfoldingCutBin = htest->FindBin(30);
// if(i == 4 && radius==2) unfoldingCutBin = htest->FindBin(30);
// if(i == 5 && radius==2) unfoldingCutBin = htest->FindBin(30);
// if(i == 0 && radius==3) unfoldingCutBin = htest->FindBin(40);
// if(i == 1 && radius==3) unfoldingCutBin = htest->FindBin(40);
// if(i == 2 && radius==3) unfoldingCutBin = htest->FindBin(40);
// if(i == 3 && radius==3) unfoldingCutBin = htest->FindBin(40);
// if(i == 4 && radius==3) unfoldingCutBin = htest->FindBin(40);
// if(i == 5 && radius==3) unfoldingCutBin = htest->FindBin(40);
// if(i == 0 && radius==4) unfoldingCutBin = htest->FindBin(50);
// if(i == 1 && radius==4) unfoldingCutBin = htest->FindBin(50);
// if(i == 2 && radius==4) unfoldingCutBin = htest->FindBin(50);
// if(i == 3 && radius==4) unfoldingCutBin = htest->FindBin(50);
// if(i == 4 && radius==4) unfoldingCutBin = htest->FindBin(50);
// if(i == 5 && radius==4) unfoldingCutBin = htest->FindBin(50);
// }
// if(etaWidth == "20_eta_20"){
// if(i == 0 && radius==2) unfoldingCutBin = htest->FindBin(30);
// if(i == 1 && radius==2) unfoldingCutBin = htest->FindBin(30);
// if(i == 2 && radius==2) unfoldingCutBin = htest->FindBin(30);
// if(i == 3 && radius==2) unfoldingCutBin = htest->FindBin(30);
// if(i == 4 && radius==2) unfoldingCutBin = htest->FindBin(30);
// if(i == 5 && radius==2) unfoldingCutBin = htest->FindBin(30);
// if(i == 0 && radius==3) unfoldingCutBin = htest->FindBin(40); //70
// if(i == 1 && radius==3) unfoldingCutBin = htest->FindBin(40);//60
// if(i == 2 && radius==3) unfoldingCutBin = htest->FindBin(40); // 50 test for Sevil
// if(i == 3 && radius==3) unfoldingCutBin = htest->FindBin(40);
// if(i == 4 && radius==3) unfoldingCutBin = htest->FindBin(40);
// if(i == 5 && radius==3) unfoldingCutBin = htest->FindBin(40);
// if(i == 0 && radius==4) unfoldingCutBin = htest->FindBin(50);
// if(i == 1 && radius==4) unfoldingCutBin = htest->FindBin(50);
// if(i == 2 && radius==4) unfoldingCutBin = htest->FindBin(50);
// if(i == 3 && radius==4) unfoldingCutBin = htest->FindBin(50);
// if(i == 4 && radius==4) unfoldingCutBin = htest->FindBin(50);
// if(i == 5 && radius==4) unfoldingCutBin = htest->FindBin(50);
// }
for(int k = 1;k<=unfoldingCutBin;k++) {
dPbPb_TrgComb[i]->SetBinContent(k,0);
dPbPb_JEC_TrgComb[i]->SetBinContent(k,0);
dPbPb_Smear_TrgComb[i]->SetBinContent(k,0);
dPbPb_Trg80[i]->SetBinContent(k,0);
dPbPb_Trg65[i]->SetBinContent(k,0);
dPbPb_Trg55[i]->SetBinContent(k,0);
dPbPb_TrgComb[i]->SetBinError(k,0);
dPbPb_JEC_TrgComb[i]->SetBinError(k,0);
dPbPb_Smear_TrgComb[i]->SetBinError(k,0);
dPbPb_Trg80[i]->SetBinError(k,0);
dPbPb_Trg65[i]->SetBinError(k,0);
dPbPb_Trg55[i]->SetBinError(k,0);
hMinBias[i]->SetBinContent(k,0);
hMinBias[i]->SetBinError(k,0);
}
}
Int_t nSVDIter = 4;
if(printDebug)cout<<"loaded the data histograms PbPb"<<endl;
// get PbPb MC
TH1F * mPbPb_Gen_test[nbins_cent], * mPbPb_Reco_test[nbins_cent], mPbPb_Martix[nbins_cent];
for(int i = 0;i<nbins_cent;++i){
// the MC there are 4 options here:
// 1) no smearing applied to Reco or Gen
// 2) Soearing on the Gen pT
// 3) Smearing on the Reco pT
// 4) Smearing on both of them
// 5) 2% JEC effect on Gen pT
// take the ratio of the RAA with all of them and plot it for a systematics, we can also take the ratio of the unfolded spectra with each one of the above and take the envelope.
if(smear == "noSmear"){
mPbPb_Gen[i] = (TH1F*)fPbPb_MC_in->Get(Form("hpbpb_JetComb_gen_R%d_%s_cent%d",radius,etaWidth,i));
mPbPb_Gen[i]->Print("base");
mPbPb_Reco[i] = (TH1F*)fPbPb_MC_in->Get(Form("hpbpb_JetComb_reco_R%d_%s_cent%d",radius,etaWidth,i));
mPbPb_Reco[i]->Print("base");
mPbPb_Matrix[i] = (TH2F*)fPbPb_MC_in->Get(Form("hpbpb_matrix_HLT_R%d_%s_cent%d",radius,etaWidth,i));
mPbPb_Matrix[i]->Print("base");
}
if(smear == "5TrigIneff_Smear"){
mPbPb_Gen[i] = (TH1F*)fPbPb_MC_in->Get(Form("hpbpb_JetComb_gen_5TrigIneff_Smear_R%d_%s_cent%d",radius,etaWidth,i));
mPbPb_Gen[i]->Print("base");
mPbPb_Reco[i] = (TH1F*)fPbPb_MC_in->Get(Form("hpbpb_JetComb_reco_5TrigIneff_Smear_R%d_%s_cent%d",radius,etaWidth,i));
mPbPb_Reco[i]->Print("base");
mPbPb_Matrix[i] = (TH2F*)fPbPb_MC_in->Get(Form("hpbpb_matrix_HLT_5TrigIneffSmear_R%d_%s_cent%d",radius,etaWidth,i));
mPbPb_Matrix[i]->Print("base");
}
if(smear == "10TrigIneff_Smear"){
mPbPb_Gen[i] = (TH1F*)fPbPb_MC_in->Get(Form("hpbpb_JetComb_gen_10TrigIneff_Smear_R%d_%s_cent%d",radius,etaWidth,i));
mPbPb_Gen[i]->Print("base");
mPbPb_Reco[i] = (TH1F*)fPbPb_MC_in->Get(Form("hpbpb_JetComb_reco_10TrigIneff_Smear_R%d_%s_cent%d",radius,etaWidth,i));
mPbPb_Reco[i]->Print("base");
mPbPb_Matrix[i] = (TH2F*)fPbPb_MC_in->Get(Form("hpbpb_matrix_HLT_10TrigIneffSmear_R%d_%s_cent%d",radius,etaWidth,i));
mPbPb_Matrix[i]->Print("base");
}
if(smear == "GenSmear"){
mPbPb_Gen[i] = (TH1F*)fPbPb_MC_in->Get(Form("hpbpb_JetComb_GenSmear_R%d_%s_cent%d",radius,etaWidth,i));
mPbPb_Gen[i]->Print("base");
mPbPb_Reco[i] = (TH1F*)fPbPb_MC_in->Get(Form("hpbpb_JetComb_reco_R%d_%s_cent%d",radius,etaWidth,i));
mPbPb_Reco[i]->Print("base");
mPbPb_Matrix[i] = (TH2F*)fPbPb_MC_in->Get(Form("hpbpb_matrix_HLT_GenSmear_R%d_%s_cent%d",radius,etaWidth,i));
mPbPb_Matrix[i]->Print("base");
}
if(smear == "RecoSmear"){
mPbPb_Gen[i] = (TH1F*)fPbPb_MC_in->Get(Form("hpbpb_JetComb_gen_R%d_%s_cent%d",radius,etaWidth,i));
mPbPb_Gen[i]->Print("base");
mPbPb_Reco[i] = (TH1F*)fPbPb_MC_in->Get(Form("hpbpb_JetComb_RecoSmear_R%d_%s_cent%d",radius,etaWidth,i));
mPbPb_Reco[i]->Print("base");
mPbPb_Matrix[i] = (TH2F*)fPbPb_MC_in->Get(Form("hpbpb_matrix_HLT_RecoSmear_R%d_%s_cent%d",radius,etaWidth,i));
mPbPb_Matrix[i]->Print("base");
}
if(smear == "BothSmear"){
mPbPb_Gen[i] = (TH1F*)fPbPb_MC_in->Get(Form("hpbpb_JetComb_GenSmear_R%d_%s_cent%d",radius,etaWidth,i));
mPbPb_Gen[i]->Print("base");
mPbPb_Reco[i] = (TH1F*)fPbPb_MC_in->Get(Form("hpbpb_JetComb_RecoSmear_R%d_%s_cent%d",radius,etaWidth,i));
mPbPb_Reco[i]->Print("base");
mPbPb_Matrix[i] = (TH2F*)fPbPb_MC_in->Get(Form("hpbpb_matrix_HLT_BothSmear_R%d_%s_cent%d",radius,etaWidth,i));
mPbPb_Matrix[i]->Print("base");
}
if(smear == "gen2pSmear"){
mPbPb_Gen[i] = (TH1F*)fPbPb_MC_in->Get(Form("hpbpb_JetComb_gen2pSmear_R%d_%s_cent%d",radius,etaWidth,i));
mPbPb_Gen[i]->Print("base");
mPbPb_Reco[i] = (TH1F*)fPbPb_MC_in->Get(Form("hpbpb_JetComb_reco_R%d_%s_cent%d",radius,etaWidth,i));
mPbPb_Reco[i]->Print("base");
mPbPb_Matrix[i] = (TH2F*)fPbPb_MC_in->Get(Form("hpbpb_matrix_HLT_gen2pSmear_R%d_%s_cent%d",radius,etaWidth,i));
mPbPb_Matrix[i]->Print("base");
}
// mPbPb_mcclosure_data[i] = (TH1F*)fMCClosure->Get(Form("akPu%dJetAnalyzer/hrec_c_f_pbpb_akPu%d_1_%d",radius, radius, i));
// mPbPb_mcclosure_data[i]->Print("base");
// mPbPb_mcclosure_gen[i] = (TH1F*)fMCClosure->Get(Form("akPu%dJetAnalyzer/hgen_f_pbpb_akPu%d_1_%d",radius, radius, i));
// mPbPb_mcclosure_gen[i]->Print("base");
// mPbPb_mcclosure_Matrix[i] = (TH2F*)fMCClosure->Get(Form("akPu%dJetAnalyzer/hmatrix_f_pbpb_akPu%d_1_%d",radius, radius, i));
// mPbPb_mcclosure_Matrix[i]->Print("base");
if(smear == "noSmear"){
mPbPb_mcclosure_data[i] = (TH1F*)fPbPb_MC_in->Get(Form("hpbpb_mcclosure_JetComb_data_R%d_%s_cent%d",radius,etaWidth,i));
mPbPb_mcclosure_data[i]->Print("base");
mPbPb_mcclosure_gen[i] = (TH1F*)fPbPb_MC_in->Get(Form("hpbpb_mcclosure_gen_JetComb_R%d_%s_cent%d",radius,etaWidth,i));
mPbPb_mcclosure_gen[i]->Print("base");
mPbPb_mcclosure_Matrix[i] = (TH2F*)fPbPb_MC_in->Get(Form("hpbpb_mcclosure_matrix_HLT_R%d_%s_cent%d",radius,etaWidth,i));
mPbPb_mcclosure_Matrix[i]->Print("base");
}
if(smear == "5TrigIneff_Smear"){
mPbPb_mcclosure_data[i] = (TH1F*)fPbPb_MC_in->Get(Form("hpbpb_mcclosure_JetComb_data_5TrigIneff_Smear_R%d_%s_cent%d",radius,etaWidth,i));
mPbPb_mcclosure_data[i]->Print("base");
mPbPb_mcclosure_gen[i] = (TH1F*)fPbPb_MC_in->Get(Form("hpbpb_mcclosure_gen_JetComb_5TrigIneff_Smear_R%d_%s_cent%d",radius,etaWidth,i));
mPbPb_mcclosure_gen[i]->Print("base");
mPbPb_mcclosure_Matrix[i] = (TH2F*)fPbPb_MC_in->Get(Form("hpbpb_mcclosure_matrix_HLT_5TrigIneff_Smear_R%d_%s_cent%d",radius,etaWidth,i));
mPbPb_mcclosure_Matrix[i]->Print("base");
}
if(smear == "10TrigIneff_Smear"){
mPbPb_mcclosure_data[i] = (TH1F*)fPbPb_MC_in->Get(Form("hpbpb_mcclosure_JetComb_data_10TrigIneff_Smear_R%d_%s_cent%d",radius,etaWidth,i));
mPbPb_mcclosure_data[i]->Print("base");
mPbPb_mcclosure_gen[i] = (TH1F*)fPbPb_MC_in->Get(Form("hpbpb_mcclosure_gen_JetComb_10TrigIneff_Smear_R%d_%s_cent%d",radius,etaWidth,i));
mPbPb_mcclosure_gen[i]->Print("base");
mPbPb_mcclosure_Matrix[i] = (TH2F*)fPbPb_MC_in->Get(Form("hpbpb_mcclosure_matrix_HLT_10TrigIneff_Smear_R%d_%s_cent%d",radius,etaWidth,i));
mPbPb_mcclosure_Matrix[i]->Print("base");
}
// if(etaWidth == "10_eta_10"){
// if(i == 0 && radius==2) unfoldingCutBin = htest->FindBin(30);
// if(i == 1 && radius==2) unfoldingCutBin = htest->FindBin(30);
// if(i == 2 && radius==2) unfoldingCutBin = htest->FindBin(30);
// if(i == 3 && radius==2) unfoldingCutBin = htest->FindBin(30);
// if(i == 4 && radius==2) unfoldingCutBin = htest->FindBin(30);
// if(i == 5 && radius==2) unfoldingCutBin = htest->FindBin(30);
// if(i == 0 && radius==3) unfoldingCutBin = htest->FindBin(40);
// if(i == 1 && radius==3) unfoldingCutBin = htest->FindBin(40);
// if(i == 2 && radius==3) unfoldingCutBin = htest->FindBin(40);
// if(i == 3 && radius==3) unfoldingCutBin = htest->FindBin(40);
// if(i == 4 && radius==3) unfoldingCutBin = htest->FindBin(40);
// if(i == 5 && radius==3) unfoldingCutBin = htest->FindBin(40);
// if(i == 0 && radius==4) unfoldingCutBin = htest->FindBin(50);
// if(i == 1 && radius==4) unfoldingCutBin = htest->FindBin(50);
// if(i == 2 && radius==4) unfoldingCutBin = htest->FindBin(50);
// if(i == 3 && radius==4) unfoldingCutBin = htest->FindBin(50);
// if(i == 4 && radius==4) unfoldingCutBin = htest->FindBin(50);
// if(i == 5 && radius==4) unfoldingCutBin = htest->FindBin(50);
// }
// if(etaWidth == "10_eta_18"){
// if(i == 0 && radius==2) unfoldingCutBin = htest->FindBin(30);
// if(i == 1 && radius==2) unfoldingCutBin = htest->FindBin(30);
// if(i == 2 && radius==2) unfoldingCutBin = htest->FindBin(30);
// if(i == 3 && radius==2) unfoldingCutBin = htest->FindBin(30);
// if(i == 4 && radius==2) unfoldingCutBin = htest->FindBin(30);
// if(i == 5 && radius==2) unfoldingCutBin = htest->FindBin(30);
// if(i == 0 && radius==3) unfoldingCutBin = htest->FindBin(40);
// if(i == 1 && radius==3) unfoldingCutBin = htest->FindBin(40);
// if(i == 2 && radius==3) unfoldingCutBin = htest->FindBin(40);
// if(i == 3 && radius==3) unfoldingCutBin = htest->FindBin(40);
// if(i == 4 && radius==3) unfoldingCutBin = htest->FindBin(40);
// if(i == 5 && radius==3) unfoldingCutBin = htest->FindBin(40);
// if(i == 0 && radius==4) unfoldingCutBin = htest->FindBin(50);
// if(i == 1 && radius==4) unfoldingCutBin = htest->FindBin(50);
// if(i == 2 && radius==4) unfoldingCutBin = htest->FindBin(50);
// if(i == 3 && radius==4) unfoldingCutBin = htest->FindBin(50);
// if(i == 4 && radius==4) unfoldingCutBin = htest->FindBin(50);
// if(i == 5 && radius==4) unfoldingCutBin = htest->FindBin(50);
// }
// if(etaWidth == "20_eta_20"){
// if(i == 0 && radius==2) unfoldingCutBin = htest->FindBin(30);
// if(i == 1 && radius==2) unfoldingCutBin = htest->FindBin(30);
// if(i == 2 && radius==2) unfoldingCutBin = htest->FindBin(30);
// if(i == 3 && radius==2) unfoldingCutBin = htest->FindBin(30);
// if(i == 4 && radius==2) unfoldingCutBin = htest->FindBin(30);
// if(i == 5 && radius==2) unfoldingCutBin = htest->FindBin(30);
// if(i == 0 && radius==3) unfoldingCutBin = htest->FindBin(40); //seviltest 70
// if(i == 1 && radius==3) unfoldingCutBin = htest->FindBin(40); //60
// if(i == 2 && radius==3) unfoldingCutBin = htest->FindBin(40);
// if(i == 3 && radius==3) unfoldingCutBin = htest->FindBin(40);
// if(i == 4 && radius==3) unfoldingCutBin = htest->FindBin(40);
// if(i == 5 && radius==3) unfoldingCutBin = htest->FindBin(40);
// if(i == 0 && radius==4) unfoldingCutBin = htest->FindBin(50);
// if(i == 1 && radius==4) unfoldingCutBin = htest->FindBin(50);
// if(i == 2 && radius==4) unfoldingCutBin = htest->FindBin(50);
// if(i == 3 && radius==4) unfoldingCutBin = htest->FindBin(50);
// if(i == 4 && radius==4) unfoldingCutBin = htest->FindBin(50);
// if(i == 5 && radius==4) unfoldingCutBin = htest->FindBin(50);
// }
for(int k = 1;k<=unfoldingCutBin;k++){
mPbPb_Gen[i]->SetBinContent(k,0);
mPbPb_Reco[i]->SetBinContent(k,0);
mPbPb_Gen[i]->SetBinError(k,0);
mPbPb_Reco[i]->SetBinError(k,0);
mPbPb_mcclosure_data[i]->SetBinContent(k,0);
mPbPb_mcclosure_data[i]->SetBinError(k,0);
mPbPb_mcclosure_gen[i]->SetBinContent(k,0);
mPbPb_mcclosure_gen[i]->SetBinError(k,0);
//mPbPb_mcclosure_data[i]->SetBinContent(k,0);
//mPbPb_mcclosure_gen[i]->SetBinContent(k,0);
// set bin content matrix l,k works
for(int l = 1;l<=mPbPb_Gen[i]->GetNbinsX();l++){
//mPbPb_Matrix[i]->SetBinContent(k,l,0);
mPbPb_Matrix[i]->SetBinContent(l,k,0);
mPbPb_mcclosure_Matrix[i]->SetBinContent(l,k,0);
//mPbPb_Matrix[i]->SetBinError(k,l,0);
mPbPb_Matrix[i]->SetBinError(l,k,0);
mPbPb_mcclosure_Matrix[i]->SetBinError(l,k,0);
}
//for(int l = 1; l<=mPbPb_mcclosure_data[i]->GetNbinsX(); l++){
//mPbPb_mcclosure_Matrix[i]->SetBinContent(k,l,0);
//mPbPb_mcclosure_Matrix[i]->SetBinContent(l,k,0);
//}
}
for(int k = 1; k<=20; k++){
for(int l = 1; l<=mPbPb_Gen[i]->GetNbinsX();l++){
mPbPb_Matrix[i]->SetBinContent(k,l,0);
mPbPb_Matrix[i]->SetBinError(k,l,0);
mPbPb_mcclosure_Matrix[i]->SetBinError(k,l,0);
mPbPb_mcclosure_Matrix[i]->SetBinContent(k,l,0);
}
}
for(int k = 20; k<80; k++){
for(int l = unfoldingCutBin; l<mPbPb_Gen[i]->GetNbinsY(); l++){
if(mPbPb_Matrix[i]->GetBinContent(k,l)== 0) continue;
mPbPb_Matrix[i]->SetBinContent(k,l, mPbPb_Matrix[i]->GetBinContent(k,l) * 1.05);
}
}
//mPbPb_Response[i] = new TH2F(Form("mPbPb_Response_cent%d",i),"Response Matrix",nbins_atlas,boundaries_atlas,nbins_atlas,boundaries_atlas);
//mPbPb_ResponseNorm[i] = new TH2F(Form("mPbPb_ResponseNorm_cent%d",i),"Normalized Response Matrix",nbins_atlas,boundaries_atlas,nbins_atlas,boundaries_atlas);
}
if(printDebug) cout<<"loaded the data and mc PbPb histograms from the files"<<endl;
// get PP data
if(printDebug) cout<<"Getting PP data and MC"<<endl;
dPP_1 = (TH1F*)fPP_in->Get(Form("hpp_HLT80_R%d_%s",radius,etaWidth));
dPP_1->Print("base");
dPP_2 = (TH1F*)fPP_in->Get(Form("hpp_HLT60_R%d_%s",radius,etaWidth));
dPP_2->Print("base");
dPP_3 = (TH1F*)fPP_in->Get(Form("hpp_HLT40_R%d_%s",radius,etaWidth));
dPP_3->Print("base");
dPP_Comb = (TH1F*)fPP_in->Get(Form("hpp_HLTComb_R%d_%s",radius,etaWidth));
//dPP_Comb = (TH1F*)dPP_1->Clone(Form("hpp_TrgComb_R%d_n20_eta_p20",radius,etaWidth));
dPP_Comb->Print("base");
// for(int k = 1;k<=dPP_Comb->FindBin(unfoldingCut);k++) {
// dPP_Comb->SetBinContent(k,0);
// dPP_1->SetBinContent(k,0);
// dPP_2->SetBinContent(k,0);
// dPP_3->SetBinContent(k,0);
// }
// get PP MC
mPP_Gen = (TH1F*)fPP_MC_in->Get(Form("hpp_JetComb_gen_R%d_%s",radius,etaWidth));
mPP_Gen->Print("base");
mPP_Reco = (TH1F*)fPP_MC_in->Get(Form("hpp_JetComb_reco_R%d_%s",radius,etaWidth));
mPP_Reco->Print("base");
mPP_Matrix = (TH2F*)fPP_MC_in->Get(Form("hpp_matrix_HLT_R%d_%s",radius,etaWidth));
mPP_Matrix->Print("base");
// mPP_mcclosure_data = (TH1F*)fMCClosure->Get(Form("ak%dJetAnalyzer/hrec_c_f_pp_ak%d_0_7",radius,radius));
// mPP_mcclosure_data->Print("base");
// mPP_mcclosure_gen = (TH1F*)fMCClosure->Get(Form("ak%dJetAnalyzer/hgen_f_pp_ak%d_0_7",radius,radius));
// mPP_mcclosure_gen->Print("base");
mPP_mcclosure_data = (TH1F*)fPP_MC_in->Get(Form("hpp_mcclosure_JetComb_data_R%d_%s",radius,etaWidth));
mPP_mcclosure_data->Print("base");
mPP_mcclosure_gen = (TH1F*)fPP_MC_in->Get(Form("hpp_mcclosure_gen_JetComb_R%d_%s",radius,etaWidth));
mPP_mcclosure_gen->Print("base");
// mPP_mcclosure_data_um = (TH1F*)fMCClosure->Get(Form("ak%dJetAnalyzer/hrec_um_c_f_pp_ak%d_1_2",radius,radius));
// mPP_mcclosure_data_um->Print("base");
// mPP_mcclosure_gen_um = (TH1F*)fMCClosure->Get(Form("ak%dJetAnalyzer/hgen_um_f_pp_ak%d_1_2",radius,radius));
// mPP_mcclosure_gen_um->Print("base");
// mPP_mcclosure_data = (TH1F*) mPP_mcclosure_data_m->Clone(Form("hrec_c_f_pp_ak%d_1_2",radius,radius));
// mPP_mcclosure_data->Add(mPP_mcclosure_data_um);
// mPP_mcclosure_gen = (TH1F*) mPP_mcclosure_gen_m->Clone(Form("hgen_f_pp_ak%d_1_2",radius,radius));
// mPP_mcclosure_gen->Add(mPP_mcclosure_gen_um);
// mPP_mcclosure_Matrix = (TH2F*)fMCClosure->Get(Form("ak%dJetAnalyzer/hmatrix_f_pp_ak%d_0_7",radius,radius));
// mPP_mcclosure_Matrix->Print("base");
mPP_mcclosure_Matrix = (TH2F*)fPP_MC_in->Get(Form("hpp_mcclosure_matrix_HLT_R%d_%s",radius,etaWidth));
mPP_mcclosure_Matrix->Print("base");
//RooUnfoldResponse ruResponsePP(mPP_Matrix->ProjectionY(),mPP_Matrix->ProjectionX(), mPP_Matrix,"","");
//regularization parameter definition:
//RooUnfoldSvd unfoldSvdPP(&ruResponsePP, dPP_Comb, nSVDIter);
//uPP_SVD = (TH1F*)unfoldSvdPP.Hreco();
// for(int k = 1;k<=dPP_Comb->FindBin(unfoldingCut);k++){
// mPP_Gen->SetBinContent(k,0);
// mPP_Reco->SetBinContent(k,0);
// mPP_mcclosure_data->SetBinContent(k,0);
// mPP_mcclosure_gen->SetBinContent(k,0);
// for(int l = 1;l<=nbins_atlas;l++){
// mPP_Matrix->SetBinContent(k,l,0);
// mPP_mcclosure_Matrix->SetBinContent(k,l,0);
// mPP_Matrix->SetBinContent(l,k,0);
// mPP_mcclosure_Matrix->SetBinContent(l,k,0);
// }
// }
//do the pp svd unfolding here:
//mPP_Matrix->Print("base");
//mPP_Response = (TH2F*)fMc_in->Get("hpp_gen");
// make the response matrix.
// here since we dont have the simple nature of the uhist histograms which makes debugging hard, we have to run the response matrix and unfolding separately for PbPb and pp which makes code ugly and not efficient but easy to debug at the same time.
if(printDebug) cout<<"Filling the PbPb response Matrix"<<endl;
// response matrix and unfolding for PbPb
// going to try it the way kurt has it.
for(int i = 0;i<nbins_cent;++i){
if(printDebug) cout<<"centrality bin iteration = "<<i<<endl;
// TF1 *f = new TF1("f","[0]*pow(x+[2],[1])");
// f->SetParameters(1e10,-8.8,40);
// TH1F *hGenSpectraCorr = (TH1F*)mPbPb_Matrix[i]->ProjectionX()->Clone(Form("hGenSpectraCorr_cent%d",i));
// hGenSpectraCorr->Fit("f"," ");
// hGenSpectraCorr->Fit("f","","");
// hGenSpectraCorr->Fit("f","LL");
// TH1F *fHist = functionHist(f,hGenSpectraCorr,Form("fHist_cent%d",i));// function that you get from the fitting
// hGenSpectraCorr->Divide(fHist);
for (int y=1;y<=mPbPb_Matrix[i]->GetNbinsY();y++) {
double sum=0;
for (int x=1;x<=mPbPb_Matrix[i]->GetNbinsX();x++) {
if (mPbPb_Matrix[i]->GetBinContent(x,y)<=1*mPbPb_Matrix[i]->GetBinError(x,y)) {
//in the above line mine had 0*getbinerror while Kurt's had 1*.
mPbPb_Matrix[i]->SetBinContent(x,y,0);
mPbPb_Matrix[i]->SetBinError(x,y,0);
}
sum+=mPbPb_Matrix[i]->GetBinContent(x,y);
}
for (int x=1;x<=mPbPb_Matrix[i]->GetNbinsX();x++) {
double ratio = 1;
// if (hGenSpectraCorr->GetBinContent(x)!=0) ratio = 1e5/hGenSpectraCorr->GetBinContent(x);
mPbPb_Matrix[i]->SetBinContent(x,y,mPbPb_Matrix[i]->GetBinContent(x,y)*ratio);
mPbPb_Matrix[i]->SetBinError(x,y,mPbPb_Matrix[i]->GetBinError(x,y)*ratio);
}
}
//mPbPb_Matrix[i]->Smooth(0);
// Ok major differences here between my code and Kurt in b-jet Tools under Unfold - lines 469 and above.
mPbPb_Response[i] = (TH2F*)mPbPb_Matrix[i]->Clone(Form("mPbPb_Response_cent%d",i));
TH1F *hProj = (TH1F*)mPbPb_Response[i]->ProjectionY()->Clone(Form("hProj_cent%d",i));
for (int y=1;y<=mPbPb_Response[i]->GetNbinsY();y++) {
double sum=0;
for (int x=1;x<=mPbPb_Response[i]->GetNbinsX();x++) {
if (mPbPb_Response[i]->GetBinContent(x,y)<=1*mPbPb_Response[i]->GetBinError(x,y)) {
// in the above if loop, kurt has 1*error and my old had 0*error
mPbPb_Response[i]->SetBinContent(x,y,0);
mPbPb_Response[i]->SetBinError(x,y,0);
}
sum+=mPbPb_Response[i]->GetBinContent(x,y);
}
for (int x=1;x<=mPbPb_Response[i]->GetNbinsX();x++) {
if (sum==0) continue;
double ratio = 1;
//if(dPbPb_TrgComb[i]->GetBinContent(y)==0) ratio = 1e-100/sum;
// else ratio = dPbPb_TrgComb[i]->GetBinContent(y)/sum
ratio = 1./sum;
if (hProj->GetBinContent(y)==0) ratio = 1e-100/sum;
else ratio = hProj->GetBinContent(y)/sum;
mPbPb_Response[i]->SetBinContent(x,y,mPbPb_Response[i]->GetBinContent(x,y)*ratio);
mPbPb_Response[i]->SetBinError(x,y,mPbPb_Response[i]->GetBinError(x,y)*ratio);
}
}
mPbPb_ResponseNorm[i] = (TH2F*)mPbPb_Matrix[i]->Clone(Form("mPbPb_ResponseNorm_cent%d",i));
for (int x=1;x<=mPbPb_ResponseNorm[i]->GetNbinsX();x++) {
double sum=0;
for (int y=1;y<=mPbPb_ResponseNorm[i]->GetNbinsY();y++) {
if (mPbPb_ResponseNorm[i]->GetBinContent(x,y)<=1*mPbPb_ResponseNorm[i]->GetBinError(x,y)) {
mPbPb_ResponseNorm[i]->SetBinContent(x,y,0);
mPbPb_ResponseNorm[i]->SetBinError(x,y,0);
}
sum+=mPbPb_ResponseNorm[i]->GetBinContent(x,y);
}
for (int y=1;y<=mPbPb_ResponseNorm[i]->GetNbinsY();y++) {
if (sum==0) continue;
double ratio = 1./sum;
mPbPb_ResponseNorm[i]->SetBinContent(x,y,mPbPb_ResponseNorm[i]->GetBinContent(x,y)*ratio);
mPbPb_ResponseNorm[i]->SetBinError(x,y,mPbPb_ResponseNorm[i]->GetBinError(x,y)*ratio);
}
}
}
if(printDebug) cout<<"Filling the PbPb mcclosure response Matrix"<<endl;
// response matrix and unfolding for PbPb for the closure test
// going to try it the way kurt has it.
for(int i = 0;i<nbins_cent;++i){
if(printDebug) cout<<"centrality bin iteration = "<<i<<endl;
TF1 *f = new TF1("f","[0]*pow(x+[2],[1])");
f->SetParameters(1e10,-8.8,40);
// TH1F *hGenSpectraCorr = (TH1F*)mPbPb_mcclosure_Matrix[i]->ProjectionX()->Clone(Form("hGenSpectraCorr_cent%d",i));
// hGenSpectraCorr->Fit("f"," ");
// hGenSpectraCorr->Fit("f","","");
// hGenSpectraCorr->Fit("f","LL");
// TH1F *fHist = functionHist(f,hGenSpectraCorr,Form("fHist_cent%d",i));// function that you get from the fitting
// hGenSpectraCorr->Divide(fHist);
for (int y=1;y<=mPbPb_mcclosure_Matrix[i]->GetNbinsY();y++) {
double sum=0;
for (int x=1;x<=mPbPb_mcclosure_Matrix[i]->GetNbinsX();x++) {
if (mPbPb_mcclosure_Matrix[i]->GetBinContent(x,y)<=1*mPbPb_mcclosure_Matrix[i]->GetBinError(x,y)) {
//in the above line mine had 0*getbinerror while Kurt's had 1*.
mPbPb_mcclosure_Matrix[i]->SetBinContent(x,y,0);
mPbPb_mcclosure_Matrix[i]->SetBinError(x,y,0);
}
sum+=mPbPb_mcclosure_Matrix[i]->GetBinContent(x,y);
}
for (int x=1;x<=mPbPb_mcclosure_Matrix[i]->GetNbinsX();x++) {
double ratio = 1;
// if (hGenSpectraCorr->GetBinContent(x)!=0) ratio = 1e5/hGenSpectraCorr->GetBinContent(x);
mPbPb_mcclosure_Matrix[i]->SetBinContent(x,y,mPbPb_mcclosure_Matrix[i]->GetBinContent(x,y)*ratio);
mPbPb_mcclosure_Matrix[i]->SetBinError(x,y,mPbPb_mcclosure_Matrix[i]->GetBinError(x,y)*ratio);
}
}
//mPbPb_mcclosure_Matrix[i]->Smooth(0);
// Ok major differences here between my code and Kurt in b-jet Tools under Unfold - lines 469 and above.
mPbPb_mcclosure_Response[i] = (TH2F*)mPbPb_mcclosure_Matrix[i]->Clone(Form("mPbPb_mcclosure_Response_cent%d",i));
TH1F *hProj = (TH1F*)mPbPb_mcclosure_Response[i]->ProjectionY()->Clone(Form("hProj_cent%d",i));
for (int y=1;y<=mPbPb_mcclosure_Response[i]->GetNbinsY();y++) {
double sum=0;
for (int x=1;x<=mPbPb_mcclosure_Response[i]->GetNbinsX();x++) {
if (mPbPb_mcclosure_Response[i]->GetBinContent(x,y)<=1*mPbPb_mcclosure_Response[i]->GetBinError(x,y)) {
// in the above if loop, kurt has 1*error and my old had 0*error
mPbPb_mcclosure_Response[i]->SetBinContent(x,y,0);
mPbPb_mcclosure_Response[i]->SetBinError(x,y,0);
}
sum+=mPbPb_mcclosure_Response[i]->GetBinContent(x,y);
}
for (int x=1;x<=mPbPb_mcclosure_Response[i]->GetNbinsX();x++) {
if (sum==0) continue;
double ratio = 1;
//if(dPbPb_mcclosure_TrgComb[i]->GetBinContent(y)==0) ratio = 1e-100/sum;
// else ratio = dPbPb_mcclosure_TrgComb[i]->GetBinContent(y)/sum
ratio = 1./sum;
if (hProj->GetBinContent(y)==0) ratio = 1e-100/sum;
else ratio = hProj->GetBinContent(y)/sum;
mPbPb_mcclosure_Response[i]->SetBinContent(x,y,mPbPb_mcclosure_Response[i]->GetBinContent(x,y)*ratio);
mPbPb_mcclosure_Response[i]->SetBinError(x,y,mPbPb_mcclosure_Response[i]->GetBinError(x,y)*ratio);
}
}
mPbPb_mcclosure_ResponseNorm[i] = (TH2F*)mPbPb_mcclosure_Matrix[i]->Clone(Form("mPbPb_mcclosure_ResponseNorm_cent%d",i));
for (int x=1;x<=mPbPb_mcclosure_ResponseNorm[i]->GetNbinsX();x++) {
double sum=0;
for (int y=1;y<=mPbPb_mcclosure_ResponseNorm[i]->GetNbinsY();y++) {
if (mPbPb_mcclosure_ResponseNorm[i]->GetBinContent(x,y)<=1*mPbPb_mcclosure_ResponseNorm[i]->GetBinError(x,y)) {
mPbPb_mcclosure_ResponseNorm[i]->SetBinContent(x,y,0);
mPbPb_mcclosure_ResponseNorm[i]->SetBinError(x,y,0);
}
sum+=mPbPb_mcclosure_ResponseNorm[i]->GetBinContent(x,y);
}
for (int y=1;y<=mPbPb_mcclosure_ResponseNorm[i]->GetNbinsY();y++) {
if (sum==0) continue;
double ratio = 1./sum;
mPbPb_mcclosure_ResponseNorm[i]->SetBinContent(x,y,mPbPb_mcclosure_ResponseNorm[i]->GetBinContent(x,y)*ratio);
mPbPb_mcclosure_ResponseNorm[i]->SetBinError(x,y,mPbPb_mcclosure_ResponseNorm[i]->GetBinError(x,y)*ratio);
}
}
}
if(printDebug) cout<<"Filling PP response Matrix"<<endl;
// response matrix for pp.
// Kurt doesnt have this whole hGenSpectraCorr thing in his macro. need to check why the difference exits between out codes
TF1 *fpp = new TF1("fpp","[0]*pow(x+[2],[1])");
fpp->SetParameters(1e10,-8.8,40);
// if(printDebug) cout<<"before getting the gen spectra corr matrix"<<endl;
// TH1F *hGenSpectraCorrPP = (TH1F*)mPP_Matrix->ProjectionX()->Clone("hGenSpectraCorrPP");
// if(printDebug) cout<<"after gettign the gen spectra corr matrix"<<endl;
// hGenSpectraCorrPP->Fit("f"," ");
// hGenSpectraCorrPP->Fit("f","","");
// hGenSpectraCorrPP->Fit("f","LL");
// TH1F *fHistPP = functionHist(fpp,hGenSpectraCorrPP,"fHistPP");// that the function that you get from the fitting
// hGenSpectraCorrPP->Divide(fHistPP);
for (int y=1;y<=mPP_Matrix->GetNbinsY();y++) {
double sum=0;
for (int x=1;x<=mPP_Matrix->GetNbinsX();x++) {
if (mPP_Matrix->GetBinContent(x,y)<=1*mPP_Matrix->GetBinError(x,y)) {
mPP_Matrix->SetBinContent(x,y,0);
mPP_Matrix->SetBinError(x,y,0);
}
sum+=mPP_Matrix->GetBinContent(x,y);
}
for (int x=1;x<=mPP_Matrix->GetNbinsX();x++) {
double ratio = 1;
// if (hGenSpectraCorrPP->GetBinContent(x)!=0) ratio = 1e5/hGenSpectraCorrPP->GetBinContent(x);
mPP_Matrix->SetBinContent(x,y,mPP_Matrix->GetBinContent(x,y)*ratio);
mPP_Matrix->SetBinError(x,y,mPP_Matrix->GetBinError(x,y)*ratio);
}
}
// mPbPb_Matrix[i]->Smooth(0);
// Ok major differences here between my code and Kurt in b-jet Tools under Unfold - lines 469 and above.
if(printDebug) cout<<"getting the response matrix"<<endl;
mPP_Response = (TH2F*)mPP_Matrix->Clone("mPP_Response");
TH1F *hProjPP = (TH1F*)mPP_Response->ProjectionY()->Clone("hProjPP");
for (int y=1;y<=mPP_Response->GetNbinsY();y++) {
double sum=0;
for (int x=1;x<=mPP_Response->GetNbinsX();x++) {
if (mPP_Response->GetBinContent(x,y)<=1*mPP_Response->GetBinError(x,y)) {
// in the above if statement, kurt has 1*error and my old has 0*error
mPP_Response->SetBinContent(x,y,0);
mPP_Response->SetBinError(x,y,0);
}
sum+=mPP_Response->GetBinContent(x,y);
}
for (int x=1;x<=mPP_Response->GetNbinsX();x++) {
if (sum==0) continue;
double ratio = 1;
//if(dPbPb_TrgComb[i]->GetBinContent(y)==0) ratio = 1e-100/sum;
// else ratio = dPbPb_TrgComb[i]->GetBinContent(y)/sum
ratio = 1./sum;
if (hProjPP->GetBinContent(y)==0) ratio = 1e-100/sum;
else ratio = hProjPP->GetBinContent(y)/sum;
mPP_Response->SetBinContent(x,y,mPP_Response->GetBinContent(x,y)*ratio);
mPP_Response->SetBinError(x,y,mPP_Response->GetBinError(x,y)*ratio);
}
}
if(printDebug) cout<<"getting the normalized response matrix"<<endl;
mPP_ResponseNorm = (TH2F*)mPP_Matrix->Clone("mPP_ResponseNorm");
for (int x=1;x<=mPP_ResponseNorm->GetNbinsX();x++) {
double sum=0;
for (int y=1;y<=mPP_ResponseNorm->GetNbinsY();y++) {
if (mPP_ResponseNorm->GetBinContent(x,y)<=1*mPP_ResponseNorm->GetBinError(x,y)) {
mPP_ResponseNorm->SetBinContent(x,y,0);
mPP_ResponseNorm->SetBinError(x,y,0);
}
sum+=mPP_ResponseNorm->GetBinContent(x,y);
}
for (int y=1;y<=mPP_ResponseNorm->GetNbinsY();y++) {
if (sum==0) continue;
double ratio = 1./sum;
mPP_ResponseNorm->SetBinContent(x,y,mPP_ResponseNorm->GetBinContent(x,y)*ratio);
mPP_ResponseNorm->SetBinError(x,y,mPP_ResponseNorm->GetBinError(x,y)*ratio);
}
}
if(printDebug) cout<<"Filling PP mcclosure response Matrix"<<endl;
// response matrix for pp.
// Kurt doesnt have this whole hGenSpectraCorr thing in his macro. need to check why the difference exits between out codes
TF1 *fpp_mcclosure = new TF1("fpp_mcclosure","[0]*pow(x+[2],[1])");
fpp_mcclosure->SetParameters(1e10,-8.8,40);
// if(printDebug) cout<<"before getting the gen spectra corr matrix"<<endl;
// TH1F *hGenSpectraCorrPP = (TH1F*)mPP_mcclosure_Matrix->ProjectionX()->Clone("hGenSpectraCorrPP");
// if(printDebug) cout<<"after gettign the gen spectra corr matrix"<<endl;
// hGenSpectraCorrPP->Fit("f"," ");
// hGenSpectraCorrPP->Fit("f","","");
// hGenSpectraCorrPP->Fit("f","LL");
// TH1F *fHistPP = functionHist(fpp,hGenSpectraCorrPP,"fHistPP");// that the function that you get from the fitting
// hGenSpectraCorrPP->Divide(fHistPP);
for (int y=1;y<=mPP_mcclosure_Matrix->GetNbinsY();y++) {
double sum=0;
for (int x=1;x<=mPP_mcclosure_Matrix->GetNbinsX();x++) {
if (mPP_mcclosure_Matrix->GetBinContent(x,y)<=1*mPP_mcclosure_Matrix->GetBinError(x,y)) {
mPP_mcclosure_Matrix->SetBinContent(x,y,0);
mPP_mcclosure_Matrix->SetBinError(x,y,0);
}
sum+=mPP_mcclosure_Matrix->GetBinContent(x,y);
}
for (int x=1;x<=mPP_mcclosure_Matrix->GetNbinsX();x++) {
double ratio = 1;
// if (hGenSpectraCorrPP->GetBinContent(x)!=0) ratio = 1e5/hGenSpectraCorrPP->GetBinContent(x);
mPP_mcclosure_Matrix->SetBinContent(x,y,mPP_mcclosure_Matrix->GetBinContent(x,y)*ratio);
mPP_mcclosure_Matrix->SetBinError(x,y,mPP_mcclosure_Matrix->GetBinError(x,y)*ratio);