TGraphErrors::gr->GetXaxis()->SetTitle() in compiled c

Hi,

I have a small code and try to give a title to the x and y axis of a TGraphErrors but it doesnt work. The compilation breaks with:

Info in <TUnixSystem::ACLiC>: creating shared library /home/adonai/Documents/./AnalTE128_N_pitch_cpp.so In file included from /home/adonai/Documents/./AnalTE128_N_pitch_cpp_ACLiC_dict.h:33, from /home/adonai/Documents/./AnalTE128_N_pitch_cpp_ACLiC_dict.cxx:16: /home/adonai/Documents/./AnalTE128_N_pitch.cpp: In function ‘void AnalTE128_N_pitch()’: /home/adonai/Documents/./AnalTE128_N_pitch.cpp:54: error: invalid use of incomplete type ‘struct TAxis’ /home/adonai/ROOT/ROOT_5.25/root/include/TGraph.h:44: error: forward declaration of ‘struct TAxis’ /home/adonai/Documents/./AnalTE128_N_pitch.cpp:55: error: invalid use of incomplete type ‘struct TAxis’ /home/adonai/ROOT/ROOT_5.25/root/include/TGraph.h:44: error: forward declaration of ‘struct TAxis’ g++: /home/adonai/Documents/./AnalTE128_N_pitch_cpp_ACLiC_dict.o: No such file or directory Error in <ACLiC>: Compilation failed!

Here is the actual code:

[code]#include
#include
#include “TROOT.h”
#include “TGraphErrors.h”
#include “TCanvas.h”

#define MODULE 13 //Module to be analysed (h13:13,h14:23,h15:33,h16:43,…)
#define LINE_BEGIN_DATA 4321 //Number of line where the actual data is in the file
//#define FILE “run001_cluster.mod” //Name of file to be loaded (.mod)

using namespace std;

ifstream & SeekLine(ifstream & infile, int lineNumber) {
int count(0);
string line;
infile.seekg(0, ios::beg);
while (!infile.eof() && infile.good() && count < lineNumber) {
getline(infile, line);
count++;
}
return infile;
}

void AnalTE128_N_pitch() {

double value[128];

TCanvas *canv1 = new TCanvas(“canv1”, “h13 noise graph”);
canv1->cd()->Update();
TGraphErrors *gr_npos = new TGraphErrors(128);

ifstream infile(“run002_cluster.mod”); //Name of file to be loaded (.mod)
for (int strip(0); strip<128; strip++) {
if ( SeekLine(infile,LINE_BEGIN_DATA+strip).good() ) {
for (int i(0); i<MODULE-1;i++) {
string trash;
infile >> trash;
}
infile >> value[strip];
}
}
for ( int grcount(0); grcount<128; grcount++) {
gr_npos->SetPoint(grcount,grcount,value[grcount]);
gr_npos->SetPointError(grcount,0,0);
}

canv1->cd();
gr_npos->SetMarkerStyle(21);
gr_npos->SetMarkerColor(kRed);
gr_npos->SetTitle(“h13 noise graph”);

gr_npos->GetXaxis()->SetTitle(“strips”);
gr_npos->GetYaxis()->SetTitle(“electrons”);

gr_npos->Draw(“AP”);

for (int i(0); i<128; i++ ) {
cout << value[i] << endl;
}

}[/code]

Please help.

BR

Erik

Hi Erik,

Just add #include "TAxis.h" in your code…

Cheers, Bertrand.

Thank you! Works fine.

BR