00001 #include "commonmacro/common.h"
00002 #include "common/Name.cc"
00003 #include "commonmacro/histutil.h"
00004
00005 void makeMinbiasUA1Ratio(
00006 const char* inName=
00007 "links/P01hi.minbias.2000.hist/hianalysis_1000.hist.root",
00008 const char* psDir="ps",
00009 int cut = 1,
00010 const char* outDir="./",
00011 const char* more = "west",
00012 float extraValue = 10)
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 gStyle->SetOptStat(0);gStyle->SetPadTickX(1);gStyle->SetPadTickY(1);
00027 TCanvas c1("c1","c1",500,400);
00028
00029 const int nbin=2;
00030 TGraphAsymmErrors* gSpec[2];
00031 TGraphAsymmErrors* gSpecPM[2][2];
00032 TGraphAsymmErrors* gUA1, *gRatio;
00033
00034 float min=0.0,max=1.2;
00035
00036 float geom=7200;
00037
00038
00039 for(int ibin=0;ibin<nbin;ibin++){
00040 setName(name,"gSpecCorrected",ibin);
00041 gSpec[ibin]=(TGraphAsymmErrors*)inRoot.Get(name);
00042 cout << gSpec[ibin]->GetName() << endl;
00043 if(!gSpec[ibin]) return;
00044 for(int ipm=0;ipm<2;ipm++){
00045 setName(name,"gSpecCorrected",ibin,sPM[ipm].Data());
00046 cout << name << endl;
00047 gSpecPM[ibin][ipm]=(TGraphAsymmErrors*)inRoot.Get(name);
00048 if(!gSpecPM[ibin][ipm]) return;
00049 }
00050 }
00051
00052 for(int ibin=0;ibin<2; ibin++){
00053 cout << "setting title"<< endl;
00054 sprintf(title,"%s / UA1 (bin %d)(cut %d)",
00055 gSpec[ibin]->GetName(),ibin,cut);
00056 Divide(&c1,1,1,title,inName);
00057 cout << "making" << endl;
00058 gUA1=makeUA1(gSpec[ibin]);
00059 cout << "done" << endl;
00060 cout << "making ratio" << endl;
00061 gRatio=makeRatio(gSpec[ibin],gUA1);
00062 cout << "done " << endl;
00063
00064 double* x=gRatio->GetX(); double* y=gRatio->GetY();
00065 double* exHigh=gRatio->GetEXhigh();
00066 double* exLow =gRatio->GetEXlow();
00067 double* ey=gRatio->GetEYhigh();
00068 for(int i=0; i<gRatio->GetN(); i++){
00069 gRatio->SetPoint(i,x[i],y[i]*geom);
00070 gRatio->SetPointError(i,exLow[i],exHigh[i],ey[i]*7200,ey[i]*7200);
00071 }
00072
00073
00074
00075 gRatio->Draw("ap");
00076 sprintf(title,"%sOverUA1",gSpec[ibin]->GetName());
00077 gRatio->SetMaximum(max); gRatio->SetMinimum(min);
00078 Print(&c1,psDir,title);
00079
00080
00081
00082
00083
00084
00085
00086
00087
00088
00089
00090
00091
00092
00093
00094
00095
00096
00097
00098
00099 }
00100
00101
00102
00103
00104 }
00105
00106
00107 TGraphAsymmErrors*
00108 makeUA1(const TGraphAsymmErrors* graph)
00109 {
00110
00111
00112
00113
00114 const Int_t nBin = graph->GetN();
00115 Double_t* xValues = graph->GetX();
00116 Double_t* yValues = graph->GetY();
00117 Double_t* errXLow = graph->GetEXlow();
00118 Double_t* errXHigh = graph->GetEXhigh();
00119
00120
00121
00122
00123
00124
00125
00126
00127
00128
00129
00130
00131
00132
00133
00134
00135
00136 sprintf(name,"h1tmp%s",graph->GetName());
00137 TH1D* h1 = new TH1D(name,name,9,1.5,6.0);
00138
00139 h1->SetBinContent(1,.61467);
00140 h1->SetBinContent(2,.58835);
00141 h1->SetBinContent(3,.55895);
00142 h1->SetBinContent(4,.52837);
00143 h1->SetBinContent(5,.50290);
00144 h1->SetBinContent(6,.47903);
00145 h1->SetBinContent(7,.45747);
00146 h1->SetBinContent(8,.43787);
00147 h1->SetBinContent(9,.40195);
00148
00149
00150
00151 Double_t A = 266.6;
00152 Double_t p0 = 1.895;
00153 Double_t n = 12.98;
00154
00155
00156
00157
00158
00159
00160
00161
00162 Double_t TAA = 26;
00163 double A_ion=197;
00164
00165 char func[200], mean[200];
00166
00167 sprintf(func,"2*pi*%.1f*%.0f*(1+x/%.2f)^(-%.2f)",A,A_ion*A_ion,p0,n);
00168
00169 sprintf(mean,"2*pi*x*%.1f*%.0f*(1+x/%.2f)^(-%.2f)",A,TAA,p0,n);
00170
00171
00172 TF1* fUA1 = new TF1("fUA1",func,lowPt,highPt);
00173 TF1* fMean = new TF1("fUA1Mean",mean,lowPt,highPt);
00174
00175 gUA1 = new TGraphAsymmErrors;
00176
00177 for(Int_t i=0; i<nBin; i++){
00178
00179
00180
00181 Double_t lowEdge = xValues[i]-errXLow[i];
00182 Double_t highEdge = xValues[i]+errXHigh[i];
00183
00184
00185 Double_t num = fMean->Integral(lowEdge,highEdge);
00186 Double_t denom = fUA1->Integral(lowEdge,highEdge);
00187
00188
00189
00190
00191
00192 Double_t UA1ErrLow = fabs(lowEdge-xValues[i]);
00193 Double_t UA1ErrHigh= fabs(highEdge-xValues[i]);
00194
00195
00196 double y = denom/(highEdge-lowEdge);
00197
00198
00199
00200
00201
00202
00203
00204
00205
00206
00207
00208 double yCorrected = y;
00209
00210 cout << "UA1 uncorrected " << y << ", corrected y " << yCorrected
00211 << " graph y " << yValues[i] << endl;
00212
00213 gUA1->SetPoint(i,xValues[i],yCorrected);
00214 gUA1->SetPointError(i,UA1ErrLow,UA1ErrHigh,0,0);
00215 }
00216
00217 gUA1->SetName("gUA1Spectrum");
00218 gUA1->SetTitle("gUA1Spectrum");
00219
00220 return gUA1;
00221
00222 }
00223
00224 TGraphAsymmErrors*
00225 makeRatio(TGraphAsymmErrors* gStar, TGraphAsymmErrors* gUA1)
00226 {
00227 cout << "********************************" << endl;
00228 cout << gStar->GetName() << endl;
00229 const Int_t nBin = gStar->GetN();
00230
00231 Double_t* starY = gStar->GetY();
00232 Double_t* starX = gStar->GetX();
00233 Double_t* starXErrLow = gStar->GetEXlow();
00234 Double_t* starXErrHigh = gStar->GetEXhigh();
00235 Double_t* starYErrHigh = gStar->GetEYhigh();
00236
00237 Double_t* ua1Y = gUA1->GetY();
00238 Double_t* ua1YErrHigh = gUA1->GetEYhigh();
00239
00240 TGraphAsymmErrors* gRatio = new TGraphAsymmErrors;
00241
00242 for(Int_t i=0; i<nBin; i++){
00243
00244 Double_t ratio = starY[i]/ua1Y[i];
00245
00246 Double_t yError =
00247 TMath::Sqrt(ratio*ratio*(starYErrHigh[i]*starYErrHigh[i]/(starY[i]*starY[i])));
00248
00249
00250 cout << "star x : " << starX[i] << endl;
00251 cout << "star y : " << starY[i] << " ua1 Y : " << ua1Y[i]
00252 << " ratio : " << ratio << endl
00253 << "error : " << yError << endl;
00254
00255 gRatio->SetPoint(i,starX[i],ratio);
00256 gRatio->SetPointError(i,starXErrLow[i],starXErrHigh[i],yError,yError);
00257 }
00258
00259 TString sName = gStar->GetName();
00260 sName.Append("UA1Ratio");
00261
00262 gRatio->SetName(sName.Data());
00263 gRatio->SetTitle(sName.Data());
00264
00265 return gRatio;
00266
00267 }
00268
00269
00270
00271
00272
00273