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