diff --git a/doc/dtc_gui.org b/doc/dtc_gui.org new file mode 100644 index 0000000..3e1d72a --- /dev/null +++ b/doc/dtc_gui.org @@ -0,0 +1,72 @@ +#+startup:fold -*- buffer-read-only: t -*- +* ------------------------------------------------------------------------------ +* DTC GUI interface: [[file:../otsdaq-mu2e-tracker/Gui/DtcGui.hh]] +* initialization +#+begin_src +.L dtc_gui.C +auto x = dtc_gui(config_name) +#+end_src +parameters: + - config_name: points to the configuration file. It is either a directory name or a file name, see below. + - locating configuration file: + - it is assumed that config_name is a located under [[file:../config][otsdaq-mu2e-tracker/config]] + - if a file='otsdaq-mu2e-tracker/config/config_name.C' exists, the configuration is taken from there + - if a directory='config/config_name' exists, the configuration is taken from config/config_name/ +* CFO panel +** status : prints the CFO status +** writeR : writes to the CFO register +** readR : reads from the CFO register +** soft reset : soft reset of the CFO +** hard reset : hard reset of the CFO +** launch : launch external CFO run plan +** EnableBmOff : enable 'Beam Off' mode - (start the run) +** DisableBmOff : disable 'Beam Off' mode - (stop the run) +- assume that the Bean On mode is disabled +- then, + + restarts executaion of the current run plan +** Extrnl CT - - obsolete +- a run plan can be started just once, no need to have a thread for that +** DTC mask : defines the number of DTCs in each time chain +- CFO supports 8 time chains +- each hex digit of the DTC mask contains the number of DTC's in the corresponding time chain: +#+begin_src + ndtcs[i] = (DtcMask >> 4*i) & 0xf +#end_src +** init readout : reads the run plan and initializes the CFO +- that includes setting the DTC mask +- currently, it is assumed that the run plans are located in $HOME/test_stand/cfo_run_plans directory +- the directory name will be soon moved to .rootrc +* DTC panel +** status : print the DTC status (several registers) +** writeR : write the DTC register +** readR : read the DTC register +** soft reset : soft reset of the DTC +** hard reset : hard reset of the DTC +** FF temp : prints the DTC firefly temperatures +** ROC pattrn : obsolete, replaced by InitReadout +** InitReadout : initializes the DTC for a given readout mode +- the DTC readout mode is defined by the CFO mode and the ROC readout mode +- DTC may be run in a so-called 'CFO emulation mode', in which no external CFO + is needed +** EmulateCFO : set to one if the DTC is running in a CFO emulation mode +** ROC readout mode: + - 0: ROC emulated patterns + - 1: digis + - 2: do we need more , i.e. digi patterns ? +** ROC tabs : each DTC panel has 6 ROC tabs +*** status : print ROC status +*** write : write ROC register +*** read : read ROC register +*** reset : reset the ROC (write 1 to register 14) +* general panel +** clear : clear the outptu window +** exit : exit +** NEvents : N(events) per run in the CFO emulation mode +** EWLength : event window length in units of 25 ns +- EWLength=80 defines an event window length of 2000 ns +** FirstTS : first event window tag in a run for teh CFO emulation mode +** SleepUS : sleep time, in us, after a single run has been taken +in a CFO emulation mode +- used by file:../otsdaq-mu2e-tracker/EmuCfoThread +* ------------------------------------------------------------------------------ +* back to [[file:otsdaq_mu2e_tracker.org]] +* ------------------------------------------------------------------------------ diff --git a/doc/otsdaq_mu2e_tracker.org b/doc/otsdaq_mu2e_tracker.org index 46a68ec..07e2ce5 100644 --- a/doc/otsdaq_mu2e_tracker.org +++ b/doc/otsdaq_mu2e_tracker.org @@ -134,7 +134,7 @@ root [2] .q #+end_src ** after that can proceed * ------------------------------------------------------------------------------ -* [[file:root_interface.org][ROOT interface]] +* [[file:root_interface.org][ROOT interface]] * [[file:tracker_roc_registers.org][tracker ROC registers]] * tracker VST configurations - all described in tfm/config @@ -162,6 +162,7 @@ Also, I claim that no power cycles are needed now after a DTC_Reset. And that no TIMEOUT should be observed on the very first event after a DTC_Reset. * [[file:control_roc.org][control_ROC.py and its commands]] +* [[file:./dtc_gui.org][DtcGui interface]] * slow control of DTCs ** DTC_0 FPGA: 4 parameters -- 0x9010 : temperature @@ -465,7 +466,7 @@ readDeviceID ('DRAC ROC ID #', '7a7fb') ** [[file:roc_id_1b561.org][ROC ID 1b561]] : <2024-05-09 Thu> installed at TS1 ** [[file:roc_id_805d6.org][ROC ID 805d6]] : <2024-02-25 Sun> installed at TS2 -* test stands TS0, TS1, TS2 +* test stands TS0, TS1, TS2 ** last update <2024-07-15 Mon> ** powering up the test stands (Vadim): https://docs.google.com/document/d/1theA9NIRA5XeUUPVuFGVhU7NddPljgaGznR9aMu-Fv8/edit?usp=sharing diff --git a/doc/tracker_roc_registers.org b/doc/tracker_roc_registers.org index e8e3c7c..cae1878 100644 --- a/doc/tracker_roc_registers.org +++ b/doc/tracker_roc_registers.org @@ -1,4 +1,4 @@ -#+startup:unfold +#+startup:unfold -*- buffer-read-only: t -*- * -------------------------------------------------------------------------------------- * TODO Tracker ROC registers @@ -22,7 +22,7 @@ | 13 | Num skipped DATA REQ | | | 14 | reset, write 1 to this register to reset the ROC | | | 16 | unused | | -| 18 | unused | | +| 18 | unused ??? | | |----------+--------------------------------------------------------------------+------| | 23 | r24<<16+r23 : SIZE_FIFO_FULL [28]+STORE_POS[25:24]+STORE_CNT[19:0] | | | 24 | | | diff --git a/otsdaq-mu2e-tracker/Gui/DtcGui.hh b/otsdaq-mu2e-tracker/Gui/DtcGui.hh index f471e58..daeb83d 100644 --- a/otsdaq-mu2e-tracker/Gui/DtcGui.hh +++ b/otsdaq-mu2e-tracker/Gui/DtcGui.hh @@ -1,3 +1,4 @@ +// -*- buffer-read-only: t -*- // Mainframe macro generated from application: root.exe // By ROOT version 6.18/04 on 2020-05-11 18:09:54 @@ -231,8 +232,7 @@ public: TString fIStage; TString fTime; - int fNDtcs; // on a machine - int fNTimeChainedDtcs; // N(DTCs) in a time chain + int fNDtcs; // on a machine DtcTabElement_t fDtcTel[2]; @@ -247,14 +247,14 @@ public: TGNumberEntry* fNEvents; // DTC , CFO emulation TGNumberEntry* fEWLength; // DTC , CFO emulation TGNumberEntry* fFirstTS; // DTC , CFO emulation - TGNumberEntry* fSleepMS; // DTC , CFO emulation, + TGNumberEntry* fSleepUS; // DTC , CFO emulation, microseconds TGNumberEntry* fPrintFreq; // DTC , CFO emulation, used by the DTC reading thread int fCfoPrintFreq; int fValidate; - Pixel_t fGreen; // completed stage tab tip - Pixel_t fYellow; // active tab tip + Pixel_t fGreen; // completed stage tab tip + Pixel_t fYellow; // active tab tip Pixel_t fDtcTabColor; // non-active tab tip Pixel_t fSubmittedColor; Pixel_t fValidatedColor; @@ -266,11 +266,11 @@ public: // threads //----------------------------------------------------------------------------- struct ThreadContext_t { - TThread* fTp; // thread pointer + TThread* fTp; // thread pointer DtcTabElement_t* fDtel; - int fRunning; // 0: stopped 1:running - int fStop; // end marker - int fCmd; // command + int fRunning; // 0: stopped 1:running + int fStop; // end marker + int fCmd; // command int fPrintLevel; int fPause; int fSleepTimeMs; @@ -327,6 +327,7 @@ public: void dtc_launch_run_plan_emulated_cfo(DtcTabElement_t* Dtel, TGTextViewostream* TextView); void dtc_print_firefly_temp (DtcTabElement_t* Dtel, TGTextViewostream* TextView); + void dtc_print_all_rocs (DtcTabElement_t* Dtel, TGTextViewostream* TextView); void print_dtc_status (); void print_roc_status (); diff --git a/otsdaq-mu2e-tracker/Gui/DtcGui_commands.cc b/otsdaq-mu2e-tracker/Gui/DtcGui_commands.cc index fd0a4a8..341e1e0 100644 --- a/otsdaq-mu2e-tracker/Gui/DtcGui_commands.cc +++ b/otsdaq-mu2e-tracker/Gui/DtcGui_commands.cc @@ -161,6 +161,7 @@ void DtcGui::cfo_hard_reset(DtcTabElement_t* Dtel, TGTextViewostream* TextView) //----------------------------------------------------------------------------- void DtcGui::clear_output() { fTextView->Clear(); + fTextView->ShowBottom(); } //----------------------------------------------------------------------------- @@ -194,6 +195,12 @@ void DtcGui::dtc_print_firefly_temp(DtcTabElement_t* Dtel, TGTextViewostream* Te catch (...) { *fTextView << Form("ERROR, BAIL OUT") << std::endl; } } +//----------------------------------------------------------------------------- +void DtcGui::dtc_print_all_rocs(DtcTabElement_t* Dtel, TGTextViewostream* TextView) { + try { Dtel->fDTC_i->PrintRocStatus(1,-1); } + catch (...) { *fTextView << Form("ERROR, BAIL OUT") << std::endl; } +} + //----------------------------------------------------------------------------- void DtcGui::print_roc_status() { // TString cmd; @@ -208,14 +215,11 @@ void DtcGui::print_roc_status() { TDatime x1; *fTextView << x1.AsSQLString() << "DtcGui:: : " << __func__ << ": START" << std::endl; - //----------------------------------------------------------------------------- // CFO doesn't have ROC's //----------------------------------------------------------------------------- - if (dtel->fData->fName == "DTC") { - try { dtel->fDTC_i->PrintRocStatus(roc); } - catch (...) { *fTextView << Form("ERROR : coudn't read ROC %i ... BAIL OUT",roc) << std::endl; } - } + try { dtel->fDTC_i->PrintRocStatus(1,1<<4*roc); } + catch (...) { *fTextView << Form("ERROR : coudn't read ROC %i ... BAIL OUT",roc) << std::endl; } TDatime x2; *fTextView << x2.AsSQLString() << strCout.str() << " DtcGui::" << __func__ @@ -238,7 +242,6 @@ void DtcGui::dtc_init_readout(DtcTabElement_t* Dtel, TGTextViewostream* TextView } catch (...) { *TextView << Form("ERROR in DtcGui::%s: failed to execute DtcInterface::InitReadout\n",__func__); } } - } //----------------------------------------------------------------------------- @@ -700,7 +703,7 @@ int DtcGui::execute_command() { TGButton* btn = (TGButton*) gTQSender; - TString* cmd = (TString*) btn->GetUserData(); + // TString* cmd = (TString*) btn->GetUserData(); DtcTabElement_t* dtel = fDtcTel+fActiveDtcID; // int roc = dtel->fActiveRocID; diff --git a/otsdaq-mu2e-tracker/Gui/DtcGui_gui.cc b/otsdaq-mu2e-tracker/Gui/DtcGui_gui.cc index 62d93bd..d0ab186 100644 --- a/otsdaq-mu2e-tracker/Gui/DtcGui_gui.cc +++ b/otsdaq-mu2e-tracker/Gui/DtcGui_gui.cc @@ -204,18 +204,18 @@ void DtcGui::BuildGui(const TGWindow *Parent, UInt_t Width, UInt_t Height) { tb->Connect("Pressed()", "DtcGui", this, "exit()"); tb->ChangeBackground(fValidatedColor); //----------------------------------------------------------------------------- -// 3. launch +// 3. ... //----------------------------------------------------------------------------- int x3offset = 10+button_sx*2; - tb = new TGTextButton(fButtonsFrame,"launch",-1,TGTextButton::GetDefaultGC()(), - TGTextButton::GetDefaultFontStruct(),kRaisedFrame); - tb->SetTextJustify(36); - tb->SetMargins(0,0,0,0); - tb->SetWrapLength(-1); - tb->MoveResize(x3offset,y0,button_dx,button_dy); - fButtonsFrame->AddFrame(tb, new TGLayoutHints(kLHintsLeft | kLHintsTop,2,2,2,2)); - tb->Connect("Pressed()", "DtcGui", this, "cfo_launch_run_plan()"); - tb->ChangeBackground(fValidatedColor); +// tb = new TGTextButton(fButtonsFrame,"launch",-1,TGTextButton::GetDefaultGC()(), +// TGTextButton::GetDefaultFontStruct(),kRaisedFrame); +// tb->SetTextJustify(36); +// tb->SetMargins(0,0,0,0); +// tb->SetWrapLength(-1); +// tb->MoveResize(x3offset,y0,button_dx,button_dy); +// fButtonsFrame->AddFrame(tb, new TGLayoutHints(kLHintsLeft | kLHintsTop,2,2,2,2)); +// tb->Connect("Pressed()", "DtcGui", this, "cfo_launch_run_plan()"); +// tb->ChangeBackground(fValidatedColor); //----------------------------------------------------------------------------- // 4 "NEvents" label followed by the entry field //----------------------------------------------------------------------------- @@ -281,23 +281,23 @@ void DtcGui::BuildGui(const TGWindow *Parent, UInt_t Width, UInt_t Height) { fButtonsFrame->AddFrame(fFirstTS, new TGLayoutHints(kLHintsLeft | kLHintsTop,2,2,2,2)); //----------------------------------------------------------------------------- -// 7: "SleepMS" label followed by the entry field +// 7: "SleepUS" label followed by the entry field //----------------------------------------------------------------------------- - lab = new TGLabel(fButtonsFrame,"Sleep MS"); + lab = new TGLabel(fButtonsFrame,"Sleep US"); fButtonsFrame->AddFrame(lab, new TGLayoutHints(kLHintsLeft | kLHintsTop,2,2,2,2)); lab->SetTextJustify(36); lab->SetMargins(0,0,0,0); lab->SetWrapLength(-1); - fSleepMS = new TGNumberEntry(fButtonsFrame, 2000, 9,999, + fSleepUS = new TGNumberEntry(fButtonsFrame, 2000000, 9,999, TGNumberFormat::kNESInteger, TGNumberFormat::kNEANonNegative, TGNumberFormat::kNELLimitMinMax, - 0, 100000); - fSleepMS->Connect("ValueSet(Long_t)", "MyMainFrame", this, "DoSetlabel()"); - (fSleepMS->GetNumberEntry())->Connect("ReturnPressed()","MyMainFrame", this,"DoSetlabel()"); + 0, 100000000); + fSleepUS->Connect("ValueSet(Long_t)", "MyMainFrame", this, "DoSetlabel()"); + (fSleepUS->GetNumberEntry())->Connect("ReturnPressed()","MyMainFrame", this,"DoSetlabel()"); - fButtonsFrame->AddFrame(fSleepMS, new TGLayoutHints(kLHintsLeft | kLHintsTop,2,2,2,2)); + fButtonsFrame->AddFrame(fSleepUS, new TGLayoutHints(kLHintsLeft | kLHintsTop,2,2,2,2)); //----------------------------------------------------------------------------- // 8: "ReadPrintFreq" label followed by the entry field //----------------------------------------------------------------------------- diff --git a/otsdaq-mu2e-tracker/Gui/DtcGui_gui_DtcTab.cc b/otsdaq-mu2e-tracker/Gui/DtcGui_gui_DtcTab.cc index 373f655..f149f59 100644 --- a/otsdaq-mu2e-tracker/Gui/DtcGui_gui_DtcTab.cc +++ b/otsdaq-mu2e-tracker/Gui/DtcGui_gui_DtcTab.cc @@ -208,7 +208,7 @@ void DtcGui::BuildDtcTabElement(TGTab*& Tab, DtcTabElement_t& DtcTel, DtcData_t* //----------------------------------------------------------------------------- // column 2 raw 6 : ROC patterns - OBSOLETE //----------------------------------------------------------------------------- - tb = new TGTextButton(group,"ROC pattrn",-1,TGTextButton::GetDefaultGC()(), + tb = new TGTextButton(group,"ROC status",-1,TGTextButton::GetDefaultGC()(), TGTextButton::GetDefaultFontStruct(),kRaisedFrame); group->AddFrame(tb, new TGLayoutHints(kLHintsLeft | kLHintsTop,2,2,2,2)); @@ -217,9 +217,9 @@ void DtcGui::BuildDtcTabElement(TGTab*& Tab, DtcTabElement_t& DtcTel, DtcData_t* tb->SetWrapLength(-1); tb->MoveResize(x0+dx+10,y0+(dy+5)*4,dx2,dy); - tb->Connect("Pressed()", "DtcGui", this, "configure_roc_pattern_mode()"); - tb->ChangeBackground(fValidatedColor); - tb->SetUserData(nullptr); + tb->Connect("Pressed()", "DtcGui", this, "execute_command()"); + // tb->ChangeBackground(fValidatedColor); + tb->SetUserData((void*) &DtcGui::dtc_print_all_rocs); //----------------------------------------------------------------------------- // column 3 row 1: write value: 1. label , 2: entry field 3: label //----------------------------------------------------------------------------- @@ -265,7 +265,7 @@ void DtcGui::BuildDtcTabElement(TGTab*& Tab, DtcTabElement_t& DtcTel, DtcData_t* tb->MoveResize(x0+dx+10+dx2+10,y0+(dy+5)*3,dx3,dy); tb->Connect("Pressed()", "DtcGui", this, "manage_read_thread()"); - // tb->ChangeBackground(fValidatedColor); // not yet + tb->ChangeBackground(fValidatedColor); // not yet tb->SetUserData(nullptr); //----------------------------------------------------------------------------- // column 3 row 5: Start CT - manage_emu_cfo_thread @@ -280,7 +280,7 @@ void DtcGui::BuildDtcTabElement(TGTab*& Tab, DtcTabElement_t& DtcTel, DtcData_t* tb->MoveResize(x0+dx+10+dx2+10,y0+(dy+5)*4,dx3,dy); tb->Connect("Pressed()", "DtcGui", this, "manage_emu_cfo_thread()"); - // tb->ChangeBackground(fValidatedColor); // not yet + tb->ChangeBackground(fValidatedColor); // not yet tb->SetUserData(nullptr); //----------------------------------------------------------------------------- // column 4 row 1: initReadout diff --git a/otsdaq-mu2e-tracker/Gui/DtcGui_threads.cc b/otsdaq-mu2e-tracker/Gui/DtcGui_threads.cc index f85ae3e..516eb17 100644 --- a/otsdaq-mu2e-tracker/Gui/DtcGui_threads.cc +++ b/otsdaq-mu2e-tracker/Gui/DtcGui_threads.cc @@ -22,9 +22,10 @@ void* DtcGui::ReaderThread(void* Context) { std::vector> list_of_dtc_blocks; - int match_ts(0); - ulong offset (0); // used in validation mode - int nerr_tot(0); + int match_ts (0); + ulong offset (0); // used in validation mode + int nerr_tot (0); + ulong nbytes_tot(0); DtcGui* dtc_gui = (DtcGui*) Context; ThreadContext_t* tc = &dtc_gui->fReaderTC; @@ -41,13 +42,15 @@ void* DtcGui::ReaderThread(void* Context) { //----------------------------------------------------------------------------- ulong ew_tag = dtc_gui->fFirstTS->GetNumberEntry()->GetIntNumber(); + if (tc->fPrintLevel > 0) { + // print header + cout << Form(" CPU T Real T event DTC EW Tag nbytes nbytes_tot ------------- ROC status ---------------- nerr nerr_tot\n"); + cout << Form("-------------------------------------------------------------------------------------------------------------------------\n"); + } + TStopwatch timer; timer.Start(); - // dtc->SoftReset(); - // dtc_i->InitRocReadoutMode(); - // dtc->ReleaseAllBuffers(DTC_DMA_Engine_DAQ); - while (tc->fStop == 0) { if (tc->fPause != 0) { TLOG(TLVL_INFO+1) << "thread alive, sleep for " << tc->fSleepTimeMs << "ms" << std::endl; @@ -70,9 +73,10 @@ void* DtcGui::ReaderThread(void* Context) { for (int i=0; iGetSubEventByteCount(); + int nbytes = dtc_block->GetSubEventByteCount(); ew_tag = dtc_block->GetEventWindowTag().GetEventWindowTag(true); char* data = (char*) dtc_block->GetRawBufferPointer(); + nbytes_tot += nbytes; int nerr(0); @@ -95,9 +99,9 @@ void* DtcGui::ReaderThread(void* Context) { float ct = timer.CpuTime(); float rt = timer.RealTime(); timer.Continue(); - cout << Form(">>> time: %9.2f %9.2f ts:%10lu DTC:%2i EWTag:%10lu nbytes: %4i ROC status: 0x%04x 0x%04x 0x%04x 0x%04x 0x%04x 0x%04x", - ct,rt,tstamp,i,ew_tag,nb,rs[0],rs[1],rs[2],rs[3],rs[4],rs[5]) - << Form(" nerr:%3i nerr_tot:%5i\n",nerr,nerr_tot); + cout << Form("%8.2f %8.2f %10lu %1i %10lu %4i %12li",ct,rt,tstamp,i,ew_tag,nbytes,nbytes_tot) + << Form(" 0x%04x 0x%04x 0x%04x 0x%04x 0x%04x 0x%04x",rs[0],rs[1],rs[2],rs[3],rs[4],rs[5]) + << Form(" %3i %5i\n",nerr,nerr_tot); if (tc->fPrintLevel > 10) { dtc_i->PrintBuffer(dtc_block->GetRawBufferPointer(),dtc_block->GetSubEventByteCount()/2); } @@ -108,9 +112,9 @@ void* DtcGui::ReaderThread(void* Context) { float ct = timer.CpuTime(); float rt = timer.RealTime(); timer.Continue(); - cout << Form(">>> time: %9.2f %9.2f ts:%10lu DTC:%2i EWTag:%10lu nbytes: %4i ROC status: 0x%04x 0x%04x 0x%04x 0x%04x 0x%04x 0x%04x", - ct,rt,tstamp,i,ew_tag,nb,rs[0],rs[1],rs[2],rs[3],rs[4],rs[5]) - << Form(" nerr:%3i nerr_tot:%5i\n",nerr,nerr_tot); + cout << Form("%8.2f %8.2f %10lu %1i %10lu %4i %12li",ct,rt,tstamp,i,ew_tag,nbytes,nbytes_tot) + << Form(" 0x%04x 0x%04x 0x%04x 0x%04x 0x%04x 0x%04x",rs[0],rs[1],rs[2],rs[3],rs[4],rs[5]) + << Form(" %3i %5i\n",nerr,nerr_tot); } } } @@ -158,29 +162,30 @@ void* DtcGui::EmuCfoThread(void* Context) { int ew_length = dtc_gui->fEWLength->GetIntNumber(); ulong nevents = dtc_gui->fNEvents->GetIntNumber(); ulong first_ts = dtc_gui->fFirstTS->GetIntNumber(); - int sleep_ms = dtc_gui->fSleepMS->GetIntNumber(); + int sleep_us = dtc_gui->fSleepUS->GetIntNumber(); - TLOG(TLVL_INFO) << Form("%s: START ew_length: %5i nevents: %10lu first_tx:%10lu sleep_ms:%5i\n", - __func__,ew_length,nevents,first_ts,sleep_ms); + TLOG(TLVL_DEBUG) << Form("%s: START ew_length: %5i nevents: %10lu first_tx:%10lu sleep_us:%8i\n", + __func__,ew_length,nevents,first_ts,sleep_us); int t0 = first_ts/dtc_gui->fCfoPrintFreq; dtc_i->InitReadout(); while (tc->fStop == 0) { - gSystem->Sleep(sleep_ms); + // gSystem->Sleep(sleep_us); + usleep(sleep_us); dtc_i->LaunchRunPlanEmulatedCfo(ew_length,nevents+1,first_ts); first_ts = first_ts+nevents; int t1 = first_ts/dtc_gui->fCfoPrintFreq; if (t1 > t0) { - printf("%s: first_ts: %10lu\n",__func__,first_ts); + TLOG(TLVL_DEBUG) << Form("first_ts: %10lu",first_ts); t0 = t1; } } - TLOG(TLVL_INFO) << "END" << std::endl; + TLOG(TLVL_DEBUG) << "END" << std::endl; return nullptr; } diff --git a/otsdaq-mu2e-tracker/Ui/DtcInterface.cc b/otsdaq-mu2e-tracker/Ui/DtcInterface.cc index 1431572..74c5199 100644 --- a/otsdaq-mu2e-tracker/Ui/DtcInterface.cc +++ b/otsdaq-mu2e-tracker/Ui/DtcInterface.cc @@ -130,201 +130,178 @@ namespace trkdaq { } //----------------------------------------------------------------------------- - void DtcInterface::PrintRocStatus(int Link) { - cout << Form("-------------------- ROC %i registers:\n",Link); - - DTC* dtc = fDtc; - - DTC_Link_ID link = DTC_Link_ID(Link); - uint32_t dat; - - uint reg = 0; - dat = dtc->ReadROCRegister(link,reg,100); - cout << Form("reg(%2i) : 0x%04x : ALWAYS\n",reg, dat); - - reg = 8; - dat = dtc->ReadROCRegister(link,reg,100); - cout << Form("reg(%2i) : 0x%04x : ROC pattern mode ?? \n",reg, dat); - - reg = 18; - dat = dtc->ReadROCRegister(link,reg,100); - cout << Form("reg(%2i) : 0x%04x :\n",reg, dat); - - reg = 16; - dat = dtc->ReadROCRegister(link,reg,100); - cout << Form("reg(%2i) : 0x%04x :\n",reg, dat); - - reg = 7; - dat = dtc->ReadROCRegister(link,reg,100); - cout << Form("reg(%2i) : 0x%04x : Fiber loss/lock counter\n",reg, dat); - - reg = 6; - dat = dtc->ReadROCRegister(link,reg,100); - cout << Form("reg(%2i) : 0x%04x : Bad Markers counter\n",reg, dat); - - reg = 4; - dat = dtc->ReadROCRegister(link,reg,100); - cout << Form("reg(%2i) : 0x%04x : Loopback coarse delay\n",reg, dat); - - uint iw, iw1, iw2; - - reg = 23; - iw1 = dtc->ReadROCRegister(link,reg ,100); - iw2 = dtc->ReadROCRegister(link,reg+1,100); - iw = (iw2 << 16) | iw1; - cout << Form("reg(%i)<<16+reg(%i) : 0x%08x : SIZE_FIFO_FULL [28]+STORE_POS[25:24]+STORE_CNT[19:0]\n", - reg+1,reg,iw); - - reg = 25; - iw1 = dtc->ReadROCRegister(link,reg ,100); - iw2 = dtc->ReadROCRegister(link,reg+1,100); - iw = (iw2 << 16) | iw1; - cout << Form("reg(%i)<<16+reg(%i) : 0x%08x : SIZE_FIFO_EMPTY[28]+FETCH_POS[25:24]+FETCH_CNT[19:0]\n", - reg+1,reg,iw); - - reg = 11; - iw1 = dtc->ReadROCRegister(link,reg ,100); - iw2 = dtc->ReadROCRegister(link,reg+1,100); - iw = (iw2 << 16) | iw1; - cout << Form("reg(%i)<<16+reg(%i) : 0x%08x : Num EWM seen\n", reg+1,reg,iw); - - reg = 64; - iw1 = dtc->ReadROCRegister(link,reg ,100); - iw2 = dtc->ReadROCRegister(link,reg+1,100); - iw = (iw2 << 16) | iw1; - cout << Form("reg(%i)<<16+reg(%i) : 0x%08x : Num windows seen\n", reg+1,reg,iw); - - reg = 27; - iw1 = dtc->ReadROCRegister(link,reg ,100); - iw2 = dtc->ReadROCRegister(link,reg+1,100); - iw = (iw2 << 16) | iw1; - cout << Form("reg(%i)<<16+reg(%i) : 0x%08x : Num HB seen\n", reg+1,reg,iw); - - reg = 29; - iw1 = dtc->ReadROCRegister(link,reg ,100); - iw2 = dtc->ReadROCRegister(link,reg+1,100); - iw = (iw2 << 16) | iw1; - cout << Form("reg(%i)<<16+reg(%i) : 0x%08x : Num null HB seen\n", reg+1,reg,iw); - - reg = 31; - iw1 = dtc->ReadROCRegister(link,reg ,100); - iw2 = dtc->ReadROCRegister(link,reg+1,100); - iw = (iw2 << 16) | iw1; - cout << Form("reg(%i)<<16+reg(%i) : 0x%08x : Num HB on hold\n", reg+1,reg,iw); - - reg = 33; - iw1 = dtc->ReadROCRegister(link,reg ,100); - iw2 = dtc->ReadROCRegister(link,reg+1,100); - iw = (iw2 << 16) | iw1; - cout << Form("reg(%i)<<16+reg(%i) : 0x%08x : Num PREFETCH seen\n\n", reg+1,reg,iw); - - reg = 9; - iw1 = dtc->ReadROCRegister(link,reg ,100); - iw2 = dtc->ReadROCRegister(link,reg+1,100); - iw = (iw2 << 16) | iw1; - cout << Form("reg(%2i)<<16+reg(%2i) : 0x%08x : Num DATA REQ seen\n", reg+1,reg,iw); - - reg = 35; - iw1 = dtc->ReadROCRegister(link,reg ,100); - iw2 = dtc->ReadROCRegister(link,reg+1,100); - iw = (iw2 << 16) | iw1; - cout << Form("reg(%i)<<16+reg(%i) : 0x%08x : Num DATA REQ written to DDR\n", reg+1,reg,iw); - - reg = 13; - dat = dtc->ReadROCRegister(link,reg,100); - cout << Form("reg(%2i) : 0x%04x : Num skipped DATA REQ\n",reg,dat); - - reg = 37; - iw1 = dtc->ReadROCRegister(link,reg ,100); - iw2 = dtc->ReadROCRegister(link,reg+1,100); - iw = (iw2 << 16) | iw1; - cout << Form("reg(%i)<<16+reg(%i) : 0x%08x : Num DATA REQ read from DDR\n", reg+1,reg,iw); - - reg = 39; - iw1 = dtc->ReadROCRegister(link,reg ,100); - iw2 = dtc->ReadROCRegister(link,reg+1,100); - iw = (iw2 << 16) | iw1; - cout << Form("reg(%i)<<16+reg(%i) : 0x%08x : Num DATA REQ sent to DTC\n", reg+1,reg,iw); - - - reg = 41; - iw1 = dtc->ReadROCRegister(link,reg ,100); - iw2 = dtc->ReadROCRegister(link,reg+1,100); - iw = (iw2 << 16) | iw1; - cout << Form("reg(%i)<<16+reg(%i) : 0x%08x : Num DATA REQ with null data\n", reg+1,reg,iw); +// print value of the register Reg for different ROCs +//----------------------------------------------------------------------------- + void DtcInterface::PrintRocRegister(uint Reg, std::string& Desc, int Format, int LinkMask) { - cout << Form("\n"); - - reg = 43; - iw1 = dtc->ReadROCRegister(link,reg ,100); - iw2 = dtc->ReadROCRegister(link,reg+1,100); - iw = (iw2 << 16) | iw1; - cout << Form("reg(%i)<<16+reg(%i) : 0x%08x : Last spill tag\n", reg+1,reg,iw); - - // uint16_t iw3; - - reg = 45; - iw1 = dtc->ReadROCRegister(link,reg ,100); - iw2 = dtc->ReadROCRegister(link,reg+1,100); - // iw3 = dtc->ReadROCRegister(link,reg+2,100); - - iw = (iw2 << 16) | iw1; - cout << Form("reg(%i)<<16+reg(%i) : 0x%08x : Last HB tag\n", reg+1,reg,iw); + std::string text; + for (int i=0; i<6; i++) { + int used = (LinkMask >> 4*i) & 0x1; + if (used == 0) continue; + + DTC_Link_ID link = DTC_Link_ID(i); + uint32_t dat; + + dat = fDtc->ReadROCRegister(link,Reg,100); + text += Form(" 0x%04x :",dat); + } + std::string sreg = Form("reg(%2i)",Reg); - reg = 48; - iw1 = dtc->ReadROCRegister(link,reg ,100); - iw2 = dtc->ReadROCRegister(link,reg+1,100); - // iw3 = dtc->ReadROCRegister(link,reg+2,100); - - iw = (iw2 << 16) | iw1; - cout << Form("reg(%i)<<16+reg(%i) : 0x%08x : Last PREFETCH tag\n", reg+1,reg,iw); + if (Format == 1) text += Form(" %s",Desc.data()); + cout << Form("%-21s :%s\n",sreg.data(),text.data()); + } + + //----------------------------------------------------------------------------- + void DtcInterface::PrintRocRegister2(uint Reg, std::string& Desc, int Format, int LinkMask) { + + std::string text; + for (int i=0; i<6; i++) { + int used = (LinkMask >> 4*i) & 0x1; + if (used == 0) continue; + + DTC_Link_ID link = DTC_Link_ID(i); + uint32_t iw1, iw2, iw; + + iw1 = fDtc->ReadROCRegister(link,Reg ,100); + iw2 = fDtc->ReadROCRegister(link,Reg+1,100); + iw = (iw2 << 16) | iw1; + text += Form(" 0x%08x :",iw); + } + + if (Format == 1) text += Form(" %s",Desc.data()); + + std::string sreg = Form("reg(%2i)<<16 | reg(%2i)",Reg+1,Reg); + + cout << Form("%-21s :%s\n",sreg.data(),text.data()); + } - reg = 51; - iw1 = dtc->ReadROCRegister(link,reg ,100); - iw2 = dtc->ReadROCRegister(link,reg+1,100); - // iw3 = dtc->ReadROCRegister(link,reg+2,100); - iw = (iw2 << 16) | iw1; - cout << Form("reg(%i)<<16+reg(%i) : 0x%08x : Last fetched tag\n", reg+1,reg,iw); +//----------------------------------------------------------------------------- +// most of the time LinkMask = -1 +//----------------------------------------------------------------------------- + void DtcInterface::PrintRocStatus(int Format, int LinkMask) { + TLOG(TLVL_DEBUG) << Form("Format=%i LinkMask 0x%08x \n",Format,LinkMask); - reg = 54; - iw1 = dtc->ReadROCRegister(link,reg ,100); - iw2 = dtc->ReadROCRegister(link,reg+1,100); - // iw3 = dtc->ReadROCRegister(link,reg+2,100); - - iw = (iw2 << 16) | iw1; - cout << Form("reg(%i)<<16+reg(%i) : 0x%08x : Last DATA REQ tag\n", reg+1,reg,iw); + std::string desc; - reg = 57; - iw1 = dtc->ReadROCRegister(link,reg ,100); - iw2 = dtc->ReadROCRegister(link,reg+1,100); - // iw3 = dtc->ReadROCRegister(link,reg+2,100); - - iw = (iw2 << 16) | iw1; - cout << Form("reg(%i)<<16+reg(%i) : 0x%08x : OFFSET tag\n", reg+1,reg,iw); + int link_mask = LinkMask; + if (LinkMask == -1) link_mask = fLinkMask; - cout << std::endl; + uint reg; - reg = 72; - dat = dtc->ReadROCRegister(link,reg,100); - cout << Form("reg(%2i) : 0x%04x : Num HB tag inconsistencies\n",reg, dat); + std::string text(" Register :"); + for (int i=0; i<6; i++) { + int used = (link_mask >> 4*i) & 0x1; + if (used == 0) continue; + text += Form(" ROC%i :",i); + } + + if (Format != 0) text += " Description"; + cout << Form("%s\n",text.data()); + cout << "------------------------------------------------------------------------\n"; - reg = 74; - dat = dtc->ReadROCRegister(link,reg,100); - cout << Form("reg(%2i) : 0x%04x : Num HB tag lost\n",reg, dat); + reg = 0; desc = "ALWAYS 0x1234"; + PrintRocRegister(reg,desc,Format,link_mask); + + reg = 8; desc = "ROC pattern mode ??"; + PrintRocRegister(reg,desc,Format,link_mask); + + reg = 18; desc = " ??"; + PrintRocRegister(reg,desc,Format,link_mask); + + reg = 16; desc = " ??"; + PrintRocRegister(reg,desc,Format,link_mask); + + reg = 7; desc = "Fiber loss/lock counter"; + PrintRocRegister(reg,desc,Format,link_mask); - reg = 73; - dat = dtc->ReadROCRegister(link,reg,100); - cout << Form("reg(%2i) : 0x%04x : Num DREQ tag inconsistencies\n",reg, dat); + reg = 6; desc = "Bad Markers counter"; + PrintRocRegister(reg,desc,Format,link_mask); + + reg = 4; desc = "Loopback coarse delay"; + PrintRocRegister(reg,desc,Format,link_mask); + + reg = 23; desc = "SIZE_FIFO_FULL [28]+STORE_POS[25:24]+STORE_CNT[19:0]"; + PrintRocRegister2(reg,desc,Format,link_mask); - reg = 75; - dat = dtc->ReadROCRegister(link,reg,100); - cout << Form("reg(%2i) : 0x%04x : Num DREQ tag lost\n",reg, dat); + reg = 25; desc = "SIZE_FIFO_EMPTY[28]+FETCH_POS[25:24]+FETCH_CNT[19:0]"; + PrintRocRegister2(reg,desc,Format,link_mask); + + reg = 11; desc = "Num EWM seen"; + PrintRocRegister2(reg,desc,Format,link_mask); + + reg = 64; desc = "Num windows seen"; + PrintRocRegister2(reg,desc,Format,link_mask); + + reg = 27; desc = "Num HB seen"; + PrintRocRegister2(reg,desc,Format,link_mask); + + reg = 29; desc = "Num null HB seen"; + PrintRocRegister2(reg,desc,Format,link_mask); + + reg = 31; desc = "Num HB on hold"; + PrintRocRegister2(reg,desc,Format,link_mask); + + reg = 33; desc = "Num PREFETCH seen"; + PrintRocRegister2(reg,desc,Format,link_mask); + + cout << Form("\n"); + + reg = 9; desc = "Num DATA REQ seen"; + PrintRocRegister2(reg,desc,Format,link_mask); + + reg = 35; desc = "Num DATA REQ written to DDR"; + PrintRocRegister2(reg,desc,Format,link_mask); + + reg = 13; desc = "Num skipped DATA REQ"; + PrintRocRegister(reg,desc,Format,link_mask); + + reg = 37; desc = "Num DATA REQ read from DDR"; + PrintRocRegister2(reg,desc,Format,link_mask); + + reg = 39; desc = "Num DATA REQ sent to DTC"; + PrintRocRegister2(reg,desc,Format,link_mask); + + reg = 41; desc = "Num DATA REQ with null data"; + PrintRocRegister2(reg,desc,Format,link_mask); + + cout << Form("\n"); + + reg = 43; desc = "Last spill tag"; + PrintRocRegister2(reg,desc,Format,link_mask); + + reg = 45; desc = "Last HB tag"; + PrintRocRegister2(reg,desc,Format,link_mask); + + reg = 48; desc = "Last PREFETCH tag"; + PrintRocRegister2(reg,desc,Format,link_mask); + + reg = 51; desc = "Last fetched tag"; + PrintRocRegister2(reg,desc,Format,link_mask); + + reg = 54; desc = "Last DATA REQ tag"; + PrintRocRegister2(reg,desc,Format,link_mask); + + reg = 57; desc = "OFFSET tag"; + PrintRocRegister2(reg,desc,Format,link_mask); + + cout << std::endl; + + reg = 72; desc = "Num HB tag inconsistencies"; + PrintRocRegister(reg,desc,Format,link_mask); + + reg = 74; desc = "Num HB tag lost"; + PrintRocRegister(reg,desc,Format,link_mask); + + reg = 73; desc = "Num DATA REQ tag inconsistencies"; + PrintRocRegister(reg,desc,Format,link_mask); + + reg = 75; desc = "Num DATA REQ tag lost"; + PrintRocRegister(reg,desc,Format,link_mask); cout << "------------------------------------------------------------------------\n"; } - //----------------------------------------------------------------------------- // according to Ryan, disabling the CFO emulation is critical, otherwise NMarkers // would be cached for the next time @@ -476,7 +453,7 @@ namespace trkdaq { //----------------------------------------------------------------------------- void DtcInterface::LaunchRunPlanEmulatedCfo(int EWLength, int NMarkers, int FirstEWTag) { - TLOG(TLVL_INFO) << Form("START : EWLength=%i NMarkers=%i FirstEWTag=%i\n",EWLength,NMarkers,FirstEWTag); + TLOG(TLVL_DEBUG) << Form("START : EWLength=%i NMarkers=%i FirstEWTag=%i\n",EWLength,NMarkers,FirstEWTag); fDtc->DisableCFOEmulation(); fDtc->SoftReset(); // write 0x9100:bit_31 = 1 @@ -490,7 +467,7 @@ namespace trkdaq { // this command sends the EWM's fDtc->EnableCFOEmulation(); // r_0x9100:bit_30 = 1 - TLOG(TLVL_INFO) << Form("END\n"); + TLOG(TLVL_DEBUG) << Form("END\n"); } //----------------------------------------------------------------------------- @@ -586,16 +563,6 @@ namespace trkdaq { PrintRegister(0x91f4,"CFO Emulation 40 MHz Clock Marker Interval "); PrintRegister(0x91f8,"CFO Marker Enables "); - // PrintRegister(0x9200,"Receive Byte Count Link 0 "); - // PrintRegister(0x9220,"Receive Packet Count Link 0 "); - // PrintRegister(0x9240,"Transmit Byte Count Link 0 "); - // PrintRegister(0x9260,"Transmit Packet Count Link 0 "); - - // PrintRegister(0x9218,"Receive Byte Count CFO "); - // PrintRegister(0x9238,"Receive Packet Count CFO "); - // PrintRegister(0x9258,"Transmit Byte Count CFO "); - // PrintRegister(0x9278,"Transmit Packet Count CFO "); - PrintRegister(0x9308,"Jitter Attenuator CSR "); PrintRegister(0x9630,"TX Data Request Packet Count Link 0 "); @@ -634,10 +601,10 @@ namespace trkdaq { int DtcInterface::ReadSpiData(int Link, vector& SpiRawData, int PrintLevel) { int rc(0); //----------------------------------------------------------------------------- -// is this really needed ? +// is this really needed ? - probably not //----------------------------------------------------------------------------- - MonicaVarLinkConfig(Link); - MonicaDigiClear(Link); + MonicaVarLinkConfig(); + MonicaDigiClear(); //----------------------------------------------------------------------------- // after writing into reg 258, sleep for some time, // then wait till reg 128 returns non-zero @@ -736,7 +703,8 @@ namespace trkdaq { ulong ts = FirstTS; bool match_ts = false; int nerr_tot(0); - ulong offset (0); // used in validation mode + ulong nbytes_tot(0); + ulong offset (0); // used in validation mode // int print_level(1); FILE* file(nullptr); @@ -786,10 +754,12 @@ namespace trkdaq { int rs[6]; for (int i=0; iGetSubEventByteCount(); + int nbytes = ev->GetSubEventByteCount(); uint64_t ew_tag = ev->GetEventWindowTag().GetEventWindowTag(true); char* data = (char*) ev->GetRawBufferPointer(); + nbytes_tot += nbytes; + int nerr(0); if (Validate > 0) { @@ -801,7 +771,7 @@ namespace trkdaq { //----------------------------------------------------------------------------- // write event to output file //----------------------------------------------------------------------------- - int nbb = fwrite(data,1,nb,file); + int nbb = fwrite(data,1,nbytes,file); if (nbb == 0) { cout << "ERROR in " << __func__ << " : failed to write event " << ew_tag << " , close file and BAIL OUT" << endl; @@ -819,8 +789,8 @@ namespace trkdaq { } if (PrintLevel > 0) { - cout << Form(" DTC:%2i EWTag:%10li nbytes: %4i ROC status: 0x%04x 0x%04x 0x%04x 0x%04x 0x%04x 0x%04x ", - i,ew_tag,nb,rs[0],rs[1],rs[2],rs[3],rs[4],rs[5]); + cout << Form(" DTC:%2i EWTag:%10li nbytes: %4i nbytes_tot:%12li ROC status: 0x%04x 0x%04x 0x%04x 0x%04x 0x%04x 0x%04x ", + i,ew_tag,nbytes,nbytes_tot,rs[0],rs[1],rs[2],rs[3],rs[4],rs[5]); } if (PrintLevel > 1) { diff --git a/otsdaq-mu2e-tracker/Ui/DtcInterface.hh b/otsdaq-mu2e-tracker/Ui/DtcInterface.hh index 4b6fec8..c859ca1 100644 --- a/otsdaq-mu2e-tracker/Ui/DtcInterface.hh +++ b/otsdaq-mu2e-tracker/Ui/DtcInterface.hh @@ -77,8 +77,15 @@ namespace trkdaq { void PrintBuffer (const void* ptr, int nw); void PrintFireflyTemp(); void PrintRegister (uint16_t Register, const char* Title = ""); - void PrintRocStatus (int Link); - void PrintStatus (); +//----------------------------------------------------------------------------- +// Format = 0 : for each register, print a register and its value +// Format = 1 : add short description of each register +// if Link = -1, print a line per register for each ROC +//----------------------------------------------------------------------------- + void PrintRocRegister (uint Reg, std::string& Desc, int Format = 1, int LinkMask = -1); + void PrintRocRegister2(uint Reg, std::string& Desc, int Format = 1, int LinkMask = -1); + void PrintRocStatus (int Format = 1, int LinkMask = -1); + void PrintStatus (); uint32_t ReadRegister (uint16_t Register); diff --git a/scripts/find_alignment.C b/scripts/find_alignment.C index bc4b457..834d1ae 100644 --- a/scripts/find_alignment.C +++ b/scripts/find_alignment.C @@ -3,12 +3,13 @@ #include "print_buffer.C" -// #include "dtcInterfaceLib/DTC.h" #include "otsdaq-mu2e-tracker/Ui/DtcInterface.hh" using namespace DTCLib; using namespace trkdaq; +//----------------------------------------------------------------------------- +// unpack data making everything an int //----------------------------------------------------------------------------- void parse_fi_output(char* Data, int NBytes) { vector val; @@ -38,7 +39,7 @@ void parse_fi_output(char* Data, int NBytes) { val.push_back(w); } - // 6 chars + // 6 shorts for (int k=0; k<6; k++) { int loc = k*2+3+48+96; short ub = Data[loc+1];