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