Hi Mat, You have at least two problems in your code below. I have fixed these two problems. Rene Brun //Declare leaf types: Double_t unFittedPhiMass; //Book histograms.. TH1F *unfittedMassHist = new TH1F("unfittedMassHist","Phi Mass, unfitted",100,0.98,1.06); cout<<"Class name: "<<mainBranch->GetLeaf("Phimass")->ClassName()<<endl; // Get pointers to the leaves we want to read out (only done once per run) TLeafD *FitMassLeaf =(TLeafD)*mainBranch->GetLeaf("Phimass")); //<===== // Int_t nevent = T->GetEntries(); Int_t nevent = 10; for (Int_t i=0;i<nevent;i++) { T.GetEvent(i); //read complete accepted event in memory //Get the data contents of the leaves.. unFittedPhiMass=FitMassLeaf->GetValue(); //Increment the histograms.. unfittedMassHist->Fill(unFittedPhiMass); //<======= } Matthew Martin wrote: > > Hi Guys, > Am having serious problems reading out my leaves from an > ntuple..the following code complains: > > Error: illegal type cast > FILE:/usr/people/msmartin/work/root/rootbin/./vertex_rene.C LINE:21 > > The whole macro is: > > { > gROOT->Reset(); > > TFile f("ufind.root"); > f.Cd("PhiFinder"); > TTree *T = (TTree*)gDirectory->Get("NTuple for new SSTTagger"); > TBranch *mainBranch = T->GetBranch("_1"); > > //Declare leaf types: > Double_t unFittedPhiMass; > > //Book histograms.. > TH1F *unfittedMassHist = new TH1F("unfittedMassHist","Phi Mass, > unfitted",100,0.98,1.06); > > cout<<"Class name: "<<mainBranch->GetLeaf("Phimass")->ClassName()<<endl; > > // Get pointers to the leaves we want to read out (only done once per run) > TLeafD *FitMassLeaf =new > TLeafD((TLeafD)*(mainBranch->GetLeaf("Phimass"))); > > // Int_t nevent = T->GetEntries(); > Int_t nevent = 10; > for (Int_t i=0;i<nevent;i++) { > T.GetEvent(i); //read complete accepted event in > memory > //Get the data contents of the leaves.. > unFittedPhiMass=FitMassLeaf->GetValue(); > //Increment the histograms.. > unfittedMassHist->Fill(*unFittedPhiMass); > } > > //draw hists.. > unfittedMassHist->Draw(); > > } > > If you want the root file, just ask! > > Cheers > > Mat Martin
This archive was generated by hypermail 2b29 : Tue Jan 02 2001 - 11:50:16 MET