Hi everyone,
first time here (and ever on a forum). I’m new to ROOT, sorry in advance if this will sound as a stupid question.
I’d like to fill multiple histograms in a function, so i created an array of pointers to histograms. When i run my code i get an error like:
error: member reference base type ‘TH1F *’ is not a structure or union
h[ind]->Fill(LHEPart_pt[ilept]); //fill histogram for pt
My source code is the following:
void Events::VarDef()
{
TH1F **h[3]; //define array of histo pt for each particle
*h[0] = new TH1F("h1", "electron pT", 80, 0.0, 250.0);
*h[1] = new TH1F("h4", "muon pT", 80, 0.0, 250.0);
*h[2] = new TH1F("h7", "tau pT", 80, 0.0, 250.0);
TH1F *hR[6]; //array of histo, rct events
hR[0] = new TH1F("hRee", "Electron pT, from rct electron event", 80, 0.0, 250.0); //hRee
hR[1] = new TH1F("hRem", "Electron pT, from rct muon event", 80, 0.0, 250.0); //hRem
hR[2] = new TH1F("hRme", "Muon pT, from rct electron event", 80, 0.0, 250.0); //hRme
hR[3] = new TH1F("hRmm", "Muon pT, from rct muon event", 80, 0.0, 250.0); //hRmm
hR[4] = new TH1F("hRte", "Tau pT, from rct electron event", 80, 0.0, 250.0); //hRte
hR[5] = new TH1F("hRtm", "Tau pT, from rct muon event", 80, 0.0, 250.0); //hRtm
TH1F *hRi[6]; //array of histo, reconstructed isolated events
hRi[0] = new TH1F("hRiee", "Electron pT, from rct iso electron event", 80, 0.0, 250.0);
hRi[1] = new TH1F("hRiem", "Electron pT, from rct iso muon event", 80, 0.0, 250.0);
hRi[2] = new TH1F("hRime", "Muon pT, from rct iso electron event", 80, 0.0, 250.0);
hRi[3] = new TH1F("hRimm", "Muon pT, from rct iso muon event", 80, 0.0, 250.0);
hRi[4] = new TH1F("hRite", "Tau pT, from rct iso electron event", 80, 0.0, 250.0);
hRi[5] = new TH1F("hRitm", "Tau pT, from rct iso muon event", 80, 0.0, 250.0);
return;
}
void Events::Filling(Int_t ind, Int_t ilept)
{
h[ind]->Fill(LHEPart_pt[ilept]); //fill histogram for pt
if(nElectron>0){ //if there is at least one reconstructed Electron
hR[ind]->Fill(Electron_pt[0]); //store pT value of Electron
if(Electron_pfRelIso03_all[0]<0.15) hRi[ind]->Fill(Electron_pt[0]);
}
if (nMuon>0){ //Muon
hR[ind+1]->Fill(Muon_pt[0]);
if(Muon_pfRelIso03_all[0]<0.15) hRi[ind+1]->Fill(Muon_pt[0]);
}
return;
}
Of course this is just a snippet of the code. I copy-pasted this example but i have other functions with the same problem (a similar one with THStack, but one at a time).
I need an array-like structure because in order functions i fill, color and write to a file my histograms with for loops.
As you can also see, i also have a reference class (automatically generated with MakeClass). Don’t know if this information could help.
Thanks in advance for the help.
_ROOT Version: 6.11/02