Adding definition of Dmax in constants and semantic modifications for the generation...
[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 dMotherInner = AliMUONConstants::Rmin(2)-kRframeHeight; 
253         Float_t dMotherOutner= AliMUONConstants::Rmax(2)+kVframeLength + 37.0; 
254         // Additional 37 cm gap is needed to wrap the corners of the slats sin Rmax represent the maximum active radius of the chamber with 2pi phi acceptance 
255         Float_t tpar[3];
256         Double_t dstation =  ( (-AliMUONConstants::DefaultChamberZ(5)) -
257                                (-AliMUONConstants::DefaultChamberZ(4)) ) /2.1;
258         tpar[0] = dMotherInner; 
259         tpar[1] = dMotherOutner;
260         tpar[2] = dstation;
261         gMC->Gsvolu("CH05", "TUBE", idAir, tpar, 3);
262         gMC->Gsvolu("CH06", "TUBE", idAir, tpar, 3);
263       }
264       // volumes for slat geometry (xx=5,..,10 chamber id): 
265       // Sxx0 Sxx1 Sxx2 Sxx3  -->   Slat Mother volumes 
266       // SxxG                          -->   Sensitive volume (gas)
267       // SxxP                          -->   PCB (copper) 
268       // SxxI                          -->   Insulator (G10) 
269       // SxxC                          -->   Carbon panel 
270       // SxxN                          -->   Nomex comb
271       // SxxX                          -->   Nomex bulk
272       // SxxH, SxxV                    -->   Horizontal and Vertical frames (Noryl)
273       // SB5x                          -->   Volumes for the 35 cm long PCB
274       // slat dimensions: slat is a MOTHER volume!!! made of air
275
276       // only for chamber 5: slat 1 has a PCB shorter by 5cm!
277
278       Float_t tlength = 35.;
279       Float_t panelpar2[3]  = { tlength/2., panelpar[1],  panelpar[2]}; 
280       Float_t nomexpar2[3]  = { tlength/2., nomexpar[1],  nomexpar[2]}; 
281       Float_t nomexbpar2[3] = { tlength/2., nomexbpar[1],  nomexbpar[2]}; 
282       Float_t insupar2[3]   = { tlength/2., insupar[1],   insupar[2]}; 
283       Float_t pcbpar2[3]    = { tlength/2., pcbpar[1],    pcbpar[2]}; 
284       Float_t senspar2[3]   = { tlength/2., senspar[1],   senspar[2]}; 
285       Float_t hFramepar2[3] = { tlength/2., hFramepar[1], hFramepar[2]}; 
286       Float_t bFramepar2[3] = { tlength/2., bFramepar[1], bFramepar[2]}; 
287       Float_t *dum=0;
288       Float_t pcbDLength3   = (kPcbLength - tlength);
289
290       const Int_t   kNslats3         = 5;  // number of slats per quadrant
291       const Int_t   kNPCB3[kNslats3] = {4, 4, 4, 3, 2}; // n PCB per slat
292       const Float_t kXpos3[kNslats3] = {0., 0., 0., 0., 0.};//{31., 0., 0., 0., 0.};
293       const Float_t kYpos3[kNslats3] = {0, 37.8, 37.7, 37.3, 33.7};
294       Float_t slatLength3[kNslats3]; 
295
296       // create and position the slat (mother) volumes 
297
298       char idSlatCh5[5];
299       char idSlatCh6[5];
300       Float_t xSlat3;
301       Float_t ySlat3 = 0;
302       Float_t angle = 0.;
303       Float_t spar2[3];
304       for (i = 0; i < kNslats3; i++){
305
306         slatLength3[i] = kPcbLength * kNPCB3[i] + 2.* kVframeLength; 
307         xSlat3 = slatLength3[i]/2. +  kDslatLength + kXpos3[i]; 
308         ySlat3 += kYpos3[i];
309
310         spar[0] = slatLength3[i]/2.; 
311         spar[1] = kSlatHeight/2.;
312         spar[2] = kSlatWidth/2.; 
313         // take away 5 cm from the first slat in chamber 5
314         if (i == 0 || i == 1 || i == 2) { // 1 pcb is shortened by 5cm
315           spar2[0] = spar[0] - pcbDLength3/2.;
316         } else {
317           spar2[0] = spar[0];
318         }
319         spar2[1] = spar[1];
320         spar2[2] = spar[2]; 
321         Float_t dzCh3 = dzCh; 
322         Float_t zSlat3 = (i%2 ==0)? -zSlat : zSlat; // seems not that zSlat3 = zSlat4 & 5 refering to plan PQ7EN345-6 ?
323
324         sprintf(idSlatCh5,"LA%d",i+kNslats3-1);
325         //gMC->Gsvolu(idSlatCh5,"BOX",kSlatMaterial,spar2,3);
326         detElemId = 509 - (i + kNslats3-1-4);
327         GetEnvelopes(4)->AddEnvelope(idSlatCh5, detElemId, true, TGeoTranslation(xSlat3, ySlat3, -zSlat3 + dzCh3),
328                                      TGeoRotation("rot1",90,angle,90,90+angle,0,0) );
329
330         sprintf(idSlatCh5,"LA%d",3*kNslats3-2+i);
331         //gMC->Gsvolu(idSlatCh5,"BOX",kSlatMaterial,spar2,3);
332         detElemId = 500 + (i + kNslats3-1-4);
333         GetEnvelopes(4)->AddEnvelope(idSlatCh5, detElemId, true, TGeoTranslation(-xSlat3, ySlat3, zSlat3 - dzCh3),
334                                      TGeoRotation("rot2",90,180+angle,90,90+angle,180,0) );
335
336         if (i > 0) { 
337           sprintf(idSlatCh5,"LA%d",kNslats3-1-i);
338           // gMC->Gsvolu(idSlatCh5,"BOX",kSlatMaterial,spar2,3);
339           detElemId = 509 + (i + kNslats3-1-4);
340           GetEnvelopes(4)->AddEnvelope(idSlatCh5, detElemId, true, TGeoTranslation(xSlat3, -ySlat3, -zSlat3 + dzCh3), 
341                                        TGeoRotation("rot3",90,angle,90,270+angle,180,0) );
342
343           sprintf(idSlatCh5,"LA%d",3*kNslats3-2-i);
344           // gMC->Gsvolu(idSlatCh5,"BOX",kSlatMaterial,spar2,3);
345           detElemId = 518 - (i + kNslats3-1-4);
346           GetEnvelopes(4)->AddEnvelope(idSlatCh5, detElemId, true, TGeoTranslation(-xSlat3, -ySlat3, zSlat3 - dzCh3),
347                                        TGeoRotation("rot4",90,180+angle,90,270+angle,0,0) );
348         }
349
350         sprintf(idSlatCh6,"LB%d",kNslats3-1+i);  
351         // gMC->Gsvolu(idSlatCh6,"BOX",kSlatMaterial,spar,3);
352         detElemId = 609 - (i  + kNslats3-1-4);
353         GetEnvelopes(5)->AddEnvelope(idSlatCh6, detElemId, true, TGeoTranslation(xSlat3, ySlat3, -zSlat3 + dzCh3),
354                                      TGeoRotation("rot5",90,angle,90,90+angle,0,0) );
355         sprintf(idSlatCh6,"LB%d",3*kNslats3-2+i);
356         // gMC->Gsvolu(idSlatCh6,"BOX",kSlatMaterial,spar,3);
357         detElemId = 600 + (i + kNslats3-1-4);
358         GetEnvelopes(5)->AddEnvelope(idSlatCh6, detElemId, true, TGeoTranslation(-xSlat3, ySlat3, zSlat3 - dzCh3),
359                                      TGeoRotation("rot6",90,180+angle,90,90+angle,180,0) );
360
361         if (i > 0) { 
362           sprintf(idSlatCh6,"LB%d",kNslats3-1-i);
363           //gMC->Gsvolu(idSlatCh6,"BOX",kSlatMaterial,spar,3);
364           detElemId = 609 + (i + kNslats3-1-4);
365           GetEnvelopes(5)->AddEnvelope(idSlatCh6, detElemId, true, TGeoTranslation(xSlat3, -ySlat3, -zSlat3 + dzCh3),
366                                        TGeoRotation("rot7",90,angle,90,270+angle,180,0) );
367
368           sprintf(idSlatCh6,"LB%d",3*kNslats3-2-i);
369           //gMC->Gsvolu(idSlatCh6,"BOX",kSlatMaterial,spar,3);
370           detElemId = 618 - (i + kNslats3-1-4);
371           GetEnvelopes(5)->AddEnvelope(idSlatCh6, detElemId, true, TGeoTranslation(-xSlat3, -ySlat3, zSlat3 - dzCh3),
372                                        TGeoRotation("rot8",90,180+angle,90,270+angle,0,0) );
373         }
374       }
375      
376       // create the panel volume 
377  
378       gMC->Gsvolu("S05C","BOX",kCarbonMaterial,panelpar,3);
379       gMC->Gsvolu("SB5C","BOX",kCarbonMaterial,panelpar2,3);
380       gMC->Gsvolu("S06C","BOX",kCarbonMaterial,panelpar,3);
381  
382       // create the nomex volume (honey comb)
383
384       gMC->Gsvolu("S05N","BOX",kNomexMaterial,nomexpar,3);
385       gMC->Gsvolu("SB5N","BOX",kNomexMaterial,nomexpar2,3);
386       gMC->Gsvolu("S06N","BOX",kNomexMaterial,nomexpar,3);
387  
388       // create the nomex volume (bulk)
389
390       gMC->Gsvolu("S05X","BOX",kNomexBMaterial,nomexbpar,3);
391       gMC->Gsvolu("SB5X","BOX",kNomexBMaterial,nomexbpar2,3);
392       gMC->Gsvolu("S06X","BOX",kNomexBMaterial,nomexbpar,3);
393
394       // create the insulating material volume 
395
396       gMC->Gsvolu("S05I","BOX",kInsuMaterial,insupar,3);
397       gMC->Gsvolu("SB5I","BOX",kInsuMaterial,insupar2,3);
398       gMC->Gsvolu("S06I","BOX",kInsuMaterial,insupar,3);
399  
400       // create the PCB volume 
401
402       gMC->Gsvolu("S05P","BOX",kPcbMaterial,pcbpar,3);
403       gMC->Gsvolu("SB5P","BOX",kPcbMaterial,pcbpar2,3);
404       gMC->Gsvolu("S06P","BOX",kPcbMaterial,pcbpar,3);
405  
406       // create the sensitive volumes,
407
408       gMC->Gsvolu("S05G","BOX",kSensMaterial,dum,0);
409       gMC->Gsvolu("S06G","BOX",kSensMaterial,dum,0);
410
411       // create the vertical frame volume 
412
413       gMC->Gsvolu("S05V","BOX",kVframeMaterial,vFramepar,3);
414       gMC->Gsvolu("S06V","BOX",kVframeMaterial,vFramepar,3);
415
416       // create the horizontal frame volume 
417
418       gMC->Gsvolu("S05H","BOX",kHframeMaterial,hFramepar,3);
419       gMC->Gsvolu("SB5H","BOX",kHframeMaterial,hFramepar2,3);
420       gMC->Gsvolu("S06H","BOX",kHframeMaterial,hFramepar,3);
421  
422       // create the horizontal border volume 
423
424       gMC->Gsvolu("S05B","BOX",kBframeMaterial,bFramepar,3);
425       gMC->Gsvolu("SB5B","BOX",kBframeMaterial,bFramepar2,3);
426       gMC->Gsvolu("S06B","BOX",kBframeMaterial,bFramepar,3);
427  
428       index = 0; 
429       for (i = 0; i<kNslats3; i++){
430         for (Int_t quadrant = 1; quadrant <= 4; quadrant++) {
431
432           if (i == 0 && quadrant == 2) continue;
433           if (i == 0 && quadrant == 4) continue;
434
435           sprintf(idSlatCh5,"LA%d",ConvertSlatNum(i,quadrant,kNslats3-1));
436           sprintf(idSlatCh6,"LB%d",ConvertSlatNum(i,quadrant,kNslats3-1));
437           Float_t xvFrame  = (slatLength3[i] - kVframeLength)/2.;
438           Float_t xvFrame2  = xvFrame;
439
440           if (i == 0 || i == 1 || i == 2) xvFrame2 -= pcbDLength3/2.;
441
442           // position the vertical frames 
443           if ( i > 2) { 
444             GetEnvelopes(4)->AddEnvelopeConstituent("S05V", idSlatCh5, 
445                                                     (2*i-1)*10+quadrant,TGeoTranslation(xvFrame,0.,0.));
446             GetEnvelopes(4)->AddEnvelopeConstituent("S05V", idSlatCh5, 
447                                                     (2*i)*10+quadrant,TGeoTranslation(-xvFrame,0.,0.));
448             GetEnvelopes(5)->AddEnvelopeConstituent("S06V", idSlatCh6, 
449                                                     (2*i-1)*10+quadrant,TGeoTranslation(xvFrame,0.,0.));
450             GetEnvelopes(5)->AddEnvelopeConstituent("S06V", idSlatCh6, 
451                                                     (2*i)*10+quadrant,TGeoTranslation(-xvFrame,0.,0.));   
452           } 
453
454           if (i == 2) {
455             GetEnvelopes(4)->AddEnvelopeConstituent("S05V", idSlatCh5, 
456                                                     (2*i-1)*10+quadrant,TGeoTranslation(xvFrame2,0.,0.));
457             GetEnvelopes(4)->AddEnvelopeConstituent("S05V", idSlatCh5, 
458                                                     (2*i)*10+quadrant,TGeoTranslation(-xvFrame,0.,0.));
459             GetEnvelopes(5)->AddEnvelopeConstituent("S06V", idSlatCh6, 
460                                                     (2*i-1)*10+quadrant,TGeoTranslation(xvFrame,0.,0.));
461             GetEnvelopes(5)->AddEnvelopeConstituent("S06V", idSlatCh6, 
462                                                     (2*i)*10+quadrant,TGeoTranslation(-xvFrame,0.,0.));
463           }
464
465           if (i == 0 || i == 1) { // no rounded spacer for the moment (Ch. Finck)
466             GetEnvelopes(4)->AddEnvelopeConstituent("S05V", idSlatCh5, 
467                                                     (2*i-1)*10+quadrant,TGeoTranslation(xvFrame2,0.,0.));
468             GetEnvelopes(5)->AddEnvelopeConstituent("S06V", idSlatCh6, 
469                                                     (2*i-1)*10+quadrant,TGeoTranslation(xvFrame,0.,0.));
470           }
471
472           // position the panels and the insulating material 
473           for (j = 0; j < kNPCB3[i]; j++){
474             if (i == 1 && j == 0) continue;
475             if (i == 0 && j == 0) continue;
476             index++;
477             Float_t xx = kSensLength * (-kNPCB3[i]/2. + j + 0.5); 
478             Float_t xx2 = xx - pcbDLength3/2.; 
479          
480             Float_t zPanel = spar[2] - nomexbpar[2]; 
481
482             if ( (i == 0 || i == 1 || i == 2) && j == kNPCB3[i]-1) { // 1 pcb is shortened by 5cm 
483               GetEnvelopes(4)->AddEnvelopeConstituent("SB5X", idSlatCh5, 2*index-1,TGeoTranslation(xx2,0.,zPanel));
484               GetEnvelopes(4)->AddEnvelopeConstituent("SB5X", idSlatCh5, 2*index,TGeoTranslation(xx2,0.,-zPanel));
485               GetEnvelopes(4)->AddEnvelopeConstituent("SB5I", idSlatCh5, index,TGeoTranslation(xx2,0.,0.));
486             } else {
487               GetEnvelopes(4)->AddEnvelopeConstituent("S05X", idSlatCh5, 2*index-1,TGeoTranslation(xx,0.,zPanel));
488               GetEnvelopes(4)->AddEnvelopeConstituent("S05X", idSlatCh5, 2*index,TGeoTranslation(xx,0.,-zPanel));
489               GetEnvelopes(4)->AddEnvelopeConstituent("S05I", idSlatCh5, index,TGeoTranslation(xx,0.,0.));
490             }
491             GetEnvelopes(5)->AddEnvelopeConstituent("S06X", idSlatCh6, 2*index-1,TGeoTranslation(xx,0.,zPanel));
492             GetEnvelopes(5)->AddEnvelopeConstituent("S06X", idSlatCh6, 2*index,TGeoTranslation(xx,0.,-zPanel));
493             GetEnvelopes(5)->AddEnvelopeConstituent("S06I", idSlatCh6, index,TGeoTranslation(xx,0.,0.));
494  
495           } 
496         }
497       }
498
499       // position the nomex volume inside the panel volume
500       gMC->Gspos("S05N",1,"S05C",0.,0.,0.,0,"ONLY"); 
501       gMC->Gspos("SB5N",1,"SB5C",0.,0.,0.,0,"ONLY"); 
502       gMC->Gspos("S06N",1,"S06C",0.,0.,0.,0,"ONLY"); 
503   
504       // position panel volume inside the bulk nomex material volume
505       gMC->Gspos("S05C",1,"S05X",0.,0.,kNomexBWidth/2.,0,"ONLY"); 
506       gMC->Gspos("SB5C",1,"SB5X",0.,0.,kNomexBWidth/2.,0,"ONLY"); 
507       gMC->Gspos("S06C",1,"S06X",0.,0.,kNomexBWidth/2.,0,"ONLY"); 
508
509       // position the PCB volume inside the insulating material volume
510       gMC->Gspos("S05P",1,"S05I",0.,0.,0.,0,"ONLY"); 
511       gMC->Gspos("SB5P",1,"SB5I",0.,0.,0.,0,"ONLY"); 
512       gMC->Gspos("S06P",1,"S06I",0.,0.,0.,0,"ONLY"); 
513   
514       // position the horizontal frame volume inside the PCB volume
515       gMC->Gspos("S05H",1,"S05P",0.,0.,0.,0,"ONLY"); 
516       gMC->Gspos("SB5H",1,"SB5P",0.,0.,0.,0,"ONLY"); 
517       gMC->Gspos("S06H",1,"S06P",0.,0.,0.,0,"ONLY"); 
518   
519       // position the sensitive volume inside the horizontal frame volume
520       gMC->Gsposp("S05G",1,"S05H",0.,0.,0.,0,"ONLY",senspar,3); 
521       gMC->Gsposp("S05G",1,"SB5H",0.,0.,0.,0,"ONLY",senspar2,3); 
522       gMC->Gsposp("S06G",1,"S06H",0.,0.,0.,0,"ONLY",senspar,3); 
523   
524  
525       // position the border volumes inside the PCB volume
526       Float_t yborder = ( kPcbHeight - kBframeHeight ) / 2.; 
527       gMC->Gspos("S05B",1,"S05P",0., yborder,0.,0,"ONLY"); 
528       gMC->Gspos("S05B",2,"S05P",0.,-yborder,0.,0,"ONLY"); 
529       gMC->Gspos("SB5B",1,"SB5P",0., yborder,0.,0,"ONLY"); 
530       gMC->Gspos("SB5B",2,"SB5P",0.,-yborder,0.,0,"ONLY"); 
531
532       gMC->Gspos("S06B",1,"S06P",0., yborder,0.,0,"ONLY"); 
533       gMC->Gspos("S06B",2,"S06P",0.,-yborder,0.,0,"ONLY"); 
534   
535       // create the NULOC volume and position it in the horizontal frame
536       gMC->Gsvolu("S05E","BOX",kNulocMaterial,nulocpar,3);
537       gMC->Gsvolu("S06E","BOX",kNulocMaterial,nulocpar,3);
538       index = 0;
539       Float_t xxmax2 = xxmax - pcbDLength3/2.;
540       for (xx = -xxmax; xx <= xxmax; xx += 2*kNulocLength) { 
541         index++; 
542         gMC->Gspos("S05E",2*index-1,"S05B", xx, 0.,-kBframeWidth/2. + kNulocWidth/2, 0, "ONLY");
543         gMC->Gspos("S05E",2*index  ,"S05B", xx, 0., kBframeWidth/2. - kNulocWidth/2, 0, "ONLY");
544         gMC->Gspos("S06E",2*index-1,"S06B", xx, 0.,-kBframeWidth/2. + kNulocWidth/2, 0, "ONLY");
545         gMC->Gspos("S06E",2*index  ,"S06B", xx, 0., kBframeWidth/2.-  kNulocWidth/2, 0, "ONLY");
546         if (xx > -xxmax2 && xx< xxmax2) {
547           gMC->Gspos("S05E",2*index-1,"SB5B", xx, 0.,-kBframeWidth/2.+ kNulocWidth/2, 0, "ONLY");
548           gMC->Gspos("S05E",2*index  ,"SB5B", xx, 0., kBframeWidth/2.- kNulocWidth/2, 0, "ONLY");
549         }
550       }
551
552       // position the volumes approximating the circular section of the pipe
553       Float_t epsilon = 0.001; 
554       Int_t ndiv = 6;
555       Int_t imax = 1;
556       Double_t divpar[3];
557       Double_t dydiv = kSensHeight/ndiv;
558       Double_t ydiv  = (kSensHeight - dydiv)/2.;
559       Double_t rmin  = AliMUONConstants::Rmin(2);// Same radius for both chamber in St3
560       Double_t xdiv  = 0.;
561       Float_t xvol;
562       Float_t yvol;
563
564       for (Int_t idiv = 0; idiv < ndiv; idiv++){ 
565         ydiv += dydiv;
566         xdiv = 0.; 
567         if (ydiv < rmin) xdiv = rmin * TMath::Sin( TMath::ACos((ydiv-dydiv/2.)/rmin) );
568         divpar[0] = (kPcbLength - xdiv)/2.; 
569         divpar[1] = dydiv/2. - epsilon;
570         divpar[2] = kSensWidth/2.; 
571         xvol = (kPcbLength + xdiv)/2.;
572         yvol = ydiv; 
573
574         // Volumes close to the beam pipe for slat i=1 so 4 slats per chamber
575         for (Int_t quadrant = 1; quadrant <= 4; quadrant++) {
576           sprintf(idSlatCh5,"LA%d",ConvertSlatNum(1,quadrant,kNslats3-1));
577           sprintf(idSlatCh6,"LB%d",ConvertSlatNum(1,quadrant,kNslats3-1));
578
579           GetEnvelopes(4)->AddEnvelopeConstituentParam("S05G", idSlatCh5, quadrant*100+imax+4*idiv+1,
580                                                        TGeoTranslation(xvol-(kPcbLength * kNPCB3[1]/2.),yvol-kPcbLength,0.),3,divpar);
581
582           GetEnvelopes(5)->AddEnvelopeConstituentParam("S06G", idSlatCh6,  quadrant*100+imax+4*idiv+1,
583                                                        TGeoTranslation(xvol-(kPcbLength * kNPCB3[1]/2.),yvol-kPcbLength,0.),3,divpar);
584         }
585       }
586
587       // Volumes close to the beam pipe for slat i=0 so 2 slats per chamber (central slat for station 3)
588       //      Gines Martinez, Subatech sep 04
589       // 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
590       // Accordingly to plan PQ-LAT-SR1 of CEA-DSM-DAPNIA-SIS/BE ph HARDY 8-Oct-2002
591       // Rmin = 31.5 cm
592       rmin = AliMUONConstants::Rmin(2); // Same radius for both chamber in St3
593       ndiv  = 9; 
594       dydiv = kSensHeight/ndiv;           // Vertical size of the box volume approximating the rounded PCB
595       ydiv  = -kSensHeight/2 + dydiv/2.;   // Initializing vertical position of the volume from bottom
596       xdiv  = 0.;                         // Initializing horizontal position of the box volumes
597
598       for (Int_t idiv = 0; idiv < ndiv; idiv++){ 
599         xdiv = TMath::Abs( rmin * TMath::Sin( TMath::ACos(ydiv/rmin) ) );
600         divpar[0] = (kPcbLength - xdiv)/2.; // Dimension of the box volume
601         divpar[1] = dydiv/2. - epsilon;
602         divpar[2] = kSensWidth/2.; 
603         xvol = (kPcbLength + xdiv)/2.; //2D traslition for positionning of box volume
604         yvol =  ydiv;
605         Int_t side;
606         for (side = 1; side <= 2; side++) {
607           sprintf(idSlatCh5,"LA%d",4);     
608           sprintf(idSlatCh6,"LB%d",4);
609           if(side == 2) {
610             sprintf(idSlatCh5,"LA%d",13);          
611             sprintf(idSlatCh6,"LB%d",13);
612           }        
613           GetEnvelopes(4)->AddEnvelopeConstituentParam("S05G", idSlatCh5,500+side*100+imax+4*idiv+1,
614                                                        TGeoTranslation(xvol-(kPcbLength * kNPCB3[0]/2.),yvol,0.),3,divpar);
615
616           GetEnvelopes(5)->AddEnvelopeConstituentParam("S06G", idSlatCh6,500+side*100+imax+4*idiv+1,
617                                                        TGeoTranslation(xvol-(kPcbLength * kNPCB3[0]/2.),yvol,0.),3,divpar);
618         }
619         ydiv += dydiv; // Going from bottom to top
620       }
621       // cout << "Geometry for Station 3...... done" << endl;   
622     }
623     
624   if (fStations[3]) {
625
626
627     // //********************************************************************
628     // //                            Station 4                             **
629     // //********************************************************************
630     //      // indices 1 and 2 for first and second chambers in the station
631     //      // iChamber (first chamber) kept for other quanties than Z,
632     //      // assumed to be the same in both chambers
633     //      corrected geometry (JP. Cussonneau, Ch. Finck)
634  
635     iChamber = &fMUON->Chamber(6);
636     iChamber1 = iChamber;
637     iChamber2 = &fMUON->Chamber(7);
638
639     const Int_t   kNslats4          = 7;  // number of slats per quadrant
640     const Int_t   kNPCB4[kNslats4]  = {5, 6, 5, 5, 4, 3, 2}; // n PCB per slat
641     const Float_t kXpos4[kNslats4]  = {38.2, 0., 0., 0., 0., 0., 0.};
642     const Float_t kYpos41[kNslats4] = {0., 38.2, 34.40, 36.60, 29.3, 37.0, 28.6};
643     const Float_t kYpos42[kNslats4] = {0., 38.2, 37.85, 37.55, 29.4, 37.0, 28.6};
644
645     Float_t slatLength4[kNslats4];     
646
647
648     // Mother volume for each chamber
649     // Outer excess and inner recess for mother volume radius
650     // with respect to ROuter and RInner
651     Float_t dMotherInner =  AliMUONConstants::Rmin(3)-kRframeHeight; 
652     // Additional 40 cm gap is needed to wrap the corners of the slats since Rmax represent the maximum active radius of the chamber with 2pi phi acceptance 
653     Float_t dMotherOutner= AliMUONConstants::Rmax(3)+kVframeLength + 40.0;
654     Float_t tpar[3];
655     Double_t dstation =  ( (-AliMUONConstants::DefaultChamberZ(7)) - 
656                            (-AliMUONConstants::DefaultChamberZ(6)) ) /2.2;
657     tpar[0] = dMotherInner; 
658     tpar[1] = dMotherOutner;
659     tpar[2] = dstation;
660     gMC->Gsvolu("CH07", "TUBE", idAir, tpar, 3);
661     gMC->Gsvolu("CH08", "TUBE", idAir, tpar, 3);
662     
663     // create and position the slat (mother) volumes 
664
665     char idSlatCh7[5];
666     char idSlatCh8[5];
667     Float_t xSlat4;
668     Float_t ySlat41 = 0;
669     Float_t ySlat42 = 0;
670
671     angle = 0.;
672
673     for (i = 0; i<kNslats4; i++){
674       slatLength4[i] = kPcbLength * kNPCB4[i] + 2. * kVframeLength; 
675       xSlat4 = slatLength4[i]/2. + kDslatLength + kXpos4[i]; 
676       ySlat41 += kYpos41[i];
677       ySlat42 += kYpos42[i];
678
679       spar[0] = slatLength4[i]/2.; 
680       spar[1] = kSlatHeight/2.;
681       spar[2] = kSlatWidth/2.; 
682       Float_t dzCh4 = dzCh;
683       Float_t zSlat4 = (i%2 ==0)? -zSlat : zSlat; 
684
685       sprintf(idSlatCh7,"LC%d",kNslats4-1+i);
686       //gMC->Gsvolu(idSlatCh7,"BOX",kSlatMaterial,spar,3);
687       detElemId = 713 - (i + kNslats4-1-6);
688       GetEnvelopes(6)->AddEnvelope(idSlatCh7, detElemId, true, TGeoTranslation(xSlat4, ySlat41, -zSlat4 + dzCh4),
689                                    TGeoRotation("rot1",90,angle,90,90+angle,0,0) );
690
691       sprintf(idSlatCh7,"LC%d",3*kNslats4-2+i);
692       //gMC->Gsvolu(idSlatCh7,"BOX",kSlatMaterial,spar,3);
693       detElemId = 700 + (i + kNslats4-1-6);
694       GetEnvelopes(6)->AddEnvelope(idSlatCh7, detElemId, true, TGeoTranslation(-xSlat4, ySlat41, zSlat4 - dzCh4),
695                                    TGeoRotation("rot2",90,180+angle,90,90+angle,180,0) );
696  
697       if (i > 0) { 
698         sprintf(idSlatCh7,"LC%d",kNslats4-1-i);
699         //gMC->Gsvolu(idSlatCh7,"BOX",kSlatMaterial,spar,3);
700         detElemId = 713 + (i + kNslats4-1-6);
701         GetEnvelopes(6)->AddEnvelope(idSlatCh7, detElemId, true, TGeoTranslation(xSlat4, -ySlat41, -zSlat4 + dzCh4),
702                                      TGeoRotation("rot3",90,angle,90,270+angle,180,0) );
703
704         sprintf(idSlatCh7,"LC%d",3*kNslats4-2-i);
705         detElemId = 726 - (i + kNslats4-1-6);
706         //gMC->Gsvolu(idSlatCh7,"BOX",kSlatMaterial,spar,3);
707         GetEnvelopes(6)->AddEnvelope(idSlatCh7, detElemId, true, 
708                                      TGeoTranslation(-xSlat4, -ySlat41, zSlat4 - dzCh4),
709                                      TGeoRotation("rot4",90,180+angle,90,270+angle,0,0) );
710       }
711
712       sprintf(idSlatCh8,"LD%d",kNslats4-1+i);
713       //gMC->Gsvolu(idSlatCh8,"BOX",kSlatMaterial,spar,3);
714       detElemId = 813 - (i + kNslats4-1-6);
715       GetEnvelopes(7)->AddEnvelope(idSlatCh8, detElemId, true, TGeoTranslation(xSlat4, ySlat42, -zSlat4 + dzCh4),
716                                    TGeoRotation("rot5",90,angle,90,90+angle,0,0) );
717
718       sprintf(idSlatCh8,"LD%d",3*kNslats4-2+i);
719       detElemId = 800 + (i + kNslats4-1-6);
720       //gMC->Gsvolu(idSlatCh8,"BOX",kSlatMaterial,spar,3);
721       GetEnvelopes(7)->AddEnvelope(idSlatCh8, detElemId, true, TGeoTranslation(-xSlat4, ySlat42, zSlat4 - dzCh4),
722                                    TGeoRotation("rot6",90,180+angle,90,90+angle,180,0) );
723       if (i > 0) { 
724         sprintf(idSlatCh8,"LD%d",kNslats4-1-i);
725         detElemId = 813 + (i + kNslats4-1-6);
726         //gMC->Gsvolu(idSlatCh8,"BOX",kSlatMaterial,spar,3);
727         GetEnvelopes(7)->AddEnvelope(idSlatCh8, detElemId, true, TGeoTranslation(xSlat4, -ySlat42, -zSlat4 + dzCh4),
728                                      TGeoRotation("rot7",90,angle,90,270+angle,180,0) );
729         sprintf(idSlatCh8,"LD%d",3*kNslats4-2-i);
730         detElemId = 826 - (i + kNslats4-1-6);
731         //gMC->Gsvolu(idSlatCh8,"BOX",kSlatMaterial,spar,3);
732         GetEnvelopes(7)->AddEnvelope(idSlatCh8, detElemId, true, TGeoTranslation(-xSlat4, -ySlat42, zSlat4 - dzCh4),
733                                      TGeoRotation("rot8",90,180+angle,90,270+angle,0,0) );
734       }
735     }
736      
737     // create the panel volume 
738  
739     gMC->Gsvolu("S07C","BOX",kCarbonMaterial,panelpar,3);
740     gMC->Gsvolu("S08C","BOX",kCarbonMaterial,panelpar,3);
741
742     // create the nomex volume 
743
744     gMC->Gsvolu("S07N","BOX",kNomexMaterial,nomexpar,3);
745     gMC->Gsvolu("S08N","BOX",kNomexMaterial,nomexpar,3);
746
747
748     // create the nomex volume (bulk)
749
750     gMC->Gsvolu("S07X","BOX",kNomexBMaterial,nomexbpar,3);
751     gMC->Gsvolu("S08X","BOX",kNomexBMaterial,nomexbpar,3);
752
753     // create the insulating material volume 
754
755     gMC->Gsvolu("S07I","BOX",kInsuMaterial,insupar,3);
756     gMC->Gsvolu("S08I","BOX",kInsuMaterial,insupar,3);
757
758     // create the PCB volume 
759
760     gMC->Gsvolu("S07P","BOX",kPcbMaterial,pcbpar,3);
761     gMC->Gsvolu("S08P","BOX",kPcbMaterial,pcbpar,3);
762  
763     // create the sensitive volumes,
764
765     gMC->Gsvolu("S07G","BOX",kSensMaterial,dum,0);
766     gMC->Gsvolu("S08G","BOX",kSensMaterial,dum,0);
767
768     // create the vertical frame volume 
769
770     gMC->Gsvolu("S07V","BOX",kVframeMaterial,vFramepar,3);
771     gMC->Gsvolu("S08V","BOX",kVframeMaterial,vFramepar,3);
772
773     // create the horizontal frame volume 
774
775     gMC->Gsvolu("S07H","BOX",kHframeMaterial,hFramepar,3);
776     gMC->Gsvolu("S08H","BOX",kHframeMaterial,hFramepar,3);
777
778     // create the horizontal border volume 
779
780     gMC->Gsvolu("S07B","BOX",kBframeMaterial,bFramepar,3);
781     gMC->Gsvolu("S08B","BOX",kBframeMaterial,bFramepar,3);
782
783     index = 0; 
784     for (i = 0; i < kNslats4; i++){
785       for (Int_t quadrant = 1; quadrant <= 4; quadrant++) {
786
787         if (i == 0 && quadrant == 2) continue;
788         if (i == 0 && quadrant == 4) continue;
789
790         sprintf(idSlatCh7,"LC%d",ConvertSlatNum(i,quadrant,kNslats4-1));
791         sprintf(idSlatCh8,"LD%d",ConvertSlatNum(i,quadrant,kNslats4-1));
792         Float_t xvFrame  = (slatLength4[i] - kVframeLength)/2.;
793
794         // position the vertical frames 
795         if (i != 1) { 
796           GetEnvelopes(6)->AddEnvelopeConstituent("S07V", idSlatCh7, (2*i-1)*10+quadrant,TGeoTranslation(xvFrame,0.,0.));
797           GetEnvelopes(6)->AddEnvelopeConstituent("S07V", idSlatCh7, (2*i)*10+quadrant,TGeoTranslation(-xvFrame,0.,0.));
798           GetEnvelopes(7)->AddEnvelopeConstituent("S08V", idSlatCh8, (2*i-1)*10+quadrant,TGeoTranslation(xvFrame,0.,0.));
799           GetEnvelopes(7)->AddEnvelopeConstituent("S08V", idSlatCh8, (2*i)*10+quadrant,TGeoTranslation(-xvFrame,0.,0.));
800         } else { // no rounded spacer yet
801           GetEnvelopes(6)->AddEnvelopeConstituent("S07V", idSlatCh7, (2*i-1)*10+quadrant,TGeoTranslation(xvFrame,0.,0.));
802           // GetEnvelopes(6)->AddEnvelopeConstituent("S07V", idSlatCh7, (2*i)*10+quadrant,TGeoTranslation(-xvFrame,0.,0.));
803           GetEnvelopes(7)->AddEnvelopeConstituent("S08V", idSlatCh8, (2*i-1)*10+quadrant,TGeoTranslation(xvFrame,0.,0.));
804           // GetEnvelopes(7)->AddEnvelopeConstituent("S08V", idSlatCh8, (2*i)*10+quadrant,TGeoTranslation(-xvFrame,0.,0.));
805         }
806         // position the panels and the insulating material 
807         for (j = 0; j < kNPCB4[i]; j++){
808           if (i == 1 && j == 0) continue;
809           index++;
810           Float_t xx = kSensLength * (-kNPCB4[i]/2.+j+.5); 
811
812           Float_t zPanel = spar[2] - nomexbpar[2]; 
813           GetEnvelopes(6)->AddEnvelopeConstituent("S07X", idSlatCh7, 2*index-1,TGeoTranslation(xx,0.,zPanel));
814           GetEnvelopes(6)->AddEnvelopeConstituent("S07X", idSlatCh7, 2*index,TGeoTranslation(xx,0.,-zPanel));
815           GetEnvelopes(6)->AddEnvelopeConstituent("S07I", idSlatCh7, index,TGeoTranslation(xx,0.,0.));
816           GetEnvelopes(7)->AddEnvelopeConstituent("S08X", idSlatCh8, 2*index-1,TGeoTranslation(xx,0.,zPanel));
817           GetEnvelopes(7)->AddEnvelopeConstituent("S08X", idSlatCh8, 2*index,TGeoTranslation(xx,0.,-zPanel));
818           GetEnvelopes(7)->AddEnvelopeConstituent("S08I", idSlatCh8, index,TGeoTranslation(xx,0.,0.));
819         }
820       } 
821     }
822
823     // position the nomex volume inside the panel volume
824     gMC->Gspos("S07N",1,"S07C",0.,0.,0.,0,"ONLY"); 
825     gMC->Gspos("S08N",1,"S08C",0.,0.,0.,0,"ONLY"); 
826
827     // position panel volume inside the bulk nomex material volume
828     gMC->Gspos("S07C",1,"S07X",0.,0.,kNomexBWidth/2.,0,"ONLY"); 
829     gMC->Gspos("S08C",1,"S08X",0.,0.,kNomexBWidth/2.,0,"ONLY"); 
830
831     // position the PCB volume inside the insulating material volume
832     gMC->Gspos("S07P",1,"S07I",0.,0.,0.,0,"ONLY"); 
833     gMC->Gspos("S08P",1,"S08I",0.,0.,0.,0,"ONLY"); 
834
835     // position the horizontal frame volume inside the PCB volume
836     gMC->Gspos("S07H",1,"S07P",0.,0.,0.,0,"ONLY"); 
837     gMC->Gspos("S08H",1,"S08P",0.,0.,0.,0,"ONLY"); 
838
839     // position the sensitive volume inside the horizontal frame volume
840     gMC->Gsposp("S07G",1,"S07H",0.,0.,0.,0,"ONLY",senspar,3); 
841     gMC->Gsposp("S08G",1,"S08H",0.,0.,0.,0,"ONLY",senspar,3); 
842
843     // position the border volumes inside the PCB volume
844     Float_t yborder = ( kPcbHeight - kBframeHeight ) / 2.; 
845     gMC->Gspos("S07B",1,"S07P",0., yborder,0.,0,"ONLY"); 
846     gMC->Gspos("S07B",2,"S07P",0.,-yborder,0.,0,"ONLY"); 
847     gMC->Gspos("S08B",1,"S08P",0., yborder,0.,0,"ONLY"); 
848     gMC->Gspos("S08B",2,"S08P",0.,-yborder,0.,0,"ONLY"); 
849
850     // create the NULOC volume and position it in the horizontal frame
851
852     gMC->Gsvolu("S07E","BOX",kNulocMaterial,nulocpar,3);
853     gMC->Gsvolu("S08E","BOX",kNulocMaterial,nulocpar,3);
854     index = 0;
855     for (xx = -xxmax; xx <= xxmax; xx += 2*kNulocLength) { 
856       index++; 
857       gMC->Gspos("S07E",2*index-1,"S07B", xx, 0.,-kBframeWidth/2. + kNulocWidth/2, 0, "ONLY");
858       gMC->Gspos("S07E",2*index  ,"S07B", xx, 0., kBframeWidth/2. - kNulocWidth/2, 0, "ONLY");
859       gMC->Gspos("S08E",2*index-1,"S08B", xx, 0.,-kBframeWidth/2. + kNulocWidth/2, 0, "ONLY");
860       gMC->Gspos("S08E",2*index  ,"S08B", xx, 0., kBframeWidth/2. - kNulocWidth/2, 0, "ONLY");
861     }
862
863     // position the volumes approximating the circular section of the pipe
864
865     Float_t epsilon = 0.001; 
866     Int_t ndiv = 10;
867     Int_t imax = 1; 
868     Double_t divpar[3];
869     Double_t dydiv = kSensHeight/ndiv;
870     Double_t ydiv  = (kSensHeight - dydiv)/2.;
871     Float_t rmin   = AliMUONConstants::Rmin(3); // Same radius for both chamber of St4
872     Float_t xdiv   = 0.; 
873     Float_t xvol;
874     Float_t yvol;
875
876     for (Int_t idiv = 0; idiv < ndiv; idiv++){ 
877       ydiv += dydiv;
878       xdiv = 0.; 
879       if (ydiv < rmin) xdiv = rmin * TMath::Sin( TMath::ACos((ydiv-dydiv/2.)/rmin) );
880       divpar[0] = (kPcbLength - xdiv)/2.; 
881       divpar[1] = dydiv/2. - epsilon;
882       divpar[2] = kSensWidth/2.; 
883       xvol = (kPcbLength + xdiv)/2.;
884       yvol = ydiv ;
885        
886       for (Int_t quadrant = 1; quadrant <= 4; quadrant++) {
887         sprintf(idSlatCh7,"LC%d",ConvertSlatNum(1,quadrant,kNslats4-1));
888         sprintf(idSlatCh8,"LD%d",ConvertSlatNum(1,quadrant,kNslats4-1));
889          
890         GetEnvelopes(6)->AddEnvelopeConstituentParam("S07G",idSlatCh7, quadrant*100+imax+4*idiv+1,
891                                                      TGeoTranslation(xvol-kPcbLength * kNPCB4[1]/2.,yvol-kPcbLength,0.),3,divpar);
892          
893         GetEnvelopes(7)->AddEnvelopeConstituentParam("S08G", idSlatCh8, quadrant*100+imax+4*idiv+1,
894                                                      TGeoTranslation(xvol-kPcbLength * kNPCB4[1]/2.,yvol-kPcbLength,0.),3,divpar);
895       }
896     }
897     // cout << "Geometry for Station 4...... done" << endl;
898
899   }
900     
901   if (fStations[4]) {
902       
903
904     // //********************************************************************
905     // //                            Station 5                             **
906     // //********************************************************************
907     //      // indices 1 and 2 for first and second chambers in the station
908     //      // iChamber (first chamber) kept for other quanties than Z,
909     //      // assumed to be the same in both chambers
910     //      corrected geometry (JP. Cussonneau, Ch. Finck)
911
912     iChamber = &fMUON->Chamber(8);
913     iChamber1 = iChamber;
914     iChamber2 = &fMUON->Chamber(9);
915  
916     const Int_t   kNslats5         = 7;  // number of slats per quadrant
917     const Int_t   kNPCB5[kNslats5] = {5, 6, 6, 6, 5, 4, 3}; // n PCB per slat
918     const Float_t kXpos5[kNslats5] = {38.2, 0., 0., 0., 0., 0., 0.};
919     const Float_t kYpos5[kNslats5] = {0., 38.2, 37.9, 37.6, 37.3, 37.05, 36.75};
920     Float_t slatLength5[kNslats5]; 
921
922     // Mother volume for each chamber
923     // Outer excess and inner recess for mother volume radius
924     // with respect to ROuter and RInner
925     Float_t dMotherInner =  AliMUONConstants::Rmin(4)-kRframeHeight; 
926     // Additional 40 cm gap is needed to wrap the corners of the slats since Rmax represent the maximum active radius of the chamber with 2pi phi acceptance 
927     Float_t dMotherOutner= AliMUONConstants::Rmax(4)+kVframeLength + 40.0;
928     Float_t tpar[3];
929     Double_t dstation =  ( (-AliMUONConstants::DefaultChamberZ(9)) - 
930                            (-AliMUONConstants::DefaultChamberZ(8)) ) /2.3;
931     tpar[0] = dMotherInner; 
932     tpar[1] = dMotherOutner;
933     tpar[2] = dstation;
934     gMC->Gsvolu("CH09", "TUBE", idAir, tpar, 3);
935     gMC->Gsvolu("CH10", "TUBE", idAir, tpar, 3);
936
937     // create and position the slat (mother) volumes 
938
939     char idSlatCh9[5];
940     char idSlatCh10[5];
941     Float_t xSlat5;
942     Float_t ySlat5 = 0;
943     angle = 0.;
944
945     for (i = 0; i < kNslats5; i++){
946
947       slatLength5[i] = kPcbLength * kNPCB5[i] + 2.* kVframeLength; 
948       xSlat5 = slatLength5[i]/2. + kDslatLength + kXpos5[i]; 
949       ySlat5 += kYpos5[i];
950
951       spar[0] = slatLength5[i]/2.; 
952       spar[1] = kSlatHeight/2.;
953       spar[2] = kSlatWidth/2.; 
954
955       Float_t dzCh5  = dzCh;
956       Float_t zSlat5 = (i%2 ==0)? -zSlat : zSlat; 
957
958       sprintf(idSlatCh9,"LE%d",kNslats5-1+i);
959       detElemId = 913 - (i + kNslats5-1-6);
960       //gMC->Gsvolu(idSlatCh9,"BOX",kSlatMaterial,spar,3);
961       GetEnvelopes(8)->AddEnvelope(idSlatCh9, detElemId, true, TGeoTranslation(xSlat5, ySlat5, -zSlat5 + dzCh5),
962                                    TGeoRotation("rot1",90,angle,90,90+angle,0,0) );
963
964       sprintf(idSlatCh9,"LE%d",3*kNslats5-2+i);
965       detElemId = 900 + (i + kNslats5-1-6);
966       //gMC->Gsvolu(idSlatCh9,"BOX",kSlatMaterial,spar,3);
967       GetEnvelopes(8)->AddEnvelope(idSlatCh9, detElemId, true, TGeoTranslation(-xSlat5, ySlat5, zSlat5 - dzCh5),
968                                    TGeoRotation("rot2",90,180+angle,90,90+angle,180,0) );
969  
970       if (i > 0) { 
971         sprintf(idSlatCh9,"LE%d",kNslats5-1-i);
972         detElemId = 913 + (i + kNslats5-1-6);
973         //gMC->Gsvolu(idSlatCh9,"BOX",kSlatMaterial,spar,3);
974         GetEnvelopes(8)->AddEnvelope(idSlatCh9, detElemId, true, TGeoTranslation(xSlat5, -ySlat5, -zSlat5 + dzCh5),
975                                      TGeoRotation("rot3",90,angle,90,270+angle,180,0) );
976
977         sprintf(idSlatCh9,"LE%d",3*kNslats5-2-i);
978         detElemId = 926 - (i + kNslats5-1-6);
979         //gMC->Gsvolu(idSlatCh9,"BOX",kSlatMaterial,spar,3);
980         GetEnvelopes(8)->AddEnvelope(idSlatCh9, detElemId, true, TGeoTranslation(-xSlat5, -ySlat5, zSlat5 - dzCh5),
981                                      TGeoRotation("rot4",90,180+angle,90,270+angle,0,0)  );
982       }
983
984       sprintf(idSlatCh10,"LF%d",kNslats5-1+i);
985       detElemId = 1013 - (i + kNslats5-1-6);
986       //gMC->Gsvolu(idSlatCh10,"BOX",kSlatMaterial,spar,3);
987       GetEnvelopes(9)->AddEnvelope(idSlatCh10, detElemId, true, TGeoTranslation(xSlat5, ySlat5, -zSlat5 + dzCh5),
988                                    TGeoRotation("rot5",90,angle,90,90+angle,0,0) );
989
990       sprintf(idSlatCh10,"LF%d",3*kNslats5-2+i);
991       detElemId = 1000 + (i + kNslats5-1-6);
992       //gMC->Gsvolu(idSlatCh10,"BOX",kSlatMaterial,spar,3);
993       GetEnvelopes(9)->AddEnvelope(idSlatCh10, detElemId, true, TGeoTranslation(-xSlat5, ySlat5, zSlat5 - dzCh5),
994                                    TGeoRotation("rot6",90,180+angle,90,90+angle,180,0) );
995
996       if (i > 0) { 
997         sprintf(idSlatCh10,"LF%d",kNslats5-1-i);
998         detElemId = 1013 + (i + kNslats5-1-6);
999         //gMC->Gsvolu(idSlatCh10,"BOX",kSlatMaterial,spar,3);
1000         GetEnvelopes(9)->AddEnvelope(idSlatCh10, detElemId, true, TGeoTranslation(xSlat5, -ySlat5, -zSlat5 + dzCh5),
1001                                      TGeoRotation("rot7",90,angle,90,270+angle,180,0) );
1002         sprintf(idSlatCh10,"LF%d",3*kNslats5-2-i);
1003         detElemId = 1026 - (i + kNslats5-1-6);
1004         //gMC->Gsvolu(idSlatCh10,"BOX",kSlatMaterial,spar,3);
1005         GetEnvelopes(9)->AddEnvelope(idSlatCh10, detElemId, true, TGeoTranslation(-xSlat5, -ySlat5, zSlat5 - dzCh5),
1006                                      TGeoRotation("rot8",90,180+angle,90,270+angle,0,0) );
1007       }
1008     }
1009
1010     // create the panel volume 
1011  
1012     gMC->Gsvolu("S09C","BOX",kCarbonMaterial,panelpar,3);
1013     gMC->Gsvolu("S10C","BOX",kCarbonMaterial,panelpar,3);
1014
1015     // create the nomex volume 
1016
1017     gMC->Gsvolu("S09N","BOX",kNomexMaterial,nomexpar,3);
1018     gMC->Gsvolu("S10N","BOX",kNomexMaterial,nomexpar,3);
1019
1020
1021     // create the nomex volume (bulk)
1022
1023     gMC->Gsvolu("S09X","BOX",kNomexBMaterial,nomexbpar,3);
1024     gMC->Gsvolu("S10X","BOX",kNomexBMaterial,nomexbpar,3);
1025
1026     // create the insulating material volume 
1027
1028     gMC->Gsvolu("S09I","BOX",kInsuMaterial,insupar,3);
1029     gMC->Gsvolu("S10I","BOX",kInsuMaterial,insupar,3);
1030
1031     // create the PCB volume 
1032
1033     gMC->Gsvolu("S09P","BOX",kPcbMaterial,pcbpar,3);
1034     gMC->Gsvolu("S10P","BOX",kPcbMaterial,pcbpar,3);
1035  
1036     // create the sensitive volumes,
1037
1038     gMC->Gsvolu("S09G","BOX",kSensMaterial,dum,0);
1039     gMC->Gsvolu("S10G","BOX",kSensMaterial,dum,0);
1040
1041     // create the vertical frame volume 
1042
1043     gMC->Gsvolu("S09V","BOX",kVframeMaterial,vFramepar,3);
1044     gMC->Gsvolu("S10V","BOX",kVframeMaterial,vFramepar,3);
1045
1046     // create the horizontal frame volume 
1047
1048     gMC->Gsvolu("S09H","BOX",kHframeMaterial,hFramepar,3);
1049     gMC->Gsvolu("S10H","BOX",kHframeMaterial,hFramepar,3);
1050
1051     // create the horizontal border volume 
1052
1053     gMC->Gsvolu("S09B","BOX",kBframeMaterial,bFramepar,3);
1054     gMC->Gsvolu("S10B","BOX",kBframeMaterial,bFramepar,3);
1055
1056     index = 0; 
1057     for (i = 0; i < kNslats5; i++){
1058       for (Int_t quadrant = 1; quadrant <= 4; quadrant++) {
1059
1060         if (i == 0 && quadrant == 2) continue;
1061         if (i == 0 && quadrant == 4) continue;
1062
1063         sprintf(idSlatCh9,"LE%d",ConvertSlatNum(i,quadrant,kNslats5-1));
1064         sprintf(idSlatCh10,"LF%d",ConvertSlatNum(i,quadrant,kNslats5-1));
1065         Float_t xvFrame  = (slatLength5[i] - kVframeLength)/2.; // ok
1066
1067         // position the vertical frames (spacers)
1068         if (i != 1) { 
1069           GetEnvelopes(8)->AddEnvelopeConstituent("S09V", idSlatCh9, (2*i-1)*10+quadrant,TGeoTranslation(xvFrame,0.,0.));
1070           GetEnvelopes(8)->AddEnvelopeConstituent("S09V", idSlatCh9, (2*i)*10+quadrant,TGeoTranslation(-xvFrame,0.,0.));
1071           GetEnvelopes(9)->AddEnvelopeConstituent("S10V", idSlatCh10, (2*i-1)*10+quadrant,TGeoTranslation(xvFrame,0.,0.));
1072           GetEnvelopes(9)->AddEnvelopeConstituent("S10V", idSlatCh10, (2*i)*10+quadrant,TGeoTranslation(-xvFrame,0.,0.));
1073         } else {  // no rounded spacer yet
1074           GetEnvelopes(8)->AddEnvelopeConstituent("S09V", idSlatCh9, (2*i-1)*10+quadrant,TGeoTranslation(xvFrame,0.,0.));
1075           //       GetEnvelopes(8)->AddEnvelopeConstituent("S09V", idSlatCh9, (2*i)*10+quadrant,TGeoTranslation(-xvFrame,0.,0.));
1076           GetEnvelopes(9)->AddEnvelopeConstituent("S10V", idSlatCh10, (2*i-1)*10+quadrant,TGeoTranslation(xvFrame,0.,0.));
1077           //       GetEnvelopes(9)->AddEnvelopeConstituent("S10V", idSlatCh10, (2*i)*10+quadrant,TGeoTranslation(-xvFrame,0.,0.));
1078         }
1079
1080         // position the panels and the insulating material 
1081         for (j = 0; j < kNPCB5[i]; j++){
1082           if (i == 1 && j == 0) continue;
1083           index++;
1084           Float_t xx = kSensLength * (-kNPCB5[i]/2.+j+.5); 
1085
1086           Float_t zPanel = spar[2] - nomexbpar[2]; 
1087           GetEnvelopes(8)->AddEnvelopeConstituent("S09X", idSlatCh9, 2*index-1,TGeoTranslation(xx,0.,zPanel));
1088           GetEnvelopes(8)->AddEnvelopeConstituent("S09X", idSlatCh9, 2*index,TGeoTranslation(xx,0.,-zPanel));
1089           GetEnvelopes(8)->AddEnvelopeConstituent("S09I", idSlatCh9, index,TGeoTranslation(xx,0.,0.));
1090
1091           GetEnvelopes(9)->AddEnvelopeConstituent("S10X", idSlatCh10, 2*index-1,TGeoTranslation(xx,0.,zPanel));
1092           GetEnvelopes(9)->AddEnvelopeConstituent("S10X", idSlatCh10, 2*index,TGeoTranslation(xx,0.,-zPanel));
1093           GetEnvelopes(9)->AddEnvelopeConstituent("S10I", idSlatCh10, index,TGeoTranslation(xx,0.,0.));
1094         }
1095       } 
1096     }
1097
1098     // position the nomex volume inside the panel volume
1099     gMC->Gspos("S09N",1,"S09C",0.,0.,0.,0,"ONLY"); 
1100     gMC->Gspos("S10N",1,"S10C",0.,0.,0.,0,"ONLY"); 
1101
1102     // position panel  volume inside the bulk nomex material volume
1103     gMC->Gspos("S09C",1,"S09X",0.,0.,kNomexBWidth/2.,0,"ONLY"); 
1104     gMC->Gspos("S10C",1,"S10X",0.,0.,kNomexBWidth/2.,0,"ONLY"); 
1105
1106     // position the PCB volume inside the insulating material volume
1107     gMC->Gspos("S09P",1,"S09I",0.,0.,0.,0,"ONLY"); 
1108     gMC->Gspos("S10P",1,"S10I",0.,0.,0.,0,"ONLY"); 
1109
1110     // position the horizontal frame volume inside the PCB volume
1111     gMC->Gspos("S09H",1,"S09P",0.,0.,0.,0,"ONLY"); 
1112     gMC->Gspos("S10H",1,"S10P",0.,0.,0.,0,"ONLY"); 
1113
1114     // position the sensitive volume inside the horizontal frame volume
1115     gMC->Gsposp("S09G",1,"S09H",0.,0.,0.,0,"ONLY",senspar,3); 
1116     gMC->Gsposp("S10G",1,"S10H",0.,0.,0.,0,"ONLY",senspar,3); 
1117
1118     // position the border volumes inside the PCB volume
1119     Float_t yborder = ( kPcbHeight - kBframeHeight ) / 2.; 
1120     gMC->Gspos("S09B",1,"S09P",0., yborder,0.,0,"ONLY"); 
1121     gMC->Gspos("S09B",2,"S09P",0.,-yborder,0.,0,"ONLY"); 
1122     gMC->Gspos("S10B",1,"S10P",0., yborder,0.,0,"ONLY"); 
1123     gMC->Gspos("S10B",2,"S10P",0.,-yborder,0.,0,"ONLY"); 
1124
1125     //      // create the NULOC volume and position it in the horizontal frame
1126
1127     gMC->Gsvolu("S09E","BOX",kNulocMaterial,nulocpar,3);
1128     gMC->Gsvolu("S10E","BOX",kNulocMaterial,nulocpar,3);
1129     index = 0;
1130     for (xx = -xxmax; xx <= xxmax; xx += 2*kNulocLength) { 
1131       index++; 
1132       gMC->Gspos("S09E",2*index-1,"S09B", xx, 0.,-kBframeWidth/2. + kNulocWidth/2, 0, "ONLY");
1133       gMC->Gspos("S09E",2*index  ,"S09B", xx, 0., kBframeWidth/2. - kNulocWidth/2, 0, "ONLY");
1134       gMC->Gspos("S10E",2*index-1,"S10B", xx, 0.,-kBframeWidth/2. + kNulocWidth/2, 0, "ONLY");
1135       gMC->Gspos("S10E",2*index  ,"S10B", xx, 0., kBframeWidth/2. - kNulocWidth/2, 0, "ONLY");
1136     }
1137
1138
1139     // position the volumes approximating the circular section of the pipe
1140     Float_t epsilon = 0.001; 
1141     Int_t ndiv = 10;
1142     Int_t imax = 1; 
1143     Double_t divpar[3];
1144     Double_t dydiv = kSensHeight/ndiv;
1145     Double_t ydiv  = (kSensHeight - dydiv)/2.;
1146     Float_t rmin   = AliMUONConstants::Rmin(4);
1147     Float_t xdiv   = 0.; 
1148     Float_t xvol;
1149     Float_t yvol; 
1150
1151     for (Int_t idiv = 0; idiv < ndiv; idiv++){ 
1152       ydiv += dydiv;
1153       xdiv = 0.; 
1154       if (ydiv < rmin) xdiv = rmin * TMath::Sin( TMath::ACos((ydiv-dydiv/2.)/rmin) );
1155       divpar[0] = (kPcbLength - xdiv)/2.; 
1156       divpar[1] = dydiv/2. - epsilon;
1157       divpar[2] = kSensWidth/2.; 
1158       xvol = (kPcbLength + xdiv)/2.;
1159       yvol = ydiv;
1160
1161       for (Int_t quadrant = 1; quadrant <= 4; quadrant++) {
1162         sprintf(idSlatCh9,"LE%d",ConvertSlatNum(1,quadrant,kNslats5-1));
1163         sprintf(idSlatCh10,"LF%d",ConvertSlatNum(1,quadrant,kNslats5-1));
1164
1165         GetEnvelopes(8)->AddEnvelopeConstituentParam("S09G", idSlatCh9, quadrant*100+imax+4*idiv+1,
1166                                                      TGeoTranslation(xvol-kPcbLength * kNPCB5[1]/2.,yvol-kPcbLength,0.),3,divpar);
1167         GetEnvelopes(9)->AddEnvelopeConstituentParam("S10G", idSlatCh10,  quadrant*100+imax+4*idiv+1,
1168                                                      TGeoTranslation(xvol-kPcbLength * kNPCB5[1]/2.,yvol-kPcbLength,0.),3,divpar);
1169       }
1170     }
1171     // cout << "Geometry for Station 5...... done" << endl;
1172
1173   }
1174 }
1175
1176
1177 //______________________________________________________________________________
1178 void AliMUONSlatGeometryBuilder::SetTransformations()
1179 {
1180 // Defines the transformations for the station345 chambers.
1181 // ---
1182
1183   if (gAlice->GetModule("DIPO")) {
1184     // if DIPO is preset, the whole station will be placed in DDIP volume
1185     SetMotherVolume(4, "DDIP");
1186     SetMotherVolume(5, "DDIP");
1187     SetVolume(4, "CH05", true);
1188     SetVolume(5, "CH06", true);
1189   }     
1190   else {
1191     SetVolume(4, "CH05");
1192     SetVolume(5, "CH06");
1193   } 
1194    
1195   if (gAlice->GetModule("SHIL")) {
1196     SetMotherVolume(6, "YOUT2");
1197     SetMotherVolume(7, "YOUT2");
1198     SetMotherVolume(8, "YOUT2");
1199     SetMotherVolume(9, "YOUT2");
1200   }  
1201
1202   SetVolume(6, "CH07");
1203   SetVolume(7, "CH08");
1204   SetVolume(8, "CH09");
1205   SetVolume(9, "CH10");
1206
1207 // Stations 345 are not perpendicular to the beam axis
1208 // See AliMUONConstants class
1209   TGeoRotation st345inclination("rot99");
1210   st345inclination.RotateX(AliMUONConstants::St345Inclination());
1211   
1212   Double_t zpos1= - AliMUONConstants::DefaultChamberZ(4); 
1213   SetTransformation(4, TGeoTranslation(0., 0., zpos1), st345inclination);
1214
1215   zpos1= - AliMUONConstants::DefaultChamberZ(5); 
1216   SetTransformation(5, TGeoTranslation(0., 0., zpos1), st345inclination);
1217
1218   zpos1 = - AliMUONConstants::DefaultChamberZ(6); 
1219   SetTransformation(6, TGeoTranslation(0., 0., zpos1), st345inclination);
1220
1221   zpos1 = - AliMUONConstants::DefaultChamberZ(7); 
1222   SetTransformation(7, TGeoTranslation(0., 0., zpos1), st345inclination );
1223
1224   zpos1 = - AliMUONConstants::DefaultChamberZ(8); 
1225   SetTransformation(8, TGeoTranslation(0., 0., zpos1), st345inclination);
1226
1227   zpos1 = - AliMUONConstants::DefaultChamberZ(9); 
1228   SetTransformation(9, TGeoTranslation(0., 0., zpos1), st345inclination);
1229
1230 }
1231
1232 //______________________________________________________________________________
1233 void AliMUONSlatGeometryBuilder::SetSensitiveVolumes()
1234 {
1235 // Defines the sensitive volumes for slat stations chambers.
1236 // ---
1237
1238   GetGeometry(4)->SetSensitiveVolume("S05G");
1239   GetGeometry(5)->SetSensitiveVolume("S06G");
1240   GetGeometry(6)->SetSensitiveVolume("S07G");
1241   GetGeometry(7)->SetSensitiveVolume("S08G");
1242   GetGeometry(8)->SetSensitiveVolume("S09G");
1243   GetGeometry(9)->SetSensitiveVolume("S10G");
1244 }
1245
1246 //______________________________________________________________________________
1247 Int_t  AliMUONSlatGeometryBuilder::ConvertSlatNum(Int_t numslat, Int_t quadnum, Int_t fspq) const
1248 {
1249 // On-line function establishing the correspondance between numslat (the slat number on a particular quadrant (numslat->0....4 for St3))
1250 // and slatnum (the slat number on the whole panel (slatnum->1...18 for St3)
1251   numslat += 1;
1252   if (quadnum==2 || quadnum==3) 
1253     numslat += fspq;
1254   else
1255     numslat = fspq + 2-numslat;
1256   numslat -= 1;
1257               
1258   if (quadnum==3 || quadnum==4) numslat += 2*fspq+1;
1259
1260   return numslat;
1261 }