00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016 #include "TGo4MainTree.h"
00017
00018 #include "Go4Log/TGo4Log.h"
00019
00020 TGo4MainTree * TGo4MainTree::fxInstance= 0;
00021
00022 const Text_t TGo4MainTree::fgcTREENAME[] = "Main";
00023 const Text_t TGo4MainTree::fgcFILENAME[] = "Go4MainTree.root";
00024
00025 const Int_t TGo4MainTree::fgiCOMPRESS = 5;
00026 const Int_t TGo4MainTree::fgiAUTOSAVESIZE = 10000000;
00027
00028 TGo4MainTree::TGo4MainTree()
00029 : fxFile(0), fxTree(0), fiMaxIndex(0), fiCurrentIndex(0)
00030 {
00031 TRACE((15,"TGo4MainTree::TGo4MainTree()", __LINE__, __FILE__));
00032
00033 fxFile = new TFile(fgcFILENAME, "UPDATE");
00034 fxFile->SetCompressionLevel(fgiCOMPRESS);
00035
00036 fxTree= dynamic_cast<TTree*> (fxFile->Get(fgcTREENAME));
00037 if(fxTree)
00038 {
00039 TGo4Log::Debug(" MainTree has been found in file %s ",fgcFILENAME);
00040 }
00041 else
00042 {
00043 fxTree = new TTree(fgcTREENAME, "The Go4 Tree");
00044 fxTree->SetAutoSave(fgiAUTOSAVESIZE);
00045 TGo4Log::Debug(" MainTree has been created in file %s ",fgcFILENAME);
00046 }
00047 fiMaxIndex= (Int_t ) fxTree->GetEntries();
00048
00049 }
00050
00051 TGo4MainTree::~TGo4MainTree()
00052 {
00053 TRACE((15,"TGo4MainTree::~TGo4MainTree()", __LINE__, __FILE__));
00054 Write();
00055 delete fxFile;
00056
00057 }
00058
00059
00060 TGo4MainTree * TGo4MainTree::Instance()
00061 {
00062 TRACE((12,"TGo4MainTree::Instance()", __LINE__, __FILE__));
00063 if (fxInstance == 0)
00064 {
00065 fxInstance = new TGo4MainTree();
00066 }
00067 else { }
00068 return fxInstance;
00069 }
00070
00071 void TGo4MainTree::SetAutoSave(Int_t bytesinterval)
00072 {
00073 TRACE((15,"TGo4MainTree::SetAutoSave(Int_t)", __LINE__, __FILE__));
00074 Instance();
00075 fxTree->SetAutoSave(bytesinterval);
00076 }
00077
00078 Int_t TGo4MainTree::Write(const char* , Int_t , Int_t )
00079 {
00080 TRACE((12,"TGo4MainTree::Write()", __LINE__, __FILE__));
00081 fxFile->cd();
00082 fxTree->Write(0, TObject::kOverwrite);
00083 return 0;
00084 }
00085
00086 void TGo4MainTree::Update()
00087 {
00088 TRACE((12,"TGo4MainTree::Update()", __LINE__, __FILE__));
00089 if( GetCurrentIndex() >= GetMaxIndex() )
00090 {
00091
00092
00093 fxTree->SetBranchStatus("*",0);
00094 fxTree->Fill();
00095 fxTree->SetBranchStatus("*",1);
00096 }
00097 else
00098 { }
00099 IncCurrentIndex();
00100 }
00101
00102 Int_t TGo4MainTree::GetMaxIndex()
00103 {
00104 fiMaxIndex = (fxTree==0) ? 0 : fxTree->GetEntries();
00105 return fiMaxIndex;
00106 }
00107
00108 ClassImp(TGo4MainTree)
00109
00110
00111
00112
00113