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