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

/Go4EventServer/TGo4TreeSource.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 "TGo4TreeSource.h"
00017 
00018 #include <iostream.h>
00019 
00020 #include "TTree.h"
00021 
00022 #include "Go4Log/TGo4Log.h"
00023 #include "Go4EventServer/TGo4MainTree.h"
00024 #include "Go4EventServer/TGo4TreeSourceParameter.h"
00025 
00026 TGo4TreeSource::TGo4TreeSource(const char* name)
00027 : TGo4EventSource(name), fxTree(0), fxBranch(0)
00028 {
00029    TRACE((15,"TGo4TreeSource::TGo4TreeSource(const char*)",__LINE__, __FILE__));
00030    Open();
00031 }
00032 
00033 TGo4TreeSource::TGo4TreeSource(TGo4TreeSourceParameter* par)
00034 : TGo4EventSource(par->GetName()), fxTree(0), fxBranch(0)
00035 {
00036    TRACE((15,"TGo4TreeSource::TGo4TreeSource(TGo4TreeSourceParameter*)",__LINE__, __FILE__));
00037    Open();
00038 }
00039 
00040 
00041 TGo4TreeSource::TGo4TreeSource()
00042 : TGo4EventSource("Go4TreeSource"), fxTree(0), fxBranch(0)
00043 {
00044    TRACE((15,"TGo4TreeSource::TGo4TreeSource()",__LINE__, __FILE__));
00045 }
00046 
00047 TGo4TreeSource::~TGo4TreeSource()
00048 {
00049    TRACE((15,"TGo4TreeSource::~TGo4TreeSource()",__LINE__, __FILE__));
00050    // we have to readout rest of branch into memory before whole tree is written again
00051    Int_t current=fxSingletonTree->GetCurrentIndex();
00052    Int_t max=fxSingletonTree->GetMaxIndex();
00053    Int_t z=0;
00054    for(Int_t ix=current; ix< max; ++ix)
00055       {
00056          z++;
00057          if( fxBranch->GetEntry(ix) == 0)
00058             {
00059                cout << "reached end of branch after "<< z << " dummy event retrieves"<<endl;
00060                break;
00061             }
00062          else { }
00063 
00064       }
00065    cout << "treesource "<< GetName() << " is destroyed after "<< z <<"dummy retrieves."<< endl;
00066 }
00067 
00068 Int_t TGo4TreeSource::Open()
00069 {
00070  TRACE((15,"TGo4TreeSource::Open()",__LINE__, __FILE__));
00071 
00072 Text_t buffer [TGo4EventSource::fguTXTLEN];
00073 snprintf(buffer,TGo4EventSource::fguTXTLEN -5, GetName());
00074 strcat(buffer,"."); // for branches containing the same event structure
00075 
00076 fxSingletonTree=TGo4MainTree::Instance();
00077 fxTree= fxSingletonTree->GetTree();
00078 fxBranch= fxTree->GetBranch(buffer);
00079 if(fxBranch)
00080    {
00081       TGo4Log::Debug(" TreeSource: Found existing branch %s ", buffer);
00082    }
00083 else
00084    {
00085       ThrowError(77,0,"!!! ERROR: Branch %s  not found!!!",buffer);
00086       //TGo4Log::Debug(" !!! TreeSource: ERROR - no branch %s ", buffer);
00087    }
00088 
00089 return 0;
00090 }
00091 
00092 
00093 
00094 Bool_t TGo4TreeSource::BuildEvent(TGo4EventElement* dest)
00095 {
00096    TRACE((12,"TGo4TreeSource::BuildEvent(TGo4EventElement*)",__LINE__, __FILE__));
00097    //
00098    Bool_t rev=kTRUE;
00099    if(dest==0) ThrowError(0,22,"!!! ERROR BuildEvent: no destination event!!!");
00100    if(fxBranch==0) ThrowError(0,23,"!!! ERROR BuildEvent: branch was not initialized !!!");
00101    fxBranch->SetAddress(&dest);
00102    Int_t current=fxSingletonTree->GetCurrentIndex();
00103    if( fxBranch->GetEntry(current) == 0)
00104       {
00105          ThrowError(0,24,"!!! ERROR BuildEvent: getting branch entry failed !!!");
00106       }
00107    else
00108       {
00109 
00110          rev=kTRUE;
00111       } // if( fxBranch->GetEntry(current) == 0)
00112    return rev;
00113 }
00114 
00115 ClassImp(TGo4TreeSource)
00116 
00117 //----------------------------END OF GO4 SOURCE FILE ---------------------

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