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