11 #include "TGraphErrors.h"
24 void getcentralitybins() {
25 TFile *f0 =
new TFile(
"Case3/Zr/Ratio_npp2.386_k3.889_x0.123_eff0.024.root");
26 TH1D *sim = (TH1D *)f0->Get(
"hRefMultSim");
27 TH1D *
data = (TH1D *)f0->Get(
"hRefMult");
29 int centralitybin[16][2];
30 double integral = sim->Integral();
31 for(
int cent=0; cent<16; cent++){
32 double distance = 1000.0;
33 double fraction = 0.05*((double)cent+1.0);
36 for(
int i=0; i<data->GetNbinsX(); i++){
37 double thisfraction = (data->Integral(i,500))/(integral);
38 double thisdistance = TMath::Abs(thisfraction - fraction);
39 if(thisdistance>distance){
40 if(cent==0){centralitybin[0][0]=500; centralitybin[0][1]=i-1;centralitybin[1][0]=i-2;}
41 else{centralitybin[cent][1]=i-1;centralitybin[cent+1][0]=i-2;}
44 else{distance=thisdistance;}
49 int newmaxbin = centralitybin[3][1]-1;
50 double zeroToTwentyIntegral = data->Integral(newmaxbin+1,500);
51 for(
int i=0; i<newmaxbin; i++){
52 double thisfraction=(sim->Integral(i,newmaxbin)+zeroToTwentyIntegral)/(integral);
53 double thisdistance = TMath::Abs(thisfraction - fraction);
54 if(thisdistance>distance){
55 if(cent==15){centralitybin[15][1]=i-2;}
56 else{centralitybin[cent][1]=i-1;centralitybin[cent+1][0]=i-2;}
59 else{distance=thisdistance;}
64 std::cout<<
"******* 16 Bins *******"<<std::endl;
65 std::cout<<
"High bins"<<std::endl;
66 for(
int i=0; i<16; i++){
67 std::cout<<centralitybin[i][0]<<std::endl;
69 std::cout<<
"Low bins"<<std::endl;
70 for(
int i=0; i<16; i++){
71 std::cout<<centralitybin[i][1]<<std::endl;
73 std::cout<<
"******* 9 Bins *******"<<std::endl;
74 std::cout<<
"High bins"<<std::endl;
75 for(
int i=0; i<9; i++){
76 if(i==0 || i==1){std::cout<<centralitybin[i][0]<<std::endl;}
77 else{std::cout<<centralitybin[2*i-1][0]<<std::endl;}
79 std::cout<<
"Low bins"<<std::endl;
80 for(
int i=0; i<9; i++){
81 if(i==0 || i==1){std::cout<<centralitybin[i][1]<<std::endl;}
82 else{std::cout<<centralitybin[2*i-1][1]<<std::endl;}