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

/Go4EventServer/TGo4MbsEvent.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 "TGo4MbsEvent.h"
00017 
00018 #include <iostream.h>
00019 #include <iomanip.h>
00020 
00021 #include "Go4Log/TGo4Log.h"
00022 #include "TGo4MbsSubEvent.h"
00023 #include "TGo4MbsSource.h"
00024 #include "TGo4RevServ.h"
00025 #include "TGo4TreeSource.h"
00026 #include "TGo4FileSource.h"
00027 
00028 TGo4MbsEvent::TGo4MbsEvent(UInt_t subnum, Short_t* subids, UInt_t datasize)
00029 : TGo4EventElement("MbsEvent-10-1"),fxIterator(0), fxMbsSource(0), fxTreeSource(0), fxFileSource(0)
00030 {
00031    TRACE((12,"TGo4MbsEvent::TGo4MbsEvent(UInt_t, Short_t, UInt_t)",__LINE__, __FILE__));
00032    fxSubEvArray=new TObjArray(subnum+5);
00033          // we choose dimension of array a bit larger
00034          // to avoid resize for later added subevts
00035    fxIterator = fxSubEvArray->MakeIterator();
00036    ResetIterator();
00037    TGo4MbsSubEvent* subeve;
00038    for (UInt_t t=0;t<subnum;++t)
00039       {
00040          subeve= new TGo4MbsSubEvent(datasize);
00041          fxSubEvArray->AddLast(subeve);
00042          subeve->SetProcid(subids[t]);
00043        }
00044    Clear();
00045 }
00046 
00047 TGo4MbsEvent::TGo4MbsEvent(UInt_t subnum,
00048                            Char_t* subcrates,
00049                            Char_t* controls,
00050                            Short_t* procids, 
00051                            UInt_t* datasizes)
00052 : TGo4EventElement("MbsEvent-10-1"),fxIterator(0), fxMbsSource(0), fxTreeSource(0), fxFileSource(0)
00053 {
00054    TRACE((12,"TGo4MbsEvent::TGo4MbsEvent(UInt_t, Char_t*, Char_t*, Short_t* UInt_t)",__LINE__, __FILE__));
00055    fxSubEvArray=new TObjArray(subnum+5);
00056          // we choose dimension of array a bit larger
00057          // to avoid TObjArray resize for later added subevts
00058    fxIterator = fxSubEvArray->MakeIterator();
00059    ResetIterator();
00060    TGo4MbsSubEvent* subeve;
00061    for (UInt_t t=0;t<subnum;++t)
00062       {
00063          subeve= new TGo4MbsSubEvent(datasizes[t]);
00064          fxSubEvArray->AddLast(subeve);
00065          subeve->SetSubcrate(subcrates[t]);
00066          subeve->SetControl(controls[t]);
00067          subeve->SetProcid(procids[t]);
00068        }
00069    Clear();
00070 }
00071 
00072 
00073 
00074 TGo4MbsEvent::TGo4MbsEvent()
00075 : fxSubEvArray(0), fxIterator(0), fxMbsSource(0), fxTreeSource(0), fxFileSource(0)
00076 {
00077    TRACE((12,"TGo4MbsEvent::TGo4MbsEvent()",__LINE__, __FILE__));
00078 //   fxSubEvArray=new TObjArray;
00079 }
00080 
00081 TGo4MbsEvent::~TGo4MbsEvent()
00082 {
00083    TRACE((12,"TGo4MbsEvent::~TGo4MbsEvent()",__LINE__, __FILE__));
00084    delete fxIterator;
00085    fxSubEvArray->Delete();
00086    delete fxSubEvArray;
00087 
00088 
00089 
00090 }
00091 
00092 Int_t TGo4MbsEvent::Fill()
00093 {
00094    TRACE((11,"TGo4MbsEvent::Fill()",__LINE__, __FILE__));
00095    // check for different source types
00096    Int_t rev=0;
00097    if(fxMbsSource)
00098       {
00099          Clear();
00100          rev=fxMbsSource->NextEvent();
00101          if(rev!=GETEVT__SUCCESS)
00102             {
00103 
00104                TGo4Log::Debug(" Mbs Event --  !!! NextEvent() error: %s !!! ",
00105                            fxMbsSource->GetErrMess());
00106                return rev;
00107             }
00108          else
00109             {
00110                fxMbsSource->BuildMbsEvent(this);
00111                return rev;
00112             }
00113       }
00114 
00115    else if(fxTreeSource)
00116       {
00117          Clear();
00118          if(fxTreeSource->BuildEvent(this))
00119             {
00120                return 0;
00121             }
00122          else
00123             {
00124                // error, may be end of tree..
00125                return 1;
00126             }
00127 
00128       }
00129 else if(fxFileSource)
00130       {
00131          Clear();
00132          if(fxFileSource->BuildEvent(this))
00133             {
00134                delete fxIterator; // need this to prepare correct iterator!
00135                fxIterator = fxSubEvArray->MakeIterator();
00136                return 0;
00137             }
00138          else
00139             {
00140                // error, may be end of tree..
00141                return 1;
00142             }
00143 
00144       }
00145 
00146    else
00147       {
00148 
00149          TGo4Log::Debug(" !!! MbsEvent: Fill ERROR:  unknown event source !!! ");
00150          return 1;
00151       }
00152 
00153    return 0;
00154 }
00155 
00156 Int_t TGo4MbsEvent::Init()
00157 {
00158    TRACE((11,"TGo4MbsEvent::Init()",__LINE__, __FILE__));
00159    // Check event sources here and downcast the correct one:
00160    // will be called once before event processing is done
00161    if(CheckEventSource("TGo4MbsSource"))
00162       {
00163          fxMbsSource = dynamic_cast<TGo4MbsSource*> (GetEventSource());
00164          fxTreeSource=0;
00165          fxFileSource=0;
00166       }
00167    else if(CheckEventSource("TGo4TreeSource"))
00168       {
00169          fxTreeSource = dynamic_cast<TGo4TreeSource*> (GetEventSource());
00170          fxMbsSource=0;
00171          fxFileSource=0;
00172       }
00173    else if(CheckEventSource("TGo4FileSource"))
00174       {
00175          fxFileSource = dynamic_cast<TGo4FileSource*> (GetEventSource());
00176          fxTreeSource=0;
00177          fxMbsSource=0;
00178       }
00179    else
00180       {
00181          TGo4Log::Debug(" !!! MbsEvent: Init ERROR:  unknown event source !!! ");
00182          return 1;
00183       }
00184    return 0;
00185 }
00186 
00187 void TGo4MbsEvent::Clear(Option_t *t)
00188 {
00189    TRACE((11,"TGo4MbsEvent::Clear()",__LINE__, __FILE__));
00190    // here iterate all subevents and clear them
00191    TGo4MbsSubEvent* sub;
00192    ResetIterator();
00193    while ((sub = NextSubEvent(kTRUE)) !=0)
00194       {
00195          sub->Clear();
00196          //cout<< "cleared subevent"<< sub->GetProcid() << endl;
00197       }
00198 //   fxHeader.Clear();
00199 //   Set(); // set to default values
00200 }
00201 
00202 
00203 void TGo4MbsEvent::Set(Int_t dlen, Short_t type, Short_t subtype,
00204                        Short_t dummy, Short_t trigger, Int_t count)
00205 {
00206    SetDlen(dlen);
00207    SetType(type);
00208    SetSubtype(subtype);
00209    SetDummy(dummy);
00210    SetTrigger(trigger);
00211    SetCount(count);
00212 }
00213 
00214 void TGo4MbsEvent::PrintEvent() {
00215    TGo4EventElement::PrintEvent();
00216 
00218 //   TGo4Log::Info( " MBS Event Header printout: ");
00219 //   TGo4Log::Info( "\tl_dlen    %d ", GetDlen() );
00220 //   TGo4Log::Info( "\ti_type    %d", GetType() );
00221 //   TGo4Log::Info( "\ti_subtype %d", GetSubtype() );
00222 //   TGo4Log::Info( "\ti_dummy   %d", GetDummy() );
00223 //   TGo4Log::Info( "\th_trigger %d", GetTrigger() );
00224 //   TGo4Log::Info( "\th_count  %d", GetCount() );
00225 
00227 cout << "MBS Event printout:"
00228       << dec      << setw(8) << (Int_t) GetCount()
00229       << " t/s "  << setw(4) << (Int_t) GetType()
00230       << " "      << setw(4) << (Int_t) GetSubtype()
00231       << " len "  << setw(8) << (Int_t) GetDlen()
00232       << " trig   " << setw(4) << (Int_t) GetTrigger()
00233       << endl;
00234    TGo4MbsSubEvent* sub;
00235    ResetIterator();
00236    while ((sub = NextSubEvent() ) !=0)
00237       {
00238          sub->PrintEvent();
00239       }
00240 
00241 
00242 
00243 }
00244 
00245 void TGo4MbsEvent::ResetIterator()
00246 {
00247    TRACE((11,"TGo4MbsEvent::ResetIterator()",__LINE__, __FILE__));
00248    if(fxIterator)
00249       fxIterator->Reset();
00250    else
00251       fxIterator = fxSubEvArray->MakeIterator();
00252 }
00253 
00254 
00255 
00256 TGo4MbsSubEvent* TGo4MbsEvent::NextSubEvent(Bool_t all)
00257 {
00258    TRACE((11,"TGo4MbsEvent::NextSubEvent()",__LINE__, __FILE__));
00259    TGo4MbsSubEvent*   sub=0;
00260    do
00261    {
00262       sub= dynamic_cast<TGo4MbsSubEvent*> (fxIterator ->Next());
00263       if(sub==0) break;
00264    }while(!all && !sub->IsFilled()); // skip not filled subevents
00265    return sub;
00266 }
00267 
00268 
00269 
00270 
00271 
00272 TGo4MbsSubEvent * TGo4MbsEvent::GetSubEvent(Char_t subcrate, Char_t ctrl, Short_t procid)
00273 {
00274    TRACE((11,"TGo4MbsEvent::GetSubEvent(Char_t)",__LINE__, __FILE__));
00275    TGo4MbsSubEvent* result=0;
00276    TGo4MbsSubEvent* sub=0;
00277    ResetIterator();
00278    while ((sub = NextSubEvent() ) !=0)
00279       {
00280          if( (sub->GetSubcrate() == subcrate)
00281                && (sub->GetControl() == ctrl)
00282                && (sub->GetProcid()== procid)   )
00283             {
00284                result=sub;
00285                break;
00286             }
00287       }
00288    return result;
00289 }
00290 
00291 TGo4MbsSubEvent * TGo4MbsEvent::GetSubEvent(Short_t procid)
00292 {
00293    TRACE((11,"TGo4MbsEvent::GetSubEvent(Short_t)",__LINE__, __FILE__));
00294    TGo4MbsSubEvent* result=0;
00295    TGo4MbsSubEvent* sub=0;
00296    ResetIterator();
00297    while ((sub = NextSubEvent() ) !=0)
00298       {
00299          if(sub->GetProcid()== procid)
00300             {
00301                result=sub;
00302                break;
00303             }
00304       }
00305    return result;
00306 }
00307 
00308 
00309 
00310 
00311 
00312 
00313 s_filhe * TGo4MbsEvent::GetMbsSourceHeader()
00314 {
00315    if(fxMbsSource)
00316       return (fxMbsSource->GetInfoHeader());
00317    else
00318       return 0;
00319 }
00320 
00321 
00322 s_bufhe * TGo4MbsEvent::GetMbsBufferHeader()
00323 {
00324    if(fxMbsSource)
00325       return (fxMbsSource->GetBufferHeader());
00326    else
00327       return 0;
00328 }
00329 
00330 void TGo4MbsEvent::SetPrintEvent(Int_t num, Int_t sid, Int_t longw, Int_t hexw, Int_t dataw)
00331 {
00332    if(fxMbsSource)
00333       return (fxMbsSource->SetPrintEvent(num,sid,longw,hexw,dataw));
00334 }
00335 
00336 
00337 ClassImp(TGo4GSIEventHeader)
00338 ClassImp(TGo4EventHeader10)
00339 ClassImp(TGo4SubEventHeader10)
00340 ClassImp(TGo4MbsEvent)
00341 
00342 
00343 
00344 
00345 
00346 //----------------------------END OF GO4 SOURCE FILE ---------------------

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