Hi All,
I am having trouble with writing loop for initialised array of histograms. I could successfully use the array objects individually (i.e //emptyENu[0]->Fill(5);//emptyENu[0]->Draw();). However, when I use the histogram pointer(emptyENu[reE]) again in another loop, I am having trouble executing the file. (.L filename.C+ didn’t give me any error messages).
void run(){
TH1F *h1= new TH1F(“h1”,“h1”,10,0.,100.);
TH1F *h1Bar= new TH1F(“h1Bar”,“h1Bar”,10,0.,100.);
TH1F *emptyENu[10];
TH1F *emptyENuBar[10];
for(int i=0; i<10; i++){
//Initialising arrays of histograms
emptyENu[i]=(TH1F*)h1->Clone(Form(“emptyENu_%d”,i));
cout<<(emptyENu[i])->GetName()<<endl;
emptyENuBar[i]=(TH1F*)h1Bar->Clone(Form(“emptyENuBar_%d”,i));
cout<<(emptyENuBar[i])->GetName()<<endl;
}
//emptyENu[0]->Fill(5);
//emptyENu[0]->Draw();
for(int i=0; i<10; i++){
emptyENu[i]->Fill(5);
}
emptyENu[0]->Draw();
}
Many Thanks,
Sarah