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

/Go4EventServer/TGo4BackStore.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 "TGo4BackStore.h"
00017 
00018 #include <iostream.h>
00019 
00020 #include "Go4Log/TGo4Log.h"
00021 #include "Go4Event/TGo4EventElement.h"
00022 #include "Go4Event/TGo4CompositeEvent.h"
00023 
00024 const Text_t TGo4BackStore::fgcTREESUF[] = "xTree";
00025 const Text_t TGo4BackStore::fgcEVBRANCHNAME[] = "Go4EventBranch.";
00026 
00027 const Int_t TGo4BackStore::fgiMAXAUTOBYTES = 100000000;
00028 
00029 TGo4BackStore::TGo4BackStore(TGo4BackStoreParameter* par)
00030 : TGo4EventStore("dummy"),
00031    fbBranchExists(kFALSE), fxEvent(0),
00032    fiSplit(par->fiSplit), fiBufsize(par->fiBufsize), fiFillCount(0)
00033 
00034 {
00035 TRACE((15,"TGo4BackStore::TGo4BackStore(TGo4BackStoreParameter* par)", __LINE__, __FILE__));
00036 
00037    Text_t buffer[TGo4EventStore::fguTXTLEN];
00038    snprintf(buffer,TGo4EventStore::fguTXTLEN -20,  par->GetName());
00039    SetName(buffer);
00040      // strip any path information from treename (could be identical with filename!)
00041    const char* lastname = par->GetTitle();
00042    const char* oldname = lastname;
00043    lastname=strstr(oldname,"/");
00044    while(lastname!=0)
00045       {
00046          oldname=lastname+1;
00047          lastname=strstr(oldname,"/");
00048       }
00049    snprintf(buffer, TGo4EventStore::fguTXTLEN -10 , oldname);
00050    strcat(buffer,fgcTREESUF);
00051    TDirectory *dirsav = gDirectory;
00052    gROOT->cd();
00053    fxTree = new TTree(buffer, "Go4BackStore");
00054    fxTree->SetAutoSave(TGo4BackStore::fgiMAXAUTOBYTES);
00055    TGo4Log::Debug(" Tree %s has been created in memory ",buffer);
00056    dirsav->cd();
00057 }
00058 
00059 TGo4BackStore::TGo4BackStore()
00060 :TGo4EventStore("Go4 Default Back Store"), fbBranchExists(kFALSE), fxEvent(0),
00061    fiSplit(1), fiBufsize(0), fiFillCount(0)
00062 {
00063    TRACE((15,"TGo4BackStore::TGo4BackStore()", __LINE__, __FILE__));
00064    // public default ctor for streamer
00065    fxTree=0;
00066 
00067 
00068 }
00069 
00070 
00071 TGo4BackStore::~TGo4BackStore()
00072 {
00073    TRACE((15,"TGo4BackStore::~TGo4BackStore()", __LINE__, __FILE__));
00074    delete fxTree;
00075 
00076 }
00077 
00078 
00079 
00080 
00081 Int_t TGo4BackStore::Store(TGo4Parameter* cali)
00082 {
00083    return 0;
00084 }
00085 
00086 Int_t TGo4BackStore::Store(TGo4Condition* conny)
00087 {
00088    return 0;
00089 }
00090 
00091 Int_t TGo4BackStore::Store(TGo4Fitter* fitty)
00092 {
00093    return 0;
00094 }
00095 
00096 Int_t TGo4BackStore::Store(TFolder* foldy)
00097 {
00098    return 0;
00099 }
00100 
00101 
00102 Int_t TGo4BackStore::Store(TGo4EventElement* event)
00103 {
00104    TRACE((12,"TGo4BackStore::Store(TGo4EventElement*)", __LINE__, __FILE__));
00105 
00106    fxEvent=event; // address of next event into event pointer
00107    if(!fbBranchExists)
00108       {
00109          // first call of Store, create new branch
00110          //cout << "**********************Creating new branch!"<< endl;
00111          if(fxEvent)
00112             {
00113                Text_t topbranchname [TGo4EventStore::fguTXTLEN];
00114                snprintf(topbranchname,TGo4EventStore::fguTXTLEN -20,"%s.", fxEvent->GetName());
00115                TBranch*   go4branch= fxTree->GetBranch(topbranchname);
00116                if(go4branch)
00117                   {
00118                      // tree already had branch of our name, check it
00119                      TGo4Log::Debug(" BackStore: Found existing branch %s , continue filling ",topbranchname );
00120                      // here we might check the classname of the stored events inbranch
00121                      go4branch->SetAddress(&fxEvent);
00122                      fbBranchExists=kTRUE;
00123 
00124                   }
00125                else
00126                   {
00127                      // no such branch existing, create a new one
00128                      TBranch *topbranch=
00129                      fxTree->Branch(topbranchname, fxEvent->ClassName(), &fxEvent, fiBufsize, fiSplit);
00130                      TGo4Log::Debug(" BackStore: Created new branch %s ", topbranchname);
00131                      fbBranchExists=kTRUE;
00132                      if (fxEvent->InheritsFrom("TGo4CompositeEvent"))
00133                       dynamic_cast<TGo4CompositeEvent*>  (fxEvent)->makeBranch(topbranch);
00134                   } // if(go4branch)
00135             }
00136          else
00137             {
00138                // this is an error....
00139                return 1;
00140             }
00141       } // if(!fbEventBranchExists)
00142    else
00143       {
00144            // need not to create a branch, use existing one
00145       }
00146    // check if autosave threshold is reached, reset tree before autosave is performed:
00147    Double_t totbytes=fxTree->GetTotBytes();
00148    if(totbytes>TGo4BackStore::fgiMAXAUTOBYTES)
00149       {
00150           fxTree->Reset();
00151           TGo4Log::Debug(" BackStore: Tree %s was Reset after %f bytes ",
00152              fxTree->GetName(), totbytes);
00153       }
00154    fxTree->Fill();
00155    return 0;
00156 }
00157 
00158 ClassImp(TGo4BackStore)
00159 
00160 
00161 
00162 
00163 
00164 //----------------------------END OF GO4 SOURCE FILE ---------------------

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