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