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