File indexing completed on 2026-07-16 08:12:43
0001 #ifndef SEPDWAVEFORM_H
0002 #define SEPDWAVEFORM_H
0003
0004 #include <calobase/TowerInfoDefs.h>
0005 #include <fun4all/SubsysReco.h>
0006 #include <fun4all/Fun4AllHistoManager.h>
0007 #include <TFile.h>
0008 #include <TTree.h>
0009 #include <TProfile.h>
0010 #include <TH2F.h>
0011
0012 #include "caloreco/CaloTowerBuilder.h"
0013 #include <caloreco/CaloWaveformProcessing.h>
0014
0015 #include <string>
0016 #include <vector>
0017
0018 class PHCompositeNode;
0019 class CaloWaveformProcessing;
0020 class TGraph;
0021 class TProfile2D;
0022
0023 class sEPDWaveform : public SubsysReco
0024 {
0025 public:
0026 sEPDWaveform(const std::string &name = "sEPDWaveform");
0027
0028 ~sEPDWaveform() override;
0029
0030 int Init(PHCompositeNode *topNode) override;
0031
0032 int process_event(PHCompositeNode *topNode) override;
0033
0034 int ResetEvent(PHCompositeNode *topNode) override;
0035
0036 int End(PHCompositeNode *topNode) override;
0037
0038 void Print(const std::string &what = "ALL") const override;
0039
0040 void SetDetector(const std::string &name) { m_Detector = name; }
0041 void SetPacketRange(int low, int high)
0042 {
0043 m_packet_low = low;
0044 m_packet_high = high;
0045 }
0046 void SetNSamples(int n) { m_n_samples = n; }
0047
0048 void SetUseOfflinePackets(bool b) { m_offline = b; }
0049 void SetOutputFileName(const std::string &name) { m_outputFileName = name; }
0050
0051 void SetFillGeometryHistograms(bool fill) { m_fill_geometry_histos = fill; }
0052 void SetFillGlobalHistograms(bool fill) { m_fill_global_histos = fill; }
0053 void SetProgressInterval(int interval) { m_progress_interval = interval; }
0054 void SetShowProgress(bool show) { m_show_progress = show; }
0055
0056 private:
0057
0058 void ShowProgress(int current, int total);
0059
0060 unsigned int (*encode_tower)(const unsigned int) = TowerInfoDefs::encode_epd;
0061
0062 static const int NARM = 2;
0063 static const int NRING = 16;
0064 static const int NPHI = 24;
0065 static const int NPHI_RING0 = 12;
0066
0067 std::string m_Detector = "SEPD";
0068 std::string m_outputFileName = "sEPD_templates.root";
0069 int m_packet_low = 9001;
0070 int m_packet_high = 9006;
0071 int m_nchannels = 128;
0072 int m_n_samples = 12;
0073
0074 int m_template_nbins = 300;
0075
0076 double m_target_hm = 4.5;
0077 bool m_offline = true;
0078
0079 bool m_fill_geometry_histos = true;
0080 bool m_fill_global_histos = true;
0081 bool m_show_progress = true;
0082 int m_progress_interval = 100;
0083
0084 TFile *m_file = nullptr;
0085 TTree *m_tree = nullptr;
0086
0087 std::vector<int> m_arm;
0088 std::vector<int> m_ring;
0089 std::vector<int> m_phibin;
0090 std::vector<double> m_peak;
0091 std::vector<double> m_peaktime;
0092 std::vector<double> m_pedestal;
0093 std::vector<double> m_ADC_peak;
0094 std::vector<double> m_ADC_peaktime;
0095 std::vector<double> m_1par_peak;
0096 std::vector<double> m_1par_pedestal;
0097 std::vector<double> m_2par_peak;
0098 std::vector<double> m_2par_pedestal;
0099 std::vector<double> m_par_peaktime;
0100 std::vector<std::vector<double>> m_waveform;
0101
0102 std::map<std::pair<unsigned int, unsigned int>, int> m_masktower;
0103
0104 Fun4AllHistoManager *hm = nullptr;
0105
0106 TProfile *hpwaveform_1[NARM][NRING] = {{nullptr}};
0107 TProfile *hpwaveform_2[NARM][NRING] = {{nullptr}};
0108 TProfile *hpwaveform_3[NARM][NRING] = {{nullptr}};
0109 TProfile *hpwaveform_1_sum = nullptr;
0110 TProfile *hpwaveform_2_sum = nullptr;
0111 TProfile *hpwaveform_3_sum = nullptr;
0112
0113 TH2F *h2waveform_1[NARM][NRING] = {{nullptr}};
0114 TH2F *h2waveform_2[NARM][NRING] = {{nullptr}};
0115 TH2F *h2waveform_3[NARM][NRING] = {{nullptr}};
0116 TH2F *h2waveform_1_sum = nullptr;
0117 TH2F *h2waveform_2_sum = nullptr;
0118 TH2F *h2waveform_3_sum = nullptr;
0119
0120 TProfile *hpwaveform_global_1 = nullptr;
0121 TProfile *hpwaveform_global_2 = nullptr;
0122 TProfile *hpwaveform_global_3 = nullptr;
0123 TH2F *h2waveform_global_1 = nullptr;
0124 TH2F *h2waveform_global_2 = nullptr;
0125 TH2F *h2waveform_global_3 = nullptr;
0126
0127 TProfile *waveform_template = nullptr;
0128
0129 TH2F* h_sig_chi2 = nullptr;
0130 TH1F* h_chi2 = nullptr;
0131 TH2F* h_sig_chi2_nt = nullptr;
0132 TH2F* h_sig1_sig2 = nullptr;
0133 TH2F* h_dif_peak_time = nullptr;
0134 TH2F* h_chi1_chi2 = nullptr;
0135 TH2F* h_ped1_ped2 = nullptr;
0136 TH2F* h_sigP1_sigP2 = nullptr;
0137 TProfile2D *p_chi2 = nullptr;
0138 TProfile2D *h_etaphi_ped = nullptr;
0139 TProfile2D *h_etaphi_ped2 = nullptr;
0140 TH1F* h_time1 = nullptr;
0141 TH1F* h_time2 = nullptr;
0142
0143 int eventCount = 0;
0144 const int NWFs = 100;
0145 int CWFs = 0;
0146 TGraph* h_wf[1000] = {nullptr};
0147
0148 CaloWaveformProcessing *WaveformProcessing = nullptr;
0149 CaloWaveformProcessing *WaveformProcessing2 = nullptr;
0150 };
0151
0152 #endif