or just:
h3->Draw(“ISO”);
See the link I sent you.
or just:
h3->Draw(“ISO”);
See the link I sent you.
And if I want to get a parametric equation out of it, then is there any option?
That’s not Drawing . May be have a look at 3D histogram fitting.
h3->Draw(“ISO”); is creating something like this...not a colored surface.!
Yes, it is mono color. See the Help.
Try GLISO (with SetCanvasPreferGL before. See Help)
Also see if one of the examples here https://root.cern/doc/master/group__tutorial__gl.html
matches what you are looking for.
I have tried with GLISO also, but, didn’t work.
It might be there too less points to draw a surface through them using the available floating options. May be try to do a 3D fit.
Yeah, may be because of less data points…
But, how to do a 3D fit and get an equation back?
Thanks for the link. it is running. But, When I combine this with the one I posted at the beginning of this series, it does not show up in the plot and does not give the equation as well!
//file fit3.C
#include "TRandom3.h"
#include "Riostream.h"
#include <iostream>
#include "TH3.h"
#include "TF3.h"
#include "TMath.h"
double myfunc3(double *x, double *par) {
double xx = (x[0] - par[1])/par[2];
double yy = (x[1] - par[3])/par[4];
double zz = (x[2] - par[5])/par[6];
double rx = TMath::Exp(-xx*xx);
double ry = TMath::Exp(-yy*yy);
double rz = TMath::Exp(-zz*zz);
double result = par[0]*rx*ry*rz;
return result;
}
void fit3() {
const unsigned nPts1 = 15;
ifstream in1;
in1.open("data_test.txt");
Float_t x1,y1,z1;
TCanvas *c1 = new TCanvas("c1"," ",0,0,700,350);
TH3F *h1 = new TH3F("h1","h1",100,1000,3000,100,0.5,1.0,100,0.0,1.0);
for (unsigned i = 0; i < nPts1; ++i) {
in1 >> x1 >> y1 >> z1;
if (!in1.good()) break;
h1->Fill(x1,y1,z1);
}
in1.close();
c1->cd();
TF3 *func3 = new TF3("func3",myfunc3,1000,3000,0.5,1.0,0.0,1.0,7);
func3->SetParameters(h1->GetMaximum(),0,0.5,0,0.5,0,0.5);
h1->Fit(func3,"r+","E");
h1->Draw("col");
func3->Draw("same");
func3->SetLineColor(kOrange+8);
func3->SetLineStyle(1);
func3->SetLineWidth(2);
h1->SetMarkerStyle(20);
h1->SetMarkerSize(1.0);
h1->SetMarkerColor(kBlue);
c1->Update();
}
It gives me:
root [0]
Processing fit3.C...
Warning in <Fit>: Fit data is empty
do you get the same ?
I am not getting any fit.
I got that but when you run the macro do you also get the message:
Warning in <Fit>: Fit data is empty
No…I am not getting that…
data_test.txt (227 Bytes)
If you test with this one, may be you can run: [please make changes correspondingly like following]
TH3F *h1 = new TH3F(“h1”,“h1”,100,1000,3000,100,0.5,1.0,100,0.0,1.0);
…
TF3 *func3 = new TF3(“func3”,myfunc3,1000,3000,0.5,1.0,0.0,1.0,7);
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.