Hi Alex, What you do is not legal. You should not use local variables for the branch addresses if you use the Tree outside the scope of the function. Declare your variables upper,lower,UID,psimass as static variables. Rene Brun On Mon, 15 Sep 2003, Alex Olivas wrote: > i'm trying to copy entries from one tree to another. > i eventually want to make cuts, but for testing i just copy > all of the entries. my code looks like... > > TTree* uniqueTree(TChain* treeName,char* particleType); > > TTree* uniqueTree(TChain* oldTree,char* particleType){ > const int nentries = (const int)oldTree->GetEntries(); > > int upper; > int lower; > double UID; > double psimass; > if(!strcmp(particleType,"Psi2s")){ > oldTree->SetBranchAddress("upper",&upper); > oldTree->SetBranchAddress("lower",&lower); > oldTree->SetBranchAddress("psiUID",&UID); > oldTree->SetBranchAddress("psimass",&psimass); > } > > oldTree->SetBranchStatus("*",0); > oldTree->SetBranchStatus("upper",1); > oldTree->SetBranchStatus("lower",1); > oldTree->SetBranchStatus("psiUID",1); > oldTree->SetBranchStatus("psimass",1); > > TTree *newtree = oldTree->CloneTree(0); > > for (Int_t i=0;i<nentries; i++) { > oldTree->GetEntry(i); > newtree->Fill(); > } > newtree->Print(); > newtree->AutoSave(); > newtree->Show(0); > oldTree->Delete(); > return newtree; > } > > i do a "Show" of the zeroth entry of the returned tree and get different > results. > > ***Before TTree* is returned > ======> EVENT:0 > upper = 1227159 > lower = -1940522577 > psimass = 3.4278 > psiUID = 10939 > > ***After TTree* is returned > ======> EVENT:0 > upper = 142061856 > lower = 1 > psimass = 3.4278 > psiUID = 0 > > any help would be greatly appreciated. > thanks, > alex. > > > >
This archive was generated by hypermail 2b29 : Thu Jan 01 2004 - 17:50:15 MET