00001 #include "common/Name.cc"
00002 #include "commonmacro/histutil.h"
00003 #include "commonmacro/common.h"
00004 void meanDca(const char* inName=
00005 "links/P01hi.minbias.2000.hist/hianalysis_1000.hist.root",
00006 const char* psDir="ps",
00007 int cut = 1,
00008 const char* outDir="./",
00009 const char* more = "",
00010 float extraValue = 1)
00011
00012 {
00013
00014 cout << "--------------------------" << endl;
00015 cout << "in name=" << inName << endl
00016 << "ps dir=" << psDir << endl
00017 << "cut=" << cut << endl;
00018 cout << "--------------------------" << endl;
00019
00020 inRoot = new TFile(inName);
00021
00022 if(!inRoot){
00023 cout << "cannot find the infile" << endl;
00024 return;
00025 }
00026 TCanvas c1("c1","c1",400,525);
00027 TString sName,sTitle;
00028 const int nPtType=1;
00029 const int nChargeType=4;
00030 const int nZperHalf=4;
00031 const int nType=2;
00032
00033 bool doPos=1;
00034
00035 TH1 *ha,*hb,*hc;
00036 char* type[] = { "Mean","Rms","Num"};
00037 char* ptType[] = { "PrPt","GlPt" };
00038 char* chargeType[] = {"Neg","Pos","PosPlusNeg","PosMinusNeg"};
00039 gStyle->SetOptStat(0);
00040
00041
00042 for(int it=0; it<nType; it++){
00043 for(int ipt=0;ipt<nPtType;ipt++){
00044 for(int iew=0;iew<2;iew++){
00045 int zBin=0;
00046 TH1* h1[nChargeType][10];
00047
00048 for(int ic=0; ic<nChargeType; ic++){
00049 if(iew<1){ zBin=1; } else { zBin=5; }
00050 for(int iz=0; iz<nZperHalf; iz++){
00051 sprintf(name,"h%s%sDcaXY%sVphiS0zBin%dSdcaXYBin1",
00052 type[it],chargeType[ic],ptType[ipt],zBin++);
00053
00054 h1[ic][iz]=(TH1D*)inRoot.Get(name); if(!h1[ic][iz]) return;
00055 }
00056 }
00057
00058 sprintf(name,"%sPosNegDcaXY%sVphi%s",
00059 type[it],ptType[ipt],sEW[iew].Data());
00060 Divide(&c1,2,2,name,inName);
00061
00062 zBin=0;
00063 for(int i=0;i<4;i++){
00064 if(iew<1){ zBin = 3-i;} else { zBin = i; }
00065 c1.cd(i+1);
00066
00067 ha=h1[0][zBin]; hb=h1[1][zBin]; hc=h1[2][zBin];
00068 setMinMax(ha,hb,hc,type[it]);
00069 TString s=ha->GetTitle();
00070
00071 s.Replace(0,s.First("("),"");
00072 s.Replace(s.First(")")+1,s.Length(),"");
00073 ha->SetTitle(s.Data());
00074 ha->SetMarkerColor(kBlue); ha->SetMarkerStyle(4);
00075
00076 ha->Draw("p"); DrawLine(ha);
00077 if(doPos){
00078 hb->SetMarkerColor(kRed);
00079 hc->SetMarkerColor(kGreen);
00080 hb->SetMarkerStyle(8);
00081 hc->SetMarkerStyle(10);
00082 hb->Draw("psame");
00083 hc->Draw("psame");
00084 }
00085
00086 }
00087 Print(&c1,psDir,name);
00088
00089
00090 if(doPos){
00091 sprintf(name,"%sPosMinusNegDcaXY%sVphi%s",
00092 type[it],ptType[ipt],sEW[iew].Data());
00093 Divide(&c1,2,2,name,inName);
00094 for(int i=0;i<4;i++){
00095 if(iew<1){ zBin = 3-i;} else { zBin = i; }
00096 c1.cd(i+1);
00097 setMinMax(h1[3][zBin],0,0,type[it]);
00098 h1[3][zBin]->Draw("p");
00099 }
00100 Print(&c1,psDir,name);
00101 }
00102 }
00103 }
00104 }
00105
00106
00107
00108
00109 for(int it=0; it<nType; it++){
00110 for(int ipt=0;ipt<nPtType;ipt++){
00111 TH1* h[nChargeType];
00112
00113 for(int ic=0; ic<nChargeType; ic++){
00114 sprintf(name,"h%s%sDcaXY%sVzS0phiBin1SdcaXYBin1",
00115 type[it],chargeType[ic],ptType[ipt],zBin++);
00116
00117 h[ic]=(TH1*)inRoot.Get(name); if(!h[ic]) return;
00118 }
00119
00120
00121 sprintf(name,"%sPosNegDcaXY%sVz",
00122 type[it],ptType[ipt]);
00123 Divide(&c1,1,2,name,inName);
00124 c1.cd(1);
00125 ha=h[0]; hb=h[1]; hc=h[2];
00126 setMinMax(ha,hb,hc,type[it]);
00127 ha->SetMarkerColor(kBlue);
00128 ha->Draw("p"); ha->SetMarkerStyle(4);DrawLine(ha);
00129 if(doPos){
00130 hb->SetMarkerColor(kRed);
00131 hc->SetMarkerColor(kGreen);
00132 hb->SetMarkerStyle(8);
00133 hc->SetMarkerStyle(10);
00134 hb->Draw("psame"); hc->Draw("psame");
00135 }
00136
00137 if(doPos){
00138 c1.cd(2);
00139 setMinMax(h[3],0,0,type[it]);
00140 h[3]->Draw("p");
00141 }
00142 Print(&c1,psDir,name);
00143
00144 }
00145 }
00146
00147
00148
00149 }
00150
00151 void setMinMax(TH1* ha,TH1* hb,TH1* hc,TString t)
00152 {
00153 if(t=="Mean"){
00154 SetMinMax(ha,-.1,.1);
00155 }
00156 else if(t=="Num"){
00157 if(hc)SetMinMax(ha,ha->GetMinimum()*0.5,hc->GetMaximum()*1.2);
00158 else SetMinMax(ha);
00159 }
00160 else if(t=="Rms"){
00161 SetMinMax(ha,0.2,0.8);
00162 }
00163 else{ cout << "Unknown type " << t << endl; }
00164 }
00165