]> git.uio.no Git - u/mrichter/AliRoot.git/blob - MUON/AliMUONv0.cxx
Use TLorentzVector for position and momentum
[u/mrichter/AliRoot.git] / MUON / AliMUONv0.cxx
1 /////////////////////////////////////////////////////////
2 //  Manager and hits classes for set:MUON version 0    //
3 /////////////////////////////////////////////////////////
4
5 #include <TTUBE.h>
6 #include <TNode.h> 
7 #include <TRandom.h> 
8
9 #include "AliMUONv0.h"
10 #include "AliRun.h"
11 #include "AliMC.h"
12 #include "iostream.h"
13 #include "AliCallf77.h"
14 #include "AliConst.h" 
15
16 #define trig trig_
17
18 extern "C" void type_of_call trig(float (*)[4], float (*)[4], int& iflag);
19
20 ClassImp(AliMUONv0)
21  
22 //___________________________________________
23 AliMUONv0::AliMUONv0() : AliMUON()
24 {
25     fChambers = 0;
26 }
27  
28 //___________________________________________
29 AliMUONv0::AliMUONv0(const char *name, const char *title)
30        : AliMUON(name,title)
31 {
32 //
33 //  z-Positions of Chambers
34     const Float_t zch[7]={511., 686., 971., 1245., 1445., 1610, 1710.};
35 //
36 //  inner diameter
37     const Float_t dmi[7]={ 35.,  47.,  67.,   86.,  100., 96., 101.96};
38 //
39 //  outer diameter
40     const Float_t dma[7]={183., 245., 346.,  442.,  513., 824., 874.};
41 //
42     Int_t k;
43
44     fChambers = new TObjArray(14);
45     
46     for (Int_t i=0; i<7; i++) {
47         for (Int_t j=0; j< 2; j++) {
48 //
49 //    
50 //    Default Parameters for Muon Tracking Stations
51             k=2*i+j;
52 //
53             (*fChambers)[k] = new AliMUONchamber();
54             AliMUONchamber* chamber = (AliMUONchamber*) (*fChambers)[k];
55             chamber->SetGid(0);
56             chamber->SetZPOS(zch[i]);
57 //
58             chamber->InitGeo(zch[i]);
59             chamber->frMin=dmi[i]/2.;
60             chamber->frMax=dma[i]/2.;
61 //
62         } // Chamber j in 
63     }     // Station i
64     fMaxStepGas=0.01; 
65     fMaxStepAlu=0.1; 
66     fMaxDestepGas=-1;
67     fMaxDestepAlu=-1;
68 }
69
70 //___________________________________________
71 void AliMUONv0::Trigger(Float_t (*x)[4], Float_t (*y)[4], Int_t& iflag)
72 {
73   trig(x,y,iflag);
74 }
75
76 //___________________________________________
77 void AliMUONv0::CreateGeometry()
78 {
79     Int_t *idtmed = fIdtmed->GetArray()-1099;
80 //
81 //   Note: all chambers have the same structure, which could be 
82 //   easily parameterised. This was intentionally not done in order
83 //   to give a starting point for the implementation of the actual 
84 //   design of each station. 
85 //
86 //   Distance between Stations
87      const Float_t dstation = 8.;
88 //
89      Float_t bpar[3];
90      Float_t tpar[3];
91      Float_t tspar[5], pgpar[10];
92      Float_t zpos1, zpos2, zfpos;
93      Float_t dframep=3.;
94      Float_t dframez=0.9;
95      Float_t dr, rMin;
96 //
97 //   Rotation matrices in the x-y plane  
98      Int_t idrotm[1199];
99 //   phi=   0 deg
100      AliMatrix(idrotm[1100],  90.,   0., 90.,  90., 0., 0.);
101 //   phi=  90 deg
102      AliMatrix(idrotm[1101],  90.,  90., 90., 180., 0., 0.);
103 //   phi= 180 deg
104      AliMatrix(idrotm[1102],  90., 180., 90., 270., 0., 0.);
105 //   phi= 270 deg
106      AliMatrix(idrotm[1103],  90., 270., 90.,   0., 0., 0.);
107 //
108      Float_t phi=2*TMath::Pi()/12/2;
109
110 //
111 //   pointer to the current chamber
112      AliMUONchamber *iChamber;
113 //********************************************************************
114 //                            Station 1                             **
115 //********************************************************************
116 //  CONCENTRIC
117      iChamber=(AliMUONchamber*) (*fChambers)[0];
118      zpos1=iChamber->ZPosition()-dstation/2; 
119      zpos2=zpos1+dstation; 
120      zfpos=-(iChamber->fdGas+dframez)/2;
121      
122 //
123 //   Mother volume
124      tpar[0] = iChamber->frMin-dframep; 
125      tpar[1] = (iChamber->frMax+dframep)/TMath::Cos(phi);
126      tpar[2] = dstation/2;
127
128      gMC->Gsvolu("C01M", "TUBE", idtmed[1100], tpar, 3);
129      gMC->Gsvolu("C02M", "TUBE", idtmed[1100], tpar, 3);
130      gMC->Gspos("C01M", 1, "ALIC", 0., 0., zpos1 , 0, "ONLY");
131      gMC->Gspos("C02M", 1, "ALIC", 0., 0., zpos2 , 0, "ONLY");
132 // Aluminium frames
133 // Outer frames
134      pgpar[0] = 360/12/2;
135      pgpar[1] = 360.;
136      pgpar[2] = 12.;
137      pgpar[3] =   2;
138      pgpar[4] = -dframez/2;
139      pgpar[5] = iChamber->frMax;
140      pgpar[6] = pgpar[5]+dframep;
141      pgpar[7] = +dframez/2;
142      pgpar[8] = pgpar[5];
143      pgpar[9] = pgpar[6];
144      gMC->Gsvolu("C01O", "PGON", idtmed[1103], pgpar, 10);
145      gMC->Gsvolu("C02O", "PGON", idtmed[1103], pgpar, 10);
146      gMC->Gspos("C01O",1,"C01M", 0.,0.,-zfpos,  0,"ONLY");
147      gMC->Gspos("C01O",2,"C01M", 0.,0.,+zfpos,  0,"ONLY");
148      gMC->Gspos("C02O",1,"C02M", 0.,0.,-zfpos,  0,"ONLY");
149      gMC->Gspos("C02O",2,"C02M", 0.,0.,+zfpos,  0,"ONLY");
150 //
151 // Inner frame
152      tpar[0]= iChamber->frMin-dframep;
153      tpar[1]= iChamber->frMin;
154      tpar[2]= dframez/2;
155      gMC->Gsvolu("C01I", "TUBE", idtmed[1103], tpar, 3);
156      gMC->Gsvolu("C02I", "TUBE", idtmed[1103], tpar, 3);
157
158      gMC->Gspos("C01I",1,"C01M", 0.,0.,-zfpos,  0,"ONLY");
159      gMC->Gspos("C01I",2,"C01M", 0.,0.,+zfpos,  0,"ONLY");
160      gMC->Gspos("C02I",1,"C02M", 0.,0.,-zfpos,  0,"ONLY");
161      gMC->Gspos("C02I",2,"C02M", 0.,0.,+zfpos,  0,"ONLY");
162 //
163 // Frame Crosses
164      bpar[0] = (iChamber->frMax - iChamber->frMin)/2;
165      bpar[1] = dframep/2;
166      bpar[2] = dframez/2;
167      gMC->Gsvolu("C01B", "BOX", idtmed[1103], bpar, 3);
168      gMC->Gsvolu("C02B", "BOX", idtmed[1103], bpar, 3);
169
170      gMC->Gspos("C01B",1,"C01M", +iChamber->frMin+bpar[0] , 0,-zfpos, 
171 idrotm[1100],"ONLY");
172      gMC->Gspos("C01B",2,"C01M", -iChamber->frMin-bpar[0] , 0,-zfpos, 
173 idrotm[1100],"ONLY");
174      gMC->Gspos("C01B",3,"C01M", 0, +iChamber->frMin+bpar[0] ,-zfpos, 
175 idrotm[1101],"ONLY");
176      gMC->Gspos("C01B",4,"C01M", 0, -iChamber->frMin-bpar[0] ,-zfpos, 
177 idrotm[1101],"ONLY");
178      gMC->Gspos("C01B",5,"C01M", +iChamber->frMin+bpar[0] , 0,+zfpos, 
179 idrotm[1100],"ONLY");
180      gMC->Gspos("C01B",6,"C01M", -iChamber->frMin-bpar[0] , 0,+zfpos, 
181 idrotm[1100],"ONLY");
182      gMC->Gspos("C01B",7,"C01M", 0, +iChamber->frMin+bpar[0] ,+zfpos, 
183 idrotm[1101],"ONLY");
184      gMC->Gspos("C01B",8,"C01M", 0, -iChamber->frMin-bpar[0] ,+zfpos, 
185 idrotm[1101],"ONLY");
186
187      gMC->Gspos("C02B",1,"C02M", +iChamber->frMin+bpar[0] , 0,-zfpos, 
188 idrotm[1100],"ONLY");
189      gMC->Gspos("C02B",2,"C02M", -iChamber->frMin-bpar[0] , 0,-zfpos, 
190 idrotm[1100],"ONLY");
191      gMC->Gspos("C02B",3,"C02M", 0, +iChamber->frMin+bpar[0] ,-zfpos, 
192 idrotm[1101],"ONLY");
193      gMC->Gspos("C02B",4,"C02M", 0, -iChamber->frMin-bpar[0] ,-zfpos, 
194 idrotm[1101],"ONLY");
195      gMC->Gspos("C02B",5,"C02M", +iChamber->frMin+bpar[0] , 0,+zfpos, 
196 idrotm[1100],"ONLY");
197      gMC->Gspos("C02B",6,"C02M", -iChamber->frMin-bpar[0] , 0,+zfpos, 
198 idrotm[1100],"ONLY");
199      gMC->Gspos("C02B",7,"C02M", 0, +iChamber->frMin+bpar[0] ,+zfpos, 
200 idrotm[1101],"ONLY");
201      gMC->Gspos("C02B",8,"C02M", 0, -iChamber->frMin-bpar[0] ,+zfpos, 
202 idrotm[1101],"ONLY");
203
204 //
205 //   Chamber Material represented by Alu sheet
206      tpar[0]= iChamber->frMin+dframep*2;
207      tpar[1]= iChamber->frMax-dframep*2;
208      tpar[2] = (iChamber->fdGas+iChamber->fdAlu)/2;
209      gMC->Gsvolu("C01A", "TUBE", idtmed[1103], tpar, 3);
210      gMC->Gsvolu("C02A", "TUBE", idtmed[1103], tpar, 3);
211      gMC->Gspos("C01A", 1, "C01M", 0., 0., 0.,  0, "ONLY");
212      gMC->Gspos("C02A", 1, "C02M", 0., 0., 0.,  0, "ONLY");
213 //     
214 //   Sensitive volumes
215      // tpar[2] = iChamber->fdGas;
216      tpar[2] = iChamber->fdGas/2;
217      gMC->Gsvolu("C01G", "TUBE", idtmed[1105], tpar, 3);
218      gMC->Gsvolu("C02G", "TUBE", idtmed[1105], tpar, 3);
219      gMC->Gspos("C01G", 1, "C01A", 0., 0., 0.,  0, "ONLY");
220      gMC->Gspos("C02G", 1, "C02A", 0., 0., 0.,  0, "ONLY");
221 //
222 // Frame Crosses to be placed inside gas 
223      dr = (iChamber->frMax - iChamber->frMin);
224      bpar[0] = TMath::Sqrt(dr*dr-dframep*dframep/4)/2;
225      bpar[1] = dframep/2;
226      bpar[2] = iChamber->fdGas/2;
227      gMC->Gsvolu("C01F", "BOX", idtmed[1103], bpar, 3);
228      gMC->Gsvolu("C02F", "BOX", idtmed[1103], bpar, 3);
229
230      gMC->Gspos("C01F",1,"C01G", +iChamber->frMin+bpar[0] , 0, 0, 
231 idrotm[1100],"ONLY");
232      gMC->Gspos("C01F",2,"C01G", -iChamber->frMin-bpar[0] , 0, 0, 
233 idrotm[1100],"ONLY");
234      gMC->Gspos("C01F",3,"C01G", 0, +iChamber->frMin+bpar[0] , 0, 
235 idrotm[1101],"ONLY");
236      gMC->Gspos("C01F",4,"C01G", 0, -iChamber->frMin-bpar[0] , 0, 
237 idrotm[1101],"ONLY");
238
239      gMC->Gspos("C02F",1,"C02G", +iChamber->frMin+bpar[0] , 0, 0, 
240 idrotm[1100],"ONLY");
241      gMC->Gspos("C02F",2,"C02G", -iChamber->frMin-bpar[0] , 0, 0, 
242 idrotm[1100],"ONLY");
243      gMC->Gspos("C02F",3,"C02G", 0, +iChamber->frMin+bpar[0] , 0, 
244 idrotm[1101],"ONLY");
245      gMC->Gspos("C02F",4,"C02G", 0, -iChamber->frMin-bpar[0] , 0, 
246 idrotm[1101],"ONLY");
247 //
248 //
249 //********************************************************************
250 //                            Station 2                             **
251 //********************************************************************
252      iChamber=(AliMUONchamber*) (*fChambers)[2];
253      zpos1=iChamber->ZPosition()-dstation/2; 
254      zpos2=zpos1+dstation; 
255      zfpos=-(iChamber->fdGas+dframez)/2;
256      
257 //
258 //   Mother volume
259      tpar[0] = iChamber->frMin-dframep; 
260      tpar[1] = (iChamber->frMax+dframep)/TMath::Cos(phi);
261      tpar[2] = dstation/2;
262
263      gMC->Gsvolu("C03M", "TUBE", idtmed[1100], tpar, 3);
264      gMC->Gsvolu("C04M", "TUBE", idtmed[1100], tpar, 3);
265      gMC->Gspos("C03M", 1, "ALIC", 0., 0., zpos1 , 0, "ONLY");
266      gMC->Gspos("C04M", 1, "ALIC", 0., 0., zpos2 , 0, "ONLY");
267 // Aluminium frames
268 // Outer frames
269      pgpar[0] = 360/12/2;
270      pgpar[1] = 360.;
271      pgpar[2] = 12.;
272      pgpar[3] =   2;
273      pgpar[4] = -dframez/2;
274      pgpar[5] = iChamber->frMax;
275      pgpar[6] = pgpar[5]+dframep;
276      pgpar[7] = +dframez/2;
277      pgpar[8] = pgpar[5];
278      pgpar[9] = pgpar[6];
279      gMC->Gsvolu("C03O", "PGON", idtmed[1103], pgpar, 10);
280      gMC->Gsvolu("C04O", "PGON", idtmed[1103], pgpar, 10);
281      gMC->Gspos("C03O",1,"C03M", 0.,0.,-zfpos,  0,"ONLY");
282      gMC->Gspos("C03O",2,"C03M", 0.,0.,+zfpos,  0,"ONLY");
283      gMC->Gspos("C04O",1,"C04M", 0.,0.,-zfpos,  0,"ONLY");
284      gMC->Gspos("C04O",2,"C04M", 0.,0.,+zfpos,  0,"ONLY");
285 //
286 // Inner frame
287      tpar[0]= iChamber->frMin-dframep;
288      tpar[1]= iChamber->frMin;
289      tpar[2]= dframez/2;
290      gMC->Gsvolu("C03I", "TUBE", idtmed[1103], tpar, 3);
291      gMC->Gsvolu("C04I", "TUBE", idtmed[1103], tpar, 3);
292
293      gMC->Gspos("C03I",1,"C03M", 0.,0.,-zfpos,  0,"ONLY");
294      gMC->Gspos("C03I",2,"C03M", 0.,0.,+zfpos,  0,"ONLY");
295      gMC->Gspos("C04I",1,"C04M", 0.,0.,-zfpos,  0,"ONLY");
296      gMC->Gspos("C04I",2,"C04M", 0.,0.,+zfpos,  0,"ONLY");
297 //
298 // Frame Crosses
299      bpar[0] = (iChamber->frMax - iChamber->frMin)/2;
300      bpar[1] = dframep/2;
301      bpar[2] = dframez/2;
302      gMC->Gsvolu("C03B", "BOX", idtmed[1103], bpar, 3);
303      gMC->Gsvolu("C04B", "BOX", idtmed[1103], bpar, 3);
304
305      gMC->Gspos("C03B",1,"C03M", +iChamber->frMin+bpar[0] , 0,-zfpos, 
306 idrotm[1100],"ONLY");
307      gMC->Gspos("C03B",2,"C03M", -iChamber->frMin-bpar[0] , 0,-zfpos, 
308 idrotm[1100],"ONLY");
309      gMC->Gspos("C03B",3,"C03M", 0, +iChamber->frMin+bpar[0] ,-zfpos, 
310 idrotm[1101],"ONLY");
311      gMC->Gspos("C03B",4,"C03M", 0, -iChamber->frMin-bpar[0] ,-zfpos, 
312 idrotm[1101],"ONLY");
313      gMC->Gspos("C03B",5,"C03M", +iChamber->frMin+bpar[0] , 0,+zfpos, 
314 idrotm[1100],"ONLY");
315      gMC->Gspos("C03B",6,"C03M", -iChamber->frMin-bpar[0] , 0,+zfpos, 
316 idrotm[1100],"ONLY");
317      gMC->Gspos("C03B",7,"C03M", 0, +iChamber->frMin+bpar[0] ,+zfpos, 
318 idrotm[1101],"ONLY");
319      gMC->Gspos("C03B",8,"C03M", 0, -iChamber->frMin-bpar[0] ,+zfpos, 
320 idrotm[1101],"ONLY");
321
322      gMC->Gspos("C04B",1,"C04M", +iChamber->frMin+bpar[0] , 0,-zfpos, 
323 idrotm[1100],"ONLY");
324      gMC->Gspos("C04B",2,"C04M", -iChamber->frMin-bpar[0] , 0,-zfpos, 
325 idrotm[1100],"ONLY");
326      gMC->Gspos("C04B",3,"C04M", 0, +iChamber->frMin+bpar[0] ,-zfpos, 
327 idrotm[1101],"ONLY");
328      gMC->Gspos("C04B",4,"C04M", 0, -iChamber->frMin-bpar[0] ,-zfpos, 
329 idrotm[1101],"ONLY");
330      gMC->Gspos("C04B",5,"C04M", +iChamber->frMin+bpar[0] , 0,+zfpos, 
331 idrotm[1100],"ONLY");
332      gMC->Gspos("C04B",6,"C04M", -iChamber->frMin-bpar[0] , 0,+zfpos, 
333 idrotm[1100],"ONLY");
334      gMC->Gspos("C04B",7,"C04M", 0, +iChamber->frMin+bpar[0] ,+zfpos, 
335 idrotm[1101],"ONLY");
336      gMC->Gspos("C04B",8,"C04M", 0, -iChamber->frMin-bpar[0] ,+zfpos, 
337 idrotm[1101],"ONLY");
338
339 //
340 //   Chamber Material represented by Alu sheet
341      tpar[0]= iChamber->frMin+dframep*2;
342      tpar[1]= iChamber->frMax-dframep*2;
343      tpar[2] = (iChamber->fdGas+iChamber->fdAlu)/2;
344      gMC->Gsvolu("C03A", "TUBE", idtmed[1103], tpar, 3);
345      gMC->Gsvolu("C04A", "TUBE", idtmed[1103], tpar, 3);
346      gMC->Gspos("C03A", 1, "C03M", 0., 0., 0.,  0, "ONLY");
347      gMC->Gspos("C04A", 1, "C04M", 0., 0., 0.,  0, "ONLY");
348 //     
349 //   Sensitive volumes
350      // tpar[2] = iChamber->fdGas;
351      tpar[2] = iChamber->fdGas/2;
352      gMC->Gsvolu("C03G", "TUBE", idtmed[1105], tpar, 3);
353      gMC->Gsvolu("C04G", "TUBE", idtmed[1105], tpar, 3);
354      gMC->Gspos("C03G", 1, "C03A", 0., 0., 0.,  0, "ONLY");
355      gMC->Gspos("C04G", 1, "C04A", 0., 0., 0.,  0, "ONLY");
356 //
357 // Frame Crosses to be placed inside gas 
358      dr = (iChamber->frMax - iChamber->frMin);
359      bpar[0] = TMath::Sqrt(dr*dr-dframep*dframep/4)/2;
360      bpar[1] = dframep/2;
361      bpar[2] = iChamber->fdGas/2;
362      gMC->Gsvolu("C03F", "BOX", idtmed[1103], bpar, 3);
363      gMC->Gsvolu("C04F", "BOX", idtmed[1103], bpar, 3);
364
365      gMC->Gspos("C03F",1,"C03G", +iChamber->frMin+bpar[0] , 0, 0, 
366 idrotm[1100],"ONLY");
367      gMC->Gspos("C03F",2,"C03G", -iChamber->frMin-bpar[0] , 0, 0, 
368 idrotm[1100],"ONLY");
369      gMC->Gspos("C03F",3,"C03G", 0, +iChamber->frMin+bpar[0] , 0, 
370 idrotm[1101],"ONLY");
371      gMC->Gspos("C03F",4,"C03G", 0, -iChamber->frMin-bpar[0] , 0, 
372 idrotm[1101],"ONLY");
373
374      gMC->Gspos("C04F",1,"C04G", +iChamber->frMin+bpar[0] , 0, 0, 
375 idrotm[1100],"ONLY");
376      gMC->Gspos("C04F",2,"C04G", -iChamber->frMin-bpar[0] , 0, 0, 
377 idrotm[1100],"ONLY");
378      gMC->Gspos("C04F",3,"C04G", 0, +iChamber->frMin+bpar[0] , 0, 
379 idrotm[1101],"ONLY");
380      gMC->Gspos("C04F",4,"C04G", 0, -iChamber->frMin-bpar[0] , 0, 
381 idrotm[1101],"ONLY");
382
383 //********************************************************************
384 //                            Station 3                             **
385 //********************************************************************
386 //  CONCENTRIC
387      iChamber=(AliMUONchamber*) (*fChambers)[4];
388      zpos1=iChamber->ZPosition(); // 975-13.75
389      zpos2=zpos1 // +dstation;
390                     +27.5;
391 //
392 //   Mother volume
393      tpar[0] = iChamber->frMin; 
394      tpar[1]= TMath::Sqrt(iChamber->frMax*iChamber->frMax + dframep*dframep) ;
395      tpar[2] = // 3.; 
396             5.325*2;
397      gMC->Gsvolu("C05M", "TUBE", idtmed[1100], tpar, 3);
398      gMC->Gsvolu("C06M", "TUBE", idtmed[1100], tpar, 3);
399      gMC->Gspos("C05M", 1, "ALIC", 0., 0., zpos1 , 0, "ONLY");
400      gMC->Gspos("C06M", 1, "ALIC", 0., 0., zpos2 , 0, "ONLY");
401 //
402 //   Mother volume for one quadrant
403      tspar[0]= iChamber->frMin;
404      tspar[1]= TMath::Sqrt(iChamber->frMax*iChamber->frMax + dframep*dframep) ;
405      tspar[2]= // dframez; 
406                  5.325;
407      tspar[3] = 0.-TMath::ATan2(dframep,iChamber->frMin)*180/kPI;
408      tspar[4] = 90.+TMath::ATan2(dframep,iChamber->frMin)*180/kPI;
409      gMC->Gsvolu("C05Q", "TUBS", idtmed[1100], tspar, 5);
410      gMC->Gsvolu("C06Q", "TUBS", idtmed[1100], tspar, 5);
411 //   Position the four quadrants
412      gMC->Gspos("C05Q",1,"C05M", 0., 0., 5.325, idrotm[1100], "ONLY");
413      gMC->Gspos("C05Q",2,"C05M", 0., 0.,-5.325, idrotm[1101], "ONLY");
414      gMC->Gspos("C05Q",3,"C05M", 0., 0., 5.325, idrotm[1102], "ONLY");
415      gMC->Gspos("C05Q",4,"C05M", 0., 0.,-5.325, idrotm[1103], "ONLY");
416
417      gMC->Gspos("C06Q",1,"C06M", 0., 0., 5.325, idrotm[1100], "ONLY");
418      gMC->Gspos("C06Q",2,"C06M", 0., 0.,-5.325, idrotm[1101], "ONLY");
419      gMC->Gspos("C06Q",3,"C06M", 0., 0., 5.325, idrotm[1102], "ONLY");
420      gMC->Gspos("C06Q",4,"C06M", 0., 0.,-5.325, idrotm[1103], "ONLY");
421 // Aluminium frames
422 // Outer frame
423      tspar[0]= iChamber->frMax-dframep*2;
424      tspar[1]= iChamber->frMax;
425      tspar[3] = 0.;
426      tspar[4] = 90.;
427      gMC->Gsvolu("C05O", "TUBS", idtmed[1100], tspar, 5);
428      gMC->Gsvolu("C06O", "TUBS", idtmed[1100], tspar, 5);
429      gMC->Gspos("C05O",1,"C05Q", 0.,0.,0.,  0,"ONLY");
430      gMC->Gspos("C06O",1,"C06Q", 0.,0.,0.,  0,"ONLY");
431 //
432 // Inner frame
433      tspar[0]= iChamber->frMin;
434      tspar[1]= iChamber->frMin+dframep*2;
435      gMC->Gsvolu("C05I", "TUBS", idtmed[1100], tspar, 5);
436      gMC->Gsvolu("C06I", "TUBS", idtmed[1100], tspar, 5);
437      gMC->Gspos("C05I",1,"C05Q", 0.,0.,0.,  0,"ONLY");
438      gMC->Gspos("C06I",1,"C06Q", 0.,0.,0.,  0,"ONLY");
439 //
440 // Boundary half frame
441      bpar[0] = (iChamber->frMax - iChamber->frMin)/2;
442      bpar[1] = dframep/2;
443      bpar[2] = 5.325;
444      gMC->Gsvolu("C05B", "BOX", idtmed[1103], bpar, 3);
445      gMC->Gsvolu("C06B", "BOX", idtmed[1103], bpar, 3);
446 //place 2 boudaries
447      gMC->Gspos("C05B",1,"C05Q", iChamber->frMin+bpar[0] ,-bpar[1],0.,  idrotm[1100],"ONLY");
448      gMC->Gspos("C05B",2,"C05Q", -bpar[1],iChamber->frMin+bpar[0] ,0.,  idrotm[1101],"ONLY");
449      gMC->Gspos("C06B",1,"C06Q", iChamber->frMin+bpar[0] ,-bpar[1],0.,  idrotm[1100],"ONLY");
450      gMC->Gspos("C06B",2,"C06Q", -bpar[1],iChamber->frMin+bpar[0] ,0.,  idrotm[1101],"ONLY");
451 //
452 // Boundary second half frame (should not overlapp with sensitive surface, nor frames)
453 //          Effective inner radius due to circle effect
454      rMin =  TMath::Sqrt(
455         (iChamber->frMin+2*dframep)*(iChamber->frMin+2*dframep) - dframep*dframep );
456      bpar[0] = (iChamber->frMax - 2*dframep - rMin ) /2;
457      bpar[2] = (5.325- (0.055 + 0.325)) / 2;
458      gMC->Gsvolu("C05H", "BOX", idtmed[1103], bpar, 3);
459      gMC->Gsvolu("C06H", "BOX", idtmed[1103], bpar, 3);
460 //place 2 boudaries
461      gMC->Gspos("C05H",1,"C05Q", rMin+bpar[0],bpar[1],  0.055+0.325+bpar[2] , idrotm[1100],"ONLY");
462      gMC->Gspos("C05H",2,"C05Q", rMin+bpar[0],bpar[1],-(0.055+0.325+bpar[2]), idrotm[1100],"ONLY");
463      gMC->Gspos("C05H",3,"C05Q", bpar[1],rMin+bpar[0],  0.055+0.325+bpar[2] , idrotm[1101],"ONLY");
464      gMC->Gspos("C05H",4,"C05Q", bpar[1],rMin+bpar[0],-(0.055+0.325+bpar[2]), idrotm[1101],"ONLY");
465      gMC->Gspos("C06H",1,"C06Q", rMin+bpar[0],bpar[1],  0.055+0.325+bpar[2] , idrotm[1100],"ONLY");
466      gMC->Gspos("C06H",2,"C06Q", rMin+bpar[0],bpar[1],-(0.055+0.325+bpar[2]), idrotm[1100],"ONLY");
467      gMC->Gspos("C06H",3,"C06Q", bpar[1],rMin+bpar[0],  0.055+0.325+bpar[2] , idrotm[1101],"ONLY");
468      gMC->Gspos("C06H",4,"C06Q", bpar[1],rMin+bpar[0],-(0.055+0.325+bpar[2]), idrotm[1101],"ONLY");
469 //
470 //   Chamber Material represented by Alu sheet
471      //     tspar[2] = (iChamber->fdAlu)+(iChamber->fdGas);
472      tspar[0]= iChamber->frMin+dframep*2;
473      tspar[1]= iChamber->frMax-dframep*2;
474      tspar[2] = 0.055 + 0.325;
475      gMC->Gsvolu("C05A", "TUBS", idtmed[1103], tspar, 5);
476      gMC->Gsvolu("C06A", "TUBS", idtmed[1103], tspar, 5);
477      gMC->Gspos("C05A", 1, "C05Q", 0., 0., 0.,  0, "ONLY");
478      gMC->Gspos("C06A", 1, "C06Q", 0., 0., 0.,  0, "ONLY");
479 //     
480 //   Sensitive volumes
481      // tpar[2] = iChamber->fdGas;
482      tspar[2] = 0.325;
483      gMC->Gsvolu("C05G", "TUBS", idtmed[1105], tspar, 5);
484      gMC->Gsvolu("C06G", "TUBS", idtmed[1105], tspar, 5);
485      gMC->Gspos("C05G", 1, "C05A", 0., 0., 0.,  0, "ONLY");
486      gMC->Gspos("C06G", 1, "C06A", 0., 0., 0.,  0, "ONLY");
487 //
488 //   Overwrite sensitive volume with ALU
489 // Overwrite Gaz volume
490      bpar[2] = 0.325;
491      gMC->Gsvolu("C05Z", "BOX", idtmed[1103], bpar, 3);
492      gMC->Gsvolu("C06Z", "BOX", idtmed[1103], bpar, 3);
493      gMC->Gspos("C05Z",1,"C05G", rMin+bpar[0] ,bpar[1],0.,  idrotm[1100],"ONLY");
494      gMC->Gspos("C05Z",2,"C05G", bpar[1], rMin+bpar[0] ,0., idrotm[1101],"ONLY");
495      gMC->Gspos("C06Z",1,"C06G", rMin+bpar[0] ,bpar[1],0.,  idrotm[1100],"ONLY");
496      gMC->Gspos("C06Z",2,"C06G", bpar[1], rMin+bpar[0] ,0., idrotm[1101],"ONLY");
497
498 //********************************************************************
499 //                            Station 4                             **
500 //********************************************************************
501      iChamber=(AliMUONchamber*) (*fChambers)[6];
502      zpos1=iChamber->ZPosition()-dstation/2; 
503      zpos2=zpos1+dstation; 
504      zfpos=-(iChamber->fdGas+dframez)/2;
505      
506 //
507 //   Mother volume
508      tpar[0] = iChamber->frMin-dframep; 
509      tpar[1] = (iChamber->frMax+dframep)/TMath::Cos(phi);
510      tpar[2] = dstation/2;
511
512      gMC->Gsvolu("C07M", "TUBE", idtmed[1100], tpar, 3);
513      gMC->Gsvolu("C08M", "TUBE", idtmed[1100], tpar, 3);
514      gMC->Gspos("C07M", 1, "ALIC", 0., 0., zpos1 , 0, "ONLY");
515      gMC->Gspos("C08M", 1, "ALIC", 0., 0., zpos2 , 0, "ONLY");
516 // Aluminium frames
517 // Outer frames
518      pgpar[0] = 360/12/2;
519      pgpar[1] = 360.;
520      pgpar[2] = 12.;
521      pgpar[3] =   2;
522      pgpar[4] = -dframez/2;
523      pgpar[5] = iChamber->frMax;
524      pgpar[6] = pgpar[5]+dframep;
525      pgpar[7] = +dframez/2;
526      pgpar[8] = pgpar[5];
527      pgpar[9] = pgpar[6];
528      gMC->Gsvolu("C07O", "PGON", idtmed[1103], pgpar, 10);
529      gMC->Gsvolu("C08O", "PGON", idtmed[1103], pgpar, 10);
530      gMC->Gspos("C07O",1,"C07M", 0.,0.,-zfpos,  0,"ONLY");
531      gMC->Gspos("C07O",2,"C07M", 0.,0.,+zfpos,  0,"ONLY");
532      gMC->Gspos("C08O",1,"C08M", 0.,0.,-zfpos,  0,"ONLY");
533      gMC->Gspos("C08O",2,"C08M", 0.,0.,+zfpos,  0,"ONLY");
534 //
535 // Inner frame
536      tpar[0]= iChamber->frMin-dframep;
537      tpar[1]= iChamber->frMin;
538      tpar[2]= dframez/2;
539      gMC->Gsvolu("C07I", "TUBE", idtmed[1103], tpar, 3);
540      gMC->Gsvolu("C08I", "TUBE", idtmed[1103], tpar, 3);
541
542      gMC->Gspos("C07I",1,"C07M", 0.,0.,-zfpos,  0,"ONLY");
543      gMC->Gspos("C07I",2,"C07M", 0.,0.,+zfpos,  0,"ONLY");
544      gMC->Gspos("C08I",1,"C08M", 0.,0.,-zfpos,  0,"ONLY");
545      gMC->Gspos("C08I",2,"C08M", 0.,0.,+zfpos,  0,"ONLY");
546 //
547 // Frame Crosses
548      bpar[0] = (iChamber->frMax - iChamber->frMin)/2;
549      bpar[1] = dframep/2;
550      bpar[2] = dframez/2;
551      gMC->Gsvolu("C07B", "BOX", idtmed[1103], bpar, 3);
552      gMC->Gsvolu("C08B", "BOX", idtmed[1103], bpar, 3);
553
554      gMC->Gspos("C07B",1,"C07M", +iChamber->frMin+bpar[0] , 0,-zfpos, 
555 idrotm[1100],"ONLY");
556      gMC->Gspos("C07B",2,"C07M", -iChamber->frMin-bpar[0] , 0,-zfpos, 
557 idrotm[1100],"ONLY");
558      gMC->Gspos("C07B",3,"C07M", 0, +iChamber->frMin+bpar[0] ,-zfpos, 
559 idrotm[1101],"ONLY");
560      gMC->Gspos("C07B",4,"C07M", 0, -iChamber->frMin-bpar[0] ,-zfpos, 
561 idrotm[1101],"ONLY");
562      gMC->Gspos("C07B",5,"C07M", +iChamber->frMin+bpar[0] , 0,+zfpos, 
563 idrotm[1100],"ONLY");
564      gMC->Gspos("C07B",6,"C07M", -iChamber->frMin-bpar[0] , 0,+zfpos, 
565 idrotm[1100],"ONLY");
566      gMC->Gspos("C07B",7,"C07M", 0, +iChamber->frMin+bpar[0] ,+zfpos, 
567 idrotm[1101],"ONLY");
568      gMC->Gspos("C07B",8,"C07M", 0, -iChamber->frMin-bpar[0] ,+zfpos, 
569 idrotm[1101],"ONLY");
570
571      gMC->Gspos("C08B",1,"C08M", +iChamber->frMin+bpar[0] , 0,-zfpos, 
572 idrotm[1100],"ONLY");
573      gMC->Gspos("C08B",2,"C08M", -iChamber->frMin-bpar[0] , 0,-zfpos, 
574 idrotm[1100],"ONLY");
575      gMC->Gspos("C08B",3,"C08M", 0, +iChamber->frMin+bpar[0] ,-zfpos, 
576 idrotm[1101],"ONLY");
577      gMC->Gspos("C08B",4,"C08M", 0, -iChamber->frMin-bpar[0] ,-zfpos, 
578 idrotm[1101],"ONLY");
579      gMC->Gspos("C08B",5,"C08M", +iChamber->frMin+bpar[0] , 0,+zfpos, 
580 idrotm[1100],"ONLY");
581      gMC->Gspos("C08B",6,"C08M", -iChamber->frMin-bpar[0] , 0,+zfpos, 
582 idrotm[1100],"ONLY");
583      gMC->Gspos("C08B",7,"C08M", 0, +iChamber->frMin+bpar[0] ,+zfpos, 
584 idrotm[1101],"ONLY");
585      gMC->Gspos("C08B",8,"C08M", 0, -iChamber->frMin-bpar[0] ,+zfpos, 
586 idrotm[1101],"ONLY");
587
588 //
589 //   Chamber Material represented by Alu sheet
590      tpar[0]= iChamber->frMin+dframep*2;
591      tpar[1]= iChamber->frMax-dframep*2;
592      tpar[2] = (iChamber->fdGas+iChamber->fdAlu)/2;
593      gMC->Gsvolu("C07A", "TUBE", idtmed[1103], tpar, 3);
594      gMC->Gsvolu("C08A", "TUBE", idtmed[1103], tpar, 3);
595      gMC->Gspos("C07A", 1, "C07M", 0., 0., 0.,  0, "ONLY");
596      gMC->Gspos("C08A", 1, "C08M", 0., 0., 0.,  0, "ONLY");
597 //     
598 //   Sensitive volumes
599      // tpar[2] = iChamber->fdGas;
600      tpar[2] = iChamber->fdGas/2;
601      gMC->Gsvolu("C07G", "TUBE", idtmed[1105], tpar, 3);
602      gMC->Gsvolu("C08G", "TUBE", idtmed[1105], tpar, 3);
603      gMC->Gspos("C07G", 1, "C07A", 0., 0., 0.,  0, "ONLY");
604      gMC->Gspos("C08G", 1, "C08A", 0., 0., 0.,  0, "ONLY");
605 //
606 // Frame Crosses to be placed inside gas 
607      dr = (iChamber->frMax - iChamber->frMin);
608      bpar[0] = TMath::Sqrt(dr*dr-dframep*dframep/4)/2;
609      bpar[1] = dframep/2;
610      bpar[2] = iChamber->fdGas/2;
611      gMC->Gsvolu("C07F", "BOX", idtmed[1103], bpar, 3);
612      gMC->Gsvolu("C08F", "BOX", idtmed[1103], bpar, 3);
613
614      gMC->Gspos("C07F",1,"C07G", +iChamber->frMin+bpar[0] , 0, 0, 
615 idrotm[1100],"ONLY");
616      gMC->Gspos("C07F",2,"C07G", -iChamber->frMin-bpar[0] , 0, 0, 
617 idrotm[1100],"ONLY");
618      gMC->Gspos("C07F",3,"C07G", 0, +iChamber->frMin+bpar[0] , 0, 
619 idrotm[1101],"ONLY");
620      gMC->Gspos("C07F",4,"C07G", 0, -iChamber->frMin-bpar[0] , 0, 
621 idrotm[1101],"ONLY");
622
623      gMC->Gspos("C08F",1,"C08G", +iChamber->frMin+bpar[0] , 0, 0, 
624 idrotm[1100],"ONLY");
625      gMC->Gspos("C08F",2,"C08G", -iChamber->frMin-bpar[0] , 0, 0, 
626 idrotm[1100],"ONLY");
627      gMC->Gspos("C08F",3,"C08G", 0, +iChamber->frMin+bpar[0] , 0, 
628 idrotm[1101],"ONLY");
629      gMC->Gspos("C08F",4,"C08G", 0, -iChamber->frMin-bpar[0] , 0, 
630 idrotm[1101],"ONLY");
631
632 //********************************************************************
633 //                            Station 5                             **
634 //********************************************************************
635      iChamber=(AliMUONchamber*) (*fChambers)[8];
636      zpos1=iChamber->ZPosition()-dstation/2; 
637      zpos2=zpos1+dstation; 
638      zfpos=-(iChamber->fdGas+dframez)/2;
639      
640 //
641 //   Mother volume
642      tpar[0] = iChamber->frMin-dframep; 
643      tpar[1] = (iChamber->frMax+dframep)/TMath::Cos(phi);
644      tpar[2] = dstation/2;
645
646      gMC->Gsvolu("C09M", "TUBE", idtmed[1100], tpar, 3);
647      gMC->Gsvolu("C10M", "TUBE", idtmed[1100], tpar, 3);
648      gMC->Gspos("C09M", 1, "ALIC", 0., 0., zpos1 , 0, "ONLY");
649      gMC->Gspos("C10M", 1, "ALIC", 0., 0., zpos2 , 0, "ONLY");
650 // Aluminium frames
651 // Outer frames
652      pgpar[0] = 360/12/2;
653      pgpar[1] = 360.;
654      pgpar[2] = 12.;
655      pgpar[3] =   2;
656      pgpar[4] = -dframez/2;
657      pgpar[5] = iChamber->frMax;
658      pgpar[6] = pgpar[5]+dframep;
659      pgpar[7] = +dframez/2;
660      pgpar[8] = pgpar[5];
661      pgpar[9] = pgpar[6];
662      gMC->Gsvolu("C09O", "PGON", idtmed[1103], pgpar, 10);
663      gMC->Gsvolu("C10O", "PGON", idtmed[1103], pgpar, 10);
664      gMC->Gspos("C09O",1,"C09M", 0.,0.,-zfpos,  0,"ONLY");
665      gMC->Gspos("C09O",2,"C09M", 0.,0.,+zfpos,  0,"ONLY");
666      gMC->Gspos("C10O",1,"C10M", 0.,0.,-zfpos,  0,"ONLY");
667      gMC->Gspos("C10O",2,"C10M", 0.,0.,+zfpos,  0,"ONLY");
668 //
669 // Inner frame
670      tpar[0]= iChamber->frMin-dframep;
671      tpar[1]= iChamber->frMin;
672      tpar[2]= dframez/2;
673      gMC->Gsvolu("C09I", "TUBE", idtmed[1103], tpar, 3);
674      gMC->Gsvolu("C10I", "TUBE", idtmed[1103], tpar, 3);
675
676      gMC->Gspos("C09I",1,"C09M", 0.,0.,-zfpos,  0,"ONLY");
677      gMC->Gspos("C09I",2,"C09M", 0.,0.,+zfpos,  0,"ONLY");
678      gMC->Gspos("C10I",1,"C10M", 0.,0.,-zfpos,  0,"ONLY");
679      gMC->Gspos("C10I",2,"C10M", 0.,0.,+zfpos,  0,"ONLY");
680 //
681 // Frame Crosses
682      bpar[0] = (iChamber->frMax - iChamber->frMin)/2;
683      bpar[1] = dframep/2;
684      bpar[2] = dframez/2;
685      gMC->Gsvolu("C09B", "BOX", idtmed[1103], bpar, 3);
686      gMC->Gsvolu("C10B", "BOX", idtmed[1103], bpar, 3);
687
688      gMC->Gspos("C09B",1,"C09M", +iChamber->frMin+bpar[0] , 0,-zfpos, 
689 idrotm[1100],"ONLY");
690      gMC->Gspos("C09B",2,"C09M", -iChamber->frMin-bpar[0] , 0,-zfpos, 
691 idrotm[1100],"ONLY");
692      gMC->Gspos("C09B",3,"C09M", 0, +iChamber->frMin+bpar[0] ,-zfpos, 
693 idrotm[1101],"ONLY");
694      gMC->Gspos("C09B",4,"C09M", 0, -iChamber->frMin-bpar[0] ,-zfpos, 
695 idrotm[1101],"ONLY");
696      gMC->Gspos("C09B",5,"C09M", +iChamber->frMin+bpar[0] , 0,+zfpos, 
697 idrotm[1100],"ONLY");
698      gMC->Gspos("C09B",6,"C09M", -iChamber->frMin-bpar[0] , 0,+zfpos, 
699 idrotm[1100],"ONLY");
700      gMC->Gspos("C09B",7,"C09M", 0, +iChamber->frMin+bpar[0] ,+zfpos, 
701 idrotm[1101],"ONLY");
702      gMC->Gspos("C09B",8,"C09M", 0, -iChamber->frMin-bpar[0] ,+zfpos, 
703 idrotm[1101],"ONLY");
704
705      gMC->Gspos("C10B",1,"C10M", +iChamber->frMin+bpar[0] , 0,-zfpos, 
706 idrotm[1100],"ONLY");
707      gMC->Gspos("C10B",2,"C10M", -iChamber->frMin-bpar[0] , 0,-zfpos, 
708 idrotm[1100],"ONLY");
709      gMC->Gspos("C10B",3,"C10M", 0, +iChamber->frMin+bpar[0] ,-zfpos, 
710 idrotm[1101],"ONLY");
711      gMC->Gspos("C10B",4,"C10M", 0, -iChamber->frMin-bpar[0] ,-zfpos, 
712 idrotm[1101],"ONLY");
713      gMC->Gspos("C10B",5,"C10M", +iChamber->frMin+bpar[0] , 0,+zfpos, 
714 idrotm[1100],"ONLY");
715      gMC->Gspos("C10B",6,"C10M", -iChamber->frMin-bpar[0] , 0,+zfpos, 
716 idrotm[1100],"ONLY");
717      gMC->Gspos("C10B",7,"C10M", 0, +iChamber->frMin+bpar[0] ,+zfpos, 
718 idrotm[1101],"ONLY");
719      gMC->Gspos("C10B",8,"C10M", 0, -iChamber->frMin-bpar[0] ,+zfpos, 
720 idrotm[1101],"ONLY");
721
722 //
723 //   Chamber Material represented by Alu sheet
724      tpar[0]= iChamber->frMin+dframep*2;
725      tpar[1]= iChamber->frMax-dframep*2;
726      tpar[2] = (iChamber->fdGas+iChamber->fdAlu)/2;
727      gMC->Gsvolu("C09A", "TUBE", idtmed[1103], tpar, 3);
728      gMC->Gsvolu("C10A", "TUBE", idtmed[1103], tpar, 3);
729      gMC->Gspos("C09A", 1, "C09M", 0., 0., 0.,  0, "ONLY");
730      gMC->Gspos("C10A", 1, "C10M", 0., 0., 0.,  0, "ONLY");
731 //     
732 //   Sensitive volumes
733      // tpar[2] = iChamber->fdGas;
734      tpar[2] = iChamber->fdGas/2;
735      gMC->Gsvolu("C09G", "TUBE", idtmed[1105], tpar, 3);
736      gMC->Gsvolu("C10G", "TUBE", idtmed[1105], tpar, 3);
737      gMC->Gspos("C09G", 1, "C09A", 0., 0., 0.,  0, "ONLY");
738      gMC->Gspos("C10G", 1, "C10A", 0., 0., 0.,  0, "ONLY");
739 //
740 // Frame Crosses to be placed inside gas 
741      dr = (iChamber->frMax - iChamber->frMin);
742      bpar[0] = TMath::Sqrt(dr*dr-dframep*dframep/4)/2;
743      bpar[1] = dframep/2;
744      bpar[2] = iChamber->fdGas/2;
745      gMC->Gsvolu("C09F", "BOX", idtmed[1103], bpar, 3);
746      gMC->Gsvolu("C10F", "BOX", idtmed[1103], bpar, 3);
747
748      gMC->Gspos("C09F",1,"C09G", +iChamber->frMin+bpar[0] , 0, 0, 
749 idrotm[1100],"ONLY");
750      gMC->Gspos("C09F",2,"C09G", -iChamber->frMin-bpar[0] , 0, 0, 
751 idrotm[1100],"ONLY");
752      gMC->Gspos("C09F",3,"C09G", 0, +iChamber->frMin+bpar[0] , 0, 
753 idrotm[1101],"ONLY");
754      gMC->Gspos("C09F",4,"C09G", 0, -iChamber->frMin-bpar[0] , 0, 
755 idrotm[1101],"ONLY");
756
757      gMC->Gspos("C10F",1,"C10G", +iChamber->frMin+bpar[0] , 0, 0, 
758 idrotm[1100],"ONLY");
759      gMC->Gspos("C10F",2,"C10G", -iChamber->frMin-bpar[0] , 0, 0, 
760 idrotm[1100],"ONLY");
761      gMC->Gspos("C10F",3,"C10G", 0, +iChamber->frMin+bpar[0] , 0, 
762 idrotm[1101],"ONLY");
763      gMC->Gspos("C10F",4,"C10G", 0, -iChamber->frMin-bpar[0] , 0, 
764 idrotm[1101],"ONLY");
765
766 ///////////////////////////////////////
767 // GEOMETRY FOR THE TRIGGER CHAMBERS //
768 ///////////////////////////////////////
769      
770 //  Distance between planes inside each trigger station
771     const Float_t DTPLANES = 15.;
772
773 //  Parameters of the Trigger Chambers
774     //Station 1
775                 
776     const Float_t X_MC1_MIN=38.;       
777     const Float_t X_MC1_MED=51.;                                
778     const Float_t X_MC1_MAX=272.;                               
779     const Float_t Y_MC1_MIN=34.;                              
780     const Float_t Y_MC1_MAX=51.;                              
781     const Float_t R_MIN1=48.;
782     const Float_t R_MAX1=64.;
783
784 // Station 1
785      iChamber=(AliMUONchamber*) (*fChambers)[10];
786      zpos1=iChamber->ZPosition();
787      zpos2=zpos1+DTPLANES;
788
789 // Mother volume definition     
790      tpar[0] = iChamber->frMin; 
791      tpar[1] = iChamber->frMax;
792      tpar[2] = 0.4;    
793      gMC->Gsvolu("CM11", "TUBE", idtmed[1100], tpar, 3);
794      gMC->Gsvolu("CM12", "TUBE", idtmed[1100], tpar, 3);
795      
796 // Definition of the flange between the beam shielding and the RPC 
797      tpar[0]= R_MIN1;
798      tpar[1]= R_MAX1;
799      tpar[2]= 0.4;
800    
801      gMC->Gsvolu("CF1A", "TUBE", idtmed[1103], tpar, 3);     //Al
802      gMC->Gspos("CF1A", 1, "CM11", 0., 0., 0., 0, "MANY");
803      gMC->Gspos("CF1A", 2, "CM12", 0., 0., 0., 0, "MANY");
804
805 // Definition of prototype for chambers in the first plane     
806           
807      tpar[0]= 0.;
808      tpar[1]= 0.;
809      tpar[2]= 0.;
810           
811      gMC->Gsvolu("CC1A", "BOX ", idtmed[1103], tpar, 0);     //Al      
812      gMC->Gsvolu("CB1A", "BOX ", idtmed[1107], tpar, 0);     //Bakelite 
813      gMC->Gsvolu("CG1A", "BOX ", idtmed[1106], tpar, 0);     //Gas streamer
814
815 // chamber type A
816      tpar[0] = -1.;
817      tpar[1] = -1.;
818      
819      const Float_t X_MC1A=X_MC1_MED+(X_MC1_MAX-X_MC1_MED)/2.;
820      const Float_t Y_MC1A=0.;
821      const Float_t Z_MC1A=0.;
822           
823      tpar[2] = 0.1;    
824      gMC->Gsposp("CG1A", 1, "CB1A", 0., 0., 0., 0, "ONLY",tpar,3);
825      tpar[2] = 0.3;
826      gMC->Gsposp("CB1A", 1, "CC1A", 0., 0., 0., 0, "ONLY",tpar,3);
827      tpar[2] = 0.4;
828      tpar[0] = (X_MC1_MAX-X_MC1_MED)/2.;
829      tpar[1] = Y_MC1_MIN;
830      gMC->Gsposp("CC1A", 1, "CM11",X_MC1A,Y_MC1A,Z_MC1A, 0, "ONLY", tpar, 3);
831      gMC->Gsposp("CC1A", 2, "CM11",-X_MC1A,Y_MC1A,Z_MC1A, 0, "ONLY", tpar, 3);
832      
833 //  chamber type B    
834      tpar[0] = (X_MC1_MAX-X_MC1_MIN)/2.;
835      tpar[1] = (Y_MC1_MAX-Y_MC1_MIN)/2.;
836      
837      const Float_t X_MC1B=X_MC1_MIN+tpar[0];
838      const Float_t Y_MC1B=Y_MC1_MIN+tpar[1];
839      const Float_t Z_MC1B=0.;
840
841      gMC->Gsposp("CC1A", 3, "CM11",X_MC1B,Y_MC1B,Z_MC1B, 0, "ONLY", tpar, 3);
842      gMC->Gsposp("CC1A", 4, "CM11",-X_MC1B,Y_MC1B,Z_MC1B, 0, "ONLY", tpar, 3);
843      gMC->Gsposp("CC1A", 5, "CM11",X_MC1B,-Y_MC1B,Z_MC1B, 0, "ONLY", tpar, 3);
844      gMC->Gsposp("CC1A", 6, "CM11",-X_MC1B,-Y_MC1B,Z_MC1B, 0, "ONLY", tpar, 3);
845      
846 //  chamber type C        
847      tpar[0] = X_MC1_MAX/2;
848      tpar[1] = Y_MC1_MAX/2;
849      
850      const Float_t X_MC1C=tpar[0];
851      const Float_t Y_MC1C=Y_MC1_MAX+tpar[1];
852      const Float_t Z_MC1C=0.;
853      
854      gMC->Gsposp("CC1A", 7, "CM11",X_MC1C,Y_MC1C,Z_MC1C, 0, "ONLY", tpar, 3);
855      gMC->Gsposp("CC1A", 8, "CM11",-X_MC1C,Y_MC1C,Z_MC1C, 0, "ONLY", tpar, 3);
856      gMC->Gsposp("CC1A", 9, "CM11",X_MC1C,-Y_MC1C,Z_MC1C, 0, "ONLY", tpar, 3);
857      gMC->Gsposp("CC1A", 10, "CM11",-X_MC1C,-Y_MC1C,Z_MC1C, 0, "ONLY", tpar, 3);
858      
859 //  chamber type D        
860      tpar[0] = X_MC1_MAX/2.;
861      tpar[1] = Y_MC1_MIN;
862      
863      const Float_t X_MC1D=tpar[0];
864      const Float_t Z_MC1D=0.;
865      
866      Float_t Y_MC1D=4.*Y_MC1_MIN;
867      gMC->Gsposp("CC1A", 11, "CM11",X_MC1D,Y_MC1D,Z_MC1D, 0, "ONLY", tpar, 3);
868      gMC->Gsposp("CC1A", 12, "CM11",X_MC1D,-Y_MC1D,Z_MC1D, 0, "ONLY", tpar, 3);
869      gMC->Gsposp("CC1A", 13, "CM11",-X_MC1D,Y_MC1D,Z_MC1D, 0, "ONLY", tpar, 3);
870      gMC->Gsposp("CC1A", 14, "CM11",-X_MC1D,-Y_MC1D,Z_MC1D, 0, "ONLY", tpar, 3);
871
872      Y_MC1D=6.*Y_MC1_MIN;
873      gMC->Gsposp("CC1A", 15, "CM11",X_MC1D,Y_MC1D,Z_MC1D, 0, "ONLY", tpar, 3);
874      gMC->Gsposp("CC1A", 16, "CM11",X_MC1D,-Y_MC1D,Z_MC1D, 0, "ONLY", tpar, 3);
875      gMC->Gsposp("CC1A", 17, "CM11",-X_MC1D,Y_MC1D,Z_MC1D, 0, "ONLY", tpar, 3);
876      gMC->Gsposp("CC1A", 18, "CM11",-X_MC1D,-Y_MC1D,Z_MC1D, 0, "ONLY", tpar, 3);
877
878      Y_MC1D=8.*Y_MC1_MIN;
879      gMC->Gsposp("CC1A", 19, "CM11",X_MC1D,Y_MC1D,Z_MC1D, 0, "ONLY", tpar, 3);
880      gMC->Gsposp("CC1A", 20, "CM11",X_MC1D,-Y_MC1D,Z_MC1D, 0, "ONLY", tpar, 3);
881      gMC->Gsposp("CC1A", 21, "CM11",-X_MC1D,Y_MC1D,Z_MC1D, 0, "ONLY", tpar, 3);
882      gMC->Gsposp("CC1A", 22, "CM11",-X_MC1D,-Y_MC1D,Z_MC1D, 0, "ONLY", tpar, 3);
883
884 // Positioning first plane in ALICE     
885      gMC->Gspos("CM11", 1, "ALIC", 0., 0., zpos1, 0, "ONLY");
886
887 // End of geometry definition for the first plane
888
889 // Station 1 - plan 2  -  same RPCs as plan 1 ==> small non covered area
890 // Y position moved (ratio zpos2/zpos1)
891      const Float_t Z_1S2=zpos2/zpos1;
892      
893 // Definition of prototype for chambers in the second plane     
894           
895      tpar[0]= 0.;
896      tpar[1]= 0.;
897      tpar[2]= 0.;
898           
899      gMC->Gsvolu("CC2A", "BOX ", idtmed[1103], tpar, 0);     //Al      
900      gMC->Gsvolu("CB2A", "BOX ", idtmed[1107], tpar, 0);     //Bakelite 
901      gMC->Gsvolu("CG2A", "BOX ", idtmed[1106], tpar, 0);     //Gas streamer
902
903 // chamber type A
904      tpar[0] = -1.;
905      tpar[1] = -1.;
906      
907      const Float_t X_MC2A=X_MC1A;
908      const Float_t Y_MC2A=0.;
909      const Float_t Z_MC2A=0.;
910           
911      tpar[2] = 0.1;    
912      gMC->Gsposp("CG2A", 1, "CB2A", 0., 0., 0., 0, "ONLY",tpar,3);
913      tpar[2] = 0.3;
914      gMC->Gsposp("CB2A", 1, "CC2A", 0., 0., 0., 0, "ONLY",tpar,3);
915      tpar[2] = 0.4;
916      tpar[0] = (X_MC1_MAX-X_MC1_MED)/2.;
917      tpar[1] = Y_MC1_MIN;
918      gMC->Gsposp("CC2A", 1, "CM12",X_MC2A,Y_MC2A,Z_MC2A, 0, "ONLY", tpar, 3);
919      gMC->Gsposp("CC2A", 2, "CM12",-X_MC2A,Y_MC2A,Z_MC2A, 0, "ONLY", tpar, 3);
920      
921 //  chamber type B    
922      tpar[0] = (X_MC1_MAX-X_MC1_MIN)/2.;
923      tpar[1] = (Y_MC1_MAX-Y_MC1_MIN)/2.;
924      
925      const Float_t X_MC2B=X_MC1B;
926      const Float_t Y_MC2B=2.*Y_MC1_MIN*Z_1S2-Y_MC1_MIN*1.5+Y_MC1_MAX*0.5;
927      const Float_t Z_MC2B=0.;
928
929      gMC->Gsposp("CC2A", 3, "CM12",X_MC2B,Y_MC2B,Z_MC2B, 0, "ONLY", tpar, 3);
930      gMC->Gsposp("CC2A", 4, "CM12",-X_MC2B,Y_MC2B,Z_MC2B, 0, "ONLY", tpar, 3);
931      gMC->Gsposp("CC2A", 5, "CM12",X_MC2B,-Y_MC2B,Z_MC2B, 0, "ONLY", tpar, 3);
932      gMC->Gsposp("CC2A", 6, "CM12",-X_MC2B,-Y_MC2B,Z_MC2B, 0, "ONLY", tpar, 3);
933      
934 //  chamber type C        
935      tpar[0] = X_MC1_MAX/2;
936      tpar[1] = Y_MC1_MAX/2;
937      
938      const Float_t X_MC2C=X_MC1C;
939      const Float_t Y_MC2C=2.*Y_MC1_MIN*Z_1S2-Y_MC1_MIN*2.+Y_MC1_MAX*1.5;
940      const Float_t Z_MC2C=0.;
941      
942      gMC->Gsposp("CC2A", 7, "CM12",X_MC2C,Y_MC2C,Z_MC2C, 0, "ONLY", tpar, 3);
943      gMC->Gsposp("CC2A", 8, "CM12",-X_MC2C,Y_MC2C,Z_MC2C, 0, "ONLY", tpar, 3);
944      gMC->Gsposp("CC2A", 9, "CM12",X_MC2C,-Y_MC2C,Z_MC2C, 0, "ONLY", tpar, 3);
945      gMC->Gsposp("CC2A", 10, "CM12",-X_MC2C,-Y_MC2C,Z_MC2C, 0, "ONLY", tpar, 3);
946      
947 //  chamber type D        
948      tpar[0] = X_MC1_MAX/2.;
949      tpar[1] = Y_MC1_MIN;
950      
951      const Float_t X_MC2D=X_MC1D;
952      const Float_t Z_MC2D=0.;
953      
954      Float_t Y_MC2D=4.*Y_MC1_MIN*Z_1S2;
955      gMC->Gsposp("CC2A", 11, "CM12",X_MC2D,Y_MC2D,Z_MC2D, 0, "ONLY", tpar, 3);
956      gMC->Gsposp("CC2A", 12, "CM12",X_MC2D,-Y_MC2D,Z_MC2D, 0, "ONLY", tpar, 3);
957      gMC->Gsposp("CC2A", 13, "CM12",-X_MC2D,Y_MC2D,Z_MC2D, 0, "ONLY", tpar, 3);
958      gMC->Gsposp("CC2A", 14, "CM12",-X_MC2D,-Y_MC2D,Z_MC2D, 0, "ONLY", tpar, 3);
959
960      Y_MC2D=6.*Y_MC1_MIN*Z_1S2;
961      gMC->Gsposp("CC2A", 15, "CM12",X_MC2D,Y_MC2D,Z_MC2D, 0, "ONLY", tpar, 3);
962      gMC->Gsposp("CC2A", 16, "CM12",X_MC2D,-Y_MC2D,Z_MC2D, 0, "ONLY", tpar, 3);
963      gMC->Gsposp("CC2A", 17, "CM12",-X_MC2D,Y_MC2D,Z_MC2D, 0, "ONLY", tpar, 3);
964      gMC->Gsposp("CC2A", 18, "CM12",-X_MC2D,-Y_MC2D,Z_MC2D, 0, "ONLY", tpar, 3);
965
966      Y_MC2D=8.*Y_MC1_MIN*Z_1S2;
967      gMC->Gsposp("CC2A", 19, "CM12",X_MC2D,Y_MC2D,Z_MC2D, 0, "ONLY", tpar, 3);
968      gMC->Gsposp("CC2A", 20, "CM12",X_MC2D,-Y_MC2D,Z_MC2D, 0, "ONLY", tpar, 3);
969      gMC->Gsposp("CC2A", 21, "CM12",-X_MC2D,Y_MC2D,Z_MC2D, 0, "ONLY", tpar, 3);
970      gMC->Gsposp("CC2A", 22, "CM12",-X_MC2D,-Y_MC2D,Z_MC2D, 0, "ONLY", tpar, 3);
971      
972      gMC->Gspos("CM12", 1, "ALIC", 0., 0., zpos2, 0, "ONLY");
973
974 // Station 2
975      iChamber=(AliMUONchamber*) (*fChambers)[12];
976      Float_t zpos3=iChamber->ZPosition();
977      Float_t zpos4=zpos3+DTPLANES;
978
979 //  Parameters of the Trigger Chambers
980                                               //Station 2
981      const Float_t X_MC3_MIN=X_MC1_MIN*zpos3/zpos1;          
982      const Float_t X_MC3_MED=X_MC1_MED*zpos3/zpos1;          
983      const Float_t X_MC3_MAX=X_MC1_MAX*zpos3/zpos1;           
984      const Float_t Y_MC3_MIN=Y_MC1_MIN*zpos3/zpos1;            
985      const Float_t Y_MC3_MAX=Y_MC1_MAX*zpos3/zpos1;             
986      const Float_t R_MIN3=R_MIN1*zpos3/zpos1;
987      const Float_t R_MAX3=R_MAX1*zpos3/zpos1;
988
989 // Mother volume definition     
990      tpar[0] = iChamber->frMin; 
991      tpar[1] = iChamber->frMax;
992      tpar[2] = 0.4;    
993      gMC->Gsvolu("CM21", "TUBE", idtmed[1100], tpar, 3);
994      gMC->Gsvolu("CM22", "TUBE", idtmed[1100], tpar, 3);
995      
996 // Definition of the flange between the beam shielding and the RPC 
997      tpar[0]= R_MIN3;
998      tpar[1]= R_MAX3;
999      tpar[2]= 0.4;
1000    
1001      gMC->Gsvolu("CF2A", "TUBE", idtmed[1103], tpar, 3);     //Al
1002      gMC->Gspos("CF2A", 1, "CM21", 0., 0., 0., 0, "MANY");
1003      gMC->Gspos("CF2A", 2, "CM22", 0., 0., 0., 0, "MANY");
1004
1005 // Definition of prototype for chambers in the third plane     
1006           
1007      tpar[0]= 0.;
1008      tpar[1]= 0.;
1009      tpar[2]= 0.;
1010           
1011      gMC->Gsvolu("CC3A", "BOX ", idtmed[1103], tpar, 0);     //Al      
1012      gMC->Gsvolu("CB3A", "BOX ", idtmed[1107], tpar, 0);     //Bakelite 
1013      gMC->Gsvolu("CG3A", "BOX ", idtmed[1106], tpar, 0);     //Gas streamer
1014
1015 // chamber type A
1016      tpar[0] = -1.;
1017      tpar[1] = -1.;
1018      
1019      const Float_t X_MC3A=X_MC3_MED+(X_MC3_MAX-X_MC3_MED)/2.;
1020      const Float_t Y_MC3A=0.;
1021      const Float_t Z_MC3A=0.;
1022           
1023      tpar[2] = 0.1;    
1024      gMC->Gsposp("CG3A", 1, "CB3A", 0., 0., 0., 0, "ONLY",tpar,3);
1025      tpar[2] = 0.3;
1026      gMC->Gsposp("CB3A", 1, "CC3A", 0., 0., 0., 0, "ONLY",tpar,3);
1027      tpar[0] = (X_MC3_MAX-X_MC3_MED)/2.;
1028      tpar[1] = Y_MC3_MIN;
1029      tpar[2] = 0.4;
1030      gMC->Gsposp("CC3A", 1, "CM21",X_MC3A,Y_MC3A,Z_MC3A, 0, "ONLY", tpar, 3);
1031      gMC->Gsposp("CC3A", 2, "CM21",-X_MC3A,Y_MC3A,Z_MC3A, 0, "ONLY", tpar, 3);
1032      
1033 //  chamber type B    
1034      tpar[0] = (X_MC3_MAX-X_MC3_MIN)/2.;
1035      tpar[1] = (Y_MC3_MAX-Y_MC3_MIN)/2.;
1036      
1037      const Float_t X_MC3B=X_MC3_MIN+tpar[0];
1038      const Float_t Y_MC3B=Y_MC3_MIN+tpar[1];
1039      const Float_t Z_MC3B=0.;
1040
1041      gMC->Gsposp("CC3A", 3, "CM21",X_MC3B,Y_MC3B,Z_MC3B, 0, "ONLY", tpar, 3);
1042      gMC->Gsposp("CC3A", 4, "CM21",-X_MC3B,Y_MC3B,Z_MC3B, 0, "ONLY", tpar, 3);
1043      gMC->Gsposp("CC3A", 5, "CM21",X_MC3B,-Y_MC3B,Z_MC3B, 0, "ONLY", tpar, 3);
1044      gMC->Gsposp("CC3A", 6, "CM21",-X_MC3B,-Y_MC3B,Z_MC3B, 0, "ONLY", tpar, 3);
1045      
1046 //  chamber type C        
1047      tpar[0] = X_MC3_MAX/2.;
1048      tpar[1] = Y_MC3_MAX/2.;
1049      
1050      const Float_t X_MC3C=tpar[0];
1051      const Float_t Y_MC3C=Y_MC3_MAX+tpar[1];
1052      const Float_t Z_MC3C=0.;
1053      
1054      gMC->Gsposp("CC3A", 7, "CM21",X_MC3C,Y_MC3C,Z_MC3C, 0, "ONLY", tpar, 3);
1055      gMC->Gsposp("CC3A", 8, "CM21",-X_MC3C,Y_MC3C,Z_MC3C, 0, "ONLY", tpar, 3);
1056      gMC->Gsposp("CC3A", 9, "CM21",X_MC3C,-Y_MC3C,Z_MC3C, 0, "ONLY", tpar, 3);
1057      gMC->Gsposp("CC3A", 10, "CM21",-X_MC3C,-Y_MC3C,Z_MC3C, 0, "ONLY", tpar, 3);
1058      
1059 //  chamber type D        
1060      tpar[0] = X_MC3_MAX/2.;
1061      tpar[1] = Y_MC3_MIN;
1062      
1063      const Float_t X_MC3D=tpar[0];
1064      const Float_t Z_MC3D=0.;
1065      
1066      Float_t Y_MC3D=4.*Y_MC3_MIN;
1067      gMC->Gsposp("CC3A", 11, "CM21",X_MC3D,Y_MC3D,Z_MC3D, 0, "ONLY", tpar, 3);
1068      gMC->Gsposp("CC3A", 12, "CM21",X_MC3D,-Y_MC3D,Z_MC3D, 0, "ONLY", tpar, 3);
1069      gMC->Gsposp("CC3A", 13, "CM21",-X_MC3D,Y_MC3D,Z_MC3D, 0, "ONLY", tpar, 3);
1070      gMC->Gsposp("CC3A", 14, "CM21",-X_MC3D,-Y_MC3D,Z_MC3D, 0, "ONLY", tpar, 3);
1071
1072      Y_MC3D=6.*Y_MC3_MIN;
1073      gMC->Gsposp("CC3A", 15, "CM21",X_MC3D,Y_MC3D,Z_MC3D, 0, "ONLY", tpar, 3);
1074      gMC->Gsposp("CC3A", 16, "CM21",X_MC3D,-Y_MC3D,Z_MC3D, 0, "ONLY", tpar, 3);
1075      gMC->Gsposp("CC3A", 17, "CM21",-X_MC3D,Y_MC3D,Z_MC3D, 0, "ONLY", tpar, 3);
1076      gMC->Gsposp("CC3A", 18, "CM21",-X_MC3D,-Y_MC3D,Z_MC3D, 0, "ONLY", tpar, 3);
1077
1078      Y_MC3D=8.*Y_MC3_MIN;
1079      gMC->Gsposp("CC3A", 19, "CM21",X_MC3D,Y_MC3D,Z_MC3D, 0, "ONLY", tpar, 3);
1080      gMC->Gsposp("CC3A", 20, "CM21",X_MC3D,-Y_MC3D,Z_MC3D, 0, "ONLY", tpar, 3);
1081      gMC->Gsposp("CC3A", 21, "CM21",-X_MC3D,Y_MC3D,Z_MC3D, 0, "ONLY", tpar, 3);
1082      gMC->Gsposp("CC3A", 22, "CM21",-X_MC3D,-Y_MC3D,Z_MC3D, 0, "ONLY", tpar, 3);
1083
1084 // Positioning third plane in ALICE     
1085      gMC->Gspos("CM21", 1, "ALIC", 0., 0., zpos3, 0, "ONLY");
1086
1087 // End of geometry definition for the third plane
1088
1089 // Station 2 - plan 4  -  same RPCs as plan 3 ==> small non covered area
1090 // Y position moved (ratio zpos4/zpos3)
1091      const Float_t Z_3S4=zpos4/zpos3;
1092      
1093 // Definition of prototype for chambers in the fourth plane     
1094           
1095      tpar[0]= 0.;
1096      tpar[1]= 0.;
1097      tpar[2]= 0.;
1098           
1099      gMC->Gsvolu("CC4A", "BOX ", idtmed[1103], tpar, 0);     //Al      
1100      gMC->Gsvolu("CB4A", "BOX ", idtmed[1107], tpar, 0);     //Bakelite 
1101      gMC->Gsvolu("CG4A", "BOX ", idtmed[1106], tpar, 0);     //Gas streamer
1102
1103 // chamber type A
1104      tpar[0] = -1.;
1105      tpar[1] = -1.;
1106      
1107      const Float_t X_MC4A=X_MC3A;
1108      const Float_t Y_MC4A=0.;
1109      const Float_t Z_MC4A=0.;
1110           
1111      tpar[2] = 0.1;    
1112      gMC->Gsposp("CG4A", 1, "CB4A", 0., 0., 0., 0, "ONLY",tpar,3);
1113      tpar[2] = 0.3;
1114      gMC->Gsposp("CB4A", 1, "CC4A", 0., 0., 0., 0, "ONLY",tpar,3);
1115      tpar[2] = 0.4;
1116      tpar[0] = (X_MC3_MAX-X_MC3_MED)/2.;
1117      tpar[1] = Y_MC3_MIN;
1118      gMC->Gsposp("CC4A", 1, "CM22",X_MC4A,Y_MC4A,Z_MC4A, 0, "ONLY", tpar, 3);
1119      gMC->Gsposp("CC4A", 2, "CM22",-X_MC4A,Y_MC4A,Z_MC4A, 0, "ONLY", tpar, 3);
1120      
1121 //  chamber type B    
1122      tpar[0] = (X_MC3_MAX-X_MC3_MIN)/2.;
1123      tpar[1] = (Y_MC3_MAX-Y_MC3_MIN)/2.;
1124      
1125      const Float_t X_MC4B=X_MC3B;
1126      const Float_t Y_MC4B=2.*Y_MC3_MIN*Z_3S4-Y_MC3_MIN*1.5+Y_MC3_MAX*0.5;
1127      const Float_t Z_MC4B=0.;
1128
1129      gMC->Gsposp("CC4A", 3, "CM22",X_MC4B,Y_MC4B,Z_MC4B, 0, "ONLY", tpar, 3);
1130      gMC->Gsposp("CC4A", 4, "CM22",-X_MC4B,Y_MC4B,Z_MC4B, 0, "ONLY", tpar, 3);
1131      gMC->Gsposp("CC4A", 5, "CM22",X_MC4B,-Y_MC4B,Z_MC4B, 0, "ONLY", tpar, 3);
1132      gMC->Gsposp("CC4A", 6, "CM22",-X_MC4B,-Y_MC4B,Z_MC4B, 0, "ONLY", tpar, 3);
1133      
1134 //  chamber type C        
1135      tpar[0] = X_MC3_MAX/2;
1136      tpar[1] = Y_MC3_MAX/2;
1137      
1138      const Float_t X_MC4C=X_MC3C;
1139      const Float_t Y_MC4C=2.*Y_MC3_MIN*Z_3S4-Y_MC3_MIN*2.+Y_MC3_MAX*1.5;
1140      const Float_t Z_MC4C=0.;
1141      
1142      gMC->Gsposp("CC4A", 7, "CM22",X_MC4C,Y_MC4C,Z_MC4C, 0, "ONLY", tpar, 3);
1143      gMC->Gsposp("CC4A", 8, "CM22",-X_MC4C,Y_MC4C,Z_MC4C, 0, "ONLY", tpar, 3);
1144      gMC->Gsposp("CC4A", 9, "CM22",X_MC4C,-Y_MC4C,Z_MC4C, 0, "ONLY", tpar, 3);
1145      gMC->Gsposp("CC4A", 10, "CM22",-X_MC4C,-Y_MC4C,Z_MC4C, 0, "ONLY", tpar, 3);
1146      
1147 //  chamber type D        
1148      tpar[0] = X_MC3_MAX/2.;
1149      tpar[1] = Y_MC3_MIN;
1150      
1151      const Float_t X_MC4D=X_MC3D;
1152      const Float_t Z_MC4D=0.;
1153      
1154      Float_t Y_MC4D=4.*Y_MC3_MIN*Z_3S4;
1155      gMC->Gsposp("CC4A", 11, "CM22",X_MC4D,Y_MC4D,Z_MC4D, 0, "ONLY", tpar, 3);
1156      gMC->Gsposp("CC4A", 12, "CM22",X_MC4D,-Y_MC4D,Z_MC4D, 0, "ONLY", tpar, 3);
1157      gMC->Gsposp("CC4A", 13, "CM22",-X_MC4D,Y_MC4D,Z_MC4D, 0, "ONLY", tpar, 3);
1158      gMC->Gsposp("CC4A", 14, "CM22",-X_MC4D,-Y_MC4D,Z_MC4D, 0, "ONLY", tpar, 3);
1159
1160      Y_MC4D=6.*Y_MC3_MIN*Z_3S4;
1161      gMC->Gsposp("CC4A", 15, "CM22",X_MC4D,Y_MC4D,Z_MC4D, 0, "ONLY", tpar, 3);
1162      gMC->Gsposp("CC4A", 16, "CM22",X_MC4D,-Y_MC4D,Z_MC4D, 0, "ONLY", tpar, 3);
1163      gMC->Gsposp("CC4A", 17, "CM22",-X_MC4D,Y_MC4D,Z_MC4D, 0, "ONLY", tpar, 3);
1164      gMC->Gsposp("CC4A", 18, "CM22",-X_MC4D,-Y_MC4D,Z_MC4D, 0, "ONLY", tpar, 3);
1165
1166      Y_MC4D=8.*Y_MC3_MIN*Z_3S4;
1167      gMC->Gsposp("CC4A", 19, "CM22",X_MC4D,Y_MC4D,Z_MC4D, 0, "ONLY", tpar, 3);
1168      gMC->Gsposp("CC4A", 20, "CM22",X_MC4D,-Y_MC4D,Z_MC4D, 0, "ONLY", tpar, 3);
1169      gMC->Gsposp("CC4A", 21, "CM22",-X_MC4D,Y_MC4D,Z_MC4D, 0, "ONLY", tpar, 3);
1170      gMC->Gsposp("CC4A", 22, "CM22",-X_MC4D,-Y_MC4D,Z_MC4D, 0, "ONLY", tpar, 3);
1171      
1172      gMC->Gspos("CM22", 1, "ALIC", 0., 0., zpos4, 0, "ONLY");
1173 }
1174
1175  
1176 //___________________________________________
1177 void AliMUONv0::CreateMaterials()
1178 {
1179   // *** DEFINITION OF AVAILABLE MUON MATERIALS *** 
1180   //
1181   //     Ar-CO2 gas 
1182     Float_t ag1[3]   = { 39.95,12.01,16. };
1183     Float_t zg1[3]   = { 18.,6.,8. };
1184     Float_t wg1[3]   = { .8,.0667,.13333 };
1185     Float_t dg1      = .001821;
1186     //
1187     //     Ar-buthane-freon gas -- trigger chambers 
1188     Float_t atr1[4]  = { 39.95,12.01,1.01,19. };
1189     Float_t ztr1[4]  = { 18.,6.,1.,9. };
1190     Float_t wtr1[4]  = { .56,.1262857,.2857143,.028 };
1191     Float_t dtr1     = .002599;
1192     //
1193     //     Ar-CO2 gas 
1194     Float_t agas[3]  = { 39.95,12.01,16. };
1195     Float_t zgas[3]  = { 18.,6.,8. };
1196     Float_t wgas[3]  = { .74,.086684,.173316 };
1197     Float_t dgas     = .0018327;
1198     //
1199     //     Ar-Isobutane gas (80%+20%) -- tracking 
1200     Float_t ag[3]    = { 39.95,12.01,1.01 };
1201     Float_t zg[3]    = { 18.,6.,1. };
1202     Float_t wg[3]    = { .8,.057,.143 };
1203     Float_t dg       = .0019596;
1204     //
1205     //     Ar-Isobutane-Forane-SF6 gas (49%+7%+40%+4%) -- trigger 
1206     Float_t atrig[5] = { 39.95,12.01,1.01,19.,32.066 };
1207     Float_t ztrig[5] = { 18.,6.,1.,9.,16. };
1208     Float_t wtrig[5] = { .49,1.08,1.5,1.84,0.04 };
1209     Float_t dtrig    = .0031463;
1210     //
1211     //     bakelite 
1212
1213     Float_t abak[3] = {12.01 , 1.01 , 16.};
1214     Float_t zbak[3] = {6.     , 1.   , 8.};
1215     Float_t wbak[3] = {6.     , 6.   , 1.}; 
1216     Float_t dbak = 1.4;
1217
1218     Float_t epsil, stmin, deemax, tmaxfd, stemax;
1219
1220     Int_t ISXFLD   = gAlice->Field()->Integ();
1221     Float_t SXMGMX = gAlice->Field()->Max();
1222     //
1223     // --- Define the various materials for GEANT --- 
1224     AliMaterial(9, "ALUMINIUM$", 26.98, 13., 2.7, 8.9, 37.2);
1225     AliMaterial(15, "AIR$      ", 14.61, 7.3, .001205, 30423.24, 67500);
1226     AliMixture(19, "Bakelite$", abak, zbak, dbak, -3, wbak);
1227     AliMixture(20, "ArC4H10 GAS$", ag, zg, dg, 3, wg);
1228     AliMixture(21, "TRIG GAS$", atrig, ztrig, dtrig, -5, wtrig);
1229     AliMixture(22, "ArCO2 80%$", ag1, zg1, dg1, 3, wg1);
1230     AliMixture(23, "Ar-freon $", atr1, ztr1, dtr1, 4, wtr1);
1231     AliMixture(24, "ArCO2 GAS$", agas, zgas, dgas, 3, wgas);
1232
1233     epsil  = .001; // Tracking precision, 
1234     stemax = -1.;  // Maximum displacement for multiple scat 
1235     tmaxfd = -20.; // Maximum angle due to field deflection 
1236     deemax = -.3;  // Maximum fractional energy loss, DLS 
1237     stmin  = -.8;
1238     //
1239     //    Air 
1240     AliMedium(1, "AIR_CH_US         ", 15, 1, ISXFLD, SXMGMX, tmaxfd, stemax, deemax, epsil, stmin);
1241     //
1242     //    Aluminum 
1243
1244     AliMedium(4, "ALU_CH_US          ", 9, 0, ISXFLD, SXMGMX, tmaxfd, fMaxStepAlu, 
1245             fMaxDestepAlu, epsil, stmin);
1246     //
1247     //    Ar-isoC4H10 gas 
1248
1249     AliMedium(6, "AR_CH_US          ", 20, 1, ISXFLD, SXMGMX, tmaxfd, fMaxStepGas, 
1250             fMaxDestepGas, epsil, stmin);
1251 //
1252     //    Ar-Isobuthane-Forane-SF6 gas 
1253
1254     AliMedium(7, "GAS_CH_TRIGGER    ", 21, 1, ISXFLD, SXMGMX, tmaxfd, stemax, deemax, epsil, stmin);
1255
1256     AliMedium(8, "BAKE_CH_TRIGGER   ", 19, 0, ISXFLD, SXMGMX, tmaxfd, fMaxStepAlu, 
1257             fMaxDestepAlu, epsil, stmin);
1258
1259 }
1260
1261 //___________________________________________
1262
1263 void AliMUONv0::Init()
1264 {
1265    printf("\n\n\n Start Init for version 0 - CPC chamber type\n\n\n");
1266
1267    // 
1268    // Initialize Tracking Chambers
1269    //
1270    for (Int_t i=0; i<NCH; i++) {
1271        ( (AliMUONchamber*) (*fChambers)[i])->Init();
1272    }
1273    //
1274    // Set the chamber (sensitive region) GEANT identifier
1275    ((AliMUONchamber*)(*fChambers)[0])->SetGid(gMC->VolId("C01G"));
1276    ((AliMUONchamber*)(*fChambers)[1])->SetGid(gMC->VolId("C02G"));
1277    ((AliMUONchamber*)(*fChambers)[2])->SetGid(gMC->VolId("C03G"));
1278    ((AliMUONchamber*)(*fChambers)[3])->SetGid(gMC->VolId("C04G"));
1279    ((AliMUONchamber*)(*fChambers)[4])->SetGid(gMC->VolId("C05G"));
1280    ((AliMUONchamber*)(*fChambers)[5])->SetGid(gMC->VolId("C06G"));
1281    ((AliMUONchamber*)(*fChambers)[6])->SetGid(gMC->VolId("C07G"));
1282    ((AliMUONchamber*)(*fChambers)[7])->SetGid(gMC->VolId("C08G"));
1283    ((AliMUONchamber*)(*fChambers)[8])->SetGid(gMC->VolId("C09G"));
1284    ((AliMUONchamber*)(*fChambers)[9])->SetGid(gMC->VolId("C10G"));
1285    ((AliMUONchamber*)(*fChambers)[10])->SetGid(gMC->VolId("CG1A"));
1286    ((AliMUONchamber*)(*fChambers)[11])->SetGid(gMC->VolId("CG2A"));
1287    ((AliMUONchamber*)(*fChambers)[12])->SetGid(gMC->VolId("CG3A"));
1288    ((AliMUONchamber*)(*fChambers)[13])->SetGid(gMC->VolId("CG4A"));
1289
1290    printf("\n\n\n Finished Init for version 0 - CPC chamber type\n\n\n");
1291 }
1292
1293 //___________________________________________
1294 void AliMUONv0::StepManager()
1295 {
1296   Int_t          copy, id;
1297   static Int_t   idvol;
1298   static Int_t   vol[2];
1299   Int_t          ipart;
1300   static Float_t hits[10];
1301   Float_t        destep, step;
1302   static Float_t eloss, xhit, yhit, tlength;
1303   const  Float_t big=1.e10;
1304   TLorentzVector pos, mom;
1305   
1306   TClonesArray &lhits = *fHits;
1307
1308   //
1309   // Set maximum step size for gas
1310   // numed=gMC->GetMedium();
1311   //
1312   // Only charged tracks
1313   if( !(gMC->TrackCharge()) ) return; 
1314   //
1315   // Only gas gap inside chamber
1316   // Tag chambers and record hits when track enters 
1317   idvol=-1;
1318   id=gMC->CurrentVolID(copy);
1319   
1320     for (Int_t i=1; i<=NCH; i++) {
1321       if(id==((AliMUONchamber*)(*fChambers)[i-1])->GetGid()){ 
1322           vol[0]=i; 
1323           idvol=i-1;
1324       }
1325     }
1326     if (idvol == -1) return;
1327   //
1328   // Get current particle id (ipart), track position (pos)  and momentum (mom) 
1329   gMC->TrackPosition(pos);
1330   gMC->TrackMomentum(mom);
1331
1332   ipart  = gMC->TrackPid();
1333   //
1334   // momentum loss and steplength in last step
1335   destep = gMC->Edep();
1336   step   = gMC->TrackStep();
1337   
1338   //
1339   // record hits when track enters ...
1340   if( gMC->IsTrackEntering()) {
1341       gMC->SetMaxStep(fMaxStepGas);
1342       //      Double_t tc = mom[0]*mom[0]+mom[1]*mom[1];
1343       //Double_t rt = TMath::Sqrt(tc);
1344       //theta   = Float_t(TMath::ATan2(rt,Double_t(mom[2])))*kRaddeg;
1345       //phi     = Float_t(TMath::ATan2(Double_t(mom[1]),Double_t(mom[0])))*kRaddeg;
1346       hits[0] = Float_t(ipart);         // Geant3 particle type
1347       hits[1] = pos[0];                 // X-position for hit
1348       hits[2] = pos[1];                 // Y-position for hit
1349       hits[3] = pos[2];                 // Z-position for hit
1350       hits[4] = mom.Theta()*kRaddeg;    // theta angle of incidence
1351       hits[5] = mom.Phi()*kRaddeg;      // phi angle of incidence 
1352       hits[8] = (Float_t) fNclusters;   // first padhit
1353       hits[9] = -1;                     // last pad hit
1354       // phi angle of incidence
1355       tlength = 0;
1356       eloss   = 0;
1357       xhit    = pos[0];
1358       yhit    = pos[1];      
1359       // Only if not trigger chamber
1360       if(idvol<10) {
1361           //
1362           //  Initialize hit position (cursor) in the segmentation model 
1363           ((AliMUONchamber*) (*fChambers)[idvol])
1364               ->SigGenInit(pos[0], pos[1], pos[2]);
1365       } else {
1366           //geant3->Gpcxyz();
1367           //printf("In the Trigger Chamber #%d\n",idvol-9);
1368       }
1369   }
1370   
1371   // 
1372   // Calculate the charge induced on a pad (disintegration) in case 
1373   //
1374   // Mip left chamber ...
1375   if( gMC->IsTrackExiting() || gMC->IsTrackStop() || gMC->IsTrackDisappeared()){
1376       gMC->SetMaxStep(big);
1377       eloss   += destep;
1378       tlength += step;
1379       
1380       // Only if not trigger chamber
1381       if(idvol<10) {
1382           if (eloss > 0) MakePadHits(xhit,yhit,eloss,idvol);
1383       }
1384           
1385       hits[6]=tlength;
1386       hits[7]=eloss;
1387       if (fNclusters > (Int_t)hits[8]) {
1388           hits[8]= hits[8]+1;
1389           hits[9]= (Float_t) fNclusters;
1390       }
1391     
1392       new(lhits[fNhits++]) 
1393           AliMUONhit(fIshunt,gAlice->CurrentTrack(),vol,hits);
1394       eloss = 0; 
1395       //
1396       // Check additional signal generation conditions 
1397       // defined by the segmentation
1398       // model (boundary crossing conditions) 
1399   } else if 
1400       (((AliMUONchamber*) (*fChambers)[idvol])
1401        ->SigGenCond(pos[0], pos[1], pos[2]))
1402   {
1403       ((AliMUONchamber*) (*fChambers)[idvol])
1404           ->SigGenInit(pos[0], pos[1], pos[2]);
1405 //      printf("\n-> MakePadHits, reason special %d",ipart);
1406       if (eloss > 0) MakePadHits(xhit,yhit,eloss,idvol);
1407       xhit     = pos[0];
1408       yhit     = pos[1]; 
1409       eloss    = destep;
1410       tlength += step ;
1411       //
1412       // nothing special  happened, add up energy loss
1413   } else {        
1414       eloss   += destep;
1415       tlength += step ;
1416   }
1417 }
1418
1419 //___________________________________________
1420 void AliMUON::MakePadHits(Float_t xhit,Float_t yhit,Float_t eloss, Int_t idvol)
1421 {
1422 //
1423 //  Calls the charge disintegration method of the current chamber and adds
1424 //  the simulated cluster to the root treee 
1425 //
1426     Int_t clhits[7];
1427     Float_t newclust[6][500];
1428     Int_t nnew;
1429     
1430     
1431 //
1432 //  Integrated pulse height on chamber
1433
1434     
1435     clhits[0]=fNhits+1;
1436 //
1437 //
1438     ((AliMUONchamber*) (*fChambers)[idvol])->DisIntegration(eloss, xhit, yhit, nnew, newclust);
1439 //    printf("\n Add new clusters %d %f", nnew, eloss*1.e9);
1440     Int_t ic=0;
1441     
1442 //
1443 //  Add new clusters
1444     for (Int_t i=0; i<nnew; i++) {
1445         if (Int_t(newclust[3][i]) > 0) {
1446             ic++;
1447 // Cathode plane
1448             clhits[1] = Int_t(newclust[5][i]);
1449 //  Cluster Charge
1450             clhits[2] = Int_t(newclust[0][i]);
1451 //  Pad: ix
1452             clhits[3] = Int_t(newclust[1][i]);
1453 //  Pad: iy 
1454             clhits[4] = Int_t(newclust[2][i]);
1455 //  Pad: charge
1456             clhits[5] = Int_t(newclust[3][i]);
1457 //  Pad: chamber sector
1458             clhits[6] = Int_t(newclust[4][i]);
1459             
1460             AddCluster(clhits);
1461         }
1462     }
1463 //    printf("\n %d new clusters added", ic);
1464 }
1465
1466 ClassImp(AliMUONchamber)        
1467     AliMUONchamber::AliMUONchamber() 
1468 {
1469     fSegmentation = new TObjArray(2);
1470     fResponse=0;
1471     fnsec=1;
1472 }
1473
1474 void AliMUONchamber::Init()
1475 {
1476     
1477     ((AliMUONsegmentation *) (*fSegmentation)[0])->Init(this);
1478     if (fnsec==2) {
1479         ((AliMUONsegmentation *) (*fSegmentation)[1])->Init(this);
1480     }
1481     
1482 }
1483
1484 void AliMUONchamber::DisIntegration(Float_t eloss, Float_t xhit, Float_t yhit,
1485                                     Int_t& nnew,Float_t newclust[6][500]) 
1486 {
1487 //    
1488 //  Generates pad hits (simulated cluster) 
1489 //  using the segmentation and the response model 
1490     Float_t dx, dy;
1491     //
1492     // Width of the integration area
1493     //
1494     dx=fResponse->Nsigma()*fResponse->ChwX();
1495     dy=fResponse->Nsigma()*fResponse->ChwY();
1496     //
1497     // Get pulse height from energy loss
1498     Float_t qtot = fResponse->IntPH(eloss);
1499     //
1500     // Loop Over Pads
1501     
1502     Float_t qcheck=0, qp;
1503     nnew=0;
1504     for (Int_t i=1; i<=fnsec; i++) {
1505         qcheck=0;
1506         AliMUONsegmentation * segmentation=(AliMUONsegmentation *) (*fSegmentation)[i-1];
1507         for (segmentation->FirstPad(xhit, yhit, dx, dy); 
1508              segmentation->MorePads(); 
1509              segmentation->NextPad()) 
1510         {
1511             qp=fResponse->IntXY(segmentation);
1512             qp=TMath::Abs(qp);
1513             
1514 //
1515 //
1516             if (qp > 1.e-4) {
1517                 qcheck+=qp;
1518             //
1519             // --- store signal information
1520                 newclust[0][nnew]=qtot;
1521                 newclust[1][nnew]=segmentation->Ix();
1522                 newclust[2][nnew]=segmentation->Iy();
1523                 newclust[3][nnew]=qp * qtot;
1524                 newclust[4][nnew]=segmentation->ISector();
1525                 newclust[5][nnew]=(Float_t) i;
1526 //              printf("\n pad hit %d %d %f %f ",nnew,i,newclust[1][nnew],newclust[2][nnew]);
1527                 nnew++;
1528
1529                 
1530             }
1531         } // Pad loop
1532 //      printf("\n check sum is %f %f %f %f %d",qcheck,qtot,xhit,yhit,fGid);
1533     } // Cathode plane loop
1534 }
1535
1536
1537 ClassImp(AliMUONsegmentation)
1538 ClassImp(AliMUONresponse)       
1539 //___________________________________________
1540 ClassImp(AliMUONsegmentationV0)
1541     void AliMUONsegmentationV0::Init(AliMUONchamber* Chamber)
1542 {
1543     fNpx=(Int_t) (Chamber->frMax/fDpx+1);
1544     fNpy=(Int_t) (Chamber->frMax/fDpy+1);
1545 }
1546
1547
1548 Float_t AliMUONsegmentationV0::GetAnod(Float_t xhit)
1549 {
1550     Float_t wire= (xhit<0)? Int_t(xhit/fWireD)+0.5:Int_t(xhit/fWireD)-0.5;
1551     return fWireD*wire;
1552 }
1553
1554 void AliMUONsegmentationV0::SetPADSIZ(Float_t p1, Float_t p2)
1555 {
1556     fDpx=p1;
1557     fDpy=p2;
1558 }
1559 void AliMUONsegmentationV0::
1560     GetPadIxy(Float_t x, Float_t y, Int_t &ix, Int_t &iy)
1561 {
1562 //  returns pad coordinates (ix,iy) for given real coordinates (x,y)
1563 //
1564     ix = (x>0)? Int_t(x/fDpx)+1 : Int_t(x/fDpx)-1;
1565     iy = (y>0)? Int_t(y/fDpy)+1 : Int_t(y/fDpy)-1;
1566     if (iy >  fNpy) iy= fNpy;
1567     if (iy < -fNpy) iy=-fNpy;
1568     if (ix >  fNpx) ix= fNpx;
1569     if (ix < -fNpx) ix=-fNpx;
1570 }
1571 void AliMUONsegmentationV0::
1572 GetPadCxy(Int_t ix, Int_t iy, Float_t &x, Float_t &y)
1573 {
1574 //  returns real coordinates (x,y) for given pad coordinates (ix,iy)
1575 //
1576     x = (ix>0) ? Float_t(ix*fDpx)-fDpx/2. : Float_t(ix*fDpx)+fDpx/2.;
1577     y = (iy>0) ? Float_t(iy*fDpy)-fDpy/2. : Float_t(iy*fDpy)+fDpy/2.;
1578 }
1579
1580 void AliMUONsegmentationV0::
1581 FirstPad(Float_t xhit, Float_t yhit, Float_t dx, Float_t dy)
1582 {
1583     //
1584     // Find the wire position (center of charge distribution)
1585     Float_t x0a=GetAnod(xhit);
1586     //
1587     // and take fNsigma*sigma around this center
1588     Float_t x01=x0a  - dx;
1589     Float_t x02=x0a  + dx;
1590     Float_t y01=yhit - dy;
1591     Float_t y02=yhit + dy;
1592     //
1593     // find the pads over which the charge distributes
1594     GetPadIxy(x01,y01,fixmin,fiymin);
1595     GetPadIxy(x02,y02,fixmax,fiymax);    
1596 //    printf("\n %f %f %d %d",x02,y02,fixmax,fiymax);
1597 //    printf("\n FirstPad called %f %f ", fDpx, fDpy);
1598 //    printf("\n Hit Position %f %f",xhit,yhit);
1599 //    printf("\n Integration limits: %i %i %i %i",fixmin,fixmax,fiymin,fiymax);
1600 //    printf("\n Integration limits: %f %f %f %f \n",x01,x02,y01,y02);
1601     // 
1602     // Set current pad to lower left corner
1603     fix=fixmin;
1604     fiy=fiymin;
1605     GetPadCxy(fix,fiy,fx,fy);
1606 }
1607
1608 void AliMUONsegmentationV0::NextPad()
1609 {
1610   // 
1611   // Step to next pad in integration region
1612     if (fix != fixmax) {
1613         fix++;
1614     } else if (fiy != fiymax) {
1615         fix=fixmin;
1616         fiy++;
1617     } else {
1618         printf("\n Error: Stepping outside integration region\n ");
1619     }
1620     GetPadCxy(fix,fiy,fx,fy);
1621 }
1622
1623 Int_t AliMUONsegmentationV0::MorePads()
1624 //
1625 // Are there more pads in the integration region
1626 {
1627     if (fix == fixmax && fiy == fiymax) {
1628         return 0;
1629     } else {
1630         return 1;
1631         
1632     }
1633 }
1634
1635 void AliMUONsegmentationV0::SigGenInit(Float_t x,Float_t y,Float_t)
1636 {
1637 //
1638 //  Initialises pad and wire position during stepping
1639     fxt =x;
1640     fyt =y;
1641     GetPadIxy(x,y,fixt,fiyt);
1642     fiwt=Int_t(x/fWireD)+1;
1643 }
1644
1645 Int_t AliMUONsegmentationV0::SigGenCond(Float_t x,Float_t y,Float_t)
1646 {
1647 //
1648 //  Signal will be generated if particle crosses pad boundary or
1649 //  boundary between two wires. 
1650     Int_t ixt, iyt;
1651     GetPadIxy(x,y,ixt,iyt);
1652     Int_t iwt=Int_t(x/fWireD)+1;
1653     
1654     if ((ixt != fixt) || (iyt !=fiyt) || (iwt != fiwt)) {
1655         return 1;
1656     } else {
1657         return 0;
1658     }
1659 }
1660 void AliMUONsegmentationV0::
1661 IntegrationLimits(Float_t& x1,Float_t& x2,Float_t& y1, Float_t& y2)
1662 {
1663     x1=fxt-fx-fDpx/2.;
1664     x2=x1+fDpx;
1665     y1=fyt-fy-fDpy/2.;
1666     y2=y1+fDpy;    
1667 }
1668
1669 void AliMUONsegmentationV0::
1670 Neighbours(Int_t iX, Int_t iY, Int_t* Nlist, Int_t Xlist[7], Int_t Ylist[7])
1671 {
1672     *Nlist=4;Xlist[0]=Xlist[1]=iX;Xlist[2]=iX-1;Xlist[3]=iX+1;
1673     Ylist[0]=iY-1;Ylist[1]=iY+1;Ylist[2]=Ylist[3]=iY;
1674 }
1675
1676 void AliMUONsegmentationV0::
1677 FitXY(AliMUONRecCluster* ,TClonesArray* )
1678     // Default : Centre of gravity method
1679 {
1680     ;
1681 }
1682
1683
1684 //___________________________________________
1685 ClassImp(AliMUONresponseV0)     
1686 Float_t AliMUONresponseV0::IntPH(Float_t eloss)
1687 {
1688   // Get number of electrons and return charge
1689      
1690   Int_t nel;
1691   nel= Int_t(eloss*1.e9/26.);
1692   Float_t charge=0;
1693   if (nel == 0) nel=1;
1694   for (Int_t i=1;i<=nel;i++) {
1695     charge -= fChslope*TMath::Log(gRandom->Rndm());    
1696   }
1697   return charge;
1698 }
1699 // -------------------------------------------
1700 Float_t AliMUONresponseV0::IntXY(AliMUONsegmentation * segmentation)
1701 {
1702
1703     const Float_t invpitch = 1/fPitch;
1704 //
1705 //  Integration limits defined by segmentation model
1706 //  
1707     Float_t xi1, xi2, yi1, yi2;
1708     segmentation->IntegrationLimits(xi1,xi2,yi1,yi2);
1709     xi1=xi1*invpitch;
1710     xi2=xi2*invpitch;
1711     yi1=yi1*invpitch;
1712     yi2=yi2*invpitch;
1713 //
1714 // The Mathieson function 
1715     Double_t ux1=fSqrtKx3*TMath::TanH(fKx2*xi1);
1716     Double_t ux2=fSqrtKx3*TMath::TanH(fKx2*xi2);
1717
1718     Double_t uy1=fSqrtKy3*TMath::TanH(fKy2*yi1);
1719     Double_t uy2=fSqrtKy3*TMath::TanH(fKy2*yi2);
1720
1721     
1722     return Float_t(4.*fKx4*(TMath::ATan(ux2)-TMath::ATan(ux1))*
1723                       fKy4*(TMath::ATan(uy2)-TMath::ATan(uy1)));
1724 }
1725
1726 // -------------------------------------------
1727 ClassImp(AliMUONgeometry)       
1728     void AliMUONgeometry::InitGeo(Float_t)
1729 {
1730       fdGas= 0.5;
1731       fdAlu= 2.5/100*8.9;
1732 }
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748