00001 TFile *outH, *inpH;
00002
00003 const int totC=4;
00004 char *tCutL[totC]={ "Pt16", "PtLMH", "EtaBF", "Qpn"};
00005
00006 const int mxAmp=4;
00007 char *ampL[mxAmp]={"a1:P", "-b1:Q", "c0:PQ", "c2:PQ"};
00008
00009 const int mxGr=200;
00010 TGraphErrors * grL[mxGr];
00011 int nGr=0;
00012 TString wrkDir="final/fixMe/";
00013
00014 endPlot(char *path="") {
00015 wrkDir="final/";
00016 wrkDir+=path;
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031 gStyle->SetOptStat(1111);
00032
00033 createTgr(wrkDir+"endVer1.hist.root");
00034
00035
00036 TString fname=wrkDir+"asyVer1.hist.root";
00037 inpH=new TFile(fname);
00038 assert(inpH->IsOpen());
00039
00040
00041 const int mxC2=6, mxC3=3, mxC4=4, mxC5=2;
00042 char *cut2L[mxC2]={ "Pt1", "Pt2", "Pt3", "Pt4", "Pt5", "Pt6"};
00043 float cut2XM[mxC2]={ 0.7,1.5,2.5,3.5,4.5,5.5};
00044 float cut2XH[mxC2]={ 0.3,.5,.5,.5,.5,.5};
00045 sortCoef(cut2L, mxC2,"Pt16", cut2XM, cut2XH );
00046
00047 char *cut3L[mxC3]={ "PtL", "PtM", "PtH"};
00048 float cut3XM[mxC3]={ 0.55, 0.85, 2.};
00049 float cut3XH[mxC3]={ 0.15, 0.15, 1.};
00050 sortCoef(cut3L, mxC3,"PtLMH", cut3XM, cut3XH );
00051
00052 char *cut4L[mxC4]={ "EtaBB", "EtaBc", "EtaFc", "EtaFF" };
00053 float cut4XM[mxC4]={ -.75, -.25, .25, .75};
00054 float cut4XH[mxC4]={ .25,.25,.25.,.25};
00055
00056
00057 sortCoef(cut4L, mxC4,"EtaBF", cut4XM, cut4XH );
00058
00059 char *cut5L[mxC5]={ "Qneg", "Qpos"};
00060 float cut5XM[mxC5]={ -1, 1};
00061 float cut5XH[mxC5]={ 0., 0.};
00062 sortCoef(cut5L, mxC5,"Qpn", cut5XM, cut5XH );
00063
00064
00065 TGraphErrors *gr;
00066 gr=appendTG("a1:P*Pt16","-b1:Q*Pt16"); gr->SetName("A_n*Pt16");
00067 gr=appendTG("a1:P*PtLMH","-b1:Q*PtLMH");gr->SetName("A_n*PtLMH");
00068 gr=appendTG("a1:P*Qpn","-b1:Q*Qpn");gr->SetName("A_n*Qpn");
00069 gr=appendTG("a1:P*EtaBF","-b1:Q*EtaBF");gr->SetName("A_n*EtaBF");
00070
00071
00072 fetchTG("c0:PQ*Pt16")->SetName("A_s*Pt16");
00073 fetchTG("c0:PQ*PtLMH")->SetName("A_s*PtLMH");
00074 fetchTG("c0:PQ*Qpn")->SetName("A_s*Qpn");
00075 takeModuleEta("c0:PQ*EtaBF","A_s*EtaBF");
00076
00077 fetchTG("c2:PQ*Pt16")->SetName("A_d*Pt16");
00078 fetchTG("c2:PQ*PtLMH")->SetName("A_d*PtLMH");
00079 fetchTG("c2:PQ*Qpn")->SetName("A_d*Qpn");
00080 takeModuleEta("c2:PQ*EtaBF","A_d*EtaBF");
00081
00082 int pl=3;
00083 plotObs("A_n",pl);
00084 plotObs("A_s",pl);
00085 plotObs("A_d",pl);
00086
00087
00088 outH->cd();
00089 int i;
00090 for(i=0;i<nGr;i++) {
00091 if(outH->Get(grL[i]->GetName())) continue;
00092 grL[i]->Write();
00093 }
00094
00095
00096
00097
00098 outH->Write();
00099
00100 return;
00101 }
00102
00103
00104
00105
00106 TGraphErrors * fetchTG(TString name) {
00107
00108 TGraphErrors *gr=0;
00109 int i;
00110 for(i=0;i<nGr && gr==0;i++) {
00111 if(!name.Contains(grL[i]->GetName())) continue;
00112 gr=grL[i];
00113 }
00114 assert(gr);
00115 return gr;
00116 }
00117
00118
00119
00120
00121 void createTgr(TString fname) {
00122 outH=new TFile(fname,"RECREATE");
00123 assert(outH->IsOpen());
00124 printf("save outH -->%s\n", fname.Data());
00125
00126 char *ampTit[mxAmp]={"An", "AnYell", "A#Sigma", "A#Delta"};
00127 int ampCol[mxAmp]={kBlue, kYellow, kGreen, kMagenta};
00128
00129 int ic,iam;
00130 for (ic=0;ic<totC;ic++) {
00131 for (iam=0;iam<mxAmp;iam++) {
00132 char name[100];
00133 sprintf(name,"%s*%s",ampL[iam],tCutL[ic]);
00134
00135 TGraphErrors *gr =new TGraphErrors;
00136 gr->SetName(name);
00137 gr->SetTitle(ampTit[iam]);
00138 gr->SetMarkerColor(ampCol[iam]);
00139 gr->SetMarkerSize(0.8);
00140 gr->SetMarkerStyle(21);
00141 assert(nGr<mxGr);
00142 grL[nGr++]=gr;
00143 }
00144 }
00145 }
00146
00147
00148
00149
00150 TGraphErrors * appendTG(char *basket, char *apple, float eps=0.){
00151
00152 TGraphErrors *gr1=fetchTG(basket);
00153 TGraphErrors *gr2=fetchTG(apple);
00154 int i;
00155 for(i=0;i<gr2->GetN();i++) {
00156 double erX=gr2->GetErrorX(i);
00157 double erY=gr2->GetErrorY(i);
00158 double x,y;
00159 gr2->GetPoint(i,x,y);
00160
00161 int n=gr1->GetN();
00162 gr1->SetPoint(n,x+eps,y);
00163 gr1->SetPointError(n,erX,erY);
00164 }
00165
00166 return gr1;
00167 }
00168
00169
00170
00171 takeModuleEta(char *inp, char *out) {
00172 TGraphErrors *gr= (TGraphErrors *)fetchTG(inp)->Clone();
00173 gr->SetName(out);
00174 int i;
00175
00176
00177 for(i=0;i<gr->GetN();i++) {
00178 double x,y;
00179 gr->GetPoint(i,x,y);
00180 if(x>0) continue;
00181 gr->SetPoint(i,-x,y);
00182 }
00183
00184
00185 assert(nGr<mxGr);
00186 grL[nGr++]=gr;
00187
00188 }
00189
00190
00191
00192 void sortCoef(char **cutL, int nC, char *tCut, float *xMean, float *xErr){
00193
00194 printf("sortCoef(%s)\n",tCut);
00195 int iam=0;
00196
00197 for(iam=0;iam<mxAmp;iam++) {
00198 TString outG=ampL[iam];
00199 outG+="*";
00200 outG+=tCut;
00201 TGraphErrors * grOut=fetchTG(outG);
00202
00203 int ic;
00204 for(ic=0;ic<nC;ic++){
00205 TString inpG=ampL[iam];
00206 inpG+="*";
00207 inpG+=cutL[ic];
00208 printf("%d '%s' -->%s xM=%f xEr=%f\n",ic,cutL[ic],inpG.Data(),xMean[ic], xErr[ic]);
00209 TGraphErrors * gr=(TGraphErrors *)inpH->Get(inpG);
00210 assert(gr);
00211 TF1 *ff=gr->GetFunction("pol0");
00212 if(ff==0) continue;
00213 float val=ff->GetParameter(0);
00214 float err=ff->GetParError(0);
00215 int n=grOut->GetN();
00216 float x=xMean[ic];
00217 if(strstr(inpG.Data(),"-b1:Q*Eta")) x=-x;
00218 grOut->SetPoint(n,x,val);
00219 grOut->SetPointError(n,xErr[ic],err);
00220 }
00221 }
00222 }
00223
00224
00225
00226
00227 void plotObs(char *obs="c0:PQ", int flag=0) {
00228 printf("plot Obs -->%s\n",obs);
00229 char *tCutX[totC]={"pT (GeV/c), 1 GeV/c bins", " pT (GeV/c), rebinned","pseudorapidity", "charge"};
00230
00231 c=new TCanvas(obs,obs,600,500);
00232 c->Divide(2,2);
00233
00234 int it;
00235 for (it=0;it<totC;it++) {
00236 char name[100];
00237 sprintf(name,"%s*%s",obs,tCutL[it]);
00238 TGraphErrors * gr=fetchTG(name);
00239 int n=gr->GetN();
00240 printf("\nit=%d name='%s', N=%d\n",it,name,n);
00241
00242 if(n<=0) continue;
00243 c->cd(1+it);
00244 gr->Draw("AP");
00245 gr->Fit("pol0");
00246
00247 TAxis *ax=gr->GetXaxis();
00248 ax->SetTitle(tCutX[it]);
00249
00250 drawFitError(gr);
00251 c->Update();
00252 modifyLabels();
00253 c->Update();
00254
00255
00256 TF1 *ff=gr->GetFunction("pol0");
00257 assert(ff);
00258 TString aaa="avr"; aaa+=name;
00259 ff->SetName(aaa);
00260
00261 if(strstr(obs,"A_n")) {
00262 sprintf(name,"%s*%s","-b1:Q",tCutL[it]);
00263 TGraphErrors * gr=fetchTG(name);
00264 if(gr->GetN()<=0) continue;
00265 gr->Draw("P");
00266 } else if(strstr(tCutL[it],"EtaBF")) {
00267 if(strstr(obs,"A_s")) sprintf(name,"c0:PQ*EtaBF");
00268 if(strstr(obs,"A_d")) sprintf(name,"c2:PQ*EtaBF");
00269 TGraphErrors * gr=fetchTG(name);
00270 if(gr->GetN()<=0) continue;
00271 gr->Draw("P");
00272 gr->SetMarkerColor(kBlack);
00273 gr->SetMarkerStyle(25);
00274 }
00275
00276
00277 float val=ff->GetParameter(0);
00278 float err=ff->GetParError(0);
00279
00280 float chi2ndf=0;
00281 if (ff->GetNDF()>0)
00282 chi2ndf=ff->GetChisquare()/ff->GetNDF();
00283
00284 float xSig=fabs(val)/err;
00285 char cKey='N';
00286 if(xSig>2) cKey='Y';
00287
00288 printf("## , %s , %s , %f , %f , %f %s\n",
00289 tCutL[it], obs, val,err, chi2ndf,ff->GetName());
00290 }
00291
00292 if(flag<=0) return;
00293 TString outFig=wrkDir+obs;
00294 if(flag&1) c->Print(outFig+".ps");
00295 if(flag&2) c->Print(outFig+".gif");
00296
00297 }
00298
00299
00300
00301 void modifyLabels(){
00302 TPaveStats *st1 =( TPaveStats *)gPad->GetPrimitive("stats");
00303 st1->SetX1NDC(0.4);
00304
00305 st1 =( TPaveStats *)gPad->GetPrimitive("title");
00306 st1->SetX2NDC(0.2);
00307 st1->SetY1NDC(.8);
00308
00309 }
00310
00311
00312
00313 void drawFitError( TGraphErrors * gr) {
00314
00315 int col=kRed;
00316 TF1 *ff=gr->GetFunction("pol0");
00317 assert(ff);
00318
00319 ff->SetLineColor(col);
00320 ff->SetParName(0,"avr");
00321
00322 float val=ff->GetParameter(0);
00323 float err=ff->GetParError(0);
00324 float upY=val+err, dwY=val-err;
00325
00326 TAxis *ax=gr->GetXaxis();
00327 float x1=ax->GetXmin();
00328 float x2=ax->GetXmax();
00329
00330 TLine *ln0=new TLine(x1,0.,x2,0.);
00331 float xlen=x2-x1;
00332 x1+=0.1*xlen;
00333 x2-=0.1*xlen;
00334 TLine *upL=new TLine(x1,upY,x2,upY);
00335 TLine *dwL=new TLine(x1,dwY,x2,dwY);
00336 upL->SetLineStyle(3);
00337 dwL->SetLineStyle(3);
00338
00339 upL->SetLineColor(col);
00340 dwL->SetLineColor(col);
00341
00342 upL->Draw();
00343 dwL->Draw();
00344 ln0->Draw();
00345 }
00346
00347
00348
00349
00350