Back to home page

sPhenix code displayed by LXR

 
 

    


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

0001 pair<double, double> mirrorPolynomial(double a, double b) {
0002     // Interchange 'x' and 'y'
0003     double mirroredA = 1.0 / a;
0004     double mirroredB = -b / a;
0005 
0006     return {mirroredA, mirroredB};
0007 }
0008 
0009 struct comb_str{
0010     int inner_i;
0011     int outer_i;
0012 };
0013 
0014 void INTT_resolution ()
0015 {
0016     pair<double,double> VTX_rz = { sqrt( pow((-0.457 + 0.0276),2) + pow((2.657 - 0.2814),2) ), -200. };
0017     pair<double,double> VTX_rz_E = { 0.0035, 15};
0018 
0019     pair<double,double> inner_r = {76.4938, 3.62798}; // note : avg r and stddev
0020     pair<double,double> outer_r = {101.493, 3.86137};
0021     
0022     vector<double> intt_all_z = {
0023         -226.463, -206.463, -186.463, -166.463, -146.463, -126.299, -110.299, -94.2993, -78.2993, -62.2993, -46.2993, -30.2994, -14.2994, // note : south from U1 to U13
0024         4.83633, 20.8363, 36.8363, 52.8363, 68.8363, 84.8363, 100.836, 116.836, 137.004, 157.004, 177.004, 197.004, 217.004 // note : north from U13 to U1
0025     };
0026 
0027     TLine * z_strip = new TLine();
0028     z_strip -> SetLineWidth(1);
0029     z_strip -> SetLineColor(1);
0030     // z_strip -> SetLineStyle(2);
0031 
0032     TLine * fired_strip = new TLine();
0033     fired_strip -> SetLineWidth(2);
0034     fired_strip -> SetLineColor(2);
0035 
0036     TCanvas * c1 = new TCanvas("","",800,800);
0037 
0038     TGraph * origin_grr = new TGraph();
0039     origin_grr -> SetPoint(0,0.,0.);
0040     origin_grr -> SetMarkerStyle(20);
0041     origin_grr -> GetXaxis() -> SetLimits(-250,250);
0042     origin_grr -> GetYaxis() -> SetRangeUser(-250,250);
0043     origin_grr -> GetXaxis() -> SetTitle("radius");
0044     origin_grr -> GetYaxis() -> SetTitle("Z axis");
0045     TF1 * track_fit = new TF1("track_fit","pol1",-250,250);
0046     track_fit -> SetLineColor(4);
0047 
0048     TLatex *draw_text = new TLatex();
0049     draw_text -> SetNDC();
0050     draw_text -> SetTextSize(0.03);
0051 
0052     vector<double> eta_vec; eta_vec.clear();
0053     vector<comb_str> comb_vec; comb_vec.clear();
0054 
0055     vector<double> eta_slope; eta_slope.clear();
0056 
0057     for(int inner_i = 0; inner_i < 26; inner_i++){
0058         for (int outer_i = 0; outer_i < 26; outer_i++ ){
0059 
0060             track_fit -> SetParameters(0,0);
0061 
0062             double strip_width_inner = ( fabs( intt_all_z[inner_i] ) < 130 ) ? 8. : 10.;
0063             double strip_width_outer = ( fabs( intt_all_z[outer_i] ) < 130 ) ? 8. : 10.;
0064 
0065             vector<double> gz = {VTX_rz.second, intt_all_z[inner_i], intt_all_z[outer_i]};
0066             vector<double> gzE = {VTX_rz_E.second, strip_width_inner, strip_width_outer};
0067             vector<double> gr = {VTX_rz.first, inner_r.first, outer_r.first};
0068             vector<double> grE = {VTX_rz_E.first, 0.16, 0.16};
0069 
0070             TGraphErrors * grrE = new TGraphErrors(gz.size(), &gr[0], &gz[0], &grE[0], &gzE[0]);
0071             grrE -> Fit(track_fit,"NQ");
0072 
0073             pair<double,double> ax_b = mirrorPolynomial(track_fit -> GetParameter(1),track_fit -> GetParameter(0));
0074 
0075             if ( (track_fit -> GetChisquare() / double(track_fit -> GetNDF())) < 10 ){
0076                 eta_vec.push_back( -1 * TMath::Log( fabs( tan( atan2(ax_b.first, (ax_b.first > 0) ? 1. : -1. ) / 2 ) ) ) );
0077                 comb_vec.push_back({inner_i,outer_i});
0078                 eta_slope.push_back(track_fit -> GetParameter(1));
0079             }
0080 
0081             grrE -> Delete();
0082         }
0083     }
0084 
0085     int n_size = eta_vec.size();
0086     int sort_vec_index[n_size];
0087     TMath::Sort(n_size, &eta_vec[0], sort_vec_index,0);
0088 
0089     
0090 
0091     c1 -> Print(Form("/sphenix/user/ChengWei/INTT/INTT_commissioning/ZeroField/20869/folder_beam_inttall-00020869-0000_event_base_ana_cluster_full_survey_3.32_excludeR40000_200kEvent_3HotCut_advanced/INTT_resolution_z%.2fmm.pdf(",VTX_rz.second));
0092     for(int comb_i = 0; comb_i < eta_vec.size(); comb_i++){
0093         origin_grr -> Draw("ap");
0094         track_fit -> SetParameters(0,0);
0095 
0096         double strip_width_inner = ( fabs( intt_all_z[ comb_vec[sort_vec_index[comb_i]].inner_i ] ) < 130 ) ? 8. : 10.;
0097         double strip_width_outer = ( fabs( intt_all_z[comb_vec[sort_vec_index[comb_i]].outer_i] ) < 130 ) ? 8. : 10.;
0098 
0099         vector<double> gz = {VTX_rz.second, intt_all_z[ comb_vec[sort_vec_index[comb_i]].inner_i ], intt_all_z[comb_vec[sort_vec_index[comb_i]].outer_i]};
0100         vector<double> gzE = {VTX_rz_E.second, strip_width_inner, strip_width_outer};
0101         vector<double> gr = {VTX_rz.first, inner_r.first, outer_r.first};
0102         vector<double> grE = {VTX_rz_E.first, 0.16, 0.16};
0103 
0104         TGraphErrors * grrE = new TGraphErrors(gz.size(), &gr[0], &gz[0], &grE[0], &gzE[0]);
0105         grrE -> SetMarkerStyle(20);
0106         grrE -> SetMarkerSize(0.5);
0107         grrE -> SetMarkerColor(2);
0108         grrE -> SetLineColor(2);
0109         grrE -> SetLineWidth(1);
0110 
0111         grrE -> Fit(track_fit,"NQ");
0112 
0113 
0114         // note : draw the strip indication line
0115         for(int i = 0; i < intt_all_z.size(); i++){
0116 
0117             double strip_width = ( fabs( intt_all_z[i] ) < 130 ) ? 8. : 10.;
0118 
0119             z_strip -> DrawLine(inner_r.first, intt_all_z[i] - strip_width, inner_r.first, intt_all_z[i] + strip_width); // note : inner 
0120             z_strip -> DrawLine(outer_r.first, intt_all_z[i] - strip_width, outer_r.first, intt_all_z[i] + strip_width); // note : outer
0121 
0122             z_strip -> DrawLine(inner_r.first - 3, intt_all_z[i] - strip_width, inner_r.first + 3, intt_all_z[i] - strip_width); // note : inner, the edge
0123             z_strip -> DrawLine(inner_r.first - 3, intt_all_z[i] + strip_width, inner_r.first + 3, intt_all_z[i] + strip_width); // note : inner, the edge 
0124             z_strip -> DrawLine(outer_r.first - 3, intt_all_z[i] - strip_width, outer_r.first + 3, intt_all_z[i] - strip_width); // note : outer, the edge
0125             z_strip -> DrawLine(outer_r.first - 3, intt_all_z[i] + strip_width, outer_r.first + 3, intt_all_z[i] + strip_width); // note : outer, the edge
0126         }
0127 
0128         grrE -> Draw("p same");
0129         fired_strip -> DrawLine(inner_r.first, intt_all_z[ comb_vec[sort_vec_index[comb_i]].inner_i ] - strip_width_inner, inner_r.first, intt_all_z[ comb_vec[sort_vec_index[comb_i]].inner_i ] + strip_width_inner); // note : inner 
0130         fired_strip -> DrawLine(outer_r.first, intt_all_z[comb_vec[sort_vec_index[comb_i]].outer_i] - strip_width_outer, outer_r.first, intt_all_z[comb_vec[sort_vec_index[comb_i]].outer_i] + strip_width_outer); // note : outer
0131         track_fit -> Draw("l same");
0132 
0133         pair<double,double> ax_b = mirrorPolynomial(track_fit -> GetParameter(1),track_fit -> GetParameter(0));
0134         
0135 
0136         draw_text -> DrawLatex(0.2, 0.85, Form("Fit #Chi^{2}/NDF : %.3f",(track_fit -> GetChisquare() / double(track_fit -> GetNDF()))));
0137         draw_text -> DrawLatex(0.2, 0.8, Form("trak eta : %.3f", -1 * TMath::Log( fabs( tan( atan2(ax_b.first, (ax_b.first > 0) ? 1. : -1. ) / 2 ) ) ) ));
0138 
0139         if ( (track_fit -> GetChisquare() / double(track_fit -> GetNDF())) < 4 )
0140             c1 -> Print(Form("/sphenix/user/ChengWei/INTT/INTT_commissioning/ZeroField/20869/folder_beam_inttall-00020869-0000_event_base_ana_cluster_full_survey_3.32_excludeR40000_200kEvent_3HotCut_advanced/INTT_resolution_z%.2fmm.pdf",VTX_rz.second));
0141         
0142         c1 -> Clear();
0143         grrE -> Delete();
0144     }
0145 
0146 
0147     origin_grr -> Draw("ap");
0148     vector<TF1 *> track_line; track_line.clear();
0149     for (int i = 0; i < eta_slope.size(); i++){
0150         track_line.push_back( new TF1("track_line","pol1",-1,250) );
0151         track_line[i] -> SetParameters(VTX_rz.second, eta_slope[i]); 
0152         track_line[i] -> Draw("lsame");
0153     }
0154     z_strip -> DrawLine(inner_r.first, intt_all_z[0] - 10. ,inner_r.first, intt_all_z[25] + 10 );
0155     z_strip -> DrawLine(outer_r.first, intt_all_z[0] - 10. ,outer_r.first, intt_all_z[25] + 10 );
0156 
0157     c1 -> Print(Form("/sphenix/user/ChengWei/INTT/INTT_commissioning/ZeroField/20869/folder_beam_inttall-00020869-0000_event_base_ana_cluster_full_survey_3.32_excludeR40000_200kEvent_3HotCut_advanced/INTT_resolution_z%.2fmm.pdf)",VTX_rz.second));
0158     c1 -> Clear();
0159 
0160 }