1 #include "commonmacro/common.h"
2 #include "common/Name.cc"
3 #include "commonmacro/histutil.h"
7 "links/P01hi.minbias.2000.hist/hianalysis_1000.hist.root",
8 const char* psDir=
"ps",
10 const char* outDir=
"./",
11 const char* more =
"west",
12 float extraValue = 10)
14 cout <<
"--------------------------" << endl;
15 cout <<
"in name=" << inName << endl
16 <<
"ps dir=" << psDir << endl
17 <<
"cut=" << cut << endl;
18 cout <<
"--------------------------" << endl;
20 inRoot =
new TFile(inName);
23 cout <<
"cannot find the infile" << endl;
26 gStyle->SetOptStat(0);gStyle->SetPadTickX(1);gStyle->SetPadTickY(1);
27 TCanvas c1(
"c1",
"c1",500,400);
30 TGraphAsymmErrors* gSpec[2];
31 TGraphAsymmErrors* gSpecPM[2][2];
32 TGraphAsymmErrors* gUA1, *gRatio;
35 for(
int ibin=0;ibin<nbin;ibin++){
36 setName(name,
"gSpecCorrected",ibin);
38 gSpec[ibin]=(TGraphAsymmErrors*)inRoot.Get(name);
39 cout << gSpec[ibin]->GetName() << endl;
40 if(!gSpec[ibin])
return;
41 for(
int ipm=0;ipm<2;ipm++){
42 setName(name,
"gSpecCorrected",ibin,sPM[ipm].Data());
44 gSpecPM[ibin][ipm]=(TGraphAsymmErrors*)inRoot.Get(name);
45 if(!gSpecPM[ibin][ipm])
return;
49 for(
int ibin=0;ibin<2; ibin++){
50 cout <<
"setting title"<< endl;
51 sprintf(title,
"%s / UA1 (bin %d)(cut %d)",
52 gSpec[ibin]->GetName(),ibin,cut);
53 Divide(&c1,1,1,title,inName);
54 cout <<
"making" << endl;
55 gUA1=makeUA1(gSpec[ibin]);
56 gRatio=makeRatio(gSpec[ibin],gUA1);
57 gRatio->Draw(
"ap"); sprintf(title,
"%sOverUA1",gSpec[ibin]->GetName());
58 gRatio->SetMaximum(1.2); gRatio->SetMinimum(.2);
59 Print(&c1,psDir,title);
60 for(
int ipm=0;ipm<2;ipm++){
64 sprintf(title,
"%s / UA1 (bin %d)(cut %d)",
65 sName.Data(),gSpecPM[ibin][ipm]->GetName(),ibin,cut);
66 Divide(&c1,1,1,title,inName);
68 gRatio=makeRatio(gSpecPM[ibin][ipm],gUA1);
70 gRatio->SetMaximum(1.2); gRatio->SetMinimum(.2);
72 sprintf(title,
"%sOverUA1",gSpecPM[ibin][ipm]->GetName());
73 Print(&c1,psDir,title);
85 makeUA1(
const TGraphAsymmErrors* graph)
91 const Int_t nBin = graph->GetN();
92 Double_t* xValues = graph->GetX();
93 Double_t* yValues = graph->GetY();
94 Double_t* errXLow = graph->GetEXlow();
95 Double_t* errXHigh = graph->GetEXhigh();
113 sprintf(name,
"h1tmp%s",graph->GetName());
114 TH1D* h1 =
new TH1D(name,name,9,1.5,6.0);
116 h1->SetBinContent(1,.61467);
117 h1->SetBinContent(2,.58835);
118 h1->SetBinContent(3,.55895);
119 h1->SetBinContent(4,.52837);
120 h1->SetBinContent(5,.50290);
121 h1->SetBinContent(6,.47903);
122 h1->SetBinContent(7,.45747);
123 h1->SetBinContent(8,.43787);
124 h1->SetBinContent(9,.40195);
141 char func[200], mean[200];
143 sprintf(func,
"2*pi*%.0f*%.0f*(1+x/%.2f)^(-%.2f)",A,TAA,p0,n);
145 sprintf(mean,
"2*pi*x*%.0f*%.0f*(1+x/%.2f)^(-%.2f)",A,TAA,p0,n);
148 TF1* fUA1 =
new TF1(
"fUA1",func,lowPt,highPt);
149 TF1* fMean =
new TF1(
"fUA1Mean",mean,lowPt,highPt);
151 gUA1 =
new TGraphAsymmErrors;
153 for(Int_t i=0; i<nBin; i++){
157 Double_t lowEdge = xValues[i]-errXLow[i];
158 Double_t highEdge = xValues[i]+errXHigh[i];
161 Double_t num = fMean->Integral(lowEdge,highEdge);
162 Double_t denom = fUA1->Integral(lowEdge,highEdge);
168 Double_t UA1ErrLow = fabs(lowEdge-xValues[i]);
169 Double_t UA1ErrHigh= fabs(highEdge-xValues[i]);
172 double y = denom/(highEdge-lowEdge);
184 double yCorrected = y;
186 cout <<
"UA1 uncorrected " << y <<
", corrected y " << yCorrected
187 <<
" graph y " << yValues[i] << endl;
189 gUA1->SetPoint(i,xValues[i],yCorrected);
190 gUA1->SetPointError(i,UA1ErrLow,UA1ErrHigh,0,0);
193 gUA1->SetName(
"gUA1Spectrum");
194 gUA1->SetTitle(
"gUA1Spectrum");
202 makeRatio(TGraphAsymmErrors* gStar, TGraphAsymmErrors* gUA1)
204 cout <<
"********************************" << endl;
205 cout << gStar->GetName() << endl;
206 const Int_t nBin = gStar->GetN();
208 Double_t* starY = gStar->GetY();
209 Double_t* starX = gStar->GetX();
210 Double_t* starXErrLow = gStar->GetEXlow();
211 Double_t* starXErrHigh = gStar->GetEXhigh();
212 Double_t* starYErrHigh = gStar->GetEYhigh();
214 Double_t* ua1Y = gUA1->GetY();
215 Double_t* ua1YErrHigh = gUA1->GetEYhigh();
217 TGraphAsymmErrors* gRatio =
new TGraphAsymmErrors;
219 for(Int_t i=0; i<nBin; i++){
221 Double_t ratio = starY[i]/ua1Y[i];
224 TMath::Sqrt(ratio*ratio*(starYErrHigh[i]*starYErrHigh[i]/(starY[i]*starY[i])));
227 cout <<
"star x : " << starX[i] << endl;
228 cout <<
"star y : " << starY[i] <<
" ua1 Y : " << ua1Y[i]
229 <<
" ratio : " << ratio << endl
230 <<
"error : " << yError << endl;
232 gRatio->SetPoint(i,starX[i],ratio);
233 gRatio->SetPointError(i,starXErrLow[i],starXErrHigh[i],yError,yError);
236 TString sName = gStar->GetName();
237 sName.Append(
"UA1Ratio");
239 gRatio->SetName(sName.Data());
240 gRatio->SetTitle(sName.Data());