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