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