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