11 #include "TGraphErrors.h"
18 void GetCentrality() {
19 TFile *f0 =
new TFile(
"glauberfit.root");
20 TH1D *sim = (TH1D *)f0->Get(
"hRefMultSim");
21 TH1D *
data = (TH1D *)f0->Get(
"hRefMultCorr");
26 int centralitybin[16][2];
27 double integral = sim->Integral();
28 for(
int cent=0; cent<16; cent++){
29 double distance = 1000.0;
30 double fraction = 0.05*((double)cent+1.0);
33 for(
int i=0; i<data->GetNbinsX(); i++){
34 double thisfraction = (data->Integral(i,500))/(integral);
35 double thisdistance = TMath::Abs(thisfraction - fraction);
37 if(thisdistance>distance){
38 if(cent==0){centralitybin[0][0]=500; centralitybin[0][1]=i-1;centralitybin[1][0]=i-2;}
39 else{centralitybin[cent][1]=i-1;centralitybin[cent+1][0]=i-2;}
42 else{distance=thisdistance;}
47 int newmaxbin = centralitybin[3][1]-1;
48 double zeroToTwentyIntegral = data->Integral(newmaxbin+1,500);
49 for(
int i=0; i<newmaxbin; i++){
50 double thisfraction=(sim->Integral(i,newmaxbin)+zeroToTwentyIntegral)/(integral);
51 double thisdistance = TMath::Abs(thisfraction - fraction);
52 if(thisdistance>distance){
53 if(cent==15){centralitybin[15][1]=i-1;}
54 else{centralitybin[cent][1]=i-1;centralitybin[cent+1][0]=i-2;}
57 else{distance=thisdistance;}
63 cout<<
"******* 16 Bins *******"<<endl;
64 cout<<
"High bins"<<endl;
65 for(
int i=0; i<16; i++){
66 cout<<data->GetXaxis()->GetBinCenter(centralitybin[i][0])+0.5<<endl;
68 cout<<
"Low bins"<<endl;
69 for(
int i=0; i<16; i++){
70 cout<<data->GetXaxis()->GetBinCenter(centralitybin[i][1])-0.5<<endl;
72 cout<<
"Integrals"<<endl;
73 for(
int i=0; i<16; i++){
74 if(i<4)cout<<(data->Integral(centralitybin[i][1],centralitybin[i][0]))/(sim->Integral())<<endl;
75 else cout<<(sim->Integral(centralitybin[i][1],centralitybin[i][0]))/(sim->Integral())<<endl;
77 cout<<
"Cumulative Integrals"<<endl;
78 for(
int i=0; i<16; i++){
79 if(i<4)cout<<(data->Integral(centralitybin[i][1],500))/(sim->Integral())<<endl;
80 else cout<<(sim->Integral(centralitybin[i][1],centralitybin[3][1]-1)+data->Integral(centralitybin[3][1],500))/(sim->Integral())<<endl;
82 cout<<
"Efficiencies"<<endl;
83 for(
int i=0; i<16; i++){
84 double thiseff = (data->Integral(centralitybin[i][1],centralitybin[i][0]))/(sim->Integral(centralitybin[i][1],centralitybin[i][0]));
85 if(thiseff>1.0) thiseff=1.0;
87 else cout<<thiseff<<endl;
98 cout<<
"******* 9 Bins *******"<<endl;
99 cout<<
"High bins"<<endl;
100 for(
int i=0; i<9; i++){
101 if(i==0 || i==1){cout<<data->GetXaxis()->GetBinCenter(centralitybin[i][0])+0.5<<endl;}
102 else{cout<<data->GetXaxis()->GetBinCenter(centralitybin[2*i-1][0])+0.5<<endl;}
104 cout<<
"Low bins"<<endl;
105 for(
int i=0; i<9; i++){
106 if(i==0 || i==1){cout<<data->GetXaxis()->GetBinCenter(centralitybin[i][1])-0.5<<endl;}
107 else{cout<<data->GetXaxis()->GetBinCenter(centralitybin[2*i-1][1])-0.5<<endl;}