BmnRoot 26.10.0-18-g4e3414f9
Software framework of the BM@N experiment
Loading...
Searching...
No Matches
TestCSCClassTransform.C
Go to the documentation of this file.
1/*
2 * This macro for testing configurations of the CSC (Cathode Strip Chamber)
3 * detector which have some module transformations in an XML-parameter file.
4 *
5 * It allows you to analyze MC-points and Hits and find their ownership to
6 * modules in various visual projections.
7 *
8 * Author: Baranov D.
9 * Created: 27.08.2021
10 *
11 */
12#include "Rtypes.h"
13
14R__ADD_INCLUDE_PATH($VMCWORKDIR)
15
16#include "Math/Transform3D.h"
17#include "TBox.h"
18#include "TCanvas.h"
19#include "TClonesArray.h"
20#include "TFile.h"
21#include "TFrame.h"
22#include "TH1F.h"
23#include "TH2F.h"
24#include "TPad.h"
25#include "TRandom.h"
26#include "TTree.h"
27#include "macro/run/bmnloadlibs.C"
28
29#include <fstream>
30#include <iostream>
31#include <vector>
32
33using namespace ROOT::Math;
34using namespace std;
35
36// Global variables
41
44vector<vector<Bool_t>> gConfig_visual; // [station][module] = bool (active/inactive)
45
46// function declaration
47void DrawPointsAndLines(vector<Plane3D::Point> points,
48 TString hexcolor,
49 Int_t marker_style,
50 Double_t marker_size,
51 Double_t line_size,
52 Bool_t isPointDraw,
53 Bool_t isLinesDraw,
54 Bool_t isCloseLine);
55void DrawPointsAndLines3D(vector<Plane3D::Point> points,
56 TString hexcolor,
57 Int_t marker_style,
58 Double_t marker_size,
59 Double_t line_size,
60 Bool_t isPointDraw,
61 Bool_t isLinesDraw,
62 Bool_t isCloseLine);
63void DrawBranchPoints(TTree* points_tree, TClonesArray* points_array, Int_t first_event, Int_t last_event);
64void DrawBranchHits(TTree* points_tree, TClonesArray* points_array, Int_t first_event, Int_t last_event);
65
67{
68
69 // ---- Load libraries --------------------------------------------------
70#if ROOT_VERSION_CODE < ROOT_VERSION(5, 99, 99)
71 gROOT->LoadMacro("$VMCWORKDIR/macro/run/bmnloadlibs.C");
72#endif
73 bmnloadlibs(); // load BmnRoot libraries
74 // -------------------------------------------------------------------------
75
76 //------------------------------------------------------------------------------
77 TString file_prefix = "";
78 // file_prefix = "_CC_4gev_b0_16fm";
79
80 // Input MC-points for CSC (called CSCPoint)
81 TClonesArray* fCSCMCPoints_Array = new TClonesArray("");
82 TString fCSCMCPoints_FileName = "$VMCWORKDIR/macro/run/bmnsim";
83 fCSCMCPoints_FileName += file_prefix;
84 fCSCMCPoints_FileName += ".root";
85 TFile* fCSCMCPoints_File = new TFile(fCSCMCPoints_FileName, "READ");
86 TTree* fCSCMCPoints_Tree = (TTree*)fCSCMCPoints_File->Get("bmndata");
87 fCSCMCPoints_Tree->GetBranch("CSCPoint")->SetAutoDelete(kTRUE);
88 fCSCMCPoints_Tree->SetBranchAddress("CSCPoint", &fCSCMCPoints_Array);
89 Int_t NEvents_fCSCMCPoints = fCSCMCPoints_Tree->GetEntries();
90
91 // Input hits for CSC
92 TClonesArray* fCSCHits_Array = new TClonesArray("");
93 TString fCSCHits_FileName = "$VMCWORKDIR/macro/run/bmndst";
94 fCSCHits_FileName += file_prefix;
95 fCSCHits_FileName += ".root";
96 TFile* fCSCHits_File = new TFile(fCSCHits_FileName, "READ");
97 TTree* fCSCHits_Tree = (TTree*)fCSCHits_File->Get("bmndata");
98 fCSCHits_Tree->GetBranch("BmnCSCHit")->SetAutoDelete(kTRUE);
99 fCSCHits_Tree->SetBranchAddress("BmnCSCHit", &fCSCHits_Array);
100 Int_t NEvents_fCSCHits = fCSCHits_Tree->GetEntries();
101 //------------------------------------------------------------------------------
102
103 // axis ranges
104 Double_t scale_coeff = 2;
105 Double_t xmin_view = -100.0 * scale_coeff;
106 Double_t xmax_view = +100.0 * scale_coeff;
107 Double_t ymin_view = -100.0 * scale_coeff;
108 Double_t ymax_view = +100.0 * scale_coeff;
109 Double_t zmin_view = +300.0; // was -100
110 Double_t zmax_view = +850.0;
111 // Double_t zmin_view = -100.0*scale_coeff; //was -100
112 // Double_t zmax_view = +300.0*scale_coeff;
113
114 // XY plane
115 planeXY_canv = new TCanvas("planeXY_canv", "planeXY_canv", 10, 10, 900, 900);
116 planeXY_canv->SetGrid();
117 TH2D* planeXY_h2 =
118 new TH2D("planeXY_h2", "planeXY_h2 (to the target(back))", 10, xmin_view, xmax_view, 10, ymin_view, ymax_view);
119 planeXY_h2->GetXaxis()->SetTitle("X(global)");
120 planeXY_h2->GetYaxis()->SetTitle("Y(global)");
121
122 // ZX plane
123 planeZX_canv = new TCanvas("planeZX_canv", "planeZX_canv", 1000, 10, 900, 900);
124 planeZX_canv->SetGrid();
125 TH2D* planeZX_h2 = new TH2D("planeZX_h2", "planeZX_h2(top)", 10, zmin_view, zmax_view, 10, xmin_view, xmax_view);
126 planeZX_h2->GetXaxis()->SetTitle("Z(global)");
127 planeZX_h2->GetYaxis()->SetTitle("X(global)");
128
129 // ZY plane
130 planeZY_canv = new TCanvas("planeZY_canv", "planeZY_canv", 1800, 10, 900, 900);
131 planeZY_canv->SetGrid();
132 TH2D* planeZY_h2 = new TH2D("planeZY_h2", "planeZY_h2(side)", 10, zmin_view, zmax_view, 10, ymin_view, ymax_view);
133 planeZY_h2->GetXaxis()->SetTitle("Z(global)");
134 planeZY_h2->GetYaxis()->SetTitle("Y(global)");
135
136 // 3D view (y and z - swapped)
137 XYZview_canv = new TCanvas("XYZview_canv", "XYZview_canv", 2900, 10, 900, 900);
138 // XYZview_canv->SetGrid();
139 TH3D* XYZview_h3 = new TH3D("XYZview_h3", "XYZview_h3", 10, zmin_view, zmax_view, 10, xmin_view, xmax_view, 10,
140 ymin_view, ymax_view);
141 XYZview_h3->GetXaxis()->SetTitle("Z");
142 XYZview_h3->GetYaxis()->SetTitle("X");
143 XYZview_h3->GetZaxis()->SetTitle("Y");
144
145 //------------------------------------------------------------------------------
146
147 // Set the path to an XML-config. file
148 TString gPathDetectorConfig = gSystem->Getenv("VMCWORKDIR");
149 gPathDetectorConfig += "/parameters/csc/XMLConfigs/";
150
151 // gPathDetectorConfig += "CSCRunSRC2021.xml";
152 // gPathDetectorConfig += "CSCFutureConfig2020.xml";
153 gPathDetectorConfig += "FullCSCRun8.xml";
154
155 // Current configuration
156 gStationSet = new BmnCSCStationSet(gPathDetectorConfig);
157
158 // Current transform configuration
160 gTransfClass->LoadFromXMLFile(gPathDetectorConfig);
161
162 // Selecting modules to visualize -------------------------------------------
163 gConfig_visual.resize(gStationSet->GetNStations()); // quantity of stations
164 for (Int_t istation = 0; istation < gConfig_visual.size(); ++istation) {
165 gConfig_visual[istation].resize(gStationSet->GetStation(istation)->GetNModules(), false); // default: inactive
166 }
167
168 // Set a visualization flag for each module
169 gConfig_visual[0][0] = true;
170 gConfig_visual[0][1] = true;
171
172 gConfig_visual[1][0] = true;
173 gConfig_visual[1][1] = true;
174
175 gConfig_visual[2][0] = true;
176 gConfig_visual[2][1] = true;
177
178 gConfig_visual[3][0] = true;
179 gConfig_visual[3][1] = true;
180
181 gConfig_visual[4][0] = true;
182 gConfig_visual[4][1] = true;
183 gConfig_visual[4][2] = true;
184 gConfig_visual[4][3] = true;
185 gConfig_visual[4][4] = true;
186 gConfig_visual[4][5] = true;
187 gConfig_visual[4][6] = true;
188 gConfig_visual[4][7] = true;
189
190 // Printing the info about the visual status of modules
191 if (1) {
192 cout << "Info about the visual status of modules:\n";
193 for (Int_t istation = 0; istation < gConfig_visual.size(); ++istation) {
194 for (Int_t imodule = 0; imodule < gConfig_visual[istation].size(); ++imodule) {
195 cout << "det[" << istation << "][" << imodule << "] = " << gConfig_visual[istation][imodule] << "\n";
196 }
197 }
198 cout << "\n";
199 }
200 //--------------------------------------------------------------------------
201
202 planeXY_canv->cd();
203 planeXY_h2->Draw();
204
205 planeZX_canv->cd();
206 planeZX_h2->Draw();
207
208 planeZY_canv->cd();
209 planeZY_h2->Draw();
210
211 XYZview_canv->cd();
212 XYZview_h3->Draw();
213
214 for (Int_t istation = 0; istation < gStationSet->GetNStations(); ++istation) {
215
216 for (Int_t imodule = 0; imodule < gStationSet->GetStation(istation)->GetNModules(); ++imodule) {
217
218 Bool_t visual_status = gConfig_visual[istation][imodule];
219
220 if (visual_status == true) {
221
222 BmnCSCModule* module = gStationSet->GetStation(istation)->GetModule(imodule);
223
224 // parameters of the current module in local coordinates
225 Double_t xmin_module = module->GetXMinModule();
226 Double_t xmax_module = module->GetXMaxModule();
227 Double_t ymin_module = module->GetYMinModule();
228 Double_t ymax_module = module->GetYMaxModule();
229 Double_t z_start_pos_module =
230 gStationSet->GetStation(istation)->GetModule(imodule)->GetZStartModulePosition();
231 Double_t z_reg_module = gStationSet->GetStation(istation)->GetModule(imodule)->GetZPositionRegistered();
232
233 // print parameters of the module
234 if (1) {
235 cout << " station[" << istation << "], module[" << imodule << "]:\n";
236 cout << " xloc_module(min:max) = ( " << xmin_module << " : " << xmax_module << ")\n";
237 cout << " yloc_module(min:max) = ( " << ymin_module << " : " << ymax_module << ")\n";
238 cout << " zloc_start_pos_module = " << z_start_pos_module << "\n";
239 cout << " zloc_reg_module = " << z_reg_module << "\n";
240 cout << "\n";
241 }
242
243 vector<Plane3D::Point> module_borders;
244 vector<Plane3D::Point> tmodule_borders; // transformed
245 vector<Plane3D::Point> rtmodule_borders; // inverse transformed
246
247 module_borders.push_back(
248 Plane3D::Point(-xmin_module, ymin_module, z_reg_module)); // x converted to global
249 module_borders.push_back(
250 Plane3D::Point(-xmin_module, ymax_module, z_reg_module)); // x converted to global
251 module_borders.push_back(
252 Plane3D::Point(-xmax_module, ymax_module, z_reg_module)); // x converted to global
253 module_borders.push_back(
254 Plane3D::Point(-xmax_module, ymin_module, z_reg_module)); // x converted to global
255
256 for (Int_t ipoint = 0; ipoint < module_borders.size(); ++ipoint) {
257 tmodule_borders.push_back(gTransfClass->ApplyTransforms(module_borders[ipoint], istation, imodule));
258 }
259
260 // DrawPointsAndLines(module_borders, "#cc0000", 20, 1.0, 1.0, false, true, true);
261 DrawPointsAndLines(tmodule_borders, "#00cc00", 20, 1.0, 1.0, false, true, true);
262 // DrawPointsAndLines(rtmodule_borders, "#0000cc", 20, 1.0, 1.0, true, true, true);
263
264 // DrawPointsAndLines3D(module_borders, "#cc0000", 20, 0.5, 1.0, false, true, true);
265 DrawPointsAndLines3D(tmodule_borders, "#00cc00", 20, 0.5, 1.0, true, true, true);
266 // DrawPointsAndLines3D(rtmodule_borders, "#0000cc", 20, 0.5, 1.0, true, true, true);
267
268 // Drawing borders of layers ------------------------------------
269 if (1) {
270 for (Int_t ilayer = 0; ilayer < module->GetNStripLayers(); ++ilayer) {
271 BmnCSCLayer layer = module->GetStripLayer(ilayer);
272
273 // parameters of the current module in local coordinates
274 Double_t xmin_layer = layer.GetXMinLayer();
275 Double_t xmax_layer = layer.GetXMaxLayer();
276 Double_t ymin_layer = layer.GetYMinLayer();
277 Double_t ymax_layer = layer.GetYMaxLayer();
278
279 Double_t xleft_sborder_layer = layer.GetXLeftStripBorderPoint();
280 Double_t yleft_sborder_layer = layer.GetYLeftStripBorderPoint();
281 Double_t xright_sborder_layer = layer.GetXRightStripBorderPoint();
282 Double_t yright_sborder_layer = layer.GetYRightStripBorderPoint();
283
284 // print parameters of the module
285 if (1) {
286 cout << " station[" << istation << "], module[" << imodule << "]:\n";
287 cout << " xloc_layer(min:max) = ( " << xmin_layer << " : " << xmax_layer << ")\n";
288 cout << " yloc_layer(min:max) = ( " << ymin_layer << " : " << ymax_layer << ")\n";
289 cout << " zloc_reg_layer = " << z_reg_module << "\n";
290 cout << "\n";
291 }
292
293 vector<Plane3D::Point> layer_borders;
294 vector<Plane3D::Point> tlayer_borders; // transformed
295 vector<Plane3D::Point> rtlayer_borders; // inverse transformed
296
297 vector<Plane3D::Point> layer_left_border_point;
298 vector<Plane3D::Point> tlayer_left_border_point; // transformed
299 vector<Plane3D::Point> rtlayer_left_border_point; // inverse transformed
300 vector<Plane3D::Point> layer_right_border_point;
301 vector<Plane3D::Point> tlayer_right_border_point; // transformed
302 vector<Plane3D::Point> rtlayer_right_border_point; // inverse transformed
303
304 layer_borders.push_back(
305 Plane3D::Point(-xmin_layer, ymin_layer, z_reg_module)); // x converted to global
306 layer_borders.push_back(
307 Plane3D::Point(-xmin_layer, ymax_layer, z_reg_module)); // x converted to global
308 layer_borders.push_back(
309 Plane3D::Point(-xmax_layer, ymax_layer, z_reg_module)); // x converted to global
310 layer_borders.push_back(
311 Plane3D::Point(-xmax_layer, ymin_layer, z_reg_module)); // x converted to global
312
313 layer_left_border_point.push_back(Plane3D::Point(-xleft_sborder_layer, yleft_sborder_layer,
314 z_reg_module)); // x converted to global
315 layer_right_border_point.push_back(Plane3D::Point(-xright_sborder_layer, yright_sborder_layer,
316 z_reg_module)); // x converted to global
317
318 for (Int_t ipoint = 0; ipoint < layer_borders.size(); ++ipoint) {
319 tlayer_borders.push_back(
320 gTransfClass->ApplyTransforms(layer_borders[ipoint], istation, imodule));
321 }
322
323 tlayer_left_border_point.push_back(
324 gTransfClass->ApplyTransforms(layer_left_border_point[0], istation, imodule));
325 tlayer_right_border_point.push_back(
326 gTransfClass->ApplyTransforms(layer_right_border_point[0], istation, imodule));
327
328 // draw module borders
329 DrawPointsAndLines(tlayer_borders, "#00cc00", 20, 1.0, 1.0, false, true, true);
330 DrawPointsAndLines3D(tlayer_borders, "#00cc00", 20, 0.5, 1.0, true, true, true);
331
332 // draw left strip border point
333 // DrawPointsAndLines(tlayer_left_border_point, "#cc0000", 20, 1.0, 1.0, true, false, false);
334 // DrawPointsAndLines3D(tlayer_left_border_point, "#cc0000", 20, 1.0, 1.0, true, false, false);
335
336 // draw right strip border point
337 // DrawPointsAndLines(tlayer_right_border_point, "#0000cc", 20, 1.0, 1.0, true, false, false);
338 // DrawPointsAndLines3D(tlayer_right_border_point, "#0000cc", 20, 1.0, 1.0, true, false, false);
339 }
340 //-------------------------------------------------------------
341 }
342 }
343 }
344 }
345
346 // What we want to add on our module planes
347
348 // DrawBranchPoints(fCSCMCPoints_Tree, fCSCMCPoints_Array, 0, NEvents_fCSCMCPoints);
349 // DrawBranchHits(fCSCHits_Tree, fCSCHits_Array, 0, NEvents_fCSCMCPoints);
350
351 DrawBranchPoints(fCSCMCPoints_Tree, fCSCMCPoints_Array, 0, 1);
352 DrawBranchHits(fCSCHits_Tree, fCSCHits_Array, 0, 1);
353
354 delete gTransfClass;
355 delete gStationSet;
356
357 cout << "It's the end" << "\n";
358 // gApplication->Terminate();
359}
360//------------------------------------------------------------------------------
361
362void DrawPointsAndLines(vector<Plane3D::Point> points,
363 TString hexcolor,
364 Int_t marker_style,
365 Double_t marker_size,
366 Double_t line_size,
367 Bool_t isPointDraw,
368 Bool_t isLinesDraw,
369 Bool_t isCloseLine)
370{
371 // Drawing the points as the markers ----------------------------------------
372 for (Int_t ipoint = 0; ipoint < points.size(); ++ipoint) {
373
374 // XY-plane -------------------------------------------------------------
375 // Markers on the XY plane
376 {
377 TMarker* marker = new TMarker(points[ipoint].X(), points[ipoint].Y(), marker_style);
378 marker->SetMarkerSize(marker_size);
379 marker->SetMarkerColor(TColor::GetColor(hexcolor));
380 planeXY_canv->cd();
381 if (isPointDraw)
382 marker->Draw();
383
384 // Lines between points on XY plane
385 Double_t x1, y1, x2, y2;
386 if (ipoint != points.size() - 1) {
387 x1 = points[ipoint].X();
388 y1 = points[ipoint].Y();
389 x2 = points[ipoint + 1].X();
390 y2 = points[ipoint + 1].Y();
391 } else {
392 if (isCloseLine) {
393 x1 = points[ipoint].X();
394 y1 = points[ipoint].Y();
395 x2 = points[0].X();
396 y2 = points[0].Y();
397 }
398 }
399 TLine* line = new TLine(x1, y1, x2, y2);
400 line->SetLineColor(TColor::GetColor(hexcolor));
401 line->SetLineWidth(line_size);
402 planeXY_canv->cd();
403 if (isLinesDraw)
404 line->Draw();
405 }
406 //----------------------------------------------------------------------
407
408 // ZX-plane -------------------------------------------------------------
409 // Markers on the ZX plane
410 {
411 TMarker* marker = new TMarker(points[ipoint].Z(), points[ipoint].X(), marker_style);
412 marker->SetMarkerSize(marker_size);
413 marker->SetMarkerColor(TColor::GetColor(hexcolor));
414 planeZX_canv->cd();
415 if (isPointDraw)
416 marker->Draw();
417
418 // Lines between points on ZX plane
419 Double_t z1, x1, z2, x2;
420 if (ipoint != points.size() - 1) {
421 z1 = points[ipoint].Z();
422 x1 = points[ipoint].X();
423 z2 = points[ipoint + 1].Z();
424 x2 = points[ipoint + 1].X();
425 } else {
426 if (isCloseLine) {
427 z1 = points[ipoint].Z();
428 x1 = points[ipoint].X();
429 z2 = points[0].Z();
430 x2 = points[0].X();
431 }
432 }
433 TLine* line = new TLine(z1, x1, z2, x2);
434 line->SetLineColor(TColor::GetColor(hexcolor));
435 line->SetLineWidth(line_size);
436 planeZX_canv->cd();
437 if (isLinesDraw)
438 line->Draw();
439 }
440 //----------------------------------------------------------------------
441
442 // ZY-plane -------------------------------------------------------------
443 // Markers on the XY plane
444 {
445 TMarker* marker = new TMarker(points[ipoint].Z(), points[ipoint].Y(), marker_style);
446 marker->SetMarkerSize(marker_size);
447 marker->SetMarkerColor(TColor::GetColor(hexcolor));
448 planeZY_canv->cd();
449 if (isPointDraw)
450 marker->Draw();
451
452 // Lines between points on XY plane
453 Double_t z1, y1, z2, y2;
454 if (ipoint != points.size() - 1) {
455 z1 = points[ipoint].Z();
456 y1 = points[ipoint].Y();
457 z2 = points[ipoint + 1].Z();
458 y2 = points[ipoint + 1].Y();
459 } else {
460 if (isCloseLine) {
461 z1 = points[ipoint].Z();
462 y1 = points[ipoint].Y();
463 z2 = points[0].Z();
464 y2 = points[0].Y();
465 }
466 }
467 TLine* line = new TLine(z1, y1, z2, y2);
468 line->SetLineColor(TColor::GetColor(hexcolor));
469 line->SetLineWidth(line_size);
470 planeZY_canv->cd();
471 if (isLinesDraw)
472 line->Draw();
473 }
474 //----------------------------------------------------------------------
475 }
476}
477
478void DrawPointsAndLines3D(vector<Plane3D::Point> points,
479 TString hexcolor,
480 Int_t marker_style,
481 Double_t marker_size,
482 Double_t line_size,
483 Bool_t isPointDraw,
484 Bool_t isLinesDraw,
485 Bool_t isCloseLine)
486{
487
488 // system coord XYZ---->ZXY
489
490 // points as the markers ----------------------------------------
491 TPolyMarker3D* markers = new TPolyMarker3D(points.size());
492 markers->SetMarkerColor(TColor::GetColor(hexcolor));
493 markers->SetMarkerStyle(marker_style);
494 markers->SetMarkerSize(marker_size);
495
496 // lines between points
497 TPolyLine3D* lines = new TPolyLine3D(points.size());
498 lines->SetLineColor(TColor::GetColor(hexcolor));
499 lines->SetLineWidth(line_size);
500
501 for (Int_t ipoint = 0; ipoint < points.size(); ++ipoint) {
502
503 markers->SetPoint(ipoint, points[ipoint].Z(), points[ipoint].X(), points[ipoint].Y());
504
505 if (ipoint != points.size() - 1) {
506 lines->SetPoint(ipoint, points[ipoint].Z(), points[ipoint].X(), points[ipoint].Y());
507 } else {
508 lines->SetPoint(ipoint, points[ipoint].Z(), points[ipoint].X(), points[ipoint].Y());
509 if (isCloseLine) {
510 lines->SetPoint(ipoint + 1, points[0].Z(), points[0].X(), points[0].Y());
511 }
512 }
513 }
514
515 XYZview_canv->cd();
516 if (isPointDraw)
517 markers->Draw();
518 if (isLinesDraw)
519 lines->Draw();
520}
521
522void DrawBranchPoints(TTree* points_tree, TClonesArray* points_array, Int_t first_event, Int_t last_event)
523{
524
525 vector<Plane3D::Point> tracks;
526 vector<Plane3D::Point> points;
527
528 for (Int_t ievent = first_event; ievent < last_event; ++ievent) {
529
530 points_tree->GetEntry(ievent);
531
532 Int_t npoints = points_array->GetEntries();
533
534 Int_t trackIdPrev = -1;
535 tracks.clear();
536
537 for (Int_t ipoint = 0; ipoint < npoints; ++ipoint) {
538
539 BmnCSCPoint* mc_point = (BmnCSCPoint*)points_array->At(ipoint);
540
541 Double_t x = ((FairMCPoint*)mc_point)->GetX();
542 Double_t y = ((FairMCPoint*)mc_point)->GetY();
543 Double_t z = ((FairMCPoint*)mc_point)->GetZ();
544
545 Double_t px = ((FairMCPoint*)mc_point)->GetPx();
546 Double_t py = ((FairMCPoint*)mc_point)->GetPy();
547 Double_t pz = ((FairMCPoint*)mc_point)->GetPz();
548
549 Int_t trackId = mc_point->GetTrackID();
550
551 Int_t station_num = mc_point->GetStation();
552 Int_t module_num = mc_point->GetModule();
553
554 // needs to determine point ownership using local positions
555 Plane3D::Point loc_point(x, y, z);
556 Plane3D::Point loc_direct(px + x, py + y, pz + z);
557 if (station_num < gStationSet->GetNStations()) {
558 if (module_num < gStationSet->GetStation(station_num)->GetNModules()) {
559 loc_point = gTransfClass->ApplyInverseTransforms(loc_point, station_num, module_num);
560 loc_direct = gTransfClass->ApplyInverseTransforms(loc_direct, station_num, module_num);
561 }
562 }
563 Double_t xloc = loc_point.X();
564 Double_t yloc = loc_point.Y();
565 Double_t zloc = loc_point.Z();
566
567 Double_t pxloc = loc_direct.X() - loc_point.X();
568 Double_t pyloc = loc_direct.Y() - loc_point.Y();
569 Double_t pzloc = loc_direct.Z() - loc_point.Z();
570
571 cout << "ipoint = " << ipoint << "\n";
572 cout << " x = " << x << "\n";
573 cout << " y = " << y << "\n";
574 cout << " z = " << z << "\n";
575 cout << " px = " << px << "\n";
576 cout << " py = " << py << "\n";
577 cout << " pz = " << pz << "\n";
578 cout << "\n";
579 cout << " xloc = " << xloc << "\n";
580 cout << " yloc = " << yloc << "\n";
581 cout << " zloc = " << zloc << "\n";
582 cout << " pxloc = " << pxloc << "\n";
583 cout << " pyloc = " << pyloc << "\n";
584 cout << " pzloc = " << pzloc << "\n";
585 cout << "\n";
586
587 Int_t current_station_num = -1;
588 Int_t current_module_num = -1;
589 Bool_t visual_status = false;
590 current_station_num = gStationSet->GetPointStationOwnership(-xloc, yloc, zloc);
591
592 if (current_station_num >= 0)
593 current_module_num =
594 gStationSet->GetStation(current_station_num)->GetPointModuleOwnership(-xloc, yloc, zloc);
595 if (current_station_num >= 0 && current_module_num >= 0)
596 visual_status = gConfig_visual[current_station_num][current_module_num];
597
598 cout << " current_station_num(point) = " << current_station_num << "\n";
599 cout << " current_module_num(point) = " << current_module_num << "\n";
600
601 TString point_color;
602 if (visual_status == true)
603 point_color = "#cc0000";
604 else
605 point_color = "#999999";
606
607 if (trackId != trackIdPrev) {
608 DrawPointsAndLines(tracks, "#ffbcad", 6, 1.0, 1.0, false, true, false);
609 DrawPointsAndLines3D(tracks, "#ffbcad", 6, 1.0, 1.0, false, true, false);
610 tracks.clear();
611 }
612 trackIdPrev = trackId;
613
614 tracks.push_back(Plane3D::Point(x, y, z));
615 points.push_back(Plane3D::Point(x, y, z));
616
617 DrawPointsAndLines(points, point_color, 20, 0.4, 1.0, true, false, false);
618 DrawPointsAndLines3D(points, point_color, 20, 0.4, 1.0, true, false, false);
619 points.clear();
620
621 // drawing directions of mc-points
622 vector<Plane3D::Point> direct_points;
623 direct_points.push_back(Plane3D::Point(x, y, z));
624 direct_points.push_back(Plane3D::Point(x + px * 10, y + py * 10, z + pz * 10)); // 10x scaling
625 DrawPointsAndLines(direct_points, point_color, 20, 0.4, 1.0, false, true, false);
626 DrawPointsAndLines3D(direct_points, point_color, 20, 0.4, 1.0, false, true, false);
627 direct_points.clear();
628 }
629 }
630}
631
632void DrawBranchHits(TTree* points_tree, TClonesArray* points_array, Int_t first_event, Int_t last_event)
633{
634
635 vector<Plane3D::Point> points;
636
637 for (Int_t ievent = first_event; ievent < last_event; ++ievent) {
638
639 points_tree->GetEntry(ievent);
640
641 Int_t npoints = points_array->GetEntries();
642
643 for (Int_t ihit = 0; ihit < npoints; ++ihit) {
644
645 BmnCSCHit* hit = (BmnCSCHit*)points_array->At(ihit);
646
647 Double_t x = hit->GetX();
648 Double_t y = hit->GetY();
649 Double_t z = hit->GetZ();
650
651 Int_t station_num = hit->GetStation();
652 Int_t module_num = hit->GetModule();
653
654 // needs to determine hit ownership using local positions
655 Plane3D::Point loc_hit(x, y, z);
656 if (station_num < gStationSet->GetNStations()) {
657 if (module_num < gStationSet->GetStation(station_num)->GetNModules()) {
658 loc_hit = gTransfClass->ApplyInverseTransforms(loc_hit, station_num, module_num);
659 }
660 }
661 Double_t xloc = loc_hit.X();
662 Double_t yloc = loc_hit.Y();
663 Double_t zloc = loc_hit.Z();
664
665 Int_t current_station_num = -1;
666 Int_t current_module_num = -1;
667 Bool_t visual_status = false;
668 current_station_num = gStationSet->GetPointStationOwnership(-xloc, yloc, zloc);
669
670 if (current_station_num >= 0)
671 current_module_num =
672 gStationSet->GetStation(current_station_num)->GetPointModuleOwnership(-xloc, yloc, zloc);
673 if (current_station_num >= 0 && current_module_num >= 0)
674 visual_status = gConfig_visual[current_station_num][current_module_num];
675
676 TString point_color;
677 if (visual_status == true)
678 point_color = "#0000cc";
679 else
680 point_color = "#ccccff";
681
682 points.push_back(Plane3D::Point(x, y, z));
683
684 DrawPointsAndLines(points, point_color, 6, 1.0, 1.0, true, false, false);
685 DrawPointsAndLines3D(points, point_color, 6, 1.0, 1.0, true, false, false);
686 points.clear();
687 }
688 }
689}
bool Bool_t
int Int_t
double Double_t
constexpr Bool_t kTRUE
#define R__ADD_INCLUDE_PATH(PATH)
#define gROOT
R__EXTERN TSystem * gSystem
Double_t GetYRightStripBorderPoint()
Definition BmnCSCLayer.h:73
Double_t GetXRightStripBorderPoint()
Definition BmnCSCLayer.h:72
Double_t GetYMaxLayer()
Definition BmnCSCLayer.h:59
Double_t GetYMinLayer()
Definition BmnCSCLayer.h:58
Double_t GetXMinLayer()
Definition BmnCSCLayer.h:56
Double_t GetYLeftStripBorderPoint()
Definition BmnCSCLayer.h:71
Double_t GetXMaxLayer()
Definition BmnCSCLayer.h:57
Double_t GetXLeftStripBorderPoint()
Definition BmnCSCLayer.h:70
Int_t GetNStripLayers()
Int_t GetModule() const
Definition BmnCSCPoint.h:59
Int_t GetStation() const
Definition BmnCSCPoint.h:58
Int_t GetModule()
Definition BmnHit.h:36
Short_t GetStation() const
Definition BmnHit.h:35
PositionVector3D< Cartesian3D< T >, DefaultCoordinateSystemTag > Point
virtual void SetLineWidth(Width_t lwidth)
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)
virtual void SetAutoDelete(bool autodel=true)
static Int_t GetColor(const char *hexcolor)
T * Get(const char *namecycle)
TAxis * GetZaxis()
TAxis * GetXaxis()
TAxis * GetYaxis()
void Draw(Option_t *option="") override
void Draw(Option_t *option="") override
virtual void SetTitle(const char *title="")
Int_t GetEntries() const override
TObject * At(Int_t idx) const override
virtual void Draw(Option_t *option="")
virtual void SetPoint(Int_t point, Double_t x, Double_t y, Double_t z)
void Draw(Option_t *option="") override
void SetPoint(Int_t n, Double_t x, Double_t y, Double_t z)
void Draw(Option_t *option="") override
virtual TBranch * GetBranch(const char *name)
virtual Int_t GetEntry(Long64_t entry, Int_t getall=0)
virtual Long64_t GetEntries() const
Int_t SetBranchAddress(const char *bname, T **add, TBranch **ptr=nullptr)
TCanvas * planeXY_canv
vector< vector< Bool_t > > gConfig_visual
BmnCSCTransform * gTransfClass
TCanvas * XYZview_canv
TCanvas * planeZX_canv
TCanvas * planeZY_canv
BmnCSCStationSet * gStationSet
void DrawBranchHits(TTree *points_tree, TClonesArray *points_array, Int_t first_event, Int_t last_event)
void DrawPointsAndLines(vector< Plane3D::Point > points, TString hexcolor, Int_t marker_style, Double_t marker_size, Double_t line_size, Bool_t isPointDraw, Bool_t isLinesDraw, Bool_t isCloseLine)
void TestCSCClassTransform()
void DrawPointsAndLines3D(vector< Plane3D::Point > points, TString hexcolor, Int_t marker_style, Double_t marker_size, Double_t line_size, Bool_t isPointDraw, Bool_t isLinesDraw, Bool_t isCloseLine)
void DrawBranchPoints(TTree *points_tree, TClonesArray *points_array, Int_t first_event, Int_t last_event)
Definition json.hpp:4446