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