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