7 TH2D* HistSlice(TH3* h3,
const char* basename,
const char* basetitle,
8 const char* slicename, Axis_t min, Axis_t max,
14 TH2D* HistSlice(TH3* h3,
const char* basename,
const char* basetitle,
15 const char* slicename,
const char* slicetype);
18 TH1D* HistSlice(TH2* h2,
const char* basename,
const char* basetitle,
19 const char* slicename,Axis_t min, Axis_t max,
28 TH1D* HistSlice(TH3* h3,
const char* basename,
const char* basetitle,
29 const char* slicename1,Axis_t min1, Axis_t max1,
30 const char* slicename2,Axis_t min2, Axis_t max2,
31 const char* projecttype,
34 TProfile* Profile(TH3* h3,
const char* basename,
const char* basetitle,
35 const char* slicename, Axis_t min, Axis_t max,
36 const char* slicetype,
37 const char* projecttype,
40 TProfile* Profile(TH2* h2,
const char* basename,
const char* basetitle,
41 const char* slicename, Axis_t min, Axis_t max,
45 TH1D* Rms(TH3* h3,
const char* basename,
const char* basetitle,
46 const char* slicename, Axis_t min, Axis_t max,
47 const char* slicetype,
48 const char* projecttype);
49 TH1D* Rms(TH2* h2,
const char* basename,
50 const char* projecttype);
53 void Rebin(TH3* h3,
int axisType,
int nBin,Axis_t* ary);
55 Int_t FindMinBin(
const TAxis* axis,Stat_t val);
56 Int_t FindMaxBin(
const TAxis* axis,Stat_t val);
57 void SetRange(
const TAxis* axis,Stat_t min,Stat_t max);
58 Stat_t FindMax(TH1* ha,TH1* hb);
59 Stat_t FindMin(TH1* ha,TH1* hb);
60 Stat_t FindMax(TH1* ha,TH1* hb,TH1* hc);
61 void Divide(TCanvas* c1,
int nx,
int ny,
const char* title=0,
const char* file=0);
62 void Print(TCanvas* c1,
const char* outDir, TString basename);
64 void SetMinMax(TH1* h);
65 void SetMinMax(TH1* h,
float min,
float max);
66 void GetMeanRms(TH1* ha,
float& cmean,
float& crms);
67 void GetMeanRmsYield(TH1* ha,
float& cmean,
float& crms);
68 void PrintMeanRms(TH1* ha,
float x,
float y,
float size=0.04);
69 void PrintMeanRmsYield(TH1* ha,
float x,
float y,
float size=0.04);
70 void ReplaceTitle(TH1* h,
char* current,
char* replace);
71 void DrawLine(TH1* h,
float y=0);
73 void showHistogramValues(TH1D* h1,
char* more=0);
74 void showTGraphValues(TGraphAsymmErrors* graph,
char* more=0);
77 void dump(TGraphAsymmErrors* g);
81 void DrawLine(TH1* h,
float y)
83 TLine* line=
new TLine; TAxis* axis=h->GetXaxis();
84 line->DrawLine(axis->GetBinLowEdge(axis->GetFirst()),y,
85 axis->GetBinUpEdge(axis->GetLast()),y);
89 void ReplaceTitle(TH1* h,
char* current,
char* replace)
91 TString s=h->GetTitle();
92 s.ReplaceAll(current,replace);
93 h->SetTitle(s.Data());
96 void SetMinMax(TH1* h,
float min,
float max)
102 void SetMinMax(TH1* h)
104 h->SetMinimum(h->GetMinimum()*0.8);
105 h->SetMaximum(h->GetMaximum()*1.2);
108 void GetMeanRms(TH1* ha,
float& mean,
float& rms)
110 TAxis* axis=ha->GetXaxis();
114 for(
int i=axis->GetFirst(); i<=axis->GetLast(); i++){
115 if(ha->GetBinContent(i)>0){
116 float val = (ha->GetBinCenter(i)*ha->GetBinContent(i));
122 n=ha->Integral(axis->GetFirst(),axis->GetLast());
125 mean /= n; rms /= n; rms=sqrt(rms - mean*mean);
129 void GetMeanRmsYield(TH1* ha,
float& mean,
float& rms)
131 TAxis* axis=ha->GetXaxis();
137 for(
int i=axis->GetFirst(); i<=axis->GetLast(); i++){
138 if(ha->GetBinContent(i)>0){
139 float val = ha->GetBinContent(i);
146 n=axis->GetLast()-axis->GetFirst()+1;
150 mean /= n; rms /= n; rms=sqrt(rms - mean*mean);
155 void PrintMeanRms(TH1* ha,
float x,
float y,
float size)
157 TText* text=
new TText;
float mean(0),rms(0);
158 text->SetTextSize(size);
160 mean = ha->GetMean(); rms = ha->GetRMS();
162 sprintf(buf,
"mean: %.3f",mean);
163 text->DrawTextNDC(x,y,buf);
164 sprintf(buf,
"rms: %.3f",rms);
165 text->DrawTextNDC(x,y-0.05,buf);
168 void PrintMeanRmsYield(TH1* ha,
float x,
float y,
float size)
170 TText* text=
new TText;
float mean(0),rms(0);
171 text->SetTextSize(size);
174 GetMeanRmsYield(ha,mean,rms);
175 sprintf(buf,
"mean: %.3f",mean);
176 text->DrawTextNDC(x,y,buf);
177 sprintf(buf,
"rms: %.3f",rms);
178 text->DrawTextNDC(x,y-0.05,buf);
183 void Divide(TCanvas *c1,
int nx,
int ny,
const char* title,
const char* file)
186 TString cTitle = (title) ? title : c1->GetTitle();
187 if(title) c1->SetTitle(title);
189 TPaveLabel *mP =
new TPaveLabel(.02,.95,.5,.98,title);
191 mP->SetBorderSize(0);
196 tFile.SetTextSize(0.02);
197 tFile.DrawTextNDC(0.1,0.0,file);
203 Double_t dy = ymax/ny;
205 Double_t ymargin = 0.02;
206 double xmargin = 0.02;
208 for (Int_t iy=0;iy<ny;iy++) {
209 double yhigh = ymax - iy*dy - ymargin;
210 double ylow = yhigh - dy + 3*ymargin;
211 if (ylow < 0) ylow = 0;
212 if (ylow > yhigh)
continue;
213 for (Int_t ix=0;ix<nx;ix++) {
215 double xlow = ix*dx + xmargin;
216 double xhigh = xlow +dx -2*xmargin;
217 if (xlow > xhigh)
continue;
219 TPad* p =
new TPad(buf,buf,xlow,ylow,xhigh,yhigh);
229 FindMinBin(
const TAxis* axis,Stat_t val)
231 Int_t bin = axis->FindBin(val);
233 return (axis->GetBinCenter(bin)<val) ? ++bin : bin;
238 Int_t FindMaxBin(
const TAxis* axis,Stat_t val)
240 Int_t bin = axis->FindBin(val);
241 if(bin>axis->GetNbins())
return axis->GetNbins();
242 return (axis->GetBinCenter(bin)>val) ? --bin : bin;
245 void SetRange(
const TAxis* axis, Stat_t min, Stat_t max)
247 axis->SetRange(FindMinBin(axis,min),FindMaxBin(axis,max));
250 FindMax(TH1* ha, TH1* hb)
252 Stat_t maxa = ha->GetMaximum();
253 Stat_t maxb = hb->GetMaximum();
254 return (maxa > maxb) ? maxa : maxb;
259 FindMin(TH1* ha, TH1* hb)
261 Stat_t mina = ha->GetMinimum();
262 Stat_t minb = hb->GetMinimum();
263 return (mina > minb) ? mina : minb;
268 FindMax(TH1* ha,TH1* hb,TH1* hc)
270 Stat_t max1 = FindMax(ha,hb);
271 Stat_t max2 = FindMax(hb,hc);
272 return (max1>max2) ? max1 : max2;
278 TH2D* HistSlice(TH3* h3,
279 const char* basename,
const char* basetitle,
280 const char* slicename, Axis_t min, Axis_t max,
281 const char* slicetype,
284 char name[200], title[200],option[20],buf[100];
285 Int_t minBin, maxBin;
290 cout <<
"Null pointer for h3 : " << basename << endl;
297 TAxis* axis = 0; TAxis* yAxis=0,*xAxis=0;
298 if(strcmp(slicetype,
"yz")==0 || strcmp(slicetype,
"zy")==0 ){
299 axis = h3->GetXaxis();
300 if(strcmp(slicetype,
"yz")==0){ yAxis=h3->GetYaxis(); xAxis=h3->GetZaxis();}
301 else { yAxis=h3->GetZaxis(); xAxis=h3->GetYaxis(); }
304 else if (strcmp(slicetype,
"xz")==0 || strcmp(slicetype,
"zx")==0){
305 axis = h3->GetYaxis();
306 if(strcmp(slicetype,
"xz")==0){ yAxis=h3->GetXaxis(); xAxis=h3->GetZaxis();}
307 else { yAxis=h3->GetZaxis(); xAxis=h3->GetXaxis(); }
310 else if (strcmp(slicetype,
"xy")==0 || strcmp(slicetype,
"yx")==0){
311 axis = h3->GetZaxis();
312 if(strcmp(slicetype,
"xy")==0){ yAxis=h3->GetXaxis(); xAxis=h3->GetYaxis();}
313 else { yAxis=h3->GetYaxis(); xAxis=h3->GetXaxis(); }
316 cerr <<
"Wrong value for slice axis for " << basename << endl;
321 minBin = 1; maxBin = axis->GetNbins();
324 minBin = FindMinBin(axis,min);
325 maxBin = FindMaxBin(axis,max);
327 sprintf(option,
"%s%s",slicetype,opt);
330 strcpy(buf,axis->GetTitle()); slicename=buf;
334 axis->SetRange(minBin,maxBin);
336 h2 = (TH2D*) h3->Project3D(option);
337 h2->SetYTitle(yAxis->GetTitle());
338 h2->SetXTitle(xAxis->GetTitle());
341 mmin = axis->GetBinLowEdge(minBin);
342 mmax = axis->GetBinUpEdge(maxBin);
345 sprintf(name,
"%s(%.2f<%s<%.2f)",basename,mmin,slicename,mmax);
346 sprintf(title,
"%s (%.2f<%s<%.2f)",basetitle,mmin,slicename,mmax);
348 h2->SetName(name); h2->SetTitle(title);
350 axis->SetRange(0,9999999);
357 TH2D* HistSlice(TH3* h3,
const char* basename,
const char* basetitle,
358 const char* slicename,
const char* slicetype)
360 TString opt = slicetype;
362 int projX=-1,projY=-1,projZ=-1;
364 if(opt.Contains(
"xy")){ projX=1; projY=0; projZ=2; }
365 else if(opt.Contains(
"yx")){ projX=0; projY=1; projZ=2;}
366 else if(opt.Contains(
"zy")){ projX=1; projY=2; projZ=0; }
367 else if(opt.Contains(
"yz")){ projX=2; projY=1; projZ=0; }
368 else if(opt.Contains(
"xz")){ projX=2; projY=0; projZ=1; }
369 else if(opt.Contains(
"zx")){ projX=0; projY=2; projZ=1; }
371 TAxis* xAxis=0, *yAxis=0, *zAxis=0;
373 case 0: xAxis = h3->GetXaxis();
break;
374 case 1: xAxis = h3->GetYaxis();
break;
375 case 2: xAxis = h3->GetZaxis();
break;
378 case 0: yAxis = h3->GetXaxis();
break;
379 case 1: yAxis = h3->GetYaxis();
break;
380 case 2: yAxis = h3->GetZaxis();
break;
383 case 0: zAxis = h3->GetXaxis();
break;
384 case 1: zAxis = h3->GetYaxis();
break;
385 case 2: zAxis = h3->GetZaxis();
break;
389 int ixmin = xAxis->GetFirst();
390 int ixmax = xAxis->GetLast();
391 int iymin = yAxis->GetFirst();
392 int iymax = yAxis->GetLast();
393 int izmin = zAxis->GetFirst();
394 int izmax = zAxis->GetLast();
395 int nx = ixmax-ixmin+1;
396 int ny = iymax-iymin+1;
397 int nz = izmax-izmin+1;
399 char* name =
new char[strlen(basename)+200];
400 char* title =
new char[strlen(basename)+200];
402 sprintf(name,
"%sSbin%dto%d",basename,izmin,izmax);
403 sprintf(title,
"%s(%.2f<%s<%.2f)",basetitle,
404 zAxis->GetBinLowEdge(izmin),slicename,zAxis->GetBinUpEdge(izmax));
418 double* xAry=0; xAry=xAxis->GetXbins()->GetArray();
419 double* yAry=0; yAry=yAxis->GetXbins()->GetArray();
424 h2=(TH2D*) h3->Project3D(slicetype);
425 h2->SetName(name); h2->SetTitle(title);
430 h2=
new TH2D(name,title,
431 nx,&xAry[ixmin-1],ny,&yAry[iymin-1]);
435 int iBinXreal=0, iBinYreal=0, iBinZreal=0;
436 for(
int ix=ixmin; ix<=ixmax; ix++){
438 case 0: iBinXreal = ix;
break;
439 case 1: iBinYreal = ix;
break;
440 case 2: iBinZreal = ix;
break;
442 for(
int iy=iymin; iy<=iymax; iy++){
444 case 0: iBinXreal = iy;
break;
445 case 1: iBinYreal = iy;
break;
446 case 2: iBinZreal = iy;
break;
449 for(
int iz=izmin; iz<=izmax; iz++){
451 case 0: iBinXreal = iz;
break;
452 case 1: iBinYreal = iz;
break;
453 case 2: iBinZreal = iz;
break;
455 int bin = h3->GetBin(iBinXreal,iBinYreal,iBinZreal);
456 h2->Fill(xAxis->GetBinCenter(ix),
457 yAxis->GetBinCenter(iy),h3->GetBinContent(bin));
468 TH1D* HistSlice(TH2* h2,
const char* basename,
const char* basetitle,
469 const char* slicename,Axis_t min, Axis_t max,
470 const char* projaxis,
473 char name[200], title[200];
474 Axis_t mmin(0),mmax(0);
475 Int_t minBin(0), maxBin(0);
480 if(strcmp(projaxis,
"x")==0){
481 axis = h2->GetYaxis();
483 else if(strcmp(projaxis,
"y")==0){
484 axis = h2->GetXaxis();
487 cout <<
"The argument must be either 'x' or 'y' " << endl;
492 minBin = 1; maxBin = axis->GetNbins();
496 minBin = FindMinBin(axis,min);
497 maxBin = FindMaxBin(axis,max);
500 if(strcmp(projaxis,
"x")==0){
501 h1= h2->ProjectionX(
"dummy",minBin,maxBin,opt);
503 strcpy(buf,axis->GetTitle()); slicename=buf;
505 h1->SetXTitle(h2->GetXaxis()->GetTitle());
507 else if(strcmp(projaxis,
"y")==0){
508 h1= h2->ProjectionY(
"dummy",minBin,maxBin,opt);
510 strcpy(buf,axis->GetTitle()); slicename=buf;
512 h1->SetXTitle(h2->GetYaxis()->GetTitle());
515 mmin = axis->GetBinLowEdge(minBin);
516 mmax = axis->GetBinUpEdge(maxBin);
522 sprintf(name,
"%s(%.2f<%s<%.2f)",basename,mmin,slicename,mmax);
523 sprintf(title,
"%s (%.2f<%s<%.2f)",basetitle,mmin,slicename,mmax);
530 TH1D* HistSlice(TH3* h3,
const char* basename,
const char* basetitle,
531 const char* slicename1,Axis_t min1, Axis_t max1,
532 const char* slicename2,Axis_t min2, Axis_t max2,
533 const char* projecttype,
537 char buf1[100],buf2[100];
538 TAxis* axis1, *axis2;
539 if(strcmp(projecttype,
"x")==0){
540 strcpy(slicetype,
"zx");
541 axis1=h3->GetYaxis(); axis2=h3->GetZaxis();
543 else if(strcmp(projecttype,
"y")==0){
544 strcpy(slicetype,
"xy");
545 axis1=h3->GetZaxis(); axis2=h3->GetXaxis();
547 else if(strcmp(projecttype,
"z")==0){
548 strcpy(slicetype,
"yz");
549 axis1=h3->GetXaxis(); axis2=h3->GetYaxis();
552 cout <<
"error: wrong project type " << basename << endl;
556 strcpy(buf1,axis1->GetTitle()); slicename1=buf1;
559 strcpy(buf2,axis2->GetTitle()); slicename2=buf2;
563 (TH2D*) HistSlice(h3,basename,basetitle,
564 slicename1,min1,max1,
567 return HistSlice(h2,h2->GetName(),h2->GetTitle(),
568 slicename2,min2,max2,
573 TProfile* Profile(TH3* h3,
const char* basename,
const char* basetitle,
574 const char* slicename, Axis_t min, Axis_t max,
575 const char* slicetype,
576 const char* projecttype,
580 TH2D* h2 = HistSlice(h3,basename,basetitle,slicename,min,max,
585 if(strstr(projecttype,
"x")){
586 sprintf(name,
"%s_profx",h2->GetName());
587 p=h2->ProfileX(name,0,9999999,opt);
590 sprintf(name,
"%s_profy",h2->GetName());
591 p=h2->ProfileY(name,0,9999999,opt);
593 p->SetTitle(h2->GetTitle());
597 TProfile* Profile(TH2* h2,
const char* basename,
const char* basetitle,
598 const char* slicename, Axis_t min, Axis_t max,
599 const char* profaxis,
603 char name[200], title[200];
604 Axis_t mmin(0),mmax(0);
605 Int_t minBin(0), maxBin(0);
609 if(strcmp(profaxis,
"x")==0){
610 axis = h2->GetYaxis();
612 else if(strcmp(profaxis,
"y")==0){
613 axis = h2->GetXaxis();
616 cout <<
"The argument must be either 'x' or 'y' " << endl;
621 minBin = 1; maxBin = axis->GetNbins();
625 minBin = FindMinBin(axis,min);
626 maxBin = FindMaxBin(axis,max);
629 if(strcmp(profaxis,
"x")==0){
630 p= h2->ProfileX(
"dummy",minBin,maxBin,opt);
632 strcpy(buf,axis->GetTitle()); slicename=buf;
634 p->SetXTitle(h2->GetXaxis()->GetTitle());
636 else if(strcmp(profaxis,
"y")==0){
637 p= h2->ProfileY(
"dummy",minBin,maxBin,opt);
639 strcpy(buf,axis->GetTitle()); slicename=buf;
641 p->SetXTitle(h2->GetYaxis()->GetTitle());
644 mmin = axis->GetBinLowEdge(minBin);
645 mmax = axis->GetBinUpEdge(maxBin);
651 sprintf(name,
"%s(%.2f<%s<%.2f)",basename,mmin,slicename,mmax);
652 sprintf(title,
"%s (%.2f<%s<%.2f)",basetitle,mmin,slicename,mmax);
660 TProfile* Rms(TH2* h2,
const char* basename,
661 const char* projecttype)
663 char name[100], xtitle[100];
665 if(strstr(projecttype,
"x")){
666 p=h2->ProfileX(
"dummy",1,h2->GetNbinsY(),
"s");
667 strcpy(xtitle,h2->GetXaxis()->GetTitle());
669 else if(strstr(projecttype,
"y")){
670 p=h2->ProfileY(
"dummy",1,h2->GetNbinsX(),
"s");
671 strcpy(xtitle,h2->GetYaxis()->GetTitle());
674 cout <<
"wrong type " << projecttype << endl; exit(1);
676 sprintf(name,
"%s%s_%s",h2->GetName(),basename,projecttype);
678 sprintf(name,
"%s_%s_rms",h2->GetName(),basename,projecttype);
679 Int_t nBin= p->GetNbinsX();
680 TH1* h1 =
new TH1D(name,name,nBin,
681 p->GetXaxis()->GetBinLowEdge(1),
682 p->GetXaxis()->GetBinUpEdge(nBin));
684 for(
int i=1;i<=nBin;i++){
685 h1->SetBinContent(i,p->GetBinError(i));
687 h1->SetBinError(i,p->GetBinContent(i)*.001);
689 h1->SetXTitle(xtitle);
693 TH1D* Rms(TH3* h3,
const char* basename,
const char* basetitle,
694 const char* slicename, Axis_t min, Axis_t max,
695 const char* slicetype,
696 const char* projecttype)
698 char name[200]; sprintf(name,
"%s_prms",basename);
699 TProfile* p = Profile(h3,name,basetitle,slicename,
700 min,max,slicetype,projecttype,
"s");
704 sprintf(name,
"%s_h1",p->GetName());
705 Int_t nBin= p->GetNbinsX();
706 TH1D* h1 =
new TH1D(name,p->GetTitle(),nBin,
707 p->GetXaxis()->GetBinLowEdge(1),
708 p->GetXaxis()->GetBinUpEdge(nBin));
711 for(
int i=1;i<=nBin;i++){
712 h1->SetBinContent(i,p->GetBinError(i));
714 h1->SetBinError(i,p->GetBinContent(i)*.001);
716 h1->SetXTitle(p->GetXaxis()->GetTitle());
722 Printps(TCanvas* c1,
const char* outDir, TString basename)
725 if(!basename.EndsWith(
".ps")) basename +=
".ps";
726 TString s = outDir; s +=
"/"; s += basename;
732 Printgif(TCanvas* c1,
const char* outDir, TString basename)
735 if(!basename.EndsWith(
".gif")) basename +=
".gif";
736 TString s = outDir; s +=
"/"; s += basename;
743 Rebin(TH3* h3,
int axisType,
int nBin, Axis_t* ary)
745 if(!h3) { cout <<
"null pointer?" << endl;
return; }
749 TH3* hClone = (TH3*)h3->Clone();
750 TString name = h3->GetName(); name +=
"Clone";
752 hClone->SetName(name.Data());
754 TAxis *rebinAxis=0, *aAxis=0, *bAxis=0;
755 TAxis *xAxis=hClone->GetXaxis(),
756 *yAxis=hClone->GetYaxis(), *zAxis=hClone->GetZaxis();
757 TAxis *newAxis,*newAaxis,*newBaxis;
761 rebinAxis=xAxis; aAxis=yAxis; bAxis=zAxis;
762 newAxis=h3->GetXaxis(); newAaxis=h3->GetYaxis(); newBaxis=h3->GetZaxis();
765 rebinAxis=yAxis; aAxis=xAxis; bAxis=zAxis;
766 newAxis=h3->GetYaxis(); newAaxis=h3->GetXaxis(); newBaxis=h3->GetZaxis();
769 rebinAxis=zAxis; aAxis=xAxis; bAxis=yAxis;
770 newAxis=h3->GetZaxis(); newAxis=h3->GetXaxis(); newBaxis=h3->GetYaxis();
772 default: cout <<
"Wrong axis type: " << axisType << endl; exit(-1);
777 cout <<
"old axis " << rebinAxis->GetNbins() << endl;
778 newAxis->Set(nBin,ary);
779 cout <<
"new axis " << newAxis->GetNbins() << endl;
781 int aNbin=aAxis->GetNbins(), bNbin=bAxis->GetNbins();
782 double* aAry =
new double[aAxis->GetNbins()+1];
783 double* bAry =
new double[bAxis->GetNbins()+1];
785 for(
int i=0; i<aNbin; i++){
787 aAry[i]=aAxis->GetBinLowEdge(bin);
789 aAry[aNbin] = aAxis->GetBinUpEdge(aNbin);
790 newAaxis->Set(aNbin,aAry);
792 for(
int i=0; i<bNbin; i++){
794 bAry[i]=bAxis->GetBinLowEdge(bin);
796 bAry[bNbin] = bAxis->GetBinUpEdge(bNbin);
797 newBaxis->Set(bNbin,bAry);
799 delete aAry;
delete bAry;
804 int iBinXreal=0, iBinYreal=0, iBinZreal=0, bin=0;
806 for(
int aBin=1; aBin<=aAxis->GetNbins(); aBin++){
807 for(
int bBin=1; bBin<=bAxis->GetNbins(); bBin++){
808 for(
int newBin=1; newBin<=nBin; newBin++){
811 for(
int rebinBin=1; rebinBin<=rebinAxis->GetNbins(); rebinBin++){
812 if(newAxis->FindBin(rebinAxis->GetBinCenter(rebinBin))==newBin){
814 case 0: iBinXreal=rebinBin; iBinYreal=aBin; iBinZreal=bBin;
break;
815 case 1: iBinXreal=aBin; iBinYreal=rebinBin; iBinZreal=bBin;
break;
816 case 2: iBinXreal=aBin; iBinYreal=bBin; iBinZreal=rebinBin;
break;
818 bin = hClone->GetBin(iBinXreal, iBinYreal, iBinZreal);
819 newval += hClone->GetBinContent(bin);
824 case 0: iBinXreal=newBin; iBinYreal=aBin; iBinZreal=bBin;
break;
825 case 1: iBinXreal=aBin; iBinYreal=newBin; iBinZreal=bBin;
break;
826 case 2: iBinXreal=aBin; iBinYreal=bBin; iBinZreal=newBin;
break;
828 bin = h3->GetBin(iBinXreal,iBinYreal,iBinZreal);
829 h3->SetBinContent(bin,newval);
859 delete hClone;
delete aAry;
delete bAry;
869 cout << h1->GetName() << endl;
870 Int_t nBin = h1->GetNbinsX();
872 for(Int_t i=1; i<=nBin; i++){
873 float errorFrac = (h1->GetBinContent(i)>0)?
874 h1->GetBinError(i)/h1->GetBinContent(i) : 0;
876 printf(
"\t%d : %.4f -- %.4f \t%.4f \t%.4f \t%.4f\n",
878 h1->GetXaxis()->GetBinLowEdge(i),
879 h1->GetXaxis()->GetBinUpEdge(i),
880 h1->GetBinContent(i),
889 cout << g->GetName() << endl;
890 double *x = g->GetX();
891 double *y = g->GetY();
893 for(
int i=0; i<g->GetN(); i++){
894 printf(
"\t%d : %.4f \t %.4f\n",i,x[i],y[i]);
899 dump(TGraphAsymmErrors* graph)
901 double* xValues = graph->GetX();
902 double* yValues = graph->GetY();
903 double* errXLow = graph->GetEXlow();
904 double* errXHigh = graph->GetEXhigh();
906 double* errYLow = graph->GetEYlow();
907 double* errYHigh = graph->GetEYhigh();
909 for(
int i=0; i<graph->GetN(); i++){
910 printf(
"\t%d : %.4f < %.4f <%.4f \t %.3e %.3e\n",
911 i,xValues[i]-errXLow[i],xValues[i],xValues[i]+errXHigh[i],
912 yValues[i],errYLow[i]);
920 showHistogramValues(TH1D* h1,
char* more)
922 *ofVal <<
"#################################################" << endl;
923 *ofVal << h1->GetName();
924 if(more) *ofVal <<
":::::"<<more << endl;
927 Int_t nBin = h1->GetNbinsX();
933 for(Int_t i=1; i<=nBin; i++){
934 errorFrac = (h1->GetBinContent(i)>0)?
935 h1->GetBinError(i)/h1->GetBinContent(i) : 0;
937 *ofVal <<
"\t" << h1->GetXaxis()->GetBinLowEdge(i) <<
" < pt < "
938 << h1->GetXaxis()->GetBinUpEdge(i) <<
" "
939 <<
"\t" << h1->GetBinContent(i) <<
" \t" << h1->GetBinError(i)
940 <<
"\t" << errorFrac << endl;
948 showTGraphValues(TGraphAsymmErrors* graph,
char* more)
950 *ofVal <<
"#################################################" << endl;
951 *ofVal << graph->GetName() <<
":::::" << more << endl;
953 const Int_t nBin = graph->GetN();
954 Double_t* xValues = graph->GetX();
955 Double_t* yValues = graph->GetY();
956 Double_t* errYHigh = graph->GetEYhigh();
957 Double_t* errXLow = graph->GetEXlow();
958 Double_t* errXHigh = graph->GetEXhigh();
960 Double_t lowEdge, upEdge, errorFrac;
962 for(Int_t i=0; i<nBin; i++){
963 lowEdge = xValues[i] - errXLow[i];
964 upEdge = xValues[i] + errXHigh[i];
966 errorFrac = errYHigh[i]/yValues[i];
968 *ofVal <<
"\t" << lowEdge <<
"<" << xValues[i] <<
"<" << upEdge
969 <<
"\t" << yValues[i] <<
"\t" << errYHigh[i] <<
"\t" << errorFrac
974 void scale2D(TH2* h2)
976 TAxis *xAxis=h2->GetXaxis();
977 TAxis *yAxis=h2->GetYaxis();
979 for(
int ix=1; ix<=xAxis->GetNbins(); ix++){
982 for(
int iy=1; iy<=yAxis->GetNbins(); iy++){
983 int bin=h2->GetBin(ix,iy);
984 sum += h2->GetBinContent(bin);
987 for(
int iy=1; iy<=yAxis->GetNbins(); iy++){
988 int bin=h2->GetBin(ix,iy);
990 h2->SetBinContent(bin,h2->GetBinContent(bin)/sum);