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