21 #ifndef ROOT_TVirtualPad
22 #include "TVirtualPad.h"
36 #ifndef ROOT_TGraphErrors
37 #include "TGraphErrors.h"
77 TH1F* histNew =
new TH1F(Form(
"%s_inv", hist->GetName()),
78 Form(
"%s (inverted)", hist->GetTitle()),
80 hist->GetXaxis()->GetXmin(),
81 hist->GetXaxis()->GetXmax());
83 const Int_t nBins = hist->GetNbinsX();
85 for(Int_t i = 1; i <= nBins; i++) {
87 if(hist->GetBinContent(i) == 0)
90 histNew->SetBinContent(i, 1.0/hist->GetBinContent(i));
91 histNew->SetBinError(i, hist->GetBinError(i)/hist->GetBinContent(i)/hist->GetBinContent(i));
99 TH1F*
HistLog(
const char* name,
const char* title, Int_t nBins, Double_t xMin, Double_t xMax)
101 if(xMin==0) xMin = xMax*1e-6;
102 const Int_t nTot = nBins+1;
103 Double_t fac = TMath::Power(xMax/xMin,1./(nTot));
104 Double_t xbins[nTot];
106 for (Int_t i=0;i<nTot;i++){
113 TH1F* h =
new TH1F(name,title,nBins,xbins);
120 TH2F*
HistLogLog(
const char* name,
const char* title, Int_t nBinsX, Double_t xMinX, Double_t xMaxX, Int_t nBinsY, Double_t xMinY, Double_t xMaxY)
122 if(xMinX==0) xMinX = xMaxX*1e-6;
123 Double_t facX = TMath::Power(xMaxX/xMinX,1./(nBinsX+1));
124 Double_t xbinsX[nBinsX+1];
125 for (Int_t i=0;i<=nBinsX;i++){
131 if(xMinY==0) xMinY = xMaxY*1e-6;
132 Double_t facY = TMath::Power(xMaxY/xMinY,1./(nBinsY+1));
133 Double_t xbinsY[nBinsY+1];
134 for (Int_t i=0;i<=nBinsY;i++){
140 TH2F* h =
new TH2F(name,title,nBinsX,xbinsX,nBinsY,xbinsY);
147 TH2F*
HistLinLog(
const char* name,
const char* title, Int_t nBinsX, Double_t xMinX, Double_t xMaxX, Int_t nBinsY, Double_t xMinY, Double_t xMaxY)
149 if(xMinY==0) xMinY = xMaxY*1e-6;
150 Double_t fac = TMath::Power(xMaxY/xMinY,1./(nBinsY+1));
151 Double_t xbinsY[nBinsY+1];
152 for (Int_t i=0;i<=nBinsY;i++){
158 TH2F* h =
new TH2F(name,title,nBinsX,xMinX,xMaxX,nBinsY,xbinsY);
164 TH2F*
HistLogLin(
const char* name,
const char* title, Int_t nBinsX, Double_t xMinX, Double_t xMaxX, Int_t nBinsY, Double_t xMinY, Double_t xMaxY)
166 if(xMinX==0) xMinX = xMaxX*1e-6;
167 Double_t fac = TMath::Power(xMaxX/xMinX,1./(nBinsX+1));
168 Double_t xbinsX[nBinsX+1];
169 for (Int_t i=0;i<=nBinsX;i++){
175 TH2F* h =
new TH2F(name,title,nBinsX,xbinsX,nBinsY,xMinY,xMaxY);
185 hist->SetMaximum(hist->GetBinContent(hist->GetMaximumBin())*factor);
189 void SetTitles(TH1* hist,
const char* title,
const char* xtitle,
const char* ytitle)
191 hist->SetTitle(title);
192 hist->GetXaxis()->SetTitle(xtitle);
193 hist->GetYaxis()->SetTitle(ytitle);
201 Double_t *x = g->GetX();
202 Double_t *y = g->GetY();
205 Double_t xmin = TMath::MinElement(n,x);
206 Double_t xmax = TMath::MaxElement(n,x);
207 Double_t ymin = TMath::MinElement(n,y);
208 Double_t ymax = TMath::MaxElement(n,y);
210 TH1F* h =
new TH1F(Form(
"%s_hist",g->GetName()),
"",100,xmin,xmax);
214 g->Draw(Form(
"%s same",opt));
221 TVirtualPad*
MakeNiceHisto(TH1* hist, TVirtualPad* c1,
const char* opt, Bool_t copy)
226 Bool_t is2dHist = hist->InheritsFrom(
"TH2");
243 gStyle->SetTitleH(0.08);
244 gStyle->SetTitleW(0.78);
245 gStyle->SetTitleX(0.16);
246 gStyle->SetTitleY(0.99);
247 gStyle->SetTitleFont(132,
" ");
248 gStyle->SetTitleSize(0.09,
" ");
250 hist->GetXaxis()->SetTitleSize(0.07);
251 hist->GetYaxis()->SetTitleSize(0.07);
252 hist->GetZaxis()->SetTitleSize(0.07);
254 hist->GetXaxis()->SetTitleOffset(1.1);
256 hist->GetYaxis()->SetTitleOffset(1.2);
257 hist->GetZaxis()->SetTitleOffset(0.9);
258 hist->GetXaxis()->SetTitleFont(132);
259 hist->GetYaxis()->SetTitleFont(132);
260 hist->GetZaxis()->SetTitleFont(132);
261 hist->GetXaxis()->SetLabelFont(132);
262 hist->GetYaxis()->SetLabelFont(132);
263 hist->GetZaxis()->SetLabelFont(132);
264 hist->GetXaxis()->SetLabelSize(0.06);
265 hist->GetYaxis()->SetLabelSize(0.06);
266 hist->GetZaxis()->SetLabelSize(0.06);
268 hist->GetXaxis()->SetLabelOffset(0.01);
269 hist->GetYaxis()->SetLabelOffset(0.015);
270 hist->GetZaxis()->SetLabelOffset(0.015);
279 Bool_t hasTitle = kTRUE;
280 const char* title = hist->GetTitle();
281 if(title && title[0] ==
'\0')
287 c1->SetLeftMargin(0.18);
288 c1->SetRightMargin(0.03);
290 c1->SetBottomMargin(0.17);
292 c1->SetTopMargin(0.09);
294 c1->SetTopMargin(0.03);
310 Bool_t colz = kFALSE;
311 if (opt.Contains(
"COLZ"))
314 Bool_t hasTitle = kTRUE;
315 const char* title = hist->GetTitle();
316 if(title && title[0] ==
'\0')
320 gStyle->SetTitleW(0.68);
326 c1->SetLeftMargin(0.18);
328 c1->SetRightMargin(0.03);
330 if(strcmp(hist->GetZaxis()->GetTitle(),
"")){
331 c1->SetRightMargin(0.17);
334 c1->SetRightMargin(0.14);
337 c1->SetBottomMargin(0.17);
339 c1->SetTopMargin(0.09);
341 c1->SetTopMargin(0.03);
344 hist->DrawCopy(option);
353 void MakeNiceHistoPad(TH1* hist, TVirtualPad* c1, Double_t scaleX, Double_t scaleY,
const char* opt, Bool_t copy)
359 Bool_t is2dHist = hist->InheritsFrom(
"TH2");
371 void MakeNiceHistoPad(TH1* hist, TVirtualPad* c, Int_t i, Int_t j, Double_t scaleX, Double_t scaleY,
const char* opt, Bool_t copy)
377 sprintf(name,
"%s_%d_%d",c->GetName(),i,j);
378 cout << name << endl;
379 TPad* c1 = ((TPad*) gROOT->FindObject(name));
382 Int_t w = c->GetWw();
383 Double_t wPad = c1->GetWNDC();
384 Int_t h = c->GetWh();
385 Double_t hPad = c1->GetHNDC();
387 cout << w <<
" " << wPad <<
" " << h <<
" " << hPad << endl;
394 Bool_t is2dHist = hist->InheritsFrom(
"TH2");
410 void MakeNice1dHistoPad(TH1* hist, TVirtualPad* c1, Double_t scaleX, Double_t scaleY,
const char* opt, Bool_t copy)
414 cout <<
"MakeNice1dHistoPad " << c1->GetName() << endl;
421 Double_t ratioX = c1->GetWNDC()*scaleX;
422 Double_t ratioY = c1->GetHNDC()*scaleY;
426 hist->GetXaxis()->SetLabelSize(hist->GetXaxis()->GetLabelSize()/ratioY);
427 hist->GetYaxis()->SetLabelSize(hist->GetYaxis()->GetLabelSize()/ratioY);
428 hist->GetZaxis()->SetLabelSize(hist->GetZaxis()->GetLabelSize()/ratioY);
430 hist->GetXaxis()->SetTitleSize(hist->GetXaxis()->GetTitleSize()/ratioY);
431 hist->GetYaxis()->SetTitleSize(hist->GetYaxis()->GetTitleSize()/ratioY);
432 hist->GetZaxis()->SetTitleSize(hist->GetZaxis()->GetTitleSize()/ratioY);
434 hist->GetXaxis()->SetLabelOffset(hist->GetXaxis()->GetLabelOffset()*ratioX);
435 hist->GetYaxis()->SetLabelOffset(hist->GetYaxis()->GetLabelOffset()*ratioY);
436 hist->GetZaxis()->SetLabelOffset(hist->GetZaxis()->GetLabelOffset()*ratioY);
438 hist->GetXaxis()->SetTitleOffset(hist->GetXaxis()->GetTitleOffset()*ratioX);
439 hist->GetYaxis()->SetTitleOffset(hist->GetYaxis()->GetTitleOffset()*ratioY);
440 hist->GetZaxis()->SetTitleOffset(hist->GetZaxis()->GetTitleOffset()*ratioY);
451 void MakeNice2dHistoPad(TH2* hist, TVirtualPad* c1, Double_t scaleX, Double_t scaleY,
const char* option, Bool_t copy)
474 Double_t ratioX = c1->GetWNDC()*scaleX;
475 Double_t ratioY = c1->GetHNDC()*scaleY;
479 hist->GetXaxis()->SetLabelSize(hist->GetXaxis()->GetLabelSize()/ratioX);
480 hist->GetYaxis()->SetLabelSize(hist->GetYaxis()->GetLabelSize()/ratioY);
481 hist->GetZaxis()->SetLabelSize(hist->GetZaxis()->GetLabelSize()/ratioY);
483 hist->GetXaxis()->SetTitleSize(hist->GetXaxis()->GetTitleSize()/ratioX);
484 hist->GetYaxis()->SetTitleSize(hist->GetYaxis()->GetTitleSize()/ratioY);
485 hist->GetZaxis()->SetTitleSize(hist->GetZaxis()->GetTitleSize()/ratioY);
487 hist->GetXaxis()->SetLabelOffset(hist->GetXaxis()->GetLabelOffset()*ratioX);
488 hist->GetYaxis()->SetLabelOffset(hist->GetYaxis()->GetLabelOffset()*ratioY);
489 hist->GetZaxis()->SetLabelOffset(hist->GetZaxis()->GetLabelOffset()*ratioY);
491 hist->GetXaxis()->SetTitleOffset(hist->GetXaxis()->GetTitleOffset()*ratioX);
492 hist->GetYaxis()->SetTitleOffset(hist->GetYaxis()->GetTitleOffset()*ratioY);
493 hist->GetZaxis()->SetTitleOffset(hist->GetZaxis()->GetTitleOffset()*ratioY);
515 hist->DrawCopy(option);
527 cout <<
"Log scale cannot start from 0 or below" << endl;
531 Double_t logxmin = TMath::Log(xmin);
532 Double_t logxmax = TMath::Log(xmax);
533 Double_t binwidth = (logxmax-logxmin)/nbins;
534 const Int_t Nbins = nbins+1;
536 xbins = (Double_t *)malloc(Nbins*
sizeof(*xbins));
538 for (Int_t i = 1; i<=nbins; i++){
539 xbins[i] = TMath::Exp(logxmin+i*binwidth);
540 cout << xbins[i] << endl;
552 Int_t xwidth, Int_t ywidth)
555 TCanvas *c1 = (TCanvas*)gROOT->GetListOfCanvases()->FindObject(canvasName);
557 c1 =
new TCanvas(canvasName, canvasName, xwidth, ywidth);
559 c1->SetWindowSize(xwidth, ywidth);
566 void IntegralWithError(TF1* func, Double_t &integral, Double_t &error,
567 Double_t xlow, Double_t xhigh,
573 func->SetRange(xlow, xhigh);
574 const Double_t* dummy = 0;
575 #if ROOT_VERSION_CODE >= ROOT_VERSION(6,0,0)
576 integral = func->Integral(xlow, xhigh, stepsize);
578 integral = func->Integral(xlow, xhigh, dummy, stepsize);
581 const Int_t npar = func->GetNpar();
583 Double_t covariance[npar][npar];
584 gMinuit->mnemat(&covariance[0][0], func->GetNpar());
586 Double_t partialDiff[npar];
588 for(Int_t i = 0; i < npar; i++) {
590 Double_t par_err = TMath::Sqrt(covariance[i][i]);
603 for(Int_t i = 0; i < npar; i++) {
604 for(Int_t j = 0; j < npar; j++) {
606 cout <<
"sigma2(" << i <<
", " << j <<
") = "
607 << partialDiff[i]*partialDiff[j]*covariance[i][j]
610 sigma2+=partialDiff[i]*partialDiff[j]*covariance[i][j];
614 error = TMath::Sqrt(sigma2);
618 void FunctionWithError(TF1* func, Double_t x, Double_t &value, Double_t &error)
620 value = func->Eval(x);
621 cout <<
"Value : " << value << endl;
623 Int_t npar = func->GetNpar();
625 Double_t covariance[npar][npar];
626 gMinuit->mnemat(&covariance[0][0], func->GetNpar());
628 Double_t partialDiff[npar];
630 for(Int_t i = 0; i < npar; i++) {
632 Double_t par_err = TMath::Sqrt(covariance[i][i]);
633 cout <<
"par_err : " << par_err << endl;
639 for(Int_t i = 0; i < npar; i++) {
640 for(Int_t j = 0; j < npar; j++) {
642 cout <<
"sigma2(" << i <<
", " << j <<
") = "
643 << partialDiff[i]*partialDiff[j]*covariance[i][j]
646 sigma2+=partialDiff[i]*partialDiff[j]*covariance[i][j];
650 error = TMath::Sqrt(sigma2);
656 Double_t stepsize, Int_t parameter,
669 Double_t parameterSave = func->GetParameter(parameter);
671 func->SetParameter(parameter, parameterSave+epsilon);
672 const Double_t* dummy = 0;
673 #if ROOT_VERSION_CODE >= ROOT_VERSION(6,0,0)
674 Double_t int1 = func->Integral(xlow, xhigh, stepsize);
676 Double_t int1 = func->Integral(xlow, xhigh, dummy, stepsize);
679 func->SetParameter(parameter, parameterSave-epsilon);
680 #if ROOT_VERSION_CODE >= ROOT_VERSION(6,0,0)
681 Double_t int2 = func->Integral(xlow, xhigh, stepsize);
683 Double_t int2 = func->Integral(xlow, xhigh, dummy, stepsize);
686 func->SetParameter(parameter, parameterSave);
688 return (int1-int2)/(2*epsilon);
693 Int_t parameter, Double_t epsilon)
705 Double_t parameterSave = func->GetParameter(parameter);
707 cout <<
"parameterSaved : " << parameterSave << endl;
709 func->SetParameter(parameter, parameterSave+epsilon);
710 Double_t func1 = func->Eval(x);
712 func->SetParameter(parameter, parameterSave-epsilon);
713 Double_t func2 = func->Eval(x);
715 func->SetParameter(parameter, parameterSave);
719 return (func1-func2)/(2*epsilon);
725 Int_t n = graph->GetN();
729 Float_t xmin = graph->GetX()[0];
730 Float_t xmax = graph->GetX()[n-1];
731 Float_t dx = (xmax-xmin)/Float_t(n-1);
735 TH1F* hist =
new TH1F(histName, 0, n, xmin, xmax);
737 for(Int_t i = 0; i < n; i++) {
739 Float_t xl = xmin+i*dx-0.5*dx;
740 Float_t xu = xmin+i*dx+0.5*dx;
742 Float_t x = graph->GetX()[i];
743 Float_t y = graph->GetY()[i];
744 Float_t ey = graph->GetEY()[i];
747 cout <<
"ARGGHHHHHH!!!!: " << xl <<
", " << x <<
", " << xu << endl;
749 hist->SetBinContent(i+1, y);
750 hist->SetBinError(i+1, ey);
753 cout << xmin <<
", " << xmax << endl;
761 const Int_t n = hist->GetNbinsX();;
765 TGraph* graph =
new TGraph(n);
767 for(Int_t i = 0; i < n; i++) {
769 graph->SetPoint(i, hist->GetXaxis()->GetBinCenter(i+1),
770 hist->GetBinContent(i));
782 Float_t lMargin, Float_t rMargin,
783 Float_t bMargin, Float_t tMargin)
787 TClonesArray* arr =
new TClonesArray(
"TPad",Nx*Ny);
790 Float_t vSpacing = 0.0;
791 Float_t vStep = (1.- bMargin - tMargin - (Ny-1) * vSpacing) / Ny;
793 Float_t hSpacing = 0.0;
794 Float_t hStep = (1.- lMargin - rMargin - (Nx-1) * hSpacing) / Nx;
798 for (Int_t i=0;i<Nx;i++) {
800 Float_t hposl,hposr,hmarl,hmarr,hfactor;
804 hposl = lMargin + i*(hStep + hSpacing);
806 hposr = hposl + hStep + hSpacing;
812 hfactor = hposr-hposl;
816 hmarl = lMargin / hfactor;
818 hmarr = rMargin / hfactor;
820 for (Int_t j=0;j<Ny;j++) {
822 Float_t vposd,vposu,vmard,vmaru,vfactor;
826 vposd = bMargin + j*(vStep + vSpacing);
828 vposu = vposd + vStep + vSpacing;
834 vfactor = vposu-vposd;
838 vmard = bMargin / vfactor;
840 vmaru = tMargin / vfactor;
846 sprintf(padname,
"%s_%i_%i",C->GetName(),i,j);
847 TPad *pad = (TPad*) gROOT->FindObject(padname);
849 std::cout <<
"NAME = " << padname <<
" " << hposl <<
" " << vposd <<
" " << hposr <<
" " << vposu << std::endl;
851 pad =
new((*arr)[i + Nx*j]) TPad(padname,
"",hposl,vposd,hposr,vposu);
852 pad->SetFillStyle(4000);
853 pad->SetLeftMargin(hmarl);
854 pad->SetRightMargin(hmarr);
855 pad->SetBottomMargin(vmard);
856 pad->SetTopMargin(vmaru);
858 pad->SetFrameBorderMode(0);
859 pad->SetBorderMode(0);
860 pad->SetBorderSize(0);
881 Bool_t is2dHist = h->InheritsFrom(
"TH2");
882 Int_t nbinsX = h->GetXaxis()->GetNbins();
883 Int_t nbinsY = h->GetYaxis()->GetNbins();
884 for(Int_t i = 1; i<=nbinsX; i++){
886 for(Int_t j = 1; j<=nbinsY; j++){
887 h->SetBinContent(i,j,h->GetBinContent(i,j)*scale);
888 h->SetBinError(i,j,h->GetBinError(i,j)*scale);
891 Double_t val = h->GetBinContent(i);
892 Double_t err = h->GetBinError(i);
894 h->SetBinContent(i,val*scale);
895 h->SetBinError(i,err*scale);
907 Int_t nbins1 = h1->GetXaxis()->GetNbins();
908 Int_t nbins2 = h2->GetXaxis()->GetNbins();
909 if(nbins1 != nbins2)
return h1;
914 TH1F* hout = (TH1F*)h1->Clone(Form(
"%s_over_%s",h1->GetName(),h2->GetName()));
917 for(Int_t i = 1; i<=nbins1; i++){
918 Double_t val1 = h1->GetBinContent(i);
919 Double_t err1 = h1->GetBinError(i);
920 Double_t val2 = h2->GetBinContent(i);
921 Double_t err2 = h2->GetBinError(i);
922 if(val2==0)
continue;
923 if(val1==0)
continue;
925 hout->SetBinContent(i,val1/val2);
926 hout->SetBinError(i,val1/val2*(err1/val1 + err2/val2));
937 Bool_t is2dHist = h->InheritsFrom(
"TH2");
938 Int_t nbinsX = h->GetXaxis()->GetNbins();
939 Int_t nbinsY = h->GetYaxis()->GetNbins();
940 for(Int_t i = 1; i<=nbinsX; i++){
941 Double_t widthX = h->GetXaxis()->GetBinWidth(i);
943 for(Int_t j = 1; j<=nbinsY; j++){
944 Double_t widthY = h->GetYaxis()->GetBinWidth(i);
945 h->SetBinContent(i,j,h->GetBinContent(i,j)/widthX/widthY);
946 h->SetBinError(i,j,h->GetBinError(i,j)/widthX/widthY);
949 Double_t val = h->GetBinContent(i);
950 Double_t err = h->GetBinError(i);
952 h->SetBinContent(i,val/widthX);
953 h->SetBinError(i,err/widthX);
962 TGraphErrors* gout =
new TGraphErrors();
965 Int_t n1 = g1->GetN();
966 Double_t *x1 = g1->GetX();
967 Double_t *y1 = g1->GetY();
968 Double_t *ex1 = g1->GetEX();
969 Double_t *ey1 = g1->GetEY();
970 Int_t n2 = g2ex->GetN();
971 Double_t *x2 = g2ex->GetX();
972 Double_t *y2 = g2ex->GetY();
974 Double_t *ey2 = g2ex->GetEY();
976 for(Int_t i1 = 0; i1<n1; i1++){
978 while(i2<n2 && x1[i1]!=x2[i2]) i2++;
979 if(y2[i2] == 0)
continue;
980 gout->SetPoint(i,x1[i],y1[i1]/y2[i2]);
981 if(g1->InheritsFrom(
"TGraphErrors") && ey1[i1] != 0 && ey2[i2] != 0)
982 gout->SetPointError(i,ex1[i1],y1[i1]/y2[i2]*(y1[i1]/ey1[i1]+y2[i2]/ey2[i2]));
993 TGraphErrors* gout =
new TGraphErrors();
995 Int_t n1 = g1->GetN();
996 Double_t *x1 = g1->GetX();
997 Double_t *y1 = g1->GetY();
998 Double_t *ex1 = g1->GetEX();
999 Double_t *ey1 = g1->GetEY();
1000 for(Int_t i1 = 0; i1<n1; i1++){
1001 gout->SetPoint(i1,x1[i1],y1[i1]*scale);
1002 if(g1->InheritsFrom(
"TGraphErrors"))
1003 gout->SetPointError(i1,ex1[i1],ey1[i1]*scale);
1011 TGraphErrors*
AddGraph(TGraph* g1, TGraph* g2, Double_t val)
1013 TGraphErrors* gout =
new TGraphErrors();
1016 Int_t n1 = g1->GetN();
1017 Double_t *x1 = g1->GetX();
1018 Double_t *y1 = g1->GetY();
1019 Double_t *ex1 = g1->GetEX();
1020 Double_t *ey1 = g1->GetEY();
1021 Int_t n2 = g2ex->GetN();
1022 Double_t *x2 = g2ex->GetX();
1023 Double_t *y2 = g2ex->GetY();
1025 Double_t *ey2 = g2ex->GetEY();
1027 for(Int_t i1 = 0; i1<n1; i1++){
1029 while(i2<n2 && x1[i1]!=x2[i2]) i2++;
1030 if(i2 == n2)
continue;
1031 gout->SetPoint(i,x1[i1],y1[i1]+val*y2[i2]);
1032 if(g1->InheritsFrom(
"TGraphErrors"))
1033 gout->SetPointError(i,ex1[i1],ey1[i1]+TMath::Abs(val)*ey2[i2]);
1044 TGraphErrors* gout =
new TGraphErrors();
1046 Int_t n1 = g1->GetN();
1047 Double_t *x1 = g1->GetX();
1048 Double_t *y1 = g1->GetY();
1051 Int_t n2 = g2->GetN();
1052 Double_t *x2 = g2->GetX();
1053 Double_t *y2 = g2->GetY();
1057 for(Int_t i1 = 0; i1<n1; i1++){
1058 Double_t dist = 10000;
1059 for(Int_t i2 = 0; i2<n2; i2++){
1060 Double_t d = (x1[i1]-x2[i2])*(x1[i1]-x2[i2])+(y1[i1]-y2[i2])*(y1[i1]-y2[i2]);
1061 if(d<dist) dist = d;
1063 gout->SetPoint(i,x1[i1],dist);
1079 Int_t n1 = g1->GetN();
1080 Double_t *x1 = g1->GetX();
1081 Double_t *y1 = g1->GetY();
1082 Double_t *ex1 = g1->GetEX();
1083 Double_t *ey1 = g1->GetEY();
1084 Int_t n2 = g2->GetN();
1085 Double_t *x2 = g2->GetX();
1087 if(n1 <= 0)
return 0;
1088 if(n2 <= 0)
return 0;
1089 TGraphErrors* gout =
new TGraphErrors();
1092 Double_t xi1 = x1[0];
1093 Double_t xf1 = x1[n1-1];
1094 for(Int_t i2 = 0; i2<n2; i2++){
1095 Double_t X = x2[i2];
1099 Int_t ip = -1, im = -1;
1100 for(Int_t i1 = 0; i1<n1; i1++){
1101 if(x1[i1]<=X) im = i1;
1102 if(x1[i1]>=X) ip = i1;
1104 if(im < 0)
continue;
1105 if(ip < 0)
continue;
1106 Double_t Y = 0, EX = 0, EY = 0;
1107 if(x1[im] == x1[ip]){
1109 if(g1->InheritsFrom(
"TGraphErrors")){
1114 Double_t fac = (X-x1[im])/(x1[ip]-x1[im]);
1115 Y = y1[im] + fac*(y1[ip]-y1[im]);
1116 if(g1->InheritsFrom(
"TGraphErrors")){
1117 EX = ex1[im] + fac*(ex1[ip]-ex1[im]);
1118 EY = ey1[im] + fac*(ey1[ip]-ey1[im]);
1124 gout->SetPoint(N,X,Y);
1125 gout->SetPointError(N,EX,EY);
TH1F * MakeNiceGraph(TGraph *g, TVirtualPad *c1, const char *opt)
TH2F * HistLogLog(const char *name, const char *title, Int_t nBinsX, Double_t xMinX, Double_t xMaxX, Int_t nBinsY, Double_t xMinY, Double_t xMaxY)
TH2F * HistLogLin(const char *name, const char *title, Int_t nBinsX, Double_t xMinX, Double_t xMaxX, Int_t nBinsY, Double_t xMinY, Double_t xMaxY)
void MakeNice1dHistoPad(TH1 *hist, TVirtualPad *c1, Double_t scaleX, Double_t scaleY, const char *opt, Bool_t copy)
TGraphErrors * DivideGraph(TGraph *g1, TGraph *g2)
TCanvas * FindCanvas(const char *canvasName, Int_t xwidth, Int_t ywidth)
void MakeNiceHistoPad(TH1 *hist, TVirtualPad *c1, Double_t scaleX, Double_t scaleY, const char *opt, Bool_t copy)
TGraphErrors * ScaleGraph(TGraph *g1, Double_t scale)
TH1F * HistLog(const char *name, const char *title, Int_t nBins, Double_t xMin, Double_t xMax)
TClonesArray * CanvasPartition(TVirtualPad *C, const Int_t Nx, const Int_t Ny, Float_t lMargin, Float_t rMargin, Float_t bMargin, Float_t tMargin)
void SetTitles(TH1 *hist, const char *title, const char *xtitle, const char *ytitle)
void SetHistMaximum(TH1 *hist, Float_t factor)
TH1F * ForceRatio(TH1F *h1, TH1F *h2)
void MakeNice1dHisto(TH1 *hist, TVirtualPad *c1, const char *opt, Bool_t copy)
void NormaliseBins(TH1 *h)
const Double_t * MakeLogBinning(Int_t nbins, Double_t xmin, Double_t xmax)
Double_t IntegralDerivative(TF1 *func, Double_t xlow, Double_t xhigh, Double_t stepsize, Int_t parameter, Double_t epsilon)
TGraphErrors * ExtrapolateGraph(TGraph *g1, TGraph *g2)
TVirtualPad * MakeNiceHisto(TH1 *hist, TVirtualPad *c1, const char *opt, Bool_t copy)
void ForceScale(TH1 *h, Double_t scale)
void MakeNice2dHistoPad(TH2 *hist, TVirtualPad *c1, Double_t scaleX, Double_t scaleY, const char *option, Bool_t copy)
void SetHistStyle(TH1 *hist)
TH1F * HistInvert(TH1 *hist)
void MakeNice2dHisto(TH2 *hist, TVirtualPad *c1, const char *option, Bool_t copy)
Double_t FunctionDerivative(TF1 *func, Double_t x, Int_t parameter, Double_t epsilon)
TGraph * GetGraphFromHistogram(TH1 *hist)
TH1F * GetHistogramFromGraph(TGraphErrors *graph, const char *histName)
TH2F * HistLinLog(const char *name, const char *title, Int_t nBinsX, Double_t xMinX, Double_t xMaxX, Int_t nBinsY, Double_t xMinY, Double_t xMaxY)
TGraphErrors * DistGraph(TGraph *g1, TGraph *g2)
TGraphErrors * AddGraph(TGraph *g1, TGraph *g2, Double_t val)