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