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