+/**************************************************************************
+ * 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
//
// 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 <TClass.h>
+#include <TFile.h>
+#include <TDirectory.h>
+#include <TObjArray.h>
+#include <TTree.h>
+#include <TTreeStream.h>
ClassImp(TTreeDataElement)
ClassImp(TTreeStream)
//
//
//
- TFile * backup = gFile;
+ TDirectory * backup = gDirectory;
fFile->cd();
object->Write();
if (backup) backup->cd();
}
}
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;
}
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;
}
void TTreeSRedirector::Close(){
//
//
- TFile * backup = gFile;
+ TDirectory * backup = gDirectory;
fFile->cd();
if (fDataLayouts){
Int_t entries = fDataLayouts->GetEntriesFast();
fBranches(0),
fTree(new TTree(treename, treename)),
fCurrentIndex(0),
+ fId(0),
fNextName(),
fNextNameCounter(),
fStatus(0)
//
// Insert object of given type
//
- if (!fElements) fElements = new TObjArray(1000);
+ if (!fElements) fElements = new TObjArray(10000);
+ if (fElements->GetSize()<=fCurrentIndex) fElements->Expand(fCurrentIndex*2);
TTreeDataElement* element = (TTreeDataElement*)fElements->At(fCurrentIndex);
if (!element) {
element = new TTreeDataElement(type);
//
// 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);
}
-TTreeStream &TTreeStream::operator<<(Char_t *name)
+TTreeStream &TTreeStream::operator<<(const Char_t *name)
{
//
// Endl