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