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