BmnRoot
Loading...
Searching...
No Matches
BmnSiProfStation.cxx
Go to the documentation of this file.
1#include "BmnSiProfStation.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 XShiftOfModules(NULL), YShiftOfModules(NULL), ZShiftOfModules(NULL),
11 ThicknessOfModules(NULL),
12 Modules(NULL)
13{}
14
15BmnSiProfStation::BmnSiProfStation(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 XShiftOfModules(NULL), YShiftOfModules(NULL), ZShiftOfModules(NULL),
25 ThicknessOfModules(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 BmnSiProfStation)\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
68 delete [] ThicknessOfModules;
69 ThicknessOfModules = NULL;
70 }
71}
72
73Double_t BmnSiProfStation::GetXShiftOfModule(Int_t module_num) {
74 if(XShiftOfModules && module_num >= 0 && module_num < NModules) {
75 return XShiftOfModules[module_num];
76 }
77 else {
78 throw(Station_Exception("Error in the function GetXShiftOfModule()"));
79 }
80}
81
82Double_t BmnSiProfStation::GetYShiftOfModule(Int_t module_num) {
83 if(YShiftOfModules && module_num >= 0 && module_num < NModules) {
84 return YShiftOfModules[module_num];
85 }
86 else {
87 throw(Station_Exception("Error in the function GetYShiftOfModule()"));
88 }
89}
90
91Double_t BmnSiProfStation::GetZShiftOfModule(Int_t module_num) {
92 if(ZShiftOfModules && module_num >= 0 && module_num < NModules) {
93 return ZShiftOfModules[module_num];
94 }
95 else {
96 throw(Station_Exception("Error in the function GetZShiftOfModule()"));
97 }
98}
99
100Double_t BmnSiProfStation::GetThicknessOfModule(Int_t module_num) {
101 if(ThicknessOfModules && module_num >= 0 && module_num < NModules) {
102 return ThicknessOfModules[module_num];
103 }
104 else {
105 throw(Station_Exception("Error in the function GetThicknessOfModule()"));
106 }
107}
108
110 if(Modules && module_num >= 0 && module_num < NModules) {
111 return Modules[module_num];
112 }
113 else {
114 throw(Station_Exception("Error in the function GetReadoutModule()"));
115 }
116}
117
119 for(Int_t imodule = 0; imodule < NModules; ++imodule) {
120 Modules[imodule]->ResetModuleData();
121 }
122}
123
124Int_t BmnSiProfStation::AddPointToStation(Double_t xcoord, Double_t ycoord, Double_t zcoord,
125 Double_t px, Double_t py, Double_t pz,
126 Double_t dEloss, Int_t refID) {
127
128 Int_t module = GetPointModuleOwnership(xcoord, ycoord, zcoord);
129
130 if(module >= 0) {
131 if(Modules[module]->AddRealPointFullOne(xcoord, ycoord, zcoord, px, py, pz, dEloss, refID)) {
132 //if(Modules[module]->AddRealPointFull(xcoord, ycoord, zcoord, px, py, pz, dEloss, refID)) {
133 //if(Modules[module]->AddRealPointSimple(xcoord, ycoord, zcoord, px, py, pz, dEloss, refID)) {
134 return module;
135 }
136 else {
137 return -1;
138 }
139 }
140 return -1;
141}
142
144 Int_t points_sum = 0;
145 for(Int_t iModule = 0; iModule < NModules; iModule++) {
146 points_sum += Modules[iModule]->GetNRealPoints();
147 }
148 return points_sum;
149}
150
152 for(Int_t iModule = 0; iModule < NModules; iModule++) {
154 }
155}
156
158 Int_t points_sum = 0;
159 for(Int_t iModule = 0; iModule < NModules; iModule++) {
160 points_sum += Modules[iModule]->GetNIntersectionPoints();
161 }
162 return points_sum;
163}
164
165Int_t BmnSiProfStation::GetPointModuleOwnership(Double_t xcoord, Double_t ycoord, Double_t zcoord) {
166 for(Int_t imodule = 0; imodule < NModules; ++imodule) {
167 if( Modules[imodule]->IsPointInsideModule(xcoord, ycoord, zcoord) ) return imodule;
168 }
169
170 return -1;
171}
172
174 XMinStation = 1.0E+10;
175 XMaxStation = -1.0E+10;
176 YMinStation = 1.0E+10;
177 YMaxStation = -1.0E+10;
178 ZMinStation = 1.0E+10;
179 ZMaxStation = -1.0E+10;
180
181 for(Int_t i = 0; i < NModules; ++i) {
182 if( Modules[i]->GetXMinModule() < XMinStation ) XMinStation = Modules[i]->GetXMinModule();
183 if( Modules[i]->GetXMaxModule() > XMaxStation ) XMaxStation = Modules[i]->GetXMaxModule();
184 if( Modules[i]->GetYMinModule() < YMinStation ) YMinStation = Modules[i]->GetYMinModule();
185 if( Modules[i]->GetYMaxModule() > YMaxStation ) YMaxStation = Modules[i]->GetYMaxModule();
186
187 Double_t zstart = Modules[i]->GetZStartModulePosition();
189 if( zstart < ZMinStation ) ZMinStation = zstart;
190 if( zend > ZMaxStation ) ZMaxStation = zend;
191 }
192}
193
194Bool_t BmnSiProfStation::CreateConfigurationFromXMLNode(TXMLNode *node) {
195 NModules = CountNumberOfModules(node);
196
198 XShiftOfModules = new Double_t[NModules];
199 YShiftOfModules = new Double_t[NModules];
200 ZShiftOfModules = new Double_t[NModules];
201
202 ThicknessOfModules = new Double_t[NModules];
203
204 //default values
205 for(Int_t i = 0; i < NModules; ++i) {
206 Modules[i] = 0; //zero-pointer
207 XShiftOfModules[i] = 0.0;
208 YShiftOfModules[i] = 0.0;
209 ZShiftOfModules[i] = 0.0;
210
211 ThicknessOfModules[i] = 0.76;
212 }
213
214 node = node->GetChildren();
215 Int_t currentModuleNum = 0;
216 while(node) {
217 if( strcmp(node->GetNodeName(), "Module") == 0 ) {
218 Bool_t parse_status = ParseModule(node, currentModuleNum);
219 if(!parse_status) return false;
220 currentModuleNum++;
221 }
222 node = node->GetNextNode();
223 }
224
225 return true;
226}
227
228Int_t BmnSiProfStation::CountNumberOfModules(TXMLNode *node) {
229 Int_t module_cnt = 0;
230 node = node->GetChildren();
231 while(node) {
232 if( strcmp(node->GetNodeName(), "Module") == 0 ) {
233 module_cnt++;
234 }
235 node = node->GetNextNode();
236 }
237 return module_cnt;
238}
239
240Bool_t BmnSiProfStation::ParseModule(TXMLNode *node, Int_t iModule) {
241
242 if( node->HasAttributes() ) {
243 TList *attrList = node->GetAttributes();
244 TXMLAttr *attr = 0;
245 TIter next(attrList);
246
247 while ((attr = (TXMLAttr*)next()) != nullptr)
248 {
249 if( strcmp(attr->GetName(), "xShift") == 0 ) {
250 XShiftOfModules[iModule] = -atof(attr->GetValue()); //inverted
251 }
252 if( strcmp(attr->GetName(), "yShift") == 0 ) {
253 YShiftOfModules[iModule] = atof(attr->GetValue());
254 }
255 if( strcmp(attr->GetName(), "zShift") == 0 ) {
256 ZShiftOfModules[iModule] = atof(attr->GetValue());
257 }
258
259 if( strcmp(attr->GetName(), "thickness") == 0 ) {
260 ThicknessOfModules[iModule] = atof(attr->GetValue());
261 }
262 }
263 }
264
265 Modules[iModule] = new BmnSiProfModule(ZPosition+ZShiftOfModules[iModule], ThicknessOfModules[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
281BmnSiProfLayer BmnSiProfStation::ParseLayer(TXMLNode *node, Int_t iLayer, Int_t iModule) {
282 Int_t zone_number; //id-number of a zone in the module (e.g. big or small)
283 StripLayerType layer_type;
284 Double_t adeg; //strip angle (positive value in degrees is clockwise from vertical)
285 Double_t pitch;
286 Double_t xsize, ysize, xorig, yorig;
287 StripNumberingDirection strip_direction;
288 Double_t lx_border, ly_border; //left border
289 Double_t rx_border, ry_border; //right border
290
291 if( node->HasAttributes() ) {
292 TList *attrList = node->GetAttributes();
293 TXMLAttr *attr = 0;
294 TIter next(attrList);
295
296 while ((attr = (TXMLAttr*)next()) != nullptr)
297 {
298 if( strcmp(attr->GetName(), "zoneNumber") == 0 ) {
299 zone_number = atoi(attr->GetValue());
300 }
301 if( strcmp(attr->GetName(), "type") == 0 ) {
302 if( strcmp(attr->GetValue(), "lower") == 0 ) {
303 layer_type = LowerStripLayer;
304 }
305 if( strcmp(attr->GetValue(), "upper") == 0 ) {
306 layer_type = UpperStripLayer;
307 }
308 }
309 if( strcmp(attr->GetName(), "stripAngle") == 0 ) {
310 adeg = atof(attr->GetValue());
311 }
312 if( strcmp(attr->GetName(), "pitch") == 0 ) {
313 pitch = atof(attr->GetValue());
314 }
315 if( strcmp(attr->GetName(), "xorig") == 0 ) {
316 xorig = -atof(attr->GetValue()); //inverted
317 }
318 if( strcmp(attr->GetName(), "yorig") == 0 ) {
319 yorig = atof(attr->GetValue());
320 }
321 if( strcmp(attr->GetName(), "xsize") == 0 ) {
322 xsize = atof(attr->GetValue());
323 }
324 if( strcmp(attr->GetName(), "ysize") == 0 ) {
325 ysize = atof(attr->GetValue());
326 }
327 if( strcmp(attr->GetName(), "stripDirection") == 0 ) {
328 if( strcmp(attr->GetValue(), "LeftToRight") == 0 ) {
329 strip_direction = LeftToRight;
330 }
331 if( strcmp(attr->GetValue(), "RightToLeft") == 0 ) {
332 strip_direction = RightToLeft;
333 }
334 }
335 if( strcmp(attr->GetName(), "lxborder") == 0 ) {
336 lx_border = -atof(attr->GetValue()); //inverted
337 }
338 if( strcmp(attr->GetName(), "lyborder") == 0 ) {
339 ly_border = atof(attr->GetValue());
340 }
341 if( strcmp(attr->GetName(), "rxborder") == 0 ) {
342 rx_border = -atof(attr->GetValue()); //inverted
343 }
344 if( strcmp(attr->GetName(), "ryborder") == 0 ) {
345 ry_border = atof(attr->GetValue());
346 }
347 }
348 }
349
350 BmnSiProfLayer layer(zone_number, layer_type,
351 xsize, ysize,
352 XShiftOfModules[iModule]+XPosition+xorig, YShiftOfModules[iModule]+YPosition+yorig,
353 pitch, adeg);
354
355 layer.SetStripNumberingOrder(strip_direction);
356
357 layer.SetStripNumberingBorders(XShiftOfModules[iModule]+XPosition+lx_border,
358 YShiftOfModules[iModule]+YPosition+ly_border,
359 XShiftOfModules[iModule]+XPosition+rx_border,
360 YShiftOfModules[iModule]+YPosition+ry_border);
361
362 //Dead zones
363 node = node->GetChildren();
364 Int_t currentDeadZoneNum = 0;
365 while(node) {
366 if( strcmp(node->GetNodeName(), "DeadZone") == 0 ) {
367 layer.AddDeadZone(ParseDeadZone(node, iModule));
368 currentDeadZoneNum++;
369 }
370 node = node->GetNextNode();
371 }
372
373 return layer;
374}
375
376DeadZoneOfStripLayer BmnSiProfStation::ParseDeadZone(TXMLNode *node, Int_t iModule) {
377 DeadZoneOfStripLayer dead_zone;
378
379 Int_t n_dead_points = CountDeadZonePoints(node);
380 Double_t *xpoints = new Double_t[n_dead_points];
381 Double_t *ypoints = new Double_t[n_dead_points];
382
383 //Dead points
384 node = node->GetChildren();
385 Int_t currentDeadPointNum = 0;
386 while(node) {
387 if( strcmp(node->GetNodeName(), "DeadPoint") == 0 ) {
388
389 if( node->HasAttributes() ) {
390 TList *attrList = node->GetAttributes();
391 TXMLAttr *attr = 0;
392 TIter next(attrList);
393
394 while ((attr = (TXMLAttr*)next()) != nullptr)
395 {
396 if( strcmp(attr->GetName(), "x") == 0 ) {
397 xpoints[currentDeadPointNum] = -atof(attr->GetValue())+XShiftOfModules[iModule]+XPosition; //inverted
398 }
399 if( strcmp(attr->GetName(), "y") == 0 ) {
400 ypoints[currentDeadPointNum] = atof(attr->GetValue())+YShiftOfModules[iModule]+YPosition;
401 }
402 }
403 }
404
405 currentDeadPointNum++;
406 }
407 node = node->GetNextNode();
408 }
409
410 dead_zone.SetDeadZone(n_dead_points, xpoints, ypoints);
411
412 delete [] xpoints;
413 delete [] ypoints;
414
415 return dead_zone;
416}
417
418Int_t BmnSiProfStation::CountDeadZonePoints(TXMLNode *node) {
419 Int_t dead_point_cnt = 0;
420 node = node->GetChildren();
421 while(node) {
422 if( strcmp(node->GetNodeName(), "DeadPoint") == 0 ) {
423 dead_point_cnt++;
424 }
425 node = node->GetNextNode();
426 }
427 return dead_point_cnt;
428}
int i
Definition P4_F32vec4.h:22
StripNumberingDirection
@ RightToLeft
@ LeftToRight
StripLayerType
@ UpperStripLayer
@ LowerStripLayer
Double_t GetModuleThickness()
Int_t GetNIntersectionPoints()
Double_t GetZStartModulePosition()
Double_t GetYMaxModule()
void AddStripLayer(BmnSiProfLayer strip_layer)
Double_t GetXMaxModule()
void CalculateStripHitIntersectionPoints()
Double_t GetXMinModule()
Double_t GetYMinModule()
Double_t * XShiftOfModules
Double_t * YShiftOfModules
BmnSiProfModule ** Modules
Int_t GetPointModuleOwnership(Double_t xcoord, Double_t ycoord, Double_t zcoord)
BmnSiProfModule * GetModule(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)
Int_t CountNProcessedPointInStation()
Double_t GetThicknessOfModule(Int_t module_num)
Double_t * ZShiftOfModules
Double_t GetYShiftOfModule(Int_t module_num)
Double_t * ThicknessOfModules
Double_t GetZShiftOfModule(Int_t module_num)
Double_t GetXShiftOfModule(Int_t module_num)
Bool_t SetDeadZone(Int_t n_points, Double_t *xpoints, Double_t *ypoints)