File indexing completed on 2025-08-05 08:11:54
0001
0002
0003 #include "InttClustering.h"
0004 #include "sigmaEff.h"
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024 vector<vector<int>> adc_setting_run = {
0025 {15, 30, 60, 90, 120, 150, 180, 210, 240}
0026
0027
0028
0029
0030
0031
0032
0033
0034
0035
0036
0037 };
0038
0039 TString color_code_2[8] = {"#CC768D","#19768D","#DDA573","#009193","#6E9193","#941100","#A08144","#517E66"};
0040
0041 struct full_hit_info {
0042 int FC;
0043 int chip_id;
0044 int chan_id;
0045 int adc;
0046 };
0047
0048
0049 struct ladder_info {
0050 int FC;
0051 TString Port;
0052 int ROC;
0053 int Direction;
0054 };
0055
0056 double get_radius(double x, double y)
0057 {
0058 return sqrt(pow(x,2)+pow(y,2));
0059 }
0060
0061 double get_radius_sign(double x, double y)
0062 {
0063 double phi = ((y) < 0) ? atan2((y),(x)) * (180./TMath::Pi()) + 360 : atan2((y),(x)) * (180./TMath::Pi());
0064
0065 return (phi > 180) ? sqrt(pow(x,2)+pow(y,2)) * -1 : sqrt(pow(x,2)+pow(y,2));
0066 }
0067
0068 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)
0069 {
0070 if (setgrid_bool == true) {pad -> SetGrid (1, 1);}
0071 pad -> SetLeftMargin (left);
0072 pad -> SetRightMargin (right);
0073 pad -> SetTopMargin (top);
0074 pad -> SetBottomMargin (bottom);
0075 pad -> SetTicks(1,1);
0076 if (set_logY == true)
0077 {
0078 pad -> SetLogy (1);
0079 }
0080
0081 }
0082
0083 std::vector<double> calculateDistanceAndClosestPoint(double x1, double y1, double x2, double y2, double target_x, double target_y) {
0084
0085 if (x1 != x2)
0086 {
0087
0088 double a = (y2 - y1) / (x2 - x1);
0089 double b = y1 - a * x1;
0090
0091
0092
0093
0094 double closest_distance = std::abs(a * target_x - target_y + b) / std::sqrt(a * a + 1);
0095
0096
0097 double Xc = (target_x + a * target_y - a * b) / (a * a + 1);
0098 double Yc = a * Xc + b;
0099
0100 return { closest_distance, Xc, Yc };
0101 }
0102 else
0103 {
0104 double closest_distance = std::abs(x1 - target_x);
0105 double Xc = x1;
0106 double Yc = target_y;
0107
0108 return { closest_distance, Xc, Yc };
0109 }
0110
0111
0112 }
0113
0114 double get_z_vertex(clu_info inner_clu, clu_info outer_clu, double target_x, double target_y)
0115 {
0116
0117
0118 double inner_clu_r = sqrt(pow(inner_clu.x,2)+ pow(inner_clu.y,2));
0119 double outer_clu_r = sqrt(pow(outer_clu.x,2)+ pow(outer_clu.y,2));
0120 double target_r = sqrt(pow(target_x,2) + pow(target_y,2));
0121
0122
0123 if ( fabs(outer_clu.z - inner_clu.z) < 0.00001 ){
0124 return outer_clu.z;
0125 }
0126 else {
0127 double slope = (outer_clu_r - inner_clu_r) / (outer_clu.z - inner_clu.z);
0128 double yIntercept = inner_clu_r - slope * inner_clu.z;
0129 double xCoordinate = (target_r - yIntercept) / slope;
0130 return xCoordinate;
0131 }
0132
0133 }
0134
0135
0136 double calculateAngleBetweenVectors(double x1, double y1, double x2, double y2, double targetX, double targetY) {
0137
0138 double vector1X = x2 - x1;
0139 double vector1Y = y2 - y1;
0140
0141 double vector2X = targetX - x1;
0142 double vector2Y = targetY - y1;
0143
0144
0145 double crossProduct = vector1X * vector2Y - vector1Y * vector2X;
0146
0147
0148
0149
0150 double magnitude1 = std::sqrt(vector1X * vector1X + vector1Y * vector1Y);
0151 double magnitude2 = std::sqrt(vector2X * vector2X + vector2Y * vector2Y);
0152
0153
0154 double dotProduct = vector1X * vector2X + vector1Y * vector2Y;
0155
0156 double angleInRadians = std::atan2(std::abs(crossProduct), dotProduct);
0157
0158 double angleInDegrees = angleInRadians * 180.0 / M_PI;
0159
0160 double angleInRadians_new = std::asin( crossProduct/(magnitude1*magnitude2) );
0161 double angleInDegrees_new = angleInRadians_new * 180.0 / M_PI;
0162
0163
0164
0165 double DCA_distance = sin(angleInRadians_new) * magnitude2;
0166
0167 return DCA_distance;
0168 }
0169
0170 void temp_bkg(TPad * c1, string conversion_mode, double peek, pair<double,double> beam_origin)
0171 {
0172 c1 -> cd();
0173
0174 int N_ladder[4] = {12, 12, 16, 16};
0175 string ladder_index_string[16] = {"00","01","02","03","04","05","06","07","08","09","10","11","12","13","14","15"};
0176
0177 vector<double> x_vec; x_vec.clear();
0178 vector<double> y_vec; y_vec.clear();
0179
0180 vector<double> x_vec_2; x_vec_2.clear();
0181 vector<double> y_vec_2; y_vec_2.clear();
0182
0183 TGraph * bkg = new TGraph();
0184 bkg -> SetTitle("INTT event display X-Y plane");
0185 bkg -> SetMarkerStyle(20);
0186 bkg -> SetMarkerSize(0.1);
0187 bkg -> SetPoint(0,0,0);
0188 bkg -> SetPoint(1,beam_origin.first,beam_origin.second);
0189 bkg -> GetXaxis() -> SetLimits(-150,150);
0190 bkg -> GetYaxis() -> SetRangeUser(-150,150);
0191 bkg -> GetXaxis() -> SetTitle("X [mm]");
0192 bkg -> GetYaxis() -> SetTitle("Y [mm]");
0193
0194 bkg -> Draw("ap");
0195
0196 TLine * ladder_line = new TLine();
0197 ladder_line -> SetLineWidth(1);
0198
0199 for (int server_i = 0; server_i < 4; server_i++)
0200 {
0201 for (int FC_i = 0; FC_i < 14; FC_i++)
0202 {
0203 ladder_line -> DrawLine(
0204 InttConversion::Get_XY_all(Form("intt%i",server_i),FC_i,14,0,conversion_mode,peek).x, InttConversion::Get_XY_all(Form("intt%i",server_i),FC_i,14,0,conversion_mode,peek).y,
0205 InttConversion::Get_XY_all(Form("intt%i",server_i),FC_i,1,0,conversion_mode,peek).x, InttConversion::Get_XY_all(Form("intt%i",server_i),FC_i,1,0,conversion_mode,peek).y
0206 );
0207 }
0208 }
0209
0210 ladder_line -> Draw("l same");
0211
0212 }
0213
0214
0215
0216
0217 void dNdeta()
0218 {
0219 TCanvas * c2 = new TCanvas("","",2500,800);
0220 c2 -> cd();
0221 TPad *pad_xy = new TPad(Form("pad_xy"), "", 0.0, 0.0, 0.33, 1.0);
0222 Characterize_Pad(pad_xy, 0.15, 0.1, 0.1, 0.1 , 0, 0);
0223 pad_xy -> Draw();
0224
0225 TPad *pad_rz = new TPad(Form("pad_rz"), "", 0.33, 0.0, 0.66, 1.0);
0226 Characterize_Pad(pad_rz, 0.15, 0.1, 0.1, 0.1 , 0, 0);
0227 pad_rz -> Draw();
0228
0229 TPad *pad_z = new TPad(Form("pad_z"), "", 0.66, 0.0, 1.0, 1.0);
0230 Characterize_Pad(pad_z, 0.15, 0.1, 0.1, 0.1 , 0, 0);
0231 pad_z -> Draw();
0232
0233 TCanvas * c1 = new TCanvas("","",1000,800);
0234 c1 -> cd();
0235
0236 string mother_folder_directory = "/home/phnxrc/INTT/cwshih/DACscan_data/zero_magnet_Takashi_used";
0237
0238 string file_name = "beam_inttall-00020869-0000_event_base_ana_cluster_survey_1_XYAlpha_Peek_3.32mm_excludeR1500_100kEvent";
0239
0240
0241
0242
0243
0244
0245
0246 system(Form("mkdir %s/folder_%s_HighN",mother_folder_directory.c_str(),file_name.c_str()));
0247 pair<double,double> beam_origin = {-0,2};
0248 double temp_Y_align = 0.;
0249 double temp_X_align = -0.;
0250
0251 double zvtx_hist_l = -500;
0252 double zvtx_hist_r = 500;
0253
0254 int Nhit_cut = 520;
0255 int clu_size_cut = 4;
0256 double clu_sum_adc_cut = 31;
0257 int N_clu_cut = 201;
0258 double phi_diff_cut = 5.72;
0259 double DCA_cut = 4;
0260 int zvtx_cal_require = 15;
0261 int zvtx_draw_requireL = 15;
0262 int zvtx_draw_requireR = 100;
0263 double Integrate_portion = 0.6826;
0264
0265
0266 int geo_mode_id = 1;
0267 string conversion_mode = (geo_mode_id == 0) ? "ideal" : "survey_1_XYAlpha_Peek";
0268 double peek = 3.32405;
0269
0270 TFile * file_in = new TFile(Form("%s/%s.root",mother_folder_directory.c_str(),file_name.c_str()),"read");
0271 TTree * tree = (TTree *)file_in->Get("tree_clu");
0272
0273 long long N_event = tree -> GetEntries();
0274 cout<<Form("N_event in file %s : %lli",file_name.c_str(), N_event)<<endl;
0275
0276 int N_hits;
0277 int N_cluster_inner;
0278 int N_cluster_outer;
0279 vector<int>* column_vec = new vector<int>();
0280 vector<double>* avg_chan_vec = new vector<double>();
0281 vector<int>* sum_adc_vec = new vector<int>();
0282 vector<int>* sum_adc_conv_vec = new vector<int>();
0283 vector<int>* size_vec = new vector<int>();
0284 vector<double>* x_vec = new vector<double>();
0285 vector<double>* y_vec = new vector<double>();
0286 vector<double>* z_vec = new vector<double>();
0287 vector<int>* layer_vec = new vector<int>();
0288 vector<double>* phi_vec = new vector<double>();
0289
0290 tree -> SetBranchAddress("nhits",&N_hits);
0291 tree -> SetBranchAddress("nclu_inner",&N_cluster_inner);
0292 tree -> SetBranchAddress("nclu_outer",&N_cluster_outer);
0293
0294 tree -> SetBranchAddress("column", &column_vec);
0295 tree -> SetBranchAddress("avg_chan", &avg_chan_vec);
0296 tree -> SetBranchAddress("sum_adc", &sum_adc_vec);
0297 tree -> SetBranchAddress("sum_adc_conv", &sum_adc_conv_vec);
0298 tree -> SetBranchAddress("size", &size_vec);
0299 tree -> SetBranchAddress("x", &x_vec);
0300 tree -> SetBranchAddress("y", &y_vec);
0301 tree -> SetBranchAddress("z", &z_vec);
0302 tree -> SetBranchAddress("layer", &layer_vec);
0303 tree -> SetBranchAddress("phi", &phi_vec);
0304
0305 TLatex *draw_text = new TLatex();
0306 draw_text -> SetNDC();
0307 draw_text -> SetTextSize(0.02);
0308
0309 vector<clu_info> temp_sPH_inner_nocolumn_vec; temp_sPH_inner_nocolumn_vec.clear();
0310 vector<clu_info> temp_sPH_outer_nocolumn_vec; temp_sPH_outer_nocolumn_vec.clear();
0311 vector<vector<double>> temp_sPH_nocolumn_vec(2);
0312 vector<vector<double>> temp_sPH_nocolumn_rz_vec(2);
0313
0314 TH2F * angle_correlation = new TH2F("","angle_correlation",361,0,361,361,0,361);
0315 angle_correlation -> SetStats(0);
0316 angle_correlation -> GetXaxis() -> SetTitle("Inner Phi (degree)");
0317 angle_correlation -> GetYaxis() -> SetTitle("Outer Phi (degree)");
0318
0319 TH2F * inner_pos_xy = new TH2F("","inner_pos_xy",360,-100,100,360,-100,100);
0320 inner_pos_xy -> SetStats(0);
0321 inner_pos_xy -> GetXaxis() -> SetTitle("X axis");
0322 inner_pos_xy -> GetYaxis() -> SetTitle("Y axis");
0323
0324 TH2F * outer_pos_xy = new TH2F("","outer_pos_xy",360,-150,150,360,-150,150);
0325 outer_pos_xy -> SetStats(0);
0326 outer_pos_xy -> GetXaxis() -> SetTitle("X axis");
0327 outer_pos_xy -> GetYaxis() -> SetTitle("Y axis");
0328
0329 TH2F * inner_outer_pos_xy = new TH2F("","inner_outer_pos_xy",360,-150,150,360,-150,150);
0330 inner_outer_pos_xy -> SetStats(0);
0331 inner_outer_pos_xy -> GetXaxis() -> SetTitle("X axis");
0332 inner_outer_pos_xy -> GetYaxis() -> SetTitle("Y axis");
0333
0334 TH1F * z_pos_diff = new TH1F("","z_pos_diff",360,-150,150);
0335 z_pos_diff -> GetXaxis() -> SetTitle("inner zpos - outer zpos");
0336 z_pos_diff -> GetYaxis() -> SetTitle("Eentry");
0337
0338 TH2F * z_pos_diff_angle_diff = new TH2F("","z_pos_diff_angle_diff",100,-25,25,200,-11,11);
0339 z_pos_diff_angle_diff -> SetStats(0);
0340 z_pos_diff_angle_diff -> GetXaxis() -> SetTitle("inner zpos - outer zpos");
0341 z_pos_diff_angle_diff -> GetYaxis() -> SetTitle("Inner phi - outer phi");
0342
0343 TH1F * Nhits_good = new TH1F("","Nhits_good",360,0,1000);
0344 Nhits_good -> GetXaxis() -> SetTitle("N hits in one event");
0345 Nhits_good -> GetYaxis() -> SetTitle("Eentry");
0346
0347 TH1F * z_pos_inner = new TH1F("","z_pos_inner",200,-150,150);
0348 z_pos_inner -> GetXaxis() -> SetTitle("inner zpos");
0349 z_pos_inner -> GetYaxis() -> SetTitle("Eentry");
0350
0351 TH1F * z_pos_outer = new TH1F("","z_pos_outer",200,-150,150);
0352 z_pos_outer -> GetXaxis() -> SetTitle("outer zpos");
0353 z_pos_outer -> GetYaxis() -> SetTitle("Eentry");
0354
0355 TH2F * z_pos_inner_outer = new TH2F("","z_pos_inner_outer",100,-150,150, 100,-150,150);
0356 z_pos_inner_outer -> SetStats(0);
0357 z_pos_inner_outer -> GetXaxis() -> SetTitle("inner zpos");
0358 z_pos_inner_outer -> GetYaxis() -> SetTitle("outer pos");
0359
0360 TH2F * DCA_point = new TH2F("","DCA_point",100,-10,10,100,-10,10);
0361 DCA_point -> SetStats(0);
0362 DCA_point -> GetXaxis() -> SetTitle("X pos (mm)");
0363 DCA_point -> GetYaxis() -> SetTitle("Y pos (mm)");
0364
0365 TH2F * DCA_distance_inner_phi = new TH2F("","DCA_distance_inner_phi",100,0,360,100,-10,10);
0366 DCA_distance_inner_phi -> SetStats(0);
0367 DCA_distance_inner_phi -> GetXaxis() -> SetTitle("inner phi");
0368 DCA_distance_inner_phi -> GetYaxis() -> SetTitle("DCA (mm)");
0369
0370 TH2F * DCA_distance_outer_phi = new TH2F("","DCA_distance_outer_phi",100,0,360,100,-10,10);
0371 DCA_distance_outer_phi -> SetStats(0);
0372 DCA_distance_outer_phi -> GetXaxis() -> SetTitle("outer phi");
0373 DCA_distance_outer_phi -> GetYaxis() -> SetTitle("DCA (mm)");
0374
0375 TH1F * N_cluster_outer_pass = new TH1F("","N_cluster_outer_pass",100,0,100);
0376 N_cluster_outer_pass -> GetXaxis() -> SetTitle("N_cluster");
0377 N_cluster_outer_pass -> GetYaxis() -> SetTitle("Eentry");
0378
0379 TH1F * N_cluster_inner_pass = new TH1F("","N_cluster_inner_pass",100,0,100);
0380 N_cluster_inner_pass -> GetXaxis() -> SetTitle("N_cluster");
0381 N_cluster_inner_pass -> GetYaxis() -> SetTitle("Eentry");
0382
0383 TH2F * N_cluster_correlation = new TH2F("","N_cluster_correlation",100,0,500,100,0,500);
0384 N_cluster_correlation -> SetStats(0);
0385 N_cluster_correlation -> GetXaxis() -> SetTitle("inner N_cluster");
0386 N_cluster_correlation -> GetYaxis() -> SetTitle("Outer N_cluster");
0387
0388 TH1F * temp_event_zvtx = new TH1F("","Z vertex dist",125,zvtx_hist_l,zvtx_hist_r);
0389 temp_event_zvtx -> GetXaxis() -> SetTitle("Z vertex position (mm)");
0390 temp_event_zvtx -> GetYaxis() -> SetTitle("Entry");
0391 vector<float> temp_event_zvtx_vec; temp_event_zvtx_vec.clear();
0392 vector<float> temp_event_zvtx_info; temp_event_zvtx_info.clear();
0393 TLine * effi_sig_range_line = new TLine();
0394 effi_sig_range_line -> SetLineWidth(3);
0395 effi_sig_range_line -> SetLineColor(TColor::GetColor("#A08144"));
0396 effi_sig_range_line -> SetLineStyle(2);
0397 TF1 * zvtx_fitting = new TF1("","gaus",-500,500);
0398
0399
0400
0401 vector<vector<double>> good_track_xy_vec; good_track_xy_vec.clear();
0402 vector<vector<double>> good_track_rz_vec; good_track_rz_vec.clear();
0403 TLine * track_line = new TLine();
0404 track_line -> SetLineWidth(1);
0405 track_line -> SetLineColor(38);
0406
0407 TLine * coord_line = new TLine();
0408 coord_line -> SetLineWidth(1);
0409 coord_line -> SetLineColor(16);
0410 coord_line -> SetLineStyle(2);
0411
0412
0413 vector<float> avg_event_zvtx_vec; avg_event_zvtx_vec.clear();
0414 TH1F * avg_event_zvtx = new TH1F("","avg_event_zvtx",125,zvtx_hist_l,zvtx_hist_r);
0415 avg_event_zvtx -> GetXaxis() -> SetTitle("Z vertex position (mm)");
0416 avg_event_zvtx -> GetYaxis() -> SetTitle("entry");
0417
0418 double mini_DCAXY;
0419 int mini_inner_i;
0420 int mini_outer_i;
0421
0422
0423 c2 -> Print(Form("%s/folder_%s_HighN/temp_event_display.pdf(",mother_folder_directory.c_str(),file_name.c_str()));
0424
0425 for (int event_i = 0; event_i < N_event; event_i++)
0426 {
0427 tree -> GetEntry(event_i);
0428 unsigned int length = column_vec -> size();
0429
0430 if (N_hits > Nhit_cut) continue;
0431 if (N_cluster_inner == 0 || N_cluster_outer == 0) continue;
0432 if (N_cluster_inner == -1 || N_cluster_outer == -1) continue;
0433 if ((N_cluster_inner + N_cluster_outer) < zvtx_cal_require) continue;
0434 if (N_cluster_inner < 5) continue;
0435 if (N_cluster_outer < 5) continue;
0436
0437
0438
0439
0440 for (int clu_i = 0; clu_i < length; clu_i++)
0441 {
0442 if (size_vec -> at(clu_i) > clu_size_cut) continue;
0443
0444 if (sum_adc_conv_vec -> at(clu_i) < clu_sum_adc_cut) continue;
0445
0446
0447
0448
0449
0450
0451
0452
0453
0454
0455
0456
0457
0458
0459
0460
0461
0462
0463
0464
0465
0466 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) );
0467 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) );
0468
0469 double clu_radius = get_radius(
0470 (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),
0471 (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)
0472 );
0473 temp_sPH_nocolumn_rz_vec[0].push_back(z_vec -> at(clu_i));
0474 temp_sPH_nocolumn_rz_vec[1].push_back( ( phi_vec -> at(clu_i) > 180 ) ? clu_radius * -1 : clu_radius );
0475
0476
0477 if (layer_vec -> at(clu_i) == 0)
0478 temp_sPH_inner_nocolumn_vec.push_back({
0479 column_vec -> at(clu_i),
0480 avg_chan_vec -> at(clu_i),
0481 sum_adc_vec -> at(clu_i),
0482 sum_adc_conv_vec -> at(clu_i),
0483 size_vec -> at(clu_i),
0484 (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),
0485 (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),
0486 z_vec -> at(clu_i),
0487 layer_vec -> at(clu_i),
0488 phi_vec -> at(clu_i)
0489 });
0490
0491 if (layer_vec -> at(clu_i) == 1)
0492 temp_sPH_outer_nocolumn_vec.push_back({
0493 column_vec -> at(clu_i),
0494 avg_chan_vec -> at(clu_i),
0495 sum_adc_vec -> at(clu_i),
0496 sum_adc_conv_vec -> at(clu_i),
0497 size_vec -> at(clu_i),
0498 (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),
0499 (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),
0500 z_vec -> at(clu_i),
0501 layer_vec -> at(clu_i),
0502 phi_vec -> at(clu_i)
0503 });
0504 }
0505
0506 int original_outer_vec_size = temp_sPH_outer_nocolumn_vec.size();
0507 N_cluster_outer_pass -> Fill(temp_sPH_outer_nocolumn_vec.size());
0508 N_cluster_inner_pass -> Fill(temp_sPH_inner_nocolumn_vec.size());
0509 N_cluster_correlation -> Fill( temp_sPH_inner_nocolumn_vec.size(), temp_sPH_outer_nocolumn_vec.size() );
0510
0511 if ((temp_sPH_inner_nocolumn_vec.size() + temp_sPH_outer_nocolumn_vec.size()) > N_clu_cut)
0512 {
0513 temp_event_zvtx_info = {-1000,-1000,-1000};
0514 temp_event_zvtx_vec.clear();
0515 temp_event_zvtx -> Reset("ICESM");
0516 good_track_xy_vec.clear();
0517 good_track_rz_vec.clear();
0518 temp_sPH_nocolumn_rz_vec.clear(); temp_sPH_nocolumn_rz_vec = vector<vector<double>>(2);
0519 temp_sPH_nocolumn_vec.clear(); temp_sPH_nocolumn_vec = vector<vector<double>>(2);
0520 temp_sPH_inner_nocolumn_vec.clear();
0521 temp_sPH_outer_nocolumn_vec.clear();
0522 continue;
0523 }
0524
0525 for ( int inner_i = 0; inner_i < temp_sPH_inner_nocolumn_vec.size(); inner_i++ )
0526 {
0527 int counting = 0;
0528 bool good_tag = false;
0529
0530 for ( int outer_i = 0; outer_i < temp_sPH_outer_nocolumn_vec.size(); outer_i++ )
0531 {
0532 if (fabs(temp_sPH_inner_nocolumn_vec[inner_i].phi - temp_sPH_outer_nocolumn_vec[outer_i].phi) < phi_diff_cut)
0533 {
0534 vector<double> DCA_info_vec = calculateDistanceAndClosestPoint(
0535 temp_sPH_inner_nocolumn_vec[inner_i].x, temp_sPH_inner_nocolumn_vec[inner_i].y,
0536 temp_sPH_outer_nocolumn_vec[outer_i].x, temp_sPH_outer_nocolumn_vec[outer_i].y,
0537 beam_origin.first, beam_origin.second
0538 );
0539
0540 double zvtx = get_z_vertex(temp_sPH_inner_nocolumn_vec[inner_i],temp_sPH_outer_nocolumn_vec[outer_i],DCA_info_vec[1],DCA_info_vec[2]);
0541
0542
0543 if (fabs(zvtx) > 240) continue;
0544
0545 good_tag = true;
0546
0547 if (counting == 0) {
0548 mini_DCAXY = DCA_info_vec[0];
0549 mini_outer_i = outer_i;
0550 }
0551 else
0552 {
0553 if (DCA_info_vec[0] < mini_DCAXY)
0554 {
0555 mini_DCAXY = DCA_info_vec[0];
0556 mini_outer_i = outer_i;
0557 }
0558 }
0559 counting = 1;
0560 }
0561 }
0562
0563 if (good_tag == true && mini_DCAXY < DCA_cut)
0564 {
0565 vector<double> DCA_info_vec = calculateDistanceAndClosestPoint(
0566 temp_sPH_inner_nocolumn_vec[inner_i].x, temp_sPH_inner_nocolumn_vec[inner_i].y,
0567 temp_sPH_outer_nocolumn_vec[mini_outer_i].x, temp_sPH_outer_nocolumn_vec[mini_outer_i].y,
0568 beam_origin.first, beam_origin.second
0569 );
0570
0571 double DCA_sign = calculateAngleBetweenVectors(
0572 temp_sPH_outer_nocolumn_vec[mini_outer_i].x, temp_sPH_outer_nocolumn_vec[mini_outer_i].y,
0573 temp_sPH_inner_nocolumn_vec[inner_i].x, temp_sPH_inner_nocolumn_vec[inner_i].y,
0574 beam_origin.first, beam_origin.second
0575 );
0576
0577 double zvtx = get_z_vertex(temp_sPH_inner_nocolumn_vec[inner_i],temp_sPH_outer_nocolumn_vec[mini_outer_i],DCA_info_vec[1],DCA_info_vec[2]);
0578 temp_event_zvtx -> Fill( zvtx );
0579 if(zvtx_hist_l <= zvtx && zvtx <= zvtx_hist_r){
0580 temp_event_zvtx_vec.push_back( zvtx );
0581 }
0582
0583 if ( event_i == 23515 )
0584 {
0585 if ( temp_sPH_outer_nocolumn_vec[mini_outer_i].phi > 60.6 && temp_sPH_outer_nocolumn_vec[mini_outer_i].phi < 98.9 )
0586 {
0587 good_track_xy_vec.push_back({temp_sPH_outer_nocolumn_vec[mini_outer_i].x,temp_sPH_outer_nocolumn_vec[mini_outer_i].y,DCA_info_vec[1],DCA_info_vec[2]});
0588 good_track_rz_vec.push_back({
0589 temp_sPH_outer_nocolumn_vec[mini_outer_i].z, (temp_sPH_outer_nocolumn_vec[mini_outer_i].phi > 180) ? get_radius(temp_sPH_outer_nocolumn_vec[mini_outer_i].x,temp_sPH_outer_nocolumn_vec[mini_outer_i].y) * -1 : get_radius(temp_sPH_outer_nocolumn_vec[mini_outer_i].x,temp_sPH_outer_nocolumn_vec[mini_outer_i].y),
0590 zvtx, (temp_sPH_outer_nocolumn_vec[mini_outer_i].phi > 180) ? get_radius(DCA_info_vec[1],DCA_info_vec[2]) * -1 : get_radius(DCA_info_vec[1],DCA_info_vec[2])
0591 }
0592 );
0593 }
0594 }
0595 else
0596 {
0597 good_track_xy_vec.push_back({temp_sPH_outer_nocolumn_vec[mini_outer_i].x,temp_sPH_outer_nocolumn_vec[mini_outer_i].y,DCA_info_vec[1],DCA_info_vec[2]});
0598 good_track_rz_vec.push_back({
0599 temp_sPH_outer_nocolumn_vec[mini_outer_i].z, (temp_sPH_outer_nocolumn_vec[mini_outer_i].phi > 180) ? get_radius(temp_sPH_outer_nocolumn_vec[mini_outer_i].x,temp_sPH_outer_nocolumn_vec[mini_outer_i].y) * -1 : get_radius(temp_sPH_outer_nocolumn_vec[mini_outer_i].x,temp_sPH_outer_nocolumn_vec[mini_outer_i].y),
0600 zvtx, (temp_sPH_outer_nocolumn_vec[mini_outer_i].phi > 180) ? get_radius(DCA_info_vec[1],DCA_info_vec[2]) * -1 : get_radius(DCA_info_vec[1],DCA_info_vec[2])
0601 }
0602 );
0603 }
0604
0605
0606
0607 DCA_point -> Fill( DCA_info_vec[1], DCA_info_vec[2] );
0608 angle_correlation -> Fill(temp_sPH_inner_nocolumn_vec[inner_i].phi,temp_sPH_outer_nocolumn_vec[mini_outer_i].phi);
0609 z_pos_diff -> Fill( temp_sPH_inner_nocolumn_vec[inner_i].z - temp_sPH_outer_nocolumn_vec[mini_outer_i].z );
0610 z_pos_diff_angle_diff -> Fill( temp_sPH_inner_nocolumn_vec[inner_i].z - temp_sPH_outer_nocolumn_vec[mini_outer_i].z, temp_sPH_inner_nocolumn_vec[inner_i].phi - temp_sPH_outer_nocolumn_vec[mini_outer_i].phi );
0611 Nhits_good -> Fill(N_hits);
0612 z_pos_inner -> Fill(temp_sPH_inner_nocolumn_vec[inner_i].z);
0613 z_pos_outer -> Fill(temp_sPH_outer_nocolumn_vec[mini_outer_i].z);
0614 z_pos_inner_outer -> Fill(temp_sPH_inner_nocolumn_vec[inner_i].z, temp_sPH_outer_nocolumn_vec[mini_outer_i].z);
0615 DCA_distance_inner_phi -> Fill(temp_sPH_inner_nocolumn_vec[inner_i].phi, DCA_sign );
0616 DCA_distance_outer_phi -> Fill(temp_sPH_outer_nocolumn_vec[mini_outer_i].phi, DCA_sign );
0617
0618
0619 temp_sPH_outer_nocolumn_vec.erase(temp_sPH_outer_nocolumn_vec.begin() + mini_outer_i);
0620
0621 }
0622 }
0623
0624
0625 if (temp_event_zvtx_vec.size() > zvtx_cal_require)
0626 {
0627
0628 temp_event_zvtx_info = sigmaEff_avg(temp_event_zvtx_vec,Integrate_portion);
0629 avg_event_zvtx -> Fill(temp_event_zvtx_info[0]);
0630 avg_event_zvtx_vec.push_back(temp_event_zvtx_info[0]);
0631
0632
0633
0634
0635
0636
0637
0638 }
0639
0640 if ( zvtx_draw_requireL < temp_event_zvtx_vec.size() && temp_event_zvtx_vec.size() < zvtx_draw_requireR)
0641 {
0642 TGraph * temp_event_xy = new TGraph(temp_sPH_nocolumn_vec[0].size(),&temp_sPH_nocolumn_vec[0][0],&temp_sPH_nocolumn_vec[1][0]);
0643 temp_event_xy -> SetTitle("INTT event display X-Y plane");
0644 temp_event_xy -> GetXaxis() -> SetLimits(-150,150);
0645 temp_event_xy -> GetYaxis() -> SetRangeUser(-150,150);
0646 temp_event_xy -> GetXaxis() -> SetTitle("X [mm]");
0647 temp_event_xy -> GetYaxis() -> SetTitle("Y [mm]");
0648 temp_event_xy -> SetMarkerStyle(20);
0649 temp_event_xy -> SetMarkerColor(2);
0650 temp_event_xy -> SetMarkerSize(1);
0651 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]);
0652 temp_event_rz -> SetTitle("INTT event display r-Z plane");
0653 temp_event_rz -> GetXaxis() -> SetLimits(-500,500);
0654 temp_event_rz -> GetYaxis() -> SetRangeUser(-150,150);
0655 temp_event_rz -> GetXaxis() -> SetTitle("Z [mm]");
0656 temp_event_rz -> GetYaxis() -> SetTitle("Radius [mm]");
0657 temp_event_rz -> SetMarkerStyle(20);
0658 temp_event_rz -> SetMarkerColor(2);
0659 temp_event_rz -> SetMarkerSize(1);
0660
0661 pad_xy -> cd();
0662 temp_bkg(pad_xy, conversion_mode, peek, beam_origin);
0663 temp_event_xy -> Draw("p same");
0664 for (int track_i = 0; track_i < good_track_xy_vec.size(); track_i++){
0665 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]);
0666 }
0667 track_line -> Draw("l same");
0668 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(),original_outer_vec_size));
0669
0670 pad_rz -> cd();
0671 temp_event_rz -> Draw("ap");
0672 effi_sig_range_line -> DrawLine(temp_event_zvtx_info[0],-150,temp_event_zvtx_info[0],150);
0673 coord_line -> DrawLine(0,-150,0,150);
0674 coord_line -> DrawLine(-500,0,500,0);
0675 for (int track_i = 0; track_i < good_track_rz_vec.size(); track_i++){
0676 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]);
0677 }
0678 draw_text -> DrawLatex(0.2, 0.85, Form("Negative radius : Clu_{outer} > 180^{0}"));
0679 draw_text -> DrawLatex(0.2, 0.81, Form("EffiSig avg : %.2f mm",temp_event_zvtx_info[0]));
0680
0681 pad_z -> cd();
0682 temp_event_zvtx -> Draw("hist");
0683
0684
0685 effi_sig_range_line -> DrawLine(temp_event_zvtx_info[1],0,temp_event_zvtx_info[1],temp_event_zvtx -> GetMaximum()*1.05);
0686 effi_sig_range_line -> DrawLine(temp_event_zvtx_info[2],0,temp_event_zvtx_info[2],temp_event_zvtx -> GetMaximum()*1.05);
0687
0688 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(),original_outer_vec_size));
0689
0690 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]));
0691 draw_text -> DrawLatex(0.2, 0.79, Form("EffiSig avg : %.2f mm",temp_event_zvtx_info[0]));
0692
0693 c2 -> Print(Form("%s/folder_%s_HighN/temp_event_display.pdf",mother_folder_directory.c_str(),file_name.c_str()));
0694 pad_xy -> Clear();
0695 pad_rz -> Clear();
0696 pad_z -> Clear();
0697
0698 }
0699
0700 for ( int inner_i = 0; inner_i < temp_sPH_inner_nocolumn_vec.size(); inner_i++ )
0701 {
0702 inner_pos_xy -> Fill(temp_sPH_inner_nocolumn_vec[inner_i].x,temp_sPH_inner_nocolumn_vec[inner_i].y);
0703 inner_outer_pos_xy -> Fill(temp_sPH_inner_nocolumn_vec[inner_i].x,temp_sPH_inner_nocolumn_vec[inner_i].y);
0704 }
0705
0706 for ( int outer_i = 0; outer_i < temp_sPH_outer_nocolumn_vec.size(); outer_i++ )
0707 {
0708 outer_pos_xy -> Fill(temp_sPH_outer_nocolumn_vec[outer_i].x,temp_sPH_outer_nocolumn_vec[outer_i].y);
0709 inner_outer_pos_xy -> Fill(temp_sPH_outer_nocolumn_vec[outer_i].x,temp_sPH_outer_nocolumn_vec[outer_i].y);
0710 }
0711
0712 temp_event_zvtx_info = {-1000,-1000,-1000};
0713 temp_event_zvtx_vec.clear();
0714 temp_event_zvtx -> Reset("ICESM");
0715 good_track_xy_vec.clear();
0716 good_track_rz_vec.clear();
0717 temp_sPH_nocolumn_rz_vec.clear(); temp_sPH_nocolumn_rz_vec = vector<vector<double>>(2);
0718 temp_sPH_nocolumn_vec.clear(); temp_sPH_nocolumn_vec = vector<vector<double>>(2);
0719 temp_sPH_inner_nocolumn_vec.clear();
0720 temp_sPH_outer_nocolumn_vec.clear();
0721 }
0722
0723 c2 -> Print(Form("%s/folder_%s_HighN/temp_event_display.pdf)",mother_folder_directory.c_str(),file_name.c_str()));
0724 c2 -> Clear();
0725 c1 -> Clear();
0726
0727
0728 c1 -> cd();
0729 vector<float> avg_event_zvtx_info = sigmaEff_avg(avg_event_zvtx_vec,Integrate_portion);
0730 avg_event_zvtx -> Draw("hist");
0731 effi_sig_range_line -> DrawLine(avg_event_zvtx_info[1],0,avg_event_zvtx_info[1],avg_event_zvtx -> GetMaximum()*1.05);
0732 effi_sig_range_line -> DrawLine(avg_event_zvtx_info[2],0,avg_event_zvtx_info[2],avg_event_zvtx -> GetMaximum()*1.05);
0733 draw_text -> DrawLatex(0.15, 0.84, Form("EffiSig min : %.2f mm, max : %.2f mm",avg_event_zvtx_info[1],avg_event_zvtx_info[2]));
0734 draw_text -> DrawLatex(0.15, 0.81, Form("EffiSig avg : %.2f mm",avg_event_zvtx_info[0]));
0735 c1 -> Print(Form("%s/folder_%s_HighN/avg_event_zvtx.pdf",mother_folder_directory.c_str(),file_name.c_str()));
0736 c1 -> Clear();
0737
0738 N_cluster_inner_pass -> Draw("hist");
0739 c1 -> Print(Form("%s/folder_%s_HighN/N_cluster_inner_pass.pdf",mother_folder_directory.c_str(),file_name.c_str()));
0740 c1 -> Clear();
0741
0742 N_cluster_outer_pass -> Draw("hist");
0743 c1 -> Print(Form("%s/folder_%s_HighN/N_cluster_outer_pass.pdf",mother_folder_directory.c_str(),file_name.c_str()));
0744 c1 -> Clear();
0745
0746 N_cluster_correlation -> Draw("colz0");
0747 c1 -> Print(Form("%s/folder_%s_HighN/N_cluster_correlation.pdf",mother_folder_directory.c_str(),file_name.c_str()));
0748 c1 -> Clear();
0749
0750 DCA_point -> Draw("colz0");
0751 c1 -> Print(Form("%s/folder_%s_HighN/DCA_point_X%.1fY%.1f_.pdf",mother_folder_directory.c_str(),file_name.c_str(),beam_origin.first,beam_origin.second));
0752 c1 -> Clear();
0753
0754 DCA_distance_inner_phi -> Draw("colz0");
0755 c1 -> Print(Form("%s/folder_%s_HighN/DCA_distance_inner_phi_X%.1fY%.1f_.pdf",mother_folder_directory.c_str(),file_name.c_str(),beam_origin.first,beam_origin.second));
0756 c1 -> Clear();
0757
0758 DCA_distance_outer_phi -> Draw("colz0");
0759 c1 -> Print(Form("%s/folder_%s_HighN/DCA_distance_outer_phi_X%.1fY%.1f_.pdf",mother_folder_directory.c_str(),file_name.c_str(),beam_origin.first,beam_origin.second));
0760 c1 -> Clear();
0761
0762 z_pos_inner_outer -> Draw("colz0");
0763 c1 -> Print(Form("%s/folder_%s_HighN/z_pos_inner_outer.pdf",mother_folder_directory.c_str(),file_name.c_str()));
0764 c1 -> Clear();
0765
0766 z_pos_inner -> Draw("hist");
0767 c1 -> Print(Form("%s/folder_%s_HighN/z_pos_inner.pdf",mother_folder_directory.c_str(),file_name.c_str()));
0768 c1 -> Clear();
0769
0770 z_pos_outer -> Draw("hist");
0771 c1 -> Print(Form("%s/folder_%s_HighN/z_pos_outer.pdf",mother_folder_directory.c_str(),file_name.c_str()));
0772 c1 -> Clear();
0773
0774 Nhits_good -> Draw("hist");
0775 c1 -> Print(Form("%s/folder_%s_HighN/Nhits_good.pdf",mother_folder_directory.c_str(),file_name.c_str()));
0776 c1 -> Clear();
0777
0778 angle_correlation -> Draw("colz0");
0779 c1 -> Print(Form("%s/folder_%s_HighN/angle_correlation.pdf",mother_folder_directory.c_str(),file_name.c_str()));
0780 c1 -> Clear();
0781
0782 z_pos_diff -> Draw("hist");
0783 c1 -> Print(Form("%s/folder_%s_HighN/z_pos_diff.pdf",mother_folder_directory.c_str(),file_name.c_str()));
0784 c1 -> Clear();
0785
0786 z_pos_diff_angle_diff -> Draw("colz0");
0787 c1 -> Print(Form("%s/folder_%s_HighN/z_pos_diff_angle_diff.pdf",mother_folder_directory.c_str(),file_name.c_str()));
0788 c1 -> Clear();
0789
0790 inner_pos_xy -> Draw("colz0");
0791 c1 -> Print(Form("%s/folder_%s_HighN/inner_pos_xy.pdf",mother_folder_directory.c_str(),file_name.c_str()));
0792 c1 -> Clear();
0793
0794 outer_pos_xy -> Draw("colz0");
0795 c1 -> Print(Form("%s/folder_%s_HighN/outer_pos_xy.pdf",mother_folder_directory.c_str(),file_name.c_str()));
0796 c1 -> Clear();
0797
0798 inner_outer_pos_xy -> Draw("colz0");
0799 c1 -> Print(Form("%s/folder_%s_HighN/inner_outer_pos_xy.pdf",mother_folder_directory.c_str(),file_name.c_str()));
0800 c1 -> Clear();
0801
0802
0803 }