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