Hi there!
I only have a question.I’ve recived this error while using the TVectorD
Error in <TVectorT::operator()>: Request index(20) outside vector range of 0 - 20
Error in <TVectorT::operator()>: Request index(20) outside vector range of 0 - 20
Error in <TVectorT::operator()>: Request index(20) outside vector range of 0 - 20
Error in <TVectorT::operator()>: Request index(20) outside vector range of 0 - 20
Also I’m new in root, there is a method to add values in a TVectorD while reading a file? I used this method, but I know that it’s not functional at all.
Hope it’s not a waste of your time.
This is my code:
TCanvas *c1 = new TCanvas("c1", "Canvas", 200, 10, 2000, 900); //creo il canvas sul quale mettere il grafico (TGraph)
c1->SetGrid();
vector<double> err_p_fabio;
vector<double> err_q_fabio;
vector<double> p_fabio;
vector<double> q_fabio;
ifstream fab("../File/coniugati_fabio.txt");
double f;
int i = 1;
while (fab >> f)
{
if (i == 1)
p_fabio.push_back(f);
if (i == 2)
q_fabio.push_back(f);
if (i == 3)
err_p_fabio.push_back(f);
if (i == 4)
{
err_q_fabio.push_back(f);
i = 0;
}
i++;
}
TVectorD x(p_fabio.size());
for (int q = 0; q <= p_fabio.size(); q++)
{
x(q) = p_fabio[q];
}
TVectorD y(q_fabio.size());
for (int w = 0; w <= err_q_fabio.size(); w++)
{
y(w) = q_fabio[w];
}
TVectorD err_x(err_p_fabio.size());
for (int q = 0; q <= err_p_fabio.size(); q++)
{
err_x(q) = err_p_fabio[q];
}
TVectorD err_y(err_q_fabio.size());
for (int w = 0; w <= err_q_fabio.size(); w++)
{
err_y(w) = err_q_fabio[w];
}
TGraphErrors *fabio = new TGraphErrors(x, y, err_x, err_y);
fabio->Draw("AP");