Dear Rooters,
I would like to create n TH1F histograms dynamically, ie
int n= 500;
for(int i=0; i<n; i++) {
TH1F *h_%d = new TH1F ("h_%d" , "", 0, -0.5, (Double_t) n+0.5 ); //%d = i
// but not delete just yet as I will need to to fill them outside this loop . I just need to create n TH1Fs, giving TH1F pointer name as the index i, indicated above.
}
{
const int n = 500;
TH1F *h[n];
for(int i = 0; i < n; i++) {
h[i] = new TH1F( TString::Format("h_%d", i), // name
TString::Format("histogram %d", i), // title
100, -0.5, ((Double_t)n + 0.5) );
}
//...fill the histograms here then draw
h_0->Draw();
for(int i = 1; i < n; i++) {
h_%d->Draw("same"); // how does one call the histogram?
}
}