4 char *cutL[mxC]={
"All",
"Pt1",
"Pt2",
"Pt3",
"Pt4",
"Pt5",
"Pt6",
"PtL",
"PtM",
"PtH",
"EtaBB",
"EtaBc",
"EtaFc",
"EtaFF",
"Qpos",
"Qneg"};
7 char *ampL[mxAmp]={
"a1:P",
"-b1:Q",
"c0:PQ",
"c2:PQ",
"a0",
"a2",
"b0",
"b2",
"c1"};
10 TGraphErrors * grL[mxGr];
18 addFills( TString outPath=
"defaultB-H/") {
19 TString inpDir=
"/star/data04/sim/balewski/LcpRun2/maxEta1.0/";
21 char *fillL=
" F2258 F2266 F2161 ";
24 fillL=
" F2053 F2075 F2076 F2083 F2095 F2102 F2105 F2110 F2116 F2127 F2132 F2134 F2135 F2136 F2147 F2153 F2161 F2162 F2175 F2178 F2181 F2185 F2187 F2192 F2193 F2196 F2201 F2207 F2208 F2212 F2216 F2222 F2235 F2246 F2251 F2257 F2258 F2266 F2269 F2275 F2277 F2281 F2289 F2290 F2301 F2303 F2304";
26 gStyle->SetPalette(1,0);
27 gStyle->SetOptStat(1111);
28 gROOT->LoadMacro(
"getPol.C");
30 createHistTgr(
"final/"+outPath+
"asyVer1.hist.root");
32 char *fill=strtok(fillL,
" ");
36 TString fname=inpDir+outPath+
"r"+fill+
".hist.root";
37 TFile * inpH=
new TFile(fname);
38 assert(inpH->IsOpen());
40 printf(
"#fail %s does not open, skip\n",fname.Data());
46 int xFill=atoi(fill+1);
50 }
while(fill=strtok(0,
" "));
56 for(icut=0;icut<mxC;icut++) {
58 plotTG(cut,3,
"final/"+outPath);
65 if(outH->Get(grL[i]->GetName()))
continue;
77 TGraphErrors * fetchTG(TString name) {
81 for(i=0;i<nGr && gr==0;i++) {
82 if(!name.Contains(grL[i]->GetName()))
continue;
92 void sortCoef(TFile *inp,
int xFill){
93 assert(inp->IsOpen());
96 getPol(xFill,P,Q,eP,eQ);
99 ePQ=PQ*sqrt(eP*eP/P/P +eQ*eQ/Q/Q);
102 int cLum=
true, cP=
true, cQ=
true,cPQ=
true;
103 if(xFill<2189) cLum=
false;
104 if(P<minPol) cP=
false;
105 if(Q<minPol) cQ=
false;
106 if(PQ<minPol2) cPQ=
false;
107 printf(
" logic cL=%d cP=%d cQ=%d cPQ=%d\n",cLum,cP,cQ,cPQ);
111 for(icut=0;icut<mxC;icut++) {
113 char *cut=cutL[icut];
119 sprintf(name,
"r%d*%s",k+1,cut);
121 h[k]=(TH1F *)inp->Get(name);
127 for(ir=0;ir<mxR;ir++) {
128 if( h[ir]==0)
continue;
129 TF1 *ff=h[ir]->GetFunction(
"fCos012");
134 for(ip=0;ip<mxPar;ip++) {
140 if(ir==0 && ip==0 ) { grName=
"a0";
141 }
else if (ir==0 && ip==1 && cP ) { grName=
"a1:P";
144 }
else if (ir==0 && ip==2 ) { grName=
"a2";
145 }
else if (ir==1 && ip==0 ) { grName=
"b0";
146 }
else if (ir==1 && ip==1 && cQ ) { grName=
"-b1:Q";
149 }
else if (ir==1 && ip==2 ) { grName=
"b2";
150 }
else if (ir==2 && ip==0 && cPQ && cLum) { grName=
"c0:PQ";
153 }
else if (ir==2 && ip==1 ) { grName=
"c1";
154 }
else if (ir==2 && ip==2 & cPQ ) { grName=
"c2:PQ";
164 TGraphErrors * gr=fetchTG(grName);
166 double val=ff->GetParameter(ip);
167 double err=ff->GetParError(ip);
168 storeVal(gr,xFill, val,err,pol,ePol);
173 double chi2=ff->GetChisquare();
174 double ndf=ff->GetNDF();
177 sprintf(name,
"chi2R%d*%s",ir+1,cut);
178 TH1F *ho=(TH1F*)fetchTG(name);
189 void createHistTgr(TString fname) {
190 outH=
new TFile(fname,
"RECREATE");
191 assert(outH->IsOpen());
192 printf(
"save outH -->%s\n", fname.Data());
196 char *ampTit[mxAmp]={
"An, ~ cos(#phi), Blue",
"An, ~ cos(#phi), Yellow",
"A#Sigma, no #phi ",
"A#Delta, ~ cos(2#phi)",
197 "a0 -instrumental",
"a2 -instrumental",
198 "b0 -instrumental",
"b2 -instrumental",
201 int ampCol[mxAmp]={kBlue,kYellow,kGreen,kMagenta,kBlack,
202 kBlack,kBlack,kBlack,kBlack};
204 for (ic=0;ic<mxC;ic++) {
205 for (iam=0;iam<mxAmp;iam++) {
207 sprintf(name,
"%s*%s",ampL[iam],cutL[ic]);
209 TGraphErrors *gr =
new TGraphErrors;
211 gr->SetTitle(ampTit[iam]);
212 gr->SetMarkerColor(ampCol[iam]);
213 gr->SetMarkerSize(0.8);
214 gr->SetMarkerStyle(21);
219 for(ir=0;ir<mxR;ir++) {
220 char name[100], tit[200];
221 sprintf(name,
"chi2R%d*%s",ir+1,cutL[ic]);
222 sprintf(tit,
"chi2 for R%d(#Phi), LCP cut=%s",ir+1,cutL[ic]);
224 TH1F *h=
new TH1F(name, tit,20,0,4);
226 grL[nGr++]=(TGraphErrors*)h;
234 void plotTG(
char *cut,
int flag=0, TString plotDir=
"./") {
235 printf(
"plot cut -->%s\n",cut);
237 c=
new TCanvas(cut,cut,900,700);
239 int ampPan[mxAmp]={2,6,9,11,1,3,5,7,10};
240 int chi2Pan[mxR]={4,8,12};
243 for (iam=0;iam<mxAmp;iam++) {
245 sprintf(name,
"%s*%s",ampL[iam],cut);
246 TGraphErrors * gr=fetchTG(name);
248 printf(
"\niam=%d name='%s', N=%d\n",iam,name,n);
256 TF1 *ff=gr->GetFunction(
"pol0");
258 float val=ff->GetParameter(0);
259 float err=ff->GetParError(0);
263 chi2ndf=ff->GetChisquare()/ff->GetNDF();
269 float xSig=fabs(val)/err;
273 printf(
"#ampl= %s , cut= %s , nFill= %d , <y>= %f , sig<y>= %f , xSig= %.1f , nonZero= %c\n",
274 ampL[iam], cut,gr->GetN(), val,err, xSig,cKey);
275 printf(
"## , %s , %s , %f , %f , %f\n",
276 ampL[iam], cut, val,err, chi2ndf);
280 for(ir=0;ir<mxR;ir++) {
282 sprintf(name,
"chi2R%d*%s",ir+1,cut);
283 TH1F *ho=(TH1F*)fetchTG(name);
287 printf(
"%s nE=%d\n",ho->GetName(),ho->GetEntries());
293 TString outFig=plotDir+
"asy";
295 if(flag&1) c->Print(outFig+
".ps");
296 if(flag&2) c->Print(outFig+
".gif");
304 void storeVal(TGraphErrors *gr,
float x,
float y,
float ey,
float fac,
float efac=0){
312 double err=fabs(val)*sqrt(e1*e1+e2*e2);
314 gr->SetPoint(n,x,val);
315 gr->SetPointError(n,.0,err);
327 TGraphErrors * gr=fetchTG(
"a1:P*All");
330 printf(
"\n name='%s', N=%d\n",gr->GetName(),n);
340 TPaveStats *st1 =( TPaveStats *)gPad->GetPrimitive(
"stats");
344 st1 =( TPaveStats *)gPad->GetPrimitive(
"title");
354 void drawFitError( TGraphErrors * gr) {
356 TF1 *ff=gr->GetFunction(
"pol0");
359 ff->SetLineColor(col);
360 ff->SetParName(0,
"avr");
362 float val=ff->GetParameter(0);
363 float err=ff->GetParError(0);
364 float upY=val+err, dwY=val-err;
366 TAxis *ax=gr->GetXaxis();
367 float x1=ax->GetXmin();
368 float x2=ax->GetXmax();
369 ax->SetTitle(
"RHIC FILL \#");
372 TLine *ln0=
new TLine(x1,0.,x2,0.);
375 TLine *upL=
new TLine(x1,upY,x2,upY);
376 TLine *dwL=
new TLine(x1,dwY,x2,dwY);
377 upL->SetLineStyle(3);
378 dwL->SetLineStyle(3);
380 upL->SetLineColor(col);
381 dwL->SetLineColor(col);
387 float xSig=fabs(val)/err;
390 printf(
" nData= %d , <y>= %f , sig<y>= %f , xSig= %.1f , nonZero= %c\n",
391 gr->GetN(), val,err, xSig,cKey);
400 TPaveStats *st1 =( TPaveStats *)gPad->GetPrimitive(
"stats");
405 st1 =( TPaveStats *)gPad->GetPrimitive(
"title");