mirror of
https://github.com/gwm17/Specter.git
synced 2024-11-22 18:28:52 -05:00
Added some much needed functionality to parameters. Can now bind with a default histogram, set parameters after default construction
This commit is contained in:
parent
34b448f850
commit
6837418ffa
|
@ -18,11 +18,12 @@ namespace Navigator {
|
|||
manager.BindParameter(delayFRTime);
|
||||
manager.BindParameter(delayBLTime);
|
||||
manager.BindParameter(delayBRTime);
|
||||
manager.BindParameter(x1);
|
||||
manager.BindParameter(x2);
|
||||
manager.BindParameter(xavg);
|
||||
manager.BindParameter(scintLeft);
|
||||
manager.BindParameter(anodeBack);
|
||||
//Bind parameters with some default histograms. Saves us the effort of making them in the UI.
|
||||
manager.BindParameter(x1, 600, -300.0, 300.0);
|
||||
manager.BindParameter(x2, 600, -300.0, 300.0);
|
||||
manager.BindParameter(xavg, 600, -300.0, 300.0);
|
||||
manager.BindParameter(scintLeft, 4096, 0.0, 4096.0);
|
||||
manager.BindParameter(anodeBack, 4096, 0.0, 4096.0);
|
||||
|
||||
manager.BindVariable(x1_weight);
|
||||
manager.BindVariable(x2_weight);
|
||||
|
|
|
@ -39,6 +39,18 @@ namespace Navigator {
|
|||
|
||||
NavParameter::~NavParameter() {}
|
||||
|
||||
//So that you can make arrays, std::vectors of NavParameters (useful for big detector arrays)
|
||||
//SpectrumManager::BindParameter() still needs to be used after this!
|
||||
void NavParameter::SetName(const std::string& name)
|
||||
{
|
||||
if (m_name != "")
|
||||
{
|
||||
NAV_ERROR("Attempting to change the name of an already bound NavParameter! Set name: {0} New name: {1}", m_name, name);
|
||||
return;
|
||||
}
|
||||
m_name = name;
|
||||
}
|
||||
|
||||
NavVariable::NavVariable() :
|
||||
m_name(""), m_pdata(nullptr)
|
||||
{
|
||||
|
|
|
@ -50,6 +50,7 @@ namespace Navigator {
|
|||
inline void SetValue(double value) { m_pdata->validFlag = true; m_pdata->value = value; }
|
||||
inline double GetValue() const { return m_pdata->value; }
|
||||
inline const std::string& GetName() const { return m_name; }
|
||||
void SetName(const std::string& name);
|
||||
|
||||
friend class SpectrumManager;
|
||||
private:
|
||||
|
|
|
@ -197,6 +197,27 @@ namespace Navigator {
|
|||
param.m_pdata = m_paramMap[param.GetName()];
|
||||
}
|
||||
|
||||
//Bind a NavParameter instance to the manager. If the Parameter doesn't exist, make a new one, otherwise attach to extant memory
|
||||
//Additionally, make a default 1D histogram for the parameter (histogram has same name as parameter)
|
||||
void SpectrumManager::BindParameter(NavParameter& param, int nbins, double minVal, double maxVal)
|
||||
{
|
||||
std::lock_guard<std::mutex> guard(m_managerMutex);
|
||||
auto iter = m_paramMap.find(param.GetName());
|
||||
if (iter == m_paramMap.end())
|
||||
{
|
||||
m_paramMap[param.GetName()].reset(new ParameterData());
|
||||
}
|
||||
|
||||
param.m_pdata = m_paramMap[param.GetName()];
|
||||
|
||||
auto histoIter = m_histoMap.find(param.GetName());
|
||||
if (histoIter == m_histoMap.end())
|
||||
{
|
||||
HistogramParameters histo(param.GetName(), param.GetName(), nbins, minVal, maxVal);
|
||||
m_histoMap[param.GetName()].reset(new Histogram1D(histo));
|
||||
}
|
||||
}
|
||||
|
||||
//Once an analysis pass is done and histograms filled, reset all parameters
|
||||
void SpectrumManager::InvalidateParameters()
|
||||
{
|
||||
|
|
|
@ -55,6 +55,7 @@ namespace Navigator {
|
|||
|
||||
/*Parameter Functions*/
|
||||
void BindParameter(NavParameter& param);
|
||||
void BindParameter(NavParameter& param, int nbins, double maxVal, double minVal);
|
||||
void InvalidateParameters();
|
||||
std::vector<std::string> GetListOfParameters();
|
||||
/*********************/
|
||||
|
|
Loading…
Reference in New Issue
Block a user