Dear ROOTers I'd better to describe my problem in some more detail. A file "htree.root" are produced by the attached files in which there're one TTree object "T" and two Branchs varible "point" and "eventn". A 2nd file "htree2.root" are produced by the same file but the Branch variable name has been changed to "circle" and "neve", that means two new branches has been produced in the 2nd file. I combine the two files in a chain(Just for understanding the TChain) by typing: ** TChain chain("T"); ** chain.Add("htree.root"); ** chain.Add("htree2.root"); ** chain.Draw("point"); ** chain.Draw("circle"); It'll draw distribution of "point" sucessfully but show the following message for "circle": ** *ERROR 26 : ** Unknown name : "circle" But if change the sequence of adding the two files, i.e. ** TChain chain("T"); ** chain.Add("htree2.root"); ** chain.Add("htree.root"); ** chain.Draw("point"); ** chain.Draw("circle"); It'll draw distribution of "circle" sucessfully but show the following message for "point" this time: ** *ERROR 26 : ** Unknown name : "point" Since Chain is intended for concatenating several pieces of the same tree residing in several files, I assume it should be able to deal with Branch "point" and "circle" together since they're in the same tree. Could you tell me where's the mistake of my operation ? Sincerely yours Xie W__W W__W / \ PHONE : 972 8 9343372 (o) 9471872 (h) / \ ( 0 _ 0) (0 _ 0 ) \_ V_/ E-mail: xiewei@ceres.weizmann.ac.il \_^ _/ / \ / \ =OOOo=======oOOO====================================OOOo=======oOOO====== #include <stdio.h> #include "TROOT.h" #include "TFile.h" #include "TH1.h" #include "TH2.h" #include "TProfile.h" #include "TRandom.h" #include "TTree.h" TROOT simple("simple","Histograms and trees"); //______________________________________________________________________________ main(int argc, char **argv) { // Create a new ROOT binary machine independent file. // Note that this file may contain any kind of ROOT objects, histograms,trees // pictures, graphics objects, detector geometries, tracks, events, etc.. // This file is now becoming the current directory. TFile hfile("htree.root","RECREATE","Demo ROOT file with histograms & trees"); // Create some histograms and a profile histogram TH1F *hpx = new TH1F("hpx","This is the px distribution",100,-4,4); TH2F *hpxpy = new TH2F("hpxpy","py ps px",40,-4,4,40,-4,4); TProfile *hprof = new TProfile("hprof","Profile of pz versus px",100,-4,4,0,20); // Define some simple structures typedef struct {Float_t x,y,z;} POINT; typedef struct { Int_t ntrack,nseg,nvertex; UInt_t flag; Float_t temperature; } EVENTN; static POINT point; static EVENTN eventn; // Create a ROOT Tree TTree *tree = new TTree("T","An example of ROOT tree with a few branches"); tree->Branch("point",&point,"x:y:z"); tree->Branch("eventn",&eventn,"ntrack/I:nseg:nvertex:flag/i:temperature/F"); tree->Branch("hpx","TH1F",&hpx,128000,0); Float_t px,py,pz; static Float_t p[3]; //--------------------Here we start a loop on 1000 events for ( Int_t i=0; i<1000; i++) { gRandom->Rannor(px,py); pz = px*px + py*py; Float_t random = gRandom->Rndm(1); // Fill histograms hpx->Fill(px); hpxpy->Fill(px,py,1); hprof->Fill(px,pz,1); // Fill structures p[0] = px; p[1] = py; p[2] = pz; point.x = 10*(random-1);; point.y = 5*random; point.z = 20*random; eventn.ntrack = Int_t(100*random); eventn.nseg = Int_t(2*eventn.ntrack); eventn.nvertex = 1; eventn.flag = Int_t(random+0.5); eventn.temperature = 20+random; // Fill the tree. For each event, save the 2 structures and 3 objects // In this simple example, the objects hpx, hprof and hpxpy are slightly // different from event to event. We expect a big compression factor! tree->Fill(); } //--------------End of the loop tree->Print(); //Save all objects in this file hfile.Write(); // Close the file. Note that this is automatically done when you leave // the application. hfile.Close(); return 0; }
This archive was generated by hypermail 2b29 : Tue Jan 04 2000 - 00:34:32 MET