File indexing completed on 2025-08-06 08:18:42
0001 #ifndef INTTMIXUPQA_H__
0002 #define INTTMIXUPQA_H__
0003
0004
0005 #include <array>
0006 #include <filesystem>
0007 #include <iomanip> // setw, setfill
0008 #include <iostream>
0009 #include <vector>
0010
0011 #include <fstream>
0012 #include <iostream>
0013 #include <set>
0014 #include <string>
0015 #include <vector>
0016
0017
0018 #include <TCanvas.h>
0019 #include <TFile.h>
0020 #include <TGraph.h>
0021 #include <TH1.h>
0022 #include <TH2.h>
0023 #include <TLegend.h>
0024 #include <TLine.h>
0025 #include <TObject.h>
0026 #include <TPaveStats.h>
0027 #include <TROOT.h>
0028 #include <TStyle.h>
0029 #include <TSystem.h>
0030 #include <TTree.h>
0031
0032
0033 #include <fun4all/SubsysReco.h>
0034
0035 #include <fun4all/Fun4AllHistoManager.h>
0036 #include <fun4all/Fun4AllReturnCodes.h>
0037
0038 #include <ffarawobjects/InttRawHit.h>
0039 #include <ffarawobjects/InttRawHitContainer.h>
0040
0041 #include <trackbase/InttEventInfo.h>
0042 #include <trackbase/InttEventInfov1.h>
0043
0044 #include <phool/PHCompositeNode.h>
0045 #include <phool/getClass.h>
0046
0047 class PHCompositeNode;
0048
0049 class InttMixupQA : public SubsysReco
0050 {
0051 public:
0052 explicit InttMixupQA(const std::string &name = "InttMixupQA", const int run_num = 0, const int felix_num = 0);
0053
0054 virtual ~InttMixupQA();
0055
0056 int Init(PHCompositeNode *) override;
0057
0058 int InitRun(PHCompositeNode *) override;
0059
0060
0061 int process_event(PHCompositeNode *) override;
0062
0063 int End(PHCompositeNode *) override;
0064
0065 int SetOutputDir(std::string const &dir);
0066
0067 void SetBcoPeakFileDir(std::string const &path) { bcopeak_dir_ = path; };
0068
0069 void SetHotChanFileDir(std::string const &path) { hotchan_dir_ = path; };
0070
0071 std::string getHistoPrefix() { return "InttMixupQA"; }
0072
0073 private:
0074
0075 int run_num_{0};
0076 int felix_num_{0};
0077 static const int kFelix_num_ = 8;
0078 static const int kFee_num_ = 14;
0079 static const int kChip_num_ = 26;
0080 static const int kChan_num_ = 128;
0081 static const int kFirst_pid_ = 3001;
0082 static const int divimul = 10;
0083
0084
0085 std::string output_dir_ = "./";
0086 std::string output_basename_ = "InttMixupEventQA_run";
0087 std::string output_root_ = "mixup.root";
0088 std::string output_pdf_ = "mixup.pdf";
0089 std::string output_txt_ = "bcopeak.pdf";
0090 TFile *tf_output_{nullptr};
0091
0092
0093 std::string bcopeak_dir_ = "./";
0094
0095 std::string bcopeak_file[kFelix_num_];
0096 bool force_suffix_ = false;
0097 bool is_official_ = false;
0098
0099 std::string suffix_;
0100
0101 std::string GetFileSuffix()
0102 {
0103 if (force_suffix_ == false)
0104 {
0105 if (is_official_ == true)
0106 return "_official";
0107 else
0108 return "_special";
0109 }
0110 return suffix_;
0111 };
0112
0113
0114 std::string hotchan_dir_ = "./";
0115 std::string hotchan_file;
0116
0117 std::set<int> bcopar_[kFelix_num_];
0118 std::set<int> otbcopar_[kFelix_num_];
0119 std::map<int, int> hotmap;
0120
0121 int ievent_ = 0;
0122 int n = kFelix_num_;
0123
0124 int prev_bcofull = 0;
0125 uint64_t long_prev_bcofull = 0;
0126 int pre_allhit[kFelix_num_] = {};
0127
0128 int NmixupEv[kFelix_num_] = {};
0129 double mixupfraction[kFelix_num_] = {};
0130 double mixupfraction_sum[kFelix_num_] = {};
0131
0132 int Nmixup_sum[kFelix_num_] = {};
0133 int pre_allhit_sum[kFelix_num_] = {};
0134 double Nmixup_ave[kFelix_num_] = {};
0135 double pre_allhit_ave[kFelix_num_] = {};
0136
0137
0138 double copyfraction[kFelix_num_] = {};
0139 double copyfraction_sum[kFelix_num_] = {};
0140 int NmixcopyEv[kFelix_num_] = {};
0141
0142 double mixupfraction_ave[kFelix_num_] = {};
0143 double Mixevent[kFelix_num_] = {};
0144 double err[kFelix_num_] = {};
0145 double copyfraction_ave[kFelix_num_] = {};
0146 double Mixcloevent[kFelix_num_] = {};
0147 double thisclone_ave[kFelix_num_] = {};
0148
0149 uint64_t first_bcofull{0};
0150
0151 int DEFAULT_BCO_VALUE[kFelix_num_] = {};
0152
0153 TGraph *g_evfraction{nullptr};
0154 TGraph *g_cloevfraction{nullptr};
0155 TGraph *g_hitfraction{nullptr};
0156 TGraph *g_copyfraction{nullptr};
0157
0158 std::map<int, int> premap_hit;
0159
0160 TH1F *h_allmulti_[kFelix_num_] = {};
0161 TH1F *h_allclone_[kFelix_num_] = {};
0162
0163 TH1F *h_mixupmulti[kFelix_num_][divimul] = {};
0164 TH1F *h_divmul[kFelix_num_][divimul] = {};
0165
0166
0167 TH2F *h_vsprefull_bco[kFelix_num_] = {};
0168 TH2F *h_vsfull_bco[kFelix_num_] = {};
0169 TH1F *h_prefull_bco[kFelix_num_] = {};
0170 TH1F *h_full_bco[kFelix_num_] = {};
0171
0172 TH1F *h_prefull_bco_all[kFelix_num_] = {};
0173 TH2F *h_vsprefull_bco_all[kFelix_num_] = {};
0174 TH1F *h_interval{nullptr};
0175 TH1F *h_mixinterval{nullptr};
0176 TH1F *h_divinter{nullptr};
0177 TH1F *h_bcofull_7{nullptr};
0178 TH1F *h_bco{nullptr};
0179
0180 TH1F *h_mixup[kFelix_num_] = {};
0181 TH2F *h_prevsNmix[kFelix_num_] = {};
0182 TH1F *h_nocopyhit[kFelix_num_] = {};
0183 TH1F *h_copyhit[kFelix_num_] = {};
0184 TH1F *h_mixcopy[kFelix_num_] = {};
0185 TH2F *h_mixvscopy[kFelix_num_] = {};
0186
0187 TFile *tf_bcopeak_[kFelix_num_] = {};
0188 TH1D *hbco[kFelix_num_] = {};
0189 TH1D *hbco_sub[kFelix_num_] = {};
0190 TH2D *h2_bco_felix[kFelix_num_] = {};
0191 TH2D *h2_bco_felix_sub[kFelix_num_] = {};
0192 TH1 *hbcohist[kFelix_num_] = {};
0193 TH1 *hbcohist2[kFelix_num_] = {};
0194
0195
0196
0197 TH2F *h_hitfra[kFelix_num_] = {};
0198 TH2F *h_bghit[kFelix_num_] = {};
0199 TH1F *h_NmixEv{nullptr};
0200 TH1F *h_AllEv{nullptr};
0201
0202 std::ofstream f_felixpeak;
0203 std::ofstream ffraction;
0204 std::ofstream fNhit[kFelix_num_];
0205 std::ofstream f_hotchan;
0206 TFile *fgraph{nullptr};
0207
0208
0209
0210
0211 int bin = 8000;
0212 int bin3 = 100;
0213 Long64_t bit = 0xFFFFFFFFFF;
0214 Long64_t bin2 = 10000;
0215
0216
0217
0218 void DrawHists();
0219
0220
0221
0222 void GetBcopeak();
0223
0224 void Readpeak();
0225
0226 void GetBcomyself();
0227
0228 void Hotchancut();
0229 };
0230 #endif