File indexing completed on 2025-08-06 08:17:42
0001 #ifndef INTT_INTTZVTX_H
0002 #define INTT_INTTZVTX_H
0003
0004 #include "InttVertexUtil.h"
0005
0006 #include <cstdint>
0007 #include <string>
0008 #include <vector>
0009
0010 class TCanvas;
0011 class TFile;
0012 class TF1;
0013 class TGraph;
0014 class TGraphErrors;
0015 class TH1;
0016 class TH2;
0017 class TLatex;
0018 class TLine;
0019 class TPad;
0020 class TTree;
0021
0022 class INTTZvtx
0023 {
0024 public:
0025 struct clu_info
0026 {
0027 int column = -1;
0028
0029 double avg_chan = -9999.9;
0030 int sum_adc = -1;
0031 int sum_adc_conv = -1;
0032 int size = -1;
0033
0034 double x = -9999.9;
0035 double y = -9999.9;
0036 double z = -9999.9;
0037 int layer = -1;
0038 double phi = -9999.9;
0039
0040 };
0041
0042 struct ZvtxInfo
0043 {
0044 public:
0045 double zvtx{-9999.};
0046 double zvtx_err{-1};
0047 double chi2ndf{-1};
0048 double width{-1};
0049 bool good{false};
0050 long nclus{0};
0051 unsigned int ntracklets{0};
0052 unsigned int ngroup{0};
0053 double peakratio{-1};
0054 double peakwidth{-1};
0055
0056 void clear()
0057 {
0058 zvtx = -9999.;
0059 zvtx_err = -1;
0060 chi2ndf = -1;
0061 width = -1;
0062 good = false;
0063 nclus = 0;
0064 ntracklets = 0;
0065 ngroup = 0;
0066 peakratio = -1;
0067 peakwidth = -1;
0068 };
0069 };
0070
0071 public:
0072 INTTZvtx(const std::string& runType,
0073 const std::string& outFolderDirectory,
0074 std::pair<double, double> beamOrigin,
0075 double phiDiffCut = 0.11,
0076 std::pair<double, double> DCACut = {-1, 1},
0077 int NCluCutl = 20,
0078 int NCluCut = 10000,
0079 unsigned int zvtxCal_require = 15,
0080 std::pair<double, double> zvtxQAWidth = {39.62, 65.36},
0081 bool drawEventDisplay = true,
0082 bool enableQA = true,
0083 bool printMessageOpt = true);
0084
0085 virtual ~INTTZvtx();
0086
0087 void Init();
0088
0089 bool ProcessEvt(int event_i,
0090 std::vector<clu_info>& temp_sPH_inner_nocolumn_vec,
0091 std::vector<clu_info>& temp_sPH_outer_nocolumn_vec,
0092 std::vector<std::vector<double>>& temp_sPH_nocolumn_vec,
0093 std::vector<std::vector<double>>& temp_sPH_nocolumn_rz_vec,
0094 int NvtxMC,
0095 double TrigZvtxMC,
0096 bool PhiCheckTag,
0097 uint64_t bco_full,
0098 int centrality_bin);
0099
0100 void ClearEvt();
0101 void PrintPlots();
0102 void EndRun();
0103
0104 void EnableEventDisplay(const bool enableEvtDisp) { draw_event_display = enableEvtDisp; }
0105 void EnableQA(const bool enableQA) { m_enable_qa = enableQA; }
0106
0107 double GetZdiffPeakMC();
0108 double GetZdiffWidthMC();
0109
0110 std::vector<double> GetEvtZPeak();
0111 std::pair<double, double> GetBeamOrigin() { return beam_origin; }
0112 ZvtxInfo& GetZvtxInfo() { return m_zvtxinfo; }
0113 void SetBeamOrigin(double beamx, double beamy) { beam_origin = std::make_pair(beamx, beamy); }
0114 void SetPrintMessageOpt(const bool opt) { print_message_opt = opt; }
0115 void SetOutDirectory(const std::string& sOutDirectory) { out_folder_directory = sOutDirectory; }
0116
0117 private:
0118 bool m_initialized{false};
0119
0120 std::string run_type;
0121 std::string out_folder_directory;
0122 std::pair<double, double> beam_origin;
0123 double phi_diff_cut;
0124 std::pair<double, double> DCA_cut;
0125 int N_clu_cut;
0126 int N_clu_cutl;
0127 unsigned int zvtx_cal_require;
0128 std::pair<double, double> zvtx_QA_width;
0129 bool draw_event_display{false};
0130 bool m_enable_qa{false};
0131 bool print_message_opt;
0132
0133 std::pair<double, double> evt_possible_z_range = {-700, 700};
0134
0135 std::vector<std::string> conversion_mode_BD = {"ideal", "survey_1_XYAlpha_Peek", "full_survey_3.32"};
0136 double Integrate_portion_final = 0.68;
0137 double Integrate_portion = 0.35;
0138 double high_multi_line = 1000;
0139 double zvtx_hist_l = -500;
0140 double zvtx_hist_r = 500;
0141 int print_rate = 50;
0142
0143 std::vector<std::vector<std::pair<bool, clu_info>>> inner_clu_phi_map{};
0144 std::vector<std::vector<std::pair<bool, clu_info>>> outer_clu_phi_map{};
0145
0146 ZvtxInfo m_zvtxinfo;
0147
0148 TH1* evt_possible_z{nullptr};
0149 TH1* line_breakdown_hist{nullptr};
0150 TF1* gaus_fit{nullptr};
0151 TF1* zvtx_finder{nullptr};
0152 TGraphErrors* z_range_gr{nullptr};
0153
0154
0155
0156 TH1* evt_select_track_phi{nullptr};
0157 TH1* evt_phi_diff_1D{nullptr};
0158 TH2* evt_phi_diff_inner_phi{nullptr};
0159 TH2* evt_inner_outer_phi{nullptr};
0160
0161
0162 TH1* avg_event_zvtx{nullptr};
0163 TH1* zvtx_evt_fitError{nullptr};
0164 TH2* zvtx_evt_fitError_corre{nullptr};
0165 TH2* zvtx_evt_width_corre{nullptr};
0166 TH2* zvtx_evt_nclu_corre{nullptr};
0167 TH1* width_density{nullptr};
0168 TH1* ES_width{nullptr};
0169 TH1* ES_width_ratio{nullptr};
0170 TH2* Z_resolution_Nclu{nullptr};
0171 TH2* Z_resolution_pos{nullptr};
0172 TH2* Z_resolution_pos_cut{nullptr};
0173 TH1* Z_resolution{nullptr};
0174 TH1* line_breakdown_gaus_ratio_hist{nullptr};
0175 TH1* line_breakdown_gaus_width_hist{nullptr};
0176 TH2* gaus_width_Nclu{nullptr};
0177 TH2* gaus_rchi2_Nclu{nullptr};
0178 TH2* final_fit_width{nullptr};
0179 TH2* N_track_candidate_Nclu{nullptr};
0180 TH1* peak_group_width_hist{nullptr};
0181 TH1* peak_group_ratio_hist{nullptr};
0182 TH1* N_group_hist{nullptr};
0183 TH1* peak_group_detail_width_hist{nullptr};
0184 TH1* peak_group_detail_ratio_hist{nullptr};
0185 TH1* N_group_detail_hist{nullptr};
0186
0187 TH2* phi_diff_inner_phi{nullptr};
0188 TH2* dca_inner_phi{nullptr};
0189
0190 std::vector<TH1*> m_v_qahist{};
0191
0192 TCanvas* c1{nullptr};
0193
0194 TCanvas* c2{nullptr};
0195 TPad* pad_xy{nullptr};
0196 TPad* pad_rz{nullptr};
0197 TPad* pad_z{nullptr};
0198 TPad* pad_z_hist{nullptr};
0199 TPad* pad_z_line{nullptr};
0200 TPad* pad_phi_diff{nullptr};
0201 TPad* pad_track_phi{nullptr};
0202 TPad* pad_inner_outer_phi{nullptr};
0203 TPad* pad_phi_diff_1D{nullptr};
0204
0205 TLine* ladder_line{nullptr};
0206 TLine* final_fit_range_line{nullptr};
0207 TLine* coord_line{nullptr};
0208 TLatex* draw_text{nullptr};
0209 TLine* eff_sig_range_line{nullptr};
0210
0211 TFile* out_file{nullptr};
0212 TTree* tree_out{nullptr};
0213
0214
0215 double out_ES_zvtx, out_ES_zvtxE, out_ES_rangeL, out_ES_rangeR, out_ES_width_density, MC_true_zvtx;
0216 double out_LB_Gaus_Mean_mean, out_LB_Gaus_Mean_meanE, out_LB_Gaus_Mean_width, out_LB_Gaus_Mean_chi2;
0217 double out_LB_Gaus_Width_width, out_LB_Gaus_Width_size_width, out_LB_Gaus_Width_offset, out_LB_geo_mean;
0218 double out_mid_cut_peak_width, out_mid_cut_peak_ratio, out_LB_cut_peak_width, out_LB_cut_peak_ratio;
0219 bool out_good_zvtx_tag;
0220 int out_eID, N_cluster_outer_out, N_cluster_inner_out, out_ES_N_good, out_mid_cut_Ngroup, out_LB_cut_Ngroup, out_centrality_bin;
0221 int out_N_cluster_north, out_N_cluster_south;
0222 uint64_t bco_full_out;
0223
0224
0225 double MC_z_diff_peak, MC_z_diff_width;
0226
0227 void InitHist();
0228 void InitCanvas();
0229 void InitTreeOut();
0230 void InitRest();
0231
0232 std::vector<float> temp_event_zvtx_info;
0233 std::vector<float> avg_event_zvtx_vec;
0234 std::vector<float> Z_resolution_vec;
0235 std::vector<double> N_group_info;
0236 std::vector<double> N_group_info_detail;
0237
0238 double final_zvtx{0};
0239 double tight_offset_width{0};
0240 double tight_offset_peak{0};
0241 double loose_offset_peak{0};
0242 double loose_offset_peakE{0};
0243 bool good_zvtx_tag{0};
0244 double good_zvtx_tag_int{0};
0245 int good_comb_id{0};
0246
0247 TGraphErrors* z_range_gr_draw{nullptr};
0248 TGraph* temp_event_xy{nullptr};
0249 TGraph* temp_event_rz{nullptr};
0250 TGraph* bkg{nullptr};
0251
0252
0253 std::vector<float> N_comb{};
0254 std::vector<float> N_comb_e{};
0255 std::vector<double> N_comb_phi{};
0256 std::vector<float> z_mid{};
0257 std::vector<float> z_range{};
0258
0259
0260 std::pair<double, double> Get_possible_zvtx(double rvtx, std::vector<double> p0, std::vector<double> p1);
0261 std::vector<double> find_Ngroup(TH1* hist_in);
0262 double get_radius(double x, double y);
0263 double calculateAngleBetweenVectors(double x1, double y1, double x2, double y2, double targetX, double targetY);
0264 double Get_extrapolation(double given_y, double p0x, double p0y, double p1x, double p1y);
0265 void line_breakdown(TH1* hist_in, std::pair<double, double> line_range);
0266
0267
0268 double get_delta_phi(double angle_1, double angle_2);
0269 double get_track_phi(double inner_clu_phi_in, double delta_phi_in);
0270
0271
0272 double LB_geo_mean(TH1* hist_in, std::pair<double, double> search_range, int event_i);
0273
0274
0275 void Characterize_Pad(TPad* pad, float left = 0.15, float right = 0.1,
0276 float top = 0.1, float bottom = 0.12,
0277 bool set_logY = false, int setgrid_bool = 0);
0278 };
0279
0280 #endif