]> git.uio.no Git - u/mrichter/AliRoot.git/blob - MUON/AliMUONSt1GeometryBuilderV2.cxx
coding violation fixes
[u/mrichter/AliRoot.git] / MUON / AliMUONSt1GeometryBuilderV2.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 // $Id$
17 //
18 //-----------------------------------------------------------------------------
19 // Class AliMUONSt1GeometryBuilderV2
20 // ---------------------------------
21 // MUON Station1 detailed geometry construction class.
22 // (Originally defined in AliMUONv2.cxx - now removed.)
23 // Included in AliRoot 2004/01/23
24 // Authors: David Guez, Ivana Hrivnacova, Marion MacCormick; IPN Orsay
25 //-----------------------------------------------------------------------------
26
27 #include "AliMUONSt1GeometryBuilderV2.h"
28 #include "AliMUONSt1SpecialMotif.h"
29 #include "AliMUON.h"
30 #include "AliMUONConstants.h"
31 #include "AliMUONGeometryModule.h"
32 #include "AliMUONGeometryEnvelopeStore.h"
33
34 #include "AliMpSegmentation.h"
35 #include "AliMpDEManager.h"
36 #include "AliMpContainers.h"
37 #include "AliMpConstants.h"
38 #include "AliMpCDB.h"
39 #include "AliMpSectorSegmentation.h"
40 #include "AliMpSector.h"
41 #include "AliMpRow.h"
42 #include "AliMpVRowSegment.h"
43 #include "AliMpMotifMap.h"
44 #include "AliMpMotifPosition.h"
45 #include "AliMpPlaneType.h"
46
47 #include "AliRun.h"
48 #include "AliMagF.h"
49 #include "AliLog.h"
50
51 #include <TVector2.h>
52 #include <TVector3.h>
53 #include <TGeoMatrix.h>
54 #include <TClonesArray.h>
55 #include <Riostream.h>
56 #include <TSystem.h>
57 #include <TVirtualMC.h>
58 #include <TGeoManager.h>
59 #include <TGeoVolume.h>
60 #include <TGeoTube.h>
61 #include <TGeoCompositeShape.h>
62
63 #ifdef WITH_STL
64   #include <vector>
65 #endif
66
67 #ifdef WITH_ROOT
68   #include "TArrayI.h"
69 #endif
70
71 /// \cond CLASSIMP
72 ClassImp(AliMUONSt1GeometryBuilderV2)
73 /// \endcond
74
75 // Thickness Constants
76 const GReal_t AliMUONSt1GeometryBuilderV2::fgkHzPadPlane=0.0148/2.;     //Pad plane
77 const GReal_t AliMUONSt1GeometryBuilderV2::fgkHzFoam = 2.503/2.;        //Foam of mechanicalplane
78 const GReal_t AliMUONSt1GeometryBuilderV2::fgkHzFR4 = 0.062/2.;         //FR4 of mechanical plane
79 const GReal_t AliMUONSt1GeometryBuilderV2::fgkHzSnPb = 0.0091/2.;       //Pad/Kapton connection (66 pt)
80 const GReal_t AliMUONSt1GeometryBuilderV2::fgkHzKapton = 0.0122/2.;     //Kapton
81 const GReal_t AliMUONSt1GeometryBuilderV2::fgkHzBergPlastic = 0.3062/2.;//Berg connector
82 const GReal_t AliMUONSt1GeometryBuilderV2::fgkHzBergCopper = 0.1882/2.; //Berg connector
83 const GReal_t AliMUONSt1GeometryBuilderV2::fgkHzDaughter = 0.0156/2.;   //Daughter board
84 const GReal_t AliMUONSt1GeometryBuilderV2::fgkHzGas = 0.42/2.;          //Gas thickness
85
86 // Quadrant Mother volume - TUBS1 - Middle layer of model
87 const GReal_t AliMUONSt1GeometryBuilderV2::fgkMotherIR1 = 18.3;
88 const GReal_t AliMUONSt1GeometryBuilderV2::fgkMotherOR1 = 105.673;   
89 const GReal_t AliMUONSt1GeometryBuilderV2::fgkMotherThick1 = 6.5/2;  
90 const GReal_t AliMUONSt1GeometryBuilderV2::fgkMotherPhiL1 = 0.; 
91 const GReal_t AliMUONSt1GeometryBuilderV2::fgkMotherPhiU1 = 90.;
92
93 // Quadrant Mother volume - TUBS2 - near and far layers of model
94 const GReal_t AliMUONSt1GeometryBuilderV2::fgkMotherIR2 = 20.7;   
95 const GReal_t AliMUONSt1GeometryBuilderV2::fgkMotherOR2 = 100.073;   
96 const GReal_t AliMUONSt1GeometryBuilderV2::fgkMotherThick2 = 3.0/2; 
97 const GReal_t AliMUONSt1GeometryBuilderV2::fgkMotherPhiL2 = 0.; 
98 const GReal_t AliMUONSt1GeometryBuilderV2::fgkMotherPhiU2 = 90.;
99
100 // Sensitive copper pads, foam layer, PCB and electronics model parameters
101 const GReal_t AliMUONSt1GeometryBuilderV2::fgkHxHole=1.5/2.;
102 const GReal_t AliMUONSt1GeometryBuilderV2::fgkHyHole=6./2.;
103 const GReal_t AliMUONSt1GeometryBuilderV2::fgkHxBergPlastic=0.74/2.;
104 const GReal_t AliMUONSt1GeometryBuilderV2::fgkHyBergPlastic=5.09/2.;
105 const GReal_t AliMUONSt1GeometryBuilderV2::fgkHxBergCopper=0.25/2.;
106 const GReal_t AliMUONSt1GeometryBuilderV2::fgkHyBergCopper=3.6/2.;
107 const GReal_t AliMUONSt1GeometryBuilderV2::fgkHxKapton=0.8/2.;
108 const GReal_t AliMUONSt1GeometryBuilderV2::fgkHyKapton=5.7/2.;
109 const GReal_t AliMUONSt1GeometryBuilderV2::fgkHxDaughter=2.3/2.;
110 const GReal_t AliMUONSt1GeometryBuilderV2::fgkHyDaughter=6.3/2.;
111 const GReal_t AliMUONSt1GeometryBuilderV2::fgkOffsetX=1.46;
112 const GReal_t AliMUONSt1GeometryBuilderV2::fgkOffsetY=0.71;
113 const GReal_t AliMUONSt1GeometryBuilderV2::fgkDeltaFilleEtamX=1.46;
114 const GReal_t AliMUONSt1GeometryBuilderV2::fgkDeltaFilleEtamY=0.051;
115
116 const GReal_t AliMUONSt1GeometryBuilderV2::fgkDeltaQuadLHC=2.6;  // LHC Origin wrt Quadrant Origin
117 const GReal_t AliMUONSt1GeometryBuilderV2::fgkFrameOffset=5.2;
118               // Fix (1) of overlap SQN* layers with SQM* ones (was 5.0)
119               
120 // Pad planes offsets
121 const GReal_t AliMUONSt1GeometryBuilderV2::fgkPadXOffsetBP =  0.50 - 0.63/2; // = 0.185
122 const GReal_t AliMUONSt1GeometryBuilderV2::fgkPadYOffsetBP = -0.31 - 0.42/2; // =-0.52
123
124 const char* AliMUONSt1GeometryBuilderV2::fgkHoleName="SCHL";      
125 const char* AliMUONSt1GeometryBuilderV2::fgkDaughterName="SCDB";  
126 const char* AliMUONSt1GeometryBuilderV2::fgkQuadrantEnvelopeName="SE";
127 const char* AliMUONSt1GeometryBuilderV2::fgkQuadrantMLayerName="SQM";
128 const char* AliMUONSt1GeometryBuilderV2::fgkQuadrantNLayerName="SQN";
129 const char* AliMUONSt1GeometryBuilderV2::fgkQuadrantFLayerName="SQF";
130 const Int_t AliMUONSt1GeometryBuilderV2::fgkFoamBoxNameOffset=200; 
131 const Int_t AliMUONSt1GeometryBuilderV2::fgkFR4BoxNameOffset=400; 
132 const Int_t AliMUONSt1GeometryBuilderV2::fgkDaughterCopyNoOffset=1000;
133
134 //______________________________________________________________________________
135 AliMUONSt1GeometryBuilderV2::AliMUONSt1GeometryBuilderV2(AliMUON* muon)
136   : AliMUONVGeometryBuilder(0, 2),
137     fMUON(muon)
138 {
139 /// Standard constructor
140 }
141  
142 //______________________________________________________________________________
143 AliMUONSt1GeometryBuilderV2::AliMUONSt1GeometryBuilderV2()
144   : AliMUONVGeometryBuilder(),
145     fMUON(0)
146 {
147 /// Default Constructor
148 }
149
150 //______________________________________________________________________________
151 AliMUONSt1GeometryBuilderV2::~AliMUONSt1GeometryBuilderV2()
152 {
153 /// Destructor
154 }
155
156
157 //
158 //  Private methods
159 //
160
161 //______________________________________________________________________________
162 TString 
163 AliMUONSt1GeometryBuilderV2::QuadrantEnvelopeName(Int_t chamber, Int_t quadrant) const
164
165 /// Generate unique envelope name from chamber Id and quadrant number
166
167   return Form("%s%d", Form("%s%d",fgkQuadrantEnvelopeName,chamber), quadrant); 
168 }
169
170 //______________________________________________________________________________
171 void AliMUONSt1GeometryBuilderV2::CreateHole()
172 {
173 /// Create all the elements found inside a foam hole
174
175   Int_t* idtmed = fMUON->GetIdtmed()->GetArray()-1099;
176   Int_t idAir  = idtmed[1100];      // medium 1
177   //Int_t idCopper  = idtmed[1109]; // medium 10 = copper 
178   Int_t idCopper  = idtmed[1121]; // medium 22 = copper 
179
180   GReal_t par[3];
181   GReal_t posX,posY,posZ;
182   
183   par[0] = fgkHxHole;
184   par[1] = fgkHyHole;
185   par[2] = fgkHzFoam;
186   gMC->Gsvolu(fgkHoleName,"BOX",idAir,par,3);
187
188   par[0] = fgkHxKapton;
189   par[1] = fgkHyKapton;
190   par[2] = fgkHzSnPb;
191   gMC->Gsvolu("SNPB", "BOX", idCopper, par, 3);
192   posX = 0.;
193   posY = 0.;
194   posZ = -fgkHzFoam+fgkHzSnPb;
195   gMC->Gspos("SNPB",1,fgkHoleName, posX, posY, posZ, 0,"ONLY");
196
197   par[0] = fgkHxHole;
198   par[1] = fgkHyBergPlastic;
199   par[2] = fgkHzKapton;
200   gMC->Gsvolu("SKPT", "BOX", idCopper, par, 3);
201   posX = 0.;
202   posY = 0.;
203   posZ = 0.;
204   gMC->Gspos("SKPT",1,fgkHoleName, posX, posY, posZ, 0,"ONLY");
205 }
206
207 //______________________________________________________________________________
208 void AliMUONSt1GeometryBuilderV2::CreateDaughterBoard()
209 {
210 /// Create all the elements in a daughter board
211
212   Int_t* idtmed = fMUON->GetIdtmed()->GetArray()-1099;
213   Int_t idAir  = idtmed[1100]; // medium 1
214   //Int_t idCopper  = idtmed[1109]; // medium 10 = copper
215   //Int_t idPlastic  =idtmed[1116]; // medium 17 = Plastic
216   Int_t idCopper  = idtmed[1121]; // medium 22 = copper
217   Int_t idPlastic  =idtmed[1127]; // medium 28 = Plastic
218
219   GReal_t par[3];
220   GReal_t posX,posY,posZ;
221
222   par[0]=fgkHxDaughter;
223   par[1]=fgkHyDaughter;
224   par[2]=TotalHzDaughter();
225   gMC->Gsvolu(fgkDaughterName,"BOX",idAir,par,3);
226   
227   par[0]=fgkHxBergPlastic;
228   par[1]=fgkHyBergPlastic;
229   par[2]=fgkHzBergPlastic;
230   gMC->Gsvolu("SBGP","BOX",idPlastic,par,3);
231   posX=0.;
232   posY=0.;
233   posZ = -TotalHzDaughter() + fgkHzBergPlastic;
234   gMC->Gspos("SBGP",1,fgkDaughterName,posX,posY,posZ,0,"ONLY");
235
236   par[0]=fgkHxBergCopper;
237   par[1]=fgkHyBergCopper;
238   par[2]=fgkHzBergCopper;
239   gMC->Gsvolu("SBGC","BOX",idCopper,par,3);
240   posX=0.;
241   posY=0.;
242   posZ=0.;
243   gMC->Gspos("SBGC",1,"SBGP",posX,posY,posZ,0,"ONLY");
244
245   par[0]=fgkHxDaughter;
246   par[1]=fgkHyDaughter;
247   par[2]=fgkHzDaughter;
248   gMC->Gsvolu("SDGH","BOX",idCopper,par,3);
249   posX=0.;
250   posY=0.;
251   posZ = -TotalHzDaughter() + 2.*fgkHzBergPlastic + fgkHzDaughter;
252   gMC->Gspos("SDGH",1,fgkDaughterName,posX,posY,posZ,0,"ONLY");
253 }
254
255 //______________________________________________________________________________
256 void AliMUONSt1GeometryBuilderV2::CreateInnerLayers()
257 {
258 /// Create the layer of sensitive volumes with gas
259 /// and the copper layer.
260
261 // Gas Medium
262   Int_t* idtmed = fMUON->GetIdtmed()->GetArray()-1099; 
263   Int_t idArCO2  = idtmed[1108];  // medium 9 (ArCO2 80%) 
264   //Int_t idCopper  = idtmed[1109]; // medium 10 = copper
265   //Int_t idArCO2   = idtmed[1124]; // medium 25 (ArCO2 80%) 
266   Int_t idCopper  = idtmed[1121]; // medium 22 = copper
267
268   Float_t par[11];
269
270 //Make gas volume - composed of 11 trapezoids
271 // section 1 of 11
272     par[0] = fgkHzGas;
273     par[1] = 0.;
274     par[2] = 0.;
275     par[3] = 71.33/2.;
276     par[4] = 9.76/2.;
277     par[5] = 48.77/2.;
278     par[6] = 15.3;
279     par[7] = 71.33/2.;
280     par[8] = 9.76/2.;
281     par[9] = 48.77/2.;
282     par[10] = 15.3;        
283
284   gMC->Gsvolu("SA1G", "TRAP", idArCO2, par, 11);
285   gMC->Gsvolu("SA2G", "TRAP", idArCO2, par, 11);
286   
287   par[0] = fgkHzPadPlane;
288   gMC->Gsvolu("SA1C", "TRAP", idCopper,par, 11);
289
290 // section 2 of 11  
291     par[0] = fgkHzGas;
292     par[1] = 0.;
293     par[2] = 0.;
294     par[3] = 79.68/2.;
295     par[4] = 10.4/2.;
296     par[5] = 57.0/2.;
297     par[6] = 0.;  
298     par[7] = 79.68/2.; 
299     par[8] = 10.4/2.;
300     par[9] = 57.0/2.;
301     par[10] = 0.;  
302   gMC->Gsvolu("SB1G", "TRAP", idArCO2, par, 11);  
303   gMC->Gsvolu("SB2G", "TRAP", idArCO2, par, 11);
304
305   par[0] = fgkHzPadPlane;
306   gMC->Gsvolu("SB1C", "TRAP", idCopper,par, 11);
307
308 // section 3 of 11
309     par[0] = fgkHzGas;
310     par[1] = 0.;
311     par[2] = 0.;
312     par[3] = 71.33/2.;
313     par[4] = 48.77/2.;
314     par[5] = 9.73/2.;
315     par[6] = -15.3;
316     par[7] = 71.33/2.;
317     par[8] = 48.77/2.;
318     par[9] = 9.73/2.;
319     par[10] = -15.3;   
320  
321   gMC->Gsvolu("SC1G", "TRAP", idArCO2, par, 11);  
322   gMC->Gsvolu("SC2G", "TRAP", idArCO2, par, 11);
323
324   par[0] = fgkHzPadPlane;
325   gMC->Gsvolu("SC1C", "TRAP", idCopper,par, 11);
326
327 // section 4 of 11
328     par[0] = fgkHzGas;
329     par[1] = 0.;
330     par[2] = 0.;
331     par[3] = 6.00/2.;
332     par[4] = 0.;
333     par[5] = 1.56/2.;
334     par[6] = 7.41; 
335     par[7] = 6.00/2.; 
336     par[8] = 0.;
337     par[9] = 1.56/2.;
338     par[10] = 7.41;    
339   gMC->Gsvolu("SD1G", "TRAP", idArCO2, par, 11);  
340   gMC->Gsvolu("SD2G", "TRAP", idArCO2, par, 11);
341
342   par[0] = fgkHzPadPlane;
343   gMC->Gsvolu("SD1C", "TRAP", idCopper,par, 11);
344
345 // section 5 of 11  
346     par[0] = fgkHzGas;
347     par[1] = 0.;
348     par[2] = 0.;
349     par[3] = 1.516/2.;
350     par[4] = 0.;
351     par[5] = 0.829/2.;
352     par[6] = 15.3;
353     par[7] = 1.516/2.;
354     par[8] = 0.;
355     par[9] = 0.829/2.;
356     par[10] = 15.3;   
357   gMC->Gsvolu("SE1G", "TRAP", idArCO2, par, 11);  
358   gMC->Gsvolu("SE2G", "TRAP", idArCO2, par, 11);
359
360   par[0] = fgkHzPadPlane;
361   gMC->Gsvolu("SE1C", "TRAP", idCopper,par, 11);
362
363 // section 6 of 11
364     par[0] = fgkHzGas;
365     par[1] = 0.;
366     par[2] = 0.;
367     par[3] = 3.92/2.;
368     par[4] = 0.;
369     par[5] = 0.562/2.;
370     par[6] = -4.1;
371     par[7] = 3.92/2.;
372     par[8] = 0.;
373     par[9] = 0.562/2.;
374     par[10] = -4.1;   
375   gMC->Gsvolu("SF1G", "TRAP", idArCO2, par, 11);  
376   gMC->Gsvolu("SF2G", "TRAP", idArCO2, par, 11);
377     
378   par[0] = fgkHzPadPlane;
379   gMC->Gsvolu("SF1C", "TRAP", idCopper,par, 11);
380
381 // section 7 of 11
382     par[0] = fgkHzGas;
383     par[1] = 0.;
384     par[2] = 0.;
385     par[3] = 0.941/2.;
386     par[4] = 0.562/2.;
387     par[5] = 0.;
388     par[6] = -16.6; 
389     par[7] = 0.941/2.;
390     par[8] = 0.562/2.;
391     par[9] = 0.;
392     par[10] =-16.6;    
393   gMC->Gsvolu("SG1G", "TRAP", idArCO2, par, 11);  
394   gMC->Gsvolu("SG2G", "TRAP", idArCO2, par, 11);
395
396   par[0] = fgkHzPadPlane;
397   gMC->Gsvolu("SG1C", "TRAP", idCopper,par, 11);
398
399 // section 8 of 11
400     par[0] = fgkHzGas;
401     par[1] = 0.;
402     par[2] = 0.;
403     par[3] = 3.94/2.;
404     par[4] = 0.57/2.;
405     par[5] = 0.;
406     par[6] = 4.14; 
407     par[7] = 3.94/2.; 
408     par[8] = 0.57/2.;
409     par[9] = 0.;
410     par[10] = 4.14;    
411   gMC->Gsvolu("SH1G", "TRAP", idArCO2, par, 11);  
412   gMC->Gsvolu("SH2G", "TRAP", idArCO2, par, 11);
413
414   par[0] = fgkHzPadPlane;
415   gMC->Gsvolu("SH1C", "TRAP", idCopper,par, 11);
416
417 // section 9 of 11  
418     par[0] = fgkHzGas;
419     par[1] = 0.;
420     par[2] = 0.;
421     par[3] = 0.95/2.;
422     par[4] = 0.;
423     par[5] = 0.57/2;
424     par[6] = 16.7;
425     par[7] = 0.95/2.;
426     par[8] = 0.;
427     par[9] = 0.57/2;
428     par[10] = 16.7;   
429   gMC->Gsvolu("SI1G", "TRAP", idArCO2, par, 11);  
430   gMC->Gsvolu("SI2G", "TRAP", idArCO2, par, 11);
431
432   par[0] = fgkHzPadPlane;
433   gMC->Gsvolu("SI1C", "TRAP", idCopper,par, 11);
434
435 // section 10 of 11
436     par[0] = fgkHzGas;
437     par[1] = 0.;
438     par[2] = 0.;
439     par[3] = 1.49/2.;
440     par[4] = 0.;
441     par[5] = 0.817/2.;
442     par[6] = -15.4;
443     par[7] = 1.49/2.;
444     par[8] = 0.;
445     par[9] = 0.817/2.;
446     par[10] = -15.4;   
447   gMC->Gsvolu("SJ1G", "TRAP", idArCO2, par, 11);  
448   gMC->Gsvolu("SJ2G", "TRAP", idArCO2, par, 11);
449     
450   par[0] = fgkHzPadPlane;
451   gMC->Gsvolu("SJ1C", "TRAP", idCopper,par, 11);
452
453 // section 11 of 11
454     par[0] = fgkHzGas;
455     par[1] = 0.;
456     par[2] = 0.;
457     par[3] = 5.93/2.;
458     par[4] = 0.;
459     par[5] = 1.49/2.;
460     par[6] = -7.16; 
461     par[7] = 5.93/2.;
462     par[8] = 0.;
463     par[9] = 1.49/2.;
464     par[10] = -7.16;    
465   gMC->Gsvolu("SK1G", "TRAP", idArCO2, par, 11);  
466   gMC->Gsvolu("SK2G", "TRAP", idArCO2, par, 11);
467
468   par[0] = fgkHzPadPlane;
469   gMC->Gsvolu("SK1C", "TRAP", idCopper,par, 11);
470 }
471
472 //______________________________________________________________________________
473 void AliMUONSt1GeometryBuilderV2::CreateQuadrant(Int_t chamber)
474 {
475 /// Create the quadrant (bending and non-bending planes)
476 /// for the given chamber
477
478   CreateFrame(chamber);
479
480 #ifdef WITH_STL
481   SpecialMap specialMap;
482   specialMap[76] = AliMUONSt1SpecialMotif(TVector2( 0.1, 0.84), 90.);
483   specialMap[75] = AliMUONSt1SpecialMotif(TVector2( 0.5, 0.36));
484   specialMap[47] = AliMUONSt1SpecialMotif(TVector2(1.01, 0.36));
485 #endif
486   
487 #ifdef WITH_ROOT
488   SpecialMap specialMap;
489   specialMap.Add(76, (Long_t) new AliMUONSt1SpecialMotif(TVector2( 0.1, 0.84), 90.));
490   specialMap.Add(75, (Long_t) new AliMUONSt1SpecialMotif(TVector2( 0.5, 0.36)));
491   specialMap.Add(47, (Long_t) new AliMUONSt1SpecialMotif(TVector2(1.01, 0.36)));
492 #endif
493
494   // Load mapping from OCDB
495   if ( ! AliMpSegmentation::Instance() ) {
496     AliFatal("Mapping has to be loaded first !");
497   }
498        
499   const AliMpSectorSegmentation* kSegmentation1 
500     = dynamic_cast<const AliMpSectorSegmentation*>(
501         AliMpSegmentation::Instance()
502           ->GetMpSegmentation(100, AliMpDEManager::GetCathod(100, AliMp::kBendingPlane))); 
503   if ( ! kSegmentation1 ) {
504     AliFatal("Could not access sector segmentation !");
505   }
506     
507   const AliMpSector* kSector1 = kSegmentation1->GetSector();
508 /*
509   AliMpSectorReader reader1(AliMp::kStation1, AliMp::kBendingPlane);
510   AliMpSector* kSector1 = reader1.BuildSector();
511 */
512   //Bool_t reflectZ = true;
513   Bool_t reflectZ = false;
514   //TVector3 where = TVector3(2.5+0.1+0.56+0.001, 2.5+0.1+0.001, 0.);
515   TVector3 where = TVector3(fgkDeltaQuadLHC + fgkPadXOffsetBP, 
516                             fgkDeltaQuadLHC + fgkPadYOffsetBP, 0.);
517   PlaceSector(kSector1, specialMap, where, reflectZ, chamber);
518   
519 #ifdef WITH_STL
520   specialMap.clear();
521   specialMap[76] = AliMUONSt1SpecialMotif(TVector2(1.01,0.59),90.);
522   specialMap[75] = AliMUONSt1SpecialMotif(TVector2(1.96, 0.17));
523   specialMap[47] = AliMUONSt1SpecialMotif(TVector2(2.18,-0.98));
524   specialMap[20] = AliMUONSt1SpecialMotif(TVector2(0.2 ,-0.08));
525   specialMap[46] = AliMUONSt1SpecialMotif(TVector2(0.2 , 0.25));
526   specialMap[74] = AliMUONSt1SpecialMotif(TVector2(0.28, 0.21));
527       // Fix (7) - overlap of SQ42 with MCHL (after moving the whole sector
528       // in the true position)   
529       // Was: specialMap[47] = AliMUONSt1SpecialMotif(TVector2(1.61,-1.18));
530 #endif
531
532 #ifdef WITH_ROOT
533   Int_t nb = AliMpConstants::ManuMask(AliMp::kNonBendingPlane);
534   specialMap.Delete();
535   specialMap.Add(76 | nb,(Long_t) new AliMUONSt1SpecialMotif(TVector2(1.01,0.59),90.));
536   specialMap.Add(75 | nb,(Long_t) new AliMUONSt1SpecialMotif(TVector2(1.96, 0.17)));
537   specialMap.Add(47 | nb,(Long_t) new AliMUONSt1SpecialMotif(TVector2(2.18,-0.98)));
538   specialMap.Add(20 | nb,(Long_t) new AliMUONSt1SpecialMotif(TVector2(0.2 ,-0.08)));
539   specialMap.Add(46 | nb,(Long_t) new AliMUONSt1SpecialMotif(TVector2(0.2 , 0.25)));
540   specialMap.Add(74 | nb,(Long_t) new AliMUONSt1SpecialMotif(TVector2(0.28, 0.21)));  
541       // Fix (7) - overlap of SQ42 with MCHL (after moving the whole sector
542       // in the true position)   
543       // Was: specialMap.Add(47,(Long_t) new AliMUONSt1SpecialMotif(TVector2(1.61,-1.18)));
544 #endif
545 /*
546   AliMpSectorReader reader2(AliMp::kStation1, AliMp::kNonBendingPlane);
547   AliMpSector* sector2 = reader2.BuildSector();
548 */  
549   const AliMpSectorSegmentation* kSegmentation2 
550     = dynamic_cast<const AliMpSectorSegmentation*>(
551         AliMpSegmentation::Instance()
552           ->GetMpSegmentation(100, AliMpDEManager::GetCathod(100, AliMp::kNonBendingPlane))); 
553   if ( ! kSegmentation2 ) {
554     AliFatal("Could not access sector segmentation !");
555   }
556     
557   const AliMpSector* kSector2 = kSegmentation2->GetSector();
558
559   //reflectZ = false;
560   reflectZ = true;
561   TVector2 offset = kSector2->Position();
562   where = TVector3(where.X()+offset.X(), where.Y()+offset.Y(), 0.); 
563       // Add the half-pad shift of the non-bending plane wrt bending plane
564       // (The shift is defined in the mapping as sector offset)
565       // Fix (4) - was TVector3(where.X()+0.63/2, ... - now it is -0.63/2
566   PlaceSector(kSector2, specialMap, where, reflectZ, chamber);
567
568 #ifdef WITH_ROOT
569   specialMap.Delete();
570 #endif
571 }
572
573 //______________________________________________________________________________
574 void AliMUONSt1GeometryBuilderV2::CreateFoamBox(
575                                         Int_t segNumber,
576                                         const  TVector2& dimensions)
577 {
578 /// Create all the elements in the copper plane
579
580   Int_t* idtmed = fMUON->GetIdtmed()->GetArray()-1099;
581   Int_t idAir  = idtmed[1100]; // medium 1
582   //Int_t idFoam = idtmed[1115]; // medium 16 = Foam
583   //Int_t idFR4  = idtmed[1114]; // medium 15 = FR4
584   Int_t idFoam = idtmed[1125]; // medium 26 = Foam
585   Int_t idFR4  = idtmed[1122]; // medium 23 = FR4
586
587   // mother volume
588   GReal_t par[3];
589   par[0] = dimensions.X();
590   par[1] = dimensions.Y();
591   par[2] = TotalHzPlane();
592   gMC->Gsvolu(PlaneSegmentName(segNumber).Data(),"BOX",idAir,par,3);
593   
594   // foam layer
595   par[0] = dimensions.X();
596   par[1] = dimensions.Y();
597   par[2] = fgkHzFoam;
598   gMC->Gsvolu(FoamBoxName(segNumber).Data(),"BOX",idFoam,par,3);
599   GReal_t posX,posY,posZ;
600   posX=0.;
601   posY=0.;
602   posZ = -TotalHzPlane() + fgkHzFoam;
603   gMC->Gspos(FoamBoxName(segNumber).Data(),1, 
604              PlaneSegmentName(segNumber).Data(),posX,posY,posZ,0,"ONLY");
605
606   // mechanical plane FR4 layer
607   par[0] = dimensions.X();
608   par[1] = dimensions.Y();
609   par[2] = fgkHzFR4;
610   gMC->Gsvolu(FR4BoxName(segNumber).Data(),"BOX",idFR4,par,3);
611   posX=0.;
612   posY=0.;
613   posZ = -TotalHzPlane()+ 2.*fgkHzFoam + fgkHzFR4;
614   gMC->Gspos(FR4BoxName(segNumber).Data(),1,
615              PlaneSegmentName(segNumber).Data(),posX,posY,posZ,0,"ONLY");
616 }
617
618 //______________________________________________________________________________
619 void AliMUONSt1GeometryBuilderV2::CreatePlaneSegment(Int_t segNumber,
620                                     const  TVector2& dimensions,
621                                     Int_t nofHoles)
622 {
623 /// Create a segment of a plane (this includes a foam layer, 
624 /// holes in the foam to feed the kaptons through, kapton connectors
625 /// and the mother board.)
626   
627   CreateFoamBox(segNumber,dimensions);
628
629   for (Int_t holeNum=0;holeNum<nofHoles;holeNum++) {
630     GReal_t posX = ((2.*holeNum+1.)/nofHoles-1.)*dimensions.X();
631     GReal_t posY = 0.;
632     GReal_t posZ = 0.;
633   
634     gMC->Gspos(fgkHoleName,holeNum+1,
635                FoamBoxName(segNumber).Data(),posX,posY,posZ,0,"ONLY");
636   }
637 }
638
639 //______________________________________________________________________________
640 void AliMUONSt1GeometryBuilderV2::CreateFrame(Int_t chamber)
641 {
642 /// Create the non-sensitive elements of the frame for the \a chamber
643 ///
644 /// Model and notation:                                                     \n
645 ///                                                                         \n
646 /// The Quadrant volume name starts with SQ                                 \n
647 /// The volume segments are numbered 00 to XX                               \n
648 ///                                                                         \n
649 ///                              OutTopFrame                                \n
650 ///                               (SQ02-16)                                 \n 
651 ///                              ------------                               \n
652 ///             OutEdgeFrame   /              |                             \n
653 ///             (SQ17-24)     /               |  InVFrame (SQ00-01)         \n 
654 ///                          /                |                             \n
655 ///                          |                |                             \n 
656 ///               OutVFrame  |            _- -                              \n
657 ///               (SQ25-39)  |           |   InArcFrame (SQ42-45)           \n
658 ///                          |           |                                  \n 
659 ///                          -------------                                  \n 
660 ///                        InHFrame (SQ40-41)                               \n 
661 ///                                                                         \n                         
662 ///                                                                         \n
663 /// 06 February 2003 - Overlapping volumes resolved.                        \n
664 /// One quarter chamber is comprised of three TUBS volumes: SQMx, SQNx, and SQFx,
665 /// where SQMx is the Quadrant Middle layer for chamber \a chamber ( posZ in [-3.25,3.25]),
666 /// SQNx is the Quadrant Near side layer for chamber \a chamber ( posZ in [-6.25,3-.25) ), and
667 /// SQFx is the Quadrant Far side layer for chamber \a chamber ( posZ in (3.25,6.25] ).
668
669   const Float_t kNearFarLHC=2.4;    // Near and Far TUBS Origin wrt LHC Origin
670
671   // tracking medias
672   Int_t* idtmed = fMUON->GetIdtmed()->GetArray()-1099;
673   
674   Int_t idAir  = idtmed[1100];       // medium 1
675   //Int_t idFrameEpoxy = idtmed[1115]; // medium 16 = Frame Epoxy ME730
676   //Int_t idInox = idtmed[1116];       // medium 17 Stainless Steel (18%Cr,9%Ni,Fe)
677   //Int_t idFR4 = idtmed[1110];        // medium 11 FR4
678   //Int_t idCopper = idtmed[1109];     // medium 10 Copper
679   //Int_t idAlu = idtmed[1103];        // medium 4 Aluminium
680   Int_t idFrameEpoxy = idtmed[1123]; // medium 24 = Frame Epoxy ME730  // was 20 not 16
681   Int_t idInox = idtmed[1128];       // medium 29 Stainless Steel (18%Cr,9%Ni,Fe) // was 21 not 17
682   Int_t idFR4 = idtmed[1122];        // medium 23 FR4  // was 15 not 11
683   Int_t idCopper = idtmed[1121];     // medium 22 Copper
684   Int_t idAlu = idtmed[1120];        // medium 21 Aluminium
685   
686   
687 // Rotation Matrices  
688       Int_t rot1, rot2, rot3;    
689       
690 //   Rotation matrices  
691      fMUON->AliMatrix(rot1,  90.,  90., 90., 180.,  0., 0.); // +90 deg in x-y plane
692      fMUON->AliMatrix(rot2,  90.,  45., 90., 135.,  0., 0.); // +45 deg in x-y plane 
693      fMUON->AliMatrix(rot3,  90.,  45., 90., 315.,180., 0.); // +45 deg in x-y + rotation 180° around y
694
695 //   Translation matrices ... NOT USED  
696 //     fMUON->AliMatrix(trans1, 90.,   0., 90.,  90.,   0., 0.); // X-> X; Y -> Y; Z -> Z
697 //     fMUON->AliMatrix(trans2, 90., 180., 90.,  90., 180., 0.); // X->-X; Y -> Y; Z ->-Z
698 //     fMUON->AliMatrix(trans3, 90., 180., 90., 270.,   0., 0.); // X->-X; Y ->-Y; Z -> Z
699 //     fMUON->AliMatrix(trans4, 90.,   0., 90., 270., 180., 0.); // X-> X; Y ->-Y; Z ->-Z
700 //  
701       // ___________________Volume thicknesses________________________
702
703   const Float_t kHzFrameThickness = 1.59/2.;     //equivalent thickness
704   const Float_t kHzOuterFrameEpoxy = 1.19/2.;    //equivalent thickness
705   const Float_t kHzOuterFrameInox = 0.1/2.;      //equivalent thickness
706   const Float_t kHzFoam = 2.083/2.;              //evaluated elsewhere
707                                                  // CHECK with fgkHzFoam
708   
709 // Pertaining to the top outer area 
710   const Float_t kHzTopAnodeSteel1 = 0.185/2.;    //equivalent thickness
711   const Float_t kHzTopAnodeSteel2 = 0.51/2.;     //equivalent thickness  
712   const Float_t kHzAnodeFR4 = 0.08/2.;           //equivalent thickness
713   const Float_t kHzTopEarthFaceCu = 0.364/2.;    //equivalent thickness
714   const Float_t kHzTopEarthProfileCu = 1.1/2.;   //equivalent thickness
715   const Float_t kHzTopPositionerSteel = 1.45/2.; //should really be 2.125/2.; 
716   const Float_t kHzTopGasSupportAl = 0.85/2.;    //equivalent thickness
717   
718 // Pertaining to the vertical outer area  
719   const Float_t kHzVerticalCradleAl = 0.8/2.;     //equivalent thickness
720   const Float_t kHzLateralSightAl = 0.975/2.;     //equivalent thickness
721   const Float_t kHzLateralPosnInoxFace = 2.125/2.;//equivalent thickness
722   const Float_t kHzLatPosInoxProfM = 6.4/2.;      //equivalent thickness
723   const Float_t kHzLatPosInoxProfNF = 1.45/2.;    //equivalent thickness
724   const Float_t kHzLateralPosnAl = 0.5/2.;        //equivalent thickness
725   const Float_t kHzVertEarthFaceCu = 0.367/2.;    //equivalent thickness
726   const Float_t kHzVertBarSteel = 0.198/2.;       //equivalent thickness
727   const Float_t kHzVertEarthProfCu = 1.1/2.;      //equivalent thickness
728
729       //_______________Parameter definitions in sequence _________
730
731 // InVFrame parameters
732   const Float_t kHxInVFrame  = 1.85/2.;
733   const Float_t kHyInVFrame  = 73.95/2.;
734   const Float_t kHzInVFrame  = kHzFrameThickness;
735
736 //Flat 7.5mm vertical section
737   const Float_t kHxV1mm  = 0.75/2.;
738   const Float_t kHyV1mm  = 1.85/2.;
739   const Float_t kHzV1mm  = kHzFrameThickness;
740
741 // OuterTopFrame Structure 
742 //
743 // FRAME
744 // The frame is composed of a cuboid and two trapezoids 
745 // (TopFrameAnode, TopFrameAnodeA, TopFrameAnodeB). 
746 // Each shape is composed of two layers (Epoxy and Inox) and 
747 // takes the frame's inner anode circuitry into account in the material budget.
748 //
749 // ANODE
750 // The overhanging anode part is composed froma cuboid and two trapezoids 
751 // (TopAnode, TopAnode1, and TopAnode2). These surfaces neglect implanted
752 // resistors, but accounts for the major Cu, Pb/Sn, and FR4 material
753 // contributions.  
754 // The stainless steel anode supports have been included.
755 //
756 // EARTHING (TopEarthFace, TopEarthProfile)
757 // Al GAS SUPPORT (TopGasSupport)
758 //  
759 // ALIGNMENT (TopPositioner) - Alignment system, three sights per quarter 
760 // chamber. This sight is forseen for the alignment of the horizontal level 
761 // (parallel to the OY axis of LHC). Its position will be evaluated relative 
762 // to a system of sights places on the cradles;
763 //
764 //---
765   
766 //TopFrameAnode parameters - cuboid, 2 layers
767   const Float_t kHxTFA = 34.1433/2.;
768   const Float_t kHyTFA = 7.75/2.;
769   const Float_t kHzTFAE = kHzOuterFrameEpoxy;     // layer 1 thickness
770   const Float_t kHzTFAI = kHzOuterFrameInox;      // layer 3 thickness
771   
772 // TopFrameAnodeA parameters - trapezoid, 2 layers
773   const Float_t kHzFAAE = kHzOuterFrameEpoxy;     // layer 1 thickness
774   const Float_t kHzFAAI = kHzOuterFrameInox;      // layer 3 thickness
775   const Float_t kTetFAA = 0.;
776   const Float_t kPhiFAA = 0.;
777   const Float_t kH1FAA = 8.7/2.;
778   const Float_t kBl1FAA = 4.35/2.;
779   const Float_t kTl1FAA =  7.75/2.;
780   const Float_t kAlp1FAA = 11.06; 
781   const Float_t kH2FAA = 8.7/2.;
782   const Float_t kBl2FAA = 4.35/2.;
783   const Float_t kTl2FAA = 7.75/2.;
784   const Float_t kAlp2FAA = 11.06;  
785   
786 // TopFrameAnodeB parameters - trapezoid, 2 layers
787   const Float_t kHzFABE = kHzOuterFrameEpoxy;     // layer 1 thickness
788   const Float_t kHzFABI = kHzOuterFrameInox;      // layer 3 thickness
789   const Float_t kTetFAB = 0.;
790   const Float_t kPhiFAB = 0.;
791   const Float_t kH1FAB = 8.70/2.;
792   const Float_t kBl1FAB = 0.;
793   const Float_t kTl1FAB = 4.35/2.;
794   const Float_t kAlp1FAB = 14.03; 
795   const Float_t kH2FAB = 8.70/2.;
796   const Float_t kBl2FAB = 0.;
797   const Float_t kTl2FAB = 4.35/2.;
798   const Float_t kAlp2FAB = 14.03;  
799   
800 // TopAnode parameters - cuboid (part 1 of 3 parts)
801   const Float_t kHxTA1 = 16.2/2.;
802   const Float_t kHyTA1 = 3.5/2.;
803   const Float_t kHzTA11 = kHzTopAnodeSteel1;   // layer 1
804   const Float_t kHzTA12 = kHzAnodeFR4;         // layer 2 
805
806 // TopAnode parameters - trapezoid 1 (part 2 of 3 parts)
807   const Float_t kHzTA21 = kHzTopAnodeSteel2;   // layer 1 
808   const Float_t kHzTA22 = kHzAnodeFR4;         // layer 2 
809   const Float_t kTetTA2 = 0.;
810   const Float_t kPhiTA2= 0.;
811   const Float_t kH1TA2 = 7.268/2.;
812   const Float_t kBl1TA2 = 2.03/2.;
813   const Float_t kTl1TA2 = 3.5/2.;
814   const Float_t kAlp1TA2 = 5.78; 
815   const Float_t kH2TA2 = 7.268/2.;
816   const Float_t kBl2TA2 = 2.03/2.;
817   const Float_t kTl2TA2 = 3.5/2.;
818   const Float_t kAlp2TA2 = 5.78;  
819
820 // TopAnode parameters - trapezoid 2 (part 3 of 3 parts)
821   const Float_t kHzTA3 = kHzAnodeFR4;       // layer 1 
822   const Float_t kTetTA3 = 0.;
823   const Float_t kPhiTA3 = 0.;
824   const Float_t kH1TA3 = 7.268/2.;
825   const Float_t kBl1TA3 = 0.;
826   const Float_t kTl1TA3 = 2.03/2.;
827   const Float_t kAlp1TA3 = 7.95; 
828   const Float_t kH2TA3 = 7.268/2.;
829   const Float_t kBl2TA3 = 0.;
830   const Float_t kTl2TA3 = 2.03/2.;
831   const Float_t kAlp2TA3 = 7.95;  
832   
833 // TopEarthFace parameters - single trapezoid
834   const Float_t kHzTEF = kHzTopEarthFaceCu;
835   const Float_t kTetTEF = 0.;
836   const Float_t kPhiTEF = 0.;
837   const Float_t kH1TEF = 1.200/2.;
838   const Float_t kBl1TEF = 21.323/2.;
839   const Float_t kTl1TEF = 17.963/2.;
840   const Float_t kAlp1TEF = -54.46; 
841   const Float_t kH2TEF = 1.200/2.;
842   const Float_t kBl2TEF = 21.323/2.;
843   const Float_t kTl2TEF = 17.963/2.;
844   const Float_t kAlp2TEF = -54.46;
845
846 // TopEarthProfile parameters - single trapezoid
847   const Float_t kHzTEP = kHzTopEarthProfileCu;
848   const Float_t kTetTEP = 0.;
849   const Float_t kPhiTEP = 0.;
850   const Float_t kH1TEP = 0.40/2.;
851   const Float_t kBl1TEP = 31.766/2.;
852   const Float_t kTl1TEP = 30.535/2.;
853   const Float_t kAlp1TEP = -56.98; 
854   const Float_t kH2TEP = 0.40/2.;
855   const Float_t kBl2TEP = 31.766/2.;
856   const Float_t kTl2TEP = 30.535/2.;
857   const Float_t kAlp2TEP = -56.98;
858
859 // TopPositioner parameters - single Stainless Steel trapezoid 
860   const Float_t kHzTP = kHzTopPositionerSteel;
861   const Float_t kTetTP = 0.;
862   const Float_t kPhiTP = 0.;
863   const Float_t kH1TP = 3.00/2.;
864   const Float_t kBl1TP = 7.023/2.;
865   const Float_t kTl1TP = 7.314/2.;
866   const Float_t kAlp1TP = 2.78; 
867   const Float_t kH2TP = 3.00/2.;
868   const Float_t kBl2TP = 7.023/2.;
869   const Float_t kTl2TP = 7.314/2.;
870   const Float_t kAlp2TP = 2.78;
871
872 // TopGasSupport parameters - single cuboid 
873   const Float_t kHxTGS  = 8.50/2.;
874   const Float_t kHyTGS  = 3.00/2.;
875   const Float_t kHzTGS  = kHzTopGasSupportAl;
876     
877 // OutEdgeFrame parameters - 4 trapezoidal sections, 2 layers of material
878 //
879 //---
880
881 // Trapezoid 1
882   const Float_t kHzOETFE = kHzOuterFrameEpoxy;    // layer 1 
883   const Float_t kHzOETFI = kHzOuterFrameInox;     // layer 3
884    
885   const Float_t kTetOETF = 0.;            // common to all 4 trapezoids
886   const Float_t kPhiOETF = 0.;            // common to all 4 trapezoids
887
888   const Float_t kH1OETF = 7.196/2.;       // common to all 4 trapezoids
889   const Float_t kH2OETF = 7.196/2.;       // common to all 4 trapezoids   
890   
891   const Float_t kBl1OETF1 = 3.75/2; 
892   const Float_t kTl1OETF1 = 3.996/2.;
893   const Float_t kAlp1OETF1 = 0.98;
894
895   const Float_t kBl2OETF1 = 3.75/2;
896   const Float_t kTl2OETF1 = 3.996/2.;
897   const Float_t kAlp2OETF1 = 0.98;
898   
899 // Trapezoid 2
900   const Float_t kBl1OETF2 = 3.01/2.;
901   const Float_t kTl1OETF2 = 3.75/2;
902   const Float_t kAlp1OETF2 = 2.94;
903       
904   const Float_t kBl2OETF2 = 3.01/2.;
905   const Float_t kTl2OETF2 = 3.75/2;
906   const Float_t kAlp2OETF2 = 2.94; 
907  
908 // Trapezoid 3
909   //const Float_t kBl1OETF3 = 1.767/2.;
910   //const Float_t kTl1OETF3 = 3.01/2.;
911   const Float_t kBl1OETF3 = 1.117/2.;
912   const Float_t kTl1OETF3 = 2.36/2.;
913   const Float_t kAlp1OETF3 = 4.94;
914         // Fix (5) - overlap of SQ21 with 041M and 125M
915       
916   //const Float_t kBl2OETF3 = 1.767/2.;
917   //const Float_t kTl2OETF3 = 3.01/2.; 
918   const Float_t kBl2OETF3 = 1.117/2.;
919   const Float_t kTl2OETF3 = 2.36/2.;
920   const Float_t kAlp2OETF3 = 4.94; 
921         // Fix (5) - overlap of SQ21 with 041M and 125M
922   
923 // Trapezoid 4
924   const Float_t kBl1OETF4 = 0.;
925   const Float_t kTl1OETF4 = 1.77/2.;
926   const Float_t kAlp1OETF4 = 7.01;
927       
928   const Float_t kBl2OETF4 = 0.;
929   const Float_t kTl2OETF4 = 1.77/2.;
930   const Float_t kAlp2OETF4 =  7.01;   
931   
932 // Frame Structure (OutVFrame):
933 //
934 // OutVFrame and corner (OutVFrame cuboid, OutVFrame trapezoid)
935 // EARTHING (VertEarthFaceCu,VertEarthSteel,VertEarthProfCu),
936 // DETECTOR POSITIONNING (SuppLateralPositionner, LateralPositionner),
937 // CRADLE (VertCradle), and
938 // ALIGNMENT (LateralSightSupport, LateralSight) 
939 //
940 //---
941
942 // OutVFrame parameters - cuboid
943   const Float_t kHxOutVFrame = 1.85/2.;
944   const Float_t kHyOutVFrame = 46.23/2.;
945   const Float_t kHzOutVFrame = kHzFrameThickness;
946
947 // OutVFrame corner parameters - trapezoid
948   const Float_t kHzOCTF = kHzFrameThickness;
949   const Float_t kTetOCTF = 0.;
950   const Float_t kPhiOCTF = 0.;
951   const Float_t kH1OCTF = 1.85/2.;
952   const Float_t kBl1OCTF = 0.;
953   const Float_t kTl1OCTF = 3.66/2.;
954   const Float_t kAlp1OCTF = 44.67; 
955   const Float_t kH2OCTF = 1.85/2.;
956   const Float_t kBl2OCTF = 0.;
957   const Float_t kTl2OCTF = 3.66/2.;
958   const Float_t kAlp2OCTF = 44.67;  
959   
960 // VertEarthFaceCu parameters - single trapezoid
961   const Float_t kHzVFC = kHzVertEarthFaceCu;
962   const Float_t kTetVFC = 0.;
963   const Float_t kPhiVFC = 0.;
964   const Float_t kH1VFC = 1.200/2.;
965   const Float_t kBl1VFC = 46.11/2.;
966   const Float_t kTl1VFC = 48.236/2.;
967   const Float_t kAlp1VFC = 41.54; 
968   const Float_t kH2VFC = 1.200/2.;
969   const Float_t kBl2VFC = 46.11/2.;
970   const Float_t kTl2VFC = 48.236/2.;
971   const Float_t kAlp2VFC = 41.54;
972     
973 // VertEarthSteel parameters - single trapezoid
974   const Float_t kHzVES = kHzVertBarSteel;
975   const Float_t kTetVES = 0.;
976   const Float_t kPhiVES = 0.;
977   const Float_t kH1VES = 1.200/2.;
978   const Float_t kBl1VES = 30.486/2.;
979   const Float_t kTl1VES = 32.777/2.;
980   const Float_t kAlp1VES = 43.67; 
981   const Float_t kH2VES = 1.200/2.;
982   const Float_t kBl2VES = 30.486/2.;
983   const Float_t kTl2VES = 32.777/2.;
984   const Float_t kAlp2VES = 43.67;
985
986 // VertEarthProfCu parameters - single trapezoid
987   const Float_t kHzVPC = kHzVertEarthProfCu;
988   const Float_t kTetVPC = 0.;
989   const Float_t kPhiVPC = 0.;
990   const Float_t kH1VPC = 0.400/2.;
991   const Float_t kBl1VPC = 29.287/2.;
992   const Float_t kTl1VPC = 30.091/2.;
993   const Float_t kAlp1VPC = 45.14; 
994   const Float_t kH2VPC = 0.400/2.;
995   const Float_t kBl2VPC = 29.287/2.;
996   const Float_t kTl2VPC = 30.091/2.;
997   const Float_t kAlp2VPC = 45.14;
998
999 // SuppLateralPositionner - single cuboid
1000   const Float_t kHxSLP  = 2.80/2.;
1001   const Float_t kHySLP  = 5.00/2.;
1002   const Float_t kHzSLP  = kHzLateralPosnAl;
1003   
1004 // LateralPositionner - squared off U bend, face view
1005   const Float_t kHxLPF  = 5.2/2.;
1006   const Float_t kHyLPF  = 3.0/2.;
1007   const Float_t kHzLPF  = kHzLateralPosnInoxFace;
1008   
1009 // LateralPositionner - squared off U bend, profile view
1010   const Float_t kHxLPP  = 0.425/2.;
1011   const Float_t kHyLPP  = 3.0/2.;
1012   const Float_t kHzLPP  = kHzLatPosInoxProfM;  // middle layer
1013   const Float_t kHzLPNF  = kHzLatPosInoxProfNF; // near and far layers
1014            
1015 // VertCradle, 3 layers (copies), each composed of 4 trapezoids
1016 // VertCradleA
1017   const Float_t kHzVC1 = kHzVerticalCradleAl;
1018   const Float_t kTetVC1 = 0.;
1019   const Float_t kPhiVC1 = 0.;
1020   const Float_t kH1VC1 = 10.25/2.;
1021   const Float_t kBl1VC1 = 3.70/2.;
1022   const Float_t kTl1VC1 = 0.;
1023   const Float_t kAlp1VC1 = -10.23; 
1024   const Float_t kH2VC1 = 10.25/2.;
1025   const Float_t kBl2VC1 = 3.70/2.;
1026   const Float_t kTl2VC1 = 0.;
1027   const Float_t kAlp2VC1 = -10.23;
1028         
1029 // VertCradleB
1030   const Float_t kHzVC2 = kHzVerticalCradleAl;
1031   const Float_t kTetVC2 = 0.;
1032   const Float_t kPhiVC2 = 0.;
1033   const Float_t kH1VC2 = 10.25/2.;
1034   const Float_t kBl1VC2 = 6.266/2.;
1035   const Float_t kTl1VC2 = 3.70/2.;
1036   const Float_t kAlp1VC2 = -7.13; 
1037   const Float_t kH2VC2 = 10.25/2.;
1038   const Float_t kBl2VC2 = 6.266/2.;
1039   const Float_t kTl2VC2 = 3.70/2.;
1040   const Float_t kAlp2VC2 = -7.13;
1041   
1042 // VertCradleC
1043   const Float_t kHzVC3 = kHzVerticalCradleAl;
1044   const Float_t kTetVC3 = 0.;
1045   const Float_t kPhiVC3 = 0.;
1046   const Float_t kH1VC3 = 10.25/2.;
1047   const Float_t kBl1VC3 = 7.75/2.;
1048   const Float_t kTl1VC3 = 6.266/2.;
1049   const Float_t kAlp1VC3 = -4.14; 
1050   const Float_t kH2VC3 = 10.25/2.;
1051   const Float_t kBl2VC3 = 7.75/2.;
1052   const Float_t kTl2VC3 = 6.266/2.;
1053   const Float_t kAlp2VC3 = -4.14;
1054
1055 // VertCradleD
1056   const Float_t kHzVC4 = kHzVerticalCradleAl;
1057   const Float_t kTetVC4 = 0.;
1058   const Float_t kPhiVC4 = 0.;
1059   const Float_t kH1VC4 = 10.27/2.;
1060   const Float_t kBl1VC4 = 8.273/2.;
1061   const Float_t kTl1VC4 = 7.75/2.;
1062   const Float_t kAlp1VC4 = -1.46; 
1063   const Float_t kH2VC4 = 10.27/2.;
1064   const Float_t kBl2VC4 = 8.273/2.;
1065   const Float_t kTl2VC4 = 7.75/2.;
1066   const Float_t kAlp2VC4 = -1.46;
1067   
1068 // LateralSightSupport - single trapezoid
1069   const Float_t kHzVSS = kHzLateralSightAl;
1070   const Float_t kTetVSS = 0.;
1071   const Float_t kPhiVSS = 0.;
1072   const Float_t kH1VSS = 5.00/2.;
1073   const Float_t kBl1VSS = 7.747/2;
1074   const Float_t kTl1VSS = 7.188/2.;
1075   const Float_t kAlp1VSS = -3.20; 
1076   const Float_t kH2VSS = 5.00/2.;
1077   const Float_t kBl2VSS = 7.747/2.;
1078   const Float_t kTl2VSS = 7.188/2.;
1079   const Float_t kAlp2VSS = -3.20;  
1080   
1081 // LateralSight (reference point) - 3 per quadrant, only 1 programmed for now
1082   const Float_t kVSInRad  = 0.6;
1083   const Float_t kVSOutRad  = 1.3;
1084   const Float_t kVSLen  = kHzFrameThickness; 
1085   
1086 //---
1087
1088 // InHFrame parameters
1089   const Float_t kHxInHFrame  = 75.8/2.;
1090   const Float_t kHyInHFrame  = 1.85/2.;
1091   const Float_t kHzInHFrame  = kHzFrameThickness;
1092  
1093 //Flat 7.5mm horizontal section
1094   const Float_t kHxH1mm  = 1.85/2.;
1095   const Float_t kHyH1mm  = 0.75/2.;
1096   const Float_t kHzH1mm  = kHzFrameThickness;
1097
1098 //---
1099
1100 // InArcFrame parameters
1101   const Float_t kIAF  = 15.70;
1102   const Float_t kOAF  = 17.55;
1103   const Float_t kHzAF  = kHzFrameThickness;
1104   const Float_t kAFphi1  = 0.0;
1105   const Float_t kAFphi2  = 90.0;
1106
1107 //---
1108
1109 // ScrewsInFrame parameters HEAD
1110   const Float_t kSCRUHMI  = 0.;
1111   const Float_t kSCRUHMA  = 0.690/2.;
1112   const Float_t kSCRUHLE  = 0.4/2.;
1113 // ScrewsInFrame parameters MIDDLE
1114   const Float_t kSCRUMMI  = 0.;
1115   const Float_t kSCRUMMA  = 0.39/2.;
1116   const Float_t kSCRUMLE  = kHzFrameThickness;
1117 // ScrewsInFrame parameters NUT
1118   const Float_t kSCRUNMI  = 0.;
1119   const Float_t kSCRUNMA  = 0.78/2.;
1120   const Float_t kSCRUNLE  = 0.8/2.;   
1121   
1122        // ___________________Make volumes________________________
1123
1124  Float_t par[11];
1125  Float_t posX,posY,posZ;
1126
1127 // Quadrant volume TUBS1, positioned at the end
1128   par[0] = fgkMotherIR1;
1129   par[1] = fgkMotherOR1; 
1130   par[2] = fgkMotherThick1;  
1131   par[3] = fgkMotherPhiL1; 
1132   par[4] = fgkMotherPhiU1;
1133   gMC->Gsvolu(QuadrantMLayerName(chamber),"TUBS",idAir,par,5);
1134
1135 // Replace the volume shape with a composite shape
1136 // with substracted overlap with beam shield (YMOT)
1137
1138   if ( gMC->IsRootGeometrySupported() ) { 
1139
1140     // Get shape
1141     TGeoVolume* mlayer 
1142       = gGeoManager->FindVolumeFast(QuadrantMLayerName(chamber));
1143     if ( !mlayer ) {
1144       AliErrorStream() 
1145          << "Quadrant volume " << QuadrantMLayerName(chamber) << " not found" 
1146          << endl;
1147     }
1148     else {
1149       TGeoShape* quadrant = mlayer->GetShape();
1150       quadrant->SetName("quadrant");     
1151
1152       // Beam shield recess
1153       par[0] = 0;
1154       par[1] = 15.4; 
1155       par[2] = fgkMotherThick1;  
1156       new TGeoTube("shield_tube", par[0], par[1], par[2]);
1157   
1158       // Displacement
1159       posX = 2.6;
1160       posY = 2.6;
1161       posZ = 0;
1162       TGeoTranslation* displacement 
1163         = new TGeoTranslation("TR", posX, posY, posZ);
1164       displacement->RegisterYourself();
1165
1166       // Composite shape
1167       TGeoShape* composite
1168       = new TGeoCompositeShape("composite", "quadrant-shield_tube:TR"); 
1169       
1170       // Reset shape to volume      
1171       mlayer->SetShape(composite);
1172     }
1173   }    
1174
1175 // Quadrant volume TUBS2, positioned at the end
1176   par[0] = fgkMotherIR2;
1177   par[1] = fgkMotherOR2; 
1178   par[2] = fgkMotherThick2;  
1179   par[3] = fgkMotherPhiL2; 
1180   par[4] = fgkMotherPhiU2;
1181
1182   gMC->Gsvolu(QuadrantNLayerName(chamber),"TUBS",idAir,par,5); 
1183   gMC->Gsvolu(QuadrantFLayerName(chamber),"TUBS",idAir,par,5); 
1184
1185    if (chamber==1) {   
1186     // InVFrame  
1187     par[0] = kHxInVFrame;
1188     par[1] = kHyInVFrame;
1189     par[2] = kHzInVFrame;
1190     gMC->Gsvolu("SQ00","BOX",idFrameEpoxy,par,3);
1191
1192     //Flat 1mm vertical section
1193     par[0] = kHxV1mm;
1194     par[1] = kHyV1mm;
1195     par[2] = kHzV1mm;
1196     gMC->Gsvolu("SQ01","BOX",idFrameEpoxy,par,3); 
1197  
1198 // OutTopFrame 
1199 //
1200 // - 3 components (a cuboid and 2 trapezes) and 2 layers (Epoxy/Inox)
1201 //
1202 //---
1203
1204     // TopFrameAnode - layer 1 of 2 
1205     par[0] = kHxTFA;
1206     par[1] = kHyTFA;
1207     par[2] = kHzTFAE;
1208     gMC->Gsvolu("SQ02","BOX",idFrameEpoxy,par,3);
1209     
1210     // TopFrameAnode - layer 2 of 2 
1211     par[2] = kHzTFAI;
1212     gMC->Gsvolu("SQ03","BOX",idInox,par,3);
1213             
1214     // TopFrameAnodeA - layer 1 of 2  
1215     par[0] = kHzFAAE;
1216     par[1] = kTetFAA;
1217     par[2] = kPhiFAA;
1218     par[3] = kH1FAA;
1219     par[4] = kBl1FAA;
1220     par[5] = kTl1FAA;
1221     par[6] = kAlp1FAA;
1222     par[7] = kH2FAA;
1223     par[8] = kBl2FAA;
1224     par[9] = kTl2FAA;
1225     par[10] = kAlp2FAA;    
1226     gMC->Gsvolu("SQ04","TRAP",idFrameEpoxy,par,11);    
1227
1228     // TopFrameAnodeA - layer 2 of 2
1229     par[0] = kHzFAAI;    
1230     gMC->Gsvolu("SQ05","TRAP",idInox,par,11); 
1231       
1232     // TopFrameAnodeB - layer 1 of 2
1233     par[0] = kHzFABE;
1234     par[1] = kTetFAB;
1235     par[2] = kPhiFAB;
1236     par[3] = kH1FAB;
1237     par[4] = kBl1FAB;
1238     par[5] = kTl1FAB;
1239     par[6] = kAlp1FAB;
1240     par[7] = kH2FAB;
1241     par[8] = kBl2FAB;
1242     par[9] = kTl2FAB;
1243     par[10] = kAlp2FAB;
1244     gMC->Gsvolu("SQ06","TRAP",idFrameEpoxy,par,11);     
1245
1246     // OutTopTrapFrameB - layer 2 of 2
1247     par[0] = kHzFABI;   
1248     gMC->Gsvolu("SQ07","TRAP",idInox,par,11);
1249
1250     // TopAnode1 -  layer 1 of 2
1251     par[0] = kHxTA1;
1252     par[1] = kHyTA1;
1253     par[2] = kHzTA11;    
1254     gMC->Gsvolu("SQ08","BOX",idInox,par,3); 
1255     
1256     // TopAnode1 -  layer 2 of 2
1257     par[2] = kHzTA12;    
1258     gMC->Gsvolu("SQ09","BOX",idFR4,par,11); 
1259
1260     // TopAnode2 -  layer 1 of 2
1261     par[0] = kHzTA21;
1262     par[1] = kTetTA2;
1263     par[2] = kPhiTA2;
1264     par[3] = kH1TA2;
1265     par[4] = kBl1TA2;
1266     par[5] = kTl1TA2;
1267     par[6] = kAlp1TA2;
1268     par[7] = kH2TA2;
1269     par[8] = kBl2TA2;
1270     par[9] = kTl2TA2;
1271     par[10] = kAlp2TA2;    
1272     gMC->Gsvolu("SQ10","TRAP",idInox,par,11); 
1273  
1274     // TopAnode2 -  layer 2 of 2
1275     par[0] = kHzTA22;    
1276     gMC->Gsvolu("SQ11","TRAP",idFR4,par,11);   
1277
1278     // TopAnode3 -  layer 1 of 1 
1279     par[0] = kHzTA3;
1280     par[1] = kTetTA3;
1281     par[2] = kPhiTA3;
1282     par[3] = kH1TA3;
1283     par[4] = kBl1TA3;
1284     par[5] = kTl1TA3;
1285     par[6] = kAlp1TA3;
1286     par[7] = kH2TA3;
1287     par[8] = kBl2TA3;
1288     par[9] = kTl2TA3;
1289     par[10] = kAlp2TA3;    
1290     gMC->Gsvolu("SQ12","TRAP",idFR4,par,11); 
1291
1292     // TopEarthFace 
1293     par[0] = kHzTEF;
1294     par[1] = kTetTEF;
1295     par[2] = kPhiTEF;
1296     par[3] = kH1TEF;
1297     par[4] = kBl1TEF;
1298     par[5] = kTl1TEF;
1299     par[6] = kAlp1TEF;
1300     par[7] = kH2TEF;
1301     par[8] = kBl2TEF;
1302     par[9] = kTl2TEF;
1303     par[10] = kAlp2TEF;    
1304     gMC->Gsvolu("SQ13","TRAP",idCopper,par,11);   
1305
1306     // TopEarthProfile 
1307     par[0] = kHzTEP;
1308     par[1] = kTetTEP;
1309     par[2] = kPhiTEP;
1310     par[3] = kH1TEP;
1311     par[4] = kBl1TEP;
1312     par[5] = kTl1TEP;
1313     par[6] = kAlp1TEP;
1314     par[7] = kH2TEP;
1315     par[8] = kBl2TEP;
1316     par[9] = kTl2TEP;
1317     par[10] = kAlp2TEP;
1318     gMC->Gsvolu("SQ14","TRAP",idCopper,par,11);       
1319
1320     // TopGasSupport  
1321     par[0] = kHxTGS;
1322     par[1] = kHyTGS;
1323     par[2] = kHzTGS;
1324     gMC->Gsvolu("SQ15","BOX",idAlu,par,3);
1325
1326     // TopPositioner parameters - single Stainless Steel trapezoid 
1327     par[0] = kHzTP;
1328     par[1] = kTetTP; 
1329     par[2] = kPhiTP;
1330     par[3] = kH1TP;
1331     par[4] = kBl1TP; 
1332     par[5] = kTl1TP; 
1333     par[6] = kAlp1TP;
1334     par[7] = kH2TP;
1335     par[8] = kBl2TP; 
1336     par[9] = kTl2TP; 
1337     par[10] = kAlp2TP;     
1338     gMC->Gsvolu("SQ16","TRAP",idInox,par,11);       
1339
1340 //
1341 // OutEdgeTrapFrame Epoxy = (4 trapezes)*2 copies*2 layers (Epoxy/Inox)
1342 //
1343 //---
1344     // Trapezoid 1 - 2 layers
1345     par[1] = kTetOETF;
1346     par[2] = kPhiOETF;
1347     par[3] = kH1OETF;
1348     par[4] = kBl1OETF1;
1349     par[5] = kTl1OETF1;
1350     par[6] = kAlp1OETF1;
1351     par[7] = kH2OETF;
1352     par[8] = kBl2OETF1;
1353     par[9] = kTl2OETF1;
1354     par[10] = kAlp2OETF1; 
1355            
1356     par[0] = kHzOETFE;             
1357     gMC->Gsvolu("SQ17","TRAP",idFrameEpoxy,par,11); 
1358     par[0] = kHzOETFI;
1359     gMC->Gsvolu("SQ18","TRAP",idInox,par,11);
1360     
1361     // Trapezoid 2 - 2 layers
1362     par[4] = kBl1OETF2;
1363     par[5] = kTl1OETF2;
1364     par[6] = kAlp1OETF2;
1365
1366     par[8] = kBl2OETF2;
1367     par[9] = kTl2OETF2;
1368     par[10] = kAlp2OETF2; 
1369     
1370     par[0] = kHzOETFE;    
1371     gMC->Gsvolu("SQ19","TRAP",idFrameEpoxy,par,11);    
1372     par[0] = kHzOETFI;    
1373     gMC->Gsvolu("SQ20","TRAP",idInox,par,11);     
1374     
1375     // Trapezoid 3 - 2 layers
1376     par[4] = kBl1OETF3;
1377     par[5] = kTl1OETF3;
1378     par[6] = kAlp1OETF3;
1379
1380     par[8] = kBl2OETF3;
1381     par[9] = kTl2OETF3;
1382     par[10] = kAlp2OETF3; 
1383  
1384     par[0] = kHzOETFE;    
1385     gMC->Gsvolu("SQ21","TRAP",idFrameEpoxy,par,11);   
1386     par[0] = kHzOETFI;    
1387     gMC->Gsvolu("SQ22","TRAP",idInox,par,11);     
1388     
1389     // Trapezoid 4 - 2 layers
1390
1391     par[4] = kBl1OETF4;
1392     par[5] = kTl1OETF4;
1393     par[6] = kAlp1OETF4;
1394
1395     par[8] = kBl2OETF4;
1396     par[9] = kTl2OETF4;
1397     par[10] = kAlp2OETF4;  
1398    
1399     par[0] = kHzOETFE;    
1400     gMC->Gsvolu("SQ23","TRAP",idFrameEpoxy,par,11);    
1401     par[0] = kHzOETFI;    
1402     gMC->Gsvolu("SQ24","TRAP",idInox,par,11);     
1403              
1404 //---
1405     // OutVFrame    
1406     par[0] = kHxOutVFrame;
1407     par[1] = kHyOutVFrame;
1408     par[2] = kHzOutVFrame;
1409     gMC->Gsvolu("SQ25","BOX",idFrameEpoxy,par,3);
1410         
1411     // OutVFrame corner  
1412     par[0] = kHzOCTF;
1413     par[1] = kTetOCTF;
1414     par[2] = kPhiOCTF;
1415     par[3] = kH1OCTF;
1416     par[4] = kBl1OCTF;
1417     par[5] = kTl1OCTF;
1418     par[6] = kAlp1OCTF;
1419     par[7] = kH2OCTF;
1420     par[8] = kBl2OCTF;
1421     par[9] = kTl2OCTF;
1422     par[10] = kAlp2OCTF;    
1423     gMC->Gsvolu("SQ26","TRAP",idFrameEpoxy,par,11);
1424  
1425     // EarthFaceCu trapezoid
1426     par[0] = kHzVFC;
1427     par[1] = kTetVFC;
1428     par[2] = kPhiVFC;
1429     par[3] = kH1VFC;
1430     par[4] = kBl1VFC;
1431     par[5] = kTl1VFC;
1432     par[6] = kAlp1VFC;
1433     par[7] = kH2VFC;
1434     par[8] = kBl2VFC;
1435     par[9] = kTl2VFC;
1436     par[10] = kAlp2VFC;   
1437     gMC->Gsvolu("SQ27","TRAP",idCopper,par,11);     
1438
1439     // VertEarthSteel trapezoid
1440     par[0] = kHzVES;
1441     par[1] = kTetVES;
1442     par[2] = kPhiVES;
1443     par[3] = kH1VES;
1444     par[4] = kBl1VES;
1445     par[5] = kTl1VES;
1446     par[6] = kAlp1VES;
1447     par[7] = kH2VES;
1448     par[8] = kBl2VES;
1449     par[9] = kTl2VES;
1450     par[10] = kAlp2VES;    
1451     gMC->Gsvolu("SQ28","TRAP",idInox,par,11); 
1452
1453     // VertEarthProfCu trapezoid       
1454     par[0] = kHzVPC;
1455     par[1] = kTetVPC;
1456     par[2] = kPhiVPC;
1457     par[3] = kH1VPC;
1458     par[4] = kBl1VPC;
1459     par[5] = kTl1VPC;
1460     par[6] = kAlp1VPC;
1461     par[7] = kH2VPC;
1462     par[8] = kBl2VPC;
1463     par[9] = kTl2VPC;
1464     par[10] = kAlp2VPC;
1465     gMC->Gsvolu("SQ29","TRAP",idCopper,par,11);
1466
1467     // SuppLateralPositionner cuboid    
1468     par[0] = kHxSLP;
1469     par[1] = kHySLP;
1470     par[2] = kHzSLP;
1471     gMC->Gsvolu("SQ30","BOX",idAlu,par,3);
1472
1473     // LateralPositionerFace
1474     par[0] = kHxLPF;
1475     par[1] = kHyLPF;
1476     par[2] = kHzLPF;
1477     gMC->Gsvolu("SQ31","BOX",idInox,par,3);
1478
1479     // LateralPositionerProfile
1480     par[0] = kHxLPP;
1481     par[1] = kHyLPP;
1482     par[2] = kHzLPP;
1483     gMC->Gsvolu("SQ32","BOX",idInox,par,3); // middle layer
1484     
1485     par[0] = kHxLPP;
1486     par[1] = kHyLPP;
1487     par[2] = kHzLPNF;
1488     gMC->Gsvolu("SQ33","BOX",idInox,par,3); // near and far layers
1489
1490     // VertCradleA - 1st trapezoid
1491     par[0] = kHzVC1;
1492     par[1] = kTetVC1;
1493     par[2] = kPhiVC1;
1494     par[3] = kH1VC1;
1495     par[4] = kBl1VC1;
1496     par[5] = kTl1VC1;
1497     par[6] = kAlp1VC1;
1498     par[7] = kH2VC1;
1499     par[8] = kBl2VC1;
1500     par[9] = kTl2VC1;
1501     par[10] = kAlp2VC1;
1502     gMC->Gsvolu("SQ34","TRAP",idAlu,par,11); 
1503     
1504     // VertCradleB - 2nd trapezoid
1505     par[0] = kHzVC2;
1506     par[1] = kTetVC2;
1507     par[2] = kPhiVC2;
1508     par[3] = kH1VC2;
1509     par[4] = kBl1VC2;
1510     par[5] = kTl1VC2;
1511     par[6] = kAlp1VC2;
1512     par[7] = kH2VC2;
1513     par[8] = kBl2VC2;
1514     par[9] = kTl2VC2;
1515     par[10] = kAlp2VC2;
1516     gMC->Gsvolu("SQ35","TRAP",idAlu,par,11);  
1517        
1518     // VertCradleC - 3rd trapezoid
1519     par[0] = kHzVC3;
1520     par[1] = kTetVC3;
1521     par[2] = kPhiVC3;
1522     par[3] = kH1VC3;
1523     par[4] = kBl1VC3;
1524     par[5] = kTl1VC3;
1525     par[6] = kAlp1VC3;
1526     par[7] = kH2VC3;
1527     par[8] = kBl2VC3;
1528     par[9] = kTl2VC3;
1529     par[10] = kAlp2VC3;    
1530     gMC->Gsvolu("SQ36","TRAP",idAlu,par,11);  
1531
1532     // VertCradleD - 4th trapezoid
1533     par[0] = kHzVC4;
1534     par[1] = kTetVC4;
1535     par[2] = kPhiVC4;
1536     par[3] = kH1VC4;
1537     par[4] = kBl1VC4;
1538     par[5] = kTl1VC4;
1539     par[6] = kAlp1VC4;
1540     par[7] = kH2VC4;
1541     par[8] = kBl2VC4;
1542     par[9] = kTl2VC4;
1543     par[10] = kAlp2VC4;    
1544     gMC->Gsvolu("SQ37","TRAP",idAlu,par,11);  
1545           
1546     // LateralSightSupport trapezoid
1547     par[0] = kHzVSS;
1548     par[1] = kTetVSS;
1549     par[2] = kPhiVSS;
1550     par[3] = kH1VSS;
1551     par[4] = kBl1VSS;
1552     par[5] = kTl1VSS;
1553     par[6] = kAlp1VSS;
1554     par[7] = kH2VSS;
1555     par[8] = kBl2VSS;
1556     par[9] = kTl2VSS;
1557     par[10] = kAlp2VSS;
1558     gMC->Gsvolu("SQ38","TRAP",idAlu,par,11);
1559
1560     // LateralSight
1561     par[0] = kVSInRad;
1562     par[1] = kVSOutRad;
1563     par[2] = kVSLen;       
1564     gMC->Gsvolu("SQ39","TUBE",idFrameEpoxy,par,3);   
1565
1566 //---
1567     // InHFrame
1568     par[0] = kHxInHFrame;
1569     par[1] = kHyInHFrame;
1570     par[2] = kHzInHFrame;
1571     gMC->Gsvolu("SQ40","BOX",idFrameEpoxy,par,3);
1572
1573     //Flat 7.5mm horizontal section
1574     par[0] = kHxH1mm;
1575     par[1] = kHyH1mm;
1576     par[2] = kHzH1mm;
1577     gMC->Gsvolu("SQ41","BOX",idFrameEpoxy,par,3);
1578
1579     // InArcFrame 
1580     par[0] = kIAF;
1581     par[1] = kOAF; 
1582     par[2] = kHzAF;  
1583     par[3] = kAFphi1; 
1584     par[4] = kAFphi2;
1585
1586     gMC->Gsvolu("SQ42","TUBS",idFrameEpoxy,par,5);
1587
1588 //---
1589     // ScrewsInFrame - 3 sections in order to avoid overlapping volumes
1590     // Screw Head, in air
1591     par[0] = kSCRUHMI;
1592     par[1] = kSCRUHMA; 
1593     par[2] = kSCRUHLE;  
1594
1595     gMC->Gsvolu("SQ43","TUBE",idInox,par,3);
1596     
1597     // Middle part, in the Epoxy
1598     par[0] = kSCRUMMI;
1599     par[1] = kSCRUMMA;
1600     par[2] = kSCRUMLE;
1601     gMC->Gsvolu("SQ44","TUBE",idInox,par,3);
1602     
1603     // Screw nut, in air
1604     par[0] = kSCRUNMI;
1605     par[1] = kSCRUNMA;
1606     par[2] = kSCRUNLE;   
1607     gMC->Gsvolu("SQ45","TUBE",idInox,par,3);     
1608    }
1609               
1610 // __________________Place volumes in the quadrant ____________ 
1611         
1612     // InVFrame  
1613     posX = kHxInVFrame;
1614     posY = 2.0*kHyInHFrame+2.*kHyH1mm+kIAF+kHyInVFrame;        
1615     posZ = 0.;
1616     gMC->Gspos("SQ00",1,QuadrantMLayerName(chamber),posX, posY, posZ, 0, "ONLY"); 
1617
1618 // keep memory of the mid position. Used for placing screws
1619     const GReal_t kMidVposX = posX;
1620     const GReal_t kMidVposY = posY;
1621     const GReal_t kMidVposZ = posZ;
1622
1623     //Flat 7.5mm vertical section
1624     posX = 2.0*kHxInVFrame+kHxV1mm;
1625     posY = 2.0*kHyInHFrame+2.*kHyH1mm+kIAF+kHyV1mm;
1626     posZ = 0.;
1627     gMC->Gspos("SQ01",1,QuadrantMLayerName(chamber),posX, posY, posZ,0, "ONLY"); 
1628     
1629     // TopFrameAnode place 2 layers of TopFrameAnode cuboids  
1630     posX = kHxTFA;
1631     posY = 2.*kHyInHFrame+2.*kHyH1mm+kIAF+2.*kHyInVFrame+kHyTFA;   
1632     posZ = kHzOuterFrameInox;
1633     gMC->Gspos("SQ02",1,QuadrantMLayerName(chamber),posX, posY, posZ,0,"ONLY"); 
1634     posZ = posZ+kHzOuterFrameInox;
1635     gMC->Gspos("SQ03",1,QuadrantMLayerName(chamber),posX, posY, posZ,0,"ONLY");
1636     
1637     // place 2 layers of TopFrameAnodeA trapezoids 
1638     posX = 35.8932+fgkDeltaQuadLHC;
1639     posY = 92.6745+fgkDeltaQuadLHC;
1640     posZ = kHzOuterFrameInox; 
1641     gMC->Gspos("SQ04",1,QuadrantMLayerName(chamber),posX, posY, posZ, rot1,"ONLY");
1642     posZ = posZ+kHzOuterFrameInox;
1643     gMC->Gspos("SQ05",1,QuadrantMLayerName(chamber),posX, posY, posZ, rot1,"ONLY");
1644     
1645     // place 2 layers of TopFrameAnodeB trapezoids 
1646     posX = 44.593+fgkDeltaQuadLHC;
1647     posY = 90.737+fgkDeltaQuadLHC;
1648     posZ = kHzOuterFrameInox; 
1649     gMC->Gspos("SQ06",1,QuadrantMLayerName(chamber),posX, posY, posZ, rot1,"ONLY");
1650     posZ = posZ+kHzOuterFrameInox;
1651     gMC->Gspos("SQ07",1,QuadrantMLayerName(chamber),posX, posY, posZ, rot1,"ONLY");    
1652
1653     // TopAnode1 place 2 layers  
1654     posX = 6.8+fgkDeltaQuadLHC;
1655     posY = 99.85+fgkDeltaQuadLHC;
1656     posZ = -1.*kHzAnodeFR4;
1657     gMC->Gspos("SQ08",1,QuadrantMLayerName(chamber),posX, posY, posZ, 0,"ONLY");  
1658     posZ = posZ+kHzTopAnodeSteel1;
1659     gMC->Gspos("SQ09",1,QuadrantMLayerName(chamber),posX, posY, posZ, 0,"ONLY");    
1660          
1661     // TopAnode2 place 2 layers
1662     posX = 18.534+fgkDeltaQuadLHC;
1663     posY = 99.482+fgkDeltaQuadLHC; 
1664     posZ = -1.*kHzAnodeFR4;    
1665     gMC->Gspos("SQ10",1,QuadrantMLayerName(chamber),posX, posY, posZ, rot1,"ONLY");
1666     posZ = posZ+kHzTopAnodeSteel2;    
1667     gMC->Gspos("SQ11",1,QuadrantMLayerName(chamber),posX, posY, posZ, rot1,"ONLY");       
1668     
1669     // TopAnode3 place 1 layer
1670     posX = 25.80+fgkDeltaQuadLHC;
1671     posY = 98.61+fgkDeltaQuadLHC;
1672     posZ = 0.;    
1673     gMC->Gspos("SQ12",1,QuadrantMLayerName(chamber),posX, posY, posZ, rot1,"ONLY");  
1674           
1675     // TopEarthFace - 2 copies
1676     posX = 23.122+fgkDeltaQuadLHC;
1677     posY = 96.90+fgkDeltaQuadLHC;
1678     posZ = kHzOuterFrameEpoxy+kHzOuterFrameInox+kHzTopEarthFaceCu;
1679     gMC->Gspos("SQ13",1,QuadrantMLayerName(chamber),posX, posY, posZ, 0,"ONLY");
1680     posZ = -1.*posZ;
1681     gMC->Gspos("SQ13",2,QuadrantMLayerName(chamber),posX, posY, posZ, 0,"ONLY");
1682
1683     // TopEarthProfile 
1684     posX = 14.475+fgkDeltaQuadLHC;
1685     posY = 97.900+fgkDeltaQuadLHC; 
1686     posZ = kHzTopEarthProfileCu;
1687     gMC->Gspos("SQ14",1,QuadrantMLayerName(chamber),posX, posY, posZ, 0,"ONLY");
1688     posZ = -1.0*posZ;
1689     gMC->Gspos("SQ14",2,QuadrantMLayerName(chamber),posX, posY, posZ, 0,"ONLY");
1690
1691     // TopGasSupport - 2 copies                            
1692     posX = 4.9500+fgkDeltaQuadLHC;
1693     posY = 96.200+fgkDeltaQuadLHC;
1694     posZ = kHzOuterFrameEpoxy+kHzOuterFrameInox+kHzTopGasSupportAl;
1695     gMC->Gspos("SQ15",1,QuadrantMLayerName(chamber),posX, posY, posZ, 0,"ONLY");
1696     posZ = -1.*posZ;
1697     gMC->Gspos("SQ15",2,QuadrantMLayerName(chamber),posX, posY, posZ, 0,"ONLY");
1698     
1699     // TopPositioner parameters - single Stainless Steel trapezoid - 2 copies
1700     posX = 7.60+fgkDeltaQuadLHC;
1701     posY = 98.98+fgkDeltaQuadLHC;   
1702     posZ = kHzOuterFrameEpoxy+kHzOuterFrameInox+2.*kHzTopGasSupportAl+kHzTopPositionerSteel;
1703     gMC->Gspos("SQ16",1,QuadrantMLayerName(chamber),posX, posY, posZ, rot1,"ONLY");
1704     posZ = -1.*posZ;
1705     gMC->Gspos("SQ16",2,QuadrantMLayerName(chamber),posX, posY, posZ, rot1,"ONLY"); 
1706
1707     // OutEdgeFrame 
1708     Float_t xCenter[8]; 
1709     Float_t yCenter[8];
1710     
1711     xCenter[0] = 73.201 + fgkDeltaQuadLHC;
1712     xCenter[1] = 78.124 + fgkDeltaQuadLHC; 
1713     //xCenter[2] = 82.862 + fgkDeltaQuadLHC;
1714     xCenter[2] = 83.102 + fgkDeltaQuadLHC;
1715     xCenter[3] = 87.418 + fgkDeltaQuadLHC; 
1716         // Fix (5) - overlap of SQ21 with 041M and 125M
1717     
1718     yCenter[0] = 68.122 + fgkDeltaQuadLHC;
1719     yCenter[1] = 62.860 + fgkDeltaQuadLHC;   
1720     //yCenter[2] = 57.420 + fgkDeltaQuadLHC;
1721     yCenter[2] = 57.660 + fgkDeltaQuadLHC;
1722     yCenter[3] = 51.800 + fgkDeltaQuadLHC; 
1723         // Fix (5) - overlap of SQ21 with 041M and 125M
1724       
1725     xCenter[4] = 68.122 + fgkDeltaQuadLHC;
1726     xCenter[5] = 62.860 + fgkDeltaQuadLHC; 
1727     xCenter[6] = 57.420 + fgkDeltaQuadLHC;
1728     xCenter[7] = 51.800 + fgkDeltaQuadLHC; 
1729     
1730     yCenter[4] = 73.210 + fgkDeltaQuadLHC;
1731     yCenter[5] = 78.124 + fgkDeltaQuadLHC; 
1732     yCenter[6] = 82.862 + fgkDeltaQuadLHC;
1733     yCenter[7] = 87.418 + fgkDeltaQuadLHC; 
1734       
1735     posZ = -1.0*kHzOuterFrameInox;     
1736     gMC->Gspos("SQ17",1,QuadrantMLayerName(chamber), xCenter[0], yCenter[0], posZ, rot2,"ONLY");
1737     gMC->Gspos("SQ17",2,QuadrantMLayerName(chamber), xCenter[4], yCenter[4], posZ, rot3,"ONLY");
1738
1739     gMC->Gspos("SQ19",1,QuadrantMLayerName(chamber), xCenter[1], yCenter[1], posZ, rot2,"ONLY");   
1740     gMC->Gspos("SQ19",2,QuadrantMLayerName(chamber), xCenter[5], yCenter[5], posZ, rot3,"ONLY");
1741
1742     gMC->Gspos("SQ21",1,QuadrantMLayerName(chamber), xCenter[2], yCenter[2], posZ, rot2,"ONLY");
1743     gMC->Gspos("SQ21",2,QuadrantMLayerName(chamber), xCenter[6], yCenter[6], posZ, rot3,"ONLY");
1744     
1745     gMC->Gspos("SQ23",1,QuadrantMLayerName(chamber), xCenter[3], yCenter[3], posZ, rot2,"ONLY");
1746     gMC->Gspos("SQ23",2,QuadrantMLayerName(chamber), xCenter[7], yCenter[7], posZ, rot3,"ONLY");
1747      
1748     posZ = posZ+kHzOuterFrameEpoxy;
1749    
1750     gMC->Gspos("SQ18",1,QuadrantMLayerName(chamber), xCenter[0], yCenter[0], posZ, rot2,"ONLY");
1751     gMC->Gspos("SQ18",2,QuadrantMLayerName(chamber), xCenter[4], yCenter[4], posZ, rot3,"ONLY");
1752     
1753     gMC->Gspos("SQ20",1,QuadrantMLayerName(chamber), xCenter[1], yCenter[1], posZ, rot2,"ONLY");   
1754     gMC->Gspos("SQ20",2,QuadrantMLayerName(chamber), xCenter[5], yCenter[5], posZ, rot3,"ONLY");
1755
1756     gMC->Gspos("SQ22",1,QuadrantMLayerName(chamber), xCenter[2], yCenter[2], posZ, rot2,"ONLY");
1757     gMC->Gspos("SQ22",2,QuadrantMLayerName(chamber), xCenter[6], yCenter[6], posZ, rot3,"ONLY");
1758        
1759     gMC->Gspos("SQ24",1,QuadrantMLayerName(chamber), xCenter[3], yCenter[3], posZ, rot2,"ONLY");
1760     gMC->Gspos("SQ24",2,QuadrantMLayerName(chamber), xCenter[7], yCenter[7], posZ, rot3,"ONLY");  
1761
1762 //---    
1763         
1764 // OutVFrame
1765     posX = 2.*kHxInVFrame+kIAF+2.*kHxInHFrame-kHxOutVFrame+2.*kHxV1mm;
1766     posY = 2.*kHyInHFrame+kHyOutVFrame;    
1767     posZ = 0.;              
1768     gMC->Gspos("SQ25",1,QuadrantMLayerName(chamber),posX, posY, posZ, 0, "ONLY"); 
1769
1770  // keep memory of the mid position. Used for placing screws
1771     const GReal_t kMidOVposX = posX;
1772     const GReal_t kMidOVposY = posY;
1773     const GReal_t kMidOVposZ = posZ;
1774
1775     const Float_t kTOPY = posY+kHyOutVFrame;
1776     const Float_t kOUTX = posX;
1777
1778 // OutVFrame corner
1779     posX = kOUTX;
1780     posY = kTOPY+((kBl1OCTF+kTl1OCTF)/2.);
1781     posZ = 0.;     
1782     gMC->Gspos("SQ26",1,QuadrantMLayerName(chamber),posX, posY, posZ, rot1,"ONLY"); 
1783
1784 // VertEarthFaceCu - 2 copies
1785     posX = 89.4000+fgkDeltaQuadLHC;
1786     posY = 25.79+fgkDeltaQuadLHC;    
1787     posZ = kHzFrameThickness+2.0*kHzFoam+kHzVertEarthFaceCu;              
1788     gMC->Gspos("SQ27",1,QuadrantMLayerName(chamber),posX, posY, posZ, rot1, "ONLY"); 
1789     posZ = -1.0*posZ; 
1790     gMC->Gspos("SQ27",2,QuadrantMLayerName(chamber),posX, posY, posZ, rot1, "ONLY"); 
1791     
1792 // VertEarthSteel - 2 copies
1793     posX = 91.00+fgkDeltaQuadLHC;
1794     posY = 30.616+fgkDeltaQuadLHC;    
1795     posZ = kHzFrameThickness+2.0*kHzFoam+kHzVertBarSteel;              
1796     gMC->Gspos("SQ28",1,QuadrantMLayerName(chamber),posX, posY, posZ, rot1, "ONLY"); 
1797     posZ = -1.0*posZ;              
1798     gMC->Gspos("SQ28",2,QuadrantMLayerName(chamber),posX, posY, posZ, rot1, "ONLY");
1799  
1800 // VertEarthProfCu - 2 copies
1801     posX = 92.000+fgkDeltaQuadLHC;
1802     posY = 29.64+fgkDeltaQuadLHC;    
1803     posZ = kHzFrameThickness;              
1804     gMC->Gspos("SQ29",1,QuadrantMLayerName(chamber),posX, posY, posZ, rot1, "ONLY"); 
1805     posZ = -1.0*posZ;    
1806     gMC->Gspos("SQ29",2,QuadrantMLayerName(chamber),posX, posY, posZ, rot1, "ONLY"); 
1807
1808 // SuppLateralPositionner - 2 copies 
1809     posX = 90.2-kNearFarLHC;
1810     posY = 5.00-kNearFarLHC;    
1811     posZ = kHzLateralPosnAl-fgkMotherThick2;             
1812     gMC->Gspos("SQ30",1,QuadrantFLayerName(chamber),posX, posY, posZ, 0, "ONLY"); 
1813     posZ = -1.0*posZ;            
1814     gMC->Gspos("SQ30",2,QuadrantNLayerName(chamber),posX, posY, posZ, 0, "ONLY"); 
1815
1816 // LateralPositionner - 2 copies - Face view
1817     posX = 92.175-kNearFarLHC-2.*kHxLPP;
1818     posY = 5.00-kNearFarLHC;   
1819     posZ =2.0*kHzLateralPosnAl+kHzLateralPosnInoxFace-fgkMotherThick2;              
1820     gMC->Gspos("SQ31",1,QuadrantFLayerName(chamber),posX, posY, posZ, 0, "ONLY"); 
1821     posZ = -1.0*posZ;             
1822     gMC->Gspos("SQ31",2,QuadrantNLayerName(chamber),posX, posY, posZ, 0, "ONLY"); 
1823
1824 // LateralPositionner -  Profile view   
1825     posX = 92.175+fgkDeltaQuadLHC+kHxLPF-kHxLPP;
1826     posY = 5.00+fgkDeltaQuadLHC;    
1827     posZ = 0.;              
1828     gMC->Gspos("SQ32",1,QuadrantMLayerName(chamber),posX, posY, posZ, 0, "ONLY"); // middle layer
1829
1830     posX = 92.175-kNearFarLHC+kHxLPF-kHxLPP; 
1831     posY = 5.0000-kNearFarLHC;    
1832     posZ = fgkMotherThick2-kHzLPNF;              
1833     gMC->Gspos("SQ33",1,QuadrantNLayerName(chamber),posX, posY, posZ, 0, "ONLY"); // near layer
1834     posZ = -1.*posZ;
1835     gMC->Gspos("SQ33",2,QuadrantFLayerName(chamber),posX, posY, posZ, 0, "ONLY"); // far layer
1836       
1837 // VertCradleA  1st Trapezoid - 3 copies
1838     posX = 95.73+fgkDeltaQuadLHC;
1839     posY = 33.26+fgkDeltaQuadLHC; 
1840     posZ = 0.;              
1841     gMC->Gspos("SQ34",2,QuadrantMLayerName(chamber),posX, posY, posZ, 0, "ONLY");  
1842
1843     posX = 95.73-kNearFarLHC;
1844     posY = 33.26-kNearFarLHC;
1845     posZ = 2.0*kHzLateralSightAl+kHzVerticalCradleAl-fgkMotherThick2;               
1846     gMC->Gspos("SQ34",1,QuadrantNLayerName(chamber),posX, posY, posZ, 0, "ONLY");
1847     posZ = -1.0*posZ;              
1848     gMC->Gspos("SQ34",3,QuadrantFLayerName(chamber),posX, posY, posZ, 0, "ONLY");
1849
1850 // VertCradleB  2nd Trapezoid - 3 copies
1851     posX = 97.29+fgkDeltaQuadLHC;
1852     posY = 23.02+fgkDeltaQuadLHC;    
1853     posZ = 0.;              
1854     gMC->Gspos("SQ35",2,QuadrantMLayerName(chamber),posX, posY, posZ, 0, "ONLY");
1855
1856     posX = 97.29-kNearFarLHC;
1857     posY = 23.02-kNearFarLHC;   
1858     posZ = 2.0*kHzLateralSightAl+kHzVerticalCradleAl-fgkMotherThick2;          
1859     gMC->Gspos("SQ35",1,QuadrantNLayerName(chamber),posX, posY, posZ, 0, "ONLY");    
1860     posZ = -1.0*posZ;          
1861     gMC->Gspos("SQ35",3,QuadrantFLayerName(chamber),posX, posY, posZ, 0, "ONLY");
1862
1863 // OutVertCradleC  3rd Trapeze - 3 copies
1864     posX = 98.31+fgkDeltaQuadLHC;
1865     posY = 12.77+fgkDeltaQuadLHC;  
1866     posZ = 0.;              
1867     gMC->Gspos("SQ36",2,QuadrantMLayerName(chamber),posX, posY, posZ, 0, "ONLY");
1868
1869     posX = 98.05-kNearFarLHC;
1870     posY = 12.77-kNearFarLHC;        
1871     posZ = 2.0*kHzLateralSightAl+kHzVerticalCradleAl-fgkMotherThick2;         
1872            // Fix (2) of extrusion SQ36 from SQN1, SQN2, SQF1, SQF2 
1873            // (was posX = 98.31 ...)
1874     gMC->Gspos("SQ36",1,QuadrantNLayerName(chamber),posX, posY, posZ, 0, "ONLY");       
1875     posZ = -1.0*posZ;
1876     gMC->Gspos("SQ36",3,QuadrantFLayerName(chamber),posX, posY, posZ, 0, "ONLY");  
1877
1878 // OutVertCradleD  4th Trapeze - 3 copies
1879     posX = 98.81+fgkDeltaQuadLHC;
1880     posY = 2.52+fgkDeltaQuadLHC;    
1881     posZ = 0.;              
1882     gMC->Gspos("SQ37",2,QuadrantMLayerName(chamber),posX, posY, posZ, 0, "ONLY");
1883    
1884     posZ = fgkMotherThick1-kHzVerticalCradleAl;                
1885     gMC->Gspos("SQ37",1,QuadrantMLayerName(chamber),posX, posY, posZ, 0, "ONLY");
1886     posZ = -1.0*posZ;          
1887     gMC->Gspos("SQ37",3,QuadrantMLayerName(chamber),posX, posY, posZ, 0, "ONLY");          
1888              
1889 // LateralSightSupport - 2 copies
1890     posX = 98.33-kNearFarLHC;
1891     posY = 10.00-kNearFarLHC;    
1892     posZ = kHzLateralSightAl-fgkMotherThick2;
1893            // Fix (3) of extrusion SQ38 from SQN1, SQN2, SQF1, SQF2 
1894            // (was posX = 98.53 ...)
1895     gMC->Gspos("SQ38",1,QuadrantNLayerName(chamber),posX, posY, posZ, 0, "ONLY"); 
1896     posZ = -1.0*posZ;             
1897     gMC->Gspos("SQ38",2,QuadrantFLayerName(chamber),posX, posY, posZ, 0, "ONLY"); 
1898     
1899 // Mire placement
1900     posX = 92.84+fgkDeltaQuadLHC;  
1901     posY = 8.13+fgkDeltaQuadLHC;
1902     posZ = 0.;
1903     gMC->Gspos("SQ39",1,QuadrantMLayerName(chamber),posX, posY, posZ, 0,"ONLY");    
1904
1905 //---
1906
1907 // InHFrame
1908     posX = 2.0*kHxInVFrame+2.*kHxV1mm+kIAF+kHxInHFrame;
1909     posY = kHyInHFrame;
1910     posZ = 0.;       
1911     gMC->Gspos("SQ40",1,QuadrantMLayerName(chamber),posX, posY, posZ, 0, "ONLY"); 
1912  
1913  // keep memory of the mid position. Used for placing screws
1914     const GReal_t kMidHposX = posX;
1915     const GReal_t kMidHposY = posY;
1916     const GReal_t kMidHposZ = posZ;
1917
1918 // Flat 7.5mm horizontal section
1919     posX = 2.0*kHxInVFrame+2.*kHxV1mm+kIAF+kHxH1mm;
1920     posY = 2.0*kHyInHFrame+kHyH1mm;
1921     posZ = 0.;
1922     gMC->Gspos("SQ41",1,QuadrantMLayerName(chamber),posX, posY, posZ,0, "ONLY"); 
1923         
1924 // InArcFrame 
1925     posX = 2.0*kHxInVFrame+2.*kHxV1mm;
1926     posY = 2.0*kHyInHFrame+2.*kHyH1mm;
1927     posZ = 0.;    
1928     gMC->Gspos("SQ42",1,QuadrantMLayerName(chamber),posX, posY, posZ,0, "ONLY"); 
1929
1930 // keep memory of the mid position. Used for placing screws
1931     const GReal_t kMidArcposX = posX;
1932     const GReal_t kMidArcposY = posY;
1933     const GReal_t kMidArcposZ = posZ;
1934
1935 // ScrewsInFrame - in sensitive volume
1936
1937      Float_t scruX[64];
1938      Float_t scruY[64]; 
1939          
1940 // Screws on IHEpoxyFrame
1941
1942      const Int_t kNumberOfScrewsIH = 14;    // no. of screws on the IHEpoxyFrame
1943      const Float_t kOffX = 5.;              // inter-screw distance 
1944
1945      // first screw coordinates 
1946      scruX[0] = 21.07;                  
1947      scruY[0] = -2.23; 
1948      // other screw coordinates      
1949      for (Int_t i = 1;i<kNumberOfScrewsIH;i++){   
1950      scruX[i] = scruX[i-1]+kOffX; 
1951      scruY[i] = scruY[0];
1952      }    
1953      // Position the volumes on the frames
1954      for (Int_t i = 0;i<kNumberOfScrewsIH;i++){
1955      posX = fgkDeltaQuadLHC + scruX[i];
1956      posY = fgkDeltaQuadLHC + scruY[i];
1957      posZ = 0.;   
1958      gMC->Gspos("SQ43",i+1,QuadrantMLayerName(chamber),posX+0.1, posY+0.1, posZ-kHzInHFrame-kSCRUHLE, 0, "ONLY");      
1959      if (chamber==1)
1960        gMC->Gspos("SQ44",i+1,"SQ40",posX+0.1-kMidHposX, posY+0.1-kMidHposY, posZ-kMidHposZ, 0, "ONLY");
1961      gMC->Gspos("SQ45",i+1,QuadrantMLayerName(chamber),posX+0.1, posY+0.1, posZ+kHzInHFrame+kSCRUNLE, 0, "ONLY"); 
1962      }
1963      // special screw coordinates
1964      scruX[63] = 16.3;  
1965      scruY[63] = -2.23; 
1966      posX = fgkDeltaQuadLHC + scruX[63];
1967      posY = fgkDeltaQuadLHC + scruY[63];
1968      posZ = 0.;            
1969      gMC->Gspos("SQ43",64,QuadrantMLayerName(chamber),posX+0.1, posY+0.1, posZ-kHzInHFrame-kSCRUHLE, 0, "ONLY");
1970      if (chamber==1)
1971        gMC->Gspos("SQ44",64,"SQ40",posX+0.1-kMidHposX, posY+0.1-kMidHposY, posZ-kMidHposZ, 0, "ONLY"); 
1972      gMC->Gspos("SQ45",64,QuadrantMLayerName(chamber),posX+0.1, posY+0.1, posZ+kHzInHFrame+kSCRUNLE, 0, "ONLY");  
1973      
1974 // Screws on the IVEpoxyFrame
1975   
1976     const Int_t kNumberOfScrewsIV = 15;     // no. of screws on the IVEpoxyFrame
1977     const Float_t kOffY = 5.;               // inter-screw distance 
1978     Int_t firstScrew = 58;
1979     Int_t lastScrew = 44;
1980  
1981     // first (special) screw coordinates
1982     scruX[firstScrew-1] = -2.23; 
1983     scruY[firstScrew-1] = 16.3; 
1984     // second (repetitive) screw coordinates
1985     scruX[firstScrew-2] = -2.23; 
1986     scruY[firstScrew-2] = 21.07;     
1987     // other screw coordinates      
1988     for (Int_t i = firstScrew-3;i>lastScrew-2;i--){   
1989     scruX[i] = scruX[firstScrew-2];
1990     scruY[i] = scruY[i+1]+kOffY;
1991     }
1992     
1993     for (Int_t i = 0;i<kNumberOfScrewsIV;i++){
1994     posX = fgkDeltaQuadLHC + scruX[i+lastScrew-1];
1995     posY = fgkDeltaQuadLHC + scruY[i+lastScrew-1];
1996     posZ = 0.;       
1997     gMC->Gspos("SQ43",i+lastScrew,QuadrantMLayerName(chamber),posX+0.1, posY+0.1, posZ-kHzInHFrame-kSCRUHLE, 0, "ONLY");     
1998     if (chamber==1)
1999       gMC->Gspos("SQ44",i+lastScrew,"SQ00",posX+0.1-kMidVposX, posY+0.1-kMidVposY, posZ-kMidVposZ, 0, "ONLY"); 
2000     gMC->Gspos("SQ45",i+lastScrew,QuadrantMLayerName(chamber),posX+0.1, posY+0.1, posZ+kHzInHFrame+kSCRUNLE, 0, "ONLY");
2001     }    
2002     
2003 // Screws on the OVEpoxyFrame
2004   
2005     const Int_t kNumberOfScrewsOV = 10;     // no. of screws on the OVEpoxyFrame
2006
2007     firstScrew = 15;
2008     lastScrew = 25;
2009  
2010     // first (repetitive) screw coordinates
2011     // notes: 1st screw should be placed in volume 40 (InnerHorizFrame)
2012     scruX[firstScrew-1] = 90.9; 
2013     scruY[firstScrew-1] = -2.23;  // true value
2014  
2015     // other screw coordinates      
2016     for (Int_t i = firstScrew; i<lastScrew; i++ ){   
2017     scruX[i] = scruX[firstScrew-1];
2018     scruY[i] = scruY[i-1]+kOffY;
2019     }
2020     for (Int_t i = 1;i<kNumberOfScrewsOV;i++){
2021     posX = fgkDeltaQuadLHC + scruX[i+firstScrew-1];
2022     posY = fgkDeltaQuadLHC + scruY[i+firstScrew-1];
2023     posZ = 0.;   
2024     gMC->Gspos("SQ43",i+firstScrew,QuadrantMLayerName(chamber),posX+0.1, posY+0.1, posZ-kHzInHFrame-kSCRUHLE, 0, "ONLY");     
2025     // ??
2026     if (chamber==1)
2027       gMC->Gspos("SQ44",i+firstScrew,"SQ25",posX+0.1-kMidOVposX, posY+0.1-kMidOVposY, posZ-kMidOVposZ, 0, "ONLY"); 
2028     gMC->Gspos("SQ45",i+firstScrew,QuadrantMLayerName(chamber),posX+0.1, posY+0.1, posZ+kHzInHFrame+kSCRUNLE, 0, "ONLY"); 
2029     }
2030     // special case for 1st screw, inside the horizontal frame (volume 40)
2031     posX = fgkDeltaQuadLHC + scruX[firstScrew-1];
2032     posY = fgkDeltaQuadLHC + scruY[firstScrew-1];
2033     posZ = 0.;   
2034     if (chamber==1)
2035       gMC->Gspos("SQ44",firstScrew,"SQ40",posX+0.1-kMidHposX, posY+0.1-kMidHposY, posZ-kMidHposZ, 0, "ONLY"); 
2036           
2037 // Inner Arc of Frame, screw positions and numbers-1
2038    scruX[62] = 16.009; scruY[62]  = 1.401;
2039    scruX[61] = 14.564; scruY[61]  = 6.791;
2040    scruX[60] = 11.363; scruY[60]  = 11.363;
2041    scruX[59] = 6.791 ; scruY[59]  = 14.564;
2042    scruX[58] = 1.401 ; scruY[58]  = 16.009;
2043     
2044     for (Int_t i = 0;i<5;i++){
2045     posX = fgkDeltaQuadLHC + scruX[i+58];
2046     posY = fgkDeltaQuadLHC + scruY[i+58];
2047     posZ = 0.;   
2048     gMC->Gspos("SQ43",i+58+1,QuadrantMLayerName(chamber),posX+0.1, posY+0.1, posZ-kHzInHFrame-kSCRUHLE, 0, "ONLY");    
2049     if (chamber==1)
2050       gMC->Gspos("SQ44",i+58+1,"SQ42",posX+0.1-kMidArcposX, posY+0.1-kMidArcposY, posZ-kMidArcposZ, 0, "ONLY");
2051     gMC->Gspos("SQ45",i+58+1,QuadrantMLayerName(chamber),posX+0.1, posY+0.1, posZ+kHzInHFrame+kSCRUNLE, 0, "ONLY");
2052     }
2053 }
2054
2055 //______________________________________________________________________________
2056 void AliMUONSt1GeometryBuilderV2::PlaceInnerLayers(Int_t chamber)
2057 {
2058 /// Place the gas and copper layers for the specified chamber.
2059
2060 // Rotation Matrices 
2061   Int_t rot1, rot2, rot3, rot4;   
2062
2063   fMUON->AliMatrix(rot1,  90., 315., 90.,  45., 0., 0.); // -45 deg
2064   fMUON->AliMatrix(rot2,  90.,  90., 90., 180., 0., 0.); //  90 deg
2065   fMUON->AliMatrix(rot3,  90., 270., 90.,   0., 0., 0.); // -90 deg 
2066   fMUON->AliMatrix(rot4,  90.,  45., 90., 135., 0., 0.); //  deg 
2067
2068   GReal_t x;
2069   GReal_t y;
2070   GReal_t zg = 0.;
2071   GReal_t zc = fgkHzGas + fgkHzPadPlane;
2072   Int_t dpos = (chamber-1)*2;
2073   TString name;
2074   
2075   x = 14.53 + fgkDeltaQuadLHC;
2076   y = 53.34 + fgkDeltaQuadLHC;
2077   name = GasVolumeName("SAG", chamber);
2078   gMC->Gspos(name,1,QuadrantMLayerName(chamber),x,y,zg,0,"ONLY");
2079   gMC->Gspos("SA1C", 1+dpos, QuadrantMLayerName(chamber),x,y, zc,0,"ONLY");
2080   gMC->Gspos("SA1C", 2+dpos, QuadrantMLayerName(chamber),x,y,-zc,0,"ONLY");
2081
2082   x = 40.67 + fgkDeltaQuadLHC;
2083   y = 40.66 + fgkDeltaQuadLHC;    
2084   name = GasVolumeName("SBG", chamber);
2085   gMC->Gspos(name,1,QuadrantMLayerName(chamber),x,y,zg,rot1,"ONLY"); 
2086   gMC->Gspos("SB1C", 1+dpos ,QuadrantMLayerName(chamber),x,y, zc,rot1,"ONLY");
2087   gMC->Gspos("SB1C", 2+dpos, QuadrantMLayerName(chamber),x,y,-zc,rot1,"ONLY");
2088
2089   x = 53.34 + fgkDeltaQuadLHC;
2090   y = 14.52 + fgkDeltaQuadLHC; 
2091   name = GasVolumeName("SCG", chamber);
2092   gMC->Gspos(name,1,QuadrantMLayerName(chamber),x,y,zg,rot2,"ONLY");
2093   gMC->Gspos("SC1C", 1+dpos ,QuadrantMLayerName(chamber),x,y, zc,rot2,"ONLY");
2094   gMC->Gspos("SC1C", 2+dpos ,QuadrantMLayerName(chamber),x,y,-zc,rot2,"ONLY");
2095
2096   x = 5.83 + fgkDeltaQuadLHC;
2097   y = 17.29 + fgkDeltaQuadLHC;
2098   name = GasVolumeName("SDG", chamber);
2099   gMC->Gspos(name,1,QuadrantMLayerName(chamber),x,y,zg,rot3,"ONLY");
2100   gMC->Gspos("SD1C", 1+dpos ,QuadrantMLayerName(chamber),x,y, zc,rot3,"ONLY");
2101   gMC->Gspos("SD1C", 2+dpos ,QuadrantMLayerName(chamber),x,y,-zc,rot3,"ONLY");
2102
2103   x = 9.04 + fgkDeltaQuadLHC;
2104   y = 16.91 + fgkDeltaQuadLHC; 
2105   name = GasVolumeName("SEG", chamber);
2106   gMC->Gspos(name,1,QuadrantMLayerName(chamber),x,y,zg,0,"ONLY");
2107   gMC->Gspos("SE1C", 1+dpos ,QuadrantMLayerName(chamber),x,y, zc,0,"ONLY");
2108   gMC->Gspos("SE1C", 2+dpos ,QuadrantMLayerName(chamber),x,y,-zc,0,"ONLY");
2109
2110   x = 10.12 + fgkDeltaQuadLHC;
2111   y = 14.67 + fgkDeltaQuadLHC;  
2112   name = GasVolumeName("SFG", chamber);
2113   gMC->Gspos(name,1,QuadrantMLayerName(chamber),x,y,zg,rot4,"ONLY");   
2114   gMC->Gspos("SF1C", 1+dpos ,QuadrantMLayerName(chamber),x,y, zc,rot4,"ONLY");
2115   gMC->Gspos("SF1C", 2+dpos ,QuadrantMLayerName(chamber),x,y,-zc,rot4,"ONLY");
2116
2117   x = 8.2042 + fgkDeltaQuadLHC;
2118   y = 16.19 + fgkDeltaQuadLHC;
2119   name = GasVolumeName("SGG", chamber);
2120   gMC->Gspos(name,1,QuadrantMLayerName(chamber),x,y,zg,rot4,"ONLY");
2121   gMC->Gspos("SG1C", 1+dpos ,QuadrantMLayerName(chamber),x,y, zc,rot4,"ONLY");
2122   gMC->Gspos("SG1C", 2+dpos ,QuadrantMLayerName(chamber),x,y,-zc,rot4,"ONLY");
2123
2124   x = 14.68 + fgkDeltaQuadLHC;
2125   y = 10.10 + fgkDeltaQuadLHC;
2126   name = GasVolumeName("SHG", chamber);
2127   gMC->Gspos(name,1,QuadrantMLayerName(chamber),x,y,zg,rot4,"ONLY");
2128   gMC->Gspos("SH1C", 1+dpos ,QuadrantMLayerName(chamber),x,y, zc,rot4,"ONLY");
2129   gMC->Gspos("SH1C", 2+dpos ,QuadrantMLayerName(chamber),x,y,-zc,rot4,"ONLY");
2130
2131   x = 16.21 + fgkDeltaQuadLHC;
2132   y = 8.17 + fgkDeltaQuadLHC;
2133   name = GasVolumeName("SIG", chamber);
2134   gMC->Gspos(name,1,QuadrantMLayerName(chamber),x,y,zg,rot4,"ONLY");
2135   gMC->Gspos("SI1C", 1+dpos ,QuadrantMLayerName(chamber),x,y, zc,rot4,"ONLY");
2136   gMC->Gspos("SI1C", 2+dpos ,QuadrantMLayerName(chamber),x,y,-zc,rot4,"ONLY");
2137
2138   x = 16.92 + fgkDeltaQuadLHC;
2139   y = 9.02 + fgkDeltaQuadLHC;
2140   name = GasVolumeName("SJG", chamber);
2141   gMC->Gspos(name,1,QuadrantMLayerName(chamber),x,y,zg,rot3,"ONLY");
2142   gMC->Gspos("SJ1C", 1+dpos ,QuadrantMLayerName(chamber),x,y, zc,rot3,"ONLY");
2143   gMC->Gspos("SJ1C", 2+dpos ,QuadrantMLayerName(chamber),x,y,-zc,rot3,"ONLY");
2144
2145   x =  17.30 + fgkDeltaQuadLHC;
2146   y =  5.85 + fgkDeltaQuadLHC;
2147   name = GasVolumeName("SKG", chamber);
2148   gMC->Gspos(name,1,QuadrantMLayerName(chamber),x,y,zg,0,"ONLY");
2149   gMC->Gspos("SK1C", 1+dpos ,QuadrantMLayerName(chamber),x,y, zc,0,"ONLY");
2150   gMC->Gspos("SK1C", 2+dpos ,QuadrantMLayerName(chamber),x,y,-zc,0,"ONLY");
2151 }
2152
2153 //______________________________________________________________________________
2154 void AliMUONSt1GeometryBuilderV2::PlaceSector(const AliMpSector* sector,
2155                             SpecialMap specialMap, 
2156                             const TVector3& where, Bool_t reflectZ, Int_t chamber)
2157 {
2158 /// Place all the segments in the mother volume, at the position defined
2159 /// by the sector's data.
2160
2161 /// \cond SKIP
2162
2163   static Int_t segNum=1;
2164   Int_t sgn;
2165   Int_t reflZ;
2166   Int_t rotMat;
2167
2168   if (!reflectZ) {
2169     sgn= 1;
2170     reflZ=0;                                     // no reflection along z... nothing
2171     fMUON->AliMatrix(rotMat,  90.,90.,90,180.,0.,0.);   // 90° rotation around z, NO reflection along z
2172   } else  {
2173     sgn=-1;
2174     fMUON->AliMatrix(reflZ,  90.,0.,90,90.,180.,0.);    // reflection along z
2175     fMUON->AliMatrix(rotMat,  90.,90.,90,180.,180.,0.); // 90° rotation around z AND reflection along z
2176   }
2177   
2178   GReal_t posX,posY,posZ;
2179   
2180 #ifdef WITH_STL  
2181   vector<Int_t> alreadyDone;
2182 #endif
2183
2184 #ifdef WITH_ROOT  
2185   TArrayI alreadyDone(20);
2186   Int_t nofAlreadyDone = 0;
2187 #endif  
2188
2189   for (Int_t irow=0;irow<sector->GetNofRows();irow++){ // for each row
2190     AliMpRow* row = sector->GetRow(irow);
2191
2192
2193     for (Int_t iseg=0;iseg<row->GetNofRowSegments();iseg++){ // for each row segment
2194       AliMpVRowSegment* seg = row->GetRowSegment(iseg);
2195       
2196 #ifdef WITH_STL 
2197       SpecialMap::iterator iter 
2198         = specialMap.find(seg->GetMotifPositionId(0));
2199
2200       if ( iter == specialMap.end()){ //if this is a normal segment (ie. not part of <specialMap>)
2201 #endif  
2202       
2203 #ifdef WITH_ROOT  
2204       Long_t value = specialMap.GetValue(seg->GetMotifPositionId(0));
2205
2206       if ( value == 0 ){ //if this is a normal segment (ie. not part of <specialMap>)
2207 #endif  
2208       
2209         // create the cathode part
2210         CreatePlaneSegment(segNum, seg->Dimensions(), seg->GetNofMotifs());
2211   
2212         posX = where.X() + seg->Position().X();
2213         posY = where.Y() + seg->Position().Y();
2214         posZ = where.Z() + sgn * (TotalHzPlane() + fgkHzGas + 2.*fgkHzPadPlane);
2215         gMC->Gspos(PlaneSegmentName(segNum).Data(), 1, 
2216                    QuadrantMLayerName(chamber), posX, posY, posZ, reflZ, "ONLY");
2217
2218         // and place all the daughter boards of this segment
2219         for (Int_t motifNum=0;motifNum<seg->GetNofMotifs();motifNum++) {
2220
2221           // Copy number
2222           Int_t motifPosId = seg->GetMotifPositionId(motifNum);
2223           AliMpMotifPosition* motifPos = 
2224             sector->GetMotifMap()->FindMotifPosition(motifPosId);
2225           Int_t copyNo = motifPosId;
2226           if ( sector->GetDirection() == AliMp::kX) copyNo += fgkDaughterCopyNoOffset;
2227   
2228           // Position
2229           posX = where.X() + motifPos->Position().X() + fgkOffsetX;
2230           posY = where.Y() + motifPos->Position().Y() + fgkOffsetY;
2231           posZ = where.Z() + sgn * (fgkMotherThick1 - TotalHzDaughter()); 
2232
2233           gMC->Gspos(fgkDaughterName, copyNo, QuadrantMLayerName(chamber), posX, posY, posZ, reflZ, "ONLY");
2234         }  
2235         segNum++;
2236         
2237       } else { 
2238
2239         // if this is a special segment 
2240         for (Int_t motifNum=0;motifNum<seg->GetNofMotifs();motifNum++) {// for each motif
2241
2242           Int_t motifPosId = seg->GetMotifPositionId(motifNum);
2243           
2244 #ifdef WITH_STL
2245           if (find(alreadyDone.begin(),alreadyDone.end(),motifPosId)
2246               != alreadyDone.end()) continue; // don't treat the same motif twice
2247
2248           AliMUONSt1SpecialMotif spMot = specialMap[motifPosId];
2249 #endif
2250 #ifdef WITH_ROOT
2251           Bool_t isDone = false;
2252           Int_t i=0;
2253           while (i<nofAlreadyDone && !isDone) {
2254             if (alreadyDone.At(i) == motifPosId) isDone=true;
2255             i++;
2256           }  
2257           if (isDone) continue; // don't treat the same motif twice
2258
2259           AliMUONSt1SpecialMotif spMot = *((AliMUONSt1SpecialMotif*)specialMap.GetValue(motifPosId));
2260 #endif
2261           // check
2262           // cout << chamber << " processing special motif: " << motifPosId << endl;  
2263
2264           AliMpMotifPosition* motifPos = sector->GetMotifMap()->FindMotifPosition(motifPosId);
2265
2266           // Copy number
2267           Int_t copyNo = motifPosId;
2268           if ( sector->GetDirection() == AliMp::kX) copyNo += fgkDaughterCopyNoOffset;
2269
2270           // place the hole for the motif, wrt the requested rotation angle
2271           Int_t rot = ( spMot.GetRotAngle()<0.1 ) ? reflZ:rotMat;
2272
2273           posX = where.X() + motifPos->Position().X() + spMot.GetDelta().X();
2274           posY = where.Y() + motifPos->Position().Y() + spMot.GetDelta().Y();
2275           posZ = where.Z() + sgn * (TotalHzPlane() + fgkHzGas + 2.*fgkHzPadPlane);
2276           gMC->Gspos(fgkHoleName, copyNo, QuadrantMLayerName(chamber), posX, posY, posZ, rot, "ONLY");
2277
2278           // then place the daughter board for the motif, wrt the requested rotation angle
2279           posX = posX+fgkDeltaFilleEtamX;
2280           posY = posY+fgkDeltaFilleEtamY;
2281           posZ = where.Z() + sgn * (fgkMotherThick1 - TotalHzDaughter()); 
2282           gMC->Gspos(fgkDaughterName, copyNo, QuadrantMLayerName(chamber), posX, posY, posZ, rot, "ONLY");
2283
2284 #ifdef WITH_STL
2285           alreadyDone.push_back(motifPosId);// mark this motif as done
2286 #endif
2287 #ifdef WITH_ROOT
2288           if (nofAlreadyDone == alreadyDone.GetSize()) 
2289              alreadyDone.Set(2*nofAlreadyDone); 
2290           alreadyDone.AddAt(motifPosId, nofAlreadyDone++);                
2291 #endif
2292           // check
2293           // cout << chamber << " processed motifPosId: " << motifPosId << endl;
2294         }               
2295       }// end of special motif case
2296     }
2297   }
2298 /// \endcond
2299
2300
2301 //______________________________________________________________________________
2302 TString AliMUONSt1GeometryBuilderV2::GasVolumeName(const TString& name, Int_t chamber) const
2303 {
2304 /// Insert the chamber number into the name.
2305
2306   TString newString(name);
2307  
2308   TString number(""); 
2309   number += chamber;
2310
2311   newString.Insert(2, number);
2312   
2313   return newString;
2314 }
2315
2316 //
2317 // public methods
2318 //
2319
2320 //______________________________________________________________________________
2321 void AliMUONSt1GeometryBuilderV2::CreateMaterials()
2322 {
2323 /// Define materials specific to station 1
2324
2325 // Materials and medias defined in MUONv1:
2326 //
2327 //  AliMaterial( 9, "ALUMINIUM$", 26.98, 13., 2.7, 8.9, 37.2);
2328 //  AliMaterial(10, "ALUMINIUM$", 26.98, 13., 2.7, 8.9, 37.2);
2329 //  AliMaterial(15, "AIR$      ", 14.61, 7.3, .001205, 30423.24, 67500);
2330 //  AliMixture( 19, "Bakelite$", abak, zbak, dbak, -3, wbak);
2331 //  AliMixture( 20, "ArC4H10 GAS$", ag, zg, dg, 3, wg);
2332 //  AliMixture( 21, "TRIG GAS$", atrig, ztrig, dtrig, -5, wtrig);
2333 //  AliMixture( 22, "ArCO2 80%$", ag1, zg1, dg1, 3, wg1);
2334 //  AliMixture( 23, "Ar-freon $", atr1, ztr1, dtr1, 4, wtr1);
2335 //  AliMixture( 24, "ArCO2 GAS$", agas, zgas, dgas, 3, wgas);
2336 //  AliMaterial(31, "COPPER$",   63.54,    29.,   8.96,  1.4, 0.);
2337 //  AliMixture( 32, "Vetronite$",aglass, zglass, dglass,    5, wglass);
2338 //  AliMaterial(33, "Carbon$",   12.01,     6.,  2.265, 18.8, 49.9);
2339 //  AliMixture( 34, "Rohacell$", arohac, zrohac, drohac,   -4, wrohac); 
2340
2341 //  AliMedium( 1, "AIR_CH_US         ",  15, 1, iSXFLD, ...
2342 //  AliMedium( 4, "ALU_CH_US          ",  9, 0, iSXFLD, ... 
2343 //  AliMedium( 5, "ALU_CH_US          ", 10, 0, iSXFLD, ... 
2344 //  AliMedium( 6, "AR_CH_US          ",  20, 1, iSXFLD, ... 
2345 //  AliMedium( 7, "GAS_CH_TRIGGER    ",  21, 1, iSXFLD, ... 
2346 //  AliMedium( 8, "BAKE_CH_TRIGGER   ",  19, 0, iSXFLD, ... 
2347 //  AliMedium( 9, "ARG_CO2   ",          22, 1, iSXFLD, ... 
2348 //  AliMedium(11, "PCB_COPPER        ",  31, 0, iSXFLD, ... 
2349 //  AliMedium(12, "VETRONITE         ",  32, 0, iSXFLD, ... 
2350 //  AliMedium(13, "CARBON            ",  33, 0, iSXFLD, ... 
2351 //  AliMedium(14, "Rohacell          ",  34, 0, iSXFLD, ... 
2352 //  AliMedium(24, "FrameCH$          ",  44, 1, iSXFLD, ...
2353
2354   //
2355   // --- Define materials for GEANT ---
2356   //
2357
2358   fMUON->AliMaterial(41, "Aluminium II$", 26.98, 13., 2.7, -8.9, 26.1);
2359        // was id: 9
2360        // from PDG and "The Particle Detector BriefBook", Bock and Vasilescu, P.18  
2361         // ??? same but the last but one argument < 0 
2362   //
2363   // --- Define mixtures for GEANT ---
2364   //
2365
2366  //  //     Ar-CO2 gas II (80%+20%)   
2367 //   Float_t ag1[2]   = { 39.95,  44.01};
2368 //   Float_t zg1[2]   = { 18., 22.};
2369 //   Float_t wg1[2]   = { .8, 0.2};
2370 //   Float_t dg1      = .001821;
2371 //   fMUON->AliMixture(45, "ArCO2 II 80%$", ag1, zg1, dg1, 2, wg1);  
2372 //             // was id: 22
2373 //             // use wg1 weighting factors (6th arg > 0)
2374
2375   // Rohacell 51  II - imide methacrylique
2376   Float_t aRohacell51[4] = { 12.01, 1.01, 16.00, 14.01}; 
2377   Float_t zRohacell51[4] = { 6., 1., 8., 7.}; 
2378   Float_t wRohacell51[4] = { 9., 13., 2., 1.};  
2379   Float_t dRohacell51 = 0.052;
2380   fMUON->AliMixture(46, "FOAM$",aRohacell51,zRohacell51,dRohacell51,-4,wRohacell51);  
2381             // was id: 32
2382             // use relative A (molecular) values (6th arg < 0)
2383    
2384   Float_t aSnPb[2] = { 118.69, 207.19};
2385   Float_t zSnPb[2] = { 50, 82};
2386   Float_t wSnPb[2] = { 0.6, 0.4} ;
2387   Float_t dSnPb = 8.926;
2388   fMUON->AliMixture(47, "SnPb$", aSnPb,zSnPb,dSnPb,2,wSnPb);
2389             // was id: 35
2390             // use wSnPb weighting factors (6th arg > 0)
2391
2392   // plastic definition from K5, Freiburg (found on web)
2393   Float_t aPlastic[2]={ 1.01, 12.01};
2394   Float_t zPlastic[2]={ 1, 6};
2395   Float_t wPlastic[2]={ 1, 1};
2396   Float_t denPlastic=1.107;
2397   fMUON->AliMixture(48, "Plastic$",aPlastic,zPlastic,denPlastic,-2,wPlastic);
2398             // was id: 33
2399             // use relative A (molecular) values (6th arg < 0)...no other info...
2400  
2401   // Not used, to be removed
2402   //
2403        // was id: 34
2404
2405   // Inox/Stainless Steel (18%Cr, 9%Ni)
2406   Float_t aInox[3] = {55.847, 51.9961, 58.6934};  
2407   Float_t zInox[3] = {26., 24., 28.};
2408   Float_t wInox[3] = {0.73, 0.18, 0.09}; 
2409   Float_t denInox = 7.930;
2410   fMUON->AliMixture(50, "StainlessSteel$",aInox,zInox,denInox,3,wInox);   
2411             // was id: 37
2412             // use wInox weighting factors (6th arg > 0) 
2413             // from CERN note NUFACT Note023, Oct.2000 
2414   //
2415   // End - Not used, to be removed
2416
2417   //
2418   // --- Define the tracking medias for GEANT ---
2419   // 
2420
2421   GReal_t epsil  = .001;       // Tracking precision,
2422   //GReal_t stemax = -1.;        // Maximum displacement for multiple scat
2423   GReal_t tmaxfd = -20.;       // Maximum angle due to field deflection
2424   //GReal_t deemax = -.3;        // Maximum fractional energy loss, DLS
2425   GReal_t stmin  = -.8;
2426   GReal_t maxStepAlu   = fMUON->GetMaxStepAlu();
2427   GReal_t maxDestepAlu = fMUON->GetMaxDestepAlu();
2428   // GReal_t maxStepGas   = fMUON->GetMaxStepGas();
2429   Int_t iSXFLD   = gAlice->Field()->PrecInteg();
2430   Float_t sXMGMX = gAlice->Field()->Max();
2431
2432   fMUON->AliMedium(21, "ALU_II$",    41, 0, iSXFLD, sXMGMX, 
2433                    tmaxfd, maxStepAlu, maxDestepAlu, epsil, stmin);
2434
2435                    // was med: 20  mat: 36
2436  //  fMUON->AliMedium(25, "ARG_CO2_II", 45, 1, iSXFLD, sXMGMX,
2437 //                    tmaxfd, maxStepGas, maxDestepAlu, epsil, stmin);
2438 //                 // was med: 9   mat: 22
2439   fMUON->AliMedium(26, "FOAM_CH$",   46, 0, iSXFLD, sXMGMX,
2440                    10.0,  0.1, 0.1, 0.1, 0.1, 0, 0) ;
2441                    // was med: 16  mat: 32
2442   fMUON->AliMedium(27, "SnPb$",      47, 0, iSXFLD, sXMGMX,  
2443                    10.0, 0.01, 1.0, 0.003, 0.003);
2444                    // was med: 19  mat: 35
2445   fMUON->AliMedium(28, "Plastic$",   48, 0, iSXFLD, sXMGMX,
2446                    10.0, 0.01, 1.0, 0.003, 0.003);
2447                    // was med: 17  mat: 33
2448
2449   // Not used, to be romoved
2450   //
2451
2452   fMUON->AliMedium(30, "InoxBolts$", 50, 1, iSXFLD, sXMGMX, 
2453                    10.0, 0.01, 1.0, 0.003, 0.003);
2454                    // was med: 21  mat: 37
2455   //
2456   // End - Not used, to be removed
2457 }
2458
2459 //______________________________________________________________________________
2460 void AliMUONSt1GeometryBuilderV2::CreateGeometry()
2461 {
2462 /// Create the detailed GEANT geometry for the dimuon arm station1
2463
2464   AliDebug(1,"Called");
2465
2466   // Define chamber volumes as virtual
2467   // 
2468
2469   // Create basic volumes
2470   // 
2471   CreateHole();
2472   CreateDaughterBoard();
2473   CreateInnerLayers();
2474   
2475   // Create reflexion matrices
2476   //
2477 /*
2478   Int_t reflXZ, reflYZ, reflXY;
2479   fMUON->AliMatrix(reflXZ,  90.,  180., 90., 90., 180., 0.);
2480   fMUON->AliMatrix(reflYZ,  90., 0., 90.,-90., 180., 0.);
2481   fMUON->AliMatrix(reflXY,  90., 180., 90., 270., 0., 0.);
2482 */
2483   // Define transformations for each quadrant
2484   // In old coordinate system:        In new coordinate system:
2485   // 
2486   // 
2487   //     II. |  I.                   I. |  II. 
2488   //         |                    (101) | (100)
2489   //   _____ | ____               _____ | ____                         
2490   //         |                          |
2491   //    III. |  IV.                 IV. | III.
2492   //                              (102) | (103) 
2493   // 
2494 /*
2495   Int_t rotm[4];
2496   rotm[0]=0;       // quadrant I
2497   rotm[1]=reflXZ;  // quadrant II
2498   rotm[2]=reflXY;  // quadrant III
2499   rotm[3]=reflYZ;  // quadrant IV
2500 */
2501   TGeoRotation rotm[4]; 
2502   rotm[0] = TGeoRotation("identity");
2503   rotm[1] = TGeoRotation("reflXZ", 90.,  180., 90., 90., 180., 0.);
2504   rotm[2] = TGeoRotation("reflXY", 90., 180., 90., 270., 0., 0.);
2505   rotm[3] = TGeoRotation("reflYZ", 90., 0., 90.,-90., 180., 0.);
2506   
2507   TVector3 scale[4];  
2508   scale[0] = TVector3( 1,  1,  1);  // quadrant I
2509   scale[1] = TVector3(-1,  1, -1);  // quadrant II
2510   scale[2] = TVector3(-1, -1,  1);  // quadrant III
2511   scale[3] = TVector3( 1, -1, -1);  // quadrant IV
2512   
2513   Int_t  detElemId[4];  
2514   detElemId[0] =  1;  // quadrant I
2515   detElemId[1] =  0;  // quadrant II
2516   detElemId[2] =  3;  // quadrant III
2517   detElemId[3] =  2;  // quadrant IV
2518   
2519   // Shift in Z of the middle layer
2520   Double_t deltaZ = 7.5/2.;         
2521
2522   // Position of quadrant I wrt to the chamber position
2523   // TVector3 pos0(-fgkDeltaQuadLHC, -fgkDeltaQuadLHC, deltaZ);
2524
2525   // Shift for near/far layers
2526   GReal_t  shiftXY = fgkFrameOffset;
2527   GReal_t  shiftZ  = fgkMotherThick1+fgkMotherThick2;
2528
2529   // Build two chambers
2530   //
2531   for (Int_t ich=1; ich<3; ich++) {
2532
2533     // Create quadrant volume
2534     CreateQuadrant(ich);
2535
2536     // Place gas volumes
2537     PlaceInnerLayers(ich);
2538     
2539     // Place the quadrant
2540     for (Int_t i=0; i<4; i++) {
2541
2542       // DE envelope
2543       GReal_t posx0, posy0, posz0;
2544       posx0 = fgkPadXOffsetBP * scale[i].X();
2545       posy0 = fgkPadYOffsetBP * scale[i].Y();;
2546       posz0 = deltaZ * scale[i].Z();
2547       GetEnvelopes(ich-1)
2548         ->AddEnvelope(QuadrantEnvelopeName(ich,i), detElemId[i] + ich*100, true,
2549                       TGeoTranslation(posx0, posy0, posz0), rotm[i]);
2550
2551       // Middle layer
2552       GReal_t posx, posy, posz;
2553       posx = -fgkDeltaQuadLHC - fgkPadXOffsetBP;
2554       posy = -fgkDeltaQuadLHC - fgkPadYOffsetBP;
2555       posz = 0.;
2556       GetEnvelopes(ich-1)
2557         ->AddEnvelopeConstituent(QuadrantMLayerName(ich), QuadrantEnvelopeName(ich,i),
2558                      i+1, TGeoTranslation(posx, posy, posz));
2559
2560       // Near/far layers
2561       GReal_t  posx2 = posx + shiftXY;;
2562       GReal_t  posy2 = posy + shiftXY;;
2563       GReal_t  posz2 = posz - shiftZ;;
2564       //gMC->Gspos(QuadrantNLayerName(ich), i+1, "ALIC", posx2, posy2, posz2, rotm[i],"ONLY");
2565       GetEnvelopes(ich-1)
2566         ->AddEnvelopeConstituent(QuadrantNLayerName(ich), QuadrantEnvelopeName(ich,i),
2567                      i+1, TGeoTranslation(posx2, posy2, posz2)); 
2568     
2569       posz2 = posz + shiftZ;      
2570       //gMC->Gspos(QuadrantFLayerName(ich), i+1, "ALIC", posx2, posy2, posz2, rotm[i],"ONLY");
2571       GetEnvelopes(ich-1)
2572         ->AddEnvelopeConstituent(QuadrantFLayerName(ich), QuadrantEnvelopeName(ich,i), 
2573                      i+1, TGeoTranslation(posx2, posy2, posz2)); 
2574    }
2575  }     
2576 }
2577
2578 //______________________________________________________________________________
2579 void AliMUONSt1GeometryBuilderV2::SetTransformations() 
2580 {
2581 /// Define the transformations for the station2 chambers.
2582
2583   if (gAlice->GetModule("SHIL")) {
2584     SetMotherVolume(0, "YOUT1");
2585     SetMotherVolume(1, "YOUT1");
2586   }  
2587
2588   SetVolume(0, "SC01", true);
2589   SetVolume(1, "SC02", true);
2590
2591   Double_t zpos1 = - AliMUONConstants::DefaultChamberZ(0); 
2592   SetTranslation(0, TGeoTranslation(0., 0., zpos1));
2593
2594   Double_t zpos2 = - AliMUONConstants::DefaultChamberZ(1); 
2595   SetTranslation(1, TGeoTranslation(0., 0., zpos2));
2596 }
2597
2598 //______________________________________________________________________________
2599 void AliMUONSt1GeometryBuilderV2::SetSensitiveVolumes()
2600 {
2601 /// Define the sensitive volumes for station2 chambers.
2602
2603   GetGeometry(0)->SetSensitiveVolume("SA1G");
2604   GetGeometry(0)->SetSensitiveVolume("SB1G");
2605   GetGeometry(0)->SetSensitiveVolume("SC1G");
2606   GetGeometry(0)->SetSensitiveVolume("SD1G");
2607   GetGeometry(0)->SetSensitiveVolume("SE1G");
2608   GetGeometry(0)->SetSensitiveVolume("SF1G");
2609   GetGeometry(0)->SetSensitiveVolume("SG1G");
2610   GetGeometry(0)->SetSensitiveVolume("SH1G");
2611   GetGeometry(0)->SetSensitiveVolume("SI1G");
2612   GetGeometry(0)->SetSensitiveVolume("SJ1G");
2613   GetGeometry(0)->SetSensitiveVolume("SK1G");
2614     
2615   GetGeometry(1)->SetSensitiveVolume("SA2G");
2616   GetGeometry(1)->SetSensitiveVolume("SB2G");
2617   GetGeometry(1)->SetSensitiveVolume("SC2G");
2618   GetGeometry(1)->SetSensitiveVolume("SD2G");
2619   GetGeometry(1)->SetSensitiveVolume("SE2G");
2620   GetGeometry(1)->SetSensitiveVolume("SF2G");
2621   GetGeometry(1)->SetSensitiveVolume("SG2G");
2622   GetGeometry(1)->SetSensitiveVolume("SH2G");
2623   GetGeometry(1)->SetSensitiveVolume("SI2G");
2624   GetGeometry(1)->SetSensitiveVolume("SJ2G");
2625   GetGeometry(1)->SetSensitiveVolume("SK2G");
2626 }
2627