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

TGo4EventElement.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 "TGo4EventElement.h"
00017 
00018 #include "Riostream.h"
00019 #include "TTree.h"
00020 
00021 #include "TGo4Log.h"
00022 
00023 #include "TGo4EventSource.h"
00024 
00025 R__EXTERN TTree *gTree;
00026 
00027 TGo4EventElement::TGo4EventElement()
00028 : TNamed("Go4Element","This is a Go4 EventElement"),
00029    fbIsValid(kTRUE), fxParent(0), fxEventSource(0)
00030 {
00031 
00032    TRACE((15,"TGo4EventElement::TGo4EventElement()",__LINE__, __FILE__));
00033    fIdentifier=-1;
00034    isActivated=kFALSE;
00035    fDebug=kFALSE;
00036 }
00037 
00038 TGo4EventElement::TGo4EventElement(const char* name)
00039 : TNamed(name,"This is a Go4 EventElement"),
00040    fbIsValid(kTRUE), fxParent(0), fxEventSource(0)
00041 {
00042 TRACE((15,"TGo4EventElement::TGo4EventElement(const char*)",__LINE__, __FILE__));
00043  fIdentifier=-1;
00044  isActivated=kFALSE;
00045  fDebug=kFALSE;
00046 }
00047 
00048 TGo4EventElement::TGo4EventElement(const char* aName,
00049                                    const char* aTitle,
00050                                    Short_t aBaseCat)
00051 {
00052 
00053 //Allocates a new event Element with name aName and title aTitle
00054 // aBaseCat could be the identifier of the Element for fast
00055 // retrieval of objects in the composite structure
00056   SetName(aName);
00057   SetTitle(aTitle);
00058   fIdentifier=aBaseCat;
00059   isActivated=kFALSE;
00060   fDebug=kFALSE;
00061 
00062 }
00063 
00064 TGo4EventElement::~TGo4EventElement()
00065 {
00066 
00067 TRACE((15,"TGo4EventElement::~TGo4EventElement()",__LINE__, __FILE__));
00068 }
00069 
00070 Bool_t TGo4EventElement::CheckEventSource(const char* classname)
00071 {
00072    TRACE((12,"TGo4EventElement::CheckEventSource(Text_t*)",__LINE__, __FILE__));
00073    if(fxEventSource==0)
00074       {
00075          return kFALSE;
00076       }
00077    else
00078       {
00079         return ( fxEventSource->InheritsFrom(classname) );
00080       }
00081 }
00082 
00083 void TGo4EventElement::PrintEvent()
00084 {
00085    TRACE((12,"TGo4EventElement::PrintEvent()",__LINE__, __FILE__));
00086 
00087    TGo4Log::Debug( " EventElement printout: ");
00088    TGo4Log::Debug( "\tIsValid=%d ",fbIsValid);
00089    if(fxEventSource)
00090       {
00091          TGo4Log::Debug( "\tEventSource: %s of class %s",
00092                         fxEventSource->GetName(),
00093                         fxEventSource->ClassName() );
00094       }
00095    else
00096       {
00097          TGo4Log::Debug( "\tNO EventSource");
00098       }
00099 }
00100 
00101 void TGo4EventElement::Print(Option_t* option) const
00102 {
00103    ((TGo4EventElement*)this) -> PrintEvent();
00104 }
00105 
00106 void TGo4EventElement::makeBranch(TBranch *parent)
00107 {
00108   // method for recursive branching algorithm
00109 
00110 }
00111 
00112 Int_t  TGo4EventElement::activateBranch(TBranch *branch,Int_t splitLevel,Int_t init){
00113 
00114   TString cad=branch->GetName();
00115   if(!isActivated){
00116       TTree* tree = branch->GetTree();
00117       TGo4EventElement *dump = this;
00118       tree->SetBranchAddress(cad.Data(), &dump );
00119 
00120       tree->SetBranchStatus(cad.Data(), 1);
00121       cad+="*";
00122       tree->SetBranchStatus(cad.Data(), 1);
00123       isActivated=kTRUE;
00124   }
00125 
00126   branch->GetEntry(0);
00127   return 0;
00128 }
00129 
00130 void TGo4EventElement::deactivate()
00131 {
00132   TString name=GetName();
00133   name+=".";
00134   gTree->SetBranchStatus(name.Data(), 0);
00135   name+="*";
00136   gTree->SetBranchStatus(name.Data(), 0);
00137   cout << "-I- Deactivating elements at location :" << name << endl;
00138 }
00139 
00140 void TGo4EventElement::activate(){
00141 
00142 TString name=GetName();
00143   name+=".";
00144   gTree->SetBranchStatus(name.Data(), 1);
00145   name+="*";
00146   gTree->SetBranchStatus(name.Data(), 1);
00147   cout << "-I- Activating elements at location :" << name << endl;;
00148 }
00149 
00150 void TGo4EventElement::Clear(Option_t *)
00151 {
00152 }
00153 
00154 Int_t TGo4EventElement::Init()
00155 {
00156    Int_t res=0;
00157    Clear();
00158    SetValid(kTRUE);
00159    cout << "**** Event " << GetName();
00160    if (fxEventSource)
00161       cout << " has source " << fxEventSource->GetName() << " class: " << fxEventSource->ClassName() << endl;
00162    else {
00163       cout << " has no data source" << endl;
00164       res = 1;
00165    }
00166    return res;
00167 }
00168 
00169 Int_t TGo4EventElement::Fill()
00170 {
00171    Int_t res=0;
00172    Clear();
00173 
00174    if (fxEventSource) {
00175       if (!fxEventSource->BuildEvent(this)) res = 1;
00176    } else
00177       res = 1;
00178 
00179    return res;
00180 }
00181 
00182 
00183 //----------------------------END OF GO4 SOURCE FILE ---------------------

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