# Plotting only one point on canvass

hi everyone i would have wanted to print only just one point on a canvass.
kindly, see part of the code.

//=== generating the functions ===//
for (Int_t i=0; i<nof; i++)
{
fna = "f"; fna += i;
fpf[i] = new TF1("fna","(((2.0*[0]*[0]*[1]*[1]*[2]*[2]*[3]*[3])/(x*x*sin([4]*[5]/360.0)*sin([4]*[5]/360.0)*sin([4]*[5]/360.0)*sin([4]*[5]/360.0)+2.0*[3]*[3]*x*sin([4]*[5]/360.0)*sin([4]*[5]/360.0)+(x*sin([4]*[5]/360.0)*sin([4]*[5]/360.0)*sqrt(x*x*sin([4]*[5]/360.0)*sin([4]*[5]/360.0)*sin([4]*[5]/360.0)*sin([4]*[5]/360.0)+4.0*[3]*[3]*x*sin([4]*[5]/360.0)*sin([4]*[5]/360.0)))))*((2.0*[3]*[3])/(2.0*[3]*[3]+x*sin([4]*[5]/360.0)*sin([4]*[5]/360.0)+sqrt(x*x*sin([4]*[5]/360.0)*sin([4]*[5]/360.0)*sin([4]*[5]/360.0)*sin([4]*[5]/360.0)+4.0*[3]*[3]*x*sin([4]*[5]/360.0)*sin([4]*[5]/360.0))))*((4.0*[3]*[3])/(4.0*[3]*[3]+x))*(((0.71)/(0.71+x))*((0.71)/(0.71+x))*((0.71)/(0.71+x))*((0.71)/(0.71+x))*([7]*[7]*[8]*[8]*cos([4]*[5]/360.0)*cos([4]*[5]/360.0)+[6]*[6]*[7]*[7]*(2.0*[3]*[3]*x*cos([4]*[5]/360.0)*cos([4]*[5]/360.0)+4.0*[3]*[3]*x*sin([4]*[5]/360.0)*sin([4]*[5]/360.0)+x*x*sin([4]*[5]/360.0)*sin([4]*[5]/360.0))/(8.0*[3]*[3]*[3]*[3]))))", 0.0025, 1.0);
fpf[i]->SetParameter(0,1.0);
fpf[i]->SetParameter(1,1.0);
fpf[i]->SetParameter(2,1.0/137.0);
fpf[i]->SetParameter(3,gRandom->Gaus(0.938272081,0.000000006));
fpf[i]->SetParameter(4,27.0);
fpf[i]->SetParameter(5,TMath::Pi());
fpf[i]->SetParameter(6,2.792847351);
fpf[i]->SetParameter(7,gRandom->Gaus(0.979,0.022)+gRandom->Gaus(0.0,0.010));
fpf[i]->SetParameter(8,gRandom->Gaus(0.914,0.024)+gRandom->Gaus(0.0,0.010));
}

Int_t nop=300;

Double_t xpt, ypt, del = 0.9975/nop;

auto av1 = new TGraph(nop);
//TGraph *av1 = new TGraph();
for (Int_t j=0; j < nop; j++)
{
xpt = del*j + 0.0025*del;
av1->SetPoint(j, xpt, 0.0);
}
for (Int_t i=0; i<nof; i++)
{
for (Int_t j=0; j < nop; j++)
{
av1->GetPoint(j, xpt, ypt);
av1->SetPoint(j, xpt, ypt + fpf[i]->Eval(xpt)/(Double_t)nof);
}
}

av1->SetMarkerStyle(7);
av1->SetMarkerColor(kGreen);
av1->SetMarkerSize(1);

//=== Plotting the point on canvas ===//
int j = 0;

TGraph *av0000 = new TGraph();
double q20 = 0.399008;
double eps = 0.01;

for (Int_t i=0; i<nof; i++)
{
av1->GetPoint(i, xpt, ypt);
if ( abs(xpt - q20) < eps)
{
av0000->GetPoint(i, xpt, ypt);
av0000->SetPoint(j, xpt, ypt + fpf[i]->Eval(xpt)/(Double_t)nof);
j++;
}
}

av0000->SetMarkerStyle(22);
av0000->SetMarkerColor(3); //green
av0000->SetMarkerSize(1);

TMultiGraph *mgp = new TMultiGraph();
mgp->SetTitle("dcs of ep, eq_s, eq_c (with mrf); Transfer Momentum in GeV^2; Differential Cross Section");
mgp->SetMinimum(1.e-5);
mgp->SetMaximum(1.e0);

but I get a curve of points.

In the code you posted we do not see the drawing part.

is this what you mean?:

TMultiGraph *mgp = new TMultiGraph();
mgp->SetTitle("dcs of ep, eq_s, eq_c (with mrf); Transfer Momentum in GeV^2; Differential Cross Section");
mgp->SetMinimum(1.e-5);
mgp->SetMaximum(1.e0);

Well â€¦ It would be better to see the whole macroâ€¦ But: if you put in a multigraph several graphs having several points how can you see only one point ?

i will send the macro in the emailâ€¦ each graph should only contain one point in this case

Please send working code. I get:

Processing TheMacro.C...
In file included from input_line_9:1:
double q21 = 0.0.498758;

Also, no need to send the code by private email. post it here as attachement.

graciasâ€¦ okay, I will
DataPoints.C (95.1 KB)

Your macro gives me this plot. What is wrong with it ?

I think you always need:

TGraph *av... = new TGraph();
j = 0; // "reset" it

mgp->Draw("a");

av0000 has 3 pointsâ€¦we see 3 points â€¦ all is fine .

i seeâ€¦ i will tweak it againâ€¦ gracias

could it be the version of ROOT?
5-34-32
5-34-34
5-34-36

unrelated question:
How do I store the output text in to a file?
I mean, the command to do it?

regards,
jaybee

If you want to use ROOT 5, you need to get rid of all c++11 and newer statements in your macro (e.g. â€śautoâ€ť).

I could not anymore recognize which are C++ statements in the code but I have commented all the â€śautoâ€ť codeDataPointStatNewEPEQDCSProbColorWithMRF02.C (95.2 KB) . But the output is still the same

I get the same plot as @couet with ROOT 5.34/36.

#include "TCanvas.h"
#include "TStyle.h"
#include "TH1.h"
#include "TF1.h"
#include "TString.h"
#include "TRandom3.h"
#include "TGraph.h"
#include "TMultiGraph.h"
#include "TMath.h"

and then try:
root [0] .x DataPointStatNewEPEQDCSProbColorWithMRF02.C++

Note: an unused variable â€śav0002â€ť: TGraph *av0002 = new TGraph();

BTW. in order to simplify your code (you can get rid of â€śjâ€ť), you can use:
av...->SetPoint(av...->GetN(), xpt, ypt + ...); // append a new point

okayâ€¦ muchas graciasâ€¦ i will implement your suggestions

yeahâ€¦ it workedâ€¦ gracias

do i need to put the data point number in â€¦-GetN(241) [for example]â€¦