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