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