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