File indexing completed on 2025-08-06 08:17:33
0001 #ifndef CALORECO_CALOWAVEFORMFITTING_H
0002 #define CALORECO_CALOWAVEFORMFITTING_H
0003
0004 #include <string>
0005 #include <vector>
0006
0007 class TProfile;
0008
0009 class CaloWaveformFitting
0010 {
0011 public:
0012 CaloWaveformFitting() = default;
0013 ~CaloWaveformFitting();
0014
0015 void set_template_file(const std::string &template_input_file)
0016 {
0017 m_template_input_file = template_input_file;
0018 return;
0019 }
0020
0021 void set_nthreads(int nthreads)
0022 {
0023 _nthreads = nthreads;
0024 return;
0025 }
0026
0027 void set_softwarezerosuppression(bool usezerosuppression, int softwarezerosuppression)
0028 {
0029 _nsoftwarezerosuppression = softwarezerosuppression;
0030 _bdosoftwarezerosuppression = usezerosuppression;
0031 }
0032 void set_maxsoftwarezerosuppression(bool usezerosuppression, int softwarezerosuppression)
0033 {
0034 _nsoftwarezerosuppression = softwarezerosuppression;
0035 _maxsoftwarezerosuppression = usezerosuppression;
0036 }
0037
0038 int get_nthreads()
0039 {
0040 return _nthreads;
0041 }
0042 void set_timeFitLim(float low, float high)
0043 {
0044 m_setTimeLim = true;
0045 m_timeLim_low = low;
0046 m_timeLim_high = high;
0047 return;
0048 }
0049
0050 void set_bitFlipRecovery(bool dobitfliprecovery)
0051 {
0052 _dobitfliprecovery = dobitfliprecovery;
0053 }
0054
0055 void set_handleSaturation(bool handleSaturation = true)
0056 {
0057 _handleSaturation = handleSaturation;
0058 }
0059
0060 std::vector<std::vector<float>> process_waveform(std::vector<std::vector<float>> waveformvector);
0061 std::vector<std::vector<float>> calo_processing_templatefit(std::vector<std::vector<float>> chnlvector);
0062 static std::vector<std::vector<float>> calo_processing_fast(const std::vector<std::vector<float>> &chnlvector);
0063 std::vector<std::vector<float>> calo_processing_nyquist(const std::vector<std::vector<float>> &chnlvector);
0064
0065 void initialize_processing(const std::string &templatefile);
0066
0067 private:
0068 static void FastMax(float x0, float x1, float x2, float y0, float y1, float y2, float &xmax, float &ymax);
0069 std::vector<float> NyquistInterpolation(std::vector<float> &vec_signal_samples);
0070 static double Dkernelodd(double x, int N);
0071 static double Dkernel(double x, int N);
0072
0073 static float stablepsinc(float t, std::vector<float> &vec_signal_samples);
0074
0075 static float psinc(float t, std::vector<float> &vec_signal_samples);
0076 double template_function(double *x, double *par);
0077
0078 TProfile *h_template{nullptr};
0079 double m_peakTimeTemp{0};
0080 int _nthreads{1};
0081 int _nzerosuppresssamples{2};
0082 int _nsoftwarezerosuppression{40};
0083
0084 float m_timeLim_low{-3.0};
0085 float m_timeLim_high{4.0};
0086 float _chi2threshold{100000};
0087 float _chi2lowthreshold{10000};
0088 float _bfr_lowpedestalthreshold{1200};
0089 float _bfr_highpedestalthreshold{4000};
0090 bool _bdosoftwarezerosuppression{false};
0091 bool _maxsoftwarezerosuppression{false};
0092 bool m_setTimeLim{false};
0093 bool _dobitfliprecovery{false};
0094 bool _handleSaturation{true};
0095
0096 std::string m_template_input_file;
0097 std::string url_template;
0098 std::string url_onnx;
0099 std::string m_model_name;
0100 };
0101 #endif