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

/Go4Event/TGo4ClonesElement.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 "TGo4ClonesElement.h"
00017 
00018 #include "TClass.h"
00019 
00020 ClassImp(TGo4ClonesElement)
00021 
00022 
00023 TGo4ClonesElement::TGo4ClonesElement()
00024 {
00025   fData=0;
00026   fNDataObjs=0;
00027 }
00028 
00029 
00030 
00031 
00032 TGo4ClonesElement::TGo4ClonesElement(const char* className, 
00033                                      Int_t size, 
00034                                      const char* aName,
00035                                      const char* aTitle, 
00036                                      Short_t aBaseCat) : 
00037     TGo4EventElement(aName, aTitle, aBaseCat)
00038 {
00039   if(!aName) SetName(className);
00040         else SetName(aName);
00041   if(!aTitle) SetTitle(className);
00042          else SetName(aTitle);
00043   fClassName = className;
00044   fData=new TClonesArray(className,size);
00045   fNDataObjs=0;
00046 }
00047 
00048 TGo4ClonesElement::~TGo4ClonesElement(void) 
00049 {
00050   //if(fDebug)  printf("-I ~TGo4ClonesElement clones at:%x \n", fData );
00051   if (fData) delete fData;
00052   fNDataObjs=0;
00053 }
00054 
00055 
00056 Int_t TGo4ClonesElement::activateBranch(TBranch *branch,Int_t splitLevel, Int_t init)
00057 {
00058   TTree* tree =branch->GetTree();
00059   TString cad,classname;
00060 
00061   if(fDebug)
00062      printf("-I TGo4ClonesElement::activateBranch(Tbranch)  \n");
00063 
00064   cad = branch->GetName();
00065   classname=cad.Data();
00066   classname.Remove(classname.Length()-1);
00067 
00068   if( fDebug ) printf(" -I TGo4ClonesElement::activateBranch(Tbranch)  truncated classname:%s  branchname:%s \n", classname.Data(),
00069                          cad.Data());
00070 
00071   TGo4ClonesElement *dump = this;
00072   tree->SetBranchAddress(cad.Data(), &dump );
00073   tree->SetBranchStatus(cad.Data(),1);
00074   cad+="*";
00075   tree->SetBranchStatus(cad.Data(),1);
00076   classname+=".fData";
00077 
00078   TGo4EventElement::activateBranch( branch, splitLevel);
00079 
00080   if(!fData)
00081      fData=new TClonesArray(fClassName.Data(),1000);
00082    tree->SetBranchAddress(classname.Data(), &fData);
00083 
00084   return 0;
00085 }
00086 
00087 
00088 void TGo4ClonesElement::makeBranch(TBranch *parent)
00089 {
00090   TGo4EventElement::makeBranch( parent );
00091 }
00092 
00093 
00094 TObject *TGo4ClonesElement::getObject(Int_t index) 
00095 {
00096   return (TObject *)fData->UncheckedAt(index);     // no bound check
00097 }
00098 
00099 void TGo4ClonesElement::Clear(Option_t *) 
00100 {
00101   if( fData) fData->Clear();
00102   fNDataObjs=0;
00103 }
00104 
00105 TObject *&TGo4ClonesElement::getSlot() 
00106 {
00107   return fData->operator[](fNDataObjs++);  // return next sequential slot
00108 }
00109 
00110 
00111 void TGo4ClonesElement::Streamer(TBuffer &R__b)
00112 {
00113    // Stream an object of class TGo4DatStore
00114   // FIXME for split level 0 support
00115   Char_t clase[200];
00116    if (R__b.IsReading()) {
00117       Version_t R__v = R__b.ReadVersion(); if (R__v) { }
00118       TGo4EventElement::Streamer(R__b);
00119       R__b.ReadString(clase,200);
00120       if ( fData && strcmp(clase,fData->GetClass()->GetName())==0)
00121        fData->Clear();
00122       else {
00123        delete fData;
00124        fData=new TClonesArray(clase);
00125       }
00126       fData->Streamer(R__b);
00127    } else {
00128 
00129       R__b.WriteVersion(TGo4ClonesElement::IsA());
00130       TGo4EventElement::Streamer(R__b);
00131       strncpy(clase,fData->GetClass()->GetName(),199);
00132       R__b.WriteString(clase);
00133       // printf("-I- TGo4ClonesElement clase:%s \n", clase);
00134       fData->Streamer(R__b);
00135    }
00136 }
00137 
00138 //----------------------------END OF GO4 SOURCE FILE ---------------------

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