Adding specific name using TString

Hello,

I hope it is possible what I am trying to achieve. Basically I have multiple datasets and I want to name their histograms’ output file based on the name of input file.

int main(int argc, const char* argv[])
{
    TString inputFile(argv[1]);
// other code...
    //Deleting from the arguments the file location and .root
    inputFile.Remove(0,9);
    inputFile.Remove(inputFile.Sizeof()-6,inputFile.Sizeof());
    //.....
    histo = (TH1D*)histograms->Get(names[i]);
    histo->Draw("e");
    c1->SetLogy(1);
    c1->Print(Form("out/plots/%s-%s.png",inputFile,names[i]));

So I thought about this, because this is sort of convenient for me… but it does not work…

Thanks in advance,
Barnabas

try:

c1->Print(Form("out/plots/%s-%s.png",inputFile.Data(),names[i]));
1 Like

Hello,

Thank you very much… I must’ve missed this when browsing the description. It is working.

Cheers,
Barnabas

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