Hayk,
In case of a chain, you cannot do
TBranch *b_Q2 =TTT->GetBranch("Q2");
The pointer to the branch will change whenever a new file is loaded. Use the following code instead:
  {
    gROOT->Reset();
    TChain *ch = new TChain("TTT");
    ch->Add("file1.root");
    ch->Add("file2.root");
    Float_t Q2;
    ch->SetBranchAddress("Q2",&Q2);
    Long64_t localEntry = ch->LoadTree(5);
    ch->GetTree()->GetBranch("Q2")->GetEntry(localEntry);
    cout<<Q2<<endl;
    return 0;
  }
Rene Brun
On 
Mon, 9 Jan 2006, Hayk Hakobyan 
wrote:
>
> Dear ROOTers,
>
> Here is attached the following program
>
> ________________________________________
> {
>   gROOT->Reset();
>   TChain *ch = new TChain("TTT");
>   ch->Add("file1.root");
>   ch->Add("file2.root");
>   Float_t Q2;
>
>   TBranch *b_Q2 =TTT->GetBranch("Q2");
>
>   b_Q2->SetAddress(&Q2);
>
>   Long64_t localEntry = ch->LoadTree(5);
>   b_Q2->GetEntry(localEntry);
>   cout<<Q2<<endl;
>   return 0;
> }
> _______________________________________
>
> file1.root and file2.root are C-structure
> .root files with TTT tree which in has
> Q2 branch.
>
> When I run this program I get
>
> *** Break *** segmentation violation
> Generating stack trace...
>
> But it is working perfectly if I enter each
> line from program by hand using CINT.
>
> What is the problem?
>
> Thanks for any help,
> Hayk.
>
>
Received on Mon Jan 09 2006 - 18:05:25 MET
This archive was generated by hypermail 2.2.0 : Mon Jan 01 2007 - 16:31:56 MET