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