00001 #include "commonmacro/common.h"
00002 #include "common/Name.cc"
00003 #include "commonmacro/histutil.h"
00004
00005 void fitPts(const char* inName=
00006 "links/P01hi.minbias.2000.hist/hianalysis_1000.hist.root",
00007 const char* psDir="ps",
00008 int cut = 1,
00009 const char* outDir="./",
00010 const char* more = "west",
00011 float extraValue = 0)
00012 {
00013 cout << "--------------------------" << endl;
00014 cout << "in name=" << inName << endl
00015 << "ps dir=" << psDir << endl
00016 << "cut=" << cut << endl;
00017 cout << "--------------------------" << endl;
00018
00019 inRoot = new TFile(inName);
00020
00021 gSystem->Load("StHiMicroEvent");
00022 gSystem->Load("StHiMicroAnalysis");
00023 Cut::SetCut(cut);
00024 Cut::ShowCuts();
00025
00026 if(!inRoot){
00027 cout << "cannot find the infile" << endl;
00028 return;
00029 }
00030 TText* t = new TText;
00031 float ptAry[] = {2,3,4,5,6};
00032 char* ptType[] = { "PtPr","PtGl"};
00033 char* chargeType[]= { "Pos","Neg","PosPlusNeg"};
00034 TH1 *ha, *hb;
00035 TCanvas c1("c1","c1",400,500);
00036 TH3* h3[2][3];
00037 TH2* h2a, *h2b; TH1* h1a, *h1b;
00038 float ptmin=1.5,ptmax=4.0;
00039 char cname[100],ctitle[100];
00040 int nc=2;
00041 int nptType=1;
00042
00043 int fitPtsCut=Cut::mFitPts[0];
00044 float fitptsary[] = { 3,fitPtsCut};
00045 char* fitptstitle[] = { "Wide","Cut"};
00046
00047 gStyle->SetOptStat(0);
00048
00049
00050
00051
00052 for(int iptType=0;iptType<nptType;iptType++){
00053
00054 sprintf(name,"Minus.h3PhiPrFitPts%s",ptType[iptType]);
00055 cout << name << endl;
00056 h3[iptType][0]=(TH3*)inRoot.Get(name);
00057
00058 sprintf(name,"Plus.h3PhiPrFitPts%s",ptType[iptType]);
00059 h3[iptType][1]=(TH3*)inRoot.Get(name);
00060
00061 h3[iptType][2]=(TH3*)h3[iptType][0]->Clone();
00062 sprintf(name,"PlusPlusMinus.h3PhiPrFitPts");
00063 h3[iptType][2]->SetName(name); h3[iptType][2]->SetTitle(name);
00064 h3[iptType][2]->Add(h3[iptType][1]);
00065 }
00066
00067 for(int if=0;if<2; if++){
00068 for(int iptType=0;iptType<nptType;iptType++){
00069
00070
00071 sprintf(cname,"fitPts%s%s",ptType[iptType],
00072 fitptstitle[if]);
00073 sprintf(ctitle,"fit pts, %s slices %d-45 (cut %d)",
00074 ptType[iptType],fitptsary[if],cut);
00075 Divide(&c1,2,2,ctitle,inName);
00076
00077 for(int j=0;j<4;j++){
00078 c1.cd(j+1);
00079 if(j==0){
00080 TLegend l(0.1,0.4,0.3,0.5); l.SetBorderSize(0);
00081 l.SetFillColor(0);
00082 }
00083 for(int ic=0;ic<nc;ic++){
00084 h2a=(TH2*)HistSlice(h3[iptType][ic],"","",0,
00085 ptAry[j],ptAry[j+1],"xy");
00086 h1a=HistSlice(h2a,"",h2a->GetTitle(),0,0,0,"x");
00087 SetRange(h1a->GetXaxis(),fitptsary[if],46);
00088 h1a->SetMarkerSize(0.6);
00089 if(ic<1){
00090 SetMinMax(h1a,0,h1a->GetMaximum()*2.5);
00091 h1a->SetMarkerStyle(4);
00092 h1a->Draw("p");
00093 PrintMeanRms(h1a,0.1,.8);
00094
00095 }
00096 else if (ic==1){
00097 h1a->SetMarkerStyle(8);
00098 h1a->Draw("psame");
00099 PrintMeanRms(h1a,0.1,.7);
00100 }
00101 else if (ic==2){
00102 h1a->SetMarkerStyle(12);
00103 h1a->Draw("psame");
00104 PrintMeanRms(h1a,0.1,.6);
00105 }
00106 if(j==0) l.AddEntry(h1a,chargeType[ic],"p");
00107 }
00108 if(j==0) l.Draw();
00109 }
00110 Print(&c1,psDir,cname);
00111
00112
00113
00114
00115
00116 for(int ic=0;ic<nc;ic++){
00117 sprintf(cname,"fitPts%s%sPhiSlices%s",
00118 ptType[iptType],chargeType[ic],fitptstitle[if]);
00119 sprintf(ctitle,"fit pts %d-45, phi slices (%.1f<%s<%.1f) %s (cut %d)",
00120 fitptsary[if],ptmin,ptType[iptType],ptmax,chargeType[ic],cut);
00121 Divide(&c1,3,4,ctitle,inName);
00122
00123 h2a=(TH2*)HistSlice(h3[iptType][ic],"","",0,
00124 ptmin,ptmax,"xy");
00125 for(int iPhi=1; iPhi<=h2a->GetNbinsY(); iPhi++){
00126 c1.cd(iPhi);
00127 TAxis *axis = h2a->GetYaxis();
00128 sprintf(title,"%d<phi<%d",
00129 axis->GetBinLowEdge(iPhi),axis->GetBinUpEdge(iPhi));
00130 sprintf(name,"%s%s%s%s",
00131 chargeType[ic],ptType[iptType],fitptstitle[if],title);
00132
00133 h1a = h2a->ProjectionX(name,iPhi,iPhi);
00134 h1a->SetMarkerStyle(8); h1a->SetMarkerSize(0.6);
00135 h1a->SetTitle(title); SetRange(h1a->GetXaxis(),fitptsary[if],45.5);
00136 h1a->Draw("p");
00137 PrintMeanRms(h1a,0.1,0.6,0.08);
00138 }
00139 Print(&c1,psDir,cname);
00140
00141 }
00142
00143
00144 for(int ic=0;ic<nc;ic++){
00145 sprintf(cname,"fitPtsMeanVPhi%s%s%s",
00146 ptType[iptType],chargeType[ic],fitptstitle[if]);
00147 sprintf(ctitle,"mean fit pts V phi %d-45 (%.1f<%s<%.1f) %s (cut %d)",
00148 fitptsary[if],ptmin,ptType[iptType],ptmax,chargeType[ic],cut);
00149 Divide(&c1,1,1,ctitle,inName);
00150 c1.cd(1); gPad->SetGridx(); gPad->SetGridy();
00151 h2a=(TH2*)HistSlice(h3[iptType][ic],"","",0,
00152 ptmin,ptmax,"xy");
00153 int low=h2a->GetXaxis()->FindBin(fitptsary[if]);
00154 sprintf(name,"meanVphi%s%s%s",
00155 chargeType[ic],ptType[iptType],fitptstitle[if]);
00156 TProfile *p=h2a->ProfileY(name,low,9999); p->SetTitle("");
00157 SetMinMax(p,30,40);
00158 p->SetMarkerStyle(8);
00159 p->Draw();
00160
00161 Print(&c1,psDir,cname);
00162
00163 }
00164
00165 }
00166 }
00167 }
00168
00169