Mother volume changed from ALIC to YOUT1/YOUT2 (defined in SHIL)
[u/mrichter/AliRoot.git] / MUON / AliMUONSlatGeometryBuilder.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 // Class AliMUONSlatGeometryBuilder
19 // -------------------------------
20 // Abstract base class for geometry construction per chamber.
21 //
22
23
24
25 // This Builder is designed according to the enveloppe methode. The basic idea is to be able to allow moves 
26 // of the slats on the support panels. 
27 // Those moves can be described with a simple set of parameters. The next step should be now to describe all 
28 // the slats and their places by a unique 
29 // class, which would make the SlatBuilder far more compact since now only three parameters can define a slat 
30 // and its position, like:
31 //   * Bool_t rounded_shape_slat
32 //   * Float_t slat_length
33 //   * Float_t slat_number or Float_t slat_position
34
35 #include <TVirtualMC.h>
36 #include <TGeoMatrix.h>
37 #include <Riostream.h>
38
39 #include "AliRun.h"
40 #include "AliLog.h"
41
42 #include "AliMUONSlatGeometryBuilder.h"
43 #include "AliMUON.h"
44 #include "AliMUONConstants.h"
45 #include "AliMUONGeometryModule.h"
46 #include "AliMUONGeometryEnvelopeStore.h"
47 #include "AliMUONConstants.h"
48
49 ClassImp(AliMUONSlatGeometryBuilder)
50
51
52 //______________________________________________________________________________
53 AliMUONSlatGeometryBuilder::AliMUONSlatGeometryBuilder(AliMUON* muon)
54  : AliMUONVGeometryBuilder(4, 5, 6, 7, 8, 9),
55    fMUON(muon)
56 {
57 // Standard constructor
58
59 }
60
61 //______________________________________________________________________________
62 AliMUONSlatGeometryBuilder::AliMUONSlatGeometryBuilder() 
63  : AliMUONVGeometryBuilder(),
64    fMUON(0)
65 {
66 // Default constructor
67 }
68
69
70 //______________________________________________________________________________
71 AliMUONSlatGeometryBuilder::AliMUONSlatGeometryBuilder(const AliMUONSlatGeometryBuilder& rhs)
72   : AliMUONVGeometryBuilder(rhs)
73 {
74   AliFatal("Copy constructor is not implemented.");
75 }
76
77 //______________________________________________________________________________
78 AliMUONSlatGeometryBuilder::~AliMUONSlatGeometryBuilder() {
79 //
80 }
81
82 //______________________________________________________________________________
83 AliMUONSlatGeometryBuilder& 
84 AliMUONSlatGeometryBuilder::operator = (const AliMUONSlatGeometryBuilder& rhs) 
85 {
86   // check assignement to self
87   if (this == &rhs) return *this;
88
89   AliFatal("Assignment operator is not implemented.");
90     
91   return *this;  
92 }
93
94 //
95 // public methods
96 //
97
98 //______________________________________________________________________________
99 void AliMUONSlatGeometryBuilder::CreateGeometry()
100 {
101   // CreateGeometry is the method containing all the informations concerning Stations 345 geometry.
102   // It includes description and placements of support panels and slats.
103   // The code comes directly from what was written in AliMUONv1.cxx before, with modifications concerning 
104   // the use of Enveloppe method to place the Geant volumes.
105   // Now, few changes would allow the creation of a Slat methode where slat could be described by few parameters, 
106   // and this builder would then be dedicated only to the
107   // placements of the slats. Those modifications could shorten the Station 345 geometry by a non-negligeable factor...
108  
109   Int_t *idtmed = fMUON->GetIdtmed()->GetArray()-1099;
110
111   Float_t angle;
112   Float_t *dum=0;
113
114   // define the id of tracking media:
115   Int_t idAir    = idtmed[1100]; // medium 1
116   Int_t idGas    = idtmed[1108]; // medium 9 = Ar-CO2 gas (80%+20%)
117   Int_t idCopper = idtmed[1110];
118   Int_t idG10    = idtmed[1111];
119   Int_t idCarbon = idtmed[1112];
120   Int_t idRoha   = idtmed[1113];
121   Int_t idNomex  = idtmed[1114]; // honey comb
122   Int_t idNoryl  = idtmed[1115]; 
123   Int_t idNomexB = idtmed[1116]; // bulk material 
124
125   // sensitive area: 40*40 cm**2
126   const Float_t kSensLength = 40.; 
127   const Float_t kSensHeight = 40.; 
128   const Float_t kSensWidth  = AliMUONConstants::Pitch()*2;// 0.5 cm, according to TDR fig 2.120 
129   const Int_t kSensMaterial = idGas;
130   //     const Float_t kYoverlap   = 1.5; 
131
132   // PCB dimensions in cm; width: 30 mum copper   
133   const Float_t kPcbLength  = kSensLength; 
134   const Float_t kPcbHeight  = 58.; // updated Ch. Finck 
135   const Float_t kPcbWidth   = 0.003; 
136   const Int_t kPcbMaterial  = idCopper;
137
138   // Insulating material: 220 mum G10 fiber  glued to pcb  
139   const Float_t kInsuLength = kPcbLength; 
140   const Float_t kInsuHeight = kPcbHeight; 
141   const Float_t kInsuWidth  = 0.022;  // updated Ch. Finck 
142   const Int_t kInsuMaterial = idG10;
143
144   // Carbon fiber panels: 200mum carbon/epoxy skin   
145   const Float_t kCarbonWidth  = 0.020;      
146   const Int_t kCarbonMaterial = idCarbon;
147
148   // Nomex (honey comb) between the two panel carbon skins    
149   const Float_t kNomexLength = kSensLength; 
150   const Float_t kNomexHeight = kSensHeight; 
151   const Float_t kNomexWidth  = 0.8; // updated Ch. Finck 
152   const Int_t kNomexMaterial = idNomex;
153  
154   // Bulk Nomex under panel sandwich Ch. Finck    
155   const Float_t kNomexBWidth  = 0.025; 
156   const Int_t kNomexBMaterial = idNomexB;
157
158   // Panel sandwich 0.02 carbon*2 + 0.8 nomex     
159   const Float_t kPanelLength = kSensLength; 
160   const Float_t kPanelHeight = kSensHeight; 
161   const Float_t kPanelWidth  = 2 * kCarbonWidth + kNomexWidth;
162
163   // Frame along the rounded (spacers) slats 
164   const Float_t kRframeHeight = 2.00; 
165
166   // spacer around the slat: 2 sticks along length,2 along height  
167   // H: the horizontal ones 
168   const Float_t kHframeLength = kPcbLength; 
169   const Float_t kHframeHeight = 1.95; // updated Ch. Finck 
170   const Float_t kHframeWidth  = kSensWidth; 
171   const Int_t kHframeMaterial = idNoryl;
172
173   // V: the vertical ones; vertical spacers 
174   const Float_t kVframeLength = 2.5; 
175   const Float_t kVframeHeight = kSensHeight + kHframeHeight; 
176   const Float_t kVframeWidth  = kSensWidth;
177   const Int_t kVframeMaterial = idNoryl;
178
179   // B: the horizontal border filled with rohacell: ok Ch. Finck
180   const Float_t kBframeLength = kHframeLength; 
181   const Float_t kBframeHeight = (kPcbHeight - kSensHeight)/2. - kHframeHeight; 
182   const Float_t kBframeWidth  = kHframeWidth;
183   const Int_t kBframeMaterial = idRoha;
184
185   // NULOC: 30 mum copper + 200 mum vetronite (same radiation length as 14mum copper) for electronics
186   const Float_t kNulocLength   = 2.5; 
187   const Float_t kNulocHeight   = kBframeHeight;
188   const Float_t kNulocWidth    = 0.0030 + 0.0014; // equivalent copper width of vetronite; 
189   const Int_t   kNulocMaterial = idCopper;
190
191   // Slat parameters
192   const Float_t kSlatHeight = kPcbHeight; 
193   const Float_t kSlatWidth  = kSensWidth + 2.*(kPcbWidth + kInsuWidth + kPanelWidth 
194                                                + kNomexBWidth); //replaced rohacell with Nomex Ch. Finck 
195   // const Int_t   kSlatMaterial = idAir;
196   const Float_t kDslatLength  = -1.25; // position of the slat respect to the beam plane (half vertical spacer) Ch. Finck
197   Float_t zSlat               = AliMUONConstants::DzSlat();// implemented Ch. Finck
198   Float_t dzCh                = AliMUONConstants::DzCh();
199
200   Float_t spar[3];  
201   Int_t i, j;
202   Int_t detElemId;
203
204   // the panel volume contains the nomex
205   Float_t panelpar[3] = { kPanelLength/2., kPanelHeight/2., kPanelWidth/2. }; 
206   Float_t nomexpar[3] = { kNomexLength/2., kNomexHeight/2., kNomexWidth/2. }; 
207   Float_t twidth =  kPanelWidth +  kNomexBWidth; 
208   Float_t nomexbpar[3] = {kNomexLength/2., kNomexHeight/2.,twidth/2. };// bulk nomex 
209
210   // insulating material contains PCB-> gas   
211   twidth = 2*(kInsuWidth + kPcbWidth) + kSensWidth ; 
212   Float_t insupar[3] = {kInsuLength/2., kInsuHeight/2., twidth/2. }; 
213   twidth -= 2 * kInsuWidth; 
214   Float_t pcbpar[3]  = {kPcbLength/2., kPcbHeight/2., twidth/2. }; 
215   Float_t senspar[3] = {kSensLength/2., kSensHeight/2., kSensWidth/2. }; 
216   Float_t theight    = 2 * kHframeHeight + kSensHeight;
217   Float_t hFramepar[3] = {kHframeLength/2., theight/2., kHframeWidth/2.}; 
218   Float_t bFramepar[3] = {kBframeLength/2., kBframeHeight/2., kBframeWidth/2.}; 
219   Float_t vFramepar[3] = {kVframeLength/2., kVframeHeight/2., kVframeWidth/2.};
220   Float_t nulocpar[3]  = {kNulocLength/2.,  kNulocHeight/2.,  kNulocWidth/2.}; 
221
222   Float_t xx;
223   Float_t xxmax = (kBframeLength - kNulocLength)/2.; 
224   Int_t index=0;
225       
226   AliMUONChamber *iChamber, *iChamber1, *iChamber2;
227
228   Int_t* fStations = new Int_t[5];
229   for (Int_t i=0; i<5; i++) fStations[i] = 1;
230   fStations[2] = 1;
231      
232   if (fStations[2])
233     {
234       //********************************************************************
235       //                            Station 3                             **
236       //********************************************************************
237       // indices 1 and 2 for first and second chambers in the station
238       // iChamber (first chamber) kept for other quanties than Z,
239       // assumed to be the same in both chambers
240
241       iChamber = &fMUON->Chamber(4);
242       iChamber1 = iChamber;
243       iChamber2 = &fMUON->Chamber(5);
244      
245       //GetGeometry(4)->SetDebug(kTRUE);
246       //GetGeometry(5)->SetDebug(kTRUE);
247  
248       if (!gAlice->GetModule("DIPO")) {
249         // Mother volume for each chamber in st3 are only defined if Dipole volue is there.
250         // Outer excess and inner recess for mother volume radius
251         // with respect to ROuter and RInner
252         Float_t dframepIn = kRframeHeight; 
253         Float_t dframepOut= kVframeLength + 37.0; // Additional 37 cm gap is needed to wrap the corners of the slats 
254         Float_t tpar[3];
255         Double_t dstation =  ( (-AliMUONConstants::DefaultChamberZ(5)) -
256                                (-AliMUONConstants::DefaultChamberZ(4)) ) /2.1;
257         tpar[0] = AliMUONConstants::Rmin(2)-dframepIn; 
258         tpar[1] = AliMUONConstants::Rmax(2)+dframepOut;
259         tpar[2] = dstation;
260         gMC->Gsvolu("CH05", "TUBE", idAir, tpar, 3);
261         gMC->Gsvolu("CH06", "TUBE", idAir, tpar, 3);
262       }
263       // volumes for slat geometry (xx=5,..,10 chamber id): 
264       // Sxx0 Sxx1 Sxx2 Sxx3  -->   Slat Mother volumes 
265       // SxxG                          -->   Sensitive volume (gas)
266       // SxxP                          -->   PCB (copper) 
267       // SxxI                          -->   Insulator (G10) 
268       // SxxC                          -->   Carbon panel 
269       // SxxN                          -->   Nomex comb
270       // SxxX                          -->   Nomex bulk
271       // SxxH, SxxV                    -->   Horizontal and Vertical frames (Noryl)
272       // SB5x                          -->   Volumes for the 35 cm long PCB
273       // slat dimensions: slat is a MOTHER volume!!! made of air
274
275       // only for chamber 5: slat 1 has a PCB shorter by 5cm!
276
277       Float_t tlength = 35.;
278       Float_t panelpar2[3]  = { tlength/2., panelpar[1],  panelpar[2]}; 
279       Float_t nomexpar2[3]  = { tlength/2., nomexpar[1],  nomexpar[2]}; 
280       Float_t nomexbpar2[3] = { tlength/2., nomexbpar[1],  nomexbpar[2]}; 
281       Float_t insupar2[3]   = { tlength/2., insupar[1],   insupar[2]}; 
282       Float_t pcbpar2[3]    = { tlength/2., pcbpar[1],    pcbpar[2]}; 
283       Float_t senspar2[3]   = { tlength/2., senspar[1],   senspar[2]}; 
284       Float_t hFramepar2[3] = { tlength/2., hFramepar[1], hFramepar[2]}; 
285       Float_t bFramepar2[3] = { tlength/2., bFramepar[1], bFramepar[2]}; 
286       Float_t *dum=0;
287       Float_t pcbDLength3   = (kPcbLength - tlength);
288
289       const Int_t   kNslats3         = 5;  // number of slats per quadrant
290       const Int_t   kNPCB3[kNslats3] = {4, 4, 4, 3, 2}; // n PCB per slat
291       const Float_t kXpos3[kNslats3] = {0., 0., 0., 0., 0.};//{31., 0., 0., 0., 0.};
292       const Float_t kYpos3[kNslats3] = {0, 37.8, 37.7, 37.3, 33.7};
293       Float_t slatLength3[kNslats3]; 
294
295       // create and position the slat (mother) volumes 
296
297       char idSlatCh5[5];
298       char idSlatCh6[5];
299       Float_t xSlat3;
300       Float_t ySlat3 = 0;
301       Float_t angle = 0.;
302       Float_t spar2[3];
303       for (i = 0; i < kNslats3; i++){
304
305         slatLength3[i] = kPcbLength * kNPCB3[i] + 2.* kVframeLength; 
306         xSlat3 = slatLength3[i]/2. +  kDslatLength + kXpos3[i]; 
307         ySlat3 += kYpos3[i];
308
309         spar[0] = slatLength3[i]/2.; 
310         spar[1] = kSlatHeight/2.;
311         spar[2] = kSlatWidth/2.; 
312         // take away 5 cm from the first slat in chamber 5
313         if (i == 0 || i == 1 || i == 2) { // 1 pcb is shortened by 5cm
314           spar2[0] = spar[0] - pcbDLength3/2.;
315         } else {
316           spar2[0] = spar[0];
317         }
318         spar2[1] = spar[1];
319         spar2[2] = spar[2]; 
320         Float_t dzCh3 = dzCh; 
321         Float_t zSlat3 = (i%2 ==0)? -zSlat : zSlat; // seems not that zSlat3 = zSlat4 & 5 refering to plan PQ7EN345-6 ?
322
323         sprintf(idSlatCh5,"LA%d",i+kNslats3-1);
324         //gMC->Gsvolu(idSlatCh5,"BOX",kSlatMaterial,spar2,3);
325         detElemId = 509 - (i + kNslats3-1-4);
326         GetEnvelopes(4)->AddEnvelope(idSlatCh5, detElemId, true, TGeoTranslation(xSlat3, ySlat3, -zSlat3 + dzCh3),
327                                      TGeoRotation("rot1",90,angle,90,90+angle,0,0) );
328
329         sprintf(idSlatCh5,"LA%d",3*kNslats3-2+i);
330         //gMC->Gsvolu(idSlatCh5,"BOX",kSlatMaterial,spar2,3);
331         detElemId = 500 + (i + kNslats3-1-4);
332         GetEnvelopes(4)->AddEnvelope(idSlatCh5, detElemId, true, TGeoTranslation(-xSlat3, ySlat3, zSlat3 - dzCh3),
333                                      TGeoRotation("rot2",90,180+angle,90,90+angle,180,0) );
334
335         if (i > 0) { 
336           sprintf(idSlatCh5,"LA%d",kNslats3-1-i);
337           // gMC->Gsvolu(idSlatCh5,"BOX",kSlatMaterial,spar2,3);
338           detElemId = 509 + (i + kNslats3-1-4);
339           GetEnvelopes(4)->AddEnvelope(idSlatCh5, detElemId, true, TGeoTranslation(xSlat3, -ySlat3, -zSlat3 + dzCh3), 
340                                        TGeoRotation("rot3",90,angle,90,270+angle,180,0) );
341
342           sprintf(idSlatCh5,"LA%d",3*kNslats3-2-i);
343           // gMC->Gsvolu(idSlatCh5,"BOX",kSlatMaterial,spar2,3);
344           detElemId = 518 - (i + kNslats3-1-4);
345           GetEnvelopes(4)->AddEnvelope(idSlatCh5, detElemId, true, TGeoTranslation(-xSlat3, -ySlat3, zSlat3 - dzCh3),
346                                        TGeoRotation("rot4",90,180+angle,90,270+angle,0,0) );
347         }
348
349         sprintf(idSlatCh6,"LB%d",kNslats3-1+i);  
350         // gMC->Gsvolu(idSlatCh6,"BOX",kSlatMaterial,spar,3);
351         detElemId = 609 - (i  + kNslats3-1-4);
352         GetEnvelopes(5)->AddEnvelope(idSlatCh6, detElemId, true, TGeoTranslation(xSlat3, ySlat3, -zSlat3 + dzCh3),
353                                      TGeoRotation("rot5",90,angle,90,90+angle,0,0) );
354         sprintf(idSlatCh6,"LB%d",3*kNslats3-2+i);
355         // gMC->Gsvolu(idSlatCh6,"BOX",kSlatMaterial,spar,3);
356         detElemId = 600 + (i + kNslats3-1-4);
357         GetEnvelopes(5)->AddEnvelope(idSlatCh6, detElemId, true, TGeoTranslation(-xSlat3, ySlat3, zSlat3 - dzCh3),
358                                      TGeoRotation("rot6",90,180+angle,90,90+angle,180,0) );
359
360         if (i > 0) { 
361           sprintf(idSlatCh6,"LB%d",kNslats3-1-i);
362           //gMC->Gsvolu(idSlatCh6,"BOX",kSlatMaterial,spar,3);
363           detElemId = 609 + (i + kNslats3-1-4);
364           GetEnvelopes(5)->AddEnvelope(idSlatCh6, detElemId, true, TGeoTranslation(xSlat3, -ySlat3, -zSlat3 + dzCh3),
365                                        TGeoRotation("rot7",90,angle,90,270+angle,180,0) );
366
367           sprintf(idSlatCh6,"LB%d",3*kNslats3-2-i);
368           //gMC->Gsvolu(idSlatCh6,"BOX",kSlatMaterial,spar,3);
369           detElemId = 618 - (i + kNslats3-1-4);
370           GetEnvelopes(5)->AddEnvelope(idSlatCh6, detElemId, true, TGeoTranslation(-xSlat3, -ySlat3, zSlat3 - dzCh3),
371                                        TGeoRotation("rot8",90,180+angle,90,270+angle,0,0) );
372         }
373       }
374      
375       // create the panel volume 
376  
377       gMC->Gsvolu("S05C","BOX",kCarbonMaterial,panelpar,3);
378       gMC->Gsvolu("SB5C","BOX",kCarbonMaterial,panelpar2,3);
379       gMC->Gsvolu("S06C","BOX",kCarbonMaterial,panelpar,3);
380  
381       // create the nomex volume (honey comb)
382
383       gMC->Gsvolu("S05N","BOX",kNomexMaterial,nomexpar,3);
384       gMC->Gsvolu("SB5N","BOX",kNomexMaterial,nomexpar2,3);
385       gMC->Gsvolu("S06N","BOX",kNomexMaterial,nomexpar,3);
386  
387       // create the nomex volume (bulk)
388
389       gMC->Gsvolu("S05X","BOX",kNomexBMaterial,nomexbpar,3);
390       gMC->Gsvolu("SB5X","BOX",kNomexBMaterial,nomexbpar2,3);
391       gMC->Gsvolu("S06X","BOX",kNomexBMaterial,nomexbpar,3);
392
393       // create the insulating material volume 
394
395       gMC->Gsvolu("S05I","BOX",kInsuMaterial,insupar,3);
396       gMC->Gsvolu("SB5I","BOX",kInsuMaterial,insupar2,3);
397       gMC->Gsvolu("S06I","BOX",kInsuMaterial,insupar,3);
398  
399       // create the PCB volume 
400
401       gMC->Gsvolu("S05P","BOX",kPcbMaterial,pcbpar,3);
402       gMC->Gsvolu("SB5P","BOX",kPcbMaterial,pcbpar2,3);
403       gMC->Gsvolu("S06P","BOX",kPcbMaterial,pcbpar,3);
404  
405       // create the sensitive volumes,
406
407       gMC->Gsvolu("S05G","BOX",kSensMaterial,dum,0);
408       gMC->Gsvolu("S06G","BOX",kSensMaterial,dum,0);
409
410       // create the vertical frame volume 
411
412       gMC->Gsvolu("S05V","BOX",kVframeMaterial,vFramepar,3);
413       gMC->Gsvolu("S06V","BOX",kVframeMaterial,vFramepar,3);
414
415       // create the horizontal frame volume 
416
417       gMC->Gsvolu("S05H","BOX",kHframeMaterial,hFramepar,3);
418       gMC->Gsvolu("SB5H","BOX",kHframeMaterial,hFramepar2,3);
419       gMC->Gsvolu("S06H","BOX",kHframeMaterial,hFramepar,3);
420  
421       // create the horizontal border volume 
422
423       gMC->Gsvolu("S05B","BOX",kBframeMaterial,bFramepar,3);
424       gMC->Gsvolu("SB5B","BOX",kBframeMaterial,bFramepar2,3);
425       gMC->Gsvolu("S06B","BOX",kBframeMaterial,bFramepar,3);
426  
427       index = 0; 
428       for (i = 0; i<kNslats3; i++){
429         for (Int_t quadrant = 1; quadrant <= 4; quadrant++) {
430
431           if (i == 0 && quadrant == 2) continue;
432           if (i == 0 && quadrant == 4) continue;
433
434           sprintf(idSlatCh5,"LA%d",ConvertSlatNum(i,quadrant,kNslats3-1));
435           sprintf(idSlatCh6,"LB%d",ConvertSlatNum(i,quadrant,kNslats3-1));
436           Float_t xvFrame  = (slatLength3[i] - kVframeLength)/2.;
437           Float_t xvFrame2  = xvFrame;
438
439           if (i == 0 || i == 1 || i == 2) xvFrame2 -= pcbDLength3/2.;
440
441           // position the vertical frames 
442           if ( i > 2) { 
443             GetEnvelopes(4)->AddEnvelopeConstituent("S05V", idSlatCh5, 
444                                                     (2*i-1)*10+quadrant,TGeoTranslation(xvFrame,0.,0.));
445             GetEnvelopes(4)->AddEnvelopeConstituent("S05V", idSlatCh5, 
446                                                     (2*i)*10+quadrant,TGeoTranslation(-xvFrame,0.,0.));
447             GetEnvelopes(5)->AddEnvelopeConstituent("S06V", idSlatCh6, 
448                                                     (2*i-1)*10+quadrant,TGeoTranslation(xvFrame,0.,0.));
449             GetEnvelopes(5)->AddEnvelopeConstituent("S06V", idSlatCh6, 
450                                                     (2*i)*10+quadrant,TGeoTranslation(-xvFrame,0.,0.));   
451           } 
452
453           if (i == 2) {
454             GetEnvelopes(4)->AddEnvelopeConstituent("S05V", idSlatCh5, 
455                                                     (2*i-1)*10+quadrant,TGeoTranslation(xvFrame2,0.,0.));
456             GetEnvelopes(4)->AddEnvelopeConstituent("S05V", idSlatCh5, 
457                                                     (2*i)*10+quadrant,TGeoTranslation(-xvFrame,0.,0.));
458             GetEnvelopes(5)->AddEnvelopeConstituent("S06V", idSlatCh6, 
459                                                     (2*i-1)*10+quadrant,TGeoTranslation(xvFrame,0.,0.));
460             GetEnvelopes(5)->AddEnvelopeConstituent("S06V", idSlatCh6, 
461                                                     (2*i)*10+quadrant,TGeoTranslation(-xvFrame,0.,0.));
462           }
463
464           if (i == 0 || i == 1) { // no rounded spacer for the moment (Ch. Finck)
465             GetEnvelopes(4)->AddEnvelopeConstituent("S05V", idSlatCh5, 
466                                                     (2*i-1)*10+quadrant,TGeoTranslation(xvFrame2,0.,0.));
467             GetEnvelopes(5)->AddEnvelopeConstituent("S06V", idSlatCh6, 
468                                                     (2*i-1)*10+quadrant,TGeoTranslation(xvFrame,0.,0.));
469           }
470
471           // position the panels and the insulating material 
472           for (j = 0; j < kNPCB3[i]; j++){
473             if (i == 1 && j == 0) continue;
474             if (i == 0 && j == 0) continue;
475             index++;
476             Float_t xx = kSensLength * (-kNPCB3[i]/2. + j + 0.5); 
477             Float_t xx2 = xx - pcbDLength3/2.; 
478          
479             Float_t zPanel = spar[2] - nomexbpar[2]; 
480
481             if ( (i == 0 || i == 1 || i == 2) && j == kNPCB3[i]-1) { // 1 pcb is shortened by 5cm 
482               GetEnvelopes(4)->AddEnvelopeConstituent("SB5X", idSlatCh5, 2*index-1,TGeoTranslation(xx2,0.,zPanel));
483               GetEnvelopes(4)->AddEnvelopeConstituent("SB5X", idSlatCh5, 2*index,TGeoTranslation(xx2,0.,-zPanel));
484               GetEnvelopes(4)->AddEnvelopeConstituent("SB5I", idSlatCh5, index,TGeoTranslation(xx2,0.,0.));
485             } else {
486               GetEnvelopes(4)->AddEnvelopeConstituent("S05X", idSlatCh5, 2*index-1,TGeoTranslation(xx,0.,zPanel));
487               GetEnvelopes(4)->AddEnvelopeConstituent("S05X", idSlatCh5, 2*index,TGeoTranslation(xx,0.,-zPanel));
488               GetEnvelopes(4)->AddEnvelopeConstituent("S05I", idSlatCh5, index,TGeoTranslation(xx,0.,0.));
489             }
490             GetEnvelopes(5)->AddEnvelopeConstituent("S06X", idSlatCh6, 2*index-1,TGeoTranslation(xx,0.,zPanel));
491             GetEnvelopes(5)->AddEnvelopeConstituent("S06X", idSlatCh6, 2*index,TGeoTranslation(xx,0.,-zPanel));
492             GetEnvelopes(5)->AddEnvelopeConstituent("S06I", idSlatCh6, index,TGeoTranslation(xx,0.,0.));
493  
494           } 
495         }
496       }
497
498       // position the nomex volume inside the panel volume
499       gMC->Gspos("S05N",1,"S05C",0.,0.,0.,0,"ONLY"); 
500       gMC->Gspos("SB5N",1,"SB5C",0.,0.,0.,0,"ONLY"); 
501       gMC->Gspos("S06N",1,"S06C",0.,0.,0.,0,"ONLY"); 
502   
503       // position panel volume inside the bulk nomex material volume
504       gMC->Gspos("S05C",1,"S05X",0.,0.,kNomexBWidth/2.,0,"ONLY"); 
505       gMC->Gspos("SB5C",1,"SB5X",0.,0.,kNomexBWidth/2.,0,"ONLY"); 
506       gMC->Gspos("S06C",1,"S06X",0.,0.,kNomexBWidth/2.,0,"ONLY"); 
507
508       // position the PCB volume inside the insulating material volume
509       gMC->Gspos("S05P",1,"S05I",0.,0.,0.,0,"ONLY"); 
510       gMC->Gspos("SB5P",1,"SB5I",0.,0.,0.,0,"ONLY"); 
511       gMC->Gspos("S06P",1,"S06I",0.,0.,0.,0,"ONLY"); 
512   
513       // position the horizontal frame volume inside the PCB volume
514       gMC->Gspos("S05H",1,"S05P",0.,0.,0.,0,"ONLY"); 
515       gMC->Gspos("SB5H",1,"SB5P",0.,0.,0.,0,"ONLY"); 
516       gMC->Gspos("S06H",1,"S06P",0.,0.,0.,0,"ONLY"); 
517   
518       // position the sensitive volume inside the horizontal frame volume
519       gMC->Gsposp("S05G",1,"S05H",0.,0.,0.,0,"ONLY",senspar,3); 
520       gMC->Gsposp("S05G",1,"SB5H",0.,0.,0.,0,"ONLY",senspar2,3); 
521       gMC->Gsposp("S06G",1,"S06H",0.,0.,0.,0,"ONLY",senspar,3); 
522   
523  
524       // position the border volumes inside the PCB volume
525       Float_t yborder = ( kPcbHeight - kBframeHeight ) / 2.; 
526       gMC->Gspos("S05B",1,"S05P",0., yborder,0.,0,"ONLY"); 
527       gMC->Gspos("S05B",2,"S05P",0.,-yborder,0.,0,"ONLY"); 
528       gMC->Gspos("SB5B",1,"SB5P",0., yborder,0.,0,"ONLY"); 
529       gMC->Gspos("SB5B",2,"SB5P",0.,-yborder,0.,0,"ONLY"); 
530
531       gMC->Gspos("S06B",1,"S06P",0., yborder,0.,0,"ONLY"); 
532       gMC->Gspos("S06B",2,"S06P",0.,-yborder,0.,0,"ONLY"); 
533   
534       // create the NULOC volume and position it in the horizontal frame
535       gMC->Gsvolu("S05E","BOX",kNulocMaterial,nulocpar,3);
536       gMC->Gsvolu("S06E","BOX",kNulocMaterial,nulocpar,3);
537       index = 0;
538       Float_t xxmax2 = xxmax - pcbDLength3/2.;
539       for (xx = -xxmax; xx <= xxmax; xx += 2*kNulocLength) { 
540         index++; 
541         gMC->Gspos("S05E",2*index-1,"S05B", xx, 0.,-kBframeWidth/2. + kNulocWidth/2, 0, "ONLY");
542         gMC->Gspos("S05E",2*index  ,"S05B", xx, 0., kBframeWidth/2. - kNulocWidth/2, 0, "ONLY");
543         gMC->Gspos("S06E",2*index-1,"S06B", xx, 0.,-kBframeWidth/2. + kNulocWidth/2, 0, "ONLY");
544         gMC->Gspos("S06E",2*index  ,"S06B", xx, 0., kBframeWidth/2.-  kNulocWidth/2, 0, "ONLY");
545         if (xx > -xxmax2 && xx< xxmax2) {
546           gMC->Gspos("S05E",2*index-1,"SB5B", xx, 0.,-kBframeWidth/2.+ kNulocWidth/2, 0, "ONLY");
547           gMC->Gspos("S05E",2*index  ,"SB5B", xx, 0., kBframeWidth/2.- kNulocWidth/2, 0, "ONLY");
548         }
549       }
550
551       // position the volumes approximating the circular section of the pipe
552       Float_t epsilon = 0.001; 
553       Int_t ndiv = 6;
554       Int_t imax = 1;
555       Double_t divpar[3];
556       Double_t dydiv = kSensHeight/ndiv;
557       Double_t ydiv  = (kSensHeight - dydiv)/2.;
558       Double_t rmin  = AliMUONConstants::Rmin(2);// Same radius for both chamber in St3
559       Double_t xdiv  = 0.;
560       Float_t xvol;
561       Float_t yvol;
562
563       for (Int_t idiv = 0; idiv < ndiv; idiv++){ 
564         ydiv += dydiv;
565         xdiv = 0.; 
566         if (ydiv < rmin) xdiv = rmin * TMath::Sin( TMath::ACos((ydiv-dydiv/2.)/rmin) );
567         divpar[0] = (kPcbLength - xdiv)/2.; 
568         divpar[1] = dydiv/2. - epsilon;
569         divpar[2] = kSensWidth/2.; 
570         xvol = (kPcbLength + xdiv)/2.;
571         yvol = ydiv; 
572
573         // Volumes close to the beam pipe for slat i=1 so 4 slats per chamber
574         for (Int_t quadrant = 1; quadrant <= 4; quadrant++) {
575           sprintf(idSlatCh5,"LA%d",ConvertSlatNum(1,quadrant,kNslats3-1));
576           sprintf(idSlatCh6,"LB%d",ConvertSlatNum(1,quadrant,kNslats3-1));
577
578           GetEnvelopes(4)->AddEnvelopeConstituentParam("S05G", idSlatCh5, quadrant*100+imax+4*idiv+1,
579                                                        TGeoTranslation(xvol-(kPcbLength * kNPCB3[1]/2.),yvol-kPcbLength,0.),3,divpar);
580
581           GetEnvelopes(5)->AddEnvelopeConstituentParam("S06G", idSlatCh6,  quadrant*100+imax+4*idiv+1,
582                                                        TGeoTranslation(xvol-(kPcbLength * kNPCB3[1]/2.),yvol-kPcbLength,0.),3,divpar);
583         }
584       }
585
586       // Volumes close to the beam pipe for slat i=0 so 2 slats per chamber (central slat for station 3)
587       //      Gines Martinez, Subatech sep 04
588       // 9 box volumes are used to define the PCB closed to the beam pipe of the slat 122000SR1 of chamber 5 and 6 of St3
589       // Accordingly to plan PQ-LAT-SR1 of CEA-DSM-DAPNIA-SIS/BE ph HARDY 8-Oct-2002
590       // Rmin = 31.5 cm
591       rmin = AliMUONConstants::Rmin(2); // Same radius for both chamber in St3
592       ndiv  = 9; 
593       dydiv = kSensHeight/ndiv;           // Vertical size of the box volume approximating the rounded PCB
594       ydiv  = -kSensHeight/2 + dydiv/2.;   // Initializing vertical position of the volume from bottom
595       xdiv  = 0.;                         // Initializing horizontal position of the box volumes
596
597       for (Int_t idiv = 0; idiv < ndiv; idiv++){ 
598         xdiv = TMath::Abs( rmin * TMath::Sin( TMath::ACos(ydiv/rmin) ) );
599         divpar[0] = (kPcbLength - xdiv)/2.; // Dimension of the box volume
600         divpar[1] = dydiv/2. - epsilon;
601         divpar[2] = kSensWidth/2.; 
602         xvol = (kPcbLength + xdiv)/2.; //2D traslition for positionning of box volume
603         yvol =  ydiv;
604         Int_t side;
605         for (side = 1; side <= 2; side++) {
606           sprintf(idSlatCh5,"LA%d",4);     
607           sprintf(idSlatCh6,"LB%d",4);
608           if(side == 2) {
609             sprintf(idSlatCh5,"LA%d",13);          
610             sprintf(idSlatCh6,"LB%d",13);
611           }        
612           GetEnvelopes(4)->AddEnvelopeConstituentParam("S05G", idSlatCh5,500+side*100+imax+4*idiv+1,
613                                                        TGeoTranslation(xvol-(kPcbLength * kNPCB3[0]/2.),yvol,0.),3,divpar);
614
615           GetEnvelopes(5)->AddEnvelopeConstituentParam("S06G", idSlatCh6,500+side*100+imax+4*idiv+1,
616                                                        TGeoTranslation(xvol-(kPcbLength * kNPCB3[0]/2.),yvol,0.),3,divpar);
617         }
618         ydiv += dydiv; // Going from bottom to top
619       }
620       // cout << "Geometry for Station 3...... done" << endl;   
621     }
622     
623   if (fStations[3]) {
624
625
626     // //********************************************************************
627     // //                            Station 4                             **
628     // //********************************************************************
629     //      // indices 1 and 2 for first and second chambers in the station
630     //      // iChamber (first chamber) kept for other quanties than Z,
631     //      // assumed to be the same in both chambers
632     //      corrected geometry (JP. Cussonneau, Ch. Finck)
633  
634     iChamber = &fMUON->Chamber(6);
635     iChamber1 = iChamber;
636     iChamber2 = &fMUON->Chamber(7);
637
638     const Int_t   kNslats4          = 7;  // number of slats per quadrant
639     const Int_t   kNPCB4[kNslats4]  = {5, 6, 5, 5, 4, 3, 2}; // n PCB per slat
640     const Float_t kXpos4[kNslats4]  = {38.2, 0., 0., 0., 0., 0., 0.};
641     const Float_t kYpos41[kNslats4] = {0., 38.2, 34.40, 36.60, 29.3, 37.0, 28.6};
642     const Float_t kYpos42[kNslats4] = {0., 38.2, 37.85, 37.55, 29.4, 37.0, 28.6};
643
644     Float_t slatLength4[kNslats4];     
645
646
647     // Mother volume for each chamber
648     // Outer excess and inner recess for mother volume radius
649     // with respect to ROuter and RInner
650     Float_t dframepIn = kRframeHeight; 
651     Float_t dframepOut= kVframeLength + 40.0; // Additional 30 cm gap is needed to wrap the corners of the slats 
652     Float_t tpar[3];
653     Double_t dstation =  ( (-AliMUONConstants::DefaultChamberZ(7)) - 
654                            (-AliMUONConstants::DefaultChamberZ(6)) ) /2.2;
655     tpar[0] = AliMUONConstants::Rmin(3)-dframepIn; 
656     tpar[1] = AliMUONConstants::Rmax(3)+dframepOut;
657     tpar[2] = dstation;
658     gMC->Gsvolu("CH07", "TUBE", idAir, tpar, 3);
659     gMC->Gsvolu("CH08", "TUBE", idAir, tpar, 3);
660     
661     // create and position the slat (mother) volumes 
662
663     char idSlatCh7[5];
664     char idSlatCh8[5];
665     Float_t xSlat4;
666     Float_t ySlat41 = 0;
667     Float_t ySlat42 = 0;
668
669     angle = 0.;
670
671     for (i = 0; i<kNslats4; i++){
672       slatLength4[i] = kPcbLength * kNPCB4[i] + 2. * kVframeLength; 
673       xSlat4 = slatLength4[i]/2. + kDslatLength + kXpos4[i]; 
674       ySlat41 += kYpos41[i];
675       ySlat42 += kYpos42[i];
676
677       spar[0] = slatLength4[i]/2.; 
678       spar[1] = kSlatHeight/2.;
679       spar[2] = kSlatWidth/2.; 
680       Float_t dzCh4 = dzCh;
681       Float_t zSlat4 = (i%2 ==0)? -zSlat : zSlat; 
682
683       sprintf(idSlatCh7,"LC%d",kNslats4-1+i);
684       //gMC->Gsvolu(idSlatCh7,"BOX",kSlatMaterial,spar,3);
685       detElemId = 713 - (i + kNslats4-1-6);
686       GetEnvelopes(6)->AddEnvelope(idSlatCh7, detElemId, true, TGeoTranslation(xSlat4, ySlat41, -zSlat4 + dzCh4),
687                                    TGeoRotation("rot1",90,angle,90,90+angle,0,0) );
688
689       sprintf(idSlatCh7,"LC%d",3*kNslats4-2+i);
690       //gMC->Gsvolu(idSlatCh7,"BOX",kSlatMaterial,spar,3);
691       detElemId = 700 + (i + kNslats4-1-6);
692       GetEnvelopes(6)->AddEnvelope(idSlatCh7, detElemId, true, TGeoTranslation(-xSlat4, ySlat41, zSlat4 - dzCh4),
693                                    TGeoRotation("rot2",90,180+angle,90,90+angle,180,0) );
694  
695       if (i > 0) { 
696         sprintf(idSlatCh7,"LC%d",kNslats4-1-i);
697         //gMC->Gsvolu(idSlatCh7,"BOX",kSlatMaterial,spar,3);
698         detElemId = 713 + (i + kNslats4-1-6);
699         GetEnvelopes(6)->AddEnvelope(idSlatCh7, detElemId, true, TGeoTranslation(xSlat4, -ySlat41, -zSlat4 + dzCh4),
700                                      TGeoRotation("rot3",90,angle,90,270+angle,180,0) );
701
702         sprintf(idSlatCh7,"LC%d",3*kNslats4-2-i);
703         detElemId = 726 - (i + kNslats4-1-6);
704         //gMC->Gsvolu(idSlatCh7,"BOX",kSlatMaterial,spar,3);
705         GetEnvelopes(6)->AddEnvelope(idSlatCh7, detElemId, true, 
706                                      TGeoTranslation(-xSlat4, -ySlat41, zSlat4 - dzCh4),
707                                      TGeoRotation("rot4",90,180+angle,90,270+angle,0,0) );
708       }
709
710       sprintf(idSlatCh8,"LD%d",kNslats4-1+i);
711       //gMC->Gsvolu(idSlatCh8,"BOX",kSlatMaterial,spar,3);
712       detElemId = 813 - (i + kNslats4-1-6);
713       GetEnvelopes(7)->AddEnvelope(idSlatCh8, detElemId, true, TGeoTranslation(xSlat4, ySlat42, -zSlat4 + dzCh4),
714                                    TGeoRotation("rot5",90,angle,90,90+angle,0,0) );
715
716       sprintf(idSlatCh8,"LD%d",3*kNslats4-2+i);
717       detElemId = 800 + (i + kNslats4-1-6);
718       //gMC->Gsvolu(idSlatCh8,"BOX",kSlatMaterial,spar,3);
719       GetEnvelopes(7)->AddEnvelope(idSlatCh8, detElemId, true, TGeoTranslation(-xSlat4, ySlat42, zSlat4 - dzCh4),
720                                    TGeoRotation("rot6",90,180+angle,90,90+angle,180,0) );
721       if (i > 0) { 
722         sprintf(idSlatCh8,"LD%d",kNslats4-1-i);
723         detElemId = 813 + (i + kNslats4-1-6);
724         //gMC->Gsvolu(idSlatCh8,"BOX",kSlatMaterial,spar,3);
725         GetEnvelopes(7)->AddEnvelope(idSlatCh8, detElemId, true, TGeoTranslation(xSlat4, -ySlat42, -zSlat4 + dzCh4),
726                                      TGeoRotation("rot7",90,angle,90,270+angle,180,0) );
727         sprintf(idSlatCh8,"LD%d",3*kNslats4-2-i);
728         detElemId = 826 - (i + kNslats4-1-6);
729         //gMC->Gsvolu(idSlatCh8,"BOX",kSlatMaterial,spar,3);
730         GetEnvelopes(7)->AddEnvelope(idSlatCh8, detElemId, true, TGeoTranslation(-xSlat4, -ySlat42, zSlat4 - dzCh4),
731                                      TGeoRotation("rot8",90,180+angle,90,270+angle,0,0) );
732       }
733     }
734      
735     // create the panel volume 
736  
737     gMC->Gsvolu("S07C","BOX",kCarbonMaterial,panelpar,3);
738     gMC->Gsvolu("S08C","BOX",kCarbonMaterial,panelpar,3);
739
740     // create the nomex volume 
741
742     gMC->Gsvolu("S07N","BOX",kNomexMaterial,nomexpar,3);
743     gMC->Gsvolu("S08N","BOX",kNomexMaterial,nomexpar,3);
744
745
746     // create the nomex volume (bulk)
747
748     gMC->Gsvolu("S07X","BOX",kNomexBMaterial,nomexbpar,3);
749     gMC->Gsvolu("S08X","BOX",kNomexBMaterial,nomexbpar,3);
750
751     // create the insulating material volume 
752
753     gMC->Gsvolu("S07I","BOX",kInsuMaterial,insupar,3);
754     gMC->Gsvolu("S08I","BOX",kInsuMaterial,insupar,3);
755
756     // create the PCB volume 
757
758     gMC->Gsvolu("S07P","BOX",kPcbMaterial,pcbpar,3);
759     gMC->Gsvolu("S08P","BOX",kPcbMaterial,pcbpar,3);
760  
761     // create the sensitive volumes,
762
763     gMC->Gsvolu("S07G","BOX",kSensMaterial,dum,0);
764     gMC->Gsvolu("S08G","BOX",kSensMaterial,dum,0);
765
766     // create the vertical frame volume 
767
768     gMC->Gsvolu("S07V","BOX",kVframeMaterial,vFramepar,3);
769     gMC->Gsvolu("S08V","BOX",kVframeMaterial,vFramepar,3);
770
771     // create the horizontal frame volume 
772
773     gMC->Gsvolu("S07H","BOX",kHframeMaterial,hFramepar,3);
774     gMC->Gsvolu("S08H","BOX",kHframeMaterial,hFramepar,3);
775
776     // create the horizontal border volume 
777
778     gMC->Gsvolu("S07B","BOX",kBframeMaterial,bFramepar,3);
779     gMC->Gsvolu("S08B","BOX",kBframeMaterial,bFramepar,3);
780
781     index = 0; 
782     for (i = 0; i < kNslats4; i++){
783       for (Int_t quadrant = 1; quadrant <= 4; quadrant++) {
784
785         if (i == 0 && quadrant == 2) continue;
786         if (i == 0 && quadrant == 4) continue;
787
788         sprintf(idSlatCh7,"LC%d",ConvertSlatNum(i,quadrant,kNslats4-1));
789         sprintf(idSlatCh8,"LD%d",ConvertSlatNum(i,quadrant,kNslats4-1));
790         Float_t xvFrame  = (slatLength4[i] - kVframeLength)/2.;
791
792         // position the vertical frames 
793         if (i != 1) { 
794           GetEnvelopes(6)->AddEnvelopeConstituent("S07V", idSlatCh7, (2*i-1)*10+quadrant,TGeoTranslation(xvFrame,0.,0.));
795           GetEnvelopes(6)->AddEnvelopeConstituent("S07V", idSlatCh7, (2*i)*10+quadrant,TGeoTranslation(-xvFrame,0.,0.));
796           GetEnvelopes(7)->AddEnvelopeConstituent("S08V", idSlatCh8, (2*i-1)*10+quadrant,TGeoTranslation(xvFrame,0.,0.));
797           GetEnvelopes(7)->AddEnvelopeConstituent("S08V", idSlatCh8, (2*i)*10+quadrant,TGeoTranslation(-xvFrame,0.,0.));
798         } else { // no rounded spacer yet
799           GetEnvelopes(6)->AddEnvelopeConstituent("S07V", idSlatCh7, (2*i-1)*10+quadrant,TGeoTranslation(xvFrame,0.,0.));
800           // GetEnvelopes(6)->AddEnvelopeConstituent("S07V", idSlatCh7, (2*i)*10+quadrant,TGeoTranslation(-xvFrame,0.,0.));
801           GetEnvelopes(7)->AddEnvelopeConstituent("S08V", idSlatCh8, (2*i-1)*10+quadrant,TGeoTranslation(xvFrame,0.,0.));
802           // GetEnvelopes(7)->AddEnvelopeConstituent("S08V", idSlatCh8, (2*i)*10+quadrant,TGeoTranslation(-xvFrame,0.,0.));
803         }
804         // position the panels and the insulating material 
805         for (j = 0; j < kNPCB4[i]; j++){
806           if (i == 1 && j == 0) continue;
807           index++;
808           Float_t xx = kSensLength * (-kNPCB4[i]/2.+j+.5); 
809
810           Float_t zPanel = spar[2] - nomexbpar[2]; 
811           GetEnvelopes(6)->AddEnvelopeConstituent("S07X", idSlatCh7, 2*index-1,TGeoTranslation(xx,0.,zPanel));
812           GetEnvelopes(6)->AddEnvelopeConstituent("S07X", idSlatCh7, 2*index,TGeoTranslation(xx,0.,-zPanel));
813           GetEnvelopes(6)->AddEnvelopeConstituent("S07I", idSlatCh7, index,TGeoTranslation(xx,0.,0.));
814           GetEnvelopes(7)->AddEnvelopeConstituent("S08X", idSlatCh8, 2*index-1,TGeoTranslation(xx,0.,zPanel));
815           GetEnvelopes(7)->AddEnvelopeConstituent("S08X", idSlatCh8, 2*index,TGeoTranslation(xx,0.,-zPanel));
816           GetEnvelopes(7)->AddEnvelopeConstituent("S08I", idSlatCh8, index,TGeoTranslation(xx,0.,0.));
817         }
818       } 
819     }
820
821     // position the nomex volume inside the panel volume
822     gMC->Gspos("S07N",1,"S07C",0.,0.,0.,0,"ONLY"); 
823     gMC->Gspos("S08N",1,"S08C",0.,0.,0.,0,"ONLY"); 
824
825     // position panel volume inside the bulk nomex material volume
826     gMC->Gspos("S07C",1,"S07X",0.,0.,kNomexBWidth/2.,0,"ONLY"); 
827     gMC->Gspos("S08C",1,"S08X",0.,0.,kNomexBWidth/2.,0,"ONLY"); 
828
829     // position the PCB volume inside the insulating material volume
830     gMC->Gspos("S07P",1,"S07I",0.,0.,0.,0,"ONLY"); 
831     gMC->Gspos("S08P",1,"S08I",0.,0.,0.,0,"ONLY"); 
832
833     // position the horizontal frame volume inside the PCB volume
834     gMC->Gspos("S07H",1,"S07P",0.,0.,0.,0,"ONLY"); 
835     gMC->Gspos("S08H",1,"S08P",0.,0.,0.,0,"ONLY"); 
836
837     // position the sensitive volume inside the horizontal frame volume
838     gMC->Gsposp("S07G",1,"S07H",0.,0.,0.,0,"ONLY",senspar,3); 
839     gMC->Gsposp("S08G",1,"S08H",0.,0.,0.,0,"ONLY",senspar,3); 
840
841     // position the border volumes inside the PCB volume
842     Float_t yborder = ( kPcbHeight - kBframeHeight ) / 2.; 
843     gMC->Gspos("S07B",1,"S07P",0., yborder,0.,0,"ONLY"); 
844     gMC->Gspos("S07B",2,"S07P",0.,-yborder,0.,0,"ONLY"); 
845     gMC->Gspos("S08B",1,"S08P",0., yborder,0.,0,"ONLY"); 
846     gMC->Gspos("S08B",2,"S08P",0.,-yborder,0.,0,"ONLY"); 
847
848     // create the NULOC volume and position it in the horizontal frame
849
850     gMC->Gsvolu("S07E","BOX",kNulocMaterial,nulocpar,3);
851     gMC->Gsvolu("S08E","BOX",kNulocMaterial,nulocpar,3);
852     index = 0;
853     for (xx = -xxmax; xx <= xxmax; xx += 2*kNulocLength) { 
854       index++; 
855       gMC->Gspos("S07E",2*index-1,"S07B", xx, 0.,-kBframeWidth/2. + kNulocWidth/2, 0, "ONLY");
856       gMC->Gspos("S07E",2*index  ,"S07B", xx, 0., kBframeWidth/2. - kNulocWidth/2, 0, "ONLY");
857       gMC->Gspos("S08E",2*index-1,"S08B", xx, 0.,-kBframeWidth/2. + kNulocWidth/2, 0, "ONLY");
858       gMC->Gspos("S08E",2*index  ,"S08B", xx, 0., kBframeWidth/2. - kNulocWidth/2, 0, "ONLY");
859     }
860
861     // position the volumes approximating the circular section of the pipe
862
863     Float_t epsilon = 0.001; 
864     Int_t ndiv = 10;
865     Int_t imax = 1; 
866     Double_t divpar[3];
867     Double_t dydiv = kSensHeight/ndiv;
868     Double_t ydiv  = (kSensHeight - dydiv)/2.;
869     Float_t rmin   = AliMUONConstants::Rmin(3); // Same radius for both chamber of St4
870     Float_t xdiv   = 0.; 
871     Float_t xvol;
872     Float_t yvol;
873
874     for (Int_t idiv = 0; idiv < ndiv; idiv++){ 
875       ydiv += dydiv;
876       xdiv = 0.; 
877       if (ydiv < rmin) xdiv = rmin * TMath::Sin( TMath::ACos((ydiv-dydiv/2.)/rmin) );
878       divpar[0] = (kPcbLength - xdiv)/2.; 
879       divpar[1] = dydiv/2. - epsilon;
880       divpar[2] = kSensWidth/2.; 
881       xvol = (kPcbLength + xdiv)/2.;
882       yvol = ydiv ;
883        
884       for (Int_t quadrant = 1; quadrant <= 4; quadrant++) {
885         sprintf(idSlatCh7,"LC%d",ConvertSlatNum(1,quadrant,kNslats4-1));
886         sprintf(idSlatCh8,"LD%d",ConvertSlatNum(1,quadrant,kNslats4-1));
887          
888         GetEnvelopes(6)->AddEnvelopeConstituentParam("S07G",idSlatCh7, quadrant*100+imax+4*idiv+1,
889                                                      TGeoTranslation(xvol-kPcbLength * kNPCB4[1]/2.,yvol-kPcbLength,0.),3,divpar);
890          
891         GetEnvelopes(7)->AddEnvelopeConstituentParam("S08G", idSlatCh8, quadrant*100+imax+4*idiv+1,
892                                                      TGeoTranslation(xvol-kPcbLength * kNPCB4[1]/2.,yvol-kPcbLength,0.),3,divpar);
893       }
894     }
895     // cout << "Geometry for Station 4...... done" << endl;
896
897   }
898     
899   if (fStations[4]) {
900       
901
902     // //********************************************************************
903     // //                            Station 5                             **
904     // //********************************************************************
905     //      // indices 1 and 2 for first and second chambers in the station
906     //      // iChamber (first chamber) kept for other quanties than Z,
907     //      // assumed to be the same in both chambers
908     //      corrected geometry (JP. Cussonneau, Ch. Finck)
909
910     iChamber = &fMUON->Chamber(8);
911     iChamber1 = iChamber;
912     iChamber2 = &fMUON->Chamber(9);
913  
914     const Int_t   kNslats5         = 7;  // number of slats per quadrant
915     const Int_t   kNPCB5[kNslats5] = {5, 6, 6, 6, 5, 4, 3}; // n PCB per slat
916     const Float_t kXpos5[kNslats5] = {38.2, 0., 0., 0., 0., 0., 0.};
917     const Float_t kYpos5[kNslats5] = {0., 38.2, 37.9, 37.6, 37.3, 37.05, 36.75};
918     Float_t slatLength5[kNslats5]; 
919
920     // Mother volume for each chamber
921     // Outer excess and inner recess for mother volume radius
922     // with respect to ROuter and RInner
923     Float_t dframepIn = kRframeHeight; 
924     Float_t dframepOut= kVframeLength + 40.0; // Additional 40 cm gap is needed to wrap the corners of the slats 
925     Float_t tpar[3];
926     Double_t dstation =  ( (-AliMUONConstants::DefaultChamberZ(9)) - 
927                            (-AliMUONConstants::DefaultChamberZ(8)) ) /2.3;
928     tpar[0] = AliMUONConstants::Rmin(4)-dframepIn; 
929     tpar[1] = AliMUONConstants::Rmax(4)+dframepOut;
930     tpar[2] = dstation;
931     gMC->Gsvolu("CH09", "TUBE", idAir, tpar, 3);
932     gMC->Gsvolu("CH10", "TUBE", idAir, tpar, 3);
933
934     // create and position the slat (mother) volumes 
935
936     char idSlatCh9[5];
937     char idSlatCh10[5];
938     Float_t xSlat5;
939     Float_t ySlat5 = 0;
940     angle = 0.;
941
942     for (i = 0; i < kNslats5; i++){
943
944       slatLength5[i] = kPcbLength * kNPCB5[i] + 2.* kVframeLength; 
945       xSlat5 = slatLength5[i]/2. + kDslatLength + kXpos5[i]; 
946       ySlat5 += kYpos5[i];
947
948       spar[0] = slatLength5[i]/2.; 
949       spar[1] = kSlatHeight/2.;
950       spar[2] = kSlatWidth/2.; 
951
952       Float_t dzCh5  = dzCh;
953       Float_t zSlat5 = (i%2 ==0)? -zSlat : zSlat; 
954
955       sprintf(idSlatCh9,"LE%d",kNslats5-1+i);
956       detElemId = 913 - (i + kNslats5-1-6);
957       //gMC->Gsvolu(idSlatCh9,"BOX",kSlatMaterial,spar,3);
958       GetEnvelopes(8)->AddEnvelope(idSlatCh9, detElemId, true, TGeoTranslation(xSlat5, ySlat5, -zSlat5 + dzCh5),
959                                    TGeoRotation("rot1",90,angle,90,90+angle,0,0) );
960
961       sprintf(idSlatCh9,"LE%d",3*kNslats5-2+i);
962       detElemId = 900 + (i + kNslats5-1-6);
963       //gMC->Gsvolu(idSlatCh9,"BOX",kSlatMaterial,spar,3);
964       GetEnvelopes(8)->AddEnvelope(idSlatCh9, detElemId, true, TGeoTranslation(-xSlat5, ySlat5, zSlat5 - dzCh5),
965                                    TGeoRotation("rot2",90,180+angle,90,90+angle,180,0) );
966  
967       if (i > 0) { 
968         sprintf(idSlatCh9,"LE%d",kNslats5-1-i);
969         detElemId = 913 + (i + kNslats5-1-6);
970         //gMC->Gsvolu(idSlatCh9,"BOX",kSlatMaterial,spar,3);
971         GetEnvelopes(8)->AddEnvelope(idSlatCh9, detElemId, true, TGeoTranslation(xSlat5, -ySlat5, -zSlat5 + dzCh5),
972                                      TGeoRotation("rot3",90,angle,90,270+angle,180,0) );
973
974         sprintf(idSlatCh9,"LE%d",3*kNslats5-2-i);
975         detElemId = 926 - (i + kNslats5-1-6);
976         //gMC->Gsvolu(idSlatCh9,"BOX",kSlatMaterial,spar,3);
977         GetEnvelopes(8)->AddEnvelope(idSlatCh9, detElemId, true, TGeoTranslation(-xSlat5, -ySlat5, zSlat5 - dzCh5),
978                                      TGeoRotation("rot4",90,180+angle,90,270+angle,0,0)  );
979       }
980
981       sprintf(idSlatCh10,"LF%d",kNslats5-1+i);
982       detElemId = 1013 - (i + kNslats5-1-6);
983       //gMC->Gsvolu(idSlatCh10,"BOX",kSlatMaterial,spar,3);
984       GetEnvelopes(9)->AddEnvelope(idSlatCh10, detElemId, true, TGeoTranslation(xSlat5, ySlat5, -zSlat5 + dzCh5),
985                                    TGeoRotation("rot5",90,angle,90,90+angle,0,0) );
986
987       sprintf(idSlatCh10,"LF%d",3*kNslats5-2+i);
988       detElemId = 1000 + (i + kNslats5-1-6);
989       //gMC->Gsvolu(idSlatCh10,"BOX",kSlatMaterial,spar,3);
990       GetEnvelopes(9)->AddEnvelope(idSlatCh10, detElemId, true, TGeoTranslation(-xSlat5, ySlat5, zSlat5 - dzCh5),
991                                    TGeoRotation("rot6",90,180+angle,90,90+angle,180,0) );
992
993       if (i > 0) { 
994         sprintf(idSlatCh10,"LF%d",kNslats5-1-i);
995         detElemId = 1013 + (i + kNslats5-1-6);
996         //gMC->Gsvolu(idSlatCh10,"BOX",kSlatMaterial,spar,3);
997         GetEnvelopes(9)->AddEnvelope(idSlatCh10, detElemId, true, TGeoTranslation(xSlat5, -ySlat5, -zSlat5 + dzCh5),
998                                      TGeoRotation("rot7",90,angle,90,270+angle,180,0) );
999         sprintf(idSlatCh10,"LF%d",3*kNslats5-2-i);
1000         detElemId = 1026 - (i + kNslats5-1-6);
1001         //gMC->Gsvolu(idSlatCh10,"BOX",kSlatMaterial,spar,3);
1002         GetEnvelopes(9)->AddEnvelope(idSlatCh10, detElemId, true, TGeoTranslation(-xSlat5, -ySlat5, zSlat5 - dzCh5),
1003                                      TGeoRotation("rot8",90,180+angle,90,270+angle,0,0) );
1004       }
1005     }
1006
1007     // create the panel volume 
1008  
1009     gMC->Gsvolu("S09C","BOX",kCarbonMaterial,panelpar,3);
1010     gMC->Gsvolu("S10C","BOX",kCarbonMaterial,panelpar,3);
1011
1012     // create the nomex volume 
1013
1014     gMC->Gsvolu("S09N","BOX",kNomexMaterial,nomexpar,3);
1015     gMC->Gsvolu("S10N","BOX",kNomexMaterial,nomexpar,3);
1016
1017
1018     // create the nomex volume (bulk)
1019
1020     gMC->Gsvolu("S09X","BOX",kNomexBMaterial,nomexbpar,3);
1021     gMC->Gsvolu("S10X","BOX",kNomexBMaterial,nomexbpar,3);
1022
1023     // create the insulating material volume 
1024
1025     gMC->Gsvolu("S09I","BOX",kInsuMaterial,insupar,3);
1026     gMC->Gsvolu("S10I","BOX",kInsuMaterial,insupar,3);
1027
1028     // create the PCB volume 
1029
1030     gMC->Gsvolu("S09P","BOX",kPcbMaterial,pcbpar,3);
1031     gMC->Gsvolu("S10P","BOX",kPcbMaterial,pcbpar,3);
1032  
1033     // create the sensitive volumes,
1034
1035     gMC->Gsvolu("S09G","BOX",kSensMaterial,dum,0);
1036     gMC->Gsvolu("S10G","BOX",kSensMaterial,dum,0);
1037
1038     // create the vertical frame volume 
1039
1040     gMC->Gsvolu("S09V","BOX",kVframeMaterial,vFramepar,3);
1041     gMC->Gsvolu("S10V","BOX",kVframeMaterial,vFramepar,3);
1042
1043     // create the horizontal frame volume 
1044
1045     gMC->Gsvolu("S09H","BOX",kHframeMaterial,hFramepar,3);
1046     gMC->Gsvolu("S10H","BOX",kHframeMaterial,hFramepar,3);
1047
1048     // create the horizontal border volume 
1049
1050     gMC->Gsvolu("S09B","BOX",kBframeMaterial,bFramepar,3);
1051     gMC->Gsvolu("S10B","BOX",kBframeMaterial,bFramepar,3);
1052
1053     index = 0; 
1054     for (i = 0; i < kNslats5; i++){
1055       for (Int_t quadrant = 1; quadrant <= 4; quadrant++) {
1056
1057         if (i == 0 && quadrant == 2) continue;
1058         if (i == 0 && quadrant == 4) continue;
1059
1060         sprintf(idSlatCh9,"LE%d",ConvertSlatNum(i,quadrant,kNslats5-1));
1061         sprintf(idSlatCh10,"LF%d",ConvertSlatNum(i,quadrant,kNslats5-1));
1062         Float_t xvFrame  = (slatLength5[i] - kVframeLength)/2.; // ok
1063
1064         // position the vertical frames (spacers)
1065         if (i != 1) { 
1066           GetEnvelopes(8)->AddEnvelopeConstituent("S09V", idSlatCh9, (2*i-1)*10+quadrant,TGeoTranslation(xvFrame,0.,0.));
1067           GetEnvelopes(8)->AddEnvelopeConstituent("S09V", idSlatCh9, (2*i)*10+quadrant,TGeoTranslation(-xvFrame,0.,0.));
1068           GetEnvelopes(9)->AddEnvelopeConstituent("S10V", idSlatCh10, (2*i-1)*10+quadrant,TGeoTranslation(xvFrame,0.,0.));
1069           GetEnvelopes(9)->AddEnvelopeConstituent("S10V", idSlatCh10, (2*i)*10+quadrant,TGeoTranslation(-xvFrame,0.,0.));
1070         } else {  // no rounded spacer yet
1071           GetEnvelopes(8)->AddEnvelopeConstituent("S09V", idSlatCh9, (2*i-1)*10+quadrant,TGeoTranslation(xvFrame,0.,0.));
1072           //       GetEnvelopes(8)->AddEnvelopeConstituent("S09V", idSlatCh9, (2*i)*10+quadrant,TGeoTranslation(-xvFrame,0.,0.));
1073           GetEnvelopes(9)->AddEnvelopeConstituent("S10V", idSlatCh10, (2*i-1)*10+quadrant,TGeoTranslation(xvFrame,0.,0.));
1074           //       GetEnvelopes(9)->AddEnvelopeConstituent("S10V", idSlatCh10, (2*i)*10+quadrant,TGeoTranslation(-xvFrame,0.,0.));
1075         }
1076
1077         // position the panels and the insulating material 
1078         for (j = 0; j < kNPCB5[i]; j++){
1079           if (i == 1 && j == 0) continue;
1080           index++;
1081           Float_t xx = kSensLength * (-kNPCB5[i]/2.+j+.5); 
1082
1083           Float_t zPanel = spar[2] - nomexbpar[2]; 
1084           GetEnvelopes(8)->AddEnvelopeConstituent("S09X", idSlatCh9, 2*index-1,TGeoTranslation(xx,0.,zPanel));
1085           GetEnvelopes(8)->AddEnvelopeConstituent("S09X", idSlatCh9, 2*index,TGeoTranslation(xx,0.,-zPanel));
1086           GetEnvelopes(8)->AddEnvelopeConstituent("S09I", idSlatCh9, index,TGeoTranslation(xx,0.,0.));
1087
1088           GetEnvelopes(9)->AddEnvelopeConstituent("S10X", idSlatCh10, 2*index-1,TGeoTranslation(xx,0.,zPanel));
1089           GetEnvelopes(9)->AddEnvelopeConstituent("S10X", idSlatCh10, 2*index,TGeoTranslation(xx,0.,-zPanel));
1090           GetEnvelopes(9)->AddEnvelopeConstituent("S10I", idSlatCh10, index,TGeoTranslation(xx,0.,0.));
1091         }
1092       } 
1093     }
1094
1095     // position the nomex volume inside the panel volume
1096     gMC->Gspos("S09N",1,"S09C",0.,0.,0.,0,"ONLY"); 
1097     gMC->Gspos("S10N",1,"S10C",0.,0.,0.,0,"ONLY"); 
1098
1099     // position panel  volume inside the bulk nomex material volume
1100     gMC->Gspos("S09C",1,"S09X",0.,0.,kNomexBWidth/2.,0,"ONLY"); 
1101     gMC->Gspos("S10C",1,"S10X",0.,0.,kNomexBWidth/2.,0,"ONLY"); 
1102
1103     // position the PCB volume inside the insulating material volume
1104     gMC->Gspos("S09P",1,"S09I",0.,0.,0.,0,"ONLY"); 
1105     gMC->Gspos("S10P",1,"S10I",0.,0.,0.,0,"ONLY"); 
1106
1107     // position the horizontal frame volume inside the PCB volume
1108     gMC->Gspos("S09H",1,"S09P",0.,0.,0.,0,"ONLY"); 
1109     gMC->Gspos("S10H",1,"S10P",0.,0.,0.,0,"ONLY"); 
1110
1111     // position the sensitive volume inside the horizontal frame volume
1112     gMC->Gsposp("S09G",1,"S09H",0.,0.,0.,0,"ONLY",senspar,3); 
1113     gMC->Gsposp("S10G",1,"S10H",0.,0.,0.,0,"ONLY",senspar,3); 
1114
1115     // position the border volumes inside the PCB volume
1116     Float_t yborder = ( kPcbHeight - kBframeHeight ) / 2.; 
1117     gMC->Gspos("S09B",1,"S09P",0., yborder,0.,0,"ONLY"); 
1118     gMC->Gspos("S09B",2,"S09P",0.,-yborder,0.,0,"ONLY"); 
1119     gMC->Gspos("S10B",1,"S10P",0., yborder,0.,0,"ONLY"); 
1120     gMC->Gspos("S10B",2,"S10P",0.,-yborder,0.,0,"ONLY"); 
1121
1122     //      // create the NULOC volume and position it in the horizontal frame
1123
1124     gMC->Gsvolu("S09E","BOX",kNulocMaterial,nulocpar,3);
1125     gMC->Gsvolu("S10E","BOX",kNulocMaterial,nulocpar,3);
1126     index = 0;
1127     for (xx = -xxmax; xx <= xxmax; xx += 2*kNulocLength) { 
1128       index++; 
1129       gMC->Gspos("S09E",2*index-1,"S09B", xx, 0.,-kBframeWidth/2. + kNulocWidth/2, 0, "ONLY");
1130       gMC->Gspos("S09E",2*index  ,"S09B", xx, 0., kBframeWidth/2. - kNulocWidth/2, 0, "ONLY");
1131       gMC->Gspos("S10E",2*index-1,"S10B", xx, 0.,-kBframeWidth/2. + kNulocWidth/2, 0, "ONLY");
1132       gMC->Gspos("S10E",2*index  ,"S10B", xx, 0., kBframeWidth/2. - kNulocWidth/2, 0, "ONLY");
1133     }
1134
1135
1136     // position the volumes approximating the circular section of the pipe
1137     Float_t epsilon = 0.001; 
1138     Int_t ndiv = 10;
1139     Int_t imax = 1; 
1140     Double_t divpar[3];
1141     Double_t dydiv = kSensHeight/ndiv;
1142     Double_t ydiv  = (kSensHeight - dydiv)/2.;
1143     Float_t rmin   = AliMUONConstants::Rmin(4);
1144     Float_t xdiv   = 0.; 
1145     Float_t xvol;
1146     Float_t yvol; 
1147
1148     for (Int_t idiv = 0; idiv < ndiv; idiv++){ 
1149       ydiv += dydiv;
1150       xdiv = 0.; 
1151       if (ydiv < rmin) xdiv = rmin * TMath::Sin( TMath::ACos((ydiv-dydiv/2.)/rmin) );
1152       divpar[0] = (kPcbLength - xdiv)/2.; 
1153       divpar[1] = dydiv/2. - epsilon;
1154       divpar[2] = kSensWidth/2.; 
1155       xvol = (kPcbLength + xdiv)/2.;
1156       yvol = ydiv;
1157
1158       for (Int_t quadrant = 1; quadrant <= 4; quadrant++) {
1159         sprintf(idSlatCh9,"LE%d",ConvertSlatNum(1,quadrant,kNslats5-1));
1160         sprintf(idSlatCh10,"LF%d",ConvertSlatNum(1,quadrant,kNslats5-1));
1161
1162         GetEnvelopes(8)->AddEnvelopeConstituentParam("S09G", idSlatCh9, quadrant*100+imax+4*idiv+1,
1163                                                      TGeoTranslation(xvol-kPcbLength * kNPCB5[1]/2.,yvol-kPcbLength,0.),3,divpar);
1164         GetEnvelopes(9)->AddEnvelopeConstituentParam("S10G", idSlatCh10,  quadrant*100+imax+4*idiv+1,
1165                                                      TGeoTranslation(xvol-kPcbLength * kNPCB5[1]/2.,yvol-kPcbLength,0.),3,divpar);
1166       }
1167     }
1168     // cout << "Geometry for Station 5...... done" << endl;
1169
1170   }
1171 }
1172
1173
1174 //______________________________________________________________________________
1175 void AliMUONSlatGeometryBuilder::SetTransformations()
1176 {
1177 // Defines the transformations for the station345 chambers.
1178 // ---
1179
1180   if (gAlice->GetModule("DIPO")) {
1181     // if DIPO is preset, the whole station will be placed in DDIP volume
1182     SetMotherVolume(4, "DDIP");
1183     SetMotherVolume(5, "DDIP");
1184     SetVolume(4, "CH05", true);
1185     SetVolume(5, "CH06", true);
1186   }     
1187   else {
1188     SetVolume(4, "CH05");
1189     SetVolume(5, "CH06");
1190   } 
1191    
1192   if (gAlice->GetModule("SHIL")) {
1193     SetMotherVolume(6, "YOUT2");
1194     SetMotherVolume(7, "YOUT2");
1195     SetMotherVolume(8, "YOUT2");
1196     SetMotherVolume(9, "YOUT2");
1197   }  
1198
1199   SetVolume(6, "CH07");
1200   SetVolume(7, "CH08");
1201   SetVolume(8, "CH09");
1202   SetVolume(9, "CH10");
1203
1204 // Stations 345 are not perpendicular to the beam axis
1205 // See AliMUONConstants class
1206   TGeoRotation st345inclination("rot99");
1207   st345inclination.RotateX(AliMUONConstants::St345Inclination());
1208   
1209   Double_t zpos1= - AliMUONConstants::DefaultChamberZ(4); 
1210   SetTransformation(4, TGeoTranslation(0., 0., zpos1), st345inclination);
1211
1212   zpos1= - AliMUONConstants::DefaultChamberZ(5); 
1213   SetTransformation(5, TGeoTranslation(0., 0., zpos1), st345inclination);
1214
1215   zpos1 = - AliMUONConstants::DefaultChamberZ(6); 
1216   SetTransformation(6, TGeoTranslation(0., 0., zpos1), st345inclination);
1217
1218   zpos1 = - AliMUONConstants::DefaultChamberZ(7); 
1219   SetTransformation(7, TGeoTranslation(0., 0., zpos1), st345inclination );
1220
1221   zpos1 = - AliMUONConstants::DefaultChamberZ(8); 
1222   SetTransformation(8, TGeoTranslation(0., 0., zpos1), st345inclination);
1223
1224   zpos1 = - AliMUONConstants::DefaultChamberZ(9); 
1225   SetTransformation(9, TGeoTranslation(0., 0., zpos1), st345inclination);
1226
1227 }
1228
1229 //______________________________________________________________________________
1230 void AliMUONSlatGeometryBuilder::SetSensitiveVolumes()
1231 {
1232 // Defines the sensitive volumes for slat stations chambers.
1233 // ---
1234
1235   GetGeometry(4)->SetSensitiveVolume("S05G");
1236   GetGeometry(5)->SetSensitiveVolume("S06G");
1237   GetGeometry(6)->SetSensitiveVolume("S07G");
1238   GetGeometry(7)->SetSensitiveVolume("S08G");
1239   GetGeometry(8)->SetSensitiveVolume("S09G");
1240   GetGeometry(9)->SetSensitiveVolume("S10G");
1241 }
1242
1243 //______________________________________________________________________________
1244 Int_t  AliMUONSlatGeometryBuilder::ConvertSlatNum(Int_t numslat, Int_t quadnum, Int_t fspq) const
1245 {
1246 // On-line function establishing the correspondance between numslat (the slat number on a particular quadrant (numslat->0....4 for St3))
1247 // and slatnum (the slat number on the whole panel (slatnum->1...18 for St3)
1248   numslat += 1;
1249   if (quadnum==2 || quadnum==3) 
1250     numslat += fspq;
1251   else
1252     numslat = fspq + 2-numslat;
1253   numslat -= 1;
1254               
1255   if (quadnum==3 || quadnum==4) numslat += 2*fspq+1;
1256
1257   return numslat;
1258 }