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

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

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