Create mutliple histogram objects

Hi,

Yes it’s possible. In fact there are quite a lot of ways to do this; you could have a look through previous postings. For instance:

In your example the error quoted is because variable length arrays aren’t allowed (although there are some other problems in the example).

One possibility could be to use a vector of pointers to TH1F objects:

#include <vector>

std::vector<TH1F*> test_root(Int_t number, const char *name, Int_t nbins, Double_t bin_low, Double_t bin_high){
  std::vector<TH1F*> v;
  for(Int_t i=1;i<=number;i++) {
    TString hname = TString::Format("h%s%d",name,i);
    TH1F *h = new TH1F(hname.Data(),"",nbins,bin_low,bin_high);
    v.push_back(h);
  }
  return v;
}