Re: Pb with Trees

Rene Brun (Rene.Brun@cern.ch)
Mon, 20 Oct 1997 15:58:36 +0200


Hi Laurent,
You provide only a subset of your program.
Do you have somewhere a statement
Event *gEvent = 0;
before the creation of the branch ?

If yes, where is your program crashing? first event?
in which call ?
Could you add the statement
tree->Print immediatly after tree_Branch ?

Please reply directly to me, not to the list.

Rene Brun

Laurent Aphecetche wrote:

> I'm trying to write objects (my objects) to a Root file, in 2 ways :
>
> 1. Serialization ;
> 2. Using a Tree (one branch) ;
>
> My program looks like :
>
> ...
> TROOT ROSEBUD("Rosebud","Rosebud : the TAPS analysis software
> package");
> TFile file("rosebud.root","RECREATE","Rosebud") ;
> TTree* tree = new TTree("EM","EM particles") ;
> TBranch* b = tree->Branch("event","Event",&gEvent,64000,0) ;
> char keyname[200] ;
>
> HLIMIT(PAWC_SIZE) ; // Init PAW
>
> SetGlobals() ;
>
> // Get the input ntuple
> FIn = new File(1,argv[1]," ",0,"INPUT","ROSEIN",1024) ;
> FIn->Open() ;
> FIn->PutId(1000) ;
> GetInputNtuple(*FIn,gInputNtuple,"Experiment") ;
> cout << (*FIn) << endl ;
>
> for ( i = 1 ; i <= atoi(argv[2]) ; i++ )
> {
> gEvent = new RBEvent ;
>
> FillEvent(i,*FIn) ;
> 
> // 1. sprintf(keyname,"Event%d",i) ;
> // 1. gEvent->Write(keyname) ;
>
> // 2. tree->Fill() ;
>
> delete gEvent ;
> }
>
> file.Close() ;
>
> The first method works fine.
> The second one gives me a Segmentation fault in TTree::GetCurrentFile.
>
> Any clue ?
>
> Thanks.
>
> --
> APHECETCHE Laurent (mailto:aphecetche@ganil.fr)
> GANIL, B.P. 5027, 14076, Caen Cedex 5, France
> Vox: +33 (0)2 31 45 45 85 - Fax: +33 (0)2 31 45 46 65
> WWW: http://ganp03.in2p3.fr/nof/ & (perso.)
> http://www.mygale.org/~p0mp0n