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