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