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