42 extern void H1LeastSquareSeqnd(Int_t n, Double_t *a, Int_t idim, Int_t &ifail, Int_t k, Double_t *b);
85 TGraph::TGraph(): TNamed(), TAttLine(), TAttFill(0, 1000), TAttMarker()
88 if (!CtorAllocate())
return;
95 TGraph::TGraph(Int_t n)
96 : TNamed(
"Graph",
"Graph"), TAttLine(), TAttFill(0, 1000), TAttMarker()
99 if (!CtorAllocate())
return;
100 FillZero(0, fNpoints);
106 TGraph::TGraph(Int_t n,
const Int_t *x,
const Int_t *y)
107 : TNamed(
"Graph",
"Graph"), TAttLine(), TAttFill(0, 1000), TAttMarker()
114 if (!CtorAllocate())
return;
115 for (Int_t i = 0; i < n; i++) {
116 fX[i] = (Double_t)x[i];
117 fY[i] = (Double_t)y[i];
124 TGraph::TGraph(Int_t n,
const Float_t *x,
const Float_t *y)
125 : TNamed(
"Graph",
"Graph"), TAttLine(), TAttFill(0, 1000), TAttMarker()
132 if (!CtorAllocate())
return;
133 for (Int_t i = 0; i < n; i++) {
142 TGraph::TGraph(Int_t n,
const Double_t *x,
const Double_t *y)
143 : TNamed(
"Graph",
"Graph"), TAttLine(), TAttFill(0, 1000), TAttMarker()
150 if (!CtorAllocate())
return;
151 n = fNpoints *
sizeof(Double_t);
159 TGraph::TGraph(
const TGraph &gr)
160 : TNamed(gr), TAttLine(gr), TAttFill(gr), TAttMarker(gr)
162 fNpoints = gr.fNpoints;
163 fMaxSize = gr.fMaxSize;
164 if (gr.fFunctions) fFunctions = (TList*)gr.fFunctions->Clone();
165 else fFunctions =
new TList;
166 if (gr.fHistogram) fHistogram = (TH1F*)gr.fHistogram->Clone();
168 fMinimum = gr.fMinimum;
169 fMaximum = gr.fMaximum;
174 fX =
new Double_t[fMaxSize];
175 fY =
new Double_t[fMaxSize];
178 Int_t n = gr.GetN() *
sizeof(Double_t);
179 memcpy(fX, gr.fX, n);
180 memcpy(fY, gr.fY, n);
186 TGraph& TGraph::operator=(
const TGraph &gr)
189 TNamed::operator=(gr);
190 TAttLine::operator=(gr);
191 TAttFill::operator=(gr);
192 TAttMarker::operator=(gr);
194 fNpoints = gr.fNpoints;
195 fMaxSize = gr.fMaxSize;
200 if (!fFunctions->IsEmpty()) {
201 fFunctions->SetBit(kInvalidObject);
205 while ((obj = fFunctions->First())) {
206 while (fFunctions->Remove(obj)) { }
213 if (gr.fFunctions) fFunctions = (TList*)gr.fFunctions->Clone();
214 else fFunctions =
new TList;
216 if (fHistogram)
delete fHistogram;
217 if (gr.fHistogram) fHistogram =
new TH1F(*(gr.fHistogram));
220 fMinimum = gr.fMinimum;
221 fMaximum = gr.fMaximum;
222 if (fX)
delete [] fX;
223 if (fY)
delete [] fY;
228 fX =
new Double_t[fMaxSize];
229 fY =
new Double_t[fMaxSize];
232 Int_t n = gr.GetN() *
sizeof(Double_t);
234 memcpy(fX, gr.fX, n);
235 memcpy(fY, gr.fY, n);
247 TGraph::TGraph(
const TVectorF &vx,
const TVectorF &vy)
248 : TNamed(
"Graph",
"Graph"), TAttLine(), TAttFill(0, 1000), TAttMarker()
250 fNpoints = TMath::Min(vx.GetNrows(), vy.GetNrows());
251 if (!CtorAllocate())
return;
252 Int_t ivxlow = vx.GetLwb();
253 Int_t ivylow = vy.GetLwb();
254 for (Int_t i = 0; i < fNpoints; i++) {
255 fX[i] = vx(i + ivxlow);
256 fY[i] = vy(i + ivylow);
266 TGraph::TGraph(
const TVectorD &vx,
const TVectorD &vy)
267 : TNamed(
"Graph",
"Graph"), TAttLine(), TAttFill(0, 1000), TAttMarker()
269 fNpoints = TMath::Min(vx.GetNrows(), vy.GetNrows());
270 if (!CtorAllocate())
return;
271 Int_t ivxlow = vx.GetLwb();
272 Int_t ivylow = vy.GetLwb();
273 for (Int_t i = 0; i < fNpoints; i++) {
274 fX[i] = vx(i + ivxlow);
275 fY[i] = vy(i + ivylow);
282 TGraph::TGraph(
const TH1 *h)
283 : TNamed(
"Graph",
"Graph"), TAttLine(), TAttFill(0, 1000), TAttMarker()
286 Error(
"TGraph",
"Pointer to histogram is null");
290 if (h->GetDimension() != 1) {
291 Error(
"TGraph",
"Histogram must be 1-D; h %s is %d-D", h->GetName(), h->GetDimension());
294 fNpoints = ((TH1*)h)->GetXaxis()->GetNbins();
297 if (!CtorAllocate())
return;
299 TAxis *xaxis = ((TH1*)h)->GetXaxis();
300 for (Int_t i = 0; i < fNpoints; i++) {
301 fX[i] = xaxis->GetBinCenter(i + 1);
302 fY[i] = h->GetBinContent(i + 1);
304 h->TAttLine::Copy(*
this);
305 h->TAttFill::Copy(*
this);
306 h->TAttMarker::Copy(*
this);
308 std::string gname =
"Graph_from_" + std::string(h->GetName());
309 SetName(gname.c_str());
310 SetTitle(h->GetTitle());
324 TGraph::TGraph(
const TF1 *f, Option_t *option)
325 : TNamed(
"Graph",
"Graph"), TAttLine(), TAttFill(0, 1000), TAttMarker()
329 Error(
"TGraph",
"Pointer to function is null");
332 fNpoints = f->GetNpx();
333 if (option) coption = *option;
334 if (coption ==
'i' || coption ==
'I') fNpoints++;
336 if (!CtorAllocate())
return;
338 Double_t xmin = f->GetXmin();
339 Double_t xmax = f->GetXmax();
340 Double_t dx = (xmax - xmin) / fNpoints;
343 for (i = 0; i < fNpoints; i++) {
344 if (coption ==
'i' || coption ==
'I') {
345 fX[i] = xmin + i * dx;
346 if (i == 0) fY[i] = 0;
347 else fY[i] = integ + ((TF1*)f)->Integral(fX[i] - dx, fX[i]);
349 }
else if (coption ==
'd' || coption ==
'D') {
350 fX[i] = xmin + (i + 0.5) * dx;
351 fY[i] = ((TF1*)f)->Derivative(fX[i]);
353 fX[i] = xmin + (i + 0.5) * dx;
354 fY[i] = ((TF1*)f)->Eval(fX[i]);
357 if (integ != 0 && coption ==
'I') {
358 for (i = 1; i < fNpoints; i++) fY[i] /= integ;
361 f->TAttLine::Copy(*
this);
362 f->TAttFill::Copy(*
this);
363 f->TAttMarker::Copy(*
this);
365 SetName(f->GetName());
366 SetTitle(f->GetTitle());
383 TGraph::TGraph(
const char *filename,
const char *format, Option_t *option)
384 : TNamed(
"Graph", filename), TAttLine(), TAttFill(0, 1000), TAttMarker()
387 TString fname = filename;
388 gSystem->ExpandPathName(fname);
390 std::ifstream infile(fname.Data());
391 if (!infile.good()) {
393 Error(
"TGraph",
"Cannot open file: %s, TGraph is Zombie", filename);
399 if (!CtorAllocate())
return;
404 if (strcmp(option,
"") == 0) {
406 while (std::getline(infile, line,
'\n')) {
407 if (2 != sscanf(line.c_str(), format, &x, &y)) {
419 TString format_ = TString(format) ;
420 format_.ReplaceAll(
" ",
"") ;
421 format_.ReplaceAll(
"\t",
"") ;
422 format_.ReplaceAll(
"lg",
"") ;
423 format_.ReplaceAll(
"s",
"") ;
424 format_.ReplaceAll(
"%*",
"0") ;
425 format_.ReplaceAll(
"%",
"1") ;
426 if (!format_.IsDigit()) {
427 Error(
"TGraph",
"Incorrect input format! Allowed formats are {\"%%lg\",\"%%*lg\" or \"%%*s\"}");
430 Int_t ntokens = format_.Length() ;
432 Error(
"TGraph",
"Incorrect input format! Only %d tag(s) in format whereas 2 \"%%lg\" tags are expected!", ntokens);
435 Int_t ntokensToBeSaved = 0 ;
436 Bool_t * isTokenToBeSaved =
new Bool_t [ntokens] ;
437 for (Int_t idx = 0; idx < ntokens; idx++) {
438 isTokenToBeSaved[idx] = TString::Format(
"%c", format_[idx]).Atoi() ;
439 if (isTokenToBeSaved[idx] == 1) {
443 if (ntokens >= 2 && ntokensToBeSaved != 2) {
444 Error(
"TGraph",
"Incorrect input format! There are %d \"%%lg\" tag(s) in format whereas 2 and only 2 are expected!", ntokensToBeSaved);
445 delete [] isTokenToBeSaved ;
450 Bool_t isLineToBeSkipped = kFALSE ;
451 char * token = NULL ;
452 TString token_str =
"" ;
453 Int_t token_idx = 0 ;
454 Double_t * value =
new Double_t [2] ;
455 Int_t value_idx = 0 ;
459 while (std::getline(infile, line,
'\n')) {
461 if (line[line.size() - 1] == char(13)) {
462 line.erase(line.end() - 1, line.end()) ;
465 token = R__STRTOK_R(const_cast<char *>(line.c_str()), option, &rest);
466 while (token != NULL && value_idx < 2) {
467 if (isTokenToBeSaved[token_idx]) {
468 token_str = TString(token) ;
469 token_str.ReplaceAll(
"\t",
"") ;
470 if (!token_str.IsFloat()) {
471 isLineToBeSkipped = kTRUE ;
474 value[value_idx] = token_str.Atof() ;
478 token = R__STRTOK_R(NULL, option, &rest);
481 if (!isLineToBeSkipped && value_idx == 2) {
488 isLineToBeSkipped = kFALSE ;
496 delete [] isTokenToBeSaved ;
511 fFunctions->SetBit(kInvalidObject);
517 while ((obj = fFunctions->First())) {
518 while (fFunctions->Remove(obj)) { }
530 Double_t **TGraph::Allocate(Int_t newsize) {
531 return AllocateArrays(2, newsize);
537 Double_t** TGraph::AllocateArrays(Int_t Narrays, Int_t arraySize)
542 Double_t **newarrays =
new Double_t*[Narrays];
544 for (Int_t i = 0; i < Narrays; ++i)
547 for (Int_t i = 0; i < Narrays; ++i)
548 newarrays[i] =
new Double_t[arraySize];
550 fMaxSize = arraySize;
560 void TGraph::Apply(TF1 *f)
562 if (fHistogram) SetBit(kResetHisto);
564 for (Int_t i = 0; i < fNpoints; i++) {
565 fY[i] = f->Eval(fX[i], fY[i]);
567 if (gPad) gPad->Modified();
573 void TGraph::Browse(TBrowser *b)
575 TString opt = gEnv->GetValue(
"TGraph.BrowseOption",
"");
577 opt = b ? b->GetDrawOption() :
"alp";
578 opt = (opt ==
"") ?
"alp" : opt.Data();
599 Double_t TGraph::Chisquare(TF1 *func, Option_t * option)
const
602 Error(
"Chisquare",
"Function pointer is Null - return -1");
606 TString opt(option); opt.ToUpper();
607 bool useRange = opt.Contains(
"R");
609 return ROOT::Fit::Chisquare(*
this, *func,useRange);
616 Bool_t TGraph::CompareArg(
const TGraph* gr, Int_t left, Int_t right)
618 Double_t xl = 0, yl = 0, xr = 0, yr = 0;
619 gr->GetPoint(left, xl, yl);
620 gr->GetPoint(right, xr, yr);
621 return (TMath::ATan2(yl, xl) > TMath::ATan2(yr, xr));
627 Bool_t TGraph::CompareX(
const TGraph* gr, Int_t left, Int_t right)
629 return gr->fX[left] > gr->fX[right];
635 Bool_t TGraph::CompareY(
const TGraph* gr, Int_t left, Int_t right)
637 return gr->fY[left] > gr->fY[right];
644 Bool_t TGraph::CompareRadius(
const TGraph* gr, Int_t left, Int_t right)
646 return gr->fX[left] * gr->fX[left] + gr->fY[left] * gr->fY[left]
647 > gr->fX[right] * gr->fX[right] + gr->fY[right] * gr->fY[right];
653 void TGraph::ComputeRange(Double_t &xmin, Double_t &ymin, Double_t &xmax, Double_t &ymax)
const
656 xmin = xmax = ymin = ymax = 0;
665 for (Int_t i = 1; i < fNpoints; i++) {
666 if (fX[i] < xmin) xmin = fX[i];
667 if (fX[i] > xmax) xmax = fX[i];
668 if (fY[i] < ymin) ymin = fY[i];
669 if (fY[i] > ymax) ymax = fY[i];
670 if (ymin>0 && (yminl==0 || ymin<yminl)) yminl = ymin;
671 if (xmin>0 && (xminl==0 || xmin<xminl)) xminl = xmin;
674 if (gPad && gPad->GetLogy() && yminl>0) ymin = yminl;
675 if (gPad && gPad->GetLogx() && xminl>0) xmin = xminl;
684 void TGraph::CopyAndRelease(Double_t **newarrays, Int_t ibegin, Int_t iend,
687 CopyPoints(newarrays, ibegin, iend, obegin);
701 Bool_t TGraph::CopyPoints(Double_t **arrays, Int_t ibegin, Int_t iend,
704 if (ibegin < 0 || iend <= ibegin || obegin < 0) {
707 if (!arrays && ibegin == obegin) {
710 Int_t n = (iend - ibegin) *
sizeof(Double_t);
712 memmove(&arrays[0][obegin], &fX[ibegin], n);
713 memmove(&arrays[1][obegin], &fY[ibegin], n);
715 memmove(&fX[obegin], &fX[ibegin], n);
716 memmove(&fY[obegin], &fY[ibegin], n);
727 Bool_t TGraph::CtorAllocate()
733 fFunctions =
new TList;
742 fX =
new Double_t[fMaxSize];
743 fY =
new Double_t[fMaxSize];
753 void TGraph::Draw(Option_t *option)
755 TString opt = option;
758 if (opt.Contains(
"same")) {
759 opt.ReplaceAll(
"same",
"");
765 if ((pos = opt.Index(
"*")) != kNPOS) {
767 opt.Replace(pos, 1,
"p");
772 if (!strlen(option)) {
774 if (!gPad->GetListOfPrimitives()->FindObject(
"TFrame")) opt =
"alp";
781 if (!gPad->IsEditable()) gROOT->MakeDefCanvas();
782 if (opt.Contains(
"a")) gPad->Clear();
787 gPad->IncrementPaletteColor(1, opt);
797 Int_t TGraph::DistancetoPrimitive(Int_t px, Int_t py)
799 TVirtualGraphPainter *painter = TVirtualGraphPainter::GetPainter();
800 if (painter)
return painter->DistancetoPrimitiveHelper(
this, px, py);
807 void TGraph::DrawGraph(Int_t n,
const Int_t *x,
const Int_t *y, Option_t *option)
809 TGraph *newgraph =
new TGraph(n, x, y);
810 TAttLine::Copy(*newgraph);
811 TAttFill::Copy(*newgraph);
812 TAttMarker::Copy(*newgraph);
813 newgraph->SetBit(kCanDelete);
814 newgraph->AppendPad(option);
820 void TGraph::DrawGraph(Int_t n,
const Float_t *x,
const Float_t *y, Option_t *option)
822 TGraph *newgraph =
new TGraph(n, x, y);
823 TAttLine::Copy(*newgraph);
824 TAttFill::Copy(*newgraph);
825 TAttMarker::Copy(*newgraph);
826 newgraph->SetBit(kCanDelete);
827 newgraph->AppendPad(option);
833 void TGraph::DrawGraph(Int_t n,
const Double_t *x,
const Double_t *y, Option_t *option)
835 const Double_t *xx = x;
836 const Double_t *yy = y;
839 TGraph *newgraph =
new TGraph(n, xx, yy);
840 TAttLine::Copy(*newgraph);
841 TAttFill::Copy(*newgraph);
842 TAttMarker::Copy(*newgraph);
843 newgraph->SetBit(kCanDelete);
844 newgraph->AppendPad(option);
850 void TGraph::DrawPanel()
852 TVirtualGraphPainter *painter = TVirtualGraphPainter::GetPainter();
853 if (painter) painter->DrawPanelHelper(
this);
871 Double_t TGraph::Eval(Double_t x, TSpline *spline, Option_t *option)
const
876 return spline->Eval(x);
879 if (fNpoints == 0)
return 0;
880 if (fNpoints == 1)
return fY[0];
882 if (option && *option) {
883 TString opt = option;
886 if (opt.Contains(
"s")) {
889 std::vector<Double_t> xsort(fNpoints);
890 std::vector<Double_t> ysort(fNpoints);
891 std::vector<Int_t> indxsort(fNpoints);
892 TMath::Sort(fNpoints, fX, &indxsort[0],
false);
893 for (Int_t i = 0; i < fNpoints; ++i) {
894 xsort[i] = fX[ indxsort[i] ];
895 ysort[i] = fY[ indxsort[i] ];
899 TSpline3 s(
"", &xsort[0], &ysort[0], fNpoints);
900 Double_t result = s.Eval(x);
911 if (TestBit(TGraph::kIsSortedX) ) {
912 low = TMath::BinarySearch(fNpoints, fX, x);
917 if (fX[low] == x)
return fY[low];
918 if (low == fNpoints-1) low--;
930 for (Int_t i = 0; i < fNpoints; ++i) {
932 if (low == -1 || fX[i] > fX[low]) {
935 }
else if (low2 == -1) low2 = i;
936 }
else if (fX[i] > x) {
937 if (up == -1 || fX[i] < fX[up]) {
940 }
else if (up2 == -1) up2 = i;
956 assert(low != -1 && up != -1);
958 if (fX[low] == fX[up])
return fY[low];
959 Double_t yn = fY[up] + (x - fX[up]) * (fY[low] - fY[up]) / (fX[low] - fX[up]);
974 void TGraph::ExecuteEvent(Int_t event, Int_t px, Int_t py)
976 TVirtualGraphPainter *painter = TVirtualGraphPainter::GetPainter();
977 if (painter) painter->ExecuteEventHelper(
this, event, px, py);
983 void TGraph::Expand(Int_t newsize)
985 Double_t **ps = ExpandAndCopy(newsize, fNpoints);
986 CopyAndRelease(ps, 0, 0, 0);
993 void TGraph::Expand(Int_t newsize, Int_t step)
995 if (newsize <= fMaxSize) {
998 Double_t **ps = Allocate(step * (newsize / step + (newsize % step ? 1 : 0)));
999 CopyAndRelease(ps, 0, fNpoints, 0);
1007 Double_t **TGraph::ExpandAndCopy(Int_t size, Int_t iend)
1009 if (size <= fMaxSize) {
1012 Double_t **newarrays = Allocate(2 * size);
1013 CopyPoints(newarrays, 0, iend, 0);
1021 void TGraph::FillZero(Int_t begin, Int_t end, Bool_t)
1023 memset(fX + begin, 0, (end - begin)*
sizeof(Double_t));
1024 memset(fY + begin, 0, (end - begin)*
sizeof(Double_t));
1030 TObject *TGraph::FindObject(
const char *name)
const
1032 if (fFunctions)
return fFunctions->FindObject(name);
1039 TObject *TGraph::FindObject(
const TObject *obj)
const
1041 if (fFunctions)
return fFunctions->FindObject(obj);
1057 TFitResultPtr TGraph::Fit(
const char *fname, Option_t *option, Option_t *, Axis_t xmin, Axis_t xmax)
1060 linear = (
char*) strstr(fname,
"++");
1062 TF1 f1(fname, fname, xmin, xmax);
1063 return Fit(&f1, option,
"", xmin, xmax);
1065 TF1 * f1 = (TF1*)gROOT->GetFunction(fname);
1067 Printf(
"Unknown function: %s", fname);
1070 return Fit(f1, option,
"", xmin, xmax);
1300 TFitResultPtr TGraph::Fit(TF1 *f1, Option_t *option, Option_t *goption, Axis_t rxmin, Axis_t rxmax)
1302 Foption_t fitOption;
1303 ROOT::Fit::FitOptionsMake(ROOT::Fit::kGraph, option, fitOption);
1305 ROOT::Fit::DataRange range(rxmin, rxmax);
1306 ROOT::Math::MinimizerOptions minOption;
1307 return ROOT::Fit::FitObject(
this, f1 , fitOption , minOption, goption, range);
1315 void TGraph::FitPanel()
1318 gROOT->MakeDefCanvas();
1321 Error(
"FitPanel",
"Unable to create a default canvas");
1326 TPluginHandler *handler = gROOT->GetPluginManager()->FindHandler(
"TFitEditor");
1327 if (handler && handler->LoadPlugin() != -1) {
1328 if (handler->ExecPlugin(2, gPad,
this) == 0)
1329 Error(
"FitPanel",
"Unable to crate the FitPanel");
1331 Error(
"FitPanel",
"Unable to find the FitPanel plug-in");
1337 Double_t TGraph::GetCorrelationFactor()
const
1339 Double_t rms1 = GetRMS(1);
1340 if (rms1 == 0)
return 0;
1341 Double_t rms2 = GetRMS(2);
1342 if (rms2 == 0)
return 0;
1343 return GetCovariance() / rms1 / rms2;
1349 Double_t TGraph::GetCovariance()
const
1351 if (fNpoints <= 0)
return 0;
1352 Double_t sum = fNpoints, sumx = 0, sumy = 0, sumxy = 0;
1354 for (Int_t i = 0; i < fNpoints; i++) {
1357 sumxy += fX[i] * fY[i];
1359 return sumxy / sum - sumx / sum * sumy / sum;
1365 Double_t TGraph::GetMean(Int_t axis)
const
1367 if (axis < 1 || axis > 2)
return 0;
1368 if (fNpoints <= 0)
return 0;
1370 for (Int_t i = 0; i < fNpoints; i++) {
1371 if (axis == 1) sumx += fX[i];
1374 return sumx / fNpoints;
1380 Double_t TGraph::GetRMS(Int_t axis)
const
1382 if (axis < 1 || axis > 2)
return 0;
1383 if (fNpoints <= 0)
return 0;
1384 Double_t sumx = 0, sumx2 = 0;
1385 for (Int_t i = 0; i < fNpoints; i++) {
1388 sumx2 += fX[i] * fX[i];
1391 sumx2 += fY[i] * fY[i];
1394 Double_t x = sumx / fNpoints;
1395 Double_t rms2 = TMath::Abs(sumx2 / fNpoints - x * x);
1396 return TMath::Sqrt(rms2);
1403 Double_t TGraph::GetErrorX(Int_t)
const
1412 Double_t TGraph::GetErrorY(Int_t)
const
1422 Double_t TGraph::GetErrorXhigh(Int_t)
const
1432 Double_t TGraph::GetErrorXlow(Int_t)
const
1442 Double_t TGraph::GetErrorYhigh(Int_t)
const
1452 Double_t TGraph::GetErrorYlow(Int_t)
const
1463 TF1 *TGraph::GetFunction(
const char *name)
const
1465 if (!fFunctions)
return 0;
1466 return (TF1*)fFunctions->FindObject(name);
1475 TH1F *TGraph::GetHistogram()
const
1477 Double_t rwxmin, rwxmax, rwymin, rwymax, maximum, minimum, dx, dy;
1478 Double_t uxmin, uxmax;
1480 ComputeRange(rwxmin, rwymin, rwxmax, rwymax);
1490 if (!TestBit(kResetHisto)) {
1491 if (gPad && gPad->GetLogx()) {
1492 if (rwxmin <= 0 || fHistogram->GetXaxis()->GetXmin() != 0)
return fHistogram;
1493 }
else if (gPad && gPad->GetLogy()) {
1494 if (rwymin <= 0 || fHistogram->GetMinimum() != 0)
return fHistogram;
1499 const_cast <TGraph*>(
this)->ResetBit(kResetHisto);
1501 historg = fHistogram;
1504 if (rwxmin == rwxmax) rwxmax += 1.;
1505 if (rwymin == rwymax) rwymax += 1.;
1506 dx = 0.1 * (rwxmax - rwxmin);
1507 dy = 0.1 * (rwymax - rwymin);
1508 uxmin = rwxmin - dx;
1509 uxmax = rwxmax + dx;
1510 minimum = rwymin - dy;
1511 maximum = rwymax + dy;
1513 if (fMinimum != -1111) minimum = fMinimum;
1514 if (fMaximum != -1111) maximum = fMaximum;
1518 if (uxmin < 0 && rwxmin >= 0) {
1519 if (gPad && gPad->GetLogx()) uxmin = 0.9 * rwxmin;
1522 if (uxmax > 0 && rwxmax <= 0) {
1523 if (gPad && gPad->GetLogx()) uxmax = 1.1 * rwxmax;
1527 if (minimum < 0 && rwymin >= 0) minimum = 0.9 * rwymin;
1529 if (minimum <= 0 && gPad && gPad->GetLogy()) minimum = 0.001 * maximum;
1530 if (uxmin <= 0 && gPad && gPad->GetLogx()) {
1531 if (uxmax > 1000) uxmin = 1;
1532 else uxmin = 0.001 * uxmax;
1538 if (fNpoints > npt) npt = fNpoints;
1539 const char *gname = GetName();
1540 if (!gname[0]) gname =
"Graph";
1541 ((TGraph*)
this)->fHistogram =
new TH1F(gname, GetTitle(), npt, rwxmin, rwxmax);
1542 if (!fHistogram)
return 0;
1543 fHistogram->SetMinimum(minimum);
1544 fHistogram->SetBit(TH1::kNoStats);
1545 fHistogram->SetMaximum(maximum);
1546 fHistogram->GetYaxis()->SetLimits(minimum, maximum);
1547 fHistogram->SetDirectory(0);
1550 fHistogram->GetXaxis()->SetTitle(historg->GetXaxis()->GetTitle());
1551 fHistogram->GetXaxis()->CenterTitle(historg->GetXaxis()->GetCenterTitle());
1552 fHistogram->GetXaxis()->RotateTitle(historg->GetXaxis()->GetRotateTitle());
1553 fHistogram->GetXaxis()->SetNoExponent(historg->GetXaxis()->GetNoExponent());
1554 fHistogram->GetXaxis()->SetNdivisions(historg->GetXaxis()->GetNdivisions());
1555 fHistogram->GetXaxis()->SetLabelFont(historg->GetXaxis()->GetLabelFont());
1556 fHistogram->GetXaxis()->SetLabelOffset(historg->GetXaxis()->GetLabelOffset());
1557 fHistogram->GetXaxis()->SetLabelSize(historg->GetXaxis()->GetLabelSize());
1558 fHistogram->GetXaxis()->SetTitleSize(historg->GetXaxis()->GetTitleSize());
1559 fHistogram->GetXaxis()->SetTitleOffset(historg->GetXaxis()->GetTitleOffset());
1560 fHistogram->GetXaxis()->SetTitleFont(historg->GetXaxis()->GetTitleFont());
1561 fHistogram->GetXaxis()->SetTimeDisplay(historg->GetXaxis()->GetTimeDisplay());
1562 fHistogram->GetXaxis()->SetTimeFormat(historg->GetXaxis()->GetTimeFormat());
1564 fHistogram->GetYaxis()->SetTitle(historg->GetYaxis()->GetTitle());
1565 fHistogram->GetYaxis()->CenterTitle(historg->GetYaxis()->GetCenterTitle());
1566 fHistogram->GetYaxis()->RotateTitle(historg->GetYaxis()->GetRotateTitle());
1567 fHistogram->GetYaxis()->SetNoExponent(historg->GetYaxis()->GetNoExponent());
1568 fHistogram->GetYaxis()->SetNdivisions(historg->GetYaxis()->GetNdivisions());
1569 fHistogram->GetYaxis()->SetLabelFont(historg->GetYaxis()->GetLabelFont());
1570 fHistogram->GetYaxis()->SetLabelOffset(historg->GetYaxis()->GetLabelOffset());
1571 fHistogram->GetYaxis()->SetLabelSize(historg->GetYaxis()->GetLabelSize());
1572 fHistogram->GetYaxis()->SetTitleSize(historg->GetYaxis()->GetTitleSize());
1573 fHistogram->GetYaxis()->SetTitleOffset(historg->GetYaxis()->GetTitleOffset());
1574 fHistogram->GetYaxis()->SetTitleFont(historg->GetYaxis()->GetTitleFont());
1575 fHistogram->GetYaxis()->SetTimeDisplay(historg->GetYaxis()->GetTimeDisplay());
1576 fHistogram->GetYaxis()->SetTimeFormat(historg->GetYaxis()->GetTimeFormat());
1586 Int_t TGraph::GetPoint(Int_t i, Double_t &x, Double_t &y)
const
1588 if (i < 0 || i >= fNpoints || !fX || !fY)
return -1;
1597 Double_t TGraph::GetPointX(Int_t i)
const
1599 if (i < 0 || i >= fNpoints || !fX)
1608 Double_t TGraph::GetPointY(Int_t i)
const
1610 if (i < 0 || i >= fNpoints || !fY)
1619 TAxis *TGraph::GetXaxis()
const
1621 TH1 *h = GetHistogram();
1623 return h->GetXaxis();
1629 TAxis *TGraph::GetYaxis()
const
1631 TH1 *h = GetHistogram();
1633 return h->GetYaxis();
1640 char *TGraph::GetObjectInfo(Int_t px, Int_t py)
const
1646 for (i = 0; i < fNpoints; i++) {
1647 Int_t dpx = px - gPad->XtoAbsPixel(gPad->XtoPad(fX[i]));
1648 Int_t dpy = py - gPad->YtoAbsPixel(gPad->YtoPad(fY[i]));
1650 if (dpx * dpx + dpy * dpy < 25) {
1656 Double_t x = gPad->PadtoX(gPad->AbsPixeltoX(px));
1657 Double_t y = gPad->PadtoY(gPad->AbsPixeltoY(py));
1660 return Form(
"x=%g, y=%g", x, y);
1662 Double_t xval = fX[ipoint];
1663 Double_t yval = fY[ipoint];
1665 return Form(
"x=%g, y=%g, point=%d, xval=%g, yval=%g", x, y, ipoint, xval, yval);
1671 void TGraph::InitGaus(Double_t xmin, Double_t xmax)
1673 Double_t allcha, sumx, sumx2, x, val, rms, mean;
1675 const Double_t sqrtpi = 2.506628;
1680 xmax = fX[fNpoints-1];
1683 allcha = sumx = sumx2 = 0;
1684 for (bin = 0; bin < fNpoints; bin++) {
1686 if (x < xmin || x > xmax)
continue;
1690 sumx2 += val * x * x;
1693 if (np == 0 || allcha == 0)
return;
1694 mean = sumx / allcha;
1695 rms = TMath::Sqrt(sumx2 / allcha - mean * mean);
1696 Double_t binwidx = TMath::Abs((xmax - xmin) / np);
1697 if (rms == 0) rms = 1;
1698 TVirtualFitter *grFitter = TVirtualFitter::GetFitter();
1699 TF1 *f1 = (TF1*)grFitter->GetUserFunc();
1700 f1->SetParameter(0, binwidx * allcha / (sqrtpi * rms));
1701 f1->SetParameter(1, mean);
1702 f1->SetParameter(2, rms);
1703 f1->SetParLimits(2, 0, 10 * rms);
1709 void TGraph::InitExpo(Double_t xmin, Double_t xmax)
1711 Double_t constant, slope;
1715 xmax = fX[fNpoints-1];
1717 Int_t nchanx = fNpoints;
1719 LeastSquareLinearFit(-nchanx, constant, slope, ifail, xmin, xmax);
1721 TVirtualFitter *grFitter = TVirtualFitter::GetFitter();
1722 TF1 *f1 = (TF1*)grFitter->GetUserFunc();
1723 f1->SetParameter(0, constant);
1724 f1->SetParameter(1, slope);
1730 void TGraph::InitPolynom(Double_t xmin, Double_t xmax)
1732 Double_t fitpar[25];
1734 TVirtualFitter *grFitter = TVirtualFitter::GetFitter();
1735 TF1 *f1 = (TF1*)grFitter->GetUserFunc();
1736 Int_t npar = f1->GetNpar();
1739 xmax = fX[fNpoints-1];
1742 LeastSquareFit(npar, fitpar, xmin, xmax);
1744 for (Int_t i = 0; i < npar; i++) f1->SetParameter(i, fitpar[i]);
1750 Int_t TGraph::InsertPoint()
1752 Int_t px = gPad->GetEventX();
1753 Int_t py = gPad->GetEventY();
1759 for (i = 0; i < fNpoints - 1; i++) {
1760 d = DistancetoLine(px, py, gPad->XtoPad(fX[i]), gPad->YtoPad(fY[i]), gPad->XtoPad(fX[i+1]), gPad->YtoPad(fY[i+1]));
1768 for (i = 0; i < fNpoints - 1; i++) {
1769 d = DistancetoLine(px, py, gPad->XtoPad(fX[i]), gPad->YtoPad(fY[i]), gPad->XtoPad(fX[i+1]), gPad->YtoPad(fY[i+1]));
1778 Int_t dpx = px - gPad->XtoAbsPixel(gPad->XtoPad(fX[0]));
1779 Int_t dpy = py - gPad->YtoAbsPixel(gPad->XtoPad(fY[0]));
1780 if (dpx * dpx + dpy * dpy < 25) ipoint = 0;
1781 else ipoint = fNpoints;
1785 InsertPointBefore(ipoint, gPad->AbsPixeltoX(px), gPad->AbsPixeltoY(py));
1795 void TGraph::InsertPointBefore(Int_t ipoint, Double_t x, Double_t y)
1798 Error(
"TGraph",
"Inserted point index should be >= 0");
1802 if (ipoint > fNpoints-1) {
1803 Error(
"TGraph",
"Inserted point index should be <= %d", fNpoints-1);
1807 Double_t **ps = ExpandAndCopy(fNpoints + 1, ipoint);
1808 CopyAndRelease(ps, ipoint, fNpoints++, ipoint + 1);
1811 FillZero(ipoint, ipoint + 1);
1849 Double_t TGraph::Integral(Int_t first, Int_t last)
const
1851 if (first < 0) first = 0;
1852 if (last < 0) last = fNpoints - 1;
1853 if (last >= fNpoints) last = fNpoints - 1;
1854 if (first >= last)
return 0;
1855 Int_t np = last - first + 1;
1862 for (Int_t i = first; i <= last; i++) {
1863 Int_t j = first + (i - first + 1) % np;
1864 sum += (fY[i] + fY[j]) * (fX[j] - fX[i]);
1866 return 0.5 * TMath::Abs(sum);
1882 Int_t TGraph::IsInside(Double_t x, Double_t y)
const
1884 return (Int_t)TMath::IsInside(x, y, fNpoints, fX, fY);
1897 void TGraph::LeastSquareFit(Int_t m, Double_t *a, Double_t xmin, Double_t xmax)
1899 const Double_t zero = 0.;
1900 const Double_t one = 1.;
1901 const Int_t idim = 20;
1904 Int_t i, k, l, ifail;
1906 Double_t da[20], xk, yk;
1910 xmax = fX[fNpoints-1];
1914 LeastSquareLinearFit(n, a[0], a[1], ifail, xmin, xmax);
1917 if (m > idim || m > n)
return;
1919 for (l = 2; l <= m; ++l) {
1921 b[m + l*20 - 21] = zero;
1925 for (k = 0; k < fNpoints; ++k) {
1927 if (xk < xmin || xk > xmax)
continue;
1932 for (l = 2; l <= m; ++l) {
1935 da[l-1] += power * yk;
1937 for (l = 2; l <= m; ++l) {
1939 b[m + l*20 - 21] += power;
1942 b[0] = Double_t(np);
1943 for (i = 3; i <= m; ++i) {
1944 for (k = i; k <= m; ++k) {
1945 b[k - 1 + (i-1)*20 - 21] = b[k + (i-2)*20 - 21];
1948 H1LeastSquareSeqnd(m, b, idim, ifail, 1, da);
1952 for (i = 1; i < m; ++i) a[i] = 0;
1955 for (i = 0; i < m; ++i) a[i] = da[i];
1972 void TGraph::LeastSquareLinearFit(Int_t ndata, Double_t &a0, Double_t &a1, Int_t &ifail, Double_t xmin, Double_t xmax)
1974 Double_t xbar, ybar, x2bar;
1977 Double_t fn, xk, yk;
1981 xmax = fX[fNpoints-1];
1985 xbar = ybar = x2bar = xybar = 0;
1987 for (i = 0; i < fNpoints; ++i) {
1989 if (xk < xmin || xk > xmax)
continue;
1993 if (yk <= 0) yk = 1e-9;
1994 yk = TMath::Log(yk);
2002 det = fn * x2bar - xbar * xbar;
2005 if (fn > 0) a0 = ybar / fn;
2011 a0 = (x2bar * ybar - xbar * xybar) / det;
2012 a1 = (fn * xybar - xbar * ybar) / det;
2018 void TGraph::Paint(Option_t *option)
2020 TVirtualGraphPainter *painter = TVirtualGraphPainter::GetPainter();
2021 if (painter) painter->PaintHelper(
this, option);
2027 void TGraph::PaintGraph(Int_t npoints,
const Double_t *x,
const Double_t *y, Option_t *chopt)
2029 TVirtualGraphPainter *painter = TVirtualGraphPainter::GetPainter();
2030 if (painter) painter->PaintGraph(
this, npoints, x, y, chopt);
2036 void TGraph::PaintGrapHist(Int_t npoints,
const Double_t *x,
const Double_t *y, Option_t *chopt)
2038 TVirtualGraphPainter *painter = TVirtualGraphPainter::GetPainter();
2039 if (painter) painter->PaintGrapHist(
this, npoints, x, y, chopt);
2045 void TGraph::PaintStats(TF1 *fit)
2047 TVirtualGraphPainter *painter = TVirtualGraphPainter::GetPainter();
2048 if (painter) painter->PaintStats(
this, fit);
2054 void TGraph::Print(Option_t *)
const
2056 for (Int_t i = 0; i < fNpoints; i++) {
2057 printf(
"x[%d]=%g, y[%d]=%g\n", i, fX[i], i, fY[i]);
2064 void TGraph::RecursiveRemove(TObject *obj)
2067 if (!fFunctions->TestBit(kInvalidObject)) fFunctions->RecursiveRemove(obj);
2069 if (fHistogram == obj) fHistogram = 0;
2075 Int_t TGraph::RemovePoint()
2077 Int_t px = gPad->GetEventX();
2078 Int_t py = gPad->GetEventY();
2084 for (i = 0; i < fNpoints; i++) {
2085 Int_t dpx = px - gPad->XtoAbsPixel(gPad->XtoPad(fX[i]));
2086 Int_t dpy = py - gPad->YtoAbsPixel(gPad->YtoPad(fY[i]));
2087 if (dpx * dpx + dpy * dpy < 100) {
2092 return RemovePoint(ipoint);
2098 Int_t TGraph::RemovePoint(Int_t ipoint)
2100 if (ipoint < 0)
return -1;
2101 if (ipoint >= fNpoints)
return -1;
2103 Double_t **ps = ShrinkAndCopy(fNpoints - 1, ipoint);
2104 CopyAndRelease(ps, ipoint + 1, fNpoints--, ipoint);
2105 if (gPad) gPad->Modified();
2112 void TGraph::SavePrimitive(std::ostream &out, Option_t *option )
2115 out <<
" " << std::endl;
2116 static Int_t frameNumber = 0;
2119 if (fNpoints >= 1) {
2121 TString fXName = TString(GetName()) + Form(
"_fx%d",frameNumber);
2122 TString fYName = TString(GetName()) + Form(
"_fy%d",frameNumber);
2123 out <<
" Double_t " << fXName <<
"[" << fNpoints <<
"] = {" << std::endl;
2124 for (i = 0; i < fNpoints-1; i++) out <<
" " << fX[i] <<
"," << std::endl;
2125 out <<
" " << fX[fNpoints-1] <<
"};" << std::endl;
2126 out <<
" Double_t " << fYName <<
"[" << fNpoints <<
"] = {" << std::endl;
2127 for (i = 0; i < fNpoints-1; i++) out <<
" " << fY[i] <<
"," << std::endl;
2128 out <<
" " << fY[fNpoints-1] <<
"};" << std::endl;
2129 if (gROOT->ClassSaved(TGraph::Class())) out <<
" ";
2130 else out <<
" TGraph *";
2131 out <<
"graph = new TGraph(" << fNpoints <<
"," << fXName <<
"," << fYName <<
");" << std::endl;
2133 if (gROOT->ClassSaved(TGraph::Class())) out <<
" ";
2134 else out <<
" TGraph *";
2135 out <<
"graph = new TGraph();" << std::endl;
2138 out <<
" graph->SetName(" << quote << GetName() << quote <<
");" << std::endl;
2139 out <<
" graph->SetTitle(" << quote << GetTitle() << quote <<
");" << std::endl;
2141 SaveFillAttributes(out,
"graph", 0, 1001);
2142 SaveLineAttributes(out,
"graph", 1, 1, 1);
2143 SaveMarkerAttributes(out,
"graph", 1, 1, 1);
2146 TString hname = fHistogram->GetName();
2147 hname += frameNumber;
2148 fHistogram->SetName(Form(
"Graph_%s", hname.Data()));
2149 fHistogram->SavePrimitive(out,
"nodraw");
2150 out <<
" graph->SetHistogram(" << fHistogram->GetName() <<
");" << std::endl;
2151 out <<
" " << std::endl;
2155 TIter next(fFunctions);
2157 while ((obj = next())) {
2158 obj->SavePrimitive(out, Form(
"nodraw #%d\n",++frameNumber));
2159 if (obj->InheritsFrom(
"TPaveStats")) {
2160 out <<
" graph->GetListOfFunctions()->Add(ptstats);" << std::endl;
2161 out <<
" ptstats->SetParent(graph->GetListOfFunctions());" << std::endl;
2164 objname.Form(
"%s%d",obj->GetName(),frameNumber);
2165 if (obj->InheritsFrom(
"TF1")) {
2166 out <<
" " << objname <<
"->SetParent(graph);\n";
2168 out <<
" graph->GetListOfFunctions()->Add("
2169 << objname <<
");" << std::endl;
2174 l = strstr(option,
"multigraph");
2176 out <<
" multigraph->Add(graph," << quote << l + 10 << quote <<
");" << std::endl;
2179 l = strstr(option,
"th2poly");
2181 out <<
" " << l + 7 <<
"->AddBin(graph);" << std::endl;
2184 out <<
" graph->Draw(" << quote << option << quote <<
");" << std::endl;
2192 void TGraph::Set(Int_t n)
2195 if (n == fNpoints)
return;
2196 Double_t **ps = Allocate(n);
2197 CopyAndRelease(ps, 0, TMath::Min(fNpoints, n), 0);
2199 FillZero(fNpoints, n, kFALSE);
2207 Bool_t TGraph::GetEditable()
const
2209 return TestBit(kNotEditable) ? kFALSE : kTRUE;
2216 void TGraph::SetEditable(Bool_t editable)
2218 if (editable) ResetBit(kNotEditable);
2219 else SetBit(kNotEditable);
2226 void TGraph::SetHighlight(Bool_t set)
2228 if (IsHighlight() == set)
return;
2230 TVirtualGraphPainter *painter = TVirtualGraphPainter::GetPainter();
2231 if (!painter)
return;
2232 SetBit(kIsHighlight, set);
2233 painter->SetHighlight(
this);
2239 void TGraph::SetMaximum(Double_t maximum)
2242 GetHistogram()->SetMaximum(maximum);
2248 void TGraph::SetMinimum(Double_t minimum)
2251 GetHistogram()->SetMinimum(minimum);
2257 void TGraph::SetPoint(Int_t i, Double_t x, Double_t y)
2260 if (fHistogram) SetBit(kResetHisto);
2262 if (i >= fMaxSize) {
2263 Double_t **ps = ExpandAndCopy(i + 1, fNpoints);
2264 CopyAndRelease(ps, 0, 0, 0);
2266 if (i >= fNpoints) {
2270 FillZero(fNpoints, i + 1);
2275 if (gPad) gPad->Modified();
2281 void TGraph::SetPointX(Int_t i, Double_t x)
2283 SetPoint(i, x, GetPointY(i));
2289 void TGraph::SetPointY(Int_t i, Double_t y)
2291 SetPoint(i, GetPointX(i), y);
2296 void TGraph::SetName(
const char *name)
2299 if (fHistogram) fHistogram->SetName(name);
2312 void TGraph::SetTitle(
const char* title)
2315 fTitle.ReplaceAll(
"#;",2,
"#semicolon",10);
2316 Int_t p = fTitle.Index(
";");
2319 if (!fHistogram) GetHistogram();
2320 fHistogram->SetTitle(title);
2321 Int_t n = fTitle.Length()-p;
2322 if (p>0) fTitle.Remove(p,n);
2323 fTitle.ReplaceAll(
"#semicolon",10,
"#;",2);
2325 if (fHistogram) fHistogram->SetTitle(title);
2332 void TGraph::SetNameTitle(
const char *name,
const char *title)
2344 Double_t **TGraph::ShrinkAndCopy(Int_t size, Int_t oend)
2346 if (size * 2 > fMaxSize || !fMaxSize) {
2349 Double_t **newarrays = Allocate(size);
2350 CopyPoints(newarrays, 0, oend, 0);
2377 void TGraph::Sort(Bool_t (*greaterfunc)(
const TGraph*, Int_t, Int_t) ,
2378 Bool_t ascending , Int_t low , Int_t high )
2382 if (greaterfunc == TGraph::CompareX && ascending && low == 0 && high == -1111)
2383 SetBit(TGraph::kIsSortedX);
2385 if (high == -1111) high = GetN() - 1;
2387 if (high <= low)
return;
2392 while (left < right) {
2394 while (left <= high && greaterfunc(
this, left, low) != ascending)
2397 while (right > low && greaterfunc(
this, right, low) == ascending)
2399 if (left < right && left < high && right > low)
2400 SwapPoints(left, right);
2404 SwapPoints(low, right);
2405 Sort(greaterfunc, ascending, low, right - 1);
2406 Sort(greaterfunc, ascending, right + 1, high);
2412 void TGraph::Streamer(TBuffer &b)
2414 if (b.IsReading()) {
2416 Version_t R__v = b.ReadVersion(&R__s, &R__c);
2418 b.ReadClassBuffer(TGraph::Class(),
this, R__v, R__s, R__c);
2419 if (fHistogram) fHistogram->SetDirectory(0);
2420 TIter next(fFunctions);
2422 while ((obj = next())) {
2423 if (obj->InheritsFrom(TF1::Class())) {
2424 TF1 *f1 = (TF1*)obj;
2425 f1->SetParent(
this);
2428 fMaxSize = fNpoints;
2432 TNamed::Streamer(b);
2433 TAttLine::Streamer(b);
2434 TAttFill::Streamer(b);
2435 TAttMarker::Streamer(b);
2437 fMaxSize = fNpoints;
2438 fX =
new Double_t[fNpoints];
2439 fY =
new Double_t[fNpoints];
2441 Float_t *x =
new Float_t[fNpoints];
2442 Float_t *y =
new Float_t[fNpoints];
2443 b.ReadFastArray(x, fNpoints);
2444 b.ReadFastArray(y, fNpoints);
2445 for (Int_t i = 0; i < fNpoints; i++) {
2452 b.ReadFastArray(fX, fNpoints);
2453 b.ReadFastArray(fY, fNpoints);
2457 if (fHistogram) fHistogram->SetDirectory(0);
2468 b.CheckByteCount(R__s, R__c, TGraph::IsA());
2472 b.WriteClassBuffer(TGraph::Class(),
this);
2479 void TGraph::SwapPoints(Int_t pos1, Int_t pos2)
2481 SwapValues(fX, pos1, pos2);
2482 SwapValues(fY, pos1, pos2);
2488 void TGraph::SwapValues(Double_t* arr, Int_t pos1, Int_t pos2)
2490 Double_t tmp = arr[pos1];
2491 arr[pos1] = arr[pos2];
2500 void TGraph::UseCurrentStyle()
2502 if (gStyle->IsReading()) {
2503 SetFillColor(gStyle->GetHistFillColor());
2504 SetFillStyle(gStyle->GetHistFillStyle());
2505 SetLineColor(gStyle->GetHistLineColor());
2506 SetLineStyle(gStyle->GetHistLineStyle());
2507 SetLineWidth(gStyle->GetHistLineWidth());
2508 SetMarkerColor(gStyle->GetMarkerColor());
2509 SetMarkerStyle(gStyle->GetMarkerStyle());
2510 SetMarkerSize(gStyle->GetMarkerSize());
2512 gStyle->SetHistFillColor(GetFillColor());
2513 gStyle->SetHistFillStyle(GetFillStyle());
2514 gStyle->SetHistLineColor(GetLineColor());
2515 gStyle->SetHistLineStyle(GetLineStyle());
2516 gStyle->SetHistLineWidth(GetLineWidth());
2517 gStyle->SetMarkerColor(GetMarkerColor());
2518 gStyle->SetMarkerStyle(GetMarkerStyle());
2519 gStyle->SetMarkerSize(GetMarkerSize());
2521 if (fHistogram) fHistogram->UseCurrentStyle();
2523 TIter next(GetListOfFunctions());
2526 while ((obj = next())) {
2527 obj->UseCurrentStyle();
2535 Int_t TGraph::Merge(TCollection* li)
2538 while (TObject* o = next()) {
2539 TGraph *g =
dynamic_cast<TGraph*
>(o);
2542 "Cannot merge - an object which doesn't inherit from TGraph found in the list");
2553 Bool_t TGraph::DoMerge(
const TGraph* g)
2555 Double_t x = 0, y = 0;
2556 for (Int_t i = 0 ; i < g->GetN(); i++) {
2557 g->GetPoint(i, x, y);
2558 SetPoint(GetN(), x, y);
2568 void TGraph::MovePoints(Double_t dx, Double_t dy, Bool_t logx, Bool_t logy)
2570 Double_t x = 0, y = 0;
2571 for (Int_t i = 0 ; i < GetN(); i++) {
2576 x = TMath::Exp(TMath::Log(x) + dx);
2581 y = TMath::Exp(TMath::Log(y) + dy);
2594 void TGraph::Zero(Int_t &k, Double_t AZ, Double_t BZ, Double_t E2, Double_t &X, Double_t &Y
2595 , Int_t maxiterations)
2597 static Double_t a, b, ya, ytest, y1, x1, h;
2598 static Int_t j1, it, j3, j2;
2615 if (TMath::Abs(Y) <= E2) {
2631 if (j1 != 2)
goto L100;
2632 if (ya * Y < 0)
goto L120;
2641 if (it >= maxiterations) k = j1;
2649 if (j1 > 3)
goto L170;
2665 if (it >= maxiterations) k = j1;
2678 if (TMath::Abs(ya) > TMath::Abs(yb)) {
2694 x2 = X - Y * (X - x1) / (Y - y1);
2697 ytest = 0.5 * TMath::Min(TMath::Abs(ya), TMath::Abs(yb));
2698 if ((x2 - a)*(x2 - b) < 0) {
2700 if (it >= maxiterations) k = j1;
2711 if ((x2 - a)*(x2 - b) >= 0) {
2716 if (it >= maxiterations) k = j1;
2724 if (j1 != 4)
return;
2735 if (ytest <= 0)
goto L130;
2736 if (TMath::Abs(Y) - ytest <= 0)
goto L150;