434 while ((
g = next())) {
478 TString opt =
gEnv->GetValue(
"TGraph.BrowseOption",
"");
480 opt =
b ?
b->GetDrawOption() :
"alp";
481 opt = (opt ==
"") ?
"alp" : opt.Data();
494 const Int_t kMaxDiff = 10;
495 Int_t distance = 9999;
497 distance =
fHistogram->DistancetoPrimitive(px,py);
498 if (distance <= 0)
return distance;
505 while ((
g = (TGraph*) next())) {
507 if (dist <= 0)
return 0;
508 if (dist < kMaxDiff) {
gPad->SetSelected(
g);
return dist;}
530 TString opt = option;
534 if (!
gPad->IsEditable())
gROOT->MakeDefCanvas();
548 char *linear = (
char*)strstr(fname,
"++");
553 TF1 *
f1 = (TF1*)
gROOT->GetFunction(fname);
554 if (!
f1) {
Printf(
"Unknown function: %s",fname);
return -1; }
726 ROOT::Fit::DataRange range(rxmin,rxmax);
727 ROOT::Math::MinimizerOptions minOption;
739 gROOT->MakeDefCanvas();
742 Error(
"FitPanel",
"Unable to create a default canvas");
747 TPluginHandler *handler =
gROOT->GetPluginManager()->FindHandler(
"TFitEditor");
750 Error(
"FitPanel",
"Unable to crate the FitPanel");
753 Error(
"FitPanel",
"Unable to find the FitPanel plug-in");
765 while ((obj = next())) {
766 if (obj == (
TObject*)
gr)
return next.GetOption();
777 Double_t allcha, sumx, sumx2,
x, val, rms, mean;
783 allcha = sumx = sumx2 = 0;
788 while ((
g = (TGraph*) next())) {
792 for (bin=0; bin<npp; bin++) {
802 if (np == 0 || allcha == 0)
return;
807 if (rms == 0) rms = 1;
865 const Int_t idim = 20;
868 Int_t i, k,
l, ifail, bin;
879 while ((
g = (TGraph*) next())) {
882 for (bin=0; bin<npp; bin++) {
884 if (xk < xmin || xk >
xmax)
continue;
892 if (
m > idim ||
m >
n)
return;
894 for (
l = 2;
l <=
m; ++
l) {
896 b[
m +
l*20 - 21] = zero;
902 while ((
g = (TGraph*) next())) {
907 for (k = 0; k <= npp; ++k) {
909 if (xk < xmin || xk >
xmax)
continue;
914 for (
l = 2;
l <=
m; ++
l) {
919 for (
l = 2;
l <=
m; ++
l) {
921 b[
m +
l*20 - 21] += power;
926 for (i = 3; i <=
m; ++i) {
927 for (k = i; k <=
m; ++k) {
928 b[k - 1 + (i-1)*20 - 21] =
b[k + (i-2)*20 - 21];
935 py=((TGraph *)
fGraphs->First())->GetY();
937 for (i=1; i<
m; ++i)
a[i] = 0;
940 for (i=0; i<
m; ++i)
a[i] = da[i];
966 xbar = ybar = x2bar = xybar = 0;
972 while ((
g = (TGraph*) next())) {
976 for (i = 0; i < npp; ++i) {
978 if (xk < xmin || xk >
xmax)
continue;
982 if (yk <= 0) yk = 1
e-9;
992 det = fn*x2bar - xbar*xbar;
995 if (fn > 0) a0 = ybar/fn;
1001 a0 = (x2bar*ybar - xbar*xybar) / det;
1002 a1 = (fn*xybar - xbar*ybar) / det;
1015 while ((
g = (TGraph*) next())) {
1016 in =
g->IsInside(
x,
y);
1048 Double_t rwxmin = 0.,rwxmax = 0.,rwymin = 0.,rwymax = 0.;
1052 while ((
g = (TGraph*) next())) {
1053 if (
g->GetN() <= 0)
continue;
1054 if (initialrangeset) {
1056 g->ComputeRange(rx1, ry1, rx2, ry2);
1057 if (rx1 < rwxmin) rwxmin = rx1;
1058 if (ry1 < rwymin) rwymin = ry1;
1059 if (rx2 > rwxmax) rwxmax = rx2;
1060 if (ry2 > rwymax) rwymax = ry2;
1062 g->ComputeRange(rwxmin, rwymin, rwxmax, rwymax);
1063 initialrangeset =
kTRUE;
1065 if (
g->GetN() > npt) npt =
g->GetN();
1067 if (rwxmin == rwxmax) rwxmax += 1.;
1068 if (rwymin == rwymax) rwymax += 1.;
1069 double dx = 0.05*(rwxmax-rwxmin);
1070 double dy = 0.05*(rwymax-rwymin);
1072 if (rwxmin <= 0) rwxmin = 0.001*rwxmax;
1073 double r = rwxmax/rwxmin;
1077 rwxmin = rwxmin - dx;
1078 rwxmax = rwxmax + dx;
1081 if (rwymin <= 0) rwymin = 0.001*rwymax;
1082 double r = rwymax/rwymin;
1086 rwymin = rwymin - dy;
1087 rwymax = rwymax + dy;
1094 fHistogram->GetYaxis()->SetLimits(rwymin,rwymax);
1130 if (!
h)
return nullptr;
1131 return h->GetXaxis();
1142 if (!
h)
return nullptr;
1143 return h->GetYaxis();
1152 const TPickerStackGuard pushGuard(
this);
1155 if (
fGraphs->GetSize() == 0)
return;
1158 strlcpy(option,choptin,128);
1159 Int_t nch = choptin ? strlen(choptin) : 0;
1160 for (
Int_t i=0;i<nch;i++) option[i] = toupper(option[i]);
1163 char *l1 = strstr(option,
"PFC");
1164 char *l2 = strstr(option,
"PLC");
1165 char *l3 = strstr(option,
"PMC");
1166 if (l1 || l2 || l3) {
1167 TString opt1 = option; opt1.
ToLower();
1168 if (l1) memcpy(l1,
" ",3);
1169 if (l2) memcpy(l2,
" ",3);
1170 if (l3) memcpy(l3,
" ",3);
1171 auto lnk =
fGraphs->FirstLink();
1174 gPad->IncrementPaletteColor(ngraphs, opt1);
1175 for (
Int_t i=0;i<ngraphs;i++) {
1176 ic =
gPad->NextPaletteColor();
1177 auto gAti = (TGraph*)(
fGraphs->At(i));
1178 if (l1) gAti->SetFillColor(ic);
1179 if (l2) gAti->SetLineColor(ic);
1180 if (l3) gAti->SetMarkerColor(ic);
1185 TString chopt = option;
1187 auto l = strstr(chopt.
Data(),
"3D");
1189 l = strstr(chopt.
Data(),
"L");
1194 l = strstr(chopt.
Data(),
"PADS");
1197 if (sscanf(&
l[4],
"%d", &fnx) > 0) {
1206 char *lrx = (
char *)strstr(chopt.
Data(),
"RX");
1207 char *lry = (
char *)strstr(chopt.
Data(),
"RY");
1213 l = strstr(chopt.
Data(),
"A");
1218 Double_t maximum, minimum, rwxmin, rwxmax, rwymin, rwymax, uxmin, uxmax, dx,
dy;
1219 rwxmin =
gPad->GetUxmin();
1220 rwxmax =
gPad->GetUxmax();
1221 rwymin =
gPad->GetUymin();
1222 rwymax =
gPad->GetUymax();
1223 std::string xtitle, ytitle, timeformat;
1230 auto lnk =
fGraphs->FirstLink();
1233 for (
Int_t i=0;i<ngraphs;i++) {
1234 TGraph* gAti = (TGraph*)(
fGraphs->At(i));
1244 timedisplay =
fHistogram->GetXaxis()->GetTimeDisplay();
1245 if (strlen(
fHistogram->GetXaxis()->GetTitle()) > 0)
1247 if (strlen(
fHistogram->GetYaxis()->GetTitle()) > 0)
1249 if (strlen(
fHistogram->GetXaxis()->GetTimeFormat()) > 0)
1250 timeformat =
fHistogram->GetXaxis()->GetTimeFormat();
1258 uxmin =
gPad->PadtoX(rwxmin);
1259 uxmax =
gPad->PadtoX(rwxmax);
1262 while (
auto g = (TGraph*) next()) {
1263 if (
g->GetN() <= 0)
continue;
1264 if (initialrangeset) {
1266 g->ComputeRange(rx1, ry1, rx2, ry2);
1267 if (rx1 < rwxmin) rwxmin = rx1;
1268 if (ry1 < rwymin) rwymin = ry1;
1269 if (rx2 > rwxmax) rwxmax = rx2;
1270 if (ry2 > rwymax) rwymax = ry2;
1272 g->ComputeRange(rwxmin, rwymin, rwxmax, rwymax);
1273 initialrangeset =
kTRUE;
1275 if (
g->GetN() > npt) npt =
g->GetN();
1277 if (rwxmin == rwxmax) rwxmax += 1.;
1278 if (rwymin == rwymax) rwymax += 1.;
1279 dx = 0.05*(rwxmax-rwxmin);
1280 dy = 0.05*(rwymax-rwymin);
1281 uxmin = rwxmin - dx;
1282 uxmax = rwxmax + dx;
1283 if (
gPad->GetLogy()) {
1284 if (rwymin <= 0) rwymin = 0.001*rwymax;
1288 minimum = rwymin - dy;
1289 maximum = rwymax + dy;
1291 if (minimum < 0 && rwymin >= 0) minimum = 0;
1292 if (maximum > 0 && rwymax <= 0) maximum = 0;
1297 if (uxmin < 0 && rwxmin >= 0) {
1298 if (
gPad->GetLogx()) uxmin = 0.9*rwxmin;
1301 if (uxmax > 0 && rwxmax <= 0) {
1302 if (
gPad->GetLogx()) uxmax = 1.1*rwxmax;
1305 if (minimum < 0 && rwymin >= 0) {
1306 if (
gPad->GetLogy()) minimum = 0.9*rwymin;
1309 if (maximum > 0 && rwymax <= 0) {
1310 if (
gPad->GetLogy()) maximum = 1.1*rwymax;
1313 if (minimum <= 0 && gPad->GetLogy()) minimum = 0.001*maximum;
1314 if (uxmin <= 0 && gPad->GetLogx()) {
1315 if (uxmax > 1000) uxmin = 1;
1316 else uxmin = 0.001*uxmax;
1321 fHistogram->GetYaxis()->SetLimits(rwymin,rwymax);
1335 fHistogram->GetYaxis()->SetLimits(rwymin,rwymax);
1338 if (!xtitle.empty())
fHistogram->GetXaxis()->SetTitle(xtitle.c_str());
1339 if (!ytitle.empty())
fHistogram->GetYaxis()->SetTitle(ytitle.c_str());
1340 if (firstx != lastx)
fHistogram->GetXaxis()->SetRange(firstx,lastx);
1341 if (timedisplay) {
fHistogram->GetXaxis()->SetTimeDisplay(timedisplay);}
1342 if (!timeformat.empty())
fHistogram->GetXaxis()->SetTimeFormat(timeformat.c_str());
1344 TString chopth(
"0");
1346 chopth.Append(
"X+");
1348 chopth.Append(
"Y+");
1354 TGraph *gfit =
nullptr;
1356 auto lnk =
fGraphs->FirstLink();
1364 obj = lnk->GetObject();
1366 gPad->PushSelectableObject(obj);
1368 if (!
gPad->PadInHighlightMode() || (
gPad->PadInHighlightMode() && obj ==
gPad->GetSelected())) {
1369 TString opt = lnk->GetOption();
1374 else obj->
Paint(
"L");
1381 gfit = (TGraph*)obj;
1387 while (
auto f = next()) {
1411 Int_t existingPads = 0;
1413 TVirtualPad *curPad =
gPad;
1416 while (
auto obj = nextPad()) {
1420 if (existingPads < neededPads) {
1424 if (nx * nx < neededPads)
1427 if (((nx * ny) - nx) >= neededPads)
1432 if (nColumn * ny < neededPads)
1434 curPad->
Divide(nColumn, ny);
1440 while (
auto g = (TGraph *) nextGraph()) {
1443 if ((apopt.
Length() == 0) && option) apopt = option;
1444 if (apopt.
Length() == 0) apopt =
"L";
1458 Double_t rwxmin=0., rwxmax=0., rwymin=0., rwymax=0.;
1461 TGraph *
g = (TGraph*) next();
1463 g->ComputeRange(rwxmin, rwymin, rwxmax, rwymax);
1470 while ((
g = (TGraph*) next())) {
1472 g->ComputeRange(rx1, ry1, rx2, ry2);
1473 if (rx1 < rwxmin) rwxmin = rx1;
1474 if (ry1 < rwymin) rwymin = ry1;
1475 if (rx2 > rwxmax) rwxmax = rx2;
1476 if (ry2 > rwymax) rwymax = ry2;
1477 if (
g->GetN() > npt) npt =
g->GetN();
1482 TH2F* frame =
new TH2F(
"frame",
"", ndiv, 0., (
Double_t)(ndiv), npt, rwxmin, rwxmax);
1493 for (i=ndiv; i>=1; i--) {
1494 g = (TGraph*) next();
1504 if (strstr(option,
"A"))
1505 frame->
Paint(
"lego9,fb,bb");
1507 if (!strstr(option,
"BB"))
1508 frame->
Paint(
"lego9,fb,a,same");
1520 while ((
g = (TGraph*) next())) {
1524 gPad->SetLineColor(
g->GetLineColor());
1525 gPad->SetLineWidth(
g->GetLineWidth());
1526 gPad->SetLineStyle(
g->GetLineStyle());
1527 gPad->TAttLine::Modify();
1528 for (i=0; i<npt-1; i++) {
1533 if (
gPad->Clip(&xc[0], &yc[0], xl, yl, xu, yu)<2) {
1540 gPad->PaintLine3D(xyz1, xyz2);
1546 if (!strstr(option,
"FB"))
1547 frame->
Paint(
"lego9,bb,a,same");
1560 TGraph *fg =
nullptr;
1563 TString mgopt = option;
1570 while ((
g = (TGraph *)next())) {
1596 while ((
g = (TGraph*) next())) {
1620 auto objr =
fGraphs->Remove(obj);
1633 thread_local Int_t frameNumber = 0;
1640 while (
auto g = iter())
1647 out <<
" " <<
fHistogram->GetName() <<
"->GetXaxis()->SetLimits(" <<
fHistogram->GetXaxis()->GetXmin() <<
", " <<
fHistogram->GetXaxis()->GetXmax() <<
");\n";
1648 out <<
" multigraph->SetHistogram(" <<
fHistogram->GetName() <<
");\n";
1653 const char *
l = strstr(option,
"th2poly");
1655 out <<
" " <<
l + 7 <<
"->AddBin(multigraph);\n";
1660 out <<
" multigraph->SetMinimum(" <<
fMinimum <<
");\n";
1662 out <<
" multigraph->SetMaximum(" <<
fMaximum <<
");\n";
int Int_t
Signed integer 4 bytes (int).
bool Bool_t
Boolean (0=false, 1=true) (bool).
double Axis_t
Axis values type (double).
double Double_t
Double 8 bytes.
const char Option_t
Option string (const char).
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.
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 Double_t GetBinLowEdge(Int_t bin) const
Return low edge of bin.
Int_t GetLast() const
Return last bin on the axis i.e.
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 GetNpar() const
virtual void SetParLimits(Int_t ipar, Double_t parmin, Double_t parmax)
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...
void Paint(Option_t *chopt="") override
This method must be overridden if a class wants to paint itself.
@ kResetHisto
fHistogram must be reset in GetHistogram
virtual TH1F * GetHistogram() const
virtual void PaintStats(TF1 *fit)
virtual void SetHistogram(TH1F *h)
1-D histogram with a float per channel (see TH1 documentation)
void SetTitle(const char *title) override
Change/set the title.
@ 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.
Double_t fMinimum
Minimum value for plotting along y.
TH1F * fHistogram
Pointer to histogram used for drawing axis.
virtual void Add(TGraph *graph, Option_t *chopt="")
virtual Int_t IsInside(Double_t x, Double_t y) const
virtual void SetMaximum(Double_t maximum=-1111)
void Paint(Option_t *chopt="") override
This method must be overridden if a class wants to paint itself.
TList * fGraphs
Pointer to list of TGraphs.
virtual Option_t * GetGraphDrawOption(const TGraph *gr) const
Double_t fMaximum
Maximum value for plotting along y.
virtual void LeastSquareFit(Int_t m, Double_t *a, Double_t xmin, Double_t xmax)
Int_t DistancetoPrimitive(Int_t px, Int_t py) override
Computes distance from point (px,py) to the object.
void Browse(TBrowser *b) override
Browse object. May be overridden for another default action.
virtual void SetMinimum(Double_t minimum=-1111)
TF1 * GetFunction(const char *name) const
void PaintPolyLine3D(Option_t *chopt="")
void PaintPads(Option_t *chopt="", Int_t nColumn=0)
void Draw(Option_t *chopt="") override
Default Draw method for all objects.
virtual void InitGaus(Double_t xmin, Double_t xmax)
void RecursiveRemove(TObject *obj) override
Recursively remove this object from a list.
virtual void InitPolynom(Double_t xmin, Double_t xmax)
void Print(Option_t *chopt="") const override
This method must be overridden when a class wants to print itself.
virtual TFitResultPtr Fit(const char *formula, Option_t *option="", Option_t *goption="", Axis_t xmin=0, Axis_t xmax=0)
void SetHistogram(TH1F *hist)
TList * GetListOfFunctions()
virtual void LeastSquareLinearFit(Int_t ndata, Double_t &a0, Double_t &a1, Int_t &ifail, Double_t xmin, Double_t xmax)
void PaintReverse(Option_t *chopt="")
void SavePrimitive(std::ostream &out, Option_t *option="") override
Save a primitive as a C++ statement(s) on output stream "out".
TList * fFunctions
Pointer to list of functions (fits and user).
virtual void InitExpo(Double_t xmin, Double_t xmax)
The TNamed class is the base class for all named ROOT classes.
void SavePrimitiveNameTitle(std::ostream &out, const char *variable_name)
Save object name and title into the output stream "out".
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.
Mother of all ROOT objects.
Bool_t TestBit(UInt_t f) const
virtual Option_t * GetOption() 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 Bool_t InheritsFrom(const char *classname) const
Returns kTRUE if object inherits from class "classname".
virtual void Error(const char *method, const char *msgfmt,...) const
Issue error message.
static void SavePrimitiveDraw(std::ostream &out, const char *variable_name, Option_t *option=nullptr)
Save invocation of primitive Draw() method Skipped if option contains "nodraw" string.
virtual void Paint(Option_t *option="")
This method must be overridden if a class wants to paint itself.
TObject()
TObject constructor.
static void SavePrimitiveConstructor(std::ostream &out, TClass *cl, const char *variable_name, const char *constructor_agrs="", Bool_t empty_line=kTRUE)
Save object constructor in the output stream "out".
@ 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
static TVirtualFitter * GetFitter()
static: return the current Fitter
virtual TObject * GetUserFunc() const
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 dist(Rotation3D const &r1, Rotation3D const &r2)
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.