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