Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members  

/Go4EventServer/TGo4MainTree.cxx

Go to the documentation of this file.
00001 //---------------------------------------------------------------
00002 //        Go4 Release Package v2.10-5 (build 21005) 
00003 //                      03-Nov-2005
00004 //---------------------------------------------------------------
00005 //       The GSI Online Offline Object Oriented (Go4) Project
00006 //       Experiment Data Processing at DVEE department, GSI
00007 //---------------------------------------------------------------
00008 //
00009 //Copyright (C) 2000- Gesellschaft f. Schwerionenforschung, GSI
00010 //                    Planckstr. 1, 64291 Darmstadt, Germany
00011 //Contact:            http://go4.gsi.de
00012 //----------------------------------------------------------------
00013 //This software can be used under the license agreements as stated
00014 //in Go4License.txt file which is part of the distribution.
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    // check if tree already exists...
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* /*dummy*/, Int_t /*option*/, Int_t /*bufsize*/)
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          // if we are at the end of the tree, increment TTree fEvents counter
00092          // without affecting the branches:
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 //----------------------------END OF GO4 SOURCE FILE ---------------------

Generated on Tue Nov 8 10:55:53 2005 for Go4-v2.10-5 by doxygen1.2.15