Re: [ROOT] Using ROOT in dynamically loadable library,

From: Tomasz Bold (bold@fatcat.ftj.agh.edu.pl)
Date: Thu Jul 15 2004 - 10:00:17 MEST


Hi,
	I do not think  I  call the things in wrong order.
See below. The sieze of file is 6423. (20000 events sould be in.)

Regards,
	Tomasz


I do this in the following order:

int init_filter ()
{
  //  filterlog = fopen("combitest.txt", "w");
  f = new TFile ("try.root","RECREATE");
  mtree = new TTree ("events","taken from online");
  mtree->Branch("b",0,"cal/I");
  mtree->Branch("c",&cal,"c/I");

  return 0;
}


This for each event:
 mtree->SetBranchAddress ("b", (void*)& _rup->.cal_mean);
  mtree->Fill();

and in finalizing function:
 mtree->AutoSave("SaveSelf");
  f->Write();
  f->Close();




--------------------------------------
Tomasz Bold
mail me:
bold@ftj.agh.edu.pl,
Tomasz.Bold@cern.ch
Tomasz.Bold@desy.de
or call:
+48 12 617 4729 (AGH)
+48 12 662 8023 (IFJ)
-------------------------------------

On Thu, 15 Jul 2004, Rene Brun wrote:

> 	Hi Tomasz,
>
> 	Your problem has nothing to do with the subject of your mail.
> 	It looks like your TTree is not created in the file.
> 	You must create the file and Tree  in the following order
> 	TFile f("myfile.root","recreate");
> 	TTree *T = new TTree("T","blabla");
> see Users Guide.
>
> Rene Brun
>
>
> On
> Wed, 14 Jul 2004, Tomasz Bold wrote:
>
> > Hi,
> > 	I wanted use some ROOT functionalities in dynamicaly loaded libs.
> > I failed.
> >
> > Imagine that I have process which is constantly running processing some
> > events. Just for check I wan to record sample. The sample will contain
> > some info from events but I do not know apriori what?
> >
> > So I create dynamically loaded librabry with the selection code. The so
> > called filter contains the selection code and all necessary things to save
> > what I need.
> > Only three functions are used. init_filter, run_filter, finalize_filetr.
> > I wanted replace some traditional IO in run_filter by TTree::Fill, in
> > init_filter hving TFile opened, in the finalize_filter closing file.
> >
> > When I run it: The created root file is always 302 bytes large.
> > I tried also
> > mtree->AutoSave("SaveSelf");
> >
> > Any idea how to force writing TTree to the file?
> >
> > Regards,
> > 	Tomasz Bold
> >
>
>



This archive was generated by hypermail 2b29 : Sun Jan 02 2005 - 05:50:08 MET