15 double betaVal[mxQ]={0.936,0.837};
16 double betaErr[mxQ]={0.017, 0.032};
18 double alphaVal[mxQ]={-0.0016, -0.0048};
19 double alphaErr[mxQ]={ 0.0008, 0.0024};
22 int kA[mxSS]={ka,kb,kc,kd};
25 TH1F *hLum=
new TH1F(
"hLum",
"hLum", 50,0.5,50.5);
27 void rdN2AL(TString inpCore=
"run9setP1234") {
28 TString iPath=
"/star/data05/scratch/balewski/2009-Wana-SL09g-p/data/";
34 for(
int iq=0;iq<mxQ;iq++) {
36 if(iq==1) tt1=
"hDataN";
37 hData[iq]=
new TH1F(tt1,tt1,30,0.5,30.5);
38 tt1=
"hAsyP";
char *tt2=
"Positive charge";
39 if(iq==1){ tt1=
"hAsyN"; tt2=
"Negative charge";}
40 hAsy[iq]=
new TH1F(tt1,tt2,7,0,7);
41 hAsy[iq]->GetXaxis()->SetLabelSize(0.065);
42 hAsy[iq]->SetLineWidth(2);
43 char *key[]={
"AL blue",
"AL yell",
"AL avr",
"ALL",
"null test",
"AL* "};
44 for(
int i=0;i<6;i++) hAsy[iq]->Fill(key[i],0.);
45 hAsy[iq]->SetMinimum(-0.95); hAsy[iq]->SetMaximum(0.95);
48 TString fullOutName=oPath+inpCore+
".wasy.hist.root";
50 TString fullInpName=iPath; fullInpName+=inpCore;
51 fullInpName+=
".wana.hist.root";
52 fd=
new TFile(fullInpName);
54 printf(
"EROR: input histo file not found, quit\n",fullInpName.Data());
57 printf(
"Opened: %s\n",fullInpName.Data());
63 for(
int iq=0;iq<mxQ;iq++) {
64 printf(
"........processing iQ=%d .....\n",iq);
65 getSignal(fd,iq,
"AspinY2");
70 fdo=
new TFile(fullOutName,
"recreate"); assert(fdo->IsOpen());
78 can=
new TCanvas(inpCore, inpCore,500,400);
79 gStyle->SetOptStat(0);
80 TPad *c=makeTitle(can,(iPath+inpCore).Data());
81 c->SetFillColor(kWhite);
83 ln=
new TLine(0,0,7,0); ln->SetLineStyle(2);
85 for(
int iq=0;iq<mxQ;iq++) {
86 c->cd(1+iq); hAsy[iq]->Draw(); ln->Draw();
87 gPad->SetFillStyle(0);
88 TString tt=hAsy[iq]->GetTitle(); tt+=
", unpol yield=";
89 float sum=hData[iq]->GetBinContent(5); tt+=(int)sum;
90 hAsy[iq]->SetTitle(tt);
93 int myMark[mxQ][5]={{21,28,25},{20,28,24}};
94 for(
int kk=2; kk<=4;kk++) {
95 hx=(TH1*) hAsy[iq]->Clone();
96 hx->Draw(
"same"); hx->SetMarkerSize(2);
97 hx->SetAxisRange(kk,kk);
99 hx->SetMarkerStyle(myMark[iq][kk-2]);
108 void getLumi( TFile *fd) {
109 TH1F *h1=fd->Get(
"AspinY1"); assert(h1);
112 for(
int k=1; k<=4; k++ ){
113 double y= h1->GetBinContent(kA[k-1]+1);
115 hLum->SetBinContent(k,y);
117 hLum->SetBinContent(5,sum);
119 printf(
" lum total=%.0f\n", sum);
121 for(
int k=1; k<=4; k++ ){
122 double y= hLum->GetBinContent(k);
123 printf(
"k=%d %.0f %.4f (spin4=%d)\n",k,y, y/sum,kA[k-1]);
124 hLum->SetBinContent(k+10,y/sum);
126 hLum->SetBinContent(6,pol1);
127 hLum->SetBinContent(7,pol2);
128 printf(
"Polarization beam_1=%.3f beam_2=%.3f\n", pol1, pol2);
136 void getSignal( TFile *fd,
int iq,
char *hcore) {
138 if(iq==0) hname+=
"_P";
139 if(iq==1) hname+=
"_N";
140 TH1F *h1=fd->Get(hname); assert(h1);
142 double sum=0, sumL=0;
143 for(
int k=1; k<=4; k++ ){
144 double y= h1->GetBinContent(kA[k-1]+1);
146 if(k==1 && iq==0) y+=4;
147 if(k==2 && iq==0) y+=3;
148 if(k==3 && iq==0) y+=1;
149 if(k==4 && iq==0) y+=2;
150 if(k==2 && iq==1) y+=2;
151 if(k==3 && iq==1) y+=1;
154 printf(
"k=%d yield=%.0f\n",k,y);
157 hData[iq]->SetBinContent(k,y);
158 double L= hLum->GetBinContent(k+10);
160 double syL=sqrt(y)/L;
162 hData[iq]->SetBinContent(k+10,yL);
163 hData[iq]->SetBinError(k+10,syL);
165 hData[iq]->SetBinContent(5,sum);
166 hData[iq]->SetBinContent(15,sumL);
173 void computeAsy(
int iq) {
177 double P1=hLum->GetBinContent(6);
178 double P2=hLum->GetBinContent(7);
180 double beta=betaVal[iq], sBeta=betaErr[iq];
181 double alpha=alphaVal[iq], sAlpha=alphaErr[iq];
184 double Ma=hD->GetBinContent(11), sMa=hD->GetBinError(11), VMa=sMa*sMa;
185 double Mb=hD->GetBinContent(12), sMb=hD->GetBinError(12), VMb=sMb*sMb;
186 double Mc=hD->GetBinContent(13), sMc=hD->GetBinError(13), VMc=sMc*sMc;
187 double Md=hD->GetBinContent(14), sMd=hD->GetBinError(14), VMd=sMd*sMd;
189 printf(
" yield total=%.0f S/(S+B)=%.2f +/-%f alpha=%f +/-%f\n", Ma+Mb+Mc+Md,beta,sBeta,alpha,sAlpha);
192 double eps, sEps, AL,sAL;
194 doEps_I( Ma+ Mb, Mc+ Md,
195 VMa+VMb, VMc+VMd, eps, sEps );
197 doPolBckgCorr(eps, sEps, P1, alpha, sAlpha, beta, sBeta,
199 hD->SetBinContent(21,eps); hA->SetBinContent(1,AL);
200 hD->SetBinError (21,sEps); hA->SetBinError (1,sAL);
202 printf(
"AL(1) %.3f %.3f nSig=%.2f\n", AL, sAL, AL/sAL);
205 doEps_I( Ma+ Mc, Mb +Md,
206 VMa+VMc, VMb+VMd, eps, sEps );
208 doPolBckgCorr(eps, sEps, P2, alpha, sAlpha, beta, sBeta,
211 hD->SetBinContent(22,eps); hA->SetBinContent(2,AL);
212 hD->SetBinError (22,sEps); hA->SetBinError (2,sAL);
214 printf(
"AL(2) %.3f %.3f nSig=%.2f\n", AL, sAL, AL/sAL);
217 doEps_II( Ma, Md, Mb +Mc,
218 VMa, VMd, VMb+VMc, eps, sEps );
219 doPolBckgCorr(eps, sEps, (P1+P2)/2., alpha, sAlpha, beta, sBeta,
222 hD->SetBinContent(23,eps); hA->SetBinContent(3,AL);
223 hD->SetBinError (23,sEps); hA->SetBinError (3,sAL);
225 printf(
"AL(1+2) %.3f $\\pm$ %.4f nSig=%.2f\n", AL, sAL, AL/sAL);
228 doEps_I( Ma+ Md, Mb +Mc,
229 VMa+VMd, VMb+VMc, eps, sEps );
231 doPolBckgCorr(eps, sEps, P2*P2, alpha, sAlpha, beta, sBeta,
235 hD->SetBinContent(24,eps); hA->SetBinContent(4,ALL);
236 hD->SetBinError (24,sEps); hA->SetBinError (4,sALL);
238 printf(
"ALL(reg) %.2f %.2f nSig=%.1f\n", ALL, sALL, ALL/sALL);
242 VMb, VMc, eps, sEps );
244 hD->SetBinContent(25,eps); hA->SetBinContent(5,eps);
245 hD->SetBinError (25,sEps); hA->SetBinError (5,sEps);
246 printf(
"eps5= Null %.3f $\\pm$ %.3f nSig=%.2f\n", eps, sEps, eps/ sEps );
250 VMa, VMd, eps, sEps );
251 doPolBckgCorr(eps, sEps, (P1+P2), alpha, sAlpha, beta, sBeta,
254 hD->SetBinContent(26,eps); hA->SetBinContent(6,AL);
255 hD->SetBinError (26,sEps); hA->SetBinError (6,sAL);
257 printf(
"AL*(eps6) %.3f %.3f nSig=%.1f\n", AL, sAL, AL/sAL);
262 void doEps_I(
double a,
double b,
double va,
double vb,
263 double &eps,
double &sEps) {
266 double xx=b*b*va+ a*a*vb;
267 sEps= sqrt( 4 * xx/sum/sum/sum/sum);
271 void doEps_II(
double a,
double b,
double c,
double Va,
double Vb,
double Vc,
272 double &eps,
double &sEps) {
275 double vEps=(4*a*c*Vb + c*c*(Va + Vb) + b*b*(4*Va + Vc) +
276 a*a*(4*Vb + Vc) + b*(4*c*Va - 2*a*Vc))/sum/sum/sum/sum;
281 void doPolBckgCorr(
double eps,
double sEps,
double P,
double a,
double sa,
double b,
double sb,
282 double &AL,
double &sAL) {
284 double v1=sEps*sEps/P/P;
286 double v3=AL*AL*sb*sb;
287 sAL=sqrt(v1+v2+v3)/b;
292 Void splitPadX(
float x, TPad **cL, TPad **cR) {
293 (*cL) =
new TPad(
"padL",
"apdL",0.0,0.,x,0.95);
295 (*cR) =
new TPad(
"padL",
"apdL",x+0.005,0.,1.0,0.95);
300 TPad *makeTitle(TCanvas *c,
char *core) {
302 TPad *pad0 =
new TPad(
"pad0",
"apd0",0.0,0.95,1.,1.);
306 TPaveText *pt =
new TPaveText(0,0.,1,1,
"br");
318 pad =
new TPad(
"pad1",
"apd1",0.0,0.0,1,.95);