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