Back to home page

sPhenix code displayed by LXR

 
 

    


File indexing completed on 2025-12-17 09:19:58

0001 #ifndef CALORECO_CALOWAVEFORMPROCESSING_H
0002 #define CALORECO_CALOWAVEFORMPROCESSING_H
0003 
0004 #include <fun4all/SubsysReco.h>
0005 
0006 #include <array>
0007 #include <string>
0008 #include <vector>
0009 
0010 class CaloWaveformFitting;
0011 
0012 class CaloWaveformProcessing : public SubsysReco
0013 {
0014  public:
0015   enum process
0016   {
0017     NONE = 0,
0018     TEMPLATE = 1,
0019     ONNX = 2,
0020     FAST = 3,
0021     NYQUIST = 4,
0022     TEMPLATE_NOSAT = 5,
0023   };
0024 
0025   CaloWaveformProcessing() = default;
0026   ~CaloWaveformProcessing() override;
0027 
0028   void set_processing_type(CaloWaveformProcessing::process modelno)
0029   {
0030     m_processingtype = modelno;
0031     return;
0032   }
0033 
0034   CaloWaveformProcessing::process get_processing_type()
0035   {
0036     return m_processingtype;
0037   }
0038 
0039   void set_template_file(const std::string &template_input_file)
0040   {
0041     m_template_input_file = template_input_file;
0042     return;
0043   }
0044 
0045   void set_template_name(const std::string &template_name)
0046   {
0047     m_template_name = template_name;
0048     return;
0049   }
0050   void set_model_file(const std::string &model_name)
0051   {
0052     m_model_name = model_name;
0053     return;
0054   }
0055 
0056   void set_nthreads(int nthreads);
0057 
0058   int get_nthreads();
0059 
0060   void set_softwarezerosuppression(bool usezerosuppression, int softwarezerosuppression)
0061   {
0062     _nsoftwarezerosuppression = softwarezerosuppression;
0063     _bdosoftwarezerosuppression = usezerosuppression;
0064   }
0065   void set_timeFitLim(float low, float high)
0066   {
0067     m_setTimeLim = true;
0068     m_timeLim_low = low;
0069     m_timeLim_high = high;
0070     return;
0071   }
0072 
0073   void set_bitFlipRecovery(bool dobitfliprecovery)
0074   {
0075     _dobitfliprecovery = dobitfliprecovery;
0076   }
0077 
0078   std::vector<std::vector<float>> process_waveform(std::vector<std::vector<float>> waveformvector);
0079   std::vector<std::vector<float>> calo_processing_ONNX(const std::vector<std::vector<float>> &chnlvector);
0080 
0081   void initialize_processing();
0082 
0083   // onnx options
0084   void set_onnx_factor(const int i, const double val) { m_Onnx_factor.at(i) = val; }
0085   void set_onnx_offset(const int i, const double val) { m_Onnx_offset.at(i) = val; }
0086 
0087  private:
0088   CaloWaveformFitting *m_Fitter{nullptr};
0089 
0090   CaloWaveformProcessing::process m_processingtype{CaloWaveformProcessing::TEMPLATE};
0091   int _nthreads{1};
0092   int _nzerosuppresssamples{2};
0093 
0094   int _nsoftwarezerosuppression{40};
0095   bool _bdosoftwarezerosuppression{false};
0096   bool _dobitfliprecovery{false};
0097 
0098   std::string m_template_input_file;
0099   std::string url_template;
0100   std::string m_template_name{"NONE"};
0101 
0102   bool m_setTimeLim{false};
0103   bool _maxsoftwarezerosuppression{false};
0104   float m_timeLim_low{-3.0};
0105   float m_timeLim_high{4.0};
0106 
0107   std::string url_onnx;
0108   std::string m_model_name{"CEMC_ONNX"};
0109   std::array<double, 4> m_Onnx_factor{std::numeric_limits<double>::quiet_NaN(), std::numeric_limits<double>::quiet_NaN(), std::numeric_limits<double>::quiet_NaN(), std::numeric_limits<double>::quiet_NaN()};
0110   std::array<double, 4> m_Onnx_offset{std::numeric_limits<double>::quiet_NaN(), std::numeric_limits<double>::quiet_NaN(), std::numeric_limits<double>::quiet_NaN(), std::numeric_limits<double>::quiet_NaN()};
0111 };
0112 
0113 #endif