Saving canvas in a diferente Linux directory using a macro

Hi there,

Using a macro I am trying to save the canvas c1 to a different Linux directory.
I have tried this:

void plotall()
{…
gSystem->Exec(“mkdir plotall”);
cout << " " << endl;
cout << " …the subdirectory “plotall” has been created. " << endl;
cout << " " << endl;
//
gSystem->Exec(“cd ./plotall”);

//Histogram variable-----------------------------Plot title
plot1d(hnconf,“n conf”,“1”,“lin”,“lin”);// Number of configurations (TB or BT or TT or BB)

}
void plot1d(TH1F* string1, TString xtitle, TString binning, TString scaley1, TString scalex1)
{
TCanvas * c1 = new TCanvas(“c1”,“c1”,1200,800);
string1->Draw();
string1->GetXaxis()->SetTitle(xtitle);
string1->GetYaxis()->SetTitle("# of Events/" + binning);
string1->GetXaxis()->CenterTitle();
string1->GetYaxis()->CenterTitle();
string1->GetXaxis()->SetTitleOffset(1.2);
string1->GetYaxis()->SetTitleOffset(1.5);
c1->Update();
if (scalex1 == “log”){
gPad->SetLogx();
}
if (scaley1 == “log”){
gPad->SetLogy();
}
c1->Modified();

TString hname1 = string1->GetName();
c1->SaveAs(hname1 + “.png”);
}

Output file created via Saved As c1.png keeps going to the top Linux directory where ROOT runs not to ./plotall.
What is wrong, please?

Thanks in advance
Luiz


_ROOT Version: 6.16/00
_Platform: Fedora 29
_Compiler: GCC 8.3 RedHat 8


  • List item
gSystem->mkdir("some/new/path", kTRUE);
// ...
gSystem->cd("some/new/path");

Thanks a lot, Wile.

cheers,
Luiz

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