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