File indexing completed on 2025-08-03 08:13:39
0001
0002
0003 #ifndef INTTZVERTEXFINDERTRAPEZOIDAL_H
0004 #define INTTZVERTEXFINDERTRAPEZOIDAL_H
0005
0006 #include <fun4all/SubsysReco.h>
0007
0008 #include <fun4all/Fun4AllReturnCodes.h>
0009 #include <trackbase/ActsGeometry.h>
0010 #include <trackbase/InttDefs.h>
0011 #include <trackbase/TrkrCluster.h>
0012 #include <trackbase/TrkrClusterContainer.h>
0013 #include <trackbase/TrkrHit.h>
0014 #include <trackbase/TrkrHitSet.h>
0015 #include <trackbase/TrkrHitSetContainer.h>
0016
0017 #include <phool/PHCompositeNode.h>
0018 #include <phool/getClass.h>
0019
0020 #include <fun4all/Fun4AllReturnCodes.h>
0021
0022 #include <string>
0023 #include <cmath>
0024 #include <cstdlib>
0025 #include <filesystem>
0026 #include <iterator>
0027 #include <algorithm>
0028
0029
0030 #include <TH1.h>
0031 #include <TF1.h>
0032 #include <TMath.h>
0033 #include <TColor.h>
0034
0035 #include "INTTvtxZF4AObj.h"
0036
0037 class PHCompositeNode;
0038 class INTTvtxZF4AObj;
0039
0040
0041 class InttZVertexFinderTrapezoidal : public SubsysReco
0042 {
0043 public:
0044
0045 InttZVertexFinderTrapezoidal(
0046 const std::string &name = "InttZVertexFinderTrapezoidal",
0047 std::pair<double, double> vertexXYIncm_in = {0, 0},
0048 bool IsFieldOn_in = false,
0049 bool IsDCACutApplied_in = true,
0050 std::pair<std::pair<double,double>,std::pair<double,double>> DeltaPhiCutInDegree_in = {{-1,1},{-1000.,1000.}},
0051 std::pair<std::pair<double,double>,std::pair<double,double>> DCAcutIncm_in = {{-1,1},{-1000.,1000.}},
0052 int ClusAdcCut_in = 35,
0053 int ClusPhiSizeCut_in = 8,
0054 bool PrintRecoDetails_in = false
0055 );
0056
0057 ~InttZVertexFinderTrapezoidal() override;
0058
0059
0060
0061
0062
0063
0064 int Init(PHCompositeNode *topNode) override;
0065
0066
0067
0068
0069
0070
0071 int InitRun(PHCompositeNode *topNode) override;
0072
0073
0074
0075
0076 int process_event(PHCompositeNode *topNode) override;
0077
0078
0079 int ResetEvent(PHCompositeNode *topNode) override;
0080
0081
0082 int EndRun(const int runnumber) override;
0083
0084
0085 int End(PHCompositeNode *topNode) override;
0086
0087
0088 int Reset(PHCompositeNode * ) override;
0089
0090 void Print(const std::string &what = "ALL") const override;
0091
0092 private:
0093 std::pair<double, double> vertexXYIncm;
0094 bool IsFieldOn;
0095 bool IsDCACutApplied;
0096 std::pair<std::pair<double,double>,std::pair<double,double>> DeltaPhiCutInDegree;
0097 std::pair<std::pair<double,double>,std::pair<double,double>> DCAcutIncm;
0098 int ClusAdcCut;
0099 int ClusPhiSizeCut;
0100 bool PrintRecoDetails;
0101
0102
0103 int PrepareClusterVec(PHCompositeNode *topNode);
0104 int PrepareINTTvtxZ();
0105
0106
0107 double get_radius(double x, double y);
0108 double get_delta_phi(double angle_1, double angle_2);
0109 double calculateAngleBetweenVectors(double x1, double y1, double x2, double y2, double targetX, double targetY);
0110 double Get_extrapolation(double given_y, double p0x, double p0y, double p1x, double p1y);
0111 std::pair<double,double> Get_possible_zvtx(double rvtx, std::vector<double> p0, std::vector<double> p1);
0112 void line_breakdown(TH1D* hist_in, std::pair<double,double> line_range);
0113 void trapezoidal_line_breakdown(TH1D * hist_in, double inner_r, double inner_z, int inner_zid, double outer_r, double outer_z, int outer_zid);
0114 std::vector<double> find_Ngroup(TH1D * hist_in);
0115 double vector_average (std::vector <double> input_vector);
0116 double vector_stddev (std::vector <double> input_vector);
0117
0118
0119 int createNodes(PHCompositeNode *topNode);
0120 INTTvtxZF4AObj * inttzobj;
0121
0122
0123 struct clu_info{
0124 double x;
0125 double y;
0126 double z;
0127
0128 int adc;
0129 int phi_size;
0130 int sensorZID;
0131 };
0132
0133 static double gaus_func(double *x, double *par)
0134 {
0135
0136
0137
0138
0139 return par[0] * TMath::Gaus(x[0],par[1],par[2]) + par[3];
0140 };
0141
0142
0143
0144 TH1D * evt_possible_z;
0145 TH1D * line_breakdown_hist;
0146 TH1D * combination_zvtx_range_shape;
0147 std::vector<clu_info> temp_sPH_inner_nocolumn_vec;
0148 std::vector<clu_info> temp_sPH_outer_nocolumn_vec;
0149 std::vector<std::vector<std::pair<bool,clu_info>>> inner_clu_phi_map;
0150 std::vector<std::vector<std::pair<bool,clu_info>>> outer_clu_phi_map;
0151
0152
0153
0154 TF1 * gaus_fit;
0155 std::vector<TF1 *> gaus_fit_vec;
0156 std::vector<double> fit_mean_mean_vec;
0157 std::vector<double> fit_mean_reducedChi2_vec;
0158 std::vector<double> fit_mean_width_vec;
0159
0160
0161
0162
0163 double INTTvtxZ;
0164 double INTTvtxZError;
0165 double NgroupTrapezoidal;
0166 double NgroupCoarse;
0167 double TrapezoidalFitWidth;
0168 double TrapezoidalFWHM;
0169 long long NClusAll;
0170 long long NClusAllInner;
0171
0172
0173
0174 const int zvtx_hist_Nbins = 1200;
0175 const double fine_bin_width = 0.05;
0176 const std::pair<double,double> evt_possible_z_range = {-70, 70};
0177 const std::pair<double,double> edge_rejection = {-50, 50};
0178 const double typeA_sensor_half_length_incm = 0.8;
0179 const double typeB_sensor_half_length_incm = 1.0;
0180 const std::vector<int> typeA_sensorZID = {0,2};
0181 const std::vector<std::string> color_code = {
0182 "#9e0142",
0183 "#d53e4f",
0184 "#f46d43",
0185 "#fdae61",
0186 "#fee08b",
0187 "#e6f598",
0188 "#abdda4",
0189 "#66c2a5",
0190 "#3288bd",
0191 "#5e4fa2"
0192 };
0193
0194
0195 const int number_of_gaus = 7;
0196
0197 };
0198
0199 #endif