00001 // $Id: TMeshUnpackProc.cxx 1037 2013-11-06 13:39:24Z linev $ 00002 //----------------------------------------------------------------------- 00003 // The GSI Online Offline Object Oriented (Go4) Project 00004 // Experiment Data Processing at EE department, GSI 00005 //----------------------------------------------------------------------- 00006 // Copyright (C) 2000- GSI Helmholtzzentrum für Schwerionenforschung GmbH 00007 // Planckstr. 1, 64291 Darmstadt, Germany 00008 // Contact: http://go4.gsi.de 00009 //----------------------------------------------------------------------- 00010 // This software can be used under the license agreements as stated 00011 // in Go4License.txt file which is part of the distribution. 00012 //----------------------------------------------------------------------- 00013 00014 #include "TMeshUnpackProc.h" 00015 00016 #include "TGo4MbsEvent.h" 00017 #include "TGo4Log.h" 00018 00019 #include "TMeshRawEvent.h" 00020 #include "TMeshB1InputEvent.h" 00021 #include "TMeshB2InputEvent.h" 00022 00023 //*********************************************************** 00024 TMeshUnpackProc::TMeshUnpackProc() : 00025 TGo4EventProcessor("Unpacker") 00026 { 00027 } 00028 //*********************************************************** 00029 // this one is used in TXXXUnpackFact.cxx 00030 TMeshUnpackProc::TMeshUnpackProc(const char* name) : 00031 TGo4EventProcessor(name) 00032 { 00033 TGo4Log::Info("TMeshUnpackProc: Create %s", name); 00034 } 00035 00036 //*********************************************************** 00037 TMeshUnpackProc::~TMeshUnpackProc() 00038 { 00039 } 00040 //*********************************************************** 00041 00042 //----------------------------------------------------------- 00043 void TMeshUnpackProc::Unpack(TMeshRawEvent* poutevt) 00044 { 00045 if(poutevt==0) return; 00046 // process subcomponents independently 00047 // note: this will run subevent loop each time, which is not performance optimized in this example 00048 // however, for the general case this unpacker decoupling is more suitable 00049 UnpackBranch1(&(poutevt->fxSub1)); 00050 UnpackBranch2(&(poutevt->fxSub2)); 00051 UnpackBranch3(&(poutevt->fxSub3)); 00052 poutevt->SetValid(kTRUE); // to store 00053 } 00054 00055 00056 void TMeshUnpackProc::UnpackBranch1(TMeshB1InputEvent* poutevt) 00057 { 00058 fInput = dynamic_cast<TGo4MbsEvent*> (GetInputEvent()); // from this 00059 if(fInput==0) { 00060 TGo4Log::Error("UnpackBranch1: no input event !"); 00061 return; 00062 } 00063 00064 Int_t index(0), value(0), lwords(0); 00065 Int_t *pdata(0); 00066 TGo4MbsSubEvent* psubevt(0); 00067 fInput->ResetIterator(); 00068 while ((psubevt = fInput->NextSubEvent()) != 0) // subevent loop 00069 { 00070 if( psubevt->GetSubcrate() == 1) 00071 { 00072 pdata=psubevt->GetDataField(); 00073 lwords= (psubevt->GetDlen() -2) * sizeof(Short_t)/sizeof(Int_t); 00074 if(lwords >= 8) lwords=8; // take only first 8 lwords 00075 for(Int_t i = 0; i<lwords; ++i) 00076 { 00077 index = *pdata&0xfff; // in case low word is index 00078 value = *pdata; // save for 2d histogram 00079 //value = (*pdata>>16)&0xfff; // in case high word is data 00080 if((value != 0) && (index>=0)) { 00081 poutevt->fiCrate1[i] = value; // fill output event 00082 } 00083 pdata++; 00084 } // for SEW LW 00085 } // if (subcrate) 00086 00087 } // while 00088 poutevt->SetValid(kTRUE); // to store 00089 } 00090 00091 void TMeshUnpackProc::UnpackBranch2(TMeshB2InputEvent* poutevt) 00092 { 00093 fInput = dynamic_cast<TGo4MbsEvent*> (GetInputEvent()); // from this 00094 if(fInput==0) { 00095 TGo4Log::Error("UnpackBranch2: no input event !"); 00096 return; 00097 } 00098 00099 Int_t index(0), value(0), lwords(0); 00100 Int_t *pdata(0); 00101 TGo4MbsSubEvent* psubevt(0); 00102 fInput->ResetIterator(); 00103 while ((psubevt = fInput->NextSubEvent()) != 0) // subevent loop 00104 { 00105 if( psubevt->GetSubcrate() == 2) 00106 { 00107 pdata=psubevt->GetDataField(); 00108 lwords= (psubevt->GetDlen() -2) * sizeof(Short_t)/sizeof(Int_t); 00109 if(lwords >= 8) lwords=8; 00110 for(Int_t i = 0; i<lwords; ++i) 00111 { 00112 index = *pdata&0xfff; 00113 //value=(*pdata>>16)&0xfff; 00114 value = *pdata; 00115 if((value != 0) && (index>=0)) { 00116 poutevt->fiCrate2[i] = value; 00117 } 00118 pdata++; 00119 } // for SEW LW 00120 } // if (subcrate) 00121 } // while 00122 poutevt->SetValid(kTRUE); // to store 00123 } 00124 00125 void TMeshUnpackProc::UnpackBranch3(TMeshB3InputEvent* poutevt) 00126 { 00127 fInput = dynamic_cast<TGo4MbsEvent*> (GetInputEvent()); // from this 00128 if(fInput==0) { 00129 TGo4Log::Error("UnpackBranch3: no input event !"); 00130 return; 00131 } 00132 00133 Int_t index(0), value(0), lwords(0); 00134 Int_t *pdata(0); 00135 TGo4MbsSubEvent* psubevt(0); 00136 fInput->ResetIterator(); 00137 while ((psubevt = fInput->NextSubEvent()) != 0) // subevent loop 00138 { 00139 if( psubevt->GetSubcrate() == 3) 00140 { 00141 pdata=psubevt->GetDataField(); 00142 lwords= (psubevt->GetDlen() -2) * sizeof(Short_t)/sizeof(Int_t); 00143 if(lwords >= 8) lwords=8; // take only first 8 lwords 00144 for(Int_t i = 0; i<lwords; ++i) 00145 { 00146 index = *pdata&0xfff; // in case low word is index 00147 //value = (*pdata>>16)&0xfff; // in case high word is data 00148 value = *pdata; 00149 if((value != 0) && (index>=0)) { 00150 poutevt->fiCrate3[i] = value; // fill output event 00151 } 00152 pdata++; 00153 } // for SEW LW 00154 } // if (subcrate) 00155 } // while 00156 poutevt->SetValid(kTRUE); // to store 00157 }