File indexing completed on 2026-07-16 08:12:43
0001 #ifndef SEPDTOWERPAIRQA_H
0002 #define SEPDTOWERPAIRQA_H
0003
0004 #include <fun4all/SubsysReco.h>
0005
0006 #include <string>
0007 #include <vector>
0008
0009 class PHCompositeNode;
0010 class TFile;
0011 class TTree;
0012 class TH1F;
0013 class TH2F;
0014 class TProfile;
0015 class TProfile2D;
0016 class CDBTTree;
0017
0018 class sEPDTowerPairQA : public SubsysReco
0019 {
0020 public:
0021 explicit sEPDTowerPairQA(const std::string &name = "sEPDTowerPairQA");
0022 ~sEPDTowerPairQA() override = default;
0023
0024 int Init(PHCompositeNode *topNode) override;
0025 int process_event(PHCompositeNode *topNode) override;
0026 int End(PHCompositeNode *topNode) override;
0027
0028 void SetOutputFile(const std::string &f) { m_outputFile = f; }
0029
0030 void SetNodeA(const std::string &n) { m_nodeA = n; }
0031 void SetNodeB(const std::string &n) { m_nodeB = n; }
0032 void SetLabelA(const std::string &l) { m_labelA = l; }
0033 void SetLabelB(const std::string &l) { m_labelB = l; }
0034 void SetAmplitudeCut(float c) { m_amp_cut = c; }
0035
0036 void SetChannelMapFile(const std::string &f) { m_channelMapFile = f; }
0037 void SetTemplateAFile(const std::string &f) { m_templateAFile = f; }
0038 void SetTemplateBFile(const std::string &f) { m_templateBFile = f; }
0039 void SetCaptureEvents(int n) { m_captureEvents = n; }
0040
0041 private:
0042 static const int NRING = 16;
0043
0044 std::string m_outputFile = "sEPDTowerPairQA.root";
0045 std::string m_nodeA = "TOWERS_SEPD";
0046 std::string m_nodeB = "TOWERSNEW_SEPD";
0047 std::string m_labelA = "cdb";
0048 std::string m_labelB = "new";
0049 float m_amp_cut = 20.0;
0050
0051 int m_event = 0;
0052 long m_npaired = 0;
0053 long m_nimproved = 0;
0054 double m_sum_dchi2 = 0.0;
0055 double m_sum_dchi2_frac = 0.0;
0056
0057 TFile *m_file = nullptr;
0058
0059 TH1F *h_dchi2 = nullptr;
0060 TH1F *h_dchi2_frac = nullptr;
0061 TH2F *h_chi2_scatter = nullptr;
0062 TProfile *p_dchi2_vs_amp = nullptr;
0063 TProfile *p_dchi2frac_vs_amp = nullptr;
0064 TProfile2D *p_dchi2frac_map = nullptr;
0065
0066 TH1F *h_dtime = nullptr;
0067 TH2F *h_amp_scatter = nullptr;
0068
0069 TTree *m_tree = nullptr;
0070 int t_ich = 0;
0071 int t_arm = 0;
0072 int t_ring = 0;
0073 float t_ampA = 0.f;
0074 float t_ampB = 0.f;
0075 float t_chi2A = 0.f;
0076 float t_chi2B = 0.f;
0077 float t_timeA = 0.f;
0078 float t_timeB = 0.f;
0079
0080 std::string m_channelMapFile;
0081 std::string m_templateAFile;
0082 std::string m_templateBFile;
0083 std::string m_mapFieldName = "epd_channel_map2";
0084 int m_captureEvents = 0;
0085
0086 static const int MAXSAMP = 16;
0087 CDBTTree *m_sepdmap = nullptr;
0088 std::vector<int> m_idxpid;
0089 std::vector<int> m_idxch;
0090 bool m_mapValidated = false;
0091 bool m_mapOK = false;
0092
0093 TProfile *m_tmplA = nullptr;
0094 TProfile *m_tmplB = nullptr;
0095 TTree *m_dtree = nullptr;
0096 int d_evt = 0;
0097 int d_ich = 0;
0098 int d_arm = 0;
0099 int d_ring = 0;
0100 int d_ns = 0;
0101 float d_raw[MAXSAMP] = {0};
0102 float d_ampA = 0.f;
0103 float d_timeA = 0.f;
0104 float d_chi2A = 0.f;
0105 float d_ampB = 0.f;
0106 float d_timeB = 0.f;
0107 float d_chi2B = 0.f;
0108
0109 static bool sepd_skip_channel(int ich, int pid);
0110 void build_index_map();
0111 TProfile *clone_template(const std::string &file, const char *newname);
0112 };
0113
0114 #endif