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