BmnRoot
Loading...
Searching...
No Matches
BmnGemStripStation.cxx
Go to the documentation of this file.
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 , DriftGapThicknessOfModules(NULL)
22 , FTransfGapThicknessOfModules(NULL)
23 , STransfGapThicknessOfModules(NULL)
24 , InductionGapThicknessOfModules(NULL)
25 , BeamHoleRadius(0.0)
26 , Modules(NULL)
27{}
28
30 Int_t iStation,
31 Double_t xpos_station,
32 Double_t ypos_station,
33 Double_t zpos_station,
34 Double_t beamradius)
35
36 : StationNumber(iStation)
37 , NModules(0)
38 , XMinStation(0.0)
39 , XMaxStation(0.0)
40 , YMinStation(0.0)
41 , YMaxStation(0.0)
42 , ZMinStation(0.0)
43 , ZMaxStation(0.0)
44 , XSize(0.0)
45 , YSize(0.0)
46 , ZSize(0.0)
47 , XPosition(xpos_station)
48 , YPosition(ypos_station)
49 , ZPosition(zpos_station)
50 , XShiftOfModules(NULL)
51 , YShiftOfModules(NULL)
52 , ZShiftOfModules(NULL)
53 , DriftGapThicknessOfModules(NULL)
54 , FTransfGapThicknessOfModules(NULL)
55 , STransfGapThicknessOfModules(NULL)
56 , InductionGapThicknessOfModules(NULL)
57 , BeamHoleRadius(beamradius)
58 , Modules(NULL)
59{
60
61 Bool_t create_status = CreateConfigurationFromXMLNode(stationNode);
62 if (!create_status) {
63 std::cerr
64 << "Error: There are problems with creation of the configuration from XML node (in BmnGemStripStation)\n";
65 }
66
67 // define station borders and sizes
69
73}
74
76{
77 for (Int_t i = 0; i < NModules; ++i) {
78 if (Modules[i]) {
79 delete Modules[i];
80 Modules[i] = NULL;
81 }
82 }
83 NModules = 0;
84
85 if (Modules) {
86 delete[] Modules;
87 Modules = NULL;
88 }
89 if (XShiftOfModules) {
90 delete[] XShiftOfModules;
91 XShiftOfModules = NULL;
92 }
93 if (YShiftOfModules) {
94 delete[] YShiftOfModules;
95 YShiftOfModules = NULL;
96 }
97 if (ZShiftOfModules) {
98 delete[] ZShiftOfModules;
99 ZShiftOfModules = NULL;
100 }
101
105 }
109 }
113 }
117 }
118}
119
121{
122 if (XShiftOfModules && module_num >= 0 && module_num < NModules) {
123 return XShiftOfModules[module_num];
124 } else {
125 throw(Station_Exception("Error in the function GetXShiftOfModule()"));
126 }
127}
128
130{
131 if (YShiftOfModules && module_num >= 0 && module_num < NModules) {
132 return YShiftOfModules[module_num];
133 } else {
134 throw(Station_Exception("Error in the function GetYShiftOfModule()"));
135 }
136}
137
139{
140 if (ZShiftOfModules && module_num >= 0 && module_num < NModules) {
141 return ZShiftOfModules[module_num];
142 } else {
143 throw(Station_Exception("Error in the function GetZShiftOfModule()"));
144 }
145}
146
148{
149 if (DriftGapThicknessOfModules && module_num >= 0 && module_num < NModules) {
150 return DriftGapThicknessOfModules[module_num];
151 } else {
152 throw(Station_Exception("Error in the function GetDriftGapThicknessOfModule()"));
153 }
154}
155
157{
158 if (FTransfGapThicknessOfModules && module_num >= 0 && module_num < NModules) {
159 return FTransfGapThicknessOfModules[module_num];
160 } else {
161 throw(Station_Exception("Error in the function GetFTransfGapThicknessOfModule()"));
162 }
163}
164
166{
167 if (STransfGapThicknessOfModules && module_num >= 0 && module_num < NModules) {
168 return STransfGapThicknessOfModules[module_num];
169 } else {
170 throw(Station_Exception("Error in the function GetSTransfGapThicknessOfModule()"));
171 }
172}
173
175{
176 if (InductionGapThicknessOfModules && module_num >= 0 && module_num < NModules) {
177 return InductionGapThicknessOfModules[module_num];
178 } else {
179 throw(Station_Exception("Error in the function GetInductionGapThicknessOfModule()"));
180 }
181}
182
184{
185 if (Modules && module_num >= 0 && module_num < NModules) {
186 return Modules[module_num];
187 } else {
188 throw(Station_Exception("Error in the function GetReadoutModule()"));
189 }
190}
191
193{
194 for (Int_t imodule = 0; imodule < NModules; ++imodule) {
195 Modules[imodule]->ResetModuleData();
196 }
197}
198
200 Double_t ycoord,
201 Double_t zcoord,
202 Double_t px,
203 Double_t py,
204 Double_t pz,
205 Double_t dEloss,
206 Int_t refID)
207{
208
209 Int_t module = GetPointModuleOwnership(xcoord, ycoord, zcoord);
210
211 if (module >= 0) {
212 // if(ReadoutModules[module]->AddRealPointFullOne(xcoord, ycoord, zcoord, dEloss, refID)) {
213 if (Modules[module]->AddRealPointFull(xcoord, ycoord, zcoord, px, py, pz, dEloss, refID)) {
214 // if(Modules[module]->AddRealPointSimple(xcoord, ycoord, zcoord, px, py, pz, dEloss, refID)) {
215 return module;
216 } else {
217 return -1;
218 }
219 }
220 return -1;
221}
222
224{
225 Int_t points_sum = 0;
226 for (Int_t iModule = 0; iModule < NModules; iModule++) {
227 points_sum += Modules[iModule]->GetNRealPoints();
228 }
229 return points_sum;
230}
231
233{
234 for (Int_t iModule = 0; iModule < NModules; iModule++) {
236 }
237}
238
240{
241 Int_t points_sum = 0;
242 for (Int_t iModule = 0; iModule < NModules; iModule++) {
243 points_sum += Modules[iModule]->GetNIntersectionPoints();
244 }
245 return points_sum;
246}
247
248Int_t BmnGemStripStation::GetPointModuleOwnership(Double_t xcoord, Double_t ycoord, Double_t zcoord)
249{
250 for (Int_t imodule = 0; imodule < NModules; ++imodule) {
251 if (Modules[imodule]->IsPointInsideModule(xcoord, ycoord, zcoord))
252 return imodule;
253 }
254
255 return -1;
256}
257
259{
260 XMinStation = 1.0E+10;
261 XMaxStation = -1.0E+10;
262 YMinStation = 1.0E+10;
263 YMaxStation = -1.0E+10;
264 ZMinStation = 1.0E+10;
265 ZMaxStation = -1.0E+10;
266
267 for (Int_t i = 0; i < NModules; ++i) {
268 if (Modules[i]->GetXMinModule() < XMinStation)
270 if (Modules[i]->GetXMaxModule() > XMaxStation)
272 if (Modules[i]->GetYMinModule() < YMinStation)
274 if (Modules[i]->GetYMaxModule() > YMaxStation)
276
277 Double_t zstart = Modules[i]->GetZStartModulePosition();
279 if (zstart < ZMinStation)
280 ZMinStation = zstart;
281 if (zend > ZMaxStation)
282 ZMaxStation = zend;
283 }
284}
285
286Bool_t BmnGemStripStation::CreateConfigurationFromXMLNode(TXMLNode* node)
287{
288 NModules = CountNumberOfModules(node);
289
291 XShiftOfModules = new Double_t[NModules];
292 YShiftOfModules = new Double_t[NModules];
293 ZShiftOfModules = new Double_t[NModules];
294
295 DriftGapThicknessOfModules = new Double_t[NModules];
299
300 // default values
301 for (Int_t i = 0; i < NModules; ++i) {
302 Modules[i] = 0; // zero-pointer
303 XShiftOfModules[i] = 0.0;
304 YShiftOfModules[i] = 0.0;
305 ZShiftOfModules[i] = 0.0;
306
311 }
312
313 node = node->GetChildren();
314 Int_t currentModuleNum = 0;
315 while (node) {
316 if (strcmp(node->GetNodeName(), "Module") == 0) {
317 Bool_t parse_status = ParseModule(node, currentModuleNum);
318 if (!parse_status)
319 return false;
320 currentModuleNum++;
321 }
322 node = node->GetNextNode();
323 }
324
325 return true;
326}
327
328Int_t BmnGemStripStation::CountNumberOfModules(TXMLNode* node)
329{
330 Int_t module_cnt = 0;
331 node = node->GetChildren();
332 while (node) {
333 if (strcmp(node->GetNodeName(), "Module") == 0) {
334 module_cnt++;
335 }
336 node = node->GetNextNode();
337 }
338 return module_cnt;
339}
340
341Bool_t BmnGemStripStation::ParseModule(TXMLNode* node, Int_t iModule)
342{
343
344 ElectronDriftDirectionInModule edrift_direction = ForwardZAxisEDrift; // default
345
346 if (node->HasAttributes()) {
347 TList* attrList = node->GetAttributes();
348 TXMLAttr* attr = 0;
349 TIter next(attrList);
350
351 while ((attr = (TXMLAttr*)next()) != nullptr) {
352 if (strcmp(attr->GetName(), "xShift") == 0) {
353 XShiftOfModules[iModule] = -atof(attr->GetValue()); // inverted
354 }
355 if (strcmp(attr->GetName(), "yShift") == 0) {
356 YShiftOfModules[iModule] = atof(attr->GetValue());
357 }
358 if (strcmp(attr->GetName(), "zShift") == 0) {
359 ZShiftOfModules[iModule] = atof(attr->GetValue());
360 }
361 if (strcmp(attr->GetName(), "driftDirection") == 0) {
362 if (strcmp(attr->GetValue(), "forward") == 0) {
363 edrift_direction = ForwardZAxisEDrift;
364 }
365 if (strcmp(attr->GetValue(), "backward") == 0) {
366 edrift_direction = BackwardZAxisEDrift;
367 }
368 }
369
370 if (strcmp(attr->GetName(), "gap_drift_thick") == 0) {
371 DriftGapThicknessOfModules[iModule] = atof(attr->GetValue());
372 }
373 if (strcmp(attr->GetName(), "gap_ftransf_thick") == 0) {
374 FTransfGapThicknessOfModules[iModule] = atof(attr->GetValue());
375 }
376 if (strcmp(attr->GetName(), "gap_stransf_thick") == 0) {
377 STransfGapThicknessOfModules[iModule] = atof(attr->GetValue());
378 }
379 if (strcmp(attr->GetName(), "gap_induct_thick") == 0) {
380 InductionGapThicknessOfModules[iModule] = atof(attr->GetValue());
381 }
382 }
383 }
384
385 Modules[iModule] =
386 new BmnGemStripModule(ZPosition + ZShiftOfModules[iModule], edrift_direction,
389
390 // Layers
391 node = node->GetChildren();
392 Int_t currentLayerNum = 0;
393 while (node) {
394 if (strcmp(node->GetNodeName(), "Layer") == 0) {
395 Modules[iModule]->AddStripLayer(ParseLayer(node, currentLayerNum, iModule));
396 currentLayerNum++;
397 }
398 node = node->GetNextNode();
399 }
400
401 return true;
402}
403
404BmnGemStripLayer BmnGemStripStation::ParseLayer(TXMLNode* node, Int_t iLayer, Int_t iModule)
405{
406 Int_t zone_number; // id-number of a zone in the module (e.g. big or small)
407 StripLayerType layer_type;
408 Double_t adeg; // strip angle (positive value in degrees is clockwise from vertical)
409 Double_t pitch;
410 Double_t xsize, ysize, xorig, yorig;
411 StripNumberingDirection strip_direction;
412 StripBorderPoint left_border, right_border;
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(), "zoneNumber") == 0) {
421 zone_number = atoi(attr->GetValue());
422 }
423 if (strcmp(attr->GetName(), "type") == 0) {
424 if (strcmp(attr->GetValue(), "lower") == 0) {
425 layer_type = LowerStripLayer;
426 }
427 if (strcmp(attr->GetValue(), "upper") == 0) {
428 layer_type = UpperStripLayer;
429 }
430 }
431 if (strcmp(attr->GetName(), "stripAngle") == 0) {
432 adeg = atof(attr->GetValue());
433 }
434 if (strcmp(attr->GetName(), "pitch") == 0) {
435 pitch = atof(attr->GetValue());
436 }
437 if (strcmp(attr->GetName(), "xorig") == 0) {
438 xorig = -atof(attr->GetValue()); // inverted
439 }
440 if (strcmp(attr->GetName(), "yorig") == 0) {
441 yorig = atof(attr->GetValue());
442 }
443 if (strcmp(attr->GetName(), "xsize") == 0) {
444 xsize = atof(attr->GetValue());
445 }
446 if (strcmp(attr->GetName(), "ysize") == 0) {
447 ysize = atof(attr->GetValue());
448 }
449 if (strcmp(attr->GetName(), "stripDirection") == 0) {
450 if (strcmp(attr->GetValue(), "LeftToRight") == 0) {
451 strip_direction = LeftToRight;
452 }
453 if (strcmp(attr->GetValue(), "RightToLeft") == 0) {
454 strip_direction = RightToLeft;
455 }
456 }
457 if (strcmp(attr->GetName(), "lborder") == 0) {
458 if (strcmp(attr->GetValue(), "LeftTop") == 0) {
459 left_border = LeftTop;
460 }
461 if (strcmp(attr->GetValue(), "LeftBottom") == 0) {
462 left_border = LeftBottom;
463 }
464 }
465 if (strcmp(attr->GetName(), "rborder") == 0) {
466 if (strcmp(attr->GetValue(), "RightTop") == 0) {
467 right_border = RightTop;
468 }
469 if (strcmp(attr->GetValue(), "RightBottom") == 0) {
470 right_border = RightBottom;
471 }
472 }
473 }
474 }
475
476 BmnGemStripLayer layer(zone_number, layer_type, xsize, ysize, XShiftOfModules[iModule] + XPosition + xorig,
477 YShiftOfModules[iModule] + YPosition + yorig, pitch, adeg);
478
479 layer.SetStripNumberingOrder(strip_direction);
480 layer.SetStripNumberingBorders(left_border, right_border);
481
482 // Dead zones
483 node = node->GetChildren();
484 Int_t currentDeadZoneNum = 0;
485 while (node) {
486 if (strcmp(node->GetNodeName(), "DeadZone") == 0) {
487 layer.AddDeadZone(ParseDeadZone(node, iModule));
488 currentDeadZoneNum++;
489 }
490 node = node->GetNextNode();
491 }
492
493 return layer;
494}
495
496DeadZoneOfStripLayer BmnGemStripStation::ParseDeadZone(TXMLNode* node, Int_t iModule)
497{
498 DeadZoneOfStripLayer dead_zone;
499
500 Int_t n_dead_points = CountDeadZonePoints(node);
501 Double_t* xpoints = new Double_t[n_dead_points];
502 Double_t* ypoints = new Double_t[n_dead_points];
503
504 // Dead points
505 node = node->GetChildren();
506 Int_t currentDeadPointNum = 0;
507 while (node) {
508 if (strcmp(node->GetNodeName(), "DeadPoint") == 0) {
509
510 if (node->HasAttributes()) {
511 TList* attrList = node->GetAttributes();
512 TXMLAttr* attr = 0;
513 TIter next(attrList);
514
515 while ((attr = (TXMLAttr*)next()) != nullptr) {
516 if (strcmp(attr->GetName(), "x") == 0) {
517 xpoints[currentDeadPointNum] =
518 -atof(attr->GetValue()) + XShiftOfModules[iModule] + XPosition; // inverted
519 }
520 if (strcmp(attr->GetName(), "y") == 0) {
521 ypoints[currentDeadPointNum] = atof(attr->GetValue()) + YShiftOfModules[iModule] + YPosition;
522 }
523 }
524 }
525
526 currentDeadPointNum++;
527 }
528 node = node->GetNextNode();
529 }
530
531 dead_zone.SetDeadZone(n_dead_points, xpoints, ypoints);
532
533 delete[] xpoints;
534 delete[] ypoints;
535
536 return dead_zone;
537}
538
539Int_t BmnGemStripStation::CountDeadZonePoints(TXMLNode* node)
540{
541 Int_t dead_point_cnt = 0;
542 node = node->GetChildren();
543 while (node) {
544 if (strcmp(node->GetNodeName(), "DeadPoint") == 0) {
545 dead_point_cnt++;
546 }
547 node = node->GetNextNode();
548 }
549 return dead_point_cnt;
550}
int i
Definition P4_F32vec4.h:22
StripBorderPoint
@ LeftTop
@ RightBottom
@ LeftBottom
@ RightTop
StripNumberingDirection
@ RightToLeft
@ LeftToRight
StripLayerType
@ UpperStripLayer
@ LowerStripLayer
Double_t GetModuleThickness()
Double_t GetZStartModulePosition()
void AddStripLayer(BmnGemStripLayer strip_layer)
Double_t * STransfGapThicknessOfModules
BmnGemStripModule ** Modules
Double_t * FTransfGapThicknessOfModules
Double_t GetDriftGapThicknessOfModule(Int_t module_num)
Double_t GetXShiftOfModule(Int_t module_num)
Double_t GetZShiftOfModule(Int_t module_num)
BmnGemStripModule * GetModule(Int_t module_num)
Double_t GetInductionGapThicknessOfModule(Int_t module_num)
Double_t GetSTransfGapThicknessOfModule(Int_t module_num)
Double_t * DriftGapThicknessOfModules
Double_t * InductionGapThicknessOfModules
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)
Double_t GetFTransfGapThicknessOfModule(Int_t module_num)
Double_t GetYShiftOfModule(Int_t module_num)
Bool_t SetDeadZone(Int_t n_points, Double_t *xpoints, Double_t *ypoints)
ElectronDriftDirectionInModule
@ BackwardZAxisEDrift
@ ForwardZAxisEDrift