-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcorrHistogramMaker.cxx
2464 lines (1802 loc) · 133 KB
/
corrHistogramMaker.cxx
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
/////ROOT LIBRARIES///////////////
#include "TROOT.h"
#include "TSystem.h"
#include "TApplication.h"
#include <TH2.h>
#include <TH3.h>
#include <TStyle.h>
#include <TCanvas.h>
#include <Riostream.h>
#include <TRandom.h>
#include <TNtuple.h>
#include <iomanip>
#include <TFile.h>
#include <TProfile.h>
#include <TGraph.h>
#include <TPad.h>
#include <TMath.h>
#include <TF1.h>
#include <THnSparse.h>
#include <TLeaf.h>
#include <TLatex.h>
#include "TError.h"
//gErrorIgnoreLevel = 4000; //default is kInfo
///////C++ Libraries/////////////////
#include <iostream>
#include <iomanip>
#include <math.h>
#include <map>
#include <vector>
#include <utility>
#include <climits>
#include <sstream>
#include <string>
#include <fstream>
#include <TAttMarker.h>
#include <algorithm>
#include <memory>
#include <iterator>
#include <ctype.h>
#include <bitset>
#include <stdio.h>
#include <stdlib.h>
using namespace std;
#include "C:/Users/ajentsch/Desktop/D0_Analysis_Code_Local_Copies/corrHistogramMaker.h"
#include "C:/Users/ajentsch/Desktop/D0_Analysis_Code_Local_Copies/histogramExtractAndSave.cxx"
/******************************
Author: Alex Jentsch
Most Recent Update: 6/27/2017
******************************/
Bool_t reject;
Double_t fline(Double_t *x, Double_t *par)
{
if ( (reject && (x[0] > 1.81 && x[0] < 1.91)) || (reject && (x[0] > 1.6 && x[0] < 1.7)) ){ //|| (reject && (x[0] > 2.0 && x[0] < 2.1))
TF1::RejectPoint();
return 0;
}
return par[0] + par[1]*x[0];
}
Double_t fexpo(Double_t *x, Double_t *par)
{
if ( (reject && (x[0] > 1.81 && x[0] < 1.91)) || (reject && (x[0] > 1.6 && x[0] < 1.7)) ){ //|| (reject && (x[0] > 2.0 && x[0] < 2.1))
TF1::RejectPoint();
return 0;
}
return exp(par[0] + par[1]*x[0]);
}
double calcScaleFactorforFit(double sigma)
{
double preFactor = TMath::Sqrt(TMath::PiOver2());
return preFactor*sigma*.5;
}
//Double_t SecH(
int corrHistogramMaker(){
TString binSubFolder = "dStar_angular_full_new_phi_binning"; //MAIN FILE NAME FOR INPUT
//-------------------------------------------------------------
//BEGIN VARIABLES SECTION
//-------------------------------------------------------------
int NUM_PHI_BINS = 16;
int NUM_ETA_BINS = 13;
int NUM_CENT_BINS = 16;
int NUM_VZ_BINS = 10;
int NUM_PT_BINS = 5; // the last pt-bin is currently the integrated bin. This needs to be reconfigured to have the integrated bin first so I am not pulling a bin out from the middle.
double NUM_FILES_COMBINED = 1;
double ETA_RANGE = 1.69;
double phiBinShift = (TMath::Pi()/16.0);
int FIRST_PT_BIN = 2;
double SBLScaleFactor = .5;
double SBRScaleFactor = .5;
//-----------------------
//file naming and input/output
//-----------------------
TString numPhi = "12";
TString numEta = "9";
TString inputRootFolder = "D0_Hadron_Correlation_Root_Files/";
//TString subFolder1 = "corrHistograms_";
//TString subFolder2 = "_Eta_";
//TString subFolder3 = "_Phi_bins";
TString rootFile = ".root";
TString outputRoot = "corrHistogramMaker";
TString slash = "/";
TString mainPath = "C:/Users/ajentsch/Desktop/";
TString mainFolder = "D0 Correlation Output Histograms/";
//TString binSubFolder = subFolder1 + numEta + subFolder2 + numPhi + subFolder3;
TString fileName = binSubFolder + rootFile;
//TString inputFileName = mainPath + inputRootFolder + numEta + subFolder2 + numPhi + subFolder3 + rootFile;
TString inputFileName = mainPath + inputRootFolder + binSubFolder + rootFile;
TString path = mainPath + mainFolder + binSubFolder + slash;
TString outputFileName = path + outputRoot + rootFile;
TFile *file = new TFile(inputFileName); //Root file with raw histograms to use for calculations
cout << "Root Data File open. " << endl << endl;
//histogramExtractAndSave(file, path); //--THIS PRINTS A BUNCH OF QA STUFF -- TURNED OFF IN STPICOD0ANAMAKER FOR NOW
//cout<<"here"<< endl;
TFile *output = new TFile(outputFileName, "RECREATE"); //root file to store calculated and scaled histograms
cout << "Root Output File open. " << endl << endl;
bool PRINT_SUB_HISTOS_RAW = false;
bool PRINT_SUB_HISTOS_SCALED = false;
bool PRINT_SUB_HISTOS_DEL_RHO = false;
bool PRINT_DELRHO_OVER_REF_HISTOS = true;
TString fileType = ".png"; //file type for output histogram pictures
TString fileTypeEps = ".eps"; //file type for progess report
TString fileTypePDF = ".pdf";
TString binLabelVz[10] = {"0", "1", "2", "3", "4", "5", "6", "7", "8", "9"};
TString binLabelCent[16] = {"0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15"};
TString binLabelPt[6] = {"0", "1", "2", "3", "4", ""};
TString PtBinLabel[6] = {"_PtBin_", "_PtBin_", "_PtBin_", "_PtBin_", "_PtBin_", ""};
TString PtSubFolders[6] = {"PtBin0/", "PtBin1/", "PtBin2/", "PtBin3/", "PtBin4/", "PtIntegrated/"};
TString outputFolders[9] = {"SibCorr/", "MixedCorr/", "ScaledMixedCorr/", "SibMinusScaledMixCorr/",
"delRho_over_rhoRefCorr/", "FullySubtractedCorr/", "USMinusLS/",
"SideBandSubtraction/", "Centralities/"};
TString invariantMassOutputFolders[6] = {"PtBin0/", "PtBin1/", "PtBin2/", "PtBin3/", "PtBin4/", "PtIntegrated/"};
TString invariantMassHistogramsFolder = "invariantMassHistograms/";
TString VzSubFolders[11] = {"VzBin0/", "VzBin1/", "VzBin2/", "VzBin3/", "VzBin4/", "VzBin5/", "VzBin6/", "VzBin7/", "VzBin8/", "VzBin9/", "VzIntegrated/"};
TString bandFolders[5] = {"LeftSideBand/","UnlikeSign/", "RightSideBand/", "LikeSign/", "SideBandAverage/"};
TH1D* oneDUSHistos[6][4];
TString oneDUSStrings[6] = {"D0_US_invMass_Pt_Bin_0", "D0_US_invMass_Pt_Bin_1", "D0_US_invMass_Pt_Bin_2", "D0_US_invMass_Pt_Bin_3", "D0_US_invMass_Pt_Bin_4", "unlikeSign"};
TH1D* oneDLSHistos[6][4];
TString oneDLSStrings[6] = {"LS_invMass_Pt_Bin_0", "LS_invMass_Pt_Bin_1", "LS_invMass_Pt_Bin_2", "LS_invMass_Pt_Bin_3", "LS_invMass_Pt_Bin_4", "LikeSignBG"};
TH1D* oneDScaledLSHistos[6][4];
TString oneDScaledLSStrings[6] = {"ScaledLS_PtBin_0", "ScaledLS_PtBin_1", "ScaledLS_PtBin_2", "ScaledLS_PtBin_3", "ScaledLS_PtBin_4", "ScaledLS"};
TH1D* oneDSubtractedInvMassHistos[6][4];
TString oneDSubtractedInvMassStrings[6] = {"D0_Minus_Scaled_LS_BG_PtBin_0", "D0_Minus_Scaled_LS_BG_PtBin_1", "D0_Minus_Scaled_LS_BG_PtBin_2", "D0_Minus_Scaled_LS_BG_PtBin_3", "D0_Minus_Scaled_LS_BG_PtBin_4","D0_Minus_Scaled_LS_BG"};
TH1D* oneDSubtractedInvMassHistosFunction[6][4];
TString oneDSubtractedInvMassStringsFunction[6] = {"US_Minus_Expo_Fit_BG_PtBin_0", "US_Minus_Expo_Fit_BG_PtBin_1", "US_Minus_Expo_Fit_BG_PtBin_2", "US_Minus_Expo_Fit_BG_PtBin_3", "US_Minus_Expo_Fit_BG_PtBin_4", "US_Minus_Expo_Fit_BG"};
TString binLabelCentralityClass[3] = {"_Peripheral", "_MidCentral", "_Central"};
double integralSideBandCounts[2];
double integralCounts[2];
//-----------------------------------
//Correlation variables and arrays
//-----------------------------------
// US histograms
TH2D* sibCorrBin[4][6][10][16]; //Raw US sibling histograms binned by centrality
TH2D* mixCorrBin[4][6][10][16]; //Raw US mixed histograms binned by centrality
TH2D* scaledMixCorrBin[4][6][10][16]; //storage for the eventual scaled mixed US histograms
TH2D* sibMinusScaledMix[4][6][10][16]; // Raw US Sibling minus scaled mixed
TH2D* delRhoOverRhoRefBin[4][6][10][16];
TH2D* rootErrorsOnDelRhoOverRhoRef[4][6][10][16];
//ERRORS STORED HERE--ALL ERRORS STORED AS VARIANCES -- SQUARE ROOT MUST BE TAKEN FOR ACTUAL ERROR
double sibCorrBinStatErrors[4][6][10][16][9][12];
double mixCorrBinStatErrors[4][6][10][16][9][12];
double scaledMixCorrBinStatErrors[4][6][10][16][9][12];
double sibMinusScaledMixStatErrors[4][6][10][16][9][12];
double delRhoOverRhoRefBinStatErrors[4][6][10][16][9][12];
//------------------------------------------------------------------
TH2D* sibCorrBinVzInt[4][6][16];
TH2D* mixCorrBinVzInt[4][6][16];
TH2D* scaledMixCorrBinVzInt[4][6][16];
TH2D* sibMinusScaledMixVzInt[4][6][16];
TH2D* delRhoOverRhoRefBinVzInt[4][6][16];
TH1D* sibCorrBinPhiProj[4][6][10][16]; //Raw US sibling histograms binned by centrality
TH1D* mixCorrBinPhiProj[4][6][10][16]; //Raw US mixed histograms binned by centrality
TH1D* scaledMixCorrBinPhiProj[4][6][10][16]; //storage for the eventual scaled mixed US histograms
TH1D* sibMinusScaledMixPhiProj[4][6][10][16]; // Raw US Sibling minus scaled mixed
TH1D* delRhoOverRhoRefBinPhiProj[4][6][10][16];
TH1D* sibCorrBinPhiProjVzInt[4][6][16];
TH1D* mixCorrBinPhiProjVzInt[4][6][16];
TH1D* scaledMixCorrBinPhiProjVzInt[4][6][16];
TH1D* sibMinusScaledMixPhiProjVzInt[4][6][16];
TH1D* delRhoOverRhoRefBinPhiProjVzInt[4][6][16];
TH1D* sibCorrUSPhiProjMinusLSPhiProjVzInt[6][16];
TH2D* sideBandAverage[6][16];
TH1D* sideBandAveragePhiProj[6][16];
TH2D* fullySubtractedCorrSideBandCent[6][16];
TH1D* fullySubtractedCorrSideBandCentPhiProj[6][16];
TH2D* delRhoOverRhoRefBinVzIntCentInt[4][6][3];
TH1D* delRhoOverRhoRefBinVzIntCentIntPhiProj[4][6][3];
TH2D* fullySubtractedCorrLSCent[6][16];
TH1D* fullySubtractedCorrLSCentPhiProj[6][16];
//TH2D* mixCorrUSVzInt[3][16];
//TH2D* mixCorrLSVzInt[3][16];
//Correlations with integrated centralities
TH2D* fullySubtractedCorrCustomCentralityUS[6][3];
TH2D* fullySubtractedCorrCustomCentralityLS[6][3];
TH1D* fullySubtractedCorrCustomCentralityLSPhiProj[6][3];
TH2D* fullySubtractedCorrCustomCentralitySideBand[6][3];
TH1D* fullySubtractedCorrCustomCentralitySideBandPhiProj[6][3];
double VzWeightFactorCustom[3][10];
double VzWeightFactorCustomTotal;
TString fullySubtractedLabelCustomCentrality = "FullSubtractedCorr_";
TString centralityBin[3] = {"Peripheral", "MidCentral", "Central"};
TString SibCorrLabels[4] = {"Sibling_SideBandLeft_correlation", "Sibling_US_correlation", "Sibling_SideBandRight_correlation", "Sibling_LS_correlation"};
TString MixCorrLabels[4] = {"Mixed_SideBandLeft_correlation", "Mixed_US_correlation", "Mixed_SideBandRight_correlation", "Mixed_LS_correlation"};
TString ScaledMixCorrLabels[4] = {"Scaled_Mixed_SideBandLeft_correlation", "Scaled_Mixed_US_correlation", "Scaled_Mixed_SideBandRight_correlation", "Scaled_Mixed_LS_correlation"};
TString SibMinusScaledMixLabels[4] = {"Sib_Minus_Scaled_Mix_SideBandLeft_correlation", "Sib_Minus_Scaled_Mix_US_correlation", "Sib_Minus_Scaled_Mix_SideBandRight_correlation", "Sib_Minus_Scaled_Mix_LS_correlation"};
TString delRhoOverRhoRefLabels[4] = {"delRho_over_RhoRef_SideBandLeft_correlation", "delRho_over_RhoRef_US_correlation", "delRho_over_RhoRef_SideBandRight_correlation", "delRho_over_RhoRef_LS_correlation"};
TString errorsFromRootDelRhoOverRhoRef[4] = {"Errors_delRho_over_RhoRef_SideBandLeft_correlation", "Errors_delRho_over_RhoRef_US_correlation", "Errors_delRho_over_RhoRef_SideBandRight_correlation", "Errors_delRho_over_RhoRef_LS_correlation"};
TString subtractedCorrLabels[2] = {"US_Minus_SidebandAverage_Corr", "US_Minus_LS_Corr"};
TString sideBandAverageLabel = "sideBandAverage";
TString phiProj = "Phi_projection_";
TString USMinusLSSubtractedLabel1 = "US_Minus_LS_Subtracted_CentBin_";
TString withFitLabel = "_With_Fit";
//TString delRhoOverRhoRefUSMinusLSLabel1 = "delRho_over_RhoRef_US_Minus_Scaled_LS_";
TString centBinLabel = "_CentBin_";
TString VzBinLabel = "_VzBin_";
TString VzIntLabel = "_Vz_Integrated_";
TString bandLabel[4] = {"SideBandLeft", "US", "SideBandRight", "LS"};
double numSib = 0;
double numMix = 0;
double numMixUS = 0;
double numMixLS = 0;
double integralRawMixHistos[4][6][10][16];
double integralRawMixHistosVzInt[4][6][16];
//double integralRawMixHistos[4][4][10][16];
double integralRawMixHistosVzIntCentInt[4][6][3];
double scaleFactorVzCent = 0;
double scaleFactorVz = 0;
double scaleFactorLS = 0;
double LSScaleFactor[6][6] = {{1.0, 1.0, 1.0, 1.0, 1.0, 1.0}, {1.0,1.0,1.0,1.0,1.0,1.0}};
double ScalingRatio[3][16];
double BOverSPlusBLS[6][4];
double BOverSPlusBFit[6][4];
double SPlusBOverSLS[6][4];
double SPlusBOverSFit[6][4];
double totalPairsSibling = 0;
double integralError[12] = {0,0,0,0,0,0,0,0,0,0,0,0};
//fully subtraced US minus LS
TString delRhoOverRhoRefUSMinusLSLabel1 = "US_delRhoOverRho_Minus_LS_delRhoOverRho_";
double v2Array[5][3];
double v2ArrayStatError[5][3];
//----------------------------
//General use variables
//----------------------------
TString str1;
TString str2;
TString str3;
TString str4;
//-------------------------------------------------------------
//END VARIABLES SECTION
//-------------------------------------------------------------
TCanvas *c = new TCanvas("c2", "Histograms", 1100, 850);
double countsPeakRegionUS = 0;
double countsPeakRegionLS = 0;
double countsSideBandUS = 0;
double countsSideBandLS = 0;
double sideBandLow = 2.0;
double sideBandHigh = 2.1;
double massLow = 1.82;
double massHigh = 1.90;
double USSideBandLeftLow = 1.72; //1.62
double USSideBandLeftHigh = 1.80; //1.7
double USSideBandRightLow = 1.92; //2.0
double USSideBandRightHigh = 2.0; //2.1
double integralLeftSB = 0;
double integralRightSB = 0;
double SBAverage = 0;
double sqrtSPlusB = 1;
double integralFit = 0;
double DMesonSig = 0;
double integral = 0;
double signalOverBG = 0;
double optimizationFactor = 0;
//double LSScaleFactor = 0;
Int_t binMassLowUS;
Int_t binMassHighUS;
Int_t binMassLowLS;
Int_t binMassHighLS;
TString title;
TString tmp;
Double_t par[5];
Double_t parBG[2];
TF1 * g1 = new TF1("m1", "gaus", 1.8, 1.9);
TF1 * e1 = new TF1("m2", "expo", 1.6, 1.78);
//TF1 * eL = new TF1("m3", "expo", 1.69, 1.81);
//TF1 * eR = new TF1("m4", "expo", 1.92, 2.0);
TF1 * BGFunc = new TF1("BGfunc", "expo", 1.6, 2.1);
TF1 * fun = new TF1("fun","gaus(0)+expo(3)",1.6,2.1);
TF1 * finalGaussian = new TF1("final Guassian", "gaus", 1.82, 1.9);
double par0;
double par1;
double par2;
double par3;
TAxis* xAxisUS;
TAxis* xAxisLS;
int LabelVersion = 0;
//------------------------------------------------------------------
//Code section to write information about this dataset to file
//------------------------------------------------------------------
/* //Fill Cuts histogram here for producing output text file
histOfCuts->SetBinContent(1, D0InvMassLow); //D0InvMassLow
histOfCuts->SetBinContent(2, D0InvMassHigh); //D0InvMassHigh
histOfCuts->SetBinContent(3, USSideBandLeftLow); //USSideBandLeftLow
histOfCuts->SetBinContent(4, USSideBandLeftHigh); //USSideBandLeftHigh
histOfCuts->SetBinContent(5, USSideBandRightLow); //USSideBandRightLow
histOfCuts->SetBinContent(6, USSideBandRightHigh); //USSideBandRightHigh
histOfCuts->SetBinContent(7, d0PtLow); //d0PtLow
histOfCuts->SetBinContent(8, d0PtHigh); //d0PtHigh
histOfCuts->SetBinContent(9, d0DaughterPionPtMin); //d0DaughterPionPtMin
histOfCuts->SetBinContent(10, d0DaughterKaonPtMin); //d0DaughterKaonPtMin
histOfCuts->SetBinContent(11, d0DecayLengthMax); //d0DecayLengthMax
histOfCuts->SetBinContent(12, d0TopologicalCutArray[0][0]); //d0DecayLengthMin
histOfCuts->SetBinContent(13, d0TopologicalCutArray[0][1]); //daughterDCA
histOfCuts->SetBinContent(14, d0TopologicalCutArray[0][2]); //d0DCAtoPV
histOfCuts->SetBinContent(15, d0TopologicalCutArray[0][3]); //pionDCA
histOfCuts->SetBinContent(16, d0TopologicalCutArray[0][4]); //kaonDCA
histOfCuts->SetBinContent(17, d0TopologicalCutArray[1][0]); //d0DecayLengthMin
histOfCuts->SetBinContent(18, d0TopologicalCutArray[1][1]); //daughterDCA
histOfCuts->SetBinContent(19, d0TopologicalCutArray[1][2]); //d0DCAtoPV
histOfCuts->SetBinContent(20, d0TopologicalCutArray[1][3]); //pionDCA
histOfCuts->SetBinContent(21, d0TopologicalCutArray[1][4]); //kaonDCA
histOfCuts->SetBinContent(22, d0TopologicalCutArray[2][0]); //d0DecayLengthMin
histOfCuts->SetBinContent(23, d0TopologicalCutArray[2][1]); //daughterDCA
histOfCuts->SetBinContent(24, d0TopologicalCutArray[2][2]); //d0DCAtoPV
histOfCuts->SetBinContent(25, d0TopologicalCutArray[2][3]); //pionDCA
histOfCuts->SetBinContent(26, d0TopologicalCutArray[2][4]); //kaonDCA
histOfCuts->SetBinContent(27, d0TopologicalCutArray[3][0]); //d0DecayLengthMin
histOfCuts->SetBinContent(28, d0TopologicalCutArray[3][1]); //daughterDCA
histOfCuts->SetBinContent(29, d0TopologicalCutArray[3][2]); //d0DCAtoPV
histOfCuts->SetBinContent(30, d0TopologicalCutArray[3][3]); //pionDCA
histOfCuts->SetBinContent(31, d0TopologicalCutArray[3][4]); //kaonDCA
histOfCuts->SetBinContent(32, d0TopologicalCutArray[4][0]); //d0DecayLengthMin
histOfCuts->SetBinContent(33, d0TopologicalCutArray[4][1]); //daughterDCA
histOfCuts->SetBinContent(34, d0TopologicalCutArray[4][2]); //d0DCAtoPV
histOfCuts->SetBinContent(35, d0TopologicalCutArray[4][3]); //pionDCA
histOfCuts->SetBinContent(36, d0TopologicalCutArray[4][4]); //kaonDCA
histOfCuts->SetBinContent(37, hadronPtMin); //hadronPtMin
histOfCuts->SetBinContent(38, hadronPtMax); //hadronPtMax
histOfCuts->SetBinContent(39, BUFFER_SIZE); //BUFFER_SIZE
histOfCuts->SetBinContent(40, NUM_PHI_BINS); //NUM_PHI_BINS
histOfCuts->SetBinContent(41, NUM_ETA_BINS); //NUM_ETA_BINS
histOfCuts->SetBinContent(42, 0); // Require HFT
histOfCuts->SetBinContent(43, trackChi2max); // chi2 cut
histOfCuts->SetBinContent(44, trackDCAtoPvtx); // DCA cut
histOfCuts->SetBinContent(49, 1); //Scale factor counter to produce text file
histOfCuts->SetBinContent(50, 0); //USE TOF STRICTLY
histOfCuts->SetBinContent(51, 0); //USE TOF HYBRID
histOfCuts->SetBinContent(52, 0); //USE DOUBLE MIS-PID PROTECTION
*/
double numEvents = 0;
numEvents = (((TH1I*) file->Get("number_of_events_used"))->GetBinContent(2))/(1000000);
ofstream cutFile;
TString cutFileName = "Cuts_and_data_information.txt";
TString cutOutputFile = path + cutFileName;
cutFile.open (cutOutputFile);
cutFile << "Important information about this data run" << endl << endl;
cutFile << "Number of Events: " << numEvents << "M Events" << endl << endl;
NUM_FILES_COMBINED = ((TH1D*) file->Get("HistOfCuts"))->GetBinContent(49);
((TH1D*) file->Get("HistOfCuts"))->Scale(1/NUM_FILES_COMBINED);
cutFile << "Trigger D0 Cuts" << endl << endl;
cutFile << "D0 InvMass Signal Band -\t" << "Low: " << ((TH1D*) file->Get("HistOfCuts"))->GetBinContent(1) << "\t" << "High: " << ((TH1D*) file->Get("HistOfCuts"))->GetBinContent(2) << endl;
cutFile << "D0 SideBandLeft Band -\t" << "Low: " << ((TH1D*) file->Get("HistOfCuts"))->GetBinContent(3) << "\t" << "High: " << ((TH1D*) file->Get("HistOfCuts"))->GetBinContent(4) << endl;
cutFile << "D0 SideBandRight Band -\t" << "Low: " << ((TH1D*) file->Get("HistOfCuts"))->GetBinContent(5) << "\t\t" << "High: " << ((TH1D*) file->Get("HistOfCuts"))->GetBinContent(6) << endl;
cutFile << "D0 Pt Cuts -\t" << "Low: " << ((TH1D*) file->Get("HistOfCuts"))->GetBinContent(7) << "\t\t" << "High: " << ((TH1D*) file->Get("HistOfCuts"))->GetBinContent(8) << endl;
cutFile << "D0 DecayLengthMax(no upper bound) -\t" << ((TH1D*) file->Get("HistOfCuts"))->GetBinContent(11) << endl;
cutFile << "D0 DaughterPtCut -\t" << "Pi : " << ((TH1D*) file->Get("HistOfCuts"))->GetBinContent(9) << "\t" << "K : " << ((TH1D*) file->Get("HistOfCuts"))->GetBinContent(10) << endl;
cutFile << "Use TOF STRICT: -\t" << ((TH1D*) file->Get("HistOfCuts"))->GetBinContent(50) << endl;
cutFile << "Use TOF HYBRID: -\t" << ((TH1D*) file->Get("HistOfCuts"))->GetBinContent(51) << endl;
cutFile << "Use DOUBLE MIS_PID_PROTECTION: -\t" << ((TH1D*) file->Get("HistOfCuts"))->GetBinContent(52) << endl;
cutFile << endl << "_____________________________________________________________" << endl;
cutFile << endl << "D0 pt 0-1 GeV/c cuts" << endl;
cutFile << "D0 DecayLengthMinimum -\t" << ((TH1D*) file->Get("HistOfCuts"))->GetBinContent(12) << endl;
cutFile << "D0 DaughterDCAMaximum -\t" << ((TH1D*) file->Get("HistOfCuts"))->GetBinContent(13) << endl;
cutFile << "D0 DCA to PV Maximum -\t" << ((TH1D*) file->Get("HistOfCuts"))->GetBinContent(14) << endl;
cutFile << "Daughter Pion DCA to PV minimum -\t" << ((TH1D*) file->Get("HistOfCuts"))->GetBinContent(15) << endl;
cutFile << "Daughter Kaon DCA to PV minimum -\t" << ((TH1D*) file->Get("HistOfCuts"))->GetBinContent(16) << endl;
cutFile << endl << "_____________________________________________________________" << endl;
cutFile << endl << "D0 pt 1.2-2 GeV/c cuts" << endl;
cutFile << "D0 DecayLengthMinimum -\t" << ((TH1D*) file->Get("HistOfCuts"))->GetBinContent(17) << endl;
cutFile << "D0 DaughterDCAMaximum -\t" << ((TH1D*) file->Get("HistOfCuts"))->GetBinContent(18) << endl;
cutFile << "D0 DCA to PV Maximum -\t" << ((TH1D*) file->Get("HistOfCuts"))->GetBinContent(19) << endl;
cutFile << "Daughter Pion DCA to PV minimum -\t" << ((TH1D*) file->Get("HistOfCuts"))->GetBinContent(20) << endl;
cutFile << "Daughter Kaon DCA to PV minimum -\t" << ((TH1D*) file->Get("HistOfCuts"))->GetBinContent(21) << endl;
cutFile << endl <<"_____________________________________________________________"<< endl;
cutFile << endl << "D0 pt 2-3 GeV/c cuts" << endl;
cutFile << "D0 DecayLengthMinimum -\t" << ((TH1D*) file->Get("HistOfCuts"))->GetBinContent(22) << endl;
cutFile << "D0 DaughterDCAMaximum -\t" << ((TH1D*) file->Get("HistOfCuts"))->GetBinContent(23) << endl;
cutFile << "D0 DCA to PV Maximum -\t" << ((TH1D*) file->Get("HistOfCuts"))->GetBinContent(24) << endl;
cutFile << "Daughter Pion DCA to PV minimum -\t" << ((TH1D*) file->Get("HistOfCuts"))->GetBinContent(25) << endl;
cutFile << "Daughter Kaon DCA to PV minimum -\t" << ((TH1D*) file->Get("HistOfCuts"))->GetBinContent(26) << endl;
cutFile << endl <<"_____________________________________________________________"<< endl;
cutFile << endl << "D0 pt 3-4 GeV/c cuts" << endl;
cutFile << "D0 DecayLengthMinimum -\t" << ((TH1D*) file->Get("HistOfCuts"))->GetBinContent(27) << endl;
cutFile << "D0 DaughterDCAMaximum -\t" << ((TH1D*) file->Get("HistOfCuts"))->GetBinContent(28) << endl;
cutFile << "D0 DCA to PV Maximum -\t" << ((TH1D*) file->Get("HistOfCuts"))->GetBinContent(29) << endl;
cutFile << "Daughter Pion DCA to PV minimum -\t" << ((TH1D*) file->Get("HistOfCuts"))->GetBinContent(30) << endl;
cutFile << "Daughter Kaon DCA to PV minimum -\t" << ((TH1D*) file->Get("HistOfCuts"))->GetBinContent(31) << endl;
cutFile << endl << "_____________________________________________________________" << endl;
cutFile << endl << "D0 pt 4-10 GeV/c cuts" << endl;
cutFile << "D0 DecayLengthMinimum -\t" << ((TH1D*) file->Get("HistOfCuts"))->GetBinContent(32) << endl;
cutFile << "D0 DaughterDCAMaximum -\t" << ((TH1D*) file->Get("HistOfCuts"))->GetBinContent(33) << endl;
cutFile << "D0 DCA to PV Maximum -\t" << ((TH1D*) file->Get("HistOfCuts"))->GetBinContent(34) << endl;
cutFile << "Daughter Pion DCA to PV minimum -\t" << ((TH1D*) file->Get("HistOfCuts"))->GetBinContent(35) << endl;
cutFile << "Daughter Kaon DCA to PV minimum -\t" << ((TH1D*) file->Get("HistOfCuts"))->GetBinContent(36) << endl;
cutFile << endl << "------------------------------------------" << endl << "Associated hadron Cuts" << endl << endl;
cutFile << "associated hadron Pt -\t" << "Low: " << ((TH1D*) file->Get("HistOfCuts"))->GetBinContent(37) << "\t" << "High: " << ((TH1D*) file->Get("HistOfCuts"))->GetBinContent(38) << endl;
cutFile << "Num of events used to mix -\t" << ": " << ((TH1D*) file->Get("HistOfCuts"))->GetBinContent(39) << endl;
cutFile << "HFT Tracks only?? -\t" << "YES(1), NO(0): " << ((TH1D*) file->Get("HistOfCuts"))->GetBinContent(42) << endl;
cutFile << "Track Chi2 Max: -\t" << ((TH1D*) file->Get("HistOfCuts"))->GetBinContent(43) << endl;
cutFile << "Track DCA Max: -\t" << ((TH1D*) file->Get("HistOfCuts"))->GetBinContent(44) << endl;
cutFile.close();
//---------------------------------------------
//BEGIN INVARIANT MASS HISTOGRAM INFORMATION
//---------------------------------------------
ofstream invariantMassInfo;
TString invariantMassInfoName = "Signal_and_background_information.txt";
TString invariantMassInfoFile = path + invariantMassInfoName;
invariantMassInfo.open (invariantMassInfoFile);
double sigPerBin[5][3];
for(int k = FIRST_PT_BIN; k < NUM_PT_BINS; k++){ //Initialize the histograms
for(int i = 0; i < 3; i++){
//if(k == 3) { LabelVersion = 1; }
tmp = oneDUSStrings[k] + binLabelCentralityClass[i];
oneDUSHistos[k][i] = (TH1D*)file->Get(tmp); //US spectrum
tmp = oneDLSStrings[k] + binLabelCentralityClass[i];
oneDLSHistos[k][i] = (TH1D*)file->Get(tmp); //LS spectrum
oneDScaledLSHistos[k][i] = (TH1D*)oneDLSHistos[k][i]->Clone(); //clone of LS spectrum to be scaled
tmp = oneDScaledLSStrings[k] + binLabelCentralityClass[i];
oneDScaledLSHistos[k][i]->SetTitle(oneDScaledLSStrings[k]);
tmp = oneDSubtractedInvMassStrings[k] + binLabelCentralityClass[i];
oneDSubtractedInvMassHistos[k][i] = new TH1D(tmp, tmp, 50, 1.6, 2.1); //final spectrum -- US minus LS (scaled)
oneDUSHistos[k][i]->GetXaxis()->SetTitle("Invariant Mass [GeV/c^{2}]");
oneDUSHistos[k][i]->GetYaxis()->SetTitle("counts");
oneDUSHistos[k][i]->GetYaxis()->SetTitleOffset(1.4);
oneDLSHistos[k][i]->GetXaxis()->SetTitle("Invariant Mass [GeV/c^{2}]");
oneDLSHistos[k][i]->GetYaxis()->SetTitle("counts");
oneDLSHistos[k][i]->GetYaxis()->SetTitleOffset(1.4);
oneDScaledLSHistos[k][i]->GetXaxis()->SetTitle("Invariant Mass [GeV/c^{2}]");
oneDScaledLSHistos[k][i]->GetYaxis()->SetTitle("counts");
oneDScaledLSHistos[k][i]->GetYaxis()->SetTitleOffset(1.4);
oneDSubtractedInvMassHistos[k][i]->GetXaxis()->SetTitle("Invariant Mass [GeV/c^{2}]");
oneDSubtractedInvMassHistos[k][i]->GetYaxis()->SetTitle("counts");
oneDSubtractedInvMassHistos[k][i]->GetYaxis()->SetTitleOffset(1.4);
xAxisUS = oneDUSHistos[k][i]->GetXaxis();
xAxisLS = oneDLSHistos[k][i]->GetXaxis();
binMassLowUS = oneDUSHistos[k][i]->GetXaxis()->FindBin(sideBandLow); //get normalization factors to scale the LS distribution
binMassHighUS = oneDUSHistos[k][i]->GetXaxis()->FindBin(sideBandHigh);
binMassLowLS = oneDLSHistos[k][i]->GetXaxis()->FindBin(sideBandLow); //get normalization factors to scale the LS distribution
binMassHighLS = oneDLSHistos[k][i]->GetXaxis()->FindBin(sideBandHigh);
countsSideBandUS = oneDUSHistos[k][i]->Integral(binMassLowUS, binMassHighUS);
binMassLowUS = oneDUSHistos[k][i]->GetXaxis()->FindBin(USSideBandLeftLow); //calculate the integral number in the LEFT SB
binMassHighUS = oneDUSHistos[k][i]->GetXaxis()->FindBin(USSideBandLeftHigh);
integralLeftSB = oneDUSHistos[k][i]->Integral(binMassLowUS, binMassHighUS);
binMassLowUS = oneDUSHistos[k][i]->GetXaxis()->FindBin(USSideBandRightLow); //calculate the integral number in the RIGHT SB
binMassHighUS = oneDUSHistos[k][i]->GetXaxis()->FindBin(USSideBandRightHigh);
integralRightSB = oneDUSHistos[k][i]->Integral(binMassLowUS, binMassHighUS);
SBAverage = .5*(integralLeftSB + integralRightSB);
countsSideBandLS = oneDLSHistos[k][i]->Integral(binMassLowLS, binMassHighLS);
//Calculate peak region values
binMassLowUS = xAxisUS->FindBin(massLow);
binMassHighUS = xAxisUS->FindBin(massHigh);
binMassLowLS = xAxisLS->FindBin(massLow);
binMassHighLS = xAxisLS->FindBin(massHigh);
oneDUSHistos[k][i]->Sumw2();
oneDUSHistos[k][i]->SetMarkerStyle(20);
oneDLSHistos[k][i]->Sumw2();
oneDLSHistos[k][i]->SetMarkerStyle(20);
oneDSubtractedInvMassHistos[k][i]->Sumw2();
oneDSubtractedInvMassHistos[k][i]->SetMarkerStyle(20);
oneDUSHistos[k][i]->Draw();
tmp = path + invariantMassHistogramsFolder + invariantMassOutputFolders[k] + oneDUSStrings[k] + binLabelCentralityClass[i] + fileType;
c->SaveAs(tmp);
//oneDUSHistos[i]->SetTitle("");
//oneDUSHistos[i]->Draw();
//tmp = path + oneDUSStrings[i] + fileTypeEps;
//c->SaveAs(tmp);
LSScaleFactor[k][i] = countsSideBandUS/countsSideBandLS;
oneDScaledLSHistos[k][i]->Scale(LSScaleFactor[k][i]); //normalize LS spectrum here
countsPeakRegionUS = oneDUSHistos[k][i]->Integral(binMassLowUS, binMassHighUS);
countsPeakRegionLS = oneDScaledLSHistos[k][i]->Integral(binMassLowLS, binMassHighLS); //this gets an estimate for B from the LS scaled to the BG in the US, using a single sideband
invariantMassInfo << endl << "____________________________________________________________________________________________________" << endl;
invariantMassInfo << "PtBin (0: 0-1, 1: 1-2, 2: 2-3, 3: 3-5, 4: 5-10, 5: all): " << k << endl;
invariantMassInfo << "CentBin (0: per, 1: mid, 2: cent, 3: all): " << i << endl;
//cout << "LS Scale Factor: " << LSScaleFactor[i] << endl;
invariantMassInfo << endl << "S+B (from integral in mass window): " << countsPeakRegionUS << endl;
oneDSubtractedInvMassHistos[k][i]->Add(oneDUSHistos[k][i], oneDScaledLSHistos[k][i], 1, -1); // form subtracted spectrum here
oneDSubtractedInvMassHistosFunction[k][i] = (TH1D*)oneDSubtractedInvMassHistos[k][i]->Clone();
tmp = oneDSubtractedInvMassStringsFunction[k] + binLabelCentralityClass[i];
oneDSubtractedInvMassHistosFunction[k][i]->SetTitle(tmp);
oneDSubtractedInvMassHistos[k][i]->Fit(g1, "qR0");
oneDSubtractedInvMassHistos[k][i]->Fit(e1, "qR0+");
g1->GetParameters(&par[0]);
e1->GetParameters(&par[3]);
fun->SetParameters(par);
oneDSubtractedInvMassHistos[k][i]->Fit(fun, "qR+");
oneDSubtractedInvMassHistos[k][i]->SetMarkerColor(2);
BGFunc->SetParameter(0, fun->GetParameter(3));
BGFunc->SetParameter(1, fun->GetParameter(4));
//------------------------This is where things are controversial -- how do I fit the residual background????-------------------
TF1 *fl = new TF1("fl",fline,1.6,2.1,2);
fl->SetParameters(2,-1);
//fit only the linear background excluding the signal area
reject = kTRUE;
oneDSubtractedInvMassHistos[k][i]->Fit(fl,"qR");
reject = kFALSE;
oneDSubtractedInvMassHistosFunction[k][i]->Add(fl, -1);
//-----------------------------------------------------------------------------------------------------------------------------
oneDSubtractedInvMassHistosFunction[k][i]->Fit(finalGaussian, "qR");
integralFit = oneDSubtractedInvMassHistosFunction[k][i]->Integral(binMassLowUS, binMassHighUS);
//integralFit is the estimate for "S"
//countsPeakRegionUS is S+B
//B = countsPeakRegionUS - integralFit
BOverSPlusBFit[k][i] = (countsPeakRegionUS - integralFit)/countsPeakRegionUS; // B/S+B scale factor from background subtraction from fit
SPlusBOverSFit[k][i] = countsPeakRegionUS/integralFit; // S+B/S used as a final scale factor on the final correlation quantity -- from fit
signalOverBG = integralFit/(countsPeakRegionUS-integralFit);
optimizationFactor = ((signalOverBG*signalOverBG)*((countsPeakRegionUS-integralFit)*(countsPeakRegionUS-integralFit)))/((countsPeakRegionUS-integralFit)*(signalOverBG+2));
invariantMassInfo << "S (from fit estimate): " << integralFit << endl;
invariantMassInfo << "B (from fit estimate): " << (countsPeakRegionUS-integralFit) << endl;
invariantMassInfo << "S+B/S from LS subtraction + expo Fit: " << SPlusBOverSFit[k][i] << endl;
invariantMassInfo << "B/S+B from LS subtraction + expo Fit: " << BOverSPlusBFit[k][i] << endl;
invariantMassInfo << endl << "Signal over background (S/B): " << signalOverBG << endl;
invariantMassInfo << "Optimization Factor: " << optimizationFactor << endl << endl;
//invariantMassInfo << endl << "Left SB: " << integralLeftSB << endl;
//invariantMassInfo << "Right SB: " << integralRightSB << endl;
//invariantMassInfo << endl << "SB Average (how close is it to B?): " << SBAverage << endl << endl;
oneDUSHistos[k][i]->Draw();
oneDScaledLSHistos[k][i]->Draw("SAME");
tmp = path + invariantMassHistogramsFolder + invariantMassOutputFolders[k] + oneDUSStrings[k] + binLabelCentralityClass[i] + withFitLabel + fileType;
c->SaveAs(tmp);
oneDLSHistos[k][i]->Draw();
tmp = path + invariantMassHistogramsFolder + invariantMassOutputFolders[k] + oneDLSStrings[k] + binLabelCentralityClass[i] + fileType;
c->SaveAs(tmp);
oneDSubtractedInvMassHistos[k][i]->Draw();
tmp = path + invariantMassHistogramsFolder + invariantMassOutputFolders[k] + oneDSubtractedInvMassStrings[k] + binLabelCentralityClass[i] + fileType;
c->SaveAs(tmp);
sqrtSPlusB = TMath::Sqrt(countsPeakRegionUS);
DMesonSig = integralFit/sqrtSPlusB;
sigPerBin[k][i] = DMesonSig;
tmp = "#frac{S}{#sqrt{S+B}} = ";
str1 = Form("%.2f",DMesonSig);
str2 = tmp + str1;
invariantMassInfo << "D0 Significance: " << DMesonSig << endl << endl;
TPaveText *textBoxSignifigance = new TPaveText(0.25, 0.75, .45, .95, "NB NDC");
textBoxSignifigance->AddText(str2);
textBoxSignifigance->GetLine(0)->SetTextSize(.041);
oneDSubtractedInvMassHistosFunction[k][i]->Draw();
textBoxSignifigance->Draw("SAME");
tmp = path + invariantMassHistogramsFolder + invariantMassOutputFolders[k] + oneDSubtractedInvMassStringsFunction[k] + binLabelCentralityClass[i] + fileType;
c->SaveAs(tmp);
}
}
invariantMassInfo.close();
cout << endl << "Invariant Mass histograms processed and S & B calculated for each Pt/Centrality bin" << endl << endl;
//Print EPS file for Lanny DOE review
//------------------------------------------
//BEGIN CORRELATION HISTOGRAM INFORMATION
//------------------------------------------
/**********************************************************************************
EXTRACT SIBLING AND MIXED HISTOGRAMS FROM RAW DATA FILE HERE
**********************************************************************************/
for(int band = 0; band < 4; band++){ //begin loop to get raw sibling and mixed histograms in both US and LS
for(int i = 0; i < NUM_CENT_BINS; i++){
for(int k = FIRST_PT_BIN; k < NUM_PT_BINS; k++){
//Sibling histogram information
str1 = SibCorrLabels[band] + PtBinLabel[k] + binLabelPt[k] + VzIntLabel + centBinLabel + binLabelCent[i];
sibCorrBinVzInt[band][k][i] = new TH2D(str1, str1, NUM_ETA_BINS, -2, 2, NUM_PHI_BINS, -TMath::PiOver2()+phiBinShift, 3*TMath::PiOver2()+phiBinShift);
str1 = SibCorrLabels[band] + phiProj + PtBinLabel[k] + binLabelPt[k] + VzIntLabel + centBinLabel + binLabelCent[i];
sibCorrBinPhiProjVzInt[band][k][i] = new TH1D(str1, str1, NUM_PHI_BINS, -TMath::PiOver2()+phiBinShift, 3*TMath::PiOver2()+phiBinShift);
formatCorrHist(sibCorrBinVzInt[band][k][i]);
//mixed histogram information
str1 = MixCorrLabels[band] + PtBinLabel[k] + binLabelPt[k] + VzIntLabel + centBinLabel + binLabelCent[i];
mixCorrBinVzInt[band][k][i] = new TH2D(str1, str1, NUM_ETA_BINS, -2, 2, NUM_PHI_BINS, -TMath::PiOver2()+phiBinShift, 3*TMath::PiOver2()+phiBinShift);
str1 = MixCorrLabels[band] + phiProj + PtBinLabel[k] + binLabelPt[k] + VzIntLabel + centBinLabel + binLabelCent[i];
mixCorrBinPhiProjVzInt[band][k][i] = new TH1D(str1, str1, NUM_PHI_BINS, -TMath::PiOver2()+phiBinShift, 3*TMath::PiOver2()+phiBinShift);
formatCorrHist(mixCorrBinPhiProjVzInt[band][k][i]);
for(int j = 0; j < 10; j++){
str1 = SibCorrLabels[band] + PtBinLabel[k] + binLabelPt[k] + VzBinLabel + binLabelVz[j] + centBinLabel + binLabelCent[i];
str2 = MixCorrLabels[band] + PtBinLabel[k] + binLabelPt[k] + VzBinLabel + binLabelVz[j] + centBinLabel + binLabelCent[i];
sibCorrBin[band][k][j][i] = (TH2D*)file->Get(str1);
mixCorrBin[band][k][j][i] = (TH2D*)file->Get(str2);
//sibCorrBin[band][k][j][i]->Sumw2();
//mixCorrBin[band][k][j][i]->Sumw2();
//This gets the stat errors for the raw sibling and mixed histograms
for(int etaBin = 0; etaBin < NUM_ETA_BINS; etaBin++){
for(int phiBin = 0; phiBin < NUM_PHI_BINS; phiBin++){
sibCorrBinStatErrors[band][k][j][i][etaBin][phiBin] = sibCorrBin[band][k][j][i]->GetBinContent(etaBin, phiBin);
mixCorrBinStatErrors[band][k][j][i][etaBin][phiBin] = mixCorrBin[band][k][j][i]->GetBinContent(etaBin, phiBin);
}
}//Stat errors
//if(k==3){totalPairsSibling = totalPairsSibling + sibCorrBin[band][k][j][i]->Integral(1, NUM_ETA_BINS, 1, NUM_PHI_BINS);}
sibCorrBinVzInt[band][k][i]->Add(sibCorrBin[band][k][j][i]);
formatCorrHist(sibCorrBin[band][k][j][i]); //histogram formatting for axes
mixCorrBinVzInt[band][k][i]->Add(mixCorrBin[band][k][j][i]);
formatCorrHist(mixCorrBin[band][k][j][i]); //histogram formatting for axes
//Sibling US
if(PRINT_SUB_HISTOS_RAW){
c->Clear();
sibCorrBin[band][k][j][i]->SetStats(0);
sibCorrBin[band][k][j][i]->Draw("SURF1"); //sibling 2D US histogram
str1 = path + outputFolders[0] + bandFolders[band] + PtSubFolders[k] + VzSubFolders[j] + SibCorrLabels[band] + VzBinLabel + binLabelVz[j] + centBinLabel + binLabelCent[i] + fileType;
c->SaveAs(str1);
}
str1 = phiProj + SibCorrLabels[band] + PtBinLabel[k] + binLabelPt[k] + VzBinLabel + binLabelVz[j] + centBinLabel + binLabelCent[i]; //sibling phi projection US
sibCorrBinPhiProj[band][k][j][i] = new TH1D(str1, str1, NUM_PHI_BINS, -TMath::PiOver2()+phiBinShift, 3*TMath::PiOver2()+phiBinShift);
sibCorrBinPhiProj[band][k][j][i] = (TH1D*)sibCorrBin[band][k][j][i]->ProjectionY();
if(PRINT_SUB_HISTOS_RAW){
str1 = path + outputFolders[0] + bandFolders[band] + PtSubFolders[k] + VzSubFolders[j] + phiProj + SibCorrLabels[band] + VzBinLabel + binLabelVz[j] + centBinLabel + binLabelCent[i] + fileType;
sibCorrBinPhiProj[band][k][j][i]->Draw();
c->SaveAs(str1);
}
sibCorrBinPhiProjVzInt[band][k][i]->Add(sibCorrBinPhiProj[band][k][j][i]);
//Mixed
if(PRINT_SUB_HISTOS_RAW){
mixCorrBin[band][k][j][i]->Draw("SURF1"); //mixling 2D US histogram
str1 = path + outputFolders[1] + bandFolders[band] + PtSubFolders[k] + VzSubFolders[j] + MixCorrLabels[band] + VzBinLabel + binLabelVz[j] + centBinLabel + binLabelCent[i] + fileType;
c->SaveAs(str1);
}
str1 = phiProj + MixCorrLabels[band] + PtBinLabel[k] + binLabelPt[k] + VzBinLabel + binLabelVz[j] + centBinLabel + binLabelCent[i]; //mixling phi projection US
mixCorrBinPhiProj[band][k][j][i] = new TH1D(str1, str1, NUM_PHI_BINS, -TMath::PiOver2()+phiBinShift, 3*TMath::PiOver2()+phiBinShift);
mixCorrBinPhiProj[band][k][j][i] = (TH1D*)mixCorrBin[band][k][j][i]->ProjectionY();
if(PRINT_SUB_HISTOS_RAW){
str1 = path + outputFolders[1] + bandFolders[band] + PtSubFolders[k] + VzSubFolders[j] + phiProj + MixCorrLabels[band] + VzBinLabel + binLabelVz[j] + centBinLabel + binLabelCent[i] + fileType;
mixCorrBinPhiProj[band][k][j][i]->Draw();
c->SaveAs(str1);
}
mixCorrBinPhiProjVzInt[band][k][i]->Add(mixCorrBinPhiProj[band][k][j][i]);
}
if(PRINT_SUB_HISTOS_RAW){
//sibling
sibCorrBinVzInt[band][k][i]->Draw("SURF1");
str1 = path + outputFolders[0] + bandFolders[band] + PtSubFolders[k] + VzSubFolders[10] + SibCorrLabels[band] + VzIntLabel + centBinLabel + binLabelCent[i] + fileType;
c->SaveAs(str1);
sibCorrBinPhiProjVzInt[band][k][i]->Draw();
str1 = path + outputFolders[0] + bandFolders[band] + PtSubFolders[k] + VzSubFolders[10] + phiProj + SibCorrLabels[band] + VzIntLabel + centBinLabel + binLabelCent[i] + fileType;
c->SaveAs(str1);
//mixed
mixCorrBinVzInt[band][k][i]->Draw("SURF1");
str1 = path + outputFolders[1] + bandFolders[band] + PtSubFolders[k] + VzSubFolders[10] + MixCorrLabels[band] + VzIntLabel + centBinLabel + binLabelCent[i] + fileType;
c->SaveAs(str1);
mixCorrBinPhiProjVzInt[band][k][i]->Draw();
str1 = path + outputFolders[1] + bandFolders[band] + PtSubFolders[k] + VzSubFolders[10] + phiProj + MixCorrLabels[band] + VzIntLabel + centBinLabel + binLabelCent[i] + fileType;
c->SaveAs(str1);
}
}
}//end loop to get raw sibling and mixed histograms in both US and LS
}
cout << endl << "Sibling and mixed histograms extracted" << endl;
/**********************************************************************************
NORMALIZE THE MIXED HISTOGRAMS HERE
**********************************************************************************/
for(int band = 0; band < 4; band++){ // begin loop to make scaled mixed histograms
for(int i = 0; i < NUM_CENT_BINS; i++){
for(int k = FIRST_PT_BIN; k < NUM_PT_BINS; k++){
str1 = ScaledMixCorrLabels[band] + PtBinLabel[k] + binLabelPt[k] + VzIntLabel + centBinLabel + binLabelCent[i];
scaledMixCorrBinVzInt[band][k][i] = new TH2D(str1, str1, NUM_ETA_BINS, -2, 2, NUM_PHI_BINS, -TMath::PiOver2()+phiBinShift, 3*TMath::PiOver2()+phiBinShift);
str1 = phiProj + ScaledMixCorrLabels[band] + PtBinLabel[k] + binLabelPt[k] + VzIntLabel + centBinLabel + binLabelCent[i];
scaledMixCorrBinPhiProjVzInt[band][k][i] = new TH1D(str1, str1, NUM_PHI_BINS, -TMath::PiOver2()+phiBinShift, 3*TMath::PiOver2()+phiBinShift);
for(int j = 0; j < 10; j++){
scaledMixCorrBin[band][k][j][i] = (TH2D*) mixCorrBin[band][k][j][i]->Clone();
//US histograms
numSib = sibCorrBin[band][k][j][i]->Integral(1, NUM_ETA_BINS, 1, NUM_PHI_BINS);
numMixUS = mixCorrBin[band][k][j][i]->Integral(1, NUM_ETA_BINS, 1, NUM_PHI_BINS);
integralRawMixHistos[band][k][j][i] = numMixUS;
scaledMixCorrBin[band][k][j][i]->Scale(numSib/numMixUS);
//VzScaleFactorUS[j] = numMixUS;
for(int etaBin = 0; etaBin < NUM_ETA_BINS; etaBin++){
for(int phiBin = 0; phiBin < NUM_PHI_BINS; phiBin++){
scaledMixCorrBinStatErrors[band][k][j][i][etaBin][phiBin] = mixCorrBinStatErrors[band][k][j][i][etaBin][phiBin]/((numSib/numMixUS)*(numSib/numMixUS));
}
}//Stat errors
//US scaled histograms
str1 = ScaledMixCorrLabels[band] + PtBinLabel[k] + binLabelPt[k] + VzBinLabel + binLabelVz[j] + centBinLabel + binLabelCent[i];
formatCorrHist(scaledMixCorrBin[band][k][j][i], str1); //formatting
if(PRINT_SUB_HISTOS_SCALED){
scaledMixCorrBin[band][k][j][i]->Draw("SURF1");
str1 = path + outputFolders[2] + bandFolders[band] + PtSubFolders[k] + VzSubFolders[j] + ScaledMixCorrLabels[band] + PtBinLabel[k] + binLabelPt[k] + VzBinLabel + binLabelVz[j] + centBinLabel + binLabelCent[i] + fileType;
c->SaveAs(str1);
}
str1 = phiProj + ScaledMixCorrLabels[band] + PtBinLabel[k] + binLabelPt[k] + VzBinLabel + binLabelVz[j] + centBinLabel + binLabelCent[i]; //scaled mix phi projection US
scaledMixCorrBinPhiProj[band][k][j][i] = new TH1D(str1, str1, NUM_PHI_BINS, -TMath::PiOver2()+phiBinShift, 3*TMath::PiOver2()+phiBinShift);
scaledMixCorrBinPhiProj[band][k][j][i] = (TH1D*)scaledMixCorrBin[band][k][j][i]->ProjectionY();
if(PRINT_SUB_HISTOS_SCALED){
str1 = path + outputFolders[2] + bandFolders[band] + PtSubFolders[k] + VzSubFolders[j] + phiProj + ScaledMixCorrLabels[band] + PtBinLabel[k] + binLabelPt[k] + VzBinLabel + binLabelVz[j] + centBinLabel + binLabelCent[i] + fileType;
scaledMixCorrBinPhiProj[band][k][j][i]->Draw();
c->SaveAs(str1);
}
}
if(PRINT_SUB_HISTOS_SCALED){
str1 = path + outputFolders[2] + bandFolders[band] + PtSubFolders[k] + VzSubFolders[10] + ScaledMixCorrLabels[band] + PtBinLabel[k] + binLabelPt[k] + VzIntLabel + centBinLabel + binLabelCent[i] + fileType;
scaledMixCorrBinVzInt[band][k][i]->Draw("SURF1");
c->SaveAs(str1);
str1 = path + outputFolders[2] + bandFolders[band] + PtSubFolders[k] + VzSubFolders[10] + phiProj + ScaledMixCorrLabels[band] + PtBinLabel[k] + binLabelPt[k] + VzIntLabel + centBinLabel + binLabelCent[i] + fileType;
scaledMixCorrBinPhiProjVzInt[band][k][i]->Draw();
c->SaveAs(str1);
}
}
} //end loop to make scaled mixed histograms */
}
//--------------------------------------------------------calculate some useful quantities here--------------------------------------
cout << endl << "Mixed Histograms Normalized." << endl << endl;
for(int band = 0; band < 4; band++){ //build arrays to store information for adding the various alpha's (Vz, centrality, etc.)
for(int k = FIRST_PT_BIN; k < NUM_PT_BINS; k++){
integralRawMixHistosVzIntCentInt[band][k][0] = 0;
integralRawMixHistosVzIntCentInt[band][k][1] = 0;
integralRawMixHistosVzIntCentInt[band][k][2] = 0;
for(int i = 0; i < NUM_CENT_BINS; i++){
integralRawMixHistosVzInt[band][k][i] = 0;
//cout << band << " " << k << " "<< i << endl;
for(int j = 0; j < 10; j++){
integralRawMixHistosVzInt[band][k][i] = integralRawMixHistosVzInt[band][k][i] + integralRawMixHistos[band][k][j][i];
}
}
}
}
//------------------------------------------------------------------------------------------------------------------------------------
cout << "Weight Factors Calculated." << endl << endl;
/**********************************************************************************
CALCULATE DELTA RHO HERE
**********************************************************************************/
for(int band = 0; band < 4; band++){ // begin loop to make sib minus scaledMixed histos (delRho)
for(int i = 0; i < NUM_CENT_BINS; i++){
for(int k = FIRST_PT_BIN; k < NUM_PT_BINS; k++){
str1 = SibMinusScaledMixLabels[band] + PtBinLabel[k] + binLabelPt[k] + VzIntLabel + centBinLabel + binLabelCent[i];
sibMinusScaledMixVzInt[band][k][i] = new TH2D(str1, str1, NUM_ETA_BINS, -2, 2, NUM_PHI_BINS, -TMath::PiOver2()+phiBinShift, 3*TMath::PiOver2()+phiBinShift);
str1 = phiProj + SibMinusScaledMixLabels[band] + PtBinLabel[k] + binLabelPt[k] + VzIntLabel + centBinLabel + binLabelCent[i];
sibMinusScaledMixPhiProjVzInt[band][k][i] = new TH1D(str1, str1, NUM_PHI_BINS, -TMath::PiOver2()+phiBinShift, 3*TMath::PiOver2()+phiBinShift);
for(int j = 0; j < 10; j++){
str1 = SibMinusScaledMixLabels[band] + PtBinLabel[k] + binLabelPt[k] + VzBinLabel + binLabelVz[j] + centBinLabel + binLabelCent[i];