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