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