CbmRoot
Loading...
Searching...
No Matches
PronyFitter.h
Go to the documentation of this file.
1/* Copyright (C) 2020-2021 Institute for Nuclear Research, Moscow
2 SPDX-License-Identifier: GPL-3.0-only
3 Authors: Nikolay Karpushkin [committer] */
4
11#ifndef PronyFitter_H
12#define PronyFitter_H
13
14#include <algorithm> // for reverse
15#include <complex> // for complex numbers
16#include <cstring> // for memcpy
17#include <iostream>
18#include <vector> // for std::vector
19
20#include <stdint.h> // for uint16_t
21#include <stdio.h> // for printf
22
23namespace PsdSignalFitting
24{
26
27 public:
30 PronyFitter(int model_order, int exponent_number, int gate_beg, int gate_end);
31
34
35 int CalcSignalBegin(float front_time_beg_03, float front_time_end);
36 int ChooseBestSignalBeginHarmonics(int first_sample, int last_sample);
37 int ChooseBestSignalBegin(int first_sample, int last_sample);
38 void MakePileUpRejection(int time_max);
41 void SolveSLEGauss(float* x, float** r, float* b, int n);
42 void SolveSLEGauss(std::complex<float>* x, std::complex<float>** r, std::complex<float>* b, int n);
43 void SolveSLECholesky(float* x, float** a, float* b, int n);
44 void CovarianceQRmod(float& rho_f, std::vector<float>& a_f, float& rho_b, std::vector<float>& a_b);
45 void CovarianceDirect(float& rho_f, std::vector<float>& a_f, float& rho_b, std::vector<float>& a_b);
46 float LevelBy2Points(float X1, float Y1, float X2, float Y2, float Y0);
47 //
48 // Setters
49 //
50 void SetDebugMode(bool IsDebug) { fIsDebug = IsDebug; };
51 void SetWaveform(std::vector<uint16_t>& uWfm, uint16_t uZeroLevel);
52 void SetSignalBegin(int SignalBeg);
53 void SetHarmonics(std::complex<float>* z);
54 void SetExternalHarmonics(std::complex<float> z1, std::complex<float> z2);
55 //
56 // Getters
57 //
58 std::complex<float>* GetHarmonics();
59 std::complex<float>* GetAmplitudes();
60 float GetIntegral(int gate_beg, int gate_end);
61 uint16_t GetFitValue(int sample_number);
62 float GetFitValue(float x);
63 float GetZeroLevel();
64 float GetX(float level, int first_sample, int last_sample);
65 float GetX(float level, int first_sample, int last_sample, float step);
66 float GetRSquare(int gate_beg, int gate_end);
67 float GetRSquareSignal();
68 float GetChiSquare(int gate_beg, int gate_end, int time_max);
69 float GetDeltaInSample(int sample);
71 float GetSignalMaxTime();
72 float GetMaxAmplitude();
74 std::vector<uint16_t> GetFitWfm() { return fuFitWfm; }
75
76 private:
77 void Initialize(int model_order, int exponent_number, int gate_beg, int gate_end);
78 void AllocData();
79 void DeleteData();
80 void Clear();
81
82 bool fIsDebug = false;
88
91
92 std::vector<uint16_t> fuWfm;
93 uint16_t fuZeroLevel;
94 std::complex<float>* fz;
95 std::complex<float>* fh;
96 std::vector<uint16_t> fuFitWfm;
98 };
99} // namespace PsdSignalFitting
100
101#endif
uint16_t GetFitValue(int sample_number)
void CovarianceDirect(float &rho_f, std::vector< float > &a_f, float &rho_b, std::vector< float > &a_b)
void SetSignalBegin(int SignalBeg)
void SetExternalHarmonics(std::complex< float > z1, std::complex< float > z2)
void SolveSLEGauss(float *x, float **r, float *b, int n)
std::complex< float > * fz
Definition PronyFitter.h:94
std::vector< uint16_t > GetFitWfm()
Definition PronyFitter.h:74
void CovarianceQRmod(float &rho_f, std::vector< float > &a_f, float &rho_b, std::vector< float > &a_b)
float GetRSquare(int gate_beg, int gate_end)
void SetHarmonics(std::complex< float > *z)
std::vector< uint16_t > fuWfm
Definition PronyFitter.h:92
int CalcSignalBegin(float front_time_beg_03, float front_time_end)
std::complex< float > * GetHarmonics()
int ChooseBestSignalBeginHarmonics(int first_sample, int last_sample)
void SetDebugMode(bool IsDebug)
Definition PronyFitter.h:50
std::complex< float > * GetAmplitudes()
void SetWaveform(std::vector< uint16_t > &uWfm, uint16_t uZeroLevel)
int ChooseBestSignalBegin(int first_sample, int last_sample)
float GetDeltaInSample(int sample)
float GetChiSquare(int gate_beg, int gate_end, int time_max)
float GetX(float level, int first_sample, int last_sample)
void Initialize(int model_order, int exponent_number, int gate_beg, int gate_end)
std::complex< float > * fh
Definition PronyFitter.h:95
float LevelBy2Points(float X1, float Y1, float X2, float Y2, float Y0)
void MakePileUpRejection(int time_max)
float GetIntegral(int gate_beg, int gate_end)
void SolveSLECholesky(float *x, float **a, float *b, int n)
std::vector< uint16_t > fuFitWfm
Definition PronyFitter.h:96