X-Git-Url: http://git.uio.no/git/?a=blobdiff_plain;f=STEER%2FTTreeStream.cxx;h=2287454cc2d547bb73d2acd071c97f16970298bd;hb=987d6d62c11e5fcb6ae8c9a8c475ab4f038f62a8;hp=a09744ecbc8ec87706d275ef458cd5cdf5a01221;hpb=d0742e95f7da73ad6ab50de81473f3d054e11902;p=u%2Fmrichter%2FAliRoot.git diff --git a/STEER/TTreeStream.cxx b/STEER/TTreeStream.cxx index a09744ecbc8..2287454cc2d 100644 --- a/STEER/TTreeStream.cxx +++ b/STEER/TTreeStream.cxx @@ -1,3 +1,20 @@ +/************************************************************************** + * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * + * * + * Author: The ALICE Off-line Project. * + * Contributors are mentioned in the code where appropriate. * + * * + * Permission to use, copy, modify and distribute this software and its * + * documentation strictly for non-commercial purposes is hereby granted * + * without fee, provided that the above copyright notice appears in all * + * copies and that both the copyright notice and this permission notice * + * appear in the supporting documentation. The authors make no claims * + * about the suitability of this software for any purpose. It is * + * provided "as is" without express or implied warranty. * + **************************************************************************/ + +/* $Id$ */ + // // marian.ivanov@cern.ch // @@ -13,13 +30,12 @@ // Run and see TTreeSRedirector::Test() as an example of TTreeSRedirectorer functionality // -/* $Id$ */ - -#include "TFile.h" -#include "TObjArray.h" -#include "TTree.h" -#include "TTreeStream.h" - +#include +#include +#include +#include +#include +#include ClassImp(TTreeDataElement) ClassImp(TTreeStream) @@ -144,6 +160,17 @@ TTreeSRedirector::~TTreeSRedirector() fFile->Close(); delete fFile; } +void TTreeSRedirector::StoreObject(TObject* object){ + // + // + // + TDirectory * backup = gDirectory; + fFile->cd(); + object->Write(); + if (backup) backup->cd(); +} + + TTreeStream & TTreeSRedirector::operator<<(Int_t id) { @@ -162,12 +189,14 @@ TTreeStream & TTreeSRedirector::operator<<(Int_t id) } } if (!clayout){ + TDirectory * backup = gDirectory; fFile->cd(); char chname[100]; sprintf(chname,"Tree%d",id); clayout = new TTreeStream(chname); clayout->fId=id; fDataLayouts->AddAt(clayout,entries); + if (backup) backup->cd(); } return *clayout; } @@ -183,11 +212,13 @@ TTreeStream & TTreeSRedirector::operator<<(const char* name) Int_t entries = fDataLayouts->GetEntriesFast(); if (!clayout){ + TDirectory * backup = gDirectory; fFile->cd(); clayout = new TTreeStream(name); clayout->fId=-1; clayout->SetName(name); fDataLayouts->AddAt(clayout,entries); + if (backup) backup->cd(); } return *clayout; } @@ -198,7 +229,7 @@ TTreeStream & TTreeSRedirector::operator<<(const char* name) void TTreeSRedirector::Close(){ // // - TFile * backup = gFile; + TDirectory * backup = gDirectory; fFile->cd(); if (fDataLayouts){ Int_t entries = fDataLayouts->GetEntriesFast(); @@ -260,6 +291,7 @@ TTreeStream::TTreeStream(const char *treename): fBranches(0), fTree(new TTree(treename, treename)), fCurrentIndex(0), + fId(0), fNextName(), fNextNameCounter(), fStatus(0) @@ -368,8 +400,8 @@ void TTreeStream::BuildTree(){ // // Build the Tree // - if (fTree->GetEntries()>0) return; - fTree = new TTree(GetName(),GetName()); + if (fTree && fTree->GetEntries()>0) return; + if (!fTree) fTree = new TTree(GetName(),GetName()); Int_t entries = fElements->GetEntriesFast(); fBranches = new TObjArray(entries);