Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members

TMeshUnpackProc.cxx

Go to the documentation of this file.
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 "TMeshUnpackProc.h"
00017 
00018 #include "Riostream.h"
00019 
00020 #include "TGo4MbsEvent.h"
00021 //#include "TGo4Analysis.h"
00022 //#include "TGo4EventElement.h"
00023 
00024 
00025 #include "TMeshRawEvent.h"
00026 #include "TMeshB1InputEvent.h"
00027 #include "TMeshB2InputEvent.h"
00028 
00029 //***********************************************************
00030 TMeshUnpackProc::TMeshUnpackProc()
00031   : TGo4EventProcessor("Unpacker")
00032 {
00033 }
00034 //***********************************************************
00035 // this one is used in TXXXUnpackFact.cxx
00036 TMeshUnpackProc::TMeshUnpackProc(const char* name)
00037   : TGo4EventProcessor(name)
00038 {
00039   cout << "**** TMeshUnpackProc: Create" << endl;
00040 
00041 
00042 }
00043 //***********************************************************
00044 TMeshUnpackProc::~TMeshUnpackProc()
00045 {
00046 
00047 }
00048 //***********************************************************
00049 
00050 //-----------------------------------------------------------
00051 void TMeshUnpackProc::Unpack(TMeshRawEvent* poutevt)
00052 {
00053    if(poutevt==0) return;
00054    // process subcomponents independently
00055    // note: this will run subevent loop each time, which is not performance optimized in this example
00056    // however, for the general case this unpacker decoupling is more suitable
00057    UnpackBranch1(&(poutevt->fxSub1));
00058    UnpackBranch2(&(poutevt->fxSub2));
00059    UnpackBranch3(&(poutevt->fxSub3));
00060    poutevt->SetValid(kTRUE); // to store
00061 }
00062 
00063 
00064 void TMeshUnpackProc::UnpackBranch1(TMeshB1InputEvent* poutevt)
00065 {
00066   TGo4MbsSubEvent* psubevt;
00067   Int_t index=0;
00068   Int_t value=0;
00069   Int_t lwords;
00070   Int_t *pdata;
00071   fInput    = dynamic_cast<TGo4MbsEvent*> (GetInputEvent()); // from this
00072   if(fInput)
00073     {
00074 
00075       fInput->ResetIterator();
00076       while ((psubevt = fInput->NextSubEvent()) != 0) // subevent loop
00077          {
00078            if( psubevt->GetSubcrate() == 1)
00079              {
00080                pdata=psubevt->GetDataField();
00081                lwords= (psubevt->GetDlen() -2) * sizeof(Short_t)/sizeof(Int_t);
00082                if(lwords >= 8) lwords=8; // take only first 8 lwords
00083                for(Int_t i = 0; i<lwords; ++i)
00084                {
00085                  index =  *pdata&0xfff;      // in case low word is index
00086                  value = *pdata; // save for 2d histogram
00087                  //value = (*pdata>>16)&0xfff; // in case high word is data
00088                  if(value != 0)
00089                   {
00090                      poutevt->fiCrate1[i] = value; // fill output event
00091                   }
00092                 pdata++;
00093                } // for SEW LW
00094              } // if (subcrate)
00095 
00096          }  // while
00097       poutevt->SetValid(kTRUE); // to store
00098     } // if(fInput)
00099   else    cout << "UnpackBranch1: no input event !"<< endl;
00100 }
00101 
00102 void TMeshUnpackProc::UnpackBranch2(TMeshB2InputEvent* poutevt)
00103 {
00104   TGo4MbsSubEvent* psubevt;
00105   Int_t index=0;
00106   Int_t value=0;
00107   Int_t lwords;
00108   Int_t *pdata;
00109   fInput    = dynamic_cast<TGo4MbsEvent*> (GetInputEvent()); // from this
00110   if(fInput)
00111     {
00112 
00113       fInput->ResetIterator();
00114       while ((psubevt = fInput->NextSubEvent()) != 0) // subevent loop
00115          {
00116            if( psubevt->GetSubcrate() == 2)
00117              {
00118                pdata=psubevt->GetDataField();
00119                lwords= (psubevt->GetDlen() -2) * sizeof(Short_t)/sizeof(Int_t);
00120                if(lwords >= 8) lwords=8;
00121                for(Int_t i = 0; i<lwords; ++i)
00122                   {
00123                     index=*pdata&0xfff;
00124                     //value=(*pdata>>16)&0xfff;
00125                     value=*pdata;
00126                     if(value != 0)
00127                       {
00128                         poutevt->fiCrate2[i] = value;
00129                       }
00130                     pdata++;
00131                   } // for SEW LW
00132              } // if (subcrate)
00133          }  // while
00134       poutevt->SetValid(kTRUE); // to store
00135     } // if(fInput)
00136   else    cout << "UnpackBranch2: no input event !"<< endl;
00137 }
00138 
00139 void TMeshUnpackProc::UnpackBranch3(TMeshB3InputEvent* poutevt)
00140 {
00141   TGo4MbsSubEvent* psubevt;
00142   Int_t index=0;
00143   Int_t value=0;
00144   Int_t lwords;
00145   Int_t *pdata;
00146   fInput    = dynamic_cast<TGo4MbsEvent*> (GetInputEvent()); // from this
00147   if(fInput)
00148     {
00149 
00150       fInput->ResetIterator();
00151       while ((psubevt = fInput->NextSubEvent()) != 0) // subevent loop
00152          {
00153            if( psubevt->GetSubcrate() == 3)
00154              {
00155                pdata=psubevt->GetDataField();
00156                lwords= (psubevt->GetDlen() -2) * sizeof(Short_t)/sizeof(Int_t);
00157                if(lwords >= 8) lwords=8; // take only first 8 lwords
00158                for(Int_t i = 0; i<lwords; ++i)
00159                   {
00160                     index =  *pdata&0xfff;      // in case low word is index
00161                     //value = (*pdata>>16)&0xfff; // in case high word is data
00162                     value = *pdata;
00163                     if(value != 0)
00164                       {
00165                         poutevt->fiCrate3[i] = value; // fill output event
00166                       }
00167                     pdata++;
00168                   } // for SEW LW
00169              } // if (subcrate)
00170          }  // while
00171       poutevt->SetValid(kTRUE); // to store
00172     } // if(fInput)
00173   else    cout << "UnpackBranch3: no input event !"<< endl;
00174 }
00175 
00176 //----------------------------END OF GO4 SOURCE FILE ---------------------

Generated on Fri Nov 28 12:59:11 2008 for Go4-v3.04-1 by  doxygen 1.4.2