]> git.uio.no Git - u/mrichter/AliRoot.git/blob - ITS/AliITSv4.cxx
Remove html/picts link before recreating it
[u/mrichter/AliRoot.git] / ITS / AliITSv4.cxx
1 ///////////////////////////////////////////////////////////////////////////////
2 //                                                                           //
3 //  Inner Traking System version 4                                           //
4 //                                                                           //
5 //Begin_Html
6 /*
7 <img src="picts/AliITSv4Class.gif">
8 </pre>
9 <br clear=left>
10 <font size=+2 color=red>
11 <p>The responsible person for this module is
12 <a href="mailto:roberto.barbera@ct.infn.it">Roberto Barbera</a>.
13 </font>
14 <pre>
15 */
16 //End_Html
17 //                                                                           //
18 ///////////////////////////////////////////////////////////////////////////////
19  
20 #include <TMath.h>
21 #include <TRandom.h>
22 #include <TVector.h>
23 #include "AliITSv4.h"
24 #include "AliRun.h"
25 #include "AliCallf77.h"
26
27 #include "TGeant3.h"
28
29 # define its_geo4          its_geo4_
30 extern "C" void type_of_call its_geo4(Int_t&, Int_t*);
31   
32 ClassImp(AliITSv4)
33  
34 //_____________________________________________________________________________
35 AliITSv4::AliITSv4() : AliITS() 
36 {
37   //
38   // Default constructor for the ITS
39   //
40   fMinorVersion=1;
41 }
42  
43 //_____________________________________________________________________________
44 AliITSv4::AliITSv4(const char *name, const char *title)
45   : AliITS(name, title)
46 {
47   //
48   // Standard constructor
49   //
50   fMinorVersion=1;
51 }
52  
53 //_____________________________________________________________________________
54 void AliITSv4::CreateGeometry()
55 {
56   //
57   // Create geometry for its version 4
58   //
59   AliMC* pMC = AliMC::GetMC();
60 #ifndef NEW
61   Int_t ivers=4*10+fMinorVersion;
62   its_geo4(ivers, gAlice->Idtmed());
63 #else
64 // *** DEFINITION OF THE GEOMETRY OF THE ITS *** 
65 // *** RB APR-1990 CATANIA *** 
66 // ORIGIN    : ROBERTO BARBERA 
67
68     Float_t xx[13] = { 0.,0.,-4.824,-4.833,-22.167,-22.585,-28.07,-27.626,
69             -38.139,-19.749,-13.449,-14.726,0. };
70     Float_t yy[13] = { 0.,34.028,34.064,
71             32.594,29.984,30.914,29.18,27.777,22.522,-7.918,-4.769,-2.216,0. };
72     Float_t xbeg[12] = { 0.,-.497,-4.827,-5.425,-22.395,-23.009,-27.919,
73             -28.161,-37.859,-19.337,-13.673,-13.773 };
74     Float_t ybeg[12] = { .43,34.032,33.564,
75             32.505,30.493,30.781,28.702,27.509,22.058,-7.711,-4.322,-2.073 };
76     Float_t xend[12] = { 0.,-4.323,-4.83,-21.643,-22.395,-27.593,-27.807,
77             -37.655,-19.988,-13.897,-14.294,-.425 };
78     Float_t yend[12] = { 33.531,34.06,33.192,
79             30.064,30.493,29.33,28.347,22.764,-7.523,-4.992,-3.077,-.064 };
80     Float_t xarc[12] = { -19.56,-14.12,-13.669,-.5,-.5,-4.327,-5.529,-21.746,
81             -22.858,-27.442,-28.474,-37.431 };
82     Float_t yarc[12] = { -7.264,-4.545,-2.765,
83             .431,33.531,33.56,33.197,30.756,30.304,28.854,28.136,22.316 };
84     Float_t rarc[12] = { .5,.5,.7,.5,.5,.5,.7,.7,.5,.5,.7,.5 };
85     Float_t rr    = 4.08332;
86     Float_t tteta = 63.;
87     Float_t pphi  = -27.;
88     Float_t gteta = 89.4;
89
90     static Double_t biga, bigb;
91     Float_t dcei[3], dela[3], dchi[3], dpcb[3], darc[5], dfra[10], dcer[3], dkap[3], dpla[3], xccc, yccc, aphi, dcop[3], dtra[3], dsil[3], 
92             atheta1213, dbus[3], dtub[3], dwat[3], depx[3], dits[3], atheta1112, atheta1011, dsup[3], xtra[8], ytra[8], ztra[8], dsrv[3];
93     static Double_t biga1, bigb1;
94     Float_t runo, xpos, ypos, zpos, rtwo, aphi1, aphi2, dtra1[3], dtra2[3], dtra3[3], dtra4[3], dbox1[3], dbox2[3];
95     Int_t jbox1, jbox2;
96     Float_t xtra1[6], ytra1[6], ztra1[6];
97     Int_t i;
98     Float_t xpos1, ypos1;
99     Int_t j;
100     Float_t angle, dcone[5], dtube[3], dpgon[10];
101     Float_t rzero, xzero, yzero;
102     static Double_t coeffa, coeffb, coeffc;
103     Int_t idrotm[5250];
104     Float_t atheta, offset;
105     Float_t offset1, offset2, dgh[15];
106     extern Double_t atg_(Float_t *, real *);
107     Float_t xcc, ycc, sep, atheta12, atheta23, atheta34, atheta45, atheta56, atheta67, atheta78, atheta89, yos, xxm, dal1[3], dal2[3];
108
109     static Double_t xcc1, ycc1, xcc2, ycc2;
110     Float_t atheta910;
111
112     Int_t *idtmed = gAlice->Idtmed();
113     
114 #define natra_ref(a_0,a_1) &natra[(a_1)*4 + a_0 - 4]
115 #define natra1_ref(a_0,a_1) &natra1[(a_1)*4 + a_0 - 4]
116 #define natra2_ref(a_0,a_1) &natra2[(a_1)*4 + a_0 - 4]
117 #define natra3_ref(a_0,a_1) &natra3[(a_1)*4 + a_0 - 4]
118 #define natra4_ref(a_0,a_1) &natra4[(a_1)*4 + a_0 - 4]
119
120
121 // --- Define ghost volume containing the whole ITS and fill it with air 
122 //     or vacuum 
123
124 // 89.4 = 90.-0.6 
125     dgh[0] = 0.;
126     dgh[1] = 360.;
127     dgh[2] = 4.;
128     dgh[3] = -70.;
129     dgh[4] = 49.999;
130     dgh[5] = 49.999;
131     dgh[6] = -25.;
132     dgh[7] = 3.;
133     dgh[8] = 49.999;
134     dgh[9] = 25.;
135     dgh[10] = 3.;
136     dgh[11] = 49.999;
137     dgh[12] = 70.;
138     dgh[13] = 49.999;
139     dgh[14] = 49.999;
140     geant->Gsvolu("ITSV", "PCON", idtmed[275], dgh, 15);
141
142 // --- Place the ghost volume in its mother volume (ALIC) and make it 
143 //     invisible 
144
145     geant->Gspos("ITSV", 1, "ALIC", 0., 0., 0., 0, "ONLY");
146     geant->Gsatt("ITSV", "SEEN", 0);
147
148 //************************************************************************
149 //*                                                                      *
150 //*                               P I X E L S                            *
151 //*                               ===========                            *
152 //*                                                                      *
153 //************************************************************************
154
155 //      GOTO 2345             ! skip ITS layer no. 1 and 2 
156
157 //--- Define ghost volume containing the Pixel Detectors and fill it with air
158 //     or vacuum 
159
160     xxm = 1.0444222222222224;
161     dgh[0] = 0.;
162     dgh[1] = 360.;
163     dgh[2] = 4.;
164     dgh[3] = -25. - 5.9900000000000002 / xxm;
165     dgh[4] = 9.;
166     dgh[5] = 9.;
167     dgh[6] = -25.;
168     dgh[7] = 3.01;
169     dgh[8] = 9.;
170     dgh[9] = 25.;
171     dgh[10] = 3.01;
172     dgh[11] = 9.;
173     dgh[12] = 5.9900000000000002 / xxm + 25.;
174     dgh[13] = 9.;
175     dgh[14] = 9.;
176     geant->Gsvolu("IT12", "PCON", idtmed[275], dgh, 15);
177
178 // --- Place the ghost volume in its mother volume (ITSV) and make it 
179 //     invisible 
180
181     geant->Gspos("IT12", 1, "ITSV", 0., 0., 0., 0, "ONLY");
182     geant->Gsatt("IT12", "SEEN", 0);
183
184 // --- Define a ghost volume containing a single element of layer #1 
185 //     and fill it with air or vacuum 
186
187     dbox1[0] = .022499999999999999;
188     dbox1[1] = .79;
189     dbox1[2] = 12.67;
190     geant->Gsvolu("IPV1", "BOX ", idtmed[203], dbox1, 3);
191             ;
192
193 //--- Divide each element of layer #1 in three ladders along the beam direction
194
195     geant->Gsdvn("IPB1", "IPV1", 3, 3);
196
197 // --- Make the ghost volumes invisible 
198
199     geant->Gsatt("IPV1", "SEEN", 0);
200     geant->Gsatt("IPB1", "SEEN", 0);
201
202 // --- Define a volume containing the chip of pixels (silicon, layer #1) 
203
204     dchi[0] = .005;
205     dchi[1] = .79;
206     dchi[2] = dbox1[2] / 3.;
207     geant->Gsvolu("ICH1", "BOX ", idtmed[200], dchi, 3);
208
209 // --- Define a volume containing the bus of pixels (silicon, layer #1) 
210
211     dbus[0] = .01;
212     dbus[1] = .64;
213     dbus[2] = 4.19;
214     geant->Gsvolu("IBU1", "BOX ", idtmed[201], dbus, 3);
215
216 // --- Define a volume containing the sensitive part of pixels 
217 //     (silicon, layer #1) 
218
219     dits[0] = .0075;
220     dits[1] = .64;
221     dits[2] = 4.19;
222     geant->Gsvolu("ITS1", "BOX ", idtmed[199], dits, 3);
223
224 // --- Place the chip into its mother (IPB1) 
225
226     xpos = dbox1[0] - dchi[0];
227     ypos = 0.;
228     zpos = 0.;
229     geant->Gspos("ICH1", 1, "IPB1", xpos, ypos, zpos, 0, "ONLY");
230
231 // --- Place the sensitive volume into its mother (IPB1) 
232
233     xpos = dbox1[0] - dchi[0] * 2. - dits[0];
234     ypos = dchi[1] - dits[1];
235     zpos = -(dchi[2] - dits[2]);
236     geant->Gspos("ITS1", 1, "IPB1", xpos, ypos, zpos, 0, "ONLY");
237
238 // --- Place the bus into its mother (IPB1) 
239
240     xpos = dbox1[0] - dchi[0] * 2. - dits[0] * 2. - dbus[0];
241     ypos = dchi[1] - dbus[1];
242     zpos = -(dchi[2] - dbus[2]);
243     geant->Gspos("IBU1", 1, "IPB1", xpos, ypos, zpos, 0, "ONLY");
244
245 // --- Define a ghost volume containing a single element of layer #2 
246 //     and fill it with air or vacuum 
247
248     dbox2[0] = .022499999999999999;
249     dbox2[1] = .79;
250     dbox2[2] = 16.91;
251     geant->Gsvolu("IPV2", "BOX ", idtmed[203], dbox2, 3);
252             ;
253
254 //--- Divide each element of layer #2 in four ladders along the beam direction
255
256     geant->Gsdvn("IPB2", "IPV2", 4, 3);
257
258 // --- Make the ghost volumes invisible 
259
260     geant->Gsatt("IPV2", "SEEN", 0);
261     geant->Gsatt("IPB2", "SEEN", 0);
262
263 // --- Define a volume containing the chip of pixels (silicon, layer #2) 
264
265     dchi[0] = .005;
266     dchi[1] = .79;
267     dchi[2] = dbox2[2] / 4.;
268     geant->Gsvolu("ICH2", "BOX ", idtmed[200], dchi, 3);
269
270 // --- Define a volume containing the bus of pixels (silicon, layer #2) 
271
272     dbus[0] = .01;
273     dbus[1] = .64;
274     dbus[2] = 4.19;
275     geant->Gsvolu("IBU2", "BOX ", idtmed[201], dbus, 3);
276
277 // --- Define a volume containing the sensitive part of pixels 
278 //     (silicon, layer #2) 
279
280     dits[0] = .0075;
281     dits[1] = .64;
282     dits[2] = 4.19;
283     geant->Gsvolu("ITS2", "BOX ", idtmed[199], dits, 3);
284
285 // --- Place the chip into its mother (IPB2) 
286
287     xpos = dbox1[0] - dbus[0] * 2. - dits[0] * 2. - dchi[0];
288     ypos = 0.;
289     zpos = 0.;
290     geant->Gspos("ICH2", 1, "IPB2", xpos, ypos, zpos, 0, "ONLY");
291
292 // --- Place the sensitive volume into its mother (IPB2) 
293
294     xpos = dbox1[0] - dbus[0] * 2. - dits[0];
295     ypos = -(dchi[1] - dits[1]);
296     zpos = -(dchi[2] - dits[2]);
297     geant->Gspos("ITS2", 1, "IPB2", xpos, ypos, zpos, 0, "ONLY");
298
299 // --- Place the bus into its mother (IPB2) 
300
301     xpos = dbox1[0] - dbus[0];
302     ypos = -(dchi[1] - dbus[1]);
303     zpos = -(dchi[2] - dbus[2]);
304     geant->Gspos("IBU2", 1, "IPB2", xpos, ypos, zpos, 0, "ONLY");
305
306 // --- Define a generic segment of an element of the mechanical support 
307
308     dsup[0] = 0.;
309     dsup[1] = 0.;
310     dsup[2] = 0.;
311     geant->Gsvolu("SPIX", "BOX ", idtmed[202], dsup, 0);
312
313 // --- Define a generic arc of an element of the mechanical support 
314
315     darc[0] = 0.;
316     darc[1] = 0.;
317     darc[2] = 0.;
318     geant->Gsvolu("SARC", "TUBS", idtmed[202], darc, 0);
319
320 // --- Define the mechanical supports of layers #1 and #2 and place the 
321 //     elements of the layers in it 
322
323     jbox1 = 0;
324 // counter over the number of elements of layer #1 ( 
325     jbox2 = 0;
326
327 // counter over the number of elements of layer #2 ( 
328     for (i = 1; i <= 10; ++i) {
329
330 // --- Place part # 1-2 (see sketch) 
331
332 // number of carbon fiber supports (see sketch) 
333         offset1 = -27.;
334         dsup[0] = .01;
335         dsup[1] = TMath::Sqrt((xend[0] - xbeg[0]) * (xend[0] - xbeg[0]) + (yend[0] - ybeg[0]) * (yend[0] - ybeg[0])) / 20.;
336         dsup[2] = 25.;
337         xcc     = (xx[0] + xx[1]) / 20.;
338         ycc     = (yy[0] + yy[1]) / 20.;
339         xccc    = (xbeg[0] + xend[0]) / 20.;
340         yccc    = (ybeg[0] + yend[0]) / 20.;
341         if (xx[0] == xx[1]) {
342             offset2 = 0.;
343         } else {
344             r2 = xx[1] - xx[0];
345             offset2 = atg_(&yy[1] - yy[0], &r2) * raddeg - 90.;
346         }
347         aphi  = (pphi + (i-1) * 36.) * degrad;
348         xzero = rr * TMath::Cos((tteta + (i-1) * 36.) * degrad);
349         yzero = rr * TMath::Sin((tteta + (i-1) * 36.) * degrad);
350         xpos1 = xccc * TMath::Cos(aphi) - yccc * TMath::Sin(aphi) + xzero;
351         ypos1 = xccc * TMath::Sin(aphi) + yccc * TMath::Cos(aphi) + yzero;
352         xpos  = xpos1 * TMath::Cos(gteta * degrad) + ypos1 * TMath::Sin(gteta *degrad);
353         ypos  = -xpos1 * TMath::Sin(gteta * degrad) + ypos1 * TMath::Cos(gteta * degrad);
354         zpos  = 0.;
355         atheta12 = (i-1) * 36. + offset1 + offset2 - gteta;
356         AliMatrix(idrotm[(i-1) * 13 + 1100], 90., atheta12, 90., atheta12 + 90., 0., 0.);
357         geant->Gsposp("SPIX", (i-1) * 13 + 1, "IT12", xpos, ypos, zpos, idrotm[(i-1) * 13 + 1100], "ONLY", dsup, 3);
358
359 // --- Place part # 2-3 (see sketch) 
360
361         offset1 = -27.;
362         dsup[0] = .01;
363         dsup[1] = TMath::Sqrt((xend[1] - xbeg[1]) * (xend[1] - xbeg[1]) + (yend[1] - ybeg[1]) * (yend[1] - ybeg[1])) / 20.;
364         dsup[2] = 25.;
365         xcc     = (xx[1] + xx[2]) / 20.;
366         ycc     = (yy[1] + yy[2]) / 20.;
367         xccc    = (xbeg[1] + xend[1]) / 20.;
368         yccc    = (ybeg[1] + yend[1]) / 20.;
369         if (xx[1] == xx[2]) {
370             offset2 = 0.;
371         } else {
372             r2 = xx[2] - xx[1];
373             offset2 = atg_(&yy[2] - yy[1], &r2) * raddeg - 90.;
374         }
375         aphi  = (pphi + (i-1) * 36.) * degrad;
376         xzero = rr * TMath::Cos((tteta + (i-1) * 36.) * degrad);
377         yzero = rr * TMath::Sin((tteta + (i-1) * 36.) * degrad);
378         xpos1 = xccc * TMath::Cos(aphi) - yccc * TMath::Sin(aphi) + xzero;
379         ypos1 = xccc * TMath::Sin(aphi) + yccc * TMath::Cos(aphi) + yzero;
380         xpos  = xpos1 * TMath::Cos(gteta * degrad) + ypos1 * TMath::Sin(gteta *degrad);
381         ypos  = -xpos1 * TMath::Sin(gteta * degrad) + ypos1 * TMath::Cos(gteta * degrad);
382         zpos  = 0.;
383         atheta23 = (i-1) * 36. + offset1 + offset2 - gteta;
384         AliMatrix(idrotm[(i-1) * 13 + 1101], 90., atheta23, 90., atheta23 + 90., 0., 0.);
385         geant->Gsposp("SPIX", (i-1) * 13 + 2, "IT12", xpos, ypos, zpos, idrotm[(i-1) * 13 + 1101], "ONLY", dsup, 3);
386
387 // --- Place an element of layer #2 
388
389         biga   = (yy[2] - yy[1]) / (xx[2] - xx[1]);
390         bigb   = (xx[2] * yy[1] - xx[1] * yy[2]) / (xx[2] - xx[1]) / 10.;
391         coeffa = biga * biga + 1.;
392         coeffb = biga * bigb - biga * ycc - xcc;
393         coeffc = xcc * xcc + ycc * ycc - ycc * 2. * bigb + bigb * bigb - .0022212369;
394         xcc1   = (-coeffb + TMath::Sqrt(coeffb * coeffb - coeffa * coeffc)) / coeffa;
395         ycc1   = biga * xcc1 + bigb;
396         biga1  = -1. / biga;
397         bigb1  = xcc1 / biga + ycc1;
398         coeffa = biga1 * biga1 + 1.;
399         coeffb = biga1 * bigb1 - biga1 * ycc1 - xcc1;
400         coeffc = xcc1 * xcc1 + ycc1 * ycc1 - ycc1 * 2. * bigb1 + bigb1 * bigb1 - (dsup[0] + dbox2[0]) * (dsup[0] + dbox2[0]);
401         xcc2   = (-coeffb + TMath::Sqrt(coeffb * coeffb - coeffa * coeffc)) / coeffa;
402         ycc2   = biga1 * xcc2 + bigb1;
403         xpos1  = xcc2 * TMath::Cos(aphi) - ycc2 * TMath::Sin(aphi) + xzero;
404         ypos1  = xcc2 * TMath::Sin(aphi) + ycc2 * TMath::Cos(aphi) + yzero;
405         xpos   = xpos1 * TMath::Cos(gteta * degrad) + ypos1 * TMath::Sin(gteta *degrad);
406         ypos   = -xpos1 * TMath::Sin(gteta * degrad) + ypos1 * TMath::Cos(gteta * degrad);
407         zpos   = 0.;
408         ++jbox2;
409         geant->Gspos("IPV2", jbox2, "IT12", xpos, ypos, zpos, idrotm[(i-1) * 13 + 1101], "ONLY");
410
411 // --- Place part # 3-4 (see sketch) 
412
413         offset1 = -27.;
414         dsup[0] = .01;
415         dsup[1] = TMath::Sqrt((xend[2] - xbeg[2]) * (xend[2] - xbeg[2]) + (yend[2] - ybeg[2]) * (yend[2] - ybeg[2])) / 20.;
416         dsup[2] = 25.;
417         xcc     = (xx[1] + xx[2]) / 20.;
418         ycc     = (yy[1] + yy[2]) / 20.;
419         xccc    = (xbeg[2] + xend[2]) / 20.;
420         yccc    = (ybeg[2] + yend[2]) / 20.;
421         if (xx[2] == xx[3]) {
422             offset2 = 0.;
423         } else {
424             r2 = xx[3] - xx[2];
425             offset2 = atg_(&yy[3] - yy[2], &r2) * raddeg - 90.;
426         }
427         aphi  = (pphi + (i-1) * 36.) * degrad;
428         xzero = rr * TMath::Cos((tteta + (i-1) * 36.) * degrad);
429         yzero = rr * TMath::Sin((tteta + (i-1) * 36.) * degrad);
430         xpos1 = xccc * TMath::Cos(aphi) - yccc * TMath::Sin(aphi) + xzero;
431         ypos1 = xccc * TMath::Sin(aphi) + yccc * TMath::Cos(aphi) + yzero;
432         xpos  = xpos1 * TMath::Cos(gteta * degrad) + ypos1 * TMath::Sin(gteta *degrad);
433         ypos  = -xpos1 * TMath::Sin(gteta * degrad) + ypos1 * TMath::Cos(gteta * degrad);
434         zpos  = 0.;
435         atheta34 = (i-1) * 36. + offset1 + offset2 - gteta;
436         AliMatrix(idrotm[(i-1) * 13 + 1102], 90., atheta34, 90., atheta34 + 90., 0., 0.);
437         geant->Gsposp("SPIX", (i-1) * 13 + 3, "IT12", xpos, ypos, zpos, idrotm[(i-1) * 13 + 1102], "ONLY", dsup, 3);
438
439 // --- Place part # 4-5 (see sketch) 
440
441         offset1 = -27.;
442         dsup[0] = .01;
443         dsup[1] = TMath::Sqrt((xend[3] - xbeg[3]) * (xend[3] - xbeg[3]) + (yend[3] - ybeg[3]) * (yend[3] - ybeg[3])) / 20.;
444         dsup[2] = 25.;
445         xcc     = (xx[3] + xx[4]) / 20.;
446         ycc     = (yy[3] + yy[4]) / 20.;
447         xccc    = (xbeg[3] + xend[3]) / 20.;
448         yccc    = (ybeg[3] + yend[3]) / 20.;
449         if (xx[3] == xx[4]) {
450             offset2 = 0.;
451         } else {
452             r2 = xx[4] - xx[3];
453             offset2 = atg_(&yy[4] - yy[3], &r2) * raddeg - 90.;
454         }
455         aphi  = (pphi + (i-1) * 36.) * degrad;
456         xzero = rr * TMath::Cos((tteta + (i-1) * 36.) * degrad);
457         yzero = rr * TMath::Sin((tteta + (i-1) * 36.) * degrad);
458         xpos1 = xccc * TMath::Cos(aphi) - yccc * TMath::Sin(aphi) + xzero;
459         ypos1 = xccc * TMath::Sin(aphi) + yccc * TMath::Cos(aphi) + yzero;
460         xpos  = xpos1 * TMath::Cos(gteta * degrad) + ypos1 * TMath::Sin(gteta *degrad);
461         ypos  = -xpos1 * TMath::Sin(gteta * degrad) + ypos1 * TMath::Cos(gteta * degrad);
462         zpos  = 0.;
463         atheta45 = (i-1) * 36. + offset1 + offset2 - gteta;
464         AliMatrix(idrotm[(i-1) * 13 + 1103], 90., atheta45, 90., atheta45 + 90., 0., 0.);
465         geant->Gsposp("SPIX", (i-1) * 13 + 4, "IT12", xpos, ypos, zpos, idrotm[(i-1) * 13 + 1103], "ONLY", dsup, 3);
466
467 // --- Place an element of layer #2 
468
469         biga   = (yy[4] - yy[3]) / (xx[4] - xx[3]);
470         bigb   = (xx[4] * yy[3] - xx[3] * yy[4]) / (xx[4] - xx[3]) / 10.;
471         coeffa = biga * biga + 1.;
472         coeffb = biga * bigb - biga * ycc - xcc;
473         coeffc = xcc * xcc + ycc * ycc - ycc * 2. * bigb + bigb * bigb + 0.;
474         xcc1   = xccc;
475         ycc1   = yccc;
476         biga1  = -1. / biga;
477         bigb1  = xcc1 / biga + ycc1;
478         coeffa = biga1 * biga1 + 1.;
479         coeffb = biga1 * bigb1 - biga1 * ycc1 - xcc1;
480         coeffc = xcc1 * xcc1 + ycc1 * ycc1 - ycc1 * 2. * bigb1 + bigb1 * bigb1 - (dsup[0] + dbox2[0]) * (dsup[0] + dbox2[0]);
481         xcc2   = (-coeffb - TMath::Sqrt(coeffb * coeffb - coeffa * coeffc)) / coeffa;
482         ycc2   = biga1 * xcc2 + bigb1;
483         xpos1  = xcc2 * TMath::Cos(aphi) - ycc2 * TMath::Sin(aphi) + xzero;
484         ypos1  = xcc2 * TMath::Sin(aphi) + ycc2 * TMath::Cos(aphi) + yzero;
485         xpos   = xpos1 * TMath::Cos(gteta * degrad) + ypos1 * TMath::Sin(gteta *degrad);
486         ypos   = -xpos1 * TMath::Sin(gteta * degrad) + ypos1 * TMath::Cos(gteta * degrad);
487         zpos   = 0.;
488         ++jbox2;
489         geant->Gspos("IPV2", jbox2, "IT12", xpos, ypos, zpos, idrotm[(i-1) * 13 + 1103], "ONLY");
490
491 // --- Place part # 5-6 (see sketch) 
492
493         offset1 = -27.;
494         dsup[0] = .01;
495         dsup[1] = TMath::Sqrt((xend[4] - xbeg[4]) * (xend[4] - xbeg[4]) + (yend[4] - ybeg[4]) * (yend[4] - ybeg[4])) / 20.;
496         dsup[2] = 25.;
497         xcc     = (xx[4] + xx[5]) / 20.;
498         ycc     = (yy[4] + yy[5]) / 20.;
499         xccc    = (xbeg[4] + xend[4]) / 20.;
500         yccc    = (ybeg[4] + yend[4]) / 20.;
501         if (xx[4] == xx[5]) {
502             offset2 = 0.;
503         } else {
504             r2 = xx[5] - xx[4];
505             offset2 = atg_(&yy[5] - yy[4], &r2) * raddeg - 90.;
506         }
507         aphi  = (pphi + (i-1) * 36.) * degrad;
508         xzero = rr * TMath::Cos((tteta + (i-1) * 36.) * degrad);
509         yzero = rr * TMath::Sin((tteta + (i-1) * 36.) * degrad);
510         xpos1 = xccc * TMath::Cos(aphi) - yccc * TMath::Sin(aphi) + xzero;
511         ypos1 = xccc * TMath::Sin(aphi) + yccc * TMath::Cos(aphi) + yzero;
512         xpos  = xpos1 * TMath::Cos(gteta * degrad) + ypos1 * TMath::Sin(gteta *degrad);
513         ypos  = -xpos1 * TMath::Sin(gteta * degrad) + ypos1 * TMath::Cos(gteta * degrad);
514         zpos  = 0.;
515         atheta56 = (i-1) * 36. + offset1 + offset2 - gteta;
516         AliMatrix(idrotm[(i-1) * 13 + 1104], 90., atheta56, 90., atheta56 + 90., 0., 0.);
517         geant->Gsposp("SPIX", (i-1) * 13 + 5, "IT12", xpos, ypos, zpos, idrotm[(i-1) * 13 + 1104], "ONLY", dsup, 3);
518
519 // --- Place part # 6-7 (see sketch) 
520
521         offset1 = -27.;
522         dsup[0] = .01;
523         dsup[1] = TMath::Sqrt((xend[5] - xbeg[5]) * (xend[5] - xbeg[5]) + (yend[5] - ybeg[5]) * (yend[5] - ybeg[5])) / 20.;
524         dsup[2] = 25.;
525         xcc     = (xx[5] + xx[6]) / 20.;
526         ycc     = (yy[5] + yy[6]) / 20.;
527         xccc    = (xbeg[5] + xend[5]) / 20.;
528         yccc    = (ybeg[5] + yend[5]) / 20.;
529         if (xx[5] == xx[6]) {
530             offset2 = 0.;
531         } else {
532             r2 = xx[6] - xx[5];
533             offset2 = atg_(&yy[6] - yy[5], &r2) * raddeg - 90.;
534         }
535         aphi  = (pphi + (i-1) * 36.) * degrad;
536         xzero = rr * TMath::Cos((tteta + (i-1) * 36.) * degrad);
537         yzero = rr * TMath::Sin((tteta + (i-1) * 36.) * degrad);
538         xpos1 = xccc * TMath::Cos(aphi) - yccc * TMath::Sin(aphi) + xzero;
539         ypos1 = xccc * TMath::Sin(aphi) + yccc * TMath::Cos(aphi) + yzero;
540         xpos  = xpos1 * TMath::Cos(gteta * degrad) + ypos1 * TMath::Sin(gteta *degrad);
541         ypos  = -xpos1 * TMath::Sin(gteta * degrad) + ypos1 * TMath::Cos(gteta * degrad);
542         zpos  = 0.;
543         atheta67 = (i-1) * 36. + offset1 + offset2 - gteta;
544         AliMatrix(idrotm[(i-1) * 13 + 1105], 90., atheta67, 90., atheta67 + 90., 0., 0.);
545         geant->Gsposp("SPIX", (i-1) * 13 + 6, "IT12", xpos, ypos, zpos, idrotm[(i-1) * 13 + 1105], "ONLY", dsup, 3);
546
547 // --- Place an element of layer #2 
548
549         biga   = (yy[6] - yy[5]) / (xx[6] - xx[5]);
550         bigb   = (xx[6] * yy[5] - xx[5] * yy[6]) / (xx[6] - xx[5]) / 10.;
551         coeffa = biga * biga + 1.;
552         coeffb = biga * bigb - biga * ycc - xcc;
553         coeffc = xcc * xcc + ycc * ycc - ycc * 2. * bigb + bigb * bigb + 0.;
554         xcc1   = xccc;
555         ycc1   = yccc;
556         biga1  = -1. / biga;
557         bigb1  = xcc1 / biga + ycc1;
558         coeffa = biga1 * biga1 + 1.;
559         coeffb = biga1 * bigb1 - biga1 * ycc1 - xcc1;
560         coeffc = xcc1 * xcc1 + ycc1 * ycc1 - ycc1 * 2. * bigb1 + bigb1 * bigb1 - (dsup[0] + dbox2[0]) * (dsup[0] + dbox2[0]);
561         xcc2   = (-coeffb - TMath::Sqrt(coeffb * coeffb - coeffa * coeffc)) / coeffa;
562         ycc2   = biga1 * xcc2 + bigb1;
563         xpos1  = xcc2 * TMath::Cos(aphi) - ycc2 * TMath::Sin(aphi) + xzero;
564         ypos1  = xcc2 * TMath::Sin(aphi) + ycc2 * TMath::Cos(aphi) + yzero;
565         xpos   = xpos1 * TMath::Cos(gteta * degrad) + ypos1 * TMath::Sin(gteta *degrad);
566         ypos   = -xpos1 * TMath::Sin(gteta * degrad) + ypos1 * TMath::Cos(gteta * degrad);
567         zpos   = 0.;
568         ++jbox2;
569         geant->Gspos("IPV2", jbox2, "IT12", xpos, ypos, zpos, idrotm[(i-1) * 13 + 1105], "ONLY");
570
571 // --- Place part # 7-8 (see sketch) 
572
573         offset1 = -27.;
574         dsup[0] = .01;
575         dsup[1] = TMath::Sqrt((xend[6] - xbeg[6]) * (xend[6] - xbeg[6]) + (yend[6] - ybeg[6]) * (yend[6] - ybeg[6])) / 20.;
576         dsup[2] = 25.;
577         xcc     = (xx[6] + xx[7]) / 20.;
578         ycc     = (yy[6] + yy[7]) / 20.;
579         xccc    = (xbeg[6] + xend[6]) / 20.;
580         yccc    = (ybeg[6] + yend[6]) / 20.;
581         if (xx[6] == xx[7]) {
582             offset2 = 0.;
583         } else {
584             r2 = xx[7] - xx[6];
585             offset2 = atg_(&yy[7] - yy[6], &r2) * raddeg - 90.;
586         }
587         aphi  = (pphi + (i-1) * 36.) * degrad;
588         xzero = rr * TMath::Cos((tteta + (i-1) * 36.) * degrad);
589         yzero = rr * TMath::Sin((tteta + (i-1) * 36.) * degrad);
590         xpos1 = xccc * TMath::Cos(aphi) - yccc * TMath::Sin(aphi) + xzero;
591         ypos1 = xccc * TMath::Sin(aphi) + yccc * TMath::Cos(aphi) + yzero;
592         xpos  = xpos1 * TMath::Cos(gteta * degrad) + ypos1 * TMath::Sin(gteta *degrad);
593         ypos  = -xpos1 * TMath::Sin(gteta * degrad) + ypos1 * TMath::Cos(gteta * degrad);
594         zpos  = 0.;
595         atheta78 = (i-1) * 36. + offset1 + offset2 - gteta;
596         AliMatrix(idrotm[(i-1) * 13 + 1106], 90., atheta78, 90., atheta78 + 90., 0., 0.);
597         geant->Gsposp("SPIX", (i-1) * 13 + 7, "IT12", xpos, ypos, zpos, idrotm[(i-1) * 13 + 1106], "ONLY", dsup, 3);
598
599 // --- Place part # 8-9 (see sketch) 
600
601         offset1 = -27.;
602         dsup[0] = .01;
603         dsup[1] = TMath::Sqrt((xend[7] - xbeg[7]) * (xend[7] - xbeg[7]) + (yend[7] - ybeg[7]) * (yend[7] - ybeg[7])) / 20.;
604         dsup[2] = 25.;
605         xcc     = (xx[7] + xx[8]) / 20.;
606         ycc     = (yy[7] + yy[8]) / 20.;
607         xccc    = (xbeg[7] + xend[7]) / 20.;
608         yccc    = (ybeg[7] + yend[7]) / 20.;
609         if (xx[1] == xx[2]) {
610             offset2 = 0.;
611         } else {
612             r2 = xx[8] - xx[7];
613             offset2 = atg_(&yy[8] - yy[7], &r2) * raddeg - 90.;
614         }
615         aphi  = (pphi + (i-1) * 36.) * degrad;
616         xzero = rr * TMath::Cos((tteta + (i-1) * 36.) * degrad);
617         yzero = rr * TMath::Sin((tteta + (i-1) * 36.) * degrad);
618         xpos1 = xccc * TMath::Cos(aphi) - yccc * TMath::Sin(aphi) + xzero;
619         ypos1 = xccc * TMath::Sin(aphi) + yccc * TMath::Cos(aphi) + yzero;
620         xpos  = xpos1 * TMath::Cos(gteta * degrad) + ypos1 * TMath::Sin(gteta *degrad);
621         ypos  = -xpos1 * TMath::Sin(gteta * degrad) + ypos1 * TMath::Cos(gteta * degrad);
622         zpos  = 0.;
623         atheta89 = (i-1) * 36. + offset1 + offset2 - gteta;
624         AliMatrix(idrotm[(i-1) * 13 + 1107], 90., atheta89, 90., atheta89 + 90., 0., 0.);
625         geant->Gsposp("SPIX", (i-1) * 13 + 8, "IT12", xpos, ypos, zpos, idrotm[(i-1) * 13 + 1107], "ONLY", dsup, 3);
626
627 // --- Place an element of layer #2 
628
629         biga   = (yy[8] - yy[7]) / (xx[8] - xx[7]);
630         bigb   = (xx[8] * yy[7] - xx[7] * yy[8]) / (xx[8] - xx[7]) / 10.;
631         coeffa = biga * biga + 1.;
632         coeffb = biga * bigb - biga * ycc - xcc;
633         coeffc = xcc * xcc + ycc * ycc - ycc * 2. * bigb + bigb * bigb - .055526209599999994;
634         xcc1   = (-coeffb - TMath::Sqrt(coeffb * coeffb - coeffa * coeffc)) / coeffa;
635         ycc1   = biga * xcc1 + bigb;
636         biga1  = -1. / biga;
637         bigb1  = xcc1 / biga + ycc1;
638         coeffa = biga1 * biga1 + 1.;
639         coeffb = biga1 * bigb1 - biga1 * ycc1 - xcc1;
640         coeffc = xcc1 * xcc1 + ycc1 * ycc1 - ycc1 * 2. * bigb1 + bigb1 * bigb1 - (dsup[0] + dbox2[0]) * (dsup[0] + dbox2[0]);
641         xcc2   = (-coeffb - TMath::Sqrt(coeffb * coeffb - coeffa * coeffc)) / coeffa;
642         ycc2   = biga1 * xcc2 + bigb1;
643         xpos1  = xcc2 * TMath::Cos(aphi) - ycc2 * TMath::Sin(aphi) + xzero;
644         ypos1  = xcc2 * TMath::Sin(aphi) + ycc2 * TMath::Cos(aphi) + yzero;
645         xpos   = xpos1 * TMath::Cos(gteta * degrad) + ypos1 * TMath::Sin(gteta *degrad);
646         ypos   = -xpos1 * TMath::Sin(gteta * degrad) + ypos1 * TMath::Cos(gteta * degrad);
647         zpos   = 0.;
648         ++jbox2;
649         geant->Gspos("IPV2", jbox2, "IT12", xpos, ypos, zpos, idrotm[(i-1) * 13 + 1107], "ONLY");
650
651 // --- Place part # 9-10 (see sketch) 
652
653         offset1 = -27.;
654         dsup[0] = .01;
655         dsup[1] = TMath::Sqrt((xend[8] - xbeg[8]) * (xend[8] - xbeg[8]) + (yend[8] - ybeg[8]) * (yend[8] - ybeg[8])) / 20.;
656         dsup[2] = 25.;
657         xcc     = (xx[8] + xx[9]) / 20.;
658         ycc     = (yy[8] + yy[9]) / 20.;
659         xccc    = (xbeg[8] + xend[8]) / 20.;
660         yccc    = (ybeg[8] + yend[8]) / 20.;
661         if (xx[8] == xx[9]) {
662             offset2 = 0.;
663         } else {
664             r2 = xx[9] - xx[8];
665             offset2 = atg_(&yy[9] - yy[8], &r2) * raddeg - 90.;
666         }
667         aphi  = (pphi + (i-1) * 36.) * degrad;
668         xzero = rr * TMath::Cos((tteta + (i-1) * 36.) * degrad);
669         yzero = rr * TMath::Sin((tteta + (i-1) * 36.) * degrad);
670         xpos1 = xccc * TMath::Cos(aphi) - yccc * TMath::Sin(aphi) + xzero;
671         ypos1 = xccc * TMath::Sin(aphi) + yccc * TMath::Cos(aphi) + yzero;
672         xpos  = xpos1 * TMath::Cos(gteta * degrad) + ypos1 * TMath::Sin(gteta *degrad);
673         ypos  = -xpos1 * TMath::Sin(gteta * degrad) + ypos1 * TMath::Cos(gteta * degrad);
674         zpos  = 0.;
675         atheta910 = (i-1) * 36. + offset1 + offset2 - gteta;
676         AliMatrix(idrotm[(i-1) * 13 + 1108], 90., atheta910, 90., atheta910 + 90., 0., 0.);
677         geant->Gsposp("SPIX", (i-1) * 13 + 9, "IT12", xpos, ypos, zpos, idrotm[(i-1) * 13 + 1108], "ONLY", dsup, 3);
678
679 // --- Place part # 12-13 (see sketch) 
680
681         offset1 = -27.;
682         dsup[0] = .01;
683         dsup[1] = TMath::Sqrt((xend[11] - xbeg[11]) * (xend[11] - xbeg[11]) + (yend[11] - ybeg[11]) * (yend[11] - ybeg[11])) / 20.;
684         dsup[2] = 25.;
685         xcc     = (xx[11] + xx[12]) / 20.;
686         ycc     = (yy[11] + yy[12]) / 20.;
687         xccc    = (xbeg[11] + xend[11]) / 20.;
688         yccc    = (ybeg[11] + yend[11]) / 20.;
689         if (xx[11] == xx[12]) {
690             offset2 = 0.;
691         } else {
692             r2 = xx[12] - xx[11];
693             offset2 = atg_(&yy[12] - yy[11], &r2) * raddeg - 90.;
694         }
695         aphi  = (pphi + (i-1) * 36.) * degrad;
696         xzero = rr * TMath::Cos((tteta + (i-1) * 36.) * degrad);
697         yzero = rr * TMath::Sin((tteta + (i-1) * 36.) * degrad);
698         xpos1 = xccc * TMath::Cos(aphi) - yccc * TMath::Sin(aphi) + xzero;
699         ypos1 = xccc * TMath::Sin(aphi) + yccc * TMath::Cos(aphi) + yzero;
700         xpos  = xpos1 * TMath::Cos(gteta * degrad) + ypos1 * TMath::Sin(gteta *degrad);
701         ypos  = -xpos1 * TMath::Sin(gteta * degrad) + ypos1 * TMath::Cos(gteta * degrad);
702         zpos  = 0.;
703         atheta1213 = (i-1) * 36. + offset1 + offset2 - gteta;
704         AliMatrix(idrotm[(i-1) * 13 + 1111], 270., atheta1213, 90., atheta1213 + 270., 0., 0.);
705         geant->Gsposp("SPIX", (i-1) * 13 + 12, "IT12", xpos, ypos, zpos, idrotm[(i-1) * 13 + 1111], "ONLY", dsup, 3);
706
707 // --- Place an element of layer #1 
708
709         biga   = (yy[12] - yy[11]) / (xx[12] - xx[11]);
710         bigb   = (xx[12] * yy[11] - xx[11] * yy[12]) / (xx[12] - xx[11]) / 10.;
711         coeffa = biga * biga + 1.;
712         coeffb = biga * bigb - biga * ycc - xcc;
713         coeffc = xcc * xcc + ycc * ycc - ycc * 2. * bigb + bigb * bigb - .015792948900000003;
714         xcc1   = (-coeffb + TMath::Sqrt(coeffb * coeffb - coeffa * coeffc)) / coeffa;
715         ycc1   = biga * xcc1 + bigb;
716         biga1  = -1. / biga;
717         bigb1  = xcc1 / biga + ycc1;
718         coeffa = biga1 * biga1 + 1.;
719         coeffb = biga1 * bigb1 - biga1 * ycc1 - xcc1;
720         coeffc = xcc1 * xcc1 + ycc1 * ycc1 - ycc1 * 2. * bigb1 + bigb1 * bigb1 - (dsup[0] + dbox1[0]) * (dsup[0] + dbox1[0]);
721         xcc2   = (-coeffb + TMath::Sqrt(coeffb * coeffb - coeffa * coeffc)) / coeffa;
722         ycc2   = biga1 * xcc2 + bigb1;
723         xpos1  = xcc2 * TMath::Cos(aphi) - ycc2 * TMath::Sin(aphi) + xzero;
724         ypos1  = xcc2 * TMath::Sin(aphi) + ycc2 * TMath::Cos(aphi) + yzero;
725         xpos   = xpos1 * TMath::Cos(gteta * degrad) + ypos1 * TMath::Sin(gteta *degrad);
726         ypos   = -xpos1 * TMath::Sin(gteta * degrad) + ypos1 * TMath::Cos(gteta * degrad);
727         zpos   = 0.;
728         ++jbox1;
729         geant->Gspos("IPV1", jbox1, "IT12", xpos, ypos, zpos, idrotm[(i-1) * 13 + 1111], "ONLY");
730
731 // --- Place part # 11-12 (see sketch) 
732
733         offset1 = -27.;
734         dsup[0] = .01;
735         dsup[1] = TMath::Sqrt((xend[10] - xbeg[10]) * (xend[10] - xbeg[10]) + (yend[10] - ybeg[10]) * (yend[10] - ybeg[10])) / 20.;
736         dsup[2] = 25.;
737         xcc     = (xx[10] + xx[11]) / 20.;
738         ycc     = (yy[10] + yy[11]) / 20.;
739         xccc    = (xbeg[10] + xend[10]) / 20.;
740         yccc    = (ybeg[10] + yend[10]) / 20.;
741         if (xx[10] == xx[11]) {
742             offset2 = 0.;
743         } else {
744             r2 = xx[11] - xx[10];
745             offset2 = atg_(&yy[11] - yy[10], &r2) * raddeg - 90.;
746         }
747         aphi  = (pphi + (i-1) * 36.) * degrad;
748         xzero = rr * TMath::Cos((tteta + (i-1) * 36.) * degrad);
749         yzero = rr * TMath::Sin((tteta + (i-1) * 36.) * degrad);
750         xpos1 = xccc * TMath::Cos(aphi) - yccc * TMath::Sin(aphi) + xzero;
751         ypos1 = xccc * TMath::Sin(aphi) + yccc * TMath::Cos(aphi) + yzero;
752         xpos  = xpos1 * TMath::Cos(gteta * degrad) + ypos1 * TMath::Sin(gteta *degrad);
753         ypos  = -xpos1 * TMath::Sin(gteta * degrad) + ypos1 * TMath::Cos(gteta * degrad);
754         zpos  = 0.;
755         atheta1112 = (i-1) * 36. + offset1 + offset2 - gteta;
756         AliMatrix(idrotm[(i-1) * 13 + 1110], 90., atheta1112, 90.,atheta1112 + 90., 0., 0.);
757         geant->Gsposp("SPIX", (i-1) * 13 + 11, "IT12", xpos, ypos, zpos, idrotm[(i-1) * 13 + 1110], "ONLY", dsup, 3);
758
759 // --- Place part # 10-11 (see sketch) 
760
761         offset1 = -27.;
762         dsup[0] = .01;
763         dsup[1] = TMath::Sqrt((xend[9] - xbeg[9]) * (xend[9] - xbeg[9]) + (yend[9] - ybeg[9]) * (yend[9] - ybeg[9])) / 20.;
764         dsup[2] = 25.;
765         xcc     = (xx[9] + xx[10]) / 20.;
766         ycc     = (yy[9] + yy[10]) / 20.;
767         xccc    = (xbeg[9] + xend[9]) / 20.;
768         yccc    = (ybeg[9] + yend[9]) / 20.;
769         if (xx[9] == xx[10]) {
770             offset2 = 0.;
771         } else {
772             r2 = xx[10] - xx[9];
773             offset2 = atg_(&yy[10] - yy[9], &r2) * raddeg - 90.;
774         }
775         aphi  = (pphi + (i-1) * 36.) * degrad;
776         xzero = rr * TMath::Cos((tteta + (i-1) * 36.) * degrad);
777         yzero = rr * TMath::Sin((tteta + (i-1) * 36.) * degrad);
778         xpos1 = xccc * TMath::Cos(aphi) - yccc * TMath::Sin(aphi) + xzero;
779         ypos1 = xccc * TMath::Sin(aphi) + yccc * TMath::Cos(aphi) + yzero;
780         xpos  = xpos1 * TMath::Cos(gteta * degrad) + ypos1 * TMath::Sin(gteta *degrad);
781         ypos  = -xpos1 * TMath::Sin(gteta * degrad) + ypos1 * TMath::Cos(gteta * degrad);
782         zpos  = 0.;
783         atheta1011 = (i-1) * 36. + offset1 + offset2 - gteta;
784         AliMatrix(idrotm[(i-1) * 13 + 1109], 270., atheta1011, 90., atheta1011 + 270., 0., 0.);
785         geant->Gsposp("SPIX", (i-1) * 13 + 10, "IT12", xpos, ypos, zpos, idrotm[(i-1) * 13 + 1109], "ONLY", dsup, 3);
786
787 // --- Place an element of layer #1 
788
789         biga   = (yy[10] - yy[9]) / (xx[10] - xx[9]);
790         bigb   = (xx[10] * yy[9] - xx[9] * yy[10]) / (xx[10] - xx[9]) / 10.;
791         coeffa = biga * biga + 1.;
792         coeffb = biga * bigb - biga * ycc - xcc;
793         coeffc = xcc * xcc + ycc * ycc - ycc * 2. * bigb + bigb * bigb - 9.9999999999999995e-7;
794         xcc1   = (-coeffb - TMath::Sqrt(coeffb * coeffb - coeffa * coeffc)) / coeffa;
795         ycc1   = biga * xcc1 + bigb;
796         biga1  = -1. / biga;
797         bigb1  = xcc1 / biga + ycc1;
798         coeffa = biga1 * biga1 + 1.;
799         coeffb = biga1 * bigb1 - biga1 * ycc1 - xcc1;
800         coeffc = xcc1 * xcc1 + ycc1 * ycc1 - ycc1 * 2. * bigb1 + bigb1 * bigb1 - (dsup[0] + dbox1[0]) * (dsup[0] + dbox1[0]);
801         xcc2   = (-coeffb + TMath::Sqrt(coeffb * coeffb - coeffa * coeffc)) / coeffa;
802         ycc2   = biga1 * xcc2 + bigb1;
803         xpos1  = xcc2 * TMath::Cos(aphi) - ycc2 * TMath::Sin(aphi) + xzero;
804         ypos1  = xcc2 * TMath::Sin(aphi) + ycc2 * TMath::Cos(aphi) + yzero;
805         xpos   = xpos1 * TMath::Cos(gteta * degrad) + ypos1 * TMath::Sin(gteta *degrad);
806         ypos   = -xpos1 * TMath::Sin(gteta * degrad) + ypos1 * TMath::Cos(gteta * degrad);
807         zpos   = 0.;
808         ++jbox1;
809         geant->Gspos("IPV1", jbox1, "IT12", xpos, ypos, zpos, idrotm[(i-1) * 13 + 1109], "ONLY");
810
811 // --- Place arc # 5 (between part 1-2 and part 2-3) (see sketch) 
812
813         darc[0] = rarc[4] / 10. - .02;
814         darc[1] = rarc[4] / 10.;
815         darc[2] = 25.;
816         darc[3] = atheta12 + 90. - (i-1) * 36.;
817         darc[4] = atheta23 + 90. - (i-1) * 36.;
818         xcc     = xarc[4] / 10.;
819         ycc     = yarc[4] / 10.;
820         aphi    = (pphi + (i-1) * 36.) * degrad;
821         xzero   = rr * TMath::Cos((tteta + (i-1) * 36.) * degrad);
822         yzero   = rr * TMath::Sin((tteta + (i-1) * 36.) * degrad);
823         xpos1   = xcc * TMath::Cos(aphi) - ycc * TMath::Sin(aphi) + xzero;
824         ypos1   = xcc * TMath::Sin(aphi) + ycc * TMath::Cos(aphi) + yzero;
825         xpos    = xpos1 * TMath::Cos(gteta * degrad) + ypos1 * TMath::Sin(gteta *degrad);
826         ypos    = -xpos1 * TMath::Sin(gteta * degrad) + ypos1 * TMath::Cos(gteta * degrad);
827         zpos    = 0.;
828         geant->Gsposp("SARC", (i-1) * 13 + 5, "IT12", xpos, ypos, zpos, idrotm[(i-1) * 13 + 1104], "ONLY", darc, 5);
829
830 // --- Place arc # 6 (between part 2-3 and part 3-4) (see sketch) 
831
832         darc[0] = rarc[5] / 10. - .02;
833         darc[1] = rarc[5] / 10.;
834         darc[2] = 25.;
835         darc[3] = atheta23 - (i-1) * 36.;
836         darc[4] = atheta34 - (i-1) * 36.;
837         xcc     = xarc[5] / 10.;
838         ycc     = yarc[5] / 10.;
839         aphi    = (pphi + (i-1) * 36.) * degrad;
840         xzero   = rr * TMath::Cos((tteta + (i-1) * 36.) * degrad);
841         yzero   = rr * TMath::Sin((tteta + (i-1) * 36.) * degrad);
842         xpos1   = xcc * TMath::Cos(aphi) - ycc * TMath::Sin(aphi) + xzero;
843         ypos1   = xcc * TMath::Sin(aphi) + ycc * TMath::Cos(aphi) + yzero;
844         xpos    = xpos1 * TMath::Cos(gteta * degrad) + ypos1 * TMath::Sin(gteta *degrad);
845         ypos    = -xpos1 * TMath::Sin(gteta * degrad) + ypos1 * TMath::Cos(gteta * degrad);
846         zpos    = 0.;
847         geant->Gsposp("SARC", (i-1) * 13 + 6, "IT12", xpos, ypos, zpos, idrotm[(i-1) * 13 + 1105], "ONLY", darc, 5);
848
849 // --- Place arc # 7 (between part 3-4 and part 4-5) (see sketch) 
850
851         darc[0] = rarc[6] / 10. - .02;
852         darc[1] = rarc[6] / 10.;
853         darc[2] = 25.;
854         darc[3] = atheta45 + 90. - (i-1) * 36.;
855         darc[4] = atheta34 + 90. - (i-1) * 36.;
856         xcc     = xarc[6] / 10.;
857         ycc     = yarc[6] / 10.;
858         aphi    = (pphi + (i-1) * 36.) * degrad;
859         xzero   = rr * TMath::Cos((tteta + (i-1) * 36.) * degrad);
860         yzero   = rr * TMath::Sin((tteta + (i-1) * 36.) * degrad);
861         xpos1   = xcc * TMath::Cos(aphi) - ycc * TMath::Sin(aphi) + xzero;
862         ypos1   = xcc * TMath::Sin(aphi) + ycc * TMath::Cos(aphi) + yzero;
863         xpos    = xpos1 * TMath::Cos(gteta * degrad) + ypos1 * TMath::Sin(gteta *degrad);
864         ypos    = -xpos1 * TMath::Sin(gteta * degrad) + ypos1 * TMath::Cos(gteta * degrad);
865         zpos    = 0.;
866         geant->Gsposp("SARC", (i-1) * 13 + 7, "IT12", xpos, ypos, zpos, idrotm[(i-1) * 13 + 1106], "ONLY", darc, 5);
867
868 // --- Place arc # 8 (between part 4-5 and part 5-6) (see sketch) 
869
870         darc[0] = rarc[7] / 10. - .02;
871         darc[1] = rarc[7] / 10.;
872         darc[2] = 25.;
873         darc[3] = atheta56 + 180. - (i-1) * 36.;
874         darc[4] = atheta45 + 180. - (i-1) * 36.;
875         xcc     = xarc[7] / 10.;
876         ycc     = yarc[7] / 10.;
877         aphi    = (pphi + (i-1) * 36.) * degrad;
878         xzero   = rr * TMath::Cos((tteta + (i-1) * 36.) * degrad);
879         yzero   = rr * TMath::Sin((tteta + (i-1) * 36.) * degrad);
880         xpos1   = xcc * TMath::Cos(aphi) - ycc * TMath::Sin(aphi) + xzero;
881         ypos1   = xcc * TMath::Sin(aphi) + ycc * TMath::Cos(aphi) + yzero;
882         xpos    = xpos1 * TMath::Cos(gteta * degrad) + ypos1 * TMath::Sin(gteta *degrad);
883         ypos    = -xpos1 * TMath::Sin(gteta * degrad) + ypos1 * TMath::Cos(gteta * degrad);
884         zpos    = 0.;
885         geant->Gsposp("SARC", (i-1) * 13 + 8, "IT12", xpos, ypos, zpos, idrotm[(i-1) * 13 + 1107], "ONLY", darc, 5);
886
887 // --- Place arc # 9 (between part 5-6 and part 6-7) (see sketch) 
888
889         darc[0] = rarc[8] / 10. - .02;
890         darc[1] = rarc[8] / 10.;
891         darc[2] = 25.;
892         darc[3] = atheta56 - 90. - (i-1) * 36.;
893         darc[4] = atheta67 - 90. - (i-1) * 36.;
894         xcc     = xarc[8] / 10.;
895         ycc     = yarc[8] / 10.;
896         aphi    = (pphi + (i-1) * 36.) * degrad;
897         xzero   = rr * TMath::Cos((tteta + (i-1) * 36.) * degrad);
898         yzero   = rr * TMath::Sin((tteta + (i-1) * 36.) * degrad);
899         xpos1   = xcc * TMath::Cos(aphi) - ycc * TMath::Sin(aphi) + xzero;
900         ypos1   = xcc * TMath::Sin(aphi) + ycc * TMath::Cos(aphi) + yzero;
901         xpos    = xpos1 * TMath::Cos(gteta * degrad) + ypos1 * TMath::Sin(gteta *degrad);
902         ypos    = -xpos1 * TMath::Sin(gteta * degrad) + ypos1 * TMath::Cos(gteta * degrad);
903         zpos    = 0.;
904         geant->Gsposp("SARC", (i-1) * 13 + 9, "IT12", xpos, ypos, zpos, idrotm[(i-1) * 13 + 1108], "ONLY", darc, 5);
905
906 // --- Place arc # 10 (between part 6-7 and part 7-8) (see sketch) 
907
908         darc[0] = rarc[9] / 10. - .02;
909         darc[1] = rarc[9] / 10.;
910         darc[2] = 25.;
911         darc[3] = atheta67 - (i-1) * 36.;
912         darc[4] = atheta78 - (i-1) * 36.;
913         xcc     = xarc[9] / 10.;
914         ycc     = yarc[9] / 10.;
915         aphi    = (pphi + (i-1) * 36.) * degrad;
916         xzero   = rr * TMath::Cos((tteta + (i-1) * 36.) * degrad);
917         yzero   = rr * TMath::Sin((tteta + (i-1) * 36.) * degrad);
918         xpos1   = xcc * TMath::Cos(aphi) - ycc * TMath::Sin(aphi) + xzero;
919         ypos1   = xcc * TMath::Sin(aphi) + ycc * TMath::Cos(aphi) + yzero;
920         xpos    = xpos1 * TMath::Cos(gteta * degrad) + ypos1 * TMath::Sin(gteta *degrad);
921         ypos    = -xpos1 * TMath::Sin(gteta * degrad) + ypos1 * TMath::Cos(gteta * degrad);
922         zpos    = 0.;
923         geant->Gsposp("SARC", (i-1) * 13 + 10, "IT12", xpos, ypos, zpos, idrotm[(i-1) * 13 + 1109], "ONLY", darc, 5);
924
925 // --- Place arc # 11 (between part 7-8 and part 8-9) (see sketch) 
926
927         darc[0] = rarc[10] / 10. - .02;
928         darc[1] = rarc[10] / 10.;
929         darc[2] = 25.;
930         darc[3] = atheta89 - 90. - (i-1) * 36.;
931         darc[4] = atheta78 - 90. - (i-1) * 36.;
932         xcc     = xarc[10] / 10.;
933         ycc     = yarc[10] / 10.;
934         aphi    = (pphi + (i-1) * 36.) * degrad;
935         xzero   = rr * TMath::Cos((tteta + (i-1) * 36.) * degrad);
936         yzero   = rr * TMath::Sin((tteta + (i-1) * 36.) * degrad);
937         xpos1   = xcc * TMath::Cos(aphi) - ycc * TMath::Sin(aphi) + xzero;
938         ypos1   = xcc * TMath::Sin(aphi) + ycc * TMath::Cos(aphi) + yzero;
939         xpos    = xpos1 * TMath::Cos(gteta * degrad) + ypos1 * TMath::Sin(gteta *degrad);
940         ypos    = -xpos1 * TMath::Sin(gteta * degrad) + ypos1 * TMath::Cos(gteta * degrad);
941         zpos    = 0.;
942         geant->Gsposp("SARC", (i-1) * 13 + 11, "IT12", xpos, ypos, zpos, idrotm[(i-1) * 13 + 1110], "ONLY", darc, 5);
943
944 // --- Place arc # 12 (between part 8-9 and part 9-10) (see sketch) 
945
946         darc[0] = rarc[11] / 10. - .02;
947         darc[1] = rarc[11] / 10.;
948         darc[2] = 25.;
949         darc[3] = atheta89 - (i-1) * 36.;
950         darc[4] = atheta910 - (i-1) * 36.;
951         xcc     = xarc[11] / 10.;
952         ycc     = yarc[11] / 10.;
953         aphi    = (pphi + (i-1) * 36.) * degrad;
954         xzero   = rr * TMath::Cos((tteta + (i-1) * 36.) * degrad);
955         yzero   = rr * TMath::Sin((tteta + (i-1) * 36.) * degrad);
956         xpos1   = xcc * TMath::Cos(aphi) - ycc * TMath::Sin(aphi) + xzero;
957         ypos1   = xcc * TMath::Sin(aphi) + ycc * TMath::Cos(aphi) + yzero;
958         xpos    = xpos1 * TMath::Cos(gteta * degrad) + ypos1 * TMath::Sin(gteta *degrad);
959         ypos    = -xpos1 * TMath::Sin(gteta * degrad) + ypos1 * TMath::Cos(gteta * degrad);
960         zpos    = 0.;
961         geant->Gsposp("SARC", (i-1) * 13 + 12, "IT12", xpos, ypos, zpos, idrotm[(i-1) * 13 + 1111], "ONLY", darc, 5);
962
963 // --- Place arc # 1 (between part 9-10 and part 10-11) (see sketch) 
964
965         darc[0] = rarc[0] / 10. - .02;
966         darc[1] = rarc[0] / 10.;
967         darc[2] = 25.;
968         darc[3] = atheta1011 + 10. - (i-1) * 36.;
969         darc[4] = atheta910 - 120. - (i-1) * 36.;
970         xcc     = xarc[0] / 10.;
971         ycc     = yarc[0] / 10.;
972         aphi    = (pphi + (i-1) * 36.) * degrad;
973         xzero   = rr * TMath::Cos((tteta + (i-1) * 36.) * degrad);
974         yzero   = rr * TMath::Sin((tteta + (i-1) * 36.) * degrad);
975         xpos1   = xcc * TMath::Cos(aphi) - ycc * TMath::Sin(aphi) + xzero;
976         ypos1   = xcc * TMath::Sin(aphi) + ycc * TMath::Cos(aphi) + yzero;
977         xpos    = xpos1 * TMath::Cos(gteta * degrad) + ypos1 * TMath::Sin(gteta *degrad);
978         ypos    = -xpos1 * TMath::Sin(gteta * degrad) + ypos1 * TMath::Cos(gteta * degrad);
979         zpos    = 0.;
980         geant->Gsposp("SARC", (i-1) * 13 + 1, "IT12", xpos, ypos, zpos, idrotm[(i-1) * 13 + 1100], "ONLY", darc, 5);
981
982 // --- Place arc # 2 (between part 10-11 and part 11-12) (see sketch) 
983
984         darc[0] = rarc[1] / 10. - .02;
985         darc[1] = rarc[1] / 10.;
986         darc[2] = 25.;
987         darc[3] = atheta1011 - (i-1) * 36.;
988         darc[4] = atheta1112 + 45. - (i-1) * 36.;
989         xcc     = xarc[1] / 10.;
990         ycc     = yarc[1] / 10.;
991         aphi    = (pphi + (i-1) * 36.) * degrad;
992         xzero   = rr * TMath::Cos((tteta + (i-1) * 36.) * degrad);
993         yzero   = rr * TMath::Sin((tteta + (i-1) * 36.) * degrad);
994         xpos1   = xcc * TMath::Cos(aphi) - ycc * TMath::Sin(aphi) + xzero;
995         ypos1   = xcc * TMath::Sin(aphi) + ycc * TMath::Cos(aphi) + yzero;
996         xpos    = xpos1 * TMath::Cos(gteta * degrad) + ypos1 * TMath::Sin(gteta *degrad);
997         ypos    = -xpos1 * TMath::Sin(gteta * degrad) + ypos1 * TMath::Cos(gteta * degrad);
998         zpos    = 0.;
999         geant->Gsposp("SARC", (i-1) * 13 + 2, "IT12", xpos, ypos, zpos, idrotm[(i-1) * 13 + 1101], "ONLY", darc, 5);
1000
1001 // --- Place arc # 3 (between part 11-12 and part 12-13) (see sketch) 
1002
1003         darc[0] = rarc[2] / 10. - .02;
1004         darc[1] = rarc[2] / 10.;
1005         darc[2] = 25.;
1006         darc[3] = atheta1213 + 115. - (i-1) * 36.;
1007         darc[4] = atheta1112 + 115. - (i-1) * 36.;
1008         xcc     = xarc[2] / 10.;
1009         ycc     = yarc[2] / 10.;
1010         aphi    = (pphi + (i-1) * 36.) * degrad;
1011         xzero   = rr * TMath::Cos((tteta + (i-1) * 36.) * degrad);
1012         yzero   = rr * TMath::Sin((tteta + (i-1) * 36.) * degrad);
1013         xpos1   = xcc * TMath::Cos(aphi) - ycc * TMath::Sin(aphi) + xzero;
1014         ypos1   = xcc * TMath::Sin(aphi) + ycc * TMath::Cos(aphi) + yzero;
1015         xpos    = xpos1 * TMath::Cos(gteta * degrad) + ypos1 * TMath::Sin(gteta *degrad);
1016         ypos    = -xpos1 * TMath::Sin(gteta * degrad) + ypos1 * TMath::Cos(gteta * degrad);
1017         zpos    = 0.;
1018         geant->Gsposp("SARC", (i-1) * 13 + 3, "IT12", xpos, ypos, zpos, idrotm[(i-1) * 13 + 1102], "ONLY", darc, 5);
1019
1020 // --- Place arc # 4 (between part 12-13 and part 1-2) (see sketch) 
1021
1022         darc[0] = rarc[3] / 10. - .02;
1023         darc[1] = rarc[3] / 10.;
1024         darc[2] = 25.;
1025         darc[3] = atheta1213 - (i-1) * 36.;
1026         darc[4] = atheta12 - (i-1) * 36.;
1027         xcc     = xarc[3] / 10.;
1028         ycc     = yarc[3] / 10.;
1029         aphi    = (pphi + (i-1) * 36.) * degrad;
1030         xzero   = rr * TMath::Cos((tteta + (i-1) * 36.) * degrad);
1031         yzero   = rr * TMath::Sin((tteta + (i-1) * 36.) * degrad);
1032         xpos1   = xcc * TMath::Cos(aphi) - ycc * TMath::Sin(aphi) + xzero;
1033         ypos1   = xcc * TMath::Sin(aphi) + ycc * TMath::Cos(aphi) + yzero;
1034         xpos    = xpos1 * TMath::Cos(gteta * degrad) + ypos1 * TMath::Sin(gteta *degrad);
1035         ypos    = -xpos1 * TMath::Sin(gteta * degrad) + ypos1 * TMath::Cos(gteta * degrad);
1036         zpos    = 0.;
1037         geant->Gsposp("SARC", (i-1) * 13 + 4, "IT12", xpos, ypos, zpos, idrotm[(i-1) * 13 + 1103], "ONLY", darc, 5);
1038
1039     }
1040
1041 //************************************************************************
1042 //*                                                                      *
1043 //*                               D R I F T S                            *
1044 //*                               ===========                            *
1045 //*                                                                      *
1046 //************************************************************************
1047
1048 // --- Define a ghost volume containing the Silicon Drift Detectors 
1049 //     (layer #3 and #4) and fill it with air or vacuum 
1050
1051     xxm = 1.0444222222222224;
1052     dgh[0] = 0.;
1053     dgh[1] = 360.;
1054     dgh[2] = 4.;
1055     dgh[3] = -25. - 5.9900000000000002 / xxm - 
1056             .0099999999999997868 / xxm - 17.990000000000002 / xxm;
1057     dgh[4] = 27.;
1058     dgh[5] = 27.;
1059     dgh[6] = -25. - 5.9900000000000002 / xxm - .0099999999999997868 / xxm;
1060     dgh[7] = 9.01;
1061     dgh[8] = 27.;
1062     dgh[9] = 5.9900000000000002 / xxm + 25. + .0099999999999997868 / xxm;
1063     dgh[10] = 9.01;
1064     dgh[11] = 27.;
1065     dgh[12] = 5.9900000000000002 / xxm + 25. + 
1066             .0099999999999997868 / xxm + 17.990000000000002 / xxm;
1067     dgh[13] = 27.;
1068     dgh[14] = 27.;
1069     geant->Gsvolu("IT34", "PCON", idtmed[275], dgh, 15);
1070
1071 // --- Place the ghost volume in its mother volume (ITSV) and make it 
1072 //     invisible 
1073
1074     geant->Gspos("IT34", 1, "ITSV", 0., 0., 0., 0, "ONLY");
1075     geant->Gsatt("IT34", "SEEN", 0);
1076
1077 // --- Layer #3 
1078
1079 //        GOTO 3456           ! skip ITS layer no. 3 
1080
1081 //--- Define a ghost volume containing a single ladder of layer #3 (with the
1082 //     smaller lenght of ribs) and fill it with air or vacuum 
1083
1084     dbox1[0] = .61539999999999995;
1085     dbox1[1] = 3.85;
1086 // the widest element is the sensitive element 
1087     dbox1[2] = 35.850000000000001;
1088 // 7.5 cm is the lenght 
1089     geant->Gsvolu("IDV1", "BOX ", idtmed[228], dbox1, 3);
1090
1091 // --- Make the ghost volume invisible 
1092
1093     geant->Gsatt("IDV1", "SEEN", 0);
1094
1095 // --- Define a volume containing the sensitive part of drifts 
1096 //     (silicon, layer #3) 
1097
1098     dits[0] = .0172;
1099 // see material budget report by G. Feofilov 
1100     dits[1] = 3.85;
1101     dits[2] = 4.35;
1102     geant->Gsvolu("ITS3", "BOX ", idtmed[224], dits, 3);
1103
1104 //--- Define the part of the (smaller) rib between two sensitive parts made of
1105 //     carbon (layer #3) 
1106
1107     dsup[0] = .5 - dits[0];
1108     dsup[1] = .01;
1109     dsup[2] = 35.850000000000001;
1110 // 7.5 cm is the lenght 
1111     geant->Gsvolu("IR11", "BOX ", idtmed[227], dsup, 3);
1112
1113 //--- Define the first part of the (smaller) rib between two sensitive parts
1114 //     made of aluminum (layer #3) 
1115
1116     dal1[0] = .5 - dits[0];
1117     dal1[1] = 4.8000000000000001e-4;
1118     dal1[2] = 35.850000000000001;
1119 // 7.5 cm is the lenght 
1120     geant->Gsvolu("IR12", "BOX ", idtmed[230], dal1, 3);
1121
1122 //--- Define the part of the (smaller) rib between two sensitive parts made of
1123 //     kapton (layer #3) 
1124
1125     dkap[0] = .5 - dits[0];
1126     dkap[1] = .01585;
1127     dkap[2] = 35.850000000000001;
1128 // 7.5 cm is the lenght 
1129     geant->Gsvolu("IR13", "BOX ", idtmed[236], dkap, 3);
1130
1131 //--- Define the second part of the (smaller) rib between two sensitive parts
1132 //     made of aluminum (layer #3) 
1133
1134     dal2[0] = .5 - dits[0];
1135     dal2[1] = .0013500000000000001;
1136     dal2[2] = 35.850000000000001;
1137 // 7.5 cm is the lenght 
1138     geant->Gsvolu("IR14", "BOX ", idtmed[230], dal2, 3);
1139
1140 // --- Define the part of the (smaller) rib between two sensitive parts 
1141 //     made of silicon (the electronics) (layer #3) 
1142
1143     dchi[0] = .5 - dits[0];
1144     dchi[1] = .0035500000000000002;
1145     dchi[2] = 35.850000000000001;
1146 // 7.5 cm is the lenght 
1147     geant->Gsvolu("IR15", "BOX ", idtmed[225], dal2, 3);
1148
1149 // --- Define the part of the (smaller) rib between two sensitive parts 
1150 //     made of water (the cooler) (layer #3) 
1151
1152     dwat[0] = .5 - dits[0];
1153     dwat[1] = .0046499999999999996;
1154     dwat[2] = 35.850000000000001;
1155 // 7.5 cm is the lenght 
1156     geant->Gsvolu("IR16", "BOX ", idtmed[231], dwat, 3);
1157
1158 //--- Define the third part of the (smaller) rib between two sensitive parts
1159 //     made of aluminum (the cooling tubes) (layer #3) 
1160
1161     dtub[0] = .5 - dits[0];
1162     dtub[1] = 6.7000000000000002e-4;
1163     dtub[2] = 35.850000000000001;
1164 // 7.5 cm is the lenght 
1165     geant->Gsvolu("IR17", "BOX ", idtmed[230], dtub, 3);
1166
1167 // --- Define the part of the end-ladder stuff made of PCB (layer #3) 
1168
1169     dpcb[0] = .03;
1170 // twice the foreseen thickness 
1171     dpcb[1] = 3.5;
1172     dpcb[2] = 7.5;
1173     geant->Gsvolu("IEL1", "BOX ", idtmed[233], dpcb, 3);
1174
1175 // --- Define the part of the end-ladder stuff made of copper (layer #3) 
1176
1177     dcop[0] = .0252;
1178 // twice the foreseen thickness 
1179     dcop[1] = 3.5;
1180     dcop[2] = 7.5;
1181     geant->Gsvolu("IEL2", "BOX ", idtmed[234], dcop, 3);
1182
1183 // --- Define the part of the end-ladder stuff made of ceramics (layer #3)
1184  */
1185
1186     dcer[0] = .04;
1187 // twice the foreseen thickness 
1188     dcer[1] = 3.5;
1189     dcer[2] = 7.5;
1190     geant->Gsvolu("IEL3", "BOX ", idtmed[235], dcer, 3);
1191
1192 // --- Define the part of the end-ladder stuff made of silicon (layer #3) 
1193
1194     dsil[0] = .003;
1195 // twice the foreseen thickness 
1196     dsil[1] = 3.5;
1197     dsil[2] = 7.5;
1198     geant->Gsvolu("IEL4", "BOX ", idtmed[226], dsil, 3);
1199
1200 //--- Place the sensitive part of the drifts (smaller ribs) into its mother
1201 //     (IDV1) 
1202
1203     ypos = 0.;
1204     for (j = 1; j <= 5; ++j) {
1205 // odd elements are up and even elements are down 
1206         if (j == 1) {
1207             xpos = dbox1[0] - dpcb[0] * 2. - dcop[0] * 2. - dcer[0] * 2. - dsil[0] * 2. - dits[0];
1208             zpos = 0. - dits[2] + 1. - dits[2] * 2. - .1 - dits[2];
1209         } else if (j == 2) {
1210             xpos = -dbox1[0] + dits[0];
1211             zpos = 0. - dits[2] + 1. - dits[2];
1212         } else if (j == 3) {
1213             xpos = dbox1[0] - dpcb[0] * 2. - dcop[0] * 2. - dcer[0] * 2. - dsil[0] * 2. - dits[0];
1214             zpos = 0.;
1215         } else if (j == 4) {
1216             xpos = -dbox1[0] + dits[0];
1217             zpos = dits[2] + 0. - 1. + dits[2];
1218         } else if (j == 5) {
1219             xpos = dbox1[0] - dpcb[0] * 2. - dcop[0] * 2. - dcer[0] * 2. - dsil[0] * 2. - dits[0];
1220             zpos = dits[2] + 0. - 1. + dits[2] * 2. + .1 + dits[2];
1221         }
1222         geant->Gspos("ITS3", j, "IDV1", xpos, ypos, zpos, 0, "ONLY");
1223     }
1224
1225 // --- Place the smaller ribs into their mother (IDV1) 
1226
1227 // --- Right ribs (just a matter of convention) 
1228
1229     xpos = .5 - dbox1[0] + dits[0];
1230     zpos = 0.;
1231
1232 // --- Carbon 
1233
1234     ypos = 2.81;
1235     geant->Gspos("IR11", 1, "IDV1", xpos, ypos, zpos, 0, "ONLY");
1236
1237 // --- Aluminum #1 
1238
1239     ypos = dsup[1] + 2.81 + dal1[1];
1240     geant->Gspos("IR12", 1, "IDV1", xpos, ypos, zpos, 0, "ONLY");
1241
1242 // --- Kapton 
1243
1244     ypos = dsup[1] + 2.81 + dal1[1] * 2. + dkap[1];
1245     geant->Gspos("IR13", 1, "IDV1", xpos, ypos, zpos, 0, "ONLY");
1246
1247 // --- Aluminum #2 
1248
1249     ypos = dsup[1] + 2.81 + dal1[1] * 2. + dkap[1] * 2. + dal2[1];
1250     geant->Gspos("IR14", 1, "IDV1", xpos, ypos, zpos, 0, "ONLY");
1251
1252 // --- Silicon (chip) 
1253
1254     ypos = dsup[1] + 2.81 + dal1[1] * 2. + dkap[1] * 2. + dal2[1] * 2. + dchi[1];
1255     geant->Gspos("IR15", 1, "IDV1", xpos, ypos, zpos, 0, "ONLY");
1256
1257 // --- Water 
1258
1259     ypos = dsup[1] + 2.81 + dal1[1] * 2. + dkap[1] * 2. + dal2[1] * 2. + dchi[1] * 2. + dwat[1];
1260     geant->Gspos("IR16", 1, "IDV1", xpos, ypos, zpos, 0, "ONLY");
1261
1262 // --- Aluminum #3 
1263
1264     ypos = dsup[1] + 2.81 + dal1[1] * 2. + dkap[1] * 2. + dal2[1] * 2. + dchi[1] * 2. + dwat[1] * 2. 
1265             + dtub[1];
1266     geant->Gspos("IR17", 1, "IDV1", xpos, ypos, zpos, 0, "ONLY");
1267
1268 // --- Right ribs (just a matter of convention) 
1269
1270 // --- Carbon 
1271
1272     ypos = -2.81;
1273     geant->Gspos("IR11", 2, "IDV1", xpos, ypos, zpos, 0, "ONLY");
1274
1275 // --- Aluminum #1 
1276
1277     ypos = -(dsup[1] + 2.81 + dal1[1]);
1278     geant->Gspos("IR12", 2, "IDV1", xpos, ypos, zpos, 0, "ONLY");
1279
1280 // --- Kapton 
1281
1282     ypos = -(dsup[1] + 2.81 + dal1[1] * 2. + dkap[1]);
1283     geant->Gspos("IR13", 2, "IDV1", xpos, ypos, zpos, 0, "ONLY");
1284
1285 // --- Aluminum #2 
1286
1287     ypos = -(dsup[1] + 2.81 + dal1[1] * 2. + dkap[1] * 
1288             2. + dal2[1]);
1289     geant->Gspos("IR14", 2, "IDV1", xpos, ypos, zpos, 0, "ONLY");
1290
1291 // --- Silicon (chip) 
1292
1293     ypos = -(dsup[1] + 2.81 + dal1[1] * 2. + dkap[1] * 
1294             2. + dal2[1] * 2. + dchi[1]);
1295     geant->Gspos("IR15", 2, "IDV1", xpos, ypos, zpos, 0, "ONLY");
1296
1297 // --- Water 
1298
1299     ypos = -(dsup[1] + 2.81 + dal1[1] * 2. + dkap[1] * 
1300             2. + dal2[1] * 2. + dchi[1] * 2. + dwat[1]);
1301     geant->Gspos("IR16", 2, "IDV1", xpos, ypos, zpos, 0, "ONLY");
1302
1303 // --- Aluminum #3 
1304
1305     ypos = -(dsup[1] + 2.81 + dal1[1] * 2. + dkap[1] * 
1306             2. + dal2[1] * 2. + dchi[1] * 2. + dwat[1] * 2. + dtub[1]);
1307     geant->Gspos("IR17", 2, "IDV1", xpos, ypos, zpos, 0, "ONLY");
1308
1309 // --- Place the end-ladder stuff into its mother (IDV1) 
1310
1311
1312 // --- Negative-Z end-ladder 
1313
1314     ypos = 0.;
1315     zpos = -28.350000000000001;
1316
1317 // --- PCB 
1318
1319     xpos = dbox1[0] - dpcb[0];
1320     geant->Gspos("IEL1", 1, "IDV1", xpos, ypos, zpos, 0, "ONLY");
1321
1322 // --- Copper 
1323
1324     xpos = dbox1[0] - dpcb[0] * 2. - dcop[0];
1325     geant->Gspos("IEL2", 1, "IDV1", xpos, ypos, zpos, 0, "ONLY");
1326
1327 // --- Ceramics 
1328
1329     xpos = dbox1[0] - dpcb[0] * 2. - dcop[0] * 2. - dcer[0];
1330     geant->Gspos("IEL3", 1, "IDV1", xpos, ypos, zpos, 0, "ONLY");
1331
1332 // --- Silicon (bus) 
1333
1334     xpos = dbox1[0] - dpcb[0] * 2. - dcop[0] * 2. - dcer[0] * 2. - dsil[0];
1335     geant->Gspos("IEL4", 1, "IDV1", xpos, ypos, zpos, 0, "ONLY");
1336
1337 // --- Positive-Z end-ladder 
1338
1339     ypos = 0.;
1340     zpos = 28.350000000000001;
1341
1342 // --- PCB 
1343
1344     xpos = dbox1[0] - dpcb[0];
1345     geant->Gspos("IEL1", 2, "IDV1", xpos, ypos, zpos, 0, "ONLY");
1346
1347 // --- Copper 
1348
1349     xpos = dbox1[0] - dpcb[0] * 2. - dcop[0];
1350     geant->Gspos("IEL2", 2, "IDV1", xpos, ypos, zpos, 0, "ONLY");
1351
1352 // --- Ceramics 
1353
1354     xpos = dbox1[0] - dpcb[0] * 2. - dcop[0] * 2. - dcer[0];
1355     geant->Gspos("IEL3", 2, "IDV1", xpos, ypos, zpos, 0, "ONLY");
1356
1357 // --- Silicon (bus) 
1358
1359     xpos = dbox1[0] - dpcb[0] * 2. - dcop[0] * 2. - dcer[0] * 2. - dsil[0];
1360     geant->Gspos("IEL4", 2, "IDV1", xpos, ypos, zpos, 0, "ONLY");
1361
1362 //--- Define a ghost volume containing a single ladder of layer #3 (with the
1363 //     larger lenght of ribs) and fill it with air or vacuum 
1364
1365     dbox2[0] = .76540000000000008;
1366     dbox2[1] = 3.85;
1367 // the widest element is the sensitive element 
1368     dbox2[2] = 35.850000000000001;
1369 // 7.5 cm is the lenght 
1370     geant->Gsvolu("IDV2", "BOX ", idtmed[228], dbox2, 3);
1371
1372 // --- Make the ghost volume invisible 
1373
1374     geant->Gsatt("IDV2", "SEEN", 0);
1375
1376 //--- Define the part of the (larger) rib between two sensitive parts madeof
1377 //     carbon (layer #3) 
1378
1379     dsup[0] = .65 - dits[0];
1380     dsup[1] = .01;
1381     dsup[2] = 35.850000000000001;
1382 // 7.5 cm is the lenght 
1383     geant->Gsvolu("IR21", "BOX ", idtmed[227], dsup, 3);
1384
1385 //--- Define the first part of the (larger) rib between two sensitive parts
1386 //     made of aluminum (layer #3) 
1387
1388     dal1[0] = .65 - dits[0];
1389     dal1[1] = 4.8000000000000001e-4;
1390     dal1[2] = 35.850000000000001;
1391 // 7.5 cm is the lenght 
1392     geant->Gsvolu("IR22", "BOX ", idtmed[230], dal1, 3);
1393
1394 //--- Define the part of the (larger) rib between two sensitive parts madeof
1395 //     kapton (layer #3) 
1396
1397     dkap[0] = .65 - dits[0];
1398     dkap[1] = .01585;
1399     dkap[2] = 35.850000000000001;
1400 // 7.5 cm is the lenght 
1401     geant->Gsvolu("IR23", "BOX ", idtmed[236], dkap, 3);
1402
1403 //--- Define the second part of the (larger) rib between two sensitive parts
1404 //     made of aluminum (layer #3) 
1405
1406     dal2[0] = .65 - dits[0];
1407     dal2[1] = .0013500000000000001;
1408     dal2[2] = 35.850000000000001;
1409 // 7.5 cm is the lenght 
1410     geant->Gsvolu("IR24", "BOX ", idtmed[230], dal2, 3);
1411
1412 // --- Define the part of the (larger) rib between two sensitive parts 
1413 //     made of silicon (the electronics) (layer #3) 
1414
1415     dchi[0] = .65 - dits[0];
1416     dchi[1] = .0035500000000000002;
1417     dchi[2] = 35.850000000000001;
1418 // 7.5 cm is the lenght 
1419     geant->Gsvolu("IR25", "BOX ", idtmed[225], dal2, 3);
1420
1421 // --- Define the part of the (larger) rib between two sensitive parts 
1422 //     made of water (the cooler) (layer #3) 
1423
1424     dwat[0] = .65 - dits[0];
1425     dwat[1] = .0046499999999999996;
1426     dwat[2] = 35.850000000000001;
1427 // 7.5 cm is the lenght 
1428     geant->Gsvolu("IR26", "BOX ", idtmed[231], dwat, 3);
1429
1430 //--- Define the third part of the (larger) rib between two sensitive parts
1431 //     made of aluminum (the cooling tubes) (layer #3) 
1432
1433     dtub[0] = .65 - dits[0];
1434     dtub[1] = 6.7000000000000002e-4;
1435     dtub[2] = 35.850000000000001;
1436 // 7.5 cm is the lenght 
1437     geant->Gsvolu("IR27", "BOX ", idtmed[230], dtub, 3);
1438
1439 //--- Place the sensitive part of the drifts (smaller ribs) into its mother
1440 //     (IDV2) 
1441
1442     ypos = 0.;
1443     for (j = 1; j <= 5; ++j) {
1444 // odd element are up and even elements are down 
1445         if (j == 1) {
1446             xpos = dbox2[0] - dpcb[0] * 2. - dcop[0] * 2. - dcer[0] * 2. - dsil[0] * 2. - dits[0];
1447             zpos = 0. - dits[2] + 1. - dits[2] * 2. - .1 - dits[2];
1448         } else if (j == 2) {
1449             xpos = -dbox2[0] + dits[0];
1450             zpos = 0. - dits[2] + 1. - dits[2];
1451         } else if (j == 3) {
1452             xpos = dbox2[0] - dpcb[0] * 2. - dcop[0] * 2. - dcer[0] * 2. - dsil[0] * 2. - dits[0];
1453             zpos = 0.;
1454         } else if (j == 4) {
1455             xpos = -dbox2[0] + dits[0];
1456             zpos = dits[2] + 0. - 1. + dits[2];
1457         } else if (j == 5) {
1458             xpos = dbox2[0] - dpcb[0] * 2. - dcop[0] * 2. - dcer[0] * 2. - dsil[0] * 2. - dits[0];
1459             zpos = dits[2] + 0. - 1. + dits[2] * 2. + .1 + dits[2];
1460         }
1461         geant->Gspos("ITS3", j, "IDV2", xpos, ypos, zpos, 0, "ONLY");
1462     }
1463
1464 // --- Place the larger ribs into their mother (IDV2) 
1465
1466
1467 // --- Right ribs (just a matter of convention) 
1468
1469     xpos = .65 - dbox2[0] + dits[0];
1470     zpos = 0.;
1471
1472 // --- Carbon 
1473
1474     ypos = 2.81;
1475     geant->Gspos("IR21", 1, "IDV2", xpos, ypos, zpos, 0, "ONLY");
1476
1477 // --- Aluminum #1 
1478
1479     ypos = dsup[1] + 2.81 + dal1[1];
1480     geant->Gspos("IR22", 1, "IDV2", xpos, ypos, zpos, 0, "ONLY");
1481
1482 // --- Kapton 
1483
1484     ypos = dsup[1] + 2.81 + dal1[1] * 2. + dkap[1];
1485     geant->Gspos("IR23", 1, "IDV2", xpos, ypos, zpos, 0, "ONLY");
1486
1487 // --- Aluminum #2 
1488
1489     ypos = dsup[1] + 2.81 + dal1[1] * 2. + dkap[1] * 2. + dal2[1];
1490     geant->Gspos("IR24", 1, "IDV2", xpos, ypos, zpos, 0, "ONLY");
1491
1492 // --- Silicon (chip) 
1493
1494     ypos = dsup[1] + 2.81 + dal1[1] * 2. + dkap[1] * 2. + dal2[1] * 2. + dchi[1];
1495     geant->Gspos("IR25", 1, "IDV2", xpos, ypos, zpos, 0, "ONLY");
1496
1497 // --- Water 
1498
1499     ypos = dsup[1] + 2.81 + dal1[1] * 2. + dkap[1] * 2. + dal2[1] * 2. + dchi[1] * 2. + dwat[1];
1500     geant->Gspos("IR26", 1, "IDV2", xpos, ypos, zpos, 0, "ONLY");
1501
1502 // --- Aluminum #3 
1503
1504     ypos = dsup[1] + 2.81 + dal1[1] * 2. + dkap[1] * 2. + dal2[1] * 2. + dchi[1] * 2. + dwat[1] * 2. 
1505             + dtub[1];
1506     geant->Gspos("IR27", 1, "IDV2", xpos, ypos, zpos, 0, "ONLY");
1507
1508 // --- Right ribs (just a matter of convention) 
1509
1510 // --- Carbon 
1511
1512     ypos = -2.81;
1513     geant->Gspos("IR21", 2, "IDV2", xpos, ypos, zpos, 0, "ONLY");
1514
1515 // --- Aluminum #1 
1516
1517     ypos = -(dsup[1] + 2.81 + dal1[1]);
1518     geant->Gspos("IR22", 2, "IDV2", xpos, ypos, zpos, 0, "ONLY");
1519
1520 // --- Kapton 
1521
1522     ypos = -(dsup[1] + 2.81 + dal1[1] * 2. + dkap[1]);
1523     geant->Gspos("IR23", 2, "IDV2", xpos, ypos, zpos, 0, "ONLY");
1524
1525 // --- Aluminum #2 
1526
1527     ypos = -(dsup[1] + 2.81 + dal1[1] * 2. + dkap[1] * 
1528             2. + dal2[1]);
1529     geant->Gspos("IR24", 2, "IDV2", xpos, ypos, zpos, 0, "ONLY");
1530
1531 // --- Silicon (chip) 
1532
1533     ypos = -(dsup[1] + 2.81 + dal1[1] * 2. + dkap[1] * 
1534             2. + dal2[1] * 2. + dchi[1]);
1535     geant->Gspos("IR25", 2, "IDV2", xpos, ypos, zpos, 0, "ONLY");
1536
1537 // --- Water 
1538
1539     ypos = -(dsup[1] + 2.81 + dal1[1] * 2. + dkap[1] * 
1540             2. + dal2[1] * 2. + dchi[1] * 2. + dwat[1]);
1541     geant->Gspos("IR26", 2, "IDV2", xpos, ypos, zpos, 0, "ONLY");
1542
1543 // --- Aluminum #3 
1544
1545     ypos = -(dsup[1] + 2.81 + dal1[1] * 2. + dkap[1] * 
1546             2. + dal2[1] * 2. + dchi[1] * 2. + dwat[1] * 2. + dtub[1]);
1547     geant->Gspos("IR27", 2, "IDV2", xpos, ypos, zpos, 0, "ONLY");
1548
1549 // --- Place the end-ladder stuff into its mother (IDV1) 
1550
1551
1552 // --- Negative-Z end-ladder 
1553
1554     ypos = 0.;
1555     zpos = -28.350000000000001;
1556
1557 // --- PCB 
1558
1559     xpos = dbox2[0] - dpcb[0];
1560     geant->Gspos("IEL1", 3, "IDV2", xpos, ypos, zpos, 0, "ONLY");
1561
1562 // --- Copper 
1563
1564     xpos = dbox2[0] - dpcb[0] * 2. - dcop[0];
1565     geant->Gspos("IEL2", 3, "IDV2", xpos, ypos, zpos, 0, "ONLY");
1566
1567 // --- Ceramics 
1568
1569     xpos = dbox2[0] - dpcb[0] * 2. - dcop[0] * 2. - dcer[0];
1570     geant->Gspos("IEL3", 3, "IDV2", xpos, ypos, zpos, 0, "ONLY");
1571
1572 // --- Silicon (bus) 
1573
1574     xpos = dbox2[0] - dpcb[0] * 2. - dcop[0] * 2. - dcer[0] * 2. - dsil[0];
1575     geant->Gspos("IEL4", 3, "IDV1", xpos, ypos, zpos, 0, "ONLY");
1576
1577 // --- Positive-Z end-ladder 
1578
1579     yos  = 0.;
1580     zpos = 28.350000000000001;
1581
1582 // --- PCB 
1583
1584     xpos = dbox2[0] - dpcb[0];
1585     geant->Gspos("IEL1", 4, "IDV2", xpos, ypos, zpos, 0, "ONLY");
1586
1587 // --- Copper 
1588
1589     xpos = dbox2[0] - dpcb[0] * 2. - dcop[0];
1590     geant->Gspos("IEL2", 4, "IDV2", xpos, ypos, zpos, 0, "ONLY");
1591
1592 // --- Ceramics 
1593
1594     xpos = dbox2[0] - dpcb[0] * 2. - dcop[0] * 2. - dcer[0];
1595     geant->Gspos("IEL3", 4, "IDV2", xpos, ypos, zpos, 0, "ONLY");
1596
1597 // --- Silicon (bus) 
1598
1599     xpos = dbox2[0] - dpcb[0] * 2. - dcop[0] * 2. - dcer[0] * 2. - dsil[0];
1600     geant->Gspos("IEL4", 4, "IDV2", xpos, ypos, zpos, 0, "ONLY");
1601
1602 //--- Place the ghost volumes containing the drift ladders of layer #3 in their
1603 //     mother volume (IT34) 
1604 //     Odd elements have large ribs and even elements have small ribs 
1605
1606     for (i = 1; i <= 12; ++i) {
1607         atheta = (i-1) * 30.;
1608         AliMatrix(idrotm[i+1299], 90., atheta, 90., atheta + 90., 0.,0.);
1609         if (i % 2 == 0) {
1610             rzero = 14.;
1611             xpos = rzero * TMath::Cos((i-1) * twopi / 12.);
1612             ypos = rzero * TMath::Sin((i-1) * twopi / 12.);
1613             zpos = 0.;
1614             geant->Gspos("IDV1", i, "IT34", xpos, ypos, zpos, idrotm[i+1299], "ONLY");
1615         } else {
1616             rzero = 13.85;
1617             xpos = rzero * TMath::Cos((i-1) * twopi / 12.);
1618             ypos = rzero * TMath::Sin((i-1) * twopi / 12.);
1619             zpos = 0.;
1620             geant->Gspos("IDV2", i, "IT34", xpos, ypos, zpos, idrotm[i+1299], "ONLY");
1621         }
1622     }
1623
1624
1625 // --- Layer #4 
1626
1627 //        GOTO 4567           ! skip ITS layer no. 4 
1628
1629 //--- Define a ghost volume containing a single ladder of layer #4 (with the
1630 //     smaller lenght of ribs) and fill it with air or vacuum 
1631
1632     dbox1[0] = .61539999999999995;
1633     dbox1[1] = 3.5;
1634 // the widest element is the end-ladder stuff 
1635     dbox1[2] = 43.449999999999996;
1636 // 7.5 cm is the lenght 
1637     geant->Gsvolu("IDV3", "BOX ", idtmed[228], dbox1, 3);
1638
1639 // --- Make the ghost volume invisible 
1640
1641     geant->Gsatt("IDV3", "SEEN", 0);
1642
1643 // --- Define a volume containing the sensitive part of drifts 
1644 //     (silicon, layer #4) 
1645
1646     dits[0] = .0172;
1647 // see material budget report by G. Feofilov 
1648     dits[1] = 3.125;
1649     dits[2] = 4.35;
1650     geant->Gsvolu("ITS4", "BOX ", idtmed[224], dits, 3);
1651
1652 //--- Define the part of the (smaller) rib between two sensitive parts made of
1653 //     carbon (layer #4) 
1654
1655     dsup[0] = .5 - dits[0];
1656     dsup[1] = .01;
1657     dsup[2] = 43.449999999999996;
1658 // 7.5 cm is the lengh 
1659     geant->Gsvolu("IR31", "BOX ", idtmed[227], dsup, 3);
1660
1661 //--- Define the first part of the (smaller) rib between two sensitive parts
1662 //     made of aluminum (layer #4) 
1663
1664     dal1[0] = .5 - dits[0];
1665     dal1[1] = 4.8000000000000001e-4;
1666     dal1[2] = 43.449999999999996;
1667 // 7.5 cm is the lengh 
1668     geant->Gsvolu("IR32", "BOX ", idtmed[230], dal1, 3);
1669
1670 //--- Define the part of the (smaller) rib between two sensitive parts made of
1671 //     kapton (layer #4) 
1672
1673     dkap[0] = .5 - dits[0];
1674     dkap[1] = .01585;
1675     dkap[2] = 43.449999999999996;
1676 // 7.5 cm is the lengh 
1677     geant->Gsvolu("IR33", "BOX ", idtmed[236], dkap, 3);
1678
1679 //--- Define the second part of the (smaller) rib between two sensitive parts
1680 //     made of aluminum (layer #4) 
1681
1682     dal2[0] = .5 - dits[0];
1683     dal2[1] = .0013500000000000001;
1684     dal2[2] = 43.449999999999996;
1685 // 7.5 cm is the lengh 
1686     geant->Gsvolu("IR34", "BOX ", idtmed[230], dal2, 3);
1687
1688 // --- Define the part of the (smaller) rib between two sensitive parts 
1689 //     made of silicon (the electronics) (layer #4) 
1690
1691     dchi[0] = .5 - dits[0];
1692     dchi[1] = .0035500000000000002;
1693     dchi[2] = 43.449999999999996;
1694 // 7.5 cm is the lengh 
1695     geant->Gsvolu("IR35", "BOX ", idtmed[225], dal2, 3);
1696
1697 // --- Define the part of the (smaller) rib between two sensitive parts 
1698 //     made of water (the cooler) (layer #4) 
1699
1700     dwat[0] = .5 - dits[0];
1701     dwat[1] = .0046499999999999996;
1702     dwat[2] = 43.449999999999996;
1703 // 7.5 cm is the lenght 
1704     geant->Gsvolu("IR36", "BOX ", idtmed[231], dwat, 3);
1705
1706 //--- Define the third part of the (smaller) rib between two sensitive parts
1707 //     made of aluminum (the cooling tubes) (layer #4) 
1708
1709     dtub[0] = .5 - dits[0];
1710     dtub[1] = 6.7000000000000002e-4;
1711     dtub[2] = 43.449999999999996;
1712 // 7.5 cm is the lengh 
1713     geant->Gsvolu("IR37", "BOX ", idtmed[230], dtub, 3);
1714
1715 // --- Define the part of the end-ladder stuff made of PCB (layer #4) 
1716
1717     dpcb[0] = .03;
1718 // twice the foreseen thickness 
1719     dpcb[1] = 3.5;
1720     dpcb[2] = 7.5;
1721     geant->Gsvolu("IEL5", "BOX ", idtmed[233], dpcb, 3);
1722
1723 // --- Define the part of the end-ladder stuff made of copper (layer #4) 
1724
1725     dcop[0] = .0252;
1726 // twice the foreseen thickness 
1727     dcop[1] = 3.5;
1728     dcop[2] = 7.5;
1729     geant->Gsvolu("IEL6", "BOX ", idtmed[234], dcop, 3);
1730
1731 // --- Define the part of the end-ladder stuff made of ceramics (layer #4)
1732  */
1733
1734     dcer[0] = .04;
1735 // twice the foreseen thickness 
1736     dcer[1] = 3.5;
1737     dcer[2] = 7.5;
1738     geant->Gsvolu("IEL7", "BOX ", idtmed[235], dcer, 3);
1739
1740 // --- Define the part of the end-ladder stuff made of silicon (layer #4) 
1741
1742     dsil[0] = .003;
1743 // twice the foreseen thickness 
1744     dsil[1] = 3.5;
1745     dsil[2] = 7.5;
1746     geant->Gsvolu("IEL8", "BOX ", idtmed[226], dsil, 3);
1747
1748 //--- Place the sensitive part of the drifts (smaller ribs) into its mother
1749 //     (IDV3) 
1750
1751     ypos = 0.;
1752     for (j = 1; j <= 7; ++j) {
1753 // odd elements are down and even elements are up 
1754         if (j == 1) {
1755             xpos = dbox1[0] - dpcb[0] * 2. - dcop[0] * 2. - dcer[0] * 2. - dsil[0] * 2. - dits[0];
1756             zpos = 0. - dits[2] + .7 - dits[2] * 2. + 0. - dits[2] * 2. + 1.3 - dits[2];
1757         } else if (j == 2) {
1758             xpos = -dbox1[0] + dits[0];
1759             zpos = 0. - dits[2] + .7 - dits[2] * 2. + 0. - dits[2];
1760         } else if (j == 3) {
1761             xpos = dbox1[0] - dpcb[0] * 2. - dcop[0] * 2. - dcer[0] * 2. - dsil[0] * 2. - dits[0];
1762             zpos = 0. - dits[2] + .7 - dits[2];
1763         } else if (j == 4) {
1764             xpos = -dbox1[0] + dits[0];
1765             zpos = 0.;
1766         } else if (j == 5) {
1767             xpos = dbox1[0] - dpcb[0] * 2. - dcop[0] * 2. - dcer[0] * 2. - dsil[0] * 2. - dits[0];
1768             zpos = dits[2] + 0. - .7 + dits[2];
1769         } else if (j == 6) {
1770             xpos = -dbox1[0] + dits[0];
1771             zpos = dits[2] + 0. - .7 + dits[2] * 2. + 0. + dits[2];
1772         } else if (j == 7) {
1773             xpos = dbox1[0] - dpcb[0] * 2. - dcop[0] * 2. - dcer[0] * 2. - dsil[0] * 2. - dits[0];
1774             zpos = dits[2] + 0. - .7 + dits[2] * 2. + 0. + dits[2] * 2. - 1.3 + dits[2];
1775         }
1776         geant->Gspos("ITS4", j, "IDV3", xpos, ypos, zpos, 0, "ONLY");
1777     }
1778
1779 // --- Place the smaller ribs into their mother (IDV3) 
1780
1781 // --- Right ribs (just a matter of convention) 
1782
1783     xpos = .5 - dbox1[0] + dits[0];
1784     zpos = 0.;
1785
1786 // --- Carbon 
1787
1788     ypos = 2.81;
1789     geant->Gspos("IR31", 1, "IDV3", xpos, ypos, zpos, 0, "ONLY");
1790
1791 // --- Aluminum #1 
1792
1793     ypos = dsup[1] + 2.81 + dal1[1];
1794     geant->Gspos("IR32", 1, "IDV3", xpos, ypos, zpos, 0, "ONLY");
1795
1796 // --- Kapton 
1797
1798     ypos = dsup[1] + 2.81 + dal1[1] * 2. + dkap[1];
1799     geant->Gspos("IR33", 1, "IDV3", xpos, ypos, zpos, 0, "ONLY");
1800
1801 // --- Aluminum #2 
1802
1803     ypos = dsup[1] + 2.81 + dal1[1] * 2. + dkap[1] * 2. + dal2[1];
1804     geant->Gspos("IR34", 1, "IDV3", xpos, ypos, zpos, 0, "ONLY");
1805
1806 // --- Silicon (chip) 
1807
1808     ypos = dsup[1] + 2.81 + dal1[1] * 2. + dkap[1] * 2. + dal2[1] * 2. + dchi[1];
1809     geant->Gspos("IR35", 1, "IDV3", xpos, ypos, zpos, 0, "ONLY");
1810
1811 // --- Water 
1812
1813     ypos = dsup[1] + 2.81 + dal1[1] * 2. + dkap[1] * 2. + dal2[1] * 2. + dchi[1] * 2. + dwat[1];
1814     geant->Gspos("IR36", 1, "IDV3", xpos, ypos, zpos, 0, "ONLY");
1815
1816 // --- Aluminum #3 
1817
1818     ypos = dsup[1] + 2.81 + dal1[1] * 2. + dkap[1] * 2. + dal2[1] * 2. + dchi[1] * 2. + dwat[1] * 2. 
1819             + dtub[1];
1820     geant->Gspos("IR37", 1, "IDV3", xpos, ypos, zpos, 0, "ONLY");
1821
1822 // --- Right ribs (just a matter of convention) 
1823
1824 // --- Carbon 
1825
1826     ypos = -2.81;
1827     geant->Gspos("IR31", 2, "IDV3", xpos, ypos, zpos, 0, "ONLY");
1828
1829 // --- Aluminum #1 
1830
1831     ypos = -(dsup[1] + 2.81 + dal1[1]);
1832     geant->Gspos("IR32", 2, "IDV3", xpos, ypos, zpos, 0, "ONLY");
1833
1834 // --- Kapton 
1835
1836     ypos = -(dsup[1] + 2.81 + dal1[1] * 2. + dkap[1]);
1837     geant->Gspos("IR33", 2, "IDV3", xpos, ypos, zpos, 0, "ONLY");
1838
1839 // --- Aluminum #2 
1840
1841     ypos = -(dsup[1] + 2.81 + dal1[1] * 2. + dkap[1] * 2. + dal2[1]);
1842     geant->Gspos("IR34", 2, "IDV3", xpos, ypos, zpos, 0, "ONLY");
1843
1844 // --- Silicon (chip) 
1845
1846     ypos = -(dsup[1] + 2.81 + dal1[1] * 2. + dkap[1] * 2. + dal2[1] * 2. + dchi[1]);
1847     geant->Gspos("IR35", 2, "IDV3", xpos, ypos, zpos, 0, "ONLY");
1848
1849 // --- Water 
1850
1851     ypos = -(dsup[1] + 2.81 + dal1[1] * 2. + dkap[1] * 2. + dal2[1] * 2. + dchi[1] * 2. + dwat[1]);
1852     geant->Gspos("IR36", 2, "IDV3", xpos, ypos, zpos, 0, "ONLY");
1853
1854 // --- Aluminum #3 
1855
1856     ypos = -(dsup[1] + 2.81 + dal1[1] * 2. + dkap[1] * 
1857             2. + dal2[1] * 2. + dchi[1] * 2. + dwat[1] * 2. + dtub[1]);
1858     geant->Gspos("IR37", 2, "IDV3", xpos, ypos, zpos, 0, "ONLY");
1859
1860 // --- Place the end-ladder stuff into its mother (IDV1) 
1861
1862
1863 // --- Negative-Z end-ladder 
1864
1865     ypos = 0.;
1866     zpos = -35.949999999999996;
1867
1868 // --- PCB 
1869
1870     xpos = dbox1[0] - dpcb[0];
1871     geant->Gspos("IEL5", 1, "IDV3", xpos, ypos, zpos, 0, "ONLY");
1872
1873 // --- Copper 
1874
1875     xpos = dbox1[0] - dpcb[0] * 2. - dcop[0];
1876     geant->Gspos("IEL6", 1, "IDV3", xpos, ypos, zpos, 0, "ONLY");
1877
1878 // --- Ceramics 
1879
1880     xpos = dbox1[0] - dpcb[0] * 2. - dcop[0] * 2. - dcer[0];
1881     geant->Gspos("IEL7", 1, "IDV3", xpos, ypos, zpos, 0, "ONLY");
1882
1883 // --- Silicon (bus) 
1884
1885     xpos = dbox1[0] - dpcb[0] * 2. - dcop[0] * 2. - dcer[0] * 2. - dsil[0];
1886     geant->Gspos("IEL8", 1, "IDV3", xpos, ypos, zpos, 0, "ONLY");
1887
1888 // --- Positive-Z end-ladder 
1889
1890     ypos = 0.;
1891     zpos = 35.949999999999996;
1892
1893 // --- PCB 
1894
1895     xpos = dbox1[0] - dpcb[0];
1896     geant->Gspos("IEL5", 2, "IDV3", xpos, ypos, zpos, 0, "ONLY");
1897
1898 // --- Copper 
1899
1900     xpos = dbox1[0] - dpcb[0] * 2. - dcop[0];
1901     geant->Gspos("IEL6", 2, "IDV3", xpos, ypos, zpos, 0, "ONLY");
1902
1903 // --- Ceramics 
1904
1905     xpos = dbox1[0] - dpcb[0] * 2. - dcop[0] * 2. - dcer[0];
1906     geant->Gspos("IEL7", 2, "IDV3", xpos, ypos, zpos, 0, "ONLY");
1907
1908 // --- Silicon (bus) 
1909
1910     xpos = dbox1[0] - dpcb[0] * 2. - dcop[0] * 2. - dcer[0] * 2. - dsil[0];
1911     geant->Gspos("IEL8", 2, "IDV3", xpos, ypos, zpos, 0, "ONLY");
1912
1913 //--- Define a ghost volume containing a single ladder of layer #4 (with the
1914 //     larger lenght of ribs) and fill it with air or vacuum 
1915
1916     dbox2[0] = .76540000000000008;
1917     dbox2[1] = 3.5;
1918 // the widest element is the end-ladder stuff 
1919     dbox2[2] = 43.449999999999996;
1920 // 7.5 cm is the lenght 
1921     geant->Gsvolu("IDV4", "BOX ", idtmed[228], dbox2, 3);
1922
1923 // --- Make the ghost volume invisible 
1924
1925     geant->Gsatt("IDV4", "SEEN", 0);
1926
1927 //--- Define the part of the (larger) rib between two sensitive parts madeof
1928 //     carbon (layer #4) 
1929
1930     dsup[0] = .65 - dits[0];
1931     dsup[1] = .01;
1932     dsup[2] = 43.449999999999996;
1933 // 7.5 cm is the lengh 
1934     geant->Gsvolu("IR41", "BOX ", idtmed[227], dsup, 3);
1935
1936 //--- Define the first part of the (larger) rib between two sensitive parts
1937 //     made of aluminum (layer #4) 
1938
1939     dal1[0] = .65 - dits[0];
1940     dal1[1] = 4.8000000000000001e-4;
1941     dal1[2] = 43.449999999999996;
1942 // 7.5 cm is the lengh 
1943     geant->Gsvolu("IR42", "BOX ", idtmed[230], dal1, 3);
1944
1945 //--- Define the part of the (larger) rib between two sensitive parts madeof
1946 //     kapton (layer #4) 
1947
1948     dkap[0] = .65 - dits[0];
1949     dkap[1] = .01585;
1950     dkap[2] = 43.449999999999996;
1951 // 7.5 cm is the lengh 
1952     geant->Gsvolu("IR43", "BOX ", idtmed[236], dkap, 3);
1953
1954 //--- Define the second part of the (larger) rib between two sensitive parts
1955 //     made of aluminum (layer #4) 
1956
1957     dal2[0] = .65 - dits[0];
1958     dal2[1] = .0013500000000000001;
1959     dal2[2] = 43.449999999999996;
1960 // 7.5 cm is the lengh 
1961     geant->Gsvolu("IR44", "BOX ", idtmed[230], dal2, 3);
1962
1963 // --- Define the part of the (larger) rib between two sensitive parts 
1964 //     made of silicon (the electronics) (layer #4) 
1965
1966     dchi[0] = .65 - dits[0];
1967     dchi[1] = .0035500000000000002;
1968     dchi[2] = 43.449999999999996;
1969 // 7.5 cm is the lengh 
1970     geant->Gsvolu("IR45", "BOX ", idtmed[225], dal2, 3);
1971
1972 // --- Define the part of the (larger) rib between two sensitive parts 
1973 //     made of water (the cooler) (layer #4) 
1974
1975     dwat[0] = .65 - dits[0];
1976     dwat[1] = .0046499999999999996;
1977     dwat[2] = 43.449999999999996;
1978 // 7.5 cm is the lengh 
1979     geant->Gsvolu("IR46", "BOX ", idtmed[231], dwat, 3);
1980
1981 //--- Define the third part of the (larger) rib between two sensitive parts
1982 //     made of aluminum (the cooling tubes) (layer #4) 
1983
1984     dtub[0] = .65 - dits[0];
1985     dtub[1] = 6.7000000000000002e-4;
1986     dtub[2] = 43.449999999999996;
1987 // 7.5 cm is the lengh 
1988     geant->Gsvolu("IR47", "BOX ", idtmed[230], dtub, 3);
1989
1990 //--- Place the sensitive part of the drifts (smaller ribs) into its mother
1991 //     (IDV4) 
1992
1993     ypos = 0.;
1994     for (j = 1; j <= 7; ++j) {
1995 // odd elements are down and even elements are up 
1996         if (j == 1) {
1997             xpos = dbox2[0] - dpcb[0] * 2. - dcop[0] * 2. - dcer[0] * 2. - dsil[0] * 2. - dits[0];
1998             zpos = 0. - dits[2] + .7 - dits[2] * 2. + 0. - dits[2] * 2. + 1.3 - dits[2];
1999         } else if (j == 2) {
2000             xpos = -dbox2[0] + dits[0];
2001             zpos = 0. - dits[2] + .7 - dits[2] * 2. + 0. - dits[2];
2002         } else if (j == 3) {
2003             xpos = dbox2[0] - dpcb[0] * 2. - dcop[0] * 2. - dcer[0] * 2. - dsil[0] * 2. - dits[0];
2004             zpos = 0. - dits[2] + .7 - dits[2];
2005         } else if (j == 4) {
2006             xpos = -dbox2[0] + dits[0];
2007             zpos = 0.;
2008         } else if (j == 5) {
2009             xpos = dbox2[0] - dpcb[0] * 2. - dcop[0] * 2. - dcer[0] * 2. - dsil[0] * 2. - dits[0];
2010             zpos = dits[2] + 0. - .7 + dits[2];
2011         } else if (j == 6) {
2012             xpos = -dbox2[0] + dits[0];
2013             zpos = dits[2] + 0. - .7 + dits[2] * 2. + 0. + dits[2];
2014         } else if (j == 7) {
2015             xpos = dbox2[0] - dpcb[0] * 2. - dcop[0] * 2. - dcer[0] * 2. - dsil[0] * 2. - dits[0];
2016             zpos = dits[2] + 0. - .7 + dits[2] * 2. + 0. + dits[2] * 2. - 1.3 + dits[2];
2017         }
2018         geant->Gspos("ITS4", j, "IDV4", xpos, ypos, zpos, 0, "ONLY");
2019     }
2020
2021 // --- Place the larger ribs into their mother (IDV4) 
2022
2023
2024 // --- Right ribs (just a matter of convention) 
2025
2026     xpos = .65 - dbox2[0] + dits[0];
2027     zpos = 0.;
2028
2029 // --- Carbon 
2030
2031     ypos = 2.81;
2032     geant->Gspos("IR41", 1, "IDV4", xpos, ypos, zpos, 0, "ONLY");
2033
2034 // --- Aluminum #1 
2035
2036     ypos = dsup[1] + 2.81 + dal1[1];
2037     geant->Gspos("IR42", 1, "IDV4", xpos, ypos, zpos, 0, "ONLY");
2038
2039 // --- Kapton 
2040
2041     ypos = dsup[1] + 2.81 + dal1[1] * 2. + dkap[1];
2042     geant->Gspos("IR43", 1, "IDV4", xpos, ypos, zpos, 0, "ONLY");
2043
2044 // --- Aluminum #2 
2045
2046     ypos = dsup[1] + 2.81 + dal1[1] * 2. + dkap[1] * 2. + dal2[1];
2047     geant->Gspos("IR44", 1, "IDV4", xpos, ypos, zpos, 0, "ONLY");
2048
2049 // --- Silicon (chip) 
2050
2051     ypos = dsup[1] + 2.81 + dal1[1] * 2. + dkap[1] * 2. + dal2[1] * 2. + dchi[1];
2052     geant->Gspos("IR45", 1, "IDV4", xpos, ypos, zpos, 0, "ONLY");
2053
2054 // --- Water 
2055
2056     ypos = dsup[1] + 2.81 + dal1[1] * 2. + dkap[1] * 2. + dal2[1] * 2. + dchi[1] * 2. + dwat[1];
2057     geant->Gspos("IR46", 1, "IDV4", xpos, ypos, zpos, 0, "ONLY");
2058
2059 // --- Aluminum #3 
2060
2061     ypos = dsup[1] + 2.81 + dal1[1] * 2. + dkap[1] * 2. + dal2[1] * 2. + dchi[1] * 2. + dwat[1] * 2. 
2062             + dtub[1];
2063     geant->Gspos("IR47", 1, "IDV4", xpos, ypos, zpos, 0, "ONLY");
2064
2065 // --- Right ribs (just a matter of convention) 
2066
2067 // --- Carbon 
2068
2069     ypos = -2.81;
2070     geant->Gspos("IR41", 2, "IDV4", xpos, ypos, zpos, 0, "ONLY");
2071
2072 // --- Aluminum #1 
2073
2074     ypos = -(dsup[1] + 2.81 + dal1[1]);
2075     geant->Gspos("IR42", 2, "IDV4", xpos, ypos, zpos, 0, "ONLY");
2076
2077 // --- Kapton 
2078
2079     ypos = -(dsup[1] + 2.81 + dal1[1] * 2. + dkap[1]);
2080     geant->Gspos("IR43", 2, "IDV4", xpos, ypos, zpos, 0, "ONLY");
2081
2082 // --- Aluminum #2 
2083
2084     ypos = -(dsup[1] + 2.81 + dal1[1] * 2. + dkap[1] * 
2085             2. + dal2[1]);
2086     geant->Gspos("IR44", 2, "IDV4", xpos, ypos, zpos, 0, "ONLY");
2087
2088 // --- Silicon (chip) 
2089
2090     ypos = -(dsup[1] + 2.81 + dal1[1] * 2. + dkap[1] * 
2091             2. + dal2[1] * 2. + dchi[1]);
2092     geant->Gspos("IR45", 2, "IDV4", xpos, ypos, zpos, 0, "ONLY");
2093
2094 // --- Water 
2095
2096     ypos = -(dsup[1] + 2.81 + dal1[1] * 2. + dkap[1] * 
2097             2. + dal2[1] * 2. + dchi[1] * 2. + dwat[1]);
2098     geant->Gspos("IR46", 2, "IDV4", xpos, ypos, zpos, 0, "ONLY");
2099
2100 // --- Aluminum #3 
2101
2102     ypos = -(dsup[1] + 2.81 + dal1[1] * 2. + dkap[1] * 
2103             2. + dal2[1] * 2. + dchi[1] * 2. + dwat[1] * 2. + dtub[1]);
2104     geant->Gspos("IR47", 2, "IDV4", xpos, ypos, zpos, 0, "ONLY");
2105
2106 // --- Place the end-ladder stuff into its mother (IDV1) 
2107
2108
2109 // --- Negative-Z end-ladder 
2110
2111     ypos = 0.;
2112     zpos = -35.949999999999996;
2113
2114 // --- PCB 
2115
2116     xpos = dbox2[0] - dpcb[0];
2117     geant->Gspos("IEL5", 3, "IDV4", xpos, ypos, zpos, 0, "ONLY");
2118
2119 // --- Copper 
2120
2121     xpos = dbox2[0] - dpcb[0] * 2. - dcop[0];
2122     geant->Gspos("IEL6", 3, "IDV4", xpos, ypos, zpos, 0, "ONLY");
2123
2124 // --- Ceramics 
2125
2126     xpos = dbox2[0] - dpcb[0] * 2. - dcop[0] * 2. - dcer[0];
2127     geant->Gspos("IEL7", 3, "IDV4", xpos, ypos, zpos, 0, "ONLY");
2128
2129 // --- Silicon (bus) 
2130
2131     xpos = dbox2[0] - dpcb[0] * 2. - dcop[0] * 2. - dcer[0] * 2. - dsil[0];
2132     geant->Gspos("IEL8", 3, "IDV4", xpos, ypos, zpos, 0, "ONLY");
2133
2134 // --- Positive-Z end-ladder 
2135
2136     yos  = 0.;
2137     zpos = 35.949999999999996;
2138
2139 // --- PCB 
2140
2141     xpos = dbox2[0] - dpcb[0];
2142     geant->Gspos("IEL5", 4, "IDV4", xpos, ypos, zpos, 0, "ONLY");
2143
2144 // --- Copper 
2145
2146     xpos = dbox2[0] - dpcb[0] * 2. - dcop[0];
2147     geant->Gspos("IEL6", 4, "IDV4", xpos, ypos, zpos, 0, "ONLY");
2148
2149 // --- Ceramics 
2150
2151     xpos = dbox2[0] - dpcb[0] * 2. - dcop[0] * 2. - dcer[0];
2152     geant->Gspos("IEL7", 4, "IDV4", xpos, ypos, zpos, 0, "ONLY");
2153
2154 // --- Silicon (bus) 
2155
2156     xpos = dbox2[0] - dpcb[0] * 2. - dcop[0] * 2. - dcer[0] * 2. - dsil[0];
2157     geant->Gspos("IEL8", 4, "IDV4", xpos, ypos, zpos, 0, "ONLY");
2158
2159 //--- Place the ghost volumes containing the drift ladders of layer #4 in their
2160 //     mother volume (IT34) 
2161 //     Odd elements have large ribs and even elements have small ribs 
2162
2163     for (i = 1; i <= 24; ++i) {
2164         atheta = (i-1) * 15.;
2165         AliMatrix(idrotm[i+1399], 90., atheta, 90., atheta + 90., 0.,0.);
2166         if (i % 2 == 0) {
2167             rzero = 23.5;
2168             xpos = rzero * TMath::Cos((i-1) * twopi / 24.);
2169             ypos = rzero * TMath::Sin((i-1) * twopi / 24.);
2170             zpos = 0.;
2171             geant->Gspos("IDV3", i, "IT34", xpos, ypos, zpos, idrotm[i+1399], "ONLY");
2172         } else {
2173             rzero = 23.399999999999999;
2174             xpos = rzero * TMath::Cos((i-1) * twopi / 24.);
2175             ypos = rzero * TMath::Sin((i-1) * twopi / 24.);
2176             zpos = 0.;
2177             geant->Gspos("IDV4", i, "IT34", xpos, ypos, zpos, idrotm[i+1399], "ONLY");
2178         }
2179     }
2180
2181
2182 //************************************************************************
2183 //*                                                                      *
2184 //*                               S T R I P S                            *
2185 //*                               ===========                            *
2186 //*                                                                      *
2187 //************************************************************************
2188
2189 // --- Define SSD with the 35+39 lay-out 
2190
2191     if (fMinorVersion == 0 || fMinorVersion == 1 || fMinorVersion ==2) {
2192
2193 //--- Define ghost volume containing the Strip Detectors and fill it with air
2194 //     or vacuum 
2195
2196         xxm = 1.0444222222222224;
2197         dgh[0] = 0.;
2198         dgh[1] = 360.;
2199         dgh[2] = 4.;
2200         dgh[3] = -25. - 5.9900000000000002 / xxm - 
2201                 .0099999999999997868 / xxm - 17.990000000000002 / xxm - 10. / xxm - 12.997999999999998 / xxm;
2202         dgh[4] = 49.998;
2203         dgh[5] = 49.998;
2204         dgh[6] = -25. - 5.9900000000000002 / xxm - 
2205                 .0099999999999997868 / xxm - 17.990000000000002 / xxm - 10. / xxm;
2206         dgh[7] = 37.;
2207         dgh[8] = 49.998;
2208         dgh[9] = 5.9900000000000002 / xxm + 25. + 
2209                 .0099999999999997868 / xxm + 17.990000000000002 / xxm + 10. / xxm;
2210         dgh[10] = 37.;
2211         dgh[11] = 49.998;
2212         dgh[12] = 5.9900000000000002 / xxm + 25. + 
2213                 .0099999999999997868 / xxm + 17.990000000000002 / xxm + 10. / xxm + 12.997999999999998 / xxm;
2214         dgh[13] = 49.998;
2215         dgh[14] = 49.998;
2216         geant->Gsvolu("IT56", "PCON", idtmed[275], dgh, 15);
2217         geant->Gspos("IT56", 1, "ITSV", 0., 0., 0., 0, "ONLY");
2218         geant->Gsatt("IT56", "SEEN", 0);
2219
2220 // --- Layer #5 
2221
2222 //        GOTO 5678           ! skip ITS layer no. 5 
2223
2224 //--- Define a ghost volume containing a single ladder of layer #5 andfill
2225 //     it with air or vacuum 
2226
2227         dbox1[0] = .044999999999999998;
2228         dbox1[1] = 3.75;
2229         dbox1[2] = 45.109999999999999;
2230         geant->Gsvolu("ISV1", "BOX ", idtmed[253], dbox1, 3);
2231
2232 // --- Make the ghost volume invisible 
2233
2234         geant->Gsatt("ISV1", "SEEN", 0);
2235
2236 // --- Define a ghost volume containing the electronics and cooling of
2237 //     a single ladder of layer #5 and fill it with air or vacuum 
2238
2239         dsrv[0] = (TMath::Sqrt(3.) / 2. * 4.2 + .47 + .05) / 2.;
2240         dsrv[1] = 3.75;
2241         dsrv[2] = 45.109999999999999;
2242         geant->Gsvolu("SSV1", "BOX ", idtmed[253], dsrv, 3);
2243
2244 // --- Make the ghost volume invisible 
2245
2246         geant->Gsatt("SSV1", "SEEN", 0);
2247
2248 // --- Define a ghost volume containing the end-ladder stuff of 
2249 //     a single ladder of layer #5 and fill it with air or vacuum 
2250
2251         dela[0] = 2.;
2252         dela[1] = 3.5;
2253         dela[2] = 4.;
2254         geant->Gsvolu("ELL5", "BOX ", idtmed[253], dela, 3);
2255
2256 // --- Make the ghost volume invisible 
2257
2258         geant->Gsatt("ELL5", "SEEN", 0);
2259
2260 // --- Define a volume containing the sensitive part of the strips 
2261 //     (silicon, layer #5) 
2262
2263         dits[0] = .015;
2264         dits[1] = 3.75;
2265         dits[2] = 2.1;
2266         geant->Gsvolu("ITS5", "BOX ", idtmed[249], dits, 3);
2267
2268 // --- Define a volume containing the electronics of the strips 
2269 //     (silicon, layer #5) 
2270
2271         dchi[0] = .02;
2272         dchi[1] = 3.4;
2273         dchi[2] = .525;
2274         geant->Gsvolu("SCH5", "BOX ", idtmed[250], dchi, 3);
2275
2276 // --- Define the cooling tubes (aluminum, layer #5) 
2277
2278         dtub[0] = .09;
2279         dtub[1] = dtub[0] + .01;
2280         dtub[2] = 45.109999999999999;
2281         geant->Gsvolu("STB5", "TUBE", idtmed[255], dtub, 3);
2282
2283 // --- Define the cooling fluid (water or freon, layer #5) 
2284
2285         dwat[0] = 0.;
2286         dwat[1] = .09;
2287         dwat[2] = 45.109999999999999;
2288         geant->Gsvolu("SWT5", "TUBE", idtmed[256], dwat, 3);
2289 //        CALL GSVOLU('SWT5','TUBE',IDTMED(258),DWAT,3,IOUT)   ! freon
2290
2291 //--- Define the (triangular) element of the heat bridge (carbon, layer #5)
2292
2293 // water 
2294         dfra[0] = 120.;
2295         dfra[1] = 360.;
2296         dfra[2] = 3.;
2297         dfra[3] = 2.;
2298         dfra[4] = -.015;
2299         dfra[5] = TMath::Sqrt(3.) * 4.2 / 6.;
2300         dfra[6] = dfra[5] + .03;
2301         dfra[7] = .015;
2302         dfra[8] = dfra[5];
2303         dfra[9] = dfra[6];
2304         geant->Gsvolu("SFR5", "PGON", idtmed[252], dfra, 10);
2305
2306 // --- Define the element connecting the triangles of the heat bridge 
2307 //     (carbon, layer #5) 
2308
2309         dcei[0] = 0.;
2310         dcei[1] = .03;
2311         dcei[2] = 45.109999999999999;
2312         geant->Gsvolu("SCE5", "TUBE", idtmed[252], dcei, 3);
2313
2314 // --- Define the part of the end-ladder stuff made of plastic (G10FR4) 
2315 //     (layer #5) 
2316
2317         dpla[0] = .089285714285714288;
2318         dpla[1] = 3.5;
2319         dpla[2] = 4.;
2320         geant->Gsvolu("EPL5", "BOX ", idtmed[262], dpla, 3);
2321
2322 // --- Define the part of the end-ladder stuff made of copper (layer #5) 
2323
2324         dcop[0] = .017857142857142856;
2325         dcop[1] = 3.5;
2326         dcop[2] = 4.;
2327         geant->Gsvolu("ECU5", "BOX ", idtmed[259], dcop, 3);
2328
2329 // --- Define the part of the end-ladder stuff made of epoxy (layer #5) 
2330
2331         depx[0] = .26785714285714285;
2332         depx[1] = 3.5;
2333         depx[2] = 4.;
2334         geant->Gsvolu("EPX5", "BOX ", idtmed[262], depx, 3);
2335
2336 // --- Define the part of the end-ladder stuff made of silicon (bus) 
2337 //     (layer #5) 
2338
2339         dsil[0] = .17857142857142858;
2340         dsil[1] = 3.5;
2341         dsil[2] = 4.;
2342         geant->Gsvolu("ESI5", "BOX ", idtmed[251], dsil, 3);
2343
2344 // --- Place the end-ladder stuff into its mother (ELL5) 
2345
2346         sep = (4. - (dpla[0] + dcop[0] + depx[0] + dsil[0]) * 2.) / 3.;
2347         ypos = 0.;
2348         zpos = 0.;
2349
2350 // --- Plastic 
2351
2352         xpos = -dela[0] + dpla[0];
2353         geant->Gspos("EPL5", 1, "ELL5", xpos, ypos, zpos, 0, "ONLY");
2354
2355 // --- Copper 
2356
2357         xpos = -dela[0] + dpla[0] * 2. + sep + dcop[0];
2358         geant->Gspos("ECU5", 1, "ELL5", xpos, ypos, zpos, 0, "ONLY");
2359
2360 // --- Epoxy 
2361
2362         xpos = -dela[0] + dpla[0] * 2. + sep + dcop[0] * 2. + sep + depx[0];
2363         geant->Gspos("EPX5", 1, "ELL5", xpos, ypos, zpos, 0, "ONLY");
2364
2365 // --- Silicon (bus) 
2366
2367         xpos = -dela[0] + dpla[0] * 2. + sep + dcop[0] * 2. + sep + depx[0] * 2. + sep + dsil[0];
2368         geant->Gspos("ESI5", 1, "ELL5", xpos, ypos, zpos, 0, "ONLY");
2369
2370 // --- Place the sensitive part of the strips into its mother (ISV1) 
2371
2372         ypos = 0.;
2373         for (j = 1; j <= 23; ++j) {
2374             if (j % 2 == 0) xpos = dbox1[0] - dits[0];
2375             else            xpos = -dbox1[0] + dits[0];
2376             zpos = ((j - 1) - 11.) * 3.91;
2377             geant->Gspos("ITS5", j, "ISV1", xpos, ypos, zpos, 0, "ONLY");
2378         }
2379
2380 // --- Place the electronics of the strips into its mother (SSV1) 
2381
2382         ypos = 0.;
2383         for (j = 1; j <= 23; ++j) {
2384             if (j % 2 == 0) xpos = -dsrv[0] + .28;
2385             else            xpos = -dsrv[0] + .28 - dits[0] * 2. - .03;
2386             zpos = ((j - 1) - 11.) * 3.91 + .85;
2387             geant->Gspos("SCH5", j, "SSV1", xpos, ypos, zpos, 0, "ONLY");
2388         }
2389
2390 //--- Place the cooling tubes and the cooling fluid into their mother (SSV1)
2391
2392         xpos = -dsrv[0] + .41;
2393         zpos = 0.;
2394
2395 // --- Left tube (just a matter of convention) 
2396
2397         ypos = -2.3500000000000001;
2398         geant->Gspos("STB5", 1, "SSV1", xpos, ypos, zpos, 0, "ONLY");
2399         geant->Gspos("SWT5", 1, "SSV1", xpos, ypos, zpos, 0, "ONLY");
2400
2401 // --- Right tube (just a matter of convention) 
2402
2403         ypos = 2.3500000000000001;
2404         geant->Gspos("STB5", 2, "SSV1", xpos, ypos, zpos, 0, "ONLY");
2405         geant->Gspos("SWT5", 2, "SSV1", xpos, ypos, zpos, 0, "ONLY");
2406
2407 // --- Place the heat bridge elements into their mother (SSV1) 
2408
2409         xpos = -dsrv[0] + .47 + TMath::Sqrt(3.) / 6. * 4.2;
2410         ypos = 0.;
2411         for (j = 1; j <= 24; ++j) {
2412             zpos = ((j - 1) - 11.) * 3.91 - 2.1000000000000001;
2413             geant->Gspos("SFR5", j, "SSV1", xpos, ypos, zpos, 0, "ONLY");
2414         }
2415
2416 // --- Place the elements connecting the triangles of the heat bridge 
2417 //     into their mother (SSV1) 
2418
2419         zpos = 0.;
2420
2421 // --- Left element (just a matter of convention) 
2422
2423         xpos = -dsrv[0] + .47;
2424         ypos = -2.1150000000000002;
2425         geant->Gspos("SCE5", 1, "SSV1", xpos, ypos, zpos, 0, "ONLY");
2426
2427 // --- Right element 
2428
2429         xpos = -dsrv[0] + .47;
2430         ypos = 2.1150000000000002;
2431         geant->Gspos("SCE5", 2, "SSV1", xpos, ypos, zpos, 0, "ONLY");
2432
2433 // --- Top element 
2434
2435         xpos = -dsrv[0] + .47 + TMath::Sqrt(3.) / 2. * 4.2 + .015;
2436         ypos = 0.;
2437         geant->Gspos("SCE5", 3, "SSV1", xpos, ypos, zpos, 0, "ONLY");
2438
2439 // --- Place the ghost volumes containing the strip ladders (ISV1), 
2440 //    electronics/cooling (SSV1) and end-ladder stuff (ELL5) of layer #5 in
2441 //     their mother volume (IT56) 
2442
2443         offset1 = atg_(.9, 40.);
2444         offset2 = 5.2;
2445         rzero   = dbox1[0] + 40.;
2446         runo    = dbox1[0] * 2. + 40. + dsrv[0];
2447         rtwo    = dbox1[0] * 2. + 40. + dela[0];
2448         for (i = 1; i <= 35; ++i) {
2449             atheta = (i-1) * twopi * raddeg / 35. + offset2;
2450             AliMatrix(idrotm[i+1499], 90., atheta, 90., atheta + 90., 0., 0.);
2451
2452 // --- Strip ladders 
2453
2454             xpos = rzero * TMath::Cos((i-1) * twopi / 35. + offset1);
2455             ypos = rzero * TMath::Sin((i-1) * twopi / 35. + offset1);
2456             zpos = 0.;
2457             geant->Gspos("ISV1", i, "IT56", xpos, ypos, zpos, idrotm[i+1499], "ONLY");
2458
2459 // --- Electronics/cooling 
2460
2461             xpos = runo * TMath::Cos((i-1) * twopi / 35. + offset1);
2462             ypos = runo * TMath::Sin((i-1) * twopi / 35. + offset1);
2463             zpos = 0.;
2464             geant->Gspos("SSV1", i, "IT56", xpos, ypos, zpos, idrotm[i+1499], "ONLY");
2465
2466 // --- End-ladders (nagative-Z and positive-Z) 
2467
2468             xpos = rtwo * TMath::Cos((i-1) * twopi / 35. + offset1);
2469             ypos = rtwo * TMath::Sin((i-1) * twopi / 35. + offset1);
2470             zpos = -(dbox1[2] + dela[2] + 6.);
2471             geant->Gspos("ELL5", i, "IT56", xpos, ypos, zpos, idrotm[i+1499], "ONLY");
2472             zpos = dbox1[2] + dela[2] + 6.;
2473             geant->Gspos("ELL5", i + 35, "IT56", xpos, ypos, zpos, idrotm[i+1499], "ONLY");
2474         }
2475
2476
2477 // --- Layer #6 
2478
2479 //        GOTO 5778           ! skip ITS layer no. 6 
2480
2481 //--- Define a ghost volume containing a single ladder of layer #6 andfill
2482 //     it with air or vacuum 
2483
2484         dbox2[0] = .044999999999999998;
2485         dbox2[1] = 3.75;
2486         dbox2[2] = 50.975000000000001;
2487         geant->Gsvolu("ISV2", "BOX ", idtmed[253], dbox2, 3);
2488
2489 // --- Make the ghost volume invisible 
2490
2491         geant->Gsatt("ISV2", "SEEN", 0);
2492
2493 // --- Define a ghost volume containing the electronics and cooling of
2494 //     a single ladder of layer #6 and fill it with air or vacuum 
2495
2496         dsrv[0] = (TMath::Sqrt(3.) / 2. * 4.2 + .47 + .05) / 2.;
2497         dsrv[1] = 3.75;
2498         dsrv[2] = 50.975000000000001;
2499         geant->Gsvolu("SSV2", "BOX ", idtmed[253], dsrv, 3);
2500
2501 // --- Make the ghost volume invisible 
2502
2503         geant->Gsatt("SSV2", "SEEN", 0);
2504
2505 // --- Define a ghost volume containing the end-ladder stuff of 
2506 //     a single ladder of layer #6 and fill it with air or vacuum 
2507
2508         dela[0] = 2.;
2509         dela[1] = 3.5;
2510         dela[2] = 4.;
2511         geant->Gsvolu("ELL6", "BOX ", idtmed[253], dela, 3);
2512
2513 // --- Make the ghost volume invisible 
2514
2515         geant->Gsatt("ELL6", "SEEN", 0);
2516
2517 // --- Define a volume containing the sensitive part of the strips 
2518 //     (silicon, layer #6) 
2519
2520         dits[0] = .015;
2521         dits[1] = 3.75;
2522         dits[2] = 2.1;
2523         geant->Gsvolu("ITS6", "BOX ", idtmed[249], dits, 3);
2524
2525 // --- Define a volume containing the electronics of the strips 
2526 //     (silicon, layer #6) 
2527
2528         dchi[0] = .02;
2529         dchi[1] = 3.4;
2530         dchi[2] = .525;
2531         geant->Gsvolu("SCH6", "BOX ", idtmed[250], dchi, 3);
2532
2533 // --- Define the cooling tubes (aluminum, layer #6) 
2534
2535         dtub[0] = .09;
2536         dtub[1] = dtub[0] + .01;
2537         dtub[2] = 50.975000000000001;
2538         geant->Gsvolu("STB6", "TUBE", idtmed[255], dtub, 3);
2539
2540 // --- Define the cooling fluid (water or freon, layer #6) 
2541
2542         dwat[0] = 0.;
2543         dwat[1] = .09;
2544         dwat[2] = 50.975000000000001;
2545         geant->Gsvolu("SWT6", "TUBE", idtmed[256], dwat, 3);
2546 //        CALL GSVOLU('SWT6','TUBE',IDTMED(258),DWAT,3,IOUT)   ! freon
2547
2548 //--- Define the (triangular) element of the heat bridge (carbon, layer #6)
2549
2550 // water 
2551         dfra[0] = 120.;
2552         dfra[1] = 360.;
2553         dfra[2] = 3.;
2554         dfra[3] = 2.;
2555         dfra[4] = -.015;
2556         dfra[5] = TMath::Sqrt(3.) * 4.2 / 6.;
2557         dfra[6] = dfra[5] + .03;
2558         dfra[7] = .015;
2559         dfra[8] = dfra[5];
2560         dfra[9] = dfra[6];
2561         geant->Gsvolu("SFR6", "PGON", idtmed[252], dfra, 10);
2562
2563 // --- Define the element connecting the triangles of the heat bridge 
2564 //     (carbon, layer #6) 
2565
2566         dcei[0] = 0.;
2567         dcei[1] = .03;
2568         dcei[2] = 50.975000000000001;
2569         geant->Gsvolu("SCE6", "TUBE", idtmed[252], dcei, 3);
2570
2571 // --- Define the part of the end-ladder stuff made of plastic (G10FR4) 
2572 //     (layer #6) 
2573
2574         dpla[0] = .089285714285714288;
2575         dpla[1] = 3.5;
2576         dpla[2] = 4.;
2577         geant->Gsvolu("EPL6", "BOX ", idtmed[262], dpla, 3);
2578
2579 // --- Define the part of the end-ladder stuff made of copper (layer #6) 
2580
2581         dcop[0] = .017857142857142856;
2582         dcop[1] = 3.5;
2583         dcop[2] = 4.;
2584         geant->Gsvolu("ECU6", "BOX ", idtmed[259], dcop, 3);
2585
2586 // --- Define the part of the end-ladder stuff made of epoxy (layer #6) 
2587
2588         depx[0] = .26785714285714285;
2589         depx[1] = 3.5;
2590         depx[2] = 4.;
2591         geant->Gsvolu("EPX6", "BOX ", idtmed[262], depx, 3);
2592
2593 // --- Define the part of the end-ladder stuff made of silicon (bus) 
2594 //     (layer #6) 
2595
2596         dsil[0] = .17857142857142858;
2597         dsil[1] = 3.5;
2598         dsil[2] = 4.;
2599         geant->Gsvolu("ESI6", "BOX ", idtmed[251], dsil, 3);
2600
2601 // --- Place the end-ladder stuff into its mother (ELL5) 
2602
2603         sep  = (4. - (dpla[0] + dcop[0] + depx[0] + dsil[0]) * 2.) / 3.;
2604         ypos = 0.;
2605         zpos = 0.;
2606
2607 // --- Plastic 
2608
2609         xpos = -dela[0] + dpla[0];
2610         geant->Gspos("EPL6", 1, "ELL6", xpos, ypos, zpos, 0, "ONLY");
2611
2612 // --- Copper 
2613
2614         xpos = -dela[0] + dpla[0] * 2. + sep + dcop[0];
2615         geant->Gspos("ECU6", 1, "ELL6", xpos, ypos, zpos, 0, "ONLY");
2616
2617 // --- Epoxy 
2618
2619         xpos = -dela[0] + dpla[0] * 2. + sep + dcop[0] * 2. + sep + depx[0];
2620         geant->Gspos("EPX6", 1, "ELL6", xpos, ypos, zpos, 0, "ONLY");
2621
2622 // --- Silicon (bus) 
2623
2624         xpos = -dela[0] + dpla[0] * 2. + sep + dcop[0] * 2. + sep + depx[0] * 2. + sep + dsil[0];
2625         geant->Gspos("ESI6", 1, "ELL6", xpos, ypos, zpos, 0, "ONLY");
2626
2627 // --- Place the sensitive part of the strips into its mother (ISV2) 
2628
2629         ypos = 0.;
2630         for (j = 1; j <= 26; ++j) {
2631             if (j % 2 == 0) xpos = dbox2[0] - dits[0];
2632             else            xpos = -dbox2[0] + dits[0];
2633             zpos = ((j - 1) - 12.) * 3.91 - 1.96;
2634             geant->Gspos("ITS6", j, "ISV2", xpos, ypos, zpos, 0, "ONLY");
2635         }
2636
2637 // --- Place the electronics of the strips into its mother (SSV2) 
2638
2639         ypos = 0.;
2640         for (j = 1; j <= 26; ++j) {
2641             if (j % 2 == 0) xpos = -dsrv[0] + .28;
2642             else            xpos = -dsrv[0] + .28 - dits[0] * 2. - .03;
2643             zpos = ((j - 1) - 12.) * 3.91 - 1.96 + .85;
2644             geant->Gspos("SCH5", j, "SSV2", xpos, ypos, zpos, 0, "ONLY");
2645         }
2646
2647 //--- Place the cooling tubes and the cooling fluid into their mother (SSV1)
2648
2649         xpos = -dsrv[0] + .41;
2650         zpos = 0.;
2651
2652 // --- Left tube (just a matter of convention) 
2653
2654         ypos = -2.3500000000000001;
2655         geant->Gspos("STB6", 1, "SSV2", xpos, ypos, zpos, 0, "ONLY");
2656         geant->Gspos("SWT6", 1, "SSV2", xpos, ypos, zpos, 0, "ONLY");
2657
2658 // --- Right tube (just a matter of convention) 
2659
2660         ypos = 2.3500000000000001;
2661         geant->Gspos("STB6", 2, "SSV2", xpos, ypos, zpos, 0, "ONLY");
2662         geant->Gspos("SWT6", 2, "SSV2", xpos, ypos, zpos, 0, "ONLY");
2663
2664 // --- Place the heat bridge elements into their mother (SSV2) 
2665
2666         xpos = -dsrv[0] + .47 + TMath::Sqrt(3.) / 6. * 4.2;
2667         ypos = 0.;
2668         for (j = 1; j <= 27; ++j) {
2669             zpos = ((j - 1) - 12.) * 3.91 - 1.96 - 2.1000000000000001;
2670             geant->Gspos("SFR6", j, "SSV2", xpos, ypos, zpos, 0, "ONLY");
2671         }
2672
2673 // --- Place the elements connecting the triangles of the heat bridge 
2674 //     into their mother (SSV2) 
2675
2676         zpos = 0.;
2677
2678 // --- Left element (just a matter of convention) 
2679
2680         xpos = -dsrv[0] + .47;
2681         ypos = -2.1150000000000002;
2682         geant->Gspos("SCE6", 1, "SSV2", xpos, ypos, zpos, 0, "ONLY");
2683
2684 // --- Right element 
2685
2686         xpos = -dsrv[0] + .47;
2687         ypos = 2.1150000000000002;
2688         geant->Gspos("SCE6", 2, "SSV2", xpos, ypos, zpos, 0, "ONLY");
2689
2690 // --- Top element 
2691
2692         xpos = -dsrv[0] + .47 + TMath::Sqrt(3.) / 2. * 4.2 + .015;
2693         ypos = 0.;
2694         geant->Gspos("SCE6", 3, "SSV2", xpos, ypos, zpos, 0, "ONLY");
2695
2696 // --- Place the ghost volumes containing the strip ladders (ISV2), 
2697 //    electronics/cooling (SSV2) and end-ladder stuff (ELL6) of layer #6 in
2698 //     their mother volume (IT56) 
2699
2700         offset1 = atg_(1., 45.);
2701         offset2 = 5.2;
2702         rzero   = dbox2[0] + 45.;
2703         runo    = dbox2[0] * 2. + 45. + dsrv[0];
2704         rtwo    = dbox2[0] * 2. + 45. + dela[0];
2705         for (i = 1; i <= 39; ++i) {
2706             atheta = (i-1) * twopi * raddeg / 39. + offset2;
2707             AliMatrix(idrotm[i+1599], 90., atheta, 90., atheta + 90., 0., 0.);
2708
2709 // --- Strip ladders 
2710
2711             xpos = rzero * TMath::Cos((i-1) * twopi / 39. + offset1);
2712             ypos = rzero * TMath::Sin((i-1) * twopi / 39. + offset1);
2713             zpos = 0.;
2714             geant->Gspos("ISV2", i, "IT56", xpos, ypos, zpos, idrotm[i+1599], "ONLY");
2715
2716 // --- Electronics/cooling 
2717
2718             xpos = runo * TMath::Cos((i-1) * twopi / 39. + offset1);
2719             ypos = runo * TMath::Sin((i-1) * twopi / 39. + offset1);
2720             zpos = 0.;
2721             geant->Gspos("SSV2", i, "IT56", xpos, ypos, zpos, idrotm[i+1599], "ONLY");
2722
2723 // --- End-ladders (nagative-Z and positive-Z) 
2724
2725             xpos = rtwo * TMath::Cos((i-1) * twopi / 39. + offset1);
2726             ypos = rtwo * TMath::Sin((i-1) * twopi / 39. + offset1);
2727             zpos = -(dbox2[2] + dela[2] + 6.);
2728             geant->Gspos("ELL6", i, "IT56", xpos, ypos, zpos, idrotm[i+1599], "ONLY");
2729             zpos = dbox2[2] + dela[2] + 6.;
2730             geant->Gspos("ELL6", i + 39, "IT56", xpos, ypos, zpos, idrotm[i+1599], "ONLY");
2731         }
2732
2733
2734     }
2735
2736 // --- Define SSD with the 32+36 lay-out 
2737
2738     if (fMinorVersion == 3 || fMinorVersion == 4 || fMinorVersion == 5) {
2739
2740 //--- Define ghost volume containing the Strip Detectors and fill it with air
2741 //     or vacuum 
2742
2743         xxm    = 1.0444222222222224;
2744         dgh[0] = 0.;
2745         dgh[1] = 360.;
2746         dgh[2] = 4.;
2747         dgh[3] = -25. - 5.9900000000000002 / xxm - 
2748                 .0099999999999997868 / xxm - 17.990000000000002 / xxm - 9. / xxm - 13.997999999999998 / xxm;
2749         dgh[4] = 49.998;
2750         dgh[5] = 49.998;
2751         dgh[6] = -25. - 5.9900000000000002 / xxm - 
2752                 .0099999999999997868 / xxm - 17.990000000000002 / xxm - 9. / xxm;
2753         dgh[7] = 36.;
2754         dgh[8] = 49.998;
2755         dgh[9] = 5.9900000000000002 / xxm + 25. + 
2756                 .0099999999999997868 / xxm + 17.990000000000002 / xxm + 9. / xxm;
2757         dgh[10] = 36.;
2758         dgh[11] = 49.998;
2759         dgh[12] = 5.9900000000000002 / xxm + 25. + 
2760                 .0099999999999997868 / xxm + 17.990000000000002 / xxm + 9. / xxm + 13.997999999999998 / xxm;
2761         dgh[13] = 49.998;
2762         dgh[14] = 49.998;
2763         geant->Gsvolu("IT56", "PCON", idtmed[275], dgh, 15);
2764         geant->Gspos("IT56", 1, "ITSV", 0., 0., 0., 0, "ONLY");
2765         geant->Gsatt("IT56", "SEEN", 0);
2766
2767 // --- Layer #5 
2768
2769 //        GOTO 6678           ! skip ITS layer no. 5 
2770
2771 //--- Define a ghost volume containing a single ladder of layer #5 andfill
2772 //     it with air or vacuum 
2773
2774         dbox1[0] = .044999999999999998;
2775         dbox1[1] = 3.75;
2776         dbox1[2] = 43.155000000000001;
2777         geant->Gsvolu("ISV1", "BOX ", idtmed[253], dbox1, 3);
2778
2779 // --- Make the ghost volume invisible 
2780
2781         geant->Gsatt("ISV1", "SEEN", 0);
2782
2783 // --- Define a ghost volume containing the electronics and cooling of
2784 //     a single ladder of layer #5 and fill it with air or vacuum 
2785
2786         dsrv[0] = (TMath::Sqrt(3.) / 2. * 4.2 + .47 + .05) / 2.;
2787         dsrv[1] = 3.75;
2788         dsrv[2] = 43.155000000000001;
2789         geant->Gsvolu("SSV1", "BOX ", idtmed[253], dsrv, 3);
2790
2791 // --- Make the ghost volume invisible 
2792
2793         geant->Gsatt("SSV1", "SEEN", 0);
2794
2795 // --- Define a ghost volume containing the end-ladder stuff of 
2796 //     a single ladder of layer #5 and fill it with air or vacuum 
2797
2798         dela[0] = 2.;
2799         dela[1] = 3.5;
2800         dela[2] = 4.;
2801         geant->Gsvolu("ELL5", "BOX ", idtmed[253], dela, 3);
2802
2803 // --- Make the ghost volume invisible 
2804
2805         geant->Gsatt("ELL5", "SEEN", 0);
2806
2807 // --- Define a volume containing the sensitive part of the strips 
2808 //     (silicon, layer #5) 
2809
2810         dits[0] = .015;
2811         dits[1] = 3.75;
2812         dits[2] = 2.1;
2813         geant->Gsvolu("ITS5", "BOX ", idtmed[249], dits, 3);
2814
2815 // --- Define a volume containing the electronics of the strips 
2816 //     (silicon, layer #5) 
2817
2818         dchi[0] = .02;
2819         dchi[1] = 3.4;
2820         dchi[2] = .525;
2821         geant->Gsvolu("SCH5", "BOX ", idtmed[250], dchi, 3);
2822
2823 // --- Define the cooling tubes (aluminum, layer #5) 
2824
2825         dtub[0] = .09;
2826         dtub[1] = dtub[0] + .01;
2827         dtub[2] = 43.155000000000001;
2828         geant->Gsvolu("STB5", "TUBE", idtmed[255], dtub, 3);
2829
2830 // --- Define the cooling fluid (water or freon, layer #5) 
2831
2832         dwat[0] = 0.;
2833         dwat[1] = .09;
2834         dwat[2] = 43.155000000000001;
2835         geant->Gsvolu("SWT5", "TUBE", idtmed[256], dwat, 3);
2836 //        CALL GSVOLU('SWT5','TUBE',IDTMED(258),DWAT,3,IOUT)   ! freon
2837
2838 //--- Define the (triangular) element of the heat bridge (carbon, layer #5)
2839
2840 // water 
2841         dfra[0] = 120.;
2842         dfra[1] = 360.;
2843         dfra[2] = 3.;
2844         dfra[3] = 2.;
2845         dfra[4] = -.015;
2846         dfra[5] = TMath::Sqrt(3.) * 4.2 / 6.;
2847         dfra[6] = dfra[5] + .03;
2848         dfra[7] = .015;
2849         dfra[8] = dfra[5];
2850         dfra[9] = dfra[6];
2851         geant->Gsvolu("SFR5", "PGON", idtmed[252], dfra, 10);
2852
2853 // --- Define the element connecting the triangles of the heat bridge 
2854 //     (carbon, layer #5) 
2855
2856         dcei[0] = 0.;
2857         dcei[1] = .03;
2858         dcei[2] = 43.155000000000001;
2859         geant->Gsvolu("SCE5", "TUBE", idtmed[252], dcei, 3);
2860
2861 // --- Define the part of the end-ladder stuff made of plastic (G10FR4) 
2862 //     (layer #5) 
2863
2864         dpla[0] = .089285714285714288;
2865         dpla[1] = 3.5;
2866         dpla[2] = 4.;
2867         geant->Gsvolu("EPL5", "BOX ", idtmed[262], dpla, 3);
2868
2869 // --- Define the part of the end-ladder stuff made of copper (layer #5) 
2870
2871         dcop[0] = .017857142857142856;
2872         dcop[1] = 3.5;
2873         dcop[2] = 4.;
2874         geant->Gsvolu("ECU5", "BOX ", idtmed[259], dcop, 3);
2875
2876 // --- Define the part of the end-ladder stuff made of epoxy (layer #5) 
2877
2878         depx[0] = .26785714285714285;
2879         depx[1] = 3.5;
2880         depx[2] = 4.;
2881         geant->Gsvolu("EPX5", "BOX ", idtmed[262], depx, 3);
2882
2883 // --- Define the part of the end-ladder stuff made of silicon (bus) 
2884 //     (layer #5) 
2885
2886         dsil[0] = .17857142857142858;
2887         dsil[1] = 3.5;
2888         dsil[2] = 4.;
2889         geant->Gsvolu("ESI5", "BOX ", idtmed[251], dsil, 3);
2890
2891 // --- Place the end-ladder stuff into its mother (ELL5) 
2892
2893         sep  = (4. - (dpla[0] + dcop[0] + depx[0] + dsil[0]) * 2.) / 3.;
2894         ypos = 0.;
2895         zpos = 0.;
2896
2897 // --- Plastic 
2898
2899         xpos = -dela[0] + dpla[0];
2900         geant->Gspos("EPL5", 1, "ELL5", xpos, ypos, zpos, 0, "ONLY");
2901
2902 // --- Copper 
2903
2904         xpos = -dela[0] + dpla[0] * 2. + sep + dcop[0];
2905         geant->Gspos("ECU5", 1, "ELL5", xpos, ypos, zpos, 0, "ONLY");
2906
2907 // --- Epoxy 
2908
2909         xpos = -dela[0] + dpla[0] * 2. + sep + dcop[0] * 2. + sep + depx[0];
2910         geant->Gspos("EPX5", 1, "ELL5", xpos, ypos, zpos, 0, "ONLY");
2911
2912 // --- Silicon (bus) 
2913
2914         xpos = -dela[0] + dpla[0] * 2. + sep + dcop[0] * 2. + sep + depx[0] * 2. + sep + dsil[0];
2915         geant->Gspos("ESI5", 1, "ELL5", xpos, ypos, zpos, 0, "ONLY");
2916
2917 // --- Place the sensitive part of the strips into its mother (ISV1) 
2918
2919         ypos = 0.;
2920         for (j = 1; j <= 22; ++j) {
2921             if (j % 2 == 0) xpos = dbox1[0] - dits[0];
2922             else            xpos = -dbox1[0] + dits[0];
2923             zpos = ((j - 1) - 10.) * 3.91 - 1.96;
2924             geant->Gspos("ITS5", j, "ISV1", xpos, ypos, zpos, 0, "ONLY");
2925         }
2926
2927 // --- Place the electronics of the strips into its mother (SSV1) 
2928
2929         ypos = 0.;
2930         for (j = 1; j <= 22; ++j) {
2931             if (j % 2 == 0) xpos = -dsrv[0] + .28;
2932             else            xpos = -dsrv[0] + .28 - dits[0] * 2. - .03;
2933             zpos = ((j - 1) - 10.) * 3.91 - 1.96 + .85;
2934             geant->Gspos("SCH5", j, "SSV1", xpos, ypos, zpos, 0, "ONLY");
2935         }
2936
2937 //--- Place the cooling tubes and the cooling fluid into their mother (SSV1)
2938
2939         xpos = -dsrv[0] + .41;
2940         zpos = 0.;
2941
2942 // --- Left tube (just a matter of convention) 
2943
2944         ypos = -2.3500000000000001;
2945         geant->Gspos("STB5", 1, "SSV1", xpos, ypos, zpos, 0, "ONLY");
2946         geant->Gspos("SWT5", 1, "SSV1", xpos, ypos, zpos, 0, "ONLY");
2947
2948 // --- Right tube (just a matter of convention) 
2949
2950         ypos = 2.3500000000000001;
2951         geant->Gspos("STB5", 2, "SSV1", xpos, ypos, zpos, 0, "ONLY");
2952         geant->Gspos("SWT5", 2, "SSV1", xpos, ypos, zpos, 0, "ONLY");
2953
2954 // --- Place the heat bridge elements into their mother (SSV1) 
2955
2956         xpos = -dsrv[0] + .47 + TMath::Sqrt(3.) / 6. * 4.2;
2957         ypos = 0.;
2958         for (j = 1; j <= 23; ++j) {
2959             zpos = ((j - 1) - 10.) * 3.91 - 1.96 - 2.1000000000000001;
2960             geant->Gspos("SFR5", j, "SSV1", xpos, ypos, zpos, 0, "ONLY");
2961         }
2962
2963 // --- Place the elements connecting the triangles of the heat bridge 
2964 //     into their mother (SSV1) 
2965
2966         zpos = 0.;
2967
2968 // --- Left element (just a matter of convention) 
2969
2970         xpos = -dsrv[0] + .47;
2971         ypos = -2.1150000000000002;
2972         geant->Gspos("SCE5", 1, "SSV1", xpos, ypos, zpos, 0, "ONLY");
2973
2974 // --- Right element 
2975
2976         xpos = -dsrv[0] + .47;
2977         ypos = 2.1150000000000002;
2978         geant->Gspos("SCE5", 2, "SSV1", xpos, ypos, zpos, 0, "ONLY");
2979
2980 // --- Top element 
2981
2982         xpos = -dsrv[0] + .47 + TMath::Sqrt(3.) / 2. * 4.2 + .015;
2983         ypos = 0.;
2984         geant->Gspos("SCE5", 3, "SSV1", xpos, ypos, zpos, 0, "ONLY");
2985
2986 // --- Place the ghost volumes containing the strip ladders (ISV1), 
2987 //    electronics/cooling (SSV1) and end-ladder stuff (ELL5) of layer #5 in
2988 //     their mother volume (IT56) 
2989
2990         offset1 = atg_(.8, 36.6);
2991         offset2 = 5.2;
2992         rzero   = dbox1[0] + 36.6;
2993         runo    = dbox1[0] * 2. + 36.6 + dsrv[0];
2994         rtwo    = dbox1[0] * 2. + 36.6 + dela[0];
2995         for (i = 1; i <= 32; ++i) {
2996             atheta = (i-1) * twopi * raddeg / 32. + offset2;
2997             AliMatrix(idrotm[i+1499], 90., atheta, 90., atheta + 90., 0., 0.);
2998
2999 // --- Strip ladders 
3000
3001             xpos = rzero * TMath::Cos((i-1) * twopi / 32. + offset1);
3002             ypos = rzero * TMath::Sin((i-1) * twopi / 32. + offset1);
3003             zpos = 0.;
3004             geant->Gspos("ISV1", i, "IT56", xpos, ypos, zpos, idrotm[i+1499], "ONLY");
3005
3006 // --- Electronics/cooling 
3007
3008             xpos = runo * TMath::Cos((i-1) * twopi / 32. + offset1);
3009             ypos = runo * TMath::Sin((i-1) * twopi / 32. + offset1);
3010             zpos = 0.;
3011             geant->Gspos("SSV1", i, "IT56", xpos, ypos, zpos, idrotm[i+1499], "ONLY");
3012
3013 // --- End-ladders (nagative-Z and positive-Z) 
3014
3015             xpos = rtwo * TMath::Cos((i-1) * twopi / 32. + offset1);
3016             ypos = rtwo * TMath::Sin((i-1) * twopi / 32. + offset1);
3017             zpos = -(dbox1[2] + dela[2] + 6.);
3018             geant->Gspos("ELL5", i, "IT56", xpos, ypos, zpos, idrotm[i+1499], "ONLY");
3019             zpos = dbox1[2] + dela[2] + 6.;
3020             geant->Gspos("ELL5", i + 35, "IT56", xpos, ypos, zpos, idrotm[i+1499], "ONLY");
3021         }
3022
3023
3024 // --- Layer #6 
3025
3026 //        GOTO 6778           ! skip ITS layer no. 6 
3027
3028 //--- Define a ghost volume containing a single ladder of layer #6 andfill
3029 //     it with air or vacuum 
3030
3031         dbox2[0] = .044999999999999998;
3032         dbox2[1] = 3.75;
3033         dbox2[2] = 47.064999999999998;
3034         geant->Gsvolu("ISV2", "BOX ", idtmed[253], dbox2, 3);
3035
3036 // --- Make the ghost volume invisible 
3037
3038         geant->Gsatt("ISV2", "SEEN", 0);
3039
3040 // --- Define a ghost volume containing the electronics and cooling of
3041 //     a single ladder of layer #6 and fill it with air or vacuum 
3042
3043         dsrv[0] = (TMath::Sqrt(3.) / 2. * 4.2 + .47 + .05) / 2.;
3044         dsrv[1] = 3.75;
3045         dsrv[2] = 47.064999999999998;
3046         geant->Gsvolu("SSV2", "BOX ", idtmed[253], dsrv, 3);
3047
3048 // --- Make the ghost volume invisible 
3049
3050         geant->Gsatt("SSV2", "SEEN", 0);
3051
3052 // --- Define a ghost volume containing the end-ladder stuff of 
3053 //     a single ladder of layer #6 and fill it with air or vacuum 
3054
3055         dela[0] = 2.;
3056         dela[1] = 3.5;
3057         dela[2] = 4.;
3058         geant->Gsvolu("ELL6", "BOX ", idtmed[253], dela, 3);
3059
3060 // --- Make the ghost volume invisible 
3061
3062         geant->Gsatt("ELL6", "SEEN", 0);
3063
3064 // --- Define a volume containing the sensitive part of the strips 
3065 //     (silicon, layer #6) 
3066
3067         dits[0] = .015;
3068         dits[1] = 3.75;
3069         dits[2] = 2.1;
3070         geant->Gsvolu("ITS6", "BOX ", idtmed[249], dits, 3);
3071
3072 // --- Define a volume containing the electronics of the strips 
3073 //     (silicon, layer #6) 
3074
3075         dchi[0] = .02;
3076         dchi[1] = 3.4;
3077         dchi[2] = .525;
3078         geant->Gsvolu("SCH6", "BOX ", idtmed[250], dchi, 3);
3079
3080 // --- Define the cooling tubes (aluminum, layer #6) 
3081
3082         dtub[0] = .09;
3083         dtub[1] = dtub[0] + .01;
3084         dtub[2] = 47.064999999999998;
3085         geant->Gsvolu("STB6", "TUBE", idtmed[255], dtub, 3);
3086
3087 // --- Define the cooling fluid (water or freon, layer #6) 
3088
3089         dwat[0] = 0.;
3090         dwat[1] = .09;
3091         dwat[2] = 47.064999999999998;
3092         geant->Gsvolu("SWT6", "TUBE", idtmed[256], dwat, 3);
3093 //        CALL GSVOLU('SWT6','TUBE',IDTMED(258),DWAT,3,IOUT)   ! freon
3094
3095 //--- Define the (triangular) element of the heat bridge (carbon, layer #6)
3096
3097 // water 
3098         dfra[0] = 120.;
3099         dfra[1] = 360.;
3100         dfra[2] = 3.;
3101         dfra[3] = 2.;
3102         dfra[4] = -.015;
3103         dfra[5] = TMath::Sqrt(3.) * 4.2 / 6.;
3104         dfra[6] = dfra[5] + .03;
3105         dfra[7] = .015;
3106         dfra[8] = dfra[5];
3107         dfra[9] = dfra[6];
3108         geant->Gsvolu("SFR6", "PGON", idtmed[252], dfra, 10);
3109
3110 // --- Define the element connecting the triangles of the heat bridge 
3111 //     (carbon, layer #6) 
3112
3113         dcei[0] = 0.;
3114         dcei[1] = .03;
3115         dcei[2] = 47.064999999999998;
3116         geant->Gsvolu("SCE6", "TUBE", idtmed[252], dcei, 3);
3117
3118 // --- Define the part of the end-ladder stuff made of plastic (G10FR4) 
3119 //     (layer #6) 
3120
3121         dpla[0] = .089285714285714288;
3122         dpla[1] = 3.5;
3123         dpla[2] = 4.;
3124         geant->Gsvolu("EPL6", "BOX ", idtmed[262], dpla, 3);
3125
3126 // --- Define the part of the end-ladder stuff made of copper (layer #6) 
3127
3128         dcop[0] = .017857142857142856;
3129         dcop[1] = 3.5;
3130         dcop[2] = 4.;
3131         geant->Gsvolu("ECU6", "BOX ", idtmed[259], dcop, 3);
3132
3133 // --- Define the part of the end-ladder stuff made of epoxy (layer #6) 
3134
3135         depx[0] = .26785714285714285;
3136         depx[1] = 3.5;
3137         depx[2] = 4.;
3138         geant->Gsvolu("EPX6", "BOX ", idtmed[262], depx, 3);
3139
3140 // --- Define the part of the end-ladder stuff made of silicon (bus) 
3141 //     (layer #6) 
3142
3143         dsil[0] = .17857142857142858;
3144         dsil[1] = 3.5;
3145         dsil[2] = 4.;
3146         geant->Gsvolu("ESI6", "BOX ", idtmed[251], dsil, 3);
3147
3148 // --- Place the end-ladder stuff into its mother (ELL5) 
3149
3150         sep= (4. - (dpla[0] + dcop[0] + depx[0] + dsil[0]) * 2.) / 3.;
3151         ypos = 0.;
3152         zpos = 0.;
3153
3154 // --- Plastic 
3155
3156         xpos = -dela[0] + dpla[0];
3157         geant->Gspos("EPL6", 1, "ELL6", xpos, ypos, zpos, 0, "ONLY");
3158
3159 // --- Copper 
3160
3161         xpos = -dela[0] + dpla[0] * 2. + sep + dcop[0];
3162         geant->Gspos("ECU6", 1, "ELL6", xpos, ypos, zpos, 0, "ONLY");
3163
3164 // --- Epoxy 
3165
3166         xpos = -dela[0] + dpla[0] * 2. + sep + dcop[0] * 2. + sep + depx[0];
3167         geant->Gspos("EPX6", 1, "ELL6", xpos, ypos, zpos, 0, "ONLY");
3168
3169 // --- Silicon (bus) 
3170
3171         xpos = -dela[0] + dpla[0] * 2. + sep + dcop[0] * 2. + sep + depx[0] * 2. + sep + dsil[0];
3172         geant->Gspos("ESI6", 1, "ELL6", xpos, ypos, zpos, 0, "ONLY");
3173
3174 // --- Place the sensitive part of the strips into its mother (ISV2) 
3175
3176         ypos = 0.;
3177         for (j = 1; j <= 24; ++j) {
3178             if (j % 2 == 0) xpos = -dbox2[0] + dits[0];
3179             else            xpos = dbox2[0] - dits[0];
3180             zpos = ((j - 1) - 11.) * 3.91 - 1.96;
3181             geant->Gspos("ITS6", j, "ISV2", xpos, ypos, zpos, 0, "ONLY");
3182         }
3183
3184 // --- Place the electronics of the strips into its mother (SSV2) 
3185
3186         ypos = 0.;
3187         for (j = 1; j <= 24; ++j) {
3188             if (j % 2 == 0) xpos = -dsrv[0] + .28 - dits[0] * 2. - .03;
3189             else            xpos = -dsrv[0] + .28;
3190             zpos = ((j - 1) - 11.) * 3.91 - 1.96 + .85;
3191             geant->Gspos("SCH5", j, "SSV1", xpos, ypos, zpos, 0, "ONLY");
3192         }
3193
3194 //--- Place the cooling tubes and the cooling fluid into their mother (SSV2)
3195
3196         xpos = -dsrv[0] + .41;
3197         zpos = 0.;
3198
3199 // --- Left tube (just a matter of convention) 
3200
3201         ypos = -2.3500000000000001;
3202         geant->Gspos("STB6", 1, "SSV2", xpos, ypos, zpos, 0, "ONLY");
3203         geant->Gspos("SWT6", 1, "SSV2", xpos, ypos, zpos, 0, "ONLY");
3204
3205 // --- Right tube (just a matter of convention) 
3206
3207         ypos = 2.3500000000000001;
3208         geant->Gspos("STB6", 2, "SSV2", xpos, ypos, zpos, 0, "ONLY");
3209         geant->Gspos("SWT6", 2, "SSV2", xpos, ypos, zpos, 0, "ONLY");
3210
3211 // --- Place the heat bridge elements into their mother (SSV2) 
3212
3213         xpos = -dsrv[0] + .47 + TMath::Sqrt(3.) / 6. * 4.2;
3214         ypos = 0.;
3215         for (j = 1; j <= 25; ++j) {
3216             zpos = ((j - 1) - 11.) * 3.91 - 1.96 - 2.1000000000000001;
3217             geant->Gspos("SFR6", j, "SSV2", xpos, ypos, zpos, 0, "ONLY");
3218         }
3219
3220 // --- Place the elements connecting the triangles of the heat bridge 
3221 //     into their mother (SSV2) 
3222
3223         zpos = 0.;
3224
3225 // --- Left element (just a matter of convention) 
3226
3227         xpos = -dsrv[0] + .47;
3228         ypos = -2.1150000000000002;
3229         geant->Gspos("SCE6", 1, "SSV2", xpos, ypos, zpos, 0, "ONLY");
3230
3231 // --- Right element 
3232
3233         xpos = -dsrv[0] + .47;
3234         ypos = 2.1150000000000002;
3235         geant->Gspos("SCE6", 2, "SSV2", xpos, ypos, zpos, 0, "ONLY");
3236
3237 // --- Top element 
3238
3239         xpos = -dsrv[0] + .47 + TMath::Sqrt(3.) / 2. * 4.2 + .015;
3240         ypos = 0.;
3241         geant->Gspos("SCE6", 3, "SSV2", xpos, ypos, zpos, 0, "ONLY");
3242
3243 // --- Place the ghost volumes containing the strip ladders (ISV2), 
3244 //    electronics/cooling (SSV2) and end-ladder stuff (ELL6) of layer #6 in
3245 //     their mother volume (IT56) 
3246
3247         offset1 = atg_(.9, 41.2);
3248         offset2 = 5.2;
3249         rzero   = dbox2[0] + 41.2;
3250         runo    = dbox2[0] * 2. + 41.2 + dsrv[0];
3251         rtwo    = dbox2[0] * 2. + 41.2 + dela[0];
3252         for (i = 1; i <= 36; ++i) {
3253             atheta = (i-1) * twopi * raddeg / 36. + offset2;
3254             AliMatrix(idrotm[i+1599], 90., atheta, 90., atheta + 90., 0., 0.);
3255
3256 // --- Strip ladders 
3257
3258             xpos = rzero * TMath::Cos((i-1) * twopi / 36. + offset1);
3259             ypos = rzero * TMath::Sin((i-1) * twopi / 36. + offset1);
3260             zpos = 0.;
3261             geant->Gspos("ISV2", i, "IT56", xpos, ypos, zpos, idrotm[i+1599], "ONLY");
3262
3263 // --- Electronics/cooling 
3264
3265             xpos = runo * TMath::Cos((i-1) * twopi / 36. + offset1);
3266             ypos = runo * TMath::Sin((i-1) * twopi / 36. + offset1);
3267             zpos = 0.;
3268             geant->Gspos("SSV2", i, "IT56", xpos, ypos, zpos, idrotm[i+1599], "ONLY");
3269
3270 // --- End-ladders (nagative-Z and positive-Z) 
3271
3272             xpos = rtwo * TMath::Cos((i-1) * twopi / 36. + offset1);
3273             ypos = rtwo * TMath::Sin((i-1) * twopi / 36. + offset1);
3274             zpos = -(dbox2[2] + dela[2] + 6.);
3275             geant->Gspos("ELL6", i, "IT56", xpos, ypos, zpos, idrotm[i+1599], "ONLY");
3276             zpos = dbox2[2] + dela[2] + 6.;
3277             geant->Gspos("ELL6", i + 39, "IT56", xpos, ypos, zpos, idrotm[i+1599], "ONLY");
3278         }
3279
3280
3281     }
3282
3283 //************************************************************************
3284 //*                                                                      *
3285 //*             E N D - C A P S     A N D     F R A M E S                *
3286 //*             =========================================                *
3287 //*                                                                      *
3288 //************************************************************************
3289
3290 // --- Define a dummy cylinder for multiple scattering tests 
3291
3292 //     GOTO 7890             ! skip dummy cylinder for multiple scatteringtests
3293
3294 //      DITS(1)=49. 
3295 //      DITS(2)=DITS(1)+0.1 
3296 //      DITS(3)=60.3 
3297 //      CALL GSVOLU('ITST','TUBE',IDTMED(255),DITS,3,IOUT) 
3298 //      CALL GSPOS('ITST',1,'ITSV',0.,0.,0.,0,'ONLY') 
3299 // 7890  CONTINUE 
3300
3301 // --- The 0.74% X0 outer wall (C) of the gas vessel at r=50cm --- 
3302
3303     if (fMinorVersion == 0 || fMinorVersion == 3) {
3304
3305 //        GOTO 8901                                  ! skip outer wall
3306
3307         dits[0] = 49.9;
3308         dits[1] = dits[0] + .06926;
3309         dits[2] = dpcb[2] * 2. + 62.7 - 10.5;
3310 // old value 60.3 
3311         geant->Gsvolu("ITSG", "TUBE", idtmed[274], dits, 3);
3312         geant->Gspos("ITSG", 1, "ITSV", 0., 0., 0., 0, "ONLY");
3313     } else {
3314         goto L8901;
3315     }
3316 L8901:
3317 // --- The frame between the end-caps (octagonal lay-out) --- 
3318
3319 //     GOTO 9012                                    ! skip octagonal frame
3320
3321     if (fMinorVersion == 1) {
3322
3323         rzero = 34.;
3324         dtra[0] = .92;
3325         dtra[1] = 1.;
3326         dtra[2] = dpcb[2] * 2. + 50.5 - 10.5;
3327         dtra1[0] = .92;
3328         dtra1[1] = 1.;
3329         dtra1[2] = TMath::Sqrt(dtra[2] * dtra[2] + 518.90999999999985) / 2.;
3330         angle = 45.;
3331         offset = angle / 2.;
3332         for (i = 1; i <= 8; ++i) {
3333             xtra[i - 1] = rzero * TMath::Cos((i-1) * angle * degrad);
3334             ytra[i - 1] = rzero * TMath::Sin((i-1) * angle * degrad);
3335             ztra[i - 1] = 0.;
3336             geant->Gsvolu(natra_ref(0, i), "TUBE", idtmed[274], dtra, 3);
3337             geant->Gspos(natra_ref(0, i), 1, "ITSV", xtra[i - 1], ytra[i - 1], ztra[i - 1], 0, "ONLY");
3338         }
3339
3340         atheta = 22.5;
3341         aphi1 = TMath::ACos(dtra[2] / TMath::Sqrt(dtra[2] * dtra[2] + (50.5 / cos(.48869219055841229) * (50.5 / cos(.48869219055841229)) 
3342                 - 2550.25))) * raddeg;
3343         aphi2 = 180. - aphi1;
3344         xpos = (xtra[0] + xtra[1]) / 2.;
3345         ypos = (ytra[0] + ytra[1]) / 2.;
3346         zpos = dtra[2] / 2.;
3347         geant->Gsvolu(natra1_ref(0, 1), "TUBE", idtmed[274], dtra1, 3);
3348         r2 = atheta + 90.;
3349         r3 = atheta + 90.;
3350         AliMatrix(idrotm[5100], 90., atheta, aphi1 + 90., r2, aphi1, r3);
3351         geant->Gspos(natra1_ref(0, 1), 1, "ITSV", xpos, ypos, zpos, idrotm[5100], "ONLY");
3352         zpos = -dtra[2] / 2.;
3353         geant->Gsvolu(natra1_ref(0, 2), "TUBE", idtmed[274], dtra1, 3);
3354         r2 = atheta + 90.;
3355         r3 = atheta + 90.;
3356         AliMatrix(idrotm[5101], 90., atheta, aphi2 + 90., r2, aphi2, r3);
3357         geant->Gspos(natra1_ref(0, 2), 1, "ITSV", xpos, ypos, zpos, idrotm[5101], "ONLY");
3358
3359         atheta = 67.5;
3360         aphi2 = TMath::ACos(dtra[2] / TMath::Sqrt(dtra[2] * dtra[2] + (50.5 / cos(.48869219055841229) * (50.5 / cos(.48869219055841229)) 
3361                 - 2550.25))) * raddeg;
3362         aphi1 = 180. - aphi2;
3363         xpos = (xtra[1] + xtra[2]) / 2.;
3364         ypos = (ytra[1] + ytra[2]) / 2.;
3365         zpos = dtra[2] / 2.;
3366         geant->Gsvolu(natra1_ref(0, 3), "TUBE", idtmed[274], dtra1, 3);
3367         r2 = atheta + 90.;
3368         r3 = atheta + 90.;
3369         AliMatrix(idrotm[5102], 90., atheta, aphi1 + 90., r2, aphi1, r3);
3370         geant->Gspos(natra1_ref(0, 3), 1, "ITSV", xpos, ypos, zpos, idrotm[5102], "ONLY");
3371         zpos = -dtra[2] / 2.;
3372         geant->Gsvolu(natra1_ref(0, 4), "TUBE", idtmed[274], dtra1, 3);
3373         r2 = atheta + 90.;
3374         r3 = atheta + 90.;
3375         AliMatrix(idrotm[5103], 90., atheta, aphi2 + 90., r2, aphi2, r3);
3376         geant->Gspos(natra1_ref(0, 4), 1, "ITSV", xpos, ypos, zpos, idrotm[5103], "ONLY");
3377
3378         atheta = 112.5;
3379         aphi1 = TMath::ACos(dtra[2] / TMath::Sqrt(dtra[2] * dtra[2] + (50.5 / cos(.48869219055841229) * (50.5 / cos(.48869219055841229)) 
3380                 - 2550.25))) * raddeg;
3381         aphi2 = 180. - aphi1;
3382         xpos = (xtra[2] + xtra[3]) / 2.;
3383         ypos = (ytra[2] + ytra[3]) / 2.;
3384         zpos = dtra[2] / 2.;
3385         geant->Gsvolu(natra1_ref(0, 5), "TUBE", idtmed[274], dtra1, 3);
3386         r2 = atheta + 90.;
3387         r3 = atheta + 90.;
3388         AliMatrix(idrotm[5104], 90., atheta, aphi1 + 90., r2, aphi1, r3);
3389         geant->Gspos(natra1_ref(0, 5), 1, "ITSV", xpos, ypos, zpos, idrotm[5104], "ONLY");
3390         zpos = -dtra[2] / 2.;
3391         geant->Gsvolu(natra1_ref(0, 6), "TUBE", idtmed[274], dtra1, 3);
3392         r2 = atheta + 90.;
3393         r3 = atheta + 90.;
3394         AliMatrix(idrotm[5105], 90., atheta, aphi2 + 90., r2, aphi2, r3);
3395         geant->Gspos(natra1_ref(0, 6), 1, "ITSV", xpos, ypos, zpos, idrotm[5105], "ONLY");
3396
3397         atheta = 157.5;
3398         aphi2 = TMath::ACos(dtra[2] / TMath::Sqrt(dtra[2] * dtra[2] + (50.5 / cos(.48869219055841229) * (50.5 / cos(.48869219055841229)) 
3399                 - 2550.25))) * raddeg;
3400         aphi1 = 180. - aphi2;
3401         xpos = (xtra[3] + xtra[4]) / 2.;
3402         ypos = (ytra[3] + ytra[4]) / 2.;
3403         zpos = dtra[2] / 2.;
3404         geant->Gsvolu(natra1_ref(0, 7), "TUBE", idtmed[274], dtra1, 3);
3405         r2 = atheta + 90.;
3406         r3 = atheta + 90.;
3407         AliMatrix(idrotm[5106], 90., atheta, aphi1 + 90., r2, aphi1, r3);
3408         geant->Gspos(natra1_ref(0, 7), 1, "ITSV", xpos, ypos, zpos, idrotm[5106], "ONLY");
3409         zpos = -dtra[2] / 2.;
3410         geant->Gsvolu(natra1_ref(0, 8), "TUBE", idtmed[274], dtra1, 3);
3411         r2 = atheta + 90.;
3412         r3 = atheta + 90.;
3413         AliMatrix(idrotm[5107], 90., atheta, aphi2 + 90., r2, aphi2, r3);
3414         geant->Gspos(natra1_ref(0, 8), 1, "ITSV", xpos, ypos, zpos, idrotm[5107], "ONLY");
3415
3416         atheta = 22.5;
3417         aphi2 = TMath::ACos(dtra[2] / TMath::Sqrt(dtra[2] * dtra[2] + (50.5 / cos(.48869219055841229) * (50.5 / cos(.48869219055841229)) 
3418                 - 2550.25))) * raddeg;
3419         aphi1 = 180. - aphi2;
3420         xpos = (xtra[4] + xtra[5]) / 2.;
3421         ypos = (ytra[4] + ytra[5]) / 2.;
3422         zpos = dtra[2] / 2.;
3423         geant->Gsvolu(natra1_ref(0, 9), "TUBE", idtmed[274], dtra1, 3);
3424         r2 = atheta + 90.;
3425         r3 = atheta + 90.;
3426         AliMatrix(idrotm[5108], 90., atheta, aphi1 + 90., r2, aphi1, r3);
3427         geant->Gspos(natra1_ref(0, 9), 1, "ITSV", xpos, ypos, zpos, idrotm[5108], "ONLY");
3428         zpos = -dtra[2] / 2.;
3429         geant->Gsvolu(natra1_ref(0, 10), "TUBE", idtmed[274], dtra1, 3);
3430         r2 = atheta + 90.;
3431         r3 = atheta + 90.;
3432         AliMatrix(idrotm[5109], 90., atheta, aphi2 + 90., r2, aphi2, r3);
3433         geant->Gspos(natra1_ref(0, 10), 1, "ITSV", xpos, ypos, zpos, idrotm[5109], "ONLY");
3434
3435         atheta = 67.5;
3436         aphi1 = TMath::ACos(dtra[2] / TMath::Sqrt(dtra[2] * dtra[2] + (50.5 / cos(.48869219055841229) * (50.5 / cos(.48869219055841229)) 
3437                 - 2550.25))) * raddeg;
3438         aphi2 = 180. - aphi1;
3439         xpos = (xtra[5] + xtra[6]) / 2.;
3440         ypos = (ytra[5] + ytra[6]) / 2.;
3441         zpos = dtra[2] / 2.;
3442         geant->Gsvolu(natra1_ref(0, 11), "TUBE", idtmed[274], dtra1, 3);
3443         r2 = atheta + 90.;
3444         r3 = atheta + 90.;
3445         AliMatrix(idrotm[5110], 90., atheta, aphi1 + 90., r2, aphi1, r3);
3446         geant->Gspos(natra1_ref(0, 11), 1, "ITSV", xpos, ypos, zpos, idrotm[5110], "ONLY");
3447         zpos = -dtra[2] / 2.;
3448         geant->Gsvolu(natra1_ref(0, 12), "TUBE", idtmed[274], dtra1, 3);
3449         r2 = atheta + 90.;
3450         r3 = atheta + 90.;
3451         AliMatrix(idrotm[5111], 90., atheta, aphi2 + 90., r2, aphi2, r3);
3452         geant->Gspos(natra1_ref(0, 12), 1, "ITSV", xpos, ypos, zpos, idrotm[5111], "ONLY");
3453
3454         atheta = 112.5;
3455         aphi2 = TMath::ACos(dtra[2] / TMath::Sqrt(dtra[2] * dtra[2] + (50.5 / cos(.48869219055841229) * (50.5 / cos(.48869219055841229)) 
3456                 - 2550.25))) * raddeg;
3457         aphi1 = 180. - aphi2;
3458         xpos = (xtra[6] + xtra[7]) / 2.;
3459         ypos = (ytra[6] + ytra[7]) / 2.;
3460         zpos = dtra[2] / 2.;
3461         geant->Gsvolu(natra1_ref(0, 13), "TUBE", idtmed[274], dtra1, 3);
3462         r2 = atheta + 90.;
3463         r3 = atheta + 90.;
3464         AliMatrix(idrotm[5112], 90., atheta, aphi1 + 90., r2, aphi1, r3);
3465         geant->Gspos(natra1_ref(0, 13), 1, "ITSV", xpos, ypos, zpos, idrotm[5112], "ONLY");
3466         zpos = -dtra[2] / 2.;
3467         geant->Gsvolu(natra1_ref(0, 14), "TUBE", idtmed[274], dtra1, 3);
3468         r2 = atheta + 90.;
3469         r3 = atheta + 90.;
3470         AliMatrix(idrotm[5113], 90., atheta, aphi2 + 90., r2, aphi2, r3);
3471         geant->Gspos(natra1_ref(0, 14), 1, "ITSV", xpos, ypos, zpos, idrotm[5113], "ONLY");
3472
3473         atheta = 157.5;
3474         aphi1 = TMath::ACos(dtra[2] / TMath::Sqrt(dtra[2] * dtra[2] + (50.5 / cos(.48869219055841229) * (50.5 / cos(.48869219055841229)) 
3475                 - 2550.25))) * raddeg;
3476         aphi2 = 180. - aphi1;
3477         xpos = (xtra[7] + xtra[0]) / 2.;
3478         ypos = (ytra[7] + ytra[0]) / 2.;
3479         zpos = dtra[2] / 2.;
3480         geant->Gsvolu(natra1_ref(0, 15), "TUBE", idtmed[274], dtra1, 3);
3481         r2 = atheta + 90.;
3482         r3 = atheta + 90.;
3483         AliMatrix(idrotm[5114], 90., atheta, aphi1 + 90., r2, aphi1, r3);
3484         geant->Gspos(natra1_ref(0, 15), 1, "ITSV", xpos, ypos, zpos, idrotm[5114], "ONLY");
3485         zpos = -dtra[2] / 2.;
3486         geant->Gsvolu(natra1_ref(0, 16), "TUBE", idtmed[274], dtra1, 3);
3487         r2 = atheta + 90.;
3488         r3 = atheta + 90.;
3489         AliMatrix(idrotm[5115], 90., atheta, aphi2 + 90., r2, aphi2, r3);
3490         geant->Gspos(natra1_ref(0, 16), 1, "ITSV", xpos, ypos, zpos, idrotm[5115], "ONLY");
3491
3492
3493     } else if (fMinorVersion == 4) {
3494
3495
3496         rzero = 34.;
3497         dtra[0] = .92;
3498         dtra[1] = 1.;
3499         dtra[2] = dpcb[2] * 2. + 50.5 - 10.5;
3500         dtra1[0] = .92;
3501         dtra1[1] = 1.;
3502         dtra1[2] = TMath::Sqrt(dtra[2] * dtra[2] + 518.91) / 2.;
3503         angle = 45.;
3504         offset = angle / 2.;
3505         for (i = 1; i <= 8; ++i) {
3506             xtra[i - 1] = rzero * TMath::Cos((i-1) * angle * degrad);
3507             ytra[i - 1] = rzero * TMath::Sin((i-1) * angle * degrad);
3508             ztra[i - 1] = 0.;
3509             geant->Gsvolu(natra_ref(0, i), "TUBE", idtmed[274], dtra, 3);
3510             geant->Gspos(natra_ref(0, i), 1, "ITSV", xtra[i - 1], ytra[i - 1], ztra[i - 1], 0, "ONLY");
3511         }
3512
3513         atheta = 22.5;
3514         aphi1 = TMath::ACos(dtra[2] / TMath::Sqrt(dtra[2] * dtra[2] + (50.5 / cos(.48869219055841229) * (50.5 / cos(.48869219055841229)) 
3515                 - 2550.25))) * raddeg;
3516         aphi2 = 180. - aphi1;
3517         xpos = (xtra[0] + xtra[1]) / 2.;
3518         ypos = (ytra[0] + ytra[1]) / 2.;
3519         zpos = dtra[2] / 2.;
3520         geant->Gsvolu(natra1_ref(0, 1), "TUBE", idtmed[274], dtra1, 3);
3521         r2 = atheta + 90.;
3522         r3 = atheta + 90.;
3523         AliMatrix(idrotm[5100], 90., atheta, aphi1 + 90., r2, aphi1, r3);
3524         geant->Gspos(natra1_ref(0, 1), 1, "ITSV", xpos, ypos, zpos, idrotm[5100], "ONLY");
3525         zpos = -dtra[2] / 2.;
3526         geant->Gsvolu(natra1_ref(0, 2), "TUBE", idtmed[274], dtra1, 3);
3527         r2 = atheta + 90.;
3528         r3 = atheta + 90.;
3529         AliMatrix(idrotm[5101], 90., atheta, aphi2 + 90., r2, aphi2, r3);
3530         geant->Gspos(natra1_ref(0, 2), 1, "ITSV", xpos, ypos, zpos, idrotm[5101], "ONLY");
3531
3532         atheta = 67.5;
3533         aphi2 = TMath::ACos(dtra[2] / TMath::Sqrt(dtra[2] * dtra[2] + (50.5 / cos(.48869219055841229) * (50.5 / cos(.48869219055841229)) 
3534                 - 2550.25))) * raddeg;
3535         aphi1 = 180. - aphi2;
3536         xpos = (xtra[1] + xtra[2]) / 2.;
3537         ypos = (ytra[1] + ytra[2]) / 2.;
3538         zpos = dtra[2] / 2.;
3539         geant->Gsvolu(natra1_ref(0, 3), "TUBE", idtmed[274], dtra1, 3);
3540         r2 = atheta + 90.;
3541         r3 = atheta + 90.;
3542         AliMatrix(idrotm[5102], 90., atheta, aphi1 + 90., r2, aphi1, r3);
3543         geant->Gspos(natra1_ref(0, 3), 1, "ITSV", xpos, ypos, zpos, idrotm[5102], "ONLY");
3544         zpos = -dtra[2] / 2.;
3545         geant->Gsvolu(natra1_ref(0, 4), "TUBE", idtmed[274], dtra1, 3);
3546         r2 = atheta + 90.;
3547         r3 = atheta + 90.;
3548         AliMatrix(idrotm[5103], 90., atheta, aphi2 + 90., r2, aphi2, r3);
3549         geant->Gspos(natra1_ref(0, 4), 1, "ITSV", xpos, ypos, zpos, idrotm[5103], "ONLY");
3550
3551         atheta = 112.5;
3552         aphi1 = TMath::ACos(dtra[2] / TMath::Sqrt(dtra[2] * dtra[2] + (50.5 / cos(.48869219055841229) * (50.5 / cos(.48869219055841229)) 
3553                 - 2550.25))) * raddeg;
3554         aphi2 = 180. - aphi1;
3555         xpos = (xtra[2] + xtra[3]) / 2.;
3556         ypos = (ytra[2] + ytra[3]) / 2.;
3557         zpos = dtra[2] / 2.;
3558         geant->Gsvolu(natra1_ref(0, 5), "TUBE", idtmed[274], dtra1, 3);
3559         r2 = atheta + 90.;
3560         r3 = atheta + 90.;
3561         AliMatrix(idrotm[5104], 90., atheta, aphi1 + 90., r2, aphi1, r3);
3562         geant->Gspos(natra1_ref(0, 5), 1, "ITSV", xpos, ypos, zpos, idrotm[5104], "ONLY");
3563         zpos = -dtra[2] / 2.;
3564         geant->Gsvolu(natra1_ref(0, 6), "TUBE", idtmed[274], dtra1, 3);
3565         r2 = atheta + 90.;
3566         r3 = atheta + 90.;
3567         AliMatrix(idrotm[5105], 90., atheta, aphi2 + 90., r2, aphi2, r3);
3568         geant->Gspos(natra1_ref(0, 6), 1, "ITSV", xpos, ypos, zpos, idrotm[5105], "ONLY");
3569
3570         atheta = 157.5;
3571         aphi2 = TMath::ACos(dtra[2] / TMath::Sqrt(dtra[2] * dtra[2] + (50.5 / cos(.48869219055841229) * (50.5 / cos(.48869219055841229)) 
3572                 - 2550.25))) * raddeg;
3573         aphi1 = 180. - aphi2;
3574         xpos = (xtra[3] + xtra[4]) / 2.;
3575         ypos = (ytra[3] + ytra[4]) / 2.;
3576         zpos = dtra[2] / 2.;
3577         geant->Gsvolu(natra1_ref(0, 7), "TUBE", idtmed[274], dtra1, 3);
3578         r2 = atheta + 90.;
3579         r3 = atheta + 90.;
3580         AliMatrix(idrotm[5106], 90., atheta, aphi1 + 90., r2, aphi1, r3);
3581         geant->Gspos(natra1_ref(0, 7), 1, "ITSV", xpos, ypos, zpos, idrotm[5106], "ONLY");
3582         zpos = -dtra[2] / 2.;
3583         geant->Gsvolu(natra1_ref(0, 8), "TUBE", idtmed[274], dtra1, 3);
3584         r2 = atheta + 90.;
3585         r3 = atheta + 90.;
3586         AliMatrix(idrotm[5107], 90., atheta, aphi2 + 90., r2, aphi2, r3);
3587         geant->Gspos(natra1_ref(0, 8), 1, "ITSV", xpos, ypos, zpos, idrotm[5107], "ONLY");
3588
3589         atheta = 22.5;
3590         aphi2 = TMath::ACos(dtra[2] / TMath::Sqrt(dtra[2] * dtra[2] + (50.5 / cos(.48869219055841229) * (50.5 / cos(.48869219055841229)) 
3591                 - 2550.25))) * raddeg;
3592         aphi1 = 180. - aphi2;
3593         xpos = (xtra[4] + xtra[5]) / 2.;
3594         ypos = (ytra[4] + ytra[5]) / 2.;
3595         zpos = dtra[2] / 2.;
3596         geant->Gsvolu(natra1_ref(0, 9), "TUBE", idtmed[274], dtra1, 3);
3597         r2 = atheta + 90.;
3598         r3 = atheta + 90.;
3599         AliMatrix(idrotm[5108], 90., atheta, aphi1 + 90., r2, aphi1, r3);
3600         geant->Gspos(natra1_ref(0, 9), 1, "ITSV", xpos, ypos, zpos, idrotm[5108], "ONLY");
3601         zpos = -dtra[2] / 2.;
3602         geant->Gsvolu(natra1_ref(0, 10), "TUBE", idtmed[274], dtra1, 3);
3603         r2 = atheta + 90.;
3604         r3 = atheta + 90.;
3605         AliMatrix(idrotm[5109], 90., atheta, aphi2 + 90., r2, aphi2, r3);
3606         geant->Gspos(natra1_ref(0, 10), 1, "ITSV", xpos, ypos, zpos, idrotm[5109], "ONLY");
3607
3608         atheta = 67.5;
3609         aphi1 = TMath::ACos(dtra[2] / TMath::Sqrt(dtra[2] * dtra[2] + (50.5 / cos(.48869219055841229) * (50.5 / cos(.48869219055841229)) 
3610                 - 2550.25))) * raddeg;
3611         aphi2 = 180. - aphi1;
3612         xpos = (xtra[5] + xtra[6]) / 2.;
3613         ypos = (ytra[5] + ytra[6]) / 2.;
3614         zpos = dtra[2] / 2.;
3615         geant->Gsvolu(natra1_ref(0, 11), "TUBE", idtmed[274], dtra1, 3);
3616         r2 = atheta + 90.;
3617         r3 = atheta + 90.;
3618         AliMatrix(idrotm[5110], 90., atheta, aphi1 + 90., r2, aphi1, r3);
3619         geant->Gspos(natra1_ref(0, 11), 1, "ITSV", xpos, ypos, zpos, idrotm[5110], "ONLY");
3620         zpos = -dtra[2] / 2.;
3621         geant->Gsvolu(natra1_ref(0, 12), "TUBE", idtmed[274], dtra1, 3);
3622         r2 = atheta + 90.;
3623         r3 = atheta + 90.;
3624         AliMatrix(idrotm[5111], 90., atheta, aphi2 + 90., r2, aphi2, r3);
3625         geant->Gspos(natra1_ref(0, 12), 1, "ITSV", xpos, ypos, zpos, idrotm[5111], "ONLY");
3626
3627         atheta = 112.5;
3628         aphi2 = TMath::ACos(dtra[2] / TMath::Sqrt(dtra[2] * dtra[2] + (50.5 / cos(.48869219055841229) * (50.5 / cos(.48869219055841229)) 
3629                 - 2550.25))) * raddeg;
3630         aphi1 = 180. - aphi2;
3631         xpos = (xtra[6] + xtra[7]) / 2.;
3632         ypos = (ytra[6] + ytra[7]) / 2.;
3633         zpos = dtra[2] / 2.;
3634         geant->Gsvolu(natra1_ref(0, 13), "TUBE", idtmed[274], dtra1, 3);
3635         r2 = atheta + 90.;
3636         r3 = atheta + 90.;
3637         AliMatrix(idrotm[5112], 90., atheta, aphi1 + 90., r2, aphi1, r3);
3638         geant->Gspos(natra1_ref(0, 13), 1, "ITSV", xpos, ypos, zpos, idrotm[5112], "ONLY");
3639         zpos = -dtra[2] / 2.;
3640         geant->Gsvolu(natra1_ref(0, 14), "TUBE", idtmed[274], dtra1, 3);
3641         r2 = atheta + 90.;
3642         r3 = atheta + 90.;
3643         AliMatrix(idrotm[5113], 90., atheta, aphi2 + 90., r2, aphi2, r3);
3644         geant->Gspos(natra1_ref(0, 14), 1, "ITSV", xpos, ypos, zpos, idrotm[5113], "ONLY");
3645
3646         atheta = 157.5;
3647         aphi1 = TMath::ACos(dtra[2] / TMath::Sqrt(dtra[2] * dtra[2] + (50.5 / cos(.48869219055841229) * (50.5 / cos(.48869219055841229)) 
3648                 - 2550.25))) * raddeg;
3649         aphi2 = 180. - aphi1;
3650         xpos = (xtra[7] + xtra[0]) / 2.;
3651         ypos = (ytra[7] + ytra[0]) / 2.;
3652         zpos = dtra[2] / 2.;
3653         geant->Gsvolu(natra1_ref(0, 15), "TUBE", idtmed[274], dtra1, 3);
3654         r2 = atheta + 90.;
3655         r3 = atheta + 90.;
3656         AliMatrix(idrotm[5114], 90., atheta, aphi1 + 90., r2, aphi1, r3);
3657         geant->Gspos(natra1_ref(0, 15), 1, "ITSV", xpos, ypos, zpos, idrotm[5114], "ONLY");
3658         zpos = -dtra[2] / 2.;
3659         geant->Gsvolu(natra1_ref(0, 16), "TUBE", idtmed[274], dtra1, 3);
3660         r2 = atheta + 90.;
3661         r3 = atheta + 90.;
3662         AliMatrix(idrotm[5115], 90., atheta, aphi2 + 90., r2, aphi2, r3);
3663         geant->Gspos(natra1_ref(0, 16), 1, "ITSV", xpos, ypos, zpos, idrotm[5115], "ONLY");
3664     } else {
3665         goto L9012;
3666     }
3667
3668 L9012:
3669
3670 // --- The frame between the end-caps (hexagonal lay-out) --- 
3671
3672 //     GOTO 9123                                    ! skip hexagonal frame
3673
3674     if (fMinorVersion == 2) {
3675
3676         rzero = 33.5;
3677         dtra2[0] = .92;
3678         dtra2[1] = 1.;
3679         dtra2[2] = dpcb[2] * 2. + 50. - 10.5;
3680         dtra3[0] = .92;
3681         dtra3[1] = 1.;
3682         dtra3[2] = 16.75;
3683         dtra4[0] = .92;
3684         dtra4[1] = 1.;
3685         dtra4[2] = TMath::Sqrt(dtra2[2] * dtra2[2] + 1088.0099999999998) / 2.;
3686         angle = 60.;
3687         offset = angle / 2.;
3688         for (i = 1; i <= 6; ++i) {
3689             xtra1[i - 1] = rzero * TMath::Cos(((i-1) * angle + offset) *degrad);
3690             ytra1[i - 1] = rzero * TMath::Sin(((i-1) * angle + offset) *degrad);
3691             ztra1[i - 1] = 0.;
3692             geant->Gsvolu(natra2_ref(0, i), "TUBE", idtmed[274], dtra2, 3);
3693             geant->Gspos(natra2_ref(0, i), 1, "ITSV", xtra1[i - 1], ytra1[i - 1], ztra1[i - 1], 0, "ONLY");
3694         }
3695
3696         atheta = 60.;
3697         aphi = 90.;
3698         xpos = (xtra1[0] + xtra1[1]) / 2.;
3699         ypos = (ytra1[0] + ytra1[1]) / 2.;
3700         zpos = 0.;
3701         geant->Gsvolu(natra3_ref(0, 1), "TUBE", idtmed[274], dtra3, 3);
3702         r2 = atheta + 90.;
3703         r3 = atheta + 90.;
3704         AliMatrix(idrotm[5200], 90., atheta, aphi + 90., r2, aphi, r3);
3705         geant->Gspos(natra3_ref(0, 1), 1, "ITSV", xpos, ypos, zpos, idrotm[5200], "ONLY");
3706
3707         atheta = 120.;
3708         aphi = 90.;
3709         xpos = (xtra1[1] + xtra1[2]) / 2.;
3710         ypos = (ytra1[1] + ytra1[2]) / 2.;
3711         zpos = 0.;
3712         geant->Gsvolu(natra3_ref(0, 2), "TUBE", idtmed[274], dtra3, 3);
3713         r2 = atheta + 90.;
3714         r3 = atheta + 90.;
3715         AliMatrix(idrotm[5201], 90., atheta, aphi + 90., r2, aphi, r3);
3716         geant->Gspos(natra3_ref(0, 2), 1, "ITSV", xpos, ypos, zpos, idrotm[5201], "ONLY");
3717
3718         atheta = 180.;
3719         aphi = 90.;
3720         xpos = (xtra1[2] + xtra1[3]) / 2.;
3721         ypos = (ytra1[2] + ytra1[3]) / 2.;
3722         zpos = 0.;
3723         geant->Gsvolu(natra3_ref(0, 3), "TUBE", idtmed[274], dtra3, 3);
3724         r2 = atheta + 90.;
3725         r3 = atheta + 90.;
3726         AliMatrix(idrotm[5202], 90., atheta, aphi + 90., r2, aphi, r3);
3727         geant->Gspos(natra3_ref(0, 3), 1, "ITSV", xpos, ypos, zpos, idrotm[5202], "ONLY");
3728
3729         atheta = 60.;
3730         aphi = 90.;
3731         xpos = (xtra1[3] + xtra1[4]) / 2.;
3732         ypos = (ytra1[3] + ytra1[4]) / 2.;
3733         zpos = 0.;
3734         geant->Gsvolu(natra3_ref(0, 4), "TUBE", idtmed[274], dtra3, 3);
3735         r2 = atheta + 90.;
3736         r3 = atheta + 90.;
3737         AliMatrix(idrotm[5203], 90., atheta, aphi + 90., r2, aphi, r3);
3738         geant->Gspos(natra3_ref(0, 4), 1, "ITSV", xpos, ypos, zpos, idrotm[5203], "ONLY");
3739
3740         atheta = 120.;
3741         aphi = 90.;
3742         xpos = (xtra1[4] + xtra1[5]) / 2.;
3743         ypos = (ytra1[4] + ytra1[5]) / 2.;
3744         zpos = 0.;
3745         geant->Gsvolu(natra3_ref(0, 5), "TUBE", idtmed[274], dtra3, 3);
3746         r2 = atheta + 90.;
3747         r3 = atheta + 90.;
3748         AliMatrix(idrotm[5204], 90., atheta, aphi + 90., r2, aphi, r3);
3749         geant->Gspos(natra3_ref(0, 5), 1, "ITSV", xpos, ypos, zpos, idrotm[5204], "ONLY");
3750
3751         atheta = 180.;
3752         aphi = 90.;
3753         xpos = (xtra1[5] + xtra1[0]) / 2.;
3754         ypos = (ytra1[5] + ytra1[0]) / 2.;
3755         zpos = 0.;
3756         geant->Gsvolu(natra3_ref(0, 6), "TUBE", idtmed[274], dtra3, 3);
3757         r2 = atheta + 90.;
3758         r3 = atheta + 90.;
3759         AliMatrix(idrotm[5205], 90., atheta, aphi + 90., r2, aphi, r3);
3760         geant->Gspos(natra3_ref(0, 6), 1, "ITSV", xpos, ypos, zpos, idrotm[5205], "ONLY");
3761
3762         atheta = 60.;
3763         aphi2 = TMath::ACos(dtra2[2] / TMath::Sqrt(dtra2[2] * dtra2[2] + (50. / cos(.59341194567807209) * (50. / cos(.59341194567807209)) 
3764                 - 2500.))) * raddeg;
3765         aphi1 = 180. - aphi2;
3766         xpos = (xtra1[0] + xtra1[1]) / 2.;
3767         ypos = (ytra1[0] + ytra1[1]) / 2.;
3768         zpos = dtra2[2] / 2.;
3769         geant->Gsvolu(natra4_ref(0, 1), "TUBE", idtmed[274], dtra4, 3);
3770         r2 = atheta + 90.;
3771         r3 = atheta + 90.;
3772         AliMatrix(idrotm[5210], 90., atheta, aphi1 + 90., r2, aphi1, r3);
3773         geant->Gspos(natra4_ref(0, 1), 1, "ITSV", xpos, ypos, zpos, idrotm[5210], "ONLY");
3774         zpos = -dtra2[2] / 2.;
3775         geant->Gsvolu(natra4_ref(0, 2), "TUBE", idtmed[274], dtra4, 3);
3776         r2 = atheta + 90.;
3777         r3 = atheta + 90.;
3778         AliMatrix(idrotm[5211], 90., atheta, aphi2 + 90., r2, aphi2, r3);
3779         geant->Gspos(natra4_ref(0, 2), 1, "ITSV", xpos, ypos, zpos, idrotm[5211], "ONLY");
3780
3781         atheta = 120.;
3782         aphi1 = TMath::ACos(dtra2[2] / TMath::Sqrt(dtra2[2] * dtra2[2] + (50. / cos(.59341194567807209) * (50. / cos(.59341194567807209)) 
3783                 - 2500.))) * raddeg;
3784         aphi2 = 180. - aphi1;
3785         xpos = (xtra1[1] + xtra1[2]) / 2.;
3786         ypos = (ytra1[1] + ytra1[2]) / 2.;
3787         zpos = dtra2[2] / 2.;
3788         geant->Gsvolu(natra4_ref(0, 3), "TUBE", idtmed[274], dtra4, 3);
3789         r2 = atheta + 90.;
3790         r3 = atheta + 90.;
3791         AliMatrix(idrotm[5212], 90., atheta, aphi1 + 90., r2, aphi1, r3);
3792         geant->Gspos(natra4_ref(0, 3), 1, "ITSV", xpos, ypos, zpos, idrotm[5212], "ONLY");
3793         zpos = -dtra2[2] / 2.;
3794         geant->Gsvolu(natra4_ref(0, 4), "TUBE", idtmed[274], dtra4, 3);
3795         r2 = atheta + 90.;
3796         r3 = atheta + 90.;
3797         AliMatrix(idrotm[5213], 90., atheta, aphi2 + 90., r2, aphi2, r3);
3798         geant->Gspos(natra4_ref(0, 4), 1, "ITSV", xpos, ypos, zpos, idrotm[5213], "ONLY");
3799
3800         atheta = 180.;
3801         aphi2 = TMath::ACos(dtra2[2] / TMath::Sqrt(dtra2[2] * dtra2[2] + (50. / cos(.59341194567807209) * (50. / cos(.59341194567807209)) 
3802                 - 2500.))) * raddeg;
3803         aphi1 = 180. - aphi2;
3804         xpos = (xtra1[2] + xtra1[3]) / 2.;
3805         ypos = (ytra1[2] + ytra1[3]) / 2.;
3806         zpos = dtra2[2] / 2.;
3807         geant->Gsvolu(natra4_ref(0, 5), "TUBE", idtmed[274], dtra4, 3);
3808         r2 = atheta + 90.;
3809         r3 = atheta + 90.;
3810         AliMatrix(idrotm[5214], 90., atheta, aphi1 + 90., r2, aphi1, r3);
3811         geant->Gspos(natra4_ref(0, 5), 1, "ITSV", xpos, ypos, zpos, idrotm[5214], "ONLY");
3812         zpos = -dtra2[2] / 2.;
3813         geant->Gsvolu(natra4_ref(0, 6), "TUBE", idtmed[274], dtra4, 3);
3814         r2 = atheta + 90.;
3815         r3 = atheta + 90.;
3816         AliMatrix(idrotm[5215], 90., atheta, aphi2 + 90., r2, aphi2, r3);
3817         geant->Gspos(natra4_ref(0, 6), 1, "ITSV", xpos, ypos, zpos, idrotm[5215], "ONLY");
3818         atheta = 180.;
3819         aphi1 = TMath::ACos(dtra2[2] / TMath::Sqrt(dtra2[2] * dtra2[2] + (50. / cos(.59341194567807209) * (50. / cos(.59341194567807209)) 
3820                 - 2500.))) * raddeg;
3821         aphi2 = 180. - aphi1;
3822         xpos = (xtra1[2] + xtra1[3]) / 2.;
3823         ypos = (ytra1[2] + ytra1[3]) / 2.;
3824         zpos = dtra2[2] / 2.;
3825         geant->Gsvolu(natra4_ref(0, 7), "TUBE", idtmed[274], dtra4, 3);
3826         r2 = atheta + 90.;
3827         r3 = atheta + 90.;
3828         AliMatrix(idrotm[5216], 90., atheta, aphi1 + 90., r2, aphi1, r3);
3829         geant->Gspos(natra4_ref(0, 7), 1, "ITSV", xpos, ypos, zpos, idrotm[5216], "ONLY");
3830         zpos = -dtra2[2] / 2.;
3831         geant->Gsvolu(natra4_ref(0, 8), "TUBE", idtmed[274], dtra4, 3);
3832         r2 = atheta + 90.;
3833         r3 = atheta + 90.;
3834         AliMatrix(idrotm[5217], 90., atheta, aphi2 + 90., r2, aphi2, r3);
3835         geant->Gspos(natra4_ref(0, 8), 1, "ITSV", xpos, ypos, zpos, idrotm[5217], "ONLY");
3836
3837         atheta = 60.;
3838         aphi2 = TMath::ACos(dtra2[2] / TMath::Sqrt(dtra2[2] * dtra2[2] + (50. / cos(.59341194567807209) * (50. / cos(.59341194567807209)) 
3839                 - 2500.))) * raddeg;
3840         aphi1 = 180. - aphi2;
3841         xpos = (xtra1[3] + xtra1[4]) / 2.;
3842         ypos = (ytra1[3] + ytra1[4]) / 2.;
3843         zpos = dtra2[2] / 2.;
3844         geant->Gsvolu(natra4_ref(0, 9), "TUBE", idtmed[274], dtra4, 3);
3845         r2 = atheta + 90.;
3846         r3 = atheta + 90.;
3847         AliMatrix(idrotm[5218], 90., atheta, aphi1 + 90., r2, aphi1, r3);
3848         geant->Gspos(natra4_ref(0, 9), 1, "ITSV", xpos, ypos, zpos, idrotm[5218], "ONLY");
3849         zpos = -dtra2[2] / 2.;
3850         geant->Gsvolu(natra4_ref(0, 10), "TUBE", idtmed[274], dtra4, 3);
3851         r2 = atheta + 90.;
3852         r3 = atheta + 90.;
3853         AliMatrix(idrotm[5219], 90., atheta, aphi2 + 90., r2, aphi2, r3);
3854         geant->Gspos(natra4_ref(0, 10), 1, "ITSV", xpos, ypos, zpos, idrotm[5219], "ONLY");
3855
3856         atheta = 120.;
3857         aphi1 = TMath::ACos(dtra2[2] / TMath::Sqrt(dtra2[2] * dtra2[2] + (50. / cos(.59341194567807209) * (50. / cos(.59341194567807209)) 
3858                 - 2500.))) * raddeg;
3859         aphi2 = 180. - aphi1;
3860         xpos = (xtra1[4] + xtra1[5]) / 2.;
3861         ypos = (ytra1[4] + ytra1[5]) / 2.;
3862         zpos = dtra2[2] / 2.;
3863         geant->Gsvolu(natra4_ref(0, 11), "TUBE", idtmed[274], dtra4, 3);
3864         r2 = atheta + 90.;
3865         r3 = atheta + 90.;
3866         AliMatrix(idrotm[5220], 90., atheta, aphi1 + 90., r2, aphi1, r3);
3867         geant->Gspos(natra4_ref(0, 11), 1, "ITSV", xpos, ypos, zpos, idrotm[5220], "ONLY");
3868         zpos = -dtra2[2] / 2.;
3869         geant->Gsvolu(natra4_ref(0, 12), "TUBE", idtmed[274], dtra4, 3);
3870         r2 = atheta + 90.;
3871         r3 = atheta + 90.;
3872         AliMatrix(idrotm[5221], 90., atheta, aphi2 + 90., r2, aphi2, r3);
3873         geant->Gspos(natra4_ref(0, 12), 1, "ITSV", xpos, ypos, zpos, idrotm[5221], "ONLY");
3874
3875         atheta = 180.;
3876         aphi2 = TMath::ACos(dtra2[2] / TMath::Sqrt(dtra2[2] * dtra2[2] + (50. / cos(.59341194567807209) * (50. / cos(.59341194567807209)) 
3877                 - 2500.))) * raddeg;
3878         aphi1 = 180. - aphi2;
3879         xpos = (xtra1[5] + xtra1[0]) / 2.;
3880         ypos = (ytra1[5] + ytra1[0]) / 2.;
3881         zpos = dtra2[2] / 2.;
3882         geant->Gsvolu(natra4_ref(0, 13), "TUBE", idtmed[274], dtra4, 3);
3883         r2 = atheta + 90.;
3884         r3 = atheta + 90.;
3885         AliMatrix(idrotm[5222], 90., atheta, aphi1 + 90., r2, aphi1, r3);
3886         geant->Gspos(natra4_ref(0, 13), 1, "ITSV", xpos, ypos, zpos, idrotm[5222], "ONLY");
3887         zpos = -dtra2[2] / 2.;
3888         geant->Gsvolu(natra4_ref(0, 14), "TUBE", idtmed[274], dtra4, 3);
3889         r2 = atheta + 90.;
3890         r3 = atheta + 90.;
3891         AliMatrix(idrotm[5223], 90., atheta, aphi2 + 90., r2, aphi2, r3);
3892         geant->Gspos(natra4_ref(0, 14), 1, "ITSV", xpos, ypos, zpos, idrotm[5223], "ONLY");
3893         atheta = 180.;
3894         aphi1 = TMath::ACos(dtra2[2] / TMath::Sqrt(dtra2[2] * dtra2[2] + (50. / cos(.59341194567807209) * (50. / cos(.59341194567807209)) 
3895                 - 2500.))) * raddeg;
3896         aphi2 = 180. - aphi1;
3897         xpos = (xtra1[5] + xtra1[0]) / 2.;
3898         ypos = (ytra1[5] + ytra1[0]) / 2.;
3899         zpos = dtra2[2] / 2.;
3900         geant->Gsvolu(natra4_ref(0, 15), "TUBE", idtmed[274], dtra4, 3);
3901         r2 = atheta + 90.;
3902         r3 = atheta + 90.;
3903         AliMatrix(idrotm[5224], 90., atheta, aphi1 + 90., r2, aphi1, r3);
3904         geant->Gspos(natra4_ref(0, 15), 1, "ITSV", xpos, ypos, zpos, idrotm[5224], "ONLY");
3905         zpos = -dtra2[2] / 2.;
3906         geant->Gsvolu(natra4_ref(0, 16), "TUBE", idtmed[274], dtra4, 3);
3907         r2 = atheta + 90.;
3908         r3 = atheta + 90.;
3909         AliMatrix(idrotm[5225], 90., atheta, aphi2 + 90., r2, aphi2, r3);
3910         geant->Gspos(natra4_ref(0, 16), 1, "ITSV", xpos, ypos, zpos, idrotm[5225], "ONLY");
3911
3912
3913     } else if (fMinorVersion == 5) {
3914
3915
3916         rzero = 33.5;
3917         dtra2[0] = .92;
3918         dtra2[1] = 1.;
3919         dtra2[2] = dpcb[2] * 2. + 50. - 10.5;
3920         dtra3[0] = .92;
3921         dtra3[1] = 1.;
3922         dtra3[2] = 16.75;
3923         dtra4[0] = .92;
3924         dtra4[1] = 1.;
3925         dtra4[2] = TMath::Sqrt(dtra2[2] * dtra2[2] + 1088.0099999999998) / 2.;
3926         angle = 60.;
3927         offset = angle / 2.;
3928         for (i = 1; i <= 6; ++i) {
3929             xtra1[i - 1] = rzero * TMath::Cos(((i-1) * angle + offset) *degrad);
3930             ytra1[i - 1] = rzero * TMath::Sin(((i-1) * angle + offset) *degrad);
3931             ztra1[i - 1] = 0.;
3932             geant->Gsvolu(natra2_ref(0, i), "TUBE", idtmed[274], dtra2, 3);
3933             geant->Gspos(natra2_ref(0, i), 1, "ITSV", xtra1[i - 1], ytra1[i - 1], ztra1[i - 1], 0, "ONLY");
3934         }
3935
3936         atheta = 60.;
3937         aphi = 90.;
3938         xpos = (xtra1[0] + xtra1[1]) / 2.;
3939         ypos = (ytra1[0] + ytra1[1]) / 2.;
3940         zpos = 0.;
3941         geant->Gsvolu(natra3_ref(0, 1), "TUBE", idtmed[274], dtra3, 3);
3942         r2 = atheta + 90.;
3943         r3 = atheta + 90.;
3944         AliMatrix(idrotm[5200], 90., atheta, aphi + 90., r2, aphi, r3);
3945         geant->Gspos(natra3_ref(0, 1), 1, "ITSV", xpos, ypos, zpos, idrotm[5200], "ONLY");
3946
3947         atheta = 120.;
3948         aphi = 90.;
3949         xpos = (xtra1[1] + xtra1[2]) / 2.;
3950         ypos = (ytra1[1] + ytra1[2]) / 2.;
3951         zpos = 0.;
3952         geant->Gsvolu(natra3_ref(0, 2), "TUBE", idtmed[274], dtra3, 3);
3953         r2 = atheta + 90.;
3954         r3 = atheta + 90.;
3955         AliMatrix(idrotm[5201], 90., atheta, aphi + 90., r2, aphi, r3);
3956         geant->Gspos(natra3_ref(0, 2), 1, "ITSV", xpos, ypos, zpos, idrotm[5201], "ONLY");
3957
3958         atheta = 180.;
3959         aphi = 90.;
3960         xpos = (xtra1[2] + xtra1[3]) / 2.;
3961         ypos = (ytra1[2] + ytra1[3]) / 2.;
3962         zpos = 0.;
3963         geant->Gsvolu(natra3_ref(0, 3), "TUBE", idtmed[274], dtra3, 3);
3964         r2 = atheta + 90.;
3965         r3 = atheta + 90.;
3966         AliMatrix(idrotm[5202], 90., atheta, aphi + 90., r2, aphi, r3);
3967         geant->Gspos(natra3_ref(0, 3), 1, "ITSV", xpos, ypos, zpos, idrotm[5202], "ONLY");
3968
3969         atheta = 60.;
3970         aphi = 90.;
3971         xpos = (xtra1[3] + xtra1[4]) / 2.;
3972         ypos = (ytra1[3] + ytra1[4]) / 2.;
3973         zpos = 0.;
3974         geant->Gsvolu(natra3_ref(0, 4), "TUBE", idtmed[274], dtra3, 3);
3975         r2 = atheta + 90.;
3976         r3 = atheta + 90.;
3977         AliMatrix(idrotm[5203], 90., atheta, aphi + 90., r2, aphi, r3);
3978         geant->Gspos(natra3_ref(0, 4), 1, "ITSV", xpos, ypos, zpos, idrotm[5203], "ONLY");
3979
3980         atheta = 120.;
3981         aphi = 90.;
3982         xpos = (xtra1[4] + xtra1[5]) / 2.;
3983         ypos = (ytra1[4] + ytra1[5]) / 2.;
3984         zpos = 0.;
3985         geant->Gsvolu(natra3_ref(0, 5), "TUBE", idtmed[274], dtra3, 3);
3986         r2 = atheta + 90.;
3987         r3 = atheta + 90.;
3988         AliMatrix(idrotm[5204], 90., atheta, aphi + 90., r2, aphi, r3);
3989         geant->Gspos(natra3_ref(0, 5), 1, "ITSV", xpos, ypos, zpos, idrotm[5204], "ONLY");
3990
3991         atheta = 180.;
3992         aphi = 90.;
3993         xpos = (xtra1[5] + xtra1[0]) / 2.;
3994         ypos = (ytra1[5] + ytra1[0]) / 2.;
3995         zpos = 0.;
3996         geant->Gsvolu(natra3_ref(0, 6), "TUBE", idtmed[274], dtra3, 3);
3997         r2 = atheta + 90.;
3998         r3 = atheta + 90.;
3999         AliMatrix(idrotm[5205], 90., atheta, aphi + 90., r2, aphi, r3);
4000         geant->Gspos(natra3_ref(0, 6), 1, "ITSV", xpos, ypos, zpos, idrotm[5205], "ONLY");
4001
4002         atheta = 60.;
4003         aphi2 = TMath::ACos(dtra2[2] / TMath::Sqrt(dtra2[2] * dtra2[2] + (50. / cos(.59341194567807209) * (50. / cos(.59341194567807209)) 
4004                 - 2500.))) * raddeg;
4005         aphi1 = 180. - aphi2;
4006         xpos = (xtra1[0] + xtra1[1]) / 2.;
4007         ypos = (ytra1[0] + ytra1[1]) / 2.;
4008         zpos = dtra2[2] / 2.;
4009         geant->Gsvolu(natra4_ref(0, 1), "TUBE", idtmed[274], dtra4, 3);
4010         r2 = atheta + 90.;
4011         r3 = atheta + 90.;
4012         AliMatrix(idrotm[5210], 90., atheta, aphi1 + 90., r2, aphi1, r3);
4013         geant->Gspos(natra4_ref(0, 1), 1, "ITSV", xpos, ypos, zpos, idrotm[5210], "ONLY");
4014         zpos = -dtra2[2] / 2.;
4015         geant->Gsvolu(natra4_ref(0, 2), "TUBE", idtmed[274], dtra4, 3);
4016         r2 = atheta + 90.;
4017         r3 = atheta + 90.;
4018         AliMatrix(idrotm[5211], 90., atheta, aphi2 + 90., r2, aphi2, r3);
4019         geant->Gspos(natra4_ref(0, 2), 1, "ITSV", xpos, ypos, zpos, idrotm[5211], "ONLY");
4020
4021         atheta = 120.;
4022         aphi1 = TMath::ACos(dtra2[2] / TMath::Sqrt(dtra2[2] * dtra2[2] + (50. / cos(.59341194567807209) * (50. / cos(.59341194567807209)) 
4023                 - 2500.))) * raddeg;
4024         aphi2 = 180. - aphi1;
4025         xpos = (xtra1[1] + xtra1[2]) / 2.;
4026         ypos = (ytra1[1] + ytra1[2]) / 2.;
4027         zpos = dtra2[2] / 2.;
4028         geant->Gsvolu(natra4_ref(0, 3), "TUBE", idtmed[274], dtra4, 3);
4029         r2 = atheta + 90.;
4030         r3 = atheta + 90.;
4031         AliMatrix(idrotm[5212], 90., atheta, aphi1 + 90., r2, aphi1, r3);
4032         geant->Gspos(natra4_ref(0, 3), 1, "ITSV", xpos, ypos, zpos, idrotm[5212], "ONLY");
4033         zpos = -dtra2[2] / 2.;
4034         geant->Gsvolu(natra4_ref(0, 4), "TUBE", idtmed[274], dtra4, 3);
4035         r2 = atheta + 90.;
4036         r3 = atheta + 90.;
4037         AliMatrix(idrotm[5213], 90., atheta, aphi2 + 90., r2, aphi2, r3);
4038         geant->Gspos(natra4_ref(0, 4), 1, "ITSV", xpos, ypos, zpos, idrotm[5213], "ONLY");
4039
4040         atheta = 180.;
4041         aphi2 = TMath::ACos(dtra2[2] / TMath::Sqrt(dtra2[2] * dtra2[2] + (50. / cos(.59341194567807209) * (50. / cos(.59341194567807209)) 
4042                 - 2500.))) * raddeg;
4043         aphi1 = 180. - aphi2;
4044         xpos = (xtra1[2] + xtra1[3]) / 2.;
4045         ypos = (ytra1[2] + ytra1[3]) / 2.;
4046         zpos = dtra2[2] / 2.;
4047         geant->Gsvolu(natra4_ref(0, 5), "TUBE", idtmed[274], dtra4, 3);
4048         r2 = atheta + 90.;
4049         r3 = atheta + 90.;
4050         AliMatrix(idrotm[5214], 90., atheta, aphi1 + 90., r2, aphi1, r3);
4051         geant->Gspos(natra4_ref(0, 5), 1, "ITSV", xpos, ypos, zpos, idrotm[5214], "ONLY");
4052         zpos = -dtra2[2] / 2.;
4053         geant->Gsvolu(natra4_ref(0, 6), "TUBE", idtmed[274], dtra4, 3);
4054         r2 = atheta + 90.;
4055         r3 = atheta + 90.;
4056         AliMatrix(idrotm[5215], 90., atheta, aphi2 + 90., r2, aphi2, r3);
4057         geant->Gspos(natra4_ref(0, 6), 1, "ITSV", xpos, ypos, zpos, idrotm[5215], "ONLY");
4058         atheta = 180.;
4059         aphi1 = TMath::ACos(dtra2[2] / TMath::Sqrt(dtra2[2] * dtra2[2] + (50. / cos(.59341194567807209) * (50. / cos(.59341194567807209)) 
4060                 - 2500.))) * raddeg;
4061         aphi2 = 180. - aphi1;
4062         xpos = (xtra1[2] + xtra1[3]) / 2.;
4063         ypos = (ytra1[2] + ytra1[3]) / 2.;
4064         zpos = dtra2[2] / 2.;
4065         geant->Gsvolu(natra4_ref(0, 7), "TUBE", idtmed[274], dtra4, 3);
4066         r2 = atheta + 90.;
4067         r3 = atheta + 90.;
4068         AliMatrix(idrotm[5216], 90., atheta, aphi1 + 90., r2, aphi1, r3);
4069         geant->Gspos(natra4_ref(0, 7), 1, "ITSV", xpos, ypos, zpos, idrotm[5216], "ONLY");
4070         zpos = -dtra2[2] / 2.;
4071         geant->Gsvolu(natra4_ref(0, 8), "TUBE", idtmed[274], dtra4, 3);
4072         r2 = atheta + 90.;
4073         r3 = atheta + 90.;
4074         AliMatrix(idrotm[5217], 90., atheta, aphi2 + 90., r2, aphi2, r3);
4075         geant->Gspos(natra4_ref(0, 8), 1, "ITSV", xpos, ypos, zpos, idrotm[5217], "ONLY");
4076
4077         atheta = 60.;
4078         aphi2 = TMath::ACos(dtra2[2] / TMath::Sqrt(dtra2[2] * dtra2[2] + (50. / cos(.59341194567807209) * (50. / cos(.59341194567807209)) 
4079                 - 2500.))) * raddeg;
4080         aphi1 = 180. - aphi2;
4081         xpos = (xtra1[3] + xtra1[4]) / 2.;
4082         ypos = (ytra1[3] + ytra1[4]) / 2.;
4083         zpos = dtra2[2] / 2.;
4084         geant->Gsvolu(natra4_ref(0, 9), "TUBE", idtmed[274], dtra4, 3);
4085         r2 = atheta + 90.;
4086         r3 = atheta + 90.;
4087         AliMatrix(idrotm[5218], 90., atheta, aphi1 + 90., r2, aphi1, r3);
4088         geant->Gspos(natra4_ref(0, 9), 1, "ITSV", xpos, ypos, zpos, idrotm[5218], "ONLY");
4089         zpos = -dtra2[2] / 2.;
4090         geant->Gsvolu(natra4_ref(0, 10), "TUBE", idtmed[274], dtra4, 3);
4091         r2 = atheta + 90.;
4092         r3 = atheta + 90.;
4093         AliMatrix(idrotm[5219], 90., atheta, aphi2 + 90., r2, aphi2, r3);
4094         geant->Gspos(natra4_ref(0, 10), 1, "ITSV", xpos, ypos, zpos, idrotm[5219], "ONLY");
4095
4096         atheta = 120.;
4097         aphi1 = TMath::ACos(dtra2[2] / TMath::Sqrt(dtra2[2] * dtra2[2] + (50. / cos(.59341194567807209) * (50. / cos(.59341194567807209)) 
4098                 - 2500.))) * raddeg;
4099         aphi2 = 180. - aphi1;
4100         xpos = (xtra1[4] + xtra1[5]) / 2.;
4101         ypos = (ytra1[4] + ytra1[5]) / 2.;
4102         zpos = dtra2[2] / 2.;
4103         geant->Gsvolu(natra4_ref(0, 11), "TUBE", idtmed[274], dtra4, 3);
4104         r2 = atheta + 90.;
4105         r3 = atheta + 90.;
4106         AliMatrix(idrotm[5220], 90., atheta, aphi1 + 90., r2, aphi1, r3);
4107         geant->Gspos(natra4_ref(0, 11), 1, "ITSV", xpos, ypos, zpos, idrotm[5220], "ONLY");
4108         zpos = -dtra2[2] / 2.;
4109         geant->Gsvolu(natra4_ref(0, 12), "TUBE", idtmed[274], dtra4, 3);
4110         r2 = atheta + 90.;
4111         r3 = atheta + 90.;
4112         AliMatrix(idrotm[5221], 90., atheta, aphi2 + 90., r2, aphi2, r3);
4113         geant->Gspos(natra4_ref(0, 12), 1, "ITSV", xpos, ypos, zpos, idrotm[5221], "ONLY");
4114
4115         atheta = 180.;
4116         aphi2 = TMath::ACos(dtra2[2] / TMath::Sqrt(dtra2[2] * dtra2[2] + (50. / cos(.59341194567807209) * (50. / cos(.59341194567807209)) 
4117                 - 2500.))) * raddeg;
4118         aphi1 = 180. - aphi2;
4119         xpos = (xtra1[5] + xtra1[0]) / 2.;
4120         ypos = (ytra1[5] + ytra1[0]) / 2.;
4121         zpos = dtra2[2] / 2.;
4122         geant->Gsvolu(natra4_ref(0, 13), "TUBE", idtmed[274], dtra4, 3);
4123         r2 = atheta + 90.;
4124         r3 = atheta + 90.;
4125         AliMatrix(idrotm[5222], 90., atheta, aphi1 + 90., r2, aphi1, r3);
4126         geant->Gspos(natra4_ref(0, 13), 1, "ITSV", xpos, ypos, zpos, idrotm[5222], "ONLY");
4127         zpos = -dtra2[2] / 2.;
4128         geant->Gsvolu(natra4_ref(0, 14), "TUBE", idtmed[274], dtra4, 3);
4129         r2 = atheta + 90.;
4130         r3 = atheta + 90.;
4131         AliMatrix(idrotm[5223], 90., atheta, aphi2 + 90., r2, aphi2, r3);
4132         geant->Gspos(natra4_ref(0, 14), 1, "ITSV", xpos, ypos, zpos, idrotm[5223], "ONLY");
4133         atheta = 180.;
4134         aphi1 = TMath::ACos(dtra2[2] / TMath::Sqrt(dtra2[2] * dtra2[2] + (50. / cos(.59341194567807209) * (50. / cos(.59341194567807209)) 
4135                 - 2500.))) * raddeg;
4136         aphi2 = 180. - aphi1;
4137         xpos = (xtra1[5] + xtra1[0]) / 2.;
4138         ypos = (ytra1[5] + ytra1[0]) / 2.;
4139         zpos = dtra2[2] / 2.;
4140         geant->Gsvolu(natra4_ref(0, 15), "TUBE", idtmed[274], dtra4, 3);
4141         r2 = atheta + 90.;
4142         r3 = atheta + 90.;
4143         AliMatrix(idrotm[5224], 90., atheta, aphi1 + 90., r2, aphi1, r3);
4144         geant->Gspos(natra4_ref(0, 15), 1, "ITSV", xpos, ypos, zpos, idrotm[5224], "ONLY");
4145         zpos = -dtra2[2] / 2.;
4146         geant->Gsvolu(natra4_ref(0, 16), "TUBE", idtmed[274], dtra4, 3);
4147         r2 = atheta + 90.;
4148         r3 = atheta + 90.;
4149         AliMatrix(idrotm[5225], 90., atheta, aphi2 + 90., r2, aphi2, r3);
4150         geant->Gspos(natra4_ref(0, 16), 1, "ITSV", xpos, ypos, zpos, idrotm[5225], "ONLY");
4151     } else {
4152         goto L9123;
4153     }
4154
4155 L9123:
4156 // --- Define the end-caps 
4157
4158 //      GOTO 9234             ! skip both end-caps 
4159
4160 // --- Define the Z>0 end-cap 
4161
4162 //      GOTO 9345             ! skip the Z>0 end-cap 
4163
4164     dcone[0] = 16.75;
4165     dcone[1] = 12.;
4166     dcone[2] = 12.02;
4167     dcone[3] = 46.899999999999999;
4168     dcone[4] = .02 / TMath::Cos(.78539816339744828) + 46.899999999999999;
4169     xpos = 0.;
4170     ypos = 0.;
4171     zpos = dpcb[2] * 2. + 45.899999999999999 - 10.5;
4172 // end-ladder electro 
4173     geant->Gsvolu("RCON", "CONE", idtmed[274], dcone, 5);
4174             ;
4175     geant->Gspos("RCON", 1, "ITSV", xpos, ypos, zpos, 0, "ONLY");
4176
4177     dtube[0] = .02 / TMath::Cos(.78539816339744828) + 
4178             46.899999999999999;
4179     dtube[1] = 49.9;
4180 // In the Simonetti's drawings 52. In the TP 50. 
4181     dtube[2] = .15;
4182     xpos = 0.;
4183     ypos = 0.;
4184     zpos = dpcb[2] * 2. + 62.799999999999997 - 10.5;
4185 // end-ladder electro 
4186     geant->Gsvolu("RTB1", "TUBE", idtmed[274], dtube, 3);
4187             ;
4188     geant->Gspos("RTB1", 1, "ITSV", xpos, ypos, zpos, 0, "ONLY");
4189
4190     dtube[0] = 10.5;
4191     dtube[1] = 12.;
4192     dtube[2] = 1.3400000000000001;
4193     xpos = 0.;
4194     ypos = 0.;
4195     zpos = dpcb[2] * 2. + 21.59 - 10.5;
4196 // end-ladder elect 
4197     geant->Gsvolu("RTB2", "TUBE", idtmed[274], dtube, 3);
4198
4199     geant->Gspos("RTB2", 1, "ITSV", xpos, ypos, zpos, 0, "ONLY");
4200
4201     dpgon[0] = 15.;
4202     dpgon[1] = 360.;
4203     dpgon[2] = 12.;
4204     dpgon[3] = 2.;
4205     dpgon[4] = dpcb[2] * 2. + 22.93 - 10.5;
4206 // end-ladder electron 
4207     dpgon[5] = 12.;
4208     dpgon[6] = 13.5;
4209     dpgon[7] = dpcb[2] * 2. + 29.149999999999999 - 10.5;
4210 // end-ladder electronics 
4211     dpgon[8] = 12.;
4212     dpgon[9] = 13.5;
4213     xpos = 0.;
4214     ypos = 0.;
4215     zpos = 0.;
4216     geant->Gsvolu("RP03", "PGON", idtmed[274], dpgon, 10);
4217     geant->Gspos("RP03", 1, "ITSV", xpos, ypos, zpos, 0, "ONLY");
4218
4219     dpgon[0] = 7.5;
4220     dpgon[1] = 360.;
4221     dpgon[2] = 24.;
4222     dpgon[3] = 2.;
4223     dpgon[4] = dpcb[2] * 2. + 35.649999999999999 - 10.5;
4224 // end-ladder e 
4225     dpgon[5] = 21.;
4226     dpgon[6] = 23.;
4227     dpgon[7] = dpcb[2] * 2. + 37.149999999999999 - 10.5;
4228 // end-ladde 
4229     dpgon[8] = 21.;
4230     dpgon[9] = 23.;
4231     xpos = 0.;
4232     ypos = 0.;
4233     zpos = 0.;
4234     geant->Gsvolu("RP04", "PGON", idtmed[274], dpgon, 10);
4235     geant->Gspos("RP04", 1, "ITSV", xpos, ypos, zpos, 0, "ONLY");
4236
4237     if (fMinorVersion == 0 || fMinorVersion == 1 || fMinorVersion ==2) {
4238         offset2 = 5.2;
4239         dpgon[0] = offset2 + 5.1428571428571432;
4240         dpgon[1] = 360.;
4241         dpgon[2] = 35.;
4242         dpgon[3] = 2.;
4243         dpgon[4] = dpcb[2] * 2. + 52.350000000000001 - 10.5;
4244 // end-ladde 
4245         dpgon[5] = 37.7;
4246         dpgon[6] = 40.;
4247         dpgon[7] = dpcb[2] * 2. + 53.850000000000001 - 10.5;
4248 // end-la 
4249         dpgon[8] = 37.7;
4250         dpgon[9] = 40.;
4251         xpos = 0.;
4252         ypos = 0.;
4253         zpos = 0.;
4254         geant->Gsvolu("RP05", "PGON", idtmed[274], dpgon, 10);
4255         geant->Gspos("RP05", 1, "ITSV", xpos, ypos, zpos, 0, "ONLY");
4256
4257         dpgon[0] = offset2 + 4.615384615384615;
4258         dpgon[1] = 360.;
4259         dpgon[2] = 39.;
4260         dpgon[3] = 2.;
4261         dpgon[4] = dpcb[2] * 2. + 57.350000000000001 - 10.5;
4262 // end-ladder 
4263         dpgon[5] = 42.7;
4264         dpgon[6] = 45.;
4265         dpgon[7] = dpcb[2] * 2. + 58.850000000000001 - 10.5;
4266 // end-la 
4267         dpgon[8] = 42.7;
4268         dpgon[9] = 45.;
4269         xpos = 0.;
4270         ypos = 0.;
4271         zpos = 0.;
4272         geant->Gsvolu("RP06", "PGON", idtmed[274], dpgon, 10);
4273         geant->Gspos("RP06", 1, "ITSV", xpos, ypos, zpos, 0, "ONLY");
4274     }
4275     if (fMinorVersion == 3 || fMinorVersion == 4 || fMinorVersion == 5) {
4276         offset2 = 5.2;
4277         dpgon[0] = offset2 + 5.625;
4278         dpgon[1] = 360.;
4279         dpgon[2] = 32.;
4280         dpgon[3] = 2.;
4281         dpgon[4] = 52.350000000000001 - 3.3999999999999986 / TMath::Tan(.78539816339744828) + dpcb[2] * 2. - 10.5;
4282 // end-ladder electronics 
4283         dpgon[5] = 34.3;
4284         dpgon[6] = 36.6;
4285         dpgon[7] = 53.850000000000001 - 3.3999999999999986 / TMath::Tan(.78539816339744828) + dpcb[2] * 2. - 10.5;
4286 // end-ladder electr 
4287         dpgon[8] = 34.3;
4288         dpgon[9] = 36.6;
4289         xpos = 0.;
4290         ypos = 0.;
4291         zpos = 0.;
4292         geant->Gsvolu("RP05", "PGON", idtmed[274], dpgon, 10);
4293         geant->Gspos("RP05", 1, "ITSV", xpos, ypos, zpos, 0, "ONLY");
4294
4295         dpgon[0] = offset2 + 5.;
4296         dpgon[1] = 360.;
4297         dpgon[2] = 36.;
4298         dpgon[3] = 2.;
4299         dpgon[4] = 57.350000000000001 - 3.7999999999999972 / TMath::Tan(.78539816339744828) + dpcb[2] * 2. - 10.5;
4300 // end-ladder electronics 
4301         dpgon[5] = 38.9;
4302         dpgon[6] = 41.2;
4303         dpgon[7] = 58.850000000000001 - 3.7999999999999972 / TMath::Tan(.78539816339744828) + dpcb[2] * 2. - 10.5;
4304 // end-ladder electr 
4305         dpgon[8] = 38.9;
4306         dpgon[9] = 41.2;
4307         xpos = 0.;
4308         ypos = 0.;
4309         zpos = 0.;
4310         geant->Gsvolu("RP06", "PGON", idtmed[274], dpgon, 10);
4311         geant->Gspos("RP06", 1, "ITSV", xpos, ypos, zpos, 0, "ONLY");
4312     }
4313
4314 // 9345 CONTINUE 
4315
4316 // --- Define the Z<0 end-cap 
4317
4318 //      GOTO 9456             ! skip the Z<0 end-cap 
4319
4320     dcone[0] = 16.75;
4321     dcone[1] = 46.899999999999999;
4322     dcone[2] = .02 / TMath::Cos(.78539816339744828) + 46.899999999999999;
4323     dcone[3] = 12.;
4324     dcone[4] = 12.02;
4325     xpos = 0.;
4326     ypos = 0.;
4327     zpos = -45.899999999999999 - dpcb[2] * 2. + 10.5;
4328 // end-ladder electr 
4329     geant->Gsvolu("LCON", "CONE", idtmed[274], dcone, 5);
4330             ;
4331     geant->Gspos("LCON", 1, "ITSV", xpos, ypos, zpos, 0, "ONLY");
4332
4333     dtube[0] = .02 / TMath::Cos(.78539816339744828) + 
4334             46.899999999999999;
4335     dtube[1] = 49.9;
4336 // In the Simonetti's drawings 52. In the TP 50. 
4337     dtube[2] = .15;
4338     xpos = 0.;
4339     ypos = 0.;
4340     zpos = -62.799999999999997 - dpcb[2] * 2. + 10.5;
4341 // end-ladder electr 
4342     geant->Gsvolu("LTB1", "TUBE", idtmed[274], dtube, 3);
4343             ;
4344     geant->Gspos("LTB1", 1, "ITSV", xpos, ypos, zpos, 0, "ONLY");
4345
4346     dtube[0] = 10.5;
4347     dtube[1] = 12.;
4348     dtube[2] = 1.3400000000000001;
4349     xpos = 0.;
4350     ypos = 0.;
4351     zpos = -21.59 - dpcb[2] * 2. + 10.5;
4352 // end-ladder elec 
4353     geant->Gsvolu("LTB2", "TUBE", idtmed[274], dtube, 3);
4354
4355     geant->Gspos("LTB2", 1, "ITSV", xpos, ypos, zpos, 0, "ONLY");
4356
4357     dpgon[0] = 15.;
4358     dpgon[1] = 360.;
4359     dpgon[2] = 12.;
4360     dpgon[3] = 2.;
4361     dpgon[4] = -29.149999999999999 - dpcb[2] * 2. + 10.5;
4362 // end-ladder electronics 
4363     dpgon[5] = 12.;
4364     dpgon[6] = 13.5;
4365     dpgon[7] = -22.93 - dpcb[2] * 2. + 10.5;
4366 // end-ladder electro 
4367     dpgon[8] = 12.;
4368     dpgon[9] = 13.5;
4369     xpos = 0.;
4370     ypos = 0.;
4371     zpos = 0.;
4372     geant->Gsvolu("LP03", "PGON", idtmed[274], dpgon, 10);
4373     geant->Gspos("LP03", 1, "ITSV", xpos, ypos, zpos, 0, "ONLY");
4374
4375     dpgon[0] = 7.5;
4376     dpgon[1] = 360.;
4377     dpgon[2] = 24.;
4378     dpgon[3] = 2.;
4379     dpgon[4] = -37.149999999999999 - dpcb[2] * 2. + 10.5;
4380 // end-ladd 
4381     dpgon[5] = 21.;
4382     dpgon[6] = 23.;
4383     dpgon[7] = -35.649999999999999 - dpcb[2] * 2. + 10.5;
4384 // end-ladder 
4385     dpgon[8] = 21.;
4386     dpgon[9] = 23.;
4387     xpos = 0.;
4388     ypos = 0.;
4389     zpos = 0.;
4390     geant->Gsvolu("LP04", "PGON", idtmed[274], dpgon, 10);
4391     geant->Gspos("LP04", 1, "ITSV", xpos, ypos, zpos, 0, "ONLY");
4392
4393     if (fMinorVersion == 0 || fMinorVersion == 1 || fMinorVersion ==2) {
4394         offset2 = 5.2;
4395         dpgon[0] = offset2 + 5.1428571428571432;
4396         dpgon[1] = 360.;
4397         dpgon[2] = 35.;
4398         dpgon[3] = 2.;
4399         dpgon[4] = -52.350000000000001 - dpcb[2] * 2. + 10.5;
4400 // end-ladd 
4401         dpgon[5] = 37.7;
4402         dpgon[6] = 40.;
4403         dpgon[7] = -53.850000000000001 - dpcb[2] * 2. + 10.5;
4404 // end-l 
4405         dpgon[8] = 37.7;
4406         dpgon[9] = 40.;
4407         xpos = 0.;
4408         ypos = 0.;
4409         zpos = 0.;
4410         geant->Gsvolu("LP05", "PGON", idtmed[274], dpgon, 10);
4411         geant->Gspos("LP05", 1, "ITSV", xpos, ypos, zpos, 0, "ONLY");
4412
4413         dpgon[0] = offset2 + 4.615384615384615;
4414         dpgon[1] = 360.;
4415         dpgon[2] = 39.;
4416         dpgon[3] = 2.;
4417         dpgon[4] = -57.350000000000001 - dpcb[2] * 2. + 10.5;
4418 // end-ladde 
4419         dpgon[5] = 42.7;
4420         dpgon[6] = 45.;
4421         dpgon[7] = -58.850000000000001 - dpcb[2] * 2. + 10.5;
4422 // end-l 
4423         dpgon[8] = 42.7;
4424         dpgon[9] = 45.;
4425         xpos = 0.;
4426         ypos = 0.;
4427         zpos = 0.;
4428         geant->Gsvolu("LP06", "PGON", idtmed[274], dpgon, 10);
4429         geant->Gspos("LP06", 1, "ITSV", xpos, ypos, zpos, 0, "ONLY");
4430     }
4431     if (fMinorVersion == 3 || fMinorVersion == 4 || fMinorVersion == 5) {
4432         offset2 = 5.2;
4433         dpgon[0] = offset2 + 5.625;
4434         dpgon[1] = 360.;
4435         dpgon[2] = 32.;
4436         dpgon[3] = 2.;
4437         dpgon[4] = 3.4 / TMath::Tan(.78539816339744828) - 52.35 - dpcb[2] * 2. + 10.5;
4438 // end-ladder electronics 
4439         dpgon[5] = 34.3;
4440         dpgon[6] = 36.6;
4441         dpgon[7] = 3.4 / TMath::Tan(.78539816339744828) - 53.85 - dpcb[2] * 2. + 10.5;
4442 // end-ladder electr 
4443         dpgon[8] = 34.3;
4444         dpgon[9] = 36.6;
4445         xpos = 0.;
4446         ypos = 0.;
4447         zpos = 0.;
4448         geant->Gsvolu("LP05", "PGON", idtmed[274], dpgon, 10);
4449         geant->Gspos("LP05", 1, "ITSV", xpos, ypos, zpos, 0, "ONLY");
4450
4451         dpgon[0] = offset2 + 5.;
4452         dpgon[1] = 360.;
4453         dpgon[2] = 36.;
4454         dpgon[3] = 2.;
4455         dpgon[4] = 3.8 / TMath::Tan(.78539816339744828) - 57.35 - dpcb[2] * 2. + 10.5;
4456 // end-ladder electronics 
4457         dpgon[5] = 38.9;
4458         dpgon[6] = 41.2;
4459         dpgon[7] = 3.8 / TMath::Tan(.78539816339744828) - 58.85 - dpcb[2] * 2. + 10.5;
4460 // end-ladder electr 
4461         dpgon[8] = 38.9;
4462         dpgon[9] = 41.2;
4463         xpos = 0.;
4464         ypos = 0.;
4465         zpos = 0.;
4466         geant->Gsvolu("LP06", "PGON", idtmed[274], dpgon, 10);
4467         geant->Gspos("LP06", 1, "ITSV", xpos, ypos, zpos, 0, "ONLY");
4468     }
4469
4470 // 9456 CONTINUE 
4471
4472
4473 // --- Outputs the geometry tree in the EUCLID/CAD format 
4474
4475     if (fEuclidOut) {
4476         geant->WriteEuclid("ITSgeometry", "ITSV", 1, 5);
4477     }
4478 #endif
4479 // --- Outputs the geometry tree in the EUCLID/CAD format 
4480
4481     if (fEuclidOut) {
4482         pMC->WriteEuclid("ITSgeometry", "ITSV", 1, 5);
4483     }
4484 }
4485  
4486 //_____________________________________________________________________________
4487 void AliITSv4::CreateMaterials()
4488 {
4489   //
4490   // Create Materials for ITS
4491   //
4492   AliITS::CreateMaterials();
4493 }
4494
4495 //_____________________________________________________________________________
4496 void AliITSv4::Init()
4497 {
4498   //
4499   // Initialise ITS after it has been created
4500   //
4501   AliMC* pMC = AliMC::GetMC();
4502   fIdSens1=pMC->VolId("ITS1");
4503   fIdSens2=pMC->VolId("ITS2");
4504   fIdSens3=pMC->VolId("ITS3");
4505   fIdSens4=pMC->VolId("ITS4");
4506   fIdSens5=pMC->VolId("ITS5");
4507   fIdSens6=pMC->VolId("ITS6");
4508
4509  
4510 //_____________________________________________________________________________
4511 void AliITSv4::StepManager()
4512 {
4513   //
4514   // Called at every step in the ITS
4515   //
4516   Int_t         copy, id;
4517   Float_t       hits[7];
4518   Int_t         vol[3];
4519   Float_t       position[3];
4520   Float_t       momentum[4];
4521   TClonesArray &lhits = *fHits;
4522   AliMC* pMC = AliMC::GetMC();
4523   //
4524   if(pMC->TrackCharge() && pMC->Edep()) {
4525     //
4526     // Only entering charged tracks
4527     if((id=pMC->CurrentVol(0,copy))==fIdSens1) {  
4528       vol[0]=1;
4529       id=pMC->CurrentVolOff(1,0,copy);      
4530       vol[1]=copy;
4531       id=pMC->CurrentVolOff(2,0,copy);
4532       vol[2]=copy;                       
4533     } else if(id==fIdSens2) {
4534       vol[0]=2;
4535       id=pMC->CurrentVolOff(1,0,copy);       
4536       vol[1]=copy;
4537       id=pMC->CurrentVolOff(2,0,copy);
4538       vol[2]=copy;                    
4539     } else if(id==fIdSens3) {
4540       vol[0]=3;
4541       vol[1]=copy;
4542       id=pMC->CurrentVolOff(1,0,copy);
4543       vol[2]=copy;             
4544     } else if(id==fIdSens4) {
4545       vol[0]=4;
4546       vol[1]=copy;
4547       id=pMC->CurrentVolOff(1,0,copy);
4548       vol[2]=copy;                  
4549     } else if(id==fIdSens5) {
4550       vol[0]=5;
4551       vol[1]=copy;
4552       id=pMC->CurrentVolOff(1,0,copy);
4553       vol[2]=copy;               
4554     } else if(id==fIdSens6) {
4555       vol[0]=6;
4556       vol[1]=copy;
4557       id=pMC->CurrentVolOff(1,0,copy);
4558       vol[2]=copy;                      
4559     } else return;
4560     pMC->TrackPosition(position);
4561     pMC->TrackMomentum(momentum);
4562     hits[0]=position[0];
4563     hits[1]=position[1];
4564     hits[2]=position[2];          
4565     hits[3]=momentum[0]*momentum[3];
4566     hits[4]=momentum[1]*momentum[3];
4567     hits[5]=momentum[2]*momentum[3];        
4568     hits[6]=pMC->Edep();
4569     new(lhits[fNhits++]) AliITShit(fIshunt,gAlice->CurrentTrack(),vol,hits);
4570   }      
4571 }