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