StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
pos_geometry.C
1 /*
2  C.Kim
3  FPost geometry show / print
4  Modified oleg's original version
5 */
6 
7 #include "TGeoManager.h"
8 #include "TGeoMaterial.h"
9 #include "TGeoMedium.h"
10 
11 #include <iostream>
12 #include <fstream>
13 using namespace std;
14 
15 void pos_geometry(const char *display="123456")
16 {
17  TString* show = new TString( display );
18 
19  TGeoManager* pos = new TGeoManager("postshower", "postshower detector");
20 
21  TGeoMaterial* vacuum = new TGeoMaterial("vacuum", 0,0,0);
22  TGeoMaterial* plastic = new TGeoMaterial("plastic", 1.02,1,1);
23  TGeoMedium* Air = new TGeoMedium("Vacuum", 0, vacuum);
24  TGeoMedium* Scint = new TGeoMedium("Scintillator", 1, plastic);
25 
26  TGeoVolume* top = pos->MakeBox("top", Air, 1000,1000,1000);
27  pos->SetTopVolume(top);
28  pos->SetTopVisible(0);
29  TGeoVolume* marker = pos->MakeBox("marker", Scint, 1.,1.,1.);
30  top->AddNodeOverlap(marker, 1, new TGeoTranslation( 120, 120,0));
31  top->AddNodeOverlap(marker, 2, new TGeoTranslation(-120,-120,0));
32 
33  TGeoVolume *SL1 = pos->MakeBox("SL1", Air, 120,120,40);
34  SL1->SetVisibility(0);
35  top->AddNodeOverlap(SL1, 1, 0);
36  TGeoVolume *SL2 = pos->MakeBox("SL2", Air, 120,120,40);
37  SL2->SetVisibility(0);
38  top->AddNodeOverlap(SL2, 1, 0);
39  TGeoVolume *NL3 = pos->MakeBox("NL3", Air, 120,120,40);
40  NL3->SetVisibility(0);
41  top->AddNodeOverlap(NL3, 1, 0);
42 
43  TGeoVolume *L4 = pos->MakeBox("L4", Air, 120,120,40);
44  L4->SetVisibility(0);
45  top->AddNodeOverlap(L4, 1, 0);
46  TGeoVolume *L5 = pos->MakeBox("L5", Air, 120,120,40);
47  L5->SetVisibility(0);
48  top->AddNodeOverlap(L5, 1, 0);
49  TGeoVolume *L6 = pos->MakeBox("L6", Air, 120,120,40);
50  L6->SetVisibility(0);
51  top->AddNodeOverlap(L6, 1, 0);
52 
53  //-------------------------------------------
54 
55  const int n_x = 17;
56  const int n_y = 43;
57  const int n_v = 19;
58  const int n_c = 6;
59 
60  const int n_tc = 7;
61  const int n_tx = 9;
62  const int n_tv = 7;
63 
64  // all lengths in cm
65  const float swidth = 5.0;
66  const float dwrap = 0.025;
67  const float start_x = 23.0;
68  const float start_y = -108.0375;
69  const float fmsSmallCellOuterEdge = 750; //FMS inner edge from IP (700) + small cell depth (45) + 5
70 
71  const float length_S1 = 108.0;
72  const float length_S2 = 85.0;
73  const float length_S3 = (length_S2-swidth)*sqrt(2);
74  float S3d_length[7] = {0};
75 
76  cout << "sintillator length:" << endl;
77  cout << Form("S1 %f", length_S1) << endl;
78  cout << Form("S2 %f", length_S2) << endl;
79  cout << Form("S3 %f", length_S3) << endl;
80 
81  TGeoVolume *slat_S1 = pos->MakeBox("slat_S1", Scint, swidth/2., length_S1/2., 0.5);
82  TGeoVolume *slat_S2 = pos->MakeBox("slat_S2", Scint, swidth/2., length_S2/2., 0.5);
83  TGeoVolume *slat_S3 = pos->MakeBox("slat_S3", Scint, swidth/2., length_S3/2., 0.5);
84  TGeoVolume *slat_S3c[7];
85  for(int i=0; i<7; i++)
86  {
87  S3d_length[i] = length_S3 - 2*(swidth+dwrap)*(i+1);
88  slat_S3c[i] = pos->MakeBox("slat_S3c", Scint, swidth/2., S3d_length[i]/2., 0.5);
89  cout << Form("S3-%d %f ", i+1, S3d_length[i]) << endl;
90  }
91 
92  //-------------------------------------------
93 
94  TGeoTranslation *trans;
95  TGeoRotation *rot;
96  TGeoCombiTrans *transrot;
97  float set_x, set_y, set_z = fmsSmallCellOuterEdge;
98  int side, scLayer;
99  int ch = -1;
100 
101  const int scWidth = 5;
102  const int scThick = 1;
103  int scAngle = 0;
104 
105  ofstream out;
106  out.open("fPostGeom.txt");
107 
108  //--------------------------------------------------------------------
109 
110  side = 1;
111 
112  cout << "==== SL1 (x segmentation)" << endl;
113  scLayer = 1;
114  scAngle = 90;
115  set_x = (swidth+dwrap)*4;
116  set_y = 65.5;
117  for( int i=0; i<n_tx; i++ ) {
118  trans = new TGeoTranslation(set_x, set_y, set_z);
119  SL1->AddNodeOverlap(slat_S2,++ch,trans);
120  cout << Form("%3d: %2d (%8.3f, %8.3f, %8.3f) S2 ", ch, i+1, set_x, set_y, set_z) << endl;
121 
122  /*
123  out <<Form("%3d %d %d %2d %8.3f %8.3f %8.3f %8.3f S2",
124  ch, side, scLayer, i+1, length_S2, set_x, set_y, set_z) <<endl;
125  */
126  out <<Form("%3d %7.3f %i %i %3i %8.3f %8.3f %7.3f",
127  ch, length_S2, scWidth, scThick, scAngle, set_x, set_y, set_z) <<endl;
128 
129  set_x -= swidth+dwrap;
130  }
131 
132  cout << "==== SL2 (south side complement, v segmentation)" << endl;
133  scLayer = 2;
134  scAngle = 45;
135  set_x = 8.5*(swidth+dwrap)*sqrt(2);
136  set_y = 65.5;
137  set_z = fmsSmallCellOuterEdge + 5.0;
138  rot = new TGeoRotation("SL2",-45,0,0);
139 
140  set_x -= (swidth+dwrap) * (n_tv*sqrt(2) + (n_tc-1)/sqrt(2));
141  set_y += (swidth+dwrap) * (n_tc+1)/sqrt(2);
142  // Top corner
143  for( int i=0; i<n_tc; i++ )
144  {
145  set_x += (swidth+dwrap)/sqrt(2);
146  set_y -= (swidth+dwrap)/sqrt(2);
147  transrot = new TGeoCombiTrans( set_x, set_y, set_z, rot );
148  SL2->AddNodeOverlap(slat_S3c[6-i],++ch,transrot);
149  cout << Form("%3d: %2d (%8.3f, %8.3f, %8.3f) S3-%d ", ch, i+1, set_x, set_y, set_z, 7-i) << endl;
150 
151  /*
152  out <<Form("%3d %d %d %2d %8.3f %8.3f %8.3f %8.3f S3-%d ",
153  ch, side, scLayer, i+1, S3d_length[6-i], set_x, set_y, set_z, 7-i) <<endl;
154  */
155  out <<Form("%3d %7.3f %i %i %3i %8.3f %8.3f %7.3f",
156  ch, S3d_length[6-i], scWidth, scThick, scAngle, set_x, set_y, set_z) <<endl;
157  }
158  set_x += (swidth+dwrap)/sqrt(2);
159  set_y -= (swidth+dwrap)/sqrt(2);
160  // Full lengths
161  for( int i=0; i<n_tv; i++ )
162  {
163  transrot = new TGeoCombiTrans( set_x, set_y, set_z, rot );
164  SL2->AddNodeOverlap(slat_S3,++ch,transrot);
165  cout << Form("%3d: %2d (%8.3f, %8.3f, %8.3f) S3 ", ch, i+1+n_tc, set_x, set_y, set_z) << endl;
166 
167  /*
168  out << Form("%3d %d %d %2d %8.3f %8.3f %8.3f %8.3f S3 ",
169  ch, side, scLayer, i+1+n_tc, length_S3, set_x, set_y, set_z) << endl;
170  */
171  out << Form("%3d %7.3f %i %i %3i %8.3f %8.3f %7.3f",
172  ch, length_S3, scWidth, scThick, scAngle, set_x, set_y, set_z) << endl;
173 
174  set_x += (swidth+dwrap)*sqrt(2);
175  }
176 
177  cout << "==== SL4 (v segmentation)" << endl;
178  scLayer = 4;
179  scAngle = 45;
180  set_z = fmsSmallCellOuterEdge + 30.0;
181  // Full lengths
182  set_x = 65.5;
183  set_y = start_y+(60.0+dwrap)/sqrt(2)+(swidth+dwrap)/2.0;
184  rot = new TGeoRotation("L4",-45,0,0);
185  set_y += (swidth+dwrap)*sqrt(2)*(n_v-1);
186  for( int i=0; i<n_v; i++ )
187  {
188  transrot = new TGeoCombiTrans( set_x, set_y, set_z, rot );
189  L4->AddNodeOverlap(slat_S3,++ch,transrot);
190  cout << Form("%3d: %2d (%8.3f, %8.3f, %8.3f) S3 ", ch, i+1, set_x, set_y, set_z) << endl;
191 
192  /*
193  out << Form("%3d %d %d %2d %8.3f %8.3f %8.3f %8.3f S3 ",
194  ch, side, scLayer, i+1, length_S3, set_x, set_y, set_z) << endl;
195  */
196  out << Form("%3d %7.3f %i %i %3i %8.3f %8.3f %7.3f",
197  ch, length_S3, scWidth, scThick, scAngle, set_x, set_y, set_z) << endl;
198 
199  set_y -= (swidth+dwrap)*sqrt(2);
200  }
201  // Bottom corner
202  set_x = 65.5;
203  set_y = start_y+(60.0+dwrap)/sqrt(2)+(swidth+dwrap)/2.0;
204  rot = new TGeoRotation("L4",-45,0,0);
205  for( int i=0; i<n_c; i++ )
206  {
207  set_x += (swidth+dwrap)/sqrt(2);
208  set_y -= (swidth+dwrap)/sqrt(2);
209  transrot = new TGeoCombiTrans( set_x, set_y, set_z, rot );
210  L4->AddNodeOverlap(slat_S3c[i],++ch,transrot);
211  cout << Form("%3d: %2d (%8.3f, %8.3f, %8.3f) S3-%d ", ch, i+1+n_v, set_x, set_y, set_z, i+1) << endl;
212 
213  /*
214  out << Form("%3d %d %d %2d %8.3f %8.3f %8.3f %8.3f S3-%d ",
215  ch, side, scLayer, i+1+n_v, S3d_length[i], set_x, set_y, set_z, i+1) <<endl;
216  */
217  out << Form("%3d %7.3f %i %i %3i %8.3f %8.3f %7.3f",
218  ch, S3d_length[i], scWidth, scThick, scAngle, set_x, set_y, set_z, i+1) <<endl;
219  }
220 
221  cout << "==== SL5 (y segmentation)" << endl;
222  scLayer = 5;
223  scAngle = 0;
224  set_x = 65.5;
225  set_y = start_y+(swidth+dwrap)/2.0;
226  set_z = fmsSmallCellOuterEdge + 35.0;
227  rot = new TGeoRotation("L5",90,0,0);
228  set_y += (swidth+dwrap)*(n_y-1);
229  for( int i=0; i<n_y; i++ )
230  {
231  transrot = new TGeoCombiTrans( set_x, set_y, set_z, rot );
232  L5->AddNodeOverlap(slat_S2,++ch,transrot);
233  cout << Form("%3d: %2d (%8.3f, %8.3f, %8.3f) S2 ", ch, i+1, set_x, set_y, set_z) << endl;
234 
235  /*
236  out << Form("%3d %d %d %2d %8.3f %8.3f %8.3f %8.3f S2 ",
237  ch, side, scLayer, i+1, length_S2, set_x, set_y, set_z) << endl;
238  */
239  out << Form("%3d %7.3f %i %i %3i %8.3f %8.3f %7.3f",
240  ch, length_S2, scWidth, scThick, scAngle, set_x, set_y, set_z) << endl;
241 
242  set_y -= swidth+dwrap;
243  }
244 
245  cout << "==== SL6 (x segmentation)" << endl;
246  scLayer = 6;
247  scAngle = 90;
248  // Top
249  set_x = start_x+(swidth+dwrap)/2.0;
250  set_y = 108.0/2.0;
251  set_z = fmsSmallCellOuterEdge + 40.0;
252  for( int i=0; i<n_x; i++ )
253  {
254  trans = new TGeoTranslation(set_x, set_y, set_z);
255  L4->AddNodeOverlap(slat_S1,++ch,trans);
256  cout << Form("%3d: %2d (%8.3f, %8.3f, %8.3f) S1 ", ch, i+1, set_x, set_y, set_z) << endl;
257 
258  /*
259  out << Form("%3d %d %d %2d %8.3f %8.3f %8.3f %8.3f S1 ",
260  ch, side, scLayer, i+1, length_S1, set_x, set_y, set_z) << endl;
261  */
262  out << Form("%3d %7.3f %i %i %3i %8.3f %8.3f %7.3f",
263  ch, length_S1, scWidth, scThick, scAngle, set_x, set_y, set_z) << endl;
264 
265  set_x += swidth+dwrap;
266  }
267  // Bottom (will need 180 deg rotation with light guides)
268  set_x = start_x+(swidth+dwrap)/2.0;
269  set_y = -108.0/2.0;
270  for( int i=n_x; i<n_x*2; i++ )
271  {
272  trans = new TGeoTranslation(set_x, set_y, set_z);
273  L4->AddNodeOverlap(slat_S1,++ch,trans);
274  cout << Form("%3d: %2d (%8.3f, %8.3f, %8.3f) S1 ", ch, i+1, set_x, set_y, set_z) << endl;
275 
276  /*
277  out << Form("%3d %d %d %2d %8.3f %8.3f %8.3f %8.3f S1 ",
278  ch, side, scLayer, i+1, length_S1, set_x, set_y, set_z) << endl;
279  */
280  out << Form("%3d %7.3f %i %i %3i %8.3f %8.3f %7.3f",
281  ch, length_S1, scWidth, scThick, scAngle, set_x, set_y, set_z) << endl;
282 
283  set_x += swidth+dwrap;
284  }
285 
286  //--------------------------------------------------------------------
287 
288  side = 2;
289 
290  cout << "==== NL3 (north side complement, v segmentation)" << endl;
291  scLayer = 3;
292  scAngle = 135;
293  set_x = -8.5*(swidth+dwrap)*sqrt(2);
294  set_y = 65.5;
295  set_z = fmsSmallCellOuterEdge + 10.0;
296  rot = new TGeoRotation("NL3",45,0,0);
297 
298  set_x += (swidth+dwrap) * (n_tv*sqrt(2) + (n_tc-1)/sqrt(2));
299  set_y += (swidth+dwrap) * (n_tc+1)/sqrt(2);
300  for( int i=0; i<n_tc; i++ )
301  {
302  set_x -= (swidth+dwrap)/sqrt(2);
303  set_y -= (swidth+dwrap)/sqrt(2);
304  transrot = new TGeoCombiTrans( set_x, set_y, set_z, rot );
305  NL3->AddNodeOverlap(slat_S3c[6-i],++ch,transrot);
306  cout << Form("%3d: %2d (%8.3f, %8.3f, %8.3f) S3-%d ", ch, i+1, set_x, set_y, set_z, 7-i) << endl;
307 
308  /*
309  out << Form("%3d %d %d %2d %8.3f %8.3f %8.3f %8.3f S3-%d ",
310  ch, side, scLayer, i+1, S3d_length[6-i], set_x, set_y, set_z, 7-i) << endl;
311  */
312  out << Form("%3d %7.3f %i %i %3i %8.3f %8.3f %7.3f",
313  ch, S3d_length[6-i], scWidth, scThick, scAngle, set_x, set_y, set_z) << endl;
314  }
315  set_x -= (swidth+dwrap)/sqrt(2);
316  set_y -= (swidth+dwrap)/sqrt(2);
317  for( int i=0; i<n_tv; i++ )
318  {
319  transrot = new TGeoCombiTrans( set_x, set_y, set_z, rot );
320  NL3->AddNodeOverlap(slat_S3,++ch,transrot);
321  cout << Form("%3d: %2d (%8.3f, %8.3f, %8.3f) S3 ", ch, i+1+n_tc, set_x, set_y, set_z) << endl;
322 
323  /*
324  out << Form("%3d %d %d %2d %8.3f %8.3f %8.3f %8.3f S3 ",
325  ch, side, scLayer, i+1+n_tc, length_S3, set_x, set_y, set_z) << endl;
326  */
327  out << Form("%3d %7.3f %i %i %3i %8.3f %8.3f %7.3f",
328  ch, length_S3, scWidth, scThick, scAngle, set_x, set_y, set_z) << endl;
329 
330  set_x -= (swidth+dwrap)*sqrt(2);
331  }
332 
333  cout << "==== NL4 (v segmentation)" << endl;
334  scLayer = 4;
335  scAngle = 135;
336  set_z = fmsSmallCellOuterEdge + 30.0;
337  //Full lengths
338  set_x = -65.5;
339  set_y = start_y+(60.0+dwrap)/sqrt(2)+(swidth+dwrap)/2.0;
340  rot = new TGeoRotation("L4",45,0,0);
341  set_y += (swidth+dwrap)*sqrt(2)*(n_v-1);
342  for( int i=0; i<n_v; i++ )
343  {
344  transrot = new TGeoCombiTrans( set_x, set_y, set_z, rot );
345  L4->AddNodeOverlap(slat_S3,++ch,transrot);
346  cout << Form("%3d: %2d (%8.3f, %8.3f, %8.3f) S3 ", ch, i+1, set_x, set_y, set_z) << endl;
347 
348  /*
349  out << Form("%3d %d %d %2d %8.3f %8.3f %8.3f %8.3f S3 ",
350  ch, side, scLayer, i+1, length_S3, set_x, set_y, set_z) << endl;
351  */
352  out << Form("%3d %7.3f %i %i %3i %8.3f %8.3f %7.3f",
353  ch, length_S3, scWidth, scThick, scAngle, set_x, set_y, set_z) << endl;
354 
355  set_y -= (swidth+dwrap)*sqrt(2);
356  }
357  //Bottom corner
358  set_x = -65.5;
359  set_y = start_y+(60.0+dwrap)/sqrt(2)+(swidth+dwrap)/2.0;
360  rot = new TGeoRotation("L4",45,0,0);
361  for( int i=0; i<n_c; i++ )
362  {
363  set_x -= (swidth+dwrap)/sqrt(2);
364  set_y -= (swidth+dwrap)/sqrt(2);
365  transrot = new TGeoCombiTrans( set_x, set_y, set_z, rot );
366  L4->AddNodeOverlap(slat_S3c[i],++ch,transrot);
367  cout << Form("%3d: %2d (%8.3f, %8.3f, %8.3f) S3-%d ", ch, i+1+n_v, set_x, set_y, set_z, i+1) << endl;
368 
369  /*
370  out << Form("%3d %d %d %2d %8.3f %8.3f %8.3f %8.3f S3-%d ",
371  ch, side, scLayer, i+1+n_v, S3d_length[i], set_x, set_y, set_z, i+1) <<endl;
372  */
373  out << Form("%3d %7.3f %i %i %3i %8.3f %8.3f %7.3f",
374  ch, S3d_length[i], scWidth, scThick, scAngle, set_x, set_y, set_z) <<endl;
375  }
376 
377  cout << "==== NL5 (y segmentation)" << endl;
378  scLayer = 5;
379  scAngle = 0;
380  set_x = -65.5;
381  set_y = start_y+(swidth+dwrap)/2.0;
382  set_z = fmsSmallCellOuterEdge + 35.0;
383  rot = new TGeoRotation("L5",-90,0,0);
384  set_y += (swidth+dwrap)*(n_y-1);
385  for( int i=0; i<n_y; i++ )
386  {
387  transrot = new TGeoCombiTrans( set_x, set_y, set_z, rot );
388  L5->AddNodeOverlap(slat_S2,++ch,transrot);
389  cout << Form("%3d: %2d (%8.3f, %8.3f, %8.3f) S2 ", ch, i+1, set_x, set_y, set_z) << endl;
390 
391  /*
392  out << Form("%3d %d %d %2d %8.3f %8.3f %8.3f %8.3f S2 ",
393  ch, side, scLayer, i+1, length_S2, set_x, set_y, set_z) << endl;
394  */
395  out << Form("%3d %7.3f %i %i %3i %8.3f %8.3f %7.3f",
396  ch, length_S2, scWidth, scThick, scAngle, set_x, set_y, set_z) << endl;
397 
398  set_y -= swidth+dwrap;
399  }
400 
401  cout << "==== NL6 (x segmentation)" << endl;
402  scLayer = 6;
403  scAngle = 90;
404  set_x = -start_x-(swidth+dwrap)/2.0;
405  set_y = 108.0/2.0;
406  set_z = fmsSmallCellOuterEdge + 40.0;
407  for( int i=0; i<n_x; i++ )
408  {
409  // Top
410  set_y = 108.0/2.0;
411  trans = new TGeoTranslation(set_x, set_y,set_z);
412  L4->AddNodeOverlap(slat_S1,++ch,trans);
413  cout << Form("%3d: %2d (%8.3f, %8.3f, %8.3f) S1 ", ch, i+1, set_x, set_y, set_z) << endl;
414 
415  /*
416  out << Form("%3d %d %d %2d %8.3f %8.3f %8.3f %8.3f S1 ",
417  ch, side, scLayer, i+1, length_S1, set_x, set_y, set_z) << endl;
418  */
419  out << Form("%3d %7.3f %i %i %3i %8.3f %8.3f %7.3f",
420  ch, length_S1, scWidth, scThick, scAngle, set_x, set_y, set_z) << endl;
421 
422  set_x += -swidth+dwrap;
423 
424  }
425  set_x = -start_x-(swidth+dwrap)/2.0;
426  set_y = -108.0/2.0;
427  for( int i=n_x; i<n_x*2; i++ )
428  {
429  // Bottom (will need 180 deg rotation with light guides)
430  set_y = -108.0/2.0;
431  trans = new TGeoTranslation(set_x, set_y, set_z);
432  L4->AddNodeOverlap(slat_S1,++ch,trans);
433  cout << Form("%3d: %2d (%8.3f, %8.3f, %8.3f) S1 ", ch, i+1, set_x, set_y, set_z) << endl;
434 
435  /*
436  out << Form("%3d %d %d %2d %8.3f %8.3f %8.3f %8.3f S1 ",
437  ch, side, scLayer, i+1, length_S1, set_x, set_y, set_z) << endl;
438  */
439  out << Form("%3d %7.3f %i %i %3i %8.3f %8.3f %7.3f",
440  ch, length_S1, scWidth, scThick, scAngle, set_x, set_y, set_z) << endl;
441 
442  set_x += -swidth+dwrap;
443  }
444 
445  out.close();
446  if( !show->Contains("1") ) SL1->SetVisDaughters( kFALSE );
447  if( !show->Contains("2") ) SL2->SetVisDaughters( kFALSE );
448  if( !show->Contains("3") ) NL3->SetVisDaughters( kFALSE );
449  if( !show->Contains("4") ) L4->SetVisDaughters( kFALSE );
450  if( !show->Contains("5") ) L5->SetVisDaughters( kFALSE );
451  if( !show->Contains("6") ) L6->SetVisDaughters( kFALSE );
452  top->Draw();
453  //top->Draw("ogl");
454 }