]> git.uio.no Git - u/mrichter/AliRoot.git/blob - ZDC/AliZDCv1.cxx
Don't write the AliMUONClusterInput singleton.
[u/mrichter/AliRoot.git] / ZDC / AliZDCv1.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.15  2001/03/12 17:47:56  hristov
19 Changes needed on Sun with CC 5.0
20
21 Revision 1.14  2001/02/23 16:48:28  coppedis
22 Correct bug in ZEM hit definition
23
24 Revision 1.13  2001/02/07 18:07:41  coppedis
25 Modif for splitting
26
27 Revision 1.12  2001/01/26 19:56:27  hristov
28 Major upgrade of AliRoot code
29
30 Revision 1.11  2001/01/16 07:43:33  hristov
31 Initialisation of ZDC hits
32
33 Revision 1.10  2000/12/14 15:20:02  coppedis
34 Hits2Digits method for digitization
35
36 Revision 1.9  2000/12/13 10:33:49  coppedis
37 Prints only if fDebug==1
38
39 Revision 1.8  2000/12/12 14:10:02  coppedis
40 Correction suggested by M. Masera
41
42 Revision 1.7  2000/11/30 17:23:47  coppedis
43 Remove first corrector dipole and introduce digitization
44
45 Revision 1.6  2000/11/22 11:33:10  coppedis
46 Major code revision
47
48 Revision 1.5  2000/10/02 21:28:20  fca
49 Removal of useless dependecies via forward declarations
50
51 Revision 1.3.2.1  2000/08/24 09:25:47  hristov
52 Patch by P.Hristov: Bug in ZDC geometry corrected by E.Scomparin
53
54 Revision 1.4  2000/08/24 09:23:59  hristov
55 Bug in ZDC geometry corrected by E.Scomparin
56
57 Revision 1.3  2000/07/12 06:59:16  fca
58 Fixing dimension of hits array
59
60 Revision 1.2  2000/07/11 11:12:34  fca
61 Some syntax corrections for non standard HP aCC
62
63 Revision 1.1  2000/07/10 13:58:01  fca
64 New version of ZDC from E.Scomparin & C.Oppedisano
65
66 Revision 1.7  2000/01/19 17:17:40  fca
67
68 Revision 1.6  1999/09/29 09:24:35  fca
69 Introduction of the Copyright and cvs Log
70
71 */
72
73 ///////////////////////////////////////////////////////////////////////////////
74 //                                                                           //
75 //  Zero Degree Calorimeter                                                  //
76 //  This class contains the basic functions for the ZDC                      //
77 //  Functions specific to one particular geometry are                        //
78 //  contained in the derived classes                                         //
79 //                                                                           //
80 ///////////////////////////////////////////////////////////////////////////////
81
82 // --- Standard libraries
83 #include "stdio.h"
84
85 // --- ROOT system
86 #include <TBRIK.h>
87 #include <TNode.h>
88 #include <TMath.h>
89 #include <TRandom.h>
90 #include <TSystem.h>
91 #include <TTree.h>
92
93
94 // --- AliRoot classes
95 #include "AliZDCv1.h"
96 #include "AliZDCHit.h"
97 #include "AliZDCDigit.h"
98 #include "AliRun.h"
99 #include "AliDetector.h"
100 #include "AliMagF.h"
101 #include "AliMC.h"
102 #include "AliCallf77.h"
103 #include "AliConst.h"
104 #include "AliPDG.h"
105 #include "TLorentzVector.h"
106  
107  
108 ClassImp(AliZDCv1)
109  
110
111 ///////////////////////////////////////////////////////////////////////////////
112 //                                                                           //
113 //  Zero Degree Calorimeter version 1                                        //
114 //                                                                           //
115 ///////////////////////////////////////////////////////////////////////////////
116
117 //_____________________________________________________________________________
118 AliZDCv1::AliZDCv1() : AliZDC()
119 {
120   //
121   // Default constructor for Zero Degree Calorimeter
122   //
123   
124   fMedSensF1  = 0;
125   fMedSensF2  = 0;
126   fMedSensZN  = 0;
127   fMedSensZP  = 0;
128   fMedSensZEM = 0;
129   fMedSensGR  = 0;
130   fMedSensPI  = 0;
131 }
132  
133 //_____________________________________________________________________________
134 AliZDCv1::AliZDCv1(const char *name, const char *title)
135   : AliZDC(name,title)
136 {
137   //
138   // Standard constructor for Zero Degree Calorimeter 
139   //
140
141   fMedSensF1  = 0;
142   fMedSensF2  = 0;
143   fMedSensZN  = 0;
144   fMedSensZP  = 0;
145   fMedSensZEM = 0;
146   fMedSensGR  = 0;
147   fMedSensPI  = 0;
148
149   
150   // Parameters for light tables
151   fNalfan = 90;       // Number of Alfa (neutrons)
152   fNalfap = 90;       // Number of Alfa (protons)
153   fNben = 18;         // Number of beta (neutrons)
154   fNbep = 28;         // Number of beta (protons)
155   Int_t ip,jp,kp;
156   for(ip=0; ip<4; ip++){
157      for(kp=0; kp<fNalfap; kp++){
158         for(jp=0; jp<fNbep; jp++){
159            fTablep[ip][kp][jp] = 0;
160         } 
161      }
162   }
163   Int_t in,jn,kn;
164   for(in=0; in<4; in++){
165      for(kn=0; kn<fNalfan; kn++){
166         for(jn=0; jn<fNben; jn++){
167            fTablen[in][kn][jn] = 0;
168         } 
169      }
170   }
171
172   // Parameters for hadronic calorimeters geometry
173   fDimZP[0] = 11.2;
174   fDimZP[1] = 6.;
175   fDimZP[2] = 75.;    
176   fPosZN[0] = 0.;
177   fPosZN[1] = 0.;
178   fPosZN[2] = 11650.;
179   fPosZP[0] = -23.;
180   fPosZP[1] = 0.;
181   fPosZP[2] = 11600.;
182   fFibZN[0] = 0.;
183   fFibZN[1] = 0.01825;
184   fFibZN[2] = 50.;
185   fFibZP[0] = 0.;
186   fFibZP[1] = 0.0275;
187   fFibZP[2] = 75.;
188   
189   // Parameters for EM calorimeter geometry
190   fPosZEM[0] = 0.;
191   fPosZEM[1] = 5.8;
192   fPosZEM[2] = 11600.;
193   
194
195   fDigits = new TClonesArray("AliZDCDigit",1000);
196 }
197  
198 //_____________________________________________________________________________
199 void AliZDCv1::CreateGeometry()
200 {
201   //
202   // Create the geometry for the Zero Degree Calorimeter version 1
203   //* Initialize COMMON block ZDC_CGEOM
204   //*
205
206   CreateBeamLine();
207   CreateZDC();
208 }
209   
210 //_____________________________________________________________________________
211 void AliZDCv1::CreateBeamLine()
212 {
213   
214   Float_t angle, zq, conpar[9], elpar[3], tubpar[3], zd1, zd2;
215   Int_t im1, im2;
216   
217   Int_t *idtmed = fIdtmed->GetArray();
218   
219   // -- Mother of the ZDCs 
220   
221   conpar[0] = 0.;
222   conpar[1] = 360.;
223   conpar[2] = 2.;
224   conpar[3] = 805.;
225   conpar[4] = 0.;
226   conpar[5] = 55.;
227   conpar[6] = 13060.;
228   conpar[7] = 0.;
229   conpar[8] = 55.;
230   gMC->Gsvolu("ZDC ", "PCON", idtmed[10], conpar, 9);
231   gMC->Gspos("ZDC ", 1, "ALIC", 0., 0., 0., 0, "ONLY");
232
233   // -- FIRST SECTION OF THE BEAM PIPE (from compensator dipole to 
234   //    beginning of D1) 
235   
236   zd1 = 1921.6;
237   
238   tubpar[0] = 6.3/2.;
239   tubpar[1] = 6.7/2.;
240   tubpar[2] = 3916.7/2.;
241   gMC->Gsvolu("P001", "TUBE", idtmed[5], tubpar, 3);
242   gMC->Gspos("P001", 1, "ZDC ", 0., 0., tubpar[2] + zd1, 0, "ONLY");
243   
244   //-- SECOND SECTION OF THE BEAM PIPE (FROM THE END OF D1 TO THE BEGINNING OF
245   //    D2) 
246   
247   //-- FROM MAGNETIC BEGINNING OG D1 TO MAGNETIC END OF D1 + 23.5 cm
248   //-- Elliptic pipe
249   
250   zd1 = 6310.8-472.5;
251   
252   elpar[0] = 6.84/2.;
253   elpar[1] = 5.86/2.;
254   elpar[2] = 945./2.;
255 //  gMC->Gsvolu("E001", "ELTU", idtmed[5], elpar, 3);
256 //  gMC->Gspos("E001", 1, "ZDC ", 0., 0., elpar[2] + zd1, 0, "ONLY");
257 //  
258   elpar[0] = 6.44/2.;
259   elpar[1] = 5.46/2.;
260   elpar[2] = 945./2.;
261 //  gMC->Gsvolu("E002", "ELTU", idtmed[10], elpar, 3);
262 //  gMC->Gspos("E002", 1, "E001", 0., 0., 0., 0, "ONLY");
263
264   zd1 += 2.*elpar[2];
265   
266   elpar[0] = 6.84/2.;
267   elpar[1] = 5.86/2.;
268   elpar[2] = 13.5/2.;
269 //  gMC->Gsvolu("E003", "ELTU", idtmed[5], elpar, 3);
270 //  gMC->Gspos("E002", 1, "ZDC ", 0., 0., elpar[2] + zd1, 0, "ONLY");
271   
272   elpar[0] = 6.44/2.;
273   elpar[1] = 5.46/2.;
274   elpar[2] = 13.5/2.;
275 //  gMC->Gsvolu("E004", "ELTU", idtmed[10], elpar, 3);
276 //  gMC->Gspos("E004", 1, "E003", 0., 0., 0., 0, "ONLY");
277
278   zd1 += 2.*elpar[2];
279   
280   conpar[0] = 25./2.;
281   conpar[1] = 6.44/2.;
282   conpar[2] = 6.84/2.;
283   conpar[3] = 10./2.;
284   conpar[4] = 10.4/2.;
285   gMC->Gsvolu("C001", "CONE", idtmed[5], conpar, 5);
286   gMC->Gspos("C001", 1, "ZDC ", 0., 0., conpar[0] + zd1, 0, "ONLY");
287
288   zd1 += 2.*conpar[0];
289   
290   tubpar[0] = 10./2.;
291   tubpar[1] = 10.4/2.;
292   tubpar[2] = 50./2.;
293   gMC->Gsvolu("P002", "TUBE", idtmed[5], tubpar, 3);
294   gMC->Gspos("P002", 1, "ZDC ", 0., 0., tubpar[2] + zd1, 0, "ONLY");
295   
296   zd1 += tubpar[2]*2.;
297   
298   tubpar[0] = 10./2.;
299   tubpar[1] = 10.4/2.;
300   tubpar[2] = 10./2.;
301   gMC->Gsvolu("P003", "TUBE", idtmed[5], tubpar, 3);
302   gMC->Gspos("P003", 1, "ZDC ", 0., 0., tubpar[2] + zd1, 0, "ONLY");
303   
304   zd1 += tubpar[2] * 2.;
305   
306   tubpar[0] = 10./2.;
307   tubpar[1] = 10.4/2.;
308   tubpar[2] = 3.16/2.;
309   gMC->Gsvolu("P004", "TUBE", idtmed[5], tubpar, 3);
310   gMC->Gspos("P004", 1, "ZDC ", 0., 0., tubpar[0] + zd1, 0, "ONLY");
311   
312   zd1 += tubpar[2] * 2.;
313   
314   tubpar[0] = 10.0/2.;
315   tubpar[1] = 10.4/2;
316   tubpar[2] = 190./2.;
317   gMC->Gsvolu("P005", "TUBE", idtmed[5], tubpar, 3);
318   gMC->Gspos("P005", 1, "ZDC ", 0., 0., tubpar[2] + zd1, 0, "ONLY");
319   
320   zd1 += tubpar[2] * 2.;
321   
322   conpar[0] = 30./2.;
323   conpar[1] = 10./2.;
324   conpar[2] = 10.4/2.;
325   conpar[3] = 20.6/2.;
326   conpar[4] = 21./2.;
327   gMC->Gsvolu("P006", "CONE", idtmed[5], conpar, 5);
328   gMC->Gspos("P006", 1, "ZDC ", 0., 0., conpar[0] + zd1, 0, "ONLY");
329   
330   zd1 += conpar[0] * 2.;
331   
332   tubpar[0] = 20.6/2.;
333   tubpar[1] = 21./2.;
334   tubpar[2] = 450./2.;
335   gMC->Gsvolu("P007", "TUBE", idtmed[5], tubpar, 3);
336   gMC->Gspos("P007", 1, "ZDC ", 0., 0., tubpar[2] + zd1, 0, "ONLY");
337   
338   zd1 += tubpar[2] * 2.;
339   
340   conpar[0] = 13.6/2.;
341   conpar[1] = 20.6/2.;
342   conpar[2] = 21./2.;
343   conpar[3] = 25.4/2.;
344   conpar[4] = 25.8/2.;
345   gMC->Gsvolu("P008", "CONE", idtmed[5], conpar, 5);
346   gMC->Gspos("P008", 1, "ZDC ", 0., 0., conpar[0] + zd1, 0, "ONLY");
347   
348   zd1 += conpar[0] * 2.;
349   
350   tubpar[0] = 25.4/2.;
351   tubpar[1] = 25.8/2.;
352   tubpar[2] = 205.8/2.;
353   gMC->Gsvolu("P009", "TUBE", idtmed[5], tubpar, 3);
354   gMC->Gspos("P009", 1, "ZDC ", 0., 0., tubpar[2] + zd1, 0, "ONLY");
355   
356   zd1 += tubpar[2] * 2.;
357   
358   tubpar[0] = 50./2.;
359   tubpar[1] = 50.4/2.;
360   tubpar[2] = 505.4/2.;
361   gMC->Gsvolu("P010", "TUBE", idtmed[5], tubpar, 3);
362   gMC->Gspos("P010", 1, "ZDC ", 0., 0., tubpar[2] + zd1, 0, "ONLY");
363   
364   zd1 += tubpar[2] * 2.;
365   
366   tubpar[0] = 50./2.;
367   tubpar[1] = 50.4/2.;
368   tubpar[2] = 700./2.;
369   gMC->Gsvolu("P011", "TUBE", idtmed[5], tubpar, 3);
370   gMC->Gspos("P011", 1, "ZDC ", 0., 0., tubpar[2] + zd1, 0, "ONLY");
371   
372   zd1 += tubpar[2] * 2.;
373   
374   tubpar[0] = 50./2.;
375   tubpar[1] = 50.4/2.;
376   tubpar[2] = 778.5/2.;
377   gMC->Gsvolu("P012", "TUBE", idtmed[5], tubpar, 3);
378   gMC->Gspos("P012", 1, "ZDC ", 0., 0., tubpar[2] + zd1, 0, "ONLY");
379   
380   zd1 += tubpar[2] * 2.;
381   
382   conpar[0] = 14.18/2.;
383   conpar[1] = 50./2.;
384   conpar[2] = 50.4/2.;
385   conpar[3] = 55./2.;
386   conpar[4] = 55.4/2.;
387   gMC->Gsvolu("P013", "CONE", idtmed[5], conpar, 5);
388   gMC->Gspos("P013", 1, "ZDC ", 0., 0., conpar[0] + zd1, 0, "ONLY");
389   
390   zd1 += conpar[0] * 2.;
391   
392   tubpar[0] = 55./2.;
393   tubpar[1] = 55.4/2.;
394   tubpar[2] = 730./2.;
395   gMC->Gsvolu("P014", "TUBE", idtmed[5], tubpar, 3);
396   gMC->Gspos("P014", 1, "ZDC ", 0., 0., tubpar[2] + zd1, 0, "ONLY");
397   
398   zd1 += tubpar[2] * 2.;
399   
400   conpar[0] = 36.86/2.;
401   conpar[1] = 55./2.;
402   conpar[2] = 55.4/2.;
403   conpar[3] = 68./2.;
404   conpar[4] = 68.4/2.;
405   gMC->Gsvolu("P015", "CONE", idtmed[5], conpar, 5);
406   gMC->Gspos("P015", 1, "ZDC ", 0., 0., conpar[0] + zd1, 0, "ONLY");
407   
408   zd1 += conpar[0] * 2.;
409   
410   tubpar[0] = 68./2.;
411   tubpar[1] = 68.4/2.;
412   tubpar[2] = 927.3/2.;
413   gMC->Gsvolu("P016", "TUBE", idtmed[5], tubpar, 3);
414   gMC->Gspos("P016", 1, "ZDC ", 0., 0., tubpar[2] + zd1, 0, "ONLY");
415   
416   zd1 += tubpar[2] * 2.;
417   
418   tubpar[0] = 0./2.;
419   tubpar[1] = 68.4/2.;
420   tubpar[2] = 0.2/2.;
421   gMC->Gsvolu("P017", "TUBE", idtmed[8], tubpar, 3);
422   gMC->Gspos("P017", 1, "ZDC ", 0., 0., tubpar[2] + zd1, 0, "ONLY");
423   
424   zd1 += tubpar[2] * 2.;
425   
426   tubpar[0] = 0./2.;
427   tubpar[1] = 5./2.;
428   tubpar[2] = 0.2/2.;
429   gMC->Gsvolu("Q017", "TUBE", idtmed[10], tubpar, 3);
430   
431   //-- Position Q017 inside P017
432   gMC->Gspos("Q017", 1, "P017", -7.7, 0., 0., 0, "ONLY");
433   
434   tubpar[0] = 0./2.;
435   tubpar[1] = 7./2.;
436   tubpar[2] = 0.2/2.;
437   gMC->Gsvolu("R017", "TUBE", idtmed[10], tubpar, 3);
438   
439   //-- Position R017 inside P017
440   gMC->Gspos("R017", 1, "P017", 7.7, 0., 0., 0, "ONLY");
441   
442   //-- BEAM PIPE BETWEEN END OF CONICAL PIPE AND BEGINNING OF D2
443   
444   tubpar[0] = 5./2.;
445   tubpar[1] = 5.4/2.;
446   tubpar[2] = 678./2.;
447   gMC->Gsvolu("P018", "TUBE", idtmed[5], tubpar, 3);
448
449   tubpar[0] = 7./2.;
450   tubpar[1] = 7.4/2.;
451   tubpar[2] = 678./2.;
452   gMC->Gsvolu("P019", "TUBE", idtmed[5], tubpar, 3);
453   
454   // -- ROTATE PIPES 
455
456   AliMatrix(im1, 90.-0.071, 0., 90., 90., .071, 180.);
457   angle = .071*kDegrad;
458   gMC->Gspos("P018", 1, "ZDC ", TMath::Sin(angle) * 645. / 2. - 9.7 + 
459                TMath::Sin(angle) * 945. / 2., 0., tubpar[2] + zd1, im1, "ONLY");
460   AliMatrix(im2, 90.+0.071, 0., 90., 90., .071, 0.);
461   gMC->Gspos("P019", 1, "ZDC ", 9.7 - TMath::Sin(angle) * 645. / 2., 0., 
462                tubpar[2] + zd1, im2, "ONLY");
463   
464   // --  END OF BEAM PIPE VOLUME DEFINITION. MAGNET DEFINITION FOLLOWS 
465   //     (LHC OPTICS 6) 
466   
467   // -- COMPENSATOR DIPOLE (MBXW) 
468   //     GAP (VACUUM WITH MAGNETIC FIELD) 
469   
470 //  tubpar[0] = 0.;
471 //  tubpar[1] = 4.5;
472 //  tubpar[2] = 340./2.;
473 //  gMC->Gsvolu("MBXW", "TUBE", idtmed[11], tubpar, 3);
474 //  gMC->Gspos("MBXW", 1, "ZDC ", 0., 0., tubpar[2] + 805., 0, "ONLY");
475   
476   // --  YOKE (IRON WITHOUT MAGNETIC FIELD) 
477   
478 //  tubpar[0] = 4.5;
479 //  tubpar[1] = 55.;
480 //  tubpar[2] = 340./2.;
481 //  gMC->Gsvolu("YMBX", "TUBE", idtmed[5], tubpar, 3);
482 //  gMC->Gspos("YMBX", 1, "ZDC ", 0., 0., tubpar[2] + 805., 0, "ONLY");
483   
484   // -- COMPENSATOR DIPOLE (MCBWA) 
485   //     GAP (VACUUM WITH MAGNETIC FIELD) 
486   
487   tubpar[0] = 0.;
488   tubpar[1] = 4.5;
489   tubpar[2] = 170./2.;
490   gMC->Gsvolu("MCBW", "TUBE", idtmed[11], tubpar, 3);
491   gMC->Gspos("MCBW", 1, "ZDC ", 0., 0., tubpar[2] + 1921.6, 0, "ONLY");
492   
493   // --  YOKE (IRON WITHOUT MAGNETIC FIELD) 
494   
495   tubpar[0] = 4.5;
496   tubpar[1] = 55.;
497   tubpar[2] = 170./2.;
498   gMC->Gsvolu("YMCB", "TUBE", idtmed[5], tubpar, 3);
499   gMC->Gspos("YMCB", 1, "ZDC ", 0., 0., tubpar[2] + 1921.6, 0, "ONLY");
500   
501   // -- INNER TRIPLET 
502   
503   zq = 2300.;
504   
505   // -- DEFINE MQXL AND MQX QUADRUPOLE ELEMENT 
506   
507   //     MQXL 
508   // --  GAP (VACUUM WITH MAGNETIC FIELD) 
509   
510   tubpar[0] = 0.;
511   tubpar[1] = 3.5;
512   tubpar[2] = 630./2.;
513   gMC->Gsvolu("MQXL", "TUBE", idtmed[11], tubpar, 3);
514   
515   // --  YOKE 
516   
517   tubpar[0] = 3.5;
518   tubpar[1] = 22.;
519   tubpar[2] = 630./2.;
520   gMC->Gsvolu("YMQL", "TUBE", idtmed[5], tubpar, 3);
521   
522   gMC->Gspos("MQXL", 1, "ZDC ", 0., 0., tubpar[2] + zq, 0, "ONLY");
523   gMC->Gspos("YMQL", 1, "ZDC ", 0., 0., tubpar[2] + zq, 0, "ONLY");
524   
525   gMC->Gspos("MQXL", 2, "ZDC ", 0., 0., tubpar[2] + zq + 2430., 0, "ONLY");
526   gMC->Gspos("YMQL", 2, "ZDC ", 0., 0., tubpar[2] + zq + 2430., 0, "ONLY");
527   
528   // --  MQX 
529   // --  GAP (VACUUM WITH MAGNETIC FIELD) 
530   
531   tubpar[0] = 0.;
532   tubpar[1] = 3.5;
533   tubpar[2] = 550./2.;
534   gMC->Gsvolu("MQX ", "TUBE", idtmed[11], tubpar, 3);
535   
536   // --  YOKE 
537   
538   tubpar[0] = 3.5;
539   tubpar[1] = 22.;
540   tubpar[2] = 550./2.;
541   gMC->Gsvolu("YMQ ", "TUBE", idtmed[5], tubpar, 3);
542   
543   gMC->Gspos("MQX ", 1, "ZDC ", 0., 0., tubpar[2] + zq + 880.,  0, "ONLY");
544   gMC->Gspos("YMQ ", 1, "ZDC ", 0., 0., tubpar[2] + zq + 880.,  0, "ONLY");
545   
546   gMC->Gspos("MQX ", 2, "ZDC ", 0., 0., tubpar[2] + zq + 1530., 0, "ONLY");
547   gMC->Gspos("YMQ ", 2, "ZDC ", 0., 0., tubpar[2] + zq + 1530., 0, "ONLY");
548   
549   // -- SEPARATOR DIPOLE D1 
550   
551   zd1 = 5838.3;
552   
553   // --  GAP (VACUUM WITH MAGNETIC FIELD) 
554   
555   tubpar[0] = 0.;
556   tubpar[1] = 7.5/2.;
557   tubpar[2] = 945./2.;
558   gMC->Gsvolu("D1  ", "TUBE", idtmed[11], tubpar, 3);
559   
560   // --  YOKE 
561   
562   tubpar[0] = 0.;
563   tubpar[1] = 110./2;
564   tubpar[2] = 945./2.;
565   gMC->Gsvolu("YD1 ", "TUBE", idtmed[5], tubpar, 3);
566   
567   gMC->Gspos("YD1 ", 1, "ZDC ", 0., 0., tubpar[2] + zd1, 0, "ONLY");
568   gMC->Gspos("D1  ", 1, "YD1 ", 0., 0., 0., 0, "ONLY");
569   
570   // -- DIPOLE D2 
571   
572   zd2 = 12147.6;
573   
574   // --  GAP (VACUUM WITH MAGNETIC FIELD) 
575   
576   tubpar[0] = 0.;
577   tubpar[1] = 7.5/2.;
578   tubpar[2] = 945./2.;
579   gMC->Gsvolu("D2  ", "TUBE", idtmed[11], tubpar, 3);
580   
581   // --  YOKE 
582   
583   tubpar[0] = 0.;
584   tubpar[1] = 55.;
585   tubpar[2] = 945./2.;
586   gMC->Gsvolu("YD2 ", "TUBE", idtmed[5], tubpar, 3);
587   
588   gMC->Gspos("YD2 ", 1, "ZDC ", 0., 0., tubpar[2] + zd2, 0, "ONLY");
589   
590   gMC->Gspos("D2  ", 1, "YD2 ", -9.7, 0., 0., 0, "ONLY");
591   gMC->Gspos("D2  ", 2, "YD2 ",  9.7, 0., 0., 0, "ONLY");
592   
593   // -- END OF MAGNET DEFINITION 
594 }
595   
596 //_____________________________________________________________________________
597 void AliZDCv1::CreateZDC()
598 {
599   
600   Int_t irot1, irot2;
601   Float_t DimPb[6], DimVoid[6];
602   
603   Int_t *idtmed = fIdtmed->GetArray();
604
605   // Parameters for hadronic calorimeters geometry
606   // NB -> parameters used ONLY in CreateZDC()
607   Float_t fDimZN[3] = {3.52, 3.52, 50.};  // Dimensions of neutron detector
608   Float_t fGrvZN[3] = {0.03, 0.03, 50.};  // Grooves for neutron detector
609   Float_t fGrvZP[3] = {0.04, 0.04, 75.};  // Grooves for proton detector
610   Int_t   fDivZN[3] = {11, 11, 0};        // Division for neutron detector
611   Int_t   fDivZP[3] = {7, 15, 0};         // Division for proton detector
612   Int_t   fTowZN[2] = {2, 2};             // Tower for neutron detector
613   Int_t   fTowZP[2] = {4, 1};             // Tower for proton detector
614
615   // Parameters for EM calorimeter geometry
616   // NB -> parameters used ONLY in CreateZDC()
617   Float_t fDimZEMPb  = 0.15*(TMath::Sqrt(2.));  // z-dimension of the Pb slice
618   Float_t fDimZEMAir = 0.001;                   // scotch
619   Float_t fFibRadZEM = 0.0315;                  // External fiber radius (including cladding)
620   Int_t   fDivZEM[3] = {92, 0, 20};             // Divisions for EM detector
621   Float_t fDimZEM0 = 2*fDivZEM[2]*(fDimZEMPb+fDimZEMAir+fFibRadZEM*(TMath::Sqrt(2.)));
622   Float_t fDimZEM[6] = {fDimZEM0, 3.5, 3.5, 45., 0., 0.}; // Dimensions of EM detector
623   Float_t fFibZEM2 = fDimZEM[2]/TMath::Sin(fDimZEM[3]*kDegrad)-fFibRadZEM;
624   Float_t fFibZEM[3] = {0., 0.0275, fFibZEM2};  // Fibers for EM calorimeter
625
626   
627   //-- Create calorimeters geometry
628   
629   //--> Neutron calorimeter (ZN) 
630   
631   gMC->Gsvolu("ZNEU", "BOX ", idtmed[1], fDimZN, 3); // Passive material  
632   gMC->Gsvolu("ZNF1", "TUBE", idtmed[3], fFibZN, 3); // Active material
633   gMC->Gsvolu("ZNF2", "TUBE", idtmed[4], fFibZN, 3); 
634   gMC->Gsvolu("ZNF3", "TUBE", idtmed[4], fFibZN, 3); 
635   gMC->Gsvolu("ZNF4", "TUBE", idtmed[3], fFibZN, 3); 
636   gMC->Gsvolu("ZNG1", "BOX ", idtmed[12], fGrvZN, 3); // Empty grooves 
637   gMC->Gsvolu("ZNG2", "BOX ", idtmed[12], fGrvZN, 3); 
638   gMC->Gsvolu("ZNG3", "BOX ", idtmed[12], fGrvZN, 3); 
639   gMC->Gsvolu("ZNG4", "BOX ", idtmed[12], fGrvZN, 3); 
640   
641   // Divide ZNEU in towers (for hits purposes) 
642   
643   gMC->Gsdvn("ZNTX", "ZNEU", fTowZN[0], 1); // x-tower 
644   gMC->Gsdvn("ZN1 ", "ZNTX", fTowZN[1], 2); // y-tower
645   
646   //-- Divide ZN1 in minitowers 
647   //  fDivZN[0]= NUMBER OF FIBERS PER TOWER ALONG X-AXIS, 
648   //  fDivZN[1]= NUMBER OF FIBERS PER TOWER ALONG Y-AXIS
649   //  (4 fibres per minitower) 
650   
651   gMC->Gsdvn("ZNSL", "ZN1 ", fDivZN[1], 2); // Slices 
652   gMC->Gsdvn("ZNST", "ZNSL", fDivZN[0], 1); // Sticks
653   
654   // --- Position the empty grooves in the sticks (4 grooves per stick)
655   Float_t dx = fDimZN[0] / fDivZN[0] / 4.;
656   Float_t dy = fDimZN[1] / fDivZN[1] / 4.;
657   
658   gMC->Gspos("ZNG1", 1, "ZNST", 0.-dx, 0.+dy, 0., 0, "ONLY");
659   gMC->Gspos("ZNG2", 1, "ZNST", 0.+dx, 0.+dy, 0., 0, "ONLY");
660   gMC->Gspos("ZNG3", 1, "ZNST", 0.-dx, 0.-dy, 0., 0, "ONLY");
661   gMC->Gspos("ZNG4", 1, "ZNST", 0.+dx, 0.-dy, 0., 0, "ONLY");
662   
663   // --- Position the fibers in the grooves 
664   gMC->Gspos("ZNF1", 1, "ZNG1", 0., 0., 0., 0, "ONLY");
665   gMC->Gspos("ZNF2", 1, "ZNG2", 0., 0., 0., 0, "ONLY");
666   gMC->Gspos("ZNF3", 1, "ZNG3", 0., 0., 0., 0, "ONLY");
667   gMC->Gspos("ZNF4", 1, "ZNG4", 0., 0., 0., 0, "ONLY");
668   
669   // --- Position the neutron calorimeter in ZDC 
670   gMC->Gspos("ZNEU", 1, "ZDC ", fPosZN[0], fPosZN[1], fPosZN[2] + fDimZN[2], 0, "ONLY");
671   
672
673   //--> Proton calorimeter (ZP)  
674   
675   gMC->Gsvolu("ZPRO", "BOX ", idtmed[2], fDimZP, 3); // Passive material
676   gMC->Gsvolu("ZPF1", "TUBE", idtmed[3], fFibZP, 3); // Active material
677   gMC->Gsvolu("ZPF2", "TUBE", idtmed[4], fFibZP, 3); 
678   gMC->Gsvolu("ZPF3", "TUBE", idtmed[4], fFibZP, 3); 
679   gMC->Gsvolu("ZPF4", "TUBE", idtmed[3], fFibZP, 3); 
680   gMC->Gsvolu("ZPG1", "BOX ", idtmed[12], fGrvZP, 3); // Empty grooves 
681   gMC->Gsvolu("ZPG2", "BOX ", idtmed[12], fGrvZP, 3); 
682   gMC->Gsvolu("ZPG3", "BOX ", idtmed[12], fGrvZP, 3); 
683   gMC->Gsvolu("ZPG4", "BOX ", idtmed[12], fGrvZP, 3); 
684     
685   //-- Divide ZPRO in towers(for hits purposes) 
686   
687   gMC->Gsdvn("ZPTX", "ZPRO", fTowZP[0], 1); // x-tower 
688   gMC->Gsdvn("ZP1 ", "ZPTX", fTowZP[1], 2); // y-tower
689   
690   
691   //-- Divide ZP1 in minitowers 
692   //  fDivZP[0]= NUMBER OF FIBERS ALONG X-AXIS PER MINITOWER, 
693   //  fDivZP[1]= NUMBER OF FIBERS ALONG Y-AXIS PER MINITOWER
694   //  (4 fiber per minitower) 
695   
696   gMC->Gsdvn("ZPSL", "ZP1 ", fDivZP[1], 2); // Slices 
697   gMC->Gsdvn("ZPST", "ZPSL", fDivZP[0], 1); // Sticks
698   
699   // --- Position the empty grooves in the sticks (4 grooves per stick)
700   dx = fDimZP[0] / fTowZP[0] / fDivZP[0] / 2.;
701   dy = fDimZP[1] / fTowZP[1] / fDivZP[1] / 2.;
702   
703   gMC->Gspos("ZPG1", 1, "ZPST", 0.-dx, 0.+dy, 0., 0, "ONLY");
704   gMC->Gspos("ZPG2", 1, "ZPST", 0.+dx, 0.+dy, 0., 0, "ONLY");
705   gMC->Gspos("ZPG3", 1, "ZPST", 0.-dx, 0.-dy, 0., 0, "ONLY");
706   gMC->Gspos("ZPG4", 1, "ZPST", 0.+dx, 0.-dy, 0., 0, "ONLY");
707   
708   // --- Position the fibers in the grooves 
709   gMC->Gspos("ZPF1", 1, "ZPG1", 0., 0., 0., 0, "ONLY");
710   gMC->Gspos("ZPF2", 1, "ZPG2", 0., 0., 0., 0, "ONLY");
711   gMC->Gspos("ZPF3", 1, "ZPG3", 0., 0., 0., 0, "ONLY");
712   gMC->Gspos("ZPF4", 1, "ZPG4", 0., 0., 0., 0, "ONLY");
713   
714
715   // --- Position the proton calorimeter in ZDC 
716   gMC->Gspos("ZPRO", 1, "ZDC ", fPosZP[0], fPosZP[1], fPosZP[2] + fDimZP[2], 0, "ONLY");
717     
718   
719   
720   //--> EM calorimeter (ZEM)  
721   
722   gMC->Gsvolu("ZEM ", "PARA", idtmed[10], fDimZEM, 6);
723   
724   gMC->Matrix(irot1,0.,0.,90.,90.,90.,180.);                // Rotation matrix 1  
725   gMC->Matrix(irot2,180.,0.,90.,fDimZEM[3]+90.,90.,fDimZEM[3]); // Rotation matrix 2
726 //  printf("irot1 = %d, irot2 = %d \n", irot1, irot2);
727   
728   gMC->Gsvolu("ZEMF", "TUBE", idtmed[3], fFibZEM, 3); // Active material
729
730   gMC->Gsdvn("ZETR", "ZEM ", fDivZEM[2], 1);         // Tranches 
731   
732   DimPb[0] = fDimZEMPb;                 // Lead slices 
733   DimPb[1] = fDimZEM[2];
734   DimPb[2] = fDimZEM[1];
735   DimPb[3] = 90.-fDimZEM[3];
736   DimPb[4] = 0.;
737   DimPb[5] = 0.;
738   gMC->Gsvolu("ZEL0", "PARA", idtmed[6], DimPb, 6);
739   gMC->Gsvolu("ZEL1", "PARA", idtmed[6], DimPb, 6);
740   gMC->Gsvolu("ZEL2", "PARA", idtmed[6], DimPb, 6);
741   
742   // --- Position the lead slices in the tranche 
743   Float_t zTran = fDimZEM[0]/fDivZEM[2]; 
744   Float_t zTrPb = -zTran+fDimZEMPb;
745   gMC->Gspos("ZEL0", 1, "ZETR", zTrPb, 0., 0., 0, "ONLY");
746   gMC->Gspos("ZEL1", 1, "ZETR", fDimZEMPb, 0., 0., 0, "ONLY");
747   
748   // --- Vacuum zone (to be filled with fibres)
749   DimVoid[0] = (zTran-2*fDimZEMPb)/2.;
750   DimVoid[1] = fDimZEM[2];
751   DimVoid[2] = fDimZEM[1];
752   DimVoid[3] = 90.-fDimZEM[3];
753   DimVoid[4] = 0.;
754   DimVoid[5] = 0.;
755   gMC->Gsvolu("ZEV0", "PARA", idtmed[10], DimVoid,6);
756   gMC->Gsvolu("ZEV1", "PARA", idtmed[10], DimVoid,6);
757   
758   // --- Divide the vacuum slice into sticks along x axis
759   gMC->Gsdvn("ZES0", "ZEV0", fDivZEM[0], 3); 
760   gMC->Gsdvn("ZES1", "ZEV1", fDivZEM[0], 3); 
761   
762   // --- Positioning the fibers into the sticks
763   gMC->Gspos("ZEMF", 1,"ZES0", 0., 0., 0., irot2, "ONLY");
764   gMC->Gspos("ZEMF", 1,"ZES1", 0., 0., 0., irot2, "ONLY");
765   
766   // --- Positioning the vacuum slice into the tranche
767   Float_t DisplFib = fDimZEM[1]/fDivZEM[0];
768   gMC->Gspos("ZEV0", 1,"ZETR", -DimVoid[0], 0., 0., 0, "ONLY");
769   gMC->Gspos("ZEV1", 1,"ZETR", -DimVoid[0]+zTran, 0., DisplFib, 0, "ONLY");
770
771   // --- Positioning the ZEM into the ZDC - rotation for 90 degrees  
772   gMC->Gspos("ZEM ", 1,"ZDC ", fPosZEM[0], fPosZEM[1], fPosZEM[2], irot1, "ONLY");
773   
774   // --- Adding last slice at the end of the EM calorimeter 
775   Float_t zLastSlice = fPosZEM[2]+fDimZEMPb+fDimZEM[0];
776   gMC->Gspos("ZEL2", 1,"ZDC ", fPosZEM[0], fPosZEM[1], zLastSlice, irot1, "ONLY");
777   
778 }
779  
780 //_____________________________________________________________________________
781 void AliZDCv1::DrawModule()
782 {
783   //
784   // Draw a shaded view of the Zero Degree Calorimeter version 1
785   //
786
787   // Set everything unseen
788   gMC->Gsatt("*", "seen", -1);
789   // 
790   // Set ALIC mother transparent
791   gMC->Gsatt("ALIC","SEEN",0);
792   //
793   // Set the volumes visible
794   gMC->Gsatt("ZDC ","SEEN",0);
795   gMC->Gsatt("P001","SEEN",1);
796   gMC->Gsatt("E001","SEEN",1);
797   gMC->Gsatt("E002","SEEN",1);
798   gMC->Gsatt("E003","SEEN",1);
799   gMC->Gsatt("E004","SEEN",1);
800   gMC->Gsatt("C001","SEEN",1);
801   gMC->Gsatt("P002","SEEN",1);
802   gMC->Gsatt("P003","SEEN",1);
803   gMC->Gsatt("P004","SEEN",1);
804   gMC->Gsatt("P005","SEEN",1);
805   gMC->Gsatt("P006","SEEN",1);
806   gMC->Gsatt("P007","SEEN",1);
807   gMC->Gsatt("P008","SEEN",1);
808   gMC->Gsatt("P009","SEEN",1);
809   gMC->Gsatt("P010","SEEN",1);
810   gMC->Gsatt("P011","SEEN",1);
811   gMC->Gsatt("P012","SEEN",1);
812   gMC->Gsatt("P013","SEEN",1);
813   gMC->Gsatt("P014","SEEN",1);
814   gMC->Gsatt("P015","SEEN",1);
815   gMC->Gsatt("P016","SEEN",1);
816   gMC->Gsatt("P017","SEEN",1);
817   gMC->Gsatt("Q017","SEEN",1);
818   gMC->Gsatt("R017","SEEN",1);
819   gMC->Gsatt("P018","SEEN",1);
820   gMC->Gsatt("P019","SEEN",1);
821 //  gMC->Gsatt("MBXW","SEEN",1);
822 //  gMC->Gsatt("YMBX","SEEN",1);
823   gMC->Gsatt("MCBW","SEEN",1);
824   gMC->Gsatt("YMCB","SEEN",1);
825   gMC->Gsatt("MQXL","SEEN",1);
826   gMC->Gsatt("YMQL","SEEN",1);
827   gMC->Gsatt("MQX ","SEEN",1);
828   gMC->Gsatt("YMQ ","SEEN",1);
829   gMC->Gsatt("D1  ","SEEN",1);
830   gMC->Gsatt("YD1 ","SEEN",1);
831   gMC->Gsatt("D2  ","SEEN",1);
832   gMC->Gsatt("YD2 ","SEEN",1);
833   gMC->Gsatt("ZNEU","SEEN",0);
834   gMC->Gsatt("ZNF1","SEEN",0);
835   gMC->Gsatt("ZNF2","SEEN",0);
836   gMC->Gsatt("ZNF3","SEEN",0);
837   gMC->Gsatt("ZNF4","SEEN",0);
838   gMC->Gsatt("ZNG1","SEEN",0);
839   gMC->Gsatt("ZNG2","SEEN",0);
840   gMC->Gsatt("ZNG3","SEEN",0);
841   gMC->Gsatt("ZNG4","SEEN",0);
842   gMC->Gsatt("ZNTX","SEEN",0);
843   gMC->Gsatt("ZN1 ","COLO",2); 
844   gMC->Gsatt("ZN1 ","SEEN",1);
845   gMC->Gsatt("ZNSL","SEEN",0);
846   gMC->Gsatt("ZNST","SEEN",0);
847   gMC->Gsatt("ZPRO","SEEN",0);
848   gMC->Gsatt("ZPF1","SEEN",0);
849   gMC->Gsatt("ZPF2","SEEN",0);
850   gMC->Gsatt("ZPF3","SEEN",0);
851   gMC->Gsatt("ZPF4","SEEN",0);
852   gMC->Gsatt("ZPG1","SEEN",0);
853   gMC->Gsatt("ZPG2","SEEN",0);
854   gMC->Gsatt("ZPG3","SEEN",0);
855   gMC->Gsatt("ZPG4","SEEN",0);
856   gMC->Gsatt("ZPTX","SEEN",0);
857   gMC->Gsatt("ZP1 ","COLO",2); 
858   gMC->Gsatt("ZP1 ","SEEN",1);
859   gMC->Gsatt("ZPSL","SEEN",0);
860   gMC->Gsatt("ZPST","SEEN",0);
861   gMC->Gsatt("ZEM ","COLO",2); 
862   gMC->Gsatt("ZEM ","SEEN",1);
863   gMC->Gsatt("ZEMF","SEEN",0);
864   gMC->Gsatt("ZETR","SEEN",0);
865   gMC->Gsatt("ZEL0","SEEN",0);
866   gMC->Gsatt("ZEL1","SEEN",0);
867   gMC->Gsatt("ZEL2","SEEN",0);
868   gMC->Gsatt("ZEV0","SEEN",0);
869   gMC->Gsatt("ZEV1","SEEN",0);
870   gMC->Gsatt("ZES0","SEEN",0);
871   gMC->Gsatt("ZES1","SEEN",0);
872   
873   //
874   gMC->Gdopt("hide", "on");
875   gMC->Gdopt("shad", "on");
876   gMC->Gsatt("*", "fill", 7);
877   gMC->SetClipBox(".");
878   gMC->SetClipBox("*", 0, 100, -100, 100, 12000, 16000);
879   gMC->DefaultRange();
880   gMC->Gdraw("alic", 40, 30, 0, 488, 220, .07, .07);
881   gMC->Gdhead(1111, "Zero Degree Calorimeter Version 1");
882   gMC->Gdman(18, 4, "MAN");
883 }
884
885 //_____________________________________________________________________________
886 void AliZDCv1::CreateMaterials()
887 {
888   //
889   // Create Materials for the Zero Degree Calorimeter
890   //
891   // Origin    : E. Scomparin 
892   
893   Int_t *idtmed = fIdtmed->GetArray();
894   
895   Float_t dens, ubuf[1], wmat[2], a[2], z[2], epsil=0.001, stmin=0.01;
896   Float_t deemax = -1, stemax;
897   Float_t fieldm = gAlice->Field()->Max();
898   Float_t tmaxfd=gAlice->Field()->Max();
899   Int_t   i, isvolActive, isvol, inofld;
900   Int_t   isxfld = gAlice->Field()->Integ();
901   
902   // --- Store in UBUF r0 for nuclear radius calculation R=r0*A**1/3 
903
904   // --- Tantalum -> ZN passive material
905   ubuf[0] = 1.1;
906   AliMaterial(1, "TANT", 180.95, 73., 16.65, .4, 11.9, ubuf, 1);
907     
908   // --- Tungsten 
909 //  ubuf[0] = 1.11;
910 //  AliMaterial(1, "TUNG", 183.85, 74., 19.3, .35, 10.3, ubuf, 1);
911   
912   // --- Brass (CuZn)  -> ZP passive material
913   dens = 8.48;
914   a[0] = 63.546;
915   a[1] = 65.39;
916   z[0] = 29.;
917   z[1] = 30.;
918   wmat[0] = .63;
919   wmat[1] = .37;
920   AliMixture(2, "BRASS               ", a, z, dens, 2, wmat);
921   
922   // --- SiO2 
923   dens = 2.64;
924   a[0] = 28.086;
925   a[1] = 15.9994;
926   z[0] = 14.;
927   z[1] = 8.;
928   wmat[0] = 1.;
929   wmat[1] = 2.;
930   AliMixture(3, "SIO2                ", a, z, dens, -2, wmat);
931   
932   
933   // --- Lead 
934   ubuf[0] = 1.12;
935   AliMaterial(5, "LEAD", 207.19, 82., 11.35, .56, 18.5, ubuf, 1);
936
937   // --- Copper 
938 //  ubuf[0] = 1.1;
939 //  AliMaterial(7, "COPP", 63.54, 29., 8.96, 1.4, 0., ubuf, 1);
940   
941   // --- Iron (energy loss taken into account)
942   ubuf[0] = 1.1;
943   AliMaterial(6, "IRON", 55.85, 26., 7.87, 1.76, 0., ubuf, 1);
944   
945   // --- Iron (no energy loss)
946   ubuf[0] = 1.1;
947   AliMaterial(7, "IRON", 55.85, 26., 7.87, 1.76, 0., ubuf, 1);
948   
949   // --- Vacuum (no magnetic field) 
950   AliMaterial(10, "VOID", 1e-16, 1e-16, 1e-16, 1e16, 1e16, ubuf,0);
951   
952   // --- Vacuum (with magnetic field) 
953   AliMaterial(11, "VOIM", 1e-16, 1e-16, 1e-16, 1e16, 1e16, ubuf,0);
954   
955   // --- Air (no magnetic field)
956   AliMaterial(12, "Air    $", 14.61, 7.3, .001205, 30420., 67500., ubuf, 0);
957   
958   // ---  Definition of tracking media: 
959   
960   // --- Tantalum = 1 ; 
961   // --- Brass = 2 ; 
962   // --- Fibers (SiO2) = 3 ; 
963   // --- Fibers (SiO2) = 4 ; 
964   // --- Lead = 5 ; 
965   // --- Iron (with energy loss) = 6 ; 
966   // --- Iron (without energy loss) = 7 ; 
967   // --- Vacuum (no field) = 10 
968   // --- Vacuum (with field) = 11 
969   // --- Air (no field) = 12 
970   
971   
972   // --- Tracking media parameters 
973   epsil  = .01;
974   stemax = 1.;
975   isvol  = 0;
976   isvolActive = 1;
977   inofld = 0;
978   fieldm = 0.;
979   
980   AliMedium(1, "ZTANT", 1, isvolActive, inofld, fieldm, tmaxfd, stemax, deemax, epsil, stmin);
981 //  AliMedium(1, "ZW", 1, isvolActive, inofld, fieldm, tmaxfd, stemax, deemax, epsil, stmin);
982   AliMedium(2, "ZBRASS", 2, isvolActive, inofld, fieldm, tmaxfd, stemax, deemax, epsil, stmin);
983   AliMedium(3, "ZSIO2", 3, isvolActive, inofld, fieldm, tmaxfd, stemax, deemax, epsil, stmin);
984   AliMedium(4, "ZQUAR", 3, isvolActive, inofld, fieldm, tmaxfd, stemax, deemax, epsil, stmin);
985   AliMedium(6, "ZLEAD", 5, isvolActive, inofld, fieldm, tmaxfd, stemax, deemax, epsil, stmin);
986 //  AliMedium(7, "ZCOPP", 7, isvolActive, inofld, fieldm, tmaxfd, stemax, deemax, epsil, stmin);
987   AliMedium(5, "ZIRON", 6, isvolActive, inofld, fieldm, tmaxfd, stemax, deemax, epsil, stmin);
988   AliMedium(8, "ZIRONN", 7, isvol, inofld, fieldm, tmaxfd, stemax, deemax, epsil, stmin);
989   AliMedium(10, "ZVOID", 10, isvol, inofld, fieldm, tmaxfd, stemax, deemax, epsil, stmin);
990   AliMedium(12, "ZAIR", 12, 0, inofld, fieldm, tmaxfd, stemax,deemax, epsil, stmin);
991   
992   fieldm = 45.;
993   AliMedium(11, "ZVOIM", 11, isvol, isxfld, fieldm, tmaxfd, stemax, deemax, epsil, stmin);
994   
995   // Thresholds for showering in the ZDCs 
996   
997   i = 1;
998   gMC->Gstpar(idtmed[i], "CUTGAM", .001);
999   gMC->Gstpar(idtmed[i], "CUTELE", .001);
1000   gMC->Gstpar(idtmed[i], "CUTNEU", .01);
1001   gMC->Gstpar(idtmed[i], "CUTHAD", .01);
1002   i = 2;
1003   gMC->Gstpar(idtmed[i], "CUTGAM", .001);
1004   gMC->Gstpar(idtmed[i], "CUTELE", .001);
1005   gMC->Gstpar(idtmed[i], "CUTNEU", .01);
1006   gMC->Gstpar(idtmed[i], "CUTHAD", .01);
1007   i = 6;
1008   gMC->Gstpar(idtmed[i], "CUTGAM", .001);
1009   gMC->Gstpar(idtmed[i], "CUTELE", .001);
1010   gMC->Gstpar(idtmed[i], "CUTNEU", .01);
1011   gMC->Gstpar(idtmed[i], "CUTHAD", .01);
1012   
1013   // Avoid too detailed showering along the beam line 
1014   
1015   i = 5;
1016   gMC->Gstpar(idtmed[i], "CUTGAM", .1);
1017   gMC->Gstpar(idtmed[i], "CUTELE", .1);
1018   gMC->Gstpar(idtmed[i], "CUTNEU", 1.);
1019   gMC->Gstpar(idtmed[i], "CUTHAD", 1.);
1020   
1021   // Avoid interaction in fibers (only energy loss allowed) 
1022   i = 3;
1023   gMC->Gstpar(idtmed[i], "DCAY", 0.);
1024   gMC->Gstpar(idtmed[i], "MULS", 0.);
1025   gMC->Gstpar(idtmed[i], "PFIS", 0.);
1026   gMC->Gstpar(idtmed[i], "MUNU", 0.);
1027   gMC->Gstpar(idtmed[i], "LOSS", 1.);
1028   gMC->Gstpar(idtmed[i], "PHOT", 0.);
1029   gMC->Gstpar(idtmed[i], "COMP", 0.);
1030   gMC->Gstpar(idtmed[i], "PAIR", 0.);
1031   gMC->Gstpar(idtmed[i], "BREM", 0.);
1032   gMC->Gstpar(idtmed[i], "DRAY", 0.);
1033   gMC->Gstpar(idtmed[i], "ANNI", 0.);
1034   gMC->Gstpar(idtmed[i], "HADR", 0.);
1035   i = 4;
1036   gMC->Gstpar(idtmed[i], "DCAY", 0.);
1037   gMC->Gstpar(idtmed[i], "MULS", 0.);
1038   gMC->Gstpar(idtmed[i], "PFIS", 0.);
1039   gMC->Gstpar(idtmed[i], "MUNU", 0.);
1040   gMC->Gstpar(idtmed[i], "LOSS", 1.);
1041   gMC->Gstpar(idtmed[i], "PHOT", 0.);
1042   gMC->Gstpar(idtmed[i], "COMP", 0.);
1043   gMC->Gstpar(idtmed[i], "PAIR", 0.);
1044   gMC->Gstpar(idtmed[i], "BREM", 0.);
1045   gMC->Gstpar(idtmed[i], "DRAY", 0.);
1046   gMC->Gstpar(idtmed[i], "ANNI", 0.);
1047   gMC->Gstpar(idtmed[i], "HADR", 0.);
1048   
1049   // Avoid interaction in void 
1050   i = 10;
1051   gMC->Gstpar(idtmed[i], "DCAY", 0.);
1052   gMC->Gstpar(idtmed[i], "MULS", 0.);
1053   gMC->Gstpar(idtmed[i], "PFIS", 0.);
1054   gMC->Gstpar(idtmed[i], "MUNU", 0.);
1055   gMC->Gstpar(idtmed[i], "LOSS", 0.);
1056   gMC->Gstpar(idtmed[i], "PHOT", 0.);
1057   gMC->Gstpar(idtmed[i], "COMP", 0.);
1058   gMC->Gstpar(idtmed[i], "PAIR", 0.);
1059   gMC->Gstpar(idtmed[i], "BREM", 0.);
1060   gMC->Gstpar(idtmed[i], "DRAY", 0.);
1061   gMC->Gstpar(idtmed[i], "ANNI", 0.);
1062   gMC->Gstpar(idtmed[i], "HADR", 0.);
1063
1064   //
1065   fMedSensF1  = idtmed[3];  // Sensitive volume: fibres type 1
1066   fMedSensF2  = idtmed[4];  // Sensitive volume: fibres type 2
1067   fMedSensZN  = idtmed[1];  // Sensitive volume: ZN passive material
1068   fMedSensZP  = idtmed[2];  // Sensitive volume: ZP passive material
1069   fMedSensZEM = idtmed[6];  // Sensitive volume: ZEM passive material
1070   fMedSensGR  = idtmed[12]; // Sensitive volume: air into the grooves
1071   fMedSensPI  = idtmed[5];  // Sensitive volume: beam pipes
1072
1073
1074 //_____________________________________________________________________________
1075 void AliZDCv1::Init()
1076 {
1077  InitTables();
1078 }
1079
1080 //_____________________________________________________________________________
1081 void AliZDCv1::InitTables()
1082 {
1083   Int_t k, j;
1084
1085   char *lightfName1,*lightfName2,*lightfName3,*lightfName4,
1086        *lightfName5,*lightfName6,*lightfName7,*lightfName8;
1087   FILE *fp1, *fp2, *fp3, *fp4, *fp5, *fp6, *fp7, *fp8;
1088
1089   lightfName1 = gSystem->ExpandPathName("$ALICE/$ALICE_LEVEL/ZDC/light22620362207s");
1090   if((fp1 = fopen(lightfName1,"r")) == NULL){
1091      printf("Cannot open file fp1 \n");
1092      return;
1093   }
1094   lightfName2 = gSystem->ExpandPathName("$ALICE/$ALICE_LEVEL/ZDC/light22620362208s");
1095   if((fp2 = fopen(lightfName2,"r")) == NULL){
1096      printf("Cannot open file fp2 \n");
1097      return;
1098   }  
1099   lightfName3 = gSystem->ExpandPathName("$ALICE/$ALICE_LEVEL/ZDC/light22620362209s");
1100   if((fp3 = fopen(lightfName3,"r")) == NULL){
1101      printf("Cannot open file fp3 \n");
1102      return;
1103   }
1104   lightfName4 = gSystem->ExpandPathName("$ALICE/$ALICE_LEVEL/ZDC/light22620362210s");
1105   if((fp4 = fopen(lightfName4,"r")) == NULL){
1106      printf("Cannot open file fp4 \n");
1107      return;
1108   }
1109 //  printf(" --- Reading light tables for ZN \n");
1110   for(k=0; k<fNalfan; k++){
1111      for(j=0; j<fNben; j++){
1112        fscanf(fp1,"%f",&fTablen[0][k][j]);
1113        fscanf(fp2,"%f",&fTablen[1][k][j]);
1114        fscanf(fp3,"%f",&fTablen[2][k][j]);
1115        fscanf(fp4,"%f",&fTablen[3][k][j]);
1116      } 
1117   }
1118   fclose(fp1);
1119   fclose(fp2);
1120   fclose(fp3);
1121   fclose(fp4);
1122   
1123   lightfName5 = gSystem->ExpandPathName("$ALICE/$ALICE_LEVEL/ZDC/light22620552207s");
1124   if((fp5 = fopen(lightfName5,"r")) == NULL){
1125      printf("Cannot open file fp5 \n");
1126      return;
1127   }
1128   lightfName6 = gSystem->ExpandPathName("$ALICE/$ALICE_LEVEL/ZDC/light22620552208s");
1129   if((fp6 = fopen(lightfName6,"r")) == NULL){
1130      printf("Cannot open file fp6 \n");
1131      return;
1132   }
1133   lightfName7 = gSystem->ExpandPathName("$ALICE/$ALICE_LEVEL/ZDC/light22620552209s");
1134   if((fp7 = fopen(lightfName7,"r")) == NULL){
1135      printf("Cannot open file fp7 \n");
1136      return;
1137   }
1138   lightfName8 = gSystem->ExpandPathName("$ALICE/$ALICE_LEVEL/ZDC/light22620552210s");
1139   if((fp8 = fopen(lightfName8,"r")) == NULL){
1140      printf("Cannot open file fp8 \n");
1141      return;
1142   }
1143 //  printf(" --- Reading light tables for ZP and ZEM \n");
1144   for(k=0; k<fNalfap; k++){
1145      for(j=0; j<fNbep; j++){
1146        fscanf(fp5,"%f",&fTablep[0][k][j]);
1147        fscanf(fp6,"%f",&fTablep[1][k][j]);
1148        fscanf(fp7,"%f",&fTablep[2][k][j]);
1149        fscanf(fp8,"%f",&fTablep[3][k][j]);
1150      } 
1151   }
1152   fclose(fp5);
1153   fclose(fp6);
1154   fclose(fp7);
1155   fclose(fp8);
1156 }
1157
1158 //_____________________________________________________________________________
1159 Int_t AliZDCv1::Digitize(Int_t Det, Int_t Quad, Int_t Light)
1160 {
1161   // Evaluation of the ADC channel corresponding to the light yield Light
1162
1163   if(fDebug == 1){
1164     printf("\n  Digitize -> Det = %d, Quad = %d, Light = %d\n", Det, Quad, Light);
1165   }   
1166   
1167   // Parameters for conversion of light yield in ADC channels
1168   Float_t fPMGain[3][5];      // PM gain
1169   Float_t fADCRes;            // ADC conversion factor
1170   
1171   Int_t j,i;
1172   for(i=0; i<3; i++){
1173      for(j=0; j<5; j++){
1174         fPMGain[i][j]   = 100000.;
1175      }
1176   }
1177   fADCRes   = 0.00000064; // ADC Resolution: 250 fC/ADCch
1178   
1179   Int_t ADCch = Int_t(Light*fPMGain[Det-1][Quad]*fADCRes);
1180      
1181   return ADCch;
1182 }
1183
1184
1185 //_____________________________________________________________________________
1186 void AliZDCv1::SDigits2Digits()
1187 {
1188    Hits2Digits(gAlice->GetNtrack());
1189 }
1190
1191 //_____________________________________________________________________________
1192 void AliZDCv1::Hits2Digits(Int_t ntracks)
1193 {
1194   AliZDCDigit *newdigit;
1195   AliZDCHit   *hit;
1196
1197   Int_t PMCZN = 0, PMCZP = 0, PMQZN[4], PMQZP[4], PMZEM = 0;
1198   
1199   Int_t i;
1200   for(i=0; i<4; i++){
1201      PMQZN[i] =0;
1202      PMQZP[i] =0;
1203   }
1204   
1205   Int_t itrack = 0;
1206   for(itrack=0; itrack<ntracks; itrack++){
1207      gAlice->ResetHits();
1208      gAlice->TreeH()->GetEvent(itrack);
1209      for(i=0; i<fHits->GetEntries(); i++){
1210         hit = (AliZDCHit*)fHits->At(i);
1211         Int_t det   = hit->GetVolume(0);
1212         Int_t quad  = hit->GetVolume(1);
1213         Int_t lightQ = Int_t(hit->GetLightPMQ());
1214         Int_t lightC = Int_t(hit->GetLightPMC());
1215         if(fDebug == 1)
1216           printf("         \n itrack = %d, fNhits = %d, det = %d, quad = %d,"
1217           "lightC = %d lightQ = %d\n", itrack, fNhits, det, quad, lightC, lightQ);
1218             
1219         if(det == 1){   //ZN 
1220           PMCZN = PMCZN + lightC;
1221           PMQZN[quad-1] = PMQZN[quad-1] + lightQ;
1222         }
1223
1224         if(det == 2){   //ZP 
1225           PMCZP = PMCZP + lightC;
1226           PMQZP[quad-1] = PMQZP[quad-1] + lightQ;
1227         }
1228
1229         if(det == 3){   //ZEM 
1230           PMZEM = PMZEM + lightC;
1231         }
1232      } // Hits loop
1233   
1234   } // Tracks loop
1235   
1236      if(fDebug == 1){
1237        printf("\n        PMCZN = %d, PMQZN[0] = %d, PMQZN[1] = %d, PMQZN[2] = %d, PMQZN[3] = %d\n"
1238             , PMCZN, PMQZN[0], PMQZN[1], PMQZN[2], PMQZN[3]);
1239        printf("\n        PMCZP = %d, PMQZP[0] = %d, PMQZP[1] = %d, PMQZP[2] = %d, PMQZP[3] = %d\n"
1240             , PMCZP, PMQZP[0], PMQZP[1], PMQZP[2], PMQZP[3]);
1241        printf("\n        PMZEM = %d\n", PMZEM);
1242      }
1243
1244   // ------------------------------------    Hits2Digits
1245   // Digits for ZN
1246      newdigit = new AliZDCDigit(1, 0, Digitize(1, 0, PMCZN));
1247      new((*fDigits)[fNdigits]) AliZDCDigit(*newdigit);
1248      fNdigits++;
1249      delete newdigit;
1250   
1251      Int_t j;
1252      for(j=0; j<4; j++){
1253         newdigit = new AliZDCDigit(1, j+1, Digitize(1, j+1, PMQZN[j]));
1254         new((*fDigits)[fNdigits]) AliZDCDigit(*newdigit);
1255         fNdigits++;
1256         delete newdigit;
1257      }
1258   
1259      // Digits for ZP
1260      newdigit = new AliZDCDigit(2, 0, Digitize(2, 0, PMCZP));
1261      new((*fDigits)[fNdigits]) AliZDCDigit(*newdigit);
1262      fNdigits++;
1263      delete newdigit;
1264   
1265      Int_t k;
1266      for(k=0; k<4; k++){
1267         newdigit = new AliZDCDigit(2, k+1, Digitize(2, k+1, PMQZP[k]));
1268         new((*fDigits)[fNdigits]) AliZDCDigit(*newdigit);
1269         fNdigits++;
1270         delete newdigit;
1271      }
1272   
1273      // Digits for ZEM
1274      newdigit = new AliZDCDigit(3, 0, Digitize(3, 0, PMZEM));
1275      new((*fDigits)[fNdigits]) AliZDCDigit(*newdigit);
1276      fNdigits++;
1277      delete newdigit;
1278       
1279   
1280   gAlice->TreeD()->Fill();
1281   gAlice->TreeD()->Write(0,TObject::kOverwrite);
1282
1283   if(fDebug == 1){
1284     printf("\n  Event Digits -----------------------------------------------------\n");  
1285     fDigits->Print("");
1286   }
1287   
1288 }
1289 //_____________________________________________________________________________
1290  void AliZDCv1::MakeBranch(Option_t *opt, char *file)
1291 {
1292   //
1293   // Create a new branch in the current Root Tree
1294   //
1295
1296   AliDetector::MakeBranch(opt);
1297   
1298   Char_t branchname[10];
1299   sprintf(branchname,"%s",GetName());
1300   const char *cD = strstr(opt,"D");
1301
1302   if (gAlice->TreeD() && cD) {
1303
1304     // Creation of the digits from hits 
1305
1306     if(fDigits!=0) fDigits->Clear();
1307     else fDigits = new TClonesArray ("AliZDCDigit",1000);
1308     char branchname[10];
1309     sprintf(branchname,"%s",GetName());
1310     gAlice->MakeBranchInTree(gAlice->TreeD(), 
1311                              branchname, &fDigits, fBufferSize, file) ;
1312     printf("* AliZDCv1::MakeBranch    * Making Branch %s for digits\n\n",branchname);
1313   }     
1314 }
1315 //_____________________________________________________________________________
1316 void AliZDCv1::StepManager()
1317 {
1318   //
1319   // Routine called at every step in the Zero Degree Calorimeters
1320   //
1321
1322   Int_t j;
1323   Int_t vol[2], ibeta=0, ialfa, ibe, nphe;
1324   Float_t x[3], xdet[3], destep, hits[10], m, ekin, um[3], ud[3], be, radius, out;
1325   TLorentzVector s, p;
1326   const char *knamed;
1327
1328   for (j=0;j<10;j++) hits[j]=0;
1329
1330   if((gMC->GetMedium() == fMedSensZN) || (gMC->GetMedium() == fMedSensZP) ||
1331      (gMC->GetMedium() == fMedSensGR) || (gMC->GetMedium() == fMedSensF1) ||
1332      (gMC->GetMedium() == fMedSensF2) || (gMC->GetMedium() == fMedSensZEM) ||
1333      (gMC->GetMedium() == fMedSensPI)){
1334        
1335   // If particle interacts with beam pipe -> return
1336     if(gMC->GetMedium() == fMedSensPI){ 
1337   
1338   // If option NoShower is set -> StopTrack
1339       if(fNoShower==1) gMC->StopTrack();
1340       return;
1341     }
1342   
1343   //Particle coordinates 
1344     gMC->TrackPosition(s);
1345     for(j=0; j<=2; j++){
1346        x[j] = s[j];
1347     }
1348     hits[0] = x[0];
1349     hits[1] = x[1];
1350     hits[2] = x[2];
1351
1352   // Determine in which ZDC the particle is
1353     knamed = gMC->CurrentVolName();
1354     if(!strncmp(knamed,"ZN",2))vol[0]=1;
1355     if(!strncmp(knamed,"ZP",2))vol[0]=2;
1356     if(!strncmp(knamed,"ZE",2))vol[0]=3;
1357   
1358   // Determine in which quadrant the particle is
1359     
1360     //Quadrant in ZN
1361     if(vol[0]==1){
1362       xdet[0] = x[0]-fPosZN[0];
1363       xdet[1] = x[1]-fPosZN[1];
1364       if((xdet[0]<=0.) && (xdet[1]>=0.))  vol[1]=1;
1365       if((xdet[0]>0.)  && (xdet[1]>0.))   vol[1]=2;
1366       if((xdet[0]<0.)  && (xdet[1]<0.))   vol[1]=3;
1367       if((xdet[0]>0.)  && (xdet[1]<0.))   vol[1]=4;
1368     }
1369     
1370     //Quadrant in ZP
1371     if(vol[0]==2){
1372       xdet[0] = x[0]-fPosZP[0];
1373       xdet[1] = x[1]-fPosZP[1];
1374       if(xdet[0]>fDimZP[0])xdet[0]=fDimZP[0]-0.01;
1375       if(xdet[0]<-fDimZP[0])xdet[0]=-fDimZP[0]+0.01;
1376       Float_t xqZP = xdet[0]/(fDimZP[0]/2);
1377       for(int i=1; i<=4; i++){
1378          if(xqZP>=(i-3) && xqZP<(i-2)){
1379            vol[1] = i;
1380            break;
1381          }
1382       }
1383     }
1384     
1385     //ZEM has only 1 quadrant
1386     if(vol[0] == 3){
1387       vol[1] = 1;
1388       xdet[0] = x[0]-fPosZEM[0];
1389       xdet[1] = x[1]-fPosZEM[1];
1390     }
1391
1392
1393   // Store impact point and kinetic energy of the ENTERING particle
1394     
1395 //    if(Curtrack==Prim){
1396       if(gMC->IsTrackEntering()){
1397         //Particle energy
1398         gMC->TrackMomentum(p);
1399         hits[3] = p[3];
1400
1401         // Impact point on ZDC  
1402         hits[4] = xdet[0];
1403         hits[5] = xdet[1];
1404         hits[6] = 0;
1405         hits[7] = 0;
1406         hits[8] = 0;
1407         hits[9] = 0;
1408
1409 //        Int_t PcID = gMC->TrackPid();
1410 //        printf("Pc ID -> %d\n",PcID);
1411         AddHit(gAlice->CurrentTrack(), vol, hits);
1412         
1413         if(fNoShower==1){
1414         gMC->StopTrack();
1415         return;
1416         }
1417       }
1418 //    }
1419              
1420       // Charged particles -> Energy loss
1421       if((destep=gMC->Edep())){
1422          if(gMC->IsTrackStop()){
1423            gMC->TrackMomentum(p);
1424            m = gMC->TrackMass();
1425            ekin = p[3]-m;
1426            if(ekin<0.) printf("ATTENTION!!!!!!!!!!!!!!! ->      ekin = %f <0 (?)",ekin);
1427            hits[9] = ekin;
1428            hits[7] = 0.;
1429            hits[8] = 0.;
1430            AddHit(gAlice->CurrentTrack(), vol, hits);
1431            }
1432          else{
1433            hits[9] = destep;
1434            hits[7] = 0.;
1435            hits[8] = 0.;
1436            AddHit(gAlice->CurrentTrack(), vol, hits);
1437            }
1438 //       printf("       -> Charged particle -> Dep. E = %f eV \n",hits[8]);
1439          }
1440 //       printf(" \n");
1441   }
1442
1443
1444   // *** Light production in fibres 
1445   if((gMC->GetMedium() == fMedSensF1) || (gMC->GetMedium() == fMedSensF2)){
1446
1447      //Select charged particles
1448      if((destep=gMC->Edep())){
1449 //       printf("               -> CHARGED particle!!! \n");
1450
1451        // Particle velocity
1452        gMC->TrackMomentum(p);
1453        Float_t ptot=TMath::Sqrt(p[0]*p[0]+p[1]*p[1]+p[2]*p[2]);
1454        Float_t beta =  ptot/p[3];
1455        if(beta<0.67) return;
1456        if((beta>=0.67) && (beta<=0.75)) ibeta = 0;
1457        if((beta>0.75)  && (beta<=0.85)) ibeta = 1;
1458        if((beta>0.85)  && (beta<=0.95)) ibeta = 2;
1459 //       if((beta>0.95)  && (beta<=1.00)) ibeta = 3;
1460        if(beta>0.95) ibeta = 3;
1461  
1462        // Angle between particle trajectory and fibre axis
1463        // 1 -> Momentum directions
1464        um[0] = p[0]/ptot;
1465        um[1] = p[1]/ptot;
1466        um[2] = p[2]/ptot;
1467        gMC->Gmtod(um,ud,2);
1468        // 2 -> Angle < limit angle
1469        Double_t alfar = TMath::ACos(ud[2]);
1470        Double_t alfa = alfar*kRaddeg;
1471        if(alfa>=110.) return;
1472        ialfa = Int_t(1.+alfa/2.);
1473  
1474        // Distance between particle trajectory and fibre axis
1475        gMC->TrackPosition(s);
1476        for(j=0; j<=2; j++){
1477           x[j] = s[j];
1478        }
1479        gMC->Gmtod(x,xdet,1);
1480        if(TMath::Abs(ud[0])>0.00001){
1481          Float_t dcoeff = ud[1]/ud[0];
1482          be = TMath::Abs((xdet[1]-dcoeff*xdet[0])/TMath::Sqrt(dcoeff*dcoeff+1.));
1483        }
1484        else{
1485          be = TMath::Abs(ud[0]);
1486        }
1487  
1488        if((vol[0]==1)) radius = fFibZN[1];
1489        if((vol[0]==2)) radius = fFibZP[1];
1490        ibe = Int_t(be*1000.+1);
1491  
1492        //Looking into the light tables 
1493        Float_t charge = gMC->TrackCharge();
1494        
1495        // (1)  ZN
1496        if((vol[0]==1)) {
1497          if(ibe>fNben) ibe=fNben;
1498          out =  charge*charge*fTablen[ibeta][ialfa][ibe];
1499          nphe = gRandom->Poisson(out);
1500          if(gMC->GetMedium() == fMedSensF1){
1501            hits[7] = nphe;      //fLightPMQ
1502            hits[8] = 0;
1503            hits[9] = 0;
1504            AddHit(gAlice->CurrentTrack(), vol, hits);
1505          }
1506          else{
1507            hits[7] = 0;
1508            hits[8] = nphe;      //fLightPMC
1509            hits[9] = 0;
1510            AddHit(gAlice->CurrentTrack(), vol, hits);
1511          }
1512        } 
1513        
1514        // (2) ZP
1515        if((vol[0]==2)) {
1516          if(ibe>fNbep) ibe=fNbep;
1517          out =  charge*charge*fTablep[ibeta][ialfa][ibe];
1518          nphe = gRandom->Poisson(out);
1519          if(gMC->GetMedium() == fMedSensF1){
1520            hits[7] = nphe;      //fLightPMQ
1521            hits[8] = 0;
1522            hits[9] = 0;
1523            AddHit(gAlice->CurrentTrack(), vol, hits);
1524          }
1525          else{
1526            hits[7] = 0;
1527            hits[8] = nphe;      //fLightPMC
1528            hits[9] = 0;
1529            AddHit(gAlice->CurrentTrack(), vol, hits);
1530          }
1531        } 
1532        // (3) ZEM
1533        if((vol[0]==3)) {
1534          if(ibe>fNbep) ibe=fNbep;
1535          out =  charge*charge*fTablep[ibeta][ialfa][ibe];
1536          nphe = gRandom->Poisson(out);
1537          hits[7] = 0;   
1538          hits[8] = nphe;        //fLightPMC
1539          hits[9] = 0;
1540          AddHit(gAlice->CurrentTrack(), vol, hits);
1541        } 
1542      }
1543        
1544    }
1545 }