Hi !
I am working on a code to add text to my graph but it is not able to write more than one line in the graph or canvas.
efficiency_R.C (1.9 KB) rad_9.txt (340 Bytes)
ROOT Version: Not Provided
Platform: Not Provided
Compiler: Not Provided
Hi !
I am working on a code to add text to my graph but it is not able to write more than one line in the graph or canvas.
efficiency_R.C (1.9 KB) rad_9.txt (340 Bytes)
ROOT Version: Not Provided
Platform: Not Provided
Compiler: Not Provided
@Wile_E_Coyote
Actually I used TpaveText in my code.
Still I am not able to write more than one line in canvas.
Read the reference page; you need to provide the coordinates of the box when you create a TPaveText.
#include "TFile.h"
#include "TGraphErrors.h"
#include "TF1.h"
Double_t Fit1(Double_t *x, Double_t *par)
{
Double_t arg1 = TMath::Log(0.01*x[0]); // in keV
Double_t arg2 = TMath::Log(0.001*x[0]); // in keV
Double_t fit_val = TMath::Exp(TMath::Power((TMath::Power((par[0]+par[1]*arg1+par[2]*arg1*arg1),(-1.0*par[3]))+TMath::Power((par[4]+par[5]*arg2+par[6]*arg2*arg2),(-1.0*par[3]))),(-1.0*1/par[3])))/1000.;
return fit_val;
}
void efficiency_R() {
TGraphErrors *g = new TGraphErrors("rad_9.txt", "%lg %lg %lg");
TF1 *RT = new TF1("RT",Fit1,100.,1500.,7.);
//rad 6,7
RT->SetParameter(0,16.);
RT->SetParameter(1,7.5);
RT->FixParameter(2,0.);
RT->FixParameter(3,15.);
RT->SetParameter(4,15.);
RT->SetParameter(5,-0.78);
RT->SetParameter(6,.015);
RT->Draw("L");
g->SetMaximum(15000.);//along Y
g->Fit("RT","IER");
g->SetMarkerStyle(3);
g->Draw("AP");
g->SetTitle("Efficiency Vs Energy(keV);Energy;Efficiency");
gStyle->SetOptFit(111); //showing the parameters on graph
TPaveText *pt = new TPaveText(77.6016,12857.83,971.9464,14578.31);
pt->SetBorderSize(0);
pt->SetFillColor(0);
pt->SetFillStyle(0);
pt->AddText("Exp{[(P0+P1*X+P2*X*X)**(-P3)+(P4+P5*Y+P6*Y*Y)**(-P3)]**(-1/P3)}");
pt->AddText("WITH X = LOG (X/100) & Y = LOG (X/1000)");
pt->Draw();
double par[7];
RT->GetChisquare();
RT->GetParameters(par);
double a = 700.0, y;
y = RT->Eval(a);
cout << "y = "<<y<<endl;
}
@couet
can I get directly the value of chi square written in the stat box? If yes, then what I have to use?
RT->GetChisquare();
@couet
I used this but I am talking about the stat box in the canvas.
@couet Maybe you could copy (“replicate”) the very first “Note” from TStyle::SetOptStat to TStyle::SetOptFit.
@robertfroast sorry I understood the opposite. see Wile answer
@Wile_E_Coyote yes it makes sense.
/// - never call SetOptFit(0111) but call SetOptFit(111) or SetOptFit(10111), 0111 will
and then also maybe correct:
/// - never call SetOptStat(000000111) but call SetOptStat(111) or SetOptStat(1000000111), 000000111 will
Yes @bellenot saw it also (PR reviewer). Thanks !