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