]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PMD/AliPMDv0.cxx
Removal of useless dependecies via forward declarations
[u/mrichter/AliRoot.git] / PMD / AliPMDv0.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 purpose. It is          *
13  * provided "as is" without express or implied warranty.                  *
14  **************************************************************************/
15
16 /*
17 $Log$
18 Revision 1.7  1999/10/06 13:05:52  fca
19 Temporary fix to keep the code working waiting for Y.Viyogi
20
21 Revision 1.6  1999/09/29 09:24:28  fca
22 Introduction of the Copyright and cvs Log
23
24 */
25
26 ///////////////////////////////////////////////////////////////////////////////
27 //                                                                           //
28 //  Photon Multiplicity Detector Version 1                                   //
29 //                                                                           //
30 //Begin_Html
31 /*
32 <img src="picts/AliPMDv0Class.gif">
33 */
34 //End_Html
35 //                                                                           //
36 ///////////////////////////////////////////////////////////////////////////////
37 #include "AliPMDv0.h"
38 #include "AliRun.h"
39 #include "AliMC.h" 
40 #include "AliConst.h" 
41 #include "AliMagF.h"
42  
43 static Float_t smod2[3], smod3[3], smod4[3];
44 static Int_t maxbox, kdet;
45 static Float_t thgas,thmin,thmax,zdist,zdist1,thlow,
46   thhigh,edge;
47 static Int_t numqu;
48 static Float_t xbox[40][40], ybox[40][40];
49 static Int_t pindex[40][40];
50  
51 ClassImp(AliPMDv0)
52 //_____________________________________________________________________________
53 AliPMDv0::AliPMDv0() : AliPMD()
54 {
55   //
56   // Default constructor 
57   //
58   fMedSens=0;
59 }
60  
61 //_____________________________________________________________________________
62 AliPMDv0::AliPMDv0(const char *name, const char *title)
63   : AliPMD(name,title)
64 {
65   //
66   // Standard constructor
67   //
68   fMedSens=0;
69 }
70
71 //_____________________________________________________________________________
72 void AliPMDv0::Coordnew()
73 {
74   //
75   // Find coordinates for pad geometry
76   //
77   // Author Y.P. Viyogi, VECC Calcutta
78   //
79
80   Float_t th1, th2, dbox, dist;
81   //Float_t xoff[40][40], yoff[40][40];
82   Int_t i, j, nbox;
83   Float_t rlow;
84   Int_t xoff1[3], yoff1[3], l;
85   Float_t rhigh, dmax, hole;
86   Int_t kk, nhol;
87   Float_t rr, xx, yy;
88   
89   th1 = thmin * kPI / 180;
90   th2 = thmax * kPI / 180;
91   /* ESTIMATES FOR OCTAGON */
92   dist = zdist * TMath::Tan(th2);
93   /* ***  04.06.97 Fixed Module size of 6 cm, 0 mm boundary. */
94   /* ***  variable pad sizes of 0.3 mm, 0.5  mm, 1.0 mm and 1.2 mm */
95   dbox = edge * 2 + 24;
96   maxbox = Int_t(dist / dbox + .5);
97   dmax= maxbox * dbox;
98   /* NOW GET THE HOLE SIZE ETC. */
99   hole = zdist * TMath::Tan(th1);
100   nhol = Int_t(hole / dbox + .5);
101   hole = nhol * dbox;
102   
103   rlow = zdist * TMath::Tan(thlow * kPI / 180);
104   rhigh = zdist * TMath::Tan(thhigh * kPI / 180);
105   for (i = 1; i <= 40; ++i) {
106     for (j = 1; j <= 40; ++j) {
107       //index[j][i] = 0;
108       //xoff[j][i] = 0;
109       //yoff[j][i] = 0;
110       xbox[j][i] = 0;
111       /* L5: */
112       ybox[j][i] = 0;
113     }
114   }
115   
116   // NOW START PLACING THE BOXES IN VARIOUS LAYERS, START FROM THE CENTRE 
117   
118   yy = dbox / 2;
119   for(i=0;i<3;i++) yoff1[i]=0;
120   nbox = 0;
121   //        PRINT*,'MAXBOX=',MAXBOX 
122   for (i = 1; i <= maxbox; ++i) {
123     xx = dbox / 2;
124     for(j=0;j<3;j++) xoff1[j]=0;
125         for (j = 1; j <= maxbox; ++j) {
126           rr = sqrt(xx*xx+yy*yy);
127           if (rr >= hole && rr <= dmax) {
128             //  BOX CAN BE FITTED 
129             //index[j][i] = 2;
130             //if (rr < rlow) index[j][i] = 1;
131             //else if (rr > rhigh) index[j][i] = 3;
132             xbox[j][i] = xx;
133             ybox[j][i] = yy;
134               ++nbox;
135               //xoff[j][i] = xoff1[index[j][i] - 1];
136               //yoff[j][i] = yoff1[index[j][i] - 1];
137           }
138           if (kdet == 1) kk = 1; else kk = 0;
139           for (l = 1; l <= 3; ++l)
140             xoff1[l - 1] += fNumPads[l + kk - 1];
141           xx += dbox;
142         }
143         
144         if (kdet == 1) kk = 1; else kk=0;
145         
146         for (l = 1; l <= 3; ++l)
147           yoff1[l - 1] += fNumPads[l + kk - 1];
148         yy += dbox;
149   }
150 }
151
152 //_____________________________________________________________________________
153 void AliPMDv0::Coordinates()
154 {
155   //
156   //  SUBROUTINE TO COMPUTE THE X- AND Y- COORDINATES OF THE BOXES 
157   //  WHICH CAN FIT INTO THE CIRCULAR REGION BETWEEN THE GIVEN ANGLES. 
158   //  INPUT : ZDIST, THMIN, THMAX, PADSIZE (FOR INSIDE and OUTSIDE PMD). 
159   //  ALL DIMENSIONS IN CM. 
160   // -- Author :        Y.P. VIYOGI, 10/05/1996. 
161
162   Float_t hole, dmax, dbox;
163   Int_t nhol;
164   Float_t dist;
165   Int_t nbox;
166   Float_t rlow;
167   Int_t i, j;
168   Float_t rhigh, rr, xx, yy, th1, th2;
169   
170   th1 = thmin*kPI/180;
171   th2 = thmax*kPI/180;
172   // ESTIMATES FOR OCTAGON 
173   dist = zdist * TMath::Tan(th2);
174   // ***  04.06.97 Fixed Module size of 24 cm, 3 mm boundary. 
175   // ***  variable pad sizes of 8 mm, 10 mm, 12mm and 15 mm 
176   dbox   = edge*2 + 24.;
177   maxbox = Int_t(dist / dbox + .5);
178   dmax   = maxbox*dbox;
179   // NOW GET THE HOLE SIZE ETC. 
180   hole = zdist * TMath::Tan(th1);
181   nhol = Int_t(hole / dbox + .5);
182   hole = nhol * dbox;
183   
184   rlow  = zdist * TMath::Tan(thlow*kPI/180);
185   rhigh = zdist * TMath::Tan(thhigh*kPI/180);
186   for (i = 0; i < 40; ++i) {
187     for (j = 0; j < 40; ++j) {
188       pindex[j][i] = 0;
189       xbox[j][i]   = 0;
190       ybox[j][i]   = 0;
191     }
192   }
193   
194   //  NOW START PLACING THE BOXES IN VARIOUS LAYERS, START FROM THE CENTRE 
195   yy   = dbox / 2;
196     nbox = 0;
197     for (i = 0; i < maxbox; ++i) {
198       xx = dbox / 2;
199       for (j = 0; j < maxbox; ++j) {
200         rr = TMath::Sqrt(xx*xx + yy*yy);
201         if (rr >= hole && rr <= dmax) {  //  BOX CAN BE FITTED 
202           pindex[j][i] = 2;
203           if (rr < rlow)  pindex[j][i] = 1;
204           if (rr > rhigh) pindex[j][i] = 3;
205           xbox[j][i] = xx;
206           ybox[j][i] = yy;
207           ++nbox;
208         }
209         xx += dbox;
210       }
211       yy += dbox;
212     }
213 }
214  
215 //_____________________________________________________________________________
216 void AliPMDv0::CreateGeometry()
217 {
218   //
219   // Create geometry for Photon Multiplicity Detector Version 1
220   //
221   //Begin_Html
222   /*
223     <img src="picts/AliPMDv0.gif">
224   */
225   //End_Html
226   //Begin_Html
227   /*
228     <img src="picts/AliPMDv0Tree.gif">
229   */
230   //End_Html
231   CreatePads();
232   CreateInside();
233 }
234  
235 //_____________________________________________________________________________
236 void AliPMDv0::CreateInside()
237 {
238   //
239   // Create inside of Pads
240   //
241   // -- Author :     Y.P. VIYOGI, 07/05/1996. 
242   // -- Modified:    P.V.K.S.Baba(JU), 15-12-97. 
243   
244   Float_t sipmd[3] = { 300.,300.,5. };
245   
246   Int_t i2;
247   
248   Float_t xiqa[4], yiqa[4];
249   Int_t inum2, inum3, inum4, i, j, k;
250   Float_t siqad[4];
251   Float_t zd, xd, yd, xp, yp, zp;
252   Int_t idrotm[100];
253   
254   Int_t *idtmed = fIdtmed->GetArray()-599;
255   
256   //  VOLUMES Names : begining with D for all PMD volumes, 
257   // The names of SIZE variables begin with S and have more meaningful
258   // characters as shown below. 
259   
260   //            VOLUME  SIZE    MEDIUM  :       REMARKS 
261   //            ------  -----   ------  : --------------------------- 
262   
263   //            DPMD    SIPMD   AIR     : INSIDE PMD  and its SIZE 
264   
265   
266   
267   // *** Define the  DPMD   Volume and fill with air *** 
268
269   gMC->Gsvolu("DPMD", "BOX ", idtmed[698], sipmd, 3);
270   
271   // *** Define DIQU Volume and fill with air 
272   siqad[0] = sipmd[0] / 2. - 1.;
273   siqad[1] = sipmd[1] / 2. - 1.;
274   siqad[2] = sipmd[2];
275   gMC->Gsvolu("DIQU","BOX ", idtmed[698], siqad, 3);
276   gMC->Gsatt("DIQU", "SEEN", 1);
277   
278   
279   // --- Place the modules in INSIDE PMD (DPMD) 
280   // --- FIRST CALCULATE THE COORDINATES OF THE MODULES WHICH CAN BE 
281   // --- ACCOMODATED. 
282   
283   kdet = 1;
284   Coordinates();
285   
286   //inum = 0;
287   zd   = 0.;
288   AliMatrix(idrotm[1], 90., 0.,   90.,  90., 0., 0.);
289   AliMatrix(idrotm[2], 90., 180., 90.,  90., 0., 0.);
290   AliMatrix(idrotm[3], 90., 180., 90., 270., 0., 0.);
291   AliMatrix(idrotm[4], 90., 0.,   90., 270., 0., 0.);
292   // ****  Filling the DIQU Vol. (One Quadrant) 
293   inum2 = 0;
294   inum3 = 0;
295     inum4 = 0;
296     for (i = 0; i < maxbox; ++i) {
297       i2 = maxbox;
298       for (j = 0; j < i2; ++j) {
299         if (xbox[j][i] <= 0 && ybox[j][i] <= 0) continue;
300         xd = xbox[j][i] - siqad[0];
301         yd = ybox[j][i] - siqad[1];
302         if (pindex[j][i] == 1) {
303           ++inum2;
304           gMC->Gsposp("DM11", inum2, "DIQU", xd, yd, zd, 0, "ONLY", smod2, 3);
305         }
306         if (pindex[j][i] == 2) {
307           ++inum3;
308           gMC->Gsposp("DM12", inum3, "DIQU", xd, yd, zd, 0, "ONLY", smod3, 3);
309         }
310         if (pindex[j][i] == 3) {
311           ++inum4;
312           gMC->Gsposp("DM13", inum4, "DIQU", xd, yd, zd, 0, "ONLY", smod4, 3);
313         }
314       }
315     }
316     xiqa[0] = siqad[0];
317     xiqa[1] = -siqad[0];
318     xiqa[2] = xiqa[1];
319     xiqa[3] = xiqa[0];
320     yiqa[0] = siqad[0];
321     yiqa[1] = yiqa[0];
322     yiqa[2] = -siqad[0];
323     yiqa[3] = yiqa[2];
324     i2      = numqu;
325     for (k = 1; k <= i2; ++k) {
326       gMC->Gsposp("DIQU", k, "DPMD", xiqa[k-1], yiqa[k-1], zd, idrotm[k], "ONLY", siqad, 3);
327     }
328     
329     // --- Place the DPMD in ALICE with front edge 6.0m from vertex  --- 
330     xp = 0.;
331     yp = 0.;
332     zp = zdist1;
333     gMC->Gspos("DPMD", 1, "ALIC", xp, yp, zp, 0, "ONLY");
334     
335 }
336
337 //_____________________________________________________________________________
338 void AliPMDv0::CreatePads()
339 {
340   //
341   // Create the geometry of the pads
342   // *** DEFINITION OF THE GEOMETRY OF THE PMD  *** 
343   // *** DIFFERENT PADS WITH SIZES 8 MM, 10 MM, 12 MM AND 15 MM SQUARE 
344   // -- Author :     Y.P. VIYOGI, 04/06/1997. 
345   // -- Modified:    P.V.K.S.Baba(JU), 13-12-97. 
346   
347   Int_t npad2;
348   Float_t /* scpv1[3], */ scpv2[3] /*, scpv3[3], scpv4[3] */;
349   Float_t  spsw1[3], spsw2[3];//, spsw3[3], spsw4[3];
350   Float_t  sw[3], xc, yc, zc;
351   Float_t sfe[3];
352   Float_t spb[3], pad1, pad2, pad3, pad4;
353   //  VOLUMES Names : begining with D for all PMD volumes, 
354   
355   //     DM11 : MODULE TYPE 
356   
357   // The names of SIZE variables begin with S and have more meaningful
358   // characters as shown below. 
359   
360   //            VOLUME  SIZE    MEDIUM  :       REMARKS 
361   //            ------  -----   ------  : --------------------------- 
362   
363   //            DPPB    SPB     PB      : PB Converter and its SIZE 
364   //            DPFE    SFE     FE      : FE Support Plate and its SIZE 
365   
366   //               DW11    SPSW3   G10     : PRESHOWER 
367   //               DV11    SCPV3   G10     : CPV 
368   //     ****************** VOLUME TREE ****************** 
369   
370   //                    DM11 (Module) 
371   //                           | 
372   //                           | 
373   //    ------------------------------------------------- 
374   //       |             |               |                 | 
375   //       |             |               |                 | 
376   //    DV11( CPV)      DPFE            DPPB              DW11(Preshower) 
377   //    ************************************************************ 
378   
379   
380   
381   Int_t *idtmed = fIdtmed->GetArray()-599;
382   
383   thgas  = fPar[2];
384   thmin  = fIn[0];
385   thmax  = fIn[1];
386   zdist1  = fIn[2];
387   zdist  = TMath::Abs(zdist1);
388   thlow  = fIn[3];
389   thhigh = fIn[4];
390   edge   = fGeo[1];
391   numqu  = Int_t(fGeo[2]);
392   
393   pad1  = fPadSize[0];
394   pad2  = fPadSize[1];
395   pad3  = fPadSize[2];
396   pad4  = fPadSize[3];
397   npad2 = Int_t(24/fPadSize[1]);
398   
399   spsw2[0] = (npad2 * pad2)/2 + edge;
400   spsw2[1] = spsw2[0];
401   spsw2[2] = (thgas + .4) / 2;
402   scpv2[0] = spsw2[0];
403   scpv2[1] = spsw2[1];
404   scpv2[2] = spsw2[2];
405 // The modules (DW11 and DV11 are filed with gas, G10 plate is ignored)
406   gMC->Gsvolu("DW11","BOX ", idtmed[604], spsw2, 3);
407   gMC->Gsatt("DW11", "SEEN", 1);
408   gMC->Gsvolu("DV11","BOX ", idtmed[604], spsw2, 3);
409   gMC->Gsatt("DV11", "SEEN", 1);
410   
411   // --- DEFINE MODULES, IRON, TUNGSTEN AND LEAD VOLUMES 
412
413   // This mod by fca, waiting for Yogendra Viyogi answer
414   spsw1[0] = spsw2[0];
415   spsw1[1] = spsw2[1];
416   spsw1[2] = spsw2[2];
417   // End of fca mod
418   
419   
420   spb[0] = spsw1[0];
421   spb[1] = spsw1[1];
422   spb[2] = .75;
423   gMC->Gsvolu("DPPB","BOX ", idtmed[600], spb, 3);
424   gMC->Gsatt("DPPB", "SEEN", 1);
425   
426   sw[0] = spsw1[0];
427   sw[1] = spsw1[1];
428   sw[2] = 0.9/2.;
429   gMC->Gsvolu("DPW ","BOX ", idtmed[600], sw, 3);
430   gMC->Gsatt("DPW ", "SEEN", 1);
431   
432   sfe[0] = spsw1[0];
433   sfe[1] = spsw1[1];
434   sfe[2] = 0.6/2.;
435   gMC->Gsvolu("DPFE","BOX ", idtmed[605], sfe, 3);
436   gMC->Gsatt("DPFE", "SEEN", 1);
437   
438   smod2[0] = spsw2[0];
439   smod2[1] = smod2[0];
440   smod2[2] = spsw2[2] + sfe[2] + spb[2] + scpv2[2];
441   gMC->Gsvolu("DM11", "BOX ", idtmed[698], smod2, 3);
442   
443   // ---  place gas box (as CPV), iron support, lead converter and gas box 
444   // ---  (preshower) in the module 
445   xc = 0.;
446   yc = 0.;
447   // --- First the CPV box 
448   zc = -(spsw2[2] + sfe[2] + spb[2] + spsw2[2]) + spsw2[2];
449   gMC->Gspos("DV11", 1, "DM11", xc, yc, zc, 0, "ONLY");
450   // --- Then iron support plate 
451   zc = zc + sfe[2] + spsw2[2];
452   gMC->Gspos("DPFE", 1, "DM11", xc, yc, zc, 0, "ONLY");
453   // --- Then lead converter plate 
454   zc = zc + sfe[2] + spb[2];
455   gMC->Gspos("DPPB", 1, "DM11", xc, yc, zc, 0, "ONLY");
456   // --- Lastly the preshower box 
457   zc = zc + spb[2] + spsw2[2];
458   gMC->Gspos("DW11", 1, "DM11", xc, yc, zc, 0, "ONLY");
459   
460 }
461  
462 //_____________________________________________________________________________
463 void AliPMDv0::DrawModule()
464 {
465   //
466   // Draw a shaded view of the Photon Multiplicity Detector
467   //
468
469   gMC->Gsatt("*", "seen", -1);
470   gMC->Gsatt("alic", "seen", 0);
471   //
472   // Set the visibility of the components
473   // 
474   gMC->Gsatt("DW11","seen",0);
475   gMC->Gsatt("DV11","seen",0);
476   gMC->Gsatt("DPPB","seen",1);
477   gMC->Gsatt("DPW ","seen",1); 
478   gMC->Gsatt("DPFE","seen",1);
479   gMC->Gsatt("DM11","seen",1);
480   gMC->Gsatt("DPMD","seen",0);
481   gMC->Gsatt("DIQU","seen",0);
482   //
483   gMC->Gdopt("hide", "on");
484   gMC->Gdopt("shad", "on");
485   gMC->Gsatt("*", "fill", 7);
486   gMC->SetClipBox(".");
487   gMC->SetClipBox("*", 0, 3000, -3000, 3000, -6000, 6000);
488   gMC->DefaultRange();
489   gMC->Gdraw("alic", 40, 30, 0, 22, 15.5, .04, .04);
490   gMC->Gdhead(1111, "Photon Multiplicity Detector Version 1");
491   gMC->Gdman(17, 5, "MAN");
492   gMC->Gdopt("hide", "off");
493 }
494
495 //_____________________________________________________________________________
496 void AliPMDv0::CreateMaterials()
497 {
498   //
499   // Create materials for the PMD version 1
500   //
501   // ORIGIN    : Y. P. VIYOGI 
502   //
503   
504   // --- The Argon- CO2 mixture --- 
505   Float_t ag[2] = { 39.95 };
506   Float_t zg[2] = { 18. };
507   Float_t wg[2] = { .8,.2 };
508   Float_t dar   = .001782;   // --- Ar density in g/cm3 --- 
509   // --- CO2 --- 
510   Float_t ac[2] = { 12.,16. };
511   Float_t zc[2] = { 6.,8. };
512   Float_t wc[2] = { 1.,2. };
513   Float_t dc    = .001977;
514   Float_t dco   = .002;  // --- CO2 density in g/cm3 ---
515   
516   Float_t absl, radl, a, d, z;
517   Float_t dg;
518   Float_t x0ar;
519   Float_t buf[1];
520   Int_t nbuf;
521   
522   Int_t *idtmed = fIdtmed->GetArray()-599;
523   Int_t isxfld = gAlice->Field()->Integ();
524   Float_t sxmgmx = gAlice->Field()->Max();
525   
526   // --- Define the various materials for GEANT --- 
527   AliMaterial(1, "Pb    $", 207.19, 82., 11.35, .56, 18.5);
528   x0ar = 19.55 / dar;
529   AliMaterial(2, "Argon$", 39.95, 18., dar, x0ar, 6.5e4);
530   AliMixture(3, "CO2  $", ac, zc, dc, -2, wc);
531   AliMaterial(4, "Al   $", 26.98, 13., 2.7, 8.9, 18.5);
532   AliMaterial(6, "Fe   $", 55.85, 26., 7.87, 1.76, 18.5);
533   AliMaterial(7, "W    $", 183.85, 74., 19.3, .35, 10.3);
534   AliMaterial(8, "G10  $", 20., 10., 1.7, 19.4, 999);
535   AliMaterial(9, "SILIC$", 28.09, 14., 2.33, 9.36, 45.);
536   AliMaterial(10, "Be   $", 9.01, 4., 1.848, 35.3, 36.7);
537   AliMaterial(15, "Cu   $", 63.54, 29., 8.96, 1.43, 15.);
538   AliMaterial(16, "C    $", 12.01, 6., 2.265, 18.8, 49.9);
539   
540   AliMaterial(96, "MYLAR$", 8.73, 4.55, 1.39, 28.7, 62.);
541   AliMaterial(97, "CONCR$", 20., 10., 2.5, 10.7, 40.);
542   AliMaterial(98, "Vacum$", 1e-9, 1e-9, 1e-9, 1e16, 1e16);
543   AliMaterial(99, "Air  $", 14.61, 7.3, .0012, 30420., 67500.);
544   
545   //    define gas-mixtures 
546   
547   char namate[21];
548   gMC->Gfmate((*fIdmate)[3], namate, a, z, d, radl, absl, buf, nbuf);
549   ag[1] = a;
550   zg[1] = z;
551   dg = (dar * 4 + dco) / 5;
552   AliMixture(5, "ArCO2$", ag, zg, dg, 2, wg);
553   
554   // Define tracking media 
555   AliMedium(1, "Pb conv.$", 1,  0, 0, isxfld, sxmgmx, 1., .1, .01, .1);
556   AliMedium(7, "W  conv.$", 7,  0, 0, isxfld, sxmgmx, 1., .1, .01, .1);
557   AliMedium(8, "G10plate$", 8,  0, 0, isxfld, sxmgmx, 1., .1, .01, .1);
558   AliMedium(4, "Al      $", 4,  0, 0, isxfld, sxmgmx, .1,  .1, .01, .1);
559   AliMedium(6, "Fe      $", 6,  0, 0, isxfld, sxmgmx, .1,  .1, .01, .1);
560   AliMedium(5, "ArCO2   $", 5,  1, 0, isxfld, sxmgmx, .1,  .1, .1,  .1);
561   AliMedium(9, "SILICON $", 9,  1, 0, isxfld, sxmgmx, .1,  .1, .1,  .1);
562   AliMedium(10, "Be      $", 10, 0, 0, isxfld, sxmgmx, .1,  .1, .01, .1);
563   AliMedium(98, "Vacuum  $", 98, 0, 0, isxfld, sxmgmx, 1., .1, .1,  10);
564   AliMedium(99, "Air gaps$", 99, 0, 0, isxfld, sxmgmx, 1., .1, .1,  .1);
565   AliMedium(15, "Cu      $", 15, 0, 0, isxfld, sxmgmx, .1,  .1, .01, .1);
566   AliMedium(16, "C       $", 16, 0, 0, isxfld, sxmgmx, .1,  .1, .01, .1);
567   
568   // --- Generate explicitly delta rays in the iron, aluminium and lead --- 
569   gMC->Gstpar(idtmed[600], "LOSS", 3.);
570   gMC->Gstpar(idtmed[600], "DRAY", 1.);
571   
572   gMC->Gstpar(idtmed[603], "LOSS", 3.);
573   gMC->Gstpar(idtmed[603], "DRAY", 1.);
574   
575   gMC->Gstpar(idtmed[604], "LOSS", 3.);
576   gMC->Gstpar(idtmed[604], "DRAY", 1.);
577   
578   gMC->Gstpar(idtmed[605], "LOSS", 3.);
579   gMC->Gstpar(idtmed[605], "DRAY", 1.);
580   
581   gMC->Gstpar(idtmed[606], "LOSS", 3.);
582   gMC->Gstpar(idtmed[606], "DRAY", 1.);
583   
584   gMC->Gstpar(idtmed[607], "LOSS", 3.);
585   gMC->Gstpar(idtmed[607], "DRAY", 1.);
586   
587   // --- Energy cut-offs in the Pb and Al to gain time in tracking --- 
588   // --- without affecting the hit patterns --- 
589   gMC->Gstpar(idtmed[600], "CUTGAM", 1e-4);
590   gMC->Gstpar(idtmed[600], "CUTELE", 1e-4);
591   gMC->Gstpar(idtmed[600], "CUTNEU", 1e-4);
592   gMC->Gstpar(idtmed[600], "CUTHAD", 1e-4);
593   gMC->Gstpar(idtmed[605], "CUTGAM", 1e-4);
594   gMC->Gstpar(idtmed[605], "CUTELE", 1e-4);
595   gMC->Gstpar(idtmed[605], "CUTNEU", 1e-4);
596   gMC->Gstpar(idtmed[605], "CUTHAD", 1e-4);
597   gMC->Gstpar(idtmed[606], "CUTGAM", 1e-4);
598   gMC->Gstpar(idtmed[606], "CUTELE", 1e-4);
599   gMC->Gstpar(idtmed[606], "CUTNEU", 1e-4);
600   gMC->Gstpar(idtmed[606], "CUTHAD", 1e-4);
601   gMC->Gstpar(idtmed[603], "CUTGAM", 1e-4);
602   gMC->Gstpar(idtmed[603], "CUTELE", 1e-4);
603   gMC->Gstpar(idtmed[603], "CUTNEU", 1e-4);
604   gMC->Gstpar(idtmed[603], "CUTHAD", 1e-4);
605   gMC->Gstpar(idtmed[609], "CUTGAM", 1e-4);
606   gMC->Gstpar(idtmed[609], "CUTELE", 1e-4);
607   gMC->Gstpar(idtmed[609], "CUTNEU", 1e-4);
608   gMC->Gstpar(idtmed[609], "CUTHAD", 1e-4);
609   
610   // --- Prevent particles stopping in the gas due to energy cut-off --- 
611   gMC->Gstpar(idtmed[604], "CUTGAM", 1e-5);
612   gMC->Gstpar(idtmed[604], "CUTELE", 1e-5);
613   gMC->Gstpar(idtmed[604], "CUTNEU", 1e-5);
614   gMC->Gstpar(idtmed[604], "CUTHAD", 1e-5);
615   gMC->Gstpar(idtmed[604], "CUTMUO", 1e-5);
616 }
617
618 //_____________________________________________________________________________
619 void AliPMDv0::Init()
620 {
621   //
622   // Initialises PMD detector after it has been built
623   //
624   Int_t i;
625   kdet=1;
626   //
627   printf("\n");
628   for(i=0;i<35;i++) printf("*");
629   printf(" PMD_INIT ");
630   for(i=0;i<35;i++) printf("*");
631   printf("\n");
632   printf("                 PMD simulation package initialised\n");
633   printf(" parameters of pmd\n");
634   printf("%6d %10.2f %10.2f %10.2f %10.2f %10.2f\n",kdet,thmin,thmax,zdist,thlow,thhigh);
635   //
636   for(i=0;i<80;i++) printf("*");
637   printf("\n");
638   //
639   Int_t *idtmed = fIdtmed->GetArray()-599;
640   fMedSens=idtmed[605-1];
641 }
642
643 //_____________________________________________________________________________
644 void AliPMDv0::StepManager()
645 {
646   //
647   // Called at each step in the PMD
648   //
649   Int_t   copy;
650   Float_t hits[4], destep;
651   Float_t center[3] = {0,0,0};
652   Int_t   vol[5];
653   const char* namep;
654   
655   if(gMC->GetMedium() == fMedSens && (destep = gMC->Edep())) {
656     
657     gMC->CurrentVolID(copy);
658     vol[0]=copy;
659     gMC->CurrentVolOffID(1,copy);
660     vol[1]=copy;
661     gMC->CurrentVolOffID(2,copy);
662     namep=gMC->CurrentVolOffName(2);
663     vol[2]=copy;
664     if(strncmp(namep,"DW11",4))vol[2]=1;
665     if(strncmp(namep,"DV11",4))vol[2]=2;
666     gMC->CurrentVolOffID(3,copy);
667     vol[3]=copy;
668     gMC->CurrentVolOffID(4,copy);
669     vol[4]=copy;
670     gMC->Gdtom(center,hits,1);
671     hits[3] = destep*1e9; //Number in eV
672     AddHit(gAlice->CurrentTrack(), vol, hits);
673   }
674 }