BmnRoot 26.10.0-18-g4e3414f9
Software framework of the BM@N experiment
Loading...
Searching...
No Matches
BmnCSCStation.cxx
Go to the documentation of this file.
1#include "BmnCSCStation.h"
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)
21 , ThicknessOfModules(NULL)
22 , Modules(NULL)
23{}
24
26 Int_t iStation,
27 Double_t xpos_station,
28 Double_t ypos_station,
29 Double_t zpos_station)
30
31 : StationNumber(iStation)
32 , NModules(0)
33 , XMinStation(0.0)
34 , XMaxStation(0.0)
35 , YMinStation(0.0)
36 , YMaxStation(0.0)
37 , ZMinStation(0.0)
38 , ZMaxStation(0.0)
39 , XSize(0.0)
40 , YSize(0.0)
41 , ZSize(0.0)
42 , XPosition(xpos_station)
43 , YPosition(ypos_station)
44 , ZPosition(zpos_station)
45 , XShiftOfModules(NULL)
46 , YShiftOfModules(NULL)
47 , ZShiftOfModules(NULL)
48 , ThicknessOfModules(NULL)
49 , Modules(NULL)
50{
51 Bool_t create_status = CreateConfigurationFromXMLNode(stationNode);
52 if (!create_status) {
53 std::cerr << "Error: There are problems with creation of the configuration from XML node (in BmnCSCStation)\n";
54 }
55
56 // define station borders and sizes
58
62}
63
65{
66 for (Int_t i = 0; i < NModules; ++i) {
67 if (Modules[i]) {
68 delete Modules[i];
69 Modules[i] = NULL;
70 }
71 }
72 NModules = 0;
73
74 if (Modules) {
75 delete[] Modules;
76 Modules = NULL;
77 }
78 if (XShiftOfModules) {
79 delete[] XShiftOfModules;
80 XShiftOfModules = NULL;
81 }
82 if (YShiftOfModules) {
83 delete[] YShiftOfModules;
84 YShiftOfModules = NULL;
85 }
86 if (ZShiftOfModules) {
87 delete[] ZShiftOfModules;
88 ZShiftOfModules = NULL;
89 }
90
92 delete[] ThicknessOfModules;
93 ThicknessOfModules = NULL;
94 }
95}
96
98{
99 if (XShiftOfModules && module_num >= 0 && module_num < NModules) {
100 return XShiftOfModules[module_num];
101 } else {
102 throw(Station_Exception("Error in the function GetXShiftOfModule()"));
103 }
104}
105
107{
108 if (YShiftOfModules && module_num >= 0 && module_num < NModules) {
109 return YShiftOfModules[module_num];
110 } else {
111 throw(Station_Exception("Error in the function GetYShiftOfModule()"));
112 }
113}
114
116{
117 if (ZShiftOfModules && module_num >= 0 && module_num < NModules) {
118 return ZShiftOfModules[module_num];
119 } else {
120 throw(Station_Exception("Error in the function GetZShiftOfModule()"));
121 }
122}
123
125{
126 if (ThicknessOfModules && module_num >= 0 && module_num < NModules) {
127 return ThicknessOfModules[module_num];
128 } else {
129 throw(Station_Exception("Error in the function GetThicknessOfModule()"));
130 }
131}
132
134{
135 if (Modules && module_num >= 0 && module_num < NModules) {
136 return Modules[module_num];
137 } else {
138 throw(Station_Exception("Error in the function GetReadoutModule()"));
139 }
140}
141
143{
144 for (Int_t imodule = 0; imodule < NModules; ++imodule) {
145 Modules[imodule]->ResetModuleData();
146 }
147}
148
150 Double_t ycoord,
151 Double_t zcoord,
152 Double_t px,
153 Double_t py,
154 Double_t pz,
155 Double_t dEloss,
156 Int_t refID)
157{
158
159 Int_t module = GetPointModuleOwnership(xcoord, ycoord, zcoord);
160
161 if (module >= 0) {
162 if (Modules[module]->AddRealPointFullOne(xcoord, ycoord, zcoord, px, py, pz, dEloss, refID)) {
163 // if(Modules[module]->AddRealPointFull(xcoord, ycoord, zcoord, px, py, pz, dEloss, refID)) {
164 // if(Modules[module]->AddRealPointSimple(xcoord, ycoord, zcoord, px, py, pz, dEloss, refID)) {
165 return module;
166 } else {
167 return -1;
168 }
169 }
170 return -1;
171}
172
174{
175 Int_t points_sum = 0;
176 for (Int_t iModule = 0; iModule < NModules; iModule++) {
177 points_sum += Modules[iModule]->GetNRealPoints();
178 }
179 return points_sum;
180}
181
183{
184 for (Int_t iModule = 0; iModule < NModules; iModule++) {
185 Modules[iModule]->CalculateStripHitIntersectionPoints();
186 }
187}
188
190{
191 Int_t points_sum = 0;
192 for (Int_t iModule = 0; iModule < NModules; iModule++) {
193 points_sum += Modules[iModule]->GetNIntersectionPoints();
194 }
195 return points_sum;
196}
197
199{
200 for (Int_t imodule = 0; imodule < NModules; ++imodule) {
201 if (Modules[imodule]->IsPointInsideModule(xcoord, ycoord, zcoord))
202 return imodule;
203 }
204
205 return -1;
206}
207
209{
210 XMinStation = 1.0E+10;
211 XMaxStation = -1.0E+10;
212 YMinStation = 1.0E+10;
213 YMaxStation = -1.0E+10;
214 ZMinStation = 1.0E+10;
215 ZMaxStation = -1.0E+10;
216
217 for (Int_t i = 0; i < NModules; ++i) {
218 if (Modules[i]->GetXMinModule() < XMinStation)
219 XMinStation = Modules[i]->GetXMinModule();
220 if (Modules[i]->GetXMaxModule() > XMaxStation)
221 XMaxStation = Modules[i]->GetXMaxModule();
222 if (Modules[i]->GetYMinModule() < YMinStation)
223 YMinStation = Modules[i]->GetYMinModule();
224 if (Modules[i]->GetYMaxModule() > YMaxStation)
225 YMaxStation = Modules[i]->GetYMaxModule();
226
227 Double_t zstart = Modules[i]->GetZStartModulePosition();
228 Double_t zend = Modules[i]->GetZStartModulePosition() + Modules[i]->GetModuleThickness();
229 if (zstart < ZMinStation)
230 ZMinStation = zstart;
231 if (zend > ZMaxStation)
232 ZMaxStation = zend;
233 }
234}
235
237{
239
244
246
247 // default values
248 for (Int_t i = 0; i < NModules; ++i) {
249 Modules[i] = 0; // zero-pointer
250 XShiftOfModules[i] = 0.0;
251 YShiftOfModules[i] = 0.0;
252 ZShiftOfModules[i] = 0.0;
253
254 ThicknessOfModules[i] = 0.76;
255 }
256
257 node = node->GetChildren();
258 Int_t currentModuleNum = 0;
259 while (node) {
260 if (strcmp(node->GetNodeName(), "Module") == 0) {
261 Bool_t parse_status = ParseModule(node, currentModuleNum);
262 if (!parse_status)
263 return false;
264 currentModuleNum++;
265 }
266 node = node->GetNextNode();
267 }
268
269 return true;
270}
271
273{
274 Int_t module_cnt = 0;
275 node = node->GetChildren();
276 while (node) {
277 if (strcmp(node->GetNodeName(), "Module") == 0) {
278 module_cnt++;
279 }
280 node = node->GetNextNode();
281 }
282 return module_cnt;
283}
284
286{
287
288 if (node->HasAttributes()) {
289 TList* attrList = node->GetAttributes();
290 TXMLAttr* attr = 0;
291 TIter next(attrList);
292
293 while ((attr = (TXMLAttr*)next()) != nullptr) {
294 if (strcmp(attr->GetName(), "xShift") == 0) {
295 XShiftOfModules[iModule] = -atof(attr->GetValue()); // inverted
296 }
297 if (strcmp(attr->GetName(), "yShift") == 0) {
298 YShiftOfModules[iModule] = atof(attr->GetValue());
299 }
300 if (strcmp(attr->GetName(), "zShift") == 0) {
301 ZShiftOfModules[iModule] = atof(attr->GetValue());
302 }
303
304 if (strcmp(attr->GetName(), "thickness") == 0) {
305 ThicknessOfModules[iModule] = atof(attr->GetValue());
306 }
307 }
308 }
309
310 Modules[iModule] = new BmnCSCModule(ZPosition + ZShiftOfModules[iModule], ThicknessOfModules[iModule]);
311
312 // Layers
313 node = node->GetChildren();
314 Int_t currentLayerNum = 0;
315 while (node) {
316 if (strcmp(node->GetNodeName(), "Layer") == 0) {
317 Modules[iModule]->AddStripLayer(ParseLayer(node, currentLayerNum, iModule));
318 currentLayerNum++;
319 }
320 node = node->GetNextNode();
321 }
322
323 return true;
324}
325
327{
328 Int_t zone_number; // id-number of a zone in the module (e.g. big or small)
329 StripLayerType layer_type;
330 Double_t adeg; // strip angle (positive value in degrees is clockwise from vertical)
331 Double_t pitch;
332 Double_t xsize, ysize, xorig, yorig;
333 StripNumberingDirection strip_direction;
334 Double_t lx_border, ly_border; // left border
335 Double_t rx_border, ry_border; // right border
336
337 if (node->HasAttributes()) {
338 TList* attrList = node->GetAttributes();
339 TXMLAttr* attr = 0;
340 TIter next(attrList);
341
342 while ((attr = (TXMLAttr*)next()) != nullptr) {
343 if (strcmp(attr->GetName(), "zoneNumber") == 0) {
344 zone_number = atoi(attr->GetValue());
345 }
346 if (strcmp(attr->GetName(), "type") == 0) {
347 if (strcmp(attr->GetValue(), "lower") == 0) {
348 layer_type = LowerStripLayer;
349 }
350 if (strcmp(attr->GetValue(), "upper") == 0) {
351 layer_type = UpperStripLayer;
352 }
353 }
354 if (strcmp(attr->GetName(), "stripAngle") == 0) {
355 adeg = atof(attr->GetValue());
356 }
357 if (strcmp(attr->GetName(), "pitch") == 0) {
358 pitch = atof(attr->GetValue());
359 }
360 if (strcmp(attr->GetName(), "xorig") == 0) {
361 xorig = -atof(attr->GetValue()); // inverted
362 }
363 if (strcmp(attr->GetName(), "yorig") == 0) {
364 yorig = atof(attr->GetValue());
365 }
366 if (strcmp(attr->GetName(), "xsize") == 0) {
367 xsize = atof(attr->GetValue());
368 }
369 if (strcmp(attr->GetName(), "ysize") == 0) {
370 ysize = atof(attr->GetValue());
371 }
372 if (strcmp(attr->GetName(), "stripDirection") == 0) {
373 if (strcmp(attr->GetValue(), "LeftToRight") == 0) {
374 strip_direction = LeftToRight;
375 }
376 if (strcmp(attr->GetValue(), "RightToLeft") == 0) {
377 strip_direction = RightToLeft;
378 }
379 }
380 if (strcmp(attr->GetName(), "lxborder") == 0) {
381 lx_border = -atof(attr->GetValue()); // inverted
382 }
383 if (strcmp(attr->GetName(), "lyborder") == 0) {
384 ly_border = atof(attr->GetValue());
385 }
386 if (strcmp(attr->GetName(), "rxborder") == 0) {
387 rx_border = -atof(attr->GetValue()); // inverted
388 }
389 if (strcmp(attr->GetName(), "ryborder") == 0) {
390 ry_border = atof(attr->GetValue());
391 }
392 }
393 }
394
395 BmnCSCLayer layer(zone_number, layer_type, xsize, ysize, XShiftOfModules[iModule] + XPosition + xorig,
396 YShiftOfModules[iModule] + YPosition + yorig, pitch, adeg);
397
398 layer.SetStripNumberingOrder(strip_direction);
399
401 XShiftOfModules[iModule] + XPosition + lx_border, YShiftOfModules[iModule] + YPosition + ly_border,
402 XShiftOfModules[iModule] + XPosition + rx_border, YShiftOfModules[iModule] + YPosition + ry_border);
403
404 // Dead zones
405 node = node->GetChildren();
406 Int_t currentDeadZoneNum = 0;
407 while (node) {
408 if (strcmp(node->GetNodeName(), "DeadZone") == 0) {
409 layer.AddDeadZone(ParseDeadZone(node, iModule));
410 currentDeadZoneNum++;
411 }
412 node = node->GetNextNode();
413 }
414
415 return layer;
416}
417
419{
420 DeadZoneOfStripLayer dead_zone;
421
422 Int_t n_dead_points = CountDeadZonePoints(node);
423 Double_t* xpoints = new Double_t[n_dead_points];
424 Double_t* ypoints = new Double_t[n_dead_points];
425
426 // Dead points
427 node = node->GetChildren();
428 Int_t currentDeadPointNum = 0;
429 while (node) {
430 if (strcmp(node->GetNodeName(), "DeadPoint") == 0) {
431
432 if (node->HasAttributes()) {
433 TList* attrList = node->GetAttributes();
434 TXMLAttr* attr = 0;
435 TIter next(attrList);
436
437 while ((attr = (TXMLAttr*)next()) != nullptr) {
438 if (strcmp(attr->GetName(), "x") == 0) {
439 xpoints[currentDeadPointNum] =
440 -atof(attr->GetValue()) + XShiftOfModules[iModule] + XPosition; // inverted
441 }
442 if (strcmp(attr->GetName(), "y") == 0) {
443 ypoints[currentDeadPointNum] = atof(attr->GetValue()) + YShiftOfModules[iModule] + YPosition;
444 }
445 }
446 }
447
448 currentDeadPointNum++;
449 }
450 node = node->GetNextNode();
451 }
452
453 dead_zone.SetDeadZone(n_dead_points, xpoints, ypoints);
454
455 delete[] xpoints;
456 delete[] ypoints;
457
458 return dead_zone;
459}
460
462{
463 Int_t dead_point_cnt = 0;
464 node = node->GetChildren();
465 while (node) {
466 if (strcmp(node->GetNodeName(), "DeadPoint") == 0) {
467 dead_point_cnt++;
468 }
469 node = node->GetNextNode();
470 }
471 return dead_point_cnt;
472}
int i
Definition P4_F32vec4.h:22
bool Bool_t
int Int_t
double Double_t
@ RightToLeft
@ LeftToRight
@ UpperStripLayer
@ LowerStripLayer
Bool_t AddDeadZone(Int_t n_points, Double_t *x_points, Double_t *y_points)
Bool_t SetStripNumberingOrder(StripNumberingDirection strip_direction)
Bool_t SetStripNumberingBorders(Double_t x_left, Double_t y_left, Double_t x_right, Double_t y_right)
Double_t ZMaxStation
BmnCSCModule ** Modules
Double_t * YShiftOfModules
Double_t ZMinStation
Bool_t ParseModule(TXMLNode *node, Int_t iModule)
Double_t GetZShiftOfModule(Int_t module_num)
DeadZoneOfStripLayer ParseDeadZone(TXMLNode *node, Int_t iModule)
Double_t GetYShiftOfModule(Int_t module_num)
Double_t * ZShiftOfModules
Int_t CountNAddedToStationPoints()
Int_t CountNProcessedPointInStation()
Double_t XPosition
void ProcessPointsInStation()
Double_t XMaxStation
Double_t GetXShiftOfModule(Int_t module_num)
Int_t CountDeadZonePoints(TXMLNode *node)
Double_t GetThicknessOfModule(Int_t module_num)
Double_t YMaxStation
virtual ~BmnCSCStation()
Double_t * ThicknessOfModules
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)
Int_t GetPointModuleOwnership(Double_t xcoord, Double_t ycoord, Double_t zcoord)
BmnCSCModule * GetModule(Int_t module_num)
Double_t * XShiftOfModules
Int_t CountNumberOfModules(TXMLNode *node)
void DefineStationBorders()
BmnCSCLayer ParseLayer(TXMLNode *node, Int_t iLayer, Int_t iModule)
Double_t ZPosition
Double_t YMinStation
Double_t XMinStation
Double_t YPosition
Bool_t CreateConfigurationFromXMLNode(TXMLNode *node)
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