Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members

TGo4TreeSource.cxx

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

Generated on Fri Nov 28 12:59:09 2008 for Go4-v3.04-1 by  doxygen 1.4.2