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