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