BmnRoot 26.10.0-18-g4e3414f9
Software framework of the BM@N experiment
Loading...
Searching...
No Matches
BmnGemStripStation.cxx
Go to the documentation of this file.
2
5 , NModules(0)
6 , XMinStation(0.0)
7 , XMaxStation(0.0)
8 , YMinStation(0.0)
9 , YMaxStation(0.0)
10 , ZMinStation(0.0)
11 , ZMaxStation(0.0)
12 , XSize(0.0)
13 , YSize(0.0)
14 , ZSize(0.0)
15 , XPosition(0.0)
16 , YPosition(0.0)
17 , ZPosition(0.0)
18 , XShiftOfModules(NULL)
19 , YShiftOfModules(NULL)
20 , ZShiftOfModules(NULL)
25 , BeamHoleRadius(0.0)
26 , Modules(NULL)
27{}
28
30 Int_t iStation,
31 Double_t xpos_station,
32 Double_t ypos_station,
33 Double_t zpos_station,
34 Double_t beamradius)
35
36 : StationNumber(iStation)
37 , NModules(0)
38 , XMinStation(0.0)
39 , XMaxStation(0.0)
40 , YMinStation(0.0)
41 , YMaxStation(0.0)
42 , ZMinStation(0.0)
43 , ZMaxStation(0.0)
44 , XSize(0.0)
45 , YSize(0.0)
46 , ZSize(0.0)
47 , XPosition(xpos_station)
48 , YPosition(ypos_station)
49 , ZPosition(zpos_station)
50 , XShiftOfModules(NULL)
51 , YShiftOfModules(NULL)
52 , ZShiftOfModules(NULL)
57 , BeamHoleRadius(beamradius)
58 , Modules(NULL)
59{
60
61 Bool_t create_status = CreateConfigurationFromXMLNode(stationNode);
62 if (!create_status) {
63 std::cerr
64 << "Error: There are problems with creation of the configuration from XML node (in BmnGemStripStation)\n";
65 }
66
67 // define station borders and sizes
69
73}
74
76{
77 for (Int_t i = 0; i < NModules; ++i) {
78 if (Modules[i]) {
79 delete Modules[i];
80 Modules[i] = NULL;
81 }
82 }
83 NModules = 0;
84
85 if (Modules) {
86 delete[] Modules;
87 Modules = NULL;
88 }
89 if (XShiftOfModules) {
90 delete[] XShiftOfModules;
91 XShiftOfModules = NULL;
92 }
93 if (YShiftOfModules) {
94 delete[] YShiftOfModules;
95 YShiftOfModules = NULL;
96 }
97 if (ZShiftOfModules) {
98 delete[] ZShiftOfModules;
99 ZShiftOfModules = NULL;
100 }
101
105 }
109 }
113 }
117 }
118}
119
121{
122 if (XShiftOfModules && module_num >= 0 && module_num < NModules) {
123 return XShiftOfModules[module_num];
124 } else {
125 throw(Station_Exception("Error in the function GetXShiftOfModule()"));
126 }
127}
128
130{
131 if (YShiftOfModules && module_num >= 0 && module_num < NModules) {
132 return YShiftOfModules[module_num];
133 } else {
134 throw(Station_Exception("Error in the function GetYShiftOfModule()"));
135 }
136}
137
139{
140 if (ZShiftOfModules && module_num >= 0 && module_num < NModules) {
141 return ZShiftOfModules[module_num];
142 } else {
143 throw(Station_Exception("Error in the function GetZShiftOfModule()"));
144 }
145}
146
148{
149 if (DriftGapThicknessOfModules && module_num >= 0 && module_num < NModules) {
150 return DriftGapThicknessOfModules[module_num];
151 } else {
152 throw(Station_Exception("Error in the function GetDriftGapThicknessOfModule()"));
153 }
154}
155
157{
158 if (FTransfGapThicknessOfModules && module_num >= 0 && module_num < NModules) {
159 return FTransfGapThicknessOfModules[module_num];
160 } else {
161 throw(Station_Exception("Error in the function GetFTransfGapThicknessOfModule()"));
162 }
163}
164
166{
167 if (STransfGapThicknessOfModules && module_num >= 0 && module_num < NModules) {
168 return STransfGapThicknessOfModules[module_num];
169 } else {
170 throw(Station_Exception("Error in the function GetSTransfGapThicknessOfModule()"));
171 }
172}
173
175{
176 if (InductionGapThicknessOfModules && module_num >= 0 && module_num < NModules) {
177 return InductionGapThicknessOfModules[module_num];
178 } else {
179 throw(Station_Exception("Error in the function GetInductionGapThicknessOfModule()"));
180 }
181}
182
184{
185 if (Modules && module_num >= 0 && module_num < NModules) {
186 return Modules[module_num];
187 } else {
188 throw(Station_Exception("Error in the function GetReadoutModule()"));
189 }
190}
191
193{
194 for (Int_t imodule = 0; imodule < NModules; ++imodule) {
195 Modules[imodule]->ResetModuleData();
196 }
197}
198
200 Double_t ycoord,
201 Double_t zcoord,
202 Double_t px,
203 Double_t py,
204 Double_t pz,
205 Double_t dEloss,
206 Int_t refID)
207{
208
209 Int_t module = GetPointModuleOwnership(xcoord, ycoord, zcoord);
210
211 if (module >= 0) {
212 if (Modules[module]->AddRealPoint(xcoord, ycoord, zcoord, px, py, pz, dEloss, refID)) {
213 return module;
214 } else {
215 return -1;
216 }
217 }
218 return -1;
219}
220
222{
223 Int_t points_sum = 0;
224 for (Int_t iModule = 0; iModule < NModules; iModule++) {
225 points_sum += Modules[iModule]->GetNRealPoints();
226 }
227 return points_sum;
228}
229
231{
232 for (Int_t iModule = 0; iModule < NModules; iModule++) {
233 Modules[iModule]->CalculateStripHitIntersectionPoints();
234 }
235}
236
238{
239 Int_t points_sum = 0;
240 for (Int_t iModule = 0; iModule < NModules; iModule++) {
241 points_sum += Modules[iModule]->GetNIntersectionPoints();
242 }
243 return points_sum;
244}
245
247{
248 for (Int_t imodule = 0; imodule < NModules; ++imodule) {
249 if (Modules[imodule]->IsPointInsideModule(xcoord, ycoord, zcoord))
250 return imodule;
251 }
252
253 return -1;
254}
255
257{
258 XMinStation = 1.0E+10;
259 XMaxStation = -1.0E+10;
260 YMinStation = 1.0E+10;
261 YMaxStation = -1.0E+10;
262 ZMinStation = 1.0E+10;
263 ZMaxStation = -1.0E+10;
264
265 for (Int_t i = 0; i < NModules; ++i) {
266 if (Modules[i]->GetXMinModule() < XMinStation)
267 XMinStation = Modules[i]->GetXMinModule();
268 if (Modules[i]->GetXMaxModule() > XMaxStation)
269 XMaxStation = Modules[i]->GetXMaxModule();
270 if (Modules[i]->GetYMinModule() < YMinStation)
271 YMinStation = Modules[i]->GetYMinModule();
272 if (Modules[i]->GetYMaxModule() > YMaxStation)
273 YMaxStation = Modules[i]->GetYMaxModule();
274
275 Double_t zstart = Modules[i]->GetZStartModulePosition();
276 Double_t zend = Modules[i]->GetZStartModulePosition() + Modules[i]->GetModuleThickness();
277 if (zstart < ZMinStation)
278 ZMinStation = zstart;
279 if (zend > ZMaxStation)
280 ZMaxStation = zend;
281 }
282}
283
285{
287
292
297
298 // default values
299 for (Int_t i = 0; i < NModules; ++i) {
300 Modules[i] = 0; // zero-pointer
301 XShiftOfModules[i] = 0.0;
302 YShiftOfModules[i] = 0.0;
303 ZShiftOfModules[i] = 0.0;
304
309 }
310
311 node = node->GetChildren();
312 Int_t currentModuleNum = 0;
313 while (node) {
314 if (strcmp(node->GetNodeName(), "Module") == 0) {
315 Bool_t parse_status = ParseModule(node, currentModuleNum);
316 if (!parse_status)
317 return false;
318 currentModuleNum++;
319 }
320 node = node->GetNextNode();
321 }
322
323 return true;
324}
325
327{
328 Int_t module_cnt = 0;
329 node = node->GetChildren();
330 while (node) {
331 if (strcmp(node->GetNodeName(), "Module") == 0) {
332 module_cnt++;
333 }
334 node = node->GetNextNode();
335 }
336 return module_cnt;
337}
338
340{
341
342 ElectronDriftDirectionInModule edrift_direction = ForwardZAxisEDrift; // default
343
344 if (node->HasAttributes()) {
345 TList* attrList = node->GetAttributes();
346 TXMLAttr* attr = 0;
347 TIter next(attrList);
348
349 while ((attr = (TXMLAttr*)next()) != nullptr) {
350 if (strcmp(attr->GetName(), "xShift") == 0) {
351 XShiftOfModules[iModule] = -atof(attr->GetValue()); // inverted
352 }
353 if (strcmp(attr->GetName(), "yShift") == 0) {
354 YShiftOfModules[iModule] = atof(attr->GetValue());
355 }
356 if (strcmp(attr->GetName(), "zShift") == 0) {
357 ZShiftOfModules[iModule] = atof(attr->GetValue());
358 }
359 if (strcmp(attr->GetName(), "driftDirection") == 0) {
360 if (strcmp(attr->GetValue(), "forward") == 0) {
361 edrift_direction = ForwardZAxisEDrift;
362 }
363 if (strcmp(attr->GetValue(), "backward") == 0) {
364 edrift_direction = BackwardZAxisEDrift;
365 }
366 }
367
368 if (strcmp(attr->GetName(), "gap_drift_thick") == 0) {
369 DriftGapThicknessOfModules[iModule] = atof(attr->GetValue());
370 }
371 if (strcmp(attr->GetName(), "gap_ftransf_thick") == 0) {
372 FTransfGapThicknessOfModules[iModule] = atof(attr->GetValue());
373 }
374 if (strcmp(attr->GetName(), "gap_stransf_thick") == 0) {
375 STransfGapThicknessOfModules[iModule] = atof(attr->GetValue());
376 }
377 if (strcmp(attr->GetName(), "gap_induct_thick") == 0) {
378 InductionGapThicknessOfModules[iModule] = atof(attr->GetValue());
379 }
380 }
381 }
382
383 Modules[iModule] =
384 new BmnGemStripModule(ZPosition + ZShiftOfModules[iModule], edrift_direction,
387
388 // Layers
389 node = node->GetChildren();
390 Int_t currentLayerNum = 0;
391 while (node) {
392 if (strcmp(node->GetNodeName(), "Layer") == 0) {
393 Modules[iModule]->AddStripLayer(ParseLayer(node, currentLayerNum, iModule));
394 currentLayerNum++;
395 }
396 node = node->GetNextNode();
397 }
398
399 return true;
400}
401
403{
404 Int_t zone_number = 0; // id-number of a zone in the module (e.g. big or small)
405 StripLayerType layer_type = LowerStripLayer;
406 Double_t adeg = 0.0; // strip angle (positive value in degrees is clockwise from vertical)
407 Double_t pitch = 0.0;
408 Double_t xsize = 0.0;
409 Double_t ysize = 0.0;
410 Double_t xorig = 0.0;
411 Double_t yorig = 0.0;
412 StripNumberingDirection strip_direction = LeftToRight;
413
414 // ENUM format for borders
415 StripBorderPoint left_border = LeftTop;
416 StripBorderPoint right_border = RightBottom;
417
418 // Coordinate format for borders
419 Bool_t useCoordinateBorders = kFALSE;
420 Double_t lx_border = 0.0;
421 Double_t ly_border = 0.0;
422 Double_t rx_border = 0.0;
423 Double_t ry_border = 0.0;
424
425 if (node->HasAttributes()) {
426 TList* attrList = node->GetAttributes();
427 TXMLAttr* attr = 0;
428 TIter next(attrList);
429
430 while ((attr = (TXMLAttr*)next()) != nullptr) {
431 if (strcmp(attr->GetName(), "zoneNumber") == 0) {
432 zone_number = atoi(attr->GetValue());
433 }
434 if (strcmp(attr->GetName(), "type") == 0) {
435 if (strcmp(attr->GetValue(), "lower") == 0) {
436 layer_type = LowerStripLayer;
437 }
438 if (strcmp(attr->GetValue(), "upper") == 0) {
439 layer_type = UpperStripLayer;
440 }
441 }
442 if (strcmp(attr->GetName(), "stripAngle") == 0) {
443 adeg = atof(attr->GetValue());
444 }
445 if (strcmp(attr->GetName(), "pitch") == 0) {
446 pitch = atof(attr->GetValue());
447 }
448 if (strcmp(attr->GetName(), "xorig") == 0) {
449 xorig = -atof(attr->GetValue()); // convert to detector system (x-inverted)
450 }
451 if (strcmp(attr->GetName(), "yorig") == 0) {
452 yorig = atof(attr->GetValue());
453 }
454 if (strcmp(attr->GetName(), "xsize") == 0) {
455 xsize = atof(attr->GetValue());
456 }
457 if (strcmp(attr->GetName(), "ysize") == 0) {
458 ysize = atof(attr->GetValue());
459 }
460 if (strcmp(attr->GetName(), "stripDirection") == 0) {
461 if (strcmp(attr->GetValue(), "LeftToRight") == 0) {
462 strip_direction = LeftToRight;
463 }
464 if (strcmp(attr->GetValue(), "RightToLeft") == 0) {
465 strip_direction = RightToLeft;
466 }
467 }
468 // ENUM format for borders
469 if (strcmp(attr->GetName(), "lborder") == 0) {
470 if (strcmp(attr->GetValue(), "LeftTop") == 0) {
471 left_border = LeftTop;
472 }
473 if (strcmp(attr->GetValue(), "LeftBottom") == 0) {
474 left_border = LeftBottom;
475 }
476 }
477 if (strcmp(attr->GetName(), "rborder") == 0) {
478 if (strcmp(attr->GetValue(), "RightTop") == 0) {
479 right_border = RightTop;
480 }
481 if (strcmp(attr->GetValue(), "RightBottom") == 0) {
482 right_border = RightBottom;
483 }
484 }
485 // Coordinate format for borders
486 if (strcmp(attr->GetName(), "lxborder") == 0) {
487 lx_border = -atof(attr->GetValue()); // convert to detector system (x-inverted)
488 useCoordinateBorders = kTRUE;
489 }
490 if (strcmp(attr->GetName(), "lyborder") == 0) {
491 ly_border = atof(attr->GetValue());
492 useCoordinateBorders = kTRUE;
493 }
494 if (strcmp(attr->GetName(), "rxborder") == 0) {
495 rx_border = -atof(attr->GetValue()); // convert to detector system (x-inverted)
496 useCoordinateBorders = kTRUE;
497 }
498 if (strcmp(attr->GetName(), "ryborder") == 0) {
499 ry_border = atof(attr->GetValue());
500 useCoordinateBorders = kTRUE;
501 }
502 }
503 }
504
505 BmnGemStripLayer layer(zone_number, layer_type, xsize, ysize, XShiftOfModules[iModule] + XPosition + xorig,
506 YShiftOfModules[iModule] + YPosition + yorig, pitch, adeg);
507
508 layer.SetStripNumberingOrder(strip_direction);
509
510 if (useCoordinateBorders) {
511 // Coordinate format
512 Double_t global_lx = XShiftOfModules[iModule] + XPosition + lx_border;
513 Double_t global_ly = YShiftOfModules[iModule] + YPosition + ly_border;
514 Double_t global_rx = XShiftOfModules[iModule] + XPosition + rx_border;
515 Double_t global_ry = YShiftOfModules[iModule] + YPosition + ry_border;
516 layer.SetStripNumberingBorders(global_lx, global_ly, global_rx, global_ry);
517 } else {
518 // ENUM format
519 layer.SetStripNumberingBorders(left_border, right_border);
520 }
521
522 // Dead zones
523 node = node->GetChildren();
524 Int_t currentDeadZoneNum = 0;
525 while (node) {
526 if (strcmp(node->GetNodeName(), "DeadZone") == 0) {
527 layer.AddDeadZone(ParseDeadZone(node, iModule));
528 currentDeadZoneNum++;
529 }
530 node = node->GetNextNode();
531 }
532
533 return layer;
534}
535
537{
538 DeadZoneOfStripLayer dead_zone;
539
540 Int_t n_dead_points = CountDeadZonePoints(node);
541 Double_t* xpoints = new Double_t[n_dead_points];
542 Double_t* ypoints = new Double_t[n_dead_points];
543
544 // Dead points
545 node = node->GetChildren();
546 Int_t currentDeadPointNum = 0;
547 while (node) {
548 if (strcmp(node->GetNodeName(), "DeadPoint") == 0) {
549
550 if (node->HasAttributes()) {
551 TList* attrList = node->GetAttributes();
552 TXMLAttr* attr = 0;
553 TIter next(attrList);
554
555 while ((attr = (TXMLAttr*)next()) != nullptr) {
556 if (strcmp(attr->GetName(), "x") == 0) {
557 xpoints[currentDeadPointNum] =
558 -atof(attr->GetValue()) + XShiftOfModules[iModule] + XPosition; // inverted
559 }
560 if (strcmp(attr->GetName(), "y") == 0) {
561 ypoints[currentDeadPointNum] = atof(attr->GetValue()) + YShiftOfModules[iModule] + YPosition;
562 }
563 }
564 }
565
566 currentDeadPointNum++;
567 }
568 node = node->GetNextNode();
569 }
570
571 dead_zone.SetDeadZone(n_dead_points, xpoints, ypoints);
572
573 delete[] xpoints;
574 delete[] ypoints;
575
576 return dead_zone;
577}
578
580{
581 Int_t dead_point_cnt = 0;
582 node = node->GetChildren();
583 while (node) {
584 if (strcmp(node->GetNodeName(), "DeadPoint") == 0) {
585 dead_point_cnt++;
586 }
587 node = node->GetNextNode();
588 }
589 return dead_point_cnt;
590}
int i
Definition P4_F32vec4.h:22
bool Bool_t
int Int_t
constexpr Bool_t kFALSE
double Double_t
constexpr Bool_t kTRUE
StripBorderPoint
@ LeftTop
@ RightBottom
@ LeftBottom
@ RightTop
@ RightToLeft
@ LeftToRight
@ UpperStripLayer
@ LowerStripLayer
Bool_t SetStripNumberingOrder(StripNumberingDirection strip_direction)
Bool_t AddDeadZone(Int_t n_points, Double_t *x_points, Double_t *y_points)
Bool_t SetStripNumberingBorders(Double_t x_left, Double_t y_left, Double_t x_right, Double_t y_right)
Int_t CountNumberOfModules(TXMLNode *node)
Double_t * STransfGapThicknessOfModules
BmnGemStripModule ** Modules
Double_t * FTransfGapThicknessOfModules
Double_t GetDriftGapThicknessOfModule(Int_t module_num)
Double_t GetXShiftOfModule(Int_t module_num)
Double_t GetZShiftOfModule(Int_t module_num)
Bool_t ParseModule(TXMLNode *node, Int_t iModule)
BmnGemStripModule * GetModule(Int_t module_num)
Double_t GetInductionGapThicknessOfModule(Int_t module_num)
Double_t GetSTransfGapThicknessOfModule(Int_t module_num)
DeadZoneOfStripLayer ParseDeadZone(TXMLNode *node, Int_t iModule)
Double_t * DriftGapThicknessOfModules
Int_t CountDeadZonePoints(TXMLNode *node)
Double_t * InductionGapThicknessOfModules
Int_t AddPointToStation(Double_t xcoord, Double_t ycoord, Double_t zcoord, Double_t px, Double_t py, Double_t pz, Double_t dEloss, Int_t refID)
Bool_t CreateConfigurationFromXMLNode(TXMLNode *node)
Int_t GetPointModuleOwnership(Double_t xcoord, Double_t ycoord, Double_t zcoord)
Double_t GetFTransfGapThicknessOfModule(Int_t module_num)
Double_t GetYShiftOfModule(Int_t module_num)
BmnGemStripLayer ParseLayer(TXMLNode *node, Int_t iLayer, Int_t iModule)
Bool_t SetDeadZone(Int_t n_points, Double_t *xpoints, Double_t *ypoints)
const char * GetValue() const
const char * GetName() const override
TList * GetAttributes()
TXMLNode * GetNextNode()
TXMLNode * GetChildren()
const char * GetNodeName() const
Bool_t HasAttributes() const
@ BackwardZAxisEDrift
@ ForwardZAxisEDrift