FairRoot/PandaRoot
createSttGeometry.C
Go to the documentation of this file.
1 #include <TGeoArb8.h>
2 #include <TGeoPgon.h>
3 #include <TGeoEltu.h>
4 #include <TGeoCompositeShape.h>
5 #include <TGeoSphere.h>
6 #include <string.h>
7 #include <ctime>
8 
9 #define PI 3.14159265
10 TGeoVolume *constructGasManifold() {
11  Double_t tubeRadius = 0.507;
12  Double_t tubeLength = 147.5;
13  Double_t frameThickness = 2;
14  TGeoVolume *gasManifold;
15  gasManifold = new TGeoVolumeAssembly("GasManifold");
16 
17  Int_t Angleda12[] = { 0, -36, -48, -96, -108, -144 };
18 
19 // GasManifold Pipe
20  Int_t gmPipelavel[30];
21  for (Int_t i = 0; i < 6; i++) {
22  for (Int_t j = 0; j < 5; j++) {
23  gmPipelavel[i * 5 + j] = 0;
24  }
25  }
26  TGeoBBox *empBox;
27  empBox = new TGeoBBox("empBox", 0, 0, .3 / sqrt(2));
28  Double_t sPoint[50][3];
29 
30  for (Int_t i = 0; i < 6; i++) {
31  for (Int_t j = 0; j < 5; j++) {
32  sPoint[i * 5 + j][0] = 42.3
33  * cos((75 - 1.5 * j + Angleda12[i]) * PI / 180);
34  sPoint[i * 5 + j][1] = 42.3
35  * sin((75 - 1.5 * j + Angleda12[i]) * PI / 180);
36  if (j != 3) {
37  sPoint[i * 5 + j][2] = (tubeLength + 2.4 - 0.8 * j - 2.1) / 2.0;
38  } else {
39  sPoint[i * 5 + j][2] = (tubeLength + 2.4 - 3.7 - 1) / 2.0;
40  }
41  }
42  }
43 
44  Double_t specArf[50][10][3];
45 
46  /* for(Int_t i=0 ; i< 6; i++){
47  for(Int_t j=0 ; j< 5; j++){
48  Int_t dLevel = gmPipelavel[i*5+j];
49  for(Int_t k=0; k<dLevel; k++){
50 
51  }
52  }
53  }*/
54  Int_t lv;
55  gmPipelavel[0] = 4;
56  specArf[0][0][0] = tubeLength + 2.4 + 2.1;
57  specArf[0][0][1] = 0;
58  specArf[0][0][2] = 0;
59  specArf[0][1][0] = 5.5;
60  specArf[0][1][1] = 90;
61  specArf[0][1][2] = 0;
62  specArf[0][2][0] = 5.1;
63  specArf[0][2][1] = 150;
64  specArf[0][2][2] = 0;
65  specArf[0][3][0] = 31.1;
66  specArf[0][3][1] = 240;
67  specArf[0][3][2] = 0;
68  gmPipelavel[1] = 4;
69  specArf[1][0][0] = tubeLength + 2.4 + 2.9;
70  specArf[1][0][1] = 0;
71  specArf[1][0][2] = 0;
72  specArf[1][1][0] = 6.5;
73  specArf[1][1][1] = 90;
74  specArf[1][1][2] = 0;
75  specArf[1][2][0] = 3.3;
76  specArf[1][2][1] = 150;
77  specArf[1][2][2] = 0;
78  specArf[1][3][0] = 32.3;
79  specArf[1][3][1] = 240;
80  specArf[1][3][2] = 0;
81  gmPipelavel[2] = 5;
82  specArf[2][0][0] = tubeLength + 2.4 + 3.7;
83  specArf[2][0][1] = 0;
84  specArf[2][0][2] = 0;
85  specArf[2][1][0] = 10.0;
86  specArf[2][1][1] = 90;
87  specArf[2][1][2] = 0;
88  specArf[2][2][0] = 14.0;
89  specArf[2][2][1] = 180;
90  specArf[2][2][2] = 0;
91  specArf[2][3][0] = 27.0;
92  specArf[2][3][1] = 240;
93  specArf[2][3][2] = 7.0;
94  specArf[2][4][0] = 21.0;
95  specArf[2][4][1] = 240;
96  specArf[2][4][2] = 0;
97  gmPipelavel[3] = 5;
98  specArf[3][0][0] = tubeLength + 2.4 + 4.7;
99  specArf[3][0][1] = 0;
100  specArf[3][0][2] = 0;
101  specArf[3][1][0] = 11.0;
102  specArf[3][1][1] = 90;
103  specArf[3][1][2] = 0;
104  specArf[3][2][0] = 19.0;
105  specArf[3][2][1] = 180;
106  specArf[3][2][2] = 0;
107  specArf[3][3][0] = 29.0;
108  specArf[3][3][1] = 240;
109  specArf[3][3][2] = 6.0;
110  specArf[3][4][0] = 16.5;
111  specArf[3][4][1] = 240;
112  specArf[3][4][2] = 0;
114  gmPipelavel[6] = 3;
115  sPoint[6][2] = (tubeLength + 2.4 - 5.0) / 2.0;
116  specArf[6][0][0] = tubeLength + 2.4 + 5.0;
117  specArf[6][0][1] = 0;
118  specArf[6][0][2] = 0;
119  specArf[6][1][0] = 5.0;
120  specArf[6][1][1] = 150;
121  specArf[6][1][2] = 0;
122  specArf[6][2][0] = 31.3;
123  specArf[6][2][1] = 60;
124  specArf[6][2][2] = 0;
125 
126  gmPipelavel[7] = 5;
127  sPoint[7][2] = (tubeLength + 2.4 - 5.2) / 2.0;
128  specArf[7][0][0] = tubeLength + 2.4 + 5.2;
129  specArf[7][0][1] = 0;
130  specArf[7][0][2] = 0;
131  specArf[7][1][0] = 6.5;
132  specArf[7][1][1] = 150;
133  specArf[7][1][2] = 0;
134  specArf[7][2][0] = 10.5;
135  specArf[7][2][1] = 120;
136  specArf[7][2][2] = 0;
137  specArf[7][3][0] = 26.8;
138  specArf[7][3][1] = 60;
139  specArf[7][3][2] = 3.6;
140  specArf[7][4][0] = 21.0;
141  specArf[7][4][1] = 60;
142  specArf[7][4][2] = 0;
143 
144  gmPipelavel[8] = 3;
145  sPoint[8][2] = (tubeLength + 2.4 - 3.2) / 2.0;
146  specArf[8][0][0] = tubeLength + 2.4 + 3.2;
147  specArf[8][0][1] = 0;
148  specArf[8][0][2] = 0;
149  specArf[8][1][0] = 2.3;
150  specArf[8][1][1] = 150;
151  specArf[8][1][2] = 0;
152  specArf[8][2][0] = 32.3;
153  specArf[8][2][1] = 60;
154  specArf[8][2][2] = 0;
155 
156  gmPipelavel[9] = 5;
157  sPoint[9][2] = (tubeLength + 2.4 - 4.2) / 2.0;
158  specArf[9][0][0] = tubeLength + 2.4 + 4.2;
159  specArf[9][0][1] = 0;
160  specArf[9][0][2] = 0;
161  specArf[9][1][0] = 2.3;
162  specArf[9][1][1] = 150;
163  specArf[9][1][2] = 0;
164  specArf[9][2][0] = 16.5;
165  specArf[9][2][1] = 120;
166  specArf[9][2][2] = 0;
167  specArf[9][3][0] = 29.0;
168  specArf[9][3][1] = 60;
169  specArf[9][3][2] = 3.5;
170  specArf[9][4][0] = 17.2;
171  specArf[9][4][1] = 60;
172  specArf[9][4][2] = 0;
173 //*************************************************
174  gmPipelavel[11] = 3;
175  sPoint[11][2] = (tubeLength + 2.4 - 4.0) / 2.0;
176  specArf[11][0][0] = tubeLength + 2.4 + 4.0;
177  specArf[11][0][1] = 0;
178  specArf[11][0][2] = 0;
179  specArf[11][1][0] = 4.4;
180  specArf[11][1][1] = 90;
181  specArf[11][1][2] = 0;
182  specArf[11][2][0] = 36.0;
183  specArf[11][2][1] = 180;
184  specArf[11][2][2] = 0;
185 
186  gmPipelavel[12] = 3;
187  sPoint[12][2] = (tubeLength + 2.4 - 4.0) / 2.0;
188  specArf[12][0][0] = tubeLength + 2.4 + 4.0;
189  specArf[12][0][1] = 0;
190  specArf[12][0][2] = 0;
191  specArf[12][1][0] = 3.2;
192  specArf[12][1][1] = 90;
193  specArf[12][1][2] = 0;
194  specArf[12][2][0] = 35.2;
195  specArf[12][2][1] = 180;
196  specArf[12][2][2] = 0;
197 
198  gmPipelavel[13] = 5;
199  sPoint[13][2] = (tubeLength + 2.4 - 5.5) / 2.0;
200  specArf[13][0][0] = tubeLength + 2.4 + 5.5;
201  specArf[13][0][1] = 0;
202  specArf[13][0][2] = 0;
203  specArf[13][1][0] = 10.0;
204  specArf[13][1][1] = 90;
205  specArf[13][1][2] = 0;
206  specArf[13][2][0] = 31.0;
207  specArf[13][2][1] = 180;
208  specArf[13][2][2] = 8.0;
209  specArf[13][3][0] = 10.0;
210  specArf[13][3][1] = 120;
211  specArf[13][3][2] = 0;
212  specArf[13][4][0] = 20.0;
213  specArf[13][4][1] = 180;
214  specArf[13][4][2] = 0;
215 
216  gmPipelavel[14] = 4;
217  sPoint[14][2] = (tubeLength + 2.4 - 4.2) / 2.0;
218  specArf[14][0][0] = tubeLength + 2.4 + 4.2;
219  specArf[14][0][1] = 0;
220  specArf[14][0][2] = 0;
221  specArf[14][1][0] = 14.2;
222  specArf[14][1][1] = 90;
223  specArf[14][1][2] = 0;
224  specArf[14][2][0] = 29.0;
225  specArf[14][2][1] = 180;
226  specArf[14][2][2] = 10.0;
227  specArf[14][3][0] = 28.0;
228  specArf[14][3][1] = 180;
229  specArf[14][3][2] = 0;
231  lv = 18;
232  gmPipelavel[lv] = 3;
233  sPoint[lv][2] = (tubeLength + 2.4 - 4.0) / 2.0;
234  specArf[lv][0][0] = tubeLength + 2.4 + 4.0;
235  specArf[lv][0][1] = 0;
236  specArf[lv][0][2] = 0;
237  specArf[lv][1][0] = 3.7;
238  specArf[lv][1][1] = 180 - 90;
239  specArf[lv][1][2] = 0;
240  specArf[lv][2][0] = 36.0;
241  specArf[lv][2][1] = 180 - 180;
242  specArf[lv][2][2] = 0;
243 
244  lv = 17;
245  gmPipelavel[lv] = 3;
246  sPoint[12][2] = (tubeLength + 2.4 - 4.0) / 2.0;
247  specArf[lv][0][0] = tubeLength + 2.4 + 4.0;
248  specArf[lv][0][1] = 0;
249  specArf[lv][0][2] = 0;
250  specArf[lv][1][0] = 2.2;
251  specArf[lv][1][1] = 180 - 90;
252  specArf[lv][1][2] = 0;
253  specArf[lv][2][0] = 35.2;
254  specArf[lv][2][1] = 180 - 180;
255  specArf[lv][2][2] = 0;
256  lv = 16;
257  gmPipelavel[lv] = 5;
258  sPoint[lv][2] = (tubeLength + 2.4 - 5.5) / 2.0;
259  specArf[lv][0][0] = tubeLength + 2.4 + 5.5;
260  specArf[lv][0][1] = 0;
261  specArf[lv][0][2] = 0;
262  specArf[lv][1][0] = 10.0;
263  specArf[lv][1][1] = 180 - 90;
264  specArf[lv][1][2] = 0;
265  specArf[lv][2][0] = 31.0;
266  specArf[lv][2][1] = 180 - 180;
267  specArf[lv][2][2] = 7.0;
268  specArf[lv][3][0] = 11.4;
269  specArf[lv][3][1] = 180 - 120;
270  specArf[lv][3][2] = 0;
271  specArf[lv][4][0] = 20.0;
272  specArf[lv][4][1] = 180 - 180;
273  specArf[lv][4][2] = 0;
274  lv = 15;
275  gmPipelavel[lv] = 4;
276  sPoint[lv][2] = (tubeLength + 2.4 - 4.2) / 2.0;
277  specArf[lv][0][0] = tubeLength + 2.4 + 4.2;
278  specArf[lv][0][1] = 0;
279  specArf[lv][0][2] = 0;
280  specArf[lv][1][0] = 15.2;
281  specArf[lv][1][1] = 180 - 90;
282  specArf[lv][1][2] = 0;
283  specArf[lv][2][0] = 29.0;
284  specArf[lv][2][1] = 180 - 180;
285  specArf[lv][2][2] = 11.4;
286  specArf[lv][3][0] = 28.0;
287  specArf[lv][3][1] = 180 - 180;
288  specArf[lv][3][2] = 0;
289 
290  for (Int_t i = 29; i > 19; i--) {
291  gmPipelavel[i] = gmPipelavel[29 - i];
292  for (Int_t j = 0; j < gmPipelavel[i]; j++) {
293  specArf[i][j][0] = specArf[29 - i][j][0];
294  specArf[i][j][2] = specArf[29 - i][j][2];
295  if (i != 0) {
296  specArf[i][j][1] = 180 - specArf[29 - i][j][1];
297  } else {
298  specArf[i][j][1] = specArf[29 - i][j][1];
299  }
300  }
301  }
302 
303  std::vector<TGeoTube*> tubef;
304  std::vector<TGeoTube*> gasf;
305  std::vector<TGeoCombiTrans*> trf;
306 
307  std::vector<TGeoVolume*> gmPipeArr;
308  std::vector<TGeoVolume*> gasArr;
309  std::vector<TGeoCompositeShape*> tubeshapecomp;
310  std::vector<TGeoCompositeShape*> gasshapecomp;
311  Int_t index = 0;
312  Int_t index2 = 0;
313  for (Int_t i = 0; i < 6; i++) {
314  for (Int_t j = 0; j < 5; j++) {
315  if (gmPipelavel[i * 5 + j] != 0) {
316  Int_t dLevel = gmPipelavel[i * 5 + j];
317  std::string name;
318  std::string tubetmpin = "empBox ";
319  std::string gastmpin = "empBox ";
320  std::string gasdel = " - (";
321 
322  Double_t sX = sPoint[i * 5 + j][0];
323  Double_t sY = sPoint[i * 5 + j][1];
324  Double_t sZ = sPoint[i * 5 + j][2];
325  Int_t sIdPoint = 0;
326  Int_t angle = 0;
327  name = "gmPipeShape" + std::to_string(i * 5 + j);
328  for (Int_t k = 0; k < dLevel; k++) {
329  Double_t x, y, z;
330  if (k == 0) {
331  angle = 0;
332  x = sX;
333  y = sY;
334  z = sZ;
335  } else if (k > 0) {
336  angle = 90;
337  x = sX
338  - (specArf[i * 5 + j][k][0] / 2)
339  * sin(
340  specArf[i * 5 + j][k][1] * PI
341  / 180);
342  y = sY
343  + (specArf[i * 5 + j][k][0] / 2)
344  * cos(
345  specArf[i * 5 + j][k][1] * PI
346  / 180);
347  z = sZ;
348  if (specArf[i * 5 + j][k][2] != 0) {
349  x =
350  x
351  + (specArf[i * 5 + j][sIdPoint][0]
352  - specArf[i * 5 + j][k][2])
353  * sin(
354  specArf[i * 5 + j][sIdPoint][1]
355  * PI / 180);
356  y =
357  y
358  - (specArf[i * 5 + j][sIdPoint][0]
359  - specArf[i * 5 + j][k][2])
360  * cos(
361  specArf[i * 5 + j][sIdPoint][1]
362  * PI / 180);
363  }
364  }
365 
366  std::string tubefname = "tubef" + std::to_string(i)
367  + std::to_string(j) + std::to_string(k);
368  std::string gasfname = "gasf" + std::to_string(i)
369  + std::to_string(j) + std::to_string(k);
370  std::string trfname = "trf" + std::to_string(i)
371  + std::to_string(j) + std::to_string(k);
372  tubef.push_back(
373  new TGeoTube(tubefname.c_str(), 0.15, .2,
374  (specArf[i * 5 + j][k][0]) / 2.0));
375  gasf.push_back(
376  new TGeoTube(gasfname.c_str(), 0, .1499,
377  (specArf[i * 5 + j][k][0]) / 2.0));
378 
379  trf.push_back(
380  new TGeoCombiTrans(trfname.c_str(), x, y, z,
381  new TGeoRotation("r",
382  specArf[i * 5 + j][k][1], angle,
383  0)));
384  trf[index2]->RegisterYourself();
385  index2++;
386  tubetmpin += "+" + tubefname + ":" + trfname;
387  gastmpin += "+" + gasfname + ":" + trfname;
388  if (k == 0)
389  gasdel += tubefname + ":" + trfname;
390  else
391  gasdel += "+" + tubefname + ":" + trfname;
392 
393  if (specArf[i * 5 + j][k][2] == 0) {
394  if (k != 0) {
395  sX = sX
396  - (specArf[i * 5 + j][k][0])
397  * sin(
398  specArf[i * 5 + j][k][1]
399  * PI / 180);
400  sY = sY
401  + (specArf[i * 5 + j][k][0])
402  * cos(
403  specArf[i * 5 + j][k][1]
404  * PI / 180);
405  } else {
406  sZ = (sZ - (tubeLength + 2.4) / 2.0) * 2;
407  }
408  sIdPoint = k;
409  }
410  }
411  gasdel += ")";
412  gastmpin += gasdel;
413  tubeshapecomp.push_back(
414  new TGeoCompositeShape(name.c_str(),
415  tubetmpin.c_str()));
416  gasshapecomp.push_back(
417  new TGeoCompositeShape(name.c_str(), gastmpin.c_str()));
418 
419  gmPipeArr.push_back(
420  new TGeoVolume("gmPipe", tubeshapecomp[index],
421  gGeoManager->GetMedium("Aluminum")));
422  TGeoVolume *gas;
423  gas = new TGeoVolume("ArCO2", gasshapecomp[index],
424  gGeoManager->GetMedium("ArCO2"));
425  gas->SetLineColor(20);
426  gasArr.push_back(gas);
427 
428  index++;
429  }
430  }
431  }
432 
433  index = 0;
434  for (Int_t i = 0; i < 6; i++) {
435  for (Int_t j = 0; j < 5; j++) {
436  if (gmPipelavel[i * 5 + j] != 0) {
437  TGeoVolume *gmPipe;
438  gmPipe = new TGeoVolumeAssembly("gasManifold");
439  gmPipe->AddNode(gmPipeArr[index], 0);
440  gmPipe->AddNode(gasArr[index], 0);
441  gasManifold->AddNode(gmPipe, index);
442  index++;
443  }
444  }
445  }
446 
447  return gasManifold;
448 }
449 
451  Double_t tubeRadius = 0.507;
452  Double_t tubeLength = 147.5;
453  Double_t frameThickness = 2.0;
454  TGeoVolume *mechanicalFrame, *frameStrip;
455  mechanicalFrame = new TGeoVolumeAssembly("mechanicalFrame");
456  frameStrip = new TGeoVolumeAssembly("frameStrip");
457 
458  TGeoVolume *tubeFrame;
459  TGeoTube *tubeFrameShape;
460  tubeFrameShape = new TGeoTube("tubeFrameShape", 0.95, 1.1, tubeLength / 2);
461  tubeFrame = new TGeoVolume("tubeFrame", tubeFrameShape,
462  gGeoManager->GetMedium("ABS"));
463  tubeFrame->SetLineColor(37);
464 
465  TGeoVolume *supportedFrame;
466  TGeoTube *bigRingShape;
467  bigRingShape = new TGeoTube("bigRingShape", 39.6, 44.3, frameThickness / 2);
468  TGeoTube *smallRingShape;
469  smallRingShape = new TGeoTube("smallRingShape", 15.0, 16.1,
470  frameThickness / 2);
471 
472  TGeoBBox *BoxShape;
473  BoxShape = new TGeoBBox("BoxShape", 3.5 / 2, 13.0, frameThickness / 2);
474  TGeoCombiTrans *tbs1 = new TGeoCombiTrans("tbs1", 3.5 / 2 + 1.0, 19.0 + 9.0,
475  0, new TGeoRotation("dd", 0, 0, 0));
476  tbs1->RegisterYourself();
477  TGeoCombiTrans *tbs2 = new TGeoCombiTrans("tbs2", 29.0 * sin(60 * PI / 180),
478  29.0 * cos(60 * PI / 180), 0, new TGeoRotation("dd", 0, 0, -60));
479  tbs2->RegisterYourself();
480  TGeoCombiTrans *tbs3 = new TGeoCombiTrans("tbs3", 29.0 * sin(60 * PI / 180),
481  -29.0 * cos(60 * PI / 180), 0, new TGeoRotation("dd", 0, 0, 60));
482  tbs3->RegisterYourself();
483  TGeoCombiTrans *tbs4 = new TGeoCombiTrans("tbs4", 3.5 / 2 + 1.0,
484  -19.0 - 9.0, 0, new TGeoRotation("dd", 0, 0, 0));
485  tbs4->RegisterYourself();
486 
487  TGeoBBox *delBoxShape;
488 
489  delBoxShape = new TGeoBBox("delBoxShape", 25.0, 50.0, frameThickness);
490  TGeoTranslation *tdbs = new TGeoTranslation("tdbs", -25.0 + 2.0, 0, 0);
491  tdbs->RegisterYourself();
492 
493  TGeoTube *delBigRingShape;
494  delBigRingShape = new TGeoTube("delBigRingShape", 41.6, 45.0,
495  frameThickness / 2);
496  TGeoTranslation *tdBRs = new TGeoTranslation("tdbrs", 0, 0, 1.2);
497  tdBRs->RegisterYourself();
498 
499  // Big Tube Hole
500  TGeoTube *tubeHoleShape; // The shape for the big tubeHole on mechanicalframe
501  tubeHoleShape = new TGeoTube("tubeHoleShape", 0, .7, frameThickness * 4);
502 
503  Int_t Angles8[] = { 78, 30, -30, -78 };
504  std::vector < TGeoTranslation > fts8;
505  for (Int_t i = 0; i < 4; i++) {
506  fts8.push_back(
507  TGeoTranslation(43.0 * cos(Angles8[i] * PI / 180),
508  43.0 * sin(Angles8[i] * PI / 180), 0));
509  }
510  std::vector<TGeoHMatrix *> tbh; // Translation for big tubeHole
511  for (Int_t i = 0; i < 4; i++) {
512  TGeoHMatrix *transfb = new TGeoHMatrix(fts8[i]);
513  tbh.push_back(transfb);
514  std::string name = "tbh" + std::to_string(i);
515  tbh[i]->SetName(name.c_str());
516  tbh[i]->RegisterYourself();
517  }
518 
519  // Small Tube Hole
520  TGeoTube *tubeHoleShape2; // The shape for the small tubeHole on mechanicalframe
521  tubeHoleShape2 = new TGeoTube("tubeHoleShape2", 0, .32, 2.0);
522 
523  Int_t Angleda12[] = { 0, -36, -48, -96, -108, -144 };
524  std::vector<TGeoTranslation*> tTHS;
525  for (Int_t i = 0; i < 6; i++) {
526  for (Int_t j = 0; j < 5; j++) {
527  tTHS.push_back(
528  new TGeoTranslation(
529  42.3
530  * cos(
531  (75 - 1.5 * j + Angleda12[i]) * PI
532  / 180),
533  42.3
534  * sin(
535  (75 - 1.5 * j + Angleda12[i]) * PI
536  / 180), 0));
537  std::string name = "tThs" + std::to_string(i * 5 + j);
538  tTHS[i * 5 + j]->SetName(name.c_str());
539  tTHS[i * 5 + j]->RegisterYourself();
540  }
541  }
542 
543  std::string tempStr =
544  "(smallRingShape + bigRingShape + BoxShape:tbs1+ BoxShape:tbs2+ BoxShape:tbs3+BoxShape:tbs4)-delBigRingShape:tdbrs-delBoxShape:tdbs";
545  for (Int_t i = 0; i < 4; i++) {
546  tempStr = tempStr + "-tubeHoleShape:tbh" + std::to_string(i);
547  }
548  for (Int_t i = 0; i < 6; i++) {
549  for (Int_t j = 0; j < 5; j++) {
550  tempStr = tempStr + " - tubeHoleShape2:tThs"
551  + std::to_string(i * 5 + j);
552  }
553  }
554 
555  TGeoCompositeShape *supportedFrameShape = new TGeoCompositeShape(
556  "supportedFrameShape", tempStr.c_str());
557 
558  supportedFrame = new TGeoVolume("supportedFrame", supportedFrameShape,
559  gGeoManager->GetMedium("Aluminum"));
560  supportedFrame->SetLineColor(29);
561 
562  TGeoVolume *gasPibeCoverM = gGeoManager->MakeTubs("gasPibeCoverM",
563  gGeoManager->GetMedium("ABS"), 42.0, 43.0, tubeLength / 2, 67.6,
564  76.4);
565  TGeoVolume *gasPibeCoverD = gGeoManager->MakeTubs("gasPibeCoverD",
566  gGeoManager->GetMedium("ABS"), 41.8, 42.8, tubeLength / 2 + 10.0,
567  67.87, 76.13);
568  TGeoShape *gPCM = gasPibeCoverM->GetShape();
569  gPCM->SetName("gPCM");
570  TGeoShape *gPCD = gasPibeCoverD->GetShape();
571  gPCD->SetName("gPCD");
572  TGeoCompositeShape *gasPibeCoverP1Shape = new TGeoCompositeShape(
573  "gasPibeCoverP1Shape", "gPCM-gPCD");
574  TGeoVolume *gasPibeCoverP1 = new TGeoVolume("gasPibeCoverP1",
575  gasPibeCoverP1Shape, gGeoManager->GetMedium("ABS"));
576  gasPibeCoverP1->SetLineColor(45);
577 
578  TGeoVolume *gasPibeHolderM = gGeoManager->MakeTubs("gasPibeHolderM",
579  gGeoManager->GetMedium("ABS"), 41.8, 42.8, 1.0, 68.15, 75.85);
580  TGeoShape *gPHM = gasPibeHolderM->GetShape();
581  gPHM->SetName("gPHM");
582 
583  TGeoCompositeShape *gasPibeHolderShape =
584  new TGeoCompositeShape("gasPibeHolderShape",
585  "gPHM - tubeHoleShape2:tThs0- tubeHoleShape2:tThs1- tubeHoleShape2:tThs2- tubeHoleShape2:tThs3- tubeHoleShape2:tThs4");
586  TGeoVolume *gasPibeHolder = new TGeoVolume("gasPibeHolder",
587  gasPibeHolderShape, gGeoManager->GetMedium("ABS"));
588  gasPibeHolder->SetLineColor(29);
589 
590  TGeoVolume *gasPibeCoverMb = gGeoManager->MakeTubs("gasPibeCoverMb",
591  gGeoManager->GetMedium("ABS"), 41.6, 42.8, tubeLength / 2,
592  19.87 + 48, 40.13 + 48);
593  TGeoVolume *gasPibeCoverDb = gGeoManager->MakeTubs("gasPibeCoverDb",
594  gGeoManager->GetMedium("ABS"), 41.8, 42.8 + 1, tubeLength / 2 + 100,
595  32.13 + 48, 39.87 + 48);
596  TGeoVolume *gasPibeCoverDb2 = gGeoManager->MakeTubs("gasPibeCoverDb2",
597  gGeoManager->GetMedium("ABS"), 41.8, 42.8, tubeLength / 2 + 100,
598  28.13 + 48, 31.87 + 48);
599  TGeoShape *gPCMb = gasPibeCoverMb->GetShape();
600  gPCMb->SetName("gPCMb");
601  TGeoShape *gPCDb = gasPibeCoverDb->GetShape();
602  gPCDb->SetName("gPCDb");
603  TGeoShape *gPCDb2 = gasPibeCoverDb2->GetShape();
604  gPCDb2->SetName("gPCDb2");
605  TGeoRotation *rd = new TGeoRotation("rd", -12, 0, 0);
606  rd->RegisterYourself();
607 
608  TGeoVolume *gasPibeCoverMb2 = gGeoManager->MakeTubs("gasPibeCoverMb2",
609  gGeoManager->GetMedium("ABS"), 41.6, 42.8, tubeLength / 2,
610  19.87 + 48, 32 + 48);
611  TGeoShape *gPCMb2 = gasPibeCoverMb2->GetShape();
612  gPCMb2->SetName("gPCMb2");
613  TGeoVolume *gasPibeCoverDb3 = gGeoManager->MakeTubs("gasPibeCoverDb3",
614  gGeoManager->GetMedium("ABS"), 41.8, 42.8 + .1,
615  tubeLength / 2 + 10.0, 28.13 + 48, 35 + 48);
616  TGeoShape *gPCDb3 = gasPibeCoverDb3->GetShape();
617  gPCDb3->SetName("gPCDb3");
618 
619  TGeoCompositeShape *gasPibeCoverP1Shapeb2 = new TGeoCompositeShape(
620  "gasPibeCoverP1Shapeb", "gPCMb2-gPCDb:rd -gPCDb3");
621  TGeoVolume *gasPibeCoverP1b2 = new TGeoVolume("gasPibeCoverP1b2",
622  gasPibeCoverP1Shapeb2, gGeoManager->GetMedium("ABS"));
623  gasPibeCoverP1b2->SetLineColor(49);
624  TGeoCompositeShape *gasPibeCoverP1Shapeb = new TGeoCompositeShape(
625  "gasPibeCoverP1Shapeb", "gPCMb-gPCDb:rd-gPCDb -gPCDb2");
626  TGeoVolume *gasPibeCoverP1b = new TGeoVolume("gasPibeCoverP1b",
627  gasPibeCoverP1Shapeb, gGeoManager->GetMedium("ABS"));
628  gasPibeCoverP1b->SetLineColor(49);
629 
630 // Translation for carbonfiber tube
631  TGeoTranslation *tx1 = new TGeoTranslation("tx1", 43.0 * cos(78 * PI / 180),
632  43.0 * sin(78 * PI / 180), (tubeLength) / 2 + 1.2);
633  tx1->RegisterYourself();
634  TGeoTranslation *tx2 = new TGeoTranslation("tx2", 43.0 * cos(30 * PI / 180),
635  43.0 * sin(30 * PI / 180), (tubeLength) / 2 + 1.2);
636  tx2->RegisterYourself();
637 
638  TGeoTranslation *tx3 = new TGeoTranslation("tx3",
639  43.0 * cos(-30 * PI / 180), 43.0 * sin(-30 * PI / 180),
640  (tubeLength) / 2 + 1.2);
641  tx3->RegisterYourself();
642  TGeoTranslation *tx4 = new TGeoTranslation("tx4",
643  43.0 * cos(-78 * PI / 180), 43.0 * sin(-78 * PI / 180),
644  (tubeLength) / 2 + 1.2);
645  tx4->RegisterYourself();
646 
647  mechanicalFrame->AddNode(gasPibeCoverP1b2, 0,
648  new TGeoTranslation(0, 0, (tubeLength) / 2 + 1.2));
649  mechanicalFrame->AddNode(gasPibeCoverP1b, 0,
650  new TGeoCombiTrans("tx4f", 0, 0, (tubeLength) / 2 + 1.2,
651  new TGeoRotation("r", -48, 0, 0)));
652  mechanicalFrame->AddNode(gasPibeCoverP1b, 1,
653  new TGeoCombiTrans("tx4f", 0, 0, (tubeLength) / 2 + 1.2,
654  new TGeoRotation("r", -108, 0, 0)));
655  mechanicalFrame->AddNode(gasPibeCoverP1b2, 1,
656  new TGeoCombiTrans("tx4f", 0, 0, (tubeLength) / 2 + 1.2,
657  new TGeoRotation("r", 0, 180, 0)));
658 
659  Double_t ArLgasPibeHolder[] = { 4.51353, 15.7344, 17.5, 17.5, 17.5, 17.5,
660  17.5, 17.5, 17.5 };
661  Double_t GasPibeHolderPosZ = 0;
662  for (Int_t i = 0; i < 9; i++) {
663  GasPibeHolderPosZ = GasPibeHolderPosZ + ArLgasPibeHolder[i];
664  frameStrip->AddNode(gasPibeHolder, 65,
665  new TGeoTranslation(0, 0, GasPibeHolderPosZ + 1.2));
666  }
667  frameStrip->AddNode(gasPibeCoverP1, 61,
668  new TGeoTranslation(0, 0, (tubeLength) / 2 + 1.2));
669 
670  mechanicalFrame->AddNode(frameStrip, 0);
671  mechanicalFrame->AddNode(frameStrip, 1,
672  new TGeoCombiTrans("tx4f", 0, 0, 0,
673  new TGeoRotation("r", -36, 0, 0)));
674  mechanicalFrame->AddNode(frameStrip, 2,
675  new TGeoCombiTrans("txg", 0, 0, 0,
676  new TGeoRotation("r", -48, 0, 0)));
677  mechanicalFrame->AddNode(frameStrip, 3,
678  new TGeoCombiTrans("tx4f", 0, 0, 0,
679  new TGeoRotation("r", -96, 0, 0)));
680  mechanicalFrame->AddNode(frameStrip, 4,
681  new TGeoCombiTrans("txg", 0, 0, 0,
682  new TGeoRotation("r", -108, 0, 0)));
683  mechanicalFrame->AddNode(frameStrip, 5,
684  new TGeoCombiTrans("txg", 0, 0, 0,
685  new TGeoRotation("r", -144, 0, 0)));
686 
687  mechanicalFrame->AddNode(tubeFrame, 15, tx1);
688  mechanicalFrame->AddNode(tubeFrame, 15, tx2);
689  mechanicalFrame->AddNode(tubeFrame, 15, tx3);
690  mechanicalFrame->AddNode(tubeFrame, 15, tx4);
691 
692  TGeoBBox *delBoxShape2;
693  delBoxShape2 = new TGeoBBox("delBoxShape2", 25.0, 50.0, 100.0);
694 
695  TGeoVolume *sttCover;
696  TGeoTube *sttCoverShape;
697  sttCoverShape = new TGeoTube("sttCoverShape",
698  42.395 + tubeRadius + .08 + 1.3, 42.395 + tubeRadius + .13 + 1.3,
699  tubeLength / 2 + 6.0);
700  TGeoTube *sttCoverShape2;
701  sttCoverShape2 = new TGeoTube("sttCoverShape2", 15.0, 15.05,
702  tubeLength / 2);
703 
704  TGeoCompositeShape *sttCoverShapeCom = new TGeoCompositeShape("sttShapeCom",
705  "(sttCoverShape+sttCoverShape2)-delBoxShape2:tdbs");
706  sttCover = new TGeoVolume("sttCover", sttCoverShapeCom,
707  gGeoManager->GetMedium("ABS"));
708  sttCover->SetLineColor(23);
709 
710  mechanicalFrame->AddNode(supportedFrame, 17,
711  new TGeoTranslation(0, 0, frameThickness / 2));
712  mechanicalFrame->AddNode(supportedFrame, 18,
713  new TGeoCombiTrans(0, 0, (tubeLength) + 1.4,
714  new TGeoRotation("r", 180, 180, 180)));
715 
716  return mechanicalFrame;
717 }
718 
719 int createstt() {
720  Double_t tubeRadius = 0.507;
721 
722  Double_t tubeLengthArr[] = { 140.0, 140.0 / cos(2.9 * PI / 180.0), 118.5,
723  98.5, 78.5, 58.5, 38.5, 18.5 };
724  Double_t crimpPinLength = 1.0;
725  TCanvas *c = new TCanvas("c", "c", 0, 0, 900, 900);
726  TString vmcWorkdir = getenv("VMCWORKDIR");
727 
728  // TString fGeoFile= vmcWorkdir + Form("/../../../Desktop/STTGEOMETRY/FAIRGEO/Asttgeo.root");
729  TString fGeoFile = vmcWorkdir + Form("/geometry/A_sttgeometry.root");
730  //if(iter!=0) fGeoFile= geomPath + Form("/jaja2.root");
731  TFile* fi = new TFile(fGeoFile, "RECREATE");
732  cout << "Output file = " << fGeoFile << endl;
733 
734  FairGeoLoader* geoLoad = new FairGeoLoader("TGeo", "FairGeoLoader");
735  FairGeoInterface *geoFace = geoLoad->getGeoInterface();
736  geoFace->setMediaFile(vmcWorkdir + "/geometry/media_pnd.geo");
737  geoFace->readMedia();
738 
739  FairGeoMedia *Media = geoFace->getMedia();
740  FairGeoBuilder *geobuild = geoLoad->getGeoBuilder();
741 
742  FairGeoMedium *SttAir = Media->getMedium("air");
743  FairGeoMedium *SttAluminum = Media->getMedium("Aluminum");
744  FairGeoMedium *SttPVC = Media->getMedium("PVC");
745  FairGeoMedium *SttMylar = Media->getMedium("mylar");
746  FairGeoMedium *SttArCO2 = Media->getMedium("ArCO2");
747  FairGeoMedium *SttArCO22b = Media->getMedium("STTmix9010_2bar");
748  FairGeoMedium *SttCopper = Media->getMedium("copper");
749  FairGeoMedium *SttReW = Media->getMedium("ReW");
750  FairGeoMedium *SttCuBe2 = Media->getMedium("CuBe2");
751  FairGeoMedium *SttABS = Media->getMedium("ABS"); //*/
752 
753  Int_t nmed = geobuild->createMedium(SttAir);
754 
755  nmed = geobuild->createMedium(SttAluminum);
756 
757  nmed = geobuild->createMedium(SttPVC);
758 
759  nmed = geobuild->createMedium(SttMylar);
760  nmed = geobuild->createMedium(SttArCO2);
761  nmed = geobuild->createMedium(SttArCO22b);
762  nmed = geobuild->createMedium(SttCopper);
763  nmed = geobuild->createMedium(SttReW);
764  nmed = geobuild->createMedium(SttCuBe2);
765  nmed = geobuild->createMedium(SttABS);
766 
767  TGeoVolume *tube, *top, *halfSide;
768  TGeoVolume *sttVol;
769 
770  // Create top volume
771  //TGeoManager *SttGeom = new TGeoManager("stt","Second stt geometry model");
772  TGeoManager* gGeoMan = (TGeoManager*) gROOT->FindObject("FAIRGeom");
773  gGeoManager->SetNsegments(80);
774 
775  top = new TGeoVolumeAssembly("top");
776  sttVol = new TGeoVolumeAssembly("stt02assembly0");
777  halfSide = new TGeoVolumeAssembly("sttHalfSide");
778  gGeoManager->SetTopVolume(top);
779 
780  // ****************************** Create Tube ******************************
781  std::vector<TGeoVolume*> tubeArr;
782  for (Int_t i = 0; i < 8; i++) {
783 
784  Double_t tubeLength = tubeLengthArr[i];
785  Double_t wireLength = tubeLength + 2.0;
786  Double_t fac = 0.000000001;
787 
788  TGeoVolume *tubeTemp;
789  TGeoVolume *cap, *EndCap, *CrimpPin, *Wire, *MylarLayer, *AlLayer1,
790  *AlLayer2, *RetainingRing, *SpringSmallRing, *SpringBigRing,
791  *NobleGas;
792  TGeoPcon *WireCoveredL2, *WireCoveredL3;
793  std::string tubeType = "tubeType"+ std::to_string(i);
794  std::string tubeName = "tubestt02-"+ std::to_string(i);
795  tubeTemp = new TGeoVolumeAssembly(tubeName.c_str());
796  cap = new TGeoVolumeAssembly("Cap");
797 
798  WireCoveredL2 = new TGeoPgon("WireCoveredLayer2", 0, 360, 80, 16);
799  WireCoveredL2->DefineSection(0, 0, (.1 + (.040 + .025) / 2) / 2 + 0.03,
800  .125);
801  WireCoveredL2->DefineSection(1, 0.025,
802  (.1 + (.040 + .025) / 2) / 2 + 0.05, .15);
803  WireCoveredL2->DefineSection(2, 0.03, (.1 + (.040 + .025) / 2) / 2,
804  .15);
805  WireCoveredL2->DefineSection(3, 0.045, (.1 + (.040 + .025) / 2) / 2,
806  .15);
807  WireCoveredL2->DefineSection(4, 0.045, (.1 + (.040 + .025) / 2) / 2,
808  .115);
809  WireCoveredL2->DefineSection(5, 0.15, (.1 + (.040 + .025) / 2) / 2,
810  .115);
811  WireCoveredL2->DefineSection(6, 0.15, (.1 + (.040 + .025) / 2) / 2,
812  .15);
813  WireCoveredL2->DefineSection(7, 0.5, (.1 + (.040 + .025) / 2) / 2, .15);
814  WireCoveredL2->DefineSection(8, 0.5, (.1 + (.040 + .025) / 2) / 2, .45);
815  WireCoveredL2->DefineSection(9, 0.55, (.1 + (.040 + .025) / 2) / 2,
816  .45);
817  WireCoveredL2->DefineSection(10, 0.55, (.1 + (.040 + .025) / 2) / 2,
818  .42);
819  WireCoveredL2->DefineSection(11, 0.58, (.1 + (.040 + .025) / 2) / 2,
820  .42);
821  WireCoveredL2->DefineSection(12, 0.58, (.1 + (.040 + .025) / 2) / 2,
822  .1);
823  WireCoveredL2->DefineSection(13, 0.7, (.1 + (.040 + .025) / 2) / 2, .1);
824  WireCoveredL2->DefineSection(14, 0.7, .03, .1);
825  WireCoveredL2->DefineSection(15, 0.8, .03, .1);
826 
827  WireCoveredL3 = new TGeoPgon("WireCoveredLayer3", 0, 360, 200, 3);
828  WireCoveredL3->DefineSection(0, 0, 0.45, 0.4975000);
829  WireCoveredL3->DefineSection(1, 0.7, 0.45, 0.4975000);
830  WireCoveredL3->DefineSection(2, 0.8, 0.45, 0.4975 - .0268); //tan(15 deg) = 0.268
831 
832  TGeoTranslation *t1 = new TGeoTranslation("t1", 0, 0, 0.5);
833  t1->RegisterYourself();
834 
835  TGeoTube *GasTubeShape;
836  GasTubeShape = new TGeoTube("gts", 0, .04, 1.0);
837  TGeoTranslation *t2 = new TGeoTranslation("t2", 0, 0.35, 0.5); // position not sure yet
838  t2->RegisterYourself();
839 
840  TGeoCompositeShape *EndCapShape = new TGeoCompositeShape("EndCapShape",
841  "WireCoveredLayer3:t1 + WireCoveredLayer2 - gts:t2");
842  EndCap = new TGeoVolume("EndCapShape", EndCapShape,
843  gGeoManager->GetMedium("ABS"));
844  EndCap->SetLineColor(8);
845 
846  TGeoTube *CrimpPinShape; // tubeTemp->AddNode(MylarLayer,5,new TGeoTranslation("z", 0, 0, tubeLength/2 + 3.5));
847  // tubeTemp->AddNode(AlLayer2,6,new TGeoTranslation("z", 0, 0, tubeLength/2 + 3.5));
848  // outfile.close();
849  // tubeTemp->CheckOverlaps(0.000001);
850  CrimpPinShape = new TGeoTube("CrimpPinShape", 0.002,
851  (0.1 + (.040 + .025) / 2) / 2, crimpPinLength / 2);
852  CrimpPin = new TGeoVolume("w1", CrimpPinShape,
853  gGeoManager->GetMedium("copper"));
854  CrimpPin->SetLineColor(25);
855  TGeoTranslation *t3 = new TGeoTranslation("t3", 0, 0,
856  0.7 - crimpPinLength / 2);
857  t3->RegisterYourself();
858 
859  // Creat simple ring (Instead of Spring)
860  TGeoTube *SmallRingShape;
861  SmallRingShape = new TGeoTube("SmallRingShape", 0.2, 0.23, .01748);
862  SpringSmallRing = new TGeoVolume("SRS", SmallRingShape,
863  gGeoManager->GetMedium("CuBe2"));
864  SpringSmallRing->SetLineColor(5);
865 
866  TGeoTube *BigRingShape;
867  BigRingShape = new TGeoTube("BigRingShape", 0.995 / 2 - .03, 0.995 / 2,
868  .01748);
869  SpringBigRing = new TGeoVolume("BRS", BigRingShape,
870  gGeoManager->GetMedium("CuBe2"));
871  SpringBigRing->SetLineColor(5);
872 
873  // Create RetainingRing
874  RetainingRing = gGeoManager->MakeTubs("RRS",
875  gGeoManager->GetMedium("PVC"), 0.115, 0.25, 0.0525, 125, 55);
876  RetainingRing->SetLineColor(35);
877 
878  // Create wire inside a tube
879  TGeoTube *WireShape;
880  WireShape = new TGeoTube("WireShape", 0, 0.001, wireLength / 2);
881  Wire = new TGeoVolume("Wire", WireShape, gGeoManager->GetMedium("ReW"));
882  Wire->SetLineColor(15);
883 
884 
885 
886  std::string tempt5 = tubeType + "t5";
887  TGeoTranslation *t5 = new TGeoTranslation(tempt5.c_str(), 0, 0,
888  tubeLength / 2 + 0.35);
889  t5->RegisterYourself();
890 
891  std::string tempt6 = tubeType + "t6";
892  TGeoTranslation *t6 = new TGeoTranslation(tempt6.c_str(), 0, 0,
893  -tubeLength / 2 - 0.35);
894  t6->RegisterYourself();
895 
896  // Create Outer tube layer
897  TGeoTube *AlLayerShape1;
898  std::string tempal1 = tubeType + "AluminiumLayerShape1";
899  AlLayerShape1 = new TGeoTube(tempal1.c_str(), 0.4975000, 0.4975030,
900  tubeLength / 2);
901  AlLayer1 = new TGeoVolume("al1", AlLayerShape1,
902  gGeoManager->GetMedium("Aluminum"));
903  AlLayer1->SetLineColor(10);
904 
905  TGeoTube *MylarShape;
906  std::string tempml1 = tubeType + "MylarLayerShape1";
907  MylarShape = new TGeoTube(tempml1.c_str(), 0.4975030, 0.5002030,
908  tubeLength / 2);
909  MylarLayer = new TGeoVolume("ml1", MylarShape,
910  gGeoManager->GetMedium("mylar"));
911 
912  MylarLayer->SetLineColor(9);
913 
914  TGeoTube *AlLayerShape2;
915  std::string tempal2 = tubeType + "AluminiumLayerShape2";
916  AlLayerShape2 = new TGeoTube(tempal2.c_str(), 0.5002030, 0.5002060,
917  tubeLength / 2);
918  AlLayer2 = new TGeoVolume("al2", AlLayerShape2,
919  gGeoManager->GetMedium("Aluminum"));
920  AlLayer2->SetLineColor(10);
921 
922  // Create Gas layer
923 // std::string tempt4 = tubeType + "t4";
924 // TGeoTranslation *t4 = new TGeoTranslation(tempt4.c_str(), 0, 0,
925 // (tubeLength - 0.4) / 2.0 + 0.55);
926 // t4->RegisterYourself();//0.7 - crimpPinLength / 2
927  std::string tempt4 = tubeType + "t4";
928  TGeoTranslation *t4 = new TGeoTranslation(tempt4.c_str(), 0, 0,
929  0.7 - crimpPinLength / 2 - tubeLength/2);
930  t4->RegisterYourself(); //
931 
932 
933 
934  std::string temptr1 = tubeType + "tr1";
935  TGeoCombiTrans *tr1 = new TGeoCombiTrans(temptr1.c_str(), 0, 0,
936  tubeLength/2 + .35, new TGeoRotation("d", 0, 180, 180));
937  tr1->RegisterYourself();
938 
939  std::string tempt7 = tubeType + "t7";
940  TGeoTranslation *t7 = new TGeoTranslation(tempt7.c_str(), 0, 0,
941  -.7 +tubeLength/2 + crimpPinLength / 2);
942  t7->RegisterYourself();
943 
944  TGeoTube *NobleGasTubeShape;
945  std::string tempgs = tubeType + "GasShape";
946  NobleGasTubeShape = new TGeoTube(tempgs.c_str(), 0, 0.4970 - fac,
947  (tubeLength - 0.4) / 2.0 - fac);
948  //std::clockt cstart4 = std::clock();
949  std::string tempStr = tempgs
950  + " -( EndCapShape:"+ tempt6 + "+ EndCapShape:" + temptr1
951  + "+ CrimpPinShape:" + tempt4 + " + CrimpPinShape:" + tempt7
952  + "+ WireShape)";
953  TGeoCompositeShape *NobleGasShape = new TGeoCompositeShape("r",
954  tempStr.c_str());
955  NobleGas = new TGeoVolume("ArCO2Sensitive", NobleGasShape,
956  gGeoManager->GetMedium("ArCO2"));
957  NobleGas->SetLineColor(20);
958 
959  TGeoVolume *testVol;
960  TGeoTube *testShape;
961  testShape = new TGeoTube("testShape", 0, 0.995 / 2, 0.1);
962  testVol = new TGeoVolume("e1", testShape,
963  gGeoManager->GetMedium("ABS"));
964  testVol->SetLineColor(8);
965 // cap->AddNode(testVol, 1);
966  cap->AddNode(CrimpPin, 0, t3);
967  cap->AddNode(EndCap, 1);
968  cap->AddNode(SpringSmallRing, 2, new TGeoTranslation("t", 0, 0, 0.2));
969  cap->AddNode(SpringSmallRing, 3, new TGeoTranslation("t", 0, 0, 0.3));
970  cap->AddNode(SpringSmallRing, 4, new TGeoTranslation("t", 0, 0, 0.4));
971  cap->AddNode(SpringBigRing, 5,
972  new TGeoTranslation("t", 0, 0, 0.5 - .02));
973  cap->AddNode(RetainingRing, 6,
974  new TGeoTranslation("t", 0, 0, 0.045 + 0.0525));
975 
976  tubeTemp->AddNode(Wire, 1);
977  tubeTemp->AddNode(cap, 2,t6);
978  tubeTemp->AddNode(cap, 3, tr1);
979  tubeTemp->AddNode(NobleGas, 0);
980  tubeTemp->AddNode(AlLayer1, 4);
981  tubeTemp->AddNode(MylarLayer, 5);
982  tubeTemp->AddNode(AlLayer2, 6);
983  tubeArr.push_back(tubeTemp);
984 // tubeTemp->CheckOverlaps(0.00001);
985  }
986 //
987 // top->AddNode(tubeArr[7], 1, new TGeoTranslation("z", 0, 1 * 20, 0));
988 // for (Int_t i = 0; i < 8; i++) {
989 // top->AddNode(tubeArr[i], 1, new TGeoTranslation("z", 0, i * 20, 0));
990 // }
991 //
992 // ****************************** Arrange tubes ******************************
993  std::vector<TGeoVolume*> sectorArr;
994  for (Int_t sector = 0; sector < 3; sector++) {
995 
996  Int_t Node = 0;
997  TGeoVolume *geoTemp;
998  //std::string name = "sector-" + to_string((sPart - 1) * (sPart - 1));
999  std::string name = "sector-" + to_string(sector);
1000 
1001  geoTemp = new TGeoVolumeAssembly(name.c_str());
1002  for (Int_t mPart = 0; mPart < 8; mPart++) {
1003 
1004  //Int_t Node=nNode;
1005 
1006  Double_t startingPointRow, startingPointCol;
1007  Int_t sIndex[10][2], eIndex[10][2];
1008  Int_t parity = 0, nRow, stack;
1009  Double_t sttRadius;
1010  Double_t deg = 2.9;
1011  Int_t tDeg;
1012  Int_t dPar0 = 0, dPar1 = 0;
1013  Int_t layerStart; //2[]={0,6,12,16,18,22};
1014  Double_t stackArraymPart7[8] = { 0, 20, 19, 16, 15, 12, 9, 4 };
1015  Double_t dPar0mPart7[8] = { 0,-1, -1, 0, 0, 0, 0, -1 };
1016  Double_t dPar1mPart7[8] = { 0, -4, -2, 0, 0, 0, 0, -1 };
1017 
1018  if (sector == 0) {
1019  dPar0 = -1;
1020  dPar1 = -4;
1021  }
1022  else if(sector == 2) {
1023  dPar0 = -4;
1024  dPar1 = -1;
1025  }
1026 
1027  if (mPart == 0) {
1028  if (sector == 1) {
1029  parity = 0;
1030  nRow = 6;
1031  layerStart = 0;
1032  } else {
1033  parity = 1;
1034  nRow = 5;
1035  layerStart = 1;
1036  }
1037  sttRadius = 17.563 - 0.878 * 3;
1038  stack = 9;
1039  tDeg = 0;
1040  }
1041 
1042  if (mPart == 1) {
1043  parity = 0;
1044  sttRadius = 21.076 - 0.878;
1045  nRow = 4;
1046  stack = 12;
1047  tDeg = 0;
1048  layerStart = 6;
1049  }
1050 
1051  if (mPart == 3) {
1052  parity = 1;
1053  tDeg = -1;
1054  sttRadius = 26.616 - 0.878- 0.878;
1055  nRow = 2;
1056  stack = 15;
1057  layerStart = 12;
1058  }
1059  if (mPart == 2) {
1060  parity = 1;
1061  tDeg = 1;
1062  sttRadius = 24.724 - 0.878- 0.878;
1063  nRow = 2;
1064  stack = 14;
1065  layerStart = 10;
1066  }
1067 
1068  if (mPart == 4) {
1069  parity = 1;
1070  tDeg = -1;
1071  sttRadius = 30.4 - 0.878- 0.878;
1072  nRow = 2;
1073  stack = 17;
1074  layerStart = 16;
1075  }
1076  if (mPart == 5) {
1077  parity = 1;
1078  tDeg = 1;
1079  sttRadius = 28.508 - 0.878- 0.878;
1080  nRow = 2;
1081  stack = 16;
1082  layerStart = 14;
1083  }
1084  if (mPart == 6) {
1085  parity = 1;
1086  sttRadius = 33.37 - 0.878 * 3;
1087  nRow = 4;
1088  stack = 18;
1089  tDeg = 0;
1090  layerStart = 18;
1091  }
1092 
1093  if (mPart == 7) {
1094  parity = 1;
1095  sttRadius = 35.126 - 0.878;
1096  nRow = 7;
1097  tDeg = 0;
1098  layerStart = 22;
1099  }
1100  for (Int_t i = parity; i < nRow + parity; i++) {
1101  if (i == 0 && mPart == 0) {
1102  sIndex[i][0] = 7;
1103  sIndex[i][1] = 7;
1104  } else if (i == 1 && mPart == 0) {
1105  sIndex[i][0] = 4;
1106  sIndex[i][1] = 4;
1107  } else {
1108  sIndex[i][0] = 0;
1109  sIndex[i][1] = 0;
1110  }
1111 
1112  if (mPart == 7) {
1113  eIndex[i][0] = stackArraymPart7[i];
1114  eIndex[i][1] = stackArraymPart7[i];
1115  if (sector == 0) {
1116  eIndex[i][0] = stackArraymPart7[i]
1117  + dPar0mPart7[i];
1118  eIndex[i][1] = stackArraymPart7[i]
1119  + dPar1mPart7[i];
1120  } else if (sector == 2) {
1121  eIndex[i][0] = stackArraymPart7[i]
1122  + dPar1mPart7[i];
1123  eIndex[i][1] = stackArraymPart7[i]
1124  + dPar0mPart7[i];
1125  }
1126 
1127  } else {
1128  eIndex[i][0] = stack + dPar0 - 4 * tDeg * tDeg;
1129  //- 4 * (1 - (1 + tDeg) / 2) * tDeg * tDeg- 4 * (1 + tDeg) / 2 * tDeg * tDeg;
1130  eIndex[i][1] = stack + dPar1 - 4 * tDeg * tDeg;
1131  //- 4 * (1 + tDeg) / 2 * tDeg * tDeg- 4 * (1 - (1 + tDeg) / 2) * tDeg * tDeg;
1132  if (i % 2 == 1)
1133  stack++;
1134  }
1135  }
1136 
1137  startingPointRow = sttRadius;
1138 
1139  for (Int_t i = parity; i < nRow + parity; i++) {
1140  Int_t p = 0;
1141  TGeoVolume *tubeLayer;
1142  Int_t layer = layerStart + i;
1143  if (parity == 1) {
1144  layer = layerStart + i - 1;
1145  }
1146  std::string tubeLayerName = "strawLayer-"
1147  + std::to_string(layer);
1148  tubeLayer = new TGeoVolumeAssembly(tubeLayerName.c_str());
1149 
1150  if (i % 2 == 0) {
1151  startingPointCol = tubeRadius;
1152  } else {
1153  startingPointCol = tubeRadius * 2;
1154  if (sIndex[i][0] == 0 || sIndex[i][1] == 0) {
1155  Int_t colindex = eIndex[i][1];
1156  p = 1;
1157  tubeLayer->AddNode(tubeArr[0],colindex ,
1158  new TGeoCombiTrans("tr",
1159  startingPointRow + i * 0.878, 0, 0,
1160  new TGeoRotation("r", 0, deg * tDeg,
1161  0)));
1162  Node++;
1163  }
1164  }
1165 
1166  Int_t sign = 1;
1167  for (Int_t l = 0; l <= 1; l++) {
1168  for (Int_t j = sIndex[i][l]; j < eIndex[i][l]; j++) {
1169 
1170  Int_t colindex;
1171  if (l == 0)
1172  colindex = (eIndex[i][1] - sIndex[i][1]) + p;
1173  //+ (1 + tDeg) / 2 * 6 * tDeg * tDeg;
1174  else
1175  colindex = (eIndex[i][1] - sIndex[i][1]) - 1;
1176  //+ (1 + tDeg) / 2 * 6 * tDeg * tDeg;
1177  colindex = colindex + (j - sIndex[i][l]) * sign;
1178 
1179  tubeLayer->AddNode(tubeArr[0], colindex,
1180  new TGeoCombiTrans("tr",
1181  startingPointRow + i * 0.878,
1182  (startingPointCol + j * tubeRadius * 2)
1183  * sign, 0,
1184  new TGeoRotation("d", 0, deg * tDeg,
1185  0)));
1186  Node++;
1187  }
1188  sign = -1;
1189  }
1190 
1191  if (tDeg != 0) {
1192  for (Int_t k = 2; k < 8; k++) {
1193 // Int_t colindex = k - 2;
1194 // if (tDeg == -1) {
1195 // colindex = k - 2 + (eIndex[i][1] - sIndex[i][1])
1196 // + (eIndex[i][0] - sIndex[i][0]) + p;
1197 // }
1198  TGeoCombiTrans *trad1 = new TGeoCombiTrans("tr",
1199  startingPointRow + i * 0.878,
1200  -tDeg
1201  * ((startingPointCol
1202  + (k + eIndex[i][(1 + tDeg) / 2]
1203  - 2) * tubeRadius * 2)- (tubeLengthArr[1]
1204  - tubeLengthArr[k])/2
1205  * sin(
1206  2.9 * PI
1207  / 180.0)),
1208  -(tubeLengthArr[1] - tubeLengthArr[k] )
1209  * cos(2.9 * PI / 180.0)/2, new TGeoRotation("r", 0, deg * tDeg, 0));
1210  trad1->RegisterYourself();
1211 
1212  TGeoCombiTrans *trad2 =
1213  new TGeoCombiTrans("tr",
1214  startingPointRow + i * 0.878,
1215  tDeg
1216  * ((startingPointCol
1217  + (k
1218  + eIndex[i][1
1219  - (1
1220  + tDeg)
1221  / 2]
1222  - 2)
1223  * tubeRadius * 2)
1224  - (tubeLengthArr[1]
1225  - tubeLengthArr[k])/2
1226  * sin(
1227  2.9 * PI
1228  / 180.0)),
1229  (tubeLengthArr[1] - tubeLengthArr[k] )
1230  * cos(2.9 * PI / 180.0)/2,
1231  new TGeoRotation("r", 0, deg * tDeg,
1232  0));
1233  trad2->RegisterYourself();
1234  tubeLayer->AddNode(tubeArr[k], 1 - (1 + tDeg) / 2, trad1);
1235  Node++;
1236 
1237  tubeLayer->AddNode(tubeArr[k], (1 + tDeg) / 2, trad2);
1238  Node++;
1239  }
1240  }
1241  geoTemp->AddNode(tubeLayer, 0);
1242  }
1243  }
1244  sectorArr.push_back(geoTemp);
1245 
1246  }
1247  halfSide->AddNode(sectorArr[0], 0,
1248  new TGeoCombiTrans(0, 0, 4 + tubeLengthArr[0] / 2,
1249  new TGeoRotation("d", 0, 0, -60)));
1250  halfSide->AddNode(sectorArr[1], 0,
1251  new TGeoTranslation(0, 0, 4.0 + tubeLengthArr[0] / 2));
1252  halfSide->AddNode(sectorArr[2], 0,
1253  new TGeoCombiTrans(0, 0, 4 + tubeLengthArr[0] / 2,
1254  new TGeoRotation("d", 0, 0, 60)));
1255 
1256  halfSide->AddNode(constructMechanicalFrame(), 1,
1257  new TGeoTranslation(0, 0, 0));
1258  halfSide->AddNode(constructGasManifold(), 2,
1259  new TGeoTranslation(0, 0, -.5));
1260 
1261  sttVol->AddNode(halfSide, 0, new TGeoTranslation("t1", 0, 0, -34.7));
1262  sttVol->AddNode(halfSide, 1,
1263  new TGeoCombiTrans( 0, 0, -34.7,
1264  new TGeoRotation("d", 0, 0, 180)));
1265 
1266  top->AddNode(sttVol, 0);
1267 
1268  top->Write();
1269  top->Draw("ogl");
1270  gGeoManager->SetVisLevel(100);
1271  gGeoManager->CloseGeometry();
1272 
1273  fi->Close();
1274 
1275  std::cout << gGeoManager->GetVisOption() << std::endl;
1276 // top->CheckOverlaps(0.00001);
1277 //gGeoManager->PrintOverlaps();
1278 
1279  return 0;
1280 }
1281 
Double_t p
Definition: anasim.C:58
#define tubeLength
Definition: createSTT.C:42
friend F32vec4 cos(const F32vec4 &a)
Definition: P4_F32vec4.h:112
Int_t t2
Definition: hist-t7.C:106
FairGeoLoader * geoLoad
Int_t i
Definition: run_full.C:25
FairGeoMedia * Media
TGeoManager * gGeoMan
friend F32vec4 sqrt(const F32vec4 &a)
Definition: P4_F32vec4.h:29
friend F32vec4 sin(const F32vec4 &a)
Definition: P4_F32vec4.h:111
TGeoVolume * constructMechanicalFrame()
TGeoManager * gGeoManager
TGeoVolume * top
Int_t t1
Definition: hist-t7.C:106
FairGeoBuilder * geobuild
TFile * fi
Double_t
int createstt()
#define PI
Double_t z
Int_t t3
Definition: hist-t7.C:106
TGeoShape * BoxShape
TString name
Double_t x
Int_t layer
Definition: reco_muo.C:36
int sign(T val)
Definition: PndCADef.h:48
FairGeoInterface * geoFace
Double_t y
Double_t angle
TString fGeoFile
TGeoVolume * constructGasManifold()