Problems with getting address from a branch

HI dear rooters,

I am a root beginner and I have a problem when trying to histogram the content of a variable in a branch. I finished by using the same code as the one in tree2.C of the tutorial, but it still does not work.

void treemanu2(){
TFile *f=new TFile (“generic/ccbar/prod3/Dstar0CPK_ccbar-Run4-29.root”);
TTree ntp999 = (TTree)f->Get(“ntp999”);
static Float_t m_mes;
TBranch *bm_mes=ntp999->GetBranch(“m_mes”);
bm_mes->SetAddress(&m_mes);
TH1F *hmes = new TH1F(“hmes”,“Mes”,100,5.273,5.283);
Int_t nentries = (Int_t)ntp999->GetEntries();
for (Int_t i=0;i<nentries;i++) {
bm_mes->GetEntry(i);
cout <<“mes=” <<m_mes << endl;
hmes->Fill(m_mes);
}
}

The m_mes variable does not contain the supposed values (that would be around 5.275) but very large floats:
root [4] .x treemanu2.C
mes=-9.14559e+26
mes=2.571e-27
mes=1.01675e-18
mes=-1.57779e-21
mes=1.30288e-37
mes=6.66079e+23
Does anyone knows what happens? The structure of my tree ntp999 is similar to t2 of tree2.C
The histogram contains the mes values mentionned
Thanks a lot.

Hi latour,
it depends on how you created the branch. My guess is that you’ve created it such that TBranch::SetAddress expects the address of a pointer to a Float_t, so static Float_t m_mes; Float_t* p_mes=&m_mes; bm_mes->SetAddress(&p_mes); should work. It might also be that the branch stores a Double_t, and not a Float_t - if the above doesn’t help please tell us how you created and filled the branch; the output of bm_mes->Print() would then also be interesting to see.
Axel.

Hi Axel,

First, thank you for your quick answer.
When I use the code you gave me, then the output is:

I tried replacing Float_t by Double_t but the result is the same.

Concerning the creation of the branch, I am a bit puzzled: it is actually one of the numerous branch of an ntuple that was generated by a method from the C++ BaBar code. Each column of the ntuple is written by:
ntuple->column(“mes”,m_mes)
(The header file says,if it can help:
The member function “column” provides the data for a column of the ntuple.
The string is the label of the column as well as being a unique identifier
of the column. The second argument provides the data (float or int) for one row in the column.)
So I do not really master the creation and filling of the branch.

When I use the bm_mes->Print():

void treemanu2(){
TFile *f=new TFile ("generic/ccbar/prod3/Dstar0CPK_ccbar-Run4-29.root");
TTree *ntp999 = (TTree*)f->Get("ntp999");
static Float_t m_mes;
 Float_t* p_mes=&m_mes;
TBranch *bm_mes=ntp999->GetBranch("m_mes");
bm_mes->SetAddress(&p_mes);
bm_mes->Print();

 TH1F *hmes   = new TH1F("hmes","Mes",100,-5.273,5.283);

   Int_t nentries = (Int_t)ntp999->GetEntries();
   for (Int_t i=0;i<nentries;i++) {
     cout << "i=" << i << endl; 
     bm_mes->GetEntry(i);
      bm_mes->Print();
      cout <<"mes=" <<m_mes << endl;
      hmes->Fill(m_mes);
   } 
}

I get:

Does it help? Thank you in advance.
Emmanuel

Hi,

The problem is that in your tree there is no way to distinguish any of the branches (they all have the same name). If this was intentional, then you might know which branch you need by its index. You could use tree->GetListOfBranches()

Cheers,
Philippe.

…and your branches contain a Double_t, not a Float_t.
Axel.

I do not really understand: I just have one branch called m_mes (the other branches have different name), which contains the mes values for all my events. So what do you mean by all the branches have the same name?
Emmanuel

Hi Emmanuel,
the reason we suspected something wrong with your branch is that the branch’s number is increasing from event to event: in the 0th event it’s the 14th branch, in the 5th event it’s the 20th branch. Can you send us the output of ntp999->Print() called after the “for (Int_t i=0;i<nentries;i++)” loop, i.e. right before the method’s closing “}”?

Did you fix your code to use a Double_t instead of a Float_t?
Axel.

The output is the following (I quoted what we are interested in):


*Tree :ntp999 : Denis Ntuple *
*Entries : 6 : Total = 1386686 bytes File Size = 20233 *

  •    :          : Tree compression factor =   1.00                       *
    

*Br 0 :m_runnumber : m_runnumber/I *
*Entries : 6 : Total Size= 12470 bytes One basket in memory *
*Baskets : 0 : Basket Size= 8000 bytes Compression= 1.00 *

*Br 1 :m_upperid : m_upperid/I *
*Entries : 6 : Total Size= 12458 bytes One basket in memory *
*Baskets : 0 : Basket Size= 8000 bytes Compression= 1.00 *

*Br 2 :m_lowerid : m_lowerid/I *
*Entries : 6 : Total Size= 12458 bytes One basket in memory *
*Baskets : 0 : Basket Size= 8000 bytes Compression= 1.00 *

*Br 3 :m_MCmode : m_MCmode/I *
*Entries : 6 : Total Size= 12452 bytes One basket in memory *
*Baskets : 0 : Basket Size= 8000 bytes Compression= 1.00 *

*Br 4 :m_r2 : m_r2/D *
*Entries : 6 : Total Size= 12460 bytes One basket in memory *
*Baskets : 0 : Basket Size= 8000 bytes Compression= 1.00 *

*Br 5 :m_thrust : m_thrust/D *
*Entries : 6 : Total Size= 12484 bytes One basket in memory *
*Baskets : 0 : Basket Size= 8000 bytes Compression= 1.00 *

*Br 6 :m_sphericity : m_sphericity/D *
*Entries : 6 : Total Size= 12508 bytes One basket in memory *
*Baskets : 0 : Basket Size= 8000 bytes Compression= 1.00 *

*Br 7 :m_Bthrust : m_Bthrust/D *
*Entries : 6 : Total Size= 12490 bytes One basket in memory *
*Baskets : 0 : Basket Size= 8000 bytes Compression= 1.00 *

*Br 8 :m_Bsphericity : m_Bsphericity/D *
*Entries : 6 : Total Size= 12514 bytes One basket in memory *
*Baskets : 0 : Basket Size= 8000 bytes Compression= 1.00 *

*Br 9 :m_cosThetaT : m_cosThetaT/D *
*Entries : 6 : Total Size= 12502 bytes One basket in memory *
*Baskets : 0 : Basket Size= 8000 bytes Compression= 1.00 *

*Br 10 :m_cosThetaS : m_cosThetaS/D *
*Entries : 6 : Total Size= 12502 bytes One basket in memory *
*Baskets : 0 : Basket Size= 8000 bytes Compression= 1.00 *

*Br 11 :m_cosBmom : m_cosBmom/D *
*Entries : 6 : Total Size= 12490 bytes One basket in memory *
*Baskets : 0 : Basket Size= 8000 bytes Compression= 1.00 *

*Br 12 :m_cosBthr : m_cosBthr/D *
*Entries : 6 : Total Size= 12490 bytes One basket in memory *
*Baskets : 0 : Basket Size= 8000 bytes Compression= 1.00 *

*Br 13 :m_cosBsph : m_cosBsph/D *
*Entries : 6 : Total Size= 12490 bytes One basket in memory *
*Baskets : 0 : Basket Size= 8000 bytes Compression= 1.00 *

*Br 14 :m_VcalSum : m_VcalSum/D *
*Entries : 6 : Total Size= 12490 bytes One basket in memory *
*Baskets : 0 : Basket Size= 8000 bytes Compression= 1.00 *

*Br 15 :m_fisher : m_fisher/D *
*Entries : 6 : Total Size= 12484 bytes One basket in memory *
*Baskets : 0 : Basket Size= 8000 bytes Compression= 1.00 *

*Br 16 :m_r2Roe : m_r2Roe/D *
*Entries : 6 : Total Size= 12478 bytes One basket in memory *
*Baskets : 0 : Basket Size= 8000 bytes Compression= 1.00 *

*Br 17 :m_thrustRoe : m_thrustRoe/D *
*Entries : 6 : Total Size= 12502 bytes One basket in memory *
*Baskets : 0 : Basket Size= 8000 bytes Compression= 1.00 *

*Br 18 :m_fisher_lg : m_fisher_lg/D *
*Entries : 6 : Total Size= 12502 bytes One basket in memory *
*Baskets : 0 : Basket Size= 8000 bytes Compression= 1.00 *

*Br 19 :m_legendre0 : m_legendre0/D *
*Entries : 6 : Total Size= 12502 bytes One basket in memory *
*Baskets : 0 : Basket Size= 8000 bytes Compression= 1.00 *

*Br 20 :m_legendre1 : m_legendre1/D *
*Entries : 6 : Total Size= 12502 bytes One basket in memory *
*Baskets : 0 : Basket Size= 8000 bytes Compression= 1.00 *

*Br 21 :m_bflavor : m_bflavor/I *
*Entries : 6 : Total Size= 12458 bytes One basket in memory *
*Baskets : 0 : Basket Size= 8000 bytes Compression= 1.00 *

*Br 22 :m_modeD0 : m_modeD0/I *
*Entries : 6 : Total Size= 12452 bytes One basket in memory *
*Baskets : 0 : Basket Size= 8000 bytes Compression= 1.00 *

*Br 23 :m_modeDstar0 : m_modeDstar0/I *
*Entries : 6 : Total Size= 12476 bytes One basket in memory *
*Baskets : 0 : Basket Size= 8000 bytes Compression= 1.00 *

*Br 24 :m_modePartner : m_modePartner/I *
*Entries : 6 : Total Size= 12482 bytes One basket in memory *
*Baskets : 0 : Basket Size= 8000 bytes Compression= 1.00 *

*Br 25 :m_partner : m_partner/b *
*Entries : 6 : Total Size= 12434 bytes One basket in memory *
*Baskets : 0 : Basket Size= 8000 bytes Compression= 1.00 *

*Br 27 :m_mes_fit : m_mes_fit/D *
*Entries : 6 : Total Size= 12490 bytes One basket in memory *
*Baskets : 0 : Basket Size= 8000 bytes Compression= 1.00 *

*Br 28 :m_deltaE_K : m_deltaE_K/D *
*Entries : 6 : Total Size= 12496 bytes One basket in memory *
*Baskets : 0 : Basket Size= 8000 bytes Compression= 1.00 *

*Br 29 :m_deltaE_K_fit : m_deltaE_K_fit/D *
*Entries : 6 : Total Size= 12520 bytes One basket in memory *
*Baskets : 0 : Basket Size= 8000 bytes Compression= 1.00 *

*Br 30 :m_chi2dof : m_chi2dof/D *
*Entries : 6 : Total Size= 12490 bytes One basket in memory *
*Baskets : 0 : Basket Size= 8000 bytes Compression= 1.00 *

*Br 31 :m_Bprob : m_Bprob/D *
*Entries : 6 : Total Size= 12478 bytes One basket in memory *
*Baskets : 0 : Basket Size= 8000 bytes Compression= 1.00 *

*Br 32 :m_candPartner : m_candPartner/b *
*Entries : 6 : Total Size= 12458 bytes One basket in memory *
*Baskets : 0 : Basket Size= 8000 bytes Compression= 1.00 *

*Br 33 :m_candDstar0 : m_candDstar0/b *
*Entries : 6 : Total Size= 12452 bytes One basket in memory *
*Baskets : 0 : Basket Size= 8000 bytes Compression= 1.00 *

*Br 34 :m_candSlowPi0 : m_candSlowPi0/b *
*Entries : 6 : Total Size= 12458 bytes One basket in memory *
*Baskets : 0 : Basket Size= 8000 bytes Compression= 1.00 *

*Br 35 :m_candGamma : m_candGamma/b *
*Entries : 6 : Total Size= 12446 bytes One basket in memory *
*Baskets : 0 : Basket Size= 8000 bytes Compression= 1.00 *

*Br 36 :m_candD0 : m_candD0/b *
*Entries : 6 : Total Size= 12428 bytes One basket in memory *
*Baskets : 0 : Basket Size= 8000 bytes Compression= 1.00 *

*Br 37 :m_candPi : m_candPi/b *
*Entries : 6 : Total Size= 12428 bytes One basket in memory *
*Baskets : 0 : Basket Size= 8000 bytes Compression= 1.00 *

*Br 38 :m_candPi0 : m_candPi0/b *
*Entries : 6 : Total Size= 12434 bytes One basket in memory *
*Baskets : 0 : Basket Size= 8000 bytes Compression= 1.00 *

*Br 39 :m_candK : m_candK/b *
*Entries : 6 : Total Size= 12422 bytes One basket in memory *
*Baskets : 0 : Basket Size= 8000 bytes Compression= 1.00 *

*Br 40 :m_candKs : m_candKs/b *
*Entries : 6 : Total Size= 12428 bytes One basket in memory *
*Baskets : 0 : Basket Size= 8000 bytes Compression= 1.00 *

*Br 41 :m_candRho0 : m_candRho0/b *
*Entries : 6 : Total Size= 12440 bytes One basket in memory *
*Baskets : 0 : Basket Size= 8000 bytes Compression= 1.00 *

*Br 42 :m_candPhi : m_candPhi/b *
*Entries : 6 : Total Size= 12434 bytes One basket in memory *
*Baskets : 0 : Basket Size= 8000 bytes Compression= 1.00 *

*Br 43 :m_candOmega : m_candOmega/b *
*Entries : 6 : Total Size= 12446 bytes One basket in memory *
*Baskets : 0 : Basket Size= 8000 bytes Compression= 1.00 *

*Br 44 :m_candEtap : m_candEtap/b *
*Entries : 6 : Total Size= 12440 bytes One basket in memory *
*Baskets : 0 : Basket Size= 8000 bytes Compression= 1.00 *

*Br 45 :m_candX : m_candX/b *
*Entries : 6 : Total Size= 12422 bytes One basket in memory *
*Baskets : 0 : Basket Size= 8000 bytes Compression= 1.00 *

*Br 46 :m_massDstar0 : m_massDstar0/D *
*Entries : 6 : Total Size= 12508 bytes One basket in memory *
*Baskets : 0 : Basket Size= 8000 bytes Compression= 1.00 *

*Br 47 :m_massDstar0Err : m_massDstar0Err/D *
*Entries : 6 : Total Size= 12526 bytes One basket in memory *
*Baskets : 0 : Basket Size= 8000 bytes Compression= 1.00 *

*Br 48 :m_massDstar0NSig : m_massDstar0NSig/D *
*Entries : 6 : Total Size= 12532 bytes One basket in memory *
*Baskets : 0 : Basket Size= 8000 bytes Compression= 1.00 *

*Br 49 :m_massDstar0Prob : m_massDstar0Prob/D *
*Entries : 6 : Total Size= 12532 bytes One basket in memory *
*Baskets : 0 : Basket Size= 8000 bytes Compression= 1.00 *

*Br 50 :m_helicityDstar0 : m_helicityDstar0/D *
*Entries : 6 : Total Size= 12532 bytes One basket in memory *
*Baskets : 0 : Basket Size= 8000 bytes Compression= 1.00 *

*Br 51 :m_helicit2Dstar0 : m_helicit2Dstar0/D *
*Entries : 6 : Total Size= 12532 bytes One basket in memory *
*Baskets : 0 : Basket Size= 8000 bytes Compression= 1.00 *

*Br 52 :m_deltaM : m_deltaM/D *
*Entries : 6 : Total Size= 12484 bytes One basket in memory *
*Baskets : 0 : Basket Size= 8000 bytes Compression= 1.00 *

*Br 53 :m_deltaMNSig : m_deltaMNSig/D *
*Entries : 6 : Total Size= 12508 bytes One basket in memory *
*Baskets : 0 : Basket Size= 8000 bytes Compression= 1.00 *

*Br 54 :m_gammaEnergyD0 : m_gammaEnergyD0/D *
*Entries : 6 : Total Size= 12526 bytes One basket in memory *
*Baskets : 0 : Basket Size= 8000 bytes Compression= 1.00 *

*Br 55 :m_pi0MomentumD0 : m_pi0MomentumD0/D *
*Entries : 6 : Total Size= 12526 bytes One basket in memory *
*Baskets : 0 : Basket Size= 8000 bytes Compression= 1.00 *

*Br 56 :m_massD0 : m_massD0/D *
*Entries : 6 : Total Size= 12484 bytes One basket in memory *
*Baskets : 0 : Basket Size= 8000 bytes Compression= 1.00 *

*Br 57 :m_massD0Err : m_massD0Err/D *
*Entries : 6 : Total Size= 12502 bytes One basket in memory *
*Baskets : 0 : Basket Size= 8000 bytes Compression= 1.00 *

*Br 58 :m_massD0NSig : m_massD0NSig/D *
*Entries : 6 : Total Size= 12508 bytes One basket in memory *
*Baskets : 0 : Basket Size= 8000 bytes Compression= 1.00 *

*Br 59 :m_massD0Prob : m_massD0Prob/D *
*Entries : 6 : Total Size= 12508 bytes One basket in memory *
*Baskets : 0 : Basket Size= 8000 bytes Compression= 1.00 *

*Br 60 :m_kaonD0 : m_kaonD0/I *
*Entries : 6 : Total Size= 12452 bytes One basket in memory *
*Baskets : 0 : Basket Size= 8000 bytes Compression= 1.00 *

*Br 61 :m_helicityD0 : m_helicityD0/D *
*Entries : 6 : Total Size= 12508 bytes One basket in memory *
*Baskets : 0 : Basket Size= 8000 bytes Compression= 1.00 *

*Br 62 :m_helicit2D0 : m_helicit2D0/D *
*Entries : 6 : Total Size= 12508 bytes One basket in memory *
*Baskets : 0 : Basket Size= 8000 bytes Compression= 1.00 *

*Br 63 :m_helicityDD : m_helicityDD/D *
*Entries : 6 : Total Size= 12508 bytes One basket in memory *
*Baskets : 0 : Basket Size= 8000 bytes Compression= 1.00 *

*Br 64 :m_helicit2DD : m_helicit2DD/D *
*Entries : 6 : Total Size= 12508 bytes One basket in memory *
*Baskets : 0 : Basket Size= 8000 bytes Compression= 1.00 *

*Br 65 :m_LHloose : m_LHloose/b *
*Entries : 6 : Total Size= 12434 bytes One basket in memory *
*Baskets : 0 : Basket Size= 8000 bytes Compression= 1.00 *

*Br 66 :m_lhRatioKvsPi : m_lhRatioKvsPi/D *
*Entries : 6 : Total Size= 12520 bytes One basket in memory *
*Baskets : 0 : Basket Size= 8000 bytes Compression= 1.00 *

*Br 67 :m_thetaC : m_thetaC/D *
*Entries : 6 : Total Size= 12484 bytes One basket in memory *
*Baskets : 0 : Basket Size= 8000 bytes Compression= 1.00 *

*Br 68 :m_thetaCErr : m_thetaCErr/D *
*Entries : 6 : Total Size= 12502 bytes One basket in memory *
*Baskets : 0 : Basket Size= 8000 bytes Compression= 1.00 *

*Br 69 :m_ringNPhot : m_ringNPhot/I *
*Entries : 6 : Total Size= 12470 bytes One basket in memory *
*Baskets : 0 : Basket Size= 8000 bytes Compression= 1.00 *

*Br 70 :m_partnerLundId : m_partnerLundId/I *
*Entries : 6 : Total Size= 12494 bytes One basket in memory *
*Baskets : 0 : Basket Size= 8000 bytes Compression= 1.00 *

*Br 71 :m_massSlowPi0 : m_massSlowPi0/D *
*Entries : 6 : Total Size= 12514 bytes One basket in memory *
*Baskets : 0 : Basket Size= 8000 bytes Compression= 1.00 *

*Br 72 :m_massSlowPi0Err : m_massSlowPi0Err/D *
*Entries : 6 : Total Size= 12532 bytes One basket in memory *
*Baskets : 0 : Basket Size= 8000 bytes Compression= 1.00 *

*Br 73 :m_massSlowPi0NSig : m_massSlowPi0NSig/D *
*Entries : 6 : Total Size= 12538 bytes One basket in memory *
*Baskets : 0 : Basket Size= 8000 bytes Compression= 1.00 *

*Br 74 :m_massSlowPi0Prob : m_massSlowPi0Prob/D *
*Entries : 6 : Total Size= 12538 bytes One basket in memory *
*Baskets : 0 : Basket Size= 8000 bytes Compression= 1.00 *

*Br 75 :m_helicitySlowPi0 : m_helicitySlowPi0/D *
*Entries : 6 : Total Size= 12538 bytes One basket in memory *
*Baskets : 0 : Basket Size= 8000 bytes Compression= 1.00 *

*Br 76 :m_massPi0 : m_massPi0/D *
*Entries : 6 : Total Size= 12490 bytes One basket in memory *
*Baskets : 0 : Basket Size= 8000 bytes Compression= 1.00 *

*Br 77 :m_massPi0Err : m_massPi0Err/D *
*Entries : 6 : Total Size= 12508 bytes One basket in memory *
*Baskets : 0 : Basket Size= 8000 bytes Compression= 1.00 *

*Br 78 :m_massPi0NSig : m_massPi0NSig/D *
*Entries : 6 : Total Size= 12514 bytes One basket in memory *
*Baskets : 0 : Basket Size= 8000 bytes Compression= 1.00 *

*Br 79 :m_massPi0Prob : m_massPi0Prob/D *
*Entries : 6 : Total Size= 12514 bytes One basket in memory *
*Baskets : 0 : Basket Size= 8000 bytes Compression= 1.00 *

*Br 80 :m_helicityPi0 : m_helicityPi0/D *
*Entries : 6 : Total Size= 12514 bytes One basket in memory *
*Baskets : 0 : Basket Size= 8000 bytes Compression= 1.00 *

*Br 81 :m_massKs : m_massKs/D *
*Entries : 6 : Total Size= 12484 bytes One basket in memory *
*Baskets : 0 : Basket Size= 8000 bytes Compression= 1.00 *

*Br 82 :m_massKsErr : m_massKsErr/D *
*Entries : 6 : Total Size= 12502 bytes One basket in memory *
*Baskets : 0 : Basket Size= 8000 bytes Compression= 1.00 *

*Br 83 :m_massKsNSig : m_massKsNSig/D *
*Entries : 6 : Total Size= 12508 bytes One basket in memory *
*Baskets : 0 : Basket Size= 8000 bytes Compression= 1.00 *

*Br 84 :m_massKsProb : m_massKsProb/D *
*Entries : 6 : Total Size= 12508 bytes One basket in memory *
*Baskets : 0 : Basket Size= 8000 bytes Compression= 1.00 *

*Br 85 :m_helicityKs : m_helicityKs/D *
*Entries : 6 : Total Size= 12508 bytes One basket in memory *
*Baskets : 0 : Basket Size= 8000 bytes Compression= 1.00 *

*Br 86 :m_decayLength : m_decayLength/D *
*Entries : 6 : Total Size= 12514 bytes One basket in memory *
*Baskets : 0 : Basket Size= 8000 bytes Compression= 1.00 *

*Br 87 :m_decaySignif : m_decaySignif/D *
*Entries : 6 : Total Size= 12514 bytes One basket in memory *
*Baskets : 0 : Basket Size= 8000 bytes Compression= 1.00 *

*Br 88 :m_cosAngle : m_cosAngle/D *
*Entries : 6 : Total Size= 12496 bytes One basket in memory *
*Baskets : 0 : Basket Size= 8000 bytes Compression= 1.00 *

*Br 89 :m_massRho0 : m_massRho0/D *
*Entries : 6 : Total Size= 12496 bytes One basket in memory *
*Baskets : 0 : Basket Size= 8000 bytes Compression= 1.00 *

*Br 90 :m_massRho0Err : m_massRho0Err/D *
*Entries : 6 : Total Size= 12514 bytes One basket in memory *
*Baskets : 0 : Basket Size= 8000 bytes Compression= 1.00 *

*Br 91 :m_massRho0NSig : m_massRho0NSig/D *
*Entries : 6 : Total Size= 12520 bytes One basket in memory *
*Baskets : 0 : Basket Size= 8000 bytes Compression= 1.00 *

*Br 92 :m_massRho0Prob : m_massRho0Prob/D *
*Entries : 6 : Total Size= 12520 bytes One basket in memory *
*Baskets : 0 : Basket Size= 8000 bytes Compression= 1.00 *

*Br 93 :m_helicityRho0 : m_helicityRho0/D *
*Entries : 6 : Total Size= 12520 bytes One basket in memory *
*Baskets : 0 : Basket Size= 8000 bytes Compression= 1.00 *

*Br 94 :m_massPhi : m_massPhi/D *
*Entries : 6 : Total Size= 12490 bytes One basket in memory *
*Baskets : 0 : Basket Size= 8000 bytes Compression= 1.00 *

*Br 95 :m_massPhiErr : m_massPhiErr/D *
*Entries : 6 : Total Size= 12508 bytes One basket in memory *
*Baskets : 0 : Basket Size= 8000 bytes Compression= 1.00 *

*Br 96 :m_massPhiNSig : m_massPhiNSig/D *
*Entries : 6 : Total Size= 12514 bytes One basket in memory *
*Baskets : 0 : Basket Size= 8000 bytes Compression= 1.00 *

*Br 97 :m_massPhiProb : m_massPhiProb/D *
*Entries : 6 : Total Size= 12514 bytes One basket in memory *
*Baskets : 0 : Basket Size= 8000 bytes Compression= 1.00 *

*Br 98 :m_kaonPhi : m_kaonPhi/I *
*Entries : 6 : Total Size= 12458 bytes One basket in memory *
*Baskets : 0 : Basket Size= 8000 bytes Compression= 1.00 *

*Br 99 :m_helicityPhi : m_helicityPhi/D *
*Entries : 6 : Total Size= 12514 bytes One basket in memory *
*Baskets : 0 : Basket Size= 8000 bytes Compression= 1.00 *

*Br 100 :m_massEtap : m_massEtap/D *
*Entries : 6 : Total Size= 12496 bytes One basket in memory *
*Baskets : 0 : Basket Size= 8000 bytes Compression= 1.00 *

*Br 101 :m_massEtapErr : m_massEtapErr/D *
*Entries : 6 : Total Size= 12514 bytes One basket in memory *
*Baskets : 0 : Basket Size= 8000 bytes Compression= 1.00 *

*Br 102 :m_massEtapNSig : m_massEtapNSig/D *
*Entries : 6 : Total Size= 12520 bytes One basket in memory *
*Baskets : 0 : Basket Size= 8000 bytes Compression= 1.00 *

*Br 103 :m_massEtapProb : m_massEtapProb/D *
*Entries : 6 : Total Size= 12520 bytes One basket in memory *
*Baskets : 0 : Basket Size= 8000 bytes Compression= 1.00 *

*Br 104 :m_helicityEtap : m_helicityEtap/D *
*Entries : 6 : Total Size= 12520 bytes One basket in memory *
*Baskets : 0 : Basket Size= 8000 bytes Compression= 1.00 *

*Br 105 :m_massOmega : m_massOmega/D *
*Entries : 6 : Total Size= 12502 bytes One basket in memory *
*Baskets : 0 : Basket Size= 8000 bytes Compression= 1.00 *

*Br 106 :m_massOmegaErr : m_massOmegaErr/D *
*Entries : 6 : Total Size= 12520 bytes One basket in memory *
*Baskets : 0 : Basket Size= 8000 bytes Compression= 1.00 *

*Br 107 :m_massOmegaNSig : m_massOmegaNSig/D *
*Entries : 6 : Total Size= 12526 bytes One basket in memory *
*Baskets : 0 : Basket Size= 8000 bytes Compression= 1.00 *

*Br 108 :m_massOmegaProb : m_massOmegaProb/D *
*Entries : 6 : Total Size= 12526 bytes One basket in memory *
*Baskets : 0 : Basket Size= 8000 bytes Compression= 1.00 *

*Br 109 :m_helicityOmega : m_helicityOmega/D *
*Entries : 6 : Total Size= 12526 bytes One basket in memory *
*Baskets : 0 : Basket Size= 8000 bytes Compression= 1.00 *

*Br 110 :m_DalitzAngleOmega : m_DalitzAngleOmega/D *
*Entries : 6 : Total Size= 12544 bytes One basket in memory *
*Baskets : 0 : Basket Size= 8000 bytes Compression= 1.00 *

Sorry for bothering you with this.
Emmanuel

And I changed Float_t to Double_t: does not change anything.
Emmanuel

Hi Emmanuel,
what you do looks fine. Can you send me a link to your root file, so I can try to reproduce what you get? The code you posted is still valid (except for the Float_t / Double_t), right?
Axel.

Hi Axel,
I sent you the link. The actual status of the code is:

void treemanu2(){


TFile *f=new TFile ("generic/ccbar/prod3/Dstar0CPK_ccbar-Run4-29.root");
TTree *ntp999 = (TTree*)f->Get("ntp999");
static Double_t m_mes;
 Double_t* p_mes=&m_mes;
TBranch *bm_mes=ntp999->GetBranch("m_mes");
bm_mes->SetAddress(&p_mes);
//bm_mes->Print();

 TH1F *hmes   = new TH1F("hmes","Mes",100,-5.273,5.283);

   Int_t nentries = (Int_t)ntp999->GetEntries();
   for (Int_t i=0;i<nentries;i++) {
     cout << "i=" << i << endl; 
     bm_mes->GetEntry(i);
     //  bm_mes->Print();
      // cout <<"mes=" <<m_mes << endl;
      hmes->Fill(m_mes);
   } 
   ntp999->Print();
}

Hi Emmanuel,
the attached macro works. For the branch type you’re using you indeed have to pass the address of a Double_t. So that was the only problem: you were passing a Float_t* instead of a Double_t*.
Cheers, Axel.
treemanu2.C (519 Bytes)

Thanks a lot for help.
Best wishes,
Emmanuel