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