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