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