Back to home page

sPhenix code displayed by LXR

 
 

    


File indexing completed on 2025-08-03 08:15:26

0001 double CBFunction(double *x, double *p)
0002 {
0003   double norm = p[0];
0004   double alpha = p[1];  // tail start
0005   double n = p[2];      // tail shape 
0006   double mu = p[3];     // upsilon mass
0007   double sigma = p[4];  // upsilon width
0008 
0009   double A = pow(n/fabs(alpha),n)*TMath::Exp(-pow(fabs(alpha),2)/2.);
0010   double B = n/fabs(alpha) - fabs(alpha);
0011   double k = (x[0]-mu)/sigma;
0012 
0013   double val;
0014   if( k > -alpha )
0015     val = norm*TMath::Exp(-0.5*pow(k,2));
0016   else
0017     val = norm*A*pow(B-k,-n);
0018 
0019   if( TMath::IsNaN(val) ) val = 0.0;
0020 
0021   return val;
0022 }
0023 
0024 double TripleCBFunction(double *x, double *p)
0025 {
0026   double norm1 = p[0];  // amplitude of Y(1S) peak
0027   double alpha = p[1];  // tail start
0028   double n = p[2];      // tail shape 
0029   double mu1 = p[3];    // upsilon (1S) mass
0030   double sigma = p[4];  // upsilon width
0031   double norm2 = p[5];
0032   double norm3 = p[6];
0033   double mu2 = mu1*1.0595;
0034   double mu3 = mu1*1.0946;
0035 
0036   double A = pow(n/fabs(alpha),n)*TMath::Exp(-pow(fabs(alpha),2)/2.);
0037   double B = n/fabs(alpha) - fabs(alpha);
0038   double k1 = (x[0]-mu1)/sigma;
0039   double k2 = (x[0]-mu2)/sigma;
0040   double k3 = (x[0]-mu3)/sigma;
0041 
0042   double val,val1,val2,val3;
0043 
0044   if( k1 > -alpha ) { val1 = norm1*TMath::Exp(-0.5*pow(k1,2)); }
0045   else { val1 = norm1*A*pow(B-k1,-n); }
0046   if( k2 > -alpha ) { val2 = norm2*TMath::Exp(-0.5*pow(k2,2)); }
0047   else { val2 = norm2*A*pow(B-k2,-n); }
0048   if( k3 > -alpha ) { val3 = norm3*TMath::Exp(-0.5*pow(k3,2)); }
0049   else { val3 = norm3*A*pow(B-k3,-n); }
0050 
0051   val = val1 + val2 + val3;
0052 
0053   if( TMath::IsNaN(val) ) val = 0.0;
0054 
0055   return val;
0056 }
0057 double SandB_CBFunction(double *x, double *p)
0058 {
0059   double norm1 = p[0];  // amplitude of Y(1S) peak
0060   double alpha = p[1];  // tail start
0061   double n = p[2];      // tail shape 
0062   double mu1 = p[3];     // upsilon (1S) mass
0063   double sigma = p[4];  // upsilon width
0064   double norm2 = p[5];
0065   double norm3 = p[6];
0066   double mu2 = mu1*1.0595;
0067   double mu3 = mu1*1.0946;
0068 
0069   double A = pow(n/fabs(alpha),n)*TMath::Exp(-pow(fabs(alpha),2)/2.);
0070   double B = n/fabs(alpha) - fabs(alpha);
0071   double k1 = (x[0]-mu1)/sigma;
0072   double k2 = (x[0]-mu2)/sigma;
0073   double k3 = (x[0]-mu3)/sigma;
0074 
0075   double val,val1,val2,val3;
0076 
0077   if( k1 > -alpha ) { val1 = norm1*TMath::Exp(-0.5*pow(k1,2)); }
0078   else { val1 = norm1*A*pow(B-k1,-n); }
0079   if( k2 > -alpha ) { val2 = norm2*TMath::Exp(-0.5*pow(k2,2)); }
0080   else { val2 = norm2*A*pow(B-k2,-n); }
0081   if( k3 > -alpha ) { val3 = norm3*TMath::Exp(-0.5*pow(k3,2)); }
0082   else { val3 = norm3*A*pow(B-k3,-n); }
0083 
0084   double bgnorm1 = p[7];
0085   double bgslope1 = p[8];
0086 
0087   double bg = exp(bgnorm1+x[0]*bgslope1);
0088 
0089   val = val1 + val2 + val3 + bg;
0090   if( TMath::IsNaN(val) ) val = 0.0;
0091 
0092   return val;
0093 }
0094 
0095 //=======================================================================
0096 
0097 void fit_vs_directcount() {
0098 
0099 const int nbins = 15;
0100 
0101 // TRUE numbers
0102 //Number of upsilons in AuAu plot = 11752 971 111
0103 //Number of upsilons in pp plot = 9755 2537 1414
0104 double Nups1[nbins+1],Nups2[nbins+1],Nups3[nbins+1];
0105 Nups1[0]=1020.82;
0106 Nups2[0]=84.3446;
0107 Nups3[0]=9.64186;
0108 Nups1[1]=2519.56;
0109 Nups2[1]=208.177;
0110 Nups3[1]=23.7977;
0111 Nups1[2]=2870.95;
0112 Nups2[2]=237.21;
0113 Nups3[2]=27.1167;
0114 Nups1[3]=2326.04;
0115 Nups2[3]=192.187;
0116 Nups3[3]=21.9699;
0117 Nups1[4]=1500.87;
0118 Nups2[4]=124.008;
0119 Nups3[4]=14.176;
0120 Nups1[5]=820.126;
0121 Nups2[5]=67.7622;
0122 Nups3[5]=7.74625;
0123 Nups1[6]=396.538;
0124 Nups2[6]=32.7637;
0125 Nups3[6]=3.74538;
0126 Nups1[7]=175.598;
0127 Nups2[7]=14.5086;
0128 Nups3[7]=1.65856;
0129 Nups1[8]=73.2069;
0130 Nups2[8]=6.04867;
0131 Nups3[8]=0.691454;
0132 Nups1[9]=29.3682;
0133 Nups2[9]=2.42653;
0134 Nups3[9]=0.277389;
0135 Nups1[10]=11.5318;
0136 Nups2[10]=0.952802;
0137 Nups3[10]=0.10892;
0138 Nups1[11]=4.49014;
0139 Nups2[11]=0.370994;
0140 Nups3[11]=0.0424103;
0141 Nups1[12]=1.75068;
0142 Nups2[12]=0.144648;
0143 Nups3[12]=0.0165355;
0144 Nups1[13]=0.688396;
0145 Nups2[13]=0.0568782;
0146 Nups3[13]=0.00650204;
0147 Nups1[14]=0.274397;
0148 Nups2[14]=0.0226719;
0149 Nups3[14]=0.00259174;
0150 
0151 double Nups1pp[nbins+1],Nups2pp[nbins+1],Nups3pp[nbins+1];
0152 Nups1pp[0]=847.355;
0153 Nups2pp[0]=220.373;
0154 Nups3pp[0]=122.825;
0155 Nups1pp[1]=2091.41;
0156 Nups2pp[1]=543.917;
0157 Nups3pp[1]=303.153;
0158 Nups1pp[2]=2383.1;
0159 Nups2pp[2]=619.776;
0160 Nups3pp[2]=345.433;
0161 Nups1pp[3]=1930.78;
0162 Nups2pp[3]=502.14;
0163 Nups3pp[3]=279.869;
0164 Nups1pp[4]=1245.83;
0165 Nups2pp[4]=324.005;
0166 Nups3pp[4]=180.585;
0167 Nups1pp[5]=680.763;
0168 Nups2pp[5]=177.047;
0169 Nups3pp[5]=98.6775;
0170 Nups1pp[6]=329.155;
0171 Nups2pp[6]=85.6039;
0172 Nups3pp[6]=47.7115;
0173 Nups1pp[7]=145.759;
0174 Nups2pp[7]=37.9077;
0175 Nups3pp[7]=21.1279;
0176 Nups1pp[8]=60.767;
0177 Nups2pp[8]=15.8038;
0178 Nups3pp[8]=8.80825;
0179 Nups1pp[9]=24.3777;
0180 Nups2pp[9]=6.33996;
0181 Nups3pp[9]=3.53358;
0182 Nups1pp[10]=9.57218;
0183 Nups2pp[10]=2.48945;
0184 Nups3pp[10]=1.3875;
0185 Nups1pp[11]=3.72714;
0186 Nups2pp[11]=0.969323;
0187 Nups3pp[11]=0.540253;
0188 Nups1pp[12]=1.45319;
0189 Nups2pp[12]=0.377933;
0190 Nups3pp[12]=0.210641;
0191 Nups1pp[13]=0.571418;
0192 Nups2pp[13]=0.14861;
0193 Nups3pp[13]=0.0828277;
0194 Nups1pp[14]=0.227769;
0195 Nups2pp[14]=0.0592364;
0196 Nups3pp[14]=0.0330155;
0197 
0198 // new suppression
0199 double raapt[9],raa1s[9],raa2s[9],oldraa1s[9],oldraa2s[9];
0200 raapt[0] = 1.5;
0201 raapt[1] = 4.5;
0202 raapt[2] = 7.5;
0203 raapt[3] = 10.5;
0204 raapt[4] = 13.5;
0205 oldraa1s[0] = 0.535;
0206 oldraa1s[1] = 0.535;
0207 oldraa1s[2] = 0.535;
0208 oldraa1s[3] = 0.535;
0209 oldraa1s[4] = 0.535;
0210 oldraa2s[0] = 0.170;
0211 oldraa2s[1] = 0.170;
0212 oldraa2s[2] = 0.170;
0213 oldraa2s[3] = 0.170;
0214 oldraa2s[4] = 0.170;
0215 raa1s[0] = 0.4960;
0216 raa1s[1] = 0.4960;
0217 raa1s[2] = 0.4955;
0218 raa1s[3] = 0.4968;
0219 raa1s[4] = 0.4743;
0220 raa2s[0] = 0.1710;
0221 raa2s[1] = 0.1629;
0222 raa2s[2] = 0.1326;
0223 raa2s[3] = 0.1232;
0224 raa2s[4] = 0.0928;
0225 TGraph* grRAA1S = new TGraph(5,raapt,raa1s);
0226 TGraph* grRAA2S = new TGraph(5,raapt,raa2s);
0227 TGraph* groldRAA1S = new TGraph(5,raapt,oldraa1s);
0228 TGraph* groldRAA2S = new TGraph(5,raapt,oldraa2s);
0229 for(int i=0; i<nbins; i++) {
0230   Nups1[i] = Nups1[i] * grRAA1S->Eval(0.5+i*1.0)/groldRAA1S->Eval(0.5+i*1.0);
0231   Nups2[i] = Nups2[i] * grRAA2S->Eval(0.5+i*1.0)/groldRAA2S->Eval(0.5+i*1.0);
0232 }
0233 grRAA1S->SetLineColor(kBlue);
0234 grRAA1S->SetLineStyle(3);
0235 grRAA1S->SetLineWidth(3);
0236 grRAA2S->SetLineColor(kMagenta);
0237 grRAA2S->SetLineStyle(3);
0238 grRAA2S->SetLineWidth(3);
0239 
0240 
0241 
0242 //gROOT->LoadMacro("sPHENIXStyle/sPhenixStyle.C");
0243 //SetsPhenixStyle();
0244 gStyle->SetOptStat(0);
0245 gStyle->SetOptFit(0);
0246 
0247 char tmpname[999];
0248 TLatex* tl[nbins+1];
0249 char tlchar[999];
0250 
0251 TH1D* hhfit[nbins+1];
0252 TH1D* hhcorrbg_scaled[nbins+1];
0253 TH1D* hhups1pp[nbins+1];
0254 TH1D* hhups2pp[nbins+1];
0255 TH1D* hhups3pp[nbins+1];
0256 TH1D* hhupspp[nbins+1];
0257 TH1D* hhups1[nbins+1];
0258 TH1D* hhups2[nbins+1];
0259 TH1D* hhups3[nbins+1];
0260 TH1D* hhups[nbins+1];
0261 TH1D* hhall_pp[nbins+1];
0262 TH1D* hhcorrbg_pp[nbins+1];
0263 
0264 TF1* fCBups1s = new TF1("fCBups1s",CBFunction,5.,14.,5);
0265 TF1* fCBups2s = new TF1("fCBups2s",CBFunction,5.,14.,5);
0266 TF1* fCBups1spp = new TF1("fCBups1spp",CBFunction,5.,14.,5);
0267 TF1* fCBups2spp = new TF1("fCBups2spp",CBFunction,5.,14.,5);
0268 TF1* fTCB = new TF1("fTCB",TripleCBFunction,5.,14.,7);
0269 TF1* fSandB = new TF1("fSandB",SandB_CBFunction,5.,14.,9);
0270 TF1* fSandBpp = new TF1("fSandBpp",SandB_CBFunction,5.,14.,9);
0271 TF1* fSandBauau = new TF1("fSandBauau",SandB_CBFunction,5.,14.,9);
0272 
0273 double tonypar1 = 0.98;    // Tony's 100 pion simulation April 2019
0274 double tonypar2 = 0.93;    // Tony's 100 pion simulation April 2019
0275 //double tonypar3 = 9.437;   // Tony's 100 pion simulation April 2019
0276 double tonypar3 = 9.448;   // benchmark
0277 double tonypar4 = 0.100;   // benchmark
0278 
0279 double u1start = 9.25;
0280 double u1stop  = 9.65;
0281 double u2start = 9.80;
0282 double u2stop  = 10.20;
0283 double u3start = 10.20;
0284 double u3stop  = 10.55;
0285 double sum1[nbins+1]      = {0.};
0286 double truesum1[nbins+1]  = {0.};
0287 double truesum1pp[nbins+1]  = {0.};
0288 double ersum1[nbins+1]    = {0.};
0289 double sum2[nbins+1]      = {0.};
0290 double truesum2[nbins+1]  = {0.};
0291 double truesum2pp[nbins+1]  = {0.};
0292 double ersum2[nbins+1]    = {0.};
0293 double sum1pp[nbins+1]    = {0.};
0294 double ersum1pp[nbins+1]  = {0.};
0295 double sum2pp[nbins+1]    = {0.};
0296 double ersum2pp[nbins+1]  = {0.};
0297 double sumfit1[nbins+1]   = {0.};
0298 double ersumfit1[nbins+1] = {0.};
0299 double sumfit2[nbins+1]   = {0.};
0300 double ersumfit2[nbins+1] = {0.};
0301 double sumfit1pp[nbins+1]   = {0.};
0302 double ersumfit1pp[nbins+1] = {0.};
0303 double sumfit2pp[nbins+1]   = {0.};
0304 double ersumfit2pp[nbins+1] = {0.};
0305 double sum1ppbg[nbins+1]    = {0.};
0306 double ersum1ppbg[nbins+1]  = {0.};
0307 double sum2ppbg[nbins+1]    = {0.};
0308 double ersum2ppbg[nbins+1]  = {0.};
0309 
0310 double xx1[nbins+1]; for(int i=0; i<nbins+1; i++) {xx1[i] = 0.50 + double(i);}
0311 double xx2[nbins+1]; for(int i=0; i<nbins+1; i++) {xx2[i] = 0.40 + double(i);}
0312 double xx3[nbins+1]; for(int i=0; i<nbins+1; i++) {xx3[i] = 0.60 + double(i);}
0313 
0314 //=====================================================================================================
0315 
0316 // read histograms created by newplotbg.C
0317 
0318 TFile* f=new TFile("ups_corrbg_24b_auau.root");
0319 for(int i=0; i<nbins+1; i++) {
0320 
0321   sprintf(tmpname,"hhfit_%d",i);
0322   hhfit[i] = (TH1D*)f->Get(tmpname);
0323   hhfit[i]->SetDirectory(gROOT);
0324   sprintf(tmpname,"hhcorrbg_scaled_%d",i);
0325   hhcorrbg_scaled[i] = (TH1D*)f->Get(tmpname);
0326   hhcorrbg_scaled[i]->SetDirectory(gROOT);
0327 
0328   sprintf(tmpname,"hhups1pp_%d",i);
0329   hhups1pp[i] = (TH1D*)f->Get(tmpname);
0330   hhups1pp[i]->SetDirectory(gROOT);
0331   sprintf(tmpname,"hhups2pp_%d",i);
0332   hhups2pp[i] = (TH1D*)f->Get(tmpname);
0333   hhups2pp[i]->SetDirectory(gROOT);
0334   sprintf(tmpname,"hhups3pp_%d",i);
0335   hhups3pp[i] = (TH1D*)f->Get(tmpname);
0336   hhups3pp[i]->SetDirectory(gROOT);
0337   sprintf(tmpname,"hhupspp_%d",i);
0338   hhupspp[i] = (TH1D*)f->Get(tmpname);
0339   hhupspp[i]->SetDirectory(gROOT);
0340 
0341   sprintf(tmpname,"hhups1_%d",i);
0342   hhups1[i] = (TH1D*)f->Get(tmpname);
0343   hhups1[i]->SetDirectory(gROOT);
0344   sprintf(tmpname,"hhups2_%d",i);
0345   hhups2[i] = (TH1D*)f->Get(tmpname);
0346   hhups2[i]->SetDirectory(gROOT);
0347   sprintf(tmpname,"hhups3_%d",i);
0348   hhups3[i] = (TH1D*)f->Get(tmpname);
0349   hhups3[i]->SetDirectory(gROOT);
0350   sprintf(tmpname,"hhups_%d",i);
0351   hhups[i] = (TH1D*)f->Get(tmpname);
0352   hhups[i]->SetDirectory(gROOT);
0353 
0354   sprintf(tmpname,"hhall_pp_%d",i);
0355   hhall_pp[i] = (TH1D*)f->Get(tmpname);
0356   hhall_pp[i]->SetDirectory(gROOT);
0357   sprintf(tmpname,"hhcorrbg_pp_%d",i);
0358   hhcorrbg_pp[i] = (TH1D*)f->Get(tmpname);
0359   hhcorrbg_pp[i]->SetDirectory(gROOT);
0360 
0361 }
0362 f->Close();
0363 
0364   // fg and bg parameters from newplotbg.C
0365   double bgpar0[nbins+1],bgpar1[nbins+1];
0366   for(int i=0; i<nbins+1; i++) {
0367     bgpar0[i] = hhcorrbg_scaled[i]->GetFunction("expo")->GetParameter(0);
0368     bgpar1[i] = hhcorrbg_scaled[i]->GetFunction("expo")->GetParameter(1);
0369   }
0370   double fgpar0 =  hhups[nbins]->GetFunction("fTCBauau")->GetParameter(0);
0371   double fgpar5 =  hhups[nbins]->GetFunction("fTCBauau")->GetParameter(5);
0372   double fgpar6 =  hhups[nbins]->GetFunction("fTCBauau")->GetParameter(6);
0373 
0374 //-------------------------------------------------------------------------------------
0375 
0376 TCanvas* cups = new TCanvas("cups","Upsilons and correlated BG",150,150,700,700);
0377 
0378   // "true" distribution
0379   fSandBauau->SetParameter(0,fgpar0);
0380   fSandBauau->SetParameter(1,tonypar1);
0381   fSandBauau->SetParameter(2,tonypar2);
0382   fSandBauau->SetParameter(3,tonypar3);
0383   fSandBauau->SetParameter(4,tonypar4);
0384   fSandBauau->SetParameter(5,fgpar5);
0385   fSandBauau->SetParameter(6,fgpar6);
0386   fSandBauau->SetParameter(7,bgpar0[nbins]);
0387   fSandBauau->SetParameter(8,bgpar1[nbins]);
0388   fSandBauau->SetLineColor(kRed);
0389 //  fSandBauau->Draw("same");
0390 
0391   // "true" Upsilon1S
0392   fCBups1s->SetParameter(0,fSandBauau->GetParameter(0));
0393   fCBups1s->SetParameter(1,fSandBauau->GetParameter(1));
0394   fCBups1s->SetParameter(2,fSandBauau->GetParameter(2));
0395   fCBups1s->SetParameter(3,fSandBauau->GetParameter(3));
0396   fCBups1s->SetParameter(4,fSandBauau->GetParameter(4));
0397   double true_ups1s_integral = fCBups1s->Integral(5.,14.);
0398   double true_ups1s_ampl = fSandBauau->GetParameter(0);
0399   double true_ups1s_amplerr = fSandBauau->GetParError(0);
0400   double binsize = hhfit[nbins]->GetBinWidth(1);
0401   cout << "TRUE Integral = " << true_ups1s_integral/binsize << " +- " << true_ups1s_integral*(true_ups1s_amplerr/true_ups1s_ampl)/binsize << "  ( " << true_ups1s_amplerr/true_ups1s_ampl*100. << "% )" << endl;
0402 
0403   // "true" corr bg
0404   TF1* fcorrbg[nbins+1];
0405   fcorrbg[nbins] = new TF1("fcorrbg_15","exp([0]+[1]*x)",7.,14.);
0406   fcorrbg[nbins]->SetParameters(bgpar0[nbins],bgpar1[nbins]);
0407   //fcorrbg[nbins]->SetLineStyle(2);
0408   fcorrbg[nbins]->SetLineWidth(1);
0409   fcorrbg[nbins]->SetLineColor(kRed);
0410 
0411 //--- FIT all pT -------------------------------------------------------------------------
0412 
0413   fSandB->SetParameter(0,fgpar0);
0414   fSandB->FixParameter(1,tonypar1);
0415   fSandB->FixParameter(2,tonypar2);
0416   fSandB->FixParameter(3,tonypar3);
0417   fSandB->FixParameter(4,tonypar4);
0418   fSandB->SetParameter(5,fgpar5);
0419   fSandB->SetParameter(6,fgpar6);
0420   fSandB->SetParameter(7,bgpar0[nbins]);
0421   fSandB->SetParameter(8,bgpar1[nbins]);
0422   hhfit[nbins]->Fit(fSandB,"qrl","",8.,11.);
0423 
0424   hhfit[nbins]->GetXaxis()->SetTitleOffset(1.0);
0425   hhfit[nbins]->GetYaxis()->SetTitleOffset(1.6);
0426   hhfit[nbins]->SetAxisRange(8.0,11.0); 
0427   hhfit[nbins]->Draw();
0428 
0429   TF1* fcorrbg_fromfit[nbins+1];
0430   sprintf(tmpname,"fcorrbg_fromfit_%d",15);
0431   fcorrbg_fromfit[nbins] = new TF1(tmpname,"exp([0]+[1]*x)",7.,14.);
0432   fcorrbg_fromfit[nbins]->SetParameters(fSandB->GetParameter(7),fSandB->GetParameter(8));
0433   fcorrbg_fromfit[nbins]->SetLineStyle(2);
0434   fcorrbg_fromfit[nbins]->SetLineWidth(3);
0435   fcorrbg_fromfit[nbins]->Draw("same");
0436   fcorrbg[nbins]->Draw("same"); // true correlated bg
0437 
0438   // counting range
0439   TLine* line1 = new TLine(u1start,0.,u1start,hhfit[nbins]->GetMaximum()*1.1); line1->SetLineStyle(2); line1->Draw();
0440   TLine* line2 = new TLine(u1stop,0.,u1stop,hhfit[nbins]->GetMaximum()*1.1); line2->SetLineStyle(2); line2->Draw();
0441 
0442   // Upsilon1S from fit
0443   fCBups1s->SetParameter(0,fSandB->GetParameter(0));
0444   fCBups1s->SetParameter(1,fSandB->GetParameter(1));
0445   fCBups1s->SetParameter(2,fSandB->GetParameter(2));
0446   fCBups1s->SetParameter(3,fSandB->GetParameter(3));
0447   fCBups1s->SetParameter(4,fSandB->GetParameter(4));
0448   double ups1s_integral = fCBups1s->Integral(5.,14.);
0449   double ups1s_ampl = fSandB->GetParameter(0);
0450   double ups1s_amplerr = fSandB->GetParError(0);
0451   cout << "Integral = " << ups1s_integral/binsize << " +- " << ups1s_integral*(ups1s_amplerr/ups1s_ampl)/binsize << "  ( " << ups1s_amplerr/ups1s_ampl*100. << "% )" << endl;
0452 
0453 //--- Direct Counting all pT ------------------------------------------------------
0454 
0455   int fbin1 = hhfit[nbins]->FindBin(u1start + 0.001);
0456   int lbin1 = hhfit[nbins]->FindBin(u1stop  - 0.001);
0457   int fbin2 = hhfit[nbins]->FindBin(u2start + 0.001);
0458   int lbin2 = hhfit[nbins]->FindBin(u2stop  - 0.001);
0459   int fbin3 = hhfit[nbins]->FindBin(u3start + 0.001);
0460   int lbin3 = hhfit[nbins]->FindBin(u3stop  - 0.001);
0461 
0462   for(int j=fbin1; j<=lbin1; j++) {
0463     //sum1[nbins]   += (hhfit[nbins]->GetBinContent(j) - fcorrbg_fromfit[nbins]->Eval(hhfit[nbins]->GetBinCenter(j)));
0464     sum1[nbins]   += (hhfit[nbins]->GetBinContent(j) - fcorrbg[nbins]->Eval(hhfit[nbins]->GetBinCenter(j)));
0465     ersum1[nbins]   += hhfit[nbins]->GetBinError(j)*hhfit[nbins]->GetBinError(j);
0466     truesum1[nbins]   += hhups1[nbins]->GetBinContent(j);
0467   }
0468   ersum1[nbins] = sqrt(ersum1[nbins]);
0469   cout << "Direct count = " << truesum1[nbins] << " +- " << ersum1[nbins] << "  ( " << ersum1[nbins]/truesum1[nbins]*100. << "% )" << endl;
0470 
0471 //============================================================================================
0472 //  VS pT
0473 //============================================================================================
0474 
0475 int npts=10;
0476 
0477 TCanvas* dummy = new TCanvas("dummy","dummy",0,0,500,500);
0478 
0479   for(int i=0; i<npts; i++) {
0480 
0481     fSandB->SetParameter(0,hhfit[i]->GetMaximum()/9.);
0482       fSandB->SetParLimits(0,0.,99999.);
0483     fSandB->FixParameter(1,tonypar1);
0484     fSandB->FixParameter(2,tonypar2);
0485     fSandB->FixParameter(3,tonypar3);
0486     fSandB->FixParameter(4,tonypar4);
0487     fSandB->SetParameter(5,fgpar5/1.);
0488       fSandB->SetParLimits(5,0.5,9999.);
0489     fSandB->SetParameter(6,fgpar6/1.);
0490       fSandB->SetParLimits(6,0.,999.);
0491     fSandB->SetParameter(7,bgpar0[i]/9.);
0492       fSandB->SetParLimits(7,0.,99.);
0493     fSandB->FixParameter(8,bgpar1[i]);
0494     hhfit[i]->Fit(fSandB,"qrl","",8.,11.);
0495 
0496     fCBups1s->SetParameter(0,fSandB->GetParameter(0));
0497     fCBups1s->SetParameter(1,fSandB->GetParameter(1));
0498     fCBups1s->SetParameter(2,fSandB->GetParameter(2));
0499     fCBups1s->SetParameter(3,fSandB->GetParameter(3));
0500     fCBups1s->SetParameter(4,fSandB->GetParameter(4));
0501     double ups1s_integral = fCBups1s->Integral(5.,14.);
0502     double ups1s_ampl = fSandB->GetParameter(0);
0503     double ups1s_amplerr = fSandB->GetParError(0);
0504 //    cout << i << "  Integral1 = " << ups1s_integral/binsize << " +- " << ups1s_integral*(ups1s_amplerr/ups1s_ampl)/binsize << "  ( " << ups1s_amplerr/ups1s_ampl*100. << "% )" << endl;
0505     sumfit1[i]   = ups1s_integral/binsize;
0506     ersumfit1[i] = ups1s_integral*(ups1s_amplerr/ups1s_ampl)/binsize;
0507 
0508     fCBups2s->SetParameter(0,fSandB->GetParameter(5));
0509     fCBups2s->SetParameter(1,fSandB->GetParameter(1));
0510     fCBups2s->SetParameter(2,fSandB->GetParameter(2));
0511     fCBups2s->SetParameter(3,fSandB->GetParameter(3));
0512     fCBups2s->SetParameter(4,fSandB->GetParameter(4));
0513     double ups2s_integral = fCBups2s->Integral(5.,14.);
0514     double ups2s_ampl = fSandB->GetParameter(5);
0515     double ups2s_amplerr = fSandB->GetParError(5);
0516     cout << i << "  Integral2 = " << ups2s_integral/binsize << " +- " << ups2s_integral*(ups2s_amplerr/ups2s_ampl)/binsize << "  ( " << ups2s_amplerr/ups2s_ampl*100. << "% )" << endl;
0517     sumfit2[i]   = ups2s_integral/binsize;
0518     ersumfit2[i] = ups2s_integral*(ups2s_amplerr/ups2s_ampl)/binsize;
0519 
0520     sprintf(tmpname,"fcorrbg_fromfit_%d",i);   // correlated bg from fit
0521     fcorrbg_fromfit[i] = new TF1(tmpname,"exp([0]+[1]*x)",7.,14.);
0522     fcorrbg_fromfit[i]->SetLineStyle(2);
0523     fcorrbg_fromfit[i]->SetParameters(fSandB->GetParameter(7),fSandB->GetParameter(8));
0524 
0525     sprintf(tmpname,"fcorrbg_%d",i);  // true correlated bg
0526     fcorrbg[i] = new TF1(tmpname,"exp([0]+[1]*x)",7.,14.);
0527     fcorrbg[i]->SetLineWidth(1);
0528     fcorrbg[i]->SetLineColor(kRed);
0529     fcorrbg[i]->SetParameters(bgpar0[i],bgpar1[i]);
0530 
0531 //--- vs pT direct counting ----------------------------------------------------
0532 
0533     sum1[i]=0.;
0534     truesum1[i]=0.;
0535     ersum1[i]=0.;
0536     sum1pp[i]=0.;
0537     ersum1pp[i]=0.;
0538     for(int j=fbin1; j<=lbin1; j++) {
0539       //sum1[i]   += (hhfit[i]->GetBinContent(j) - fcorrbg_fromfit[i]->Eval(hhfit[i]->GetBinCenter(j)));
0540       sum1[i]   += (hhfit[i]->GetBinContent(j) - fcorrbg[i]->Eval(hhfit[i]->GetBinCenter(j)));
0541       ersum1[i]   += hhfit[i]->GetBinError(j)*hhfit[i]->GetBinError(j);
0542       sum1pp[i]   += hhupspp[i]->GetBinContent(j);
0543       ersum1pp[i]   += hhupspp[i]->GetBinError(j)*hhupspp[i]->GetBinError(j);
0544       truesum1[i]   += hhups1[i]->GetBinContent(j);
0545     }
0546     ersum1[i] = sqrt(ersum1[i]);
0547     ersum1pp[i] = sqrt(ersum1pp[i]);
0548     //cout << "   Direct count1 = " << truesum1[i] << " +- " << ersum1[i] << "  ( " << ersum1[i]/sum1[i]*100. << "% )" << endl;
0549 
0550     sum2[i]=0.;
0551     truesum2[i]=0.;
0552     ersum2[i]=0.;
0553     sum2pp[i]=0.;
0554     ersum2pp[i]=0.;
0555     for(int j=fbin2; j<=lbin2; j++) {
0556       //sum2[i]   += (hhfit[i]->GetBinContent(j) - fcorrbg_fromfit[i]->Eval(hhfit[i]->GetBinCenter(j)));
0557       sum2[i]   += (hhfit[i]->GetBinContent(j) - fcorrbg[i]->Eval(hhfit[i]->GetBinCenter(j)));
0558       ersum2[i]   += hhfit[i]->GetBinError(j)*hhfit[i]->GetBinError(j);
0559       sum2pp[i]   += hhupspp[i]->GetBinContent(j);
0560       ersum2pp[i]   += hhupspp[i]->GetBinError(j)*hhupspp[i]->GetBinError(j);
0561       truesum2[i]   += hhups2[i]->GetBinContent(j);
0562     }
0563     ersum2[i] = sqrt(ersum2[i]);
0564     ersum2pp[i] = sqrt(ersum2pp[i]);
0565     cout << "   Direct count2 = " << truesum2[i] << " +- " << ersum2[i] << "  ( " << ersum2[i]/sum2[i]*100. << "% )" << endl;
0566 
0567 
0568   } // end loop over pT bins
0569 
0570 delete dummy;
0571 
0572 TCanvas* cupsvspt_fit = new TCanvas("cupsvspt_fit","Upsilons vs. p_{T} after fit",100,100,1100,900);
0573 cupsvspt_fit->Divide(3,3);
0574 for(int i=0; i<9; i++) {
0575 if(i==0)  {cupsvspt_fit->cd(0);}
0576 if(i==1)  {cupsvspt_fit->cd(1);}
0577 if(i==2)  {cupsvspt_fit->cd(2);}
0578 if(i==3)  {cupsvspt_fit->cd(3);}
0579 if(i==4)  {cupsvspt_fit->cd(4);}
0580 if(i==5)  {cupsvspt_fit->cd(5);}
0581 if(i==6)  {cupsvspt_fit->cd(6);}
0582 if(i==7)  {cupsvspt_fit->cd(7);}
0583 if(i==8)  {cupsvspt_fit->cd(8);}
0584   hhfit[i]->SetAxisRange(8.0,11.0); 
0585   hhfit[i]->Draw();
0586   fcorrbg_fromfit[i]->Draw("same");
0587   fcorrbg[i]->Draw("same");
0588   sprintf(tlchar,"%d-%d GeV",i,i+1);   tl[i] = new TLatex(8.2,hhfit[i]->GetMaximum()*0.95,tlchar); tl[i]->Draw();
0589 }
0590 
0591 
0592 
0593 
0594 //==========================================================================
0595 //  p+p
0596 //==========================================================================
0597 cout << endl << "---------- p+p ---------------------------------------" << endl << endl;
0598 
0599 double bgpar0pp[nbins+1],bgpar1pp[nbins+1];
0600 for(int i=0; i<nbins+1; i++) {
0601   bgpar0pp[i] = hhcorrbg_pp[i]->GetFunction("expo")->GetParameter(0);
0602   bgpar1pp[i] = hhcorrbg_pp[i]->GetFunction("expo")->GetParameter(1);
0603 }
0604 TF1* fcorrbg_pp[nbins+1];
0605 TF1* fcorrbg_pp_fromfit[nbins+1];
0606 
0607 TCanvas* cpp = new TCanvas("cpp","p+p",100,100,700,700);
0608 
0609   double tmpmax = hhall_pp[nbins]->GetMaximum();
0610 
0611   fSandBpp->SetParameter(0,tmpmax/9.);
0612     fSandBpp->SetParLimits(0,0.,99999.);
0613   fSandBpp->FixParameter(1,tonypar1);
0614   fSandBpp->FixParameter(2,tonypar2);
0615   fSandBpp->FixParameter(3,tonypar3);
0616   fSandBpp->FixParameter(4,0.089); // p+p mass resolution
0617   fSandBpp->SetParameter(5,tmpmax/99.);
0618     fSandBpp->SetParLimits(5,0.5,9999.);
0619   fSandBpp->SetParameter(6,tmpmax/99.);
0620     fSandBpp->SetParLimits(6,0.,999.);
0621   fSandBpp->SetParameter(7,bgpar0pp[nbins]/9.);
0622     fSandBpp->SetParLimits(7,0.,99.);
0623   fSandBpp->SetParameter(8,bgpar1pp[nbins]);
0624     hhall_pp[nbins]->Fit(fSandBpp,"qrl","",7.,12.);
0625     hhall_pp[nbins]->SetAxisRange(8.,11.);
0626     hhall_pp[nbins]->Draw();
0627 //    hhcorrbg_pp[nbins]->GetFunction("expo")->SetLineWidth(1);
0628 //    hhcorrbg_pp[nbins]->GetFunction("expo")->SetLineColor(kRed);
0629 //    hhcorrbg_pp[nbins]->GetFunction("expo")->Draw("same");  // "true" correlated bg
0630       sprintf(tmpname,"fcorrbg_pp_%d",nbins);  // "true" correlated bg copy
0631       fcorrbg_pp[nbins] = new TF1(tmpname,"exp([0]+[1]*x)",7.,14.);
0632       fcorrbg_pp[nbins]->SetLineColor(kRed);
0633       fcorrbg_pp[nbins]->SetLineWidth(1);
0634       fcorrbg_pp[nbins]->SetParameters(bgpar0[nbins], bgpar1pp[nbins]);
0635       fcorrbg_pp[nbins]->Draw("same");
0636   
0637     sprintf(tmpname,"fcorrbg_pp_fromfit_%d",nbins);  // correlated bg from fit
0638     fcorrbg_pp_fromfit[nbins] = new TF1(tmpname,"exp([0]+[1]*x)",7.,14.);
0639     fcorrbg_pp_fromfit[nbins]->SetLineStyle(2);
0640     fcorrbg_pp_fromfit[nbins]->SetParameters(hhall_pp[nbins]->GetFunction("fSandBpp")->GetParameter(7), hhall_pp[nbins]->GetFunction("fSandBpp")->GetParameter(8));
0641     fcorrbg_pp_fromfit[nbins]->Draw("same");
0642 
0643 
0644     fCBups1spp->SetParameter(0,fSandBpp->GetParameter(0));
0645     fCBups1spp->SetParameter(1,fSandBpp->GetParameter(1));
0646     fCBups1spp->SetParameter(2,fSandBpp->GetParameter(2));
0647     fCBups1spp->SetParameter(3,fSandBpp->GetParameter(3));
0648     fCBups1spp->SetParameter(4,fSandBpp->GetParameter(4));
0649     double ups1spp_integral = fCBups1spp->Integral(5.,14.);
0650     double ups1spp_ampl = fSandBpp->GetParameter(0);
0651     double ups1spp_amplerr = fSandBpp->GetParError(0);
0652     cout << "p+p Integral1 = " << ups1spp_integral/binsize << " +- " << ups1spp_integral*(ups1spp_amplerr/ups1spp_ampl)/binsize << "  ( " << ups1spp_amplerr/ups1spp_ampl*100. << "% )" << endl;
0653     fCBups2spp->SetParameter(0,fSandBpp->GetParameter(5));
0654     fCBups2spp->SetParameter(1,fSandBpp->GetParameter(1));
0655     fCBups2spp->SetParameter(2,fSandBpp->GetParameter(2));
0656     fCBups2spp->SetParameter(3,fSandBpp->GetParameter(3));
0657     fCBups2spp->SetParameter(4,fSandBpp->GetParameter(4));
0658     double ups2spp_integral = fCBups2spp->Integral(5.,14.);
0659     double ups2spp_ampl = fSandBpp->GetParameter(5);
0660     double ups2spp_amplerr = fSandBpp->GetParError(5);
0661     cout << "p+p Integral2 = " << ups2spp_integral/binsize << " +- " << ups2spp_integral*(ups2spp_amplerr/ups2spp_ampl)/binsize << "  ( " << ups2spp_amplerr/ups2spp_ampl*100. << "% )" << endl;
0662 
0663 //------ p+p vs. pT -------------------------------------------------------------------------------
0664 
0665 TCanvas* dummy2 = new TCanvas("dummy2","dummy2",0,0,500,500);
0666 
0667   for(int i=0; i<npts; i++) {
0668 
0669   double tmpmax = hhall_pp[i]->GetMaximum()/9.;
0670 
0671     fSandBpp->SetParameter(0,tmpmax);
0672       fSandBpp->SetParLimits(0,0.,99999.);
0673     fSandBpp->FixParameter(1,tonypar1);
0674     fSandBpp->FixParameter(2,tonypar2);
0675     fSandBpp->FixParameter(3,tonypar3);
0676     fSandBpp->FixParameter(4,0.089); // p+p mass resolution
0677     fSandBpp->SetParameter(5,tmpmax);
0678       fSandBpp->SetParLimits(5,0.0,9999.);
0679     fSandBpp->SetParameter(6,tmpmax);
0680       fSandBpp->SetParLimits(6,0.0,999.);
0681     double tmppar7 = bgpar0pp[i]; if(tmppar7<0.) {tmppar7=0.;}
0682     fSandBpp->SetParameter(7,tmppar7);
0683       fSandBpp->SetParLimits(7,0.,99.);
0684     fSandBpp->FixParameter(8,bgpar1pp[i]);
0685       hhall_pp[i]->Fit(fSandBpp,"qrl","",8.,11.);
0686 
0687       sprintf(tmpname,"fcorrbg_pp_%d",i);  // "true" correlated bg copy
0688       fcorrbg_pp[i] = new TF1(tmpname,"exp([0]+[1]*x)",7.,14.);
0689       fcorrbg_pp[i]->SetLineColor(kRed);
0690       fcorrbg_pp[i]->SetLineWidth(1);
0691       fcorrbg_pp[i]->SetParameters(bgpar0pp[i], bgpar1pp[i]);
0692 
0693       sprintf(tmpname,"fcorrbg_pp_fromfit_%d",i);  // correlated bg from fit
0694       fcorrbg_pp_fromfit[i] = new TF1(tmpname,"exp([0]+[1]*x)",7.,14.);
0695       fcorrbg_pp_fromfit[i]->SetLineStyle(2);
0696       fcorrbg_pp_fromfit[i]->SetParameters(hhall_pp[i]->GetFunction("fSandBpp")->GetParameter(7), hhall_pp[i]->GetFunction("fSandBpp")->GetParameter(8));
0697 
0698       fCBups1spp->SetParameter(0,fSandBpp->GetParameter(0));
0699       fCBups1spp->SetParameter(1,fSandBpp->GetParameter(1));
0700       fCBups1spp->SetParameter(2,fSandBpp->GetParameter(2));
0701       fCBups1spp->SetParameter(3,fSandBpp->GetParameter(3));
0702       fCBups1spp->SetParameter(4,fSandBpp->GetParameter(4));
0703       double ups1spp_integral = fCBups1spp->Integral(5.,14.);
0704       double ups1spp_ampl = fSandBpp->GetParameter(0);
0705       double ups1spp_amplerr = fSandBpp->GetParError(0);
0706       fCBups2spp->SetParameter(0,fSandBpp->GetParameter(5));
0707       fCBups2spp->SetParameter(1,fSandBpp->GetParameter(1));
0708       fCBups2spp->SetParameter(2,fSandBpp->GetParameter(2));
0709       fCBups2spp->SetParameter(3,fSandBpp->GetParameter(3));
0710       fCBups2spp->SetParameter(4,fSandBpp->GetParameter(4));
0711       double ups2spp_integral = fCBups2spp->Integral(5.,14.);
0712       double ups2spp_ampl = fSandBpp->GetParameter(5);
0713       double ups2spp_amplerr = fSandBpp->GetParError(5);
0714       cout << "p+p Integral1 vs pT = " << i << " " << ups1spp_integral/binsize << " +- " << ups1spp_integral*(ups1spp_amplerr/ups1spp_ampl)/binsize << "  ( " << ups1spp_amplerr/ups1spp_ampl*100. << "% )" << endl;
0715 
0716 
0717         sumfit1pp[i]   = ups1spp_integral/binsize;
0718         ersumfit1pp[i] = ups1spp_integral*(ups1spp_amplerr/ups1spp_ampl)/binsize;
0719         sumfit2pp[i]   = ups2spp_integral/binsize;
0720         ersumfit2pp[i] = ups2spp_integral*(ups2spp_amplerr/ups2spp_ampl)/binsize;
0721 
0722         truesum1pp[i]=0.;
0723         truesum2pp[i]=0.;
0724         sum1ppbg[i]=0.;
0725         ersum1ppbg[i]=0.;
0726         sum2ppbg[i]=0.;
0727         ersum2ppbg[i]=0.;
0728         for(int j=fbin1; j<=lbin1; j++) {
0729           //sum1ppbg[i]   += (hhall_pp[i]->GetBinContent(j) - fcorrbg_pp_fromfit[i]->Eval(hhall_pp[i]->GetBinCenter(j)));
0730           sum1ppbg[i]   += hhall_pp[i]->GetBinContent(j) - fcorrbg_pp[i]->Eval(hhall_pp[i]->GetBinCenter(j));
0731           ersum1ppbg[i] += hhall_pp[i]->GetBinError(j)*hhall_pp[i]->GetBinError(j);
0732           truesum1pp[i]   += hhups1pp[i]->GetBinContent(j);
0733         }
0734         ersum1ppbg[i] = sqrt(ersum1ppbg[i]);
0735           for(int j=fbin2; j<=lbin2; j++) {
0736           sum2ppbg[i]   += hhall_pp[i]->GetBinContent(j) - fcorrbg_pp[i]->Eval(hhall_pp[i]->GetBinCenter(j));
0737           ersum2ppbg[i] += hhall_pp[i]->GetBinError(j)*hhall_pp[i]->GetBinError(j);
0738           truesum2pp[i]   += hhups2pp[i]->GetBinContent(j);
0739         }
0740         ersum2ppbg[i] = sqrt(ersum2ppbg[i]);
0741 
0742 
0743   } // end loop over p+p pT bins
0744 
0745 delete dummy;
0746 
0747 TCanvas* cupsvspt_pp = new TCanvas("cupsvspt_pp","p+p Upsilons vs. p_{T}",100,100,1100,900);
0748 cupsvspt_pp->Divide(3,3);
0749 for(int i=0; i<9; i++) {
0750 if(i==0)  {cupsvspt_pp->cd(0);}
0751 if(i==1)  {cupsvspt_pp->cd(1);}
0752 if(i==2)  {cupsvspt_pp->cd(2);}
0753 if(i==3)  {cupsvspt_pp->cd(3);}
0754 if(i==4)  {cupsvspt_pp->cd(4);}
0755 if(i==5)  {cupsvspt_pp->cd(5);}
0756 if(i==6)  {cupsvspt_pp->cd(6);}
0757 if(i==7)  {cupsvspt_pp->cd(7);}
0758 if(i==8)  {cupsvspt_pp->cd(8);}
0759   hhall_pp[i]->SetAxisRange(8.0,11.0);
0760   hhall_pp[i]->Draw();
0761   fcorrbg_pp[i]->Draw("same");
0762   fcorrbg_pp_fromfit[i]->Draw("same");
0763   sprintf(tlchar,"%d-%d GeV",i,i+1);   tl[i] = new TLatex(8.2,hhall_pp[i]->GetMaximum()*0.95,tlchar); tl[i]->Draw();
0764 }
0765 
0766 //
0767 //=== compare errors from direct counting and fit
0768 //
0769 
0770 TCanvas* cercomp = new TCanvas("cercomp","error comparizon",50,50,700,700);
0771 TH2F* hhcomp = new TH2F("hhcomp"," ",10,0.,10.,10,0.,1.0);
0772 hhcomp->GetXaxis()->SetTitle("Transverse momentum [GeV/c]");
0773 hhcomp->GetXaxis()->SetTitleOffset(1.0);
0774 hhcomp->Draw();
0775 
0776 double reler1[nbins+1],reler2[nbins+1];
0777 double relerfit1[nbins+1],relerfit2[nbins+1];
0778 double reler1pp[nbins+1],reler2pp[nbins+1];
0779 double reler1ppbg[nbins+1],reler2ppbg[nbins+1];
0780 double relerfit1pp[nbins+1],relerfit2pp[nbins+1];
0781 for(int i=0; i<npts; i++) { 
0782   reler1[i] = ersum1[i]/truesum1[i];           reler2[i] = ersum2[i]/truesum2[i]; 
0783   relerfit1[i] = ersumfit1[i]/Nups1[i];        relerfit2[i] = ersumfit2[i]/Nups2[i]; 
0784   reler1pp[i] = ersum1pp[i]/truesum1pp[i];     reler2pp[i] = ersum2pp[i]/truesum2pp[i];     // direct count no bg
0785   reler1ppbg[i] = ersum1ppbg[i]/truesum1pp[i]; reler2ppbg[i] = ersum2ppbg[i]/truesum2pp[i]; // direct count with bg
0786   relerfit1pp[i] = ersumfit1pp[i]/Nups1pp[i];  relerfit2pp[i] = ersumfit2pp[i]/Nups2pp[i];  // fit
0787 }
0788 
0789 TGraphErrors* grcomp1 = new TGraphErrors(npts,xx1,reler1,0,0);
0790 grcomp1->SetMarkerStyle(20);
0791 grcomp1->SetMarkerColor(kBlack);
0792 grcomp1->SetLineColor(kBlack);
0793 grcomp1->SetLineWidth(2);
0794 grcomp1->SetMarkerSize(1.5);
0795 grcomp1->Draw("p");
0796 
0797 TGraphErrors* grcompfit1 = new TGraphErrors(npts,xx1,relerfit1,0,0);
0798 grcompfit1->SetMarkerStyle(24);
0799 grcompfit1->SetMarkerColor(kBlack);
0800 grcompfit1->SetLineColor(kBlack);
0801 grcompfit1->SetLineWidth(2);
0802 grcompfit1->SetMarkerSize(1.5);
0803 grcompfit1->Draw("p");
0804 
0805 TCanvas* cercomppp = new TCanvas("cercomppp","p+p error comparizon",50,50,700,700);
0806 TH2F* hhcomppp = new TH2F("hhcomppp"," ",10,0.,10.,10,0.,1.0);
0807 hhcomppp->GetXaxis()->SetTitle("Transverse momentum [GeV/c]");
0808 hhcomppp->GetXaxis()->SetTitleOffset(1.0);
0809 hhcomppp->Draw();
0810 
0811 TGraphErrors* grcomp1pp = new TGraphErrors(npts,xx1,reler1pp,0,0);
0812 grcomp1pp->SetMarkerStyle(20);
0813 grcomp1pp->SetMarkerColor(kBlue);
0814 grcomp1pp->SetLineColor(kBlue);
0815 grcomp1pp->SetLineWidth(2);
0816 grcomp1pp->SetMarkerSize(1.5);
0817 grcomp1pp->Draw("p");
0818 
0819 TGraphErrors* grcomp1ppbg = new TGraphErrors(npts,xx1,reler1ppbg,0,0);
0820 grcomp1ppbg->SetMarkerStyle(21);
0821 grcomp1ppbg->SetMarkerColor(kBlue);
0822 grcomp1ppbg->SetLineColor(kBlue);
0823 grcomp1ppbg->SetLineWidth(2);
0824 grcomp1ppbg->SetMarkerSize(1.5);
0825 grcomp1ppbg->Draw("p");
0826 
0827 TGraphErrors* grcompfit1pp = new TGraphErrors(npts,xx1,relerfit1pp,0,0);
0828 grcompfit1pp->SetMarkerStyle(24);
0829 grcompfit1pp->SetMarkerColor(kBlue);
0830 grcompfit1pp->SetLineColor(kBlue);
0831 grcompfit1pp->SetLineWidth(2);
0832 grcompfit1pp->SetMarkerSize(1.5);
0833 grcompfit1pp->Draw("p");
0834 
0835 
0836 //==========================================================================
0837 //  RAA
0838 //==========================================================================
0839 
0840 double raa1[nbins+1],raa2[nbins+1],raa3[nbins+1],erraa1[nbins+1],erraa2[nbins+1],erraa3[nbins+1];
0841 double raa1fit[nbins+1],raa2fit[nbins+1],raa3fit[nbins+1],erraa1fit[nbins+1],erraa2fit[nbins+1],erraa3fit[nbins+1];
0842 
0843 for(int i=0; i<nbins; i++) { 
0844 
0845   raa1[i] = 0.535 * grRAA1S->Eval(0.5+i*1.0)/groldRAA1S->Eval(0.5+i*1.0); 
0846   raa2[i] = 0.170 * grRAA2S->Eval(0.5+i*1.0)/groldRAA2S->Eval(0.5+i*1.0); 
0847   raa3[i] = 0.035; 
0848   raa1fit[i] = 0.535 * grRAA1S->Eval(0.5+i*1.0)/groldRAA1S->Eval(0.5+i*1.0); 
0849   raa2fit[i] = 0.170 * grRAA2S->Eval(0.5+i*1.0)/groldRAA2S->Eval(0.5+i*1.0); 
0850   raa3fit[i] = 0.035; 
0851 
0852   erraa1[i] = raa1[i]*sqrt(pow(ersum1[i]/truesum1[i],2)+pow(ersum1pp[i]/truesum1pp[i],2));
0853   erraa2[i] = raa2[i]*sqrt(pow(ersum2[i]/truesum2[i],2)+pow(ersum2pp[i]/truesum2pp[i],2));
0854   erraa1fit[i] = raa1fit[i]*sqrt(pow(ersumfit1[i]/Nups1[i],2)+pow(ersumfit1pp[i]/Nups1pp[i],2));
0855   erraa2fit[i] = raa2fit[i]*sqrt(pow(ersumfit2[i]/Nups2[i],2)+pow(ersumfit2pp[i]/Nups2pp[i],2));
0856 
0857 }
0858 
0859 // plot icomparison direct counting vs. fit
0860 
0861 TCanvas* craa = new TCanvas("craa","R_{AA}",120,120,600,600);
0862 TH2F* hh2 = new TH2F("hh2"," ",10,0.,10.,10,0.,0.8);
0863 hh2->GetXaxis()->SetTitle("Transverse momentum [GeV/c]");
0864 hh2->GetXaxis()->SetTitleOffset(1.0);
0865 hh2->GetXaxis()->SetTitleColor(1);
0866 hh2->GetXaxis()->SetTitleSize(0.040);
0867 hh2->GetXaxis()->SetLabelSize(0.040);
0868 hh2->GetYaxis()->SetTitle("R_{AA}");
0869 hh2->GetYaxis()->SetTitleOffset(1.3);
0870 hh2->GetYaxis()->SetTitleSize(0.040);
0871 hh2->GetYaxis()->SetLabelSize(0.040);
0872 hh2->Draw();
0873 
0874 TGraphErrors* gr1 = new TGraphErrors(npts,xx2,raa1,0,erraa1);
0875 gr1->SetMarkerStyle(20);
0876 gr1->SetMarkerColor(kBlack);
0877 gr1->SetLineColor(kBlack);
0878 gr1->SetLineWidth(2);
0879 gr1->SetMarkerSize(1.5);
0880 gr1->Draw("p");
0881 
0882 TGraphErrors* gr1fit = new TGraphErrors(npts,xx3,raa1fit,0,erraa1fit);
0883 gr1fit->SetMarkerStyle(24);
0884 gr1fit->SetMarkerColor(kBlack);
0885 gr1fit->SetLineColor(kBlack);
0886 gr1fit->SetLineWidth(2);
0887 gr1fit->SetMarkerSize(1.5);
0888 gr1fit->Draw("p");
0889 
0890 TGraphErrors* gr2 = new TGraphErrors(npts-2,xx2,raa2,0,erraa2);
0891 gr2->SetMarkerStyle(20);
0892 gr2->SetMarkerColor(kRed);
0893 gr2->SetLineColor(kRed);
0894 gr2->SetLineWidth(2);
0895 gr2->SetMarkerSize(1.5);
0896 gr2->Draw("p");
0897 
0898 TGraphErrors* gr2fit = new TGraphErrors(npts-2,xx3,raa2fit,0,erraa2fit);
0899 gr2fit->SetMarkerStyle(24);
0900 gr2fit->SetMarkerColor(kRed);
0901 gr2fit->SetLineColor(kRed);
0902 gr2fit->SetLineWidth(2);
0903 gr2fit->SetMarkerSize(1.5);
0904 gr2fit->Draw("p");
0905 
0906 delete dummy;
0907 
0908 // plot fit
0909 
0910 TCanvas* craafit = new TCanvas("craafit","R_{AA}",20,20,600,600);
0911 TH2F* hh2f = new TH2F("hh2f"," ",10,0.,10.,10,0.,0.8);
0912 hh2f->GetXaxis()->SetTitle("Transverse momentum [GeV/c]");
0913 hh2f->GetXaxis()->SetTitleOffset(1.0);
0914 hh2f->GetXaxis()->SetTitleColor(1);
0915 hh2f->GetXaxis()->SetTitleSize(0.040);
0916 hh2f->GetXaxis()->SetLabelSize(0.040);
0917 hh2f->GetYaxis()->SetTitle("R_{AA}");
0918 hh2f->GetYaxis()->SetTitleOffset(1.3);
0919 hh2f->GetYaxis()->SetTitleSize(0.040);
0920 hh2f->GetYaxis()->SetLabelSize(0.040);
0921 hh2f->Draw();
0922 
0923 TGraphErrors* gr1f = new TGraphErrors(npts,xx1,raa1fit,0,erraa1fit);
0924 gr1f->SetMarkerStyle(20);
0925 gr1f->SetMarkerColor(kBlack);
0926 gr1f->SetLineColor(kBlack);
0927 gr1f->SetLineWidth(2);
0928 gr1f->SetMarkerSize(1.5);
0929 gr1f->SetName("gr2c");
0930 gr1f->Draw("p");
0931 
0932 TGraphErrors* gr2f = new TGraphErrors(npts-2,xx1,raa2fit,0,erraa2fit);
0933 gr2f->SetMarkerStyle(20);
0934 gr2f->SetMarkerColor(kRed);
0935 gr2f->SetLineColor(kRed);
0936 gr2f->SetLineWidth(2);
0937 gr2f->SetMarkerSize(1.5);
0938 gr2f->SetName("gr2f");
0939 gr2f->Draw("p");
0940 
0941 TLegend *leg = new TLegend(0.2,0.77,0.5,0.92);
0942 leg->SetFillColor(10);
0943 leg->SetFillStyle(1001);
0944 //TLegendEntry *entry=leg->AddEntry("gr1f","Y(1S)","p");
0945 //entry=leg->AddEntry("gr2f","Y(2S)","p");
0946 //entry=leg->AddEntry("","","");
0947 leg->AddEntry("gr1f","Y(1S)","p");
0948 leg->AddEntry("gr2f","Y(2S)","p");
0949 leg->AddEntry("","","");
0950 leg->Draw();
0951 TLatex* l1 = new TLatex(3.5,0.73,"sPHENIX Simulation");
0952 l1->Draw();
0953 
0954 grRAA1S->Draw("l");
0955 grRAA2S->Draw("l");
0956 
0957 // plot direct count
0958 
0959 TCanvas* craacount = new TCanvas("craacount","R_{AA}",20,20,600,600);
0960 TH2F* hh2c = new TH2F("hh2c"," ",10,0.,10.,10,0.,0.8);
0961 hh2c->GetXaxis()->SetTitle("Transverse momentum [GeV/c]");
0962 hh2c->GetXaxis()->SetTitleOffset(1.0);
0963 hh2c->GetXaxis()->SetTitleColor(1);
0964 hh2c->GetXaxis()->SetTitleSize(0.040);
0965 hh2c->GetXaxis()->SetLabelSize(0.040);
0966 hh2c->GetYaxis()->SetTitle("R_{AA}");
0967 hh2c->GetYaxis()->SetTitleOffset(1.3);
0968 hh2c->GetYaxis()->SetTitleSize(0.040);
0969 hh2c->GetYaxis()->SetLabelSize(0.040);
0970 hh2c->Draw();
0971 
0972 TGraphErrors* gr1c = new TGraphErrors(npts,xx1,raa1,0,erraa1);
0973 gr1c->SetMarkerStyle(20);
0974 gr1c->SetMarkerColor(kBlack);
0975 gr1c->SetLineColor(kBlack);
0976 gr1c->SetLineWidth(2);
0977 gr1c->SetMarkerSize(1.5);
0978 gr1c->SetName("gr1c");
0979 gr1c->Draw("p");
0980 
0981 TGraphErrors* gr2c = new TGraphErrors(npts-3,xx1,raa2,0,erraa2);
0982 gr2c->SetMarkerStyle(20);
0983 gr2c->SetMarkerColor(kRed);
0984 gr2c->SetLineColor(kRed);
0985 gr2c->SetLineWidth(2);
0986 gr2c->SetMarkerSize(1.5);
0987 gr2c->SetName("gr2c");
0988 gr2c->Draw("p");
0989 
0990 TLegend *legc = new TLegend(0.2,0.77,0.5,0.92);
0991 legc->SetFillColor(10);
0992 legc->SetFillStyle(1001);
0993 legc->AddEntry("gr1c","Y(1S)","p");
0994 legc->AddEntry("gr2c","Y(2S)","p");
0995 legc->AddEntry("","","");
0996 //TLegendEntry *entry2=legc->AddEntry("gr1c","Y(1S)","p");
0997 //entry2=legc->AddEntry("gr2c","Y(2S)","p");
0998 //entry2=legc->AddEntry("","","");
0999 legc->Draw();
1000 TLatex* l1c = new TLatex(3.5,0.73,"sPHENIX Simulation");
1001 l1c->Draw();
1002 
1003 grRAA1S->Draw("l");
1004 grRAA2S->Draw("l");
1005 
1006 }
1007