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