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

/Go4EventServer/TGo4MbsSubEvent.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 "TGo4MbsSubEvent.h"
00017 
00018 #include <iostream.h>
00019 #include <iomanip.h>
00020 
00021 #include "Go4Log/TGo4Log.h"
00022 #include "TGo4MbsSource.h"
00023 
00024 TGo4MbsSubEvent::TGo4MbsSubEvent() :
00025    TGo4EventElement(),
00026    fbIsFilled(kFALSE), 
00027    fbIsDataOwner(kFALSE),
00028    fxHeader(),
00029    fiAllocLen(0),
00030    fiData(0)
00031 {
00032    TRACE((12,"TGo4MbstSubEvent::TGo4MbsSubEvent()",__LINE__, __FILE__));
00033 }
00034 
00035 TGo4MbsSubEvent::TGo4MbsSubEvent(Int_t datasize) :
00036    TGo4EventElement(),
00037    fbIsFilled(kFALSE), 
00038    fbIsDataOwner(kTRUE),
00039    fxHeader(),
00040    fiAllocLen(0),
00041    fiData(0)
00042 {
00043    TRACE((12,"TGo4MbsSubEvent::TGo4MbsSubEvent(UInt_t)",__LINE__, __FILE__));
00044    if(fbIsDataOwner)
00045       {
00046          fiData= new Int_t[datasize];
00047          fiAllocLen=datasize;
00048       }
00049 }
00050 
00051 TGo4MbsSubEvent::~TGo4MbsSubEvent()
00052 {
00053    TRACE((12,"TGo4MbsSubEvent::~TGo4MbsSubEvent()",__LINE__, __FILE__));
00054    // check if Clear with only the used field elements worked correctly
00055    Clear();
00056    if(fbIsDataOwner)
00057       {
00058          for(Int_t t=0; t<GetAllocatedLength() ;++t)
00059             {
00060                if(fiData[t]!=0)
00061                      {
00062                         TGo4Log::Debug( " MBS SubEvent dtor WARNING: Data(%d) not zero after Clear !!!  ",t);
00063                      }
00064                else {}
00065             }
00066          delete [] fiData;
00067       }
00068 }
00069 
00070 
00071 
00072 void TGo4MbsSubEvent::PrintEvent() {
00073    TRACE((11,"TGo4MbsSubEvent::PrintEvent()",__LINE__, __FILE__));
00075 //   TGo4Log::Info( " MBS SubEvent Header printout: ");
00076 //   TGo4Log::Info( "\tl_dlen    %d ", GetDlen() );
00077 //   TGo4Log::Info( "\ti_type    %d", GetType() );
00078 //   TGo4Log::Info( "\ti_subtype %d", GetSubtype() );
00079 //   TGo4Log::Info( "\ti_procid   %d", GetProcid() );
00080 //   TGo4Log::Info( "\th_subcrate %d", GetSubcrate() );
00081 //   TGo4Log::Info( "\th_control  %d", GetControl() );
00082 //   TGo4Log::Info( "\tAllocatedLen  %d", GetAllocatedLength() );
00083 //   TGo4Log::Info( "\tIsFilled  %d", IsFilled() );
00084 //   TGo4Log::Info( "\tDatafield:");
00085 //   for(Int_t i=0; i<GetAllocatedLength();++i)
00086 //      {
00087 //         if(i+10>GetAllocatedLength())
00088 //           TGo4Log::Info("\t   %d",fiData[i]);
00089 //         else
00090 //            TGo4Log::Info("\t   %d %d %d %d %d %d %d %d %d %d",
00091 //               fiData[i++],
00092 //               fiData[i++],
00093 //               fiData[i++],
00094 //               fiData[i++],
00095 //               fiData[i++],
00096 //               fiData[i++],
00097 //               fiData[i++],
00098 //               fiData[i++],
00099 //               fiData[i++],
00100 //               fiData[i]);
00101 //      }
00102 
00104 Bool_t printhexa=kFALSE;
00105 Int_t* pData = (Int_t *) GetDataField();
00106 cout << "   Mbs Subevent    t/s "
00107 <<      dec << setw(4) << (Int_t)GetType()
00108 << " "      << setw(4) << (Int_t)GetSubtype()
00109 << " len "  << setw(8) << (Int_t)GetDlen()
00110 << " procid "   << setw(4) << (Int_t)GetProcid()
00111 << " ctrl " << setw(4) << (Int_t)GetControl()
00112 << " cr "   << setw(4) << (Int_t)GetSubcrate()
00113 << endl;
00114 if(printhexa) cout << hex; else cout << dec;
00115 for(Int_t i=0; i < GetDlen()/2-1; i++)
00116  {
00117    cout << setw(12) << *pData << " ";
00118    if((i-3) % 4 == 0) cout << endl;
00119    pData++;
00120  }
00121 cout << endl;
00122 }
00123 
00124 void TGo4MbsSubEvent::Set(Int_t dlen,
00125                           Short_t type,
00126                           Short_t subtype,
00127                           Short_t procid,
00128                           Char_t subcrate,
00129                           Char_t ctrl)
00130 {
00131    SetDlen(dlen);
00132    SetType(type);
00133    SetSubtype(subtype);
00134    //SetProcid(procid); do not change procid and identifiers!!
00135    //SetSubcrate(subcrate);
00136    //SetControl(ctrl);
00137 }
00138 
00139 void  TGo4MbsSubEvent::Clear(Option_t *t)
00140 {
00141    TRACE((11,"TGo4MbsSubEvent::Clear()",__LINE__, __FILE__));
00142 fbIsFilled=kFALSE;
00143 if(fbIsDataOwner)
00144       {
00145          // clear array of data
00146          Int_t dleng= GetDlen();
00147          if(dleng==0) dleng=2; // default value for dleng is not zero!!
00148          // only clear regions which were used by the previous fill...
00149          //cout <<"Mbssubevent::Clear: dlen=" << dleng << endl;
00150          Int_t fieldlength=   (dleng-2) / TGo4MbsSource::fguLONGBYSHORT ; // field is Int_t
00151          if(fieldlength>fiAllocLen)
00152                fieldlength=fiAllocLen;
00153 
00154          if(fieldlength==0)
00155                fiData[0]=0; // clear in case of zero subevents!
00156          for(Int_t t=0; t<fieldlength;++t)
00157             {
00158                fiData[t]=0;
00159                //cout<< fiData[t]<< " ";
00160             }
00161          //cout<<endl<< "Subevent: cleared "<< fiAllocLen << "int field at "<<fiData << endl;
00162          fxHeader.Clear();
00163          Set(dleng); // set to default values, but remember last datalength
00164       }//if(fbIsDataOwner)
00165 else {}
00166 }
00167 
00168 void TGo4MbsSubEvent::ReAllocate(Int_t newsize)
00169 {
00170    TRACE((11,"TGo4MbsSubEvent::ReAllocate(UInt_t)",__LINE__, __FILE__));
00171 if(!fbIsDataOwner) return;
00172    if( newsize <= fiAllocLen )
00173       {
00174          // newsize is smaller, we do not reallocate
00175       }
00176    else
00177       {
00178          delete [] fiData;
00179          fiData= new Int_t[newsize];
00180          //cout<< "Subevent: Reallocating " << newsize << ", previous:"<< fiAllocLen<<endl;
00181          TGo4Log::Debug(" MbsSubEvent: Reallocating Data field from %d to %d longwords ",fiAllocLen,newsize);
00182          fiAllocLen=newsize;
00183          Clear();
00184       }
00185 
00186 }
00187 
00188 ClassImp(TGo4MbsSubEvent)
00189 
00190 
00191 
00192 
00193 //----------------------------END OF GO4 SOURCE FILE ---------------------

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