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