DDASToys for NSCLDAQ  6.2-000
FitManager.h
Go to the documentation of this file.
1 /*
2  This software is Copyright by the Board of Trustees of Michigan
3  State University (c) Copyright 2017.
4 
5  You may use this software under the terms of the GNU public license
6  (GPL). The terms of this license are described at:
7 
8  http://www.gnu.org/licenses/gpl.txt
9 
10  Authors:
11  Aaron Chester
12  FRIB
13  Michigan State University
14  East Lansing, MI 48824-1321
15 */
16 
24 #ifndef FITMANAGER_H
25 #define FITMANAGER_H
26 
27 #include <vector>
28 #include <cstdint>
29 #include <string>
30 
31 class QWidget;
32 
33 namespace ddastoys {
34  struct HitExtension;
35  class DDASFitHit;
36  class Configuration;
37 }
38 
52 // Overkill probably but:
53 // 1) I don't want to remember flag values
54 // 2) Adding more fitting methods by name may be nice
55 // 3) I felt like making an enum
56 
58 enum fitMethod {
62 };
63 
65 {
66 public:
68  FitManager();
70  ~FitManager();
71 
76  void configure(std::string method);
78  void readConfigFile();
80  void readTemplateFile();
90  std::vector<double> getSinglePulseFit(
91  const ddastoys::HitExtension& ext, unsigned low, unsigned high
92  );
102  std::vector<double> getDoublePulseFit(
103  const ddastoys::HitExtension& ext, unsigned low, unsigned high
104  );
110  unsigned getLowFitLimit(const ddastoys::DDASFitHit& hit);
116  unsigned getHighFitLimit(const ddastoys::DDASFitHit& hit);
117 
122  void setMethod(fitMethod m) { m_method = m; };
127  enum fitMethod getMethod() { return m_method; };
128 
129 private:
140  double singlePulse(
141  double A1, double k1, double k2, double x1, double C, double x
142  );
157  double doublePulse(
158  double A1, double k1, double k2, double x1,
159  double A2, double k3, double k4, double x2,
160  double C, double x
161  );
169  bool checkParamValue(double param);
174  void issueWarning(std::string msg);
175 
176 private:
177  ddastoys::Configuration* m_pConfig; //<! Configuration file manager.
178  fitMethod m_method;
179  bool m_config;
180  bool m_templateConfig;
181 };
182 
183 #endif
fitMethod
Fit method enum class.
Definition: FitManager.h:58
@ ANALYTIC
Analytic fit.
Definition: FitManager.h:59
@ TEMPLATE
Template fit.
Definition: FitManager.h:60
@ ML_INFERENCE
Machine learning inference fit.
Definition: FitManager.h:61
Provides an interface for calculating trace fits using HitExtension fit parameters.
Definition: FitManager.h:65
void configure(std::string method)
Configure the fit method settings.
Definition: FitManager.cpp:69
unsigned getLowFitLimit(const ddastoys::DDASFitHit &hit)
Get the lower limit of the fit range.
Definition: FitManager.cpp:203
void readTemplateFile()
Read the template file using the Configuration class.
Definition: FitManager.cpp:125
void readConfigFile()
Read the configuration file using the Configuration class.
Definition: FitManager.cpp:106
std::vector< double > getSinglePulseFit(const ddastoys::HitExtension &ext, unsigned low, unsigned high)
Create and return a vector of fit values for each trace sample in the fit range.
Definition: FitManager.cpp:140
enum fitMethod getMethod()
Get the fitting method.
Definition: FitManager.h:127
void setMethod(fitMethod m)
Set the fitting method.
Definition: FitManager.h:122
~FitManager()
Destructor.
Definition: FitManager.cpp:55
std::vector< double > getDoublePulseFit(const ddastoys::HitExtension &ext, unsigned low, unsigned high)
Create and return a vector of fit values for each trace sample in the fit range.
Definition: FitManager.cpp:172
FitManager()
Constructor.
Definition: FitManager.cpp:43
unsigned getHighFitLimit(const ddastoys::DDASFitHit &hit)
Get the upper limit of the fit range.
Definition: FitManager.cpp:221
Manage fit configuration information.
Definition: Configuration.h:68
Encapsulates data for DDAS hits that may have fitted traces.
Definition: DDASFitHit.h:46
The data structure appended to each fit hit.
Definition: fit_extensions.h:82