Back to home page

sPhenix code displayed by LXR

 
 

    


File indexing completed on 2025-08-05 08:11:56

0001 // #include "DAC_Scan_ladder.h"
0002 //#include "InttConversion.h"
0003 #include "/sphenix/user/ChengWei/INTT/INTT_commissioning/INTT_CW/INTT_commissioning/DAC_Scan/InttConversion_new.h"
0004 #include "/sphenix/user/ChengWei/INTT/INTT_commissioning/INTT_CW/INTT_commissioning/DAC_Scan/InttClustering.h"
0005 #include "sigmaEff.h"
0006 #include "sPhenixStyle.C"
0007 
0008 // todo : the number of number is given by the adc_setting_run !!!
0009 // todo : also the range of the hist.
0010 // todo : the adc follows the following convention
0011 // todo : 1. the increment has to be 4
0012 // todo : remember to check the "adc_conv"
0013 // vector<vector<int>> adc_setting_run = {  
0014 //     // {8  , 12 , 16 , 20 , 24 , 28 , 32 , 36 },
0015 //     // {28 , 32 , 36 , 40 , 44 , 48 , 52 , 56 },
0016 //     {48 , 52 , 56 , 60 , 64 , 68 , 72 , 76 }, // note : 3
0017 //     {68 , 72 , 76 , 80 , 84 , 88 , 92 , 96 }, // note : 4
0018 //     {88 , 92 , 96 , 100, 104, 108, 112, 116}, // note : 5
0019 //     {108, 112, 116, 120, 124, 128, 132, 136}, // note : 6
0020 //     {128, 132, 136, 140, 144, 148, 152, 156}, // note : 7
0021 //     // {148, 152, 156, 160, 164, 168, 172, 176},
0022 //     // {168, 172, 176, 180, 184, 188, 192, 196},
0023 //     // {188, 192, 196, 200, 204, 208, 212, 216}
0024 // };
0025 
0026 vector<vector<int>> adc_setting_run = { 
0027     {15, 30, 60, 90, 120, 150, 180, 210, 240}
0028     // {15, 30, 50, 70, 90, 110, 130, 150,170}
0029     // {8  , 12 , 16 , 20 , 24 , 28 , 32 , 36 },
0030     // {28 , 32 , 36 , 40 , 44 , 48 , 52 , 56 },
0031     // {48 , 52 , 56 , 60 , 64 , 68 , 72 , 76 }, // note : 3
0032     // {68 , 72 , 76 , 80 , 84 , 88 , 92 , 96 }, // note : 4
0033     // {88 , 92 , 96 , 100, 104, 108, 112, 116}, // note : 5
0034     // {108, 112, 116, 120, 124, 128, 132, 136}, // note : 6
0035     // {128, 132, 136, 140, 144, 148, 152, 156}, // note : 7
0036     // {148, 152, 156, 160, 164, 168, 172, 176},
0037     // {168, 172, 176, 180, 184, 188, 192, 196},
0038     // {188, 192, 196, 200, 204, 208, 212, 216}
0039 };
0040 
0041 TString color_code_2[8] = {"#CC768D","#19768D","#DDA573","#009193","#6E9193","#941100","#A08144","#517E66"};
0042 
0043 struct full_hit_info {
0044     int FC;
0045     int chip_id;
0046     int chan_id;
0047     int adc;
0048 };
0049 
0050 
0051 struct ladder_info {
0052     int FC;
0053     TString Port;
0054     int ROC;
0055     int Direction; // note : 0 : south, 1 : north 
0056 };
0057 
0058 double get_radius(double x, double y)
0059 {
0060     return sqrt(pow(x,2)+pow(y,2));
0061 }
0062 
0063 double get_radius_sign(double x, double y)
0064 {
0065     double phi = ((y) < 0) ? atan2((y),(x)) * (180./TMath::Pi()) + 360 : atan2((y),(x)) * (180./TMath::Pi());
0066     
0067     return (phi > 180) ? sqrt(pow(x,2)+pow(y,2)) * -1 : sqrt(pow(x,2)+pow(y,2)); 
0068 }
0069 
0070 void Characterize_Pad (TPad *pad, float left = 0.15, float right = 0.1, float top = 0.1, float bottom = 0.12, bool set_logY = false, int setgrid_bool = 0)
0071 {
0072     if (setgrid_bool == true) {pad -> SetGrid (1, 1);}
0073     pad -> SetLeftMargin   (left);
0074     pad -> SetRightMargin  (right);
0075     pad -> SetTopMargin    (top);
0076     pad -> SetBottomMargin (bottom);
0077     pad -> SetTicks(1,1);
0078     if (set_logY == true)
0079     {
0080         pad -> SetLogy (1);
0081     }
0082     
0083 }
0084 
0085 std::vector<double> calculateDistanceAndClosestPoint(double x1, double y1, double x2, double y2, double target_x, double target_y) {
0086     
0087     if (x1 != x2)
0088     {
0089         // Calculate the slope and intercept of the line passing through (x1, y1) and (x2, y2)
0090         double a = (y2 - y1) / (x2 - x1);
0091         double b = y1 - a * x1;
0092 
0093         // cout<<"slope : y="<<a<<"x+"<<b<<endl;
0094         
0095         // Calculate the closest distance from (target_x, target_y) to the line y = ax + b
0096         double closest_distance = std::abs(a * target_x - target_y + b) / std::sqrt(a * a + 1);
0097 
0098         // Calculate the coordinates of the closest point (Xc, Yc) on the line y = ax + b
0099         double Xc = (target_x + a * target_y - a * b) / (a * a + 1);
0100         double Yc = a * Xc + b;
0101 
0102         return { closest_distance, Xc, Yc };
0103     }
0104     else 
0105     {
0106         double closest_distance = std::abs(x1 - target_x);
0107         double Xc = x1;
0108         double Yc = target_y;
0109 
0110         return { closest_distance, Xc, Yc };
0111     }
0112     
0113     
0114 }
0115 
0116 double get_z_vertex(clu_info inner_clu, clu_info outer_clu, double target_x, double target_y)
0117 {
0118     // note : x = z, 
0119     // note : y = radius
0120     double inner_clu_r = sqrt(pow(inner_clu.x,2)+ pow(inner_clu.y,2));
0121     double outer_clu_r = sqrt(pow(outer_clu.x,2)+ pow(outer_clu.y,2));
0122     double target_r    = sqrt(pow(target_x,2)   + pow(target_y,2));
0123 
0124     // Use the slope equation (y = ax + b) to calculate the x-coordinate for the target y
0125     if ( fabs(outer_clu.z - inner_clu.z) < 0.00001 ){
0126         return outer_clu.z;
0127     }
0128     else {
0129         double slope = (outer_clu_r - inner_clu_r) / (outer_clu.z - inner_clu.z);
0130         double yIntercept = inner_clu_r - slope * inner_clu.z;
0131         double xCoordinate = (target_r - yIntercept) / slope;
0132         return xCoordinate;
0133     }
0134     
0135 }
0136 
0137 // Function to calculate the angle between two vectors in degrees using the cross product
0138 double calculateAngleBetweenVectors(double x1, double y1, double x2, double y2, double targetX, double targetY) {
0139     // Calculate the vectors vector_1 (point_1 to point_2) and vector_2 (point_1 to target)
0140     double vector1X = x2 - x1;
0141     double vector1Y = y2 - y1;
0142 
0143     double vector2X = targetX - x1;
0144     double vector2Y = targetY - y1;
0145 
0146     // Calculate the cross product of vector_1 and vector_2 (z-component)
0147     double crossProduct = vector1X * vector2Y - vector1Y * vector2X;
0148     
0149     // cout<<" crossProduct : "<<crossProduct<<endl;
0150 
0151     // Calculate the magnitudes of vector_1 and vector_2
0152     double magnitude1 = std::sqrt(vector1X * vector1X + vector1Y * vector1Y);
0153     double magnitude2 = std::sqrt(vector2X * vector2X + vector2Y * vector2Y);
0154 
0155     // Calculate the angle in radians using the inverse tangent of the cross product and dot product
0156     double dotProduct = vector1X * vector2X + vector1Y * vector2Y;
0157 
0158     double angleInRadians = std::atan2(std::abs(crossProduct), dotProduct);
0159     // Convert the angle from radians to degrees and return it
0160     double angleInDegrees = angleInRadians * 180.0 / M_PI;
0161     
0162     double angleInRadians_new = std::asin( crossProduct/(magnitude1*magnitude2) );
0163     double angleInDegrees_new = angleInRadians_new * 180.0 / M_PI;
0164     
0165     // cout<<"angle : "<<angleInDegrees_new<<endl;
0166 
0167     double DCA_distance = sin(angleInRadians_new) * magnitude2;
0168 
0169     return DCA_distance;
0170 }
0171 
0172 void temp_bkg(TPad * c1, string conversion_mode, double peek, pair<double,double> beam_origin, InttConversion * ch_pos_DB)
0173 {
0174     c1 -> cd();
0175 
0176     int N_ladder[4] = {12, 12, 16, 16};
0177     string ladder_index_string[16] = {"00","01","02","03","04","05","06","07","08","09","10","11","12","13","14","15"};
0178 
0179     vector<double> x_vec; x_vec.clear();
0180     vector<double> y_vec; y_vec.clear();
0181 
0182     vector<double> x_vec_2; x_vec_2.clear();
0183     vector<double> y_vec_2; y_vec_2.clear();
0184 
0185     TGraph * bkg = new TGraph();
0186     bkg -> SetTitle("INTT event display X-Y plane");
0187     bkg -> SetMarkerStyle(20);
0188     bkg -> SetMarkerSize(0.1);
0189     bkg -> SetPoint(0,0,0);
0190     bkg -> SetPoint(1,beam_origin.first,beam_origin.second);
0191     bkg -> GetXaxis() -> SetLimits(-150,150);
0192     bkg -> GetYaxis() -> SetRangeUser(-150,150);
0193     bkg -> GetXaxis() -> SetTitle("X [mm]");
0194     bkg -> GetYaxis() -> SetTitle("Y [mm]");
0195     
0196     bkg -> Draw("ap");
0197 
0198     TLine * ladder_line = new TLine();
0199     ladder_line -> SetLineWidth(1);
0200 
0201     for (int server_i = 0; server_i < 4; server_i++)
0202     {
0203         for (int FC_i = 0; FC_i < 14; FC_i++)
0204         {
0205             ladder_line -> DrawLine(
0206                 ch_pos_DB -> Get_XY_all(Form("intt%i",server_i),FC_i,14,0).x, ch_pos_DB -> Get_XY_all(Form("intt%i",server_i),FC_i,14,0).y,
0207                 ch_pos_DB -> Get_XY_all(Form("intt%i",server_i),FC_i,1,0).x, ch_pos_DB -> Get_XY_all(Form("intt%i",server_i),FC_i,1,0).y
0208             );
0209         }
0210     }
0211     
0212     ladder_line -> Draw("l same");
0213 
0214 }
0215 
0216 double grEY_stddev (TGraphErrors * input_grr)
0217 {
0218     vector<double> input_vector; input_vector.clear();
0219     for (int i = 0; i < input_grr -> GetN(); i++)
0220     {  
0221         input_vector.push_back( input_grr -> GetPointY(i) );
0222     }
0223 
0224     double sum=0;
0225     double average;
0226     double sum_subt = 0;
0227     for (int i=0; i<input_vector.size(); i++)
0228         {
0229             sum+=input_vector[i];
0230 
0231         }
0232     average=sum/input_vector.size();
0233     //cout<<"average is : "<<average<<endl;
0234 
0235     for (int i=0; i<input_vector.size(); i++)
0236         {
0237             //cout<<input_vector[i]-average<<endl;
0238             sum_subt+=pow((input_vector[i]-average),2);
0239 
0240         }
0241     //cout<<"sum_subt : "<<sum_subt<<endl;
0242     double stddev;
0243     stddev=sqrt(sum_subt/(input_vector.size()-1));  
0244     return stddev;
0245 }   
0246 
0247 pair<double, double> mirrorPolynomial(double a, double b) {
0248     // Interchange 'x' and 'y'
0249     double mirroredA = 1.0 / a;
0250     double mirroredB = -b / a;
0251 
0252     return {mirroredA, mirroredB};
0253 }
0254 
0255 // note : pair<reduced chi2, eta of the track>
0256 // note : vector : {r,z}
0257 // note : p0 : vertex point {r,z,zerror}
0258 // note : p1 : inner layer
0259 // note : p2 : outer layer
0260 pair<double,double> Get_eta(vector<double>p0, vector<double>p1, vector<double>p2)
0261 {
0262     vector<double> r_vec  = {p0[0], p1[0], p2[0]}; 
0263     vector<double> z_vec  = {p0[1], p1[1], p2[1]}; 
0264     vector<double> re_vec = {0, 0, 0}; 
0265     vector<double> ze_vec = {p0[2], ( fabs( p1[1] ) < 130 ) ? 8. : 10., ( fabs( p2[1] ) < 130 ) ? 8. : 10.}; 
0266 
0267     // note : swap the r and z, to have easier fitting 
0268     // note : in principle, Z should be in the x axis, R should be in the Y axis
0269     TGraphErrors * track_gr = new TGraphErrors(3,&r_vec[0],&z_vec[0],&re_vec[0],&ze_vec[0]);    
0270     
0271     double vertical_line = ( fabs( grEY_stddev(track_gr) ) < 0.00001 ) ? 1 : 0;
0272     
0273     if (vertical_line) {return {0,0};}
0274     else 
0275     {
0276         TF1 * fit_rz = new TF1("fit_rz","pol1",-500,500);
0277         fit_rz -> SetParameters(0,0);
0278 
0279         track_gr -> Fit(fit_rz,"NQ");
0280 
0281         pair<double,double> ax_b = mirrorPolynomial(fit_rz -> GetParameter(1),fit_rz -> GetParameter(0));
0282 
0283         return  {(fit_rz -> GetChisquare() / double(fit_rz -> GetNDF())), -1 * TMath::Log( fabs( tan( atan2(ax_b.first, (ax_b.first > 0) ? 1. : -1. ) / 2 ) ) )};
0284 
0285     }
0286 
0287 }
0288 
0289 // note : vector : {r,z}
0290 // note : p0 : vertex point {r,z,zerror}
0291 // note : p1 : another point from detector
0292 // note : since only two points -> no strip width considered
0293 double Get_eta_2P(vector<double>p0, vector<double>p1)
0294 {
0295     // vector<double> r_vec  = {p0[0], p1[0]}; 
0296     // vector<double> z_vec  = {p0[1], p1[1]}; 
0297     // vector<double> re_vec = {0, 0}; 
0298     // vector<double> ze_vec = {p0[2], ( fabs( p1[1] ) < 130 ) ? 8. : 10.}; 
0299 
0300     // note : swap the r and z, to have easier fitting 
0301     // note : in principle, Z should be in the x axis, R should be in the Y axis
0302     // TGraphErrors * track_gr = new TGraphErrors(3,&r_vec[0],&z_vec[0],&re_vec[0],&ze_vec[0]);    
0303     
0304     // double vertical_line = ( fabs( grEY_stddev(track_gr) ) < 0.00001 ) ? 1 : 0;
0305     
0306     return  -1 * TMath::Log( fabs( tan( atan2(p1[0] - p0[0], p1[1] - p0[1]) / 2 ) ) );
0307 
0308     // if (vertical_line) {return 0;}
0309     // else 
0310     // {
0311     //     TF1 * fit_rz = new TF1("fit_rz","pol1",-500,500);
0312     //     fit_rz -> SetParameters(0,0);
0313 
0314     //     track_gr -> Fit(fit_rz,"NQ");
0315 
0316     //     pair<double,double> ax_b = mirrorPolynomial(fit_rz -> GetParameter(1),fit_rz -> GetParameter(0));
0317     // }
0318 
0319 }
0320 
0321 double Get_extrapolation(double given_y, double p0x, double p0y, double p1x, double p1y) // note : x : z, y : r
0322 {
0323     if ( fabs(p0x - p1x) < 0.00001 ){ // note : the line is vertical (if z is along the x axis)
0324         return p0x;
0325     }
0326     else {
0327         double slope = (p1y - p0y) / (p1x - p0x);
0328         double yIntercept = p0y - slope * p0x;
0329         double xCoordinate = (given_y - yIntercept) / slope;
0330         return xCoordinate;
0331     }
0332 }
0333 
0334 pair<double,double> Get_possible_zvtx(double rvtx, vector<double> p0, vector<double> p1) // note : inner p0, outer p1, vector {r,z}, -> {y,x}
0335 {
0336     vector<double> p0_z_edge = { ( fabs( p0[1] ) < 130 ) ? p0[1] - 8. : p0[1] - 10., ( fabs( p0[1] ) < 130 ) ? p0[1] + 8. : p0[1] + 10.}; // note : vector {left edge, right edge}
0337     vector<double> p1_z_edge = { ( fabs( p1[1] ) < 130 ) ? p1[1] - 8. : p1[1] - 10., ( fabs( p1[1] ) < 130 ) ? p1[1] + 8. : p1[1] + 10.}; // note : vector {left edge, right edge}
0338 
0339     double edge_first  = Get_extrapolation(rvtx,p0_z_edge[0],p0[0],p1_z_edge[1],p1[0]);
0340     double edge_second = Get_extrapolation(rvtx,p0_z_edge[1],p0[0],p1_z_edge[0],p1[0]);
0341 
0342     double mid_point = (edge_first + edge_second) / 2.;
0343     double possible_width = fabs(edge_first - edge_second) / 2.;
0344 
0345     return {mid_point, possible_width}; // note : first : mid point, second : width
0346 
0347 }
0348 
0349 // note : use "ls *.root > file_list.txt" to create the list of the file in the folder, full directory in the file_list.txt
0350 // note : set_folder_name = "folder_xxxx"
0351 // note : server_name = "inttx"
0352 void INTT_zvtx(string run_ID, int geo_mode_id, string file_event, bool full_event, int run_Nevent)
0353 {
0354     
0355     SetsPhenixStyle();
0356 
0357     TCanvas * c4 = new TCanvas("","",850,800);    
0358     c4 -> cd();
0359     
0360     TCanvas * c2 = new TCanvas("","",2500,800);    
0361     c2 -> cd();
0362     TPad *pad_xy = new TPad(Form("pad_xy"), "", 0.0, 0.0, 0.33, 1.0);
0363     Characterize_Pad(pad_xy, 0.15, 0.1, 0.1, 0.1 , 0, 0);
0364     pad_xy -> Draw();
0365 
0366     TPad *pad_rz = new TPad(Form("pad_rz"), "", 0.33, 0.0, 0.66, 1.0);
0367     Characterize_Pad(pad_rz, 0.15, 0.1, 0.1, 0.1 , 0, 0);
0368     pad_rz -> Draw();
0369 
0370     TPad *pad_z = new TPad(Form("pad_z"), "", 0.66, 0.0, 1.0, 1.0);
0371     Characterize_Pad(pad_z, 0.15, 0.1, 0.1, 0.1 , 0, 0);
0372     pad_z -> Draw();
0373 
0374     TCanvas * c1 = new TCanvas("","",950,800);
0375     c1 -> cd();
0376 
0377     //todo : can be more than it, possibly
0378     vector<string> conversion_mode_BD = {"ideal", "survey_1_XYAlpha_Peek_3.32mm", "full_survey_3.32"};
0379     // vector<string> conversion_mode_BD = {"ideal", "survey_1_XYAlpha_Peek", "full_survey_3.32"};
0380     
0381     // string mother_folder_directory = "/home/phnxrc/INTT/cwshih/DACscan_data/zero_magnet_Takashi_used";
0382     // string file_name = "beam_inttall-00020869-0000_event_base_ana_cluster_ideal_excludeR1500_100kEvent";
0383     // string file_name = "beam_inttall-00020869-0000_event_base_ana_cluster_survey_1_XYAlpha_Peek_3.32mm_excludeR1500_100kEvent";
0384 
0385     // string run_ID = "20869"; string file_event = "150";
0386     // todo : change the file name.
0387     string mother_folder_directory = "/sphenix/user/ChengWei/INTT/INTT_commissioning/ZeroField/" + run_ID;
0388     // string file_name = "beam_inttall-000" +run_ID+ "-0000_event_base_ana_cluster_survey_1_XYAlpha_Peek_3.32mm_excludeR20000_"+ file_event +"kEvent_3HotCut";
0389     string file_name = "beam_inttall-000" +run_ID+ "-0000_event_base_ana_cluster_"+ conversion_mode_BD[geo_mode_id] +"_excludeR40000_"+ file_event +"kEvent_3HotCut";
0390 
0391     cout<<"the input file name : "<<file_name<<endl;
0392     sleep(5);
0393 
0394     // string mother_folder_directory = "/home/phnxrc/INTT/cwshih/DACscan_data/new_DAC_Scan_0722/AllServer/DAC2";
0395     // string file_name = "beam_inttall-00023058-0000_event_base_ana_cluster_ideal_excludeR2000_100kEvent";
0396 
0397     system(Form("mkdir %s/folder_%s_advanced",mother_folder_directory.c_str(),file_name.c_str()));
0398     system(Form("mkdir %s/folder_%s_advanced/good_track",mother_folder_directory.c_str(),file_name.c_str()));
0399 
0400     pair<double,double> beam_origin = {-0.457 + 0.0276, 2.657 - 0.2814}; // note : for run20869
0401     pair<double,double> beam_origin_U = {0.0004, 0.0035}; // note : for run20869, the uncertainty of the VTXxy, calculated by the fit errors with the error propagation
0402     double temp_Y_align = 0.;
0403     double temp_X_align = -0.;
0404 
0405     double zvtx_hist_l = -500;
0406     double zvtx_hist_r = 500;
0407 
0408     int Nhit_cut = 20000;           // note : if (> Nhit_cut)          -> continue
0409     int Nhit_cutl = 400;          // note : if (< Nhit_cutl)         -> continue 
0410     int clu_size_cut = 4;           // note : if (> clu_size_cut)      -> continue
0411     double clu_sum_adc_cut = 31;    // note : if (< clu_sum_adc_cut)   -> continue
0412     int N_clu_cut = 15000;          // note : if (> N_clu_cut)         -> continue  unit number
0413     int N_clu_cutl = 0;           // note : if (< N_clu_cutl)        -> continue  unit number
0414     double phi_diff_cut = 3.5;      // note : if (< phi_diff_cut)      -> pass      unit degree
0415     double DCA_cut = 4;             // note : if (< DCA_cut)           -> pass      unit mm
0416     int zvtx_cal_require = 15;      // note : if (> zvtx_cal_require)  -> pass
0417     int zvtx_draw_requireL = 15;       
0418     int zvtx_draw_requireR = 40000;   // note : if ( zvtx_draw_requireL < event && event < zvtx_draw_requireR) -> pass
0419     double Integrate_portion = 0.4; // todo : it was 0.6826, try to require less event, as most of the tracklets are not that useful
0420     double Integrate_portion_final = 0.68;
0421     bool draw_event_display = false;
0422     int print_rate = 5;
0423 
0424     // double mean_zvtx = -195.45; // note : unit : mm
0425 
0426     // bool full_event = false;
0427     long long used_event = run_Nevent;
0428 
0429     // double dNdeta_upper_range = 20;
0430 
0431     // todo : change the geo draw mode if needed
0432     int geo_mode_id_draw = 1;
0433     string conversion_mode = (geo_mode_id_draw == 0) ? "ideal" : "survey_1_XYAlpha_Peek";
0434     double peek = 3.32405;
0435 
0436     // note : the initiator of the INTT geometry class
0437     InttConversion * ch_pos_DB = new InttConversion(conversion_mode_BD[geo_mode_id], peek);
0438 
0439     TFile * file_in = new TFile(Form("%s/%s.root",mother_folder_directory.c_str(),file_name.c_str()),"read");
0440     TTree * tree = (TTree *)file_in->Get("tree_clu");
0441     
0442     long long N_event = (full_event == true) ? tree -> GetEntries() : used_event;
0443     cout<<Form("N_event in file %s : %lli",file_name.c_str(), N_event)<<endl;
0444 
0445     int N_hits;
0446     int N_cluster_inner;
0447     int N_cluster_outer;
0448     Long64_t bco_full;
0449     vector<int>* column_vec = new vector<int>();
0450     vector<double>* avg_chan_vec = new vector<double>();
0451     vector<int>* sum_adc_vec = new vector<int>();
0452     vector<int>* sum_adc_conv_vec = new vector<int>();
0453     vector<int>* size_vec = new vector<int>();
0454     vector<double>* x_vec = new vector<double>();
0455     vector<double>* y_vec = new vector<double>();
0456     vector<double>* z_vec = new vector<double>();
0457     vector<int>* layer_vec = new vector<int>();
0458     vector<double>* phi_vec = new vector<double>();
0459 
0460     tree -> SetBranchStatus("*",0);
0461     tree -> SetBranchStatus("nhits",1);
0462     tree -> SetBranchStatus("nclu_inner",1);
0463     tree -> SetBranchStatus("nclu_outer",1);
0464     tree -> SetBranchStatus("bco_full",1);
0465     tree -> SetBranchStatus("column",1);
0466     tree -> SetBranchStatus("avg_chan",1);
0467     tree -> SetBranchStatus("sum_adc",1);
0468     tree -> SetBranchStatus("sum_adc_conv",1);
0469     tree -> SetBranchStatus("size",1);
0470     tree -> SetBranchStatus("x",1);
0471     tree -> SetBranchStatus("y",1);
0472     tree -> SetBranchStatus("z",1);
0473     tree -> SetBranchStatus("layer",1);
0474     tree -> SetBranchStatus("phi",1);
0475 
0476 
0477     tree -> SetBranchAddress("nhits",&N_hits);
0478     tree -> SetBranchAddress("nclu_inner",&N_cluster_inner);
0479     tree -> SetBranchAddress("nclu_outer",&N_cluster_outer);
0480     tree -> SetBranchAddress("bco_full",&bco_full);
0481     tree -> SetBranchAddress("column", &column_vec);
0482     tree -> SetBranchAddress("avg_chan", &avg_chan_vec);
0483     tree -> SetBranchAddress("sum_adc", &sum_adc_vec);
0484     tree -> SetBranchAddress("sum_adc_conv", &sum_adc_conv_vec);
0485     tree -> SetBranchAddress("size", &size_vec);
0486     tree -> SetBranchAddress("x", &x_vec);
0487     tree -> SetBranchAddress("y", &y_vec);
0488     tree -> SetBranchAddress("z", &z_vec);
0489     tree -> SetBranchAddress("layer", &layer_vec);
0490     tree -> SetBranchAddress("phi", &phi_vec);
0491 
0492     TFile * out_file = new TFile(Form("%s/folder_%s_advanced/INTT_zvtx.root",mother_folder_directory.c_str(),file_name.c_str()),"RECREATE");
0493 
0494     int out_eID, N_cluster_outer_out, N_cluster_inner_out, out_N_good;
0495     double out_zvtx, out_zvtxE, out_rangeL, out_rangeR, out_width_density;
0496     Long64_t bco_full_out; 
0497 
0498     TTree * tree_out =  new TTree ("tree_Z", "INTT Z info.");
0499     tree_out -> Branch("eID",&out_eID);
0500     tree_out -> Branch("bco_full",&bco_full_out);
0501     tree_out -> Branch("nclu_inner",&N_cluster_inner_out);
0502     tree_out -> Branch("nclu_outer",&N_cluster_outer_out);
0503     tree_out -> Branch("zvtx",&out_zvtx);
0504     tree_out -> Branch("zvtxE",&out_zvtxE);
0505     tree_out -> Branch("rangeL",&out_rangeL);
0506     tree_out -> Branch("rangeR",&out_rangeR);
0507     tree_out -> Branch("N_good",&out_N_good);
0508     tree_out -> Branch("Width_density",&out_width_density);
0509 
0510     TLatex *draw_text = new TLatex();
0511     draw_text -> SetNDC();
0512     draw_text -> SetTextSize(0.03);
0513 
0514     vector<clu_info> temp_sPH_inner_nocolumn_vec; temp_sPH_inner_nocolumn_vec.clear();
0515     vector<clu_info> temp_sPH_outer_nocolumn_vec; temp_sPH_outer_nocolumn_vec.clear();
0516     vector<vector<double>> temp_sPH_nocolumn_vec(2);
0517     vector<vector<double>> temp_sPH_nocolumn_rz_vec(2);
0518 
0519     TH2F * angle_correlation = new TH2F("","angle_correlation",361,0,361,361,0,361);
0520     angle_correlation -> SetStats(0);
0521     angle_correlation -> GetXaxis() -> SetTitle("Inner Phi (degree)");
0522     angle_correlation -> GetYaxis() -> SetTitle("Outer Phi (degree)");
0523 
0524     TH2F * inner_pos_xy = new TH2F("","inner_pos_xy",360,-100,100,360,-100,100);
0525     inner_pos_xy -> SetStats(0);
0526     inner_pos_xy -> GetXaxis() -> SetTitle("X axis");
0527     inner_pos_xy -> GetYaxis() -> SetTitle("Y axis");
0528 
0529     TH2F * outer_pos_xy = new TH2F("","outer_pos_xy",360,-150,150,360,-150,150);
0530     outer_pos_xy -> SetStats(0);
0531     outer_pos_xy -> GetXaxis() -> SetTitle("X axis");
0532     outer_pos_xy -> GetYaxis() -> SetTitle("Y axis");
0533 
0534     TH2F * inner_outer_pos_xy = new TH2F("","inner_outer_pos_xy",360,-150,150,360,-150,150);
0535     inner_outer_pos_xy -> SetStats(0);
0536     inner_outer_pos_xy -> GetXaxis() -> SetTitle("X axis");
0537     inner_outer_pos_xy -> GetYaxis() -> SetTitle("Y axis");
0538 
0539     TH1F * z_pos_diff = new TH1F("","z_pos_diff",360,-150,150);
0540     z_pos_diff -> GetXaxis() -> SetTitle("inner zpos - outer zpos");
0541     z_pos_diff -> GetYaxis() -> SetTitle("Eentry");
0542 
0543     TH2F * z_pos_diff_angle_diff = new TH2F("","z_pos_diff_angle_diff",100,-25,25,200,-11,11);
0544     z_pos_diff_angle_diff -> SetStats(0);
0545     z_pos_diff_angle_diff -> GetXaxis() -> SetTitle("inner zpos - outer zpos");
0546     z_pos_diff_angle_diff -> GetYaxis() -> SetTitle("Inner phi - outer phi");
0547 
0548     TH1F * Nhits_good = new TH1F("","Nhits_good",360,0,1000);
0549     Nhits_good -> GetXaxis() -> SetTitle("N hits in one event");
0550     Nhits_good -> GetYaxis() -> SetTitle("Eentry");
0551 
0552     TH1F * z_pos_inner = new TH1F("","z_pos_inner",200,-150,150);
0553     z_pos_inner -> GetXaxis() -> SetTitle("inner zpos");
0554     z_pos_inner -> GetYaxis() -> SetTitle("Eentry");
0555 
0556     TH1F * z_pos_outer = new TH1F("","z_pos_outer",200,-150,150);
0557     z_pos_outer -> GetXaxis() -> SetTitle("outer zpos");
0558     z_pos_outer -> GetYaxis() -> SetTitle("Eentry");
0559 
0560     TH2F * z_pos_inner_outer = new TH2F("","z_pos_inner_outer",100,-150,150, 100,-150,150);
0561     z_pos_inner_outer -> SetStats(0);
0562     z_pos_inner_outer -> GetXaxis() -> SetTitle("inner zpos");
0563     z_pos_inner_outer -> GetYaxis() -> SetTitle("outer pos");
0564 
0565     TH2F * DCA_point = new TH2F("","DCA_point",100,-10,10,100,-10,10);
0566     DCA_point -> SetStats(0);
0567     DCA_point -> GetXaxis() -> SetTitle("X pos (mm)");
0568     DCA_point -> GetYaxis() -> SetTitle("Y pos (mm)");
0569 
0570     TH2F * DCA_distance_inner_phi = new TH2F("","DCA_distance_inner_phi",100,0,360,100,-10,10);
0571     DCA_distance_inner_phi -> SetStats(0);
0572     DCA_distance_inner_phi -> GetXaxis() -> SetTitle("inner phi");
0573     DCA_distance_inner_phi -> GetYaxis() -> SetTitle("DCA (mm)");
0574 
0575     TH2F * DCA_distance_outer_phi = new TH2F("","DCA_distance_outer_phi",100,0,360,100,-10,10);
0576     DCA_distance_outer_phi -> SetStats(0);
0577     DCA_distance_outer_phi -> GetXaxis() -> SetTitle("outer phi");
0578     DCA_distance_outer_phi -> GetYaxis() -> SetTitle("DCA (mm)");
0579 
0580     TH1F * N_cluster_outer_pass = new TH1F("","N_cluster_outer_pass",100,0,100);
0581     N_cluster_outer_pass -> GetXaxis() -> SetTitle("N_cluster");
0582     N_cluster_outer_pass -> GetYaxis() -> SetTitle("Eentry");
0583 
0584     TH1F * N_cluster_inner_pass = new TH1F("","N_cluster_inner_pass",100,0,100);
0585     N_cluster_inner_pass -> GetXaxis() -> SetTitle("N_cluster");
0586     N_cluster_inner_pass -> GetYaxis() -> SetTitle("Eentry");
0587 
0588     TH2F * N_cluster_correlation = new TH2F("","N_cluster_correlation",100,0,500,100,0,500);
0589     N_cluster_correlation -> SetStats(0);
0590     N_cluster_correlation -> GetXaxis() -> SetTitle("inner N_cluster");
0591     N_cluster_correlation -> GetYaxis() -> SetTitle("Outer N_cluster");
0592 
0593     TH1F * temp_event_zvtx = new TH1F("","Z vertex dist",125,zvtx_hist_l,zvtx_hist_r);
0594     temp_event_zvtx -> GetXaxis() -> SetTitle("Z vertex position (mm)");
0595     temp_event_zvtx -> GetYaxis() -> SetTitle("Entry");
0596     vector<float> temp_event_zvtx_vec; temp_event_zvtx_vec.clear();
0597     vector<float> temp_event_zvtx_info; temp_event_zvtx_info.clear();
0598     TLine * effi_sig_range_line = new TLine();
0599     effi_sig_range_line -> SetLineWidth(3);
0600     effi_sig_range_line -> SetLineColor(TColor::GetColor("#A08144"));
0601     effi_sig_range_line -> SetLineStyle(2);
0602     TF1 * zvtx_fitting = new TF1("","gaus",-500,500);
0603 
0604     double N_good_event = 0;
0605 
0606     TF1 * zvtx_finder = new TF1("zvtx_finder","pol0",-1,3000); 
0607 
0608     
0609     vector<vector<double>> good_track_xy_vec; good_track_xy_vec.clear();
0610     vector<vector<double>> good_track_rz_vec; good_track_rz_vec.clear();
0611     vector<vector<double>> good_comb_rz_vec; good_comb_rz_vec.clear();
0612     vector<vector<double>> good_comb_xy_vec; good_comb_xy_vec.clear();
0613     vector<vector<double>> good_comb_phi_vec; good_comb_phi_vec.clear();
0614     vector<vector<double>> good_tracklet_rz; good_tracklet_rz.clear();
0615     TLine * track_line = new TLine();
0616     track_line -> SetLineWidth(1);
0617     track_line -> SetLineColorAlpha(38,0.5);
0618 
0619     TLine * coord_line = new TLine();
0620     coord_line -> SetLineWidth(1);
0621     coord_line -> SetLineColor(16);
0622     coord_line -> SetLineStyle(2);
0623 
0624 
0625     vector<float> avg_event_zvtx_vec; avg_event_zvtx_vec.clear();
0626     TH1F * avg_event_zvtx = new TH1F("","avg_event_zvtx",125,zvtx_hist_l,zvtx_hist_r);
0627     // avg_event_zvtx -> SetMarkerStyle(20);
0628     // avg_event_zvtx -> SetMarkerSize(0.8);
0629     // avg_event_zvtx -> SetMarkerColor(TColor::GetColor("#1A3947"));
0630     avg_event_zvtx -> SetLineColor(TColor::GetColor("#1A3947"));
0631     avg_event_zvtx -> SetLineWidth(2);
0632     avg_event_zvtx -> GetYaxis() -> SetTitle("Entry");
0633     avg_event_zvtx -> GetXaxis() -> SetTitle("Z vertex position [mm]");
0634     avg_event_zvtx -> GetYaxis() -> SetRangeUser(0,50);
0635     avg_event_zvtx -> SetTitleSize(0.06, "X");
0636     avg_event_zvtx -> SetTitleSize(0.06, "Y");
0637     avg_event_zvtx -> GetXaxis() -> SetTitleOffset(0.82);
0638     avg_event_zvtx -> GetYaxis() -> SetTitleOffset(1.1);
0639     avg_event_zvtx -> GetXaxis() -> CenterTitle(true);
0640     avg_event_zvtx -> GetYaxis() -> CenterTitle(true);
0641     avg_event_zvtx -> GetXaxis() -> SetNdivisions(505);
0642 
0643     TH1F * zvtx_evt_width = new TH1F("","zvtx_evt_width",150,0,800);
0644     zvtx_evt_width -> GetXaxis() -> SetTitle(" mm ");
0645     zvtx_evt_width -> GetYaxis() -> SetTitle("entry");
0646     zvtx_evt_width -> GetXaxis() -> SetNdivisions(505);
0647 
0648     TH2F * zvtx_evt_fitError_corre = new TH2F("","zvtx_evt_fitError_corre",200,0,10000,200,0,20);
0649     zvtx_evt_fitError_corre -> GetXaxis() -> SetTitle(" # of clusters ");
0650     zvtx_evt_fitError_corre -> GetYaxis() -> SetTitle(" #pm mm ");
0651     zvtx_evt_fitError_corre -> GetXaxis() -> SetNdivisions(505);
0652 
0653     TH2F * zvtx_evt_width_corre = new TH2F("","zvtx_evt_width_corre",200,0,10000,200,0,300);
0654     zvtx_evt_width_corre -> GetXaxis() -> SetTitle(" # of clusters ");
0655     zvtx_evt_width_corre -> GetYaxis() -> SetTitle(" mm ");
0656     zvtx_evt_width_corre -> GetXaxis() -> SetNdivisions(505);
0657 
0658     TH2F * zvtx_evt_nclu_corre = new TH2F("","zvtx_evt_nclu_corre",200,0,10000,200,-500,500);
0659     zvtx_evt_nclu_corre -> GetXaxis() -> SetTitle(" # of clusters ");
0660     zvtx_evt_nclu_corre -> GetYaxis() -> SetTitle(" zvtx [mm] ");
0661     zvtx_evt_nclu_corre -> GetXaxis() -> SetNdivisions(505);
0662 
0663     TH1F * width_density = new TH1F("","width_density",200,0,1); // note : N good hits / width
0664     width_density -> GetXaxis() -> SetTitle(" N good zvtx / width ");
0665     width_density -> GetYaxis() -> SetTitle(" Entry ");
0666     width_density -> GetXaxis() -> SetNdivisions(505);
0667     
0668     int inner_1_check = 0; int inner_2_check = 0; int inner_3_check = 0; int inner_4_check = 0;
0669     int outer_1_check = 0; int outer_2_check = 0; int outer_3_check = 0; int outer_4_check = 0;
0670     vector<int> used_outer_check(temp_sPH_outer_nocolumn_vec.size(),0);
0671     vector<float> N_comb; vector<float> N_comb_e; vector<float> z_mid; vector<float> z_range;
0672     vector<double> effi_N_comb; vector<double> effi_z_mid; vector<double> effi_N_comb_e; vector<double> effi_z_range;
0673 
0674     int N_event_pass_number = 0;
0675     
0676     if (draw_event_display) c2 -> Print(Form("%s/folder_%s_advanced/temp_event_display.pdf(",mother_folder_directory.c_str(),file_name.c_str()));
0677 
0678     for (int event_i = 0; event_i < N_event; event_i++)
0679     {
0680         if (event_i % 1000 == 0) cout<<"code running... "<<event_i<<endl;
0681         tree -> GetEntry(event_i);
0682         unsigned int length = column_vec -> size();
0683 
0684         out_eID = event_i;
0685         N_cluster_inner_out = -1;
0686         N_cluster_outer_out = -1;
0687         out_zvtx = -1;
0688         out_zvtxE = -1;
0689         out_rangeL = -1;
0690         out_rangeR = -1;
0691         out_N_good = -1;
0692         bco_full_out = bco_full;
0693         out_width_density = -1;
0694 
0695         if (event_i == 13) cout<<"test, eID : "<<event_i<<" Nhits "<<N_hits<<endl;
0696 
0697         if (N_hits > Nhit_cut) {tree_out -> Fill(); continue;}
0698         if (N_hits < Nhit_cutl) {tree_out -> Fill(); continue;}
0699 
0700         N_event_pass_number += 1;
0701 
0702         if (N_cluster_inner == 0 || N_cluster_outer == 0) {tree_out -> Fill(); continue;}
0703         if (N_cluster_inner == -1 || N_cluster_outer == -1) {tree_out -> Fill(); continue;}
0704         if ((N_cluster_inner + N_cluster_outer) < zvtx_cal_require) {tree_out -> Fill(); continue;}
0705         if (N_cluster_inner < 30) {tree_out -> Fill(); continue;}
0706         if (N_cluster_outer < 30) {tree_out -> Fill(); continue;}
0707         
0708 
0709         // note : apply some selection to remove the hot channels
0710         // note : and make the inner_clu_vec and outer_clu_vec
0711         for (int clu_i = 0; clu_i < length; clu_i++)
0712         {
0713             if (size_vec -> at(clu_i) > clu_size_cut) continue; 
0714             // if (size_vec -> at(clu_i) < 2) continue;
0715             if (sum_adc_conv_vec -> at(clu_i) < clu_sum_adc_cut) continue;
0716             // if (z_vec -> at(clu_i) < 0) continue;
0717             
0718             // note : inner
0719             // if (layer_vec -> at(clu_i) == 0 && x_vec -> at(clu_i) < -75 && x_vec -> at(clu_i) > -80 && y_vec -> at(clu_i) > 7.5 && y_vec -> at(clu_i) < 12.5 ) continue;
0720             // // if (layer_vec -> at(clu_i) == 0 && x_vec -> at(clu_i) > 35 && x_vec -> at(clu_i) < 40 && y_vec -> at(clu_i) > 65 && y_vec -> at(clu_i) < 70 ) continue;
0721             // if (layer_vec -> at(clu_i) == 0 && phi_vec -> at(clu_i) > 295 && phi_vec -> at(clu_i) < 302) continue;
0722             // if (layer_vec -> at(clu_i) == 0 && phi_vec -> at(clu_i) > 210 && phi_vec -> at(clu_i) < 213) continue;
0723             // if (layer_vec -> at(clu_i) == 0 && phi_vec -> at(clu_i) > 55 && phi_vec -> at(clu_i) < 65) continue;
0724             // if (layer_vec -> at(clu_i) == 0 && phi_vec -> at(clu_i) > 348 && phi_vec -> at(clu_i) < 353) continue;
0725             // if (layer_vec -> at(clu_i) == 0 && phi_vec -> at(clu_i) > 265 && phi_vec -> at(clu_i) < 270) continue;
0726 
0727             // note : outer
0728             // if (layer_vec -> at(clu_i) == 1 && x_vec -> at(clu_i) < -70 && x_vec -> at(clu_i) > -75 && y_vec -> at(clu_i) > 70 && y_vec -> at(clu_i) < 80 ) continue;
0729             // // if (layer_vec -> at(clu_i) == 1 && x_vec -> at(clu_i) > 70 && x_vec -> at(clu_i) < 83 && y_vec -> at(clu_i) > 50 && y_vec -> at(clu_i) < 65 ) continue;
0730             // // if (layer_vec -> at(clu_i) == 1 && x_vec -> at(clu_i) > 70 && x_vec -> at(clu_i) < 83 && y_vec -> at(clu_i) > 63 && y_vec -> at(clu_i) < 75 ) continue;
0731             // if (layer_vec -> at(clu_i) == 1 && x_vec -> at(clu_i) < -70 && x_vec -> at(clu_i) > -75 && y_vec -> at(clu_i) < -70 && y_vec -> at(clu_i) > -75 ) continue;
0732             // if (layer_vec -> at(clu_i) == 1 && phi_vec -> at(clu_i) > 335 && phi_vec -> at(clu_i) < 340) continue;
0733             // if (layer_vec -> at(clu_i) == 1 && phi_vec -> at(clu_i) > 105 && phi_vec -> at(clu_i) < 115) continue;
0734             // if (layer_vec -> at(clu_i) == 1 && phi_vec -> at(clu_i) > 25 && phi_vec -> at(clu_i) < 47) continue; // todo : for the "new_DAC_Scan_0722/AllServer/DAC2"
0735 
0736 
0737             temp_sPH_nocolumn_vec[0].push_back( (phi_vec -> at(clu_i) > 90 && phi_vec -> at(clu_i) < 270 ) ? x_vec -> at(clu_i) + temp_X_align : x_vec -> at(clu_i) );
0738             temp_sPH_nocolumn_vec[1].push_back( (phi_vec -> at(clu_i) > 90 && phi_vec -> at(clu_i) < 270 ) ? y_vec -> at(clu_i) + temp_Y_align : y_vec -> at(clu_i) );
0739             
0740             double clu_radius = get_radius(
0741                 (phi_vec -> at(clu_i) > 90 && phi_vec -> at(clu_i) < 270 ) ? x_vec -> at(clu_i) + temp_X_align : x_vec -> at(clu_i), 
0742                 (phi_vec -> at(clu_i) > 90 && phi_vec -> at(clu_i) < 270 ) ? y_vec -> at(clu_i) + temp_Y_align : y_vec -> at(clu_i)
0743             );
0744             temp_sPH_nocolumn_rz_vec[0].push_back(z_vec -> at(clu_i));
0745             temp_sPH_nocolumn_rz_vec[1].push_back( ( phi_vec -> at(clu_i) > 180 ) ? clu_radius * -1 : clu_radius );
0746             
0747 
0748             if (layer_vec -> at(clu_i) == 0) // note : inner
0749                 temp_sPH_inner_nocolumn_vec.push_back({
0750                     column_vec -> at(clu_i), 
0751                     avg_chan_vec -> at(clu_i), 
0752                     sum_adc_vec -> at(clu_i), 
0753                     sum_adc_conv_vec -> at(clu_i), 
0754                     size_vec -> at(clu_i), 
0755                     (phi_vec -> at(clu_i) > 90 && phi_vec -> at(clu_i) < 270 ) ? x_vec -> at(clu_i) + temp_X_align : x_vec -> at(clu_i), 
0756                     (phi_vec -> at(clu_i) > 90 && phi_vec -> at(clu_i) < 270 ) ? y_vec -> at(clu_i) + temp_Y_align : y_vec -> at(clu_i), 
0757                     z_vec -> at(clu_i), 
0758                     layer_vec -> at(clu_i), 
0759                     phi_vec -> at(clu_i)
0760                 });
0761             
0762             if (layer_vec -> at(clu_i) == 1) // note : outer
0763                 temp_sPH_outer_nocolumn_vec.push_back({
0764                     column_vec -> at(clu_i), 
0765                     avg_chan_vec -> at(clu_i), 
0766                     sum_adc_vec -> at(clu_i), 
0767                     sum_adc_conv_vec -> at(clu_i), 
0768                     size_vec -> at(clu_i), 
0769                     (phi_vec -> at(clu_i) > 90 && phi_vec -> at(clu_i) < 270 ) ? x_vec -> at(clu_i) + temp_X_align : x_vec -> at(clu_i), 
0770                     (phi_vec -> at(clu_i) > 90 && phi_vec -> at(clu_i) < 270 ) ? y_vec -> at(clu_i) + temp_Y_align : y_vec -> at(clu_i), 
0771                     z_vec -> at(clu_i), 
0772                     layer_vec -> at(clu_i), 
0773                     phi_vec -> at(clu_i)
0774                 });            
0775         }
0776 
0777         inner_1_check = 0;
0778         inner_2_check = 0;
0779         inner_3_check = 0;
0780         inner_4_check = 0;
0781         for (int inner_i = 0; inner_i < temp_sPH_inner_nocolumn_vec.size(); inner_i++) {
0782             if (temp_sPH_inner_nocolumn_vec[inner_i].phi >= 0 && temp_sPH_inner_nocolumn_vec[inner_i].phi < 90)    inner_1_check = 1;
0783             if (temp_sPH_inner_nocolumn_vec[inner_i].phi >= 90 && temp_sPH_inner_nocolumn_vec[inner_i].phi < 180)  inner_2_check = 1;
0784             if (temp_sPH_inner_nocolumn_vec[inner_i].phi >= 180 && temp_sPH_inner_nocolumn_vec[inner_i].phi < 270) inner_3_check = 1;
0785             if (temp_sPH_inner_nocolumn_vec[inner_i].phi >= 270 && temp_sPH_inner_nocolumn_vec[inner_i].phi < 360) inner_4_check = 1;
0786 
0787             if ( (inner_1_check + inner_2_check + inner_3_check + inner_4_check) == 4 ) break;
0788         }
0789 
0790         outer_1_check = 0;
0791         outer_2_check = 0;
0792         outer_3_check = 0;
0793         outer_4_check = 0;
0794         for (int outer_i = 0; outer_i < temp_sPH_outer_nocolumn_vec.size(); outer_i++) {
0795             if (temp_sPH_outer_nocolumn_vec[outer_i].phi >= 0 && temp_sPH_outer_nocolumn_vec[outer_i].phi < 90)    outer_1_check = 1;
0796             if (temp_sPH_outer_nocolumn_vec[outer_i].phi >= 90 && temp_sPH_outer_nocolumn_vec[outer_i].phi < 180)  outer_2_check = 1;
0797             if (temp_sPH_outer_nocolumn_vec[outer_i].phi >= 180 && temp_sPH_outer_nocolumn_vec[outer_i].phi < 270) outer_3_check = 1;
0798             if (temp_sPH_outer_nocolumn_vec[outer_i].phi >= 270 && temp_sPH_outer_nocolumn_vec[outer_i].phi < 360) outer_4_check = 1;
0799 
0800             if ( (outer_1_check + outer_2_check + outer_3_check + outer_4_check) == 4 ) break;
0801         }
0802 
0803         // N_cluster_outer_pass -> Fill(temp_sPH_outer_nocolumn_vec.size());
0804         // N_cluster_inner_pass -> Fill(temp_sPH_inner_nocolumn_vec.size());
0805         // N_cluster_correlation -> Fill( temp_sPH_inner_nocolumn_vec.size(), temp_sPH_outer_nocolumn_vec.size() );
0806 
0807         if ((temp_sPH_inner_nocolumn_vec.size() + temp_sPH_outer_nocolumn_vec.size()) > N_clu_cut || (temp_sPH_inner_nocolumn_vec.size() + temp_sPH_outer_nocolumn_vec.size()) < N_clu_cutl)
0808         {
0809             temp_event_zvtx_info = {-1000,-1000,-1000};
0810             temp_event_zvtx_vec.clear();
0811             temp_event_zvtx -> Reset("ICESM");
0812             good_track_xy_vec.clear();
0813             good_track_rz_vec.clear();
0814             good_comb_rz_vec.clear();
0815             good_comb_xy_vec.clear();
0816             good_comb_phi_vec.clear();
0817             temp_sPH_nocolumn_rz_vec.clear(); temp_sPH_nocolumn_rz_vec = vector<vector<double>>(2);
0818             temp_sPH_nocolumn_vec.clear(); temp_sPH_nocolumn_vec = vector<vector<double>>(2);
0819             temp_sPH_inner_nocolumn_vec.clear();
0820             temp_sPH_outer_nocolumn_vec.clear();
0821             tree_out -> Fill();
0822             continue;
0823         }
0824 
0825         if ( (inner_1_check + inner_2_check + inner_3_check + inner_4_check + outer_1_check + outer_2_check + outer_3_check + outer_4_check) != 8 )
0826         {
0827             cout<<"some quater of INTT doens't work !! eID : "<<event_i<<endl;
0828             temp_event_zvtx_info = {-1000,-1000,-1000};
0829             temp_event_zvtx_vec.clear();
0830             temp_event_zvtx -> Reset("ICESM");
0831             good_track_xy_vec.clear();
0832             good_track_rz_vec.clear();
0833             good_comb_rz_vec.clear();
0834             good_comb_xy_vec.clear();
0835             good_comb_phi_vec.clear();
0836             temp_sPH_nocolumn_rz_vec.clear(); temp_sPH_nocolumn_rz_vec = vector<vector<double>>(2);
0837             temp_sPH_nocolumn_vec.clear(); temp_sPH_nocolumn_vec = vector<vector<double>>(2);
0838             temp_sPH_inner_nocolumn_vec.clear();
0839             temp_sPH_outer_nocolumn_vec.clear();
0840             tree_out -> Fill();
0841             continue;
0842         }
0843         
0844         N_comb.clear();
0845         N_comb_e.clear();
0846         z_mid.clear(); 
0847         z_range.clear();
0848         
0849 
0850         // note : try to make sure that the clusters not to be used twice or more 
0851         used_outer_check.clear();
0852         used_outer_check = vector<int>(temp_sPH_outer_nocolumn_vec.size(),0);
0853 
0854         for ( int inner_i = 0; inner_i < temp_sPH_inner_nocolumn_vec.size(); inner_i++ )
0855         {
0856             
0857             for ( int outer_i = 0; outer_i < temp_sPH_outer_nocolumn_vec.size(); outer_i++ )
0858             {
0859                 bool DCA_tag = false;
0860                 if (used_outer_check[outer_i] == 1) continue; // note : this outer cluster was already used, skip the trial of this combination
0861                 
0862                 vector<double> DCA_info_vec = calculateDistanceAndClosestPoint(
0863                     temp_sPH_inner_nocolumn_vec[inner_i].x, temp_sPH_inner_nocolumn_vec[inner_i].y,
0864                     temp_sPH_outer_nocolumn_vec[outer_i].x, temp_sPH_outer_nocolumn_vec[outer_i].y,
0865                     beam_origin.first, beam_origin.second
0866                 );
0867 
0868                 double DCA_sign = calculateAngleBetweenVectors(
0869                     temp_sPH_outer_nocolumn_vec[outer_i].x, temp_sPH_outer_nocolumn_vec[outer_i].y,
0870                     temp_sPH_inner_nocolumn_vec[inner_i].x, temp_sPH_inner_nocolumn_vec[inner_i].y,
0871                     beam_origin.first, beam_origin.second
0872                 );
0873 
0874                 if (DCA_info_vec[0] != fabs(DCA_sign) && fabs( DCA_info_vec[0] - fabs(DCA_sign) ) > 0.1 ){
0875                     cout<<"different DCA : "<<DCA_info_vec[0]<<" "<<DCA_sign<<" diff : "<<DCA_info_vec[0] - fabs(DCA_sign)<<endl;}
0876 
0877                 if (fabs(temp_sPH_inner_nocolumn_vec[inner_i].phi - temp_sPH_outer_nocolumn_vec[outer_i].phi) < phi_diff_cut)
0878                 {
0879                     if (DCA_info_vec[0] < DCA_cut){
0880 
0881                         used_outer_check[outer_i] = 1; //note : this outer cluster was already used!
0882 
0883                         pair<double,double> z_range_info = Get_possible_zvtx( 
0884                             get_radius(beam_origin.first,beam_origin.second), 
0885                             {get_radius(temp_sPH_inner_nocolumn_vec[inner_i].x, temp_sPH_inner_nocolumn_vec[inner_i].y), temp_sPH_inner_nocolumn_vec[inner_i].z}, // note : unsign radius
0886                             {get_radius(temp_sPH_outer_nocolumn_vec[outer_i].x, temp_sPH_outer_nocolumn_vec[outer_i].y), temp_sPH_outer_nocolumn_vec[outer_i].z}  // note : unsign radius
0887                         );
0888                         
0889                         N_comb.push_back(inner_i);
0890                         N_comb_e.push_back(0);
0891                         z_mid.push_back(z_range_info.first);
0892                         z_range.push_back(z_range_info.second);
0893 
0894                         DCA_tag = true;
0895                     }
0896                     
0897 
0898                     // DCA_point -> Fill( DCA_info_vec[1], DCA_info_vec[2] );
0899                     // angle_correlation -> Fill(temp_sPH_inner_nocolumn_vec[inner_i].phi,temp_sPH_outer_nocolumn_vec[outer_i].phi);
0900                     // z_pos_diff -> Fill( temp_sPH_inner_nocolumn_vec[inner_i].z - temp_sPH_outer_nocolumn_vec[outer_i].z );
0901                     // z_pos_diff_angle_diff -> Fill( temp_sPH_inner_nocolumn_vec[inner_i].z - temp_sPH_outer_nocolumn_vec[outer_i].z, temp_sPH_inner_nocolumn_vec[inner_i].phi - temp_sPH_outer_nocolumn_vec[outer_i].phi );
0902                     // Nhits_good -> Fill(N_hits);
0903                     // z_pos_inner -> Fill(temp_sPH_inner_nocolumn_vec[inner_i].z);
0904                     // z_pos_outer -> Fill(temp_sPH_outer_nocolumn_vec[outer_i].z);
0905                     // z_pos_inner_outer -> Fill(temp_sPH_inner_nocolumn_vec[inner_i].z, temp_sPH_outer_nocolumn_vec[outer_i].z);
0906                     // DCA_distance_inner_phi -> Fill(temp_sPH_inner_nocolumn_vec[inner_i].phi, (temp_sPH_inner_nocolumn_vec[inner_i].phi > 90 && temp_sPH_inner_nocolumn_vec[inner_i].phi < 270) ? DCA_sign * -1 : DCA_sign );
0907                     // DCA_distance_outer_phi -> Fill(temp_sPH_outer_nocolumn_vec[outer_i].phi, (temp_sPH_outer_nocolumn_vec[outer_i].phi > 90 && temp_sPH_outer_nocolumn_vec[outer_i].phi < 270) ? DCA_sign * -1 : DCA_sign );
0908                     // DCA_distance_inner_phi -> Fill(temp_sPH_inner_nocolumn_vec[inner_i].phi, DCA_sign );
0909                     // DCA_distance_outer_phi -> Fill(temp_sPH_outer_nocolumn_vec[outer_i].phi, DCA_sign );
0910 
0911                     if(DCA_tag == true) break; // note : since this combination (one inner cluster, one outer cluster) satisfied the reuqiremet, no reason to ask this inner cluster try with other outer clusters
0912 
0913                     // cout<<"good comb : "<<fabs(temp_sPH_inner_nocolumn_vec[inner_i].phi - temp_sPH_outer_nocolumn_vec[outer_i].phi)<<" radius in : "<<get_radius(temp_sPH_inner_nocolumn_vec[inner_i].x, temp_sPH_inner_nocolumn_vec[inner_i].y)<<" radius out : "<<get_radius(temp_sPH_outer_nocolumn_vec[outer_i].x, temp_sPH_outer_nocolumn_vec[outer_i].y)<<endl;
0914                 } // note : end of if 
0915                     
0916 
0917             } // note : end of outer loop
0918         } // note : end of inner loop
0919 
0920         // cout<<"test tag 0"<<endl;
0921         TGraphErrors * z_range_gr;
0922         effi_N_comb.clear();
0923         effi_z_mid.clear();
0924         effi_N_comb_e.clear();
0925         effi_z_range.clear();
0926         // cout<<"test tag 1"<<endl;
0927         if (N_comb.size() > zvtx_cal_require)
0928         {   
0929             temp_event_zvtx_info = sigmaEff_avg(z_mid,Integrate_portion);
0930             
0931             for (int track_i = 0; track_i < N_comb.size(); track_i++) {
0932                 if (temp_event_zvtx_info[1] <= z_mid[track_i] && z_mid[track_i] <= temp_event_zvtx_info[2]) {
0933                     effi_N_comb.push_back(N_comb[track_i]);
0934                     effi_z_mid.push_back(z_mid[track_i]);
0935                     effi_N_comb_e.push_back(N_comb_e[track_i]);
0936                     effi_z_range.push_back(z_range[track_i]);
0937                 }
0938             }
0939 
0940             z_range_gr = new TGraphErrors(effi_N_comb.size(),&effi_N_comb[0],&effi_z_mid[0],&effi_N_comb_e[0],&effi_z_range[0]);
0941             // z_range_gr = new TGraph(effi_N_comb.size(),&effi_N_comb[0],&effi_z_mid[0]);
0942             z_range_gr -> Fit(zvtx_finder,"NQ","",0,N_comb[N_comb.size() - 1] * 0.7); // note : not fit all the combination
0943             
0944             
0945             // avg_event_zvtx -> Fill(zvtx_finder -> GetParameter(0));
0946             zvtx_evt_width -> Fill(fabs( zvtx_finder -> GetParError(0)));
0947             zvtx_evt_fitError_corre -> Fill(temp_sPH_inner_nocolumn_vec.size() + temp_sPH_outer_nocolumn_vec.size(), fabs( zvtx_finder -> GetParError(0)));
0948             zvtx_evt_width_corre -> Fill(temp_sPH_inner_nocolumn_vec.size() + temp_sPH_outer_nocolumn_vec.size(), fabs(temp_event_zvtx_info[2] - temp_event_zvtx_info[1]));
0949             width_density -> Fill( effi_N_comb.size() / fabs(temp_event_zvtx_info[2] - temp_event_zvtx_info[1]) );
0950             if ( ( effi_N_comb.size() / fabs(temp_event_zvtx_info[2] - temp_event_zvtx_info[1]) ) > 0.3 ){ // Todo : change the width density here
0951                 zvtx_evt_nclu_corre -> Fill(temp_sPH_inner_nocolumn_vec.size() + temp_sPH_outer_nocolumn_vec.size(), zvtx_finder -> GetParameter(0));
0952                 avg_event_zvtx -> Fill(zvtx_finder -> GetParameter(0));
0953                 avg_event_zvtx_vec.push_back(zvtx_finder -> GetParameter(0));
0954             }
0955             
0956             out_eID = event_i;
0957             N_cluster_inner_out = temp_sPH_inner_nocolumn_vec.size();
0958             N_cluster_outer_out = temp_sPH_outer_nocolumn_vec.size();
0959             out_zvtx = zvtx_finder -> GetParameter(0);
0960             out_zvtxE = zvtx_finder -> GetParError(0);
0961             out_rangeL = temp_event_zvtx_info[1];
0962             out_rangeR = temp_event_zvtx_info[2];
0963             out_N_good = effi_N_comb.size();
0964             bco_full_out = bco_full;
0965             out_width_density = effi_N_comb.size() / fabs(temp_event_zvtx_info[2] - temp_event_zvtx_info[1]);
0966             tree_out -> Fill();
0967 
0968             z_range_gr -> Delete();
0969         } // note : if N good tracks in xy found > certain value
0970         // cout<<"test tag 2"<<endl;
0971         else {tree_out -> Fill();}
0972             
0973 
0974         if ( zvtx_draw_requireL < N_comb.size() && draw_event_display == true && N_comb.size() > zvtx_cal_require)
0975         {   
0976             TGraph * temp_event_xy = new TGraph(temp_sPH_nocolumn_vec[0].size(),&temp_sPH_nocolumn_vec[0][0],&temp_sPH_nocolumn_vec[1][0]);
0977             temp_event_xy -> SetTitle("INTT event display X-Y plane");
0978             temp_event_xy -> GetXaxis() -> SetLimits(-150,150);
0979             temp_event_xy -> GetYaxis() -> SetRangeUser(-150,150);
0980             temp_event_xy -> GetXaxis() -> SetTitle("X [mm]");
0981             temp_event_xy -> GetYaxis() -> SetTitle("Y [mm]");
0982             temp_event_xy -> SetMarkerStyle(20);
0983             temp_event_xy -> SetMarkerColor(2);
0984             temp_event_xy -> SetMarkerSize(1);
0985             TGraph * temp_event_rz = new TGraph(temp_sPH_nocolumn_rz_vec[0].size(),&temp_sPH_nocolumn_rz_vec[0][0],&temp_sPH_nocolumn_rz_vec[1][0]);
0986             temp_event_rz -> SetTitle("INTT event display r-Z plane");
0987             temp_event_rz -> GetXaxis() -> SetLimits(-500,500);
0988             temp_event_rz -> GetYaxis() -> SetRangeUser(-150,150);
0989             temp_event_rz -> GetXaxis() -> SetTitle("Z [mm]");
0990             temp_event_rz -> GetYaxis() -> SetTitle("Radius [mm]");
0991             temp_event_rz -> SetMarkerStyle(20);
0992             temp_event_rz -> SetMarkerColor(2);
0993             temp_event_rz -> SetMarkerSize(1);
0994 
0995             pad_xy -> cd();
0996             temp_bkg(pad_xy, conversion_mode, peek, beam_origin, ch_pos_DB);
0997             temp_event_xy -> Draw("p same");
0998             for (int track_i = 0; track_i < good_track_xy_vec.size(); track_i++){
0999                 track_line -> DrawLine(good_track_xy_vec[track_i][0],good_track_xy_vec[track_i][1],good_track_xy_vec[track_i][2],good_track_xy_vec[track_i][3]);
1000             }
1001             track_line -> Draw("l same");
1002             draw_text -> DrawLatex(0.2, 0.85, Form("eID : %i, Total event hit : %i, innter Ncluster : %i, outer Ncluster : %i",event_i,N_hits,temp_sPH_inner_nocolumn_vec.size(),temp_sPH_outer_nocolumn_vec.size()));
1003         
1004             pad_rz -> cd();
1005             temp_event_rz -> Draw("ap");    
1006             // effi_sig_range_line -> DrawLine(temp_event_zvtx_info[0],-150,temp_event_zvtx_info[0],150);
1007             coord_line -> DrawLine(0,-150,0,150);
1008             coord_line -> DrawLine(-500,0,500,0);
1009             for (int track_i = 0; track_i < good_track_rz_vec.size(); track_i++){
1010                 track_line -> DrawLine(good_track_rz_vec[track_i][0],good_track_rz_vec[track_i][1],good_track_rz_vec[track_i][2],good_track_rz_vec[track_i][3]);
1011             }
1012             draw_text -> DrawLatex(0.2, 0.85, Form("Negative radius : Clu_{outer} > 180^{0}"));
1013             // draw_text -> DrawLatex(0.2, 0.81, Form("EffiSig avg : %.2f mm",temp_event_zvtx_info[0]));
1014 
1015             // cout<<"test tag 2-5"<<endl;    
1016             pad_z -> cd();
1017             TGraphErrors * z_range_gr_draw = new TGraphErrors(N_comb.size(),&N_comb[0],&z_mid[0],&N_comb_e[0],&z_range[0]);
1018             z_range_gr_draw -> GetYaxis() -> SetRangeUser(-650,650);
1019             z_range_gr_draw -> SetMarkerStyle(20);
1020             z_range_gr_draw -> Draw("ap");
1021             zvtx_finder -> Draw("lsame");
1022             draw_text -> DrawLatex(0.2, 0.82, Form("Event Zvtx %.2f mm, error : #pm%.2f", zvtx_finder -> GetParameter(0), zvtx_finder -> GetParError(0)));
1023             draw_text -> DrawLatex(0.2, 0.78, Form("Width density : %.2f", ( effi_N_comb.size() / fabs(temp_event_zvtx_info[2] - temp_event_zvtx_info[1]) )));
1024             draw_text -> DrawLatex(0.2, 0.74, Form("Width : %.2f to %.2f mm", temp_event_zvtx_info[2] , temp_event_zvtx_info[1]));
1025 
1026             
1027 
1028             effi_sig_range_line -> DrawLine(z_range_gr_draw->GetXaxis()->GetXmin(),temp_event_zvtx_info[1],z_range_gr_draw->GetXaxis()->GetXmax(),temp_event_zvtx_info[1]);
1029             effi_sig_range_line -> DrawLine(z_range_gr_draw->GetXaxis()->GetXmin(),temp_event_zvtx_info[2],z_range_gr_draw->GetXaxis()->GetXmax(),temp_event_zvtx_info[2]);
1030 
1031 
1032             // temp_event_zvtx -> Draw("hist");
1033             // // zvtx_fitting -> Draw("lsame");
1034             // effi_sig_range_line -> DrawLine(temp_event_zvtx_info[1],0,temp_event_zvtx_info[1],temp_event_zvtx -> GetMaximum()*1.05);
1035             // effi_sig_range_line -> DrawLine(temp_event_zvtx_info[2],0,temp_event_zvtx_info[2],temp_event_zvtx -> GetMaximum()*1.05);
1036             // draw_text -> DrawLatex(0.2, 0.85, Form("eID : %i, Total event hit : %i, innter Ncluster : %i, outer Ncluster : %i",event_i,N_hits,temp_sPH_inner_nocolumn_vec.size(),temp_sPH_outer_nocolumn_vec.size()));
1037             // // draw_text -> DrawLatex(0.2, 0.84, Form("Gaus fit mean : %.3f mm",zvtx_fitting -> GetParameter(1)));
1038             // draw_text -> DrawLatex(0.2, 0.82, Form("EffiSig min : %.2f mm, max : %.2f mm",temp_event_zvtx_info[1],temp_event_zvtx_info[2]));
1039             // draw_text -> DrawLatex(0.2, 0.79, Form("EffiSig avg : %.2f mm",temp_event_zvtx_info[0]));
1040 
1041             if(draw_event_display && (event_i % print_rate) == 0){c2 -> Print(Form("%s/folder_%s_advanced/temp_event_display.pdf",mother_folder_directory.c_str(),file_name.c_str()));}
1042             pad_xy -> Clear();
1043             pad_rz -> Clear();
1044             pad_z  -> Clear();
1045 
1046             temp_event_xy -> Delete();
1047             temp_event_rz -> Delete();
1048             z_range_gr_draw -> Delete();
1049 
1050         }
1051         // cout<<"test tag 3"<<endl;
1052 
1053         // for ( int inner_i = 0; inner_i < temp_sPH_inner_nocolumn_vec.size(); inner_i++ )
1054         // {
1055         //     inner_pos_xy -> Fill(temp_sPH_inner_nocolumn_vec[inner_i].x,temp_sPH_inner_nocolumn_vec[inner_i].y);
1056         //     inner_outer_pos_xy -> Fill(temp_sPH_inner_nocolumn_vec[inner_i].x,temp_sPH_inner_nocolumn_vec[inner_i].y);
1057         // }
1058 
1059         // for ( int outer_i = 0; outer_i < temp_sPH_outer_nocolumn_vec.size(); outer_i++ )
1060         // {
1061         //     outer_pos_xy -> Fill(temp_sPH_outer_nocolumn_vec[outer_i].x,temp_sPH_outer_nocolumn_vec[outer_i].y);
1062         //     inner_outer_pos_xy -> Fill(temp_sPH_outer_nocolumn_vec[outer_i].x,temp_sPH_outer_nocolumn_vec[outer_i].y);
1063         // }
1064 
1065         temp_event_zvtx_info = {-1000,-1000,-1000};
1066         temp_event_zvtx_vec.clear();
1067         temp_event_zvtx -> Reset("ICESM");
1068         good_track_xy_vec.clear();
1069         good_track_rz_vec.clear();
1070         good_comb_rz_vec.clear();
1071         good_comb_xy_vec.clear();
1072         good_comb_phi_vec.clear();
1073         temp_sPH_nocolumn_rz_vec.clear(); temp_sPH_nocolumn_rz_vec = vector<vector<double>>(2);
1074         temp_sPH_nocolumn_vec.clear(); temp_sPH_nocolumn_vec = vector<vector<double>>(2);
1075         temp_sPH_inner_nocolumn_vec.clear();
1076         temp_sPH_outer_nocolumn_vec.clear();
1077         N_comb.clear();
1078         N_comb_e.clear();
1079         z_mid.clear();
1080         z_range.clear();
1081     } // note : end of event 
1082 
1083     if (draw_event_display) {c2 -> Print(Form("%s/folder_%s_advanced/temp_event_display.pdf)",mother_folder_directory.c_str(),file_name.c_str()));}
1084     c2 -> Clear();
1085     c1 -> Clear();
1086 
1087     tree_out->SetDirectory(out_file);
1088     tree_out -> Write("", TObject::kOverwrite);
1089 
1090     cout<<"test1, z size : "<<avg_event_zvtx_vec.size()<<endl;    
1091 
1092     c1 -> cd();
1093     vector<float> avg_event_zvtx_info = sigmaEff_avg(avg_event_zvtx_vec,Integrate_portion_final);
1094 
1095     avg_event_zvtx -> SetMinimum( 0 );  avg_event_zvtx -> SetMaximum( avg_event_zvtx->GetBinContent(avg_event_zvtx->GetMaximumBin()) * 1.5 );
1096     avg_event_zvtx -> Draw("hist");
1097 
1098     TLatex *ltx = new TLatex();
1099     ltx->SetNDC();
1100     ltx->SetTextSize(0.045);
1101     ltx->DrawLatex(gPad->GetLeftMargin(), 1 - gPad->GetTopMargin() + 0.01, "#it{#bf{sPHENIX INTT}} Work-in-progress");
1102     ltx->DrawLatex(0.54, 0.86, Form("Run %s",run_ID.c_str()));
1103     ltx->DrawLatex(0.54, 0.81, "Au+Au #sqrt{s_{NN}} = 200 GeV");
1104 
1105     effi_sig_range_line -> DrawLine(avg_event_zvtx_info[1],0,avg_event_zvtx_info[1],avg_event_zvtx -> GetMaximum());
1106     effi_sig_range_line -> DrawLine(avg_event_zvtx_info[2],0,avg_event_zvtx_info[2],avg_event_zvtx -> GetMaximum());    
1107     draw_text -> DrawLatex(0.21, 0.87, Form("EffiSig min : %.2f mm",avg_event_zvtx_info[1]));
1108     draw_text -> DrawLatex(0.21, 0.83, Form("EffiSig max : %.2f mm",avg_event_zvtx_info[2]));
1109     draw_text -> DrawLatex(0.21, 0.79, Form("EffiSig avg : %.2f mm",avg_event_zvtx_info[0]));
1110     c1 -> Print(Form("%s/folder_%s_advanced/avg_event_zvtx.pdf",mother_folder_directory.c_str(),file_name.c_str()));
1111     c1 -> Clear();
1112 
1113 
1114 
1115     width_density -> Draw("hist"); 
1116     ltx->DrawLatex(gPad->GetLeftMargin(), 1 - gPad->GetTopMargin() + 0.01, "#it{#bf{sPHENIX INTT}} Work-in-progress");
1117     c1 -> Print(Form("%s/folder_%s_advanced/width_density.pdf",mother_folder_directory.c_str(),file_name.c_str()));
1118     c1 -> Clear();
1119 
1120     zvtx_evt_width -> Draw("hist"); 
1121     ltx->DrawLatex(gPad->GetLeftMargin(), 1 - gPad->GetTopMargin() + 0.01, "#it{#bf{sPHENIX INTT}} Work-in-progress");
1122     c1 -> Print(Form("%s/folder_%s_advanced/zvtx_evt_width.pdf",mother_folder_directory.c_str(),file_name.c_str()));
1123     c1 -> Clear();
1124 
1125     zvtx_evt_fitError_corre -> Draw("colz0"); 
1126     ltx->DrawLatex(gPad->GetLeftMargin(), 1 - gPad->GetTopMargin() + 0.01, "#it{#bf{sPHENIX INTT}} Work-in-progress");
1127     c1 -> Print(Form("%s/folder_%s_advanced/zvtx_evt_fitError_corre.pdf",mother_folder_directory.c_str(),file_name.c_str()));
1128     c1 -> Clear();
1129 
1130     zvtx_evt_nclu_corre -> Draw("colz0"); 
1131     ltx->DrawLatex(gPad->GetLeftMargin(), 1 - gPad->GetTopMargin() + 0.01, "#it{#bf{sPHENIX INTT}} Work-in-progress");
1132     c1 -> Print(Form("%s/folder_%s_advanced/zvtx_evt_nclu_corre.pdf",mother_folder_directory.c_str(),file_name.c_str()));
1133     c1 -> Clear();
1134 
1135     zvtx_evt_width_corre -> Draw("colz0"); 
1136     ltx->DrawLatex(gPad->GetLeftMargin(), 1 - gPad->GetTopMargin() + 0.01, "#it{#bf{sPHENIX INTT}} Work-in-progress");
1137     c1 -> Print(Form("%s/folder_%s_advanced/zvtx_evt_width_corre.pdf",mother_folder_directory.c_str(),file_name.c_str()));
1138     c1 -> Clear();
1139 
1140     // N_cluster_inner_pass -> Draw("hist"); 
1141     // c1 -> Print(Form("%s/folder_%s_advanced/N_cluster_inner_pass.pdf",mother_folder_directory.c_str(),file_name.c_str()));
1142     // c1 -> Clear();
1143 
1144     // N_cluster_outer_pass -> Draw("hist");
1145     // c1 -> Print(Form("%s/folder_%s_advanced/N_cluster_outer_pass.pdf",mother_folder_directory.c_str(),file_name.c_str()));
1146     // c1 -> Clear();
1147 
1148     // N_cluster_correlation -> Draw("colz0");
1149     // c1 -> Print(Form("%s/folder_%s_advanced/N_cluster_correlation.pdf",mother_folder_directory.c_str(),file_name.c_str()));
1150     // c1 -> Clear();
1151 
1152     // DCA_point -> Draw("colz0");
1153     // c1 -> Print(Form("%s/folder_%s_advanced/DCA_point_X%.1fY%.1f_.pdf",mother_folder_directory.c_str(),file_name.c_str(),beam_origin.first,beam_origin.second));
1154     // c1 -> Clear();
1155 
1156     // DCA_distance_inner_phi -> Draw("colz0");
1157     // c1 -> Print(Form("%s/folder_%s_advanced/DCA_distance_inner_phi_X%.1fY%.1f_.pdf",mother_folder_directory.c_str(),file_name.c_str(),beam_origin.first,beam_origin.second));
1158     // c1 -> Clear();
1159 
1160     // DCA_distance_outer_phi -> Draw("colz0");
1161     // c1 -> Print(Form("%s/folder_%s_advanced/DCA_distance_outer_phi_X%.1fY%.1f_.pdf",mother_folder_directory.c_str(),file_name.c_str(),beam_origin.first,beam_origin.second));
1162     // c1 -> Clear();
1163 
1164     // z_pos_inner_outer -> Draw("colz0");
1165     // c1 -> Print(Form("%s/folder_%s_advanced/z_pos_inner_outer.pdf",mother_folder_directory.c_str(),file_name.c_str()));
1166     // c1 -> Clear();
1167 
1168     // z_pos_inner -> Draw("hist");
1169     // c1 -> Print(Form("%s/folder_%s_advanced/z_pos_inner.pdf",mother_folder_directory.c_str(),file_name.c_str()));
1170     // c1 -> Clear();
1171 
1172     // z_pos_outer -> Draw("hist");
1173     // c1 -> Print(Form("%s/folder_%s_advanced/z_pos_outer.pdf",mother_folder_directory.c_str(),file_name.c_str()));
1174     // c1 -> Clear();
1175 
1176     // Nhits_good -> Draw("hist");
1177     // c1 -> Print(Form("%s/folder_%s_advanced/Nhits_good.pdf",mother_folder_directory.c_str(),file_name.c_str()));
1178     // c1 -> Clear();
1179 
1180     // angle_correlation -> Draw("colz0");
1181     // c1 -> Print(Form("%s/folder_%s_advanced/angle_correlation.pdf",mother_folder_directory.c_str(),file_name.c_str()));
1182     // c1 -> Clear();
1183 
1184     // z_pos_diff -> Draw("hist");
1185     // c1 -> Print(Form("%s/folder_%s_advanced/z_pos_diff.pdf",mother_folder_directory.c_str(),file_name.c_str()));
1186     // c1 -> Clear();
1187 
1188     // z_pos_diff_angle_diff -> Draw("colz0");
1189     // c1 -> Print(Form("%s/folder_%s_advanced/z_pos_diff_angle_diff.pdf",mother_folder_directory.c_str(),file_name.c_str()));
1190     // c1 -> Clear();
1191 
1192     // inner_pos_xy -> Draw("colz0");
1193     // c1 -> Print(Form("%s/folder_%s_advanced/inner_pos_xy.pdf",mother_folder_directory.c_str(),file_name.c_str()));
1194     // c1 -> Clear();
1195 
1196     // outer_pos_xy -> Draw("colz0");
1197     // c1 -> Print(Form("%s/folder_%s_advanced/outer_pos_xy.pdf",mother_folder_directory.c_str(),file_name.c_str()));
1198     // c1 -> Clear();
1199 
1200     // inner_outer_pos_xy -> Draw("colz0");
1201     // c1 -> Print(Form("%s/folder_%s_advanced/inner_outer_pos_xy.pdf",mother_folder_directory.c_str(),file_name.c_str()));
1202     // c1 -> Clear();
1203 }