Fill hist using "for" loop

Hi,

I’ve been trying to do a simple histogram filling of values from a .root file.
Using the simple algorithm below, I always get zero for the values declared as Double_t being filled.

[code]{
gROOT->Reset();
//Load SUSY1 1st root file
TFile *g = new TFile(“user.MarijaMilosavljevic.SU1_jimmy_susy.recon.v12000601.SV_HPTV_12071.AANT1._00001.root”);
TTree Truth0 = (TTree)g->Get(“Truth0”);

//Declaration of variable to be filled
Int_t El_N;
Double_t El_p_T;
Double_t El_E;

//Set branch address and tell where will get the value from
Truth0->SetBranchAddress(“El_N”, &El_N);
Truth0->SetBranchAddress(“El_p_T”,&El_p_T);
Truth0->SetBranchAddress(“El_E”,&El_E);

//determine number of events in the tree Truth0
Int_t nevent = Truth0->GetEntries();

//initialization of a histograms
TH1F *h1 = new TH1F(“h1”,“Electron_Pt”,100,0,150);

//Fill histogram
for (Int_t i = 0; i< 100; i++){
Truth0->GetEntry(i);
cout << "number of e is "<< El_N << " and El_p_T is “<< El_p_T <<” and Energy is "<<El_E<< endl;
h1->Fill(El_p_T);
}
}[/code]

The data declared as Int_t is fine when it’s filled. But, for data declared as Double_t, they always yield “0”.

I try to look up the structure of this .root file, and see that, El_p_T and El_E are both declared as “vector” in the .root file.

My question is that, is using h1->Fill() not suitable for this type of data? That’s why it always yield “o.” If that’s the problem, what’s a way to fill this type of data? Or, is it other kind of issue?

Regards,

Raksapol

[quote]I try to look up the structure of this .root file, and see that, El_p_T and El_E are both declared as “vector” in the .root file.[/quote]The problem is with the retrieval, since those branches contain a vector you must pass the address of a pointer to a vector to SetBranchAddress.

Cheers,
Philippe

Merci beaucoup.