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