2c0d3390be0c66633e3097f9c6caba2a0b59be18
[u/mrichter/AliRoot.git] / MUON / AliMUONv1.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.14  2000/11/06 09:16:50  morsch
19 Avoid overlap of slat volumes.
20
21 Revision 1.13  2000/10/26 07:33:44  morsch
22 Correct x-position of slats in station 5.
23
24 Revision 1.12  2000/10/25 19:55:35  morsch
25 Switches for each station individually for debug and lego.
26
27 Revision 1.11  2000/10/22 16:44:01  morsch
28 Update of slat geometry for stations 3,4,5 (A. deFalco)
29
30 Revision 1.10  2000/10/12 16:07:04  gosset
31 StepManager:
32 * SigGenCond only called for tracking chambers,
33   hence no more division by 0,
34   and may use last ALIROOT/dummies.C with exception handling;
35 * "10" replaced by "AliMUONConstants::NTrackingCh()".
36
37 Revision 1.9  2000/10/06 15:37:22  morsch
38 Problems with variable redefinition in for-loop solved.
39 Variable names starting with u-case letters changed to l-case.
40
41 Revision 1.8  2000/10/06 09:06:31  morsch
42 Include Slat chambers (stations 3-5) into geometry (A. de Falco)
43
44 Revision 1.7  2000/10/02 21:28:09  fca
45 Removal of useless dependecies via forward declarations
46
47 Revision 1.6  2000/10/02 17:20:45  egangler
48 Cleaning of the code (continued ) :
49 -> coding conventions
50 -> void Streamers
51 -> some useless includes removed or replaced by "class" statement
52
53 Revision 1.5  2000/06/28 15:16:35  morsch
54 (1) Client code adapted to new method signatures in AliMUONSegmentation (see comments there)
55 to allow development of slat-muon chamber simulation and reconstruction code in the MUON
56 framework. The changes should have no side effects (mostly dummy arguments).
57 (2) Hit disintegration uses 3-dim hit coordinates to allow simulation
58 of chambers with overlapping modules (MakePadHits, Disintegration).
59
60 Revision 1.4  2000/06/26 14:02:38  morsch
61 Add class AliMUONConstants with MUON specific constants using static memeber data and access methods.
62
63 Revision 1.3  2000/06/22 14:10:05  morsch
64 HP scope problems corrected (PH)
65
66 Revision 1.2  2000/06/15 07:58:49  morsch
67 Code from MUON-dev joined
68
69 Revision 1.1.2.14  2000/06/14 14:37:25  morsch
70 Initialization of TriggerCircuit added (PC)
71
72 Revision 1.1.2.13  2000/06/09 21:55:47  morsch
73 Most coding rule violations corrected.
74
75 Revision 1.1.2.12  2000/05/05 11:34:29  morsch
76 Log inside comments.
77
78 Revision 1.1.2.11  2000/05/05 10:06:48  morsch
79 Coding Rule violations regarding trigger section corrected (CP)
80 Log messages included.
81 */
82
83 /////////////////////////////////////////////////////////
84 //  Manager and hits classes for set:MUON version 0    //
85 /////////////////////////////////////////////////////////
86
87 #include <TTUBE.h>
88 #include <TNode.h> 
89 #include <TRandom.h> 
90 #include <TLorentzVector.h> 
91 #include <iostream.h>
92
93 #include "AliMUONv1.h"
94 #include "AliRun.h"
95 #include "AliMC.h"
96 #include "AliMagF.h"
97 #include "AliCallf77.h"
98 #include "AliConst.h" 
99 #include "AliMUONChamber.h"
100 #include "AliMUONHit.h"
101 #include "AliMUONPadHit.h"
102 #include "AliMUONConstants.h"
103 #include "AliMUONTriggerCircuit.h"
104
105 ClassImp(AliMUONv1)
106  
107 //___________________________________________
108 AliMUONv1::AliMUONv1() : AliMUON()
109 {
110 // Constructor
111     fChambers = 0;
112 }
113  
114 //___________________________________________
115 AliMUONv1::AliMUONv1(const char *name, const char *title)
116        : AliMUON(name,title)
117 {
118 // Constructor
119 }
120
121 //___________________________________________
122 void AliMUONv1::CreateGeometry()
123 {
124 //
125 //   Note: all chambers have the same structure, which could be 
126 //   easily parameterised. This was intentionally not done in order
127 //   to give a starting point for the implementation of the actual 
128 //   design of each station. 
129   Int_t *idtmed = fIdtmed->GetArray()-1099;
130
131 //   Distance between Stations
132 //
133      Float_t bpar[3];
134      Float_t tpar[3];
135      Float_t pgpar[10];
136      Float_t zpos1, zpos2, zfpos;
137      Float_t dframep=.001; // Value for station 3 should be 6 ...
138      Float_t dframep1=.001;
139 //     Bool_t frames=kTRUE;
140      Bool_t frames=kFALSE;     
141      
142      Float_t dframez=0.9;
143      Float_t dr;
144      Float_t dstation;
145
146 //
147 //   Rotation matrices in the x-y plane  
148      Int_t idrotm[1199];
149 //   phi=   0 deg
150      AliMatrix(idrotm[1100],  90.,   0., 90.,  90., 0., 0.);
151 //   phi=  90 deg
152      AliMatrix(idrotm[1101],  90.,  90., 90., 180., 0., 0.);
153 //   phi= 180 deg
154      AliMatrix(idrotm[1102],  90., 180., 90., 270., 0., 0.);
155 //   phi= 270 deg
156      AliMatrix(idrotm[1103],  90., 270., 90.,   0., 0., 0.);
157 //
158      Float_t phi=2*TMath::Pi()/12/2;
159
160 //
161 //   pointer to the current chamber
162 //   pointer to the current chamber
163      Int_t idAlu1=idtmed[1103];
164      Int_t idAlu2=idtmed[1104];
165 //     Int_t idAlu1=idtmed[1100];
166 //     Int_t idAlu2=idtmed[1100];
167      Int_t idAir=idtmed[1100];
168      Int_t idGas=idtmed[1105];
169      
170
171      AliMUONChamber *iChamber, *iChamber1, *iChamber2;
172      Int_t stations[5] = {1, 1, 1, 1, 1};
173      
174      if (stations[0]) {
175          
176 //********************************************************************
177 //                            Station 1                             **
178 //********************************************************************
179 //  CONCENTRIC
180      // indices 1 and 2 for first and second chambers in the station
181      // iChamber (first chamber) kept for other quanties than Z,
182      // assumed to be the same in both chambers
183      iChamber1 = iChamber = (AliMUONChamber*) (*fChambers)[0];
184      iChamber2 =(AliMUONChamber*) (*fChambers)[1];
185      zpos1=iChamber1->Z(); 
186      zpos2=iChamber2->Z();
187      dstation = zpos2 - zpos1;
188      zfpos=-(iChamber->DGas()+dframez+iChamber->DAlu())/2;
189      
190 //
191 //   Mother volume
192      tpar[0] = iChamber->RInner()-dframep1; 
193      tpar[1] = (iChamber->ROuter()+dframep1)/TMath::Cos(phi);
194      tpar[2] = dstation/5;
195
196      gMC->Gsvolu("C01M", "TUBE", idAir, tpar, 3);
197      gMC->Gsvolu("C02M", "TUBE", idAir, tpar, 3);
198      gMC->Gspos("C01M", 1, "ALIC", 0., 0., zpos1 , 0, "ONLY");
199      gMC->Gspos("C02M", 1, "ALIC", 0., 0., zpos2 , 0, "ONLY");     
200 // Aluminium frames
201 // Outer frames
202      pgpar[0] = 360/12/2;
203      pgpar[1] = 360.;
204      pgpar[2] = 12.;
205      pgpar[3] =   2;
206      pgpar[4] = -dframez/2;
207      pgpar[5] = iChamber->ROuter();
208      pgpar[6] = pgpar[5]+dframep1;
209      pgpar[7] = +dframez/2;
210      pgpar[8] = pgpar[5];
211      pgpar[9] = pgpar[6];
212      gMC->Gsvolu("C01O", "PGON", idAlu1, pgpar, 10);
213      gMC->Gsvolu("C02O", "PGON", idAlu1, pgpar, 10);
214      gMC->Gspos("C01O",1,"C01M", 0.,0.,-zfpos,  0,"ONLY");
215      gMC->Gspos("C01O",2,"C01M", 0.,0.,+zfpos,  0,"ONLY");
216      gMC->Gspos("C02O",1,"C02M", 0.,0.,-zfpos,  0,"ONLY");
217      gMC->Gspos("C02O",2,"C02M", 0.,0.,+zfpos,  0,"ONLY");
218 //
219 // Inner frame
220      tpar[0]= iChamber->RInner()-dframep1;
221      tpar[1]= iChamber->RInner();
222      tpar[2]= dframez/2;
223      gMC->Gsvolu("C01I", "TUBE", idAlu1, tpar, 3);
224      gMC->Gsvolu("C02I", "TUBE", idAlu1, tpar, 3);
225
226      gMC->Gspos("C01I",1,"C01M", 0.,0.,-zfpos,  0,"ONLY");
227      gMC->Gspos("C01I",2,"C01M", 0.,0.,+zfpos,  0,"ONLY");
228      gMC->Gspos("C02I",1,"C02M", 0.,0.,-zfpos,  0,"ONLY");
229      gMC->Gspos("C02I",2,"C02M", 0.,0.,+zfpos,  0,"ONLY");
230 //
231 // Frame Crosses
232      if (frames) {
233
234          bpar[0] = (iChamber->ROuter() - iChamber->RInner())/2;
235          bpar[1] = dframep1/2;
236          bpar[2] = dframez/2;
237          gMC->Gsvolu("C01B", "BOX", idAlu1, bpar, 3);
238          gMC->Gsvolu("C02B", "BOX", idAlu1, bpar, 3);
239          
240          gMC->Gspos("C01B",1,"C01M", +iChamber->RInner()+bpar[0] , 0,-zfpos, 
241                     idrotm[1100],"ONLY");
242          gMC->Gspos("C01B",2,"C01M", -iChamber->RInner()-bpar[0] , 0,-zfpos, 
243                     idrotm[1100],"ONLY");
244          gMC->Gspos("C01B",3,"C01M", 0, +iChamber->RInner()+bpar[0] ,-zfpos, 
245                     idrotm[1101],"ONLY");
246          gMC->Gspos("C01B",4,"C01M", 0, -iChamber->RInner()-bpar[0] ,-zfpos, 
247                     idrotm[1101],"ONLY");
248          gMC->Gspos("C01B",5,"C01M", +iChamber->RInner()+bpar[0] , 0,+zfpos, 
249                     idrotm[1100],"ONLY");
250          gMC->Gspos("C01B",6,"C01M", -iChamber->RInner()-bpar[0] , 0,+zfpos, 
251                     idrotm[1100],"ONLY");
252          gMC->Gspos("C01B",7,"C01M", 0, +iChamber->RInner()+bpar[0] ,+zfpos, 
253                     idrotm[1101],"ONLY");
254          gMC->Gspos("C01B",8,"C01M", 0, -iChamber->RInner()-bpar[0] ,+zfpos, 
255                     idrotm[1101],"ONLY");
256          
257          gMC->Gspos("C02B",1,"C02M", +iChamber->RInner()+bpar[0] , 0,-zfpos, 
258                     idrotm[1100],"ONLY");
259          gMC->Gspos("C02B",2,"C02M", -iChamber->RInner()-bpar[0] , 0,-zfpos, 
260                     idrotm[1100],"ONLY");
261          gMC->Gspos("C02B",3,"C02M", 0, +iChamber->RInner()+bpar[0] ,-zfpos, 
262                     idrotm[1101],"ONLY");
263          gMC->Gspos("C02B",4,"C02M", 0, -iChamber->RInner()-bpar[0] ,-zfpos, 
264                     idrotm[1101],"ONLY");
265          gMC->Gspos("C02B",5,"C02M", +iChamber->RInner()+bpar[0] , 0,+zfpos, 
266                     idrotm[1100],"ONLY");
267          gMC->Gspos("C02B",6,"C02M", -iChamber->RInner()-bpar[0] , 0,+zfpos, 
268                     idrotm[1100],"ONLY");
269          gMC->Gspos("C02B",7,"C02M", 0, +iChamber->RInner()+bpar[0] ,+zfpos, 
270                     idrotm[1101],"ONLY");
271          gMC->Gspos("C02B",8,"C02M", 0, -iChamber->RInner()-bpar[0] ,+zfpos, 
272                     idrotm[1101],"ONLY");
273      }
274 //
275 //   Chamber Material represented by Alu sheet
276      tpar[0]= iChamber->RInner();
277      tpar[1]= iChamber->ROuter();
278      tpar[2] = (iChamber->DGas()+iChamber->DAlu())/2;
279      gMC->Gsvolu("C01A", "TUBE",  idAlu2, tpar, 3);
280      gMC->Gsvolu("C02A", "TUBE",idAlu2, tpar, 3);
281      gMC->Gspos("C01A", 1, "C01M", 0., 0., 0.,  0, "ONLY");
282      gMC->Gspos("C02A", 1, "C02M", 0., 0., 0.,  0, "ONLY");
283 //     
284 //   Sensitive volumes
285      // tpar[2] = iChamber->DGas();
286      tpar[2] = iChamber->DGas()/2;
287      gMC->Gsvolu("C01G", "TUBE", idtmed[1108], tpar, 3);
288      gMC->Gsvolu("C02G", "TUBE", idtmed[1108], tpar, 3);
289      gMC->Gspos("C01G", 1, "C01A", 0., 0., 0.,  0, "ONLY");
290      gMC->Gspos("C02G", 1, "C02A", 0., 0., 0.,  0, "ONLY");
291 //
292 // Frame Crosses to be placed inside gas 
293      if (frames) {
294
295          dr = (iChamber->ROuter() - iChamber->RInner());
296          bpar[0] = TMath::Sqrt(dr*dr-dframep1*dframep1/4)/2;
297          bpar[1] = dframep1/2;
298          bpar[2] = iChamber->DGas()/2;
299          gMC->Gsvolu("C01F", "BOX", idAlu1, bpar, 3);
300          gMC->Gsvolu("C02F", "BOX", idAlu1, bpar, 3);
301          
302          gMC->Gspos("C01F",1,"C01G", +iChamber->RInner()+bpar[0] , 0, 0, 
303                     idrotm[1100],"ONLY");
304          gMC->Gspos("C01F",2,"C01G", -iChamber->RInner()-bpar[0] , 0, 0, 
305                     idrotm[1100],"ONLY");
306          gMC->Gspos("C01F",3,"C01G", 0, +iChamber->RInner()+bpar[0] , 0, 
307                     idrotm[1101],"ONLY");
308          gMC->Gspos("C01F",4,"C01G", 0, -iChamber->RInner()-bpar[0] , 0, 
309                     idrotm[1101],"ONLY");
310          
311          gMC->Gspos("C02F",1,"C02G", +iChamber->RInner()+bpar[0] , 0, 0, 
312                     idrotm[1100],"ONLY");
313          gMC->Gspos("C02F",2,"C02G", -iChamber->RInner()-bpar[0] , 0, 0, 
314                     idrotm[1100],"ONLY");
315          gMC->Gspos("C02F",3,"C02G", 0, +iChamber->RInner()+bpar[0] , 0, 
316                     idrotm[1101],"ONLY");
317          gMC->Gspos("C02F",4,"C02G", 0, -iChamber->RInner()-bpar[0] , 0, 
318                     idrotm[1101],"ONLY");
319      }
320      }
321      if (stations[1]) {
322          
323 //********************************************************************
324 //                            Station 2                             **
325 //********************************************************************
326      // indices 1 and 2 for first and second chambers in the station
327      // iChamber (first chamber) kept for other quanties than Z,
328      // assumed to be the same in both chambers
329      iChamber1 = iChamber = (AliMUONChamber*) (*fChambers)[2];
330      iChamber2 =(AliMUONChamber*) (*fChambers)[3];
331      zpos1=iChamber1->Z(); 
332      zpos2=iChamber2->Z();
333      dstation = zpos2 - zpos1;
334      zfpos=-(iChamber->DGas()+dframez+iChamber->DAlu())/2;
335      
336 //
337 //   Mother volume
338      tpar[0] = iChamber->RInner()-dframep; 
339      tpar[1] = (iChamber->ROuter()+dframep)/TMath::Cos(phi);
340      tpar[2] = dstation/5;
341
342      gMC->Gsvolu("C03M", "TUBE", idAir, tpar, 3);
343      gMC->Gsvolu("C04M", "TUBE", idAir, tpar, 3);
344      gMC->Gspos("C03M", 1, "ALIC", 0., 0., zpos1 , 0, "ONLY");
345      gMC->Gspos("C04M", 1, "ALIC", 0., 0., zpos2 , 0, "ONLY");
346
347 // Aluminium frames
348 // Outer frames
349      pgpar[0] = 360/12/2;
350      pgpar[1] = 360.;
351      pgpar[2] = 12.;
352      pgpar[3] =   2;
353      pgpar[4] = -dframez/2;
354      pgpar[5] = iChamber->ROuter();
355      pgpar[6] = pgpar[5]+dframep;
356      pgpar[7] = +dframez/2;
357      pgpar[8] = pgpar[5];
358      pgpar[9] = pgpar[6];
359      gMC->Gsvolu("C03O", "PGON", idAlu1, pgpar, 10);
360      gMC->Gsvolu("C04O", "PGON", idAlu1, pgpar, 10);
361      gMC->Gspos("C03O",1,"C03M", 0.,0.,-zfpos,  0,"ONLY");
362      gMC->Gspos("C03O",2,"C03M", 0.,0.,+zfpos,  0,"ONLY");
363      gMC->Gspos("C04O",1,"C04M", 0.,0.,-zfpos,  0,"ONLY");
364      gMC->Gspos("C04O",2,"C04M", 0.,0.,+zfpos,  0,"ONLY");
365 //
366 // Inner frame
367      tpar[0]= iChamber->RInner()-dframep;
368      tpar[1]= iChamber->RInner();
369      tpar[2]= dframez/2;
370      gMC->Gsvolu("C03I", "TUBE", idAlu1, tpar, 3);
371      gMC->Gsvolu("C04I", "TUBE", idAlu1, tpar, 3);
372
373      gMC->Gspos("C03I",1,"C03M", 0.,0.,-zfpos,  0,"ONLY");
374      gMC->Gspos("C03I",2,"C03M", 0.,0.,+zfpos,  0,"ONLY");
375      gMC->Gspos("C04I",1,"C04M", 0.,0.,-zfpos,  0,"ONLY");
376      gMC->Gspos("C04I",2,"C04M", 0.,0.,+zfpos,  0,"ONLY");
377 //
378 // Frame Crosses
379      if (frames) {
380
381          bpar[0] = (iChamber->ROuter() - iChamber->RInner())/2;
382          bpar[1] = dframep/2;
383          bpar[2] = dframez/2;
384          gMC->Gsvolu("C03B", "BOX", idAlu1, bpar, 3);
385          gMC->Gsvolu("C04B", "BOX", idAlu1, bpar, 3);
386          
387          gMC->Gspos("C03B",1,"C03M", +iChamber->RInner()+bpar[0] , 0,-zfpos, 
388                     idrotm[1100],"ONLY");
389          gMC->Gspos("C03B",2,"C03M", -iChamber->RInner()-bpar[0] , 0,-zfpos, 
390                     idrotm[1100],"ONLY");
391          gMC->Gspos("C03B",3,"C03M", 0, +iChamber->RInner()+bpar[0] ,-zfpos, 
392                     idrotm[1101],"ONLY");
393          gMC->Gspos("C03B",4,"C03M", 0, -iChamber->RInner()-bpar[0] ,-zfpos, 
394                     idrotm[1101],"ONLY");
395          gMC->Gspos("C03B",5,"C03M", +iChamber->RInner()+bpar[0] , 0,+zfpos, 
396                     idrotm[1100],"ONLY");
397          gMC->Gspos("C03B",6,"C03M", -iChamber->RInner()-bpar[0] , 0,+zfpos, 
398                     idrotm[1100],"ONLY");
399          gMC->Gspos("C03B",7,"C03M", 0, +iChamber->RInner()+bpar[0] ,+zfpos, 
400                     idrotm[1101],"ONLY");
401          gMC->Gspos("C03B",8,"C03M", 0, -iChamber->RInner()-bpar[0] ,+zfpos, 
402                     idrotm[1101],"ONLY");
403          
404          gMC->Gspos("C04B",1,"C04M", +iChamber->RInner()+bpar[0] , 0,-zfpos, 
405                     idrotm[1100],"ONLY");
406          gMC->Gspos("C04B",2,"C04M", -iChamber->RInner()-bpar[0] , 0,-zfpos, 
407                     idrotm[1100],"ONLY");
408          gMC->Gspos("C04B",3,"C04M", 0, +iChamber->RInner()+bpar[0] ,-zfpos, 
409                     idrotm[1101],"ONLY");
410          gMC->Gspos("C04B",4,"C04M", 0, -iChamber->RInner()-bpar[0] ,-zfpos, 
411                     idrotm[1101],"ONLY");
412          gMC->Gspos("C04B",5,"C04M", +iChamber->RInner()+bpar[0] , 0,+zfpos, 
413                     idrotm[1100],"ONLY");
414          gMC->Gspos("C04B",6,"C04M", -iChamber->RInner()-bpar[0] , 0,+zfpos, 
415                     idrotm[1100],"ONLY");
416          gMC->Gspos("C04B",7,"C04M", 0, +iChamber->RInner()+bpar[0] ,+zfpos, 
417                     idrotm[1101],"ONLY");
418          gMC->Gspos("C04B",8,"C04M", 0, -iChamber->RInner()-bpar[0] ,+zfpos, 
419                     idrotm[1101],"ONLY");
420      }
421 //
422 //   Chamber Material represented by Alu sheet
423      tpar[0]= iChamber->RInner();
424      tpar[1]= iChamber->ROuter();
425      tpar[2] = (iChamber->DGas()+iChamber->DAlu())/2;
426      gMC->Gsvolu("C03A", "TUBE", idAlu2, tpar, 3);
427      gMC->Gsvolu("C04A", "TUBE", idAlu2, tpar, 3);
428      gMC->Gspos("C03A", 1, "C03M", 0., 0., 0.,  0, "ONLY");
429      gMC->Gspos("C04A", 1, "C04M", 0., 0., 0.,  0, "ONLY");
430 //     
431 //   Sensitive volumes
432      // tpar[2] = iChamber->DGas();
433      tpar[2] = iChamber->DGas()/2;
434      gMC->Gsvolu("C03G", "TUBE", idGas, tpar, 3);
435      gMC->Gsvolu("C04G", "TUBE", idGas, tpar, 3);
436      gMC->Gspos("C03G", 1, "C03A", 0., 0., 0.,  0, "ONLY");
437      gMC->Gspos("C04G", 1, "C04A", 0., 0., 0.,  0, "ONLY");
438
439      if (frames) {
440 //
441 // Frame Crosses to be placed inside gas 
442          dr = (iChamber->ROuter() - iChamber->RInner());
443          bpar[0] = TMath::Sqrt(dr*dr-dframep*dframep/4)/2;
444          bpar[1] = dframep/2;
445          bpar[2] = iChamber->DGas()/2;
446          gMC->Gsvolu("C03F", "BOX", idAlu1, bpar, 3);
447          gMC->Gsvolu("C04F", "BOX", idAlu1, bpar, 3);
448          
449          gMC->Gspos("C03F",1,"C03G", +iChamber->RInner()+bpar[0] , 0, 0, 
450                     idrotm[1100],"ONLY");
451          gMC->Gspos("C03F",2,"C03G", -iChamber->RInner()-bpar[0] , 0, 0, 
452                     idrotm[1100],"ONLY");
453          gMC->Gspos("C03F",3,"C03G", 0, +iChamber->RInner()+bpar[0] , 0, 
454                     idrotm[1101],"ONLY");
455          gMC->Gspos("C03F",4,"C03G", 0, -iChamber->RInner()-bpar[0] , 0, 
456                     idrotm[1101],"ONLY");
457          
458          gMC->Gspos("C04F",1,"C04G", +iChamber->RInner()+bpar[0] , 0, 0, 
459                     idrotm[1100],"ONLY");
460          gMC->Gspos("C04F",2,"C04G", -iChamber->RInner()-bpar[0] , 0, 0, 
461                     idrotm[1100],"ONLY");
462          gMC->Gspos("C04F",3,"C04G", 0, +iChamber->RInner()+bpar[0] , 0, 
463                     idrotm[1101],"ONLY");
464          gMC->Gspos("C04F",4,"C04G", 0, -iChamber->RInner()-bpar[0] , 0, 
465                     idrotm[1101],"ONLY");
466      }
467      }
468      // define the id of tracking media:
469      Int_t idCopper = idtmed[1110];
470      Int_t idGlass  = idtmed[1111];
471      Int_t idCarbon = idtmed[1112];
472      Int_t idRoha   = idtmed[1113];
473
474       // sensitive area: 40*40 cm**2
475      const Float_t sensLength = 40.; 
476      const Float_t sensHeight = 40.; 
477      const Float_t sensWidth  = 0.5; // according to TDR fig 2.120 
478      const Int_t sensMaterial = idGas;
479      const Float_t yOverlap   = 1.5; 
480
481      // PCB dimensions in cm; width: 30 mum copper   
482      const Float_t pcbLength  = sensLength; 
483      const Float_t pcbHeight  = 60.; 
484      const Float_t pcbWidth   = 0.003;   
485      const Int_t pcbMaterial  = idCopper;
486
487      // Insulating material: 200 mum glass fiber glued to pcb  
488      const Float_t insuLength = pcbLength; 
489      const Float_t insuHeight = pcbHeight; 
490      const Float_t insuWidth  = 0.020;   
491      const Int_t insuMaterial = idGlass;
492
493      // Carbon fiber panels: 200mum carbon/epoxy skin   
494      const Float_t panelLength = sensLength; 
495      const Float_t panelHeight = sensHeight; 
496      const Float_t panelWidth  = 0.020;      
497      const Int_t panelMaterial = idCarbon;
498
499      // rohacell between the two carbon panels   
500      const Float_t rohaLength = sensLength; 
501      const Float_t rohaHeight = sensHeight; 
502      const Float_t rohaWidth  = 0.5;
503      const Int_t rohaMaterial = idRoha;
504
505      // Frame around the slat: 2 sticks along length,2 along height  
506      // H: the horizontal ones 
507      const Float_t hFrameLength = pcbLength; 
508      const Float_t hFrameHeight = 1.5; 
509      const Float_t hFrameWidth  = sensWidth; 
510      const Int_t hFrameMaterial = idGlass;
511
512      // V: the vertical ones 
513      const Float_t vFrameLength = 4.0; 
514      const Float_t vFrameHeight = sensHeight + hFrameHeight; 
515      const Float_t vFrameWidth  = sensWidth;
516      const Int_t vFrameMaterial = idGlass;
517
518      // B: the horizontal border filled with rohacell 
519      const Float_t bFrameLength = hFrameLength; 
520      const Float_t bFrameHeight = (pcbHeight - sensHeight)/2. - hFrameHeight; 
521      const Float_t bFrameWidth  = hFrameWidth;
522      const Int_t bFrameMaterial = idRoha;
523
524      // NULOC: 30 mum copper + 200 mum vetronite (same radiation length as 14mum copper)
525      const Float_t nulocLength = 2.5; 
526      const Float_t nulocHeight = 7.5; 
527      const Float_t nulocWidth  = 0.0030 + 0.0014; // equivalent copper width of vetronite; 
528      const Int_t   nulocMaterial = idCopper;
529
530      // Gassiplex package 
531      const Float_t gassiLength   = 1.0; 
532      const Float_t gassiHeight   = 1.0; 
533      const Float_t gassiWidth    = 0.15; // check it !!!
534      const Int_t   gassiMaterial = idGlass; 
535
536      const Float_t slatHeight = pcbHeight; 
537      const Float_t slatWidth = sensWidth + 2.*(pcbWidth + insuWidth + 
538                                                2.* panelWidth + rohaWidth);
539      const Int_t slatMaterial = idAir;
540      const Float_t dSlatLength = vFrameLength; // border on left and right 
541
542      Float_t spar[3];  
543      Int_t i, j;
544
545      Float_t sensPar[3] = { sensLength/2., sensHeight/2., sensWidth/2. }; 
546      Float_t pcbpar[3] = { pcbLength/2., pcbHeight/2., pcbWidth/2. }; 
547      Float_t insupar[3] = { insuLength/2., insuHeight/2., insuWidth/2. }; 
548      Float_t panelpar[3] = { panelLength/2., panelHeight/2., panelWidth/2. }; 
549      Float_t rohapar[3] = { rohaLength/2., rohaHeight/2., rohaWidth/2. }; 
550      Float_t vFramepar[3]={vFrameLength/2., vFrameHeight/2., vFrameWidth/2.}; 
551      Float_t hFramepar[3]={hFrameLength/2., hFrameHeight/2., hFrameWidth/2.}; 
552      Float_t bFramepar[3]={bFrameLength/2., bFrameHeight/2., bFrameWidth/2.}; 
553      Float_t nulocpar[3]={nulocLength/2., nulocHeight/2., nulocWidth/2.}; 
554      Float_t gassipar[3]={gassiLength/2., gassiHeight/2., gassiWidth/2.}; 
555      Float_t xx;
556      Float_t xxmax = (bFrameLength - nulocLength)/2.; 
557      Int_t index=0;
558      
559      if (stations[2]) {
560          
561 //********************************************************************
562 //                            Station 3                             **
563 //********************************************************************
564      // indices 1 and 2 for first and second chambers in the station
565      // iChamber (first chamber) kept for other quanties than Z,
566      // assumed to be the same in both chambers
567      iChamber1 = iChamber = (AliMUONChamber*) (*fChambers)[4];
568      iChamber2 =(AliMUONChamber*) (*fChambers)[5];
569      zpos1=iChamber1->Z(); 
570      zpos2=iChamber2->Z();
571      dstation = zpos2 - zpos1;
572
573      zfpos=-(iChamber->DGas()+dframez+iChamber->DAlu())/2;
574 //
575 //   Mother volume
576      tpar[0] = iChamber->RInner()-dframep; 
577      tpar[1] = (iChamber->ROuter()+dframep)/TMath::Cos(phi);
578      tpar[2] = dstation/5;
579      gMC->Gsvolu("C05M", "TUBE", idAir, tpar, 3);
580      gMC->Gsvolu("C06M", "TUBE", idAir, tpar, 3);
581      gMC->Gspos("C05M", 1, "ALIC", 0., 0., zpos1 , 0, "ONLY");
582      gMC->Gspos("C06M", 1, "ALIC", 0., 0., zpos2 , 0, "ONLY");
583  
584      // volumes for slat geometry (xx=5,..,10 chamber id): 
585      // Sxx0 Sxx1 Sxx2 Sxx3  -->   Slat Mother volumes 
586      // SxxG                          -->   Sensitive volume (gas)
587      // SxxP                          -->   PCB (copper) 
588      // SxxI                          -->   Insulator (vetronite) 
589      // SxxC                          -->   Carbon panel 
590      // SxxR                          -->   Rohacell
591      // SxxH, SxxV                    -->   Horizontal and Vertical frames (vetronite)
592
593      // slat dimensions: slat is a MOTHER volume!!! made of air
594
595
596      const Int_t nSlats3 = 4;  // number of slats per quadrant
597      const Int_t nPCB3[nSlats3] = {3,4,3,2}; // n PCB per slat
598      Float_t slatLength3[nSlats3]; 
599
600      // create and position the slat (mother) volumes 
601
602      char volNam5[5];
603      char volDiv5[5];
604      char volNam6[5];
605      char volDiv6[5];
606      Float_t xSlat3;
607
608      for (i = 0; i<nSlats3; i++){
609          slatLength3[i] = pcbLength * nPCB3[i] + 2. * dSlatLength; 
610          xSlat3 = slatLength3[i]/2. - vFrameLength/2.; 
611          if (i==0) xSlat3 += 40.;
612          
613          Float_t ySlat31 =  sensHeight * (i+0.5) - yOverlap * i - yOverlap/2.; 
614          Float_t ySlat32 = -sensHeight * (i+0.5) + yOverlap * i + yOverlap/2.; 
615          spar[0] = slatLength3[i]/2.; 
616          spar[1] = slatHeight/2.;
617          spar[2] = slatWidth/2.; 
618          // zSlat to be checked (odd downstream or upstream?)
619          Float_t zSlat = (i%2 ==0)? -slatWidth/2. : slatWidth/2.; 
620          zSlat*=1.01;
621          sprintf(volNam5,"S05%d",i);
622          gMC->Gsvolu(volNam5,"BOX",slatMaterial,spar,3);
623          gMC->Gspos(volNam5, i*4+1,"C05M", xSlat3, ySlat31, zSlat, 0, "ONLY");
624          gMC->Gspos(volNam5, i*4+2,"C05M",-xSlat3, ySlat31, zSlat, 0, "ONLY");
625          gMC->Gspos(volNam5, i*4+3,"C05M", xSlat3, ySlat32,-zSlat, 0, "ONLY");
626          gMC->Gspos(volNam5, i*4+4,"C05M",-xSlat3, ySlat32,-zSlat, 0, "ONLY");
627          sprintf(volNam6,"S06%d",i);
628          gMC->Gsvolu(volNam6,"BOX",slatMaterial,spar,3);
629          gMC->Gspos(volNam6, i*4+1,"C06M", xSlat3, ySlat31, zSlat, 0, "ONLY");
630          gMC->Gspos(volNam6, i*4+2,"C06M",-xSlat3, ySlat31, zSlat, 0, "ONLY");
631          gMC->Gspos(volNam6, i*4+3,"C06M", xSlat3, ySlat32,-zSlat, 0, "ONLY");
632          gMC->Gspos(volNam6, i*4+4,"C06M",-xSlat3, ySlat32,-zSlat, 0, "ONLY");
633          // 1st pcb in 1st slat made by some rectangular divisions
634 /*
635          if (i==0) {                        
636              Int_t ndiv=8;
637              Double_t dydiv= sensHeight/ndiv;
638              Double_t ydiv = -dydiv; 
639              for (Int_t idiv=0;idiv<ndiv; idiv++){ 
640                  ydiv+= dydiv;
641                  Float_t xdiv =0; 
642                  if (ydiv<30) xdiv= 30. * TMath::Sin( TMath::ACos(ydiv/30.) );
643                  spar[0] = (pcbLength-xdiv)/2.; 
644                  spar[1] = dydiv/2.;
645                  spar[2] = slatWidth/2.; 
646                  
647                  sprintf(volDiv5,"D05%d",idiv);
648                  sprintf(volDiv6,"D06%d",idiv);
649                  
650                  gMC->Gsvolu(volDiv5,"BOX",sensMaterial,spar,3);
651                  Float_t xvol=(pcbLength+xdiv)/2.;
652                  Float_t yvol=ydiv+dydiv/2.;
653                  gMC->Gspos(volDiv5, 1,"C05M", xvol, yvol, zSlat, 0, "ONLY");
654                  gMC->Gspos(volDiv5, 2,"C05M",-xvol, yvol, zSlat, 0, "ONLY");
655                  gMC->Gspos(volDiv5, 3,"C05M", xvol,-yvol,-zSlat, 0, "ONLY");
656                  gMC->Gspos(volDiv5, 4,"C05M",-xvol,-yvol,-zSlat, 0, "ONLY");
657                  gMC->Gspos(volDiv6, 1,"C06M", xvol, yvol, zSlat, 0, "ONLY");
658                  gMC->Gspos(volDiv6, 2,"C06M",-xvol, yvol, zSlat, 0, "ONLY");
659                  gMC->Gspos(volDiv6, 3,"C06M", xvol,-yvol,-zSlat, 0, "ONLY");
660                  gMC->Gspos(volDiv6, 4,"C06M",-xvol,-yvol,-zSlat, 0, "ONLY");
661              }
662          }
663  */
664      }
665
666      // create the sensitive volumes (subdivided as the PCBs),
667
668      gMC->Gsvolu("S05G","BOX",sensMaterial,sensPar,3);
669      gMC->Gsvolu("S06G","BOX",sensMaterial,sensPar,3);
670
671      // create the PCB volume 
672
673      gMC->Gsvolu("S05P","BOX",pcbMaterial,pcbpar,3);
674      gMC->Gsvolu("S06P","BOX",pcbMaterial,pcbpar,3);
675  
676      // create the insulating material volume 
677
678      gMC->Gsvolu("S05I","BOX",insuMaterial,insupar,3);
679      gMC->Gsvolu("S06I","BOX",insuMaterial,insupar,3);
680
681      // create the panel volume 
682  
683      gMC->Gsvolu("S05C","BOX",panelMaterial,panelpar,3);
684      gMC->Gsvolu("S06C","BOX",panelMaterial,panelpar,3);
685
686      // create the rohacell volume 
687
688      gMC->Gsvolu("S05R","BOX",rohaMaterial,rohapar,3);
689      gMC->Gsvolu("S06R","BOX",rohaMaterial,rohapar,3);
690
691      // create the vertical frame volume 
692
693      gMC->Gsvolu("S05V","BOX",vFrameMaterial,vFramepar,3);
694      gMC->Gsvolu("S06V","BOX",vFrameMaterial,vFramepar,3);
695
696      // create the horizontal frame volume 
697
698      gMC->Gsvolu("S05H","BOX",hFrameMaterial,hFramepar,3);
699      gMC->Gsvolu("S06H","BOX",hFrameMaterial,hFramepar,3);
700
701      // create the horizontal border volume 
702
703      gMC->Gsvolu("S05B","BOX",bFrameMaterial,bFramepar,3);
704      gMC->Gsvolu("S06B","BOX",bFrameMaterial,bFramepar,3);
705
706      index=0; 
707      for (i = 0; i<nSlats3; i++){
708        sprintf(volNam5,"S05%d",i);
709        sprintf(volNam6,"S06%d",i);
710        Float_t xvFrame  = (slatLength3[i] - vFrameLength)/2.;
711        gMC->Gspos("S05V",2*i-1,volNam5, xvFrame, 0., 0. , 0, "ONLY");
712        gMC->Gspos("S05V",2*i  ,volNam5,-xvFrame, 0., 0. , 0, "ONLY");
713        gMC->Gspos("S06V",2*i-1,volNam6, xvFrame, 0., 0. , 0, "ONLY");
714        gMC->Gspos("S06V",2*i  ,volNam6,-xvFrame, 0., 0. , 0, "ONLY");
715        for (j=0; j<nPCB3[i]; j++){
716          index++;
717          Float_t xx = sensLength * (-nPCB3[i]/2.+j+.5); 
718          Float_t yy = 0.;
719          Float_t zSens = 0.;  
720          gMC->Gspos("S05G",index,volNam5, xx, yy, zSens , 0, "ONLY");
721          gMC->Gspos("S06G",index,volNam6, xx, yy, zSens , 0, "ONLY");
722          Float_t zPCB = (sensWidth+pcbWidth)/2.; 
723          gMC->Gspos("S05P",2*index-1,volNam5, xx, yy, zPCB , 0, "ONLY");
724          gMC->Gspos("S05P",2*index  ,volNam5, xx, yy,-zPCB , 0, "ONLY");
725          gMC->Gspos("S06P",2*index-1,volNam6, xx, yy, zPCB , 0, "ONLY");
726          gMC->Gspos("S06P",2*index  ,volNam6, xx, yy,-zPCB , 0, "ONLY");
727          Float_t zInsu = (insuWidth+pcbWidth)/2. + zPCB; 
728          gMC->Gspos("S05I",2*index-1,volNam5, xx, yy, zInsu , 0, "ONLY");
729          gMC->Gspos("S05I",2*index  ,volNam5, xx, yy,-zInsu , 0, "ONLY");
730          gMC->Gspos("S06I",2*index-1,volNam6, xx, yy, zInsu , 0, "ONLY");
731          gMC->Gspos("S06I",2*index  ,volNam6, xx, yy,-zInsu , 0, "ONLY");
732          Float_t zPanel1 = (insuWidth+panelWidth)/2. + zInsu; 
733          gMC->Gspos("S05C",4*index-3,volNam5, xx, yy, zPanel1 , 0, "ONLY");
734          gMC->Gspos("S05C",4*index-2,volNam5, xx, yy,-zPanel1 , 0, "ONLY");
735          gMC->Gspos("S06C",4*index-3,volNam6, xx, yy, zPanel1 , 0, "ONLY");
736          gMC->Gspos("S06C",4*index-2,volNam6, xx, yy,-zPanel1 , 0, "ONLY");
737          Float_t zRoha = (rohaWidth+panelWidth)/2. + zPanel1; 
738          gMC->Gspos("S05R",2*index-1,volNam5, xx, yy, zRoha , 0, "ONLY");
739          gMC->Gspos("S05R",2*index  ,volNam5, xx, yy,-zRoha , 0, "ONLY");
740          gMC->Gspos("S06R",2*index-1,volNam6, xx, yy, zRoha , 0, "ONLY");
741          gMC->Gspos("S06R",2*index  ,volNam6, xx, yy,-zRoha , 0, "ONLY");
742          Float_t zPanel2 = (rohaWidth+panelWidth)/2. + zRoha; 
743          gMC->Gspos("S05C",4*index-1,volNam5, xx, yy, zPanel2 , 0, "ONLY");
744          gMC->Gspos("S05C",4*index  ,volNam5, xx, yy,-zPanel2 , 0, "ONLY");
745          gMC->Gspos("S06C",4*index-1,volNam6, xx, yy, zPanel2 , 0, "ONLY");
746          gMC->Gspos("S06C",4*index  ,volNam6, xx, yy,-zPanel2 , 0, "ONLY");
747          Float_t yframe = (sensHeight + hFrameHeight)/2.;
748          gMC->Gspos("S05H",2*index-1,volNam5, xx, yframe, 0. , 0, "ONLY");
749          gMC->Gspos("S05H",2*index  ,volNam5, xx,-yframe, 0. , 0, "ONLY");
750          gMC->Gspos("S06H",2*index-1,volNam6, xx, yframe, 0. , 0, "ONLY");
751          gMC->Gspos("S06H",2*index  ,volNam6, xx,-yframe, 0. , 0, "ONLY");
752          Float_t yborder = (bFrameHeight + hFrameHeight)/2. + yframe;
753          gMC->Gspos("S05B",2*index-1,volNam5, xx, yborder, 0. , 0, "ONLY");
754          gMC->Gspos("S05B",2*index  ,volNam5, xx,-yborder, 0. , 0, "ONLY");
755          gMC->Gspos("S06B",2*index-1,volNam6, xx, yborder, 0. , 0, "ONLY");
756          gMC->Gspos("S06B",2*index  ,volNam6, xx,-yborder, 0. , 0, "ONLY");
757        } 
758      }
759
760      // create the NULOC volume and position it in the horizontal frame
761
762      gMC->Gsvolu("S05N","BOX",nulocMaterial,nulocpar,3);
763      gMC->Gsvolu("S06N","BOX",nulocMaterial,nulocpar,3);
764
765
766      index = 0;
767
768
769      for (xx = -xxmax; xx<=xxmax; xx+=3*nulocLength) { 
770        index++; 
771        gMC->Gspos("S05N",2*index-1,"S05B", xx, 0.,-bFrameWidth/4., 0, "ONLY");
772        gMC->Gspos("S05N",2*index  ,"S05B", xx, 0., bFrameWidth/4., 0, "ONLY");
773        gMC->Gspos("S06N",2*index-1,"S06B", xx, 0.,-bFrameWidth/4., 0, "ONLY");
774        gMC->Gspos("S06N",2*index  ,"S06B", xx, 0., bFrameWidth/4., 0, "ONLY");
775      }
776
777      // create the gassiplex volume 
778
779      gMC->Gsvolu("S05E","BOX",gassiMaterial,gassipar,3);
780      gMC->Gsvolu("S06E","BOX",gassiMaterial,gassipar,3);
781
782
783      // position 4 gassiplex in the nuloc
784
785      gMC->Gspos("S05E",1,"S05N", 0., -3 * nulocHeight/8., 0. , 0, "ONLY");
786      gMC->Gspos("S05E",2,"S05N", 0.,    - nulocHeight/8., 0. , 0, "ONLY");
787      gMC->Gspos("S05E",3,"S05N", 0.,      nulocHeight/8., 0. , 0, "ONLY");
788      gMC->Gspos("S05E",4,"S05N", 0.,  3 * nulocHeight/8., 0. , 0, "ONLY");
789      gMC->Gspos("S06E",1,"S06N", 0., -3 * nulocHeight/8., 0. , 0, "ONLY");
790      gMC->Gspos("S06E",2,"S06N", 0.,    - nulocHeight/8., 0. , 0, "ONLY");
791      gMC->Gspos("S06E",3,"S06N", 0.,      nulocHeight/8., 0. , 0, "ONLY");
792      gMC->Gspos("S06E",4,"S06N", 0.,  3 * nulocHeight/8., 0. , 0, "ONLY");
793      }
794  if (stations[3]) {
795      
796
797 //********************************************************************
798 //                            Station 4                             **
799 //********************************************************************
800      // indices 1 and 2 for first and second chambers in the station
801      // iChamber (first chamber) kept for other quanties than Z,
802      // assumed to be the same in both chambers
803      iChamber1 = iChamber = (AliMUONChamber*) (*fChambers)[6];
804      iChamber2 =(AliMUONChamber*) (*fChambers)[7];
805      zpos1=iChamber1->Z(); 
806      zpos2=iChamber2->Z();
807      dstation = zpos2 - zpos1;
808      zfpos=-(iChamber->DGas()+dframez+iChamber->DAlu())/2;
809      
810 //
811 //   Mother volume
812      tpar[0] = iChamber->RInner()-dframep; 
813      tpar[1] = (iChamber->ROuter()+dframep)/TMath::Cos(phi);
814      tpar[2] = dstation/5;
815
816      gMC->Gsvolu("C07M", "TUBE", idAir, tpar, 3);
817      gMC->Gsvolu("C08M", "TUBE", idAir, tpar, 3);
818      gMC->Gspos("C07M", 1, "ALIC", 0., 0., zpos1 , 0, "ONLY");
819      gMC->Gspos("C08M", 1, "ALIC", 0., 0., zpos2 , 0, "ONLY");
820      
821
822      const Int_t nSlats4 = 6;  // number of slats per quadrant
823      const Int_t nPCB4[nSlats4] = {4,5,5,4,3,2}; // n PCB per slat
824
825      // slat dimensions: slat is a MOTHER volume!!! made of air
826      Float_t slatLength4[nSlats4];     
827
828      // create and position the slat (mother) volumes 
829
830      char volNam7[5];
831      char volNam8[5];
832      Float_t xSlat4;
833      Float_t ySlat4;
834
835
836      for (i = 0; i<nSlats4; i++){
837          slatLength4[i] = pcbLength * nPCB4[i] + 2. * dSlatLength; 
838          xSlat4 = slatLength4[i]/2. - vFrameLength/2.; 
839          if (i==0) xSlat4 += 37.5;
840          ySlat4 =  sensHeight * i - yOverlap *i;
841          
842          spar[0] = slatLength4[i]/2.; 
843          spar[1] = slatHeight/2.;
844          spar[2] = slatWidth/2.; 
845          // zSlat to be checked (odd downstream or upstream?)
846          Float_t zSlat = (i%2 ==0)? slatWidth/2. : -slatWidth/2.; 
847          zSlat*=1.01;
848          sprintf(volNam7,"S07%d",i);
849          gMC->Gsvolu(volNam7,"BOX",slatMaterial,spar,3);
850          gMC->Gspos(volNam7, i*4+1,"C07M", xSlat4, ySlat4, zSlat, 0, "ONLY");
851          gMC->Gspos(volNam7, i*4+2,"C07M",-xSlat4, ySlat4, zSlat, 0, "ONLY");
852          if (i>0) { 
853            gMC->Gspos(volNam7, i*4+3,"C07M", xSlat4,-ySlat4, zSlat, 0, "ONLY");
854            gMC->Gspos(volNam7, i*4+4,"C07M",-xSlat4,-ySlat4, zSlat, 0, "ONLY");
855          }
856          sprintf(volNam8,"S08%d",i);
857          gMC->Gsvolu(volNam8,"BOX",slatMaterial,spar,3);
858          gMC->Gspos(volNam8, i*4+1,"C08M", xSlat4, ySlat4, zSlat, 0, "ONLY");
859          gMC->Gspos(volNam8, i*4+2,"C08M",-xSlat4, ySlat4, zSlat, 0, "ONLY");
860          if (i>0) { 
861            gMC->Gspos(volNam8, i*4+3,"C08M", xSlat4,-ySlat4, zSlat, 0, "ONLY");
862            gMC->Gspos(volNam8, i*4+4,"C08M",-xSlat4,-ySlat4, zSlat, 0, "ONLY");
863          }
864      }
865
866      // create the sensitive volumes (subdivided as the PCBs),
867  
868      gMC->Gsvolu("S07G","BOX",sensMaterial,sensPar,3);
869      gMC->Gsvolu("S08G","BOX",sensMaterial,sensPar,3);
870
871      // create the PCB volume 
872
873      gMC->Gsvolu("S07P","BOX",pcbMaterial,pcbpar,3);
874      gMC->Gsvolu("S08P","BOX",pcbMaterial,pcbpar,3);
875  
876      // create the insulating material volume 
877
878      gMC->Gsvolu("S07I","BOX",insuMaterial,insupar,3);
879      gMC->Gsvolu("S08I","BOX",insuMaterial,insupar,3);
880
881      // create the panel volume 
882
883      gMC->Gsvolu("S07C","BOX",panelMaterial,panelpar,3);
884      gMC->Gsvolu("S08C","BOX",panelMaterial,panelpar,3);
885
886      // create the rohacell volume 
887  
888      gMC->Gsvolu("S07R","BOX",rohaMaterial,rohapar,3);
889      gMC->Gsvolu("S08R","BOX",rohaMaterial,rohapar,3);
890
891      // create the vertical frame volume 
892
893      gMC->Gsvolu("S07V","BOX",vFrameMaterial,vFramepar,3);
894      gMC->Gsvolu("S08V","BOX",vFrameMaterial,vFramepar,3);
895
896      // create the horizontal frame volume 
897
898      gMC->Gsvolu("S07H","BOX",hFrameMaterial,hFramepar,3);
899      gMC->Gsvolu("S08H","BOX",hFrameMaterial,hFramepar,3);
900
901      // create the horizontal border volume 
902
903      gMC->Gsvolu("S07B","BOX",bFrameMaterial,bFramepar,3);
904      gMC->Gsvolu("S08B","BOX",bFrameMaterial,bFramepar,3);
905  
906      for (i = 0; i<nSlats4; i++){
907        sprintf(volNam7,"S07%d",i);
908        sprintf(volNam8,"S08%d",i);
909        Float_t xvFrame  = (slatLength4[i] - vFrameLength)/2.;
910        gMC->Gspos("S07V",2*i-1,volNam7, xvFrame, 0., 0. , 0, "ONLY");
911        gMC->Gspos("S07V",2*i  ,volNam7,-xvFrame, 0., 0. , 0, "ONLY");
912        gMC->Gspos("S08V",2*i-1,volNam8, xvFrame, 0., 0. , 0, "ONLY");
913        gMC->Gspos("S08V",2*i  ,volNam8,-xvFrame, 0., 0. , 0, "ONLY");
914        for (j=0; j<nPCB4[i]; j++){
915          index++;
916          Float_t xx = sensLength * (-nPCB4[i]/2.+j+.5); 
917          Float_t yy = 0.;
918          Float_t zSens = 0.;  
919          gMC->Gspos("S07G",index,volNam7, xx, yy, zSens , 0, "ONLY");
920          gMC->Gspos("S08G",index,volNam8, xx, yy, zSens , 0, "ONLY");
921          Float_t zPCB = (sensWidth+pcbWidth)/2.; 
922          gMC->Gspos("S07P",2*index-1,volNam7, xx, yy, zPCB , 0, "ONLY");
923          gMC->Gspos("S07P",2*index  ,volNam7, xx, yy,-zPCB , 0, "ONLY");
924          gMC->Gspos("S08P",2*index-1,volNam8, xx, yy, zPCB , 0, "ONLY");
925          gMC->Gspos("S08P",2*index  ,volNam8, xx, yy,-zPCB , 0, "ONLY");
926          Float_t zInsu = (insuWidth+pcbWidth)/2. + zPCB; 
927          gMC->Gspos("S07I",2*index-1,volNam7, xx, yy, zInsu , 0, "ONLY");
928          gMC->Gspos("S07I",2*index  ,volNam7, xx, yy,-zInsu , 0, "ONLY");
929          gMC->Gspos("S08I",2*index-1,volNam8, xx, yy, zInsu , 0, "ONLY");
930          gMC->Gspos("S08I",2*index  ,volNam8, xx, yy,-zInsu , 0, "ONLY");
931          Float_t zPanel1 = (insuWidth+panelWidth)/2. + zInsu; 
932          gMC->Gspos("S07C",4*index-3,volNam7, xx, yy, zPanel1 , 0, "ONLY");
933          gMC->Gspos("S07C",4*index-2,volNam7, xx, yy,-zPanel1 , 0, "ONLY");
934          gMC->Gspos("S08C",4*index-3,volNam8, xx, yy, zPanel1 , 0, "ONLY");
935          gMC->Gspos("S08C",4*index-2,volNam8, xx, yy,-zPanel1 , 0, "ONLY");
936          Float_t zRoha = (rohaWidth+panelWidth)/2. + zPanel1; 
937          gMC->Gspos("S07R",2*index-1,volNam7, xx, yy, zRoha , 0, "ONLY");
938          gMC->Gspos("S07R",2*index  ,volNam7, xx, yy,-zRoha , 0, "ONLY");
939          gMC->Gspos("S08R",2*index-1,volNam8, xx, yy, zRoha , 0, "ONLY");
940          gMC->Gspos("S08R",2*index  ,volNam8, xx, yy,-zRoha , 0, "ONLY");
941          Float_t zPanel2 = (rohaWidth+panelWidth)/2. + zRoha; 
942          gMC->Gspos("S07C",4*index-1,volNam7, xx, yy, zPanel2 , 0, "ONLY");
943          gMC->Gspos("S07C",4*index  ,volNam7, xx, yy,-zPanel2 , 0, "ONLY");
944          gMC->Gspos("S08C",4*index-1,volNam8, xx, yy, zPanel2 , 0, "ONLY");
945          gMC->Gspos("S08C",4*index  ,volNam8, xx, yy,-zPanel2 , 0, "ONLY");
946          Float_t yframe = (sensHeight + hFrameHeight)/2.;
947          gMC->Gspos("S07H",2*index-1,volNam7, xx, yframe, 0. , 0, "ONLY");
948          gMC->Gspos("S07H",2*index  ,volNam7, xx,-yframe, 0. , 0, "ONLY");
949          gMC->Gspos("S08H",2*index-1,volNam8, xx, yframe, 0. , 0, "ONLY");
950          gMC->Gspos("S08H",2*index  ,volNam8, xx,-yframe, 0. , 0, "ONLY");
951          Float_t yborder = (bFrameHeight + hFrameHeight)/2. + yframe;
952          gMC->Gspos("S07B",2*index-1,volNam7, xx, yborder, 0. , 0, "ONLY");
953          gMC->Gspos("S07B",2*index  ,volNam7, xx,-yborder, 0. , 0, "ONLY");
954          gMC->Gspos("S08B",2*index-1,volNam8, xx, yborder, 0. , 0, "ONLY");
955          gMC->Gspos("S08B",2*index  ,volNam8, xx,-yborder, 0. , 0, "ONLY");
956        } 
957      }
958
959      // create the NULOC volume and position it in the horizontal frame
960  
961      gMC->Gsvolu("S07N","BOX",nulocMaterial,nulocpar,3);
962      gMC->Gsvolu("S08N","BOX",nulocMaterial,nulocpar,3);
963
964
965      index = 0; 
966      for (xx = -xxmax; xx<=xxmax; xx+=3*nulocLength) { 
967        index++; 
968        gMC->Gspos("S07N",2*index-1,"S07B", xx, 0.,-bFrameWidth/4., 0, "ONLY");
969        gMC->Gspos("S07N",2*index  ,"S07B", xx, 0., bFrameWidth/4., 0, "ONLY");
970        gMC->Gspos("S08N",2*index-1,"S08B", xx, 0.,-bFrameWidth/4., 0, "ONLY");
971        gMC->Gspos("S08N",2*index  ,"S08B", xx, 0., bFrameWidth/4., 0, "ONLY");
972      }
973
974      // create the gassiplex volume 
975
976      gMC->Gsvolu("S07E","BOX",gassiMaterial,gassipar,3);
977      gMC->Gsvolu("S08E","BOX",gassiMaterial,gassipar,3);
978
979
980      // position 4 gassiplex in the nuloc
981
982      gMC->Gspos("S07E",1,"S07N", 0., -3 * nulocHeight/8., 0. , 0, "ONLY");
983      gMC->Gspos("S07E",2,"S07N", 0.,    - nulocHeight/8., 0. , 0, "ONLY");
984      gMC->Gspos("S07E",3,"S07N", 0.,      nulocHeight/8., 0. , 0, "ONLY");
985      gMC->Gspos("S07E",4,"S07N", 0.,  3 * nulocHeight/8., 0. , 0, "ONLY");
986      gMC->Gspos("S08E",1,"S08N", 0., -3 * nulocHeight/8., 0. , 0, "ONLY");
987      gMC->Gspos("S08E",2,"S08N", 0.,    - nulocHeight/8., 0. , 0, "ONLY");
988      gMC->Gspos("S08E",3,"S08N", 0.,      nulocHeight/8., 0. , 0, "ONLY");
989      gMC->Gspos("S08E",4,"S08N", 0.,  3 * nulocHeight/8., 0. , 0, "ONLY");
990      
991  }
992  if (stations[4]) {
993      
994
995 //********************************************************************
996 //                            Station 5                             **
997 //********************************************************************
998      // indices 1 and 2 for first and second chambers in the station
999      // iChamber (first chamber) kept for other quanties than Z,
1000      // assumed to be the same in both chambers
1001      iChamber1 = iChamber = (AliMUONChamber*) (*fChambers)[8];
1002      iChamber2 =(AliMUONChamber*) (*fChambers)[9];
1003      zpos1=iChamber1->Z(); 
1004      zpos2=iChamber2->Z();
1005      dstation = zpos2 - zpos1;
1006      zfpos=-(iChamber->DGas()+dframez+iChamber->DAlu())/2;
1007      
1008 //
1009 //   Mother volume
1010      tpar[0] = iChamber->RInner()-dframep; 
1011      tpar[1] = (iChamber->ROuter()+dframep)/TMath::Cos(phi);
1012      tpar[2] = dstation/5;
1013
1014      gMC->Gsvolu("C09M", "TUBE", idAir, tpar, 3);
1015      gMC->Gsvolu("C10M", "TUBE", idAir, tpar, 3);
1016      gMC->Gspos("C09M", 1, "ALIC", 0., 0., zpos1 , 0, "ONLY");
1017      gMC->Gspos("C10M", 1, "ALIC", 0., 0., zpos2 , 0, "ONLY");
1018
1019
1020      const Int_t nSlats5 = 7;  // number of slats per quadrant
1021      const Int_t nPCB5[nSlats5] = {7,7,6,6,5,4,2}; // n PCB per slat
1022
1023      // slat dimensions: slat is a MOTHER volume!!! made of air
1024      Float_t slatLength5[nSlats5]; 
1025      char volNam9[5];
1026      char volNam10[5];
1027      Float_t xSlat5;
1028      Float_t ySlat5;
1029
1030      for (i = 0; i<nSlats5; i++){
1031        slatLength5[i] = pcbLength * nPCB5[i] + 2. * dSlatLength; 
1032        xSlat5 = slatLength5[i]/2. - vFrameLength/2.; 
1033        if (i==0) xSlat5 += 37.5;
1034        ySlat5 = sensHeight * i - yOverlap * i; 
1035        spar[0] = slatLength5[i]/2.; 
1036        spar[1] = slatHeight/2.;
1037        spar[2] = slatWidth/2.; 
1038        // zSlat to be checked (odd downstream or upstream?)
1039        Float_t zSlat = (i%2 ==0)? -slatWidth/2. : slatWidth/2.; 
1040        zSlat*=1.01;
1041        sprintf(volNam9,"S09%d",i);
1042        gMC->Gsvolu(volNam9,"BOX",slatMaterial,spar,3);
1043        gMC->Gspos(volNam9, i*4+1,"C09M", xSlat5, ySlat5, zSlat, 0, "ONLY");
1044        gMC->Gspos(volNam9, i*4+2,"C09M",-xSlat5, ySlat5, zSlat, 0, "ONLY");
1045        if (i>0) { 
1046          gMC->Gspos(volNam9, i*4+3,"C09M", xSlat5,-ySlat5, zSlat, 0, "ONLY");
1047          gMC->Gspos(volNam9, i*4+4,"C09M",-xSlat5,-ySlat5, zSlat, 0, "ONLY");
1048        }
1049        sprintf(volNam10,"S10%d",i);
1050        gMC->Gsvolu(volNam10,"BOX",slatMaterial,spar,3);
1051        gMC->Gspos(volNam10, i*4+1,"C10M", xSlat5, ySlat5, zSlat, 0, "ONLY");
1052        gMC->Gspos(volNam10, i*4+2,"C10M",-xSlat5, ySlat5, zSlat, 0, "ONLY");
1053        if (i>0) { 
1054          gMC->Gspos(volNam10, i*4+3,"C10M", xSlat5,-ySlat5, zSlat, 0, "ONLY");
1055          gMC->Gspos(volNam10, i*4+4,"C10M",-xSlat5,-ySlat5, zSlat, 0, "ONLY");
1056        }
1057      }
1058
1059      // create the sensitive volumes (subdivided as the PCBs),
1060       
1061      gMC->Gsvolu("S09G","BOX",sensMaterial,sensPar,3);
1062      gMC->Gsvolu("S10G","BOX",sensMaterial,sensPar,3);
1063      
1064      // create the PCB volume 
1065      
1066      gMC->Gsvolu("S09P","BOX",pcbMaterial,pcbpar,3);
1067      gMC->Gsvolu("S10P","BOX",pcbMaterial,pcbpar,3);
1068  
1069      // create the insulating material volume 
1070      
1071      gMC->Gsvolu("S09I","BOX",insuMaterial,insupar,3);
1072      gMC->Gsvolu("S10I","BOX",insuMaterial,insupar,3);
1073
1074      // create the panel volume 
1075   
1076      gMC->Gsvolu("S09C","BOX",panelMaterial,panelpar,3);
1077      gMC->Gsvolu("S10C","BOX",panelMaterial,panelpar,3);
1078      
1079      // create the rohacell volume 
1080       
1081      gMC->Gsvolu("S09R","BOX",rohaMaterial,rohapar,3);
1082      gMC->Gsvolu("S10R","BOX",rohaMaterial,rohapar,3);
1083      
1084      // create the vertical frame volume 
1085    
1086      gMC->Gsvolu("S09V","BOX",vFrameMaterial,vFramepar,3);
1087      gMC->Gsvolu("S10V","BOX",vFrameMaterial,vFramepar,3);
1088
1089      // create the horizontal frame volume 
1090   
1091      gMC->Gsvolu("S09H","BOX",hFrameMaterial,hFramepar,3);
1092      gMC->Gsvolu("S10H","BOX",hFrameMaterial,hFramepar,3);
1093
1094      // create the horizontal border volume 
1095
1096      gMC->Gsvolu("S09B","BOX",bFrameMaterial,bFramepar,3);
1097      gMC->Gsvolu("S10B","BOX",bFrameMaterial,bFramepar,3);
1098
1099      
1100      for (i = 0; i<nSlats5; i++){
1101        sprintf(volNam9,"S09%d",i);
1102        sprintf(volNam10,"S10%d",i);
1103        Float_t xvFrame  = (slatLength5[i] - vFrameLength)/2.;
1104        gMC->Gspos("S09V",2*i-1,volNam9, xvFrame, 0., 0. , 0, "ONLY");
1105        gMC->Gspos("S09V",2*i  ,volNam9,-xvFrame, 0., 0. , 0, "ONLY");
1106        gMC->Gspos("S10V",2*i-1,volNam10, xvFrame, 0., 0. , 0, "ONLY");
1107        gMC->Gspos("S10V",2*i  ,volNam10,-xvFrame, 0., 0. , 0, "ONLY");
1108        for (j=0; j<nPCB5[i]; j++){
1109          index++;
1110          Float_t xx = sensLength/2. * (-nPCB5[i]+2*j+1); 
1111          Float_t yy = 0.;
1112          Float_t zSens = 0.;  
1113          gMC->Gspos("S09G",index,volNam9, xx, yy, zSens , 0, "ONLY");
1114          gMC->Gspos("S10G",index,volNam10, xx, yy, zSens , 0, "ONLY");
1115          Float_t zPCB = (sensWidth+pcbWidth)/2.; 
1116          gMC->Gspos("S09P",2*index-1,volNam9, xx, yy, zPCB , 0, "ONLY");
1117          gMC->Gspos("S09P",2*index  ,volNam9, xx, yy,-zPCB , 0, "ONLY");
1118          gMC->Gspos("S10P",2*index-1,volNam10, xx, yy, zPCB , 0, "ONLY");
1119          gMC->Gspos("S10P",2*index  ,volNam10, xx, yy,-zPCB , 0, "ONLY");
1120          Float_t zInsu = (insuWidth+pcbWidth)/2. + zPCB; 
1121          gMC->Gspos("S09I",2*index-1,volNam9, xx, yy, zInsu , 0, "ONLY");
1122          gMC->Gspos("S09I",2*index  ,volNam9, xx, yy,-zInsu , 0, "ONLY");
1123          gMC->Gspos("S10I",2*index-1,volNam10, xx, yy, zInsu , 0, "ONLY");
1124          gMC->Gspos("S10I",2*index  ,volNam10, xx, yy,-zInsu , 0, "ONLY");
1125          Float_t zPanel1 = (insuWidth+panelWidth)/2. + zInsu; 
1126          gMC->Gspos("S09C",4*index-3,volNam9, xx, yy, zPanel1 , 0, "ONLY");
1127          gMC->Gspos("S09C",4*index-2,volNam9, xx, yy,-zPanel1 , 0, "ONLY");
1128          gMC->Gspos("S10C",4*index-3,volNam10, xx, yy, zPanel1 , 0, "ONLY");
1129          gMC->Gspos("S10C",4*index-2,volNam10, xx, yy,-zPanel1 , 0, "ONLY");
1130          Float_t zRoha = (rohaWidth+panelWidth)/2. + zPanel1; 
1131          gMC->Gspos("S09R",2*index-1,volNam9, xx, yy, zRoha , 0, "ONLY");
1132          gMC->Gspos("S09R",2*index  ,volNam9, xx, yy,-zRoha , 0, "ONLY");
1133          gMC->Gspos("S10R",2*index-1,volNam10, xx, yy, zRoha , 0, "ONLY");
1134          gMC->Gspos("S10R",2*index  ,volNam10, xx, yy,-zRoha , 0, "ONLY");
1135          Float_t zPanel2 = (rohaWidth+panelWidth)/2. + zRoha; 
1136          gMC->Gspos("S09C",4*index-1,volNam9, xx, yy, zPanel2 , 0, "ONLY");
1137          gMC->Gspos("S09C",4*index  ,volNam9, xx, yy,-zPanel2 , 0, "ONLY");
1138          gMC->Gspos("S10C",4*index-1,volNam10, xx, yy, zPanel2 , 0, "ONLY");
1139          gMC->Gspos("S10C",4*index  ,volNam10, xx, yy,-zPanel2 , 0, "ONLY");
1140          Float_t yframe = (sensHeight + hFrameHeight)/2.;
1141          gMC->Gspos("S09H",2*index-1,volNam9, xx, yframe, 0. , 0, "ONLY");
1142          gMC->Gspos("S09H",2*index  ,volNam9, xx,-yframe, 0. , 0, "ONLY");
1143          gMC->Gspos("S10H",2*index-1,volNam10, xx, yframe, 0. , 0, "ONLY");
1144          gMC->Gspos("S10H",2*index  ,volNam10, xx,-yframe, 0. , 0, "ONLY");
1145          Float_t yborder = (bFrameHeight + hFrameHeight)/2. + yframe;
1146          gMC->Gspos("S09B",2*index-1,volNam9, xx, yborder, 0. , 0, "ONLY");
1147          gMC->Gspos("S09B",2*index  ,volNam9, xx,-yborder, 0. , 0, "ONLY");
1148          gMC->Gspos("S10B",2*index-1,volNam10, xx, yborder, 0. , 0, "ONLY");
1149          gMC->Gspos("S10B",2*index  ,volNam10, xx,-yborder, 0. , 0, "ONLY");
1150        } 
1151      }
1152
1153      // create the NULOC volume and position it in the horizontal frame
1154      
1155      gMC->Gsvolu("S09N","BOX",nulocMaterial,nulocpar,3);
1156      gMC->Gsvolu("S10N","BOX",nulocMaterial,nulocpar,3);
1157  
1158      index = 0; 
1159      for (xx = -xxmax; xx<=xxmax; xx+=3*nulocLength) { 
1160        index++; 
1161        gMC->Gspos("S09N",2*index-1,"S09B", xx, 0.,-bFrameWidth/4., 0, "ONLY");
1162        gMC->Gspos("S09N",2*index  ,"S09B", xx, 0., bFrameWidth/4., 0, "ONLY");
1163        gMC->Gspos("S10N",2*index-1,"S10B", xx, 0.,-bFrameWidth/4., 0, "ONLY");
1164        gMC->Gspos("S10N",2*index  ,"S10B", xx, 0., bFrameWidth/4., 0, "ONLY");
1165      }
1166
1167      // create the gassiplex volume 
1168      
1169      gMC->Gsvolu("S09E","BOX",gassiMaterial,gassipar,3);
1170      gMC->Gsvolu("S10E","BOX",gassiMaterial,gassipar,3);
1171
1172
1173      // position 4 gassiplex in the nuloc
1174      
1175      gMC->Gspos("S09E",1,"S09N", 0., -3 * nulocHeight/8., 0. , 0, "ONLY");
1176      gMC->Gspos("S09E",2,"S09N", 0.,    - nulocHeight/8., 0. , 0, "ONLY");
1177      gMC->Gspos("S09E",3,"S09N", 0.,      nulocHeight/8., 0. , 0, "ONLY");
1178      gMC->Gspos("S09E",4,"S09N", 0.,  3 * nulocHeight/8., 0. , 0, "ONLY");
1179      gMC->Gspos("S10E",1,"S10N", 0., -3 * nulocHeight/8., 0. , 0, "ONLY");
1180      gMC->Gspos("S10E",2,"S10N", 0.,    - nulocHeight/8., 0. , 0, "ONLY");
1181      gMC->Gspos("S10E",3,"S10N", 0.,      nulocHeight/8., 0. , 0, "ONLY");
1182      gMC->Gspos("S10E",4,"S10N", 0.,  3 * nulocHeight/8., 0. , 0, "ONLY");
1183      
1184  }
1185  
1186
1187 ///////////////////////////////////////
1188 // GEOMETRY FOR THE TRIGGER CHAMBERS //
1189 ///////////////////////////////////////
1190
1191 // 03/00 P. Dupieux : introduce a slighly more realistic  
1192 //                    geom. of the trigger readout planes with
1193 //                    2 Zpos per trigger plane (alternate
1194 //                    between left and right of the trigger)  
1195
1196 //  Parameters of the Trigger Chambers
1197
1198                 
1199      const Float_t kXMC1MIN=34.;       
1200      const Float_t kXMC1MED=51.;                                
1201      const Float_t kXMC1MAX=272.;                               
1202      const Float_t kYMC1MIN=34.;                              
1203      const Float_t kYMC1MAX=51.;                              
1204      const Float_t kRMIN1=50.;
1205      const Float_t kRMAX1=62.;
1206      const Float_t kRMIN2=50.;
1207      const Float_t kRMAX2=66.;
1208
1209 //   zposition of the middle of the gas gap in mother vol 
1210      const Float_t kZMCm=-3.6;
1211      const Float_t kZMCp=+3.6;
1212
1213
1214 // TRIGGER STATION 1 - TRIGGER STATION 1 - TRIGGER STATION 1
1215
1216      // iChamber 1 and 2 for first and second chambers in the station
1217      // iChamber (first chamber) kept for other quanties than Z,
1218      // assumed to be the same in both chambers
1219      iChamber1 = iChamber = (AliMUONChamber*) (*fChambers)[10];
1220      iChamber2 =(AliMUONChamber*) (*fChambers)[11]; 
1221
1222      // 03/00 
1223      // zpos1 and zpos2 are now the middle of the first and second
1224      // plane of station 1 : 
1225      // zpos1=(16075+15995)/2=16035 mm, thick/2=40 mm
1226      // zpos2=(16225+16145)/2=16185 mm, thick/2=40 mm
1227      //
1228      // zpos1m=15999 mm , zpos1p=16071 mm (middles of gas gaps)
1229      // zpos2m=16149 mm , zpos2p=16221 mm (middles of gas gaps)
1230      // rem : the total thickness accounts for 1 mm of al on both 
1231      // side of the RPCs (see zpos1 and zpos2), as previously
1232
1233      zpos1=iChamber1->Z();
1234      zpos2=iChamber2->Z();
1235
1236
1237 // Mother volume definition     
1238      tpar[0] = iChamber->RInner(); 
1239      tpar[1] = iChamber->ROuter();
1240      tpar[2] = 4.0;    
1241      gMC->Gsvolu("CM11", "TUBE", idAir, tpar, 3);
1242      gMC->Gsvolu("CM12", "TUBE", idAir, tpar, 3);
1243      
1244 // Definition of the flange between the beam shielding and the RPC 
1245      tpar[0]= kRMIN1;
1246      tpar[1]= kRMAX1;
1247      tpar[2]= 4.0;
1248    
1249      gMC->Gsvolu("CF1A", "TUBE", idAlu1, tpar, 3);     //Al
1250      gMC->Gspos("CF1A", 1, "CM11", 0., 0., 0., 0, "MANY");
1251      gMC->Gspos("CF1A", 2, "CM12", 0., 0., 0., 0, "MANY");
1252
1253
1254 // FIRST PLANE OF STATION 1
1255
1256 //   ratios of zpos1m/zpos1p and inverse for first plane
1257      Float_t zmp=(zpos1-3.6)/(zpos1+3.6);
1258      Float_t zpm=1./zmp;
1259    
1260
1261 // Definition of prototype for chambers in the first plane     
1262           
1263      tpar[0]= 0.;
1264      tpar[1]= 0.;
1265      tpar[2]= 0.;
1266           
1267      gMC->Gsvolu("CC1A", "BOX ", idAlu1, tpar, 0);           //Al    
1268      gMC->Gsvolu("CB1A", "BOX ", idtmed[1107], tpar, 0);     //Bakelite 
1269      gMC->Gsvolu("CG1A", "BOX ", idtmed[1106], tpar, 0);     //Gas streamer
1270
1271 // chamber type A
1272      tpar[0] = -1.;
1273      tpar[1] = -1.;
1274      
1275      const Float_t kXMC1A=kXMC1MED+(kXMC1MAX-kXMC1MED)/2.;
1276      const Float_t kYMC1Am=0.;
1277      const Float_t kYMC1Ap=0.;
1278           
1279      tpar[2] = 0.1;    
1280      gMC->Gsposp("CG1A", 1, "CB1A", 0., 0., 0., 0, "ONLY",tpar,3);
1281      tpar[2] = 0.3;
1282      gMC->Gsposp("CB1A", 1, "CC1A", 0., 0., 0., 0, "ONLY",tpar,3);
1283
1284      tpar[2] = 0.4;
1285      tpar[0] = (kXMC1MAX-kXMC1MED)/2.;
1286      tpar[1] = kYMC1MIN;
1287
1288      gMC->Gsposp("CC1A", 1, "CM11",kXMC1A,kYMC1Am,kZMCm, 0, "ONLY", tpar, 3);
1289      gMC->Gsposp("CC1A", 2, "CM11",-kXMC1A,kYMC1Ap,kZMCp, 0, "ONLY", tpar, 3);
1290      
1291 //  chamber type B    
1292      Float_t tpar1save=tpar[1];
1293      Float_t y1msave=kYMC1Am;
1294      Float_t y1psave=kYMC1Ap;
1295  
1296      tpar[0] = (kXMC1MAX-kXMC1MIN)/2.;
1297      tpar[1] = (kYMC1MAX-kYMC1MIN)/2.;
1298      
1299      const Float_t kXMC1B=kXMC1MIN+tpar[0];
1300      const Float_t kYMC1Bp=(y1msave+tpar1save)*zpm+tpar[1];
1301      const Float_t kYMC1Bm=(y1psave+tpar1save)*zmp+tpar[1];
1302
1303      gMC->Gsposp("CC1A", 3, "CM11",kXMC1B,kYMC1Bp,kZMCp, 0, "ONLY", tpar, 3);
1304      gMC->Gsposp("CC1A", 4, "CM11",-kXMC1B,kYMC1Bm,kZMCm, 0, "ONLY", tpar, 3);
1305      gMC->Gsposp("CC1A", 5, "CM11",kXMC1B,-kYMC1Bp,kZMCp, 0, "ONLY", tpar, 3);
1306      gMC->Gsposp("CC1A", 6, "CM11",-kXMC1B,-kYMC1Bm,kZMCm, 0, "ONLY", tpar, 3);
1307      
1308 //  chamber type C  (end of type B !!)      
1309      tpar1save=tpar[1];
1310      y1msave=kYMC1Bm;
1311      y1psave=kYMC1Bp;
1312
1313      tpar[0] = kXMC1MAX/2;
1314      tpar[1] = kYMC1MAX/2;
1315      
1316      const Float_t kXMC1C=tpar[0];
1317 // warning : same Z than type B
1318      const Float_t kYMC1Cp=(y1psave+tpar1save)*1.+tpar[1];
1319      const Float_t kYMC1Cm=(y1msave+tpar1save)*1.+tpar[1];
1320      
1321      gMC->Gsposp("CC1A", 7, "CM11",kXMC1C,kYMC1Cp,kZMCp, 0, "ONLY", tpar, 3);
1322      gMC->Gsposp("CC1A", 8, "CM11",-kXMC1C,kYMC1Cm,kZMCm, 0, "ONLY", tpar, 3);
1323      gMC->Gsposp("CC1A", 9, "CM11",kXMC1C,-kYMC1Cp,kZMCp, 0, "ONLY", tpar, 3);
1324      gMC->Gsposp("CC1A", 10, "CM11",-kXMC1C,-kYMC1Cm,kZMCm, 0, "ONLY", tpar, 3);
1325      
1326 //  chamber type D, E and F (same size)        
1327      tpar1save=tpar[1];
1328      y1msave=kYMC1Cm;
1329      y1psave=kYMC1Cp;
1330
1331      tpar[0] = kXMC1MAX/2.;
1332      tpar[1] = kYMC1MIN;
1333      
1334      const Float_t kXMC1D=tpar[0];
1335      const Float_t kYMC1Dp=(y1msave+tpar1save)*zpm+tpar[1];
1336      const Float_t kYMC1Dm=(y1psave+tpar1save)*zmp+tpar[1];
1337      
1338      gMC->Gsposp("CC1A", 11, "CM11",kXMC1D,kYMC1Dm,kZMCm, 0, "ONLY", tpar, 3);
1339      gMC->Gsposp("CC1A", 12, "CM11",-kXMC1D,kYMC1Dp,kZMCp, 0, "ONLY", tpar, 3);
1340      gMC->Gsposp("CC1A", 13, "CM11",kXMC1D,-kYMC1Dm,kZMCm, 0, "ONLY", tpar, 3);
1341      gMC->Gsposp("CC1A", 14, "CM11",-kXMC1D,-kYMC1Dp,kZMCp, 0, "ONLY", tpar, 3);
1342
1343
1344      tpar1save=tpar[1];
1345      y1msave=kYMC1Dm;
1346      y1psave=kYMC1Dp;
1347      const Float_t kYMC1Ep=(y1msave+tpar1save)*zpm+tpar[1];
1348      const Float_t kYMC1Em=(y1psave+tpar1save)*zmp+tpar[1];
1349      
1350      gMC->Gsposp("CC1A", 15, "CM11",kXMC1D,kYMC1Ep,kZMCp, 0, "ONLY", tpar, 3);
1351      gMC->Gsposp("CC1A", 16, "CM11",-kXMC1D,kYMC1Em,kZMCm, 0, "ONLY", tpar, 3);
1352      gMC->Gsposp("CC1A", 17, "CM11",kXMC1D,-kYMC1Ep,kZMCp, 0, "ONLY", tpar, 3);
1353      gMC->Gsposp("CC1A", 18, "CM11",-kXMC1D,-kYMC1Em,kZMCm, 0, "ONLY", tpar, 3);
1354
1355      tpar1save=tpar[1];
1356      y1msave=kYMC1Em;
1357      y1psave=kYMC1Ep;
1358      const Float_t kYMC1Fp=(y1msave+tpar1save)*zpm+tpar[1];
1359      const Float_t kYMC1Fm=(y1psave+tpar1save)*zmp+tpar[1];
1360     
1361      gMC->Gsposp("CC1A", 19, "CM11",kXMC1D,kYMC1Fm,kZMCm, 0, "ONLY", tpar, 3);
1362      gMC->Gsposp("CC1A", 20, "CM11",-kXMC1D,kYMC1Fp,kZMCp, 0, "ONLY", tpar, 3);
1363      gMC->Gsposp("CC1A", 21, "CM11",kXMC1D,-kYMC1Fm,kZMCm, 0, "ONLY", tpar, 3);
1364      gMC->Gsposp("CC1A", 22, "CM11",-kXMC1D,-kYMC1Fp,kZMCp, 0, "ONLY", tpar, 3);
1365
1366 // Positioning first plane in ALICE     
1367      gMC->Gspos("CM11", 1, "ALIC", 0., 0., zpos1, 0, "ONLY");
1368
1369 // End of geometry definition for the first plane of station 1
1370
1371
1372
1373 // SECOND PLANE OF STATION 1 : proj ratio = zpos2/zpos1
1374
1375      const Float_t kZ12=zpos2/zpos1;
1376       
1377 // Definition of prototype for chambers in the second plane of station 1    
1378           
1379      tpar[0]= 0.;
1380      tpar[1]= 0.;
1381      tpar[2]= 0.;
1382           
1383      gMC->Gsvolu("CC2A", "BOX ", idAlu1, tpar, 0);           //Al    
1384      gMC->Gsvolu("CB2A", "BOX ", idtmed[1107], tpar, 0);     //Bakelite 
1385      gMC->Gsvolu("CG2A", "BOX ", idtmed[1106], tpar, 0);     //Gas streamer
1386
1387 // chamber type A
1388      tpar[0] = -1.;
1389      tpar[1] = -1.;
1390      
1391      const Float_t kXMC2A=kXMC1A*kZ12;
1392      const Float_t kYMC2Am=0.;
1393      const Float_t kYMC2Ap=0.;
1394           
1395      tpar[2] = 0.1;    
1396      gMC->Gsposp("CG2A", 1, "CB2A", 0., 0., 0., 0, "ONLY",tpar,3);
1397      tpar[2] = 0.3;
1398      gMC->Gsposp("CB2A", 1, "CC2A", 0., 0., 0., 0, "ONLY",tpar,3);
1399
1400      tpar[2] = 0.4;
1401      tpar[0] = ((kXMC1MAX-kXMC1MED)/2.)*kZ12;
1402      tpar[1] = kYMC1MIN*kZ12;
1403
1404      gMC->Gsposp("CC2A", 1, "CM12",kXMC2A,kYMC2Am,kZMCm, 0, "ONLY", tpar, 3);
1405      gMC->Gsposp("CC2A", 2, "CM12",-kXMC2A,kYMC2Ap,kZMCp, 0, "ONLY", tpar, 3);
1406      
1407
1408 //  chamber type B    
1409
1410      tpar[0] = ((kXMC1MAX-kXMC1MIN)/2.)*kZ12;
1411      tpar[1] = ((kYMC1MAX-kYMC1MIN)/2.)*kZ12;
1412      
1413      const Float_t kXMC2B=kXMC1B*kZ12;
1414      const Float_t kYMC2Bp=kYMC1Bp*kZ12;
1415      const Float_t kYMC2Bm=kYMC1Bm*kZ12;
1416      gMC->Gsposp("CC2A", 3, "CM12",kXMC2B,kYMC2Bp,kZMCp, 0, "ONLY", tpar, 3);
1417      gMC->Gsposp("CC2A", 4, "CM12",-kXMC2B,kYMC2Bm,kZMCm, 0, "ONLY", tpar, 3);
1418      gMC->Gsposp("CC2A", 5, "CM12",kXMC2B,-kYMC2Bp,kZMCp, 0, "ONLY", tpar, 3);
1419      gMC->Gsposp("CC2A", 6, "CM12",-kXMC2B,-kYMC2Bm,kZMCm, 0, "ONLY", tpar, 3);
1420
1421      
1422 //  chamber type C   (end of type B !!)     
1423
1424      tpar[0] = (kXMC1MAX/2)*kZ12;
1425      tpar[1] = (kYMC1MAX/2)*kZ12;
1426      
1427      const Float_t kXMC2C=kXMC1C*kZ12;
1428      const Float_t kYMC2Cp=kYMC1Cp*kZ12;
1429      const Float_t kYMC2Cm=kYMC1Cm*kZ12;     
1430      gMC->Gsposp("CC2A", 7, "CM12",kXMC2C,kYMC2Cp,kZMCp, 0, "ONLY", tpar, 3);
1431      gMC->Gsposp("CC2A", 8, "CM12",-kXMC2C,kYMC2Cm,kZMCm, 0, "ONLY", tpar, 3);
1432      gMC->Gsposp("CC2A", 9, "CM12",kXMC2C,-kYMC2Cp,kZMCp, 0, "ONLY", tpar, 3);
1433      gMC->Gsposp("CC2A", 10, "CM12",-kXMC2C,-kYMC2Cm,kZMCm, 0, "ONLY", tpar, 3);
1434      
1435 //  chamber type D, E and F (same size)        
1436
1437      tpar[0] = (kXMC1MAX/2.)*kZ12;
1438      tpar[1] = kYMC1MIN*kZ12;
1439      
1440      const Float_t kXMC2D=kXMC1D*kZ12;
1441      const Float_t kYMC2Dp=kYMC1Dp*kZ12;
1442      const Float_t kYMC2Dm=kYMC1Dm*kZ12;     
1443      gMC->Gsposp("CC2A", 11, "CM12",kXMC2D,kYMC2Dm,kZMCm, 0, "ONLY", tpar, 3);
1444      gMC->Gsposp("CC2A", 12, "CM12",-kXMC2D,kYMC2Dp,kZMCp, 0, "ONLY", tpar, 3);
1445      gMC->Gsposp("CC2A", 13, "CM12",kXMC2D,-kYMC2Dm,kZMCm, 0, "ONLY", tpar, 3);
1446      gMC->Gsposp("CC2A", 14, "CM12",-kXMC2D,-kYMC2Dp,kZMCp, 0, "ONLY", tpar, 3);
1447
1448      const Float_t kYMC2Ep=kYMC1Ep*kZ12;
1449      const Float_t kYMC2Em=kYMC1Em*kZ12;
1450      gMC->Gsposp("CC2A", 15, "CM12",kXMC2D,kYMC2Ep,kZMCp, 0, "ONLY", tpar, 3);
1451      gMC->Gsposp("CC2A", 16, "CM12",-kXMC2D,kYMC2Em,kZMCm, 0, "ONLY", tpar, 3);
1452      gMC->Gsposp("CC2A", 17, "CM12",kXMC2D,-kYMC2Ep,kZMCp, 0, "ONLY", tpar, 3);
1453      gMC->Gsposp("CC2A", 18, "CM12",-kXMC2D,-kYMC2Em,kZMCm, 0, "ONLY", tpar, 3);
1454
1455
1456      const Float_t kYMC2Fp=kYMC1Fp*kZ12;
1457      const Float_t kYMC2Fm=kYMC1Fm*kZ12;
1458      gMC->Gsposp("CC2A", 19, "CM12",kXMC2D,kYMC2Fm,kZMCm, 0, "ONLY", tpar, 3);
1459      gMC->Gsposp("CC2A", 20, "CM12",-kXMC2D,kYMC2Fp,kZMCp, 0, "ONLY", tpar, 3);
1460      gMC->Gsposp("CC2A", 21, "CM12",kXMC2D,-kYMC2Fm,kZMCm, 0, "ONLY", tpar, 3);
1461      gMC->Gsposp("CC2A", 22, "CM12",-kXMC2D,-kYMC2Fp,kZMCp, 0, "ONLY", tpar, 3);
1462
1463 // Positioning second plane of station 1 in ALICE     
1464      
1465      gMC->Gspos("CM12", 1, "ALIC", 0., 0., zpos2, 0, "ONLY");
1466
1467 // End of geometry definition for the second plane of station 1
1468
1469
1470
1471 // TRIGGER STATION 2 - TRIGGER STATION 2 - TRIGGER STATION 2    
1472
1473      // 03/00 
1474      // zpos3 and zpos4 are now the middle of the first and second
1475      // plane of station 2 : 
1476      // zpos3=(17075+16995)/2=17035 mm, thick/2=40 mm
1477      // zpos4=(17225+17145)/2=17185 mm, thick/2=40 mm
1478      //
1479      // zpos3m=16999 mm , zpos3p=17071 mm (middles of gas gaps)
1480      // zpos4m=17149 mm , zpos4p=17221 mm (middles of gas gaps)
1481      // rem : the total thickness accounts for 1 mm of al on both 
1482      // side of the RPCs (see zpos3 and zpos4), as previously
1483      iChamber1 = iChamber = (AliMUONChamber*) (*fChambers)[12];
1484      iChamber2 =(AliMUONChamber*) (*fChambers)[13];
1485      Float_t zpos3=iChamber1->Z();
1486      Float_t zpos4=iChamber2->Z();
1487
1488
1489 // Mother volume definition     
1490      tpar[0] = iChamber->RInner(); 
1491      tpar[1] = iChamber->ROuter();
1492      tpar[2] = 4.0;    
1493  
1494      gMC->Gsvolu("CM21", "TUBE", idAir, tpar, 3);
1495      gMC->Gsvolu("CM22", "TUBE", idAir, tpar, 3);
1496      
1497 // Definition of the flange between the beam shielding and the RPC 
1498 //  ???? interface shielding
1499
1500      tpar[0]= kRMIN2;
1501      tpar[1]= kRMAX2;
1502      tpar[2]= 4.0;
1503    
1504      gMC->Gsvolu("CF2A", "TUBE", idAlu1, tpar, 3);            //Al
1505      gMC->Gspos("CF2A", 1, "CM21", 0., 0., 0., 0, "MANY");
1506      gMC->Gspos("CF2A", 2, "CM22", 0., 0., 0., 0, "MANY");
1507     
1508
1509
1510 // FIRST PLANE OF STATION 2 : proj ratio = zpos3/zpos1
1511
1512      const Float_t kZ13=zpos3/zpos1; 
1513
1514 // Definition of prototype for chambers in the first plane of station 2       
1515      tpar[0]= 0.;
1516      tpar[1]= 0.;
1517      tpar[2]= 0.;
1518           
1519      gMC->Gsvolu("CC3A", "BOX ", idAlu1, tpar, 0);           //Al  
1520      gMC->Gsvolu("CB3A", "BOX ", idtmed[1107], tpar, 0);     //Bakelite 
1521      gMC->Gsvolu("CG3A", "BOX ", idtmed[1106], tpar, 0);     //Gas streamer
1522
1523
1524 // chamber type A
1525      tpar[0] = -1.;
1526      tpar[1] = -1.;
1527      
1528      const Float_t kXMC3A=kXMC1A*kZ13;
1529      const Float_t kYMC3Am=0.;
1530      const Float_t kYMC3Ap=0.;
1531           
1532      tpar[2] = 0.1;    
1533      gMC->Gsposp("CG3A", 1, "CB3A", 0., 0., 0., 0, "ONLY",tpar,3);
1534      tpar[2] = 0.3;
1535      gMC->Gsposp("CB3A", 1, "CC3A", 0., 0., 0., 0, "ONLY",tpar,3);
1536
1537      tpar[2] = 0.4;
1538      tpar[0] = ((kXMC1MAX-kXMC1MED)/2.)*kZ13;
1539      tpar[1] = kYMC1MIN*kZ13;
1540      gMC->Gsposp("CC3A", 1, "CM21",kXMC3A,kYMC3Am,kZMCm, 0, "ONLY", tpar, 3);
1541      gMC->Gsposp("CC3A", 2, "CM21",-kXMC3A,kYMC3Ap,kZMCp, 0, "ONLY", tpar, 3);
1542
1543      
1544 //  chamber type B    
1545      tpar[0] = ((kXMC1MAX-kXMC1MIN)/2.)*kZ13;
1546      tpar[1] = ((kYMC1MAX-kYMC1MIN)/2.)*kZ13;
1547      
1548      const Float_t kXMC3B=kXMC1B*kZ13;
1549      const Float_t kYMC3Bp=kYMC1Bp*kZ13;
1550      const Float_t kYMC3Bm=kYMC1Bm*kZ13;
1551      gMC->Gsposp("CC3A", 3, "CM21",kXMC3B,kYMC3Bp,kZMCp, 0, "ONLY", tpar, 3);
1552      gMC->Gsposp("CC3A", 4, "CM21",-kXMC3B,kYMC3Bm,kZMCm, 0, "ONLY", tpar, 3);
1553      gMC->Gsposp("CC3A", 5, "CM21",kXMC3B,-kYMC3Bp,kZMCp, 0, "ONLY", tpar, 3);
1554      gMC->Gsposp("CC3A", 6, "CM21",-kXMC3B,-kYMC3Bm,kZMCm, 0, "ONLY", tpar, 3);
1555
1556      
1557 //  chamber type C  (end of type B !!)      
1558      tpar[0] = (kXMC1MAX/2)*kZ13;
1559      tpar[1] = (kYMC1MAX/2)*kZ13;
1560      
1561      const Float_t kXMC3C=kXMC1C*kZ13;
1562      const Float_t kYMC3Cp=kYMC1Cp*kZ13;
1563      const Float_t kYMC3Cm=kYMC1Cm*kZ13;     
1564      gMC->Gsposp("CC3A", 7, "CM21",kXMC3C,kYMC3Cp,kZMCp, 0, "ONLY", tpar, 3);
1565      gMC->Gsposp("CC3A", 8, "CM21",-kXMC3C,kYMC3Cm,kZMCm, 0, "ONLY", tpar, 3);
1566      gMC->Gsposp("CC3A", 9, "CM21",kXMC3C,-kYMC3Cp,kZMCp, 0, "ONLY", tpar, 3);
1567      gMC->Gsposp("CC3A", 10, "CM21",-kXMC3C,-kYMC3Cm,kZMCm, 0, "ONLY", tpar, 3);
1568      
1569
1570 //  chamber type D, E and F (same size)         
1571
1572      tpar[0] = (kXMC1MAX/2.)*kZ13;
1573      tpar[1] = kYMC1MIN*kZ13;
1574      
1575      const Float_t kXMC3D=kXMC1D*kZ13;
1576      const Float_t kYMC3Dp=kYMC1Dp*kZ13;
1577      const Float_t kYMC3Dm=kYMC1Dm*kZ13;          
1578      gMC->Gsposp("CC3A", 11, "CM21",kXMC3D,kYMC3Dm,kZMCm, 0, "ONLY", tpar, 3);
1579      gMC->Gsposp("CC3A", 12, "CM21",-kXMC3D,kYMC3Dp,kZMCp, 0, "ONLY", tpar, 3);
1580      gMC->Gsposp("CC3A", 13, "CM21",kXMC3D,-kYMC3Dm,kZMCm, 0, "ONLY", tpar, 3);
1581      gMC->Gsposp("CC3A", 14, "CM21",-kXMC3D,-kYMC3Dp,kZMCp, 0, "ONLY", tpar, 3);
1582
1583      const Float_t kYMC3Ep=kYMC1Ep*kZ13;
1584      const Float_t kYMC3Em=kYMC1Em*kZ13;
1585      gMC->Gsposp("CC3A", 15, "CM21",kXMC3D,kYMC3Ep,kZMCp, 0, "ONLY", tpar, 3);
1586      gMC->Gsposp("CC3A", 16, "CM21",-kXMC3D,kYMC3Em,kZMCm, 0, "ONLY", tpar, 3);
1587      gMC->Gsposp("CC3A", 17, "CM21",kXMC3D,-kYMC3Ep,kZMCp, 0, "ONLY", tpar, 3);
1588      gMC->Gsposp("CC3A", 18, "CM21",-kXMC3D,-kYMC3Em,kZMCm, 0, "ONLY", tpar, 3);
1589
1590      const Float_t kYMC3Fp=kYMC1Fp*kZ13;
1591      const Float_t kYMC3Fm=kYMC1Fm*kZ13;
1592      gMC->Gsposp("CC3A", 19, "CM21",kXMC3D,kYMC3Fm,kZMCm, 0, "ONLY", tpar, 3);
1593      gMC->Gsposp("CC3A", 20, "CM21",-kXMC3D,kYMC3Fp,kZMCp, 0, "ONLY", tpar, 3);
1594      gMC->Gsposp("CC3A", 21, "CM21",kXMC3D,-kYMC3Fm,kZMCm, 0, "ONLY", tpar, 3);
1595      gMC->Gsposp("CC3A", 22, "CM21",-kXMC3D,-kYMC3Fp,kZMCp, 0, "ONLY", tpar, 3);
1596        
1597
1598 // Positioning first plane of station 2 in ALICE
1599      
1600      gMC->Gspos("CM21", 1, "ALIC", 0., 0., zpos3, 0, "ONLY");
1601
1602 // End of geometry definition for the first plane of station 2
1603
1604
1605
1606
1607 // SECOND PLANE OF STATION 2 : proj ratio = zpos4/zpos1
1608
1609      const Float_t kZ14=zpos4/zpos1;
1610      
1611 // Definition of prototype for chambers in the second plane of station 2    
1612           
1613      tpar[0]= 0.;
1614      tpar[1]= 0.;
1615      tpar[2]= 0.;
1616           
1617      gMC->Gsvolu("CC4A", "BOX ", idAlu1, tpar, 0);           //Al      
1618      gMC->Gsvolu("CB4A", "BOX ", idtmed[1107], tpar, 0);     //Bakelite 
1619      gMC->Gsvolu("CG4A", "BOX ", idtmed[1106], tpar, 0);     //Gas streamer
1620
1621 // chamber type A
1622      tpar[0] = -1.;
1623      tpar[1] = -1.;
1624      
1625      const Float_t kXMC4A=kXMC1A*kZ14;
1626      const Float_t kYMC4Am=0.;
1627      const Float_t kYMC4Ap=0.;
1628           
1629      tpar[2] = 0.1;    
1630      gMC->Gsposp("CG4A", 1, "CB4A", 0., 0., 0., 0, "ONLY",tpar,3);
1631      tpar[2] = 0.3;
1632      gMC->Gsposp("CB4A", 1, "CC4A", 0., 0., 0., 0, "ONLY",tpar,3);
1633
1634      tpar[2] = 0.4;
1635      tpar[0] = ((kXMC1MAX-kXMC1MED)/2.)*kZ14;
1636      tpar[1] = kYMC1MIN*kZ14;
1637      gMC->Gsposp("CC4A", 1, "CM22",kXMC4A,kYMC4Am,kZMCm, 0, "ONLY", tpar, 3);
1638      gMC->Gsposp("CC4A", 2, "CM22",-kXMC4A,kYMC4Ap,kZMCp, 0, "ONLY", tpar, 3);
1639      
1640
1641 //  chamber type B    
1642      tpar[0] = ((kXMC1MAX-kXMC1MIN)/2.)*kZ14;
1643      tpar[1] = ((kYMC1MAX-kYMC1MIN)/2.)*kZ14;
1644      
1645      const Float_t kXMC4B=kXMC1B*kZ14;
1646      const Float_t kYMC4Bp=kYMC1Bp*kZ14;
1647      const Float_t kYMC4Bm=kYMC1Bm*kZ14;
1648      gMC->Gsposp("CC4A", 3, "CM22",kXMC4B,kYMC4Bp,kZMCp, 0, "ONLY", tpar, 3);
1649      gMC->Gsposp("CC4A", 4, "CM22",-kXMC4B,kYMC4Bm,kZMCm, 0, "ONLY", tpar, 3);
1650      gMC->Gsposp("CC4A", 5, "CM22",kXMC4B,-kYMC4Bp,kZMCp, 0, "ONLY", tpar, 3);
1651      gMC->Gsposp("CC4A", 6, "CM22",-kXMC4B,-kYMC4Bm,kZMCm, 0, "ONLY", tpar, 3);
1652
1653      
1654 //  chamber type C   (end of type B !!)      
1655      tpar[0] =(kXMC1MAX/2)*kZ14;
1656      tpar[1] =  (kYMC1MAX/2)*kZ14;
1657      
1658      const Float_t kXMC4C=kXMC1C*kZ14;
1659      const Float_t kYMC4Cp=kYMC1Cp*kZ14;
1660      const Float_t kYMC4Cm=kYMC1Cm*kZ14;     
1661      gMC->Gsposp("CC4A", 7, "CM22",kXMC4C,kYMC4Cp,kZMCp, 0, "ONLY", tpar, 3);
1662      gMC->Gsposp("CC4A", 8, "CM22",-kXMC4C,kYMC4Cm,kZMCm, 0, "ONLY", tpar, 3);
1663      gMC->Gsposp("CC4A", 9, "CM22",kXMC4C,-kYMC4Cp,kZMCp, 0, "ONLY", tpar, 3);
1664      gMC->Gsposp("CC4A", 10, "CM22",-kXMC4C,-kYMC4Cm,kZMCm, 0, "ONLY", tpar, 3);
1665
1666      
1667 //  chamber type D, E and F (same size)      
1668      tpar[0] = (kXMC1MAX/2.)*kZ14;
1669      tpar[1] =  kYMC1MIN*kZ14;
1670      
1671      const Float_t kXMC4D=kXMC1D*kZ14;
1672      const Float_t kYMC4Dp=kYMC1Dp*kZ14;
1673      const Float_t kYMC4Dm=kYMC1Dm*kZ14;          
1674      gMC->Gsposp("CC4A", 11, "CM22",kXMC4D,kYMC4Dm,kZMCm, 0, "ONLY", tpar, 3);
1675      gMC->Gsposp("CC4A", 12, "CM22",-kXMC4D,kYMC4Dp,kZMCp, 0, "ONLY", tpar, 3);
1676      gMC->Gsposp("CC4A", 13, "CM22",kXMC4D,-kYMC4Dm,kZMCm, 0, "ONLY", tpar, 3);
1677      gMC->Gsposp("CC4A", 14, "CM22",-kXMC4D,-kYMC4Dp,kZMCp, 0, "ONLY", tpar, 3);
1678
1679      const Float_t kYMC4Ep=kYMC1Ep*kZ14;
1680      const Float_t kYMC4Em=kYMC1Em*kZ14;          
1681      gMC->Gsposp("CC4A", 15, "CM22",kXMC4D,kYMC4Ep,kZMCp, 0, "ONLY", tpar, 3);
1682      gMC->Gsposp("CC4A", 16, "CM22",-kXMC4D,kYMC4Em,kZMCm, 0, "ONLY", tpar, 3);
1683      gMC->Gsposp("CC4A", 17, "CM22",kXMC4D,-kYMC4Ep,kZMCp, 0, "ONLY", tpar, 3);
1684      gMC->Gsposp("CC4A", 18, "CM22",-kXMC4D,-kYMC4Em,kZMCm, 0, "ONLY", tpar, 3);
1685
1686      const Float_t kYMC4Fp=kYMC1Fp*kZ14;
1687      const Float_t kYMC4Fm=kYMC1Fm*kZ14;          
1688      gMC->Gsposp("CC4A", 19, "CM22",kXMC4D,kYMC4Fm,kZMCm, 0, "ONLY", tpar, 3);
1689      gMC->Gsposp("CC4A", 20, "CM22",-kXMC4D,kYMC4Fp,kZMCp, 0, "ONLY", tpar, 3);
1690      gMC->Gsposp("CC4A", 21, "CM22",kXMC4D,-kYMC4Fm,kZMCm, 0, "ONLY", tpar, 3);
1691      gMC->Gsposp("CC4A", 22, "CM22",-kXMC4D,-kYMC4Fp,kZMCp, 0, "ONLY", tpar, 3);
1692      
1693
1694 // Positioning second plane of station 2 in ALICE
1695      
1696      gMC->Gspos("CM22", 1, "ALIC", 0., 0., zpos4, 0, "ONLY");
1697
1698 // End of geometry definition for the second plane of station 2
1699
1700 // End of trigger geometry definition
1701
1702 }
1703
1704
1705  
1706 //___________________________________________
1707 void AliMUONv1::CreateMaterials()
1708 {
1709   // *** DEFINITION OF AVAILABLE MUON MATERIALS *** 
1710   //
1711   //     Ar-CO2 gas 
1712     Float_t ag1[3]   = { 39.95,12.01,16. };
1713     Float_t zg1[3]   = { 18.,6.,8. };
1714     Float_t wg1[3]   = { .8,.0667,.13333 };
1715     Float_t dg1      = .001821;
1716     //
1717     //     Ar-buthane-freon gas -- trigger chambers 
1718     Float_t atr1[4]  = { 39.95,12.01,1.01,19. };
1719     Float_t ztr1[4]  = { 18.,6.,1.,9. };
1720     Float_t wtr1[4]  = { .56,.1262857,.2857143,.028 };
1721     Float_t dtr1     = .002599;
1722     //
1723     //     Ar-CO2 gas 
1724     Float_t agas[3]  = { 39.95,12.01,16. };
1725     Float_t zgas[3]  = { 18.,6.,8. };
1726     Float_t wgas[3]  = { .74,.086684,.173316 };
1727     Float_t dgas     = .0018327;
1728     //
1729     //     Ar-Isobutane gas (80%+20%) -- tracking 
1730     Float_t ag[3]    = { 39.95,12.01,1.01 };
1731     Float_t zg[3]    = { 18.,6.,1. };
1732     Float_t wg[3]    = { .8,.057,.143 };
1733     Float_t dg       = .0019596;
1734     //
1735     //     Ar-Isobutane-Forane-SF6 gas (49%+7%+40%+4%) -- trigger 
1736     Float_t atrig[5] = { 39.95,12.01,1.01,19.,32.066 };
1737     Float_t ztrig[5] = { 18.,6.,1.,9.,16. };
1738     Float_t wtrig[5] = { .49,1.08,1.5,1.84,0.04 };
1739     Float_t dtrig    = .0031463;
1740     //
1741     //     bakelite 
1742
1743     Float_t abak[3] = {12.01 , 1.01 , 16.};
1744     Float_t zbak[3] = {6.     , 1.   , 8.};
1745     Float_t wbak[3] = {6.     , 6.   , 1.}; 
1746     Float_t dbak = 1.4;
1747
1748     Float_t epsil, stmin, deemax, tmaxfd, stemax;
1749
1750     Int_t iSXFLD   = gAlice->Field()->Integ();
1751     Float_t sXMGMX = gAlice->Field()->Max();
1752     //
1753     // --- Define the various materials for GEANT --- 
1754     AliMaterial(9, "ALUMINIUM$", 26.98, 13., 2.7, 8.9, 37.2);
1755     AliMaterial(10, "ALUMINIUM$", 26.98, 13., 2.7, 8.9, 37.2);
1756     AliMaterial(15, "AIR$      ", 14.61, 7.3, .001205, 30423.24, 67500);
1757     AliMixture(19, "Bakelite$", abak, zbak, dbak, -3, wbak);
1758     AliMixture(20, "ArC4H10 GAS$", ag, zg, dg, 3, wg);
1759     AliMixture(21, "TRIG GAS$", atrig, ztrig, dtrig, -5, wtrig);
1760     AliMixture(22, "ArCO2 80%$", ag1, zg1, dg1, 3, wg1);
1761     AliMixture(23, "Ar-freon $", atr1, ztr1, dtr1, 4, wtr1);
1762     AliMixture(24, "ArCO2 GAS$", agas, zgas, dgas, 3, wgas);
1763     // materials for slat: 
1764     //     Sensitive area: gas (already defined) 
1765     //     PCB: copper 
1766     //     insulating material and frame: vetronite
1767     //     walls: carbon, rohacell, carbon 
1768   Float_t aglass[5]={12.01, 28.09, 16.,   10.8,  23.};
1769   Float_t zglass[5]={ 6.,   14.,    8.,    5.,   11.};
1770   Float_t wglass[5]={ 0.5,  0.105, 0.355, 0.03,  0.01};
1771   Float_t dglass=1.74;
1772
1773   // rohacell: C9 H13 N1 O2
1774   Float_t arohac[4] = {12.01,  1.01, 14.010, 16.};
1775   Float_t zrohac[4] = { 6.,    1.,    7.,     8.};
1776   Float_t wrohac[4] = { 9.,   13.,    1.,     2.};
1777   Float_t drohac    = 0.03;
1778
1779   AliMaterial(31, "COPPER$",   63.54,    29.,   8.96,  1.4, 0.);
1780   AliMixture(32, "Vetronite$",aglass, zglass, dglass,    5, wglass);
1781   AliMaterial(33, "Carbon$",   12.01,     6.,  2.265, 18.8, 49.9);
1782   AliMixture(34, "Rohacell$", arohac, zrohac, drohac,   -4, wrohac); 
1783
1784
1785     epsil  = .001; // Tracking precision, 
1786     stemax = -1.;  // Maximum displacement for multiple scat 
1787     tmaxfd = -20.; // Maximum angle due to field deflection 
1788     deemax = -.3;  // Maximum fractional energy loss, DLS 
1789     stmin  = -.8;
1790     //
1791     //    Air 
1792     AliMedium(1, "AIR_CH_US         ", 15, 1, iSXFLD, sXMGMX, tmaxfd, stemax, deemax, epsil, stmin);
1793     //
1794     //    Aluminum 
1795
1796     AliMedium(4, "ALU_CH_US          ", 9, 0, iSXFLD, sXMGMX, tmaxfd, fMaxStepAlu, 
1797             fMaxDestepAlu, epsil, stmin);
1798     AliMedium(5, "ALU_CH_US          ", 10, 0, iSXFLD, sXMGMX, tmaxfd, fMaxStepAlu, 
1799             fMaxDestepAlu, epsil, stmin);
1800     //
1801     //    Ar-isoC4H10 gas 
1802
1803     AliMedium(6, "AR_CH_US          ", 20, 1, iSXFLD, sXMGMX, tmaxfd, fMaxStepGas, 
1804             fMaxDestepGas, epsil, stmin);
1805 //
1806     //    Ar-Isobuthane-Forane-SF6 gas 
1807
1808     AliMedium(7, "GAS_CH_TRIGGER    ", 21, 1, iSXFLD, sXMGMX, tmaxfd, stemax, deemax, epsil, stmin);
1809
1810     AliMedium(8, "BAKE_CH_TRIGGER   ", 19, 0, iSXFLD, sXMGMX, tmaxfd, fMaxStepAlu, 
1811             fMaxDestepAlu, epsil, stmin);
1812
1813     AliMedium(9, "ARG_CO2   ", 22, 1, iSXFLD, sXMGMX, tmaxfd, fMaxStepGas, 
1814             fMaxDestepAlu, epsil, stmin);
1815     // tracking media for slats: check the parameters!! 
1816     AliMedium(11, "PCB_COPPER        ", 31, 0, iSXFLD, sXMGMX, tmaxfd, 
1817               fMaxStepAlu, fMaxDestepAlu, epsil, stmin);
1818     AliMedium(12, "VETRONITE         ", 32, 0, iSXFLD, sXMGMX, tmaxfd, 
1819               fMaxStepAlu, fMaxDestepAlu, epsil, stmin);
1820     AliMedium(13, "CARBON            ", 33, 0, iSXFLD, sXMGMX, tmaxfd, 
1821               fMaxStepAlu, fMaxDestepAlu, epsil, stmin);
1822     AliMedium(14, "Rohacell          ", 34, 0, iSXFLD, sXMGMX, tmaxfd, 
1823               fMaxStepAlu, fMaxDestepAlu, epsil, stmin);
1824 }
1825
1826 //___________________________________________
1827
1828 void AliMUONv1::Init()
1829 {
1830    // 
1831    // Initialize Tracking Chambers
1832    //
1833
1834    printf("\n\n\n Start Init for version 1 - CPC chamber type\n\n\n");
1835    Int_t i;
1836    for (i=0; i<AliMUONConstants::NCh(); i++) {
1837        ( (AliMUONChamber*) (*fChambers)[i])->Init();
1838    }
1839    
1840    //
1841    // Set the chamber (sensitive region) GEANT identifier
1842    AliMC* gMC = AliMC::GetMC(); 
1843    ((AliMUONChamber*)(*fChambers)[0])->SetGid(gMC->VolId("C01G"));
1844    ((AliMUONChamber*)(*fChambers)[1])->SetGid(gMC->VolId("C02G"));
1845
1846    ((AliMUONChamber*)(*fChambers)[2])->SetGid(gMC->VolId("C03G"));
1847    ((AliMUONChamber*)(*fChambers)[3])->SetGid(gMC->VolId("C04G"));
1848
1849    ((AliMUONChamber*)(*fChambers)[4])->SetGid(gMC->VolId("S05G"));
1850    ((AliMUONChamber*)(*fChambers)[5])->SetGid(gMC->VolId("S06G"));
1851
1852    ((AliMUONChamber*)(*fChambers)[6])->SetGid(gMC->VolId("S07G"));
1853    ((AliMUONChamber*)(*fChambers)[7])->SetGid(gMC->VolId("S08G"));
1854
1855    ((AliMUONChamber*)(*fChambers)[8])->SetGid(gMC->VolId("S09G"));
1856    ((AliMUONChamber*)(*fChambers)[9])->SetGid(gMC->VolId("S10G"));
1857
1858    ((AliMUONChamber*)(*fChambers)[10])->SetGid(gMC->VolId("CG1A"));
1859    ((AliMUONChamber*)(*fChambers)[11])->SetGid(gMC->VolId("CG2A"));
1860    ((AliMUONChamber*)(*fChambers)[12])->SetGid(gMC->VolId("CG3A"));
1861    ((AliMUONChamber*)(*fChambers)[13])->SetGid(gMC->VolId("CG4A"));
1862
1863    printf("\n\n\n Finished Init for version 0 - CPC chamber type\n\n\n");
1864
1865    //cp 
1866    printf("\n\n\n Start Init for Trigger Circuits\n\n\n");
1867    for (i=0; i<AliMUONConstants::NTriggerCircuit(); i++) {
1868      ( (AliMUONTriggerCircuit*) (*fTriggerCircuits)[i])->Init(i);
1869    }
1870    printf(" Finished Init for Trigger Circuits\n\n\n");
1871    //cp
1872
1873 }
1874
1875 //___________________________________________
1876 void AliMUONv1::StepManager()
1877 {
1878   Int_t          copy, id;
1879   static Int_t   idvol;
1880   static Int_t   vol[2];
1881   Int_t          ipart;
1882   TLorentzVector pos;
1883   TLorentzVector mom;
1884   Float_t        theta,phi;
1885   Float_t        destep, step;
1886   
1887   static Float_t eloss, eloss2, xhit, yhit, zhit, tof, tlength;
1888   const  Float_t kBig=1.e10;
1889   //  modifs perso
1890   static Float_t hits[15];
1891
1892   TClonesArray &lhits = *fHits;
1893
1894   //
1895   // Set maximum step size for gas
1896   // numed=gMC->GetMedium();
1897   //
1898   // Only charged tracks
1899   if( !(gMC->TrackCharge()) ) return; 
1900   //
1901   // Only gas gap inside chamber
1902   // Tag chambers and record hits when track enters 
1903   idvol=-1;
1904   id=gMC->CurrentVolID(copy);
1905   
1906     for (Int_t i=1; i<=AliMUONConstants::NCh(); i++) {
1907       if(id==((AliMUONChamber*)(*fChambers)[i-1])->GetGid()){ 
1908           vol[0]=i; 
1909           idvol=i-1;
1910       }
1911     }
1912     if (idvol == -1) return;
1913   //
1914   // Get current particle id (ipart), track position (pos)  and momentum (mom) 
1915   gMC->TrackPosition(pos);
1916   gMC->TrackMomentum(mom);
1917
1918   ipart  = gMC->TrackPid();
1919   //Int_t ipart1 = gMC->IdFromPDG(ipart);
1920   //printf("ich, ipart %d %d \n",vol[0],ipart1);
1921
1922   //
1923   // momentum loss and steplength in last step
1924   destep = gMC->Edep();
1925   step   = gMC->TrackStep();
1926   
1927   //
1928   // record hits when track enters ...
1929   if( gMC->IsTrackEntering()) {
1930       gMC->SetMaxStep(fMaxStepGas);
1931       Double_t tc = mom[0]*mom[0]+mom[1]*mom[1];
1932       Double_t rt = TMath::Sqrt(tc);
1933       Double_t pmom = TMath::Sqrt(tc+mom[2]*mom[2]);
1934       Double_t tx=mom[0]/pmom;
1935       Double_t ty=mom[1]/pmom;
1936       Double_t tz=mom[2]/pmom;
1937       Double_t s=((AliMUONChamber*)(*fChambers)[idvol])
1938           ->ResponseModel()
1939           ->Pitch()/tz;
1940       theta   = Float_t(TMath::ATan2(rt,Double_t(mom[2])))*kRaddeg;
1941       phi     = Float_t(TMath::ATan2(Double_t(mom[1]),Double_t(mom[0])))*kRaddeg;
1942       hits[0] = Float_t(ipart);         // Geant3 particle type
1943       hits[1] = pos[0]+s*tx;                 // X-position for hit
1944       hits[2] = pos[1]+s*ty;                 // Y-position for hit
1945       hits[3] = pos[2]+s*tz;                 // Z-position for hit
1946       hits[4] = theta;                  // theta angle of incidence
1947       hits[5] = phi;                    // phi angle of incidence 
1948       hits[8] = (Float_t) fNPadHits;   // first padhit
1949       hits[9] = -1;                     // last pad hit
1950
1951       // modifs perso
1952       hits[10] = mom[3]; // hit momentum P
1953       hits[11] = mom[0]; // Px/P
1954       hits[12] = mom[1]; // Py/P
1955       hits[13] = mom[2]; // Pz/P
1956       // fin modifs perso
1957       tof=gMC->TrackTime();
1958       hits[14] = tof;    // Time of flight
1959       // phi angle of incidence
1960       tlength = 0;
1961       eloss   = 0;
1962       eloss2  = 0;
1963       xhit    = pos[0];
1964       yhit    = pos[1];      
1965       zhit    = pos[2];      
1966       // Only if not trigger chamber
1967
1968       
1969       
1970
1971       if(idvol<AliMUONConstants::NTrackingCh()) {
1972           //
1973           //  Initialize hit position (cursor) in the segmentation model 
1974           ((AliMUONChamber*) (*fChambers)[idvol])
1975               ->SigGenInit(pos[0], pos[1], pos[2]);
1976       } else {
1977           //geant3->Gpcxyz();
1978           //printf("In the Trigger Chamber #%d\n",idvol-9);
1979       }
1980   }
1981   eloss2+=destep;
1982   
1983   // 
1984   // Calculate the charge induced on a pad (disintegration) in case 
1985   //
1986   // Mip left chamber ...
1987   if( gMC->IsTrackExiting() || gMC->IsTrackStop() || gMC->IsTrackDisappeared()){
1988       gMC->SetMaxStep(kBig);
1989       eloss   += destep;
1990       tlength += step;
1991       
1992       Float_t x0,y0,z0;
1993       Float_t localPos[3];
1994       Float_t globalPos[3] = {pos[0], pos[1], pos[2]};
1995       gMC->Gmtod(globalPos,localPos,1); 
1996
1997       if(idvol<AliMUONConstants::NTrackingCh()) {
1998 // tracking chambers
1999           x0 = 0.5*(xhit+pos[0]);
2000           y0 = 0.5*(yhit+pos[1]);
2001           z0 = 0.5*(zhit+pos[2]);
2002           //      z0 = localPos[2];
2003       } else {
2004 // trigger chambers
2005           x0=xhit;
2006           y0=yhit;
2007 //        z0=yhit;
2008           z0=0.;
2009       }
2010       
2011
2012       if (eloss >0)  MakePadHits(x0,y0,z0,eloss,tof,idvol);
2013       
2014           
2015       hits[6]=tlength;
2016       hits[7]=eloss2;
2017       if (fNPadHits > (Int_t)hits[8]) {
2018           hits[8]= hits[8]+1;
2019           hits[9]= (Float_t) fNPadHits;
2020       }
2021     
2022       new(lhits[fNhits++]) 
2023           AliMUONHit(fIshunt,gAlice->CurrentTrack(),vol,hits);
2024       eloss = 0; 
2025       //
2026       // Check additional signal generation conditions 
2027       // defined by the segmentation
2028       // model (boundary crossing conditions)
2029       // only for tracking chambers
2030   } else if 
2031       ((idvol < AliMUONConstants::NTrackingCh()) &&
2032        ((AliMUONChamber*) (*fChambers)[idvol])->SigGenCond(pos[0], pos[1], pos[2]))
2033   {
2034       ((AliMUONChamber*) (*fChambers)[idvol])
2035           ->SigGenInit(pos[0], pos[1], pos[2]);
2036       
2037       Float_t localPos[3];
2038       Float_t globalPos[3] = {pos[0], pos[1], pos[2]};
2039       gMC->Gmtod(globalPos,localPos,1); 
2040
2041
2042       if (eloss > 0 && idvol < AliMUONConstants::NTrackingCh())
2043         MakePadHits(0.5*(xhit+pos[0]),0.5*(yhit+pos[1]),pos[2],eloss,tof,idvol);
2044       xhit     = pos[0];
2045       yhit     = pos[1]; 
2046       zhit     = pos[2]; 
2047       eloss    = destep;
2048       tlength += step ;
2049       //
2050       // nothing special  happened, add up energy loss
2051   } else {        
2052       eloss   += destep;
2053       tlength += step ;
2054   }
2055 }
2056
2057