• Main Page
  • Related Pages
  • Namespaces
  • Data Structures
  • Files
  • File List
  • Globals

beamtime/gsi-aug12/hd/go4/TMbsCrateProc.cxx (r4864/r3220)

Go to the documentation of this file.
00001 #include "TMbsCrateProc.h"
00002 
00003 #include <stdlib.h>
00004 
00005 #include "TTimeStamp.h"
00006 #include "TSystem.h"
00007 #include "TROOT.h"
00008 #include "TGo4Log.h"
00009 
00010 // still need this for subevent types:
00011 #include "roc/Message.h"
00012 #include "roc/Board.h"
00013 
00014 #if defined(VERSION_VFTX) || defined(VERSION_VFTX_28)  // For Heidelberg tests!
00015    #include "../mbs/cbmvme0.h"
00016 #else
00017    #include "../mbs/cbmvme.h"
00018 #endif
00019 
00020 const uint32_t vme_setup[MAX__N_MOD*6] = VME__MODULES;
00021 
00022 uint64_t vme_tags[MAX__N_MOD];
00023 
00024 #define CAEN1290_DEBUG 0
00025 #define L1182_DEBUG 0
00026 
00027 TMbsCrateProc::TMbsCrateProc() :
00028    TCBMBeamtimeProc(),
00029    fOutputEvent(0)
00030 {
00031 }
00032 
00033 TMbsCrateProc::TMbsCrateProc(const char* name) :
00034    TCBMBeamtimeProc(name),
00035    fOutputEvent(0)
00036 {
00037    TGo4Log::Info("TMbsCrateProc: Create instance %s", name);
00038 
00039    TString obname, obtitle;   
00040 
00041    fPar = (TMbsCrateParam*) MakeParameter("MbsCratePar", "TMbsCrateParam");
00042    
00043    // v1290 histograms
00044 
00045    iCaenEnabled = 0;
00046    for (int n=0;n<MAX_1290;n++)
00047       if( 1 == fPar->uCaenTdcHistosEnabled[n] )
00048       {
00049          if( kTRUE == fPar->bCaenDebug || kTRUE == fPar->bCaenTriggerTime )
00050             fTDC[n].MakeHistos(this, fPar->bCaenDebug, fPar->bCaenTriggerTime, Form("TDC%d",n));
00051          else {
00052             fTDC[n].MakeHistos(this, Form("TDC%d",n));
00053             if( CAEN1290_DEBUG )
00054                fTDC[n].MakeDebugHistos(this, Form("TDC%d",n));
00055          }
00056          iCaenEnabled++;
00057       }
00058 
00059    if( 1 < iCaenEnabled && 1 == fPar->uCaenCoincidenceMap)
00060    {
00061       /*
00062       fAllTDC_chanMapL = MakeTH2('I', "CAEN/chanMap_CaenTdcL", "Channel (L) during same event?",
00063             MAX_1290*T1290Data::NumChan, -0.5, MAX_1290*T1290Data::NumChan-0.5,
00064             MAX_1290*T1290Data::NumChan, -0.5, MAX_1290*T1290Data::NumChan-0.5,
00065            "Channel 1 []", "Channel 2[]", "Events []");
00066       */
00067       iMapIndex = 0;
00068       for( Int_t iModule1 = 0; iModule1 < MAX_1290; iModule1 ++)
00069          for( Int_t iModule2 = iModule1; iModule2 < MAX_1290; iModule2 ++)
00070          {
00071             if( MAX_1290*(MAX_1290+1)/2 < iMapIndex )
00072             {
00073                TGo4Log::Info("****Mbs unpacker: Error creating caen mapping histos: index out of boundary : %d / %d (tdc #%d VS tdc #%d)",
00074                      iMapIndex, MAX_FPGA_TDC*(MAX_FPGA_TDC+1)/2, iModule1, iModule2);
00075                break;
00076             }
00077             fTDC_chanMapL[ iMapIndex ] =
00078                      MakeTH2('I', Form("CAEN/Mapp%d_%dCaen", iModule1, iModule2 ),
00079                                   Form("Channel during same event?, Tdc %d VS Tdc %d", iModule1, iModule2),
00080                                   T1290Data::NumChan, -0.5, T1290Data::NumChan - 0.5,
00081                                   T1290Data::NumChan, -0.5, T1290Data::NumChan - 0.5,
00082                                   Form("Channel Tdc #%d []", iModule1),
00083                                   Form("Channel Tdc #%d []", iModule2),"Events []");
00084             iMapIndex++;
00085          }
00086    }
00087 
00088    for (int n=0;n<MAX_965;n++)
00089       if( 1 == fPar->uCaenQdcHistosEnabled[n] )
00090          for (int ch=0;ch<MQDC_t::NumChan;ch++) {
00091             obname.Form("QDC%d/Charge%d_%d",n,n,ch);
00092             obtitle.Form("Charge of QDC %d channel %d",n,ch);
00093             fQdc_Charge[n][ch] = MakeTH1('I',obname.Data(),obtitle.Data(),4096,1,4096,"charge");
00094          }
00095 
00096    for (int n=0;n<MAX_FPGA_TDC;n++)
00097       if( 1 == fPar->uVftxHistosEnabled[n] )
00098          for (int ch=0;ch<FPGA_TDC_NBCHAN;ch++) {
00099             obname.Form("FPGA_TDC%d/FPGA_TDC%d_Ch%d", n, n, ch);
00100             obtitle.Form("Fine counter of TDC%d channel %d", n, ch);
00101             fFPGA_Ch[n][ch] = MakeTH1('I', obname.Data(), obtitle.Data(), 0x800, 0, 0x800, "cnt");
00102          }
00103 
00104    // 1182 histograms
00105    for (int n=0;n<MAX_1182;n++)
00106       if( 1 == fPar->uLecroyQdcHistosEnabled[n] )
00107          for (int ch=0;ch<NUM_1182_CH;ch++) {
00108             obname.Form("118%d/118%d_channel%d", n+2, n+2, ch);
00109             obtitle.Form("118%d Channel %d", n+2, ch);
00110             f1182h[n][ch] = MakeTH1('I', obname.Data(), obtitle.Data(), 1024, 0, 4096.);
00111          }
00112 
00113 
00114    // QFW histograms
00115    if( 1 == fPar->uQFWHistosEnabled )
00116    {
00117       fQFWcnt = MakeTH1('I', "QFW/QFWcnt", "Counts in QFW channels", 4, 0, 4, "cnt");
00118       fQFWerr = MakeTH1('I', "QFW/QFWerr", "Error counts in QFW channels", 4, 0, 4, "err");
00119 
00120       fQFWInfo = new TLatex(0.5,0.5,"-- demo text --");
00121       fQFWInfo->SetName("QFWInfo");
00122       fQFWInfo->SetNDC();
00123       AddObject(fQFWInfo);
00124    }
00125 
00126    for (int n=0;n<MAX__N_MOD;n++) {
00127       if (n != (int)vme_setup[n*6]) {
00128          TGo4Log::Error("Wrong setup in cbmvme.h file in row %d",n);
00129          exit(1);
00130       }
00131 
00132       vme_tags[n] = (((uint64_t) vme_setup[n*6+5]) << 32) | vme_setup[n*6+4];
00133 
00134       if ((n>0) && (vme_tags[n]==0)) {
00135          TGo4Log::Error("Wrong setup in cbmvme.h - zero tag in row %d", n);
00136          exit(1);
00137       }
00138    }
00139 
00140    TGo4Log::Info("TMbsCrateProc - Histograms created");
00141 }
00142 
00143 TMbsCrateProc::~TMbsCrateProc()
00144 {
00145    cout << "**** TMbsCrateProc: Delete instance " << endl;
00146 }
00147 
00148 void TMbsCrateProc::InitEvent(TGo4EventElement* outevnt)
00149 {
00150    TCBMBeamtimeEvent* btevent=dynamic_cast<TCBMBeamtimeEvent*>(outevnt);
00151    if(btevent)
00152    {
00153       // since output event object is never discarded within processor lifetime,
00154       // we just search for subevent by name once to speed up processing
00155       if(fOutputEvent==0)
00156          fOutputEvent=dynamic_cast<TMbsCrateEvent*>(btevent->GetSubEvent("MBSCRATE"));
00157    }
00158    else
00159    {
00160 
00161       fOutputEvent= dynamic_cast<TMbsCrateEvent*>(outevnt);
00162    }
00163    if(fOutputEvent==0) {
00164       GO4_STOP_ANALYSIS_MESSAGE("**** TMbsCrateProc: Fatal error: output event is not a TMbsCrateEvent!!! STOP GO4");
00165    }
00166 }
00167 
00168 void TMbsCrateProc::ProcessSubevent(TGo4MbsSubEvent* subevt)
00169 {
00170 // uncomment this to test with previous beamtime lmds:
00171    if (subevt->GetProcid() == roc::proc_COSY_Nov11) {
00172 // comment this to test with previous beamtime lmds:
00173 //   if (subevt->GetProcid() == roc::proc_GSI_Aug12) {
00174       // MBS data from GSI beamtime, August 11
00175       // subevt->GetControl() == 9 from Master MBS, subevt->GetControl() == 10 from Slave MBS
00176 
00177       Int_t *pdata = subevt->GetDataField();
00178       UInt_t lwords = subevt->GetIntLen();
00179 
00180       // printf("CERN subevent Control %u TOTALLEN = %u\n", subevt->GetControl(), lwords);
00181 
00182       Int_t* tagpos[MAX__N_MOD];
00183       Int_t taglen[MAX__N_MOD];
00184 
00185       for (int n=0;n<MAX__N_MOD;n++) {
00186          tagpos[n] = 0;
00187          taglen[n] = 0;
00188       }
00189 
00190       int lasttag = -1;
00191 
00192       for (UInt_t cur = 0; cur < lwords; ++cur) {
00193          uint64_t* ptag = (uint64_t*) pdata;
00194          bool find = false;
00195 
00196          for (int ntag=1;ntag<MAX__N_MOD;ntag++)
00197             if ((*ptag == vme_tags[ntag]) && (vme_tags[ntag]!=0)) {
00198                if (lasttag>=0) {
00199                   taglen[lasttag] = pdata - tagpos[lasttag];
00200                   lasttag = -1;
00201                }
00202 
00203                if (tagpos[ntag]==0) {
00204                   pdata+=2; cur+=1;
00205                   tagpos[ntag] = pdata;
00206                   lasttag = ntag;
00207                } else {
00208                   TGo4Log::Error("FORMAT ERROR found tag %lld twice\n", vme_tags[ntag]);
00209                   pdata+=2; cur+=1;
00210                }
00211 
00212                find = true;
00213                break;
00214             }
00215 
00216          if (!find) pdata++;
00217       }
00218 
00219       if (lasttag>=0)
00220          taglen[lasttag] = pdata - tagpos[lasttag];
00221 
00222       // for (int ntag=0;ntag<numtags;ntag++)
00223       //    if (tagpos[ntag])
00224       //       printf("TAG %d POS %lu LEN %d\n", ntag, tagpos[ntag] - p0, taglen[ntag]);
00225 
00226 
00227       // if (GetTriggerNumber()==8) {
00228       //   fOutputEvent->SetValid(kFALSE);
00229       //   return;
00230       // }
00231 
00232 
00233       // actually process data in subroutines:
00234 
00235       if (tagpos[VME__ID_1182] && taglen[VME__ID_1182])
00236          Process1182(0, tagpos[VME__ID_1182], taglen[VME__ID_1182]);  // 1182
00237       if (tagpos[VME__ID_1183] && taglen[VME__ID_1183])
00238          Process1182(1, tagpos[VME__ID_1183], taglen[VME__ID_1183]);  // 1183
00239 
00240       for (int tdc=VME__ID_TDC1;tdc<=VME__ID_TDC8;tdc++)
00241          if (tagpos[tdc] && taglen[tdc])
00242             Process1290(tdc-VME__ID_TDC1, tagpos[tdc], taglen[tdc]);  // all TDCs
00243 
00244       for (int qdc=VME__ID_QDC1;qdc<=VME__ID_QDC2;qdc++)
00245          if (tagpos[qdc] && taglen[qdc])
00246             Process965(qdc-VME__ID_QDC1, tagpos[qdc], taglen[qdc]);  // all QDCs
00247 
00248       for (int fpga=VME__ID_FPGA1;fpga<=VME__ID_FPGA7;fpga++)
00249          if (tagpos[fpga] && taglen[fpga])
00250             ProcessVFTX(fpga-VME__ID_FPGA1, (uint32_t*) tagpos[fpga], taglen[fpga]);  // all FPGAs
00251 
00252       if (tagpos[VME__ID_QFW] && taglen[VME__ID_QFW])
00253          ProcessQFW((uint32_t*)tagpos[VME__ID_QFW], taglen[VME__ID_QFW]);  // QFW
00254 
00255       if (tagpos[VME__ID_SCOM] && taglen[VME__ID_SCOM])
00256          ProcessScalOrMu((uint32_t*)tagpos[VME__ID_SCOM], taglen[VME__ID_SCOM]);  // Scaler Or Multiplicity
00257 
00258       if( 1 < iCaenEnabled && 1 == fPar->uCaenCoincidenceMap)
00259          for (Int_t iCaentdc1 = 0; iCaentdc1 < MAX_1290; iCaentdc1++)
00260             if( 1 == fPar->uCaenTdcHistosEnabled[iCaentdc1] )
00261                for (Int_t iChannel1 = 0; iChannel1 < T1290Data::NumChan; iChannel1++)
00262                {
00263                   // Go back to index for VFTX internal map
00264                   iMapIndex = MAX_1290*(MAX_1290+1)/2
00265                            - (MAX_1290-iCaentdc1)*((MAX_1290-iCaentdc1)+1)/2;
00266 
00267                   if( MAX_1290*(MAX_1290+1)/2 < iMapIndex )
00268                   {
00269                      TGo4Log::Info("****Vftx monitor: Error filling mapping histos: index out of boundary : %d / %d (tdc #%d VS tdc #%d)",
00270                            iMapIndex, MAX_1290*(MAX_1290+1)/2, iCaentdc1, iCaentdc1);
00271                      return;
00272                   } // if( MAX_1290*(MAX_1290+1)/2 < iMapIndex )
00273 
00274                   //if( 0 < fOutputEvent->fMtdc[iCaentdc1].hit_lead[iChannel1] &&
00275                   //    0 < fOutputEvent->fMtdc[iCaentdc1].hit_trail[iChannel1] )
00276                   if( 0 < fOutputEvent->fMtdc[iCaentdc1].hit_lead[iChannel1] )
00277                   {
00278                      for (Int_t iChannel2 = iChannel1+1; iChannel2 < T1290Data::NumChan; iChannel2++)
00279                         //if( 0 < fOutputEvent->fMtdc[iCaentdc1].hit_lead[iChannel2] &&
00280                         //    0 < fOutputEvent->fMtdc[iCaentdc1].hit_trail[iChannel2])
00281                         if( 0 < fOutputEvent->fMtdc[iCaentdc1].hit_lead[iChannel2] )
00282                            /*
00283                            fAllTDC_chanMapL->Fill( iCaentdc1*T1290Data::NumChan + iChannel1,
00284                                                   iCaentdc1*T1290Data::NumChan + iChannel2);
00285                                                   */
00286                            fTDC_chanMapL[iMapIndex] ->Fill( iChannel1, iChannel2);
00287 
00288                      for (Int_t iCaentdc2 = iCaentdc1+1; iCaentdc2 < MAX_1290; iCaentdc2++)
00289                      {
00290                         // Find index for corresponding VFTX against VFTX map
00291                         iMapIndex = MAX_1290*(MAX_1290+1)/2
00292                                  - (MAX_1290-iCaentdc1)*((MAX_FPGA_TDC-iCaentdc1)+1)/2
00293                                  + (iCaentdc2 - iCaentdc1);
00294                         if( MAX_1290*(MAX_1290+1)/2 < iMapIndex )
00295                         {
00296                            TGo4Log::Info("****Vftx monitor: Error filling mapping histos: index out of boundary : %d / %d (tdc #%d VS tdc #%d)",
00297                                  iMapIndex, MAX_1290*(MAX_1290+1)/2, iCaentdc1, iCaentdc2);
00298                            return;
00299                         } // if( MAX_1290*(MAX_1290+1)/2 < iMapIndex )
00300 
00301                         if( 1 == fPar->uCaenTdcHistosEnabled[iCaentdc2] )
00302                            for (Int_t iChannel2 = 0; iChannel2 < T1290Data::NumChan; iChannel2++)
00303                               //if( 0 < fOutputEvent->fMtdc[iCaentdc2].hit_lead[iChannel2] &&
00304                               //    0 < fOutputEvent->fMtdc[iCaentdc2].hit_trail[iChannel2] )
00305                               if( 0 < fOutputEvent->fMtdc[iCaentdc2].hit_lead[iChannel2]  )
00306                               /*
00307                                  fAllTDC_chanMapL->Fill( iCaentdc1*T1290Data::NumChan + iChannel1,
00308                                                         iCaentdc2*T1290Data::NumChan + iChannel2);
00309                               */
00310                                  fTDC_chanMapL[iMapIndex] ->Fill( iChannel1, iChannel2);
00311                      } // for (Int_t iCaentdc2 = iCaentdc1+1; iCaentdc2 < MAX_1290; iCaentdc2++)
00312                   } // if( 0 < fOutputEvent->fMtdc[iCaentdc1].hit_lead[iChannel1] && same for trail )
00313                } // for (Int_t iChannel1 = 0; iChannel1 < T1290Data::NumChan; iChannel1++)
00314 
00315       fOutputEvent->SetValid(kTRUE);
00316    }
00317 }
00318 
00319 
00320 
00321 
00322 void TMbsCrateProc::Process1182(int num, int* pdata, int len)
00323 {
00324    if (len < 2 + NUM_1182_CH ) {
00325       cout <<"TBeamMonitorProc:Process1182 data length"<< len << "not sufficient!" <<endl;
00326       return;
00327    }
00328 
00329    if (num>=MAX_1182) {
00330       cout << "Wrong ID=" << num << " of 1182 module" << endl;
00331       return;
00332    }
00333 
00334    // skip event header:
00335    int header = *pdata++;
00336    if (L1182_DEBUG)  printf("1182 header:0x%0x \n",header);
00337 
00338    // skip status
00339    int status = *pdata++;
00340    if (L1182_DEBUG)
00341       printf("1182 status:0x%0x :  \n"
00342             "        conversion complete    (bit0): 0x%x\n"
00343             "        conversion in progress (bit1): 0x%x\n"
00344             "        front(1)/rear(0) panel (bit2): 0x%x\n"
00345             "        Event buffer not full  (bit3): 0x%x\n"
00346             "        Event count       (bits 4..7): 0x%x\n"
00347             "        should be 0            (bit8): 0x%x\n"
00348             "        should be 0            (bit9): 0x%x\n",
00349             status, status & 1, (status >> 1) & 1 , (status >> 2) & 1, (status >> 3) & 1,
00350             (status >> 4) & 0xf,  (status >> 8) & 1, (status >> 9) & 1);
00351 
00352    for(int ch=0;ch<NUM_1182_CH;++ch) {
00353       int val = *pdata++;
00354       
00355       if( 1 == fPar->uLecroyQdcHistosEnabled[num] )
00356          f1182h[num][ch]->Fill(val);
00357 
00358       fOutputEvent->fData1182[num][ch] = val; // output event to root tree
00359    }
00360 
00361    fOutputEvent->SetValid(kTRUE);
00362 }
00363 
00364 void TMbsCrateProc::Process1290(int num, int* pdata, unsigned int len)
00365 {
00366    if (num >= MAX_1290) {
00367       cout << "Wrong 1290 index " << num << endl;
00368       return;
00369    }
00370 
00371    int expected_geo = 0;
00372 
00373    if (num<0) {
00374       // if number is not specified, try to identify it base on GEO value
00375       expected_geo = T1290Data::FindGeo(pdata, len);
00376       if (expected_geo<=0) {
00377          printf("ERROR: Did not found GEO in the data\n");
00378          return;
00379       }
00380 
00381       switch (expected_geo) {
00382          case 5: num = 8; break;
00383          case 6: num = 9; break;
00384          case 7: num = 10; break;
00385          case 8: num = 11; break;
00386          case 9: num = 12; break;
00387          case 10: num = 13; break;
00388          case 11: num = 14; break;
00389          default:
00390             printf("Unsupported GEO code %d\n", expected_geo);
00391             return;
00392       }
00393 
00394       // printf("Found GEO code %d defined num %d\n", expected_geo, num);
00395 
00396    } else {
00397       switch(num) {
00398          case 0: expected_geo = 8; break;
00399          case 1: expected_geo = 9; break;
00400          case 2: expected_geo = 10; break;
00401          case 3: expected_geo = 11; break;
00402          case 4: expected_geo = 12; break;
00403          case 5: expected_geo = 13; break;
00404          case 6: expected_geo = 14; break;
00405          case 7: expected_geo = 15; break;
00406        }
00407    }
00408    // printf("Process1290 num = %d expected GEO = %d len = %u\n", num, expected_geo, len);
00409 
00410    fOutputEvent->fMtdc[num].Unpack(pdata, len, expected_geo);
00411 
00412    if( 1 == fPar->uCaenTdcHistosEnabled[num] )
00413    {
00414       if( kTRUE == fPar->bCaenDebug || kTRUE == fPar->bCaenTriggerTime )
00415          fTDC[num].FillHistos(fOutputEvent->fMtdc[num], fPar->bCaenDebug, fPar->bCaenTriggerTime);
00416       else
00417       {
00418          fTDC[num].FillHistos(fOutputEvent->fMtdc[num]);
00419          if( CAEN1290_DEBUG )
00420             fTDC[num].FillDebugHistos(fOutputEvent->fMtdc[num]);
00421       }
00422    }
00423 
00424    fOutputEvent->SetValid(kTRUE);
00425 }
00426 
00427 void TMbsCrateProc::Process965(int num, int* pdata, unsigned int len)
00428 {
00429         int geo, crate, count;
00430         Int_t timeOffset;
00431         int data;
00432         
00433         if (num >= MAX_965) {
00434                 cout << "Wrong 965 index " << num << endl;
00435                 return;
00436         }
00437         geo = 0;
00438         timeOffset = 0;
00439         data = *pdata++;
00440         len--;
00441         count = 0;
00442         if (num<0) {
00443                 // if number is not specified, try to identify it base on GEO value
00444                 geo = MQDC_t::FindGeo(pdata, &count, &crate);
00445                 if (geo<=0) {
00446                         printf("ERROR: Did not found GEO in the data\n");
00447                         return;
00448                 }
00449                 switch (geo) {
00450                         case 0: num = 0; break;
00451                         case 1: num = 1; break;
00452                         case 2: num = 2; break;
00453                         default:
00454                                 printf("Unsupported GEO code %d\n", geo);
00455                                 return;
00456                 }
00457         }
00458         else
00459         {
00460                 if(((data>>24) & 0x7) == 0x2)
00461                 {
00462                         count = (data >> 8) & 0x3f;
00463                 }
00464                 switch(num) {
00465                         case 0: geo = 0; break;
00466                         case 1: geo = 1; break;
00467                         case 2: geo = 2; break;
00468                 }
00469         }
00470         fOutputEvent->fMqdc[num].Unpack(pdata, count, geo);
00471         
00472    if( 1 == fPar->uCaenQdcHistosEnabled[num] )
00473       for (int ch=0; ch<MQDC_t::NumChan; ch++) {
00474          if(fOutputEvent->fMqdc[num].charge[ch]>0)
00475             fQdc_Charge[num][ch]->Fill(fOutputEvent->fMqdc[num].charge[ch]);
00476        }
00477         
00478         fOutputEvent->SetValid(kTRUE);
00479 }
00480 
00481 void TMbsCrateProc::ProcessVFTX(int num, uint32_t* pdata, unsigned int len)
00482 {
00483    if ((num<0) || (num>=MAX_FPGA_TDC)) 
00484    {
00485       TGo4Log::Error("Error VFTX number %d out of bound (max %d) ", num, MAX_FPGA_TDC);
00486       return;
00487    }
00488 
00489    uint32_t l_dat = *pdata++; // module header
00490    if ( (l_dat & TDC_EVT_HEADER_KEY_MASK)>>TDC_EVT_HEADER_KEY_SHIFT != TDC_EVT_HEADER_KEYWORD ) 
00491    {
00492       TGo4Log::Warn("this is not a vftx %d header, jumping this sub-event...", num);
00493       //return;
00494    }
00495    FPGA_TDC_header header;
00496    uint32_t l_nr_cha   = (l_dat & TDC_EVT_HEADER_NB_MASK);
00497    header.nr_data = l_nr_cha;
00498    header.mod_nr = ((l_dat & TDC_EVT_HEADER_MOD_MASK) >> TDC_EVT_HEADER_MOD_SHIFT); 
00499    if (l_nr_cha+2 != len && l_nr_cha+2 + 256 != len)
00500    {
00501      TGo4Log::Warn("wrong length in vftx %d header, jumping this sub-event... %d vs %d", num, l_nr_cha+2, len);
00502      // Return commented: MBS vftxlib.c for gsi aug 12 not compatible with too many data in event: 
00503      // only 8 bit where used to code event size => effective limitation to 256 hits then loop
00504       //return;
00505    }
00506    
00507    l_dat = *pdata++;  // vulom tdc fifo header
00508    if (l_dat & TDC_FIFO_MESSAGE_TYPE) 
00509    {
00510       header.fpga_fifo_tt = (l_dat & TDC_FIFO_HEADER_TRIG_TYPE) >> TDC_FIFO_HEADER_TRIG_TYPE_SHIFT;
00511       header.fpga_fifo_ct = (l_dat & TDC_FIFO_HEADER_TRIG_TIME) >> TDC_FIFO_HEADER_TRIG_TIME_SHIFT;
00512       header.fpga_fifo_nd = (l_dat & TDC_FIFO_HEADER_DATA_CNT);
00513    } // if (l_dat & TDC_FIFO_MESSAGE_TYPE) 
00514    else 
00515    {
00516       TGo4Log::Warn("vftx %d fifo header missing... ", num);
00517    }
00518    
00519       
00520    // cout << "mod: " << num << " ct: " << header.fpga_fifo_ct << endl;
00521    fOutputEvent->fFPGAHEAD[num].push_back(header);
00522    // cout << "TDC" << num << " , data items: " << header.nr_data << endl;
00523    // cout << "trigger ct: " << header.fpga_fifo_ct << "data nb: " << header.fpga_fifo_nd << endl;
00524    while (l_nr_cha-- > 0) 
00525    {
00526       uint32_t l_da0 = *pdata++;
00527 
00528       FPGA_TDC_hit hit;
00529       if ((l_da0 & TDC_FIFO_MESSAGE_TYPE) == TDC_FIFO_MESSAGE_TYPE) 
00530       {
00531          TGo4Log::Warn("wrong data item in vftx %d: type %d (message %08x, header %08x), jumping this sub-event...", 
00532                        num, (l_da0 & TDC_FIFO_MESSAGE_TYPE)>>TDC_FIFO_MESSAGE_TYPE_SHIFT, l_da0, l_dat);
00533          TGo4Log::Warn("Message: tt %01u ct %5u nd %3u", 
00534                       (l_da0 & TDC_FIFO_HEADER_TRIG_TYPE) >> TDC_FIFO_HEADER_TRIG_TYPE_SHIFT,
00535                       (l_da0 & TDC_FIFO_HEADER_TRIG_TIME) >> TDC_FIFO_HEADER_TRIG_TIME_SHIFT,
00536                       (l_da0 & TDC_FIFO_HEADER_DATA_CNT) );
00537          TGo4Log::Warn("Header : tt %01u ct %5u nd %3u", 
00538                       (l_dat & TDC_FIFO_HEADER_TRIG_TYPE) >> TDC_FIFO_HEADER_TRIG_TYPE_SHIFT,
00539                       (l_dat & TDC_FIFO_HEADER_TRIG_TIME) >> TDC_FIFO_HEADER_TRIG_TIME_SHIFT,
00540                       (l_dat & TDC_FIFO_HEADER_DATA_CNT) );
00541          return;
00542       }
00543       hit.ch_ix        = (l_da0 & TDC_FIFO_DATA_CHAN) >> TDC_FIFO_DATA_CHAN_SHIFT; //4-5 bit
00544       if (hit.ch_ix > FPGA_TDC_NBCHAN - 1)
00545          TGo4Log::Warn("channel number larger then %d found in vftx %d", FPGA_TDC_NBCHAN -1, num);
00546          
00547       hit.future_bit   = (l_da0 & TDC_FIFO_FUTURE_BIT) >> TDC_FIFO_FUTURE_BIT_SHIFT;  //  1 bit
00548       hit.coarse_ct    = (l_da0 & TDC_FIFO_COARSE_CT) >> TDC_FIFO_COARSE_CT_SHIFT;   // 15 bit
00549       hit.ch_tim       = (l_da0 & TDC_FIFO_FINE_CT);        // 10 bit, 11th bit empty
00550 
00551       // cout << "data: "<< l_nr_cha << " ch: " << hit.ch_ix << " ct: " << hit.coarse_ct;
00552       // cout << " ft: " << hit.ch_tim << " fut: " << hit.future_bit << endl;
00553       fOutputEvent->fFPGA[num].push_back(hit);
00554       
00555       if( 1 == fPar->uVftxHistosEnabled[num] )
00556          if (hit.ch_ix<FPGA_TDC_NBCHAN)
00557             fFPGA_Ch[num][hit.ch_ix]->Fill(hit.ch_tim);
00558     } // while (l_nr_cha-- > 0) 
00559     
00560     //cout<<" FPGA TDC num "<<num<<" finished"<<endl;
00561    fOutputEvent->SetValid(kTRUE);
00562 }
00563 
00564 void TMbsCrateProc::ProcessQFW(uint32_t* pdata, unsigned int len)
00565 {
00566    if (len!=9) {
00567       TGo4Log::Error("Wrong QFW format");
00568       return;
00569    }
00570 
00571    for (int n=0;n<4;n++) {
00572       fOutputEvent->fQFW.counters[n] = *pdata++;
00573       if( 1 == fPar->uQFWHistosEnabled )
00574          fQFWcnt->SetBinContent(n+1, fOutputEvent->fQFW.counters[n]);
00575    }
00576 
00577    TString txt = "#splitline";
00578 
00579    for (int n=0;n<4;n++) {
00580       fOutputEvent->fQFW.errcnt[n] = *pdata++;
00581       if( 1 == fPar->uQFWHistosEnabled )
00582          fQFWerr->SetBinContent(n+1, fOutputEvent->fQFW.errcnt[n]);
00583 
00584       txt+=Form("{#scale[2.0]{#color[2]{Ch%d cnt:%10u err:%10u}}}", n, fOutputEvent->fQFW.counters[n], fOutputEvent->fQFW.errcnt[n]);
00585    }
00586 
00587    fOutputEvent->fQFW.setup = *pdata;
00588 
00589    txt+=Form("{#scale[2.0]{#color[2]{Setup: %d}}}", fOutputEvent->fQFW.setup);
00590 
00591    if( 1 == fPar->uQFWHistosEnabled )
00592       fQFWInfo->SetText(0.2, 0.5, txt.Data());
00593 
00594    fOutputEvent->SetValid(kTRUE);
00595 }
00596 
00597 void TMbsCrateProc::ProcessScalOrMu(uint32_t* pdata, unsigned int len)
00598 {
00599    if (len != SCALORMU_NB_SCAL) {
00600       TGo4Log::Error("Wrong Scaler Or Multiplicity sub-event length: %u instead of %d",
00601             len, SCALORMU_NB_SCAL);
00602       return;
00603    }
00604    if( 1 == fPar->uDebug )
00605       TGo4Log::Info("Scaler Or Multiplicity sub-event found!");
00606    for( Int_t iScalerInd=0; iScalerInd < SCALORMU_NB_SCAL; iScalerInd++)
00607       fOutputEvent->fScalOrMu.uScaler[iScalerInd] = (UInt_t)*pdata++;
00608 }
00609 

Generated on Tue Dec 10 2013 04:52:18 for ROCsoft by  doxygen 1.7.1