From c7e357fd30b0c89ead63d42b689d7d11dedc863d Mon Sep 17 00:00:00 2001 From: RYAN RIVERA Date: Mon, 29 Jun 2026 14:33:14 -0500 Subject: [PATCH 1/5] Cleanup CFO loopback behavior --- .../FEInterfaces/CFOFrontEndInterfaceImpl.cc | 14 +++++++++----- .../FEInterfaces/DTCFrontEndInterfaceImpl.cc | 10 +++++----- 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/otsdaq-mu2e/FEInterfaces/CFOFrontEndInterfaceImpl.cc b/otsdaq-mu2e/FEInterfaces/CFOFrontEndInterfaceImpl.cc index 7840e5b3..349d8df6 100644 --- a/otsdaq-mu2e/FEInterfaces/CFOFrontEndInterfaceImpl.cc +++ b/otsdaq-mu2e/FEInterfaces/CFOFrontEndInterfaceImpl.cc @@ -157,7 +157,7 @@ void CFOFrontEndInterface::registerFEMacros(void) static_cast( &CFOFrontEndInterface::LoopbackTest), // feMacroFunction std::vector{ // namesOfInputArgs - "Number of Loopback Exponent (Default := 3, which is 8 Loopback Markers sent)", + // "Number of Loopback Exponent (Default := 3, which is 8 Loopback Markers sent)", // as of June 2026 -- defaulting to 0 exponent always (first loopback is somehow different than 2+ loopbacks) "Number of Loopback tests (Default := 1)", "Target Link (-1 for all, Default := -1)", "Target ROC (-1 for all, Default := -1)", @@ -617,10 +617,11 @@ void CFOFrontEndInterface::LoopbackTest(__ARGS__) ostr << std::endl; // parameters - const int numberOfLoopbacksExp = __GET_ARG_IN__( - "Number of Loopback Exponent (Default := 3, which is 8 Loopback Markers sent)", - uint32_t, - 3); + const int numberOfLoopbacksExp = 0; + // __GET_ARG_IN__( + // "Number of Loopback Exponent (Default := 3, which is 8 Loopback Markers sent)", + // uint32_t, + // 3); const int numberOfLoopbackTests = __GET_ARG_IN__("Number of Loopback tests (Default := 1)", uint32_t, 1); const int targetLink = @@ -933,6 +934,9 @@ void CFOFrontEndInterface::LoopbackTest(__ARGS__) // ostr << std::endl << std::endl; + if(ostr.str().empty()) + ostr << "No loopback measurements were successful. Check the link status of targeted links." << std::endl; + __SET_ARG_OUT__("Response", ostr.str()); } // end LoopbackTest() diff --git a/otsdaq-mu2e/FEInterfaces/DTCFrontEndInterfaceImpl.cc b/otsdaq-mu2e/FEInterfaces/DTCFrontEndInterfaceImpl.cc index 411d3322..f62765b8 100644 --- a/otsdaq-mu2e/FEInterfaces/DTCFrontEndInterfaceImpl.cc +++ b/otsdaq-mu2e/FEInterfaces/DTCFrontEndInterfaceImpl.cc @@ -630,8 +630,8 @@ void DTCFrontEndInterface::registerFEMacros(void) "Loopback Manual Setup", static_cast( &DTCFrontEndInterface::ManualLoopbackSetup), - std::vector{"setAsPassthrough"}, - std::vector{}, + std::vector{"setAsPassthrough (Default := false)"}, + std::vector{"Result"}, 1, // requiredUserPermissions "*", "Toggles the DTC CFO loopback mode. " @@ -7807,17 +7807,18 @@ void DTCFrontEndInterface::CFOEmulatorLoopbackTests(__ARGS__) //======================================================================== void DTCFrontEndInterface::ManualLoopbackSetup(__ARGS__) { - bool setAsPassthrough = __GET_ARG_IN__("setAsPassthrough", bool); + bool setAsPassthrough = __GET_ARG_IN__("setAsPassthrough (Default := false)", bool); __COUTV__(setAsPassthrough); if(setAsPassthrough) { getDTC()->DisableCFOLoopback(); - return; } else getDTC()->EnableCFOLoopback(); + __SET_ARG_OUT__("Result", getDTC()->FormatDTCControl()); + //as of June 2026, do not target one ROC (all done at once) return; @@ -7831,7 +7832,6 @@ void DTCFrontEndInterface::ManualLoopbackSetup(__ARGS__) getDTC()->DisableLink(DTCLib::DTC_ROC_Links[i]); getDTC()->EnableLink(DTCLib::DTC_ROC_Links[ROC_Link]); - } //end ManualLoopbackSetup() //======================================================================== From 199f502810b3a03e78d8d4629ab08ab0205dbc5d Mon Sep 17 00:00:00 2001 From: RYAN RIVERA Date: Mon, 29 Jun 2026 15:00:39 -0500 Subject: [PATCH 2/5] Deliver Ploty plot of CFO loopback results --- .../FEInterfaces/CFOFrontEndInterfaceImpl.cc | 38 +++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/otsdaq-mu2e/FEInterfaces/CFOFrontEndInterfaceImpl.cc b/otsdaq-mu2e/FEInterfaces/CFOFrontEndInterfaceImpl.cc index 349d8df6..224cf03e 100644 --- a/otsdaq-mu2e/FEInterfaces/CFOFrontEndInterfaceImpl.cc +++ b/otsdaq-mu2e/FEInterfaces/CFOFrontEndInterfaceImpl.cc @@ -866,6 +866,44 @@ void CFOFrontEndInterface::LoopbackTest(__ARGS__) } } } + + // build Plotly histogram of delay measurements + { + std::stringstream plotlySs; + plotlySs << R"({"data":[)"; + + bool firstTrace = true; + for(const auto& [map_index, results] : roc_results) + { + const int counts = results.counts; + if(counts <= 0) + continue; + + if(!firstTrace) + plotlySs << ","; + firstTrace = false; + + plotlySs << R"({"x":[)"; + for(int i = 0; i < counts; ++i) + { + if(i > 0) + plotlySs << ","; + plotlySs << results.graph->GetY()[i]; + } + plotlySs << R"(],"type":"histogram","name":"Link )" + << (map_index / 100) << " ROC " << (map_index % 100) + << R"(","opacity":0.75})"; + } + + plotlySs << R"(],"layout":{)" + << R"("title":{"text":"CFO Loopback Delay"},)" + << R"("xaxis":{"title":{"text":"Delay [ns]"}},)" + << R"("yaxis":{"title":{"text":"Count"}},)" + << R"("barmode":"overlay"}})"; + + __SET_ARG_OUT__(PLOTLY_PLOT, plotlySs.str()); + } + if(writeFile) { tree->Write(); From 472b99eb6e79887299e36a78961eb3756b06b00e Mon Sep 17 00:00:00 2001 From: anorman Date: Tue, 30 Jun 2026 14:10:40 -0500 Subject: [PATCH 3/5] Added PLOTLY_PLOT histogram to DTC's CFO Emulator Loopback test --- .../FEInterfaces/DTCFrontEndInterfaceImpl.cc | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/otsdaq-mu2e/FEInterfaces/DTCFrontEndInterfaceImpl.cc b/otsdaq-mu2e/FEInterfaces/DTCFrontEndInterfaceImpl.cc index f62765b8..de7297f6 100644 --- a/otsdaq-mu2e/FEInterfaces/DTCFrontEndInterfaceImpl.cc +++ b/otsdaq-mu2e/FEInterfaces/DTCFrontEndInterfaceImpl.cc @@ -7802,6 +7802,25 @@ void DTCFrontEndInterface::CFOEmulatorLoopbackTests(__ARGS__) __SET_ARG_OUT__("Average", std::format("{:.2f} ns", result)); __SET_ARG_OUT__("Maximum", std::format("{:.2f} ns", max_value)); __SET_ARG_OUT__("Minimum", std::format("{:.2f} ns", min_value)); + + // build Plotly histogram of delay measurements + { + std::stringstream plotlySs; + plotlySs << R"({"data":[{"x":[)"; + for(int i = 0; i < numberOfTests; ++i) + { + if(i > 0) + plotlySs << ","; + plotlySs << results[i]; + } + plotlySs << R"(],"type":"histogram","name":"Loopback Delay","opacity":0.75}])" + << R"(,"layout":{)" + << R"("title":{"text":"CFO Emulator Loopback Delay"},)" + << R"("xaxis":{"title":{"text":"Delay [ns]"}},)" + << R"("yaxis":{"title":{"text":"Count"}}}})"; + + __SET_ARG_OUT__(PLOTLY_PLOT, plotlySs.str()); + } } //end CFOEmulatorLoopbackTests() //======================================================================== From fd4f608ade26bff3743bed263990d1b4773bb797 Mon Sep 17 00:00:00 2001 From: RYAN RIVERA Date: Tue, 30 Jun 2026 14:11:18 -0500 Subject: [PATCH 4/5] Format fix --- otsdaq-mu2e/FEInterfaces/CFOFrontEndInterfaceImpl.cc | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/otsdaq-mu2e/FEInterfaces/CFOFrontEndInterfaceImpl.cc b/otsdaq-mu2e/FEInterfaces/CFOFrontEndInterfaceImpl.cc index 224cf03e..3bb936ef 100644 --- a/otsdaq-mu2e/FEInterfaces/CFOFrontEndInterfaceImpl.cc +++ b/otsdaq-mu2e/FEInterfaces/CFOFrontEndInterfaceImpl.cc @@ -890,9 +890,8 @@ void CFOFrontEndInterface::LoopbackTest(__ARGS__) plotlySs << ","; plotlySs << results.graph->GetY()[i]; } - plotlySs << R"(],"type":"histogram","name":"Link )" - << (map_index / 100) << " ROC " << (map_index % 100) - << R"(","opacity":0.75})"; + plotlySs << R"(],"type":"histogram","name":"Link )" << (map_index / 100) + << " ROC " << (map_index % 100) << R"(","opacity":0.75})"; } plotlySs << R"(],"layout":{)" @@ -973,7 +972,9 @@ void CFOFrontEndInterface::LoopbackTest(__ARGS__) // ostr << std::endl << std::endl; if(ostr.str().empty()) - ostr << "No loopback measurements were successful. Check the link status of targeted links." << std::endl; + ostr << "No loopback measurements were successful. Check the link status of " + "targeted links." + << std::endl; __SET_ARG_OUT__("Response", ostr.str()); From e6f2cfec5cca9287c9204fd04c1b41bdc6fa8c0f Mon Sep 17 00:00:00 2001 From: rrivera747 <107584474+rrivera747@users.noreply.github.com> Date: Mon, 6 Jul 2026 15:14:28 -0500 Subject: [PATCH 5/5] Potential fix for pull request finding Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> --- otsdaq-mu2e/FEInterfaces/CFOFrontEndInterfaceImpl.cc | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/otsdaq-mu2e/FEInterfaces/CFOFrontEndInterfaceImpl.cc b/otsdaq-mu2e/FEInterfaces/CFOFrontEndInterfaceImpl.cc index 3bb936ef..10f02186 100644 --- a/otsdaq-mu2e/FEInterfaces/CFOFrontEndInterfaceImpl.cc +++ b/otsdaq-mu2e/FEInterfaces/CFOFrontEndInterfaceImpl.cc @@ -971,7 +971,14 @@ void CFOFrontEndInterface::LoopbackTest(__ARGS__) // ostr << std::endl << std::endl; - if(ostr.str().empty()) + bool anySuccessful = false; + for(const auto& [map_index, results] : roc_results) + if(results.counts > 0) + { + anySuccessful = true; + break; + } + if(!anySuccessful) ostr << "No loopback measurements were successful. Check the link status of " "targeted links." << std::endl;