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