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