34 int kA[mxSS]={ka,kb,kc,kd};
35 int minYieldPerSpin=1;
38 TH1F * hAL1[mxQ], *hAL2[mxQ], *hALL[mxQ], *hEpsNull[mxQ], *hNused[mxQ], *hBeta[mxQ];
40 TH1F * hALfin[mxQ],* hLumi;
41 double SumYieldPerSpin[mxQ][mxEta][mxSS];
50 void rdN2AL2012(TString inpCore=
"run12toySetB", TString bgYear=
"2012",
double pol1=0.5,
double pol2=0.99 ) {
53 inpCore=
"../results_August28/8.29.12/run12long";pol1=0.549; pol2=0.571;
54 TString bgName=
"8.15.12/bkgdBetaModel_"+bgYear+
".hist.root";
58 gROOT->LoadMacro(
"setWALmodel.C");
60 fdBG=
new TFile(bgName); assert(fdBG->IsOpen());
63 TString dataName=inpCore+
".wana.hist.root";
64 fdData=
new TFile(dataName); assert(fdData->IsOpen());
65 printf(
"Opened %s\n",fdData->GetName());
68 memset(SumYieldPerSpin,0,
sizeof(SumYieldPerSpin));
70 TH1F *hAbsLum=(TH1F *)fdData->Get(
"Eta8/AEta8spinY1"); assert(hAbsLum);
71 hLumi=newSpin4Histo(
"relLumi",
"renormalized relative lums");
73 for(
int is=0; is<mxSS; is++){
75 double y= hAbsLum->GetBinContent(bin);
77 hLumi->SetBinContent(bin,y);
80 hLumi->Scale(mxSS/sum);
81 for(
int is=0; is<mxSS; is++)
82 hLumi->SetBinError(kA[is]+1,1./2/sqrt(sum));
84 double rLumi[mxSS],sLumi[mxSS];
85 for(
int is=0; is<mxSS; is++) {
86 rLumi[is]= hLumi->GetBinContent(kA[is]+1);
87 sLumi[is]= hLumi->GetBinError(kA[is]+1);
90 printf(
"renorm lumis: %.4f %.4f %.4f %.4f QCD eve count=%.1e\n", rLumi[0],rLumi[1],rLumi[2],rLumi[3],sum);
91 printf(
" have errors: %.4f %.4f %.4f %.4f 1/2/sqrt(N)=%.1e\n", sLumi[0],sLumi[1],sLumi[2],sLumi[3],1./2/sqrt(sum));
94 TH1F *h; TGraphErrors *gr;
96 for(
int iq=0; iq<mxQ; iq++) {
97 if(skipWminus && iq==1)
continue;
98 TString Q=
"P";
if (iq) Q=
"N";
100 hNused[iq]=newEtaBinHisto(
"Nused_"+Q,
" Lum-norm. events, Q="+Q,
"EVENTS");
102 hAL1[iq]=h=newEtaBinHisto(
"AL1_"+Q,
"beam 1 AL (starEta) , Q="+Q,
"A_L");
103 h->SetMarkerStyle(22+iq*4);
104 h->SetMarkerSize(1.3);
106 hAL2[iq]=h=newEtaBinHisto(
"AL2_"+Q,
" beam 2 AL (starEta) , Q="+Q,
"A_L");
107 h->SetMarkerStyle(21+iq*4);
109 hALL[iq]=h=newEtaBinHisto(
"ALL_"+Q,
" beam 1*2 ALL, Q="+Q,
"A_LL");
110 h->SetMarkerStyle(23+iq*9);
111 h->SetMarkerSize(1.3);
113 hEpsNull[iq]=h=newEtaBinHisto(
"EpsNull_"+Q,
"EpsNull , Q="+Q,
"Eps_null");
114 h->SetMarkerStyle(21+iq*4);
116 hALfin[iq]=h=newEtaBinHisto(
"finAL_"+Q,
"AL (polBeamEta) , Q="+Q,
"A_L");
117 h->SetMarkerStyle(21+iq*4);
121 hBeta[iq]=(TH1F *)fdBG->Get(
"beta"+Q+
"_"+bgYear); assert(hBeta);
124 printf(
"\n\n ========== PHASE_I =========== Q=%s\n",Q.Data());
128 for(
int starPhysEtaBin=1; starPhysEtaBin<=mxEta; starPhysEtaBin++) {
129 printf(
"\n------------ processing Q=%s ------- starEtaBin=%d ------\n",Q.Data(),starPhysEtaBin);
132 TH1F *hData=(TH1F *)fdData->Get(Form(
"Eta%d/AEta%dspinY2_",starPhysEtaBin,starPhysEtaBin)+Q); assert(hData);
133 TH1F *hDataE=(TH1F *)fdData->Get(Form(
"Eta%d/AEta%dspinEY2_",starPhysEtaBin,starPhysEtaBin)+Q); assert(hDataE);
136 if(addEndcap && ( starPhysEtaBin==5 )) hData->Add(hDataE);
137 if( starPhysEtaBin==7 || starPhysEtaBin==6) {
138 if (addEndcap ) hData=hDataE;
144 double beta =hBeta[iq] ->GetBinContent(starPhysEtaBin);
145 double betaErr=hBeta[iq] ->GetBinError(starPhysEtaBin);
148 if(beta<0.1) {printf(
"changed beta WARN\n"); beta=0.9;}
149 double alpha1=0, alpha2=0;
150 double alphaErr1=0, alphaErr2=0;
156 printf(
"raw Wyields iQ=%d starEtaBin%d: ",iq,starPhysEtaBin);
159 for(
int is=0; is<mxSS; is++) {
160 double val= hData->GetBinContent(kA[is]+1);
161 if (val<minYieldPerSpin) skipBin++;
162 M[is]=val/ rLumi[is];
163 VM[is]=val/ rLumi[is]/ rLumi[is];
165 SumYieldPerSpin[iq][starPhysEtaBin-1][is]=M[is];
167 printf(
" %.0f ",val);
170 printf(
" sumN=%.1f skipBin=%d\n",sum,skipBin);
171 if(skipBin) { printf(
" SKIP this starEtaBin due to low stats\n");
continue;}
172 printf(
"alpha1: %.4f +/- %.4f, ",alpha1, alphaErr1);
173 printf(
"alpha2: %.4f +/- %.4f, ",alpha2, alphaErr2);
174 printf(
"beta: %.4f +/- %.4f\n",beta,betaErr);
176 hNused[iq]->SetBinContent(starPhysEtaBin,sum);
181 if(starPhysEtaBin!=8) {
182 printf(
"..................... AL for beam 1 \n");
183 computeAL(pol1, alpha1,alphaErr1, beta,betaErr,
184 M[0]+ M[1], M[2]+ M[3],
185 VM[0]+VM[1], VM[2]+VM[3], A, sA);
186 hAL1[iq]->SetBinContent(starPhysEtaBin,A);
187 hAL1[iq]->SetBinError (starPhysEtaBin,sA);
189 printf(
"..................... AL for beam 2 \n");
190 computeAL(pol2, alpha2,alphaErr2, beta,betaErr,
191 M[0]+ M[2], M[1]+ M[3],
192 VM[0]+VM[2], VM[1]+VM[3], A, sA);
193 hAL2[iq]->SetBinContent(starPhysEtaBin,A);
194 hAL2[iq]->SetBinError (starPhysEtaBin,sA);
196 printf(
"..................... AL for beam 1+2 over Barrel \n");
197 doEps_II( M[0], M[3], M[1]+ M[2],
198 VM[0], VM[3], VM[1]+VM[2], eps, sEps);
199 printf(
"epsALsym= %.3f $\\pm$ %.3f nSig=%.2f \n", eps, sEps, eps/ sEps);
201 doPolBckgCorr(eps, sEps,(pol1+pol2)/2., alpha1, alphaErr1, beta, betaErr, A, sA);
202 printf(
"ALsym=%.3f +/- %.3f nSig=%.2f\n", A, sA, A/sA);
203 hAL1[iq]->SetBinContent(starPhysEtaBin,A);
204 hAL1[iq]->SetBinError (starPhysEtaBin,sA);
207 printf(
"..................... ALL for beam 1*2 \n");
209 computeAL(pol1*pol2, 0. , 0., beta,betaErr,
210 M[0]+ M[3], M[1]+ M[2],
211 VM[0]+VM[3], VM[1]+VM[2], A, sA);
213 hALL[iq]->SetBinContent(starPhysEtaBin,A);
214 hALL[iq]->SetBinError (starPhysEtaBin,sA);
217 printf(
"..................... EpsNULL \n");
218 doEps_II( M[1], M[2], M[0]+ M[3],
219 VM[1], VM[2], VM[0]+VM[3], eps, sEps);
220 printf(
"epsNull_not= %.3f $\\pm$ %.3f nSig=%.2f \n", eps, sEps, eps/ sEps);
221 hEpsNull[iq]->SetBinContent(starPhysEtaBin,eps);
222 hEpsNull[iq]->SetBinError (starPhysEtaBin,sEps);
229 printf(
"\n\n ========== PHASE_II =========== Q=%s\n",Q.Data());
233 for (
int k=10;k <=20; k++) {
234 printf(
"\n........ processing iQ=%d ..... polBeamEtaBin=%d ....\n",iq,k);
237 if(k==20) { k1=8; k2=-999; }
240 if(k1>0) N1 = hNused[iq]->GetBinContent(k1);
241 if(k2>0) N2 = hNused[iq]->GetBinContent(k2);
242 hNused[iq]->SetBinContent(k,N1+N2);
243 if(N1+N2<=0)
continue;
245 printf(
"..................... AL from both beams \n");
246 doOneBinAverage(k1,k2, hAL1[iq], hAL2[iq],k, hALfin[iq]);
248 printf(
"..................... ALL from both beams \n");
249 doOneBinAverage(k1,k2, hALL[iq], hALL[iq],k, hALL[iq]);
250 printf(
"..................... EpsNull from both beams \n");
251 doOneBinAverage(k1,k2, hEpsNull[iq], hEpsNull[iq],k, hEpsNull[iq]);
259 TString outName=inpCore+
".wasy.hist.root";
260 TFile *fdOut=
new TFile(outName,
"recreate"); assert(fdOut->IsOpen());
262 for(
int iq=0; iq<mxQ; iq++) {
263 if(skipWminus && iq==1)
continue;
265 makeNiceSummaryPlotPerBeam(inpCore, iq);
266 makeNiceSummaryPlotSumBeam(inpCore, iq);
267 printNiceTable(inpCore, iq, pol1, pol2);
269 hEpsNull[iq]->Write();
285 void doOneBinAverage(
int k1,
int k2, TH1F *h1, TH1F *h2,
int k, TH1F *hfin) {
286 double A1=0, A2=0, sA1=0, sA2=0, N1=0, N2=0;
287 double A1=0, A2=0, sA1=0, sA2=0;
289 A1 = h1->GetBinContent(k1);
290 sA1= h1->GetBinError(k1);
293 A2 = h2->GetBinContent(k2);
294 sA2= h2->GetBinError(k2);
296 double A=999,sA=0.01;
297 averageTwoValues(A1,sA1, A2,sA2, A,sA);
298 printf(
" k=%d k1=%d k2=%d -> A=%.3f +/-%.3f\n",k,k1,k2,A,sA);
299 hfin->SetBinContent(k,A);
300 hfin->SetBinError(k,sA);
305 void averageTwoValues(
double x,
double sx,
double y,
double sy ,
double &A,
double &sA) {
306 printf(
"X=%.3f sX=%.3f; Y=%.3f sY=%.3f\n",x,sx,y,sy);
307 if( sx<=0.) { A=y; sA=sy;
return; }
308 if( sy<=0.) { A=x; sA=sx;
return; }
314 sA=sqrt(wx*wx*sx*sx +wy*wy*sy*sy);
315 printf(
"wx=%f wy=%f --> A=%f\n",wx,wy,A);
321 void computeAL(
double pol,
double alpha,
double alphaErr,
double beta,
double betaErr,
322 double Ma,
double Mb,
double VMa,
double VMb,
double &A,
double &sA) {
323 printf(
"computeAL: pol=%.3f Ma+Mb=%.1f\n",pol, Ma+Mb);
324 printf(
"alpha: %.4f +/- %.4f , ",alpha, alphaErr);
325 printf(
"beta: %.4f +/- %.4f\n",beta,betaErr);
326 printf(
"Ma=%.1f Va=%.1f; ",Ma, VMa); printf(
" Mb=%.1f Vb=%.1f\n",Mb, VMb);
329 doEps_I( Ma, Mb, VMa, VMb , eps, sEps );
330 printf(
"eps= %.3f $\\pm$ %.3f nSig=%.2f sig(eps)*sqrt(Ma+Mb)=%.3f\n", eps, sEps, eps/ sEps , sEps*sqrt(Ma+Mb));
332 doPolBckgCorr(eps, sEps, pol, alpha, alphaErr, beta, betaErr, A, sA);
333 printf(
"A=%.3f +/- %.3f nSig=%.2f\n", A, sA, A/sA);
338 void doEps_I(
double a,
double b,
double va,
double vb,
339 double &eps,
double &sEps) {
340 printf(
"doEps_I: Ma=%f Mb=%f\n",a,b);
343 double xx=b*b*va+ a*a*vb;
344 sEps= sqrt( 4 * xx/sum/sum/sum/sum);
350 void doEps_II(
double a,
double b,
double c,
double Va,
double Vb,
double Vc,
351 double &eps,
double &sEps) {
352 printf(
"doEps_II: Ma=%f Mb=%f Mc=%f\n",a,b,c);
356 double vEps=(4*a*c*Vb + c*c*(Va + Vb) + b*b*(4*Va + Vc) +
357 a*a*(4*Vb + Vc) + b*(4*c*Va - 2*a*Vc))/sum/sum/sum/sum;
364 void doPolBckgCorr(
double eps,
double sEps,
double P,
365 double a,
double sa,
double b,
double sb,
366 double &AL,
double &sAL) {
369 double v1=sEps*sEps/P/P;
371 double v3=AL*AL*sb*sb;
372 sAL=sqrt(v1+v2+v3)/b;
377 void splitPadX(
float x, TPad **cL, TPad **cR) {
378 (*cL) =
new TPad(
"padL",
"apdL",0.0,0.,x,0.95);
380 (*cR) =
new TPad(
"padL",
"apdL",x+0.005,0.,1.0,0.95);
385 void splitPadY(
float y, TPad **cU, TPad **cD) {
386 (*cU) =
new TPad(
"padD",
"apdD",0,y+0.005,1.0,1.);
388 (*cD) =
new TPad(
"padU",
"apdU",0.0,0.,1.,y);
398 TPad *makeTitle(TCanvas *c,TString core) {
400 TPad *pad0 =
new TPad(
"pad0",
"apd0",0.0,0.95,1.,1.);
404 TPaveText *pt =
new TPaveText(0,0.,1,1,
"br");
416 pad =
new TPad(
"pad1",
"apd1",0.0,0.0,1,.95);
426 void makeNiceSummaryPlotPerBeam(TString inpCore,
int iq) {
427 TString Q=
"P";
if (iq) Q=
"N";
429 TString titC1=inpCore+
"one Q="+Q;
430 can=
new TCanvas(titC1, titC1,600,720);
431 gStyle->SetOptStat(0);
432 TPad *c=makeTitle(can,inpCore+
" Q="+Q+
", perBeam");
435 ln=
new TLine(0,0,10,0); ln->SetLineStyle(1);ln->SetLineColor(kBlue);
437 float yMx=1.05, xMx=8.4;
438 bxEE=
new TBox(6.5,-yMx,xMx,yMx);
439 bxEE->SetFillColor(15); bxEE->SetFillStyle(3944);
442 TH1F *hX[4]= {hAL1[iq],hALL[iq],hAL2[iq],hEpsNull[iq]};
443 for(
int ih=0;ih<4;ih++) {
446 hX[ih]->Draw(); hX[ih]->SetAxisRange(0,xMx);
447 hX[ih]->SetMinimum(-yMx); hX[ih]->SetMaximum(yMx);
448 TAxis *ax=hX[ih]->GetXaxis();
449 ax->SetTitle(
"STAR #eta bins "); ax->SetTitleSize(0.06); ax->SetTitleOffset(0.8);
450 ax->SetLabelSize(0.05);
455 ar=
new TArrow(0.6,-yMx*.9,6.3,-yMx*.9, 0.025); ar->Draw(); ar->SetLineColor(8);
456 tx1=
new TLatex(0.8,-yMx*.8,
"-0.9"); tx1->Draw(); tx1->SetTextColor(8);
457 tx1=
new TLatex(5.5,-yMx*.8,
"+1.3"); tx1->Draw();tx1->SetTextColor(8);
458 tx1=
new TLatex(8.1,yMx*.8,
"Barrel"); tx1->Draw();tx1->SetTextAngle(90);
459 tx1=
new TLatex(7.1,yMx*.74,
"+Endcap"); tx1->Draw();tx1->SetTextAngle(90);
461 ar=
new TArrow(0.6,-yMx*.9,6.3,-yMx*.9, 0.025,
"<"); ar->Draw(); ar->SetLineColor(8);
462 tx1=
new TLatex(0.8,-yMx*.8,
"+0.9"); tx1->Draw();tx1->SetTextColor(8);
463 tx1=
new TLatex(5.5,-yMx*.8,
"-1.3"); tx1->Draw();tx1->SetTextColor(8);
464 tx1=
new TLatex(7.1,yMx*.75,
"-Endcap"); tx1->Draw();tx1->SetTextAngle(90);
467 tx1=
new TLatex(3.1,-yMx*.8,
"polBeam #eta"); tx1->Draw();tx1->SetTextColor(8);
479 void makeNiceSummaryPlotSumBeam(TString inpCore,
int iq) {
481 TString Q=
"P";
if (iq) Q=
"N";
482 ln=
new TLine(9,0,21,0); ln->SetLineStyle(1);ln->SetLineColor(kBlue);
484 TString titC1=inpCore+
"sum Q="+Q;
485 can=
new TCanvas(titC1, titC1,700,700);
486 gStyle->SetOptStat(0);
487 TPad *c=makeTitle(can,inpCore+
" Q="+Q+
", sumBeam");
489 TPad *cL,*cR; splitPadX(0.5,&cL,&cR);
493 TAxis *ax=h->GetXaxis();
494 ax->SetTitle(
"polBeam #eta bins "); ax->SetTitleSize(0.06); ax->SetTitleOffset(0.73);
495 ax->SetLabelSize(0.05);
498 float yMx=1.05, x1=9.5, x2=20.4;
499 bxEE=
new TBox(18.5,-yMx,x2,yMx); bxEE->SetFillColor(15); bxEE->SetFillStyle(3944);
500 bxEF=
new TBox(x1,-yMx,10.5,yMx); bxEF->SetFillColor(15); bxEF->SetFillStyle(3944);
502 h->Draw(); h->SetAxisRange(x1,x2);
503 h->SetMinimum(-yMx); h->SetMaximum(yMx);
505 bxEE->Draw(); bxEF->Draw(); ln->Draw();
506 ar=
new TArrow(10.6,-yMx*.85,18.3,-yMx*.85, 0.025); ar->Draw(); ar->SetLineColor(8);
507 tx1=
new TLatex(10.8,-yMx*.8,
"-1.3"); tx1->Draw(); tx1->SetTextColor(8);
508 tx1=
new TLatex(17.1,-yMx*.8,
"+1.3"); tx1->Draw();tx1->SetTextColor(8);
509 tx1=
new TLatex(12.5,-yMx*.8,
"polBeam #eta"); tx1->Draw();tx1->SetTextColor(8);
510 tx1=
new TLatex(20.1,yMx*.8,
"Barrel"); tx1->Draw();tx1->SetTextAngle(90);
511 tx1=
new TLatex(19.1,yMx*.74,
"+Endcap"); tx1->Draw();tx1->SetTextAngle(90);
512 tx1=
new TLatex(10.1,yMx*.75,
"-Endcap"); tx1->Draw();tx1->SetTextAngle(90);
517 TH1F *hWAL=fdWAL->Get(
"modW_AL_"+Q); assert(hWAL);
521 cR->cd(); cR->Divide(1,2);
525 TPad *cRL,*cRR; splitPadX(0.5,&cRL,&cRR);
527 for(
int jj=0;jj<2;jj++) {
528 h=(TH1F*)hALL[iq]->
Clone();
531 h=(TH1F*)hEpsNull[iq]->
Clone();
535 gPad->SetLeftMargin(0.20);
538 ax->SetTitle(
"polBeam #eta bins ");
539 ax->SetTitleSize(txSz); ax->SetTitleOffset(0.65);
540 ax->SetLabelSize(txSz); ax->SetLabelOffset(-0.01);
542 ax->SetLabelSize(txSz);
543 ax->SetTitleSize(txSz); ax->SetTitleOffset(0.99);
544 h->Draw(); h->SetAxisRange(x1,x2);
546 h->SetMinimum(-yMx); h->SetMaximum(yMx);
551 ar=
new TArrow(14.6,yMx*1.05,18.3,yMx*1.05, 0.025); ar->Draw(); ar->SetLineColor(8);
552 tx1=
new TLatex(14.8,yMx*.85,
"0"); tx1->Draw(); tx1->SetTextColor(8);tx1->SetTextSize(txSz);
553 tx1=
new TLatex(17.1,yMx*.85,
"+1.3"); tx1->Draw();tx1->SetTextColor(8);tx1->SetTextSize(txSz);
555 tx1=
new TLatex(20.1,yMx*.8,
"Barrel"); tx1->Draw();tx1->SetTextAngle(90);tx1->SetTextSize(txSz);
556 tx1=
new TLatex(19.1,yMx*.74,
"Endcap"); tx1->Draw();tx1->SetTextAngle(90);tx1->SetTextSize(txSz);
560 TH1F *hWALL=fdWAL->Get(
"modW_ALL_"+Q); assert(hWALL);
567 gPad->SetLeftMargin(0.15);
569 h->Draw(); h->SetAxisRange(0,8.4);
572 ax->SetTitle(
"STAR #eta bins ");
573 ax->SetTitleSize(txSz); ax->SetTitleOffset(0.9);
574 ax->SetLabelSize(txSz); ax->SetLabelOffset(0.01);
576 ax->SetLabelSize(txSz);
577 ax->SetTitleSize(txSz); ax->SetTitleOffset(0.85);
578 h->Draw(
"h text"); h->SetMarkerSize(3.);
579 h->SetFillColor(kBlue);
581 bxEG=
new TBox(6.5,0.1,8.5,1e6); bxEG->SetFillColor(15); bxEG->SetFillStyle(3944);
586 ar=
new TArrow(0.6,1.3,6.3,1.3, 0.025); ar->Draw(); ar->SetLineColor(8);
587 tx1=
new TLatex(0.8,2,
"-0.9"); tx1->Draw(); tx1->SetTextColor(8);
588 tx1=
new TLatex(5.5,2,
"+1.3"); tx1->Draw();tx1->SetTextColor(8);
589 tx1=
new TLatex(8.1,3,
"Barrel"); tx1->Draw();tx1->SetTextAngle(90); tx1->SetTextColor(8);
590 tx1=
new TLatex(7.1,3,
"Endcap"); tx1->Draw();tx1->SetTextAngle(90); tx1->SetTextColor(8);
591 tx1=
new TLatex(3.1,2,
"STAR #eta"); tx1->Draw();tx1->SetTextColor(8); tx1->SetTextColor(8);
599 void printNiceTable(TString inpCore,
int iq,
double pol1=0.5,
double pol2=0.5 ) {
600 TString Q=
"P";
if (iq) Q=
"N";
602 printf(
"\n******* W(eta) summary for charge=%s INPUT=%s *********\n",Q.Data(), inpCore.Data());
604 printf(
"lumi-corrections: ");
605 for(
int is=0; is<mxSS; is++)printf(
"%.3f, ",hLumi->GetBinContent(kA[is]+1));
607 printf(
" applied\nstar-bin, sum , yield ++ +- -+ -- , 1/sqrt(sum), beta\n");
608 for(
int starPhysEtaBin=1; starPhysEtaBin<=8; starPhysEtaBin++) {
609 double val=hNused[iq]->GetBinContent(starPhysEtaBin);
611 printf(
"%d %6.0f, ", starPhysEtaBin,val);
612 for(
int is=0; is<mxSS; is++) printf(
"%5.0f ",SumYieldPerSpin[iq][starPhysEtaBin-1][is]);
613 printf(
", %.3f, %.2f\n", 1./sqrt(val), hBeta[iq]->GetBinContent(starPhysEtaBin));
616 printf(
"Spin results: pol1=%.2f pol2=%.2f\npolBeam-bin, events, *** AL ***,sig*sqrt(M)\n",pol1, pol2);
617 for (
int k=10;k <=20; k++) {
618 double eve=hNused[iq]->GetBinContent(k);
619 val=hALfin[iq]->GetBinContent(k);
620 float err=hALfin[iq]->GetBinError(k);
621 printf(
"%d %6.0f %.3f +/- %.3f nSig=%.1f , %.2f\n",k, eve,val,err,fabs(val)/err , err*sqrt(eve));
624 printf(
"polBeam-bin, events,*** ALL *** ,sig*sqrt(M)\n");
625 for (
int k=15;k <=20; k++) {
626 double eve=hNused[iq]->GetBinContent(k);
627 val=hALfin[iq]->GetBinContent(k);
628 val=hALL[iq]->GetBinContent(k);
629 err=hALL[iq]->GetBinError(k);
630 printf(
"%d %6.0f %.3f +/- %.3f nSig=%.1f , %.2f\n",k, eve,val,err,fabs(val)/err , err*sqrt(eve));
632 printf(
"polBeam-bin, events, *** NULL *** \n");
633 for (
int k=15;k <=20; k++) {
634 double eve=hNused[iq]->GetBinContent(k);
635 val=hEpsNull[iq]->GetBinContent(k);
636 err=hEpsNull[iq]->GetBinError(k);
637 err=hALL[iq]->GetBinError(k);
638 printf(
"%d %6.0f %.3f +/- %.3f nSig=%.1f \n",k, eve,val,err,fabs(val)/err );
641 printf(
"\******* end ************** charge=%s ********\n",Q.Data());
645 void saveEtaSpectra(
int iq) {
646 TString Q=
"P";
if (iq) Q=
"N";
647 c3=
new TCanvas(
"etaYiled_"+Q,
"etaYield_"+Q);
650 TGraphErrors *gr=
new TGraphErrors;
651 gr->SetName(
"finEta_"+Q);
652 gr->SetTitle(
"final W Q=P+N yield ; average STAR #eta #\pm bin rms; events");
658 for(
int starPhysEtaBin=1; starPhysEtaBin<=mxEta; starPhysEtaBin++) {
660 TH1F *hEta=(TH1F *)fdData->Get(Form(
"Eta%d/AEta%dspinLepEta_",starPhysEtaBin,starPhysEtaBin)+Q); assert(hEta);
661 TH1F *hEtaE=(TH1F *)fdData->Get(Form(
"Eta%d/AEta%dspinELepEta_",starPhysEtaBin,starPhysEtaBin)+Q); assert(hEtaE);
662 hEtaE->SetFillColor(24);
664 hEta->Rebin(4);hEtaE->Rebin(4);
665 c3->cd(starPhysEtaBin); gPad->SetBottomMargin(0.15);
666 if( starPhysEtaBin==6 || starPhysEtaBin ==7) hEta=hEtaE;
668 if( starPhysEtaBin==5) { hEta->Add(hEtaE);hEtaE->Draw(
"same"); }
669 float eveEta= hEta->GetEntries();
670 float avrEta= hEta->GetMean();
671 float rmsEta= hEta->GetRMS();
672 printf(
"etaBin=%d eve=%d Eta=%.3f +/- %.3f\n",starPhysEtaBin,eveEta, avrEta, rmsEta);
673 ttx=
new TLatex(-1,yyMx*0.85,Form(
"%.0f eve, #eta= %.2f",eveEta,avrEta));
674 ttx->Draw();ttx->SetTextSize(1.5*txSz);ttx->SetTextColor(kBlue);
675 gr->SetPoint(starPhysEtaBin-1,avrEta,eveEta);
676 gr->SetPointError(starPhysEtaBin-1,rmsEta,sqrt(eveEta));
677 hEta->SetMaximum(yyMx);
678 hEta->SetLineWidth(2);
681 ax->SetTitleSize(txSz); ax->SetTitleOffset(0.9);
682 ax->SetLabelSize(txSz); ax->SetLabelOffset(0.01);
684 ax->SetLabelSize(txSz);
685 ax->SetTitleSize(txSz); ax->SetTitleOffset(0.85);
688 hEta->Write() ; hEta->SetAxisRange(-1.1,1.6);
692 c3->cd(9); gr->Draw(
"A P");
virtual TObject * Clone(const char *newname="") const
the custom implementation fo the TObject::Clone