Re: Adding a branch

From: Philippe Canal <pcanal_at_fnal.gov>
Date: Mon, 23 May 2011 10:18:40 -0500


Hi Michelle,

> TBranch *newBranch = tree->Branch("alpha",&alpha,"alpha[nshower]/F");

nshower needs to be initialized before it can be used. You could try:

TTree *tree = (TTree*)f.Get("sim");

    tree->GetEntry(0);
    TBranch *newBranch = tree->Branch("alpha",&alpha,"alpha[nshower]/F");

    Float_t energy,tgalpha,alphar,alpha;     TBranch *newBranch = tree->Branch("alpha",&alpha,"alpha[nshower]/F");

Is nshower really limited to the value 0 and 1? Should you be using an array of float?

> energy = tree->GetBranch("shower.Energy");

Humm GetBranch return a TBranch* ... you probalby meant:

tree->SetBranchAddress("shower.Energy",&energy); for (Long64_t i = 0; i < nentries; i++) {

    tree->GetEntry(i);
    tgalpha = (1*55251.1*(pow(30.0,2)/2)*0.000001)/energy;

Cheers,
Philippe. Received on Mon May 23 2011 - 17:21:27 CEST

This archive was generated by hypermail 2.2.0 : Mon May 23 2011 - 17:50:01 CEST