File indexing completed on 2025-08-07 08:12:23
0001
0002
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 #include "../INTTDSTchain.C"
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027 vector<vector<int>> adc_setting_run = {
0028 {15, 30, 60, 90, 120, 150, 180, 210, 240}
0029
0030
0031
0032
0033
0034
0035
0036
0037
0038
0039
0040 };
0041
0042 TString color_code_2[8] = {"#CC768D","#19768D","#DDA573","#009193","#6E9193","#941100","#A08144","#517E66"};
0043
0044 struct full_hit_info {
0045 int FC;
0046 int chip_id;
0047 int chan_id;
0048 int adc;
0049 };
0050
0051
0052 struct ladder_info {
0053 int FC;
0054 TString Port;
0055 int ROC;
0056 int Direction;
0057 };
0058
0059 double get_radius(double x, double y)
0060 {
0061 return sqrt(pow(x,2)+pow(y,2));
0062 }
0063
0064 double get_radius_sign(double x, double y)
0065 {
0066 double phi = ((y) < 0) ? atan2((y),(x)) * (180./TMath::Pi()) + 360 : atan2((y),(x)) * (180./TMath::Pi());
0067
0068 return (phi > 180) ? sqrt(pow(x,2)+pow(y,2)) * -1 : sqrt(pow(x,2)+pow(y,2));
0069 }
0070
0071 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)
0072 {
0073 if (setgrid_bool == true) {pad -> SetGrid (1, 1);}
0074 pad -> SetLeftMargin (left);
0075 pad -> SetRightMargin (right);
0076 pad -> SetTopMargin (top);
0077 pad -> SetBottomMargin (bottom);
0078 pad -> SetTicks(1,1);
0079 if (set_logY == true)
0080 {
0081 pad -> SetLogy (1);
0082 }
0083
0084 }
0085
0086 std::vector<double> calculateDistanceAndClosestPoint(double x1, double y1, double x2, double y2, double target_x, double target_y) {
0087
0088 if (x1 != x2)
0089 {
0090
0091 double a = (y2 - y1) / (x2 - x1);
0092 double b = y1 - a * x1;
0093
0094
0095
0096
0097 double closest_distance = std::abs(a * target_x - target_y + b) / std::sqrt(a * a + 1);
0098
0099
0100 double Xc = (target_x + a * target_y - a * b) / (a * a + 1);
0101 double Yc = a * Xc + b;
0102
0103 return { closest_distance, Xc, Yc };
0104 }
0105 else
0106 {
0107 double closest_distance = std::abs(x1 - target_x);
0108 double Xc = x1;
0109 double Yc = target_y;
0110
0111 return { closest_distance, Xc, Yc };
0112 }
0113
0114
0115 }
0116
0117 double get_z_vertex(clu_info inner_clu, clu_info outer_clu, double target_x, double target_y)
0118 {
0119
0120
0121 double inner_clu_r = sqrt(pow(inner_clu.x,2)+ pow(inner_clu.y,2));
0122 double outer_clu_r = sqrt(pow(outer_clu.x,2)+ pow(outer_clu.y,2));
0123 double target_r = sqrt(pow(target_x,2) + pow(target_y,2));
0124
0125
0126 if ( fabs(outer_clu.z - inner_clu.z) < 0.00001 ){
0127 return outer_clu.z;
0128 }
0129 else {
0130 double slope = (outer_clu_r - inner_clu_r) / (outer_clu.z - inner_clu.z);
0131 double yIntercept = inner_clu_r - slope * inner_clu.z;
0132 double xCoordinate = (target_r - yIntercept) / slope;
0133 return xCoordinate;
0134 }
0135
0136 }
0137
0138
0139 double calculateAngleBetweenVectors(double x1, double y1, double x2, double y2, double targetX, double targetY) {
0140
0141 double vector1X = x2 - x1;
0142 double vector1Y = y2 - y1;
0143
0144 double vector2X = targetX - x1;
0145 double vector2Y = targetY - y1;
0146
0147
0148 double crossProduct = vector1X * vector2Y - vector1Y * vector2X;
0149
0150
0151
0152
0153 double magnitude1 = std::sqrt(vector1X * vector1X + vector1Y * vector1Y);
0154 double magnitude2 = std::sqrt(vector2X * vector2X + vector2Y * vector2Y);
0155
0156
0157 double dotProduct = vector1X * vector2X + vector1Y * vector2Y;
0158
0159 double angleInRadians = std::atan2(std::abs(crossProduct), dotProduct);
0160
0161 double angleInDegrees = angleInRadians * 180.0 / M_PI;
0162
0163 double angleInRadians_new = std::asin( crossProduct/(magnitude1*magnitude2) );
0164 double angleInDegrees_new = angleInRadians_new * 180.0 / M_PI;
0165
0166
0167
0168 double DCA_distance = sin(angleInRadians_new) * magnitude2;
0169
0170 return DCA_distance;
0171 }
0172
0173 void temp_bkg(TPad * c1, string conversion_mode, double peek, pair<double,double> beam_origin, InttConversion * ch_pos_DB)
0174 {
0175 c1 -> cd();
0176
0177 int N_ladder[4] = {12, 12, 16, 16};
0178 string ladder_index_string[16] = {"00","01","02","03","04","05","06","07","08","09","10","11","12","13","14","15"};
0179
0180 vector<double> x_vec; x_vec.clear();
0181 vector<double> y_vec; y_vec.clear();
0182
0183 vector<double> x_vec_2; x_vec_2.clear();
0184 vector<double> y_vec_2; y_vec_2.clear();
0185
0186 TGraph * bkg = new TGraph();
0187 bkg -> SetTitle("INTT event display X-Y plane");
0188 bkg -> SetMarkerStyle(20);
0189 bkg -> SetMarkerSize(0.1);
0190 bkg -> SetPoint(0,0,0);
0191 bkg -> SetPoint(1,beam_origin.first,beam_origin.second);
0192 bkg -> GetXaxis() -> SetLimits(-150,150);
0193 bkg -> GetYaxis() -> SetRangeUser(-150,150);
0194 bkg -> GetXaxis() -> SetTitle("X [mm]");
0195 bkg -> GetYaxis() -> SetTitle("Y [mm]");
0196
0197 bkg -> Draw("ap");
0198
0199 TLine * ladder_line = new TLine();
0200 ladder_line -> SetLineWidth(1);
0201
0202 for (int server_i = 0; server_i < 4; server_i++)
0203 {
0204 for (int FC_i = 0; FC_i < 14; FC_i++)
0205 {
0206 ladder_line -> DrawLine(
0207 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,
0208 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
0209 );
0210 }
0211 }
0212
0213 ladder_line -> Draw("l same");
0214
0215 }
0216
0217 double grEY_stddev (TGraphErrors * input_grr)
0218 {
0219 vector<double> input_vector; input_vector.clear();
0220 for (int i = 0; i < input_grr -> GetN(); i++)
0221 {
0222 input_vector.push_back( input_grr -> GetPointY(i) );
0223 }
0224
0225 double sum=0;
0226 double average;
0227 double sum_subt = 0;
0228 for (int i=0; i<input_vector.size(); i++)
0229 {
0230 sum+=input_vector[i];
0231
0232 }
0233 average=sum/input_vector.size();
0234
0235
0236 for (int i=0; i<input_vector.size(); i++)
0237 {
0238
0239 sum_subt+=pow((input_vector[i]-average),2);
0240
0241 }
0242
0243 double stddev;
0244 stddev=sqrt(sum_subt/(input_vector.size()-1));
0245 return stddev;
0246 }
0247
0248 pair<double, double> mirrorPolynomial(double a, double b) {
0249
0250 double mirroredA = 1.0 / a;
0251 double mirroredB = -b / a;
0252
0253 return {mirroredA, mirroredB};
0254 }
0255
0256
0257
0258
0259
0260
0261 pair<double,double> Get_eta(vector<double>p0, vector<double>p1, vector<double>p2)
0262 {
0263 vector<double> r_vec = {p0[0], p1[0], p2[0]};
0264 vector<double> z_vec = {p0[1], p1[1], p2[1]};
0265 vector<double> re_vec = {0, 0, 0};
0266 vector<double> ze_vec = {p0[2], ( fabs( p1[1] ) < 130 ) ? 8. : 10., ( fabs( p2[1] ) < 130 ) ? 8. : 10.};
0267
0268
0269
0270 TGraphErrors * track_gr = new TGraphErrors(3,&r_vec[0],&z_vec[0],&re_vec[0],&ze_vec[0]);
0271
0272 double vertical_line = ( fabs( grEY_stddev(track_gr) ) < 0.00001 ) ? 1 : 0;
0273
0274 if (vertical_line) {return {0,0};}
0275 else
0276 {
0277 TF1 * fit_rz = new TF1("fit_rz","pol1",-500,500);
0278 fit_rz -> SetParameters(0,0);
0279
0280 track_gr -> Fit(fit_rz,"NQ");
0281
0282 pair<double,double> ax_b = mirrorPolynomial(fit_rz -> GetParameter(1),fit_rz -> GetParameter(0));
0283
0284 return {(fit_rz -> GetChisquare() / double(fit_rz -> GetNDF())), -1 * TMath::Log( fabs( tan( atan2(ax_b.first, (ax_b.first > 0) ? 1. : -1. ) / 2 ) ) )};
0285
0286 }
0287
0288 }
0289
0290
0291
0292
0293
0294 double Get_eta_2P(vector<double>p0, vector<double>p1){
0295 return -1 * TMath::Log( fabs( tan( atan2(p1[0] - p0[0], p1[1] - p0[1]) / 2 ) ) );
0296 }
0297
0298 double Get_extrapolation(double given_y, double p0x, double p0y, double p1x, double p1y)
0299 {
0300 if ( fabs(p0x - p1x) < 0.00001 ){
0301 return p0x;
0302 }
0303 else {
0304 double slope = (p1y - p0y) / (p1x - p0x);
0305 double yIntercept = p0y - slope * p0x;
0306 double xCoordinate = (given_y - yIntercept) / slope;
0307 return xCoordinate;
0308 }
0309 }
0310
0311 pair<double,double> Get_possible_zvtx(double rvtx, vector<double> p0, vector<double> p1)
0312 {
0313 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.};
0314 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.};
0315
0316 double edge_first = Get_extrapolation(rvtx,p0_z_edge[0],p0[0],p1_z_edge[1],p1[0]);
0317 double edge_second = Get_extrapolation(rvtx,p0_z_edge[1],p0[0],p1_z_edge[0],p1[0]);
0318
0319 double mid_point = (edge_first + edge_second) / 2.;
0320 double possible_width = fabs(edge_first - edge_second) / 2.;
0321
0322 return {mid_point, possible_width};
0323
0324 }
0325
0326 double gaus_func(double *x, double *par)
0327 {
0328
0329
0330
0331
0332 return par[0] * TMath::Gaus(x[0],par[1],par[2]) + par[3];
0333 }
0334
0335
0336
0337
0338 void INTT_zvtx()
0339 {
0340
0341 SetsPhenixStyle();
0342
0343 TCanvas * c4 = new TCanvas("","",850,800);
0344 c4 -> cd();
0345
0346 TCanvas * c2 = new TCanvas("","",3400,800);
0347 c2 -> cd();
0348 TPad *pad_xy = new TPad(Form("pad_xy"), "", 0.0, 0.0, 0.25, 1.0);
0349 Characterize_Pad(pad_xy, 0.15, 0.1, 0.1, 0.1 , 0, 0);
0350 pad_xy -> Draw();
0351
0352 TPad *pad_rz = new TPad(Form("pad_rz"), "", 0.25, 0.0, 0.50, 1.0);
0353 Characterize_Pad(pad_rz, 0.15, 0.1, 0.1, 0.1 , 0, 0);
0354 pad_rz -> Draw();
0355
0356 TPad *pad_z = new TPad(Form("pad_z"), "", 0.50, 0.0, 0.75, 1.0);
0357 Characterize_Pad(pad_z, 0.15, 0.1, 0.1, 0.1 , 0, 0);
0358 pad_z -> Draw();
0359
0360 TPad *pad_z_hist = new TPad(Form("pad_z_hist"), "", 0.75, 0.0, 1, 1.0);
0361 Characterize_Pad(pad_z_hist, 0.15, 0.1, 0.1, 0.1 , 0, 0);
0362 pad_z_hist -> Draw();
0363
0364 TCanvas * c1 = new TCanvas("","",950,800);
0365 c1 -> cd();
0366
0367
0368 vector<string> conversion_mode_BD = {"ideal", "survey_1_XYAlpha_Peek_3.32mm", "full_survey_3.32"};
0369
0370
0371
0372
0373
0374
0375
0376
0377
0378
0379
0380
0381 int geo_mode_id = 0;
0382 string mother_folder_directory = "/sphenix/user/ChengWei/sPH_dNdeta/dNdEta_INTT_MC"; string file_name = "MC_ZF_1_30400";
0383 string MC_list_name = "dst_INTTdNdEta.list";
0384
0385 TChain * chain_in = new TChain("EventTree");
0386 INTTDSTchain inttDSTMC(chain_in,mother_folder_directory,MC_list_name);
0387 std::printf("inttDSTMC N event : %lli \n", chain_in->GetEntries());
0388 long long N_event = chain_in->GetEntries();
0389
0390 cout<<"the input file name : "<<file_name<<endl;
0391 sleep(5);
0392
0393
0394
0395
0396 string out_folder_directory = Form("%s/folder_%s_advanced_test2",mother_folder_directory.c_str(),file_name.c_str());
0397
0398 system(Form("mkdir %s",out_folder_directory.c_str()));
0399
0400
0401 pair<double,double> beam_origin = {-0.015, 0.012};
0402 pair<double,double> beam_origin_U = {0.0004, 0.0035};
0403 double temp_Y_align = 0.;
0404 double temp_X_align = -0.;
0405
0406 double zvtx_hist_l = -500;
0407 double zvtx_hist_r = 500;
0408
0409
0410
0411
0412 int clu_size_cut = 4;
0413 double clu_sum_adc_cut = -1;
0414 int N_clu_cut = 10000;
0415 int N_clu_cutl = 20;
0416 double phi_diff_cut = 0.11;
0417 double DCA_cut = 0.5;
0418 int zvtx_cal_require = 15;
0419 int zvtx_draw_requireL = 15;
0420 int zvtx_draw_requireR = 40000;
0421 double Integrate_portion = 0.68;
0422 double Integrate_portion_final = 0.68;
0423 bool draw_event_display = true;
0424 int print_rate = 40;
0425
0426
0427
0428
0429
0430
0431
0432
0433
0434 int geo_mode_id_draw = 0;
0435 string conversion_mode = (geo_mode_id_draw == 0) ? "ideal" : "survey_1_XYAlpha_Peek";
0436 double peek = 3.32405;
0437
0438
0439 InttConversion * ch_pos_DB = new InttConversion(conversion_mode_BD[geo_mode_id], peek);
0440
0441
0442 TFile * out_file = new TFile(Form("%s/INTT_zvtx.root",out_folder_directory.c_str()),"RECREATE");
0443
0444 int out_eID, N_cluster_outer_out, N_cluster_inner_out, out_N_good;
0445 double out_zvtx, out_zvtxE, out_rangeL, out_rangeR, out_width_density, MC_true_zvtx;
0446 Long64_t bco_full_out;
0447
0448 TTree * tree_out = new TTree ("tree_Z", "INTT Z info.");
0449 tree_out -> Branch("eID",&out_eID);
0450 tree_out -> Branch("bco_full",&bco_full_out);
0451 tree_out -> Branch("nclu_inner",&N_cluster_inner_out);
0452 tree_out -> Branch("nclu_outer",&N_cluster_outer_out);
0453 tree_out -> Branch("zvtx",&out_zvtx);
0454 tree_out -> Branch("zvtxE",&out_zvtxE);
0455 tree_out -> Branch("rangeL",&out_rangeL);
0456 tree_out -> Branch("rangeR",&out_rangeR);
0457 tree_out -> Branch("N_good",&out_N_good);
0458 tree_out -> Branch("Width_density",&out_width_density);
0459 tree_out -> Branch("MC_true_zvtx",&MC_true_zvtx);
0460
0461 TLatex *draw_text = new TLatex();
0462 draw_text -> SetNDC();
0463 draw_text -> SetTextSize(0.03);
0464
0465 vector<clu_info> temp_sPH_inner_nocolumn_vec; temp_sPH_inner_nocolumn_vec.clear();
0466 vector<clu_info> temp_sPH_outer_nocolumn_vec; temp_sPH_outer_nocolumn_vec.clear();
0467 vector<vector<double>> temp_sPH_nocolumn_vec(2);
0468 vector<vector<double>> temp_sPH_nocolumn_rz_vec(2);
0469
0470 TH1F * temp_event_zvtx = new TH1F("","Z vertex dist",125,zvtx_hist_l,zvtx_hist_r);
0471 temp_event_zvtx -> GetXaxis() -> SetTitle("Z vertex position (mm)");
0472 temp_event_zvtx -> GetYaxis() -> SetTitle("Entry");
0473 vector<float> temp_event_zvtx_vec; temp_event_zvtx_vec.clear();
0474 vector<float> temp_event_zvtx_info; temp_event_zvtx_info.clear();
0475 TLine * eff_sig_range_line = new TLine();
0476 eff_sig_range_line -> SetLineWidth(3);
0477 eff_sig_range_line -> SetLineColor(TColor::GetColor("#A08144"));
0478 eff_sig_range_line -> SetLineStyle(2);
0479
0480
0481 double N_good_event = 0;
0482
0483 TF1 * zvtx_finder = new TF1("zvtx_finder","pol0",-1,6000);
0484 zvtx_finder -> SetLineColor(2);
0485 zvtx_finder -> SetLineWidth(1);
0486
0487
0488 vector<vector<double>> good_track_xy_vec; good_track_xy_vec.clear();
0489 vector<vector<double>> good_track_rz_vec; good_track_rz_vec.clear();
0490 vector<vector<double>> good_comb_rz_vec; good_comb_rz_vec.clear();
0491 vector<vector<double>> good_comb_xy_vec; good_comb_xy_vec.clear();
0492 vector<vector<double>> good_comb_phi_vec; good_comb_phi_vec.clear();
0493 vector<vector<double>> good_tracklet_rz; good_tracklet_rz.clear();
0494 TLine * track_line = new TLine();
0495 track_line -> SetLineWidth(1);
0496 track_line -> SetLineColorAlpha(38,0.5);
0497
0498 TLine * coord_line = new TLine();
0499 coord_line -> SetLineWidth(1);
0500 coord_line -> SetLineColor(16);
0501 coord_line -> SetLineStyle(2);
0502
0503
0504 vector<float> avg_event_zvtx_vec; avg_event_zvtx_vec.clear();
0505 vector<float> Z_resolution_vec; Z_resolution_vec.clear();
0506 TH1F * avg_event_zvtx = new TH1F("","avg_event_zvtx",100,zvtx_hist_l,zvtx_hist_r);
0507
0508
0509
0510 avg_event_zvtx -> SetLineColor(TColor::GetColor("#1A3947"));
0511 avg_event_zvtx -> SetLineWidth(2);
0512 avg_event_zvtx -> GetYaxis() -> SetTitle("Entry");
0513 avg_event_zvtx -> GetXaxis() -> SetTitle("Z vertex position [mm]");
0514 avg_event_zvtx -> GetYaxis() -> SetRangeUser(0,50);
0515 avg_event_zvtx -> SetTitleSize(0.06, "X");
0516 avg_event_zvtx -> SetTitleSize(0.06, "Y");
0517 avg_event_zvtx -> GetXaxis() -> SetTitleOffset(0.82);
0518 avg_event_zvtx -> GetYaxis() -> SetTitleOffset(1.1);
0519 avg_event_zvtx -> GetXaxis() -> CenterTitle(true);
0520 avg_event_zvtx -> GetYaxis() -> CenterTitle(true);
0521 avg_event_zvtx -> GetXaxis() -> SetNdivisions(505);
0522
0523 TH1F * zvtx_evt_width = new TH1F("","zvtx_evt_width",150,0,800);
0524 zvtx_evt_width -> GetXaxis() -> SetTitle(" mm ");
0525 zvtx_evt_width -> GetYaxis() -> SetTitle("entry");
0526 zvtx_evt_width -> GetXaxis() -> SetNdivisions(505);
0527
0528 TH2F * zvtx_evt_fitError_corre = new TH2F("","zvtx_evt_fitError_corre",200,0,10000,200,0,20);
0529 zvtx_evt_fitError_corre -> GetXaxis() -> SetTitle(" # of clusters ");
0530 zvtx_evt_fitError_corre -> GetYaxis() -> SetTitle(" #pm mm ");
0531 zvtx_evt_fitError_corre -> GetXaxis() -> SetNdivisions(505);
0532
0533 TH2F * zvtx_evt_width_corre = new TH2F("","zvtx_evt_width_corre",200,0,10000,200,0,300);
0534 zvtx_evt_width_corre -> GetXaxis() -> SetTitle(" # of clusters ");
0535 zvtx_evt_width_corre -> GetYaxis() -> SetTitle(" mm ");
0536 zvtx_evt_width_corre -> GetXaxis() -> SetNdivisions(505);
0537
0538 TH2F * zvtx_evt_nclu_corre = new TH2F("","zvtx_evt_nclu_corre",200,0,10000,200,-500,500);
0539 zvtx_evt_nclu_corre -> GetXaxis() -> SetTitle(" # of clusters ");
0540 zvtx_evt_nclu_corre -> GetYaxis() -> SetTitle(" zvtx [mm] ");
0541 zvtx_evt_nclu_corre -> GetXaxis() -> SetNdivisions(505);
0542
0543 TH1F * width_density = new TH1F("","width_density",200,0,40);
0544 width_density -> GetXaxis() -> SetTitle(" N good zvtx / width ");
0545 width_density -> GetYaxis() -> SetTitle(" Entry ");
0546 width_density -> GetXaxis() -> SetNdivisions(505);
0547
0548 TH2F * Z_resolution_Nclu = new TH2F("","Z_resolution_Nclu",200,0,10000,200,-100,100);
0549 Z_resolution_Nclu -> GetXaxis() -> SetTitle(" # of clusters ");
0550 Z_resolution_Nclu -> GetYaxis() -> SetTitle(" #Delta Z (Reco - True) [mm]");
0551 Z_resolution_Nclu -> GetXaxis() -> SetNdivisions(505);
0552
0553 TH2F * Z_resolution_pos = new TH2F("","Z_resolution_pos",200,-350,350,200,-100,100);
0554 Z_resolution_pos -> GetXaxis() -> SetTitle("True Zvtx [mm]");
0555 Z_resolution_pos -> GetYaxis() -> SetTitle(" #Delta Z (Reco - True) [mm]");
0556 Z_resolution_pos -> GetXaxis() -> SetNdivisions(505);
0557
0558 TH2F * Z_resolution_pos_cut = new TH2F("","Z_resolution_pos_cut",200,-350,350,200,-100,100);
0559 Z_resolution_pos_cut -> GetXaxis() -> SetTitle("True Zvtx [mm]");
0560 Z_resolution_pos_cut -> GetYaxis() -> SetTitle(" #Delta Z (Reco - True) [mm]");
0561 Z_resolution_pos_cut -> GetXaxis() -> SetNdivisions(505);
0562
0563 TH1F * Z_resolution = new TH1F("","Z_resolution",200,-100,100);
0564 Z_resolution -> GetXaxis() -> SetTitle(" #Delta Z (Reco - True) [mm]");
0565 Z_resolution -> GetYaxis() -> SetTitle(" Entry ");
0566 Z_resolution -> GetXaxis() -> SetNdivisions(505);
0567
0568 TH1F * evt_possible_z = new TH1F("","evt_possible_z",100,-700,700);
0569 evt_possible_z -> SetLineWidth(1);
0570 evt_possible_z -> GetXaxis() -> SetTitle("Z [mm]");
0571 evt_possible_z -> GetYaxis() -> SetTitle("Entry");
0572 TF1 * gaus_fit = new TF1("gaus_fit",gaus_func,-600,600,4);
0573 gaus_fit -> SetLineColor(2);
0574 gaus_fit -> SetLineWidth(1);
0575 gaus_fit -> SetNpx(1000);
0576
0577 TH2F * gaus_width_Nclu = new TH2F("","gaus_width_Nclu",200,0,10000,200,0,100);
0578 gaus_width_Nclu -> GetXaxis() -> SetTitle(" # of clusters ");
0579 gaus_width_Nclu -> GetYaxis() -> SetTitle("Gaus fit width [mm]");
0580 gaus_width_Nclu -> GetXaxis() -> SetNdivisions(505);
0581
0582 TH2F * gaus_rchi2_Nclu = new TH2F("","gaus_rchi2_Nclu",200,0,10000,200,0,25);
0583 gaus_rchi2_Nclu -> GetXaxis() -> SetTitle(" # of clusters ");
0584 gaus_rchi2_Nclu -> GetYaxis() -> SetTitle("Gaus fit #chi2^{2}/NDF");
0585 gaus_rchi2_Nclu -> GetXaxis() -> SetNdivisions(505);
0586
0587
0588 vector<TH1F * > DeltaPhi_DCA; DeltaPhi_DCA.clear();
0589 for (int i = 0; i < 20; i++){
0590 DeltaPhi_DCA.push_back(new TH1F("",Form("range : %i to %i",i * 500, (i + 1) * 500),100,0,5));
0591 cout<<Form("hist %i, range : %i to %i", i, i * 500, (i + 1) * 500)<<endl;
0592 DeltaPhi_DCA[i] -> GetXaxis() -> SetTitle(" #sqrt{#Delta#phi^{2} + DCA^{2}}");
0593 DeltaPhi_DCA[i] -> GetYaxis() -> SetTitle(" Entry ");
0594 DeltaPhi_DCA[i] -> GetXaxis() -> SetNdivisions(505);
0595 }
0596
0597
0598
0599 int inner_1_check = 0; int inner_2_check = 0; int inner_3_check = 0; int inner_4_check = 0;
0600 int outer_1_check = 0; int outer_2_check = 0; int outer_3_check = 0; int outer_4_check = 0;
0601 vector<int> used_outer_check(temp_sPH_outer_nocolumn_vec.size(),0);
0602 vector<float> N_comb; vector<float> N_comb_e; vector<float> z_mid; vector<float> z_range;
0603 vector<double> eff_N_comb; vector<double> eff_z_mid; vector<double> eff_N_comb_e; vector<double> eff_z_range;
0604
0605 int N_event_pass_number = 0;
0606 long good_comb_id = 0;
0607
0608 if (draw_event_display) c2 -> Print(Form("%s/temp_event_display.pdf(",out_folder_directory.c_str()));
0609
0610 for (int event_i = 0; event_i < 20000; event_i++)
0611 {
0612 if (event_i % 1000 == 0) cout<<"code running... "<<event_i<<endl;
0613 inttDSTMC.LoadTree(event_i);
0614 inttDSTMC.GetEntry(event_i);
0615 unsigned int length = inttDSTMC.ClusX->size();
0616
0617 out_eID = event_i;
0618 N_cluster_inner_out = -1;
0619 N_cluster_outer_out = -1;
0620 out_zvtx = -1;
0621 out_zvtxE = -1;
0622 out_rangeL = -1;
0623 out_rangeR = -1;
0624 out_N_good = -1;
0625 bco_full_out = -1;
0626 MC_true_zvtx = -1000;
0627 out_width_density = -1;
0628
0629
0630
0631
0632
0633
0634
0635 N_event_pass_number += 1;
0636
0637
0638
0639 if ((length) < zvtx_cal_require) {tree_out -> Fill(); continue;}
0640 if ((length) < N_clu_cutl) {printf("low clu continue, NClus : %i \n", length); tree_out -> Fill(); continue;}
0641 if (inttDSTMC.TruthPV_x -> size() != 1) {cout<<"Nvtx more than one, event : "<<event_i<<" Nvtx : "<<inttDSTMC.TruthPV_x -> size()<<endl; tree_out -> Fill(); continue;}
0642
0643
0644
0645 for (int clu_i = 0; clu_i < length; clu_i++)
0646 {
0647 if (int(inttDSTMC.ClusPhiSize -> at(clu_i)) > clu_size_cut) continue;
0648 if (int(inttDSTMC.ClusAdc -> at(clu_i)) < clu_sum_adc_cut) continue;
0649
0650 double clu_x = inttDSTMC.ClusX -> at(clu_i) * 10;
0651 double clu_y = inttDSTMC.ClusY -> at(clu_i) * 10;
0652 double clu_z = inttDSTMC.ClusZ -> at(clu_i) * 10;
0653 double clu_phi = (clu_y < 0) ? atan2(clu_y,clu_x) * (180./TMath::Pi()) + 360 : atan2(clu_y,clu_x) * (180./TMath::Pi());
0654 int clu_layer = (inttDSTMC.ClusLayer -> at(clu_i) == 3 || inttDSTMC.ClusLayer -> at(clu_i) == 4) ? 0 : 1;
0655 double clu_radius = get_radius(clu_x, clu_y);
0656
0657 temp_sPH_nocolumn_vec[0].push_back( clu_x );
0658 temp_sPH_nocolumn_vec[1].push_back( clu_y );
0659
0660 temp_sPH_nocolumn_rz_vec[0].push_back( clu_z );
0661 temp_sPH_nocolumn_rz_vec[1].push_back( ( clu_phi > 180 ) ? clu_radius * -1 : clu_radius );
0662
0663
0664 if (clu_layer == 0)
0665 temp_sPH_inner_nocolumn_vec.push_back({
0666 -1,
0667 -1,
0668 int(inttDSTMC.ClusAdc -> at(clu_i)),
0669 int(inttDSTMC.ClusAdc -> at(clu_i)),
0670 int(inttDSTMC.ClusPhiSize -> at(clu_i)),
0671 clu_x,
0672 clu_y,
0673 clu_z,
0674 clu_layer,
0675 clu_phi
0676 });
0677
0678 if (clu_layer == 1)
0679 temp_sPH_outer_nocolumn_vec.push_back({
0680 -1,
0681 -1,
0682 int(inttDSTMC.ClusAdc -> at(clu_i)),
0683 int(inttDSTMC.ClusAdc -> at(clu_i)),
0684 int(inttDSTMC.ClusPhiSize -> at(clu_i)),
0685 clu_x,
0686 clu_y,
0687 clu_z,
0688 clu_layer,
0689 clu_phi
0690 });
0691 }
0692
0693 inner_1_check = 0;
0694 inner_2_check = 0;
0695 inner_3_check = 0;
0696 inner_4_check = 0;
0697 for (int inner_i = 0; inner_i < temp_sPH_inner_nocolumn_vec.size(); inner_i++) {
0698 if (temp_sPH_inner_nocolumn_vec[inner_i].phi >= 0 && temp_sPH_inner_nocolumn_vec[inner_i].phi < 90) inner_1_check = 1;
0699 if (temp_sPH_inner_nocolumn_vec[inner_i].phi >= 90 && temp_sPH_inner_nocolumn_vec[inner_i].phi < 180) inner_2_check = 1;
0700 if (temp_sPH_inner_nocolumn_vec[inner_i].phi >= 180 && temp_sPH_inner_nocolumn_vec[inner_i].phi < 270) inner_3_check = 1;
0701 if (temp_sPH_inner_nocolumn_vec[inner_i].phi >= 270 && temp_sPH_inner_nocolumn_vec[inner_i].phi < 360) inner_4_check = 1;
0702
0703 if ( (inner_1_check + inner_2_check + inner_3_check + inner_4_check) == 4 ) break;
0704 }
0705
0706 outer_1_check = 0;
0707 outer_2_check = 0;
0708 outer_3_check = 0;
0709 outer_4_check = 0;
0710 for (int outer_i = 0; outer_i < temp_sPH_outer_nocolumn_vec.size(); outer_i++) {
0711 if (temp_sPH_outer_nocolumn_vec[outer_i].phi >= 0 && temp_sPH_outer_nocolumn_vec[outer_i].phi < 90) outer_1_check = 1;
0712 if (temp_sPH_outer_nocolumn_vec[outer_i].phi >= 90 && temp_sPH_outer_nocolumn_vec[outer_i].phi < 180) outer_2_check = 1;
0713 if (temp_sPH_outer_nocolumn_vec[outer_i].phi >= 180 && temp_sPH_outer_nocolumn_vec[outer_i].phi < 270) outer_3_check = 1;
0714 if (temp_sPH_outer_nocolumn_vec[outer_i].phi >= 270 && temp_sPH_outer_nocolumn_vec[outer_i].phi < 360) outer_4_check = 1;
0715
0716 if ( (outer_1_check + outer_2_check + outer_3_check + outer_4_check) == 4 ) break;
0717 }
0718
0719 if (temp_sPH_inner_nocolumn_vec.size() < 10 || temp_sPH_outer_nocolumn_vec.size() < 10 || (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)
0720 {
0721 temp_event_zvtx_info = {-1000,-1000,-1000};
0722 temp_event_zvtx_vec.clear();
0723 temp_event_zvtx -> Reset("ICESM");
0724 good_track_xy_vec.clear();
0725 good_track_rz_vec.clear();
0726 good_comb_rz_vec.clear();
0727 good_comb_xy_vec.clear();
0728 good_comb_phi_vec.clear();
0729 temp_sPH_nocolumn_rz_vec.clear(); temp_sPH_nocolumn_rz_vec = vector<vector<double>>(2);
0730 temp_sPH_nocolumn_vec.clear(); temp_sPH_nocolumn_vec = vector<vector<double>>(2);
0731 temp_sPH_inner_nocolumn_vec.clear();
0732 temp_sPH_outer_nocolumn_vec.clear();
0733 tree_out -> Fill();
0734 continue;
0735 }
0736
0737 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 )
0738 {
0739 cout<<"some quater of INTT doens't work !! eID : "<<event_i<<endl;
0740 temp_event_zvtx_info = {-1000,-1000,-1000};
0741 temp_event_zvtx_vec.clear();
0742 temp_event_zvtx -> Reset("ICESM");
0743 good_track_xy_vec.clear();
0744 good_track_rz_vec.clear();
0745 good_comb_rz_vec.clear();
0746 good_comb_xy_vec.clear();
0747 good_comb_phi_vec.clear();
0748 temp_sPH_nocolumn_rz_vec.clear(); temp_sPH_nocolumn_rz_vec = vector<vector<double>>(2);
0749 temp_sPH_nocolumn_vec.clear(); temp_sPH_nocolumn_vec = vector<vector<double>>(2);
0750 temp_sPH_inner_nocolumn_vec.clear();
0751 temp_sPH_outer_nocolumn_vec.clear();
0752 tree_out -> Fill();
0753 continue;
0754 }
0755
0756 N_comb.clear();
0757 N_comb_e.clear();
0758 z_mid.clear();
0759 z_range.clear();
0760
0761
0762
0763
0764
0765 for ( int inner_i = 0; inner_i < temp_sPH_inner_nocolumn_vec.size(); inner_i++ )
0766 {
0767
0768 for ( int outer_i = 0; outer_i < temp_sPH_outer_nocolumn_vec.size(); outer_i++ )
0769 {
0770
0771
0772
0773
0774
0775
0776
0777
0778
0779
0780
0781
0782
0783
0784 if (fabs(temp_sPH_inner_nocolumn_vec[inner_i].phi - temp_sPH_outer_nocolumn_vec[outer_i].phi) < phi_diff_cut)
0785 {
0786 vector<double> DCA_info_vec = calculateDistanceAndClosestPoint(
0787 temp_sPH_inner_nocolumn_vec[inner_i].x, temp_sPH_inner_nocolumn_vec[inner_i].y,
0788 temp_sPH_outer_nocolumn_vec[outer_i].x, temp_sPH_outer_nocolumn_vec[outer_i].y,
0789 beam_origin.first, beam_origin.second
0790 );
0791
0792 if (DCA_info_vec[0] < DCA_cut){
0793
0794
0795
0796 pair<double,double> z_range_info = Get_possible_zvtx(
0797 get_radius(beam_origin.first,beam_origin.second),
0798 {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},
0799 {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}
0800 );
0801
0802 N_comb.push_back(good_comb_id);
0803 N_comb_e.push_back(0);
0804 z_mid.push_back(z_range_info.first);
0805 z_range.push_back(z_range_info.second);
0806
0807 evt_possible_z -> Fill(z_range_info.first);
0808
0809 good_comb_id += 1;
0810
0811
0812 }
0813
0814
0815
0816
0817 }
0818
0819
0820 }
0821 }
0822
0823 good_comb_id = 0;
0824
0825
0826 TGraphErrors * z_range_gr;
0827 eff_N_comb.clear();
0828 eff_z_mid.clear();
0829 eff_N_comb_e.clear();
0830 eff_z_range.clear();
0831
0832 if (N_comb.size() > zvtx_cal_require)
0833 {
0834 double final_selection_widthU, final_selection_widthD;
0835
0836 gaus_fit -> SetParameters(evt_possible_z -> GetBinContent( evt_possible_z -> GetMaximumBin() ), evt_possible_z -> GetBinCenter( evt_possible_z -> GetMaximumBin() ), 40, 0);
0837 gaus_fit -> SetParLimits(3,0,10000);
0838 evt_possible_z -> Fit(gaus_fit, "NQ");
0839
0840 if (temp_sPH_inner_nocolumn_vec.size() + temp_sPH_outer_nocolumn_vec.size() < 1000) {
0841 temp_event_zvtx_info = sigmaEff_avg(z_mid,Integrate_portion);
0842 final_selection_widthU = ( fabs(temp_event_zvtx_info[2] - temp_event_zvtx_info[1]) / 2. < fabs(gaus_fit -> GetParameter(2)) ) ? temp_event_zvtx_info[2] : (gaus_fit -> GetParameter(1) + fabs(gaus_fit -> GetParameter(2)));
0843 final_selection_widthD = ( fabs(temp_event_zvtx_info[2] - temp_event_zvtx_info[1]) / 2. < fabs(gaus_fit -> GetParameter(2)) ) ? temp_event_zvtx_info[1] : (gaus_fit -> GetParameter(1) - fabs(gaus_fit -> GetParameter(2)));
0844 }
0845 else {
0846 temp_event_zvtx_info = {0,-1000,-999.99};
0847 final_selection_widthU = (gaus_fit -> GetParameter(1) + fabs(gaus_fit -> GetParameter(2)));
0848 final_selection_widthD = (gaus_fit -> GetParameter(1) - fabs(gaus_fit -> GetParameter(2)));
0849 }
0850
0851
0852
0853 for (int track_i = 0; track_i < N_comb.size(); track_i++) {
0854
0855 if ( final_selection_widthD <= z_mid[track_i] && z_mid[track_i] <= final_selection_widthU ){
0856 eff_N_comb.push_back(N_comb[track_i]);
0857 eff_z_mid.push_back(z_mid[track_i]);
0858 eff_N_comb_e.push_back(N_comb_e[track_i]);
0859 eff_z_range.push_back(z_range[track_i]);
0860 }
0861 }
0862
0863 z_range_gr = new TGraphErrors(eff_N_comb.size(),&eff_N_comb[0],&eff_z_mid[0],&eff_N_comb_e[0],&eff_z_range[0]);
0864
0865 z_range_gr -> Fit(zvtx_finder,"NQ","",0,N_comb[N_comb.size() - 1]);
0866
0867 gaus_width_Nclu -> Fill(temp_sPH_inner_nocolumn_vec.size() + temp_sPH_outer_nocolumn_vec.size(), fabs(gaus_fit -> GetParameter(2)));
0868 gaus_rchi2_Nclu -> Fill(temp_sPH_inner_nocolumn_vec.size() + temp_sPH_outer_nocolumn_vec.size(), gaus_fit -> GetChisquare() / double(gaus_fit -> GetNDF()));
0869
0870
0871 zvtx_evt_width -> Fill(fabs( zvtx_finder -> GetParError(0)));
0872 zvtx_evt_fitError_corre -> Fill(temp_sPH_inner_nocolumn_vec.size() + temp_sPH_outer_nocolumn_vec.size(), fabs( zvtx_finder -> GetParError(0)));
0873 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]));
0874 width_density -> Fill( eff_N_comb.size() / fabs(temp_event_zvtx_info[2] - temp_event_zvtx_info[1]) );
0875 if ( ( eff_N_comb.size() / fabs(temp_event_zvtx_info[2] - temp_event_zvtx_info[1]) ) > 0.3 ){
0876 zvtx_evt_nclu_corre -> Fill(temp_sPH_inner_nocolumn_vec.size() + temp_sPH_outer_nocolumn_vec.size(), zvtx_finder -> GetParameter(0));
0877 avg_event_zvtx -> Fill(zvtx_finder -> GetParameter(0));
0878 avg_event_zvtx_vec.push_back(zvtx_finder -> GetParameter(0));
0879 Z_resolution -> Fill( zvtx_finder -> GetParameter(0) - (inttDSTMC.TruthPV_trig_z*10.) );
0880 Z_resolution_vec.push_back( zvtx_finder -> GetParameter(0) - (inttDSTMC.TruthPV_trig_z*10.) );
0881 Z_resolution_Nclu -> Fill( temp_sPH_inner_nocolumn_vec.size() + temp_sPH_outer_nocolumn_vec.size() , zvtx_finder -> GetParameter(0) - (inttDSTMC.TruthPV_trig_z*10.) );
0882 Z_resolution_pos -> Fill(inttDSTMC.TruthPV_trig_z*10., zvtx_finder -> GetParameter(0) - (inttDSTMC.TruthPV_trig_z*10.));
0883 if (temp_sPH_inner_nocolumn_vec.size() + temp_sPH_outer_nocolumn_vec.size() > 1000) {Z_resolution_pos_cut -> Fill(inttDSTMC.TruthPV_trig_z*10., zvtx_finder -> GetParameter(0) - (inttDSTMC.TruthPV_trig_z*10.));}
0884 }
0885
0886 out_eID = event_i;
0887 N_cluster_inner_out = temp_sPH_inner_nocolumn_vec.size();
0888 N_cluster_outer_out = temp_sPH_outer_nocolumn_vec.size();
0889 out_zvtx = zvtx_finder -> GetParameter(0);
0890 out_zvtxE = zvtx_finder -> GetParError(0);
0891 out_rangeL = temp_event_zvtx_info[1];
0892 out_rangeR = temp_event_zvtx_info[2];
0893 out_N_good = eff_N_comb.size();
0894 bco_full_out = -1;
0895 MC_true_zvtx = inttDSTMC.TruthPV_trig_z*10.;
0896 out_width_density = eff_N_comb.size() / fabs(temp_event_zvtx_info[2] - temp_event_zvtx_info[1]);
0897 tree_out -> Fill();
0898
0899 z_range_gr -> Delete();
0900 }
0901
0902 else {tree_out -> Fill();}
0903
0904
0905 if (zvtx_draw_requireL < N_comb.size() && draw_event_display == true && N_comb.size() > zvtx_cal_require)
0906 {
0907 TGraph * temp_event_xy = new TGraph(temp_sPH_nocolumn_vec[0].size(),&temp_sPH_nocolumn_vec[0][0],&temp_sPH_nocolumn_vec[1][0]);
0908 temp_event_xy -> SetTitle("INTT event display X-Y plane");
0909 temp_event_xy -> GetXaxis() -> SetLimits(-150,150);
0910 temp_event_xy -> GetYaxis() -> SetRangeUser(-150,150);
0911 temp_event_xy -> GetXaxis() -> SetTitle("X [mm]");
0912 temp_event_xy -> GetYaxis() -> SetTitle("Y [mm]");
0913 temp_event_xy -> SetMarkerStyle(20);
0914 temp_event_xy -> SetMarkerColor(2);
0915 temp_event_xy -> SetMarkerSize(1);
0916 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]);
0917 temp_event_rz -> SetTitle("INTT event display r-Z plane");
0918 temp_event_rz -> GetXaxis() -> SetLimits(-500,500);
0919 temp_event_rz -> GetYaxis() -> SetRangeUser(-150,150);
0920 temp_event_rz -> GetXaxis() -> SetTitle("Z [mm]");
0921 temp_event_rz -> GetYaxis() -> SetTitle("Radius [mm]");
0922 temp_event_rz -> SetMarkerStyle(20);
0923 temp_event_rz -> SetMarkerColor(2);
0924 temp_event_rz -> SetMarkerSize(1);
0925
0926 pad_xy -> cd();
0927 temp_bkg(pad_xy, conversion_mode, peek, beam_origin, ch_pos_DB);
0928 temp_event_xy -> Draw("p same");
0929 for (int track_i = 0; track_i < good_track_xy_vec.size(); track_i++){
0930 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]);
0931 }
0932 track_line -> Draw("l same");
0933 draw_text -> DrawLatex(0.2, 0.85, Form("eID : %i, innter Ncluster : %i, outer Ncluster : %i",event_i,temp_sPH_inner_nocolumn_vec.size(),temp_sPH_outer_nocolumn_vec.size()));
0934
0935 pad_rz -> cd();
0936 temp_event_rz -> Draw("ap");
0937
0938 coord_line -> DrawLine(0,-150,0,150);
0939 coord_line -> DrawLine(-500,0,500,0);
0940 for (int track_i = 0; track_i < good_track_rz_vec.size(); track_i++){
0941 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]);
0942 }
0943 draw_text -> DrawLatex(0.2, 0.85, Form("Negative radius : Clu_{outer} > 180^{0}"));
0944
0945
0946
0947 pad_z -> cd();
0948 TGraphErrors * z_range_gr_draw = new TGraphErrors(N_comb.size(),&N_comb[0],&z_mid[0],&N_comb_e[0],&z_range[0]);
0949 z_range_gr_draw -> GetYaxis() -> SetRangeUser(-650,650);
0950 z_range_gr_draw -> SetMarkerStyle(20);
0951 z_range_gr_draw -> Draw("ap");
0952
0953 draw_text -> DrawLatex(0.2, 0.82, Form("Event Zvtx %.2f mm, error : #pm%.2f", zvtx_finder -> GetParameter(0), zvtx_finder -> GetParError(0)));
0954 draw_text -> DrawLatex(0.2, 0.78, Form("Width density : %.2f", ( eff_N_comb.size() / fabs(temp_event_zvtx_info[2] - temp_event_zvtx_info[1]) )));
0955 draw_text -> DrawLatex(0.2, 0.74, Form("Width : %.2f to %.2f mm", temp_event_zvtx_info[2] , temp_event_zvtx_info[1]));
0956
0957 eff_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]);
0958 eff_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]);
0959 z_range_gr_draw -> Draw("p same");
0960 zvtx_finder -> Draw("lsame");
0961
0962
0963 pad_z_hist -> cd();
0964 evt_possible_z -> Draw("hist");
0965 gaus_fit -> Draw("lsame");
0966 draw_text -> DrawLatex(0.2, 0.82, Form("Gaus mean %.2f mm", gaus_fit -> GetParameter(1)));
0967 draw_text -> DrawLatex(0.2, 0.78, Form("Width : %.2f mm", fabs(gaus_fit -> GetParameter(2))));
0968 draw_text -> DrawLatex(0.2, 0.74, Form("Reduced #chi2 : %.3f", gaus_fit -> GetChisquare() / double(gaus_fit -> GetNDF())));
0969
0970
0971
0972
0973
0974
0975
0976
0977
0978
0979 if(draw_event_display && (event_i % print_rate) == 0){c2 -> Print(Form("%s/temp_event_display.pdf",out_folder_directory.c_str()));}
0980 if(fabs(gaus_fit -> GetParameter(2)) > 40) {
0981 cout<<"check event : "<<event_i<<" width : "<<fabs(gaus_fit -> GetParameter(2))<<" NClu : "<<temp_sPH_inner_nocolumn_vec.size() + temp_sPH_outer_nocolumn_vec.size()<<endl;
0982 c2 -> Print(Form("%s/temp_event_display.pdf",out_folder_directory.c_str()));
0983 }
0984 if (fabs(temp_event_zvtx_info[2] - temp_event_zvtx_info[1])>100){
0985 cout<<"check event : "<<event_i<<" eff_width : "<<fabs(temp_event_zvtx_info[2] - temp_event_zvtx_info[1])<<" NClu : "<<temp_sPH_inner_nocolumn_vec.size() + temp_sPH_outer_nocolumn_vec.size()<<endl;
0986 c2 -> Print(Form("%s/temp_event_display.pdf",out_folder_directory.c_str()));
0987 }
0988 pad_xy -> Clear();
0989 pad_rz -> Clear();
0990 pad_z -> Clear();
0991 pad_z_hist -> Clear();
0992
0993 temp_event_xy -> Delete();
0994 temp_event_rz -> Delete();
0995 z_range_gr_draw -> Delete();
0996
0997 }
0998
0999
1000 evt_possible_z -> Reset("ICESM");
1001 temp_event_zvtx_info = {-1000,-1000,-1000};
1002 temp_event_zvtx_vec.clear();
1003 temp_event_zvtx -> Reset("ICESM");
1004 good_track_xy_vec.clear();
1005 good_track_rz_vec.clear();
1006 good_comb_rz_vec.clear();
1007 good_comb_xy_vec.clear();
1008 good_comb_phi_vec.clear();
1009 temp_sPH_nocolumn_rz_vec.clear(); temp_sPH_nocolumn_rz_vec = vector<vector<double>>(2);
1010 temp_sPH_nocolumn_vec.clear(); temp_sPH_nocolumn_vec = vector<vector<double>>(2);
1011 temp_sPH_inner_nocolumn_vec.clear();
1012 temp_sPH_outer_nocolumn_vec.clear();
1013 N_comb.clear();
1014 N_comb_e.clear();
1015 z_mid.clear();
1016 z_range.clear();
1017 }
1018
1019 if (draw_event_display) {c2 -> Print(Form("%s/temp_event_display.pdf)",out_folder_directory.c_str()));}
1020 c2 -> Clear();
1021 c1 -> Clear();
1022
1023 tree_out->SetDirectory(out_file);
1024 tree_out -> Write("", TObject::kOverwrite);
1025
1026 cout<<"test1, z size : "<<avg_event_zvtx_vec.size()<<endl;
1027
1028 c1 -> cd();
1029 vector<float> avg_event_zvtx_info = sigmaEff_avg(avg_event_zvtx_vec,Integrate_portion_final);
1030
1031 avg_event_zvtx -> SetMinimum( 0 ); avg_event_zvtx -> SetMaximum( avg_event_zvtx->GetBinContent(avg_event_zvtx->GetMaximumBin()) * 1.5 );
1032 avg_event_zvtx -> Draw("hist");
1033
1034 TLatex *ltx = new TLatex();
1035 ltx->SetNDC();
1036 ltx->SetTextSize(0.045);
1037 ltx->SetTextAlign(31);
1038 ltx->DrawLatex(1 - gPad->GetRightMargin(), 1 - gPad->GetTopMargin() + 0.01, "#it{#bf{sPHENIX INTT}} Simulation");
1039
1040
1041
1042 eff_sig_range_line -> DrawLine(avg_event_zvtx_info[1],0,avg_event_zvtx_info[1],avg_event_zvtx -> GetMaximum());
1043 eff_sig_range_line -> DrawLine(avg_event_zvtx_info[2],0,avg_event_zvtx_info[2],avg_event_zvtx -> GetMaximum());
1044 draw_text -> DrawLatex(0.21, 0.87, Form("EffSig min : %.2f mm",avg_event_zvtx_info[1]));
1045 draw_text -> DrawLatex(0.21, 0.83, Form("EffSig max : %.2f mm",avg_event_zvtx_info[2]));
1046 draw_text -> DrawLatex(0.21, 0.79, Form("EffSig avg : %.2f mm",avg_event_zvtx_info[0]));
1047 c1 -> Print(Form("%s/avg_event_zvtx.pdf",out_folder_directory.c_str()));
1048 c1 -> Clear();
1049
1050
1051
1052 width_density -> Draw("hist");
1053 ltx->DrawLatex(1 - gPad->GetRightMargin(), 1 - gPad->GetTopMargin() + 0.01, "#it{#bf{sPHENIX INTT}} Simulation");
1054 c1 -> Print(Form("%s/width_density.pdf",out_folder_directory.c_str()));
1055 c1 -> Clear();
1056
1057 zvtx_evt_width -> Draw("hist");
1058 ltx->DrawLatex(1 - gPad->GetRightMargin(), 1 - gPad->GetTopMargin() + 0.01, "#it{#bf{sPHENIX INTT}} Simulation");
1059 c1 -> Print(Form("%s/zvtx_evt_width.pdf",out_folder_directory.c_str()));
1060 c1 -> Clear();
1061
1062 vector<float> Z_resolution_vec_info = sigmaEff_avg(Z_resolution_vec,Integrate_portion_final);
1063
1064 gaus_fit -> SetParameters(Z_resolution -> GetBinContent( Z_resolution -> GetMaximumBin() ), Z_resolution -> GetBinCenter( Z_resolution -> GetMaximumBin() ), 3, 0);
1065 gaus_fit -> SetParLimits(3,0,10);
1066 Z_resolution -> Fit(gaus_fit, "NQ");
1067
1068 Z_resolution -> Draw("hist");
1069 gaus_fit -> Draw("lsame");
1070 eff_sig_range_line -> DrawLine(Z_resolution_vec_info[1],0,Z_resolution_vec_info[1],Z_resolution -> GetMaximum());
1071 eff_sig_range_line -> DrawLine(Z_resolution_vec_info[2],0,Z_resolution_vec_info[2],Z_resolution -> GetMaximum());
1072 draw_text -> DrawLatex(0.21, 0.87, Form("EffSig min : %.2f mm",Z_resolution_vec_info[1]));
1073 draw_text -> DrawLatex(0.21, 0.83, Form("EffSig max : %.2f mm",Z_resolution_vec_info[2]));
1074 draw_text -> DrawLatex(0.21, 0.79, Form("EffSig avg : %.2f mm",Z_resolution_vec_info[0]));
1075 draw_text -> DrawLatex(0.21, 0.71, Form("Gaus mean : %.2f mm",gaus_fit -> GetParameter(1)));
1076 draw_text -> DrawLatex(0.21, 0.67, Form("Gaus width : %.2f mm",fabs(gaus_fit -> GetParameter(2))));
1077 ltx->DrawLatex(1 - gPad->GetRightMargin(), 1 - gPad->GetTopMargin() + 0.01, "#it{#bf{sPHENIX INTT}} Simulation");
1078 c1 -> Print(Form("%s/Z_resolution.pdf",out_folder_directory.c_str()));
1079 c1 -> Clear();
1080
1081 Z_resolution_Nclu -> Draw("colz0");
1082 ltx->DrawLatex(1 - gPad->GetRightMargin(), 1 - gPad->GetTopMargin() + 0.01, "#it{#bf{sPHENIX INTT}} Simulation");
1083 c1 -> Print(Form("%s/Z_resolution_Nclu.pdf",out_folder_directory.c_str()));
1084 c1 -> Clear();
1085
1086 Z_resolution_pos -> Draw("colz0");
1087 ltx->DrawLatex(1 - gPad->GetRightMargin(), 1 - gPad->GetTopMargin() + 0.01, "#it{#bf{sPHENIX INTT}} Simulation");
1088 c1 -> Print(Form("%s/Z_resolution_pos.pdf",out_folder_directory.c_str()));
1089 c1 -> Clear();
1090
1091 Z_resolution_pos_cut -> Draw("colz0");
1092 ltx->DrawLatex(1 - gPad->GetRightMargin(), 1 - gPad->GetTopMargin() + 0.01, "#it{#bf{sPHENIX INTT}} Simulation");
1093 c1 -> Print(Form("%s/Z_resolution_pos_cut.pdf",out_folder_directory.c_str()));
1094 c1 -> Clear();
1095
1096
1097 zvtx_evt_fitError_corre -> Draw("colz0");
1098 ltx->DrawLatex(1 - gPad->GetRightMargin(), 1 - gPad->GetTopMargin() + 0.01, "#it{#bf{sPHENIX INTT}} Simulation");
1099 c1 -> Print(Form("%s/zvtx_evt_fitError_corre.pdf",out_folder_directory.c_str()));
1100 c1 -> Clear();
1101
1102 zvtx_evt_nclu_corre -> Draw("colz0");
1103 ltx->DrawLatex(1 - gPad->GetRightMargin(), 1 - gPad->GetTopMargin() + 0.01, "#it{#bf{sPHENIX INTT}} Simulation");
1104 c1 -> Print(Form("%s/zvtx_evt_nclu_corre.pdf",out_folder_directory.c_str()));
1105 c1 -> Clear();
1106
1107 zvtx_evt_width_corre -> Draw("colz0");
1108 ltx->DrawLatex(1 - gPad->GetRightMargin(), 1 - gPad->GetTopMargin() + 0.01, "#it{#bf{sPHENIX INTT}} Simulation");
1109 c1 -> Print(Form("%s/zvtx_evt_width_corre.pdf",out_folder_directory.c_str()));
1110 c1 -> Clear();
1111
1112 gaus_width_Nclu -> Draw("colz0");
1113 ltx->DrawLatex(1 - gPad->GetRightMargin(), 1 - gPad->GetTopMargin() + 0.01, "#it{#bf{sPHENIX INTT}} Simulation");
1114 c1 -> Print(Form("%s/gaus_width_Nclu.pdf",out_folder_directory.c_str()));
1115 c1 -> Clear();
1116
1117 gaus_rchi2_Nclu -> Draw("colz0");
1118 ltx->DrawLatex(1 - gPad->GetRightMargin(), 1 - gPad->GetTopMargin() + 0.01, "#it{#bf{sPHENIX INTT}} Simulation");
1119 c1 -> Print(Form("%s/gaus_rchi2_Nclu.pdf",out_folder_directory.c_str()));
1120 c1 -> Clear();
1121 }