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