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