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