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