BmnRoot 26.10.0-18-g4e3414f9
Software framework of the BM@N experiment
Loading...
Searching...
No Matches
TestSiBTConfig_Visual.C
Go to the documentation of this file.
1// Macro 06.12.2021
2/*
3 * Визуальная и параметрическая проверка SiBT-конфигураций, включающая:
4 * - проверка расположения точки на станции, модуле, слое
5 * - размеры модуля, слоя и его визуальное представление (фронтальный и верхний виды)
6 * - расположение мертвых зон, наклона стрипов, их границы нумерации и направление
7 *
8 * Есть возможность интерактивного добаление точек на фронтальной плоскости при
9 * помощи SHIFT+Mouse_click автоматическим расчетом хитов-пересечений
10 *
11 * Обнуление информации на плоскости и станции
12 */
13
14#include "TCanvas.h"
15#include "TDOMParser.h"
16#include "TF1.h"
17#include "TGaxis.h"
18#include "TGraph.h"
19#include "TH1F.h"
20#include "TH2F.h"
21#include "THStack.h"
22#include "TLegend.h"
23#include "TMath.h"
24#include "TPaveLabel.h"
25#include "TRandom.h"
26#include "TSpectrum.h"
27#include "TWbox.h"
28
29#include <fstream>
30#include <vector>
31
32using namespace TMath;
33
35
37
40
41vector<TMarker*> g_points_marker;
42
43// Возможность добавления точек мышкой
45
46// Рисовать добавленные мышкой точки на канвах отдельных слоев
48
49// Выводить информацию в поток о всех хитах на станции при добавлении новой точки
51
52void DrawCreatedStationFront(BmnSiBTStation* station, vector<TLorentzVector>& points);
53void DrawCreatedStationTop(BmnSiBTStation* station, vector<TLorentzVector>& points);
54
56{
57
58 // Enable transparency OpenGL via gStyle
59 gStyle->SetCanvasPreferGL(1);
60
61 BmnSiBTStationSet* StationSet = new BmnSiBTStationSet("../../parameters/SiBT/XMLConfigs/SiBTRun8.xml");
62
63 // Определение принадлежности по конкретной точке ---------------------------
64 if (1) {
65
66 // Тестовая точка (без обработкой станцией - просто определение станции по ее положению)
67
68 Double_t x = -0.0; // don't forget to invert
69 Double_t y = 0.0;
70 Double_t z = -422.34;
71
73
74 vector<TLorentzVector> test_points;
75 TLorentzVector test_point;
76 test_point.SetXYZT(x, y, z, 0);
77 test_points.push_back(test_point);
78
79 Int_t station_num = -1;
80 Int_t module_num = -1;
81
82 station_num = StationSet->GetPointStationOwnership(z);
83 // station_num = StationSet->GetPointStationOwnership(x, y, z);
84
85 if (station_num != -1) {
86 BmnSiBTStation* station = StationSet->GetStation(station_num);
87
88 DrawCreatedStationFront(station, test_points);
89 DrawCreatedStationTop(station, test_points);
90
91 module_num = station->GetPointModuleOwnership(x, y, z);
92 }
93
94 if (station_num != -1 && module_num != -1) {
95 cout << " Point (x:y:z) = ( " << x << " : " << y << " : " << z
96 << " ) can be registered by the current configuration:\n";
97 cout << " station = " << station_num << "\n";
98 cout << " module = " << module_num << "\n";
99 } else {
100 cout << " Point (x:y:z) = ( " << x << " : " << y << " : " << z << " ) is incorrect:\n";
101 cout << " station = " << station_num << "\n";
102 cout << " module = " << module_num << "\n";
103 }
104 }
105 //--------------------------------------------------------------------------
106
107 // delete StationSet;
108
109 cout << "It's the end" << "\n";
110 // gApplication->Terminate();
111}
112
113void DrawCreatedStationFront(BmnSiBTStation* station, vector<TLorentzVector>& points)
114{
115
116 TString description_text = "";
117 description_text += "FRONT: station ";
118 description_text += station->GetStationNumber();
119 description_text += ", xpos = ";
120 description_text += station->GetXPosition();
121 description_text += ", ypos = ";
122 description_text += station->GetYPosition();
123 description_text += ", zpos = ";
124 description_text += station->GetZPosition();
125 TCanvas* station_front_canv = new TCanvas("station_front_canv", description_text, 10, 10, 1000, 1000);
126 station_front_canv->SetGrid();
127
128 Int_t StationNumber = station->GetStationNumber();
129 Double_t XSize = station->GetXSize();
130 Double_t YSize = station->GetYSize();
131 Double_t ZSize = station->GetZSize();
132 Double_t XMinStation = station->GetXMinStation();
133 Double_t XMaxStation = station->GetXMaxStation();
134 Double_t YMinStation = station->GetYMinStation();
135 Double_t YMaxStation = station->GetYMaxStation();
136 Double_t ZMinStation = station->GetZMinStation();
137 Double_t ZMaxStation = station->GetZMaxStation();
138 Double_t XPosition = station->GetXPosition();
139 Double_t YPosition = station->GetYPosition();
140 Double_t ZPosition = station->GetZPosition();
141 Int_t NModules = station->GetNModules();
142
143 Double_t* XShiftsOfModules = new Double_t[NModules];
144 Double_t* YShiftsOfModules = new Double_t[NModules];
145 Double_t* ZShiftsOfModules = new Double_t[NModules];
146 Double_t maxXShift = 0.0;
147 Double_t maxYShift = 0.0;
148 Double_t maxZShift = 0.0;
149 for (Int_t iModule = 0; iModule < NModules; ++iModule) {
150 XShiftsOfModules[iModule] = station->GetXShiftOfModule(iModule);
151 YShiftsOfModules[iModule] = station->GetYShiftOfModule(iModule);
152 ZShiftsOfModules[iModule] = station->GetZShiftOfModule(iModule);
153
154 if (fabs(XShiftsOfModules[iModule]) > maxXShift)
155 maxXShift = fabs(XShiftsOfModules[iModule]);
156 if (fabs(YShiftsOfModules[iModule]) > maxYShift)
157 maxYShift = fabs(YShiftsOfModules[iModule]);
158 if (fabs(ZShiftsOfModules[iModule]) > maxZShift)
159 maxZShift = fabs(ZShiftsOfModules[iModule]);
160 }
161
162 if (1) {
163 cout << "StationNumber = " << StationNumber << "\n";
164 cout << " XSize = " << XSize << "\n";
165 cout << " YSize = " << YSize << "\n";
166 cout << " ZSize = " << ZSize << "\n";
167 cout << "\n";
168 cout << " XMinStation = " << XMinStation << "\n";
169 cout << " XMaxStation = " << XMaxStation << "\n";
170 cout << " YMinStation = " << YMinStation << "\n";
171 cout << " YMaxStation = " << YMaxStation << "\n";
172 cout << " ZMinStation = " << ZMinStation << "\n";
173 cout << " ZMaxStation = " << ZMaxStation << "\n";
174 cout << "\n";
175 cout << " XPosition = " << XPosition << "\n";
176 cout << " YPosition = " << YPosition << "\n";
177 cout << " ZPosition = " << ZPosition << "\n";
178 cout << "\n";
179 cout << " NModules = " << NModules << "\n";
180 for (Int_t iModule = 0; iModule < NModules; ++iModule) {
181 cout << " XShiftsOfModules[" << iModule << "] = " << XShiftsOfModules[iModule] << "\n";
182 cout << " YShiftsOfModules[" << iModule << "] = " << YShiftsOfModules[iModule] << "\n";
183 cout << " ZShiftsOfModules[" << iModule << "] = " << ZShiftsOfModules[iModule] << "\n";
184
185 BmnSiBTModule* module = station->GetModule(iModule);
186
187 Double_t XModuleSize = module->GetXSize();
188 Double_t YModuleSize = module->GetYSize();
189 Double_t XMinModule = module->GetXMinModule();
190 Double_t XMaxModule = module->GetXMaxModule();
191 Double_t YMinModule = module->GetYMinModule();
192 Double_t YMaxModule = module->GetYMaxModule();
193
194 cout << " XModuleSize = " << XModuleSize << "\n";
195 cout << " YModuleSize = " << YModuleSize << "\n";
196 cout << " XMinModule = " << XMinModule << "\n";
197 cout << " XMaxModule = " << XMaxModule << "\n";
198 cout << " YMinModule = " << YMinModule << "\n";
199 cout << " YMaxModule = " << YMaxModule << "\n";
200 cout << "\n";
201
202 Int_t NLayers = module->GetNStripLayers();
203 for (Int_t iLayer = 0; iLayer < NLayers; ++iLayer) {
204 BmnSiBTLayer layer = module->GetStripLayer(iLayer);
205
206 Double_t stripAngleDeg = layer.GetAngleDeg();
207 Double_t pitch = layer.GetPitch();
208 Double_t XLayerSize = layer.GetXSize();
209 Double_t YLayerSize = layer.GetYSize();
210 Double_t XMinLayer = layer.GetXMinLayer();
211 Double_t XMaxLayer = layer.GetXMaxLayer();
212 Double_t YMinLayer = layer.GetYMinLayer();
213 Double_t YMaxLayer = layer.GetYMaxLayer();
214 StripLayerType layerType = layer.GetType();
215 Double_t xLeftBorderLayer = layer.GetXLeftStripBorderPoint();
216 Double_t xRightBorderLayer = layer.GetXRightStripBorderPoint();
217 Double_t yLeftBorderLayer = layer.GetYLeftStripBorderPoint();
218 Double_t yRightBorderLayer = layer.GetYRightStripBorderPoint();
219 StripNumberingDirection stripDirection = layer.GetStripNumberingOrder();
220
221 cout << " Layer[" << iLayer << "]:\n";
222 cout << " stripAngleDeg = " << stripAngleDeg << "\n";
223 cout << " pitch = " << pitch << "\n";
224 cout << "\n";
225 cout << " XLayerSize = " << XLayerSize << "\n";
226 cout << " YLayerSize = " << YLayerSize << "\n";
227 cout << "\n";
228 cout << " XMinLayer = " << XMinLayer << "\n";
229 cout << " XMaxLayer = " << XMaxLayer << "\n";
230 cout << " YMinLayer = " << YMinLayer << "\n";
231 cout << " YMaxLayer = " << YMaxLayer << "\n";
232 cout << "\n";
233 if (layerType == StripLayerType::LowerStripLayer) {
234 cout << " layerType = " << "lower" << "\n";
235 }
236 if (layerType == StripLayerType::UpperStripLayer) {
237 cout << " layerType = " << "upper" << "\n";
238 }
239 cout << "\n";
240 cout << " xLeftBorderLayer = " << xLeftBorderLayer << "\n";
241 cout << " xRightBorderLayer = " << xRightBorderLayer << "\n";
242 cout << " yLeftBorderLayer = " << yLeftBorderLayer << "\n";
243 cout << " yRightBorderLayer = " << yRightBorderLayer << "\n";
244 if (stripDirection == StripNumberingDirection::LeftToRight) {
245 cout << " stripDirection = " << "LeftToRight" << "\n";
246 }
247 if (stripDirection == StripNumberingDirection::RightToLeft) {
248 cout << " stripDirection = " << "RightToLeft" << "\n";
249 }
250 cout << "\n";
251
252 vector<DeadZoneOfStripLayer> deadZones = layer.GetDeadZones();
253
254 for (Int_t idead = 0; idead < deadZones.size(); ++idead) {
255 cout << " DeadZone[" << idead << "]:\n";
256
257 Int_t NDeadPoints = deadZones[idead].GetNPoints();
258
259 for (Int_t ip = 0; ip < NDeadPoints; ++ip) {
260 cout << " (x,y) = ( " << deadZones[idead].GetXPoint(ip) << ", "
261 << deadZones[idead].GetYPoint(ip) << " )\n";
262 }
263 cout << "\n";
264 }
265 }
266 }
267 cout << "-----------------------------------------------------------\n";
268 }
269
270 BmnSiBTModule** Modules = new BmnSiBTModule*[NModules];
271 for (Int_t imod = 0; imod < NModules; imod++) {
272 Modules[imod] = station->GetModule(imod);
273 }
274
275 /*
276 Double_t range_size = 0.0;
277 if( XSize > YSize ) range_size = XSize;
278 else range_size = YSize;
279 range_size *= 0.5 + 0.05;
280 if( fabs(XPosition)+maxXShift > fabs(YPosition)+maxYShift ) range_size+= fabs(XPosition)+maxXShift;
281 else range_size+= fabs(YPosition)+maxYShift;
282 */
283
284 Double_t xmin = XMinStation - XSize * 0.3;
285 Double_t xmax = XMaxStation + XSize * 0.3;
286 Double_t ymin = YMinStation - YSize * 0.3;
287 Double_t ymax = YMaxStation + YSize * 0.3;
288
289 // TH2F *station_front_2dhist = new TH2F("station_front_2dhist", description_text, 100, -range_size, range_size,
290 // 100, -range_size, range_size);
291 TH2F* station_front_2dhist = new TH2F("station_front_2dhist", description_text, 100, xmin, xmax, 100, ymin, ymax);
292 station_front_2dhist->GetXaxis()->SetTitle("+x (classical)");
293 station_front_2dhist->GetYaxis()->SetTitle("+y");
294 station_front_canv->cd();
295 station_front_2dhist->Draw();
296
297 TBox** modules_box = new TBox*[NModules];
298
299 for (Int_t im = 0; im < NModules; im++) {
300
301 // module borders -------------------------------------------------------
302 Double_t x_min_module = Modules[im]->GetXMinModule();
303 Double_t x_max_module = Modules[im]->GetXMaxModule();
304 Double_t y_min_module = Modules[im]->GetYMinModule();
305 Double_t y_max_module = Modules[im]->GetYMaxModule();
306
307 modules_box[im] = new TBox(x_min_module, y_min_module, x_max_module, y_max_module);
308
309 modules_box[im]->SetLineColor(TColor::GetColor("#000000"));
310 modules_box[im]->SetLineStyle(2);
311 modules_box[im]->SetLineWidth(1);
312 modules_box[im]->SetFillColor(TColor::GetColor("#cccccc"));
313 modules_box[im]->SetFillStyle(0); // 0 - not filled, 1001 - solid
314
315 station_front_canv->cd();
316 // modules_box[im]->Draw("f");
317 modules_box[im]->Draw("l");
318 //----------------------------------------------------------------------
319
320 // layers ---------------------------------------------------------------
321 Int_t NLayers = Modules[im]->GetNStripLayers();
322
323 for (Int_t ilayer = 0; ilayer < NLayers; ++ilayer) {
324
325 // Separate canvas for current layer
326 description_text = "";
327 description_text += "FRONT: station ";
328 description_text += station->GetStationNumber();
329 description_text += ", module = ";
330 description_text += im;
331 description_text += ", layer = ";
332 description_text += ilayer;
333 TCanvas* layer_canv =
334 new TCanvas(TString(TString("layer_canv_") += ilayer) += im, description_text, 10, 10, 1000, 1200);
335 layer_canv->SetGrid();
336
337 // TH2F *layer_2dhist = new TH2F(TString(TString("layer_2dhist_")+=ilayer)+=im, description_text, 100,
338 // -range_size, range_size, 100, -range_size, range_size);
339 TH2F* layer_2dhist = new TH2F(TString(TString("layer_2dhist_") += ilayer) += im, description_text, 100,
340 xmin, xmax, 100, ymin, ymax);
341 layer_2dhist->GetXaxis()->SetTitle("+x (classical)");
342 layer_2dhist->GetYaxis()->SetTitle("+y");
343 layer_canv->cd();
344 layer_2dhist->Draw();
345 //------------------------------------------------------------------
346
347 BmnSiBTLayer layer = Modules[im]->GetStripLayer(ilayer);
348
349 Double_t x_min_layer = layer.GetXMinLayer();
350 Double_t x_max_layer = layer.GetXMaxLayer();
351 Double_t y_min_layer = layer.GetYMinLayer();
352 Double_t y_max_layer = layer.GetYMaxLayer();
353
354 TBox* layer_box = new TBox(x_min_layer, y_min_layer, x_max_layer, y_max_layer);
355
356 layer_box->SetLineColorAlpha(TColor::GetColor("#009900"), 0.3);
357 layer_box->SetLineStyle(1);
358 layer_box->SetLineWidth(1);
359 // layer_box->SetFillColor(TColor::GetColor("#cccccc"));
360 layer_box->SetFillColorAlpha(TColor::GetColor("#cccccc"), 0.3);
361 layer_box->SetFillStyle(1001); // 0 - not filled, 1001 - solid
362
363 station_front_canv->cd();
364 // layer_box->Draw("f");
365 layer_box->Draw("fl");
366
367 layer_canv->cd();
368 layer_box->Draw("fl");
369
370 // layer dead zones--------------------------------------------------
371 vector<DeadZoneOfStripLayer> DeadZones = layer.GetDeadZones();
372 Int_t NDeadZones = DeadZones.size();
373
374 TPolyLine* dead_zones_polylines = new TPolyLine[NDeadZones];
375
376 for (Int_t izone = 0; izone < NDeadZones; ++izone) {
377 DeadZoneOfStripLayer dead_zone = DeadZones[izone];
378
379 for (Int_t ipoint = 0; ipoint < dead_zone.GetNPoints(); ++ipoint) {
380 Double_t x = dead_zone.GetXPoint(ipoint);
381 Double_t y = dead_zone.GetYPoint(ipoint);
382 dead_zones_polylines[izone].SetNextPoint(x, y);
383 if (ipoint == dead_zone.GetNPoints() - 1) {
384 dead_zones_polylines[izone].SetNextPoint(dead_zone.GetXPoint(0), dead_zone.GetYPoint(0));
385 }
386 }
387
388 dead_zones_polylines[izone].SetFillStyle(1001);
389 dead_zones_polylines[izone].SetLineColorAlpha(TColor::GetColor("#ff0000"), 0.3);
390 dead_zones_polylines[izone].SetFillColorAlpha(TColor::GetColor("#ffc7c7"), 0.3);
391 dead_zones_polylines[izone].SetLineWidth(1);
392
393 station_front_canv->cd();
394 dead_zones_polylines[izone].Draw("f");
395 dead_zones_polylines[izone].Draw("");
396
397 layer_canv->cd();
398 dead_zones_polylines[izone].Draw("f");
399 dead_zones_polylines[izone].Draw("");
400 }
401 //------------------------------------------------------------------
402
403 // strip borders ----------------------------------------------------
404 Double_t x_left_border = layer.GetXLeftStripBorderPoint();
405 Double_t y_left_border = layer.GetYLeftStripBorderPoint();
406 Double_t x_right_border = layer.GetXRightStripBorderPoint();
407 Double_t y_right_border = layer.GetYRightStripBorderPoint();
408
409 StripNumberingDirection strip_direction = layer.GetStripNumberingOrder();
410
411 Double_t strip_angle_deg = layer.GetAngleDeg();
412 Double_t x_shift_up_left = Tan(strip_angle_deg * DegToRad()) * (y_max_layer - y_left_border);
413 Double_t x_shift_down_left = Tan(strip_angle_deg * DegToRad()) * (y_left_border - y_min_layer);
414 Double_t x_shift_up_right = Tan(strip_angle_deg * DegToRad()) * (y_max_layer - y_right_border);
415 Double_t x_shift_down_right = Tan(strip_angle_deg * DegToRad()) * (y_right_border - y_min_layer);
416
417 TLine* left_strip_line = new TLine();
418 left_strip_line->SetX1(x_left_border - x_shift_down_left);
419 left_strip_line->SetX2(x_left_border + x_shift_up_left);
420 left_strip_line->SetY1(y_min_layer);
421 left_strip_line->SetY2(y_max_layer);
422 left_strip_line->SetLineColor(TColor::GetColor("#033cc0"));
423 left_strip_line->Draw();
424
425 TLine* right_strip_line = new TLine();
426 right_strip_line->SetX1(x_right_border - x_shift_down_right);
427 right_strip_line->SetX2(x_right_border + x_shift_up_right);
428 right_strip_line->SetY1(y_min_layer);
429 right_strip_line->SetY2(y_max_layer);
430 right_strip_line->SetLineColor(TColor::GetColor("#033cc0"));
431 right_strip_line->Draw();
432
433 TMarker* left_border_marker = new TMarker(x_left_border, y_left_border, 20);
434 left_border_marker->SetMarkerSize(1.2);
435 left_border_marker->SetMarkerColor(TColor::GetColor("#ff0000"));
436 left_border_marker->Draw();
437
438 TMarker* right_border_marker = new TMarker(x_right_border, y_right_border, 20);
439 right_border_marker->SetMarkerSize(1.2);
440 right_border_marker->SetMarkerColor(TColor::GetColor("#ff0000"));
441 right_border_marker->Draw();
442
443 TArrow* strip_direction_arrow = new TArrow();
444 if (strip_direction == LeftToRight) {
445 strip_direction_arrow->SetX1(x_left_border);
446 strip_direction_arrow->SetX2(x_right_border);
447 } else {
448 strip_direction_arrow->SetX1(x_right_border);
449 strip_direction_arrow->SetX2(x_left_border);
450 }
451 strip_direction_arrow->SetY1(y_max_layer);
452 strip_direction_arrow->SetY2(y_max_layer);
453 strip_direction_arrow->SetArrowSize(0.02);
454 strip_direction_arrow->SetLineColor(TColor::GetColor("#f4a900"));
455 strip_direction_arrow->SetFillColor(TColor::GetColor("#f4a900"));
456 strip_direction_arrow->SetLineWidth(1);
457 strip_direction_arrow->Draw("|>");
458 //------------------------------------------------------------------
459
460 // center line of a layer------------------------------------------------
461 Double_t x_center_layer = (layer_box->GetX1() + layer_box->GetX2()) * 0.5;
462 Double_t y_center_layer = (layer_box->GetY1() + layer_box->GetY2()) * 0.5;
463 TLine* x_center_layer_line =
464 new TLine(x_center_layer, layer_box->GetY1(), x_center_layer, layer_box->GetY2());
465 TLine* y_center_layer_line =
466 new TLine(layer_box->GetX1(), y_center_layer, layer_box->GetX2(), y_center_layer);
467 x_center_layer_line->SetLineColor(TColor::GetColor("#00ccff"));
468 y_center_layer_line->SetLineColor(TColor::GetColor("#00ccff"));
469
470 layer_canv->cd();
471 x_center_layer_line->Draw();
472 y_center_layer_line->Draw();
473 //------------------------------------------------------------------
474
475 // strip angle slope of a layer -------------------------------------
476 strip_angle_deg = layer.GetAngleDeg();
477 Double_t strip_angle_rad = strip_angle_deg * TMath::Pi() / 180;
478 Double_t vert_leg = fabs(y_center_layer - layer_box->GetY2());
479 Double_t hor_leg = vert_leg * Tan(strip_angle_rad);
480 Double_t x_edge_layer = x_center_layer + hor_leg;
481 Double_t y_edge_layer = layer_box->GetY2();
482 TLine* strip_slope_layer_line = new TLine(x_center_layer, y_center_layer, x_edge_layer, y_edge_layer);
483 strip_slope_layer_line->SetLineColor(TColor::GetColor("#00ff33"));
484
485 layer_canv->cd();
486 strip_slope_layer_line->Draw();
487 //------------------------------------------------------------------
488
489 // Нарисовать точку на слое, по которой мы определяем в какой станции находимся
490 // draw a point in the layer ----------------------------------------
491 TMarker* mark_point_front = new TMarker[points.size()];
492 for (int ip = 0; ip < points.size(); ip++) {
493 mark_point_front[ip].SetX(points.at(ip).X());
494 mark_point_front[ip].SetY(points.at(ip).Y());
495 mark_point_front[ip].SetMarkerStyle(5);
496 mark_point_front[ip].SetMarkerSize(1.0);
497 mark_point_front[ip].SetMarkerColor(TColor::GetColor("#0000ff"));
498
499 layer_canv->cd();
500 cout << "mark_point_front[ip].GetX() = " << mark_point_front[ip].GetX() << "\n";
501 mark_point_front[ip].Draw();
502 }
503 //------------------------------------------------------------------
504 }
505 //----------------------------------------------------------------------
506 }
507
508 // Нарисовать точку на станции, по которой мы определяем в какой станции находимся и какую рисовать
509 // draw a point in the station ----------------------------------------------
510 TMarker* mark_point_front = new TMarker[points.size()];
511 for (int ip = 0; ip < points.size(); ip++) {
512 mark_point_front[ip].SetX(points.at(ip).X());
513 mark_point_front[ip].SetY(points.at(ip).Y());
514 mark_point_front[ip].SetMarkerStyle(5);
515 mark_point_front[ip].SetMarkerSize(1.0);
516 mark_point_front[ip].SetMarkerColor(TColor::GetColor("#0000ff"));
517
518 station_front_canv->cd();
519 mark_point_front[ip].Draw();
520 }
521 //--------------------------------------------------------------------------
522
523 g_current_station = station;
524
526 station_front_canv->AddExec("ex", "RecognizeModuleNumFromPointAndDrawIt(station_front_canv)");
527 // station_front_canv->AddExec("ex", "RecognizeModuleNumFromPointAndDrawIt()");
528 }
529}
530
531//------------------------------------------------------------------------------
532
534{
535 // void RecognizeModuleNumFromPointAndDrawIt() {
536
537 Int_t event = gPad->GetEvent();
538 Int_t eventX = gPad->GetEventX();
539 Int_t eventY = gPad->GetEventY();
540 TObject* object = gPad->GetSelected();
541
542 // if(event == kButtonDown) {
543 if (event == kButton1Shift) { // mouse click with shift button
544 Double_t x = gPad->AbsPixeltoX(eventX);
545 Double_t y = gPad->AbsPixeltoY(eventY);
546
547 Int_t module_num = g_current_station->GetPointModuleOwnership(x, y, g_z_current_point);
548
549 cout << "\n-------------------------------------------------------------\n";
550
551 if (module_num != -1) {
552
553 cout << " point ( " << x << " : " << y << " ) is in:\n";
554 cout << " module = " << module_num << "\n";
555
556 BmnSiBTModule* module = g_current_station->GetModule(module_num);
557 Int_t NLayers = module->GetNStripLayers();
558
559 for (Int_t ilayer = 0; ilayer < NLayers; ++ilayer) {
560
561 BmnSiBTLayer layer = module->GetStripLayer(ilayer);
562
563 if (layer.IsPointInsideStripLayer(x, y)) {
564 cout << " layer[" << ilayer << "] : ";
565 if (layer.GetType() == LowerStripLayer)
566 cout << "LowerStripLayer";
567 if (layer.GetType() == UpperStripLayer)
568 cout << "UpperStripLayer";
569 cout << ", angle = " << layer.GetAngleDeg();
570 cout << ", pitch = " << layer.GetPitch();
571 cout << ", nstrips = " << layer.GetNStrips();
572 cout << ", sizes = (" << layer.GetXSize() << " x " << layer.GetYSize() << ")";
573 cout << ", strip_pos = " << layer.ConvertPointToStripPosition(x, y);
574 cout << "\n";
575 }
576 }
577
578 } else {
579 cout << " point ( " << x << " : " << y << " ) is out any modules!!!\n";
580 }
581
582 TMarker* point_marker = new TMarker(x, y, 2);
583 point_marker->SetMarkerSize(1.0);
584 point_marker->SetMarkerColor(TColor::GetColor("#ff0000"));
585
586 g_points_marker.push_back(point_marker);
587
588 station_front_canv->cd();
589 g_points_marker[g_points_marker.size() - 1]->Draw();
590
591 // other canvas drawing
593 TSeqCollection* collect = gROOT->GetListOfCanvases();
594 Int_t nentries = collect->GetEntries();
595 for (Int_t ie = 0; ie < nentries; ++ie) {
596 TObject* obj = collect->At(ie);
597 if (TString(obj->GetName()).Contains("layer_canv_")) {
598 ((TCanvas*)obj)->cd();
599 point_marker->Draw();
600 ((TCanvas*)obj)->Update();
601 }
602 }
603 }
604
605 if (module_num != -1) {
606
607 g_current_station->AddPointToStation(x, y, g_z_current_point, 0.0, 0.0, 1.0, 1.0, 0);
608 g_current_station->ProcessPointsInStation();
609
610 if (g_hits_marker) {
611 delete[] g_hits_marker;
612
613 g_hits_marker = 0;
614 g_n_hits_marker = 0;
615 }
616
617 Int_t NModules = g_current_station->GetNModules();
618
620 cout << "\n Number of intersection points:\n";
621
622 for (Int_t im = 0; im < NModules; ++im) {
623 BmnSiBTModule* module = g_current_station->GetModule(im);
624 Int_t NHits = module->GetNIntersectionPoints();
625 g_n_hits_marker += NHits;
626
628 cout << " in module[" << im << "] : " << NHits << "\n";
629 }
630
632 cout << " in all modules : " << g_n_hits_marker << "\n\n";
633
634 if (g_n_hits_marker == 0)
635 return;
636
638 Int_t hit_marker_cnt = 0;
639
641 cout << " Intersection points:\n";
642
643 for (Int_t im = 0; im < NModules; ++im) {
644
646 cout << " module[" << im << "]:\n";
647
648 BmnSiBTModule* module = g_current_station->GetModule(im);
649
650 Int_t NHits = module->GetNIntersectionPoints();
651
652 for (Int_t ihit = 0; ihit < NHits; ++ihit) {
653
654 Double_t x_hit = module->GetIntersectionPointX(ihit);
655 Double_t y_hit = module->GetIntersectionPointY(ihit);
656 Double_t z_hit = module->GetZPositionRegistered();
657
659 cout << " hit[" << ihit << "] = ( " << x_hit << " : " << y_hit << " : " << z_hit << " ) "
660 << "\n";
661
662 // which layers?
663 Int_t NLayers = module->GetNStripLayers();
664 for (Int_t ilayer = 0; ilayer < NLayers; ++ilayer) {
665 BmnSiBTLayer layer = module->GetStripLayer(ilayer);
666 if (layer.IsPointInsideStripLayer(x_hit, y_hit)) {
668 cout << " layer[" << ilayer << "] : ";
669 if (layer.GetType() == LowerStripLayer)
670 cout << "LowerStripLayer";
671 if (layer.GetType() == UpperStripLayer)
672 cout << "UpperStripLayer";
673 cout << ", angle = " << layer.GetAngleDeg();
674 cout << ", pitch = " << layer.GetPitch();
675 cout << ", nstrips = " << layer.GetNStrips();
676 cout << ", sizes = (" << layer.GetXSize() << " x " << layer.GetYSize() << ")";
678 cout << "\n";
679 }
680 }
681
683 cout << "\n";
684
685 g_hits_marker[hit_marker_cnt].SetX(x_hit);
686 g_hits_marker[hit_marker_cnt].SetY(y_hit);
687 g_hits_marker[hit_marker_cnt].SetMarkerSize(1.0);
688 g_hits_marker[hit_marker_cnt].SetMarkerStyle(5);
689 g_hits_marker[hit_marker_cnt].SetMarkerColor(TColor::GetColor("#009900"));
690
691 station_front_canv->cd();
692 g_hits_marker[hit_marker_cnt].Draw();
693
694 // other canvas drawing
696 TSeqCollection* collect = gROOT->GetListOfCanvases();
697 Int_t nentries = collect->GetEntries();
698 for (Int_t ie = 0; ie < nentries; ++ie) {
699 TObject* obj = collect->At(ie);
700 if (TString(obj->GetName()).Contains("layer_canv_")) {
701
702 Int_t NLayers = module->GetNStripLayers();
703
704 for (Int_t ilayer = 0; ilayer < NLayers; ++ilayer) {
705
706 BmnSiBTLayer layer = module->GetStripLayer(ilayer);
707
708 if (layer.IsPointInsideStripLayer(x_hit, y_hit)) {
709 TString laymod = "";
710 laymod += ilayer;
711 laymod += im;
712
713 if (TString(obj->GetName()).Contains(laymod)) {
714 ((TCanvas*)obj)->cd();
715 g_hits_marker[hit_marker_cnt].Draw();
716 ((TCanvas*)obj)->Update();
717 }
718 }
719 }
720 }
721 }
722 }
723
724 hit_marker_cnt++;
725 }
726 cout << "\n";
727 }
728 }
729 cout << "-------------------------------------------------------------\n";
730 }
731
732 if (event == kKeyPress) {
733 cout << "key button was pressed\n";
734 cout << "px = " << eventX << "\n";
735 cout << "py = " << (char)eventY << "\n";
736
737 if (eventX == (int)'c') {
738
739 g_current_station->Reset();
740
741 if (g_hits_marker != 0) {
742 delete[] g_hits_marker;
743 g_hits_marker = 0;
744 g_n_hits_marker = 0;
745 }
746
747 for (Int_t i = 0; i < g_points_marker.size(); ++i) {
748 g_points_marker[i]->Delete();
749 }
750 g_points_marker.clear();
751
752 station_front_canv->Update();
753
754 // other canvas drawing
756 TSeqCollection* collect = gROOT->GetListOfCanvases();
757 Int_t nentries = collect->GetEntries();
758 for (Int_t ie = 0; ie < nentries; ++ie) {
759 TObject* obj = collect->At(ie);
760 if (TString(obj->GetName()).Contains("layer_canv_")) {
761 ((TCanvas*)obj)->Update();
762 }
763 }
764 }
765 }
766 }
767
768 /*if(object) {
769 if(object->InheritsFrom("TMarker")) {
770 TMarker *marker = (TMarker*)object;
771 //cout << "marker (x,y) = ( " << marker->GetX() << " : " << marker->GetY() << " )\n";
772 }
773 }*/
774}
775
776void DrawCreatedStationTop(BmnSiBTStation* station, vector<TLorentzVector>& points)
777{
778
779 TString description_text = "";
780 description_text += "TOP: station ";
781 description_text += station->GetStationNumber();
782 description_text += ", xpos = ";
783 description_text += station->GetXPosition();
784 description_text += ", ypos = ";
785 description_text += station->GetYPosition();
786 description_text += ", zpos = ";
787 description_text += station->GetZPosition();
788 TCanvas* station_top_canv = new TCanvas("station_top_canv", description_text, 10, 10, 1000, 1200);
789 station_top_canv->SetGrid();
790
791 Int_t StationNumber = station->GetStationNumber();
792 Double_t XSize = station->GetXSize();
793 Double_t YSize = station->GetYSize();
794 Double_t ZSize = station->GetZSize();
795 Double_t XMinStation = station->GetXMinStation();
796 Double_t XMaxStation = station->GetXMaxStation();
797 Double_t YMinStation = station->GetYMinStation();
798 Double_t YMaxStation = station->GetYMaxStation();
799 Double_t ZMinStation = station->GetZMinStation();
800 Double_t ZMaxStation = station->GetZMaxStation();
801 Double_t XPosition = station->GetXPosition();
802 Double_t YPosition = station->GetYPosition();
803 Double_t ZPosition = station->GetZPosition();
804 Int_t NModules = station->GetNModules();
805
806 Double_t* XShiftsOfModules = new Double_t[NModules];
807 Double_t* YShiftsOfModules = new Double_t[NModules];
808 Double_t* ZShiftsOfModules = new Double_t[NModules];
809 Double_t maxXShift = 0.0;
810 Double_t maxYShift = 0.0;
811 Double_t maxZShift = 0.0;
812 for (Int_t iModule = 0; iModule < NModules; ++iModule) {
813 XShiftsOfModules[iModule] = station->GetXShiftOfModule(iModule);
814 YShiftsOfModules[iModule] = station->GetYShiftOfModule(iModule);
815 ZShiftsOfModules[iModule] = station->GetZShiftOfModule(iModule);
816
817 if (fabs(XShiftsOfModules[iModule]) > maxXShift)
818 maxXShift = fabs(XShiftsOfModules[iModule]);
819 if (fabs(YShiftsOfModules[iModule]) > maxYShift)
820 maxYShift = fabs(YShiftsOfModules[iModule]);
821 if (fabs(ZShiftsOfModules[iModule]) > maxZShift)
822 maxZShift = fabs(ZShiftsOfModules[iModule]);
823 }
824
825 BmnSiBTModule** Modules = new BmnSiBTModule*[NModules];
826 for (Int_t imod = 0; imod < NModules; imod++) {
827 Modules[imod] = station->GetModule(imod);
828 }
829
830 // Double_t xrange_size = XSize + fabs(XPosition) + maxXShift;
831 // xrange_size *= 0.5 + 0.1;
832
833 Double_t xmin = XMinStation - XSize * 0.3;
834 Double_t xmax = XMaxStation + XSize * 0.3;
835 Double_t zmin = ZMinStation - ZSize * 5.0;
836 Double_t zmax = ZMaxStation + ZSize * 5.0;
837
838 // TH2F *station_top_2dhist = new TH2F("station_top_2dhist", description_text, 100, -xrange_size, xrange_size, 100,
839 // ZPosition-xrange_size*0.5, ZPosition+xrange_size*0.5);
840 TH2F* station_top_2dhist = new TH2F("station_top_2dhist", description_text, 100, xmin, xmax, 100, zmin, zmax);
841 station_top_2dhist->GetXaxis()->SetTitle("+x (classical)");
842 station_top_2dhist->GetYaxis()->SetTitle("+z");
843 station_top_2dhist->Draw();
844
845 TBox** modules_box = new TBox*[NModules];
846
847 for (Int_t im = 0; im < NModules; im++) {
848
849 // module borders -------------------------------------------------------
850 Double_t x_min_module = Modules[im]->GetXMinModule();
851 Double_t x_max_module = Modules[im]->GetXMaxModule();
852 Double_t z_min_module = Modules[im]->GetZStartModulePosition();
853 Double_t z_max_module = Modules[im]->GetZStartModulePosition() + Modules[im]->GetModuleThickness();
854
855 modules_box[im] = new TBox(x_min_module, z_min_module, x_max_module, z_max_module);
856
857 modules_box[im]->SetLineColor(TColor::GetColor("#000000"));
858 modules_box[im]->SetLineStyle(2);
859 modules_box[im]->SetLineWidth(1);
860 modules_box[im]->SetFillColor(TColor::GetColor("#cccccc"));
861 modules_box[im]->SetFillStyle(0); // 0 - not filled, 1001 - solid
862
863 station_top_canv->cd();
864 // modules_box[im]->Draw("f");
865 modules_box[im]->Draw("l");
866 //----------------------------------------------------------------------
867
868 Double_t x_center_module = (modules_box[im]->GetX1() + modules_box[im]->GetX2()) * 0.5;
869 TLine* x_center_module_line =
870 new TLine(x_center_module, modules_box[im]->GetY1(), x_center_module, modules_box[im]->GetY2());
871 x_center_module_line->SetLineColor(TColor::GetColor("#00ccff"));
872 x_center_module_line->Draw();
873 }
874
875 TMarker* mark_point_top = new TMarker[points.size()];
876 for (int ip = 0; ip < points.size(); ip++) {
877 mark_point_top[ip].SetX(points.at(ip).X());
878 mark_point_top[ip].SetY(points.at(ip).Z());
879 mark_point_top[ip].SetMarkerStyle(5);
880 mark_point_top[ip].SetMarkerSize(1.0);
881 mark_point_top[ip].SetMarkerColor(TColor::GetColor("#0000ff"));
882 mark_point_top[ip].Draw();
883 }
884}
kKeyPress
kButton1Shift
friend F32vec4 fabs(const F32vec4 &a)
Definition P4_F32vec4.h:52
int i
Definition P4_F32vec4.h:22
bool Bool_t
int Int_t
double Double_t
#define gROOT
R__EXTERN TStyle * gStyle
#define gPad
StripNumberingDirection
@ RightToLeft
@ LeftToRight
StripLayerType
@ UpperStripLayer
@ LowerStripLayer
Double_t GetXSize()
vector< DeadZoneOfStripLayer > GetDeadZones()
Bool_t IsPointInsideStripLayer(Double_t x, Double_t y)
Int_t GetNStrips()
Double_t GetPitch()
Double_t ConvertPointToStripPosition(Double_t x, Double_t y)
Double_t GetYLeftStripBorderPoint()
Double_t GetXMaxLayer()
Double_t GetYSize()
Double_t GetYMaxLayer()
Double_t GetAngleDeg()
Double_t GetYRightStripBorderPoint()
StripLayerType GetType()
Double_t GetYMinLayer()
Double_t GetXMinLayer()
Double_t GetXLeftStripBorderPoint()
Double_t GetXRightStripBorderPoint()
StripNumberingDirection GetStripNumberingOrder()
Double_t GetXMaxModule()
Double_t GetYMinModule()
Double_t GetYMaxModule()
Int_t GetNStripLayers()
Double_t GetZStartModulePosition()
BmnSiBTLayer & GetStripLayer(Int_t num)
Double_t GetModuleThickness()
Double_t GetXMinModule()
Int_t GetPointStationOwnership(Double_t zcoord)
BmnSiBTStation * GetStation(Int_t station_num)
Double_t GetZSize()
Double_t GetZShiftOfModule(Int_t module_num)
BmnSiBTModule * GetModule(Int_t module_num)
Double_t GetYShiftOfModule(Int_t module_num)
Int_t GetStationNumber()
Double_t GetXShiftOfModule(Int_t module_num)
Double_t GetZPosition()
Double_t GetZMaxStation()
Double_t GetZMinStation()
Double_t GetYPosition()
Double_t GetXSize()
Double_t GetYMaxStation()
Double_t GetXPosition()
Double_t GetXMaxStation()
Double_t GetYSize()
Double_t GetXMinStation()
Int_t GetPointModuleOwnership(Double_t xcoord, Double_t ycoord, Double_t zcoord)
Double_t GetYMinStation()
Double_t GetXPoint(Int_t index)
Double_t GetYPoint(Int_t index)
virtual void SetArrowSize(Float_t arrowsize=0.05)
void Draw(Option_t *option="") override
virtual void SetFillColor(Color_t fcolor)
virtual void SetFillColorAlpha(Color_t fcolor, Float_t falpha)
virtual void SetFillStyle(Style_t fstyle)
virtual void SetLineStyle(Style_t lstyle)
virtual void SetLineWidth(Width_t lwidth)
virtual void SetLineColorAlpha(Color_t lcolor, Float_t lalpha)
virtual void SetLineColor(Color_t lcolor)
virtual void SetMarkerColor(Color_t mcolor=1)
virtual void SetMarkerStyle(Style_t mstyle=1)
virtual void SetMarkerSize(Size_t msize=1)
void Draw(Option_t *option="") override
Double_t GetX1() const
Double_t GetX2() const
Double_t GetY1() const
Double_t GetY2() const
TVirtualPad * cd(Int_t subpadnumber=0) override
void Update() override
virtual Int_t GetEntries() const
static Int_t GetColor(const char *hexcolor)
TAxis * GetXaxis()
TAxis * GetYaxis()
void Draw(Option_t *option="") override
virtual void SetY2(Double_t y2)
virtual void SetX2(Double_t x2)
virtual void SetX1(Double_t x1)
virtual void SetY1(Double_t y1)
void SetXYZT(Double_t x, Double_t y, Double_t z, Double_t t)
virtual void SetX(Double_t x)
void Draw(Option_t *option="") override
virtual void SetY(Double_t y)
Double_t GetX() const
virtual void SetTitle(const char *title="")
virtual const char * GetName() const
virtual void Draw(Option_t *option="")
void AddExec(const char *name, const char *command) override
void SetGrid(Int_t valuex=1, Int_t valuey=1) override
void Draw(Option_t *option="") override
virtual Int_t SetNextPoint(Double_t x, Double_t y)
virtual TObject * At(Int_t idx) const=0
Bool_t Contains(const char *pat, ECaseCompare cmp=kExact) const
void DrawCreatedStationTop(BmnSiBTStation *station, vector< TLorentzVector > &points)
void TestSiBTConfig_Visual()
void RecognizeModuleNumFromPointAndDrawIt(TCanvas *station_front_canv)
void DrawCreatedStationFront(BmnSiBTStation *station, vector< TLorentzVector > &points)
Int_t g_n_hits_marker
Bool_t g_ShowIntersectionPointInfo
TMarker * g_hits_marker
Double_t g_z_current_point
vector< TMarker * > g_points_marker
Bool_t g_EnableAddingPoints
Bool_t g_DrawOnSeparateLayers
constexpr Double_t DegToRad()
constexpr Double_t Pi()
Double_t Tan(Double_t)