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