4 TGraphErrors* ua1Data200();
6 TF1* ua1Fit130(scale=1);
9 scale(TGraphAsymmErrors* graph,
double scale);
12 scale(TGraphErrors* graph,
double scale);
16 divide(TGraphASymmErrors* graph,
double div,
double divErr=0);
21 makeUA1(
const TGraphAsymmErrors* graph,
int type=0);
24 divide(TGraphAsymmErrors* graphA,TGraphAsymmErrors* graphB);
29 makeUA1Ratio(TGraphAsymmErrors* gSTAR,
30 int type,
double scale);
34 makeUA1RatioDiv(TGraphAsymmErrors* gSTAR,
35 double TAA,
double TAAErr=0);
39 makeUA1TAAHistError(TGraphAsymmErrors* gSTAR,
40 double TAA,
double TAAError);
44 makeUA1ScaleError(TGraphAsymmErrors* gSTAR,
45 float scale,
float scaleLow,
float scaleHigh);
53 removeXErrors(TGraphAsymmErrors* g);
57 kludgeBackground(TGraphAsymmErrors* graph,
float val)
59 double* xValues = graph->GetX();
60 double* yValues = graph->GetY();
61 double* errXLow = graph->GetEXlow();
62 double* errXHigh = graph->GetEXhigh();
64 double* errYLow = graph->GetEYlow();
65 double* errYHigh = graph->GetEYhigh();
67 for(
int i=0; i<graph->GetN(); i++){
68 double y=yValues[i]*(1-val);
69 double yErr=errYLow[i]*(1-val);
71 graph->SetPoint(i,xValues[i],y);
72 graph->SetPointError(i,errXLow[i],errXHigh[i],
80 kludgeSystematics(TGraphAsymmErrors* graph)
85 double* xValues = graph->GetX();
86 double* yValues = graph->GetY();
87 double* errXLow = graph->GetEXlow();
88 double* errXHigh = graph->GetEXhigh();
90 double* errYLow = graph->GetEYlow();
91 double* errYHigh = graph->GetEYhigh();
94 for(
int i=0; i<n; i++){
97 if(i==(n-2)) yErr=yValues[i]*.10;
98 else if(i==(n-1)) yErr=yValues[i]*.15;
99 else yErr=yValues[i]*.08;
103 graph->SetPointError(i,errXLow[i],errXHigh[i],
117 scale(TGraphAsymmErrors* graph,
double scale)
119 if(DEBUG)printf(
"SCALE=%.2e\n (1/SCALE=%.2e)\n",scale,1./scale);
120 double* xValues = graph->GetX();
121 double* yValues = graph->GetY();
122 double* errXLow = graph->GetEXlow();
123 double* errXHigh = graph->GetEXhigh();
125 double* errYLow = graph->GetEYlow();
126 double* errYHigh = graph->GetEYhigh();
128 for(
int i=0; i<graph->GetN(); i++){
129 double y=yValues[i], eYLow=errYLow[i], eYHigh=errYHigh[i];
130 double yScaled=yValues[i]*scale;
131 double eYLowScaled = errYLow[i]*scale;
132 double eYHighScaled =errYHigh[i]*scale;
134 graph->SetPoint(i,xValues[i],yScaled);
135 graph->SetPointError(i,errXLow[i],errXHigh[i],
136 eYLowScaled,eYHighScaled);
138 printf(
"\tbin=%d : %.2f<%.2f<%.2f: y=%.2e, yScaled=%.2e\n\t\t yErrLow=%.2e, yErrLowScaled=%.2e\n",
139 i,xValues[i]-errXLow[i],xValues[i],xValues[i]+errXHigh[i],
140 y,yScaled,eYLow,eYLowScaled);
150 divide(TGraphAsymmErrors* graph,
double div,
double divErr)
152 if(DEBUG)printf(
"DIVIDE=%.2e, err=%.2e\n",div,divErr);
153 double* xValues = graph->GetX();
154 double* yValues = graph->GetY();
155 double* errXLow = graph->GetEXlow();
156 double* errXHigh = graph->GetEXhigh();
158 double* errYLow = graph->GetEYlow();
159 double* errYHigh = graph->GetEYhigh();
161 for(
int i=0; i<graph->GetN(); i++){
162 double y=yValues[i], eYLow=errYLow[i], eYHigh=errYHigh[i];
163 double yDiv=yValues[i]/div;
164 double eY = errYLow[i];
165 double eYDiv = errYLow[i]/div;
168 eYDiv=yDiv*sqrt((eY/y)*(eY/y) + (divErr/div)*(divErr/div));
172 graph->SetPoint(i,xValues[i],yDiv);
173 graph->SetPointError(i,errXLow[i],errXHigh[i],
176 printf(
"\tbin=%d : %.2f<%.2f<%.2f: y=%.2e, yScaled=%.2e\n\t\t yErrLow=%.2e, yErrLowScaled=%.2e\n",
177 i,xValues[i]-errXLow[i],xValues[i],xValues[i]+errXHigh[i],
189 scale(TGraphErrors* graph,
double scale)
191 if(DEBUG)printf(
"SCALE=%.2e\n (1/SCALE=%.2e)\n",scale,1./scale);
192 double* xValues = graph->GetX();
193 double* yValues = graph->GetY();
194 double* errX = graph->GetEX();
195 double* errY = graph->GetEY();
197 for(
int i=0; i<graph->GetN(); i++){
198 double y=yValues[i],eY=errY[i];
199 double yScaled=yValues[i]*scale;
201 double eYScaled = errY[i]*scale;
203 graph->SetPoint(i,xValues[i],yScaled);
204 graph->SetPointError(i,errX[i],eYScaled);
216 TGraphErrors* ua1Data200()
218 TGraphErrors* g=
new TGraphErrors;
219 g->SetName(
"gUA1Data200GeV");
223 double x[n],y[n],ey[n];
226 x[0] = 0.25; y[0] = 62.0; ey[0] = 3.1;
227 x[1] = 0.35; y[1] = 36.2; ey[1] = 1.8;
228 x[2] = 0.45; y[2] = 20.8; ey[2] = 1.0;
229 x[3] = 0.55; y[3] = 12.32; ey[3] = 0.62;
230 x[4] = 0.65; y[4] = 7.33; ey[4] = 0.37;
231 x[5] = 0.75; y[5] = 4.54; ey[5] = 0.23;
232 x[6] = 0.85; y[6] = 2.77; ey[6] = 0.14;
233 x[7] = 0.95; y[7] = 1.724; ey[7] = 0.088;
234 x[8] = 1.05; y[8] = 1.162; ey[8] = 0.060;
235 x[9] = 1.15; y[9] = 0.769; ey[9] = 0.040;
236 x[10] = 1.25; y[10] = 0.521; ey[10] = 0.028;
237 x[11] = 1.35; y[11] = 0.344; ey[11] = 0.019;
238 x[12] = 1.45; y[12] = 0.240; ey[12] = 0.013;
239 x[13] = 1.55; y[13] = 0.1680; ey[13] = 0.0095;
240 x[14] = 1.65; y[14] = 0.1180; ey[14] = 0.0069;
241 x[15] = 1.75; y[15] = 0.0861; ey[15] = 0.0053;
242 x[16] = 1.85; y[16] = 0.0579; ey[16] = 0.0038;
243 x[17] = 1.95; y[17] = 0.0440; ey[17] = 0.0030;
244 x[18] = 2.05; y[18] = 0.0308; ey[18] = 0.0023;
245 x[19] = 2.15; y[19] = 0.0223; ey[19] = 0.0018;
246 x[20] = 2.25; y[20] = 0.0167; ey[20] = 0.0014;
247 x[21] = 2.35; y[21] = 0.0143; ey[21] = 0.0013;
248 x[22] = 2.45; y[22] = 0.0092; ey[22] = 0.0010;
249 x[23] = 2.55; y[23] = 0.00575; ey[23] = 0.00071;
250 x[24] = 2.65; y[24] = 0.00558; ey[24] = 0.00069;
251 x[25] = 2.75; y[25] = 0.00376; ey[25] = 0.00054;
252 x[26] = 2.85; y[26] = 0.00362; ey[26] = 0.00052;
253 x[27] = 2.95; y[27] = 0.00322; ey[27] = 0.00048;
254 x[28] = 3.05; y[28] = 0.00191; ey[28] = 0.00035;
255 x[29] = 3.15; y[29] = 0.00179; ey[29] = 0.00034;
256 x[30] = 3.25; y[30] = 0.00126; ey[30] = 0.00028;
257 x[31] = 3.35; y[31] = 0.00155; ey[31] = 0.00030;
258 x[32] = 3.45; y[32] = 0.00072; ey[32] = 0.00020;
259 x[33] = 3.55; y[33] = 0.00060; ey[33] = 0.00018;
260 x[34] = 3.65; y[34] = 0.000286; ey[34] = 0.000086;
261 x[35] = 3.85; y[35] = 0.000389; ey[35] = 0.000098;
262 x[36] = 4.10; y[36] = 0.000172; ey[36] = 0.000051;
263 x[37] = 4.50; y[37] = 0.000114; ey[37] = 0.000035;
264 x[38] = 5.70; y[38] = 0.0000135; ey[38] = 0.0000067;
265 x[39] = 6.70; y[39] = 0.0000066; ey[39] = 0.0000043;
268 for(
int i=0; i<n; i++){
269 g->SetPoint(i,x[i],y[i]);
270 g->SetPointError(i,ex[i],ey[i]);
277 TF1* ua1Fit130(
double scale)
279 double A = 266.6;
double p0 = 1.895;
double n = 12.98;
280 const char* fcn =
"[3]*[0]*(1+x/[1])^-[2]";
282 fUA1 =
new TF1(
"fUA1)130",fcn,lowPt,highPt);
283 fUA1->SetParameter(0,A);
284 fUA1->SetParameter(1,p0);
285 fUA1->SetParameter(2,n);
286 fUA1->SetParameter(3,scale);
306 makeUA1(
const TGraphAsymmErrors* graph,
int type)
308 if(DEBUG)printf(
"MAKEUA1 type=%d (2piA(1=pt/p0)^-n)\n",type);
312 const int nBin = graph->GetN();
313 double* xValues = graph->GetX();
314 double* yValues = graph->GetY();
315 double* errXLow = graph->GetEXlow();
316 double* errXHigh = graph->GetEXhigh();
318 TGraphAsymmErrors* gUA1=
new TGraphAsymmErrors;
319 gUA1->SetName(
"ua1");
327 A = 266.6; p0 = 1.895; n = 12.98;
break;
329 A = 260.6; p0 = 2.0701; n = 13.9;
break;
331 A = 270.5; p0 = 1.8053; n = 12.514;
break;
333 cout <<
"wrong type=" << type << endl; exit(1);
336 double lowPt=0, highPt=6;
339 const char* fcn =
"2*pi*[0]*(1+x/[1])^-[2]";
341 fUA1 =
new TF1(
"fUA1",fcn,lowPt,highPt);
342 fUA1->SetParameter(0,A);
343 fUA1->SetParameter(1,p0);
344 fUA1->SetParameter(2,n);
347 for(
int i=0;i<nBin; i++){
351 double lowEdge = xValues[i]-errXLow[i];
352 double highEdge = xValues[i]+errXHigh[i];
353 double binWidth = highEdge-lowEdge;
355 double value = fUA1->Integral(lowEdge,highEdge)/binWidth;
358 printf(
"\tbin=%d : %.2f<%.2f<%.2f : val=%.4e\n",
359 i,lowEdge,xValues[i],highEdge,value);
361 gUA1->SetPoint(i,xValues[i],value);
362 gUA1->SetPointError(i,errXLow[i],errXHigh[i],0,0);
374 divide(TGraphAsymmErrors* graphA,TGraphAsymmErrors* graphB)
376 if(DEBUG)printf(
"DIVIDE\n");
378 const int nBin = graphA->GetN();
379 if(nBin != graphB->GetN()){
380 cout <<
"divide(..) :different bins sizes" << endl; exit(1);
383 double* xValuesA = graphA->GetX();
384 double* yValuesA = graphA->GetY();
385 double* errXLowA = graphA->GetEXlow();
386 double* errXHighA = graphA->GetEXhigh();
387 double* errYA = graphA->GetEYhigh();
390 double* xValuesB = graphB->GetX();
391 double* yValuesB = graphB->GetY();
392 double* errYB = graphB->GetEYhigh();
394 TGraphAsymmErrors* gRatio =
new TGraphAsymmErrors;
395 gRatio->SetName(
"gRatio"); gRatio->SetTitle(
"gRatio");
397 for(
int i=0; i<nBin; i++){
398 if(yValuesB[i]==static_cast<double>(0)) {
399 cout <<
"divide: cant divide by 0" << endl;
401 double yRatio = yValuesA[i]/yValuesB[i];
405 errYA[i]*errYA[i]/(yValuesA[i]*yValuesA[i])+
406 errYB[i]*errYB[i]/(yValuesB[i]*yValuesB[i])
409 gRatio->SetPoint(i,xValuesA[i],yRatio);
410 gRatio->SetPointError(i,errXLowA[i],errXHighA[i],
412 double low=xValuesA[i]-errXLowA[i];
413 double high=xValuesA[i]+errXHighA[i];
415 printf(
"\tbin=%d : %.2f<%.2f<%.2f : \n\t\tvalA=%.2e, valB=%.2e, A/B=%.2e\n\t\t errA=%.2e, errB=%.2e, errA/B=%.2e\n",
416 i,low,xValuesA[i],high,yValuesA[i],yValuesB[i],
417 yRatio,errYA[i],errYB[i],errY);
432 makeUA1Ratio(TGraphAsymmErrors* gSTAR,
433 int type,
double scale)
435 TGraphAsymmErrors* gUA1=makeUA1(gSTAR,type);
436 TGraphAsymmErrors* gRatio=divide(gSTAR,gUA1);
437 double *y=gRatio->GetY();
446 makeUA1RatioDiv(TGraphAsymmErrors* gSTAR,
447 double TAA,
double TAAErr)
449 TGraphAsymmErrors* gUA1=makeUA1(gSTAR,0);
450 TGraphAsymmErrors* gRatio=divide(gSTAR,gUA1);
451 divide(gRatio,TAA,TAAErr);
457 makeUA1TAAHistError(TGraphAsymmErrors* gSTAR,
458 double TAA,
double TAAErr)
460 if(DEBUG)printf(
"makeUA1TAAHistError\n");
464 TGraphAsymmErrors* gRatioErr=makeUA1RatioDiv(gSTAR,TAA,TAAErr);
466 double* xValues = gRatioErr->GetX();
467 double* yValues = gRatioErr->GetY();
468 double* errXLow = gRatioErr->GetEXlow();
469 double* errXHigh = gRatioErr->GetEXhigh();
471 double* errYLow = gRatioErr->GetEYlow();
472 double* errYHigh = gRatioErr->GetEYhigh();
475 const int nAry=gRatioErr->GetN()+1;
476 const int nBin=nAry-1;
477 double* xAry=
new double[nAry];
478 double* yAry=
new double[nBin];
479 double* yErr=
new double[nBin];
481 for(
int i=0;i<nBin;i++){
482 float lowEdge=xValues[i]-errXLow[i];
488 xAry[nAry-1]=xValues[gRatioErr->GetN()-1]+errXHigh[gRatioErr->GetN()-1];
491 TH1D* h=
new TH1D(
"h",
"h",nBin,xAry);
492 for(
int i=0;i<nBin;i++){
495 h->SetBinContent(i+1,yAry[i]);
496 h->SetBinError(i+1,yErr[i]);
514 makeUA1ScaleError(TGraphAsymmErrors* gSTAR,
515 float scale,
float scaleLow,
float scaleHigh)
517 if(DEBUG)printf(
"ERROR\n");
518 if(DEBUG)printf(
"BEST\n");
519 TGraphAsymmErrors* gBestRatio=makeUA1Ratio(gSTAR,0,scale);
524 if(DEBUG)printf(
"LOW RATIO\n");
525 TGraphAsymmErrors* gLowRatio=makeUA1Ratio(gSTAR,2,scaleLow);
526 if(DEBUG)printf(
"HIGH RATIO\n");
527 TGraphAsymmErrors* gHighRatio=makeUA1Ratio(gSTAR,1,scaleHigh);
535 TGraphAsymmErrors* gError=
536 (TGraphAsymmErrors*)gBestRatio->Clone();
537 gError->SetName(
"gError");gError->SetTitle(
"gError");
540 double* eYBest=gBestRatio->GetEYlow();
543 double* yValuesBest=gBestRatio->GetY();
544 double* yValuesLow=gLowRatio->GetY();
545 double* yValuesHigh=gHighRatio->GetY();
548 double* xValues=gBestRatio->GetX();
549 double* eXHigh=gBestRatio->GetEXhigh();
550 double* eXLow=gBestRatio->GetEXlow();
552 if(DEBUG)printf(
"SET ERRORS\n");
554 for(
int i=0; i<gBestRatio->GetN(); i++){
556 double eYHigh=yValuesHigh[i]-yValuesBest[i];
557 double eYLow=yValuesBest[i]-yValuesLow[i];
558 gError->SetPointError(i,0,0,eYLow+eYBest[i],eYHigh+eYBest[i]);
561 printf(
"\tbin=%d : %.2f<%.2f<%.2f : yBest=%.2e\n\t\teYhigh=%.2e, eYlow=%.2e, eYbest=%.2e\n",
562 i,xValues[i]-eXLow[i],xValues[i],xValues[i]+eXHigh[i],
563 yValuesBest[i],eYHigh,eYLow,eYBest[i]);
580 cout <<
"###makeHMinus : " << cent << endl;
582 char* fname=
"~/afs/real/PJacobs.root";
584 TFile* frank =
new TFile(fname);
585 if(!frank ||!frank->IsOpen()) exit(1);
587 TGraphAsymmErrors* gHMinus =
new TGraphAsymmErrors;
588 gHMinus->SetName(
"hMinus");
590 char buf[100];
char* basename=
"hPlusMinus";
591 TH1* hMinus, *hMinusb;
596 sprintf(buf,
"%s_00",basename);
597 hMinus=(TH1*)frank->Get(buf);
600 sprintf(buf,
"%s_02",basename);
601 hMinus=(TH1*)frank->Get(buf);
602 sprintf(buf,
"%s_03",basename);
603 hMinusb=(TH1*)frank->Get(buf);
604 hMinus->Add(hMinusb); hMinus->Scale(0.5);
607 sprintf(buf,
"%s_10",basename);
608 hMinus=(TH1*)frank->Get(buf);
611 sprintf(buf,
"%s_08",basename);
612 hMinus=(TH1*)frank->Get(buf);
615 sprintf(buf,
"%s_07",basename);
616 hMinus=(TH1*)frank->Get(buf);
619 sprintf(buf,
"%s_06",basename);
620 hMinus=(TH1*)frank->Get(buf);
623 sprintf(buf,
"%s_05",basename);
624 hMinus=(TH1*)frank->Get(buf);
625 sprintf(buf,
"%s_04",basename);
626 hMinusb=(TH1*)frank->Get(buf);
627 hMinus->Add(hMinusb); hMinus->Scale(0.5);
630 cout <<
"Unknown cent = " << cent << endl; exit(1);
637 for(
int i=firstbin; i<=hMinus->GetNbinsX(); i++){
638 double y=hMinus->GetBinContent(i);
639 double yerr=hMinus->GetBinError(i);
640 double x =hMinus->GetBinCenter(i);
641 double xerr=hMinus->GetBinWidth(i)/2.;
644 gHMinus->SetPoint(i-firstbin,x,y);
645 gHMinus->SetPointError(i-firstbin,xerr,xerr,yerr,yerr);
673 removeXErrors(TGraphAsymmErrors* g)
675 TGraphAsymmErrors* gClone=(TGraphAsymmErrors*)g->Clone();
677 double* eYHigh=gClone->GetEYhigh();
678 double* eYLow=gClone->GetEYlow();
680 for(
int i=0;i<g->GetN(); i++){
681 gClone->SetPointError(i,0,0,eYLow[i],eYHigh[i]);
686 void drawAxisBins(TGraphAsymmErrors* g,
float size,
float yMax)
689 TLine* li=
new TLine; li->SetLineWidth(1);
692 double* eXLow=g->GetEXlow();
693 double* eXHigh=g->GetEXhigh();
696 for(
int i=0; i<g->GetN(); i++){
697 double low = x[i]-eXLow[i];
698 double high= x[i]+eXHigh[i];
702 li->DrawLine(low,yMax-size,low,yMax);
703 li->DrawLine(high,yMax-size,high,yMax);