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