Bug fixed in the StepManager to account for the difference in the geometry tree for...
[u/mrichter/AliRoot.git] / ITS / AliITSvPPRasymm.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.37  2001/05/10 00:12:59  nilsen
19 Finished fixing up the default segmentation for the PPR geometry.
20
21 Revision 1.36  2001/05/09 01:02:21  nilsen
22 Finished fixing SetDefaults for the segmentation of SPD, SDD, and SSD.
23
24 Revision 1.35  2001/05/03 08:40:15  barbera
25 Volume ITSD slightly modified to be consistent with v5. Some improvement in the printouts. The last commit did not complete successfully.
26
27 Revision 1.33  2001/05/01 22:40:42  nilsen
28 Partical update of SetDefault.
29
30 Revision 1.32  2001/04/22 13:48:09  barbera
31 New values of media parameters and thickness of SPD end-ladder electronics as given by Fabio Formenti
32
33 Revision 1.31  2001/04/04 07:02:16  barbera
34 Position of the cylinders holding rails corrected
35
36 Revision 1.30  2001/03/29 22:02:30  barbera
37 Some changes to the services due to the new drawings from the engineers.
38
39 Revision 1.29  2001/03/29 05:28:56  barbera
40 Rails material changed from aluminum to carbon fiber according with the decision of the last Technical Board
41
42 Revision 1.28  2001/03/28 06:40:20  barbera
43 Central and services mother volumes made consistenf for detailed and coarse geometry. Switch for rails added to the coarse geometries
44
45 Revision 1.26  2001/03/23 00:12:23  nilsen
46 Set Reading of AliITSgeom data from Geant3 common blocks as the default and
47 not a .det file. Removed redundent calls to BuildGeometry.
48
49 Revision 1.25  2001/03/20 19:22:51  barbera
50 Flags for the rails and the cooling fluid added. Some changes in the volumes of the SSD cones after the meeting with the engineers in Torino.
51
52 Revision 1.23  2001/03/13 21:18:44  barbera
53 Some misleading comments removed
54
55 Revision 1.22  2001/03/13 18:13:30  barbera
56 Some mother volumes sligthly modified to eliminate an overlap with the absorber
57
58 Revision 1.21  2001/03/13 08:36:23  hristov
59 fabsf replaced by TMath::Abs
60
61 Revision 1.20  2001/03/13 00:17:41  barbera
62 New SDD geometry got grom F. Tosello and checked by the SDD engineers
63
64 Revision 1.19  2001/02/28 18:23:13  barbera
65 Setters and getters to set/get the detector and chip thickness on SPD layers added
66
67 Revision 1.18  2001/02/27 23:18:24  barbera
68 Full parameterization of detector and chip thicknesses for layer 1 and layer 2 of SPD as requested by the project leader
69
70 Revision 1.17  2001/02/19 22:14:55  nilsen
71 Fix for all 4 versions 11, 12, 21, and 22.
72
73 Revision 1.16  2001/02/19 20:10:34  barbera
74 Set option=2 and thickness=2 as default values --> SetMinorVersion=22
75
76 Revision 1.15  2001/02/19 19:44:00  barbera
77 Air density parameter corrected
78
79 Revision 1.14  2001/02/13 16:53:35  nilsen
80 Fixed a but when trying to use GEANT4. Needed to replace
81 if(!((TGeant3*)gMC)) with if(!(dynamic_casst<TGeant3*>(gMC)))
82 because just casting gMC to be TGeant3* even when it realy is a TGeant3 pointer
83 did not result in a zero value. For AliITSv5asymm and AliITSv5symm, needed
84 to fix a bug in the initilizers and a bug in BuildGeometry. This is now done
85 in the same way as in AliITSv5.cxx.
86
87 Revision 1.13  2001/02/09 20:06:26  nilsen
88 Fixed bug in distructor. Can't distroy fixxed length arrays. Thanks Peter.
89
90 Revision 1.12  2001/02/09 13:53:38  barbera
91 Int_t redefinition avoided
92
93 Revision 1.11  2001/02/09 06:55:38  barbera
94 SPD option re-set to B. It was A by mistake
95
96 Revision 1.10  2001/02/09 00:05:31  nilsen
97 Added fMajor/MinorVersion variables and made other changes to better make
98 use of the new code changes in AliITSgeom related classes.
99
100
101 Revision 1.9  2001/02/08 16:00:37  barbera
102 New thicknesses (300+300 um) added for SPD chips and detectors and set as default. Many other refinements.
103
104 Revision 1.8  2001/02/06 08:03:44  barbera
105 Material redefinition in SDD
106
107 Revision 1.7  2001/02/05 13:34:57  barbera
108 Updated version of the ITS detailed geometry
109
110 Revision 1.5  2001/01/30 09:23:13  hristov
111 Streamers removed (R.Brun)
112
113 Revision 1.4  2001/01/23 20:08:03  barbera
114 Option B for pixels implemented and set as default
115
116 Revision 1.3  2001/01/17 08:08:20  barbera
117 Some media parameters modified
118
119 Revision 1.1.2.1  2001/01/15 13:38:08  barbera
120 New ITS detailed geometry to be used for the PPR
121
122 */
123
124 ///////////////////////////////////////////////////////////////////////////////
125 //                                                                           //
126 //  Inner Traking System version PPR  asymmetric                             //
127 //  This class contains the base procedures for the Inner Tracking System    //
128 //                                                                           //
129 // Authors: R. Barbera                                                       //
130 // version 8.                                                                //
131 // Created  January 15 2001.                                                 //
132 //                                                                           //
133 //  NOTE: THIS IS THE  ASYMMETRIC PPR geometry of the ITS.                   //
134 //                                                                           //
135 ///////////////////////////////////////////////////////////////////////////////
136
137 // See AliITSvPPRasymm::StepManager().
138 #include <iostream.h>
139 #include <iomanip.h>
140 #include <stdio.h>
141 #include <stdlib.h>
142 #include <TMath.h>
143 #include <TGeometry.h>
144 #include <TNode.h>
145 #include <TTUBE.h>
146 #include <TFile.h>    // only required for Tracking function?
147 #include <TCanvas.h>
148 #include <TObjArray.h>
149 #include <TLorentzVector.h>
150 #include <TObjString.h>
151 #include <TClonesArray.h>
152 #include <TBRIK.h>
153 #include <TSystem.h>
154
155 #include "AliMC.h"
156 #include "AliRun.h"
157 #include "AliMagF.h"
158 #include "AliConst.h"
159 #include "../TGeant3/TGeant3.h"
160 #include "AliITSGeant3Geometry.h"
161 #include "AliITShit.h"
162 #include "AliITS.h"
163 #include "AliITSvPPRasymm.h"
164 #include "AliITSgeom.h"
165 #include "AliITSgeomSPD.h"
166 #include "AliITSgeomSDD.h"
167 #include "AliITSgeomSSD.h"
168 #include "AliITSDetType.h"
169 #include "AliITSresponseSPD.h"
170 #include "AliITSresponseSDD.h"
171 #include "AliITSresponseSSD.h"
172 #include "AliITSsegmentationSPD.h"
173 #include "AliITSsegmentationSDD.h"
174 #include "AliITSsegmentationSSD.h"
175 #include "AliITSClusterFinderSPD.h"
176 #include "AliITSClusterFinderSDD.h"
177 #include "AliITSClusterFinderSSD.h"
178
179
180 ClassImp(AliITSvPPRasymm)
181  
182 //_____________________________________________________________________________
183 AliITSvPPRasymm::AliITSvPPRasymm() {
184 ////////////////////////////////////////////////////////////////////////
185 //    Standard default constructor for the ITS version 8.
186 ////////////////////////////////////////////////////////////////////////
187     Int_t i;
188
189     fIdN          = 0;
190     fIdName       = 0;
191     fIdSens       = 0;
192     fEuclidOut    = kFALSE; // Don't write Euclide file
193     fGeomDetOut   = kFALSE; // Don't write .det file
194     fGeomDetIn    = kFALSE; // Don't Read .det file
195     fMajorVersion = IsVersion();
196     fMinorVersion = -1;
197     for(i=0;i<60;i++) fRead[i] = '\0';
198     for(i=0;i<60;i++) fWrite[i] = '\0';
199     for(i=0;i<60;i++) fEuclidGeomDet[i] = '\0';
200 }
201 //_____________________________________________________________________________
202 AliITSvPPRasymm::AliITSvPPRasymm(const char *name, const char *title) : AliITS(name, title){
203 ////////////////////////////////////////////////////////////////////////
204 //    Standard constructor for the ITS version 8.
205 ////////////////////////////////////////////////////////////////////////
206     Int_t i;
207
208     fIdN = 6;
209     fIdName = new TString[fIdN];
210     fIdName[0] = "ITS1";
211     fIdName[1] = "ITS2";
212     fIdName[2] = "ITS3";
213     fIdName[3] = "ITS4";
214     fIdName[4] = "ITS5";
215     fIdName[5] = "ITS6";
216     fIdSens    = new Int_t[fIdN];
217     for(i=0;i<fIdN;i++) fIdSens[i] = 0;
218     fMajorVersion = IsVersion();
219     fMinorVersion = 2;
220     fEuclidOut    = kFALSE; // Don't write Euclide file
221     fGeomDetOut   = kFALSE; // Don't write .det file
222     fGeomDetIn    = kFALSE; // Don't Read .det file
223     SetThicknessDet1();
224     SetThicknessDet2();
225     SetThicknessChip1();
226     SetThicknessChip2();                         
227
228     fEuclidGeometry="$ALICE_ROOT/ITS/ITSgeometry_vPPRasymm2.euc";
229     strncpy(fEuclidGeomDet,"$ALICE_ROOT/ITS/ITSgeometry_vPPRasymm2.det",60);
230     strncpy(fRead,fEuclidGeomDet,60);
231     strncpy(fWrite,fEuclidGeomDet,60);
232 }
233 //____________________________________________________________________________
234 AliITSvPPRasymm::AliITSvPPRasymm(const AliITSvPPRasymm &source){
235 ////////////////////////////////////////////////////////////////////////
236 //     Copy Constructor for ITS version 8.
237 ////////////////////////////////////////////////////////////////////////
238     if(&source == this) return;
239     Warning("Copy Constructor","Not allowed to copy AliITSvPPRasymm");
240     return;
241 }
242 //_____________________________________________________________________________
243 AliITSvPPRasymm& AliITSvPPRasymm::operator=(const AliITSvPPRasymm &source){
244 ////////////////////////////////////////////////////////////////////////
245 //    Assignment operator for the ITS version 8.
246 ////////////////////////////////////////////////////////////////////////
247     if(&source == this) return *this;
248     Warning("= operator","Not allowed to copy AliITSvPPRasymm");
249     return *this;
250 }
251 //_____________________________________________________________________________
252 AliITSvPPRasymm::~AliITSvPPRasymm() {
253 ////////////////////////////////////////////////////////////////////////
254 //    Standard destructor for the ITS version 8.
255 ////////////////////////////////////////////////////////////////////////
256 }
257 //__________________________________________________________________________
258 void AliITSvPPRasymm::BuildGeometry(){
259 ////////////////////////////////////////////////////////////////////////
260 //    Geometry builder for the ITS version 8.
261 ////////////////////////////////////////////////////////////////////////
262     TNode *node, *top;
263     const int kColorITS=kYellow;
264     //
265     top = gAlice->GetGeometry()->GetNode("alice");
266
267     new TTUBE("S_layer1","Layer1 of ITS","void",3.95,3.95+0.05475,12.25);
268     top->cd();
269     node = new TNode("Layer1","Layer1","S_layer1",0,0,0,"");
270     node->SetLineColor(kColorITS);
271     fNodes->Add(node);
272
273     new TTUBE("S_layer2","Layer2 of ITS","void",7.,7.+0.05475,16.3);
274     top->cd();
275     node = new TNode("Layer2","Layer2","S_layer2",0,0,0,"");
276     node->SetLineColor(kColorITS);
277     fNodes->Add(node);
278
279     new TTUBE("S_layer3","Layer3 of ITS","void",15.,15.+0.05288,21.1);
280     top->cd();
281     node = new TNode("Layer3","Layer3","S_layer3",0,0,0,"");
282     node->SetLineColor(kColorITS);
283     fNodes->Add(node);
284
285     new TTUBE("S_layer4","Layer4 of ITS","void",24,24+0.05288,29.6);
286     top->cd();
287     node = new TNode("Layer4","Layer4","S_layer4",0,0,0,"");
288     node->SetLineColor(kColorITS);
289     fNodes->Add(node);
290
291     new TTUBE("S_layer5","Layer5 of ITS","void",40,40+0.05382,45.1);
292     top->cd();
293     node = new TNode("Layer5","Layer5","S_layer5",0,0,0,"");
294     node->SetLineColor(kColorITS);
295     fNodes->Add(node);
296
297     new TTUBE("S_layer6","Layer6 of ITS","void",45,45+0.05382,50.4);
298     top->cd();
299     node = new TNode("Layer6","Layer6","S_layer6",0,0,0,"");
300     node->SetLineColor(kColorITS);
301     fNodes->Add(node);
302 }
303 //_____________________________________________________________________________
304 void AliITSvPPRasymm::CreateGeometry(){
305 ////////////////////////////////////////////////////////////////////////
306 //    This routine defines and Creates the geometry for version 6 of the ITS.
307 ////////////////////////////////////////////////////////////////////////
308   
309   //INNER RADII OF THE SILICON LAYERS 
310   // Float_t rl[6]    = { 3.8095,7.,15.,24.,38.1,43.5765 };   
311   //THICKNESSES OF LAYERS (in % radiation length)
312   Float_t drl[6]   = { 1.03,1.03,0.94,0.95,0.91,0.87 };   
313   //HALF LENGTHS OF LAYERS  
314   // Float_t dzl[6]   = { 14.35,14.35,25.1,32.1,49.405,55.27 };
315   //LENGTHS OF END-LADDER BOXES (ALL INCLUDED)
316   // Float_t dzb[6]   = { 12.4,12.4,13.5,15.,7.5,7.5 };   
317   //THICKNESSES OF END-LADDER BOXES (ALL INCLUDED)
318   // Float_t drb[6]   = { rl[1]-rl[0],0.2,5.,5.,4.,4. };        
319
320  
321   Float_t dits[100], rlim, zmax;
322   // Float_t zpos;
323   // Float_t pcits[50]
324   Float_t ztpc;
325   Int_t idrotm[1999], i;
326   Float_t dgh[100];
327
328
329   // Define some variables for SPD
330
331   Float_t dits1[3], di101[3], di107[3], di10b[3], di106[3];  // for layer 1 
332   Float_t di103[3], di10a[3], di102[3];                      // for layer 1
333   Float_t dits2[3], di1d1[3], di1d7[3], di20b[3], di1d6[3];  // for layer 2
334   Float_t di1d3[3], di20a[3], di1d2[3];                      // for layer 2  
335   Float_t di108[3], di104[3];                                // for both layers  
336
337   Float_t ddet1=300.;     // total detector thickness on layer 1 (micron)
338   Float_t dchip1=300.;    // total chip thickness on layer 1 (micron)
339   
340   Float_t ddet2=300.;     // total detector thickness on layer 2 (micron)                         
341   Float_t dchip2=300.;    // total chip thickness on layer 2 (micron)
342   
343   Float_t dbus=200.;      // total bus thickness on both layers (micron)
344
345   ddet1 = GetThicknessDet1();
346   ddet2 = GetThicknessDet2();
347   dchip1 = GetThicknessChip1();
348   dchip2 = GetThicknessChip2();    
349
350   if(ddet1 < 100. || ddet1 > 300.) {
351      cout << "ITS - WARNING: the detector thickness for layer 1 is outside the range of [100,300] microns."
352           " The default value of 300 microns will be used." << endl;
353           ddet1=300.;
354   }
355   
356   if(ddet2 < 100. || ddet2 > 300.) {
357      cout << "ITS - WARNING: the detector thickness for layer 2 is outside the range of [100,300] microns."
358           " The default value of 300 microns will be used." << endl;
359           ddet2=300.;
360   }
361   
362   if(dchip1 < 150. || dchip1 > 300.) {
363      cout << "ITS - WARNING: the chip thickness for layer 1 is outside the range of [150,300] microns."
364           " The default value of 300 microns will be used." << endl;
365           dchip1=300.;
366   }
367   
368   if(dchip2 < 150. || dchip2 > 300.) {
369      cout << "ITS - WARNING: the chip thickness for layer 2 is outside the range of [150,300] microns."
370           " The default value of 300 microns will be used." << endl;
371           dchip2=300.;
372   }      
373
374   Int_t rails = 1;       // flag for rails (1 --> rails in; 0 --> rails out)
375   
376   Int_t fluid = 1;       // flag for the cooling fluid (1 --> water; 0 --> freon)
377
378   rails = GetRails();
379
380   fluid = GetCoolingFluid();
381
382   if(rails != 0 && rails != 1) {
383      cout << "ITS - WARNING: the switch for rails is not set neither to 0 (rails out) nor to 1 (rails in)." 
384      " The default value of 1 (rails in) will be used." << endl;
385         
386   }  
387   
388   if(fluid != 0 && fluid != 1) {
389      cout << "ITS - WARNING: the switch for cooling fluid is not set neither to 0 (freon) nor to 1 (water)." 
390      " The default value of 1 (water) will be used." << endl;  
391   }       
392    
393   cout << "ITS: Detector thickness on layer 1 is set to " << ddet1 << " microns." << endl;
394   cout << "ITS: Chip thickness on layer 1 is set to " << dchip1 << " microns." << endl;
395   cout << "ITS: Detector thickness on layer 2 is set to " << ddet2 << " microns." << endl;
396   cout << "ITS: Chip thickness on layer 2 is set to " << dchip2 << " microns." << endl;
397   if(rails == 0 ) {
398      cout << "ITS: Rails are out." << endl; 
399   } else {
400      cout << "ITS: Rails are in." << endl;
401   }   
402   if(fluid == 0 ) {
403      cout << "ITS: The cooling fluid is freon." << endl; 
404   } else {
405      cout << "ITS: The cooling fluid is water." << endl;
406   }   
407
408   ddet1  = ddet1*0.0001/2.; // conversion from tot length in um to half in cm
409   ddet2  = ddet2*0.0001/2.; // conversion from tot length in um to half in cm   
410   dchip1 = dchip1*0.0001/2.;// conversion from tot length in um to half in cm   
411   dchip2 = dchip2*0.0001/2.;// conversion from tot length in um to half in cm   
412   dbus   = dbus*0.0001/2.;  // conversion from tot length in um to half in cm       
413                 
414   Float_t deltax, deltay; 
415
416   Int_t thickness = fMinorVersion/10;
417   Int_t option    = fMinorVersion - 10*thickness;
418
419
420   // Define some variables for SDD
421
422
423   Float_t sin30, cos30;
424
425   // SDD electronics+services main volumes
426   Float_t I018dits[3], I024dits[3], I047dits[3], I048dits[3];
427
428   // SDD detector ladder
429
430   Float_t I302dits[3], I402dits[3], I004dits[3], I005dits[3];
431   Float_t Y_SDD_sep = 0.20;
432   Float_t ySDD;
433   Int_t   iSDD;
434   Float_t Z_SDD_lay3[6] = {18.55, 10.95, 3.70, -3.70, -11.20, -18.35};
435   Float_t Z_SDD_lay4[8] = {25.75, 18.60, 11.00, 3.70, -3.70, -11.20, -18.45, -26.05};
436
437   // ladder foot and end-ladder (frame and cooling)
438   Float_t I028dits[3], I420dits[3], I421dits[3], I422dits[6], I423dits[3];
439   Float_t I424dits[3], xI424, yI424;
440   Float_t I425dits[3];
441   Int_t    indI425;
442   Float_t I029dits[4], I030dits[4], I031dits[3], I032dits[3];
443
444   // SDD ladder frame and cooling
445   Float_t SDD_CoolPipe[3] = {1.7000, -0.5500, 0.0000};
446   Float_t I035dits[3], I037dits[3], I038dits[3];
447   Float_t I039dits[3], xI039, yI039;
448   Float_t I041dits[5];
449
450   // SDD hybrid, chips and capacitors
451   Float_t I050dits[3], xI050, yI050;
452   Float_t I052dits[3], xI052, yI052;
453   Float_t I042dits[3], xI042, yI042;
454   Float_t xI042space = 0.17;
455   Float_t I043dits[3], xI043, yI043;
456   Float_t xI043space = 0.17;
457   Float_t zchip, zChipSpace;
458   Float_t I051dits[3], xI051, yI051, zI051, yI051space, xcap;
459   Int_t     ichip, icap;
460
461   // SDD microcables
462   Float_t I044dits[4], xI044, yI044, volI044;
463   Float_t xHV, yHV, zHV, xLV, yLV, zLV;
464   Char_t   HVname[5], LVname[5];
465
466
467   // Define media off-set
468   
469   Int_t *idtmed = fIdtmed->GetArray()-199;
470
471   
472   // Rotation matrices
473   
474   // SPD - option 'a' (this is NOT the default so leave commented)
475   
476   
477   if (option == 1) {
478   
479      AliMatrix(idrotm[201],90.0,90.0,90.0,180.0,0.0,0.0);
480      AliMatrix(idrotm[202],90.0,90.0,90.0,0.0,0.0,0.0);
481      AliMatrix(idrotm[203],90.0,350.0,90.0,260.0,0.0,0.0);
482      AliMatrix(idrotm[204],90.0,170.0,90.0,80.0,0.0,0.0);
483      AliMatrix(idrotm[205],90.0,10.0,90.0,100.0,0.0,0.0);
484      AliMatrix(idrotm[206],90.0,190.0,90.0,280.0,0.0,0.0);
485      AliMatrix(idrotm[207],90.0,342.0,90.0,72.0,0.0,0.0);
486      AliMatrix(idrotm[208],90.0,156.999893,90.0,246.999893,0.0,0.0);
487      AliMatrix(idrotm[209],90.0,147.999802,90.0,237.999893,0.0,0.0);
488      AliMatrix(idrotm[210],90.0,138.999802,90.0,228.999802,0.0,0.0);
489      AliMatrix(idrotm[211],90.0,129.999802,90.0,219.999802,0.0,0.0);
490      AliMatrix(idrotm[212],90.0,36.7896,90.0,126.789597,0.0,0.0);
491      AliMatrix(idrotm[213],90.0,343.579712,90.0,73.579697,0.0,0.0);
492      AliMatrix(idrotm[214],90.0,95.413696,90.0,185.413696,0.0,0.0);
493      AliMatrix(idrotm[215],90.0,5.4141,90.0,95.414101,0.0,0.0);
494      AliMatrix(idrotm[216],90.0,318.296906,90.0,48.296902,0.0,0.0);
495      AliMatrix(idrotm[217],90.0,67.000099,90.0,157.000107,0.0,0.0);
496      AliMatrix(idrotm[218],90.0,337.003998,90.0,67.003998,0.0,0.0);
497      AliMatrix(idrotm[219],90.0,247.000305,90.0,337.000305,0.0,0.0);
498      AliMatrix(idrotm[220],90.0,305.633514,90.0,35.633499,0.0,0.0);
499      AliMatrix(idrotm[221],90.0,58.000198,90.0,148.000198,0.0,0.0);
500      AliMatrix(idrotm[222],90.0,327.997101,90.0,57.997101,0.0,0.0 );
501      AliMatrix(idrotm[223],90.0,237.994202,90.0,327.994202,0.0,0.0);
502      AliMatrix(idrotm[224],90.0,296.627502,90.0,26.627399,0.0,0.0);
503      AliMatrix(idrotm[225],90.0,48.994099,90.0,138.994095,0.0,0.0);
504      AliMatrix(idrotm[226],90.0,318.990997,90.0,48.991001,0.0,0.0);
505      AliMatrix(idrotm[227],90.0,228.988205,90.0,318.98819,0.0,0.0);
506      AliMatrix(idrotm[228],90.0,287.621399,90.0,17.621401,0.0,0.0);
507      AliMatrix(idrotm[229],90.0,39.988098,90.0,129.988098,0.0,0.0);
508      AliMatrix(idrotm[230],90.0,309.984985,90.0,39.985001,0.0,0.0);
509      AliMatrix(idrotm[231],90.0,327.2612,90.0,57.2612,0.0,0.0);
510      AliMatrix(idrotm[232],90.0,237.261398,90.0,327.261414,0.0,0.0);
511      AliMatrix(idrotm[233],90.0,252.000504,90.0,342.000488,0.0,0.0 );
512      AliMatrix(idrotm[234],90.0,71.9991,90.0,161.9991,0.0,0.0);
513      AliMatrix(idrotm[235],90.0,270.0,90.0,0.0,0.0,0.0);
514      AliMatrix(idrotm[236],90.0,180.013702,90.0,270.013702,0.0,0.0);
515      AliMatrix(idrotm[237],90.0,0.0,90.0,90.0,180.0,0.0);
516      AliMatrix(idrotm[238],90.0,144.0,90.0,234.0,0.0,0.0);
517      AliMatrix(idrotm[239],90.0,216.0,90.0,306.0,0.0,0.0);
518      AliMatrix(idrotm[240],90.0,288.0,90.0,18.0,0.0,0.0);
519      AliMatrix(idrotm[241],90.0,324.0,90.0,54.0,0.0,0.0);
520      AliMatrix(idrotm[242],90.0,36.0,90.0,126.0,0.0,0.0);
521      AliMatrix(idrotm[243],90.0,108.0,90.0,198.0,0.0,0.0);
522      AliMatrix(idrotm[244],90.0,0.0,90.0,270.0,180.0,0.0);
523      AliMatrix(idrotm[245],90.0,342.0,90.0,252.0,180.0,0.0);
524      AliMatrix(idrotm[246],90.0,130.0,90.0,40.0,180.0,0.0);
525      AliMatrix(idrotm[247],90.0,139.0,90.0,49.0,180.0,0.0);
526      AliMatrix(idrotm[248],90.0,148.0,90.0,58.0,180.0,0.0);
527      AliMatrix(idrotm[249],90.0,157.0,90.0,67.0,180.0,0.0);
528      AliMatrix(idrotm[1003],90.0,73.5,90.0,163.5,0.0,0.0);
529      AliMatrix(idrotm[1011],90.0,342.0,90.0,72.0,0.0,0.0);
530      AliMatrix(idrotm[1039],90.0,72.0,90.0,162.0,0.0,0.0);
531      AliMatrix(idrotm[1043],90.0,66.91,90.0,156.91,0.0,0.0);
532      AliMatrix(idrotm[1065],90.0,144.0,90.0,234.0,0.0,0.0);
533      AliMatrix(idrotm[1078],90.0,180.0,90.0,270.0,0.0,0.0);
534      AliMatrix(idrotm[1088],90.0,57.41,90.0,147.41,0.0,0.0);
535      AliMatrix(idrotm[1089],90.0,333.0,90.0,63.0,0.0,0.0);
536      AliMatrix(idrotm[1090],90.0,351.0,90.0,81.0,0.0,0.0);
537      AliMatrix(idrotm[1091],90.0,216.0,90.0,306.0,0.0,0.0);
538      AliMatrix(idrotm[1092],90.0,27.0,90.0,117.0,0.0,0.0);
539      AliMatrix(idrotm[1093],90.0,18.0,90.0,108.0,0.0,0.0);
540      AliMatrix(idrotm[1094],90.0,9.0,90.0,99.0,0.0,0.0);
541      AliMatrix(idrotm[1104],90.0,252.0,90.0,342.0,0.0,0.0);
542      AliMatrix(idrotm[1106],90.0,36.0,90.0,126.0,0.0,0.0);
543      AliMatrix(idrotm[1107],90.0,108.0,90.0,198.0,0.0,0.0);
544      AliMatrix(idrotm[1108],90.0,324.0,90.0,54.0,180.0,0.0);
545      AliMatrix(idrotm[1109],90.0,0.0,90.0,90.0,180.0,0.0);
546      AliMatrix(idrotm[1110],90.0,36.0,90.0,126.0,180.0,0.0);
547      AliMatrix(idrotm[1111],90.0,72.0,90.0,162.0,180.0,0.0);
548      AliMatrix(idrotm[1112],90.0,108.0,90.0,198.0,180.0,0.0);
549      AliMatrix(idrotm[1113],90.0,144.0,90.0,234.0,180.0,0.0);
550      AliMatrix(idrotm[1114],90.0,180.0,90.0,270.0,180.0,0.0);
551      AliMatrix(idrotm[1115],90.0,216.0,90.0,306.0,180.0,0.0);
552      AliMatrix(idrotm[1116],90.0,252.0,90.0,342.0,180.0,0.0);
553      AliMatrix(idrotm[1117],90.0,288.0,90.0,18.0,0.0,0.0);
554      AliMatrix(idrotm[1118],90.0,288.0,90.0,18.0,180.0,0.0);
555      AliMatrix(idrotm[1130],90.0,324.0,90.0,54.0,0.0,0.0);  
556
557   }
558   
559   // SPD - option 'b' (this is the default)  
560     
561   if (option == 2) {
562
563      AliMatrix(idrotm[201],90.0,0.0,90.0,90.0,180.0,0.0);
564      AliMatrix(idrotm[202],90.0,90.0,90.0,0.0,0.0,0.0);
565      AliMatrix(idrotm[203],90.0,350.0,90.0,260.0,0.0,0.0);
566      AliMatrix(idrotm[204],90.0,170.0,90.0,80.0,0.0,0.0);
567      AliMatrix(idrotm[205],90.0,10.0,90.0,100.0,0.0,0.0);
568      AliMatrix(idrotm[206],90.0,190.0,90.0,280.0,0.0,0.0);
569      AliMatrix(idrotm[207],90.0,342.0,90.0,72.0,0.0,0.0);
570      AliMatrix(idrotm[208],90.0,156.999893,90.0,246.999893,0.0,0.0);
571      AliMatrix(idrotm[209],90.0,147.999802,90.0,237.999893,0.0,0.0);
572      AliMatrix(idrotm[210],90.0,138.999802,90.0,228.999802,0.0,0.0);
573      AliMatrix(idrotm[211],90.0,129.999802,90.0,219.999802,0.0,0.0);
574      AliMatrix(idrotm[212],90.0,36.7896,90.0,126.789597,0.0,0.0);
575      AliMatrix(idrotm[213],90.0,343.579712,90.0,73.579697,0.0,0.0);
576      AliMatrix(idrotm[214],90.0,95.413696,90.0,185.413696,0.0,0.0);
577      AliMatrix(idrotm[215],90.0,5.4141,90.0,95.414101,0.0,0.0);
578      AliMatrix(idrotm[216],90.0,318.296906,90.0,48.296902,0.0,0.0);
579      AliMatrix(idrotm[217],90.0,67.000099,90.0,157.000107,0.0,0.0);
580      AliMatrix(idrotm[218],90.0,337.003998,90.0,67.003998,0.0,0.0);
581      AliMatrix(idrotm[219],90.0,247.000305,90.0,337.000305,0.0,0.0);
582      AliMatrix(idrotm[220],90.0,305.633514,90.0,35.633499,0.0,0.0);
583      AliMatrix(idrotm[221],90.0,58.000198,90.0,148.000198,0.0,0.0);
584      AliMatrix(idrotm[222],90.0,327.997101,90.0,57.997101,0.0,0.0);
585      AliMatrix(idrotm[223],90.0,237.994202,90.0,327.994202,0.0,0.0);
586      AliMatrix(idrotm[224],90.0,296.627502,90.0,26.627399,0.0,0.0);
587      AliMatrix(idrotm[225],90.0,48.994099,90.0,138.994095,0.0,0.0);
588      AliMatrix(idrotm[226],90.0,318.990997,90.0,48.991001,0.0,0.0);
589      AliMatrix(idrotm[227],90.0,228.988205,90.0,318.98819,0.0,0.0);
590      AliMatrix(idrotm[228],90.0,287.621399,90.0,17.621401,0.0,0.0);
591      AliMatrix(idrotm[229],90.0,39.988098,90.0,129.988098,0.0,0.0);
592      AliMatrix(idrotm[230],90.0,309.984985,90.0,39.985001,0.0,0.0);
593      AliMatrix(idrotm[231],90.0,327.2612,90.0,57.2612,0.0,0.0);
594      AliMatrix(idrotm[232],90.0,237.261398,90.0,327.261414,0.0,0.0);
595      AliMatrix(idrotm[233],90.0,252.000504,90.0,342.000488,0.0,0.0);
596      AliMatrix(idrotm[234],90.0,71.9991,90.0,161.9991,0.0,0.0);
597      AliMatrix(idrotm[235],90.0,270.0,90.0,0.0,0.0,0.0);
598      AliMatrix(idrotm[236],90.0,180.013702,90.0,270.013702,0.0,0.0);
599      AliMatrix(idrotm[237],90.0,90.0,90.0,180.0,0.0,0.0);
600      AliMatrix(idrotm[238],90.0,0.0,90.0,270.0,180.0,0.0);
601      AliMatrix(idrotm[239],90.0,342.0,90.0,252.0,180.0,0.0);
602      AliMatrix(idrotm[240],90.0,130.0,90.0,40.0,180.0,0.0);
603      AliMatrix(idrotm[241],90.0,139.0,90.0,49.0,180.0,0.0);
604      AliMatrix(idrotm[242],90.0,148.0,90.0,58.0,180.0,0.0);
605      AliMatrix(idrotm[243],90.0,157.0,90.0,67.0,180.0,0.0);
606      AliMatrix(idrotm[244],90.0,216.0,90.0,306.0,0.0,0.0);
607      AliMatrix(idrotm[245],90.0,36.0,90.0,126.0,0.0,0.0);
608      AliMatrix(idrotm[246],90.0,108.0,90.0,198.0,0.0,0.0);
609      AliMatrix(idrotm[247],90.0,144.0,90.0,234.0,0.0,0.0);
610      AliMatrix(idrotm[248],90.0,288.0,90.0,18.0,0.0,0.0);
611      AliMatrix(idrotm[249],90.0,324.0,90.0,54.0,0.0,0.0);  
612      AliMatrix(idrotm[1003],90.0,73.5,90.0,163.5,0.0,0.0);
613      AliMatrix(idrotm[1011],90.0,342.0,90.0,72.0,0.0,0.0);
614      AliMatrix(idrotm[1039],90.0,72.0,90.0,162.0,0.0,0.0);
615      AliMatrix(idrotm[1043],90.0,66.91,90.0,156.91,0.0,0.0);
616      AliMatrix(idrotm[1065],90.0,144.0,90.0,234.0,0.0,0.0);
617      AliMatrix(idrotm[1078],90.0,180.0,90.0,270.0,0.0,0.0);
618      AliMatrix(idrotm[1088],90.0,57.41,90.0,147.41,0.0,0.0);
619      AliMatrix(idrotm[1089],90.0,333.0,90.0,63.0,0.0,0.0);
620      AliMatrix(idrotm[1090],90.0,351.0,90.0,81.0,0.0,0.0);
621      AliMatrix(idrotm[1091],90.0,216.0,90.0,306.0,0.0,0.0);
622      AliMatrix(idrotm[1092],90.0,27.0,90.0,117.0,0.0,0.0);
623      AliMatrix(idrotm[1093],90.0,18.0,90.0,108.0,0.0,0.0);
624      AliMatrix(idrotm[1094],90.0,9.0,90.0,99.0,0.0,0.0);
625      AliMatrix(idrotm[1104],90.0,252.0,90.0,342.0,0.0,0.0);
626      AliMatrix(idrotm[1106],90.0,36.0,90.0,126.0,0.0,0.0);
627      AliMatrix(idrotm[1107],90.0,108.0,90.0,198.0,0.0,0.0);
628      AliMatrix(idrotm[1108],90.0,324.0,90.0,54.0,180.0,0.0);
629      AliMatrix(idrotm[1109],90.0,0.0,90.0,90.0,180.0,0.0);
630      AliMatrix(idrotm[1110],90.0,36.0,90.0,126.0,180.0,0.0);
631      AliMatrix(idrotm[1111],90.0,72.0,90.0,162.0,180.0,0.0);
632      AliMatrix(idrotm[1112],90.0,108.0,90.0,198.0,180.0,0.0);
633      AliMatrix(idrotm[1113],90.0,144.0,90.0,234.0,180.0,0.0);
634      AliMatrix(idrotm[1114],90.0,180.0,90.0,270.0,180.0,0.0);
635      AliMatrix(idrotm[1115],90.0,216.0,90.0,306.0,180.0,0.0);
636      AliMatrix(idrotm[1116],90.0,252.0,90.0,342.0,180.0,0.0);
637      AliMatrix(idrotm[1117],90.0,288.0,90.0,18.0,0.0,0.0);
638      AliMatrix(idrotm[1118],90.0,288.0,90.0,18.0,180.0,0.0);
639      AliMatrix(idrotm[1130],90.0,324.0,90.0,54.0,0.0,0.0);  
640
641   }
642     
643   // SDD
644   
645   AliMatrix(idrotm[301],0.0,0.0,90.0,90.0,90.0,180.0);  
646   AliMatrix(idrotm[302],0.0,0.0,90.0,90.0,90.0,0.0);
647   AliMatrix(idrotm[303],180.0,0.0,90.0,90.0,90.0,0.0); 
648   AliMatrix(idrotm[304],180.0,0.0,90.0,90.0,90.0,180.0); 
649   AliMatrix(idrotm[305],90.0,347.14,90.0,77.14,0.0,0.0); 
650   AliMatrix(idrotm[306],90.0,321.43,90.0,51.43,0.0,0.0); 
651   AliMatrix(idrotm[307],90.0,295.71,90.0,25.71,0.0,0.0);
652   AliMatrix(idrotm[308],90.0,244.29,90.0,334.29,0.0,0.0);
653   AliMatrix(idrotm[309],90.0,218.57,90.0,308.57,0.0,0.0);
654   AliMatrix(idrotm[310],90.0,167.14,90.0,257.14,0.0,0.0);
655   AliMatrix(idrotm[311],90.0,141.43,90.0,231.43,0.0,0.0);  
656   AliMatrix(idrotm[312],90.0,0.0,0.0,0.0,90.0,270.0);
657   AliMatrix(idrotm[313],90.0,115.71,90.0,205.71,0.0,0.0); 
658   AliMatrix(idrotm[314],90.0,335.45,90.0,65.45,0.0,0.0); 
659   AliMatrix(idrotm[315],90.0,319.09,90.0,49.09,0.0,0.0); 
660   AliMatrix(idrotm[316],90.0,302.73,90.0,32.73,0.0,0.0); 
661   AliMatrix(idrotm[317],90.0,286.36,90.0,16.36,0.0,0.0);
662   AliMatrix(idrotm[318],90.0,270.0,90.0,360.0,0.0,0.0);
663   AliMatrix(idrotm[319],90.0,253.64,90.0,343.64,0.0,0.0);
664   AliMatrix(idrotm[320],90.0,237.27,90.0,327.27,0.0,0.0);
665   AliMatrix(idrotm[321],90.0,12.86,90.0,102.86,0.0,0.0);  
666   AliMatrix(idrotm[322],90.0,220.91,90.0,310.91,0.0,0.0);
667   AliMatrix(idrotm[323],90.0,204.55,90.0,294.55,0.0,0.0); 
668   AliMatrix(idrotm[324],90.0,188.18,90.0,278.18,0.0,0.0); 
669   AliMatrix(idrotm[325],90.0,171.82,90.0,261.82,0.0,0.0); 
670   AliMatrix(idrotm[326],90.0,155.45,90.0,245.45,0.0,0.0); 
671   AliMatrix(idrotm[327],90.0,139.09,90.0,229.09,0.0,0.0);
672   AliMatrix(idrotm[328],90.0,122.73,90.0,212.73,0.0,0.0);
673   AliMatrix(idrotm[329],90.0,106.36,90.0,196.36,0.0,0.0);
674   AliMatrix(idrotm[330],90.0,73.64,90.0,163.64,0.0,0.0);    
675   AliMatrix(idrotm[331],90.0,40.91,90.0,130.91,0.0,0.0);  
676   AliMatrix(idrotm[332],90.0,24.55,90.0,114.55,0.0,0.0);
677   AliMatrix(idrotm[333],90.0,38.57,90.0,128.57,0.0,0.0); 
678   AliMatrix(idrotm[334],90.0,351.82,90.0,81.82,0.0,0.0); 
679   AliMatrix(idrotm[335],90.0,8.18,90.0,98.18,0.0,0.0); 
680   AliMatrix(idrotm[336],90.0,64.29,90.0,154.29,0.0,0.0); 
681   AliMatrix(idrotm[337],111.0,300.0,21.0,300.0,90.0,30.0);
682   AliMatrix(idrotm[338],69.0,240.0,159.0,240.0,90.0,150.0);
683   AliMatrix(idrotm[339],111.0,240.0,21.0,240.0,90.0,150.0);
684   AliMatrix(idrotm[340],69.0,300.0,159.0,300.0,90.0,30.0);  
685   AliMatrix(idrotm[341],128.0,0.0,38.0,0.0,90.0,270.0);  
686   AliMatrix(idrotm[342],90.0,240.0,180.0,0.0,90.0,330.);
687   AliMatrix(idrotm[343],90.0,120.0,180.0,0.0,90.0,210.0); 
688   AliMatrix(idrotm[344],90.0,0.0,180.0,0.0,90.0,90.0); 
689   AliMatrix(idrotm[345],90.0,180.0,90.0,90.0,0.0,0.0); 
690   AliMatrix(idrotm[346],90.0,300.0,90.0,30.0,0.0,0.0); 
691   AliMatrix(idrotm[347],90.0,240.0,90.0,150.0,0.0,0.0);
692   AliMatrix(idrotm[348],90.0,180.0,0.0,0.0,90.0,270.0);
693   AliMatrix(idrotm[349],90.0,235.0,90.0,145.0,0.0,0.0);
694   AliMatrix(idrotm[350],90.0,90.0,90.0,180.0,0.0,0.0);  
695   AliMatrix(idrotm[351],90.0,305.0,90.0,35.0,0.0,0.0);  
696   AliMatrix(idrotm[352],0.0,0.0,90.0,0.0,90.0,90.0);
697   AliMatrix(idrotm[353],90.0,60.0,90.0,150.0,0.0,0.0); 
698   AliMatrix(idrotm[354],90.0,120.0,90.0,30.0,0.0,0.0); 
699   AliMatrix(idrotm[355],90.0,180.0,90.0,90.0,180.0,0.0); 
700   AliMatrix(idrotm[356],90.0,270.0,90.0,0.0,0.0,0.0); 
701   AliMatrix(idrotm[366],90.0,57.27,90.0,147.27,0.0,0.0); 
702   AliMatrix(idrotm[386],90.0,192.86,90.0,282.86,0.0,0.0);  
703    
704   // SSD
705   
706   AliMatrix(idrotm[501],90.0,148.24,90.0,238.24,0.0,0.0);
707   AliMatrix(idrotm[503],90.0,137.65,90.0,227.65,0.0,0.0); 
708   AliMatrix(idrotm[504],90.0,127.06,90.0,217.06,0.0,0.0);  
709   AliMatrix(idrotm[505],90.0,116.47,90.0,206.47,0.0,0.0);  
710   AliMatrix(idrotm[506],90.0,105.88,90.0,195.88,0.0,0.0);  
711   AliMatrix(idrotm[507],90.0,95.29,90.0,185.29,0.0,0.0);  
712   AliMatrix(idrotm[508],90.0,84.71,90.0,174.71,0.0,0.0);
713   AliMatrix(idrotm[509],90.0,74.12,90.0,164.12,0.0,0.0);
714   AliMatrix(idrotm[510],90.0,63.53,90.0,153.53,0.0,0.0);  
715   AliMatrix(idrotm[511],90.0,52.94,90.0,142.94,0.0,0.0);
716   AliMatrix(idrotm[512],90.0,42.35,90.0,132.35,0.0,0.0);
717   AliMatrix(idrotm[513],90.0,31.76,90.0,121.76,0.0,0.0); 
718   AliMatrix(idrotm[514],90.0,10.59,90.0,100.59,0.0,0.0);  
719   AliMatrix(idrotm[515],90.0,349.41,90.0,79.41,0.0,0.0);  
720   AliMatrix(idrotm[516],90.0,338.82,90.0,68.82,0.0,0.0);  
721   AliMatrix(idrotm[517],90.0,328.24,90.0,58.24,0.0,0.0);  
722   AliMatrix(idrotm[518],90.0,317.65,90.0,47.65,0.0,0.0);
723   AliMatrix(idrotm[519],90.0,307.06,90.0,37.06,0.0,0.0);
724   AliMatrix(idrotm[520],90.0,296.47,90.0,26.47,0.0,0.0);  
725   AliMatrix(idrotm[521],90.0,285.88,90.0,15.88,0.0,0.0);
726   AliMatrix(idrotm[522],90.0,275.29,90.0,5.29,0.0,0.0);
727   AliMatrix(idrotm[523],90.0,264.71,90.0,354.71,0.0,0.0); 
728   AliMatrix(idrotm[524],90.0,254.12,90.0,344.12,0.0,0.0);  
729   AliMatrix(idrotm[525],90.0,243.53,90.0,333.53,0.0,0.0);  
730   AliMatrix(idrotm[526],90.0,232.94,90.0,322.94,0.0,0.0);  
731   AliMatrix(idrotm[527],90.0,222.35,90.0,312.35,0.0,0.0);  
732   AliMatrix(idrotm[528],90.0,211.76,90.0,301.76,0.0,0.0);
733   AliMatrix(idrotm[529],90.0,190.59,90.0,280.59,0.0,0.0);
734   AliMatrix(idrotm[530],90.0,169.41,90.0,259.41,0.0,0.0);  
735   AliMatrix(idrotm[531],90.0,158.82,90.0,248.82,0.0,0.0);
736   AliMatrix(idrotm[532],90.0,360.0,90.0,90.0,0.0,0.0);
737   AliMatrix(idrotm[533],90.0,180.0,90.0,270.0,0.0,0.0); 
738   AliMatrix(idrotm[534],90.0,189.47,90.0,279.47,0.0,0.0);  
739   AliMatrix(idrotm[535],90.0,198.95,90.0,288.95,0.0,0.0);  
740   AliMatrix(idrotm[537],90.0,217.89,90.0,307.89,0.0,0.0);  
741   AliMatrix(idrotm[538],90.0,227.37,90.0,317.37,0.0,0.0);
742   AliMatrix(idrotm[539],90.0,236.84,90.0,326.84,0.0,0.0);
743   AliMatrix(idrotm[540],90.0,246.32,90.0,336.32,0.0,0.0);  
744   AliMatrix(idrotm[541],90.0,255.79,90.0,345.79,0.0,0.0);
745   AliMatrix(idrotm[542],90.0,265.26,90.0,355.26,0.0,0.0);
746   AliMatrix(idrotm[543],90.0,274.74,90.0,4.74,0.0,0.0); 
747   AliMatrix(idrotm[544],90.0,284.21,90.0,14.21,0.0,0.0);  
748   AliMatrix(idrotm[545],90.0,293.68,90.0,23.68,0.0,0.0);  
749   AliMatrix(idrotm[546],90.0,303.16,90.0,33.16,0.0,0.0);  
750   AliMatrix(idrotm[547],90.0,312.63,90.0,42.63,0.0,0.0);  
751   AliMatrix(idrotm[548],90.0,322.11,90.0,52.11,0.0,0.0);
752   AliMatrix(idrotm[549],90.0,331.58,90.0,61.58,0.0,0.0);
753   AliMatrix(idrotm[550],90.0,341.05,90.0,71.05,0.0,0.0);  
754   AliMatrix(idrotm[551],90.0,350.53,90.0,80.53,0.0,0.0);
755   AliMatrix(idrotm[552],90.0,9.47,90.0,99.47,0.0,0.0);
756   AliMatrix(idrotm[553],90.0,18.95,90.0,108.95,0.0,0.0); 
757   AliMatrix(idrotm[555],90.0,37.89,90.0,127.89,0.0,0.0);  
758   AliMatrix(idrotm[556],90.0,47.37,90.0,137.37,0.0,0.0);  
759   AliMatrix(idrotm[557],90.0,56.84,90.0,146.84,0.0,0.0);  
760   AliMatrix(idrotm[558],90.0,66.32,90.0,156.32,0.0,0.0);
761   AliMatrix(idrotm[559],90.0,75.79,90.0,165.79,0.0,0.0);
762   AliMatrix(idrotm[560],90.0,85.26,90.0,175.26,0.0,0.0);  
763   AliMatrix(idrotm[561],90.0,94.74,90.0,184.74,0.0,0.0);
764   AliMatrix(idrotm[562],90.0,104.21,90.0,194.21,0.0,0.0);
765   AliMatrix(idrotm[563],90.0,113.68,90.0,203.68,0.0,0.0); 
766   AliMatrix(idrotm[564],90.0,123.16,90.0,213.16,0.0,0.0);  
767   AliMatrix(idrotm[565],90.0,132.63,90.0,222.63,0.0,0.0);  
768   AliMatrix(idrotm[566],90.0,142.11,90.0,232.11,0.0,0.0);  
769   AliMatrix(idrotm[567],90.0,151.58,90.0,241.58,0.0,0.0);  
770   AliMatrix(idrotm[568],90.0,161.05,90.0,251.05,0.0,0.0);
771   AliMatrix(idrotm[569],90.0,170.53,90.0,260.53,0.0,0.0);
772   AliMatrix(idrotm[570],90.0,180.0,90.0,90.0,180.0,0.0);  
773   AliMatrix(idrotm[571],90.0,0.0,0.0,0.0,90.0,270.0);
774   AliMatrix(idrotm[572],90.0,180.0,0.0,0.0,90.0,270.0);
775   AliMatrix(idrotm[573],90.0,180.0,90.0,90.0,0.0,0.0); 
776   AliMatrix(idrotm[575],90.0,120.0,180.0,0.0,90.0,210.0);  
777   AliMatrix(idrotm[576],65.71,300.0,90.0,30.0,24.29,120.0);  
778   AliMatrix(idrotm[577],114.29,300.0,90.0,30.0,155.71,120.0);  
779   AliMatrix(idrotm[579],65.71,240.0,90.0,150.0,24.29,60.0);
780   AliMatrix(idrotm[580],114.29,240.0,90.0,150.0,155.71,60.0);  
781   AliMatrix(idrotm[581],90.0,240.0,180.0,0.0,90.0,330.0);
782   AliMatrix(idrotm[583],90.0,0.0,180.0,0.0,90.0,90.0); 
783   AliMatrix(idrotm[584],90.0,180.0,180.0,0.0,90.0,90.0);  
784   AliMatrix(idrotm[586],180.0,0.0,90.0,90.0,90.0,0.0);  
785   AliMatrix(idrotm[618],90.0,201.18,90.0,291.18,0.0,0.0);
786   AliMatrix(idrotm[620],90.0,28.42,90.0,118.42,0.0,0.0);  
787   AliMatrix(idrotm[623],90.0,208.42,90.0,298.42,0.0,0.0);
788   AliMatrix(idrotm[633],132.46,0.0,90.0,90.0,42.46,360.0);
789   AliMatrix(idrotm[653],90.0,21.18,90.0,111.18,0.0,0.0); 
790
791   
792   // SDD cone
793
794   AliMatrix(idrotm[846],90.0,300.0,90.0,30.0,0.0,0.0);
795   AliMatrix(idrotm[851],90.0,305.0,90.0,35.0,0.0,0.0);
796   AliMatrix(idrotm[853],90.0,60.0,90.0,150.0,0.0,0.0);
797   AliMatrix(idrotm[856],90.0,0.0,90.0,90.0,180.0,0.0);
798   AliMatrix(idrotm[857],90.0,5.0,90.0,95.0,180.0,0.0);
799   AliMatrix(idrotm[858],90.0,65.0,90.0,155.0,180.0,0.0);
800   AliMatrix(idrotm[859],90.0,305.0,90.0,35.0,180.0,0.0);
801   AliMatrix(idrotm[860],90.0,245.0,90.0,335.0,180.0,0.0);
802   AliMatrix(idrotm[861],90.0,185.0,90.0,275.0,180.0,0.0);
803   AliMatrix(idrotm[862],90.0,125.0,90.0,215.0,180.0,0.0);
804   AliMatrix(idrotm[863],90.0,257.5,90.0,347.5,180.0,0.0);
805   AliMatrix(idrotm[864],90.0,227.5,90.0,317.5,180.0,0.0);
806   AliMatrix(idrotm[865],90.0,197.5,90.0,287.5,180.0,0.0);
807   AliMatrix(idrotm[867],90.0,167.5,90.0,257.5,180.0,0.0);
808   AliMatrix(idrotm[868],90.0,287.5,90.0,17.5,0.0,0.0);  
809   AliMatrix(idrotm[869],90.0,137.5,90.0,227.5,180.0,0.0);
810   AliMatrix(idrotm[870],90.0,107.5,90.0,197.5,180.0,0.0);
811   AliMatrix(idrotm[871],90.0,77.5,90.0,167.5,180.0,0.0);
812   AliMatrix(idrotm[872],90.0,47.5,90.0,137.5,180.0,0.0);
813   AliMatrix(idrotm[873],90.0,17.5,90.0,107.5,180.0,0.0);
814   AliMatrix(idrotm[874],90.0,347.5,90.0,77.5,180.0,0.0);
815   AliMatrix(idrotm[875],90.0,317.5,90.0,47.5,180.0,0.0);
816   AliMatrix(idrotm[876],90.0,287.5,90.0,17.5,180.0,0.0);
817   AliMatrix(idrotm[877],90.0,185.0,90.0,275.0,0.0,0.0);
818   AliMatrix(idrotm[878],90.0,180.0,90.0,270.0,0.0,0.0);  
819   AliMatrix(idrotm[879],90.0,125.0,90.0,215.0,0.0,0.0);
820   AliMatrix(idrotm[880],90.0,65.0,90.0,155.0,0.0,0.0);
821   AliMatrix(idrotm[881],90.0,5.0,90.0,95.0,0.0,0.0);
822   AliMatrix(idrotm[882],90.0,245.0,90.0,335.0,0.0,0.0);
823   AliMatrix(idrotm[883],90.0,47.5,90.0,137.5,0.0,0.0);
824   AliMatrix(idrotm[884],90.0,77.5,90.0,167.5,0.0,0.0);
825   AliMatrix(idrotm[885],90.0,107.5,90.0,197.5,0.0,0.0);
826   AliMatrix(idrotm[887],90.0,137.5,90.0,227.5,0.0,0.0);
827   AliMatrix(idrotm[888],90.0,167.5,90.0,257.5,0.0,0.0);
828   AliMatrix(idrotm[889],90.0,197.5,90.0,287.5,0.0,0.0);
829   AliMatrix(idrotm[890],90.0,227.5,90.0,317.5,0.0,0.0);
830   AliMatrix(idrotm[891],90.0,347.5,90.0,77.5,0.0,0.0);
831   AliMatrix(idrotm[892],90.0,317.5,90.0,47.5,0.0,0.0);
832   AliMatrix(idrotm[893],90.0,257.5,90.0,347.5,0.0,0.0);
833   AliMatrix(idrotm[894],90.0,270.0,0.0,0.0,90.0,180.0);
834   AliMatrix(idrotm[895],90.0,286.36,0.0,0.0,90.0,196.36);
835   AliMatrix(idrotm[896],90.0,302.73,0.0,0.0,90.0,212.73);
836   AliMatrix(idrotm[897],90.0,319.09,0.0,0.0,90.0,229.09);
837   AliMatrix(idrotm[898],90.0,17.5,90.0,107.5,0.0,0.0);
838   AliMatrix(idrotm[899],90.0,335.45,0.0,0.0,90.0,245.45);
839   AliMatrix(idrotm[900],90.0,351.82,0.0,0.0,90.0,261.82);
840   AliMatrix(idrotm[901],90.0,8.18,0.0,0.0,90.0,278.18);
841   AliMatrix(idrotm[902],90.0,24.55,0.0,0.0,90.0,294.55);
842   AliMatrix(idrotm[903],90.0,40.91,0.0,0.0,90.0,310.91);
843   AliMatrix(idrotm[904],90.0,57.27,0.0,0.0,90.0,327.27);
844   AliMatrix(idrotm[905],90.0,73.64,0.0,0.0,90.0,343.64);
845   AliMatrix(idrotm[906],90.0,90.0,0.0,0.0,90.0,360.0);
846   AliMatrix(idrotm[907],90.0,106.36,0.0,0.0,90.0,16.36);
847   AliMatrix(idrotm[908],90.0,122.73,0.0,0.0,90.0,32.73);
848   AliMatrix(idrotm[909],90.0,139.09,0.0,0.0,90.0,49.09);
849   AliMatrix(idrotm[910],90.0,155.45,0.0,0.0,90.0,65.45);
850   AliMatrix(idrotm[911],90.0,171.82,0.0,0.0,90.0,81.82);
851   AliMatrix(idrotm[912],90.0,188.18,0.0,0.0,90.0,98.18);
852   AliMatrix(idrotm[913],90.0,204.55,0.0,0.0,90.0,114.55);
853   AliMatrix(idrotm[914],90.0,220.91,0.0,0.0,90.0,130.91);
854   AliMatrix(idrotm[915],90.0,237.27,0.0,0.0,90.0,147.27);
855   AliMatrix(idrotm[916],90.0,253.64,0.0,0.0,90.0,163.64);
856   AliMatrix(idrotm[917],90.0,295.71,0.0,0.0,90.0,205.71);
857   AliMatrix(idrotm[918],90.0,321.43,0.0,0.0,90.0,231.43);
858   AliMatrix(idrotm[919],90.0,347.14,0.0,0.0,90.0,257.14);
859   AliMatrix(idrotm[920],90.0,12.86,0.0,0.0,90.0,282.86);
860   AliMatrix(idrotm[921],90.0,38.57,0.0,0.0,90.0,308.57);
861   AliMatrix(idrotm[922],90.0,64.29,0.0,0.0,90.0,334.29);
862   AliMatrix(idrotm[923],90.0,115.71,0.0,0.0,90.0,25.71);
863   AliMatrix(idrotm[924],90.0,141.43,0.0,0.0,90.0,51.43);
864   AliMatrix(idrotm[925],90.0,167.14,0.0,0.0,90.0,77.14);
865   AliMatrix(idrotm[926],90.0,192.86,0.0,0.0,90.0,102.86);
866   AliMatrix(idrotm[927],90.0,218.57,0.0,0.0,90.0,128.57);
867   AliMatrix(idrotm[928],90.0,244.29,0.0,0.0,90.0,154.29);
868   AliMatrix(idrotm[929],90.0,120.0,90.0,210.0,0.0,0.0);
869   AliMatrix(idrotm[930],90.0,240.0,90.0,330.0,0.0,0.0);
870   AliMatrix(idrotm[931],90.0,60.0,90.0,150.0,180.0,0.0);
871   AliMatrix(idrotm[932],90.0,120.0,90.0,210.0,180.0,0.0);
872   AliMatrix(idrotm[933],90.0,180.0,90.0,270.0,180.0,0.0);
873   AliMatrix(idrotm[934],90.0,240.0,90.0,330.0,180.0,0.0);
874   AliMatrix(idrotm[935],90.0,300.0,90.0,30.0,180.0,0.0);
875
876   // SSD cone
877
878   AliMatrix(idrotm[701],90.0,0.0,90.0,90.0,180.0,0.0);
879   AliMatrix(idrotm[702],90.0,347.5,90.0,77.5,180.0,0.0);
880   AliMatrix(idrotm[703],90.0,17.5,90.0,107.5,180.0,0.0);
881   AliMatrix(idrotm[704],90.0,47.5,90.0,137.5,180.0,0.0);
882   AliMatrix(idrotm[705],90.0,77.5,90.0,167.5,180.0,0.0);
883   AliMatrix(idrotm[706],90.0,107.5,90.0,197.5,180.0,0.0);
884   AliMatrix(idrotm[707],90.0,137.5,90.0,227.5,180.0,0.0);
885   AliMatrix(idrotm[708],90.0,167.5,90.0,257.5,180.0,0.0);
886   AliMatrix(idrotm[709],90.0,197.5,90.0,287.5,180.0,0.0);
887   AliMatrix(idrotm[710],90.0,227.5,90.0,317.5,180.0,0.0);
888   AliMatrix(idrotm[711],90.0,257.5,90.0,347.5,180.0,0.0);
889   AliMatrix(idrotm[712],90.0,287.5,90.0,17.5,180.0,0.0);
890   AliMatrix(idrotm[713],90.0,317.5,90.0,47.5,180.0,0.0);
891   AliMatrix(idrotm[714],90.0,328.4,90.0,58.4,180.0,0.0);
892   AliMatrix(idrotm[715],90.0,28.4,90.0,118.4,180.0,0.0);
893   AliMatrix(idrotm[716],90.0,88.4,90.0,178.4,180.0,0.0);
894   AliMatrix(idrotm[717],90.0,148.4,90.0,238.4,180.0,0.0);
895   AliMatrix(idrotm[718],90.0,208.4,90.0,298.4,180.0,0.0);
896   AliMatrix(idrotm[719],90.0,268.4,90.0,358.4,180.0,0.0);
897   AliMatrix(idrotm[720],90.0,28.4,90.0,118.4,0.0,0.0);
898   AliMatrix(idrotm[721],90.0,88.4,90.0,178.4,0.0,0.0);
899   AliMatrix(idrotm[722],90.0,148.4,90.0,238.4,0.0,0.0);
900   AliMatrix(idrotm[723],90.0,208.4,90.0,298.4,0.0,0.0);
901   AliMatrix(idrotm[724],90.0,268.4,90.0,358.4,0.0,0.0);
902   AliMatrix(idrotm[725],90.0,328.4,90.0,58.4,0.0,0.0);
903   AliMatrix(idrotm[726],90.0,77.5,90.0,167.5,0.0,0.0);
904   AliMatrix(idrotm[727],90.0,107.5,90.0,197.5,0.0,0.0);
905   AliMatrix(idrotm[728],90.0,137.5,90.0,227.5,0.0,0.0);
906   AliMatrix(idrotm[729],90.0,167.5,90.0,257.5,0.0,0.0);
907   AliMatrix(idrotm[730],90.0,227.5,90.0,317.5,0.0,0.0);
908   AliMatrix(idrotm[731],90.0,257.5,90.0,347.5,0.0,0.0);
909   AliMatrix(idrotm[732],90.0,317.5,90.0,47.5,0.0,0.0);  
910   AliMatrix(idrotm[733],90.0,197.5,90.0,287.5,0.0,0.0);
911   AliMatrix(idrotm[734],90.0,347.5,90.0,77.5,0.0,0.0);
912   AliMatrix(idrotm[735],90.0,47.5,90.0,137.5,0.0,0.0);
913   AliMatrix(idrotm[768],90.0,287.5,90.0,17.5,0.0,0.0);
914   AliMatrix(idrotm[798],90.0,17.5,90.0,107.5,0.0,0.0);
915
916   // Services
917     
918   AliMatrix(idrotm[200], 90., 0., 90., 90., 180., 0.);  
919
920
921   //     CONVERT INTO CM (RL(SI)=9.36 CM) 
922   
923   for (i = 0; i < 6; ++i) {
924     drl[i] = drl[i] / 100. * 9.36;
925   }
926     
927   //     FIELD CAGE HALF LENGTH 
928   
929   rlim  = 50.;
930   zmax  = 74.;
931   ztpc = 284.;
932   
933   // --- Define ghost volume containing the whole ITS (including services) 
934   //     and fill it with air 
935   
936   dgh[0] = 0.;
937   dgh[1] = 360.;
938   dgh[2] = 16.;
939   dgh[3] = -ztpc-5.-0.1;
940   dgh[4] = 46;   
941   dgh[5] = 85.;
942   dgh[6] = -ztpc;
943   dgh[7] = 46;   
944   dgh[8] = 85.;
945   dgh[9] = -ztpc;
946   dgh[10] = 46;  
947   dgh[11] = rlim+6;
948   dgh[12] = -97.5;
949   dgh[13] = 46;  
950   dgh[14] = rlim+6;
951   dgh[15] = -zmax;
952   dgh[16] = 46;  
953   dgh[17] = rlim+6;
954   dgh[18] = -48;   
955   dgh[19] = 6;
956   dgh[20] = rlim+6;
957   dgh[21] = -28.6;   
958   dgh[22] = 6;
959   dgh[23] = rlim+6;    
960   dgh[24] = -27.6;  
961   dgh[25] = 3.295;
962   dgh[26] = rlim+6; 
963   dgh[27] = 27.6;   
964   dgh[28] = 3.295;
965   dgh[29] = rlim+6;
966   dgh[30] = 28.6;   
967   dgh[31] = 6;
968   dgh[32] = rlim+6;
969   dgh[33] = 48;   
970   dgh[34] = 6;
971   dgh[35] = rlim+6;  
972   dgh[36] = zmax;
973   dgh[37] = 46;
974   dgh[38] = rlim+6;
975   dgh[39] = 97.5;
976   dgh[40] = 46;  
977   dgh[41] = rlim+6;
978   dgh[42] = ztpc;
979   dgh[43] = 62;     
980   dgh[44] = 62+4.;  
981   dgh[45] = ztpc;
982   dgh[46] = 62;     
983   dgh[47] = 85.;
984   dgh[48] = ztpc+4.+0.1;
985   dgh[49] = 62.4;
986   dgh[50] = 85.;
987   gMC->Gsvolu("ITSV", "PCON", idtmed[205], dgh, 51);
988
989   
990   // --- Place the ghost volume in its mother volume (ALIC) and make it 
991   //     invisible 
992   
993   gMC->Gspos("ITSV", 1, "ALIC", 0., 0., 0., 0, "ONLY");
994   //gMC->Gsatt("ITSV", "SEEN", 0); 
995
996
997   // --- Define ghost volume containing the six layers and fill it with air 
998   
999   dgh[0] = 0.;
1000   dgh[1] = 360.;
1001   dgh[2] = 8.;
1002   dgh[3] = -zmax;  
1003   dgh[4] = 46.;
1004   dgh[5] = rlim;
1005   dgh[6] = -47.5;    
1006   dgh[7] = 6.005;
1007   dgh[8] = rlim;
1008   dgh[9] = -28.5;    
1009   dgh[10] = 6.005;
1010   dgh[11] = rlim;  
1011   dgh[12] = -27.5;   
1012   dgh[13] = 3.3;
1013   dgh[14] = rlim;
1014   dgh[15] = 27.5;    
1015   dgh[16] = 3.3;
1016   dgh[17] = rlim;
1017   dgh[18] = 28.5;    
1018   dgh[19] = 6.005;
1019   dgh[20] = rlim;
1020   dgh[21] = 47.5;    
1021   dgh[22] = 6.005;
1022   dgh[23] = rlim;
1023   dgh[24] = zmax;    
1024   dgh[25] = 46.;
1025   dgh[26] = rlim;
1026   gMC->Gsvolu("ITSD", "PCON", idtmed[205], dgh, 27);
1027   
1028   // --- Place the ghost volume in its mother volume (ITSV) and make it 
1029   //     invisible 
1030   
1031   gMC->Gspos("ITSD", 1, "ITSV", 0., 0., 0., 0, "ONLY");
1032   //gMC->Gsatt("ITSD", "SEEN", 0);
1033
1034
1035   // --- Define SPD (option 'a') volumes ----------------------------
1036   
1037   // SPD - option 'a' 
1038   // (this is NOT the default)
1039
1040   if (option == 1) {
1041   
1042      dits[0] = 3.7;
1043      dits[1] = 7.75;
1044      dits[2] = 26.1;
1045      gMC->Gsvolu("IT12", "TUBE", idtmed[254], dits, 3);   
1046
1047      dits[0] = 3.7;
1048      dits[1] = 7.7;
1049      dits[2] = 24;
1050      dits[3] = 57;
1051      dits[4] = 100;
1052      gMC->Gsvolu("I12A", "TUBS", idtmed[254], dits, 5);    // sector
1053
1054      di10a[0] = 0.843;
1055      di10a[1] = ddet1+dchip1+dbus+0.0025;
1056      di10a[2] = 19.344;
1057      gMC->Gsvolu("I10A", "BOX ", idtmed[254], di10a, 3);    // mother volume
1058                                                             // on layer 1
1059      di20a[0] = 0.843;
1060      di20a[1] = ddet2+dchip2+dbus+0.0025;
1061      di20a[2] = 19.344;
1062      gMC->Gsvolu("I20A", "BOX ", idtmed[254], di20a, 3);    // mother volume
1063                                                             // on layer 2
1064      dits[0] = 1.3673;
1065      dits[1] = 0.01;
1066      dits[2] = 24;
1067      gMC->Gsvolu("I123", "BOX ", idtmed[253], dits, 3);
1068
1069      dits[0] = 0.06;
1070      dits[1] = 0.08;
1071      dits[2] = 24;
1072      dits[3] = -36.79;
1073      dits[4] = 21.834;
1074      gMC->Gsvolu("I121", "TUBS", idtmed[253], dits, 5);  
1075
1076      dits[0] = 0.1253;
1077      dits[1] = 0.01;
1078      dits[2] = 24;
1079      gMC->Gsvolu("I122", "BOX ", idtmed[253], dits, 3);  
1080
1081      dits[0] = 0.04;
1082      dits[1] = 0.06 ;
1083      dits[2] = 24;
1084      dits[3] = 126.79;
1085      dits[4] = 270;
1086      gMC->Gsvolu("I120", "TUBS", idtmed[253], dits, 5);  
1087
1088      dits[0] = 0.1134;
1089      dits[1] = 0.01;
1090      dits[2] = 24;
1091      gMC->Gsvolu("I144", "BOX ", idtmed[253], dits, 3);  
1092
1093      dits[0] = 0.25;
1094      dits[1] = 0.06;
1095      dits[2] = 24;
1096      gMC->Gsvolu("I113", "BOX ", idtmed[254], dits, 3);  
1097
1098      dits[0] = 0.077;
1099      dits[1] = 0.01;
1100      dits[2] = 24;
1101      gMC->Gsvolu("I143", "BOX ", idtmed[253], dits, 3);   
1102
1103      dits[0] = 0.04;
1104      dits[1] = 0.06;
1105      dits[2] = 24;
1106      dits[3] = 0;
1107      dits[4] = 90;
1108      gMC->Gsvolu("I142", "TUBS", idtmed[253], dits, 5); 
1109
1110      dits[0] = 0.0695;
1111      dits[1] = 0.01;
1112      dits[2] = 24;
1113      gMC->Gsvolu("I141", "BOX ", idtmed[253], dits, 3);  
1114
1115      dits[0] = 0.06;
1116      dits[1] = 0.08;
1117      dits[2] = 24;
1118      dits[3] = 0;
1119      dits[4] = 108;
1120      gMC->Gsvolu("I140", "TUBS", idtmed[253], dits, 5);  
1121
1122      dits[0] = 0.1835;
1123      dits[1] = 0.01;
1124      dits[2] = 24;
1125      gMC->Gsvolu("I139", "BOX ", idtmed[253], dits, 3);
1126
1127      dits[0] = 0.1894 ;
1128      dits[1] = 0.01;
1129      dits[2] = 24;
1130      gMC->Gsvolu("I138", "BOX ", idtmed[253], dits, 3);  
1131
1132      dits[0] = 0.04;
1133      dits[1] = 0.06;
1134      dits[2] = 24;
1135      dits[3] = 0;
1136      dits[4] = 75.261;
1137      gMC->Gsvolu("I137", "TUBS", idtmed[253], dits, 5);  
1138
1139      dits[0] = 1.3401;
1140      dits[1] = 0.01;
1141      dits[2] = 24;
1142      gMC->Gsvolu("I136", "BOX ", idtmed[253], dits, 3);  
1143
1144      dits[0] = 0.05;
1145      dits[1] = 0.07;
1146      dits[2] = 24;
1147      dits[3] = 0;
1148      dits[4] = 72.739;
1149      gMC->Gsvolu("I135", "TUBS", idtmed[253], dits, 5);  
1150
1151      dits[0] = 0.1193;
1152      dits[1] = 0.01;
1153      dits[2] = 24;
1154      gMC->Gsvolu("I134", "BOX ", idtmed[253], dits, 3);    
1155
1156      dits[0] = 0.163;
1157      dits[1] = 0.01;
1158      dits[2] = 24;
1159      gMC->Gsvolu("I133", "BOX ", idtmed[253], dits, 3);   
1160
1161      dits[0] = 0.04;
1162      dits[1] = 0.06;
1163      dits[2] = 24;
1164      dits[3] = 0;
1165      dits[4] = 157.633;
1166      gMC->Gsvolu("I132", "TUBS", idtmed[253], dits, 5); 
1167
1168      dits[0] = 0.2497;
1169      dits[1] = 0.01;
1170      dits[2] = 24;
1171      gMC->Gsvolu("I131", "BOX ", idtmed[253], dits, 3); 
1172
1173      dits[0] = 0.06;
1174      dits[1] = 0.08;
1175      dits[2] = 24;
1176      dits[3] = 0;
1177      dits[4] = 148.633;
1178      gMC->Gsvolu("I130", "TUBS", idtmed[253], dits, 5); 
1179
1180      dits[0] = 0.292;
1181      dits[1] = 0.01;
1182      dits[2] = 24;
1183      gMC->Gsvolu("I129", "BOX ", idtmed[253], dits, 3);  
1184
1185      dits[0] = 0.163;
1186      dits[1] = 0.01;
1187      dits[2] = 24;
1188      gMC->Gsvolu("I128", "BOX ", idtmed[253], dits, 3);  
1189
1190      dits[0] = 0.04;
1191      dits[1] = 0.06;
1192      dits[2] = 24;
1193      dits[3] = 0;
1194      dits[4] = 161.297;
1195      gMC->Gsvolu("I126", "TUBS", idtmed[253], dits, 5);
1196
1197      dits[0] = 0.2433;
1198      dits[1] = 0.01;
1199      dits[2] = 24;
1200      gMC->Gsvolu("I125", "BOX ", idtmed[253], dits, 3);  
1201
1202      dits[0] = 0.06;
1203      dits[1] = 0.08;
1204      dits[2] = 24;
1205      dits[3] = 0;
1206      dits[4] = 42.883;
1207      gMC->Gsvolu("I124", "TUBS", idtmed[253], dits, 5);  
1208
1209      di103[0] = 0.793;
1210      di103[1] = ddet1+dchip1;
1211      di103[2] = 3.536;
1212      gMC->Gsvolu("I103", "BOX ", idtmed[254], di103, 3); // contains det and chip  
1213                                                          // layer 1
1214      dits[0] = 0.793;
1215      dits[1] = 0.475;  //0.685; 0.015
1216      dits[2] = 2.5;
1217      gMC->Gsvolu("I105", "BOX ", idtmed[290], dits, 3);  // end-ladder electr.
1218
1219      di104[0] = 0.843;
1220      di104[1] = dbus;
1221      di104[2] = 14.344;
1222      gMC->Gsvolu("I104", "BOX ", idtmed[275], di104, 3);  // bus for both layers
1223
1224      di1d3[0] = 0.793;
1225      di1d3[1] = ddet2+dchip2;
1226      di1d3[2] = 3.536;
1227      gMC->Gsvolu("I1D3", "BOX ", idtmed[254], di1d3, 3); // contains det and chip
1228                                                          // layer 2
1229      dits[0] = 0.793;
1230      dits[0] = 0.06;
1231      dits[1] = 0.08;
1232      dits[2] = 24;
1233      dits[3] = 0;
1234      dits[4] = 80;
1235      gMC->Gsvolu("I112", "TUBS", idtmed[253], dits, 5);  
1236
1237      dits[0] = 0.04;
1238      dits[1] = 0.06;
1239      dits[2] = 24;
1240      dits[3] = 0;
1241      dits[4] = 80;
1242      gMC->Gsvolu("I111", "TUBS", idtmed[253], dits, 5);  
1243
1244      dits[0] = 0.15;
1245      dits[1] = 0.0146;
1246      dits[2] = 24;
1247      gMC->Gsvolu("I118", "BOX ", idtmed[273], dits, 3);  
1248
1249      dits[0] = 0.1315;
1250      dits[1] = 0.01;
1251      dits[2] = 24;
1252      gMC->Gsvolu("I110", "BOX ", idtmed[253], dits, 3);  
1253
1254      dits[0] = 0.025;
1255      dits[1] = 0.035;
1256      dits[2] = 24;
1257      dits[3] = 0;
1258      dits[4] = 180;
1259      gMC->Gsvolu("I114", "TUBS", idtmed[264], dits, 5);  
1260
1261      if (fluid == 1) {
1262         dits[0] = 0;
1263         dits[1] = 0.025;
1264         dits[2] = 24;
1265         dits[3] = 0;
1266         dits[4] = 180;
1267         gMC->Gsvolu("I115", "TUBS", idtmed[211], dits, 5); // set water as cooling fluid   
1268      } else {
1269         dits[0] = 0;
1270         dits[1] = 0.025;
1271         dits[2] = 24;
1272         dits[3] = 0;
1273         dits[4] = 180;
1274         gMC->Gsvolu("I115", "TUBS", idtmed[212], dits, 5); // set freon as cooling fluid       
1275      }
1276      
1277      dits[0] = 0.063;
1278      dits[1] = 0.035;
1279      dits[2] = 24;
1280      gMC->Gsvolu("I116", "BOX ", idtmed[264], dits, 3); 
1281
1282      di102[0] = 0.793;
1283      di102[1] = dchip1;
1284      di102[2] = 0.68;
1285      gMC->Gsvolu("I102", "BOX ", idtmed[201], di102, 3);   // chip layer 1
1286           
1287      di1d2[0] = 0.793;
1288      di1d2[1] = dchip2;
1289      di1d2[2] = 0.68;
1290      gMC->Gsvolu("I1D2", "BOX ", idtmed[201], di1d2, 3);   // chip      layer 2
1291
1292      di101[0] = 0.705;
1293      di101[1] = ddet1;
1294      di101[2] = 3.536;
1295      gMC->Gsvolu("I101", "BOX ", idtmed[250], di101, 3);   // contains detector 
1296                                                            // layer 1
1297      di1d1[0] = 0.705;
1298      di1d1[1] = ddet2;
1299      di1d1[2] = 3.536;
1300      gMC->Gsvolu("I1D1", "BOX ", idtmed[250], di1d1, 3);   // contains detector 
1301                                                            // layer 2
1302      if (fluid == 1) {
1303         dits[0] = 0.063;
1304         dits[1] = 0.025;
1305         dits[2] = 24;
1306         gMC->Gsvolu("I117", "BOX ", idtmed[211], dits, 3); // set water as cooling fuid
1307      } else {
1308         dits[0] = 0.063;
1309         dits[1] = 0.025;
1310         dits[2] = 24;
1311         gMC->Gsvolu("I117", "BOX ", idtmed[212], dits, 3); // set freon as cooling fluid
1312      }
1313
1314      dits1[0] = 0.64;
1315      dits1[1] = ddet1;
1316      dits1[2] = 3.48;
1317      gMC->Gsvolu("ITS1", "BOX ", idtmed[200], dits1, 3);   // detector layer 1
1318
1319      dits2[0] = 0.64;
1320      dits2[1] = ddet2;
1321      dits2[2] = 3.48;
1322      gMC->Gsvolu("ITS2", "BOX ", idtmed[200], dits2, 3);   // detector layer 2
1323
1324      dits[0] = 3.701;
1325      dits[1] = 7.699;
1326      dits[2] = 4;
1327      dits[3] = 57.1;
1328      dits[4] = 99.9;  
1329      gMC->Gsvolu("I650", "TUBS", idtmed[254], dits, 5);  // was I150 in old geom.
1330
1331      dits[0] = 0;
1332      dits[1] = 0.5;
1333      dits[2] = 1.5;
1334      gMC->Gsvolu("I676", "TUBE", idtmed[274], dits, 3); // was I176 in old geom.
1335
1336      dits[0] = 0;
1337      dits[1] = 0.18;
1338      dits[2] = 0.8;
1339      gMC->Gsvolu("I673", "TUBE", idtmed[274], dits, 3); // was I173 in old geom.
1340
1341      dits[0] = 0;
1342      dits[1] = 0.18;
1343      dits[2] = 3;
1344      gMC->Gsvolu("I671", "TUBE", idtmed[274], dits, 3); // was I171 in old geom.
1345
1346      dits[0] = 0;
1347      dits[1] = 0.075;
1348      dits[2] = 0.8;
1349      gMC->Gsvolu("I669", "TUBE", idtmed[264], dits, 3); // was I169 in old geom.
1350
1351      dits[0] = 3.5;
1352      dits[1] = 5.6;
1353      dits[2] = 0.55;
1354      dits[3] = 0;
1355      dits[4] = 38;
1356      gMC->Gsvolu("I667", "TUBS", idtmed[263], dits, 5); // was I167 in old geom.
1357
1358      dits[0] = 6.6;
1359      dits[1] = 7.6;
1360      dits[2] = 0.5;
1361      dits[3] = 0;
1362      dits[4] = 9;
1363      gMC->Gsvolu("I666", "TUBS", idtmed[263], dits, 5); // was I166 in old geom.
1364
1365      dits[0] = 0.26;
1366      dits[1] = 0.32;
1367      dits[2] = 0.55;
1368      gMC->Gsvolu("I678", "TUBE", idtmed[263], dits, 3); // was I178 in old geom.
1369
1370      if (fluid == 1) {
1371         dits[0] = 0;
1372         dits[1] = 0.3;
1373         dits[2] = 1.5;
1374         gMC->Gsvolu("I677", "TUBE", idtmed[211], dits, 3); // set water as cooling fluid
1375                                                            // was I177 in old geom.
1376      } else {
1377          dits[0] = 0;
1378         dits[1] = 0.3;
1379         dits[2] = 1.5;
1380         gMC->Gsvolu("I677", "TUBE", idtmed[212], dits, 3); // set freon as cooling fluid
1381                                                            // was I177 in old geom.    
1382      }
1383      
1384      dits[0] = 0.07;
1385      dits[1] = 0.125;
1386      dits[2] = 0.3;
1387      gMC->Gsvolu("I675", "TUBE", idtmed[263], dits, 3); // was I175 in old geom.
1388
1389      if (fluid == 1) {
1390         dits[0] = 0;
1391         dits[1] = 0.1;
1392         dits[2] = 0.8;
1393         gMC->Gsvolu("I674", "TUBE", idtmed[211], dits, 3); // set water as cooling fluid
1394                                                            // was I174 in old geom.
1395      } else {
1396         dits[0] = 0;
1397         dits[1] = 0.1;
1398         dits[2] = 0.8;
1399         gMC->Gsvolu("I674", "TUBE", idtmed[212], dits, 3); // set freon as cooling fluid
1400                                                            // was I174 in old geom.     
1401      }
1402      
1403      if (fluid == 1) {
1404         dits[0] = 0;
1405         dits[1] = 0.1;
1406         dits[2] = 3;
1407         gMC->Gsvolu("I672", "TUBE", idtmed[211], dits, 3); // set water as cooling fluid
1408                                                            // was I172 in old geom.
1409      } else {
1410         dits[0] = 0;
1411         dits[1] = 0.1;
1412         dits[2] = 3;
1413         gMC->Gsvolu("I672", "TUBE", idtmed[212], dits, 3); // set freon as cooling fluid
1414                                                            // was I172 in old geom.        
1415      }
1416      
1417      if (fluid == 1) {     
1418         dits[0] = 0;
1419         dits[1] = 0.0746;
1420         dits[2] = 0.8;
1421         gMC->Gsvolu("I670", "TUBE", idtmed[211], dits, 3); // set water as cooling fluid
1422                                                            // was I170 in old geom.
1423      } else {
1424         dits[0] = 0;
1425         dits[1] = 0.0746;
1426         dits[2] = 0.8;
1427         gMC->Gsvolu("I670", "TUBE", idtmed[212], dits, 3); // set freon as cooling fluid
1428                                                            // was I170 in old geom.     
1429      }
1430      
1431      if (fluid == 1) {     
1432         dits[0] = 3.7;
1433         dits[1] = 5.4;
1434         dits[2] = 0.35;
1435         dits[3] = 2;
1436         dits[4] = 36;
1437         gMC->Gsvolu("I668", "TUBS", idtmed[211], dits, 5); // set water as cooling fluid
1438                                                            // was I168 in old geom.
1439      } else {
1440         dits[0] = 3.7;
1441         dits[1] = 5.4;
1442         dits[2] = 0.35;
1443         dits[3] = 2;
1444         dits[4] = 36;
1445         gMC->Gsvolu("I668", "TUBS", idtmed[212], dits, 5); // set freon as cooling fluid
1446                                                            // was I168 in old geom.
1447      }
1448
1449
1450   }
1451
1452   // --- Define SPD (option 'b') volumes ----------------------------
1453   
1454   // SPD - option 'b' 
1455   // (this is the default)
1456
1457   if (option == 2) {
1458   
1459      dits[0] = 3.7;
1460      dits[1] = 7.75;
1461      dits[2] = 26.1;
1462      gMC->Gsvolu("IT12", "TUBE", idtmed[254], dits, 3);   
1463
1464      dits[0] = 3.7;
1465      dits[1] = 7.7;
1466      dits[2] = 24;
1467      dits[3] = 57;
1468      dits[4] = 100;
1469      gMC->Gsvolu("I12B", "TUBS", idtmed[254], dits, 5);   // sector
1470
1471      di10b[0] = 0.843;
1472      di10b[1] = ddet1+dchip1+dbus+0.0025;  
1473      di10b[2] = 19.344;
1474      gMC->Gsvolu("I10B", "BOX ", idtmed[254], di10b, 3);   // mother volume 
1475                                                                 // on layer 1
1476
1477      di20b[0] = 0.843;
1478      di20b[1] = ddet2+dchip2+dbus+0.0025;   
1479      di20b[2] = 19.344;
1480      gMC->Gsvolu("I20B", "BOX ", idtmed[254], di20b, 3);   // mother volume
1481                                                                 // layer 2
1482
1483      dits[0] = 1.3673;
1484      dits[1] = 0.01;
1485      dits[2] = 24;
1486      gMC->Gsvolu("I123", "BOX ", idtmed[253], dits, 3);
1487
1488      dits[0] = 0.06;
1489      dits[1] = 0.08;
1490      dits[2] = 24;
1491      dits[3] = -36.79;
1492      dits[4] = 21.834;
1493      gMC->Gsvolu("I121", "TUBS", idtmed[253], dits, 5);  
1494
1495      dits[0] = 0.1253;
1496      dits[1] = 0.01;
1497      dits[2] = 24;
1498      gMC->Gsvolu("I122", "BOX ", idtmed[253], dits, 3);  
1499
1500      dits[0] = 0.04;
1501      dits[1] = 0.06 ;
1502      dits[2] = 24;
1503      dits[3] = 126.79;
1504      dits[4] = 270;
1505      gMC->Gsvolu("I120", "TUBS", idtmed[253], dits, 5);  
1506
1507      dits[0] = 0.1134;
1508      dits[1] = 0.01;
1509      dits[2] = 24;
1510      gMC->Gsvolu("I144", "BOX ", idtmed[253], dits, 3);  
1511
1512      dits[0] = 0.25;
1513      dits[1] = 0.06;
1514      dits[2] = 24;
1515      gMC->Gsvolu("I113", "BOX ", idtmed[254], dits, 3);  
1516
1517      dits[0] = 0.077;
1518      dits[1] = 0.01;
1519      dits[2] = 24;
1520      gMC->Gsvolu("I143", "BOX ", idtmed[253], dits, 3);   
1521
1522      dits[0] = 0.04;
1523      dits[1] = 0.06;
1524      dits[2] = 24;
1525      dits[3] = 0;
1526      dits[4] = 90;
1527      gMC->Gsvolu("I142", "TUBS", idtmed[253], dits, 5); 
1528
1529      dits[0] = 0.0695;
1530      dits[1] = 0.01;
1531      dits[2] = 24;
1532      gMC->Gsvolu("I141", "BOX ", idtmed[253], dits, 3);  
1533
1534      dits[0] = 0.06;
1535      dits[1] = 0.08;
1536      dits[2] = 24;
1537      dits[3] = 0;
1538      dits[4] = 108;
1539      gMC->Gsvolu("I140", "TUBS", idtmed[253], dits, 5);  
1540
1541      dits[0] = 0.1835;
1542      dits[1] = 0.01;
1543      dits[2] = 24;
1544      gMC->Gsvolu("I139", "BOX ", idtmed[253], dits, 3);
1545
1546      dits[0] = 0.1894 ;
1547      dits[1] = 0.01;
1548      dits[2] = 24;
1549      gMC->Gsvolu("I138", "BOX ", idtmed[253], dits, 3);  
1550
1551      dits[0] = 0.04;
1552      dits[1] = 0.06;
1553      dits[2] = 24;
1554      dits[3] = 0;
1555      dits[4] = 75.261;
1556      gMC->Gsvolu("I137", "TUBS", idtmed[253], dits, 5);  
1557
1558      dits[0] = 1.3401;
1559      dits[1] = 0.01;
1560      dits[2] = 24;
1561      gMC->Gsvolu("I136", "BOX ", idtmed[253], dits, 3);  
1562
1563      dits[0] = 0.05;
1564      dits[1] = 0.07;
1565      dits[2] = 24;
1566      dits[3] = 0;
1567      dits[4] = 72.739;
1568      gMC->Gsvolu("I135", "TUBS", idtmed[253], dits, 5);  
1569
1570      dits[0] = 0.1193;
1571      dits[1] = 0.01;
1572      dits[2] = 24;
1573      gMC->Gsvolu("I134", "BOX ", idtmed[253], dits, 3);    
1574
1575      dits[0] = 0.163;
1576      dits[1] = 0.01;
1577      dits[2] = 24;
1578      gMC->Gsvolu("I133", "BOX ", idtmed[253], dits, 3);   
1579
1580      dits[0] = 0.04;
1581      dits[1] = 0.06;
1582      dits[2] = 24;
1583      dits[3] = 0;
1584      dits[4] = 157.633;
1585      gMC->Gsvolu("I132", "TUBS", idtmed[253], dits, 5); 
1586
1587      dits[0] = 0.2497;
1588      dits[1] = 0.01;
1589      dits[2] = 24;
1590      gMC->Gsvolu("I131", "BOX ", idtmed[253], dits, 3); 
1591
1592      dits[0] = 0.06;
1593      dits[1] = 0.08;
1594      dits[2] = 24;
1595      dits[3] = 0;
1596      dits[4] = 148.633;
1597      gMC->Gsvolu("I130", "TUBS", idtmed[253], dits, 5); 
1598
1599      dits[0] = 0.292;
1600      dits[1] = 0.01;
1601      dits[2] = 24;
1602      gMC->Gsvolu("I129", "BOX ", idtmed[253], dits, 3);  
1603
1604      dits[0] = 0.163;
1605      dits[1] = 0.01;
1606      dits[2] = 24;
1607      gMC->Gsvolu("I128", "BOX ", idtmed[253], dits, 3);  
1608
1609      dits[0] = 0.04;
1610      dits[1] = 0.06;
1611      dits[2] = 24;
1612      dits[3] = 0;
1613      dits[4] = 161.297;
1614      gMC->Gsvolu("I126", "TUBS", idtmed[253], dits, 5);
1615
1616      dits[0] = 0.2433;
1617      dits[1] = 0.01;
1618      dits[2] = 24;
1619      gMC->Gsvolu("I125", "BOX ", idtmed[253], dits, 3);  
1620
1621      dits[0] = 0.06;
1622      dits[1] = 0.08;
1623      dits[2] = 24;
1624      dits[3] = 0;
1625      dits[4] = 42.883;
1626      gMC->Gsvolu("I124", "TUBS", idtmed[253], dits, 5);  
1627
1628      dits[0] = 0.793;
1629      dits[1] = 0.475 ;  //0.685; 0.015
1630      dits[2] = 2.5;
1631      gMC->Gsvolu("I105", "BOX ", idtmed[290], dits, 3);  
1632
1633      di107[0] = 0.793;
1634      di107[1] = ddet1+dchip1;
1635      di107[2] = 3.536;
1636      gMC->Gsvolu("I107", "BOX ", idtmed[254], di107, 3); // contains det and chip   
1637                                                          // layer 1
1638      dits[0] = 0.705;
1639      dits[1] = 0.01;
1640      dits[2] = 2.5;
1641      gMC->Gsvolu("I109", "BOX ", idtmed[275], dits, 3);  
1642
1643      di108[0] = 0.705;
1644      di108[1] = dbus;
1645      di108[2] = 14.344;
1646      gMC->Gsvolu("I108", "BOX ", idtmed[275], di108, 3); // bus for both layers 
1647
1648      di1d7[0] = 0.7975;
1649      di1d7[1] = ddet2+dchip2;   
1650      di1d7[2] = 3.536;
1651      gMC->Gsvolu("I1D7", "BOX ", idtmed[254], di1d7, 3); // contains det and chip
1652                                                          // layer 2
1653      dits[0] = 0.06;
1654      dits[1] = 0.08;
1655      dits[2] = 24;
1656      dits[3] = 0;
1657      dits[4] = 80;
1658      gMC->Gsvolu("I112", "TUBS", idtmed[253], dits, 5);  
1659
1660      dits[0] = 0.04;
1661      dits[1] = 0.06;
1662      dits[2] = 24;
1663      dits[3] = 0;
1664      dits[4] = 80;
1665      gMC->Gsvolu("I111", "TUBS", idtmed[253], dits, 5);  
1666
1667      dits[0] = 0.15;
1668      dits[1] = 0.0146;
1669      dits[2] = 24;
1670      gMC->Gsvolu("I118", "BOX ", idtmed[273], dits, 3);  
1671
1672      dits[0] = 0.1315;
1673      dits[1] = 0.01;
1674      dits[2] = 24;
1675      gMC->Gsvolu("I110", "BOX ", idtmed[253], dits, 3);  
1676
1677      dits[0] = 0.025;
1678      dits[1] = 0.035;
1679      dits[2] = 24;
1680      dits[3] = 0;
1681      dits[4] = 180;
1682      gMC->Gsvolu("I114", "TUBS", idtmed[264], dits, 5);  
1683
1684      if (fluid == 1) {
1685         dits[0] = 0;
1686         dits[1] = 0.025;
1687         dits[2] = 24;
1688         dits[3] = 0;
1689         dits[4] = 180;
1690         gMC->Gsvolu("I115", "TUBS", idtmed[211], dits, 5);  // set water as cooling fluid   
1691      } else {
1692         dits[0] = 0;
1693         dits[1] = 0.025;
1694         dits[2] = 24;
1695         dits[3] = 0;
1696         dits[4] = 180;
1697         gMC->Gsvolu("I115", "TUBS", idtmed[212], dits, 5);  // set freon as cooling fluid
1698      }
1699      
1700      dits[0] = 0.063;
1701      dits[1] = 0.035;
1702      dits[2] = 24;
1703      gMC->Gsvolu("I116", "BOX ", idtmed[264], dits, 3); 
1704
1705      di106[0] = 0.7975;
1706      di106[1] = dchip1;   
1707      di106[2] = 0.68;
1708      gMC->Gsvolu("I106", "BOX ", idtmed[201], di106, 3);   // chip layer 1
1709
1710      di1d6[0] = 0.7975;
1711      di1d6[1] = dchip2;   
1712      di1d6[2] = 0.68;
1713      gMC->Gsvolu("I1D6", "BOX ", idtmed[201], di1d6, 3);   // chip layer 2
1714
1715      di101[0] = 0.705;
1716      di101[1] = ddet1;
1717      di101[2] = 3.536;
1718      gMC->Gsvolu("I101", "BOX ", idtmed[250], di101, 3);  // contains detector  
1719                                                           // layer 1
1720      di1d1[0] = 0.705;
1721      di1d1[1] = ddet2;   
1722      di1d1[2] = 3.536;
1723      gMC->Gsvolu("I1D1", "BOX ", idtmed[250], di1d1, 3);  // contains detector  
1724                                                           // layer 2
1725    
1726      if (fluid == 1) {
1727         dits[0] = 0.063;
1728         dits[1] = 0.025;
1729         dits[2] = 24;
1730         gMC->Gsvolu("I117", "BOX ", idtmed[211], dits, 3); // set water as cooling fluid
1731      } else {
1732         dits[0] = 0.063;
1733         dits[1] = 0.025;
1734         dits[2] = 24;
1735         gMC->Gsvolu("I117", "BOX ", idtmed[212], dits, 3); // set freon as cooling fluid
1736      }
1737
1738      dits1[0] = 0.64;
1739      dits1[1] = ddet1;
1740      dits1[2] = 3.48;
1741      gMC->Gsvolu("ITS1", "BOX ", idtmed[200], dits1, 3);   // detector layer 1
1742
1743      dits2[0] = 0.64;
1744      dits2[1] = ddet2;  
1745      dits2[2] = 3.48;
1746      gMC->Gsvolu("ITS2", "BOX ", idtmed[200], dits2, 3);   // detector layer 2
1747
1748      dits[0] = 3.701;
1749      dits[1] = 7.699;
1750      dits[2] = 4;
1751      dits[3] = 57.1;
1752      dits[4] = 99.9;  
1753      gMC->Gsvolu("I650", "TUBS", idtmed[254], dits, 5);  // was I150 in old geom.
1754
1755      dits[0] = 0;
1756      dits[1] = 0.5;
1757      dits[2] = 1.5;
1758      gMC->Gsvolu("I676", "TUBE", idtmed[274], dits, 3); // was I176 in old geom.
1759
1760      dits[0] = 0;
1761      dits[1] = 0.18;
1762      dits[2] = 0.8;
1763      gMC->Gsvolu("I673", "TUBE", idtmed[274], dits, 3); // was I173 in old geom.
1764
1765      dits[0] = 0;
1766      dits[1] = 0.18;
1767      dits[2] = 3;
1768      gMC->Gsvolu("I671", "TUBE", idtmed[274], dits, 3); // was I171 in old geom.
1769
1770      dits[0] = 0;
1771      dits[1] = 0.075;
1772      dits[2] = 0.8;
1773      gMC->Gsvolu("I669", "TUBE", idtmed[264], dits, 3); // was I169 in old geom.
1774
1775      dits[0] = 3.5;
1776      dits[1] = 5.6;
1777      dits[2] = 0.55;
1778      dits[3] = 0;
1779      dits[4] = 38;
1780      gMC->Gsvolu("I667", "TUBS", idtmed[263], dits, 5); // was I167 in old geom.
1781
1782      dits[0] = 6.6;
1783      dits[1] = 7.6;
1784      dits[2] = 0.5;
1785      dits[3] = 0;
1786      dits[4] = 9;
1787      gMC->Gsvolu("I666", "TUBS", idtmed[263], dits, 5); // was I166 in old geom.
1788
1789      dits[0] = 0.26;
1790      dits[1] = 0.32;
1791      dits[2] = 0.55;
1792      gMC->Gsvolu("I678", "TUBE", idtmed[263], dits, 3); // was I178 in old geom.
1793
1794      if (fluid == 1) {
1795         dits[0] = 0;
1796         dits[1] = 0.3;
1797         dits[2] = 1.5;
1798         gMC->Gsvolu("I677", "TUBE", idtmed[211], dits, 3); //set water as cooling fluid
1799                                                            // was I177 in old geom.
1800      } else {
1801         dits[0] = 0;
1802         dits[1] = 0.3;
1803         dits[2] = 1.5;
1804         gMC->Gsvolu("I677", "TUBE", idtmed[212], dits, 3); //set freon as cooling fluid
1805                                                            // was I177 in old geom.     
1806      }
1807
1808      dits[0] = 0.07;
1809      dits[1] = 0.125;
1810      dits[2] = 0.3;
1811      gMC->Gsvolu("I675", "TUBE", idtmed[263], dits, 3); // was I175 in old geom.
1812
1813      if (fluid == 1) {
1814         dits[0] = 0;
1815         dits[1] = 0.1;
1816         dits[2] = 0.8;
1817         gMC->Gsvolu("I674", "TUBE", idtmed[211], dits, 3); //set water as cooling fluid
1818                                                            // was I174 in old geom.
1819      } else {
1820         dits[0] = 0;
1821         dits[1] = 0.1;
1822         dits[2] = 0.8;
1823         gMC->Gsvolu("I674", "TUBE", idtmed[212], dits, 3); //set freon as cooling fluid
1824                                                            // was I174 in old geom.     
1825      }
1826      
1827      if (fluid == 1) {
1828         dits[0] = 0;
1829         dits[1] = 0.1;
1830         dits[2] = 3;
1831         gMC->Gsvolu("I672", "TUBE", idtmed[211], dits, 3); //set water as cooling fluid
1832                                                            // was I172 in old geom.
1833      } else {
1834         dits[0] = 0;
1835         dits[1] = 0.1;
1836         dits[2] = 3;
1837         gMC->Gsvolu("I672", "TUBE", idtmed[212], dits, 3); //set freon as cooling fluid
1838                                                            // was I172 in old geom.     
1839      }
1840      
1841      if (fluid == 1) {
1842         dits[0] = 0;
1843         dits[1] = 0.0746;
1844         dits[2] = 0.8;
1845         gMC->Gsvolu("I670", "TUBE", idtmed[211], dits, 3); //set water as cooling fluid
1846                                                            // was I170 in old geom.
1847      } else {
1848         dits[0] = 0;
1849         dits[1] = 0.0746;
1850         dits[2] = 0.8;
1851         gMC->Gsvolu("I670", "TUBE", idtmed[212], dits, 3); //set freon as cooling fluid
1852                                                            // was I170 in old geom.     
1853      }
1854      
1855      if (fluid == 1) {
1856         dits[0] = 3.7;
1857         dits[1] = 5.4;
1858         dits[2] = 0.35;
1859         dits[3] = 2;
1860         dits[4] = 36;
1861         gMC->Gsvolu("I668", "TUBS", idtmed[211], dits, 5); //set water as cooling fluid
1862                                                            // was I168 in old geom.
1863      } else {
1864         dits[0] = 3.7;
1865         dits[1] = 5.4;
1866         dits[2] = 0.35;
1867         dits[3] = 2;
1868         dits[4] = 36;
1869         gMC->Gsvolu("I668", "TUBS", idtmed[212], dits, 5); //set freon as cooling fluid
1870                                                            // was I168 in old geom.     
1871      }
1872      
1873
1874   }
1875
1876   // --- Define SDD volumes ------------------------------------------
1877
1878   
1879   cos30 = cos(30.*3.14159/180.);
1880   sin30 = sin(30.*3.14159/180.);
1881
1882   
1883   dits[0] = 0;
1884   dits[1] = 360;
1885   dits[2] = 6;
1886   dits[3] = -34.6; 
1887   dits[4] = 23.49;
1888   dits[5] = 28;
1889   dits[6] = -23.65; 
1890   dits[7] = 23.49;
1891   dits[8] = 28;
1892   dits[9] = -23.65;  
1893   dits[10] = 14.59; 
1894   dits[11] = 28;
1895   dits[12] = 23.65;   
1896   dits[13] = 14.59;
1897   dits[14] = 28;
1898   dits[15] = 23.65;    
1899   dits[16] = 23.49;
1900   dits[17] = 28;
1901   dits[18] = 34.6;  
1902   dits[19] = 23.49;
1903   dits[20] = 28;
1904   gMC->Gsvolu("IT34", "PCON", idtmed[209], dits, 21);  
1905
1906   // block of the SDD electronics and related ladder frame 
1907   I018dits[0] = 3.2;
1908   I018dits[1] = 2;
1909   I018dits[2] = 3.65;
1910   gMC->Gsvolu("I018", "BOX ", idtmed[209], I018dits, 3);  
1911
1912   // block of the SDD end ladder 
1913   I024dits[0] = 3.2;
1914   I024dits[1] = 2;
1915   I024dits[2] = 2.725;
1916   gMC->Gsvolu("I024", "BOX ", idtmed[209], I024dits, 3);  
1917
1918   // ladder frame of layer 3 - F.T. March,7-2001
1919   I047dits[0] = I018dits[0];
1920   I047dits[1] = I018dits[1];
1921   I047dits[2] = 6*I018dits[2] + 2*I024dits[2]; 
1922   gMC->Gsvolu("I047", "BOX ", idtmed[209], I047dits, 3);  
1923
1924   // ladder frame of layer 4 - F.T. March,7-2001
1925   I048dits[0] = I018dits[0];
1926   I048dits[1] = I018dits[1];
1927   I048dits[2] = 8*I018dits[2] + 2*I024dits[2]; 
1928   gMC->Gsvolu("I048", "BOX ", idtmed[209], I048dits, 3);  
1929
1930
1931   // global SDD volume (sensitive + insensitive) 
1932   I302dits[0] = 3.6250;
1933   I302dits[1] = 0.0150;
1934   I302dits[2] = 4.3794;
1935   gMC->Gsvolu("I302", "BOX ", idtmed[278], I302dits, 3);
1936
1937   // Like for I302 - F.T. March,7-2001
1938   I402dits[0] = 3.6250;
1939   I402dits[1] = 0.0150;
1940   I402dits[2] = 4.3794;
1941   gMC->Gsvolu("I402", "BOX ", idtmed[278], I402dits, 3);  
1942
1943   // SDD ladder of layer 3 - F.T. March,7-2001
1944   I004dits[0] = I302dits[0]+0.005;
1945   I004dits[1] = 2*I302dits[1]+Y_SDD_sep/2.;
1946   I004dits[2] = TMath::Abs(Z_SDD_lay3[0]);
1947   if (I004dits[2] < TMath::Abs(Z_SDD_lay3[5])) {
1948     I004dits[2] = TMath::Abs(Z_SDD_lay3[5]);
1949   }
1950   I004dits[2] = I004dits[2] + I302dits[2];
1951   gMC->Gsvolu("I004", "BOX ", idtmed[209], I004dits, 3);  
1952
1953   // SDD ladder of layer 4 - F.T. March,7-2001
1954   I005dits[0] = I402dits[0]+0.005;
1955   I005dits[1] = 2*I402dits[1]+Y_SDD_sep/2.;
1956   I005dits[2] = TMath::Abs(Z_SDD_lay4[0]);
1957   if (I005dits[2] < TMath::Abs(Z_SDD_lay4[7])) {
1958     I005dits[2] = TMath::Abs(Z_SDD_lay4[7]);
1959   }
1960   I005dits[2] = I005dits[2] + I402dits[2];
1961   gMC->Gsvolu("I005", "BOX ", idtmed[209], I005dits, 3);  
1962
1963
1964   // -- block of the SDD ladder foot and end ladder
1965
1966   // ladder foot mother volume
1967   I028dits[0] = 3.0000;
1968   I028dits[1] = 0.4000;
1969   I028dits[2] = 0.9000;
1970   gMC->Gsvolu("I028", "BOX ", idtmed[224], I028dits, 3);  
1971
1972   // positioning-box #1 at SDD end-ladder - F.T. March,7-2001
1973   I420dits[0] = 0.4500;
1974   I420dits[1] = 0.4000;
1975   I420dits[2] = 0.4500;
1976   gMC->Gsvolu("I420", "BOX ", idtmed[264], I420dits, 3);  
1977
1978   // positioning-box #2 at SDD end-ladder - F.T. March,7-2001
1979   I421dits[0] = 0.;
1980   I421dits[1] = 0.25;
1981   I421dits[2] = I420dits[1];
1982   gMC->Gsvolu("I421", "TUBE", idtmed[209], I421dits, 3);  
1983
1984   // reference ruby-sphere at SDD end-ladder - F.T. March,7-2001 
1985   I422dits[0] = 0.0000;
1986   I422dits[1] = 0.2000;
1987   I422dits[2] = 0.0000;
1988   I422dits[3] = 180.00;
1989   I422dits[4] = 0.0000;
1990   I422dits[5] = 360.00;
1991   gMC->Gsvolu("I422", "SPHE", idtmed[277], I422dits, 6);  
1992
1993   // support for ruby-sphere (I422) - F.T. March,7-2001
1994   I423dits[0] = 0.0000;
1995   I423dits[1] = 0.1000;
1996   I423dits[2] = (I420dits[1]-I422dits[1])/2.;
1997   gMC->Gsvolu("I423", "TUBE", idtmed[264], I423dits, 3);  
1998
1999   // passage for HV microcables - F.T. March,7-2001
2000   I424dits[0] = 1.5000;
2001   I424dits[1] = 0.1500;
2002   I424dits[2] = I421dits[2];
2003   gMC->Gsvolu("I424", "BOX ", idtmed[209], I424dits, 3);  
2004
2005   // HV microcables segment at the end ladder - F.T. March,7-2001
2006   I425dits[0] = 1.350000;
2007   I425dits[1] = 0.015250;
2008   I425dits[2] = I024dits[2];
2009   gMC->Gsvolu("I425", "BOX ", idtmed[279], I425dits, 3);  
2010
2011   // lower edge of SDD ladder frame at end-ladder - part 1
2012   dits[0] = 0.2;
2013   dits[1] = 0.1815;
2014   dits[2] = I024dits[2];
2015   dits[3] = 0.015;
2016   gMC->Gsvolu("I025", "TRD1", idtmed[208], dits, 4);  
2017
2018   // lower edge of SDD ladder frame at end-ladder - part 2
2019   dits[0] = 0.183;
2020   dits[1] = 0.165;
2021   dits[2] = I024dits[2];
2022   dits[3] = 0.015;
2023   gMC->Gsvolu("I026", "TRD1", idtmed[208], dits, 4);  
2024
2025   // new: for the 1st top rod of the structure 
2026   // at the end-ladder - F.T. March,7-2001
2027   I029dits[0] = 0.2;
2028   I029dits[1] = 0.1815;
2029   I029dits[2] = 1.0100;
2030   I029dits[3] = 0.015;
2031   gMC->Gsvolu("I029", "TRD1", idtmed[208], I029dits, 4);  
2032
2033   // new: for the 2nd top rod of the structure 
2034   // at the end-ladder - F.T. March,7-2001
2035   I030dits[0] = 0.1830;
2036   I030dits[1] = 0.1650;
2037   I030dits[2] = 1.0100;
2038   I030dits[3] = 0.0150;
2039   gMC->Gsvolu("I030", "TRD1", idtmed[208], I030dits, 4);  
2040
2041   // inox cooling tubes for the end ladder - F.T. March,7-2001
2042   I031dits[0] = 0.093;
2043   I031dits[1] = 0.1;
2044   I031dits[2] = I024dits[2];
2045   gMC->Gsvolu("I031", "TUBE", idtmed[264], I031dits, 3);  
2046
2047   if (fluid == 1) {
2048      // cooling water for the end ladder - F.T. March,7-2001
2049      I032dits[0] = 0;
2050      I032dits[1] = I031dits[0];
2051      I032dits[2] = I024dits[2];
2052      gMC->Gsvolu("I032", "TUBE", idtmed[211], I032dits, 3);  
2053   } else {
2054      // cooling freon for the end ladder - R.B. March,21-2001
2055      I032dits[0] = 0;
2056      I032dits[1] = I031dits[0];
2057      I032dits[2] = I024dits[2];
2058      gMC->Gsvolu("I032", "TUBE", idtmed[212], I032dits, 3);    
2059   }
2060   
2061   // -- block of the SDD ladder frame holding the electronics
2062
2063   // edge of the ladder frame - part 1
2064   dits[0] = 0.2;
2065   dits[1] = 0.182;
2066   dits[2] = 3.65;
2067   dits[3] = 0.015;
2068   gMC->Gsvolu("I019", "TRD1", idtmed[208], dits, 4);  
2069
2070   // edge of the ladder frame - part 2
2071   dits[0] = 0.183;
2072   dits[1] = 0.165;
2073   dits[2] = 3.65;
2074   dits[3] = 0.015;
2075   gMC->Gsvolu("I020", "TRD1", idtmed[208], dits, 4);  
2076
2077   // inclined segments of the ladder frame
2078   dits[0] = 2.23;
2079   dits[1] = 2.1;
2080   dits[2] = 0.05;
2081   dits[3] = 0.03;
2082   gMC->Gsvolu("I021", "TRD1", idtmed[208], dits, 4);  
2083
2084   // horiz.segments of the ladders, normal to ladder edges
2085   dits[0] = 2.1;
2086   dits[1] = 2;
2087   dits[2] = 0.06;
2088   dits[3] = 0.04;
2089   gMC->Gsvolu("I022", "TRD1", idtmed[208], dits, 4);  
2090
2091   // horiz.segments of the ladders, at 45 deg. to ladder edges
2092   dits[0] = 2.615;
2093   dits[1] = 2.465;
2094   dits[2] = 0.06;
2095   dits[3] = 0.04;
2096   gMC->Gsvolu("I023", "TRD1", idtmed[208], dits, 4);  
2097
2098   // supports of the ceramic pins holding the detectors
2099   dits[0] = 0.3;
2100   dits[1] = 0.05;
2101   dits[2] = 0.15;
2102   gMC->Gsvolu("I033", "BOX ", idtmed[208], dits, 3);  
2103
2104   // ceramic pins holding the detectors
2105   dits[0] = 0;
2106   dits[1] = 0.05;
2107   dits[2] = 0.225;
2108   gMC->Gsvolu("I034", "TUBE", idtmed[277], dits, 3);  
2109
2110   // holders of cooling tubes
2111   I035dits[0] = 0.1;
2112   I035dits[1] = 0.15;
2113   I035dits[2] = 0.2;
2114   gMC->Gsvolu("I035", "TUBE", idtmed[208], I035dits, 3);
2115
2116   // top holders of microcables
2117   dits[0] = 0.2;
2118   dits[1] = 0.01;
2119   dits[2] = 0.05;
2120   gMC->Gsvolu("I036", "BOX ", idtmed[208], dits, 3);  
2121
2122   // inox cooling tubes - F.T. March,7-2001
2123   I037dits[0] = 0.093;
2124   I037dits[1] = 0.1;
2125   I037dits[2] = I018dits[2];
2126   gMC->Gsvolu("I037", "TUBE", idtmed[264], I037dits, 3);
2127
2128   if (fluid == 1) {
2129      // cooling water - F.T. March,7-2001
2130      I038dits[0] = 0;
2131      I038dits[1] = I037dits[0];
2132      I038dits[2] = I018dits[2];
2133      gMC->Gsvolu("I038", "TUBE", idtmed[211], I038dits, 3);  
2134   } else {
2135      // cooling freon - R.B. March,21-2001
2136      I038dits[0] = 0;
2137      I038dits[1] = I037dits[0];
2138      I038dits[2] = I018dits[2];
2139      gMC->Gsvolu("I038", "TUBE", idtmed[212], I038dits, 3);    
2140   }
2141   // -- block of the SDD electronics (heat bridge, chips, hybrid, anode microcable)
2142
2143   // SDD heat bridge - F.T. March,7-2001
2144   I039dits[0] = 1.1000;
2145   I039dits[1] = 0.0087;
2146   I039dits[2] = 3.2500;
2147   gMC->Gsvolu("I039", "BOX ", idtmed[268], I039dits, 3);  
2148
2149   // SDD clip part 1
2150   dits[0] = 0.25;
2151   dits[1] = 0.01;
2152   dits[2] = I039dits[2];
2153   gMC->Gsvolu("I040", "BOX ", idtmed[268], dits, 3);  
2154
2155   // SDD clip part 2
2156   I041dits[0] = 0.1;
2157   I041dits[1] = 0.12;
2158   I041dits[2] = I039dits[2];
2159   I041dits[3] = 90;
2160   I041dits[4] = 320;
2161   gMC->Gsvolu("I041", "TUBS", idtmed[268], I041dits, 5);  
2162
2163
2164   // SDD PASCAL - F.T. March,7-2001
2165   I042dits[0] = 0.5000;
2166   I042dits[1] = 0.0175;
2167   I042dits[2] = 0.5000;
2168   gMC->Gsvolu("I042", "BOX ", idtmed[206], I042dits, 3);  
2169
2170   // SDD AMBRA - F.T. March,7-2001
2171   I043dits[0] = 0.3500;
2172   I043dits[1] = 0.0175;
2173   I043dits[2] = 0.5000;
2174   gMC->Gsvolu("I043", "BOX ", idtmed[206], I043dits, 3);  
2175
2176   // SDD capacitors - F.T. March,7-2001
2177   I051dits[0] = 0.1400;
2178   I051dits[1] = 0.0350;
2179   I051dits[2] = 0.0625;
2180   gMC->Gsvolu("I051", "BOX ", idtmed[276], I051dits, 3);  
2181
2182   // SDD hybrid circuit - F.T. March,7-2001
2183   I052dits[0] = 1.725000;
2184   I052dits[1] = 0.003743;
2185   I052dits[2] = I039dits[2];
2186   gMC->Gsvolu("I052", "BOX ", idtmed[281], I052dits, 3);
2187
2188   // SDD anode microcable : changed - F.T. March,7-2001
2189   I044dits[0] = I018dits[2];
2190   I044dits[1] = I039dits[2];
2191   I044dits[2] = 0.00084;
2192   I044dits[3] = (15.189149/(I044dits[0]+I044dits[1]))/2;
2193   gMC->Gsvolu("I044", "TRD1", idtmed[282], I044dits, 4);  
2194   volI044 = ((2*I044dits[0] + 2*I044dits[1]) * 2*I044dits[2])/2 * 2*I044dits[3];
2195
2196   // SDD electronics box - F.T. March,7-2001
2197   I050dits[1] = I039dits[1]+I052dits[1]+I051dits[1]+I044dits[2];
2198   I050dits[0] = I018dits[1]/cos(30.*3.14159/180.)-I050dits[1]*sin(30.*3.14159/180.);
2199   I050dits[2] = I018dits[2];
2200   gMC->Gsvolu("I050", "BOX ", idtmed[209], I050dits, 3);
2201
2202   // SDD sensitive volume
2203   dits[0] = 3.50850;
2204   dits[1] = 0.01499; // not 0.015 because it is included into I302 which is 0.015
2205   dits[2] = 3.76320;
2206   gMC->Gsvolu("ITS3", "BOX ", idtmed[200], dits, 3);  
2207
2208   // Like for ITS3 - F.T. March,7-2001
2209   dits[0] = 3.50850;
2210   dits[1] = 0.01499; // not 0.015 because it is included into I402 which is 0.015
2211   dits[2] = 3.76320;
2212   gMC->Gsvolu("ITS4", "BOX ", idtmed[200], dits, 3);  
2213
2214
2215   // --- Define SSD volumes ------------------------------------------
2216
2217     
2218   dits[0] = 0;
2219   dits[1] = 360;
2220   dits[2] = 6;
2221   dits[3] = -57.45;
2222   dits[4] = 43.6;
2223   dits[5] = 48;  
2224   dits[6] = -49.15; 
2225   dits[7] = 43.6;
2226   dits[8] = 48;  
2227   dits[9] = -49.15;  
2228   dits[10] = 36.9;
2229   dits[11] = 48;  
2230   dits[12] = 50.55;  
2231   dits[13] = 36.9;
2232   dits[14] = 48;  
2233   dits[15] = 50.55;  
2234   dits[16] = 43.6;
2235   dits[17] = 48;  
2236   dits[18] = 57.45;
2237   dits[19] = 43.6;
2238   dits[20] = 48;   
2239   gMC->Gsvolu("IT56", "PCON", idtmed[220], dits, 21);   
2240   
2241   dits[0] =  3.4;
2242   dits[1] = 1.955;
2243   dits[2] = 56.5; 
2244   gMC->Gsvolu("I570", "BOX ", idtmed[204], dits, 3);  
2245   
2246   dits[0] = 3.75;
2247   dits[1] = 0.045;
2248   dits[2] = 50.975;
2249   gMC->Gsvolu("I569", "BOX ", idtmed[204], dits, 3);  
2250   
2251   dits[0] = 3.4;
2252   dits[1] = 1.955;
2253   dits[2] = 47; 
2254   gMC->Gsvolu("I571", "BOX ", idtmed[204], dits, 3);  
2255   
2256   dits[0] = 3.75;
2257   dits[1] = 0.045;
2258   dits[2] = 43.3;  
2259   gMC->Gsvolu("I565", "BOX ", idtmed[204], dits, 3);  
2260   
2261   dits[0] = 3.4;
2262   dits[1] = 1.955;
2263   dits[2] = 3.15;
2264   gMC->Gsvolu("I553", "BOX ", idtmed[204], dits, 3);  
2265   
2266   dits[0] = 3.405;
2267   dits[1] = 1.955;
2268   dits[2] = 1.955;
2269   gMC->Gsvolu("I523", "BOX ", idtmed[204], dits, 3);  
2270   
2271   dits[0] = 3.75;
2272   dits[1] = 0.015;
2273   dits[2] = 2.1;
2274   gMC->Gsvolu("I566", "BOX ", idtmed[206], dits, 3); 
2275   
2276   dits[0] = 3.4;
2277   dits[1] = 1.955;
2278   dits[2] = 3.15;
2279   gMC->Gsvolu("I544", "BOX ", idtmed[204], dits, 3);  
2280   
2281   dits[0] = 3.41;
2282   dits[1] = 1.955;
2283   dits[2] = 1.955;
2284   gMC->Gsvolu("I516", "BOX ", idtmed[204], dits, 3);  
2285   
2286   dits[0] = 3.75;
2287   dits[1] = 0.015;
2288   dits[2] = 2.1;
2289   gMC->Gsvolu("I562", "BOX ", idtmed[206], dits, 3);   
2290   
2291   if (fluid == 1) {
2292      dits[0] = 0;
2293      dits[1] = 0.07;
2294      dits[2] = 3.15;
2295      gMC->Gsvolu("I559", "TUBE", idtmed[211], dits, 3);  // set water as cooling fluid
2296   } else {
2297      dits[0] = 0;
2298      dits[1] = 0.07;
2299      dits[2] = 3.15;
2300      gMC->Gsvolu("I559", "TUBE", idtmed[212], dits, 3);  // set freon as cooling fluid
2301   }
2302   
2303   dits[0] = 0.07;
2304   dits[1] = 0.1;
2305   dits[2] = 3.15;
2306   gMC->Gsvolu("I560", "TUBE", idtmed[210], dits, 3);  
2307   
2308   dits[0] = 0.225;
2309   dits[1] = 0.195;
2310   dits[2] = 3.15;
2311   dits[3] = 0.025;
2312   gMC->Gsvolu("I558", "TRD1", idtmed[203], dits, 4);  
2313   
2314   dits[0] = 0.25;
2315   dits[1] = 0.22;
2316   dits[2] = 3.15;
2317   dits[3] = 0.025;
2318   gMC->Gsvolu("I557", "TRD1", idtmed[203], dits, 4);  
2319   
2320   dits[0] = 2.17;
2321   dits[1] = 0.035;
2322   dits[2] = 0.05;
2323   gMC->Gsvolu("I556", "BOX ", idtmed[203], dits, 3);  
2324   
2325   dits[0] = 2 ;
2326   dits[1] = 0.035;
2327   dits[2] = 0.05;
2328   gMC->Gsvolu("I554", "BOX ", idtmed[203], dits, 3);  
2329   
2330   dits[0] = 2.675;
2331   dits[1] = 0.035;
2332   dits[2] = 0.05;
2333   gMC->Gsvolu("I555", "BOX ", idtmed[203], dits, 3); 
2334   
2335   dits[0] = 0.3;
2336   dits[1] = 0.15;
2337   dits[2] = 0.15;
2338   gMC->Gsvolu("I561", "BOX ", idtmed[203], dits, 3);  
2339   
2340   dits[0] = 0.025;
2341   dits[1] = 0.025;
2342   dits[2] = 0.05;
2343   gMC->Gsvolu("I519", "BOX ", idtmed[214], dits, 3);  
2344   
2345   dits[0] = 0.304;
2346   dits[1] = 0.0275;
2347   dits[2] = 0.432;
2348   gMC->Gsvolu("I521", "BOX ", idtmed[206], dits, 3);   
2349   
2350   dits[0] = 0.16;
2351   dits[1] = 0.08;
2352   dits[2] = 0.08;
2353   gMC->Gsvolu("I520", "BOX ", idtmed[214], dits, 3);  
2354   
2355   dits[0] = 3.4;
2356   dits[1] = 0.015;
2357   dits[2] = 0.525;
2358   gMC->Gsvolu("I518", "BOX ", idtmed[203], dits, 3);  
2359   
2360   dits[0] = 0.15;
2361   dits[1] = 0.105;
2362   dits[2] = 0.29;
2363   dits[3] = 0.08;
2364   gMC->Gsvolu("I522", "TRD1", idtmed[203], dits, 4);  
2365   
2366   dits[0] = 0.07;
2367   dits[1] = 0.1;
2368   dits[2] = 1.955;
2369   gMC->Gsvolu("I542", "TUBE", idtmed[210], dits, 3);  
2370   
2371   if (fluid == 1) {
2372      dits[0] = 0;
2373      dits[1] = 0.07;
2374      dits[2] = 1.955;
2375      gMC->Gsvolu("I541", "TUBE", idtmed[211], dits, 3);  // set water as cooling fluid 
2376   } else {
2377      dits[0] = 0;
2378      dits[1] = 0.07;
2379      dits[2] = 1.955;
2380      gMC->Gsvolu("I541", "TUBE", idtmed[212], dits, 3);  // set freon as cooling fluid
2381   }
2382   
2383   dits[0] = 0.3;
2384   dits[1] = 0.15;
2385   dits[2] = 0.15;
2386   gMC->Gsvolu("I543", "BOX ", idtmed[203], dits, 3);  
2387   
2388   dits[0] = 0.25;
2389   dits[1] = 0.22;
2390   dits[2] = 1.955;
2391   dits[3] = 0.025;
2392   gMC->Gsvolu("I537", "TRD1", idtmed[203], dits, 4); 
2393   
2394   dits[0] = 0.225;
2395   dits[1] = 0.195;
2396   dits[2] = 1.955;
2397   dits[4] = 0.025;
2398   gMC->Gsvolu("I538", "TRD1", idtmed[203], dits, 4);  
2399   
2400   dits[0] = 2.17;
2401   dits[1] = 0.035;
2402   dits[2] = 0.05;
2403   gMC->Gsvolu("I536", "BOX ", idtmed[203], dits, 3);  
2404   
2405   dits[0] = 2.675;
2406   dits[1] = 0.035;
2407   dits[2] = 0.05;
2408   gMC->Gsvolu("I535", "BOX ", idtmed[203], dits, 3);   
2409   
2410   dits[0] = 2;
2411   dits[1] = 0.035;
2412   dits[2] = 0.05;
2413   gMC->Gsvolu("I534", "BOX ", idtmed[203], dits, 3);  
2414   
2415   dits[0] = 0;
2416   dits[1] = 0.05;
2417   dits[2] = 0.17;
2418   gMC->Gsvolu("I540", "TUBE", idtmed[203], dits, 3);  
2419   
2420   dits[0] = 0;
2421   dits[1] = 0.05;
2422   dits[2] = 0.205;
2423   gMC->Gsvolu("I539", "TUBE", idtmed[203], dits, 3);  
2424   
2425   dits[0] = 3.65;
2426   dits[1] = 0.015;
2427   dits[2] = 2;
2428   gMC->Gsvolu("ITS6", "BOX ", idtmed[200], dits, 3);  
2429   
2430   if (fluid == 1) {
2431      dits[0] = 0;
2432      dits[1] = 0.07;
2433      dits[2] = 3.15;
2434      gMC->Gsvolu("I550", "TUBE", idtmed[211], dits, 3);  // set water as cooling fluid
2435   } else {
2436      dits[0] = 0;
2437      dits[1] = 0.07;
2438      dits[2] = 3.15;
2439      gMC->Gsvolu("I550", "TUBE", idtmed[212], dits, 3);  // set freon as cooling fluid
2440   }
2441   
2442   dits[0] = 0.07;
2443   dits[1] = 0.1;
2444   dits[2] = 3.15;
2445   gMC->Gsvolu("I551", "TUBE", idtmed[210], dits, 3);  
2446   
2447   dits[0] = 0.225;
2448   dits[1] = 0.195;
2449   dits[2] = 3.15;
2450   dits[3] = 0.025;
2451   gMC->Gsvolu("I549", "TRD1", idtmed[203], dits, 4); 
2452   
2453   dits[0] = 0.25;
2454   dits[1] = 0.22;
2455   dits[2] = 3.15;
2456   dits[3] = 0.025;
2457   gMC->Gsvolu("I548", "TRD1", idtmed[203], dits, 4);  
2458   
2459   dits[0] = 2.17;
2460   dits[1] = 0.035;
2461   dits[2] = 0.05;
2462   gMC->Gsvolu("I547", "BOX ", idtmed[203], dits, 3);  
2463   
2464   dits[0] = 2;
2465   dits[1] = 0.035;
2466   dits[2] = 0.05;
2467   gMC->Gsvolu("I545", "BOX ", idtmed[203], dits, 3);   
2468   
2469   dits[0] = 2.675;
2470   dits[1] = 0.035;
2471   dits[2] = 0.05;
2472   gMC->Gsvolu("I546", "BOX ", idtmed[203], dits, 3);  
2473   
2474   dits[0] = 0.3;
2475   dits[1] = 0.15;
2476   dits[2] = 0.15;
2477   gMC->Gsvolu("I552", "BOX ", idtmed[203], dits, 3);  
2478   
2479   dits[0] = 0.304;
2480   dits[1] = 0.0275;
2481   dits[2] = 0.4322;
2482   gMC->Gsvolu("I515", "BOX ", idtmed[206], dits, 3);  
2483   
2484   dits[0] = 0.025;
2485   dits[1] = 0.025;
2486   dits[2] = 0.05;
2487   gMC->Gsvolu("I513", "BOX ", idtmed[214], dits, 3);  
2488   
2489   dits[0] = 0.16;
2490   dits[1] = 0.08;
2491   dits[2] = 0.08;
2492   gMC->Gsvolu("I514", "BOX ", idtmed[214], dits, 3);  
2493   
2494   dits[0] = 3.4;
2495   dits[1] = 0.015;
2496   dits[2] = 0.525;
2497   gMC->Gsvolu("I512", "BOX ", idtmed[203], dits, 3);  
2498   
2499   dits[0] = 0.225;
2500   dits[1] = 0.195;
2501   dits[2] = 1.955;
2502   dits[3] = 0.025;
2503   gMC->Gsvolu("I528", "TRD1", idtmed[203], dits, 4); 
2504   
2505   dits[0] = 0.25;
2506   dits[1] = 0.22;
2507   dits[2] = 1.955;
2508   dits[3] = 0.025;
2509   gMC->Gsvolu("I527", "TRD1", idtmed[203], dits, 4);  
2510   
2511   dits[0] = 2.17;
2512   dits[1] = 0.035;
2513   dits[2] = 0.05;
2514   gMC->Gsvolu("I526", "BOX ", idtmed[203], dits, 3);  
2515   
2516   dits[0] = 2.675;
2517   dits[1] = 0.035;
2518   dits[2] = 0.05;
2519   gMC->Gsvolu("I525", "BOX ", idtmed[203], dits, 3);  
2520    
2521   dits[0] = 2;
2522   dits[1] = 0.035;
2523   dits[2] = 0.05;
2524   gMC->Gsvolu("I524", "BOX ", idtmed[203], dits, 3);  
2525    
2526   dits[0] = 0;
2527   dits[1] = 0.05;
2528   dits[2] = 0.205;
2529   gMC->Gsvolu("I529", "TUBE", idtmed[203], dits, 3);  
2530    
2531   dits[0] = 0;
2532   dits[1] = 0.05;
2533   dits[2] = 0.17;
2534   gMC->Gsvolu("I530", "TUBE", idtmed[203], dits, 3);  
2535    
2536   dits[0] = 0.15;
2537   dits[1] = 0.105;
2538   dits[2] = 0.29;
2539   dits[3] = 0.08;
2540   gMC->Gsvolu("I517", "TRD1", idtmed[203], dits, 4);  
2541   
2542   if (fluid == 1) {
2543      dits[0] = 0;
2544      dits[1] = 0.07;
2545      dits[2] = 1.955;
2546      gMC->Gsvolu("I531", "TUBE", idtmed[211], dits, 3);  // set water as cooling fluid
2547   } else {
2548      dits[0] = 0;
2549      dits[1] = 0.07;
2550      dits[2] = 1.955;
2551      gMC->Gsvolu("I531", "TUBE", idtmed[212], dits, 3);  // set freon as cooling fluid
2552   }
2553      
2554   dits[0] = 0.07;
2555   dits[1] = 0.1;
2556   dits[2] = 1.955;
2557   gMC->Gsvolu("I532", "TUBE", idtmed[210], dits, 3);  
2558  
2559   dits[0] = 0.3;
2560   dits[1] = 0.15;
2561   dits[2] = 0.15;
2562   gMC->Gsvolu("I533", "BOX ", idtmed[203], dits, 3);  
2563   
2564   dits[0] = 3.65;
2565   dits[1] = 0.015;
2566   dits[2] = 2;
2567   gMC->Gsvolu("ITS5", "BOX ", idtmed[200], dits, 3);  
2568
2569
2570
2571   // --- Define volumes of shield of SPD ----------------
2572
2573
2574   dits[0] = 8.37;
2575   dits[1] = 9.93;
2576   dits[2] = 25;
2577   gMC->Gsvolu("IC01", "TUBE", idtmed[289], dits, 3);   
2578
2579   dits[0] = 8.3;
2580   dits[1] = 9.995;
2581   dits[2] = 17.5/2.;
2582   gMC->Gsvolu("IC02", "TUBE", idtmed[289], dits, 3);    
2583   
2584  
2585   // --- Define volume of first cylinder between SPD and SDD --------------
2586   
2587   dits[0] = (21.-0.128)/2.;      
2588   dits[1] = 21./2.;
2589   dits[2] = 39.4;      
2590   gMC->Gsvolu("ICY1", "TUBE", idtmed[208], dits, 3);
2591          
2592   // --- Define volume of second cylinder between SDD and SSD --------------
2593
2594   dits[0] = (59.5-0.128)/2.;      
2595   dits[1] = 59.5/2.;
2596   dits[2] = 56.2;      // was 57
2597   gMC->Gsvolu("ICY2", "TUBE", idtmed[208], dits, 3);
2598
2599   // --- Define volumes of SDD cone ---------------------------------- 
2600
2601   dits[0] = 0;
2602   dits[1] = 360;
2603   dits[2] = 12;
2604   dits[3] = -59.7;
2605   dits[4] = 27;
2606   dits[5] = 28.6;
2607   dits[6] = -42.7;
2608   dits[7] = 10;
2609   dits[8] = 28.6;
2610   dits[9] = -34.65;
2611   dits[10] = 10;
2612   dits[11] = 28.6;
2613   dits[12] = -34.65;
2614   dits[13] = 10;
2615   dits[14] = 23.495;
2616   dits[15] = -23.7;
2617   dits[16] = 10;
2618   dits[17] = 23.495;
2619   dits[18] = -23.7;
2620   dits[19] = 10;
2621   dits[20] = 14.595;
2622   dits[21] = 23.7;
2623   dits[22] = 10;
2624   dits[23] = 14.595;
2625   dits[24] = 23.7;
2626   dits[25] = 10;
2627   dits[26] = 23.495;
2628   dits[27] = 34.65;
2629   dits[28] = 10;
2630   dits[29] = 23.495;
2631   dits[30] = 34.65;
2632   dits[31] = 10;
2633   dits[32] = 28.6;
2634   dits[33] = 42.7;
2635   dits[34] = 10;
2636   dits[35] = 28.6;
2637   dits[36] = 59.7;
2638   dits[37] = 27.2637;
2639   dits[38] = 28.6;             
2640   gMC->Gsvolu("IS02", "PCON", idtmed[204], dits, 39);
2641   
2642   dits[0] = 0;
2643   dits[1] = 360;
2644   dits[2] = 6;
2645   dits[3] = 38.65;
2646   dits[4] = 10.75;    
2647   dits[5] = 12.25;      
2648   dits[6] = 40.15;
2649   dits[7] = 10.75;
2650   dits[8] = 13.96;   
2651   dits[9] = 40.15;
2652   dits[10] = 12.46;  
2653   dits[11] = 13.96;
2654   dits[12] = 55.75;
2655   dits[13] = 27;
2656   dits[14] = 28.5;
2657   dits[15] = 55.75;
2658   dits[16] = 27;
2659   dits[17] = 28.5;
2660   dits[18] = 57.25;
2661   dits[19] = 27;
2662   dits[20] = 28.5;       
2663   gMC->Gsvolu("I093", "PCON", idtmed[272], dits, 21);  // SDD cone
2664
2665   dits[0] = 0;
2666   dits[1] = 50;
2667   dits[2] = 3;
2668   dits[3] = 39;  
2669   dits[4] = 14;
2670   dits[5] = 18.75;
2671   dits[6] = 46.7-3;
2672   dits[7] = 14;
2673   dits[8] = 18.75;
2674   dits[9] = 51.45-3;
2675   dits[10] = 18.75;
2676   dits[11] = 18.75;
2677   gMC->Gsvolu("I099", "PCON", idtmed[204], dits, 12); // SDD 3 cone hole
2678
2679   dits[0] = 0;
2680   dits[1] = 25;
2681   dits[2] = 3;
2682   dits[3] = 49;
2683   dits[4] = 23.4;
2684   dits[5] = 26.4;
2685   dits[6] = 56.1-3;
2686   dits[7] = 23.4;
2687   dits[8] = 26.4;
2688   dits[9] = 59.1-3;
2689   dits[10] = 26.4;
2690   dits[11] = 26.4;
2691   gMC->Gsvolu("I200", "PCON", idtmed[204], dits, 12); // SDD 4 cone hole
2692
2693   dits[0] = 10.0;
2694   dits[1] = 10.5;
2695   dits[2] = 0.25;
2696   gMC->Gsvolu("I090", "TUBE", idtmed[224], dits, 3);  // SDD cylinder flange
2697
2698   dits[0] = 21.95;
2699   dits[1] = 22.95;    
2700   dits[2] = 1;
2701   gMC->Gsvolu("I098", "TUBE", idtmed[283], dits, 3);    // ladder support on layer 4
2702
2703   dits[0] = 13.1;    
2704   dits[1] = 14.1;    
2705   dits[2] = 1;
2706   gMC->Gsvolu("I097", "TUBE", idtmed[283], dits, 3);    // ladder support on layer 3
2707
2708   dits[0] = 1;
2709   dits[1] = 1;
2710   dits[2] = 7.74;
2711   gMC->Gsvolu("I202", "BOX ", idtmed[272], dits, 3);
2712
2713   dits[0] = 1;
2714   dits[1] = 1;
2715   dits[2] = 9.14;
2716   gMC->Gsvolu("I203", "BOX ", idtmed[272], dits, 3);
2717
2718   dits[0] = 21.95;
2719   dits[1] = 22.95;
2720   dits[2] = 1;
2721   gMC->Gsvolu("I095", "TUBE", idtmed[224], dits, 3);
2722
2723   dits[0] = 3;
2724   dits[1] = 2.7;
2725   dits[2] = 1;
2726   dits[3] = 0.63;
2727   gMC->Gsvolu("I096", "TRD1", idtmed[264], dits, 4);
2728
2729   dits[0] = 13.1;
2730   dits[1] = 14.1;
2731   dits[2] = 1;
2732   gMC->Gsvolu("I094", "TUBE", idtmed[224], dits, 3);
2733   
2734   
2735   // --- Define volumes of SSD cone ----------------------------------    
2736             
2737
2738   dits[0] = 0;
2739   dits[1] = 360;
2740   dits[2] = 12;
2741   dits[3] = -zmax;
2742   dits[4] = 46;         
2743   dits[5] = 49.25;       
2744   dits[6] = -61.2;
2745   dits[7] = 28.7;
2746   dits[8] = 49.25;       
2747   dits[9] = -57.5;
2748   dits[10] = 28.7;
2749   dits[11] = 49.25;      
2750   dits[12] = -57.5;
2751   dits[13] = 28.7;
2752   dits[14] = 43.5;
2753   dits[15] = -49.2;
2754   dits[16] = 28.7;
2755   dits[17] = 43.5;
2756   dits[18] = -49.2;
2757   dits[19] = 28.7;
2758   dits[20] = 36.85;
2759   dits[21] = 50.6;
2760   dits[22] = 28.7;
2761   dits[23] = 36.85;
2762   dits[24] = 50.6;
2763   dits[25] = 28.7;
2764   dits[26] = 43.5;
2765   dits[27] = 57.5;
2766   dits[28] = 28.7;
2767   dits[29] = 43.5;
2768   dits[30] = 57.5;
2769   dits[31] = 28.7;
2770   dits[32] = 49.25;      
2771   dits[33] = 61.2;
2772   dits[34] = 28.7;
2773   dits[35] = 49.25;      
2774   dits[36] = zmax;
2775   dits[37] = 46;      
2776   dits[38] = 49.25;      
2777   gMC->Gsvolu("IS01", "PCON", idtmed[204], dits, 39);   // SSD cone mother volume
2778   
2779   dits[0] = 0;
2780   dits[1] = 360;
2781   dits[2] = 6;
2782   dits[3] = -zmax;  
2783   dits[4] = 47.75;  
2784   dits[5] = 49.25;  
2785   dits[6] = -zmax+2.;  
2786   dits[7] = 47.75;  
2787   dits[8] = 49.25;   
2788   dits[9] = -71.2819;
2789   dits[10] = 46.75;   
2790   dits[11] = 49.0319;
2791   dits[12] = -57.25;   // was 58.5 
2792   dits[13] = 32.9681;
2793   dits[14] = 34.75;
2794   dits[15] = -57.25;   // was 58.5   
2795   dits[16] = 30;
2796   dits[17] = 34.75;
2797   dits[18] = -55.75;   // was 57 
2798   dits[19] = 30;     
2799   dits[20] = 32.25;    // was 31.5 
2800   gMC->Gsvolu("I212", "PCON", idtmed[272], dits, 21);  // SSD cone
2801   
2802   dits[0] = 28.75;          
2803   dits[1] = 29.75;   
2804   dits[2] = 0.5;
2805   gMC->Gsvolu("I211", "TUBE", idtmed[224], dits, 3);   // SSD cylinder flange
2806   
2807   dits[0] = 35.8;   
2808   dits[1] = 36.8;   
2809   dits[2] = 1;
2810   gMC->Gsvolu("I217", "TUBE", idtmed[283], dits, 3);   // ladder support on layer 5 
2811   
2812   dits[0] = 41.4;  
2813   dits[1] = 42.4;  
2814   dits[2] = 1;
2815   gMC->Gsvolu("I219", "TUBE", idtmed[283], dits, 3);   // ladder support on layer 6
2816         
2817   dits[0] = 42.05+5.;       
2818   dits[1] = 42.55+5.;     
2819   dits[2] = 1.25;
2820   gMC->Gsvolu("I214", "TUBE", idtmed[224], dits, 3);   // layer 6 electronic support
2821                                                        // this will change after PPR
2822   dits[0] = 37.05+5.;   
2823   dits[1] = 37.55+5.;   
2824   dits[2] = 1.25;
2825   gMC->Gsvolu("I213", "TUBE", idtmed[224], dits, 3);   // layer 5 electronic support
2826                                                        // this will change after PPR
2827   dits[0] = 0;
2828   dits[1] = 25;
2829   dits[2] = 5;
2830   dits[3] = -zmax+3;
2831   dits[4] = 45.5;
2832   dits[5] = 45.5;
2833   dits[6] = -69.7+3;
2834   dits[7] = 37;
2835   dits[8] = 45.5;
2836   dits[9] = -68.5+3;
2837   dits[10] = 37;
2838   dits[11] = 45.5;
2839   dits[12] = -68.5+4.8;  
2840   dits[13] = 37;
2841   dits[14] = 45.5; 
2842   dits[15] = -63.5+4.8;
2843   dits[16] = 37;
2844   dits[17] = 45.5;   
2845   gMC->Gsvolu("I215", "PCON", idtmed[204], dits, 18);  // SSD cone hole 
2846  
2847   dits[0] = 0;
2848   dits[1] = 3.2;
2849   dits[2] = 9;
2850   dits[3] = -14;
2851   dits[4] = 30.5;
2852   dits[5] = 33.5;
2853   dits[6] = -9.85;
2854   dits[7] = 30.5;
2855   dits[8] = 33.5;
2856   dits[9] = -9.85;
2857   dits[10] = 30.5;
2858   dits[11] = 43.45;
2859   dits[12] = -7.85;
2860   dits[13] = 30.5;
2861   dits[14] = 43.45;
2862   dits[15] = -7.85;
2863   dits[16] = 30.5;
2864   dits[17] = 36.5;
2865   dits[18] = -7;
2866   dits[19] = 30.5;
2867   dits[20] = 36.5;
2868   dits[21] = -4;
2869   dits[22] = 33.0173;
2870   dits[23] = 36.5;
2871   dits[24] = -4;
2872   dits[25] = 33.0173;
2873   dits[26] = 36.80;
2874   dits[27] = -2;
2875   dits[28] = 34.6955;
2876   dits[29] = 36.80;
2877   gMC->Gsvolu("I216", "PCON", idtmed[272], dits, 30); // supports (1-6) of the ladders
2878        
2879        
2880   // --- Place SPD (option 'a') volumes into their mother volume IT12
2881   
2882   // SPD - option 'a' 
2883   // (this is NOT the default)
2884
2885   if (option == 1) {
2886
2887      gMC->Gspos("I12A",5,"IT12",0.0,0.0,0.0,idrotm[238],"MANY");
2888      gMC->Gspos("I12A",6,"IT12",0.0,0.0,0.0,idrotm[236],"MANY");
2889      gMC->Gspos("I12A",7,"IT12",0.0,0.0,0.0,idrotm[239],"MANY");
2890      gMC->Gspos("I12A",8,"IT12",0.0,0.0,0.0,idrotm[233],"MANY");
2891      gMC->Gspos("I12A",9,"IT12",0.0,0.0,0.0,idrotm[240],"MANY");
2892      gMC->Gspos("I12A",10,"IT12",0.0,0.0,0.0,idrotm[241],"MANY");
2893      gMC->Gspos("I12A",2,"IT12",0.0,0.0,0.0,idrotm[242],"MANY");
2894      gMC->Gspos("I12A",3,"IT12",0.0,0.0,0.0,idrotm[234],"MANY");
2895      gMC->Gspos("I12A",4,"IT12",0.0,0.0,0.0,idrotm[243],"MANY");
2896      gMC->Gspos("I12A",1,"IT12",0.0,0.0,0.0,0,"MANY");
2897      deltax=((ddet1-0.01/2.)+(dchip1-0.015/2.))*TMath::Cos(270.*TMath::Pi()/180.);  // see definition of idrotm[244]
2898           deltay=((ddet1-0.01/2.)+(dchip1-0.015/2.))*TMath::Sin(270.*TMath::Pi()/180.);  // see definition of idrotm[244]
2899      gMC->Gspos("I10A",2,"I12A",0.203+deltax,3.8206+deltay,0.0,idrotm[244],"ONLY");       
2900      deltax=((ddet1-0.01/2.)+(dchip1-0.015/2.))*TMath::Cos(252.*TMath::Pi()/180.);  // see definition of idrotm[245]
2901           deltay=((ddet1-0.01/2.)+(dchip1-0.015/2.))*TMath::Sin(252.*TMath::Pi()/180.);  // see definition of idrotm[245]  
2902      gMC->Gspos("I10A",1,"I12A",1.4531+deltax,3.8152+deltay,0.0,idrotm[245],"ONLY");
2903      deltax=((ddet2-0.01/2.)+(dchip2-0.015/2.))*TMath::Cos(40.*TMath::Pi()/180.);  // see definition of idrotm[246]
2904           deltay=((ddet2-0.01/2.)+(dchip2-0.015/2.))*TMath::Sin(40.*TMath::Pi()/180.);  // see definition of idrotm[246]  
2905      gMC->Gspos("I20A",1,"I12A",3.0174+deltax,6.5143+deltay,0.0,idrotm[246],"ONLY");
2906      deltax=((ddet2-0.01/2.)+(dchip2-0.015/2.))*TMath::Cos(49.*TMath::Pi()/180.);  // see definition of idrotm[247]
2907           deltay=((ddet2-0.01/2.)+(dchip2-0.015/2.))*TMath::Sin(49.*TMath::Pi()/180.);  // see definition of idrotm[247] 
2908      gMC->Gspos("I20A",2,"I12A",1.9612+deltax,6.9062+deltay,0.0,idrotm[247],"ONLY");
2909      deltax=((ddet2-0.01/2.)+(dchip2-0.015/2.))*TMath::Cos(58.*TMath::Pi()/180.);  // see definition of idrotm[248]
2910           deltay=((ddet2-0.01/2.)+(dchip2-0.015/2.))*TMath::Sin(58.*TMath::Pi()/180.);  // see definition of idrotm[248] 
2911      gMC->Gspos("I20A",3,"I12A",0.8567+deltax,7.1279+deltay,0.0,idrotm[248],"ONLY");
2912      deltax=((ddet2-0.01/2.)+(dchip2-0.015/2.))*TMath::Cos(67.*TMath::Pi()/180.);  // see definition of idrotm[249]
2913           deltay=((ddet2-0.01/2.)+(dchip2-0.015/2.))*TMath::Sin(67.*TMath::Pi()/180.);  // see definition of idrotm[249] 
2914      gMC->Gspos("I20A",4,"I12A",-0.2689+deltax,7.1742+deltay,0.0,idrotm[249],"ONLY");
2915      gMC->Gspos("I123",2,"I12A",-0.2978,5.5196,0.0,idrotm[214],"ONLY");
2916      gMC->Gspos("I121",2,"I12A",-0.2385,4.1518,0.0,idrotm[213],"ONLY");
2917      gMC->Gspos("I122",2,"I12A",-0.2968,4.0207,0.0,idrotm[212],"ONLY");
2918      gMC->Gspos("I120",2,"I12A",-0.3672,3.9056,0.0,0,"ONLY");
2919      gMC->Gspos("I144",1,"I12A",-0.2538,3.8556,0.0,0,"ONLY");
2920      gMC->Gspos("I113",3,"I12A",0.1095,3.9056,0.0,0,"ONLY");
2921      gMC->Gspos("I143",1,"I12A",0.4365,3.8556,0.0,idrotm[236],"ONLY");
2922      gMC->Gspos("I142",1,"I12A",0.5136,3.9056,0.0,idrotm[235],"ONLY");
2923      gMC->Gspos("I141",1,"I12A",0.5636,3.9752,0.0,idrotm[201],"ONLY");
2924      gMC->Gspos("I140",1,"I12A",0.6336,4.0447,0.0,idrotm[234],"ONLY");
2925      gMC->Gspos("I139",1,"I12A",0.8297,4.0545,0.0,idrotm[207],"ONLY");
2926      gMC->Gspos("I113",5,"I12A",1.2575,3.9681,0.0,idrotm[207],"ONLY");
2927      gMC->Gspos("I138",1,"I12A",1.66,3.7848,0.0,idrotm[207],"ONLY");
2928      gMC->Gspos("I137",1,"I12A",1.8556,3.7738,0.0,idrotm[233],"ONLY");
2929      gMC->Gspos("I136",1,"I12A",2.6224,4.874,0.0,idrotm[232],"ONLY");
2930      gMC->Gspos("I135",1,"I12A",3.2967,6.0337,0.0,idrotm[231],"ONLY");
2931      gMC->Gspos("I134",1,"I12A",3.266,6.1636,0.0,idrotm[230],"ONLY");
2932      gMC->Gspos("I113",1,"I12A",2.9903,6.4144,0.0,idrotm[211],"ONLY");
2933      gMC->Gspos("I133",3,"I12A",2.7631,6.7627,0.0,idrotm[230],"ONLY");
2934      gMC->Gspos("I132",3,"I12A",2.62,6.8555,0.0,idrotm[229],"ONLY");
2935      gMC->Gspos("I131",3,"I12A",2.648,6.6023,0.0,idrotm[228],"ONLY");
2936      gMC->Gspos("I130",3,"I12A",2.6569,6.3431,0.0,idrotm[227],"ONLY");
2937      gMC->Gspos("I129",3,"I12A",2.3906,6.4819,0.0,idrotm[226],"ONLY");
2938      gMC->Gspos("I113",2,"I12A",1.9488,6.7998,0.0,idrotm[210],"ONLY");
2939      gMC->Gspos("I133",2,"I12A",1.6699,7.1085,0.0,idrotm[226],"ONLY");
2940      gMC->Gspos("I132",2,"I12A",1.5142,7.1777,0.0,idrotm[225],"ONLY");
2941      gMC->Gspos("I131",2,"I12A",1.5814,6.932,0.0,idrotm[224],"ONLY");
2942      gMC->Gspos("I130",2,"I12A",1.6308,6.6774,0.0,idrotm[223],"ONLY");
2943      gMC->Gspos("I129",2,"I12A",1.346,6.7728,0.0,idrotm[222],"ONLY");
2944      gMC->Gspos("I113",6,"I12A",0.8599,7.0176,0.0,idrotm[209],"ONLY");
2945      gMC->Gspos("I133",1,"I12A",0.5362,7.2789,0.0,idrotm[222],"ONLY");
2946      gMC->Gspos("I132",1,"I12A",0.3715,7.3228,0.0,idrotm[221],"ONLY");
2947      gMC->Gspos("I131",1,"I12A",0.4763,7.0907,0.0,idrotm[220],"ONLY");
2948      gMC->Gspos("I130",1,"I12A",0.5649,6.8469,0.0,idrotm[219],"ONLY");
2949      gMC->Gspos("I129",1,"I12A",0.2688,6.8966,0.0,idrotm[218],"ONLY");
2950      gMC->Gspos("I113",4,"I12A",-0.2497,7.0624,0.0,idrotm[208],"ONLY");
2951      gMC->Gspos("I128",1,"I12A",-0.6103,7.2698,0.0,idrotm[218],"ONLY");
2952      gMC->Gspos("I126",2,"I12A",-0.7799,7.2874,0.0,idrotm[217],"ONLY");
2953      gMC->Gspos("I125",2,"I12A",-0.6315,7.0883,0.0,idrotm[216],"ONLY");
2954      gMC->Gspos("I124",2,"I12A",-0.4965,6.8742,0.0,idrotm[215],"ONLY");
2955      gMC->Gspos("I103",3,"I10A",-0.05,-di10a[1]+2.*di104[1]+di103[1],-3.536,idrotm[237],"ONLY");
2956      gMC->Gspos("I103",4,"I10A",-0.05,-di10a[1]+2.*di104[1]+di103[1],-10.708,idrotm[237],"ONLY");
2957      gMC->Gspos("I103",1,"I10A",-0.05,-di10a[1]+2.*di104[1]+di103[1],10.708,0,"ONLY");
2958      gMC->Gspos("I103",2,"I10A",-0.05,-di10a[1]+2.*di104[1]+di103[1],3.536,0,"ONLY");
2959      gMC->Gspos("I105",1,"I10A",-0.05,0.01,-16.844,idrotm[237],"ONLY");
2960      gMC->Gspos("I105",2,"I10A",-0.05,0.01,16.844,0,"ONLY");
2961      gMC->Gspos("I104",1,"I10A",0.0,-di10a[1]+di104[1],0.0,0,"ONLY");
2962      gMC->Gspos("I1D3",3,"I20A",-0.05,-di20a[1]+2.*di104[1]+di1d3[1],-3.536,idrotm[237],"ONLY");
2963      gMC->Gspos("I1D3",4,"I20A",-0.05,-di20a[1]+2.*di104[1]+di1d3[1],-10.708,idrotm[237],"ONLY");
2964      gMC->Gspos("I1D3",1,"I20A",-0.05,-di20a[1]+2.*di104[1]+di1d3[1],10.708,0,"ONLY");
2965      gMC->Gspos("I1D3",2,"I20A",-0.05,-di20a[1]+2.*di104[1]+di1d3[1],3.536,0,"ONLY");
2966      gMC->Gspos("I105",3,"I20A",-0.05,0.01,-16.844,idrotm[237],"ONLY");
2967      gMC->Gspos("I105",4,"I20A",-0.05,0.01,16.844,0,"ONLY");
2968      gMC->Gspos("I104",2,"I20A",0.0,-di20a[1]+di104[1],0.0,0,"ONLY");
2969      gMC->Gspos("I112",2,"I113",0.25,0.02,0.0,idrotm[206],"ONLY");
2970      gMC->Gspos("I111",2,"I113",0.1318,-0.0008,0.0,idrotm[205],"ONLY");
2971      gMC->Gspos("I118",1,"I113",0.0,-0.0454,0.0,0,"ONLY");
2972      gMC->Gspos("I110",1,"I113",0.0,0.0492,0.0,0,"ONLY");
2973      gMC->Gspos("I114",1,"I113",0.063,0.0042,0.0,idrotm[202],"ONLY");
2974      gMC->Gspos("I115",1,"I113",0.063,0.0042,0.0,idrotm[202],"ONLY");
2975      gMC->Gspos("I115",2,"I113",-0.063,0.0042,0.0,idrotm[201],"ONLY");
2976      gMC->Gspos("I114",2,"I113",-0.063,0.0042,0.0,idrotm[201],"ONLY");
2977      gMC->Gspos("I116",1,"I113",0.0,0.0042,0.0,0,"ONLY");
2978      gMC->Gspos("I111",1,"I113",-0.1318,-0.0008,0.0,idrotm[204],"ONLY");
2979      gMC->Gspos("I112",1,"I113",-0.25,0.02,0.0,idrotm[203],"ONLY");
2980      gMC->Gspos("I101",1,"I103",-0.088,ddet1,0.0,0,"ONLY");
2981      gMC->Gspos("I102",1,"I103",0.0,-dchip1,-2.8,0,"ONLY");
2982      gMC->Gspos("I102",2,"I103",0.0,-dchip1,-1.4,0,"ONLY");
2983      gMC->Gspos("I102",3,"I103",0.0,-dchip1,0.0,0,"ONLY");
2984      gMC->Gspos("I102",4,"I103",0.0,-dchip1,1.4,0,"ONLY");
2985      gMC->Gspos("I102",5,"I103",0.0,-dchip1,2.8,0,"ONLY");
2986      gMC->Gspos("I1D1",1,"I1D3",-0.088,ddet2,0.0,0,"ONLY");
2987      gMC->Gspos("I1D2",1,"I1D3",0.0,-dchip2,-2.8,0,"ONLY");
2988      gMC->Gspos("I1D2",2,"I1D3",0.0,-dchip2,-1.4,0,"ONLY");
2989      gMC->Gspos("I1D2",3,"I1D3",0.0,-dchip2,0.0,0,"ONLY");
2990      gMC->Gspos("I1D2",4,"I1D3",0.0,-dchip2,1.4,0,"ONLY");
2991      gMC->Gspos("I1D2",5,"I1D3",0.0,-dchip2,2.8,0,"ONLY");
2992      gMC->Gspos("I117",1,"I116",0.0,0.0,0.0,0,"ONLY");
2993      gMC->Gspos("ITS1",1,"I101",0.0,0.0,0.0,0,"ONLY");
2994      gMC->Gspos("ITS2",1,"I1D1",0.0,0.0,0.0,0,"ONLY");
2995      gMC->Gspos("I650",16,"IT12",0.0,0.0,22.0,idrotm[1104],"MANY");
2996      gMC->Gspos("I650",20,"IT12",0.0,0.0,22.0,idrotm[1130],"MANY");
2997      gMC->Gspos("I650",18,"IT12",0.0,0.0,22.0,idrotm[1117],"MANY");
2998      gMC->Gspos("I650",1,"IT12",0.0,0.0,22.0,0,"MANY");
2999      gMC->Gspos("I650",4,"IT12",0.0,0.0,22.0,idrotm[1106],"MANY");
3000      gMC->Gspos("I650",6,"IT12",0.0,0.0,22.0,idrotm[1039],"MANY");
3001      gMC->Gspos("I650",8,"IT12",0.0,0.0,22.0,idrotm[1107],"MANY");
3002      gMC->Gspos("I650",10,"IT12",0.0,0.0,22.0,idrotm[1065],"MANY");
3003      gMC->Gspos("I650",12,"IT12",0.0,0.0,22.0,idrotm[1078],"MANY");
3004      gMC->Gspos("I650",14,"IT12",0.0,0.0,22.0,idrotm[1091],"MANY");
3005      gMC->Gspos("I650",19,"IT12",0.0,0.0,-22.0,idrotm[1108],"MANY");
3006      gMC->Gspos("I650",2,"IT12",0.0,0.0,-22.0,idrotm[1109],"MANY");
3007      gMC->Gspos("I650",3,"IT12",0.0,0.0,-22.0,idrotm[1110],"MANY");
3008      gMC->Gspos("I650",5,"IT12",0.0,0.0,-22.0,idrotm[1111],"MANY");
3009      gMC->Gspos("I650",7,"IT12",0.0,0.0,-22.0,idrotm[1112],"MANY");
3010      gMC->Gspos("I650",9,"IT12",0.0,0.0,-22.0,idrotm[1113],"MANY");
3011      gMC->Gspos("I650",11,"IT12",0.0,0.0,-22.0,idrotm[1114],"MANY");
3012      gMC->Gspos("I650",13,"IT12",0.0,0.0,-22.0,idrotm[1115],"MANY");
3013      gMC->Gspos("I650",15,"IT12",0.0,0.0,-22.0,idrotm[1116],"MANY");
3014      gMC->Gspos("I650",17,"IT12",0.0,0.0,-22.0,idrotm[1118],"MANY");
3015      gMC->Gspos("I666",1,"I650",0.0,0.0,0.25,idrotm[1003],"MANY");
3016      gMC->Gspos("I667",1,"I650",0.1102,0.9945,0.45,idrotm[1088],"ONLY");
3017      gMC->Gspos("I669",3,"I650",0.1883,4.0372,-3.2,0,"ONLY");
3018      gMC->Gspos("I671",3,"I650",0.1883,4.0372,0.6,0,"ONLY");
3019      gMC->Gspos("I669",2,"I650",1.3343,4.0609,-3.2,0,"ONLY");
3020      gMC->Gspos("I671",2,"I650",1.3343,4.0609,0.6,0,"ONLY");
3021      gMC->Gspos("I669",6,"I650",2.9567,6.1959,-3.2,idrotm[1089],"ONLY");
3022      gMC->Gspos("I671",6,"I650",2.9567,6.1959,0.6,idrotm[1089],"ONLY");
3023      gMC->Gspos("I669",5,"I650",1.9511,6.5822,-3.2,idrotm[1011],"ONLY");
3024      gMC->Gspos("I671",5,"I650",1.9511,6.5822,0.6,idrotm[1011],"ONLY");
3025      gMC->Gspos("I669",4,"I650",0.8974,6.8064,-3.2,idrotm[1090],"ONLY");
3026      gMC->Gspos("I671",4,"I650",0.8974,6.8064,0.6,idrotm[1090],"ONLY");
3027      gMC->Gspos("I669",1,"I650",-0.1784,6.863,-3.2,0,"ONLY");
3028      gMC->Gspos("I671",1,"I650",-0.1784,6.863,0.6,0,"ONLY");
3029      gMC->Gspos("I673",1,"I650",0.2173,4.8037,1.8,0,"ONLY");
3030      gMC->Gspos("I673",6,"I650",1.5093,4.5605,1.8,0,"ONLY");
3031      gMC->Gspos("I673",4,"I650",-0.173,6.2531,1.8,idrotm[1092],"ONLY");
3032      gMC->Gspos("I673",3,"I650",0.8073,6.2032,1.8,idrotm[1093],"ONLY");
3033      gMC->Gspos("I673",2,"I650",1.7678,6.0005,1.8,idrotm[1094],"ONLY");
3034      gMC->Gspos("I673",5,"I650",2.6847,5.6501,1.8,0,"ONLY");
3035      gMC->Gspos("I676",2,"I650",1.7618,5.2269,2.5,0,"ONLY");
3036      gMC->Gspos("I676",1,"I650",0.4018,5.5869,2.5,0,"ONLY");
3037      gMC->Gspos("I668",1,"I667",0.0,0.0,0.0,0,"ONLY");
3038      gMC->Gspos("I670",1,"I669",0.0,0.0,0.0,0,"ONLY");
3039      gMC->Gspos("I672",1,"I671",0.0,0.0,0.0,0,"ONLY");
3040      gMC->Gspos("I674",1,"I673",0.0,0.0,0.0,0,"MANY");
3041      gMC->Gspos("I675",1,"I673",0.0,0.0,-0.5,0,"ONLY");
3042      gMC->Gspos("I677",1,"I676",0.0,0.0,0.0,0,"MANY");
3043      gMC->Gspos("I678",1,"I676",0.0,0.0,-0.95,0,"ONLY");    
3044
3045   }
3046
3047
3048   // --- Place SPD (option 'b') volumes into their mother volume IT12
3049   
3050   // SPD - option 'b' 
3051   // (this is the default)
3052
3053   if (option == 2) {
3054
3055      gMC->Gspos("I12B",1,"IT12",0.0,0.0,0.0,0,"MANY");
3056      gMC->Gspos("I12B",8,"IT12",0.0,0.0,0.0,idrotm[233],"MANY");
3057      gMC->Gspos("I12B",7,"IT12",0.0,0.0,0.0,idrotm[244],"MANY");
3058      gMC->Gspos("I12B",6,"IT12",0.0,0.0,0.0,idrotm[236],"MANY");
3059      gMC->Gspos("I12B",2,"IT12",0.0,0.0,0.0,idrotm[245],"MANY");
3060      gMC->Gspos("I12B",3,"IT12",0.0,0.0,0.0,idrotm[234],"MANY");
3061      gMC->Gspos("I12B",4,"IT12",0.0,0.0,0.0,idrotm[246],"MANY");
3062      gMC->Gspos("I12B",5,"IT12",0.0,0.0,0.0,idrotm[247],"MANY");
3063      gMC->Gspos("I12B",9,"IT12",0.0,0.0,0.0,idrotm[248],"MANY");
3064      gMC->Gspos("I12B",10,"IT12",0.0,0.0,0.0,idrotm[249],"MANY");
3065      deltax=((ddet1-0.01/2.)+(dchip1-0.015/2.))*TMath::Cos(270.*TMath::Pi()/180.);  // see definition of idrotm[238]
3066           deltay=((ddet1-0.01/2.)+(dchip1-0.015/2.))*TMath::Sin(270.*TMath::Pi()/180.);  // see definition of idrotm[238]
3067      gMC->Gspos("I10B",2,"I12B",0.203+deltax,3.8206+deltay,0.0,idrotm[238],"ONLY");       
3068      deltax=((ddet1-0.01/2.)+(dchip1-0.015/2.))*TMath::Cos(252.*TMath::Pi()/180.);  // see definition of idrotm[239]
3069           deltay=((ddet1-0.01/2.)+(dchip1-0.015/2.))*TMath::Sin(252.*TMath::Pi()/180.);  // see definition of idrotm[239]  
3070      gMC->Gspos("I10B",1,"I12B",1.4531+deltax,3.8152+deltay,0.0,idrotm[239],"ONLY");
3071      deltax=((ddet2-0.01/2.)+(dchip2-0.015/2.))*TMath::Cos(40.*TMath::Pi()/180.);  // see definition of idrotm[240]
3072           deltay=((ddet2-0.01/2.)+(dchip2-0.015/2.))*TMath::Sin(40.*TMath::Pi()/180.);  // see definition of idrotm[240]  
3073      gMC->Gspos("I20B",1,"I12B",3.0174+deltax,6.5143+deltay,0.0,idrotm[240],"ONLY");
3074      deltax=((ddet2-0.01/2.)+(dchip2-0.015/2.))*TMath::Cos(49.*TMath::Pi()/180.);  // see definition of idrotm[241]
3075           deltay=((ddet2-0.01/2.)+(dchip2-0.015/2.))*TMath::Sin(49.*TMath::Pi()/180.);  // see definition of idrotm[241] 
3076      gMC->Gspos("I20B",2,"I12B",1.9612+deltax,6.9062+deltay,0.0,idrotm[241],"ONLY");
3077      deltax=((ddet2-0.01/2.)+(dchip2-0.015/2.))*TMath::Cos(58.*TMath::Pi()/180.);  // see definition of idrotm[242]
3078           deltay=((ddet2-0.01/2.)+(dchip2-0.015/2.))*TMath::Sin(58.*TMath::Pi()/180.);  // see definition of idrotm[242] 
3079      gMC->Gspos("I20B",3,"I12B",0.8567+deltax,7.1279+deltay,0.0,idrotm[242],"ONLY");
3080      deltax=((ddet2-0.01/2.)+(dchip2-0.015/2.))*TMath::Cos(67.*TMath::Pi()/180.);  // see definition of idrotm[243]
3081           deltay=((ddet2-0.01/2.)+(dchip2-0.015/2.))*TMath::Sin(67.*TMath::Pi()/180.);  // see definition of idrotm[243] 
3082      gMC->Gspos("I20B",4,"I12B",-0.2689+deltax,7.1742+deltay,0.0,idrotm[243],"ONLY");
3083      gMC->Gspos("I123",1,"I12B",-0.2978,5.5196,0.0,idrotm[214],"ONLY");
3084      gMC->Gspos("I121",1,"I12B",-0.2385,4.1518,0.0,idrotm[213],"ONLY");
3085      gMC->Gspos("I122",1,"I12B",-0.2968,4.0207,0.0,idrotm[212],"ONLY");
3086      gMC->Gspos("I120",1,"I12B",-0.3672,3.9056,0.0,0,"ONLY");
3087      gMC->Gspos("I144",1,"I12B",-0.2538,3.8556,0.0,0,"ONLY");
3088      gMC->Gspos("I113",3,"I12B",0.1095,3.9056,0.0,0,"ONLY");
3089      gMC->Gspos("I143",1,"I12B",0.4365,3.8556,0.0,idrotm[236],"ONLY");
3090      gMC->Gspos("I142",1,"I12B",0.5136,3.9056,0.0,idrotm[235],"ONLY");
3091      gMC->Gspos("I141",1,"I12B",0.5636,3.9752,0.0,idrotm[237],"ONLY");
3092      gMC->Gspos("I140",1,"I12B",0.6336,4.0447,0.0,idrotm[234],"ONLY");
3093      gMC->Gspos("I139",1,"I12B",0.8297,4.0545,0.0,idrotm[207],"ONLY");
3094      gMC->Gspos("I113",5,"I12B",1.2575,3.9681,0.0,idrotm[207],"ONLY");
3095      gMC->Gspos("I138",1,"I12B",1.66,3.7848,0.0,idrotm[207],"ONLY");
3096      gMC->Gspos("I137",1,"I12B",1.8556,3.7738,0.0,idrotm[233],"ONLY");
3097      gMC->Gspos("I136",1,"I12B",2.6224,4.874,0.0,idrotm[232],"ONLY");
3098      gMC->Gspos("I135",1,"I12B",3.2967,6.0337,0.0,idrotm[231],"ONLY");
3099      gMC->Gspos("I134",1,"I12B",3.266,6.1636,0.0,idrotm[230],"ONLY");
3100      gMC->Gspos("I113",1,"I12B",2.9903,6.4144,0.0,idrotm[211],"ONLY");
3101      gMC->Gspos("I133",3,"I12B",2.7631,6.7627,0.0,idrotm[230],"ONLY");
3102      gMC->Gspos("I132",3,"I12B",2.62,6.8555,0.0,idrotm[229],"ONLY");
3103      gMC->Gspos("I131",3,"I12B",2.648,6.6023,0.0,idrotm[228],"ONLY");
3104      gMC->Gspos("I130",3,"I12B",2.6569,6.3431,0.0,idrotm[227],"ONLY");
3105      gMC->Gspos("I129",3,"I12B",2.3906,6.4819,0.0,idrotm[226],"ONLY");
3106      gMC->Gspos("I113",2,"I12B",1.9488,6.7998,0.0,idrotm[210],"ONLY");
3107      gMC->Gspos("I133",2,"I12B",1.6699,7.1085,0.0,idrotm[226],"ONLY");
3108      gMC->Gspos("I132",2,"I12B",1.5142,7.1777,0.0,idrotm[225],"ONLY");
3109      gMC->Gspos("I131",2,"I12B",1.5814,6.932,0.0,idrotm[224],"ONLY");
3110      gMC->Gspos("I130",2,"I12B",1.6308,6.6774,0.0,idrotm[223],"ONLY");
3111      gMC->Gspos("I129",2,"I12B",1.346,6.7728,0.0,idrotm[222],"ONLY");
3112      gMC->Gspos("I113",6,"I12B",0.8599,7.0176,0.0,idrotm[209],"ONLY");
3113      gMC->Gspos("I133",1,"I12B",0.5362,7.2789,0.0,idrotm[222],"ONLY");
3114      gMC->Gspos("I132",1,"I12B",0.3715,7.3228,0.0,idrotm[221],"ONLY");
3115      gMC->Gspos("I131",1,"I12B",0.4763,7.0907,0.0,idrotm[220],"ONLY");
3116      gMC->Gspos("I130",1,"I12B",0.5649,6.8469,0.0,idrotm[219],"ONLY");
3117      gMC->Gspos("I129",1,"I12B",0.2688,6.8966,0.0,idrotm[218],"ONLY");
3118      gMC->Gspos("I113",4,"I12B",-0.2497,7.0624,0.0,idrotm[208],"ONLY");
3119      gMC->Gspos("I128",1,"I12B",-0.6103,7.2698,0.0,idrotm[218],"ONLY");
3120      gMC->Gspos("I126",1,"I12B",-0.7799,7.2874,0.0,idrotm[217],"ONLY");
3121      gMC->Gspos("I125",1,"I12B",-0.6315,7.0883,0.0,idrotm[216],"ONLY");
3122      gMC->Gspos("I124",1,"I12B",-0.4965,6.8742,0.0,idrotm[215],"ONLY");
3123      gMC->Gspos("I105",3,"I10B",-0.05,-0.01,-16.844,idrotm[201],"ONLY");
3124      gMC->Gspos("I105",4,"I10B",-0.05,-0.01,16.844,0,"ONLY");
3125      gMC->Gspos("I107",2,"I10B",-0.0455,-di10b[1]+di107[1],3.536,0,"ONLY");
3126      gMC->Gspos("I107",1,"I10B",-0.0455,-di10b[1]+di107[1],10.708,0,"ONLY");
3127      gMC->Gspos("I107",4,"I10B",-0.0455,-di10b[1]+di107[1],-10.708,idrotm[201],"ONLY");
3128      gMC->Gspos("I107",3,"I10B",-0.0455,-di10b[1]+di107[1],-3.536,idrotm[201],"ONLY");
3129      gMC->Gspos("I109",1,"I10B",-0.138,0.015,-16.844,idrotm[201],"ONLY");
3130      gMC->Gspos("I109",2,"I10B",-0.138,0.015,16.844,0,"ONLY");
3131      gMC->Gspos("I108",1,"I10B",-0.138,-di10b[1]+2.*di107[1]+di108[1],0.0,0,"ONLY");
3132      gMC->Gspos("I105",1,"I20B",-0.05,-0.01,-16.844,idrotm[201],"ONLY");
3133      gMC->Gspos("I105",2,"I20B",-0.05,-0.01,16.844,0,"ONLY");
3134      gMC->Gspos("I1D7",2,"I20B",-0.0455,-di20b[1]+di1d7[1],3.536,0,"ONLY");
3135      gMC->Gspos("I1D7",1,"I20B",-0.0455,-di20b[1]+di1d7[1],10.708,0,"ONLY");
3136      gMC->Gspos("I1D7",4,"I20B",-0.0455,-di20b[1]+di1d7[1],-10.708,idrotm[201],"ONLY");
3137      gMC->Gspos("I1D7",3,"I20B",-0.0455,-di20b[1]+di1d7[1],-3.536,idrotm[201],"ONLY");
3138      gMC->Gspos("I109",3,"I20B",-0.138,0.015,-16.844,idrotm[201],"ONLY");
3139      gMC->Gspos("I109",4,"I20B",-0.138,0.015,16.844,0,"ONLY");
3140      gMC->Gspos("I108",2,"I20B",-0.138,-di20b[1]+2.*di1d7[1]+di108[1],0.0,0,"ONLY");
3141      gMC->Gspos("I112",2,"I113",0.25,0.02,0.0,idrotm[206],"ONLY");
3142      gMC->Gspos("I111",2,"I113",0.1318,-0.0008,0.0,idrotm[205],"ONLY");
3143      gMC->Gspos("I118",1,"I113",0.0,-0.0454,0.0,0,"ONLY");
3144      gMC->Gspos("I110",1,"I113",0.0,0.0492,0.0,0,"ONLY");
3145      gMC->Gspos("I114",1,"I113",0.063,0.0042,0.0,idrotm[202],"ONLY");
3146      gMC->Gspos("I115",1,"I113",0.063,0.0042,0.0,idrotm[202],"ONLY");
3147      gMC->Gspos("I115",2,"I113",-0.063,0.0042,0.0,idrotm[237],"ONLY");
3148      gMC->Gspos("I114",2,"I113",-0.063,0.0042,0.0,idrotm[237],"ONLY");
3149      gMC->Gspos("I116",1,"I113",0.0,0.0042,0.0,0,"ONLY");
3150      gMC->Gspos("I111",1,"I113",-0.1318,-0.0008,0.0,idrotm[204],"ONLY");
3151      gMC->Gspos("I112",1,"I113",-0.25,0.02,0.0,idrotm[203],"ONLY");
3152      gMC->Gspos("I106",1,"I107",0.0,-dchip1,-1.4,0,"ONLY");
3153      gMC->Gspos("I106",2,"I107",0.0,-dchip1,0.0,0,"ONLY");
3154      gMC->Gspos("I106",3,"I107",0.0,-dchip1,1.4,0,"ONLY");
3155      gMC->Gspos("I106",4,"I107",0.0,-dchip1,2.8,0,"ONLY");
3156      gMC->Gspos("I106",5,"I107",0.0,-dchip1,-2.8,0,"ONLY");
3157      gMC->Gspos("I101",1,"I107",0.0,ddet1,0.0,0,"ONLY");
3158      gMC->Gspos("I1D6",1,"I1D7",0.0,-dchip2,-1.4,0,"ONLY");
3159      gMC->Gspos("I1D6",2,"I1D7",0.0,-dchip2,0.0,0,"ONLY");
3160      gMC->Gspos("I1D6",3,"I1D7",0.0,-dchip2,1.4,0,"ONLY");
3161      gMC->Gspos("I1D6",4,"I1D7",0.0,-dchip2,2.8,0,"ONLY");
3162      gMC->Gspos("I1D6",5,"I1D7",0.0,-dchip2,-2.8,0,"ONLY");
3163      gMC->Gspos("I1D1",1,"I1D7",0.0,ddet2,0.0,0,"ONLY");
3164      gMC->Gspos("I117",1,"I116",0.0,0.0,0.0,0,"ONLY");
3165      gMC->Gspos("ITS1",1,"I101",0.0,0.0,0.0,0,"ONLY");
3166      gMC->Gspos("ITS2",1,"I1D1",0.0,0.0,0.0,0,"ONLY");
3167      gMC->Gspos("I650",16,"IT12",0.0,0.0,22.0,idrotm[1104],"MANY");
3168      gMC->Gspos("I650",20,"IT12",0.0,0.0,22.0,idrotm[1130],"MANY");
3169      gMC->Gspos("I650",18,"IT12",0.0,0.0,22.0,idrotm[1117],"MANY");
3170      gMC->Gspos("I650",1,"IT12",0.0,0.0,22.0,0,"MANY");
3171      gMC->Gspos("I650",4,"IT12",0.0,0.0,22.0,idrotm[1106],"MANY");
3172      gMC->Gspos("I650",6,"IT12",0.0,0.0,22.0,idrotm[1039],"MANY");
3173      gMC->Gspos("I650",8,"IT12",0.0,0.0,22.0,idrotm[1107],"MANY");
3174      gMC->Gspos("I650",10,"IT12",0.0,0.0,22.0,idrotm[1065],"MANY");
3175      gMC->Gspos("I650",12,"IT12",0.0,0.0,22.0,idrotm[1078],"MANY");
3176      gMC->Gspos("I650",14,"IT12",0.0,0.0,22.0,idrotm[1091],"MANY");
3177      gMC->Gspos("I650",19,"IT12",0.0,0.0,-22.0,idrotm[1108],"MANY");
3178      gMC->Gspos("I650",2,"IT12",0.0,0.0,-22.0,idrotm[1109],"MANY");
3179      gMC->Gspos("I650",3,"IT12",0.0,0.0,-22.0,idrotm[1110],"MANY");
3180      gMC->Gspos("I650",5,"IT12",0.0,0.0,-22.0,idrotm[1111],"MANY");
3181      gMC->Gspos("I650",7,"IT12",0.0,0.0,-22.0,idrotm[1112],"MANY");
3182      gMC->Gspos("I650",9,"IT12",0.0,0.0,-22.0,idrotm[1113],"MANY");
3183      gMC->Gspos("I650",11,"IT12",0.0,0.0,-22.0,idrotm[1114],"MANY");
3184      gMC->Gspos("I650",13,"IT12",0.0,0.0,-22.0,idrotm[1115],"MANY");
3185      gMC->Gspos("I650",15,"IT12",0.0,0.0,-22.0,idrotm[1116],"MANY");
3186      gMC->Gspos("I650",17,"IT12",0.0,0.0,-22.0,idrotm[1118],"MANY");
3187      gMC->Gspos("I666",1,"I650",0.0,0.0,0.25,idrotm[1003],"MANY");
3188      gMC->Gspos("I667",1,"I650",0.1102,0.9945,0.45,idrotm[1088],"ONLY");
3189      gMC->Gspos("I669",3,"I650",0.1883,4.0372,-3.2,0,"ONLY");
3190      gMC->Gspos("I671",3,"I650",0.1883,4.0372,0.6,0,"ONLY");
3191      gMC->Gspos("I669",2,"I650",1.3343,4.0609,-3.2,0,"ONLY");
3192      gMC->Gspos("I671",2,"I650",1.3343,4.0609,0.6,0,"ONLY");
3193      gMC->Gspos("I669",6,"I650",2.9567,6.1959,-3.2,idrotm[1089],"ONLY");
3194      gMC->Gspos("I671",6,"I650",2.9567,6.1959,0.6,idrotm[1089],"ONLY");
3195      gMC->Gspos("I669",5,"I650",1.9511,6.5822,-3.2,idrotm[1011],"ONLY");
3196      gMC->Gspos("I671",5,"I650",1.9511,6.5822,0.6,idrotm[1011],"ONLY");
3197      gMC->Gspos("I669",4,"I650",0.8974,6.8064,-3.2,idrotm[1090],"ONLY");
3198      gMC->Gspos("I671",4,"I650",0.8974,6.8064,0.6,idrotm[1090],"ONLY");
3199      gMC->Gspos("I669",1,"I650",-0.1784,6.863,-3.2,0,"ONLY");
3200      gMC->Gspos("I671",1,"I650",-0.1784,6.863,0.6,0,"ONLY");
3201      gMC->Gspos("I673",1,"I650",0.2173,4.8037,1.8,0,"ONLY");
3202      gMC->Gspos("I673",6,"I650",1.5093,4.5605,1.8,0,"ONLY");
3203      gMC->Gspos("I673",4,"I650",-0.173,6.2531,1.8,idrotm[1092],"ONLY");
3204      gMC->Gspos("I673",3,"I650",0.8073,6.2032,1.8,idrotm[1093],"ONLY");
3205      gMC->Gspos("I673",2,"I650",1.7678,6.0005,1.8,idrotm[1094],"ONLY");
3206      gMC->Gspos("I673",5,"I650",2.6847,5.6501,1.8,0,"ONLY");
3207      gMC->Gspos("I676",2,"I650",1.7618,5.2269,2.5,0,"ONLY");
3208      gMC->Gspos("I676",1,"I650",0.4018,5.5869,2.5,0,"ONLY");
3209      gMC->Gspos("I668",1,"I667",0.0,0.0,0.0,0,"ONLY");
3210      gMC->Gspos("I670",1,"I669",0.0,0.0,0.0,0,"ONLY");
3211      gMC->Gspos("I672",1,"I671",0.0,0.0,0.0,0,"ONLY");
3212      gMC->Gspos("I674",1,"I673",0.0,0.0,0.0,0,"MANY");
3213      gMC->Gspos("I675",1,"I673",0.0,0.0,-0.5,0,"ONLY");
3214      gMC->Gspos("I677",1,"I676",0.0,0.0,0.0,0,"MANY");
3215      gMC->Gspos("I678",1,"I676",0.0,0.0,-0.95,0,"ONLY");  
3216
3217   }
3218     
3219   // --- Place SDD volumes into their mother volume IT34
3220
3221   
3222   // -- position SDD detectors of ladder 3 / layer 3
3223
3224   gMC->Gspos("ITS3", 1,"I302",  0.0,      0.0,    0.0,    0,           "ONLY");
3225   ySDD = Y_SDD_sep/2.+I302dits[1];
3226   for (iSDD=0; iSDD<6; iSDD++) {
3227     gMC->Gspos("I302", iSDD+1, "I004",  0.0, ySDD,  Z_SDD_lay3[iSDD], 0, "ONLY");
3228     ySDD = -ySDD;
3229   }
3230
3231   gMC->Gspos("I004", 1,"IT34", -3.2777,  14.3607, 0.0,   idrotm[321],"ONLY");
3232   gMC->Gspos("I004", 2,"IT34", -9.5581,  11.9855, 0.0,   idrotm[333],"ONLY");
3233   gMC->Gspos("I004", 3,"IT34",-13.2713,   6.3911, 0.0,   idrotm[336],"ONLY");
3234   gMC->Gspos("I004", 4,"IT34",-15.33,     0.0,    0.0,   idrotm[350],"ONLY");
3235   gMC->Gspos("I004", 5,"IT34",-13.2713,  -6.3911, 0.0,   idrotm[313],"ONLY");
3236   gMC->Gspos("I004", 6,"IT34", -9.5581, -11.9855, 0.0,   idrotm[311],"ONLY");
3237   gMC->Gspos("I004", 7,"IT34", -3.2777, -14.3607, 0.0,   idrotm[310],"ONLY");
3238   gMC->Gspos("I004", 8,"IT34",  3.4112, -14.9456, 0.0,   idrotm[386],"ONLY");
3239   gMC->Gspos("I004", 9,"IT34",  9.184,  -11.5164, 0.0,   idrotm[309],"ONLY");
3240   gMC->Gspos("I004",10,"IT34", 13.8119,  -6.6514, 0.0,   idrotm[308],"ONLY");
3241   gMC->Gspos("I004",11,"IT34", 14.73,     0.0,    0.0,   idrotm[356],"ONLY");
3242   gMC->Gspos("I004",12,"IT34", 13.8119,   6.6514, 0.0,   idrotm[307],"ONLY");
3243   gMC->Gspos("I004",13,"IT34",  9.184,   11.5164, 0.0,   idrotm[306],"ONLY");
3244   gMC->Gspos("I004",14,"IT34",  3.4113,  14.9456, 0.0,   idrotm[305],"ONLY");
3245
3246
3247   // -- position SDD detectors of ladder 4 / layer 4
3248
3249   gMC->Gspos("ITS4", 1,"I402",  0.0,      0.000,  0.0,   0,"ONLY");
3250   ySDD = -(Y_SDD_sep/2.+I402dits[1]);
3251   for (iSDD=0; iSDD<8; iSDD++) {
3252     gMC->Gspos("I402", iSDD+1, "I005",  0.0, ySDD,  Z_SDD_lay4[iSDD], 0, "ONLY");
3253     ySDD = -ySDD;
3254   }
3255   
3256   gMC->Gspos("I005", 1,"IT34", -3.3629,  23.3895,-0.15,  idrotm[335],"ONLY");
3257   gMC->Gspos("I005", 2,"IT34",-10.0447,  21.9949,-0.15,  idrotm[332],"ONLY");
3258   gMC->Gspos("I005", 3,"IT34",-15.4744,  17.8584,-0.15,  idrotm[331],"ONLY");
3259   gMC->Gspos("I005", 4,"IT34",-20.3415,  13.0727,-0.15,  idrotm[366],"ONLY");
3260   gMC->Gspos("I005", 5,"IT34",-22.6728,   6.6573,-0.15,  idrotm[330],"ONLY");
3261   gMC->Gspos("I005", 6,"IT34",-24.18,     0.0,   -0.15,  idrotm[350],"ONLY");
3262   gMC->Gspos("I005", 7,"IT34",-22.6728,  -6.6573,-0.15,  idrotm[329],"ONLY");
3263   gMC->Gspos("I005", 8,"IT34",-20.3415, -13.0727,-0.15,  idrotm[328],"ONLY");
3264   gMC->Gspos("I005", 9,"IT34",-15.4744, -17.8584,-0.15,  idrotm[327],"ONLY");
3265   gMC->Gspos("I005",10,"IT34",-10.0447, -21.9949,-0.15,  idrotm[326],"ONLY");
3266   gMC->Gspos("I005",11,"IT34", -3.3629, -23.3895,-0.15,  idrotm[325],"ONLY");
3267   gMC->Gspos("I005",12,"IT34",  3.4412, -23.9339,-0.15,  idrotm[324],"ONLY");
3268   gMC->Gspos("I005",13,"IT34",  9.8163, -21.4946,-0.15,  idrotm[323],"ONLY");
3269   gMC->Gspos("I005",14,"IT34", 15.8345, -18.274, -0.15,  idrotm[322],"ONLY");
3270   gMC->Gspos("I005",15,"IT34", 19.8788, -12.7753,-0.15,  idrotm[320],"ONLY");
3271   gMC->Gspos("I005",16,"IT34", 23.2005,  -6.8123,-0.15,  idrotm[319],"ONLY");
3272   gMC->Gspos("I005",17,"IT34", 23.63,     0.0,   -0.15,  idrotm[318],"ONLY");
3273   gMC->Gspos("I005",18,"IT34", 23.2005,   6.8123,-0.15,  idrotm[317],"ONLY");
3274   gMC->Gspos("I005",19,"IT34", 19.8788,  12.7753,-0.15,  idrotm[316],"ONLY");
3275   gMC->Gspos("I005",20,"IT34", 15.8345,  18.274, -0.15,  idrotm[315],"ONLY");
3276   gMC->Gspos("I005",21,"IT34",  9.8163,  21.4946,-0.15,  idrotm[314],"ONLY");
3277   gMC->Gspos("I005",22,"IT34",  3.4412,  23.9339,-0.15,  idrotm[334],"ONLY");
3278
3279
3280   // -- build block of the SDD ladder frame holding the electronics
3281
3282   gMC->Gspos("I019", 1,"I018", -1.9,     -1.735,  0.0, idrotm[344], "ONLY");
3283   gMC->Gspos("I019", 2,"I018",  1.987,   -1.5843, 0.0, idrotm[343], "ONLY");
3284   gMC->Gspos("I019", 3,"I018", -0.087,    1.7066, 0.0, idrotm[342], "ONLY");
3285
3286   gMC->Gspos("I020", 1,"I018", -1.9782,  -1.569,  0.0, idrotm[342], "ONLY");
3287   gMC->Gspos("I020", 2,"I018",  1.8824,  -1.735,  0.0, idrotm[344], "ONLY");
3288   gMC->Gspos("I020", 3,"I018",  0.0958,   1.6913, 0.0, idrotm[343], "ONLY");
3289
3290   gMC->Gspos("I021", 1,"I018",  1.0761,   0.0835, 2.6008, idrotm[340], "ONLY");
3291   gMC->Gspos("I021", 2,"I018", -1.0761,   0.0835,-2.8008, idrotm[339], "ONLY");
3292   gMC->Gspos("I021", 3,"I018", -1.0761,   0.0835,-1.0492, idrotm[338], "ONLY");
3293   gMC->Gspos("I021", 4,"I018",  1.0761,   0.0835,-2.8008, idrotm[337], "ONLY");
3294   gMC->Gspos("I021", 5,"I018",  1.0761,   0.0835,-1.0492, idrotm[340], "ONLY");
3295   gMC->Gspos("I021", 6,"I018", -1.0761,   0.0835, 0.8492, idrotm[339], "ONLY");
3296   gMC->Gspos("I021", 7,"I018", -1.0761,   0.0835, 2.6008, idrotm[338], "ONLY");
3297   gMC->Gspos("I021", 8,"I018",  1.0761,   0.0835, 0.8492, idrotm[337], "ONLY");
3298
3299   gMC->Gspos("I022", 1,"I018",  0.0,     -1.79,   3.55,   idrotm[312], "ONLY");
3300   gMC->Gspos("I022", 2,"I018",  0.0,     -1.79,  -0.1,    idrotm[312], "ONLY");
3301
3302   gMC->Gspos("I023", 1,"I018",  0.0,     -1.79,   1.725,  idrotm[341], "ONLY");
3303   gMC->Gspos("I023", 2,"I018",  0.0,     -1.79,  -1.925,  idrotm[341], "ONLY");
3304
3305   gMC->Gspos("I033", 1,"I018",  1.8,     -1.75,   1.35,   0,           "MANY");
3306   gMC->Gspos("I033", 2,"I018", -1.8,     -1.75,  -2.65,   idrotm[345], "MANY");
3307   gMC->Gspos("I033", 3,"I018", -1.8,     -1.75,   1.35,   idrotm[345], "MANY");
3308   gMC->Gspos("I033", 4,"I018",  1.8,     -1.75,  -2.65,   0,           "MANY");
3309
3310   gMC->Gspos("I034", 1,"I018",  1.6,     -1.775,  1.35,   idrotm[312], "ONLY");
3311   gMC->Gspos("I034", 2,"I018", -1.6,     -1.775, -2.65,   idrotm[348], "ONLY");
3312   gMC->Gspos("I034", 3,"I018", -1.6,     -1.775,  1.35,   idrotm[348], "ONLY");
3313   gMC->Gspos("I034", 4,"I018",  1.6,     -1.775, -2.65,   idrotm[312], "ONLY");
3314
3315   gMC->Gspos("I035", 1,"I018",  1.7,     -0.55, I018dits[2]-I035dits[2], 0, "MANY");
3316   gMC->Gspos("I035", 2,"I018", -1.7,     -0.55, I018dits[2]-I035dits[2], 0, "MANY");
3317
3318   gMC->Gspos("I036", 1,"I018",  0.3087,   1.7191, 3.56,   idrotm[346], "ONLY");
3319   gMC->Gspos("I036", 2,"I018",  0.3087,   1.7191,-0.11,   idrotm[346], "ONLY");
3320   gMC->Gspos("I036", 3,"I018", -0.3087,   1.7191,-0.11,   idrotm[347], "ONLY");
3321   gMC->Gspos("I036", 4,"I018", -0.3087,   1.7191, 3.56,   idrotm[347], "ONLY");
3322
3323   gMC->Gspos("I037", 1,"I018",  SDD_CoolPipe[0], SDD_CoolPipe[1], SDD_CoolPipe[2], 0 , "ONLY");
3324   gMC->Gspos("I037", 2,"I018", -SDD_CoolPipe[0], SDD_CoolPipe[1], SDD_CoolPipe[2], 0 , "ONLY");
3325
3326   gMC->Gspos("I038", 1,"I018",  SDD_CoolPipe[0], SDD_CoolPipe[1], SDD_CoolPipe[2], 0 , "ONLY");
3327   gMC->Gspos("I038", 2,"I018", -SDD_CoolPipe[0], SDD_CoolPipe[1], SDD_CoolPipe[2], 0 , "ONLY");
3328
3329   gMC->Gspos("I040", 1,"I018",  1.9204,  -0.7118, 0.0, idrotm[346],"ONLY");
3330   gMC->Gspos("I040", 2,"I018", -1.9204,  -0.7118, 0.0, idrotm[347],"ONLY");
3331   gMC->Gspos("I041", 1,"I018",  SDD_CoolPipe[0], SDD_CoolPipe[1], SDD_CoolPipe[2], idrotm[346], "ONLY");
3332   gMC->Gspos("I041", 2,"I018", -SDD_CoolPipe[0], SDD_CoolPipe[1], SDD_CoolPipe[2], idrotm[347], "ONLY");
3333
3334
3335   // -- build block of the SDD electronics (heat bridge, chips, hybrid, anode microcable)
3336
3337   xI050 = SDD_CoolPipe[0]+SDD_CoolPipe[1]*sin30+I050dits[1]/cos30+I041dits[1];
3338   yI050 = 0;
3339   xI039 = -SDD_CoolPipe[1]/cos30;
3340   yI039 = -I050dits[1]+I039dits[1];
3341   gMC->Gspos("I039", 1,"I050",  xI039, yI039, 0.0, 0, "ONLY");
3342   xI042 = xI039+I039dits[0]-xI042space-I042dits[0];
3343   yI042 = yI039+I039dits[1]+I042dits[1];
3344   xI043 = xI039-I039dits[0]+xI043space+I043dits[0];
3345   yI043 = yI039+I039dits[1]+I043dits[1];
3346   zChipSpace = I042dits[2];
3347   if (zChipSpace < I043dits[2]) {
3348     zChipSpace = I043dits[2];
3349   }
3350   zChipSpace = zChipSpace * 2;
3351   yI051space = (2*I039dits[2] - 4*zChipSpace)/5;
3352   zchip = -I039dits[2] + yI051space + zChipSpace/2.;
3353   for (ichip=0; ichip<4; ichip++) { 
3354     gMC->Gspos("I042", ichip+1, "I050", xI042, yI042, zchip, 0, "ONLY");
3355     gMC->Gspos("I043", ichip+1, "I050", xI043, yI043, zchip, 0, "ONLY");
3356     zchip += zChipSpace + yI051space;
3357   }
3358   xcap = 2*I039dits[0]/5.;
3359   yI051 = yI039+I039dits[1]+I051dits[1];
3360   zI051 = -I039dits[2] + yI051space/3.;
3361   icap = 1;
3362   for (ichip=0; ichip<5; ichip++) { 
3363     xI051 = xI039-I039dits[0]+xcap;
3364     gMC->Gspos("I051", icap++,"I050", xI051, yI051, zI051, 0, "ONLY");
3365     zI051 += yI051space/3.;
3366     gMC->Gspos("I051", icap++,"I050", xI051, yI051, zI051, 0, "ONLY");
3367     xI051 += xcap;
3368     gMC->Gspos("I051", icap++,"I050", xI051, yI051, zI051, 0, "ONLY");
3369     xI051 += xcap;
3370     gMC->Gspos("I051", icap++,"I050", xI051, yI051, zI051, 0, "ONLY");
3371     xI051 += xcap;
3372     gMC->Gspos("I051", icap++,"I050", xI051, yI051, zI051, 0, "ONLY");
3373     zI051 -= yI051space/3.;
3374     if (ichip == 0) {
3375       gMC->Gspos("I051", icap++,"I050", xI051, yI051, zI051, 0, "ONLY");
3376     }
3377     zI051 += zChipSpace + yI051space;
3378   }
3379   xI052 = -I050dits[0]+I052dits[0];
3380   yI052 = yI051+I051dits[1]+I052dits[1];
3381   gMC->Gspos("I052", 1,"I050", xI052, yI052, 0.0, 0, "ONLY");
3382   xI044 = I050dits[0]-I044dits[3];
3383   yI044 = yI052+I052dits[1]+I044dits[2];
3384   gMC->Gspos("I044", 1,"I050", xI044, yI044, 0.0, idrotm[301], "ONLY");
3385   gMC->Gspos("I050", 1,"I018",  xI050,  yI050,  0.0, idrotm[346],"ONLY");
3386   gMC->Gspos("I050", 2,"I018", -xI050,  yI050,  0.0, idrotm[347],"ONLY");
3387
3388
3389   // -- build block of the SDD ladder frame at the end ladders
3390
3391   gMC->Gspos("I021",12,"I024",  1.0761,   0.0836,-0.1242, idrotm[340], "ONLY");
3392   gMC->Gspos("I021",11,"I024", -1.0761,   0.0836,-0.1242, idrotm[338], "ONLY");
3393   gMC->Gspos("I021",13,"I024", -1.0761,   0.0836,-1.8758, idrotm[339], "ONLY");
3394   gMC->Gspos("I021",14,"I024",  1.0761,   0.0836,-1.8758, idrotm[337], "ONLY");
3395
3396   gMC->Gspos("I022", 3,"I024",  0.0,     -1.7899, 0.825,  idrotm[312], "ONLY");
3397
3398   gMC->Gspos("I023", 3,"I024",  0.0,     -1.7899,-1.0,    idrotm[341], "ONLY");
3399
3400   gMC->Gspos("I025", 1,"I024", -1.9,     -1.7349, 0.0,    idrotm[344], "ONLY");
3401   gMC->Gspos("I025", 2,"I024",  1.987,   -1.5842, 0.0,    idrotm[343], "ONLY");
3402
3403   gMC->Gspos("I026", 1,"I024", -1.9782,  -1.5689, 0.0,    idrotm[342], "ONLY");
3404   gMC->Gspos("I026", 2,"I024",  1.8824,  -1.7349, 0.0,    idrotm[344], "ONLY");
3405
3406   gMC->Gspos("I029", 1,"I024", -0.087,    1.7067, I029dits[2]-I024dits[2], idrotm[342], "ONLY");
3407
3408   gMC->Gspos("I030", 1,"I024",  0.0958,   1.6914, I030dits[2]-I024dits[2], idrotm[343], "ONLY");
3409
3410   gMC->Gspos("I031", 1,"I024",  SDD_CoolPipe[0], SDD_CoolPipe[1], SDD_CoolPipe[2], 0 ,"ONLY");
3411   gMC->Gspos("I031", 2,"I024", -SDD_CoolPipe[0], SDD_CoolPipe[1], SDD_CoolPipe[2], 0 ,"ONLY");
3412
3413   gMC->Gspos("I032", 1,"I024",  SDD_CoolPipe[0], SDD_CoolPipe[1], SDD_CoolPipe[2], 0 ,"ONLY");
3414   gMC->Gspos("I032", 2,"I024", -SDD_CoolPipe[0], SDD_CoolPipe[1], SDD_CoolPipe[2], 0 ,"ONLY");
3415
3416
3417   xI424 = I028dits[0]/3.;
3418   yI424 = -I028dits[1]+I424dits[1];
3419   gMC->Gspos("I422", 1,"I421", 0.0, 0.0, 0.0, 0, "ONLY");
3420   gMC->Gspos("I423", 1,"I421", 0.0, 0.0, I421dits[2]-I423dits[2], 0, "ONLY");
3421   gMC->Gspos("I421", 1,"I420", 0.0, 0.0, 0.0, idrotm[312], "ONLY");
3422   gMC->Gspos("I420", 1,"I028", -I028dits[0]/3., I028dits[1]-I420dits[1], 0.0, 0, "ONLY");
3423   gMC->Gspos("I424", 1,"I028", xI424, yI424, 0.0, 0, "ONLY");
3424   gMC->Gspos("I028", 1,"I024", 0.0, I028dits[1]-I024dits[1], I024dits[2]-I028dits[2], 0, "MANY");
3425
3426
3427   // -- build the SDD ladder 3
3428
3429   indI425 = 1;
3430   gMC->Gspos("I024", 1,"I047",  0.0,      0.0,   24.625, 0,           "ONLY");  
3431   gMC->Gspos("I018", 1,"I047",  0.0,      0.0,    3.65,  0,           "ONLY");
3432   gMC->Gspos("I018", 2,"I047",  0.0,      0.0,   10.95,  0,           "ONLY");
3433   gMC->Gspos("I018", 3,"I047",  0.0,      0.0,   18.25,  0,           "ONLY");
3434   gMC->Gspos("I018", 4,"I047",  0.0,      0.0,   -3.65,  0,           "ONLY");
3435   gMC->Gspos("I018", 5,"I047",  0.0,      0.0,  -10.95,  0,           "ONLY");
3436   gMC->Gspos("I018", 6,"I047",  0.0,      0.0,  -18.25,  0,           "ONLY");
3437   gMC->Gspos("I024", 2,"I047",  0.0,      0.0,  -24.625, idrotm[355], "ONLY");
3438   HVname[0] = 'I';
3439   HVname[1] = '3';
3440   HVname[2] = '1';  
3441   HVname[4] = '\0';
3442   for (iSDD=0; iSDD<3; iSDD++) {
3443     HVname[3] = (Char_t)(48+iSDD+5);
3444     dits[0] = 1.350000;
3445     dits[1] = I425dits[1];
3446     dits[2] = (I047dits[2] - 2*I024dits[2] - Z_SDD_lay3[iSDD])/2.;
3447     gMC->Gsvolu(HVname, "BOX ", idtmed[279], dits, 3);
3448     xHV = 0.0;
3449     yHV = -I047dits[1] + (2*iSDD+1)*dits[1];
3450     zHV = I047dits[2] - 2*I024dits[2] - dits[2];
3451     gMC->Gspos(HVname, 1,"I047", xHV, yHV,  zHV, 0, "ONLY");
3452     gMC->Gspos(HVname, 2,"I047", xHV, yHV, -zHV, 0, "ONLY");
3453     gMC->Gspos("I425", indI425++,"I047",  xI424, yHV,   24.625, 0, "ONLY");
3454     gMC->Gspos("I425", indI425++,"I047", -xI424, yHV,  -24.625, 0, "ONLY");
3455   }
3456   LVname[0] = 'I';
3457   LVname[1] = '3';
3458   LVname[2] = '1';  
3459   LVname[4] = '\0';
3460   for (iSDD=0; iSDD<3; iSDD++) {