Dependency on implementations of AliSegmentation and AliMUONResponse moved to AliMUON...
[u/mrichter/AliRoot.git] / MUON / AliMUONvTemp.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 purpeateose. It is      *
13  * provided "as is" without express or implied warranty.                  *
14  **************************************************************************/
15
16 /*
17 $Log$
18 Revision 1.1  2001/01/30 12:23:33  morsch
19 Tempory MUON version which has full signal generation (summable digits) and geometry compatible with
20 DIPO and SHIL, i.e. size of station 3 has been reduced.
21
22 */
23
24 /////////////////////////////////////////////////////////
25 //  Manager and hits classes for set:MUON version 0    //
26 /////////////////////////////////////////////////////////
27
28 #include <TLorentzVector.h> 
29 #include "AliMUONvTemp.h"
30 #include "AliRun.h"
31 #include "AliMC.h"
32 #include "AliMUONChamber.h"
33 #include "AliMUONConstants.h"
34 #include "AliMUONFactory.h"
35
36 ClassImp(AliMUONvTemp)
37 AliMUONvTemp::AliMUONvTemp(const char *name, const char *title)
38        : AliMUONv1(name, title)
39 {
40 //  Constructor
41       AliMUONFactory::Build(this, "temporary");
42 }
43 //___________________________________________
44 void AliMUONvTemp::CreateGeometry()
45 {
46 //
47 //   Note: all chambers have the same structure, which could be 
48 //   easily parameterised. This was intentionally not done in order
49 //   to give a starting point for the implementation of the actual 
50 //   design of each station. 
51   Int_t *idtmed = fIdtmed->GetArray()-1099;
52
53 //   Distance between Stations
54 //
55      Float_t bpar[3];
56      Float_t tpar[3];
57 //      Float_t pgpar[10];
58      Float_t zpos1, zpos2, zfpos;
59      // Outer excess and inner recess for mother volume radius
60      // with respect to ROuter and RInner
61      Float_t dframep=.001; // Value for station 3 should be 6 ...
62      // Width (RdPhi) of the frame crosses for stations 1 and 2 (cm)
63 //      Float_t dframep1=.001;
64      Float_t dframep1 = 11.0;
65 //      Bool_t frameCrosses=kFALSE;     
66      Bool_t frameCrosses=kTRUE;     
67      
68 //      Float_t dframez=0.9;
69      // Half of the total thickness of frame crosses (including DAlu)
70      // for each chamber in stations 1 and 2:
71      // 3% of X0 of composite material,
72      // but taken as Aluminium here, with same thickness in number of X0
73      Float_t dframez = 3. * 8.9 / 100;
74 //      Float_t dr;
75      Float_t dstation;
76
77 //
78 //   Rotation matrices in the x-y plane  
79      Int_t idrotm[1199];
80 //   phi=   0 deg
81      AliMatrix(idrotm[1100],  90.,   0., 90.,  90., 0., 0.);
82 //   phi=  90 deg
83      AliMatrix(idrotm[1101],  90.,  90., 90., 180., 0., 0.);
84 //   phi= 180 deg
85      AliMatrix(idrotm[1102],  90., 180., 90., 270., 0., 0.);
86 //   phi= 270 deg
87      AliMatrix(idrotm[1103],  90., 270., 90.,   0., 0., 0.);
88 //
89      Float_t phi=2*TMath::Pi()/12/2;
90
91 //
92 //   pointer to the current chamber
93 //   pointer to the current chamber
94      Int_t idAlu1=idtmed[1103]; // medium 4
95      Int_t idAlu2=idtmed[1104]; // medium 5
96 //     Int_t idAlu1=idtmed[1100];
97 //     Int_t idAlu2=idtmed[1100];
98      Int_t idAir=idtmed[1100]; // medium 1
99 //      Int_t idGas=idtmed[1105]; // medium 6 = Ar-isoC4H10 gas
100      Int_t idGas=idtmed[1108]; // medium 9 = Ar-CO2 gas (80%+20%)
101      
102
103      AliMUONChamber *iChamber, *iChamber1, *iChamber2;
104      Int_t stations[5] = {1, 1, 1, 1, 1};
105      
106      if (stations[0]) {
107          
108 //********************************************************************
109 //                            Station 1                             **
110 //********************************************************************
111 //  CONCENTRIC
112      // indices 1 and 2 for first and second chambers in the station
113      // iChamber (first chamber) kept for other quanties than Z,
114      // assumed to be the same in both chambers
115      iChamber1 = iChamber = (AliMUONChamber*) (*fChambers)[0];
116      iChamber2 =(AliMUONChamber*) (*fChambers)[1];
117      zpos1=iChamber1->Z(); 
118      zpos2=iChamber2->Z();
119      dstation = zpos2 - zpos1;
120      // DGas decreased from standard one (0.5)
121      iChamber->SetDGas(0.4); iChamber2->SetDGas(0.4);
122      // DAlu increased from standard one (3% of X0),
123      // because more electronics with smaller pads
124      iChamber->SetDAlu(3.5 * 8.9 / 100.); iChamber2->SetDAlu(3.5 * 8.9 / 100.);
125      zfpos=-(iChamber->DGas()+dframez+iChamber->DAlu())/2;
126      
127 //
128 //   Mother volume
129      tpar[0] = iChamber->RInner()-dframep; 
130      tpar[1] = (iChamber->ROuter()+dframep)/TMath::Cos(phi);
131      tpar[2] = dstation/8;
132
133      gMC->Gsvolu("C01M", "TUBE", idAir, tpar, 3);
134      gMC->Gsvolu("C02M", "TUBE", idAir, tpar, 3);
135      gMC->Gspos("C01M", 1, "ALIC", 0., 0., zpos1 , 0, "ONLY");
136      gMC->Gspos("C02M", 1, "ALIC", 0., 0., zpos2 , 0, "ONLY");     
137 // // Aluminium frames
138 // // Outer frames
139 //      pgpar[0] = 360/12/2;
140 //      pgpar[1] = 360.;
141 //      pgpar[2] = 12.;
142 //      pgpar[3] =   2;
143 //      pgpar[4] = -dframez/2;
144 //      pgpar[5] = iChamber->ROuter();
145 //      pgpar[6] = pgpar[5]+dframep1;
146 //      pgpar[7] = +dframez/2;
147 //      pgpar[8] = pgpar[5];
148 //      pgpar[9] = pgpar[6];
149 //      gMC->Gsvolu("C01O", "PGON", idAlu1, pgpar, 10);
150 //      gMC->Gsvolu("C02O", "PGON", idAlu1, pgpar, 10);
151 //      gMC->Gspos("C01O",1,"C01M", 0.,0.,-zfpos,  0,"ONLY");
152 //      gMC->Gspos("C01O",2,"C01M", 0.,0.,+zfpos,  0,"ONLY");
153 //      gMC->Gspos("C02O",1,"C02M", 0.,0.,-zfpos,  0,"ONLY");
154 //      gMC->Gspos("C02O",2,"C02M", 0.,0.,+zfpos,  0,"ONLY");
155 // //
156 // // Inner frame
157 //      tpar[0]= iChamber->RInner()-dframep1;
158 //      tpar[1]= iChamber->RInner();
159 //      tpar[2]= dframez/2;
160 //      gMC->Gsvolu("C01I", "TUBE", idAlu1, tpar, 3);
161 //      gMC->Gsvolu("C02I", "TUBE", idAlu1, tpar, 3);
162
163 //      gMC->Gspos("C01I",1,"C01M", 0.,0.,-zfpos,  0,"ONLY");
164 //      gMC->Gspos("C01I",2,"C01M", 0.,0.,+zfpos,  0,"ONLY");
165 //      gMC->Gspos("C02I",1,"C02M", 0.,0.,-zfpos,  0,"ONLY");
166 //      gMC->Gspos("C02I",2,"C02M", 0.,0.,+zfpos,  0,"ONLY");
167 //
168 // Frame Crosses
169      if (frameCrosses) {
170          // outside gas
171          // security for inside mother volume
172          bpar[0] = (iChamber->ROuter() - iChamber->RInner())
173            * TMath::Cos(TMath::ASin(dframep1 /
174                                    (iChamber->ROuter() - iChamber->RInner())))
175            / 2.0;
176          bpar[1] = dframep1/2;
177          // total thickness will be (4 * bpar[2]) for each chamber,
178          // which has to be equal to (2 * dframez) - DAlu
179          bpar[2] = (2.0 * dframez - iChamber->DAlu()) / 4.0;
180          gMC->Gsvolu("C01B", "BOX", idAlu1, bpar, 3);
181          gMC->Gsvolu("C02B", "BOX", idAlu1, bpar, 3);
182          
183          gMC->Gspos("C01B",1,"C01M", +iChamber->RInner()+bpar[0] , 0,-zfpos, 
184                     idrotm[1100],"ONLY");
185          gMC->Gspos("C01B",2,"C01M", -iChamber->RInner()-bpar[0] , 0,-zfpos, 
186                     idrotm[1100],"ONLY");
187          gMC->Gspos("C01B",3,"C01M", 0, +iChamber->RInner()+bpar[0] ,-zfpos, 
188                     idrotm[1101],"ONLY");
189          gMC->Gspos("C01B",4,"C01M", 0, -iChamber->RInner()-bpar[0] ,-zfpos, 
190                     idrotm[1101],"ONLY");
191          gMC->Gspos("C01B",5,"C01M", +iChamber->RInner()+bpar[0] , 0,+zfpos, 
192                     idrotm[1100],"ONLY");
193          gMC->Gspos("C01B",6,"C01M", -iChamber->RInner()-bpar[0] , 0,+zfpos, 
194                     idrotm[1100],"ONLY");
195          gMC->Gspos("C01B",7,"C01M", 0, +iChamber->RInner()+bpar[0] ,+zfpos, 
196                     idrotm[1101],"ONLY");
197          gMC->Gspos("C01B",8,"C01M", 0, -iChamber->RInner()-bpar[0] ,+zfpos, 
198                     idrotm[1101],"ONLY");
199          
200          gMC->Gspos("C02B",1,"C02M", +iChamber->RInner()+bpar[0] , 0,-zfpos, 
201                     idrotm[1100],"ONLY");
202          gMC->Gspos("C02B",2,"C02M", -iChamber->RInner()-bpar[0] , 0,-zfpos, 
203                     idrotm[1100],"ONLY");
204          gMC->Gspos("C02B",3,"C02M", 0, +iChamber->RInner()+bpar[0] ,-zfpos, 
205                     idrotm[1101],"ONLY");
206          gMC->Gspos("C02B",4,"C02M", 0, -iChamber->RInner()-bpar[0] ,-zfpos, 
207                     idrotm[1101],"ONLY");
208          gMC->Gspos("C02B",5,"C02M", +iChamber->RInner()+bpar[0] , 0,+zfpos, 
209                     idrotm[1100],"ONLY");
210          gMC->Gspos("C02B",6,"C02M", -iChamber->RInner()-bpar[0] , 0,+zfpos, 
211                     idrotm[1100],"ONLY");
212          gMC->Gspos("C02B",7,"C02M", 0, +iChamber->RInner()+bpar[0] ,+zfpos, 
213                     idrotm[1101],"ONLY");
214          gMC->Gspos("C02B",8,"C02M", 0, -iChamber->RInner()-bpar[0] ,+zfpos, 
215                     idrotm[1101],"ONLY");
216      }
217 //
218 //   Chamber Material represented by Alu sheet
219      tpar[0]= iChamber->RInner();
220      tpar[1]= iChamber->ROuter();
221      tpar[2] = (iChamber->DGas()+iChamber->DAlu())/2;
222      gMC->Gsvolu("C01A", "TUBE",  idAlu2, tpar, 3);
223      gMC->Gsvolu("C02A", "TUBE",idAlu2, tpar, 3);
224      gMC->Gspos("C01A", 1, "C01M", 0., 0., 0.,  0, "ONLY");
225      gMC->Gspos("C02A", 1, "C02M", 0., 0., 0.,  0, "ONLY");
226 //     
227 //   Sensitive volumes
228      // tpar[2] = iChamber->DGas();
229      tpar[2] = iChamber->DGas()/2;
230      gMC->Gsvolu("C01G", "TUBE", idGas, tpar, 3);
231      gMC->Gsvolu("C02G", "TUBE", idGas, tpar, 3);
232      gMC->Gspos("C01G", 1, "C01A", 0., 0., 0.,  0, "ONLY");
233      gMC->Gspos("C02G", 1, "C02A", 0., 0., 0.,  0, "ONLY");
234 //
235 // Frame Crosses to be placed inside gas
236      // NONE: chambers are sensitive everywhere
237 //      if (frameCrosses) {
238
239 //       dr = (iChamber->ROuter() - iChamber->RInner());
240 //       bpar[0] = TMath::Sqrt(dr*dr-dframep1*dframep1/4)/2;
241 //       bpar[1] = dframep1/2;
242 //       bpar[2] = iChamber->DGas()/2;
243 //       gMC->Gsvolu("C01F", "BOX", idAlu1, bpar, 3);
244 //       gMC->Gsvolu("C02F", "BOX", idAlu1, bpar, 3);
245          
246 //       gMC->Gspos("C01F",1,"C01G", +iChamber->RInner()+bpar[0] , 0, 0, 
247 //                  idrotm[1100],"ONLY");
248 //       gMC->Gspos("C01F",2,"C01G", -iChamber->RInner()-bpar[0] , 0, 0, 
249 //                  idrotm[1100],"ONLY");
250 //       gMC->Gspos("C01F",3,"C01G", 0, +iChamber->RInner()+bpar[0] , 0, 
251 //                  idrotm[1101],"ONLY");
252 //       gMC->Gspos("C01F",4,"C01G", 0, -iChamber->RInner()-bpar[0] , 0, 
253 //                  idrotm[1101],"ONLY");
254          
255 //       gMC->Gspos("C02F",1,"C02G", +iChamber->RInner()+bpar[0] , 0, 0, 
256 //                  idrotm[1100],"ONLY");
257 //       gMC->Gspos("C02F",2,"C02G", -iChamber->RInner()-bpar[0] , 0, 0, 
258 //                  idrotm[1100],"ONLY");
259 //       gMC->Gspos("C02F",3,"C02G", 0, +iChamber->RInner()+bpar[0] , 0, 
260 //                  idrotm[1101],"ONLY");
261 //       gMC->Gspos("C02F",4,"C02G", 0, -iChamber->RInner()-bpar[0] , 0, 
262 //                  idrotm[1101],"ONLY");
263 //      }
264      }
265      if (stations[1]) {
266          
267 //********************************************************************
268 //                            Station 2                             **
269 //********************************************************************
270      // indices 1 and 2 for first and second chambers in the station
271      // iChamber (first chamber) kept for other quanties than Z,
272      // assumed to be the same in both chambers
273      iChamber1 = iChamber = (AliMUONChamber*) (*fChambers)[2];
274      iChamber2 =(AliMUONChamber*) (*fChambers)[3];
275      zpos1=iChamber1->Z(); 
276      zpos2=iChamber2->Z();
277      dstation = zpos2 - zpos1;
278      // DGas and DAlu not changed from standard values
279      zfpos=-(iChamber->DGas()+dframez+iChamber->DAlu())/2;
280      
281 //
282 //   Mother volume
283      tpar[0] = iChamber->RInner()-dframep; 
284      tpar[1] = (iChamber->ROuter()+dframep)/TMath::Cos(phi);
285      tpar[2] = dstation/10;
286
287      gMC->Gsvolu("C03M", "TUBE", idAir, tpar, 3);
288      gMC->Gsvolu("C04M", "TUBE", idAir, tpar, 3);
289      gMC->Gspos("C03M", 1, "ALIC", 0., 0., zpos1 , 0, "ONLY");
290      gMC->Gspos("C04M", 1, "ALIC", 0., 0., zpos2 , 0, "ONLY");
291
292 // // Aluminium frames
293 // // Outer frames
294 //      pgpar[0] = 360/12/2;
295 //      pgpar[1] = 360.;
296 //      pgpar[2] = 12.;
297 //      pgpar[3] =   2;
298 //      pgpar[4] = -dframez/2;
299 //      pgpar[5] = iChamber->ROuter();
300 //      pgpar[6] = pgpar[5]+dframep;
301 //      pgpar[7] = +dframez/2;
302 //      pgpar[8] = pgpar[5];
303 //      pgpar[9] = pgpar[6];
304 //      gMC->Gsvolu("C03O", "PGON", idAlu1, pgpar, 10);
305 //      gMC->Gsvolu("C04O", "PGON", idAlu1, pgpar, 10);
306 //      gMC->Gspos("C03O",1,"C03M", 0.,0.,-zfpos,  0,"ONLY");
307 //      gMC->Gspos("C03O",2,"C03M", 0.,0.,+zfpos,  0,"ONLY");
308 //      gMC->Gspos("C04O",1,"C04M", 0.,0.,-zfpos,  0,"ONLY");
309 //      gMC->Gspos("C04O",2,"C04M", 0.,0.,+zfpos,  0,"ONLY");
310 // //
311 // // Inner frame
312 //      tpar[0]= iChamber->RInner()-dframep;
313 //      tpar[1]= iChamber->RInner();
314 //      tpar[2]= dframez/2;
315 //      gMC->Gsvolu("C03I", "TUBE", idAlu1, tpar, 3);
316 //      gMC->Gsvolu("C04I", "TUBE", idAlu1, tpar, 3);
317
318 //      gMC->Gspos("C03I",1,"C03M", 0.,0.,-zfpos,  0,"ONLY");
319 //      gMC->Gspos("C03I",2,"C03M", 0.,0.,+zfpos,  0,"ONLY");
320 //      gMC->Gspos("C04I",1,"C04M", 0.,0.,-zfpos,  0,"ONLY");
321 //      gMC->Gspos("C04I",2,"C04M", 0.,0.,+zfpos,  0,"ONLY");
322 //
323 // Frame Crosses
324      if (frameCrosses) {
325          // outside gas
326          // security for inside mother volume
327          bpar[0] = (iChamber->ROuter() - iChamber->RInner())
328            * TMath::Cos(TMath::ASin(dframep1 /
329                                    (iChamber->ROuter() - iChamber->RInner())))
330            / 2.0;
331          bpar[1] = dframep1/2;
332          // total thickness will be (4 * bpar[2]) for each chamber,
333          // which has to be equal to (2 * dframez) - DAlu
334          bpar[2] = (2.0 * dframez - iChamber->DAlu()) / 4.0;
335          gMC->Gsvolu("C03B", "BOX", idAlu1, bpar, 3);
336          gMC->Gsvolu("C04B", "BOX", idAlu1, bpar, 3);
337          
338          gMC->Gspos("C03B",1,"C03M", +iChamber->RInner()+bpar[0] , 0,-zfpos, 
339                     idrotm[1100],"ONLY");
340          gMC->Gspos("C03B",2,"C03M", -iChamber->RInner()-bpar[0] , 0,-zfpos, 
341                     idrotm[1100],"ONLY");
342          gMC->Gspos("C03B",3,"C03M", 0, +iChamber->RInner()+bpar[0] ,-zfpos, 
343                     idrotm[1101],"ONLY");
344          gMC->Gspos("C03B",4,"C03M", 0, -iChamber->RInner()-bpar[0] ,-zfpos, 
345                     idrotm[1101],"ONLY");
346          gMC->Gspos("C03B",5,"C03M", +iChamber->RInner()+bpar[0] , 0,+zfpos, 
347                     idrotm[1100],"ONLY");
348          gMC->Gspos("C03B",6,"C03M", -iChamber->RInner()-bpar[0] , 0,+zfpos, 
349                     idrotm[1100],"ONLY");
350          gMC->Gspos("C03B",7,"C03M", 0, +iChamber->RInner()+bpar[0] ,+zfpos, 
351                     idrotm[1101],"ONLY");
352          gMC->Gspos("C03B",8,"C03M", 0, -iChamber->RInner()-bpar[0] ,+zfpos, 
353                     idrotm[1101],"ONLY");
354          
355          gMC->Gspos("C04B",1,"C04M", +iChamber->RInner()+bpar[0] , 0,-zfpos, 
356                     idrotm[1100],"ONLY");
357          gMC->Gspos("C04B",2,"C04M", -iChamber->RInner()-bpar[0] , 0,-zfpos, 
358                     idrotm[1100],"ONLY");
359          gMC->Gspos("C04B",3,"C04M", 0, +iChamber->RInner()+bpar[0] ,-zfpos, 
360                     idrotm[1101],"ONLY");
361          gMC->Gspos("C04B",4,"C04M", 0, -iChamber->RInner()-bpar[0] ,-zfpos, 
362                     idrotm[1101],"ONLY");
363          gMC->Gspos("C04B",5,"C04M", +iChamber->RInner()+bpar[0] , 0,+zfpos, 
364                     idrotm[1100],"ONLY");
365          gMC->Gspos("C04B",6,"C04M", -iChamber->RInner()-bpar[0] , 0,+zfpos, 
366                     idrotm[1100],"ONLY");
367          gMC->Gspos("C04B",7,"C04M", 0, +iChamber->RInner()+bpar[0] ,+zfpos, 
368                     idrotm[1101],"ONLY");
369          gMC->Gspos("C04B",8,"C04M", 0, -iChamber->RInner()-bpar[0] ,+zfpos, 
370                     idrotm[1101],"ONLY");
371      }
372 //
373 //   Chamber Material represented by Alu sheet
374      tpar[0]= iChamber->RInner();
375      tpar[1]= iChamber->ROuter();
376      tpar[2] = (iChamber->DGas()+iChamber->DAlu())/2;
377      gMC->Gsvolu("C03A", "TUBE", idAlu2, tpar, 3);
378      gMC->Gsvolu("C04A", "TUBE", idAlu2, tpar, 3);
379      gMC->Gspos("C03A", 1, "C03M", 0., 0., 0.,  0, "ONLY");
380      gMC->Gspos("C04A", 1, "C04M", 0., 0., 0.,  0, "ONLY");
381 //     
382 //   Sensitive volumes
383      // tpar[2] = iChamber->DGas();
384      tpar[2] = iChamber->DGas()/2;
385      gMC->Gsvolu("C03G", "TUBE", idGas, tpar, 3);
386      gMC->Gsvolu("C04G", "TUBE", idGas, tpar, 3);
387      gMC->Gspos("C03G", 1, "C03A", 0., 0., 0.,  0, "ONLY");
388      gMC->Gspos("C04G", 1, "C04A", 0., 0., 0.,  0, "ONLY");
389 //
390 // Frame Crosses to be placed inside gas 
391      // NONE: chambers are sensitive everywhere
392 //      if (frameCrosses) {
393
394 //       dr = (iChamber->ROuter() - iChamber->RInner());
395 //       bpar[0] = TMath::Sqrt(dr*dr-dframep1*dframep1/4)/2;
396 //       bpar[1] = dframep1/2;
397 //       bpar[2] = iChamber->DGas()/2;
398 //       gMC->Gsvolu("C03F", "BOX", idAlu1, bpar, 3);
399 //       gMC->Gsvolu("C04F", "BOX", idAlu1, bpar, 3);
400          
401 //       gMC->Gspos("C03F",1,"C03G", +iChamber->RInner()+bpar[0] , 0, 0, 
402 //                  idrotm[1100],"ONLY");
403 //       gMC->Gspos("C03F",2,"C03G", -iChamber->RInner()-bpar[0] , 0, 0, 
404 //                  idrotm[1100],"ONLY");
405 //       gMC->Gspos("C03F",3,"C03G", 0, +iChamber->RInner()+bpar[0] , 0, 
406 //                  idrotm[1101],"ONLY");
407 //       gMC->Gspos("C03F",4,"C03G", 0, -iChamber->RInner()-bpar[0] , 0, 
408 //                  idrotm[1101],"ONLY");
409          
410 //       gMC->Gspos("C04F",1,"C04G", +iChamber->RInner()+bpar[0] , 0, 0, 
411 //                  idrotm[1100],"ONLY");
412 //       gMC->Gspos("C04F",2,"C04G", -iChamber->RInner()-bpar[0] , 0, 0, 
413 //                  idrotm[1100],"ONLY");
414 //       gMC->Gspos("C04F",3,"C04G", 0, +iChamber->RInner()+bpar[0] , 0, 
415 //                  idrotm[1101],"ONLY");
416 //       gMC->Gspos("C04F",4,"C04G", 0, -iChamber->RInner()-bpar[0] , 0, 
417 //                  idrotm[1101],"ONLY");
418 //      }
419      }
420      // define the id of tracking media:
421      Int_t idCopper = idtmed[1110];
422      Int_t idGlass  = idtmed[1111];
423      Int_t idCarbon = idtmed[1112];
424      Int_t idRoha   = idtmed[1113];
425
426       // sensitive area: 40*40 cm**2
427      const Float_t sensLength = 40.; 
428      const Float_t sensHeight = 40.; 
429      const Float_t sensWidth  = 0.5; // according to TDR fig 2.120 
430      const Int_t sensMaterial = idGas;
431      const Float_t yOverlap   = 1.5; 
432
433      // PCB dimensions in cm; width: 30 mum copper   
434      const Float_t pcbLength  = sensLength; 
435      const Float_t pcbHeight  = 60.; 
436      const Float_t pcbWidth   = 0.003;   
437      const Int_t pcbMaterial  = idCopper;
438
439      // Insulating material: 200 mum glass fiber glued to pcb  
440      const Float_t insuLength = pcbLength; 
441      const Float_t insuHeight = pcbHeight; 
442      const Float_t insuWidth  = 0.020;   
443      const Int_t insuMaterial = idGlass;
444
445      // Carbon fiber panels: 200mum carbon/epoxy skin   
446      const Float_t panelLength = sensLength; 
447      const Float_t panelHeight = sensHeight; 
448      const Float_t panelWidth  = 0.020;      
449      const Int_t panelMaterial = idCarbon;
450
451      // rohacell between the two carbon panels   
452      const Float_t rohaLength = sensLength; 
453      const Float_t rohaHeight = sensHeight; 
454      const Float_t rohaWidth  = 0.5;
455      const Int_t rohaMaterial = idRoha;
456
457      // Frame around the slat: 2 sticks along length,2 along height  
458      // H: the horizontal ones 
459      const Float_t hFrameLength = pcbLength; 
460      const Float_t hFrameHeight = 1.5; 
461      const Float_t hFrameWidth  = sensWidth; 
462      const Int_t hFrameMaterial = idGlass;
463
464      // V: the vertical ones 
465      const Float_t vFrameLength = 4.0; 
466      const Float_t vFrameHeight = sensHeight + hFrameHeight; 
467      const Float_t vFrameWidth  = sensWidth;
468      const Int_t vFrameMaterial = idGlass;
469
470      // B: the horizontal border filled with rohacell 
471      const Float_t bFrameLength = hFrameLength; 
472      const Float_t bFrameHeight = (pcbHeight - sensHeight)/2. - hFrameHeight; 
473      const Float_t bFrameWidth  = hFrameWidth;
474      const Int_t bFrameMaterial = idRoha;
475
476      // NULOC: 30 mum copper + 200 mum vetronite (same radiation length as 14mum copper)
477      const Float_t nulocLength = 2.5; 
478      const Float_t nulocHeight = 7.5; 
479      const Float_t nulocWidth  = 0.0030 + 0.0014; // equivalent copper width of vetronite; 
480      const Int_t   nulocMaterial = idCopper;
481
482      const Float_t slatHeight = pcbHeight; 
483      const Float_t slatWidth = sensWidth + 2.*(pcbWidth + insuWidth + 
484                                                2.* panelWidth + rohaWidth);
485      const Int_t slatMaterial = idAir;
486      const Float_t dSlatLength = vFrameLength; // border on left and right 
487
488      Float_t spar[3];  
489      Int_t i, j;
490
491      // the panel volume contains the rohacell
492
493      Float_t twidth = 2 * panelWidth + rohaWidth; 
494      Float_t panelpar[3] = { panelLength/2., panelHeight/2., twidth/2. }; 
495      Float_t rohapar[3] = { rohaLength/2., rohaHeight/2., rohaWidth/2. }; 
496
497      // insulating material contains PCB-> gas-> 2 borders filled with rohacell
498
499      twidth = 2*(insuWidth + pcbWidth) + sensWidth;  
500      Float_t insupar[3] = { insuLength/2., insuHeight/2., twidth/2. }; 
501      twidth -= 2 * insuWidth; 
502      Float_t pcbpar[3] = { pcbLength/2., pcbHeight/2., twidth/2. }; 
503      Float_t senspar[3] = { sensLength/2., sensHeight/2., sensWidth/2. }; 
504      Float_t theight = 2*hFrameHeight + sensHeight;
505      Float_t hFramepar[3]={hFrameLength/2., theight/2., hFrameWidth/2.}; 
506      Float_t bFramepar[3]={bFrameLength/2., bFrameHeight/2., bFrameWidth/2.}; 
507      Float_t vFramepar[3]={vFrameLength/2., vFrameHeight/2., vFrameWidth/2.}; 
508      Float_t nulocpar[3]={nulocLength/2., nulocHeight/2., nulocWidth/2.}; 
509      Float_t xx;
510      Float_t xxmax = (bFrameLength - nulocLength)/2.; 
511      Int_t index=0;
512      
513      if (stations[2]) {
514          
515 //********************************************************************
516 //                            Station 3                             **
517 //********************************************************************
518      // indices 1 and 2 for first and second chambers in the station
519      // iChamber (first chamber) kept for other quanties than Z,
520      // assumed to be the same in both chambers
521      iChamber1 = iChamber = (AliMUONChamber*) (*fChambers)[4];
522      iChamber2 =(AliMUONChamber*) (*fChambers)[5];
523      zpos1=iChamber1->Z(); 
524      zpos2=iChamber2->Z();
525      dstation = zpos2 - zpos1;
526
527 //      zfpos=-(iChamber->DGas()+dframez+iChamber->DAlu())/2; // not used any more
528 //
529 //   Mother volume
530 //     tpar[0] = iChamber->RInner()-vFrameLength; 
531      tpar[0] = 30.; 
532 //     tpar[1] = (iChamber->ROuter()+dframep)*TMath::Sqrt(2.);
533      tpar[1] = 160.;
534      tpar[2] = dstation/4;
535      gMC->Gsvolu("C05M", "TUBE", idAir, tpar, 3);
536      gMC->Gsvolu("C06M", "TUBE", idAir, tpar, 3);
537      gMC->Gspos("C05M", 1, "ALIC", 0., 0., zpos1 , 0, "ONLY");
538      gMC->Gspos("C06M", 1, "ALIC", 0., 0., zpos2 , 0, "ONLY");
539  
540      // volumes for slat geometry (xx=5,..,10 chamber id): 
541      // Sxx0 Sxx1 Sxx2 Sxx3  -->   Slat Mother volumes 
542      // SxxG                          -->   Sensitive volume (gas)
543      // SxxP                          -->   PCB (copper) 
544      // SxxI                          -->   Insulator (vetronite) 
545      // SxxC                          -->   Carbon panel 
546      // SxxR                          -->   Rohacell
547      // SxxH, SxxV                    -->   Horizontal and Vertical frames (vetronite)
548
549      // slat dimensions: slat is a MOTHER volume!!! made of air
550
551      const Int_t nSlats3 = 4;  // number of slats per quadrant
552      const Int_t nPCB3[nSlats3] = {2, 2, 2, 1}; // n PCB per slat
553      const Float_t xpos3[nSlats3] = {32., 40., 0., 0.};
554      Float_t slatLength3[nSlats3]; 
555
556      // create and position the slat (mother) volumes 
557
558      char volNam5[5];
559      char volNam6[5];
560      Float_t xSlat3;
561
562      for (i = 0; i<nSlats3; i++){
563        slatLength3[i] = pcbLength * nPCB3[i] + 2. * dSlatLength; 
564        xSlat3 = slatLength3[i]/2. - vFrameLength/2. + xpos3[i]; 
565        if (i==1) slatLength3[i] -=  2. *dSlatLength; // frame out in PCB with circular border 
566        Float_t ySlat31 =  sensHeight * i - yOverlap * i; 
567        Float_t ySlat32 = -sensHeight * i + yOverlap * i; 
568        spar[0] = slatLength3[i]/2.; 
569        spar[1] = slatHeight/2.;
570        spar[2] = slatWidth/2. * 1.01; 
571        Float_t dzCh3=spar[2] * 1.01;
572        // zSlat to be checked (odd downstream or upstream?)
573        Float_t zSlat = (i%2 ==0)? spar[2] : -spar[2]; 
574        sprintf(volNam5,"S05%d",i);
575        gMC->Gsvolu(volNam5,"BOX",slatMaterial,spar,3);
576        gMC->Gspos(volNam5, i*4+1,"C05M", xSlat3, ySlat31, zSlat+2.*dzCh3, 0, "ONLY");
577        gMC->Gspos(volNam5, i*4+2,"C05M",-xSlat3, ySlat31, zSlat-2.*dzCh3, 0, "ONLY");
578        
579        if (i>0) { 
580          gMC->Gspos(volNam5, i*4+3,"C05M", xSlat3, ySlat32, zSlat+2.*dzCh3, 0, "ONLY");
581          gMC->Gspos(volNam5, i*4+4,"C05M",-xSlat3, ySlat32, zSlat-2.*dzCh3, 0, "ONLY");
582        }
583
584        sprintf(volNam6,"S06%d",i);
585        gMC->Gsvolu(volNam6,"BOX",slatMaterial,spar,3);
586        gMC->Gspos(volNam6, i*4+1,"C06M", xSlat3, ySlat31, zSlat+2.*dzCh3, 0, "ONLY");
587        gMC->Gspos(volNam6, i*4+2,"C06M",-xSlat3, ySlat31, zSlat-2.*dzCh3, 0, "ONLY");
588        if (i>0) { 
589          gMC->Gspos(volNam6, i*4+3,"C06M", xSlat3, ySlat32, zSlat+2.*dzCh3, 0, "ONLY");
590          gMC->Gspos(volNam6, i*4+4,"C06M",-xSlat3, ySlat32, zSlat-2.*dzCh3, 0, "ONLY");
591        }
592      }
593
594      // create the panel volume 
595  
596      gMC->Gsvolu("S05C","BOX",panelMaterial,panelpar,3);
597      gMC->Gsvolu("S06C","BOX",panelMaterial,panelpar,3);
598
599      // create the rohacell volume 
600
601      gMC->Gsvolu("S05R","BOX",rohaMaterial,rohapar,3);
602      gMC->Gsvolu("S06R","BOX",rohaMaterial,rohapar,3);
603
604      // create the insulating material volume 
605
606      gMC->Gsvolu("S05I","BOX",insuMaterial,insupar,3);
607      gMC->Gsvolu("S06I","BOX",insuMaterial,insupar,3);
608
609      // create the PCB volume 
610
611      gMC->Gsvolu("S05P","BOX",pcbMaterial,pcbpar,3);
612      gMC->Gsvolu("S06P","BOX",pcbMaterial,pcbpar,3);
613  
614      // create the sensitive volumes,
615      gMC->Gsvolu("S05G","BOX",sensMaterial,0,0);
616      gMC->Gsvolu("S06G","BOX",sensMaterial,0,0);
617
618
619      // create the vertical frame volume 
620
621      gMC->Gsvolu("S05V","BOX",vFrameMaterial,vFramepar,3);
622      gMC->Gsvolu("S06V","BOX",vFrameMaterial,vFramepar,3);
623
624      // create the horizontal frame volume 
625
626      gMC->Gsvolu("S05H","BOX",hFrameMaterial,hFramepar,3);
627      gMC->Gsvolu("S06H","BOX",hFrameMaterial,hFramepar,3);
628
629      // create the horizontal border volume 
630
631      gMC->Gsvolu("S05B","BOX",bFrameMaterial,bFramepar,3);
632      gMC->Gsvolu("S06B","BOX",bFrameMaterial,bFramepar,3);
633
634      index=0; 
635      for (i = 0; i<nSlats3; i++){
636        sprintf(volNam5,"S05%d",i);
637        sprintf(volNam6,"S06%d",i);
638        Float_t xvFrame  = (slatLength3[i] - vFrameLength)/2.;
639        // position the vertical frames 
640        if (i!=1) { 
641          gMC->Gspos("S05V",2*i-1,volNam5, xvFrame, 0., 0. , 0, "ONLY");
642          gMC->Gspos("S05V",2*i  ,volNam5,-xvFrame, 0., 0. , 0, "ONLY");
643          gMC->Gspos("S06V",2*i-1,volNam6, xvFrame, 0., 0. , 0, "ONLY");
644          gMC->Gspos("S06V",2*i  ,volNam6,-xvFrame, 0., 0. , 0, "ONLY");
645        }       
646        // position the panels and the insulating material 
647        for (j=0; j<nPCB3[i]; j++){
648          index++;
649          Float_t xx = sensLength * (-nPCB3[i]/2.+j+.5); 
650          
651          Float_t zPanel = spar[2] - panelpar[2]; 
652          gMC->Gspos("S05C",2*index-1,volNam5, xx, 0., zPanel , 0, "ONLY");
653          gMC->Gspos("S05C",2*index  ,volNam5, xx, 0.,-zPanel , 0, "ONLY");
654          gMC->Gspos("S06C",2*index-1,volNam6, xx, 0., zPanel , 0, "ONLY");
655          gMC->Gspos("S06C",2*index  ,volNam6, xx, 0.,-zPanel , 0, "ONLY");
656
657          gMC->Gspos("S05I",index,volNam5, xx, 0., 0 , 0, "ONLY");
658          gMC->Gspos("S06I",index,volNam6, xx, 0., 0 , 0, "ONLY");
659        } 
660      }
661
662      // position the rohacell volume inside the panel volume
663      gMC->Gspos("S05R",1,"S05C",0.,0.,0.,0,"ONLY"); 
664      gMC->Gspos("S06R",1,"S06C",0.,0.,0.,0,"ONLY"); 
665
666      // position the PCB volume inside the insulating material volume
667      gMC->Gspos("S05P",1,"S05I",0.,0.,0.,0,"ONLY"); 
668      gMC->Gspos("S06P",1,"S06I",0.,0.,0.,0,"ONLY"); 
669      // position the horizontal frame volume inside the PCB volume
670      gMC->Gspos("S05H",1,"S05P",0.,0.,0.,0,"ONLY"); 
671      gMC->Gspos("S06H",1,"S06P",0.,0.,0.,0,"ONLY"); 
672      // position the sensitive volume inside the horizontal frame volume
673      gMC->Gsposp("S05G",1,"S05H",0.,0.,0.,0,"ONLY",senspar,3); 
674      gMC->Gsposp("S06G",1,"S06H",0.,0.,0.,0,"ONLY",senspar,3); 
675      // position the border volumes inside the PCB volume
676      Float_t yborder = ( pcbHeight - bFrameHeight ) / 2.; 
677      gMC->Gspos("S05B",1,"S05P",0., yborder,0.,0,"ONLY"); 
678      gMC->Gspos("S05B",2,"S05P",0.,-yborder,0.,0,"ONLY"); 
679      gMC->Gspos("S06B",1,"S06P",0., yborder,0.,0,"ONLY"); 
680      gMC->Gspos("S06B",2,"S06P",0.,-yborder,0.,0,"ONLY"); 
681
682      // create the NULOC volume and position it in the horizontal frame
683
684      gMC->Gsvolu("S05N","BOX",nulocMaterial,nulocpar,3);
685      gMC->Gsvolu("S06N","BOX",nulocMaterial,nulocpar,3);
686      index = 0;
687      for (xx = -xxmax; xx<=xxmax; xx+=3*nulocLength) { 
688        index++; 
689        gMC->Gspos("S05N",2*index-1,"S05B", xx, 0.,-bFrameWidth/4., 0, "ONLY");
690        gMC->Gspos("S05N",2*index  ,"S05B", xx, 0., bFrameWidth/4., 0, "ONLY");
691        gMC->Gspos("S06N",2*index-1,"S06B", xx, 0.,-bFrameWidth/4., 0, "ONLY");
692        gMC->Gspos("S06N",2*index  ,"S06B", xx, 0., bFrameWidth/4., 0, "ONLY");
693      }
694      
695      // position the volumes approximating the circular section of the pipe
696      Float_t yoffs = sensHeight/2. - yOverlap; 
697      Float_t epsilon = 0.001; 
698      Int_t ndiv=6;
699      Float_t divpar[3];
700      Double_t dydiv= sensHeight/ndiv;
701      Double_t ydiv = yoffs -dydiv - yOverlap/2.;
702      Int_t imax=0; 
703      //     for (Int_t islat=0; islat<nSlats3; islat++) imax += nPCB3[islat]; 
704      imax = 1; 
705      Float_t rmin = 35.; 
706      Float_t z1 = -spar[2], z2=2*spar[2]*1.01; 
707      for (Int_t idiv=0;idiv<ndiv; idiv++){ 
708        ydiv+= dydiv;
709        Float_t xdiv = 0.; 
710        if (ydiv<rmin) xdiv= rmin * TMath::Sin( TMath::ACos(ydiv/rmin) );
711        divpar[0] = (pcbLength-xdiv)/2.; 
712        divpar[1] = dydiv/2. - epsilon;
713        divpar[2] = sensWidth/2.; 
714        Float_t xvol=(pcbLength+xdiv)/2.+1.999;
715        Float_t yvol=ydiv + dydiv/2.; 
716        gMC->Gsposp("S05G",imax+4*idiv+1,"C05M", xvol, yvol, z1+z2, 0, "ONLY",divpar,3);
717        gMC->Gsposp("S06G",imax+4*idiv+1,"C06M", xvol, yvol, z1+z2, 0, "ONLY",divpar,3);
718        gMC->Gsposp("S05G",imax+4*idiv+2,"C05M", xvol,-yvol, z1+z2, 0, "ONLY",divpar,3);
719        gMC->Gsposp("S06G",imax+4*idiv+2,"C06M", xvol,-yvol, z1+z2, 0, "ONLY",divpar,3);
720        gMC->Gsposp("S05G",imax+4*idiv+3,"C05M",-xvol, yvol, z1-z2, 0, "ONLY",divpar,3);
721        gMC->Gsposp("S06G",imax+4*idiv+3,"C06M",-xvol, yvol, z1-z2, 0, "ONLY",divpar,3);
722        gMC->Gsposp("S05G",imax+4*idiv+4,"C05M",-xvol,-yvol, z1-z2, 0, "ONLY",divpar,3);
723        gMC->Gsposp("S06G",imax+4*idiv+4,"C06M",-xvol,-yvol, z1-z2, 0, "ONLY",divpar,3);
724      }
725      }
726      
727
728  if (stations[3]) {
729
730 //********************************************************************
731 //                            Station 4                             **
732 //********************************************************************
733      // indices 1 and 2 for first and second chambers in the station
734      // iChamber (first chamber) kept for other quanties than Z,
735      // assumed to be the same in both chambers
736      iChamber1 = iChamber = (AliMUONChamber*) (*fChambers)[6];
737      iChamber2 =(AliMUONChamber*) (*fChambers)[7];
738      zpos1=iChamber1->Z(); 
739      zpos2=iChamber2->Z();
740      dstation = zpos2 - zpos1;
741 //      zfpos=-(iChamber->DGas()+dframez+iChamber->DAlu())/2; // not used any more
742      
743 //
744 //   Mother volume
745      tpar[0] = 37.5-vFrameLength/2.-0.1; 
746      tpar[1] = (iChamber->ROuter()+dframep)/TMath::Cos(phi);
747      tpar[2] = 3.252;
748
749      gMC->Gsvolu("C07M", "TUBE", idAir, tpar, 3);
750      gMC->Gsvolu("C08M", "TUBE", idAir, tpar, 3);
751      gMC->Gspos("C07M", 1, "ALIC", 0., 0., zpos1 , 0, "ONLY");
752      gMC->Gspos("C08M", 1, "ALIC", 0., 0., zpos2 , 0, "ONLY");
753      
754
755      const Int_t nSlats4 = 6;  // number of slats per quadrant
756      const Int_t nPCB4[nSlats4] = {4,4,5,5,4,3}; // n PCB per slat
757      const Float_t xpos4[nSlats4] = {37.5, 40., 0., 0., 0., 0.};
758      Float_t slatLength4[nSlats4];     
759
760      // create and position the slat (mother) volumes 
761
762      char volNam7[5];
763      char volNam8[5];
764      Float_t xSlat4;
765      Float_t ySlat4;
766
767      for (i = 0; i<nSlats4; i++){
768        slatLength4[i] = pcbLength * nPCB4[i] + 2. * dSlatLength; 
769        xSlat4 = slatLength4[i]/2. - vFrameLength/2. + xpos4[i]; 
770        if (i==1) slatLength4[i] -=  2. *dSlatLength; // frame out in PCB with circular border 
771        ySlat4 =  sensHeight * i - yOverlap *i;
772        
773        spar[0] = slatLength4[i]/2.; 
774        spar[1] = slatHeight/2.;
775        spar[2] = slatWidth/2.*1.01; 
776        Float_t dzCh4=spar[2]*1.01;
777        // zSlat to be checked (odd downstream or upstream?)
778        Float_t zSlat = (i%2 ==0)? spar[2] : -spar[2]; 
779        sprintf(volNam7,"S07%d",i);
780        gMC->Gsvolu(volNam7,"BOX",slatMaterial,spar,3);
781        gMC->Gspos(volNam7, i*4+1,"C07M", xSlat4, ySlat4, zSlat+2.*dzCh4, 0, "ONLY");
782        gMC->Gspos(volNam7, i*4+2,"C07M",-xSlat4, ySlat4, zSlat-2.*dzCh4, 0, "ONLY");
783        if (i>0) { 
784          gMC->Gspos(volNam7, i*4+3,"C07M", xSlat4,-ySlat4, zSlat+2.*dzCh4, 0, "ONLY");
785          gMC->Gspos(volNam7, i*4+4,"C07M",-xSlat4,-ySlat4, zSlat-2.*dzCh4, 0, "ONLY");
786        }
787        sprintf(volNam8,"S08%d",i);
788        gMC->Gsvolu(volNam8,"BOX",slatMaterial,spar,3);
789        gMC->Gspos(volNam8, i*4+1,"C08M", xSlat4, ySlat4, zSlat+2.*dzCh4, 0, "ONLY");
790        gMC->Gspos(volNam8, i*4+2,"C08M",-xSlat4, ySlat4, zSlat-2.*dzCh4, 0, "ONLY");
791        if (i>0) { 
792          gMC->Gspos(volNam8, i*4+3,"C08M", xSlat4,-ySlat4, zSlat+2.*dzCh4, 0, "ONLY");
793          gMC->Gspos(volNam8, i*4+4,"C08M",-xSlat4,-ySlat4, zSlat-2.*dzCh4, 0, "ONLY");
794        }
795      }
796      
797
798      // create the panel volume 
799  
800      gMC->Gsvolu("S07C","BOX",panelMaterial,panelpar,3);
801      gMC->Gsvolu("S08C","BOX",panelMaterial,panelpar,3);
802
803      // create the rohacell volume 
804
805      gMC->Gsvolu("S07R","BOX",rohaMaterial,rohapar,3);
806      gMC->Gsvolu("S08R","BOX",rohaMaterial,rohapar,3);
807
808      // create the insulating material volume 
809
810      gMC->Gsvolu("S07I","BOX",insuMaterial,insupar,3);
811      gMC->Gsvolu("S08I","BOX",insuMaterial,insupar,3);
812
813      // create the PCB volume 
814
815      gMC->Gsvolu("S07P","BOX",pcbMaterial,pcbpar,3);
816      gMC->Gsvolu("S08P","BOX",pcbMaterial,pcbpar,3);
817  
818      // create the sensitive volumes,
819
820      gMC->Gsvolu("S07G","BOX",sensMaterial,0,0);
821      gMC->Gsvolu("S08G","BOX",sensMaterial,0,0);
822
823      // create the vertical frame volume 
824
825      gMC->Gsvolu("S07V","BOX",vFrameMaterial,vFramepar,3);
826      gMC->Gsvolu("S08V","BOX",vFrameMaterial,vFramepar,3);
827
828      // create the horizontal frame volume 
829
830      gMC->Gsvolu("S07H","BOX",hFrameMaterial,hFramepar,3);
831      gMC->Gsvolu("S08H","BOX",hFrameMaterial,hFramepar,3);
832
833      // create the horizontal border volume 
834
835      gMC->Gsvolu("S07B","BOX",bFrameMaterial,bFramepar,3);
836      gMC->Gsvolu("S08B","BOX",bFrameMaterial,bFramepar,3);
837
838      index=0; 
839      for (i = 0; i<nSlats4; i++){
840        sprintf(volNam7,"S07%d",i);
841        sprintf(volNam8,"S08%d",i);
842        Float_t xvFrame  = (slatLength4[i] - vFrameLength)/2.;
843        // position the vertical frames 
844        if (i!=1) { 
845          gMC->Gspos("S07V",2*i-1,volNam7, xvFrame, 0., 0. , 0, "ONLY");
846          gMC->Gspos("S07V",2*i  ,volNam7,-xvFrame, 0., 0. , 0, "ONLY");
847          gMC->Gspos("S08V",2*i-1,volNam8, xvFrame, 0., 0. , 0, "ONLY");
848          gMC->Gspos("S08V",2*i  ,volNam8,-xvFrame, 0., 0. , 0, "ONLY");
849        }
850        // position the panels and the insulating material 
851        for (j=0; j<nPCB4[i]; j++){
852          index++;
853          Float_t xx = sensLength * (-nPCB4[i]/2.+j+.5); 
854
855          Float_t zPanel = spar[2] - panelpar[2]; 
856          gMC->Gspos("S07C",2*index-1,volNam7, xx, 0., zPanel , 0, "ONLY");
857          gMC->Gspos("S07C",2*index  ,volNam7, xx, 0.,-zPanel , 0, "ONLY");
858          gMC->Gspos("S08C",2*index-1,volNam8, xx, 0., zPanel , 0, "ONLY");
859          gMC->Gspos("S08C",2*index  ,volNam8, xx, 0.,-zPanel , 0, "ONLY");
860
861          gMC->Gspos("S07I",index,volNam7, xx, 0., 0 , 0, "ONLY");
862          gMC->Gspos("S08I",index,volNam8, xx, 0., 0 , 0, "ONLY");
863        } 
864      }
865
866      // position the rohacell volume inside the panel volume
867      gMC->Gspos("S07R",1,"S07C",0.,0.,0.,0,"ONLY"); 
868      gMC->Gspos("S08R",1,"S08C",0.,0.,0.,0,"ONLY"); 
869
870      // position the PCB volume inside the insulating material volume
871      gMC->Gspos("S07P",1,"S07I",0.,0.,0.,0,"ONLY"); 
872      gMC->Gspos("S08P",1,"S08I",0.,0.,0.,0,"ONLY"); 
873      // position the horizontal frame volume inside the PCB volume
874      gMC->Gspos("S07H",1,"S07P",0.,0.,0.,0,"ONLY"); 
875      gMC->Gspos("S08H",1,"S08P",0.,0.,0.,0,"ONLY"); 
876      // position the sensitive volume inside the horizontal frame volume
877      gMC->Gsposp("S07G",1,"S07H",0.,0.,0.,0,"ONLY",senspar,3); 
878      gMC->Gsposp("S08G",1,"S08H",0.,0.,0.,0,"ONLY",senspar,3); 
879      // position the border volumes inside the PCB volume
880      Float_t yborder = ( pcbHeight - bFrameHeight ) / 2.; 
881      gMC->Gspos("S07B",1,"S07P",0., yborder,0.,0,"ONLY"); 
882      gMC->Gspos("S07B",2,"S07P",0.,-yborder,0.,0,"ONLY"); 
883      gMC->Gspos("S08B",1,"S08P",0., yborder,0.,0,"ONLY"); 
884      gMC->Gspos("S08B",2,"S08P",0.,-yborder,0.,0,"ONLY"); 
885
886      // create the NULOC volume and position it in the horizontal frame
887
888      gMC->Gsvolu("S07N","BOX",nulocMaterial,nulocpar,3);
889      gMC->Gsvolu("S08N","BOX",nulocMaterial,nulocpar,3);
890      index = 0;
891      for (xx = -xxmax; xx<=xxmax; xx+=3*nulocLength) { 
892        index++; 
893        gMC->Gspos("S07N",2*index-1,"S07B", xx, 0.,-bFrameWidth/4., 0, "ONLY");
894        gMC->Gspos("S07N",2*index  ,"S07B", xx, 0., bFrameWidth/4., 0, "ONLY");
895        gMC->Gspos("S08N",2*index-1,"S08B", xx, 0.,-bFrameWidth/4., 0, "ONLY");
896        gMC->Gspos("S08N",2*index  ,"S08B", xx, 0., bFrameWidth/4., 0, "ONLY");
897      }
898
899      // position the volumes approximating the circular section of the pipe
900      Float_t yoffs = sensHeight/2. - yOverlap/2.; 
901      Float_t epsilon = 0.001; 
902      Int_t ndiv=6;
903      Float_t divpar[3];
904      Double_t dydiv= sensHeight/ndiv;
905      Double_t ydiv = yoffs -dydiv - yOverlap/2.;
906      Int_t imax=0; 
907      //     for (Int_t islat=0; islat<nSlats3; islat++) imax += nPCB3[islat]; 
908      imax = 1; 
909      Float_t rmin = 40.; 
910      Float_t z1 = -spar[2], z2=2*spar[2]*1.01; 
911      for (Int_t idiv=0;idiv<ndiv; idiv++){ 
912        ydiv+= dydiv;
913        Float_t xdiv = 0.; 
914        if (ydiv<rmin) xdiv= rmin * TMath::Sin( TMath::ACos(ydiv/rmin) );
915        divpar[0] = (pcbLength-xdiv)/2.; 
916        divpar[1] = dydiv/2. - epsilon;
917        divpar[2] = sensWidth/2.; 
918        Float_t xvol=(pcbLength+xdiv)/2.+1.999;
919        Float_t yvol=ydiv + dydiv/2.;
920        gMC->Gsposp("S07G",imax+4*idiv+1,"C07M", xvol, yvol, z1+z2, 0, "ONLY",divpar,3);
921        gMC->Gsposp("S08G",imax+4*idiv+1,"C08M", xvol, yvol, z1+z2, 0, "ONLY",divpar,3);
922        gMC->Gsposp("S07G",imax+4*idiv+2,"C07M", xvol,-yvol, z1+z2, 0, "ONLY",divpar,3);
923        gMC->Gsposp("S08G",imax+4*idiv+2,"C08M", xvol,-yvol, z1+z2, 0, "ONLY",divpar,3);
924        gMC->Gsposp("S07G",imax+4*idiv+3,"C07M",-xvol, yvol, z1-z2, 0, "ONLY",divpar,3);
925        gMC->Gsposp("S08G",imax+4*idiv+3,"C08M",-xvol, yvol, z1-z2, 0, "ONLY",divpar,3);
926        gMC->Gsposp("S07G",imax+4*idiv+4,"C07M",-xvol,-yvol, z1-z2, 0, "ONLY",divpar,3);
927        gMC->Gsposp("S08G",imax+4*idiv+4,"C08M",-xvol,-yvol, z1-z2, 0, "ONLY",divpar,3);
928      }
929
930  }
931
932  if (stations[4]) {
933      
934
935 //********************************************************************
936 //                            Station 5                             **
937 //********************************************************************
938      // indices 1 and 2 for first and second chambers in the station
939      // iChamber (first chamber) kept for other quanties than Z,
940      // assumed to be the same in both chambers
941      iChamber1 = iChamber = (AliMUONChamber*) (*fChambers)[8];
942      iChamber2 =(AliMUONChamber*) (*fChambers)[9];
943      zpos1=iChamber1->Z(); 
944      zpos2=iChamber2->Z();
945      dstation = zpos2 - zpos1;
946 //      zfpos=-(iChamber->DGas()+dframez+iChamber->DAlu())/2; // not used any more
947      
948 //
949 //   Mother volume
950      tpar[0] = 37.5-vFrameLength/2.-0.1; 
951      tpar[1] = (iChamber->ROuter()+dframep)/TMath::Cos(phi);
952      tpar[2] = dstation/5.;
953
954      gMC->Gsvolu("C09M", "TUBE", idAir, tpar, 3);
955      gMC->Gsvolu("C10M", "TUBE", idAir, tpar, 3);
956      gMC->Gspos("C09M", 1, "ALIC", 0., 0., zpos1 , 0, "ONLY");
957      gMC->Gspos("C10M", 1, "ALIC", 0., 0., zpos2 , 0, "ONLY");
958
959
960      const Int_t nSlats5 = 7;  // number of slats per quadrant
961      const Int_t nPCB5[nSlats5] = {5,5,6,6,5,4,3}; // n PCB per slat
962      const Float_t xpos5[nSlats5] = {37.5, 40., 0., 0., 0., 0., 0.};
963      Float_t slatLength5[nSlats5]; 
964      char volNam9[5];
965      char volNam10[5];
966      Float_t xSlat5;
967      Float_t ySlat5;
968
969      for (i = 0; i<nSlats5; i++){
970        slatLength5[i] = pcbLength * nPCB5[i] + 2. * dSlatLength; 
971        xSlat5 = slatLength5[i]/2. - vFrameLength/2. +xpos5[i]; 
972        if (i==1) slatLength5[i] -=  2. *dSlatLength; // frame out in PCB with circular border 
973        ySlat5 = sensHeight * i - yOverlap * i; 
974        spar[0] = slatLength5[i]/2.; 
975        spar[1] = slatHeight/2.;
976        spar[2] = slatWidth/2. * 1.01; 
977        Float_t dzCh5=spar[2]*1.01;
978        // zSlat to be checked (odd downstream or upstream?)
979        Float_t zSlat = (i%2 ==0)? -spar[2] : spar[2]; 
980        sprintf(volNam9,"S09%d",i);
981        gMC->Gsvolu(volNam9,"BOX",slatMaterial,spar,3);
982        gMC->Gspos(volNam9, i*4+1,"C09M", xSlat5, ySlat5, zSlat+2.*dzCh5, 0, "ONLY");
983        gMC->Gspos(volNam9, i*4+2,"C09M",-xSlat5, ySlat5, zSlat-2.*dzCh5, 0, "ONLY");
984        if (i>0) { 
985            gMC->Gspos(volNam9, i*4+3,"C09M", xSlat5,-ySlat5, zSlat+2.*dzCh5, 0, "ONLY");
986            gMC->Gspos(volNam9, i*4+4,"C09M",-xSlat5,-ySlat5, zSlat-2.*dzCh5, 0, "ONLY");
987        }
988        sprintf(volNam10,"S10%d",i);
989        gMC->Gsvolu(volNam10,"BOX",slatMaterial,spar,3);
990        gMC->Gspos(volNam10, i*4+1,"C10M", xSlat5, ySlat5, zSlat+2.*dzCh5, 0, "ONLY");
991        gMC->Gspos(volNam10, i*4+2,"C10M",-xSlat5, ySlat5, zSlat-2.*dzCh5, 0, "ONLY");
992        if (i>0) { 
993            gMC->Gspos(volNam10, i*4+3,"C10M", xSlat5,-ySlat5, zSlat+2.*dzCh5, 0, "ONLY");
994            gMC->Gspos(volNam10, i*4+4,"C10M",-xSlat5,-ySlat5, zSlat-2.*dzCh5, 0, "ONLY");
995        }
996      }
997
998      // create the panel volume 
999  
1000      gMC->Gsvolu("S09C","BOX",panelMaterial,panelpar,3);
1001      gMC->Gsvolu("S10C","BOX",panelMaterial,panelpar,3);
1002
1003      // create the rohacell volume 
1004
1005      gMC->Gsvolu("S09R","BOX",rohaMaterial,rohapar,3);
1006      gMC->Gsvolu("S10R","BOX",rohaMaterial,rohapar,3);
1007
1008      // create the insulating material volume 
1009
1010      gMC->Gsvolu("S09I","BOX",insuMaterial,insupar,3);
1011      gMC->Gsvolu("S10I","BOX",insuMaterial,insupar,3);
1012
1013      // create the PCB volume 
1014
1015      gMC->Gsvolu("S09P","BOX",pcbMaterial,pcbpar,3);
1016      gMC->Gsvolu("S10P","BOX",pcbMaterial,pcbpar,3);
1017  
1018      // create the sensitive volumes,
1019
1020      gMC->Gsvolu("S09G","BOX",sensMaterial,0,0);
1021      gMC->Gsvolu("S10G","BOX",sensMaterial,0,0);
1022
1023      // create the vertical frame volume 
1024
1025      gMC->Gsvolu("S09V","BOX",vFrameMaterial,vFramepar,3);
1026      gMC->Gsvolu("S10V","BOX",vFrameMaterial,vFramepar,3);
1027
1028      // create the horizontal frame volume 
1029
1030      gMC->Gsvolu("S09H","BOX",hFrameMaterial,hFramepar,3);
1031      gMC->Gsvolu("S10H","BOX",hFrameMaterial,hFramepar,3);
1032
1033      // create the horizontal border volume 
1034
1035      gMC->Gsvolu("S09B","BOX",bFrameMaterial,bFramepar,3);
1036      gMC->Gsvolu("S10B","BOX",bFrameMaterial,bFramepar,3);
1037
1038      index=0; 
1039      for (i = 0; i<nSlats5; i++){
1040        sprintf(volNam9,"S09%d",i);
1041        sprintf(volNam10,"S10%d",i);
1042        Float_t xvFrame  = (slatLength5[i] - vFrameLength)/2.;
1043        // position the vertical frames 
1044        if (i!=1) { 
1045          gMC->Gspos("S09V",2*i-1,volNam9, xvFrame, 0., 0. , 0, "ONLY");
1046          gMC->Gspos("S09V",2*i  ,volNam9,-xvFrame, 0., 0. , 0, "ONLY");
1047          gMC->Gspos("S10V",2*i-1,volNam10, xvFrame, 0., 0. , 0, "ONLY");
1048          gMC->Gspos("S10V",2*i  ,volNam10,-xvFrame, 0., 0. , 0, "ONLY");
1049        }
1050        
1051        // position the panels and the insulating material 
1052        for (j=0; j<nPCB5[i]; j++){
1053          index++;
1054          Float_t xx = sensLength * (-nPCB5[i]/2.+j+.5); 
1055
1056          Float_t zPanel = spar[2] - panelpar[2]; 
1057          gMC->Gspos("S09C",2*index-1,volNam9, xx, 0., zPanel , 0, "ONLY");
1058          gMC->Gspos("S09C",2*index  ,volNam9, xx, 0.,-zPanel , 0, "ONLY");
1059          gMC->Gspos("S10C",2*index-1,volNam10, xx, 0., zPanel , 0, "ONLY");
1060          gMC->Gspos("S10C",2*index  ,volNam10, xx, 0.,-zPanel , 0, "ONLY");
1061
1062          gMC->Gspos("S09I",index,volNam9, xx, 0., 0 , 0, "ONLY");
1063          gMC->Gspos("S10I",index,volNam10, xx, 0., 0 , 0, "ONLY");
1064        } 
1065      }
1066
1067      // position the rohacell volume inside the panel volume
1068      gMC->Gspos("S09R",1,"S09C",0.,0.,0.,0,"ONLY"); 
1069      gMC->Gspos("S10R",1,"S10C",0.,0.,0.,0,"ONLY"); 
1070
1071      // position the PCB volume inside the insulating material volume
1072      gMC->Gspos("S09P",1,"S09I",0.,0.,0.,0,"ONLY"); 
1073      gMC->Gspos("S10P",1,"S10I",0.,0.,0.,0,"ONLY"); 
1074      // position the horizontal frame volume inside the PCB volume
1075      gMC->Gspos("S09H",1,"S09P",0.,0.,0.,0,"ONLY"); 
1076      gMC->Gspos("S10H",1,"S10P",0.,0.,0.,0,"ONLY"); 
1077      // position the sensitive volume inside the horizontal frame volume
1078      gMC->Gsposp("S09G",1,"S09H",0.,0.,0.,0,"ONLY",senspar,3); 
1079      gMC->Gsposp("S10G",1,"S10H",0.,0.,0.,0,"ONLY",senspar,3); 
1080      // position the border volumes inside the PCB volume
1081      Float_t yborder = ( pcbHeight - bFrameHeight ) / 2.; 
1082      gMC->Gspos("S09B",1,"S09P",0., yborder,0.,0,"ONLY"); 
1083      gMC->Gspos("S09B",2,"S09P",0.,-yborder,0.,0,"ONLY"); 
1084      gMC->Gspos("S10B",1,"S10P",0., yborder,0.,0,"ONLY"); 
1085      gMC->Gspos("S10B",2,"S10P",0.,-yborder,0.,0,"ONLY"); 
1086
1087      // create the NULOC volume and position it in the horizontal frame
1088
1089      gMC->Gsvolu("S09N","BOX",nulocMaterial,nulocpar,3);
1090      gMC->Gsvolu("S10N","BOX",nulocMaterial,nulocpar,3);
1091      index = 0;
1092      for (xx = -xxmax; xx<=xxmax; xx+=3*nulocLength) { 
1093        index++; 
1094        gMC->Gspos("S09N",2*index-1,"S09B", xx, 0.,-bFrameWidth/4., 0, "ONLY");
1095        gMC->Gspos("S09N",2*index  ,"S09B", xx, 0., bFrameWidth/4., 0, "ONLY");
1096        gMC->Gspos("S10N",2*index-1,"S10B", xx, 0.,-bFrameWidth/4., 0, "ONLY");
1097        gMC->Gspos("S10N",2*index  ,"S10B", xx, 0., bFrameWidth/4., 0, "ONLY");
1098      }
1099      // position the volumes approximating the circular section of the pipe
1100      Float_t yoffs = sensHeight/2. - yOverlap/2.; 
1101      Float_t epsilon = 0.001; 
1102      Int_t ndiv=6;
1103      Float_t divpar[3];
1104      Double_t dydiv= sensHeight/ndiv;
1105      Double_t ydiv = yoffs -dydiv - yOverlap/2.;
1106      Int_t imax=0; 
1107      //     for (Int_t islat=0; islat<nSlats3; islat++) imax += nPCB3[islat]; 
1108      imax = 1; 
1109      Float_t rmin = 40.; 
1110      Float_t z1 = spar[2], z2=2*spar[2]*1.01; 
1111      for (Int_t idiv=0;idiv<ndiv; idiv++){ 
1112        ydiv+= dydiv;
1113        Float_t xdiv = 0.; 
1114        if (ydiv<rmin) xdiv= rmin * TMath::Sin( TMath::ACos(ydiv/rmin) );
1115        divpar[0] = (pcbLength-xdiv)/2.; 
1116        divpar[1] = dydiv/2. - epsilon;
1117        divpar[2] = sensWidth/2.; 
1118        Float_t xvol=(pcbLength+xdiv)/2. + 1.999;
1119        Float_t yvol=ydiv + dydiv/2.;
1120        gMC->Gsposp("S09G",imax+4*idiv+1,"C09M", xvol, yvol, z1+z2, 0, "ONLY",divpar,3);
1121        gMC->Gsposp("S10G",imax+4*idiv+1,"C10M", xvol, yvol, z1+z2, 0, "ONLY",divpar,3);
1122        gMC->Gsposp("S09G",imax+4*idiv+2,"C09M", xvol,-yvol, z1+z2, 0, "ONLY",divpar,3);
1123        gMC->Gsposp("S10G",imax+4*idiv+2,"C10M", xvol,-yvol, z1+z2, 0, "ONLY",divpar,3);
1124        gMC->Gsposp("S09G",imax+4*idiv+3,"C09M",-xvol, yvol, z1-z2, 0, "ONLY",divpar,3);
1125        gMC->Gsposp("S10G",imax+4*idiv+3,"C10M",-xvol, yvol, z1-z2, 0, "ONLY",divpar,3);
1126        gMC->Gsposp("S09G",imax+4*idiv+4,"C09M",-xvol,-yvol, z1-z2, 0, "ONLY",divpar,3);
1127        gMC->Gsposp("S10G",imax+4*idiv+4,"C10M",-xvol,-yvol, z1-z2, 0, "ONLY",divpar,3);
1128      }
1129
1130  }
1131  
1132
1133 ///////////////////////////////////////
1134 // GEOMETRY FOR THE TRIGGER CHAMBERS //
1135 ///////////////////////////////////////
1136
1137 // 03/00 P. Dupieux : introduce a slighly more realistic  
1138 //                    geom. of the trigger readout planes with
1139 //                    2 Zpos per trigger plane (alternate
1140 //                    between left and right of the trigger)  
1141
1142 //  Parameters of the Trigger Chambers
1143
1144                 
1145      const Float_t kXMC1MIN=34.;       
1146      const Float_t kXMC1MED=51.;                                
1147      const Float_t kXMC1MAX=272.;                               
1148      const Float_t kYMC1MIN=34.;                              
1149      const Float_t kYMC1MAX=51.;                              
1150      const Float_t kRMIN1=50.;
1151      const Float_t kRMAX1=62.;
1152      const Float_t kRMIN2=50.;
1153      const Float_t kRMAX2=66.;
1154
1155 //   zposition of the middle of the gas gap in mother vol 
1156      const Float_t kZMCm=-3.6;
1157      const Float_t kZMCp=+3.6;
1158
1159
1160 // TRIGGER STATION 1 - TRIGGER STATION 1 - TRIGGER STATION 1
1161
1162      // iChamber 1 and 2 for first and second chambers in the station
1163      // iChamber (first chamber) kept for other quanties than Z,
1164      // assumed to be the same in both chambers
1165      iChamber1 = iChamber = (AliMUONChamber*) (*fChambers)[10];
1166      iChamber2 =(AliMUONChamber*) (*fChambers)[11]; 
1167
1168      // 03/00 
1169      // zpos1 and zpos2 are now the middle of the first and second
1170      // plane of station 1 : 
1171      // zpos1=(16075+15995)/2=16035 mm, thick/2=40 mm
1172      // zpos2=(16225+16145)/2=16185 mm, thick/2=40 mm
1173      //
1174      // zpos1m=15999 mm , zpos1p=16071 mm (middles of gas gaps)
1175      // zpos2m=16149 mm , zpos2p=16221 mm (middles of gas gaps)
1176      // rem : the total thickness accounts for 1 mm of al on both 
1177      // side of the RPCs (see zpos1 and zpos2), as previously
1178
1179      zpos1=iChamber1->Z();
1180      zpos2=iChamber2->Z();
1181
1182
1183 // Mother volume definition     
1184      tpar[0] = iChamber->RInner(); 
1185      tpar[1] = iChamber->ROuter();
1186      tpar[2] = 4.0;    
1187      gMC->Gsvolu("CM11", "TUBE", idAir, tpar, 3);
1188      gMC->Gsvolu("CM12", "TUBE", idAir, tpar, 3);
1189      
1190 // Definition of the flange between the beam shielding and the RPC 
1191      tpar[0]= kRMIN1;
1192      tpar[1]= kRMAX1;
1193      tpar[2]= 4.0;
1194    
1195      gMC->Gsvolu("CF1A", "TUBE", idAlu1, tpar, 3);     //Al
1196      gMC->Gspos("CF1A", 1, "CM11", 0., 0., 0., 0, "MANY");
1197      gMC->Gspos("CF1A", 2, "CM12", 0., 0., 0., 0, "MANY");
1198
1199
1200 // FIRST PLANE OF STATION 1
1201
1202 //   ratios of zpos1m/zpos1p and inverse for first plane
1203      Float_t zmp=(zpos1-3.6)/(zpos1+3.6);
1204      Float_t zpm=1./zmp;
1205    
1206
1207 // Definition of prototype for chambers in the first plane     
1208           
1209      tpar[0]= 0.;
1210      tpar[1]= 0.;
1211      tpar[2]= 0.;
1212           
1213      gMC->Gsvolu("CC1A", "BOX ", idAlu1, tpar, 0);           //Al    
1214      gMC->Gsvolu("CB1A", "BOX ", idtmed[1107], tpar, 0);     //Bakelite 
1215      gMC->Gsvolu("CG1A", "BOX ", idtmed[1106], tpar, 0);     //Gas streamer
1216
1217 // chamber type A
1218      tpar[0] = -1.;
1219      tpar[1] = -1.;
1220      
1221      const Float_t kXMC1A=kXMC1MED+(kXMC1MAX-kXMC1MED)/2.;
1222      const Float_t kYMC1Am=0.;
1223      const Float_t kYMC1Ap=0.;
1224           
1225      tpar[2] = 0.1;    
1226      gMC->Gsposp("CG1A", 1, "CB1A", 0., 0., 0., 0, "ONLY",tpar,3);
1227      tpar[2] = 0.3;
1228      gMC->Gsposp("CB1A", 1, "CC1A", 0., 0., 0., 0, "ONLY",tpar,3);
1229
1230      tpar[2] = 0.4;
1231      tpar[0] = (kXMC1MAX-kXMC1MED)/2.;
1232      tpar[1] = kYMC1MIN;
1233
1234      gMC->Gsposp("CC1A", 1, "CM11",kXMC1A,kYMC1Am,kZMCm, 0, "ONLY", tpar, 3);
1235      gMC->Gsposp("CC1A", 2, "CM11",-kXMC1A,kYMC1Ap,kZMCp, 0, "ONLY", tpar, 3);
1236      
1237 //  chamber type B    
1238      Float_t tpar1save=tpar[1];
1239      Float_t y1msave=kYMC1Am;
1240      Float_t y1psave=kYMC1Ap;
1241  
1242      tpar[0] = (kXMC1MAX-kXMC1MIN)/2.;
1243      tpar[1] = (kYMC1MAX-kYMC1MIN)/2.;
1244      
1245      const Float_t kXMC1B=kXMC1MIN+tpar[0];
1246      const Float_t kYMC1Bp=(y1msave+tpar1save)*zpm+tpar[1];
1247      const Float_t kYMC1Bm=(y1psave+tpar1save)*zmp+tpar[1];
1248
1249      gMC->Gsposp("CC1A", 3, "CM11",kXMC1B,kYMC1Bp,kZMCp, 0, "ONLY", tpar, 3);
1250      gMC->Gsposp("CC1A", 4, "CM11",-kXMC1B,kYMC1Bm,kZMCm, 0, "ONLY", tpar, 3);
1251      gMC->Gsposp("CC1A", 5, "CM11",kXMC1B,-kYMC1Bp,kZMCp, 0, "ONLY", tpar, 3);
1252      gMC->Gsposp("CC1A", 6, "CM11",-kXMC1B,-kYMC1Bm,kZMCm, 0, "ONLY", tpar, 3);
1253      
1254 //  chamber type C  (end of type B !!)      
1255      tpar1save=tpar[1];
1256      y1msave=kYMC1Bm;
1257      y1psave=kYMC1Bp;
1258
1259      tpar[0] = kXMC1MAX/2;
1260      tpar[1] = kYMC1MAX/2;
1261      
1262      const Float_t kXMC1C=tpar[0];
1263 // warning : same Z than type B
1264      const Float_t kYMC1Cp=(y1psave+tpar1save)*1.+tpar[1];
1265      const Float_t kYMC1Cm=(y1msave+tpar1save)*1.+tpar[1];
1266      
1267      gMC->Gsposp("CC1A", 7, "CM11",kXMC1C,kYMC1Cp,kZMCp, 0, "ONLY", tpar, 3);
1268      gMC->Gsposp("CC1A", 8, "CM11",-kXMC1C,kYMC1Cm,kZMCm, 0, "ONLY", tpar, 3);
1269      gMC->Gsposp("CC1A", 9, "CM11",kXMC1C,-kYMC1Cp,kZMCp, 0, "ONLY", tpar, 3);
1270      gMC->Gsposp("CC1A", 10, "CM11",-kXMC1C,-kYMC1Cm,kZMCm, 0, "ONLY", tpar, 3);
1271      
1272 //  chamber type D, E and F (same size)        
1273      tpar1save=tpar[1];
1274      y1msave=kYMC1Cm;
1275      y1psave=kYMC1Cp;
1276
1277      tpar[0] = kXMC1MAX/2.;
1278      tpar[1] = kYMC1MIN;
1279      
1280      const Float_t kXMC1D=tpar[0];
1281      const Float_t kYMC1Dp=(y1msave+tpar1save)*zpm+tpar[1];
1282      const Float_t kYMC1Dm=(y1psave+tpar1save)*zmp+tpar[1];
1283      
1284      gMC->Gsposp("CC1A", 11, "CM11",kXMC1D,kYMC1Dm,kZMCm, 0, "ONLY", tpar, 3);
1285      gMC->Gsposp("CC1A", 12, "CM11",-kXMC1D,kYMC1Dp,kZMCp, 0, "ONLY", tpar, 3);
1286      gMC->Gsposp("CC1A", 13, "CM11",kXMC1D,-kYMC1Dm,kZMCm, 0, "ONLY", tpar, 3);
1287      gMC->Gsposp("CC1A", 14, "CM11",-kXMC1D,-kYMC1Dp,kZMCp, 0, "ONLY", tpar, 3);
1288
1289
1290      tpar1save=tpar[1];
1291      y1msave=kYMC1Dm;
1292      y1psave=kYMC1Dp;
1293      const Float_t kYMC1Ep=(y1msave+tpar1save)*zpm+tpar[1];
1294      const Float_t kYMC1Em=(y1psave+tpar1save)*zmp+tpar[1];
1295      
1296      gMC->Gsposp("CC1A", 15, "CM11",kXMC1D,kYMC1Ep,kZMCp, 0, "ONLY", tpar, 3);
1297      gMC->Gsposp("CC1A", 16, "CM11",-kXMC1D,kYMC1Em,kZMCm, 0, "ONLY", tpar, 3);
1298      gMC->Gsposp("CC1A", 17, "CM11",kXMC1D,-kYMC1Ep,kZMCp, 0, "ONLY", tpar, 3);
1299      gMC->Gsposp("CC1A", 18, "CM11",-kXMC1D,-kYMC1Em,kZMCm, 0, "ONLY", tpar, 3);
1300
1301      tpar1save=tpar[1];
1302      y1msave=kYMC1Em;
1303      y1psave=kYMC1Ep;
1304      const Float_t kYMC1Fp=(y1msave+tpar1save)*zpm+tpar[1];
1305      const Float_t kYMC1Fm=(y1psave+tpar1save)*zmp+tpar[1];
1306     
1307      gMC->Gsposp("CC1A", 19, "CM11",kXMC1D,kYMC1Fm,kZMCm, 0, "ONLY", tpar, 3);
1308      gMC->Gsposp("CC1A", 20, "CM11",-kXMC1D,kYMC1Fp,kZMCp, 0, "ONLY", tpar, 3);
1309      gMC->Gsposp("CC1A", 21, "CM11",kXMC1D,-kYMC1Fm,kZMCm, 0, "ONLY", tpar, 3);
1310      gMC->Gsposp("CC1A", 22, "CM11",-kXMC1D,-kYMC1Fp,kZMCp, 0, "ONLY", tpar, 3);
1311
1312 // Positioning first plane in ALICE     
1313      gMC->Gspos("CM11", 1, "ALIC", 0., 0., zpos1, 0, "ONLY");
1314
1315 // End of geometry definition for the first plane of station 1
1316
1317
1318
1319 // SECOND PLANE OF STATION 1 : proj ratio = zpos2/zpos1
1320
1321      const Float_t kZ12=zpos2/zpos1;
1322       
1323 // Definition of prototype for chambers in the second plane of station 1    
1324           
1325      tpar[0]= 0.;
1326      tpar[1]= 0.;
1327      tpar[2]= 0.;
1328           
1329      gMC->Gsvolu("CC2A", "BOX ", idAlu1, tpar, 0);           //Al    
1330      gMC->Gsvolu("CB2A", "BOX ", idtmed[1107], tpar, 0);     //Bakelite 
1331      gMC->Gsvolu("CG2A", "BOX ", idtmed[1106], tpar, 0);     //Gas streamer
1332
1333 // chamber type A
1334      tpar[0] = -1.;
1335      tpar[1] = -1.;
1336      
1337      const Float_t kXMC2A=kXMC1A*kZ12;
1338      const Float_t kYMC2Am=0.;
1339      const Float_t kYMC2Ap=0.;
1340           
1341      tpar[2] = 0.1;    
1342      gMC->Gsposp("CG2A", 1, "CB2A", 0., 0., 0., 0, "ONLY",tpar,3);
1343      tpar[2] = 0.3;
1344      gMC->Gsposp("CB2A", 1, "CC2A", 0., 0., 0., 0, "ONLY",tpar,3);
1345
1346      tpar[2] = 0.4;
1347      tpar[0] = ((kXMC1MAX-kXMC1MED)/2.)*kZ12;
1348      tpar[1] = kYMC1MIN*kZ12;
1349
1350      gMC->Gsposp("CC2A", 1, "CM12",kXMC2A,kYMC2Am,kZMCm, 0, "ONLY", tpar, 3);
1351      gMC->Gsposp("CC2A", 2, "CM12",-kXMC2A,kYMC2Ap,kZMCp, 0, "ONLY", tpar, 3);
1352      
1353
1354 //  chamber type B    
1355
1356      tpar[0] = ((kXMC1MAX-kXMC1MIN)/2.)*kZ12;
1357      tpar[1] = ((kYMC1MAX-kYMC1MIN)/2.)*kZ12;
1358      
1359      const Float_t kXMC2B=kXMC1B*kZ12;
1360      const Float_t kYMC2Bp=kYMC1Bp*kZ12;
1361      const Float_t kYMC2Bm=kYMC1Bm*kZ12;
1362      gMC->Gsposp("CC2A", 3, "CM12",kXMC2B,kYMC2Bp,kZMCp, 0, "ONLY", tpar, 3);
1363      gMC->Gsposp("CC2A", 4, "CM12",-kXMC2B,kYMC2Bm,kZMCm, 0, "ONLY", tpar, 3);
1364      gMC->Gsposp("CC2A", 5, "CM12",kXMC2B,-kYMC2Bp,kZMCp, 0, "ONLY", tpar, 3);
1365      gMC->Gsposp("CC2A", 6, "CM12",-kXMC2B,-kYMC2Bm,kZMCm, 0, "ONLY", tpar, 3);
1366
1367      
1368 //  chamber type C   (end of type B !!)     
1369
1370      tpar[0] = (kXMC1MAX/2)*kZ12;
1371      tpar[1] = (kYMC1MAX/2)*kZ12;
1372      
1373      const Float_t kXMC2C=kXMC1C*kZ12;
1374      const Float_t kYMC2Cp=kYMC1Cp*kZ12;
1375      const Float_t kYMC2Cm=kYMC1Cm*kZ12;     
1376      gMC->Gsposp("CC2A", 7, "CM12",kXMC2C,kYMC2Cp,kZMCp, 0, "ONLY", tpar, 3);
1377      gMC->Gsposp("CC2A", 8, "CM12",-kXMC2C,kYMC2Cm,kZMCm, 0, "ONLY", tpar, 3);
1378      gMC->Gsposp("CC2A", 9, "CM12",kXMC2C,-kYMC2Cp,kZMCp, 0, "ONLY", tpar, 3);
1379      gMC->Gsposp("CC2A", 10, "CM12",-kXMC2C,-kYMC2Cm,kZMCm, 0, "ONLY", tpar, 3);
1380      
1381 //  chamber type D, E and F (same size)        
1382
1383      tpar[0] = (kXMC1MAX/2.)*kZ12;
1384      tpar[1] = kYMC1MIN*kZ12;
1385      
1386      const Float_t kXMC2D=kXMC1D*kZ12;
1387      const Float_t kYMC2Dp=kYMC1Dp*kZ12;
1388      const Float_t kYMC2Dm=kYMC1Dm*kZ12;     
1389      gMC->Gsposp("CC2A", 11, "CM12",kXMC2D,kYMC2Dm,kZMCm, 0, "ONLY", tpar, 3);
1390      gMC->Gsposp("CC2A", 12, "CM12",-kXMC2D,kYMC2Dp,kZMCp, 0, "ONLY", tpar, 3);
1391      gMC->Gsposp("CC2A", 13, "CM12",kXMC2D,-kYMC2Dm,kZMCm, 0, "ONLY", tpar, 3);
1392      gMC->Gsposp("CC2A", 14, "CM12",-kXMC2D,-kYMC2Dp,kZMCp, 0, "ONLY", tpar, 3);
1393
1394      const Float_t kYMC2Ep=kYMC1Ep*kZ12;
1395      const Float_t kYMC2Em=kYMC1Em*kZ12;
1396      gMC->Gsposp("CC2A", 15, "CM12",kXMC2D,kYMC2Ep,kZMCp, 0, "ONLY", tpar, 3);
1397      gMC->Gsposp("CC2A", 16, "CM12",-kXMC2D,kYMC2Em,kZMCm, 0, "ONLY", tpar, 3);
1398      gMC->Gsposp("CC2A", 17, "CM12",kXMC2D,-kYMC2Ep,kZMCp, 0, "ONLY", tpar, 3);
1399      gMC->Gsposp("CC2A", 18, "CM12",-kXMC2D,-kYMC2Em,kZMCm, 0, "ONLY", tpar, 3);
1400
1401
1402      const Float_t kYMC2Fp=kYMC1Fp*kZ12;
1403      const Float_t kYMC2Fm=kYMC1Fm*kZ12;
1404      gMC->Gsposp("CC2A", 19, "CM12",kXMC2D,kYMC2Fm,kZMCm, 0, "ONLY", tpar, 3);
1405      gMC->Gsposp("CC2A", 20, "CM12",-kXMC2D,kYMC2Fp,kZMCp, 0, "ONLY", tpar, 3);
1406      gMC->Gsposp("CC2A", 21, "CM12",kXMC2D,-kYMC2Fm,kZMCm, 0, "ONLY", tpar, 3);
1407      gMC->Gsposp("CC2A", 22, "CM12",-kXMC2D,-kYMC2Fp,kZMCp, 0, "ONLY", tpar, 3);
1408
1409 // Positioning second plane of station 1 in ALICE     
1410      
1411      gMC->Gspos("CM12", 1, "ALIC", 0., 0., zpos2, 0, "ONLY");
1412
1413 // End of geometry definition for the second plane of station 1
1414
1415
1416
1417 // TRIGGER STATION 2 - TRIGGER STATION 2 - TRIGGER STATION 2    
1418
1419      // 03/00 
1420      // zpos3 and zpos4 are now the middle of the first and second
1421      // plane of station 2 : 
1422      // zpos3=(17075+16995)/2=17035 mm, thick/2=40 mm
1423      // zpos4=(17225+17145)/2=17185 mm, thick/2=40 mm
1424      //
1425      // zpos3m=16999 mm , zpos3p=17071 mm (middles of gas gaps)
1426      // zpos4m=17149 mm , zpos4p=17221 mm (middles of gas gaps)
1427      // rem : the total thickness accounts for 1 mm of al on both 
1428      // side of the RPCs (see zpos3 and zpos4), as previously
1429      iChamber1 = iChamber = (AliMUONChamber*) (*fChambers)[12];
1430      iChamber2 =(AliMUONChamber*) (*fChambers)[13];
1431      Float_t zpos3=iChamber1->Z();
1432      Float_t zpos4=iChamber2->Z();
1433
1434
1435 // Mother volume definition     
1436      tpar[0] = iChamber->RInner(); 
1437      tpar[1] = iChamber->ROuter();
1438      tpar[2] = 4.0;    
1439  
1440      gMC->Gsvolu("CM21", "TUBE", idAir, tpar, 3);
1441      gMC->Gsvolu("CM22", "TUBE", idAir, tpar, 3);
1442      
1443 // Definition of the flange between the beam shielding and the RPC 
1444 //  ???? interface shielding
1445
1446      tpar[0]= kRMIN2;
1447      tpar[1]= kRMAX2;
1448      tpar[2]= 4.0;
1449    
1450      gMC->Gsvolu("CF2A", "TUBE", idAlu1, tpar, 3);            //Al
1451      gMC->Gspos("CF2A", 1, "CM21", 0., 0., 0., 0, "MANY");
1452      gMC->Gspos("CF2A", 2, "CM22", 0., 0., 0., 0, "MANY");
1453     
1454
1455
1456 // FIRST PLANE OF STATION 2 : proj ratio = zpos3/zpos1
1457
1458      const Float_t kZ13=zpos3/zpos1; 
1459
1460 // Definition of prototype for chambers in the first plane of station 2       
1461      tpar[0]= 0.;
1462      tpar[1]= 0.;
1463      tpar[2]= 0.;
1464           
1465      gMC->Gsvolu("CC3A", "BOX ", idAlu1, tpar, 0);           //Al  
1466      gMC->Gsvolu("CB3A", "BOX ", idtmed[1107], tpar, 0);     //Bakelite 
1467      gMC->Gsvolu("CG3A", "BOX ", idtmed[1106], tpar, 0);     //Gas streamer
1468
1469
1470 // chamber type A
1471      tpar[0] = -1.;
1472      tpar[1] = -1.;
1473      
1474      const Float_t kXMC3A=kXMC1A*kZ13;
1475      const Float_t kYMC3Am=0.;
1476      const Float_t kYMC3Ap=0.;
1477           
1478      tpar[2] = 0.1;    
1479      gMC->Gsposp("CG3A", 1, "CB3A", 0., 0., 0., 0, "ONLY",tpar,3);
1480      tpar[2] = 0.3;
1481      gMC->Gsposp("CB3A", 1, "CC3A", 0., 0., 0., 0, "ONLY",tpar,3);
1482
1483      tpar[2] = 0.4;
1484      tpar[0] = ((kXMC1MAX-kXMC1MED)/2.)*kZ13;
1485      tpar[1] = kYMC1MIN*kZ13;
1486      gMC->Gsposp("CC3A", 1, "CM21",kXMC3A,kYMC3Am,kZMCm, 0, "ONLY", tpar, 3);
1487      gMC->Gsposp("CC3A", 2, "CM21",-kXMC3A,kYMC3Ap,kZMCp, 0, "ONLY", tpar, 3);
1488
1489      
1490 //  chamber type B    
1491      tpar[0] = ((kXMC1MAX-kXMC1MIN)/2.)*kZ13;
1492      tpar[1] = ((kYMC1MAX-kYMC1MIN)/2.)*kZ13;
1493      
1494      const Float_t kXMC3B=kXMC1B*kZ13;
1495      const Float_t kYMC3Bp=kYMC1Bp*kZ13;
1496      const Float_t kYMC3Bm=kYMC1Bm*kZ13;
1497      gMC->Gsposp("CC3A", 3, "CM21",kXMC3B,kYMC3Bp,kZMCp, 0, "ONLY", tpar, 3);
1498      gMC->Gsposp("CC3A", 4, "CM21",-kXMC3B,kYMC3Bm,kZMCm, 0, "ONLY", tpar, 3);
1499      gMC->Gsposp("CC3A", 5, "CM21",kXMC3B,-kYMC3Bp,kZMCp, 0, "ONLY", tpar, 3);
1500      gMC->Gsposp("CC3A", 6, "CM21",-kXMC3B,-kYMC3Bm,kZMCm, 0, "ONLY", tpar, 3);
1501
1502      
1503 //  chamber type C  (end of type B !!)      
1504      tpar[0] = (kXMC1MAX/2)*kZ13;
1505      tpar[1] = (kYMC1MAX/2)*kZ13;
1506      
1507      const Float_t kXMC3C=kXMC1C*kZ13;
1508      const Float_t kYMC3Cp=kYMC1Cp*kZ13;
1509      const Float_t kYMC3Cm=kYMC1Cm*kZ13;     
1510      gMC->Gsposp("CC3A", 7, "CM21",kXMC3C,kYMC3Cp,kZMCp, 0, "ONLY", tpar, 3);
1511      gMC->Gsposp("CC3A", 8, "CM21",-kXMC3C,kYMC3Cm,kZMCm, 0, "ONLY", tpar, 3);
1512      gMC->Gsposp("CC3A", 9, "CM21",kXMC3C,-kYMC3Cp,kZMCp, 0, "ONLY", tpar, 3);
1513      gMC->Gsposp("CC3A", 10, "CM21",-kXMC3C,-kYMC3Cm,kZMCm, 0, "ONLY", tpar, 3);
1514      
1515
1516 //  chamber type D, E and F (same size)         
1517
1518      tpar[0] = (kXMC1MAX/2.)*kZ13;
1519      tpar[1] = kYMC1MIN*kZ13;
1520      
1521      const Float_t kXMC3D=kXMC1D*kZ13;
1522      const Float_t kYMC3Dp=kYMC1Dp*kZ13;
1523      const Float_t kYMC3Dm=kYMC1Dm*kZ13;          
1524      gMC->Gsposp("CC3A", 11, "CM21",kXMC3D,kYMC3Dm,kZMCm, 0, "ONLY", tpar, 3);
1525      gMC->Gsposp("CC3A", 12, "CM21",-kXMC3D,kYMC3Dp,kZMCp, 0, "ONLY", tpar, 3);
1526      gMC->Gsposp("CC3A", 13, "CM21",kXMC3D,-kYMC3Dm,kZMCm, 0, "ONLY", tpar, 3);
1527      gMC->Gsposp("CC3A", 14, "CM21",-kXMC3D,-kYMC3Dp,kZMCp, 0, "ONLY", tpar, 3);
1528
1529      const Float_t kYMC3Ep=kYMC1Ep*kZ13;
1530      const Float_t kYMC3Em=kYMC1Em*kZ13;
1531      gMC->Gsposp("CC3A", 15, "CM21",kXMC3D,kYMC3Ep,kZMCp, 0, "ONLY", tpar, 3);
1532      gMC->Gsposp("CC3A", 16, "CM21",-kXMC3D,kYMC3Em,kZMCm, 0, "ONLY", tpar, 3);
1533      gMC->Gsposp("CC3A", 17, "CM21",kXMC3D,-kYMC3Ep,kZMCp, 0, "ONLY", tpar, 3);
1534      gMC->Gsposp("CC3A", 18, "CM21",-kXMC3D,-kYMC3Em,kZMCm, 0, "ONLY", tpar, 3);
1535
1536      const Float_t kYMC3Fp=kYMC1Fp*kZ13;
1537      const Float_t kYMC3Fm=kYMC1Fm*kZ13;
1538      gMC->Gsposp("CC3A", 19, "CM21",kXMC3D,kYMC3Fm,kZMCm, 0, "ONLY", tpar, 3);
1539      gMC->Gsposp("CC3A", 20, "CM21",-kXMC3D,kYMC3Fp,kZMCp, 0, "ONLY", tpar, 3);
1540      gMC->Gsposp("CC3A", 21, "CM21",kXMC3D,-kYMC3Fm,kZMCm, 0, "ONLY", tpar, 3);
1541      gMC->Gsposp("CC3A", 22, "CM21",-kXMC3D,-kYMC3Fp,kZMCp, 0, "ONLY", tpar, 3);
1542        
1543
1544 // Positioning first plane of station 2 in ALICE
1545      
1546      gMC->Gspos("CM21", 1, "ALIC", 0., 0., zpos3, 0, "ONLY");
1547
1548 // End of geometry definition for the first plane of station 2
1549
1550
1551
1552
1553 // SECOND PLANE OF STATION 2 : proj ratio = zpos4/zpos1
1554
1555      const Float_t kZ14=zpos4/zpos1;
1556      
1557 // Definition of prototype for chambers in the second plane of station 2    
1558           
1559      tpar[0]= 0.;
1560      tpar[1]= 0.;
1561      tpar[2]= 0.;
1562           
1563      gMC->Gsvolu("CC4A", "BOX ", idAlu1, tpar, 0);           //Al      
1564      gMC->Gsvolu("CB4A", "BOX ", idtmed[1107], tpar, 0);     //Bakelite 
1565      gMC->Gsvolu("CG4A", "BOX ", idtmed[1106], tpar, 0);     //Gas streamer
1566
1567 // chamber type A
1568      tpar[0] = -1.;
1569      tpar[1] = -1.;
1570      
1571      const Float_t kXMC4A=kXMC1A*kZ14;
1572      const Float_t kYMC4Am=0.;
1573      const Float_t kYMC4Ap=0.;
1574           
1575      tpar[2] = 0.1;    
1576      gMC->Gsposp("CG4A", 1, "CB4A", 0., 0., 0., 0, "ONLY",tpar,3);
1577      tpar[2] = 0.3;
1578      gMC->Gsposp("CB4A", 1, "CC4A", 0., 0., 0., 0, "ONLY",tpar,3);
1579
1580      tpar[2] = 0.4;
1581      tpar[0] = ((kXMC1MAX-kXMC1MED)/2.)*kZ14;
1582      tpar[1] = kYMC1MIN*kZ14;
1583      gMC->Gsposp("CC4A", 1, "CM22",kXMC4A,kYMC4Am,kZMCm, 0, "ONLY", tpar, 3);
1584      gMC->Gsposp("CC4A", 2, "CM22",-kXMC4A,kYMC4Ap,kZMCp, 0, "ONLY", tpar, 3);
1585      
1586
1587 //  chamber type B    
1588      tpar[0] = ((kXMC1MAX-kXMC1MIN)/2.)*kZ14;
1589      tpar[1] = ((kYMC1MAX-kYMC1MIN)/2.)*kZ14;
1590      
1591      const Float_t kXMC4B=kXMC1B*kZ14;
1592      const Float_t kYMC4Bp=kYMC1Bp*kZ14;
1593      const Float_t kYMC4Bm=kYMC1Bm*kZ14;
1594      gMC->Gsposp("CC4A", 3, "CM22",kXMC4B,kYMC4Bp,kZMCp, 0, "ONLY", tpar, 3);
1595      gMC->Gsposp("CC4A", 4, "CM22",-kXMC4B,kYMC4Bm,kZMCm, 0, "ONLY", tpar, 3);
1596      gMC->Gsposp("CC4A", 5, "CM22",kXMC4B,-kYMC4Bp,kZMCp, 0, "ONLY", tpar, 3);
1597      gMC->Gsposp("CC4A", 6, "CM22",-kXMC4B,-kYMC4Bm,kZMCm, 0, "ONLY", tpar, 3);
1598
1599      
1600 //  chamber type C   (end of type B !!)      
1601      tpar[0] =(kXMC1MAX/2)*kZ14;
1602      tpar[1] =  (kYMC1MAX/2)*kZ14;
1603      
1604      const Float_t kXMC4C=kXMC1C*kZ14;
1605      const Float_t kYMC4Cp=kYMC1Cp*kZ14;
1606      const Float_t kYMC4Cm=kYMC1Cm*kZ14;     
1607      gMC->Gsposp("CC4A", 7, "CM22",kXMC4C,kYMC4Cp,kZMCp, 0, "ONLY", tpar, 3);
1608      gMC->Gsposp("CC4A", 8, "CM22",-kXMC4C,kYMC4Cm,kZMCm, 0, "ONLY", tpar, 3);
1609      gMC->Gsposp("CC4A", 9, "CM22",kXMC4C,-kYMC4Cp,kZMCp, 0, "ONLY", tpar, 3);
1610      gMC->Gsposp("CC4A", 10, "CM22",-kXMC4C,-kYMC4Cm,kZMCm, 0, "ONLY", tpar, 3);
1611
1612      
1613 //  chamber type D, E and F (same size)      
1614      tpar[0] = (kXMC1MAX/2.)*kZ14;
1615      tpar[1] =  kYMC1MIN*kZ14;
1616      
1617      const Float_t kXMC4D=kXMC1D*kZ14;
1618      const Float_t kYMC4Dp=kYMC1Dp*kZ14;
1619      const Float_t kYMC4Dm=kYMC1Dm*kZ14;          
1620      gMC->Gsposp("CC4A", 11, "CM22",kXMC4D,kYMC4Dm,kZMCm, 0, "ONLY", tpar, 3);
1621      gMC->Gsposp("CC4A", 12, "CM22",-kXMC4D,kYMC4Dp,kZMCp, 0, "ONLY", tpar, 3);
1622      gMC->Gsposp("CC4A", 13, "CM22",kXMC4D,-kYMC4Dm,kZMCm, 0, "ONLY", tpar, 3);
1623      gMC->Gsposp("CC4A", 14, "CM22",-kXMC4D,-kYMC4Dp,kZMCp, 0, "ONLY", tpar, 3);
1624
1625      const Float_t kYMC4Ep=kYMC1Ep*kZ14;
1626      const Float_t kYMC4Em=kYMC1Em*kZ14;          
1627      gMC->Gsposp("CC4A", 15, "CM22",kXMC4D,kYMC4Ep,kZMCp, 0, "ONLY", tpar, 3);
1628      gMC->Gsposp("CC4A", 16, "CM22",-kXMC4D,kYMC4Em,kZMCm, 0, "ONLY", tpar, 3);
1629      gMC->Gsposp("CC4A", 17, "CM22",kXMC4D,-kYMC4Ep,kZMCp, 0, "ONLY", tpar, 3);
1630      gMC->Gsposp("CC4A", 18, "CM22",-kXMC4D,-kYMC4Em,kZMCm, 0, "ONLY", tpar, 3);
1631
1632      const Float_t kYMC4Fp=kYMC1Fp*kZ14;
1633      const Float_t kYMC4Fm=kYMC1Fm*kZ14;          
1634      gMC->Gsposp("CC4A", 19, "CM22",kXMC4D,kYMC4Fm,kZMCm, 0, "ONLY", tpar, 3);
1635      gMC->Gsposp("CC4A", 20, "CM22",-kXMC4D,kYMC4Fp,kZMCp, 0, "ONLY", tpar, 3);
1636      gMC->Gsposp("CC4A", 21, "CM22",kXMC4D,-kYMC4Fm,kZMCm, 0, "ONLY", tpar, 3);
1637      gMC->Gsposp("CC4A", 22, "CM22",-kXMC4D,-kYMC4Fp,kZMCp, 0, "ONLY", tpar, 3);
1638      
1639
1640 // Positioning second plane of station 2 in ALICE
1641      
1642      gMC->Gspos("CM22", 1, "ALIC", 0., 0., zpos4, 0, "ONLY");
1643
1644 // End of geometry definition for the second plane of station 2
1645
1646 // End of trigger geometry definition
1647
1648 }