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