CbmRoot
PronyFitter.h
Go to the documentation of this file.
1 
7 #ifndef PronyFitter_H
8 #define PronyFitter_H
9 
10 #include <algorithm> // for reverse
11 #include <complex> // for complex numbers
12 #include <cstring> // for memcpy
13 #include <iostream>
14 #include <stdint.h> // for uint16_t
15 #include <stdio.h> // for printf
16 #include <vector> // for std::vector
17 
18 namespace PsdSignalFitting {
19  class PronyFitter {
20 
21  public:
24  PronyFitter(int model_order,
25  int exponent_number,
26  int gate_beg,
27  int gate_end);
28 
30  ~PronyFitter() { Clear(); };
31 
32  int CalcSignalBegin(float front_time_beg_03, float front_time_end);
33  int ChooseBestSignalBeginHarmonics(int first_sample, int last_sample);
34  int ChooseBestSignalBegin(int first_sample, int last_sample);
35  void MakePileUpRejection(int time_max);
36  void CalculateFitHarmonics();
38  void SolveSLEGauss(float* x, float** r, float* b, int n);
39  void SolveSLEGauss(std::complex<float>* x,
40  std::complex<float>** r,
41  std::complex<float>* b,
42  int n);
43  void SolveSLECholesky(float* x, float** a, float* b, int n);
44  void CovarianceQRmod(float& rho_f,
45  std::vector<float>& a_f,
46  float& rho_b,
47  std::vector<float>& a_b);
48  void CovarianceDirect(float& rho_f,
49  std::vector<float>& a_f,
50  float& rho_b,
51  std::vector<float>& a_b);
52  float LevelBy2Points(float X1, float Y1, float X2, float Y2, float Y0);
53  //
54  // Setters
55  //
56  void SetDebugMode(bool IsDebug) { fIsDebug = IsDebug; };
57  void SetWaveform(std::vector<uint16_t>& uWfm, uint16_t uZeroLevel);
58  void SetSignalBegin(int SignalBeg);
59  void SetHarmonics(std::complex<float>* z);
60  void SetExternalHarmonics(std::complex<float> z1, std::complex<float> z2);
61  //
62  // Getters
63  //
64  std::complex<float>* GetHarmonics();
65  std::complex<float>* GetAmplitudes();
66  float GetIntegral(int gate_beg, int gate_end);
67  uint16_t GetFitValue(int sample_number);
68  float GetFitValue(float x);
69  float GetZeroLevel();
70  float GetX(float level, int first_sample, int last_sample);
71  float GetX(float level, int first_sample, int last_sample, float step);
72  float GetRSquare(int gate_beg, int gate_end);
73  float GetRSquareSignal();
74  float GetChiSquare(int gate_beg, int gate_end, int time_max);
75  float GetDeltaInSample(int sample);
77  float GetSignalMaxTime();
78  float GetMaxAmplitude();
79  int GetNumberPolRoots();
80  std::vector<uint16_t> GetFitWfm() { return fuFitWfm; }
81 
82  private:
83  void Initialize(int model_order,
84  int exponent_number,
85  int gate_beg,
86  int gate_end);
87  void AllocData();
88  void DeleteData();
89  void Clear();
90 
91  bool fIsDebug = false;
94  int fGateBeg;
95  int fGateEnd;
97 
100 
101  std::vector<uint16_t> fuWfm;
102  uint16_t fuZeroLevel;
103  std::complex<float>* fz;
104  std::complex<float>* fh;
105  std::vector<uint16_t> fuFitWfm;
106  uint16_t fuFitZeroLevel;
107  };
108 } // namespace PsdSignalFitting
109 
110 #endif
PsdSignalFitting::PronyFitter::fSignalBegin
int fSignalBegin
Definition: PronyFitter.h:98
PsdSignalFitting::PronyFitter::SetSignalBegin
void SetSignalBegin(int SignalBeg)
Definition: PronyFitter.cxx:48
PsdSignalFitting::PronyFitter::DeleteData
void DeleteData()
Definition: PronyFitter.cxx:995
PsdSignalFitting::PronyFitter::CovarianceDirect
void CovarianceDirect(float &rho_f, std::vector< float > &a_f, float &rho_b, std::vector< float > &a_b)
Definition: PronyFitter.cxx:122
PsdSignalFitting::PronyFitter::fuZeroLevel
uint16_t fuZeroLevel
Definition: PronyFitter.h:102
PsdSignalFitting::PronyFitter::SetHarmonics
void SetHarmonics(std::complex< float > *z)
Definition: PronyFitter.cxx:424
PsdSignalFitting::PronyFitter::fGateBeg
int fGateBeg
Definition: PronyFitter.h:94
PsdSignalFitting::PronyFitter::fGateEnd
int fGateEnd
Definition: PronyFitter.h:95
PsdSignalFitting::PronyFitter::~PronyFitter
~PronyFitter()
Definition: PronyFitter.h:30
PsdSignalFitting::PronyFitter::GetIntegral
float GetIntegral(int gate_beg, int gate_end)
Definition: PronyFitter.cxx:546
PsdSignalFitting::PronyFitter::GetFitWfm
std::vector< uint16_t > GetFitWfm()
Definition: PronyFitter.h:80
PsdSignalFitting::PronyFitter::GetRSquareSignal
float GetRSquareSignal()
Definition: PronyFitter.cxx:681
PsdSignalFitting::PronyFitter::ChooseBestSignalBeginHarmonics
int ChooseBestSignalBeginHarmonics(int first_sample, int last_sample)
Definition: PronyFitter.cxx:760
PsdSignalFitting::PronyFitter
Definition: PronyFitter.h:19
PsdSignalFitting::PronyFitter::GetDeltaInSample
float GetDeltaInSample(int sample)
Definition: PronyFitter.cxx:733
PsdSignalFitting::PronyFitter::Clear
void Clear()
Definition: PronyFitter.cxx:1000
PsdSignalFitting::PronyFitter::GetNumberPolRoots
int GetNumberPolRoots()
Definition: PronyFitter.cxx:442
PsdSignalFitting::PronyFitter::fuFitZeroLevel
uint16_t fuFitZeroLevel
Definition: PronyFitter.h:106
PsdSignalFitting::PronyFitter::GetSignalMaxTime
float GetSignalMaxTime()
Definition: PronyFitter.cxx:574
PsdSignalFitting::PronyFitter::fuFitWfm
std::vector< uint16_t > fuFitWfm
Definition: PronyFitter.h:105
PsdSignalFitting::PronyFitter::GetAmplitudes
std::complex< float > * GetAmplitudes()
Definition: PronyFitter.cxx:544
PsdSignalFitting::PronyFitter::GetFitValue
uint16_t GetFitValue(int sample_number)
Definition: PronyFitter.cxx:555
PsdSignalFitting::PronyFitter::SetWaveform
void SetWaveform(std::vector< uint16_t > &uWfm, uint16_t uZeroLevel)
Definition: PronyFitter.cxx:35
PsdSignalFitting::PronyFitter::LevelBy2Points
float LevelBy2Points(float X1, float Y1, float X2, float Y2, float Y0)
Definition: PronyFitter.cxx:648
z2
Double_t z2[nSects2]
Definition: pipe_v16a_mvdsts100.h:11
PsdSignalFitting::PronyFitter::GetRSquare
float GetRSquare(int gate_beg, int gate_end)
Definition: PronyFitter.cxx:656
PsdSignalFitting::PronyFitter::fTotalPolRoots
int fTotalPolRoots
Definition: PronyFitter.h:99
PsdSignalFitting::PronyFitter::CovarianceQRmod
void CovarianceQRmod(float &rho_f, std::vector< float > &a_f, float &rho_b, std::vector< float > &a_b)
Definition: PronyFitter.cxx:188
PsdSignalFitting::PronyFitter::fz
std::complex< float > * fz
Definition: PronyFitter.h:103
PsdSignalFitting::PronyFitter::fuWfm
std::vector< uint16_t > fuWfm
Definition: PronyFitter.h:101
PsdSignalFitting::PronyFitter::CalcSignalBegin
int CalcSignalBegin(float front_time_beg_03, float front_time_end)
Definition: PronyFitter.cxx:43
PsdSignalFitting::PronyFitter::fIsDebug
bool fIsDebug
Definition: PronyFitter.h:91
PsdSignalFitting::PronyFitter::GetZeroLevel
float GetZeroLevel()
Definition: PronyFitter.cxx:572
PsdSignalFitting::PronyFitter::fh
std::complex< float > * fh
Definition: PronyFitter.h:104
PsdSignalFitting::PronyFitter::SolveSLEGauss
void SolveSLEGauss(float *x, float **r, float *b, int n)
Definition: PronyFitter.cxx:817
PsdSignalFitting::PronyFitter::GetX
float GetX(float level, int first_sample, int last_sample)
Definition: PronyFitter.cxx:592
PsdSignalFitting::PronyFitter::Initialize
void Initialize(int model_order, int exponent_number, int gate_beg, int gate_end)
Definition: PronyFitter.cxx:15
x
Double_t x
Definition: CbmMvdSensorDigiToHitTask.cxx:68
PsdSignalFitting::PronyFitter::fExpNumber
int fExpNumber
Definition: PronyFitter.h:93
PsdSignalFitting::PronyFitter::SetDebugMode
void SetDebugMode(bool IsDebug)
Definition: PronyFitter.h:56
PsdSignalFitting::PronyFitter::ChooseBestSignalBegin
int ChooseBestSignalBegin(int first_sample, int last_sample)
Definition: PronyFitter.cxx:798
PsdSignalFitting::PronyFitter::fSampleTotal
int fSampleTotal
Definition: PronyFitter.h:96
PsdSignalFitting::PronyFitter::SolveSLECholesky
void SolveSLECholesky(float *x, float **a, float *b, int n)
Definition: PronyFitter.cxx:949
PsdSignalFitting::PronyFitter::CalculateFitAmplitudes
void CalculateFitAmplitudes()
Definition: PronyFitter.cxx:446
PsdSignalFitting::PronyFitter::AllocData
void AllocData()
Definition: PronyFitter.cxx:26
PsdSignalFitting::PronyFitter::GetHarmonics
std::complex< float > * GetHarmonics()
Definition: PronyFitter.cxx:440
PsdSignalFitting::PronyFitter::GetMaxAmplitude
float GetMaxAmplitude()
Definition: PronyFitter.cxx:588
z1
Double_t z1[nSects1]
Definition: pipe_v16a_mvdsts100.h:6
PsdSignalFitting::PronyFitter::CalculateFitHarmonics
void CalculateFitHarmonics()
Definition: PronyFitter.cxx:54
PsdSignalFitting::PronyFitter::PronyFitter
PronyFitter()
Definition: PronyFitter.h:23
PsdSignalFitting::PronyFitter::fModelOrder
int fModelOrder
Definition: PronyFitter.h:92
PsdSignalFitting::PronyFitter::SetExternalHarmonics
void SetExternalHarmonics(std::complex< float > z1, std::complex< float > z2)
Definition: PronyFitter.cxx:428
PsdSignalFitting
Definition: PronyFitter.cxx:5
PsdSignalFitting::PronyFitter::GetChiSquare
float GetChiSquare(int gate_beg, int gate_end, int time_max)
Definition: PronyFitter.cxx:685
PsdSignalFitting::PronyFitter::MakePileUpRejection
void MakePileUpRejection(int time_max)
Definition: PronyFitter.cxx:444
PsdSignalFitting::PronyFitter::GetSignalBeginFromPhase
float GetSignalBeginFromPhase()
Definition: PronyFitter.cxx:581