say I have something previously defined arrays of TH1F *h0[i] to hn[i] pointers
for (int i = 0; i < n+1; i++) {
h0[i] = new TH1F( TString::Format("h0%d", i), "", nPos, -0.5, ((Double_t) nPos + 0.5) );
h1[i] = new TH1F( TString::Format("h1%d", i), "", nPos, -0.5, ((Double_t) nPos + 0.5) );
...
hn[i] = new TH1F( TString::Format("h7%d", i), TString::Format("Channel %d", chanEval[7]), nPos, -0.5 ((Double_t) nPos + 0.5) );
}
and at some point I want to draw, n TH1Fs in a single canvas. Instead of
Int_t w =2000; Int_t h = 965;
TCanvas *c0 = new TCanvas("c0","",w,h);
c0->SetWindowSize( w+(w-c0->GetWw()), h+(h-c0->GetWh()) );
c0->Divide(n/2,2);
c0->cd(1);
gPad->Update();
h0[0]->Draw("C");
for (int i = 1; i<n; i++){
h0[i]->SetLineColor(i+1);
h0[i]->Draw("same c");
}
...
c0->cd(n);
gPad->Update();
h1[0]->Draw("C");
for (int i = 1; i<n; i++){
hn[i]->SetLineColor(i+1);
hn[i]->SetLineColor(i+1);
}
how can I more elegantly write , where %d = i
for (int i=1; i<9; i++){
c0->cd (i);
gPad->Update();
h(%d-1)[0]->Draw("C");
for (int i = 1; i<n; i++){
h(%d - 1)[i]->SetLineColor(i+1);
h(%d-1)[i]->Draw("same c");
}
}