Hi,
in analysing a Tree, I have the need to create an array of histogram, or something equivalent, with a variable number of elements.
I have tried the following:
TH1F **h_pt_t_pdf=new TH1F*[num_pdf];
for(int i=0; i<num_pdf; i++){
sprintf(h_name,"pt_t_pdf%i",i+1);
h_pt_t_pdf[i]=new TH1F(h_name,"",n_pt_t,l_pt_t);
}
where num_pdf is an int previously calculated, n_pt_t contains the number of bins and l_pt_t the edges of the histogram.
This works if the code is interpreted, while fails if compiled, returnig the error:
/home/matteo/codice_analisi/./analisi.cxx:450:9: error: ‘h_pt_t_pdf’ was not declared in this scope
I’m including the following headers:
#include <TH1.h>
#include <TArray.h>
#include<TObject.h>
#include <TSystem.h>
#include <TLorentzVector.h>
#include <TMath.h>
#include <TChain.h>
#include <TFile.h>
#include <TClonesArray.h>
but I think something is missing.
I know this approach is quite rough, but I was not able to find anything useful over the internet.
Any help will be really appreciated.
Thanks,
Matteo