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