Re: TROOT...

From: Fons Rademakers (Fons.Rademakers@cern.ch)
Date: Thu Aug 06 1998 - 13:26:29 MEST


Hi Simon,

   the TROOT object has to live as long as the main() program (or at
least as long as the last ROOT object). In your case TROOT goes out of
scope at the end of the RootWriter::store_tracks() method while some other
ROOT objects still stay alive like bestand and Boom. Try putting
TROOT as first line in main(), or as global object just before main.

Does the problem persist in that case?

Cheers, Fons.



S.J.M. Peeters wrote:
> 
> Hi ROOTers,
> 
> The code at the bottom of the file produces the following error:
> 
> Error in <TFile::TFile>: file  does not exist
> 
>  *** Break *** bus error
> 
> ( 0)  0xc1821f00   StackTrace__11TUnixSystemFv + 0x28
> [/afs/cern.ch/na49/library/local/ROOT/hpux10aCC/root/lib/libUnix.sl]
> ( 1)  0xc1820938   DispatchSignals__11TUnixSystemF8ESignals + 0xd0
> [/afs/cern.ch/na49/library/local/ROOT/hpux10aCC/root/lib/libUnix.sl]
> ( 2)  0xc181f420   SigHandler__F8ESignals + 0x30
> [/afs/cern.ch/na49/library/local/ROOT/hpux10aCC/root/lib/libUnix.sl]
> ( 3)  0xc1823780   sighandler__Fi + 0x68
> [/afs/cern.ch/na49/library/local/ROOT/hpux10aCC/root/lib/libUnix.sl]
> ( 4)  0xc012f2e0   _sigreturn  [/usr/lib/libc.1]
> ( 5)  0xc1864994   _sigreturn + 0x3e995
> [/afs/cern.ch/na49/library/local/ROOT/hpux10aCC/root/lib/libTree.sl]
> ( 6)  0xc1867ee4   GetBasket__7TBranchFi + 0x134
> [/afs/cern.ch/na49/library/local/ROOT/hpux10aCC/root/lib/libTree.sl]
> ( 7)  0xc18679bc   Fill__7TBranchFv + 0x54
> [/afs/cern.ch/na49/library/local/ROOT/hpux10aCC/root/lib/libTree.sl]
> ( 8)  0xc186b714   Fill__13TBranchObjectFv + 0xb4
> [/afs/cern.ch/na49/library/local/ROOT/hpux10aCC/root/lib/libTree.sl]
> ( 9)  0xc18dae1c   Fill__5TTreeFv + 0x8c
> [/afs/cern.ch/na49/library/local/ROOT/hpux10aCC/root/lib/libTree.sl]
> ...
> 
> I suspected it had something to do with the inheretance from TOBject, so I
> initailised TROOT in the main program where the class is called, but that
> was not succesfull.. it didn't recognize the initialisation.
> 
> This is the program, the error occurs when the program goes through the
> track_list for the first time.
> 
> void RootWriter::store_tracks(const list<Track*> &track_list) {
> 
>    TROOT ROOTiPatRec("iPatRec","Track reconstruction from seeds");
>    TFile *Bestand = new TFile("Tracks.root","RECREATE");
>    TTree *Boom  = new TTree("Boom","Tracks with residuals");
>    AlignmentTrack *FillTrack = 0;
>    Boom->Branch("track","AlignmentTrack",&FillTrack,0,64000);
> 
>    TStopwatch timer;
>    timer.Start();
> 
>    list<Track*>::const_iterator itbTrackList;
>    for ( itbTrackList  = track_list.begin() ;
>          itbTrackList != track_list.end()   ;
>        ++itbTrackList                      ) {
>       Int_t HitCounter = 0;
>       list<AlignmentHit> TempTrack;
>       list<HitOnTrack*> MyList((*itbTrackList)->list_of_hits());
>       vector<Double_t>  MyRes ((*itbTrackList)->residuals());
>       vector<Double_t>::const_iterator itbResidual = MyRes.begin();
>       list<HitOnTrack*>::iterator itbHitList;
>       for ( itbHitList  = MyList.begin() ;
>             itbHitList != MyList.end()   ;
>           ++itbHitList                                       ) {
>          vector<Double_t> TempResidual;
>          HitCounter++;
>          if ( itbResidual != MyRes.end() ) {
>             if ( (*itbHitList)->status() == -21) {
>                TempResidual.push_back(*(itbResidual++));
>                TempResidual.push_back(*(itbResidual++));
>             } else {
>                TempResidual.push_back(*(itbResidual++));
>             } // if HitContainer[index].is_pixel()
>          } else {
>             cout << "Inconstistent datalength of hits and residuals!" <<
> endl;
>          } // if itbResidual
>          AlignmentHit TempHit( (*itbHitList)->status(), TempResidual ,
>                                (*itbHitList)->index () );
>          TempTrack.push_back(TempHit);
>       } // for itbHitList
>       FillTrack = new AlignmentTrack(TempTrack);
>       Boom->Fill();
>       delete FillTrack;
>    } // for itbTrackList
>    Boom->Print();
>    cout << "done" << endl;
> 
>    //  Stop timer and print results
>    timer.Stop();
>    cout << "Real time: " << timer.RealTime() << endl;
>    cout << "CPU  time: " << timer.CpuTime()  << endl;
>    //cout << "File size: " <<  << endl;
>    Bestand->Write();
>    Bestand->Close();
> }
> 
> Thanks in advance,
> 
> Simon Peeters.
> 
>  --
>     NIKHEF, National Institute for Nuclear and High Energy Physics
>     Kruislaan 409, office H-044 Tel:(+31-20-592) 5140
>     P.O. Box 41882, 1009 DB Amsterdam (NL) Fax:(+31-20-592) 5155
>     CERN, building 40, office 2-D06 Tel:(+41-22-76) 71157

-- 
Org:    CERN, European Laboratory for Particle Physics.
Mail:   1211 Geneve 23, Switzerland          Phone: +41 22 7679248
E-Mail: Fons.Rademakers@cern.ch              Fax:   +41 22 7677910



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