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