Issue in root compilation (directly from terminal)

Hi ROOTers,

I have an issue when i try to execute my program directly from the terminal. Actually, my script work if I use it from the root interface (when I do : root -l) but when I try to run it from the terminal (using "g++ -o Plotting_AlignmentFiles_Final Plotting_AlignmentFiles_Final.cc root-config --cflags --libs" then ./Plotting_AlignmentFiles_Final Trans_Alignment_5710.dat) I have a big list of errors.

The errors are :slight_smile:
Error in TGaxis::PaintAxis: length of axis is 0
Error in TGaxis::PaintAxis: length of axis is 0
Error in TGaxis::PaintAxis: length of axis is 0
Error in TGaxis::PaintAxis: length of axis is 0
Error in TGaxis::PaintAxis: length of axis is 0
Error in TGaxis::PaintAxis: length of axis is 0
Error in TGaxis::PaintAxis: length of axis is 0
Error in TGaxis::PaintAxis: length of axis is 0
Error in TGaxis::PaintAxis: length of axis is 0
Error in TGaxis::PaintAxis: length of axis is 0
Error in TGaxis::PaintAxis: length of axis is 0
Error in TGaxis::PaintAxis: length of axis is 0
Error in TGaxis::PaintAxis: length of axis is 0
Error in TGaxis::PaintAxis: length of axis is 0
Info in TCanvas::Print: gif file PLOTS/XY_YZ_XZ_Channel_1.gif has been created
Warning in TCanvas::Constructor: Deleting canvas with same name: c1
Error in TGaxis::PaintAxis: length of axis is 0
Error in TGaxis::PaintAxis: length of axis is 0
Error in TGaxis::PaintAxis: length of axis is 0
Error in TGaxis::PaintAxis: length of axis is 0
Error in TGaxis::PaintAxis: length of axis is 0
Error in TGaxis::PaintAxis: length of axis is 0
Error in TGaxis::PaintAxis: length of axis is 0
Error in TGaxis::PaintAxis: length of axis is 0
Error in TGaxis::PaintAxis: length of axis is 0
Error in TGaxis::PaintAxis: length of axis is 0
Error in TGaxis::PaintAxis: length of axis is 0
Error in TGaxis::PaintAxis: length of axis is 0
Error in TGaxis::PaintAxis: length of axis is 0
Error in TGaxis::PaintAxis: length of axis is 0
Error in TGaxis::PaintAxis: length of axis is 0
Error in TGaxis::PaintAxis: length of axis is 0
Error in TGaxis::PaintAxis: length of axis is 0
Error in TGaxis::PaintAxis: length of axis is 0
Error in TGaxis::PaintAxis: length of axis is 0
Error in TGaxis::PaintAxis: length of axis is 0
Error in TGaxis::PaintAxis: length of axis is 0
Error in TGaxis::PaintAxis: length of axis is 0
Error in TGaxis::PaintAxis: length of axis is 0
Error in TGaxis::PaintAxis: length of axis is 0
Error in TGaxis::PaintAxis: length of axis is 0
Error in TGaxis::PaintAxis: length of axis is 0
Error in TGaxis::PaintAxis: length of axis is 0
Error in TGaxis::PaintAxis: length of axis is 0
Info in TCanvas::Print: gif file PLOTS/XY_YZ_XZ_Channel_2.gif has been created
Warning in TCanvas::Constructor: Deleting canvas with same name: c1
Error in TGaxis::PaintAxis: length of axis is 0
Error in TGaxis::PaintAxis: length of axis is 0
Error in TPad::Range: illegal world coordinates range: x1=0.000000, y1=-0.000000, x2=0.000000, y2=0.000000
Error in TPad::RangeAxis: illegal axis coordinates range: xmin=0.000000, ymin=0.000000, xmax=0.000000, ymax=0.000000
Error in TPad::Range: illegal world coordinates range: x1=0.000000, y1=-12.500000, x2=0.000000, y2=12.500000
Error in TPad::RangeAxis: illegal axis coordinates range: xmin=0.000000, ymin=-10.000000, xmax=0.000000, ymax=10.000000
Error in TPad::Range: illegal world coordinates range: x1=0.000000, y1=-12.500000, x2=0.000000, y2=12.500000
Error in TPad::RangeAxis: illegal axis coordinates range: xmin=0.000000, ymin=-10.000000, xmax=0.000000, ymax=10.000000
Error in TGaxis::PaintAxis: length of axis is 0
Error in TGaxis::PaintAxis: length of axis is 0
Error in TPad::Range: illegal world coordinates range: x1=0.000000, y1=-12.500000, x2=0.000000, y2=12.500000
Error in TPad::RangeAxis: illegal axis coordinates range: xmin=0.000000, ymin=-10.000000, xmax=0.000000, ymax=10.000000
Info in TCanvas::Print: gif file PLOTS/XY_YZ_XZ_Channel_4.gif has been created
Warning in TCanvas::Constructor: Deleting canvas with same name: c1
Error in TGaxis::PaintAxis: length of axis is 0
Error in TGaxis::PaintAxis: length of axis is 0
Error in TGaxis::PaintAxis: length of axis is 0
Error in TGaxis::PaintAxis: length of axis is 0
Error in TGaxis::PaintAxis: length of axis is 0
Error in TGaxis::PaintAxis: length of axis is 0
Error in TGaxis::PaintAxis: length of axis is 0
Error in TGaxis::PaintAxis: length of axis is 0
Error in TPad::Range: illegal world coordinates range: x1=0.000000, y1=0.000000, x2=0.000000, y2=0.000000
Error in TPad::RangeAxis: illegal axis coordinates range: xmin=0.000000, ymin=0.000000, xmax=0.000000, ymax=0.000000
Error in TPad::Range: illegal world coordinates range: x1=0.000000, y1=-12.500000, x2=0.000000, y2=12.500000
Error in TPad::RangeAxis: illegal axis coordinates range: xmin=0.000000, ymin=-10.000000, xmax=0.000000, ymax=10.000000
Error in TPad::Range: illegal world coordinates range: x1=0.000000, y1=-12.500000, x2=0.000000, y2=12.500000
Error in TPad::RangeAxis: illegal axis coordinates range: xmin=0.000000, ymin=-10.000000, xmax=0.000000, ymax=10.000000
Error in TGaxis::PaintAxis: length of axis is 0
Error in TGaxis::PaintAxis: length of axis is 0
Error in TGaxis::PaintAxis: length of axis is 0
Error in TGaxis::PaintAxis: length of axis is 0
Error in TGaxis::PaintAxis: length of axis is 0
Error in TGaxis::PaintAxis: length of axis is 0
Error in TGaxis::PaintAxis: length of axis is 0
Error in TGaxis::PaintAxis: length of axis is 0
Error in TPad::Range: illegal world coordinates range: x1=0.000000, y1=-12.500000, x2=0.000000, y2=12.500000
Error in TPad::RangeAxis: illegal axis coordinates range: xmin=0.000000, ymin=-10.000000, xmax=0.000000, ymax=10.000000
Error in TGaxis::PaintAxis: length of axis is 0
Error in TGaxis::PaintAxis: length of axis is 0
Info in TCanvas::Print: gif file PLOTS/XY_YZ_XZ_Channel_5.gif has been created
Warning in TCanvas::Constructor: Deleting canvas with same name: c1
Error in TGaxis::PaintAxis: length of axis is 0
Error in TGaxis::PaintAxis: length of axis is 0
Error in TGaxis::PaintAxis: length of axis is 0
Error in TGaxis::PaintAxis: length of axis is 0
Error in TGaxis::PaintAxis: length of axis is 0
Error in TGaxis::PaintAxis: length of axis is 0
Error in TGaxis::PaintAxis: length of axis is 0
Error in TGaxis::PaintAxis: length of axis is 0
Error in TPad::Range: illegal world coordinates range: x1=0.000000, y1=0.000000, x2=0.000000, y2=0.000000
Error in TPad::RangeAxis: illegal axis coordinates range: xmin=0.000000, ymin=0.000000, xmax=0.000000, ymax=0.000000
Error in TPad::Range: illegal world coordinates range: x1=0.000000, y1=-12.500000, x2=0.000000, y2=12.500000
Error in TPad::RangeAxis: illegal axis coordinates range: xmin=0.000000, ymin=-10.000000, xmax=0.000000, ymax=10.000000
Error in TPad::Range: illegal world coordinates range: x1=0.000000, y1=-12.500000, x2=0.000000, y2=12.500000
Error in TPad::RangeAxis: illegal axis coordinates range: xmin=0.000000, ymin=-10.000000, xmax=0.000000, ymax=10.000000
Error in TGaxis::PaintAxis: length of axis is 0
Error in TGaxis::PaintAxis: length of axis is 0
Error in TGaxis::PaintAxis: length of axis is 0
Error in TGaxis::PaintAxis: length of axis is 0
Error in TGaxis::PaintAxis: length of axis is 0
Error in TGaxis::PaintAxis: length of axis is 0
Error in TGaxis::PaintAxis: length of axis is 0
Error in TGaxis::PaintAxis: length of axis is 0

Here is my script :slight_smile:

for(int i=0;i<16;i++){	

	iloop=i*4;

		for(int j=iloop;j<iloop+4;j++){
			
			if(j==0) {continue;}
			else if(j%4==0){continue;}
			else {
			
			
			if(j==1){
			XG1[0]=x[j];
			YG1[0]=y[j];
			ZG1[0]=z[j];}
			
			else if((j-1)%4==0){
			XG1[0]=x[j];
			YG1[0]=y[j];
			ZG1[0]=z[j];}
			
			
			
			else if(j==2){
			XG2[0]=x[j];
			YG2[0]=y[j];
			ZG2[0]=z[j];}
			
			else if((j-2)%4==0){
			XG2[0]=x[j];
			YG2[0]=y[j];
			ZG2[0]=z[j];}
			
			
			
			else if(j==3 || (j-3)%4==0){
			XG3[0]=x[j];
			YG3[0]=y[j];
			ZG3[0]=z[j];}
			
			
					
//std::cout<<YG[0]<<std::endl;
//std::cout<<ZG[0]<<std::endl;
			
			}
		}

	
	char title[64];
	sprintf(title,"Channel_%i -- Plots XY / YZ / XZ",TitlePlot[i]);

	TCanvas *c1 = new TCanvas("c1",title);
	
	TPaveLabel* TitleG = new TPaveLabel(0.1,0.96,0.9,0.99,title);
  	TitleG->Draw();
  
	
	TPad* c = new TPad("Graph","Graph",0.01,0.05,0.95,0.95);
  	c->Draw();
  	c->cd();
  	
	c->Divide(1,3);
	TMultiGraph *CT1=new TMultiGraph();
	TMultiGraph *CT2=new TMultiGraph();
	TMultiGraph *CT3=new TMultiGraph();


	c->cd(1); //First graph (X function of Y)
	c->cd(1)->SetGrid();
	
	TGraph *CT1_1=new TGraph(nbpts,XG1,YG1);
	CT1_1->SetMarkerStyle(3);
	CT1_1->SetMarkerSize(3);
	CT1_1->SetMarkerColor(2);//Color for ROC 0
	CT1->Add(CT1_1);
	TGraph *CT1_2=new TGraph(nbpts,XG2,YG2);
	CT1_2->SetMarkerStyle(3);
	CT1_2->SetMarkerSize(3);
	CT1_2->SetMarkerColor(3);//Color for ROC 1
	CT1->Add(CT1_2);
	TGraph *CT1_3=new TGraph(nbpts,XG3,YG3);
	CT1_3->SetMarkerStyle(3);
	CT1_3->SetMarkerSize(3);
	CT1_3->SetMarkerColor(4);//Color for ROC 2
	CT1->Add(CT1_3);
	CT1->Draw("apl");
	CT1->SetTitle("X function of Y");
	gStyle->SetTitleFontSize(0.1);	
	CT1->GetXaxis()->SetRangeUser(-4.0,4.0);
	CT1->GetXaxis()->SetTitle("X location (#mum)");
	CT1->GetXaxis()->SetTitleSize(0.08);
	CT1->GetXaxis()->SetTitleOffset(0.4);
	CT1->GetYaxis()->SetRangeUser(-10.,10.);
	CT1->GetYaxis()->SetTitle("Y location (#mum)");
	CT1->GetYaxis()->SetTitleSize(0.08);
	CT1->GetYaxis()->SetTitleOffset(0.2);
	


	gPad->Update();
	gPad->Modified();
	
	TLegend* legend1 = new TLegend(1,0.9,0.9,0.5);
	legend1->AddEntry(CT1_1,"ROC 0");
	legend1->AddEntry(CT1_2,"ROC 1");
	legend1->AddEntry(CT1_3,"ROC 2");
	legend1->SetFillStyle(0);
	legend1->Draw();
	

	c->cd(2); //Second Graph (Y function of Z)
	c->cd(2)->SetGrid();	
	
	TGraph *CT2_1=new TGraph(nbpts,YG1,ZG1);
	CT2_1->SetMarkerStyle(3);
	CT2_1->SetMarkerSize(3);
	CT2_1->SetMarkerColor(2);
	CT2->Add(CT2_1);
	TGraph *CT2_2=new TGraph(nbpts,YG2,ZG2);
	CT2_2->SetMarkerStyle(3);
	CT2_2->SetMarkerSize(3);
	CT2_2->SetMarkerColor(3);
	CT2->Add(CT2_2);
	TGraph *CT2_3=new TGraph(nbpts,YG3,ZG3);
	CT2_3->SetMarkerStyle(3);
	CT2_3->SetMarkerSize(3);
	CT2_3->SetMarkerColor(4);
	CT2->Add(CT2_3);
	CT2->Draw("apl");
	CT2->SetTitle("Y function of Z");
	CT2->GetXaxis()->SetRangeUser(-4.0,4.0);
	CT2->GetXaxis()->SetTitle("Y location (#mum)");
	CT2->GetXaxis()->SetTitleSize(0.08);
	CT2->GetXaxis()->SetTitleOffset(0.4);
	CT2->GetYaxis()->SetRangeUser(-10.,10.);
	CT2->GetYaxis()->SetTitle("Z location (#mum)");
	CT2->GetYaxis()->SetTitleSize(0.08);
	CT2->GetYaxis()->SetTitleOffset(0.2);
	
	

	
	
	gPad->Update();
	gPad->Modified();
	
	TLegend* legend2 = new TLegend(1,0.9,0.9,0.5);
	legend2->AddEntry(CT1_1,"ROC 0");
	legend2->AddEntry(CT1_2,"ROC 1");
	legend2->AddEntry(CT1_3,"ROC 2");
	legend2->SetFillStyle(0);
	legend2->Draw();
	

	c->cd(3); //Third Graph (X function of Z)
	c->cd(3)->SetGrid();	
	


	TGraph *CT3_1=new TGraph(nbpts,XG1,ZG1);
	
	CT3_1->SetMarkerStyle(3);
	CT3_1->SetMarkerSize(3);
	CT3_1->SetMarkerColor(2);
	CT3->Add(CT3_1);
	TGraph *CT3_2=new TGraph(nbpts,XG2,ZG2);
	CT3_2->SetMarkerStyle(3);
	CT3_2->SetMarkerSize(3);
	CT3_2->SetMarkerColor(3);
	CT3->Add(CT3_2);
	TGraph *CT3_3=new TGraph(nbpts,XG3,ZG3);
	CT3_3->SetMarkerStyle(3);
	CT3_3->SetMarkerSize(3);
	CT3_3->SetMarkerColor(4);
	CT3->Add(CT3_3);
	CT3->Draw("apl");
	CT3->SetTitle("X function of Z");
	CT3->GetXaxis()->SetRangeUser(-4.0,4.0);
	CT3->GetXaxis()->SetTitle("X location (#mum)");
	CT3->GetXaxis()->SetTitleSize(0.08);
	CT3->GetXaxis()->SetTitleOffset(0.4);
	CT3->GetYaxis()->SetRangeUser(-10.,10.);
	CT3->GetYaxis()->SetTitle("Z location (#mum)");
	CT3->GetYaxis()->SetTitleSize(0.08);
	CT3->GetYaxis()->SetTitleOffset(0.2);

	
	
	gPad->Update();
	gPad->Modified();
	
	TLegend* legend3 = new TLegend(1,0.9,0.9,0.5);
	legend3->AddEntry(CT1_1,"ROC 0");
	legend3->AddEntry(CT1_2,"ROC 1");
	legend3->AddEntry(CT1_3,"ROC 2");
	legend3->SetFillStyle(0);
	legend3->Draw();
	
	
	//Sauvegarder le canvas et le vider pr le nouveau tour de boucle
	c1->SaveAs(TString::Format("PLOTS/XY_YZ_XZ_Channel_%i.gif",TitlePlot[i]));
	
	//delete legend3,legend1,legend2,TitleG,CT1,CT1_1,CT1_2,CT1_3,CT2,CT2_1,CT2_2,CT2_3,CT3,CT3_1,CT3_2,CT3_3,c1;


	}//End of the 2nd for loop

I thank you by advance.

What you posted is compilable, it is only a fragment.

Sorry, I thought it was enouth

This is my entire script :


#include <stdio.h>
#include <iostream>
#include <fstream>
#include <sstream>
#include <vector>
#include <string>
#include <map>
#include <numeric>
#include <math.h>
#include <utility>

#include "TCanvas.h"
#include "TGraphErrors.h"
#include "TGraph.h"
#include "TROOT.h"
#include "TRint.h"
#include "TFile.h"
#include "TStyle.h"
#include "TLine.h"
#include "Riostream.h"
#include "TAxis.h"
#include "TChain.h"
#include "TAttMarker.h"
#include "TMultiGraph.h"
#include "TLegend.h"
#include "TPaveLabel.h"
#include "TLatex.h"
#include "TGaxis.h"
#include "THistPainter.h"
#include "TPad.h"
#include "TProfile.h"
#include "TF1.h"
#include "TEnv.h"



void ReadFile(std::string const FileName)
{

	std::ifstream File(FileName.c_str());
	if (File)
		{//opening test
		}
	else
		{
		std::cout<<"opening file error"<<std::endl;
		}


	gEnv->GetValue("Canvas.SavePrecision", -1);
	gEnv->SetValue("Canvas.SavePrecision", 16);



int Channel, ROC;

Int_t n = 64; 
Double_t x[64];
Double_t y[64];
Double_t z[64];

int i=0;

//Loop to read each lines
for(std::string Line; std::getline(File,Line);) {


//Test to don't consider uninteresting lines
	if(Line.size()<1) { continue; }
	if(Line.at(0)=='#') { continue; }
	
	
	std::istringstream LineStream;
	LineStream.str(Line);


	LineStream >> Channel >> ROC;


float X,Y,Z,R,RX,RY;


		if (ROC == -1){
	
			LineStream >> RX >> RY >> X >> Y >> Z ;
			}
		else if (ROC == 0 || ROC == 1 || ROC == 2){
			LineStream >> R >> X >> Y >> Z ;
			}

//Put the X and Y read in arrays for plotting
Double_t x[64];
Double_t y[64];
Double_t z[64];


x[i]=X;
y[i]=Y;
z[i]=Z;


//TEST
//std::cout<<x[i]<<std::endl;
//std::cout<<Y<<std::endl;

i++;
}//End of the for loop




Int_t nbpts=1;
Double_t XG1[1],YG1[1],ZG1[1];
Double_t XG2[1],YG2[1],ZG2[1];
Double_t XG3[1],YG3[1],ZG3[1];

int iloop;
int TitlePlot[16]={1,2,4,5,7,8,10,11,13,14,16,17,19,20,22,23};


for(int i=0;i<16;i++){	

	iloop=i*4;

		for(int j=iloop;j<iloop+4;j++){
			
			if(j==0) {continue;}
			else if(j%4==0){continue;}
			else {
			
			
			if(j==1){
			XG1[0]=x[j];
			YG1[0]=y[j];
			ZG1[0]=z[j];}
			
			else if((j-1)%4==0){
			XG1[0]=x[j];
			YG1[0]=y[j];
			ZG1[0]=z[j];}
			
			
			
			else if(j==2){
			XG2[0]=x[j];
			YG2[0]=y[j];
			ZG2[0]=z[j];}
			
			else if((j-2)%4==0){
			XG2[0]=x[j];
			YG2[0]=y[j];
			ZG2[0]=z[j];}
			
			
			
			else if(j==3 || (j-3)%4==0){
			XG3[0]=x[j];
			YG3[0]=y[j];
			ZG3[0]=z[j];}
			
			
					
//std::cout<<YG[0]<<std::endl;
//std::cout<<ZG[0]<<std::endl;
			
			}
		}

	
	char title[64];
	sprintf(title,"Channel_%i -- Plots XY / YZ / XZ",TitlePlot[i]);

	TCanvas *c1 = new TCanvas("c1",title);
	
	TPaveLabel* TitleG = new TPaveLabel(0.1,0.96,0.9,0.99,title);
  	TitleG->Draw();
  
	
	TPad* c = new TPad("Graph","Graph",0.01,0.05,0.95,0.95);
  	c->Draw();
  	c->cd();
  	
	c->Divide(1,3);
	TMultiGraph *CT1=new TMultiGraph();
	TMultiGraph *CT2=new TMultiGraph();
	TMultiGraph *CT3=new TMultiGraph();


	c->cd(1); //First graph (X function of Y)
	c->cd(1)->SetGrid();
	
TGraph *CT1_1=new TGraph(nbpts,XG1,YG1);
	CT1_1->SetMarkerStyle(3);
	CT1_1->SetMarkerSize(3);
	CT1_1->SetMarkerColor(2);//Color for ROC 0
	CT1->Add(CT1_1);
	TGraph *CT1_2=new TGraph(nbpts,XG2,YG2);
	CT1_2->SetMarkerStyle(3);
	CT1_2->SetMarkerSize(3);
	CT1_2->SetMarkerColor(3);//Color for ROC 1
	CT1->Add(CT1_2);
	TGraph *CT1_3=new TGraph(nbpts,XG3,YG3);
	CT1_3->SetMarkerStyle(3);
	CT1_3->SetMarkerSize(3);
	CT1_3->SetMarkerColor(4);//Color for ROC 2
	CT1->Add(CT1_3);
	CT1->Draw("apl");
	CT1->SetTitle("X function of Y");
	gStyle->SetTitleFontSize(0.1);	
	CT1->GetXaxis()->SetRangeUser(-4.0,4.0);
	CT1->GetXaxis()->SetTitle("X location (#mum)");
	CT1->GetXaxis()->SetTitleSize(0.08);
	CT1->GetXaxis()->SetTitleOffset(0.4);
	CT1->GetYaxis()->SetRangeUser(-10.,10.);
	CT1->GetYaxis()->SetTitle("Y location (#mum)");
	CT1->GetYaxis()->SetTitleSize(0.08);
	CT1->GetYaxis()->SetTitleOffset(0.2);
	


	gPad->Update();
	gPad->Modified();
	
	TLegend* legend1 = new TLegend(1,0.9,0.9,0.5);
	legend1->AddEntry(CT1_1,"ROC 0");
	legend1->AddEntry(CT1_2,"ROC 1");
	legend1->AddEntry(CT1_3,"ROC 2");
	legend1->SetFillStyle(0);
	legend1->Draw();


c->cd(2); //Second Graph (Y function of Z)
	c->cd(2)->SetGrid();	
	
	TGraph *CT2_1=new TGraph(nbpts,YG1,ZG1);
	CT2_1->SetMarkerStyle(3);
	CT2_1->SetMarkerSize(3);
	CT2_1->SetMarkerColor(2);
	CT2->Add(CT2_1);
	TGraph *CT2_2=new TGraph(nbpts,YG2,ZG2);
	CT2_2->SetMarkerStyle(3);
	CT2_2->SetMarkerSize(3);
	CT2_2->SetMarkerColor(3);
	CT2->Add(CT2_2);
	TGraph *CT2_3=new TGraph(nbpts,YG3,ZG3);
	CT2_3->SetMarkerStyle(3);
	CT2_3->SetMarkerSize(3);
	CT2_3->SetMarkerColor(4);
	CT2->Add(CT2_3);
	CT2->Draw("apl");
	CT2->SetTitle("Y function of Z");
	CT2->GetXaxis()->SetRangeUser(-4.0,4.0);
	CT2->GetXaxis()->SetTitle("Y location (#mum)");
	CT2->GetXaxis()->SetTitleSize(0.08);
	CT2->GetXaxis()->SetTitleOffset(0.4);
	CT2->GetYaxis()->SetRangeUser(-10.,10.);
	CT2->GetYaxis()->SetTitle("Z location (#mum)");
	CT2->GetYaxis()->SetTitleSize(0.08);
	CT2->GetYaxis()->SetTitleOffset(0.2);

gPad->Update();
	gPad->Modified();
	
	TLegend* legend2 = new TLegend(1,0.9,0.9,0.5);
	legend2->AddEntry(CT1_1,"ROC 0");
	legend2->AddEntry(CT1_2,"ROC 1");
	legend2->AddEntry(CT1_3,"ROC 2");
	legend2->SetFillStyle(0);
	legend2->Draw();
	

	c->cd(3); //Third Graph (X function of Z)
	c->cd(3)->SetGrid();	
	


	TGraph *CT3_1=new TGraph(nbpts,XG1,ZG1);
	
	CT3_1->SetMarkerStyle(3);
	CT3_1->SetMarkerSize(3);
	CT3_1->SetMarkerColor(2);
	CT3->Add(CT3_1);
	TGraph *CT3_2=new TGraph(nbpts,XG2,ZG2);
	CT3_2->SetMarkerStyle(3);
	CT3_2->SetMarkerSize(3);
	CT3_2->SetMarkerColor(3);
	CT3->Add(CT3_2);

TGraph *CT3_3=new TGraph(nbpts,XG3,ZG3);
	CT3_3->SetMarkerStyle(3);
	CT3_3->SetMarkerSize(3);
	CT3_3->SetMarkerColor(4);
	CT3->Add(CT3_3);
	CT3->Draw("apl");
	CT3->SetTitle("X function of Z");
	CT3->GetXaxis()->SetRangeUser(-4.0,4.0);
	CT3->GetXaxis()->SetTitle("X location (#mum)");
	CT3->GetXaxis()->SetTitleSize(0.08);
	CT3->GetXaxis()->SetTitleOffset(0.4);
	CT3->GetYaxis()->SetRangeUser(-10.,10.);
	CT3->GetYaxis()->SetTitle("Z location (#mum)");
	CT3->GetYaxis()->SetTitleSize(0.08);
	CT3->GetYaxis()->SetTitleOffset(0.2);

	
	
	gPad->Update();
	gPad->Modified();

TLegend* legend3 = new TLegend(1,0.9,0.9,0.5);
	legend3->AddEntry(CT1_1,"ROC 0");
	legend3->AddEntry(CT1_2,"ROC 1");
	legend3->AddEntry(CT1_3,"ROC 2");
	legend3->SetFillStyle(0);
	legend3->Draw();
	
	
	//Sauvegarder le canvas et le vider pr le nouveau tour de boucle
	c1->SaveAs(TString::Format("PLOTS/XY_YZ_XZ_Channel_%i.gif",TitlePlot[i]));
	
	//delete legend3,legend1,legend2,TitleG,CT1,CT1_1,CT1_2,CT1_3,CT2,CT2_1,CT2_2,CT2_3,CT3,CT3_1,CT3_2,CT3_3,c1;


	}//End of the 2nd for loop
	
	
File.close();
}



int main(int argc,char* argv[]){
	 /*if (argc != 2) {
    		std::cerr << "Usage: " << argv[0] << " [DataFile.dat]" << std::endl;
    		return 1;
  		}*/
  		
	std::string const FileName = argv[1];
	
	ReadFile(FileName);
	
return 0;
}

At least one bug is this:

    Double_t x[64];
    Double_t y[64];
    Double_t z[64];

    // ... some lines omitted ...

    for (std::string Line; std::getline(File, Line);) {
        // ... some lines omitted ...

        // Put the X and Y read in arrays for plotting
        Double_t x[64];
        Double_t y[64];
        Double_t z[64];

        // ... some lines omitted ... (writing to x,y,z)
    } // End of the for loop

    // ... some lines omitted ...
    // now you are reading x,y,z

You are declaring these variables outside and inside a for loop, hiding the outer variables. Thus when you are using these x, y, and z after the loop you are accessing uninitialized values.

Didn’t you compile with warnings enabaled?!

Ok I correct that, I delete the array declaration in the loop but it doesn’t work yet.
To compile, I use this command :
g++ -o nameofmyscript.cc nameofmyscript root-config --cflags --libs

can I use the normal c++ warnings with a root compilation?

Sorry for all of that but Root is really new for me, I discover it last week.

Thank you again for your time.

Sure, just add -Wall -Wextra -Wpedantic or whatever flags you like.

By the way: zero is divisible by any nonzero integer without remainder. You don’t need all your extra checks for zero.

Also, I’d use vectors so that you don’t have the arbitrary limit of 64 lines (or add a check that i can never be >= 64 if the size is fixed). Since your file is small, you could provide that as well so one can reproduce your problem easily.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.