1
0
Fork 0
mirror of https://github.com/gwm17/Specter.git synced 2024-11-22 10:18:50 -05:00

Added in scaler interface. Single graph with a list showing all scalers

This commit is contained in:
Gordon McCann 2022-06-22 19:56:02 -04:00
parent c5a8e8dad0
commit 709219f562
9 changed files with 113 additions and 2 deletions

View File

@ -11,7 +11,8 @@ namespace Specter {
//Construct each NavParameter with their unique name. Then bind them to the SpectrumManager.
SPSAnalysisStage::SPSAnalysisStage() :
AnalysisStage("SPSAnalysis"), delayFLTime("delayFLTime"), delayFRTime("delayFRTime"), delayBLTime("delayBLTime"), delayBRTime("delayBRTime"), x1("x1"), x2("x2"), xavg("xavg"),
scintLeft("scintLeft"), anodeBack("anodeBack"), anodeFront("anodeFront"), cathode("cathode"), xavg_sabreCoinc("xavg_sabreCoinc"), x1_weight("x1_weight"), x2_weight("x2_weight")
scintLeft("scintLeft"), anodeBack("anodeBack"), anodeFront("anodeFront"), cathode("cathode"), xavg_sabreCoinc("xavg_sabreCoinc"), x1_weight("x1_weight"), x2_weight("x2_weight"),
beamIntegrator("beamIntegrator")
{
SPEC_PROFILE_FUNCTION();
SpectrumManager& manager = SpectrumManager::GetInstance();
@ -43,6 +44,8 @@ namespace Specter {
manager.BindVariable(x1_weight);
manager.BindVariable(x2_weight);
manager.BindScaler(beamIntegrator);
}
SPSAnalysisStage::~SPSAnalysisStage() {}
@ -72,6 +75,11 @@ namespace Specter {
scintLeft.SetValue(hit.longEnergy);
break;
}
case 133:
{
beamIntegrator.Increment();
break;
}
case 135:
{
if (hit.longEnergy > cathode.GetValue())

View File

@ -36,6 +36,9 @@ namespace Specter {
//Create a few variables
Variable x1_weight;
Variable x2_weight;
//Create a scaler
Scaler beamIntegrator;
};
}

View File

@ -84,6 +84,8 @@ target_sources(Specter PRIVATE
Specter/Editor/SpectrumDialog.h
Specter/Editor/SpectrumPanel.cpp
Specter/Editor/SpectrumPanel.h
Specter/Editor/ScalerPanel.h
Specter/Editor/ScalerPanel.cpp
Specter/Utils/Instrumentor.h
Specter/Utils/TCPClient.cpp
Specter/Utils/TCPClient.h

View File

@ -6,6 +6,8 @@ namespace Specter {
ScalerGraph::ScalerGraph(const GraphArgs& args) :
m_args(args), m_lastScalerVal(0)
{
if (m_args.maxPoints < 2) //saftey check guaranteeing we have enough points to make a graph
m_args.maxPoints = 2;
m_xPoints.reserve(m_args.maxPoints);
m_xPoints.reserve(m_args.maxPoints);
}
@ -27,7 +29,7 @@ namespace Specter {
m_xPoints[i] = m_xPoints[i + 1];
m_yPoints[i] = m_yPoints[i + 1];
}
m_xPoints[m_args.maxPoints - 1] = timeStep;
m_xPoints[m_args.maxPoints - 1] = m_xPoints[m_args.maxPoints - 2] + timeStep;
m_yPoints[m_args.maxPoints - 1] = rate;
}

View File

@ -414,6 +414,13 @@ namespace Specter {
m_scalerMap[scaler.GetName()].reset(new std::atomic<uint64_t>(0));
}
scaler.m_pdata = m_scalerMap[scaler.GetName()];
GraphArgs args;
args.name = scaler.GetName() + "_graph";
args.maxPoints = 10;
args.scalerName = scaler.GetName();
m_graphMap[args.name].reset(new ScalerGraph(args));
}
void SpectrumManager::ResetScalers()

View File

@ -40,6 +40,7 @@ namespace Specter {
void EditorLayer::OnUpdate(Timestep& step)
{
SpectrumManager::GetInstance().UpdateGraphs(step);
}
void EditorLayer::OnEvent(Event& e)
@ -65,6 +66,18 @@ namespace Specter {
std::sort(m_paramList.begin(), m_paramList.end(), SortByString);
}
void EditorLayer::UpdateScalerList()
{
m_scalerList = SpectrumManager::GetInstance().GetListOfScalers();
std::sort(m_scalerList.begin(), m_scalerList.end(), SortByString);
}
void EditorLayer::UpdateGraphList()
{
m_graphList = SpectrumManager::GetInstance().GetListOfGraphs();
std::sort(m_graphList.begin(), m_graphList.end(), SortByName<GraphArgs>);
}
//The main function
void EditorLayer::OnImGuiRender()
{
@ -75,6 +88,8 @@ namespace Specter {
UpdateParameterList();
UpdateHistogramList();
UpdateCutList();
UpdateScalerList();
UpdateGraphList();
startFlag = false;
}
// We are using the ImGuiWindowFlags_NoDocking flag to make the parent window not dockable into,
@ -210,6 +225,8 @@ namespace Specter {
if(m_spectrumDialog.ImGuiRenderSpectrumDialog(m_histoList, m_cutList, m_paramList))
UpdateHistogramList();
m_scalerPanel.OnImGuiRender(m_scalerList, m_graphList);
m_sourceDialog.ImGuiRenderSourceDialog();
RemoveHistogramDialog();

View File

@ -13,7 +13,9 @@
#include "Specter/Events/PhysicsEvent.h"
#include "Specter/Core/Histogram.h"
#include "Specter/Core/Cut.h"
#include "Specter/Core/Graph.h"
#include "SpectrumPanel.h"
#include "ScalerPanel.h"
#include "FileDialog.h"
#include "SpectrumDialog.h"
#include "SourceDialog.h"
@ -44,11 +46,14 @@ namespace Specter {
void UpdateHistogramList();
void UpdateCutList();
void UpdateParameterList(); //Currently not really used, only once. Params all made at construction time of PhysicsLayer
void UpdateScalerList(); //Currently not really used, only once. Scalers all made at construction time of PhysicsLayer
void UpdateGraphList(); //Same
void ExportHistogram(HistogramArgs selectedGram, const std::string& filename);
EventCallbackFunc m_callbackFunc;
SpectrumPanel m_spectrumPanel;
ScalerPanel m_scalerPanel;
FileDialog m_fileDialog;
SpectrumDialog m_spectrumDialog;
SourceDialog m_sourceDialog;
@ -57,6 +62,8 @@ namespace Specter {
std::vector<HistogramArgs> m_histoList;
std::vector<CutArgs> m_cutList;
std::vector<std::string> m_paramList;
std::vector<std::string> m_scalerList;
std::vector<GraphArgs> m_graphList;
//ImGui Settings
bool dockspaceOpen = true;

View File

@ -0,0 +1,43 @@
#include "ScalerPanel.h"
#include "Specter/Core/SpectrumManager.h"
#include "imgui.h"
#include "implot.h"
namespace Specter {
ScalerPanel::ScalerPanel() {}
ScalerPanel::~ScalerPanel() {}
void ScalerPanel::OnImGuiRender(const std::vector<std::string>& scalerList, const std::vector<GraphArgs>& graphList)
{
SpectrumManager& manager = SpectrumManager::GetInstance();
if (ImGui::Begin("ScalerPanel"))
{
if (ImGui::TreeNode("Scalers"))
{
for (auto& scaler : scalerList)
{
ImGui::BulletText("%s", scaler.c_str());
}
ImGui::TreePop();
}
if (ImGui::BeginCombo("Graph to Plot", m_selectedGraph.name.c_str()))
{
for (auto& graph : graphList)
{
if (ImGui::Selectable(graph.name.c_str(), m_selectedGraph.name == graph.name))
m_selectedGraph = graph;
}
ImGui::EndCombo();
}
if (ImPlot::BeginPlot("Scaler Graphs"))
{
manager.DrawGraph(m_selectedGraph.name);
ImPlot::EndPlot();
}
}
ImGui::End();
}
}

View File

@ -0,0 +1,22 @@
#ifndef SCALER_PANEL_H
#define SCALER_PANEL_H
#include "Specter/Core/Graph.h"
namespace Specter {
class ScalerPanel
{
public:
ScalerPanel();
~ScalerPanel();
void OnImGuiRender(const std::vector<std::string>& scalerList, const std::vector<GraphArgs>& graphList);
private:
GraphArgs m_selectedGraph;
};
}
#endif