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