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