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