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

/Go4ExampleUserSource/TYYYRawEvent.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 "TYYYRawEvent.h"
00017 
00018 #include <iostream.h>
00019 
00020 #include "TYYYEventSource.h"
00021 #include "Go4EventServer/TGo4TreeSource.h"
00022 #include "Go4EventServer/TGo4FileSource.h"
00023 
00024 TYYYRawEvent::TYYYRawEvent()
00025 :TGo4EventElement("YYYRawEvent"), fxUserSource(0), fxTreeSource(0), fxFileSource(0)
00026 {
00027    fiColumns=0;
00028    fdData=0; // default ctor is for streamer only, avoid heap objects here!
00029 
00030 }
00031 
00032 TYYYRawEvent::TYYYRawEvent(const Text_t* name)
00033 :TGo4EventElement(name), fxUserSource(0), fxTreeSource(0), fxFileSource(0)
00034 {
00035    fiColumns=10;
00036    fdData=new Double_t[fiColumns];
00037 
00038 }
00039 
00040 TYYYRawEvent::~TYYYRawEvent()
00041 {
00042 
00043 delete [] fdData;
00044 
00045 }
00046 
00047 Int_t TYYYRawEvent::Fill()
00048 {
00049 Int_t rev=0;
00050    if(fxUserSource)
00051       {
00052          Clear();
00053          // fill from our source
00054          rev=fxUserSource->NextEvent();
00055          if(rev!=0)
00056             {
00057                cout<<"YYY Raw Event --  !!! NextEvent() error:";
00058                cout<<fxUserSource->GetErrMess()<<endl;
00059                return rev;
00060             }
00061          else
00062             {
00063                fxUserSource->BuildYYYEvent(this);
00064                return rev;
00065             }
00066       }
00067 
00068    else if(fxTreeSource)
00069       {
00070          Clear();
00071          if(fxTreeSource->BuildEvent(this))
00072             {
00073                return 0;
00074             }
00075          else
00076             {
00077                // error, may be end of tree..
00078                return 1;
00079             }
00080 
00081       }
00082 else if(fxFileSource)
00083       {
00084          Clear();
00085          if(fxFileSource->BuildEvent(this))
00086             {
00087                return 0;
00088             }
00089          else
00090             {
00091                // error, may be end of tree..
00092                return 1;
00093             }
00094 
00095       }
00096 
00097    else
00098       {
00099 
00100          TGo4Log::Debug(" !!! YYYEvent: Fill ERROR:  unknown event source !!! ");
00101          return 1;
00102       }
00103 
00104    return 0;
00105 }
00106 
00107 Int_t TYYYRawEvent::Init()
00108 {
00109    // Check event sources here and downcast the correct one:
00110    // will be called once before event processing is done
00111    if(CheckEventSource("TYYYEventSource"))
00112       {
00113          fxUserSource = dynamic_cast<TYYYEventSource*> (GetEventSource());
00114          fxTreeSource=0;
00115          fxFileSource=0;
00116       }
00117    else if(CheckEventSource("TGo4TreeSource"))
00118       {
00119          fxTreeSource = dynamic_cast<TGo4TreeSource*> (GetEventSource());
00120          fxUserSource=0;
00121          fxFileSource=0;
00122       }
00123    else if(CheckEventSource("TGo4FileSource"))
00124       {
00125          fxFileSource = dynamic_cast<TGo4FileSource*> (GetEventSource());
00126          fxTreeSource=0;
00127          fxUserSource=0;
00128       }
00129    else
00130       {
00131          cout<<" !!! YYYEvent: Init ERROR:  unknown event source !!!"<<endl;
00132          return 1;
00133       }
00134    return 0;
00135 }
00136 
00137 
00138 
00139 void TYYYRawEvent::Clear(Option_t *t)
00140 {
00141 for(Int_t t=0; t<fiColumns;++t)
00142 {
00143    fdData[t]=0;
00144 }
00145 
00146 }
00147 
00148 void TYYYRawEvent::ReAllocate(Int_t newsize)
00149 {
00150    if( newsize <= fiColumns )
00151       {
00152          // newsize is smaller, we do not reallocate
00153       }
00154    else
00155       {
00156         cout <<"*** YYYRawEvent reallocating from "<<fiColumns<<" to "<<newsize << endl;
00157          Double_t* narray=new Double_t[newsize];
00158          for(Int_t i=0;i<fiColumns;++i)
00159             {
00160              narray[i]=fdData[i];
00161             }
00162          delete [] fdData;
00163          fdData=narray;
00164          fiColumns=newsize;
00165       }
00166 
00167 }
00168 
00169 
00170 
00171 void TYYYRawEvent::PrintEvent() {
00172    TGo4EventElement::PrintEvent();
00173    cout<<" YYY Event printout: "<<endl;
00174    for(Int_t t=0; t<fiColumns;++t)
00175    {
00176       cout <<"\t dat("<<t<<")="<<fdData[t]<<endl;
00177    }
00178 }
00179 
00180 
00181 ClassImp(TYYYRawEvent)
00182 
00183 
00184 
00185 
00186 
00187 //----------------------------END OF GO4 SOURCE FILE ---------------------

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