390 while ((
g = next())) {
440 if (!graphlist)
return;
448 if (!strlen(chopt))
fGraphs->
Add(obj,lnk->GetOption());
462 opt =
b ?
b->GetDrawOption() :
"alp";
463 opt = (opt ==
"") ?
"alp" : opt.
Data();
476 const Int_t kMaxDiff = 10;
477 Int_t distance = 9999;
480 if (distance <= 0)
return distance;
487 while ((
g = (
TGraph*) next())) {
488 Int_t dist =
g->DistancetoPrimitive(px,py);
489 if (dist <= 0)
return 0;
490 if (dist < kMaxDiff) {
gPad->SetSelected(
g);
return dist;}
516 if (!
gPad->IsEditable())
gROOT->MakeDefCanvas();
530 char *linear = (
char*)strstr(fname,
"++");
536 if (!
f1) {
Printf(
"Unknown function: %s",fname);
return -1; }
721 gROOT->MakeDefCanvas();
724 Error(
"FitPanel",
"Unable to create a default canvas");
732 Error(
"FitPanel",
"Unable to crate the FitPanel");
735 Error(
"FitPanel",
"Unable to find the FitPanel plug-in");
747 while ((obj = next())) {
759 Double_t allcha, sumx, sumx2,
x, val, rms, mean;
765 allcha = sumx = sumx2 = 0;
770 while ((
g = (
TGraph*) next())) {
774 for (bin=0; bin<npp; bin++) {
776 if (x<xmin || x>
xmax)
continue;
784 if (
np == 0 || allcha == 0)
return;
789 if (rms == 0) rms = 1;
847 const Int_t idim = 20;
850 Int_t i, k,
l, ifail, bin;
861 while ((
g = (
TGraph*) next())) {
864 for (bin=0; bin<npp; bin++) {
866 if (xk < xmin || xk >
xmax)
continue;
874 if (
m > idim ||
m >
n)
return;
876 for (
l = 2;
l <=
m; ++
l) {
878 b[
m +
l*20 - 21] = zero;
884 while ((
g = (
TGraph*) next())) {
889 for (k = 0; k <= npp; ++k) {
891 if (xk < xmin || xk >
xmax)
continue;
896 for (
l = 2;
l <=
m; ++
l) {
901 for (
l = 2;
l <=
m; ++
l) {
903 b[
m +
l*20 - 21] += power;
908 for (i = 3; i <=
m; ++i) {
909 for (k = i; k <=
m; ++k) {
910 b[k - 1 + (i-1)*20 - 21] =
b[k + (i-2)*20 - 21];
919 for (i=1; i<
m; ++i)
a[i] = 0;
922 for (i=0; i<
m; ++i)
a[i] = da[i];
948 xbar = ybar = x2bar = xybar = 0;
954 while ((
g = (
TGraph*) next())) {
958 for (i = 0; i < npp; ++i) {
960 if (xk < xmin || xk >
xmax)
continue;
964 if (yk <= 0) yk = 1
e-9;
974 det = fn*x2bar - xbar*xbar;
977 if (fn > 0) a0 = ybar/fn;
983 a0 = (x2bar*ybar - xbar*xybar) / det;
984 a1 = (fn*xybar - xbar*ybar) / det;
997 while ((
g = (
TGraph*) next())) {
998 in =
g->IsInside(
x,
y);
1030 Double_t rwxmin = 0.,rwxmax = 0.,rwymin = 0.,rwymax = 0.;
1034 while ((
g = (
TGraph*) next())) {
1035 if (
g->GetN() <= 0)
continue;
1036 if (initialrangeset) {
1038 g->ComputeRange(rx1, ry1, rx2, ry2);
1039 if (rx1 < rwxmin) rwxmin = rx1;
1040 if (ry1 < rwymin) rwymin = ry1;
1041 if (rx2 > rwxmax) rwxmax = rx2;
1042 if (ry2 > rwymax) rwymax = ry2;
1044 g->ComputeRange(rwxmin, rwymin, rwxmax, rwymax);
1045 initialrangeset =
kTRUE;
1047 if (
g->GetN() > npt) npt =
g->GetN();
1049 if (rwxmin == rwxmax) rwxmax += 1.;
1050 if (rwymin == rwymax) rwymax += 1.;
1051 double dx = 0.05*(rwxmax-rwxmin);
1052 double dy = 0.05*(rwymax-rwymin);
1053 rwxmin = rwxmin - dx;
1054 rwxmax = rwxmax + dx;
1056 if (rwymin <= 0) rwymin = 0.001*rwymax;
1057 double r = rwymax/rwymin;
1061 rwymin = rwymin - dy;
1062 rwymax = rwymax + dy;
1105 if (!
h)
return nullptr;
1106 return h->GetXaxis();
1117 if (!
h)
return nullptr;
1118 return h->GetYaxis();
1133 strlcpy(
option,choptin,128);
1134 Int_t nch = choptin ? strlen(choptin) : 0;
1138 char *l1 = strstr(
option,
"PFC");
1139 char *l2 = strstr(
option,
"PLC");
1140 char *l3 = strstr(
option,
"PMC");
1141 if (l1 || l2 || l3) {
1143 if (l1) memcpy(l1,
" ",3);
1144 if (l2) memcpy(l2,
" ",3);
1145 if (l3) memcpy(l3,
" ",3);
1149 gPad->IncrementPaletteColor(ngraphs, opt1);
1150 for (
Int_t i=0;i<ngraphs;i++) {
1151 ic =
gPad->NextPaletteColor();
1153 if (l1) gAti->SetFillColor(ic);
1154 if (l2) gAti->SetLineColor(ic);
1155 if (l3) gAti->SetMarkerColor(ic);
1162 auto l = strstr(chopt.
Data(),
"3D");
1164 l = strstr(chopt.
Data(),
"L");
1169 l = strstr(chopt.
Data(),
"PADS");
1176 char *lrx = (
char *)strstr(chopt.
Data(),
"RX");
1177 char *lry = (
char *)strstr(chopt.
Data(),
"RY");
1183 l = strstr(chopt.
Data(),
"A");
1188 Double_t maximum, minimum, rwxmin, rwxmax, rwymin, rwymax, uxmin, uxmax, dx, dy;
1189 rwxmin =
gPad->GetUxmin();
1190 rwxmax =
gPad->GetUxmax();
1191 rwymin =
gPad->GetUymin();
1192 rwymax =
gPad->GetUymax();
1193 std::string xtitle, ytitle, timeformat;
1203 for (
Int_t i=0;i<ngraphs;i++) {
1228 uxmin =
gPad->PadtoX(rwxmin);
1229 uxmax =
gPad->PadtoX(rwxmax);
1232 while (
auto g = (
TGraph*) next()) {
1233 if (
g->GetN() <= 0)
continue;
1234 if (initialrangeset) {
1236 g->ComputeRange(rx1, ry1, rx2, ry2);
1237 if (rx1 < rwxmin) rwxmin = rx1;
1238 if (ry1 < rwymin) rwymin = ry1;
1239 if (rx2 > rwxmax) rwxmax = rx2;
1240 if (ry2 > rwymax) rwymax = ry2;
1242 g->ComputeRange(rwxmin, rwymin, rwxmax, rwymax);
1243 initialrangeset =
kTRUE;
1245 if (
g->GetN() > npt) npt =
g->GetN();
1247 if (rwxmin == rwxmax) rwxmax += 1.;
1248 if (rwymin == rwymax) rwymax += 1.;
1249 dx = 0.05*(rwxmax-rwxmin);
1250 dy = 0.05*(rwymax-rwymin);
1251 uxmin = rwxmin - dx;
1252 uxmax = rwxmax + dx;
1253 if (
gPad->GetLogy()) {
1254 if (rwymin <= 0) rwymin = 0.001*rwymax;
1258 minimum = rwymin - dy;
1259 maximum = rwymax + dy;
1261 if (minimum < 0 && rwymin >= 0) minimum = 0;
1262 if (maximum > 0 && rwymax <= 0) maximum = 0;
1267 if (uxmin < 0 && rwxmin >= 0) {
1268 if (
gPad->GetLogx()) uxmin = 0.9*rwxmin;
1271 if (uxmax > 0 && rwxmax <= 0) {
1272 if (
gPad->GetLogx()) uxmax = 1.1*rwxmax;
1275 if (minimum < 0 && rwymin >= 0) {
1276 if (
gPad->GetLogy()) minimum = 0.9*rwymin;
1279 if (maximum > 0 && rwymax <= 0) {
1280 if (
gPad->GetLogy()) maximum = 1.1*rwymax;
1283 if (minimum <= 0 && gPad->GetLogy()) minimum = 0.001*maximum;
1284 if (uxmin <= 0 && gPad->GetLogx()) {
1285 if (uxmax > 1000) uxmin = 1;
1286 else uxmin = 0.001*uxmax;
1314 if (strstr(chopt.
Data(),
"X+")) chopth.
Append(
"X+");
1315 if (strstr(chopt.
Data(),
"Y+")) chopth.
Append(
"Y+");
1316 if (strstr(chopt.
Data(),
"I")) chopth.
Append(
"A");
1330 obj = lnk->GetObject();
1332 gPad->PushSelectableObject(obj);
1334 if (!
gPad->PadInHighlightMode() || (
gPad->PadInHighlightMode() && obj ==
gPad->GetSelected())) {
1335 TString opt = lnk->GetOption();
1340 else obj->
Paint(
"L");
1353 while (
auto f = next()) {
1377 Int_t existingPads = 0;
1382 while (
auto obj = nextPad()) {
1386 if (existingPads < neededPads) {
1389 if (nx*nx < neededPads) nx++;
1391 if (((nx*ny)-nx) >= neededPads) ny--;
1397 while (
auto g = (
TGraph *) nextGraph()) {
1401 if (apopt.
Length() == 0) apopt =
"L";
1415 Double_t rwxmin=0., rwxmax=0., rwymin=0., rwymax=0.;
1420 g->ComputeRange(rwxmin, rwymin, rwxmax, rwymax);
1427 while ((
g = (
TGraph*) next())) {
1429 g->ComputeRange(rx1, ry1, rx2, ry2);
1430 if (rx1 < rwxmin) rwxmin = rx1;
1431 if (ry1 < rwymin) rwymin = ry1;
1432 if (rx2 > rwxmax) rwxmax = rx2;
1433 if (ry2 > rwymax) rwymax = ry2;
1434 if (
g->GetN() > npt) npt =
g->GetN();
1439 TH2F* frame =
new TH2F(
"frame",
"", ndiv, 0., (
Double_t)(ndiv), npt, rwxmin, rwxmax);
1450 for (i=ndiv; i>=1; i--) {
1462 frame->
Paint(
"lego9,fb,bb");
1464 if (!strstr(
option,
"BB"))
1465 frame->
Paint(
"lego9,fb,a,same");
1477 while ((
g = (
TGraph*) next())) {
1481 gPad->SetLineColor(
g->GetLineColor());
1482 gPad->SetLineWidth(
g->GetLineWidth());
1483 gPad->SetLineStyle(
g->GetLineStyle());
1484 gPad->TAttLine::Modify();
1485 for (i=0; i<npt-1; i++) {
1490 if (
gPad->Clip(&xc[0], &yc[0], xl, yl, xu, yu)<2) {
1497 gPad->PaintLine3D(xyz1, xyz2);
1503 if (!strstr(
option,
"FB"))
1504 frame->
Paint(
"lego9,bb,a,same");
1527 while ((
g = (
TGraph *)next())) {
1553 while ((
g = (
TGraph*) next())) {
1591 out<<
" "<<std::endl;
1595 out<<
" TMultiGraph *";
1596 out<<
"multigraph = new TMultiGraph();"<<std::endl;
1597 out<<
" multigraph->SetName("<<quote<<
GetName()<<quote<<
");"<<std::endl;
1598 out<<
" multigraph->SetTitle("<<quote<<
GetTitle()<<quote<<
");"<<std::endl;
1602 while (
auto g = iter())
1605 const char *
l = strstr(
option,
"th2poly");
1607 out<<
" "<<
l+7<<
"->AddBin(multigraph);"<<std::endl;
1609 out<<
" multigraph->Draw(" <<quote<<
option<<quote<<
");"<<std::endl;
1615 out<<
" multigraph->GetXaxis()->SetLimits("<<xaxis->
GetXmin()<<
", "<<xaxis->
GetXmax()<<
");"<<std::endl;
1618 if (yaxis) yaxis->
SaveAttributes(out,
"multigraph",
"->GetYaxis()");
1619 if (
fMinimum != -1111) out<<
" multigraph->SetMinimum("<<
fMinimum<<
");"<<std::endl;
1620 if (
fMaximum != -1111) out<<
" multigraph->SetMaximum("<<
fMaximum<<
");"<<std::endl;
RooFitResult * fit(const char *options)
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t np
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t r
void H1LeastSquareSeqnd(Int_t n, Double_t *a, Int_t idim, Int_t &ifail, Int_t k, Double_t *b)
Extracted from CERN Program library routine DSEQN.
void H1LeastSquareSeqnd(Int_t n, Double_t *a, Int_t idim, Int_t &ifail, Int_t k, Double_t *b)
Extracted from CERN Program library routine DSEQN.
void Printf(const char *fmt,...)
Formats a string in a circular formatting buffer and prints the string.
class describing the range in the coordinates it supports multiple range in a coordinate.
virtual void SetNdivisions(Int_t n=510, Bool_t optim=kTRUE)
Set the number of divisions for this axis.
Class to manage histogram axis.
virtual void SetBinLabel(Int_t bin, const char *label)
Set label for bin.
virtual Bool_t GetTimeDisplay() const
const char * GetTitle() const override
Returns title of object.
virtual Double_t GetBinLowEdge(Int_t bin) const
Return low edge of bin.
virtual void SetTimeDisplay(Int_t value)
void SaveAttributes(std::ostream &out, const char *name, const char *subname) override
Save axis attributes as C++ statement(s) on output stream out.
Int_t GetLast() const
Return last bin on the axis i.e.
virtual void SetLimits(Double_t xmin, Double_t xmax)
virtual const char * GetTimeFormat() const
virtual void SetTimeFormat(const char *format="")
Change the format used for time plotting.
virtual void SetRange(Int_t first=0, Int_t last=0)
Set the viewing range for the axis using bin numbers.
virtual Double_t GetBinUpEdge(Int_t bin) const
Return up edge of bin.
Int_t GetFirst() const
Return first bin on the axis i.e.
Using a TBrowser one can browse all ROOT objects.
virtual Int_t GetSize() const
Return the capacity of the collection, i.e.
virtual Int_t GetValue(const char *name, Int_t dflt) const
Returns the integer value for a resource.
virtual Int_t GetNpar() const
virtual void SetParLimits(Int_t ipar, Double_t parmin, Double_t parmax)
Set lower and upper limits for parameter ipar.
virtual void SetParameter(Int_t param, Double_t value)
Provides an indirection to the TFitResult class and with a semantics identical to a TFitResult pointe...
A TGraph is an object made of two arrays X and Y with npoints each.
void Paint(Option_t *chopt="") override
Draw this graph with its current attributes.
@ kResetHisto
fHistogram must be reset in GetHistogram
virtual void PaintStats(TF1 *fit)
Draw the stats.
TH1F * GetHistogram() const
Returns a pointer to the histogram used to draw the axis Takes into account the two following cases.
virtual void SetHistogram(TH1F *h)
1-D histogram with a float per channel (see TH1 documentation)}
TH1 is the base class of all histogram classes in ROOT.
virtual void SetDirectory(TDirectory *dir)
By default, when a histogram is created, it is added to the list of histogram objects in the current ...
Int_t DistancetoPrimitive(Int_t px, Int_t py) override
Compute distance from point px,py to a line.
void SetTitle(const char *title) override
Change (i.e.
@ kNoStats
Don't draw stats box.
TObject * FindObject(const char *name) const override
Search object named name in the list of functions.
virtual Double_t GetMaximum(Double_t maxval=FLT_MAX) const
Return maximum value smaller than maxval of bins in the range, unless the value has been overridden b...
virtual void SetMaximum(Double_t maximum=-1111)
virtual void SetMinimum(Double_t minimum=-1111)
void Paint(Option_t *option="") override
Control routine to paint any kind of histograms.
virtual Double_t GetMinimum(Double_t minval=-FLT_MAX) const
Return minimum value larger than minval of bins in the range, unless the value has been overridden by...
virtual void SetStats(Bool_t stats=kTRUE)
Set statistics option on/off.
2-D histogram with a float per channel (see TH1 documentation)}
Option_t * GetOption() const
Option_t * GetOption() const override
Returns the object option stored in the list.
TObject * FindObject(const char *name) const override
Find an object in this list using its name.
void Add(TObject *obj) override
TObject * Remove(TObject *obj) override
Remove object from the list.
TObject * First() const override
Return the first object in the list. Returns 0 when list is empty.
virtual TObjLink * FirstLink() const
void Delete(Option_t *option="") override
Remove all objects from the list AND delete all heap based objects.
TObject * At(Int_t idx) const override
Returns the object at position idx. Returns 0 if idx is out of range.
A TMultiGraph is a collection of TGraph (or derived) objects.
Double_t fMinimum
Minimum value for plotting along y.
TH1F * fHistogram
Pointer to histogram used for drawing axis.
TMultiGraph()
TMultiGraph default constructor.
virtual TFitResultPtr Fit(const char *formula, Option_t *option="", Option_t *goption="", Axis_t xmin=0, Axis_t xmax=0)
Fit this graph with function with name fname.
void Paint(Option_t *chopt="") override
Paint all the graphs of this multigraph.
TList * GetListOfGraphs() const
TList * fGraphs
Pointer to list of TGraphs.
virtual void Add(TGraph *graph, Option_t *chopt="")
Add a new graph to the list of graphs.
Double_t fMaximum
Maximum value for plotting along y.
virtual void SetMinimum(Double_t minimum=-1111)
Set multigraph minimum.
Int_t DistancetoPrimitive(Int_t px, Int_t py) override
Compute distance from point px,py to each graph.
void Browse(TBrowser *b) override
Browse multigraph.
TH1F * GetHistogram()
Returns a pointer to the histogram used to draw the axis.
TF1 * GetFunction(const char *name) const
Return pointer to function with name.
virtual void LeastSquareFit(Int_t m, Double_t *a, Double_t xmin, Double_t xmax)
Least squares lpolynomial fitting without weights.
virtual void InitPolynom(Double_t xmin, Double_t xmax)
Compute Initial values of parameters for a polynom.
void PaintPolyLine3D(Option_t *chopt="")
Paint all the graphs of this multigraph as 3D lines.
virtual void InitExpo(Double_t xmin, Double_t xmax)
Compute Initial values of parameters for an exponential.
void Draw(Option_t *chopt="") override
Draw this multigraph with its current attributes.
virtual void FitPanel()
Display a panel with all histogram fit options.
void RecursiveRemove(TObject *obj) override
Recursively remove this object from a list.
void Print(Option_t *chopt="") const override
Print the list of graphs.
TIter begin() const
Get iterator over internal graphs list.
virtual void LeastSquareLinearFit(Int_t ndata, Double_t &a0, Double_t &a1, Int_t &ifail, Double_t xmin, Double_t xmax)
Least square linear fit without weights.
~TMultiGraph() override
TMultiGraph destructor.
void PaintPads(Option_t *chopt="")
Divides the active pad and draws all Graphs in the Multigraph separately.
virtual Option_t * GetGraphDrawOption(const TGraph *gr) const
Return the draw option for the TGraph gr in this TMultiGraph.
TAxis * GetYaxis()
Get y axis of the graph.
virtual void InitGaus(Double_t xmin, Double_t xmax)
Compute Initial values of parameters for a gaussian.
virtual Int_t IsInside(Double_t x, Double_t y) const
Return 1 if the point (x,y) is inside one of the graphs 0 otherwise.
TList * GetListOfFunctions()
Return pointer to list of functions.
virtual void SetMaximum(Double_t maximum=-1111)
Set multigraph maximum.
void PaintReverse(Option_t *chopt="")
Paint all the graphs of this multigraph reverting values along X and/or Y axis.
void SavePrimitive(std::ostream &out, Option_t *option="") override
Save primitive as a C++ statement(s) on output stream out.
TList * fFunctions
Pointer to list of functions (fits and user)
TAxis * GetXaxis()
Get x axis of the graph.
The TNamed class is the base class for all named ROOT classes.
virtual void SetTitle(const char *title="")
Set the title of the TNamed.
const char * GetName() const override
Returns name of object.
const char * GetTitle() const override
Returns title of object.
TObject * GetObject() const
Mother of all ROOT objects.
R__ALWAYS_INLINE Bool_t TestBit(UInt_t f) const
virtual void AppendPad(Option_t *option="")
Append graphics object to current pad.
void SetBit(UInt_t f, Bool_t set)
Set or unset the user status bits as specified in f.
virtual void Error(const char *method, const char *msgfmt,...) const
Issue error message.
virtual void Paint(Option_t *option="")
This method must be overridden if a class wants to paint itself.
@ kInvalidObject
if object ctor succeeded but object should not be used
@ kMustCleanup
if object destructor must call RecursiveRemove()
Longptr_t ExecPlugin(int nargs)
Int_t LoadPlugin()
Load the plugin library for this handler.
void ToLower()
Change string to lower-case.
const char * Data() const
TString & ReplaceAll(const TString &s1, const TString &s2)
TString & Append(const char *cs)
static TString Format(const char *fmt,...)
Static method which formats a string using a printf style format descriptor and return a TString.
Bool_t IsWhitespace() const
Bool_t Contains(const char *pat, ECaseCompare cmp=kExact) const
Abstract Base Class for Fitting.
static TVirtualFitter * GetFitter()
static: return the current Fitter
virtual TObject * GetUserFunc() const
TVirtualPad is an abstract base class for the Pad and Canvas classes.
virtual TList * GetListOfPrimitives() const =0
virtual TVirtualPad * cd(Int_t subpadnumber=0)=0
virtual void Divide(Int_t nx=1, Int_t ny=1, Float_t xmargin=0.01, Float_t ymargin=0.01, Int_t color=0)=0
void Clear(Option_t *option="") override=0
TFitResultPtr FitObject(TH1 *h1, TF1 *f1, Foption_t &option, const ROOT::Math::MinimizerOptions &moption, const char *goption, ROOT::Fit::DataRange &range)
fitting function for a TH1 (called from TH1::Fit)
void FitOptionsMake(EFitObjectType type, const char *option, Foption_t &fitOption)
Decode list of options into fitOption.
Double_t Log(Double_t x)
Returns the natural logarithm of x.
Double_t Sqrt(Double_t x)
Returns the square root of x.
Double_t Log10(Double_t x)
Returns the common (base-10) logarithm of x.
Short_t Abs(Short_t d)
Returns the absolute value of parameter Short_t d.