Re: Using MakeClass output

From: lijowski@cosray2.wustl.edu
Date: Mon Oct 04 1999 - 17:15:56 MEST


  Rene,
  
  When I added  

  TTH.Loop();

  to the main program the g++ compiler return following error

GNU C++ version 2.8.1 (sparc-sun-solaris2.7) compiled by GNU C version 2.8.1.
read_Tree.cxx: In function `int main(int, char **)':
read_Tree.cxx:45: request for member `Loop' in `TTH()', which is of non-aggregate type `TEST_CLASS ()()'
make: *** [read_Tree] Error 1

  I don't know whether it is important but I have been running 
  root 2.22/10 recompiled with gcc 2.8.1 on Solaris 2.7.

  By the way I overcame this problem using MakeCode output instead.

  Thank you.

   Michal 

> From Rene.Brun@cern.ch Mon Oct 04 14:47:01 1999
> Delivered-To: lijowski@cosray2.wustl.edu
> Date: Mon, 04 Oct 1999 14:45:36 +0000
> From: Rene Brun <Rene.Brun@cern.ch>
> MIME-Version: 1.0
> To: lijowski@cosray2.wustl.edu
> CC: roottalk@hpsalo.cern.ch
> Subject: Re: Using MakeClass output
> Content-Transfer-Encoding: 7bit
> 
> Hi Michal,
> I do not understand your question.
> In your main program, you should simply invoke the Loop function of the
> generated class:
> 
> int main(int argc, char **argv)
> {
>     
>    TROOT test_Tree("TEST", "Tree");
> 
>    TEST_CLASS TTH(); 
>    TTH.Loop();
> 
>    return 0;
> }
> 
> 
> Rene Brun
> 
> 
> lijowski@cosray2.wustl.edu wrote:
> > 
> >   Hello,
> > 
> >   I have question regarding using MakeClass output in compiled programs
> >   related to my unsufficient experience in C++.
> >   Below are two small programs, one which creates a file, a tree, and
> >   uses MakeClass to generate templates for the second program which
> >   attempts to access this tree. I could not find any example to follow.
> > 
> >   Thanks and regards
> > 
> >   Michal Lijowski
> > 
> > // This program writes a Tree into the output file
> > 
> > #include <TROOT.h>
> > #include <Rtypes.h>
> > #include <TFile.h>
> > #include <TTree.h>
> > #include <TBranch.h>
> > 
> > // ----------------------------------------------------------------------
> > 
> > int main(int argc, char **argv)
> > {
> > 
> >    TROOT test_Tree("TEST", "Tree");
> > 
> >    TFile *tfile = new TFile("TEST.root", "RECREATE", "test Tree");
> > 
> > // file is compressed
> >     Int_t comp = 1;  // compress file
> >     tfile -> SetCompressionLevel(comp);
> >     Int_t bufsize = 32000;
> > 
> > // make TOP subdirectory
> >     tfile -> mkdir("TOP");
> > 
> >     gDirectory -> cd("TOP");
> > 
> > // Create a new Tree with branches
> > 
> >    TTree *TT = new TTree("TT", "test data");
> >    TT -> SetAutoSave(100000000); // autosave when 1000 kB is written
> > 
> >    Int_t  EVTNO;
> >    TT -> Branch("EVTNO", &EVTNO, "EVTNO/i", bufsize);
> >    for (Int_t ii = 0; ii < 50000; ii++) {
> >        EVTNO = ii;
> >        TT -> Fill();
> >    }
> >    TT -> MakeClass("TEST_CLASS");
> >    tfile -> Write();
> >    tfile -> Close();
> > 
> >    return 0;
> > }
> > 
> > // -----------------------------------------------------------------------
> > 
> > // This program reads the ROOT Tree
> > 
> > #include <TROOT.h>
> > #include <TTree.h>
> > #include <TEST_CLASS.h>
> > 
> > void TEST_CLASS::Loop()
> > {
> > //   In a Root session, you can do:
> > //      Root > .L TEST_CLASS.C
> > //      Root > TEST_CLASS t
> > //      Root > t.GetEntry(12); // Fill t data members with entry number 12
> > //      Root > t.Show();       // Show values of entry 12
> > //      Root > t.Show(16);     // Read and show values of entry 16
> > //      Root > t.Loop();       // Loop on all entries
> > //
> > 
> > //     This is the loop skeleton
> > //       To read only selected branches, Insert statements like:
> > // METHOD1:
> > //    fTree->SetBranchStatus("*",0);  // disable all branches
> > //    fTree->SetBranchStatus("branchname",1);  // activate branchname
> > // METHOD2: replace line
> > //    fTree->GetEntry(i);  // read all branches
> > //by  b_branchname->GetEntry(i); //read only this branch
> >    if (fTree == 0) return;
> > 
> >    Int_t nentries = Int_t(fTree->GetEntries());
> > 
> >    Int_t nbytes = 0, nb = 0;
> >    for (Int_t i=0; i<nentries;i++) {
> >       nb = fTree->GetEntry(i);   nbytes += nb;
> >    }
> > }
> > 
> > // ----------------------------------------------------------------------
> > 
> > int main(int argc, char **argv)
> > {
> > 
> >    TROOT test_Tree("TEST", "Tree");
> > 
> >    TEST_CLASS TTH();
> > 
> >    return 0;
> > }
> 



This archive was generated by hypermail 2b29 : Tue Jan 04 2000 - 00:43:40 MET