NSCL DDAS  1.0
Support for XIA DDAS at the NSCL
 All Classes Namespaces Files Functions Variables Macros Pages
lmfit.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  Ron Fox
12  Jeromy Tompkins
13  NSCL
14  Michigan State University
15  East Lansing, MI 48824-1321
16 */
17 
21 #ifndef LMFIT_H
22 #define LMFIT_H
23 #include <vector>
24 #include <stdint.h>
25 namespace DDAS {
26 // The following structs are used by the fitting
27 // functions.
28 
29 // Describes a single pulse without an offset.
30 
32  double position; // Where the pusle is.
33  double amplitude; // Pulse amplitude
34  double steepness; // Logistic steepness factor.
35  double decayTime; // Decay time constant.
36 };
37 
38 // Full fitting information for the single pulse:
39 
40 struct fit1Info { // Info from single pulse fit:
41  unsigned iterations; // Iterations for fit to converge
42  unsigned fitStatus; // fit status from GSL.
43  double chiSquare;
44  PulseDescription pulse;
45  double offset; // Constant offset.
46 
47 };
48 
49 // Full fitting information for the double pulse:
50 
51 struct fit2Info { // info from double pulse fit:
52  unsigned iterations; // Iterations needed to converge.
53  unsigned fitStatus; // Fit status from GSL
54  double chiSquare;
55  PulseDescription pulses[2]; // The two pulses
56  double offset; // Ofset on which they sit.
57 };
58 
59 // For good measure here's what we append to a DDAS Hit that's
60 // had its trace fitted.
61 
62 struct HitExtension { // Data added to hits with traces:
63  fit1Info onePulseFit;
64  fit2Info twoPulseFit;
65 };
66 // This struct is passed around the fitting subsystem to jacobian
67 // and function evaluators.
68 //
70  const std::vector<std::pair<uint16_t, uint16_t> >* s_pPoints;
71 };
72 
73 
74 void lmfit1(
75  fit1Info* pResult, std::vector<uint16_t>& trace,
76  const std::pair<unsigned, unsigned>& limits, uint16_t saturation = 0xffff
77 );
78 void lmfit2(
79  fit2Info* pResult, std::vector<uint16_t>& trace,
80  const std::pair<unsigned, unsigned>& limits,
81  fit1Info* pSinglePulseFit = nullptr, uint16_t saturation = 0xffff
82 );
83 
84 void lmfit2fixedT(
85  fit2Info* pResult, std::vector<uint16_t>& trace,
86  const std::pair<unsigned, unsigned>& limits,
87  fit1Info* pSinglePulseFit = nullptr, uint16_t saturation = 0xffff
88 );
89 
90 };
91 
92 #endif
Definition: lmfit.h:69
Definition: lmfit.h:51
Definition: lmfit.h:62
Definition: lmfit.h:40
Definition: functions.h:26
Definition: lmfit.h:31