SourceXtractorPlusPlus 0.19
SourceXtractor++, the next generation SExtractor
Loading...
Searching...
No Matches
FlexibleModelFittingParameterManager.h
Go to the documentation of this file.
1
17/*
18 * FlexibleModelFittingParameterManager.h
19 *
20 * Created on: Oct 9, 2018
21 * Author: mschefer
22 */
23
24#ifndef _SEIMPLEMENTATION_PLUGIN_FLEXIBLEMODELFITTING_FLEXIBLEMODELFITTINGPARAMETERMANAGER_H_
25#define _SEIMPLEMENTATION_PLUGIN_FLEXIBLEMODELFITTING_FLEXIBLEMODELFITTINGPARAMETERMANAGER_H_
26
27#include <map>
28#include <vector>
29
33
34namespace SourceXtractor {
35
36// Needed to store the source in a reference_wrapper
38 return &a.get() < &b.get();
39}
40
41class FlexibleModelFittingParameter;
42
44
45public:
46
49
50
53
54 auto key = std::make_tuple(std::cref(source), parameter);
55 m_accessed_params.insert(key);
56 followDependencies(source, parameter);
57 auto p = m_params.at(key);
58 return p;
59 }
60
63 m_params[std::make_tuple(std::cref(source), parameter)] = engine_parameter;
64
65 if (std::dynamic_pointer_cast<const FlexibleModelFittingFreeParameter>(parameter)) {
67 }
68 }
69
70 int getParameterNb() const {
71 return m_params.size();
72 }
73
75 m_accessed_params.clear();
76 }
77
79 auto key = std::make_tuple(std::cref(source), parameter);
80 return m_accessed_params.count(key) > 0;
81 }
82
84 return m_parameter_indices.at(engine_parameter);
85 }
86
88 return getParameterIndex(getParameter(source, parameter));
89 }
90
91private:
94
95 // remember the order of the parameters for model fitting (used to retrieve sigma)
98
99 // Propagate access to dependees
101 auto dependent_parameter = std::dynamic_pointer_cast<const FlexibleModelFittingDependentParameter>(parameter).get();
102 if (dependent_parameter) {
103 for (auto &dependee : dependent_parameter->getDependees()) {
104 auto key_dependee = std::make_tuple(std::cref(source), dependee);
105 m_accessed_params.insert(key_dependee);
106 followDependencies(source, dependee);
107 }
108 }
109 }
110};
111
112}
113
114
115
116#endif /* _SEIMPLEMENTATION_PLUGIN_FLEXIBLEMODELFITTING_FLEXIBLEMODELFITTINGPARAMETERMANAGER_H_ */
T at(T... args)
int getParameterIndex(const SourceInterface &source, std::shared_ptr< const FlexibleModelFittingParameter > parameter) const
std::map< std::tuple< std::reference_wrapper< const SourceInterface >, std::shared_ptr< const FlexibleModelFittingParameter > >, std::shared_ptr< ModelFitting::BasicParameter > > m_params
std::set< std::tuple< std::reference_wrapper< const SourceInterface >, std::shared_ptr< const FlexibleModelFittingParameter > > > m_accessed_params
std::map< std::shared_ptr< ModelFitting::BasicParameter >, int > m_parameter_indices
int getParameterIndex(std::shared_ptr< ModelFitting::BasicParameter > engine_parameter) const
void followDependencies(const SourceInterface &source, std::shared_ptr< const FlexibleModelFittingParameter > parameter) const
void addParameter(const SourceInterface &source, std::shared_ptr< const FlexibleModelFittingParameter > parameter, std::shared_ptr< ModelFitting::BasicParameter > engine_parameter)
bool isParamAccessed(const SourceInterface &source, std::shared_ptr< const FlexibleModelFittingParameter > parameter) const
std::shared_ptr< ModelFitting::BasicParameter > getParameter(const SourceInterface &source, std::shared_ptr< const FlexibleModelFittingParameter > parameter) const
The SourceInterface is an abstract "source" that has properties attached to it.
T make_tuple(T... args)
bool operator<(std::reference_wrapper< const SourceInterface > a, std::reference_wrapper< const SourceInterface > b)
T cref(T... args)