]> git.uio.no Git - u/mrichter/AliRoot.git/blob - ZDC/AliZDCv3.cxx
M submitMerging.sh - Using groups for jobs submitting
[u/mrichter/AliRoot.git] / ZDC / AliZDCv3.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 ///////////////////////////////////////////////////////////////////////
18 //                                                                   //
19 //              AliZDCv3 --- new ZDC geometry                        //
20 //          with both ZDC arms geometry implemented                  //
21 //                                                                   //  
22 ///////////////////////////////////////////////////////////////////////
23
24 // --- Standard libraries
25 #include "stdio.h"
26
27 // --- ROOT system
28 #include <TMath.h>
29 #include <TRandom.h>
30 #include <TSystem.h>
31 #include <TTree.h>
32 #include <TVirtualMC.h>
33 #include <TGeoManager.h>
34 #include <TGeoMatrix.h>
35 #include <TGeoCone.h>
36 #include <TGeoShape.h>
37 #include <TGeoCompositeShape.h>
38 #include <TParticle.h>
39
40 // --- AliRoot classes
41 #include "AliLog.h"
42 #include "AliConst.h"
43 #include "AliMagF.h"
44 #include "AliRun.h"
45 #include "AliZDCv3.h"
46 #include "AliMC.h"
47  
48 class  AliZDCHit;
49 class  AliPDG;
50 class  AliDetector;
51  
52  
53 ClassImp(AliZDCv3)
54
55 //_____________________________________________________________________________
56 AliZDCv3::AliZDCv3() : 
57   AliZDC(),
58   fMedSensF1(0),
59   fMedSensF2(0),
60   fMedSensZP(0),
61   fMedSensZN(0),
62   fMedSensZEM(0),
63   fMedSensGR(0),
64   fMedSensPI(0),
65   fMedSensTDI(0),
66   fNalfan(0),
67   fNalfap(0),
68   fNben(0),  
69   fNbep(0),
70   fZEMLength(0),
71   fpLostITC(0), 
72   fpLostD1C(0), 
73   fpDetectedC(0),
74   fnDetectedC(0),
75   fpLostITA(0), 
76   fpLostD1A(0), 
77   fpLostTDI(0), 
78   fpDetectedA(0),
79   fnDetectedA(0)
80 {
81   //
82   // Default constructor for Zero Degree Calorimeter
83   //
84   
85 }
86  
87 //_____________________________________________________________________________
88 AliZDCv3::AliZDCv3(const char *name, const char *title) : 
89   AliZDC(name,title),
90   fMedSensF1(0),
91   fMedSensF2(0),
92   fMedSensZP(0),
93   fMedSensZN(0),
94   fMedSensZEM(0),
95   fMedSensGR(0),
96   fMedSensPI(0),
97   fMedSensTDI(0),
98   fNalfan(90),
99   fNalfap(90),
100   fNben(18),  
101   fNbep(28), 
102   fZEMLength(0),
103   fpLostITC(0), 
104   fpLostD1C(0), 
105   fpDetectedC(0),
106   fnDetectedC(0),
107   fpLostITA(0), 
108   fpLostD1A(0), 
109   fpLostTDI(0), 
110   fpDetectedA(0),
111   fnDetectedA(0)  
112 {
113   //
114   // Standard constructor for Zero Degree Calorimeter 
115   //
116   //
117   // Check that DIPO, ABSO, DIPO and SHIL is there (otherwise tracking is wrong!!!)
118   
119   AliModule* pipe=gAlice->GetModule("PIPE");
120   AliModule* abso=gAlice->GetModule("ABSO");
121   AliModule* dipo=gAlice->GetModule("DIPO");
122   AliModule* shil=gAlice->GetModule("SHIL");
123   if((!pipe) || (!abso) || (!dipo) || (!shil)) {
124     Error("Constructor","ZDC needs PIPE, ABSO, DIPO and SHIL!!!\n");
125     exit(1);
126   } 
127   //
128   Int_t ip,jp,kp;
129   for(ip=0; ip<4; ip++){
130      for(kp=0; kp<fNalfap; kp++){
131         for(jp=0; jp<fNbep; jp++){
132            fTablep[ip][kp][jp] = 0;
133         } 
134      }
135   }
136   Int_t in,jn,kn;
137   for(in=0; in<4; in++){
138      for(kn=0; kn<fNalfan; kn++){
139         for(jn=0; jn<fNben; jn++){
140            fTablen[in][kn][jn] = 0;
141         } 
142      }
143   }
144   //
145   // Parameters for hadronic calorimeters geometry
146   // Positions updated after post-installation measurements
147   fDimZN[0] = 3.52;
148   fDimZN[1] = 3.52;
149   fDimZN[2] = 50.;  
150   fDimZP[0] = 11.2;
151   fDimZP[1] = 6.;
152   fDimZP[2] = 75.;    
153   fPosZNC[0] = 0.;
154   fPosZNC[1] = 1.2;
155   fPosZNC[2] = -11397.3; 
156   fPosZPC[0] = 24.35;
157   fPosZPC[1] = 0.;
158   fPosZPC[2] = -11389.3; 
159   fPosZNA[0] = 0.;
160   fPosZNA[1] = 1.2;
161   fPosZNA[2] = 11395.8;  
162   fPosZPA[0] = 24.35;
163   fPosZPA[1] = 0.;
164   fPosZPA[2] = 11387.8; 
165   fFibZN[0] = 0.;
166   fFibZN[1] = 0.01825;
167   fFibZN[2] = 50.;
168   fFibZP[0] = 0.;
169   fFibZP[1] = 0.0275;
170   fFibZP[2] = 75.;
171   // Parameters for EM calorimeter geometry
172   fPosZEM[0] = 8.5;
173   fPosZEM[1] = 0.;
174   fPosZEM[2] = 735.;
175   Float_t kDimZEMPb  = 0.15*(TMath::Sqrt(2.));  // z-dimension of the Pb slice
176   Float_t kDimZEMAir = 0.001;                   // scotch
177   Float_t kFibRadZEM = 0.0315;                  // External fiber radius (including cladding)
178   Int_t   kDivZEM[3] = {92, 0, 20};             // Divisions for EM detector
179   Float_t kDimZEM0 = 2*kDivZEM[2]*(kDimZEMPb+kDimZEMAir+kFibRadZEM*(TMath::Sqrt(2.)));
180   fZEMLength = kDimZEM0;
181   
182 }
183  
184 //_____________________________________________________________________________
185 void AliZDCv3::CreateGeometry()
186 {
187   //
188   // Create the geometry for the Zero Degree Calorimeter version 2
189   //* Initialize COMMON block ZDC_CGEOM
190   //*
191
192   CreateBeamLine();
193   CreateZDC();
194 }
195   
196 //_____________________________________________________________________________
197 void AliZDCv3::CreateBeamLine()
198 {
199   //
200   // Create the beam line elements
201   //
202   
203   Double_t zd1, zd2, zCorrDip, zInnTrip, zD1, zD2;
204   Double_t conpar[9], tubpar[3], tubspar[5], boxpar[3];
205
206   //-- rotation matrices for the legs
207   Int_t irotpipe1, irotpipe2;
208   gMC->Matrix(irotpipe1,90.-1.0027,0.,90.,90.,1.0027,180.);      
209   gMC->Matrix(irotpipe2,90.+1.0027,0.,90.,90.,1.0027,0.);
210
211   //
212   Int_t *idtmed = fIdtmed->GetArray();
213   
214   ////////////////////////////////////////////////////////////////
215   //                                                            //
216   //                SIDE C - RB26 (dimuon side)                 //
217   //                                                            //
218   ///////////////////////////////////////////////////////////////
219   
220   
221   // -- Mother of the ZDCs (Vacuum PCON)
222   zd1 = 1921.6;
223   
224   conpar[0] = 0.;
225   conpar[1] = 360.;
226   conpar[2] = 2.;
227   conpar[3] = -13500.;
228   conpar[4] = 0.;
229   conpar[5] = 55.;
230   conpar[6] = -zd1;
231   conpar[7] = 0.;
232   conpar[8] = 55.;
233   gMC->Gsvolu("ZDCC", "PCON", idtmed[10], conpar, 9);
234   gMC->Gspos("ZDCC", 1, "ALIC", 0., 0., 0., 0, "ONLY");
235   
236
237   // -- BEAM PIPE from compensator dipole to the beginning of D1) 
238   tubpar[0] = 6.3/2.;
239   tubpar[1] = 6.7/2.;
240   // From beginning of ZDC volumes to beginning of D1
241   tubpar[2] = (5838.3-zd1)/2.;
242   gMC->Gsvolu("QT01", "TUBE", idtmed[7], tubpar, 3);
243   gMC->Gspos("QT01", 1, "ZDCC", 0., 0., -tubpar[2]-zd1, 0, "ONLY");
244   // Ch.debug
245   //printf("    QT01 TUBE pipe from z = %1.2f to z= %1.2f (D1 beg.)\n",-zd1,-2*tubpar[2]-zd1);
246   
247   //-- BEAM PIPE from the end of D1 to the beginning of D2) 
248   
249   //-- FROM MAGNETIC BEGINNING OF D1 TO MAGNETIC END OF D1
250   //--  Cylindrical pipe (r = 3.47) + conical flare  
251   // -> Beginning of D1
252   zd1 += 2.*tubpar[2];
253   
254   tubpar[0] = 6.94/2.;
255   tubpar[1] = 7.34/2.;
256   tubpar[2] = (6909.8-zd1)/2.;
257   gMC->Gsvolu("QT02", "TUBE", idtmed[7], tubpar, 3);
258   gMC->Gspos("QT02", 1, "ZDCC", 0., 0., -tubpar[2]-zd1, 0, "ONLY");
259   // Ch.debug
260   //printf("    QT02 TUBE pipe from z = %1.2f to z= %1.2f\n",-zd1,-2*tubpar[2]-zd1);
261
262   zd1 += 2.*tubpar[2];
263   
264   tubpar[0] = 9./2.;
265   tubpar[1] = 9.6/2.;
266   tubpar[2] = (7022.8-zd1)/2.;
267   gMC->Gsvolu("QT03", "TUBE", idtmed[7], tubpar, 3);
268   gMC->Gspos("QT03", 1, "ZDCC", 0., 0., -tubpar[2]-zd1, 0, "ONLY");
269   // Ch.debug
270   //printf("    QT03 TUBE pipe from z = %1.2f to z= %1.2f\n",-zd1,-2*tubpar[2]-zd1);
271
272   zd1 += 2.*tubpar[2];
273   
274   conpar[0] = 39.2/2.;
275   conpar[1] = 18./2.;
276   conpar[2] = 18.6/2.;
277   conpar[3] = 9./2.;
278   conpar[4] = 9.6/2.;
279   gMC->Gsvolu("QC01", "CONE", idtmed[7], conpar, 5);
280   gMC->Gspos("QC01", 1, "ZDCC", 0., 0., -conpar[0]-zd1, 0, "ONLY");
281   // Ch.debug
282   //printf("    QC01 CONE pipe from z = %1.2f to z= %1.2f\n",-zd1,-2*conpar[0]-zd1);
283   
284   zd1 += conpar[0] * 2.;
285   
286   // ******************************************************
287   // N.B.-> according to last vacuum layout 
288   // private communication by D. Macina, mail 27/1/2009
289   // ****************************************************** 
290   // 2nd section of VCTCQ+VAMTF+TCTVB+VAMTF+TCLIA+VAMTF+1st part of VCTCP
291   Float_t totLength1 = 160.8 + 78. + 148. + 78. + 148. + 78. + 9.3;
292   //
293   tubpar[0] = 18.6/2.;
294   tubpar[1] = 7.6/2.;
295   tubpar[2] = totLength1/2.;
296   gMC->Gsvolu("QE01", "ELTU", idtmed[7], tubpar, 3);  
297
298   tubpar[0] = 18.0/2.;
299   tubpar[1] = 7.0/2.;
300   tubpar[2] = totLength1/2.;
301   gMC->Gsvolu("QE02", "ELTU", idtmed[10], tubpar, 3);  
302   gMC->Gspos("QE02", 1, "ZDCC", 0., 0., -tubpar[2]-zd1, 0, "ONLY"); 
303   gMC->Gspos("QE02", 1, "QE01", 0., 0., 0., 0, "ONLY");  
304   // Ch.debug
305   //printf("    QE02 ELTU from z = %1.2f to z= %1.2f\n",-zd1,-2*tubpar[2]-zd1);
306   
307   zd1 += tubpar[2] * 2.;
308   
309   // 2nd part of VCTCP
310   conpar[0] = 31.5/2.;
311   conpar[1] = 21.27/2.;
312   conpar[2] = 21.87/2.;
313   conpar[3] = 18.0/2.;
314   conpar[4] = 18.6/2.;
315   gMC->Gsvolu("QC02", "CONE", idtmed[7], conpar, 5);
316   gMC->Gspos("QC02", 1, "ZDCC", 0., 0., -conpar[0]-zd1, 0, "ONLY");
317   // Ch.debug
318   //printf("    QC02 CONE pipe from z = %1.2f to z= %1.2f\n",-zd1,-2*conpar[0]-zd1);
319   
320   zd1 += conpar[0] * 2.;
321
322   // 3rd section of VCTCP+VCDWC+VMLGB   
323   Float_t totLenght2 = 9.2 + 530.5+40.;
324   tubpar[0] = 21.2/2.;
325   tubpar[1] = 21.9/2.;
326   tubpar[2] = totLenght2/2.;
327   gMC->Gsvolu("QT04", "TUBE", idtmed[7], tubpar, 3);
328   gMC->Gspos("QT04", 1, "ZDCC", 0., 0., -tubpar[2]-zd1, 0, "ONLY");
329   // Ch.debug
330   //printf("    QT04 TUBE pipe from z = %1.2f to z= %1.2f\n",-zd1,-2*tubpar[2]-zd1);
331   
332   zd1 += tubpar[2] * 2.;
333   
334   // First part of VCTCD
335   // skewed transition cone from ID=212.7 mm to ID=797 mm
336   conpar[0] = 121./2.;
337   conpar[1] = 79.7/2.;
338   conpar[2] = 81.3/2.;
339   conpar[3] = 21.27/2.;
340   conpar[4] = 21.87/2.;
341   gMC->Gsvolu("QC03", "CONE", idtmed[7], conpar, 5);
342   gMC->Gspos("QC03", 1, "ZDCC", 0., 0., -conpar[0]-zd1, 0, "ONLY");
343   // Ch.debug
344   //printf("    QC03 CONE pipe from z = %1.2f to z= %1.2f\n",-zd1,-2*conpar[0]-zd1);
345   
346   zd1 += 2.*conpar[0];
347   
348   // VCDGB + 1st part of VCTCH
349   tubpar[0] = 79.7/2.;
350   tubpar[1] = 81.3/2.;
351   tubpar[2] = (5*475.2+97.)/2.;
352   gMC->Gsvolu("QT05", "TUBE", idtmed[7], tubpar, 3);
353   gMC->Gspos("QT05", 1, "ZDCC", 0., 0., -tubpar[2]-zd1, 0, "ONLY");
354   // Ch.debug
355   //printf("    QT05 TUBE pipe from z = %1.2f to z= %1.2f\n",-zd1,-2*tubpar[2]-zd1);
356   
357   zd1 += 2.*tubpar[2];
358      
359   // 2nd part of VCTCH
360   // Transition from ID=797 mm to ID=196 mm:
361   // in order to simulate the thin window opened in the transition cone
362   // we divide the transition cone in three cones:
363   // (1) 8 mm thick (2) 3 mm thick (3) the third 8 mm thick
364   
365   // (1) 8 mm thick
366   conpar[0] = 9.09/2.; // 15 degree
367   conpar[1] = 74.82868/2.;
368   conpar[2] = 76.42868/2.; // thickness 8 mm 
369   conpar[3] = 79.7/2.;
370   conpar[4] = 81.3/2.; // thickness 8 mm  
371   gMC->Gsvolu("QC04", "CONE", idtmed[7], conpar, 5);
372   gMC->Gspos("QC04", 1, "ZDCC", 0., 0., -conpar[0]-zd1, 0, "ONLY");
373   // Ch.debug
374   //printf("    QC04 CONE pipe from z = %1.2f to z= %1.2f\n",-zd1,-2*conpar[0]-zd1);
375
376   zd1 += 2.*conpar[0];  
377
378   // (2) 3 mm thick
379   conpar[0] = 96.2/2.; // 15 degree
380   conpar[1] = 23.19588/2.;
381   conpar[2] = 23.79588/2.; // thickness 3 mm 
382   conpar[3] = 74.82868/2.;
383   conpar[4] = 75.42868/2.; // thickness 3 mm  
384   gMC->Gsvolu("QC05", "CONE", idtmed[7], conpar, 5);
385   gMC->Gspos("QC05", 1, "ZDCC", 0., 0., -conpar[0]-zd1, 0, "ONLY");  
386   // Ch.debug
387   //printf("    QC05 CONE pipe from z = %1.2f to z= %1.2f\n",-zd1,-2*conpar[0]-zd1);
388
389   zd1 += 2.*conpar[0];
390   
391   // (3) 8 mm thick
392   conpar[0] = 6.71/2.; // 15 degree
393   conpar[1] = 19.6/2.;
394   conpar[2] = 21.2/2.;// thickness 8 mm 
395   conpar[3] = 23.19588/2.;
396   conpar[4] = 24.79588/2.;// thickness 8 mm 
397   gMC->Gsvolu("QC06", "CONE", idtmed[7], conpar, 5);
398   gMC->Gspos("QC06", 1, "ZDCC", 0., 0., -conpar[0]-zd1, 0, "ONLY");
399   // Ch.debug
400   //printf("    QC06 CONE pipe from z = %1.2f to z= %1.2f\n",-zd1,-2*conpar[0]-zd1);
401
402   zd1 += 2.*conpar[0];
403   
404   // VMZAR (5 volumes)  
405   tubpar[0] = 20.2/2.;
406   tubpar[1] = 20.6/2.;
407   tubpar[2] = 2.15/2.;
408   gMC->Gsvolu("QT06", "TUBE", idtmed[7], tubpar, 3);
409   gMC->Gspos("QT06", 1, "ZDCC", 0., 0., -tubpar[2]-zd1, 0, "ONLY");
410   // Ch.debug
411   //printf("    QT06 TUBE pipe from z = %1.2f to z= %1.2f\n",-zd1,-2*tubpar[2]-zd1);
412
413   zd1 += 2.*tubpar[2];
414   
415   conpar[0] = 6.9/2.;
416   conpar[1] = 23.9/2.;
417   conpar[2] = 24.3/2.;
418   conpar[3] = 20.2/2.;
419   conpar[4] = 20.6/2.;
420   gMC->Gsvolu("QC07", "CONE", idtmed[7], conpar, 5);
421   gMC->Gspos("QC07", 1, "ZDCC", 0., 0., -conpar[0]-zd1, 0, "ONLY");
422   // Ch.debug
423   //printf("    QC07 CONE pipe from z = %1.2f to z= %1.2f\n",-zd1,-2*conpar[0]-zd1);
424
425   zd1 += 2.*conpar[0];
426
427   tubpar[0] = 23.9/2.;
428   tubpar[1] = 25.5/2.;
429   tubpar[2] = 17.0/2.;
430   gMC->Gsvolu("QT07", "TUBE", idtmed[7], tubpar, 3);
431   gMC->Gspos("QT07", 1, "ZDCC", 0., 0., -tubpar[2]-zd1, 0, "ONLY");
432   // Ch.debug
433   //printf("    QT07 TUBE pipe from z = %1.2f to z= %1.2f\n",-zd1,-2*tubpar[2]-zd1);
434  
435   zd1 += 2.*tubpar[2];
436   
437   conpar[0] = 6.9/2.;
438   conpar[1] = 20.2/2.;
439   conpar[2] = 20.6/2.;
440   conpar[3] = 23.9/2.;
441   conpar[4] = 24.3/2.;
442   gMC->Gsvolu("QC08", "CONE", idtmed[7], conpar, 5);
443   gMC->Gspos("QC08", 1, "ZDCC", 0., 0., -conpar[0]-zd1, 0, "ONLY");
444   // Ch.debug
445   //printf("    QC08 CONE pipe from z = %1.2f to z= %1.2f\n",-zd1,-2*conpar[0]-zd1);
446
447   zd1 += 2.*conpar[0];
448   
449   tubpar[0] = 20.2/2.;
450   tubpar[1] = 20.6/2.;
451   tubpar[2] = 2.15/2.;
452   gMC->Gsvolu("QT08", "TUBE", idtmed[7], tubpar, 3);
453   gMC->Gspos("QT08", 1, "ZDCC", 0., 0., -tubpar[2]-zd1, 0, "ONLY");
454   // Ch.debug
455   //printf("    QT08 TUBE pipe from z = %1.2f to z= %1.2f\n",-zd1,-2*tubpar[2]-zd1);
456
457   zd1 += 2.*tubpar[2];
458   
459   // Flange (ID=196 mm)(last part of VMZAR and first part of VCTYB)
460   tubpar[0] = 19.6/2.;
461   tubpar[1] = 25.3/2.;
462   tubpar[2] = 4.9/2.;
463   gMC->Gsvolu("QT09", "TUBE", idtmed[7], tubpar, 3);
464   gMC->Gspos("QT09", 1, "ZDCC", 0., 0., -tubpar[2]-zd1, 0, "ONLY");
465   // Ch.debug
466   //printf("    QT09 TUBE pipe from z = %1.2f to z= %1.2f\n",-zd1,-2*tubpar[2]-zd1);
467  
468   zd1 += 2.*tubpar[2];
469   // Ch.debug
470   //printf("    Beginning of VCTYB volume @ z = %1.2f \n",-zd1);
471   
472   // simulation of the trousers (VCTYB)     
473   tubpar[0] = 19.6/2.;
474   tubpar[1] = 20.0/2.;
475   tubpar[2] = 3.9/2.;
476   gMC->Gsvolu("QT10", "TUBE", idtmed[7], tubpar, 3);
477   gMC->Gspos("QT10", 1, "ZDCC", 0., 0., -tubpar[2]-zd1, 0, "ONLY");
478   // Ch.debug
479   //printf("    QT10 TUBE pipe from z = %1.2f to z= %1.2f\n",-zd1,-2*tubpar[2]-zd1);
480
481   zd1 += 2.*tubpar[2];
482
483   // transition cone from ID=196. to ID=216.6
484   conpar[0] = 32.55/2.;
485   conpar[1] = 21.66/2.;
486   conpar[2] = 22.06/2.;
487   conpar[3] = 19.6/2.;
488   conpar[4] = 20.0/2.;
489   gMC->Gsvolu("QC09", "CONE", idtmed[7], conpar, 5);
490   gMC->Gspos("QC09", 1, "ZDCC", 0., 0., -conpar[0]-zd1, 0, "ONLY");
491   // Ch.debug
492   //printf("    QC09 CONE pipe from z = %1.2f to z= %1.2f\n",-zd1,-2*conpar[0]-zd1);
493
494   zd1 += 2.*conpar[0]; 
495   
496   // tube  
497   tubpar[0] = 21.66/2.;
498   tubpar[1] = 22.06/2.;
499   tubpar[2] = 28.6/2.;
500   gMC->Gsvolu("QT11", "TUBE", idtmed[7], tubpar, 3);
501   gMC->Gspos("QT11", 1, "ZDCC", 0., 0., -tubpar[2]-zd1, 0, "ONLY");
502   // Ch.debug
503   //printf("    QT11 TUBE pipe from z = %1.2f to z= %1.2f\n",-zd1,-2*tubpar[2]-zd1);
504
505   zd1 += 2.*tubpar[2];
506   // Ch.debug
507   //printf("    Beginning of recombination chamber @ z = %f \n",-zd1);
508
509   // --------------------------------------------------------
510   // RECOMBINATION CHAMBER IMPLEMENTED USING TGeo CLASSES!!!!
511   // author: Chiara (August 2008)
512   // --------------------------------------------------------
513   // TRANSFORMATION MATRICES
514   // Combi transformation: 
515   Double_t dx = -3.970000;
516   Double_t dy = 0.000000;
517   Double_t dz = 0.0;
518   // Rotation: 
519   Double_t thx = 84.989100;   Double_t phx = 180.000000;
520   Double_t thy = 90.000000;   Double_t phy = 90.000000;
521   Double_t thz = 185.010900;  Double_t phz = 0.000000;
522   TGeoRotation *rotMatrix1c = new TGeoRotation("c",thx,phx,thy,phy,thz,phz);
523   // Combi transformation: 
524   dx = -3.970000;
525   dy = 0.000000;
526   dz = 0.0;
527   TGeoCombiTrans *rotMatrix2c = new TGeoCombiTrans("ZDCC_c1", dx,dy,dz,rotMatrix1c);
528   rotMatrix2c->RegisterYourself();
529   // Combi transformation: 
530   dx = 3.970000;
531   dy = 0.000000;
532   dz = 0.0;
533   // Rotation: 
534   thx = 95.010900;   phx = 180.000000;
535   thy = 90.000000;   phy = 90.000000;
536   thz = 180.-5.010900;    phz = 0.000000;
537   TGeoRotation *rotMatrix3c = new TGeoRotation("",thx,phx,thy,phy,thz,phz);
538   TGeoCombiTrans *rotMatrix4c = new TGeoCombiTrans("ZDCC_c2", dx,dy,dz,rotMatrix3c);
539   rotMatrix4c->RegisterYourself();
540
541   // VOLUMES DEFINITION
542   // Volume: ZDCC
543   TGeoVolume *pZDCC = gGeoManager->GetVolume("ZDCC");
544   
545   conpar[0] = (90.1-0.95-0.26-0.0085)/2.;
546   conpar[1] = 0.0/2.;
547   conpar[2] = 21.6/2.;
548   conpar[3] = 0.0/2.;
549   conpar[4] = 5.8/2.;
550   new TGeoCone("QCLext", conpar[0],conpar[1],conpar[2],conpar[3],conpar[4]);
551   
552   conpar[0] = (90.1-0.95-0.26-0.0085)/2.;
553   conpar[1] = 0.0/2.;
554   conpar[2] = 21.2/2.;
555   conpar[3] = 0.0/2.;
556   conpar[4] = 5.4/2.;
557   new TGeoCone("QCLint", conpar[0],conpar[1],conpar[2],conpar[3],conpar[4]);
558
559   // Outer trousers
560   TGeoCompositeShape *pOutTrousersC = new TGeoCompositeShape("outTrousersC", "QCLext:ZDCC_c1+QCLext:ZDCC_c2");
561   
562   // Volume: QCLext
563   TGeoMedium *medZDCFe = gGeoManager->GetMedium("ZDC_ZIRON");
564   TGeoVolume *pQCLext = new TGeoVolume("QCLext",pOutTrousersC, medZDCFe);
565   pQCLext->SetLineColor(kGreen);
566   pQCLext->SetVisLeaves(kTRUE);
567   //
568   TGeoTranslation *tr1c = new TGeoTranslation(0., 0., (Double_t) -conpar[0]-0.95-zd1);
569   //printf("    Recombination chamber from z = %1.2f to z= %1.2f\n",-zd1,-2*conpar[0]-0.95-zd1);
570   //
571   pZDCC->AddNode(pQCLext, 1, tr1c);
572   // Inner trousers
573   TGeoCompositeShape *pIntTrousersC = new TGeoCompositeShape("intTrousersC", "QCLint:ZDCC_c1+QCLint:ZDCC_c2");
574   // Volume: QCLint
575   TGeoMedium *medZDCvoid = gGeoManager->GetMedium("ZDC_ZVOID");
576   TGeoVolume *pQCLint = new TGeoVolume("QCLint",pIntTrousersC, medZDCvoid);
577   pQCLint->SetLineColor(kTeal);
578   pQCLint->SetVisLeaves(kTRUE);
579   pQCLext->AddNode(pQCLint, 1);
580     
581   zd1 += 90.1;
582   Double_t offset = 0.5;
583   zd1 = zd1+offset;
584   
585   //  second section : 2 tubes (ID = 54. OD = 58.)  
586   tubpar[0] = 5.4/2.;
587   tubpar[1] = 5.8/2.;
588   tubpar[2] = 40.0/2.;
589   gMC->Gsvolu("QT12", "TUBE", idtmed[7], tubpar, 3);
590   gMC->Gspos("QT12", 1, "ZDCC", -15.8/2., 0., -tubpar[2]-zd1, 0, "ONLY");
591   gMC->Gspos("QT12", 2, "ZDCC",  15.8/2., 0., -tubpar[2]-zd1, 0, "ONLY");  
592   // Ch.debug
593   //printf("    QT12 TUBE from z = %1.2f to z= %1.2f\n",-zd1,-2*tubpar[2]-zd1);
594   
595   zd1 += 2.*tubpar[2];
596   
597   // transition x2zdc to recombination chamber : skewed cone  
598   conpar[0] = (10.-0.2-offset)/2.;
599   conpar[1] = 5.4/2.;
600   conpar[2] = 5.8/2.;
601   conpar[3] = 6.3/2.;
602   conpar[4] = 7.0/2.;
603   gMC->Gsvolu("QC10", "CONE", idtmed[7], conpar, 5); 
604   gMC->Gspos("QC10", 1, "ZDCC", -7.9-0.175, 0., -conpar[0]-0.1-zd1, irotpipe1, "ONLY");
605   gMC->Gspos("QC10", 2, "ZDCC", 7.9+0.175, 0., -conpar[0]-0.1-zd1, irotpipe2, "ONLY");
606   //printf("    QC10 CONE from z = %1.2f to z= %1.2f\n",-zd1,-2*conpar[0]-0.2-zd1);
607
608   zd1 += 2.*conpar[0]+0.2;
609   
610   // 2 tubes (ID = 63 mm OD=70 mm)      
611   tubpar[0] = 6.3/2.;
612   tubpar[1] = 7.0/2.;
613   tubpar[2] = 639.8/2.;
614   gMC->Gsvolu("QT13", "TUBE", idtmed[7], tubpar, 3);
615   gMC->Gspos("QT13", 1, "ZDCC", -16.5/2., 0., -tubpar[2]-zd1, 0, "ONLY");
616   gMC->Gspos("QT13", 2, "ZDCC",  16.5/2., 0., -tubpar[2]-zd1, 0, "ONLY");
617   //printf("    QT13 TUBE from z = %1.2f to z= %1.2f\n",-zd1,-2*tubpar[2]-zd1);  
618
619   zd1 += 2.*tubpar[2];
620   //printf("    END OF SIDE C BEAM PIPE DEFINITION @ z = %f\n",-zd1);
621
622            
623   // -- Luminometer (Cu box) in front of ZN - side C
624   boxpar[0] = 8.0/2.;
625   boxpar[1] = 8.0/2.;
626   boxpar[2] = 15./2.;
627   gMC->Gsvolu("QLUC", "BOX ", idtmed[9], boxpar, 3);
628   gMC->Gspos("QLUC", 1, "ZDCC", 0., 0.,  fPosZNC[2]+66.+boxpar[2], 0, "ONLY");
629   //printf("    QLUC LUMINOMETER from z = %1.2f to z= %1.2f\n",  fPosZNC[2]+66., fPosZNC[2]+66.+2*boxpar[2]);
630                  
631   // --  END OF BEAM PIPE VOLUME DEFINITION FOR SIDE C (RB26 SIDE) 
632   // ----------------------------------------------------------------
633
634   ////////////////////////////////////////////////////////////////
635   //                                                            //
636   //                SIDE A - RB24                               //
637   //                                                            //
638   ///////////////////////////////////////////////////////////////
639
640   // Rotation Matrices definition
641   Int_t irotpipe3, irotpipe4, irotpipe5;
642   //-- rotation matrices for the tilted cone after the TDI to recenter vacuum chamber      
643   gMC->Matrix(irotpipe3,90.-1.8934,0.,90.,90.,1.8934,180.);    
644   //-- rotation matrices for the tilted tube before and after the TDI 
645   gMC->Matrix(irotpipe4,90.-3.8,0.,90.,90.,3.8,180.);       
646   //-- rotation matrix for the tilted cone after the TDI
647   gMC->Matrix(irotpipe5,90.+9.8,0.,90.,90.,9.8,0.);     
648
649   // -- Mother of the ZDCs (Vacuum PCON)                
650   zd2 = 1910.22;// zd2 initial value
651   
652   conpar[0] = 0.;
653   conpar[1] = 360.;
654   conpar[2] = 2.;
655   conpar[3] = zd2;
656   conpar[4] = 0.;
657   conpar[5] = 55.;
658   conpar[6] = 13500.;
659   conpar[7] = 0.;
660   conpar[8] = 55.;
661   gMC->Gsvolu("ZDCA", "PCON", idtmed[10], conpar, 9);
662   gMC->Gspos("ZDCA", 1, "ALIC", 0., 0., 0., 0, "ONLY");
663   
664   // To avoid overlaps 1 micron are left between certain volumes!
665   Double_t dxNoOverlap = 0.0;
666   //zd2 += dxNoOverlap;  
667   
668   // BEAM PIPE from 19.10 m to inner triplet beginning (22.965 m)  
669   tubpar[0] = 6.0/2.;
670   tubpar[1] = 6.4/2.;
671   tubpar[2] = 386.28/2. - dxNoOverlap; 
672   gMC->Gsvolu("QA01", "TUBE", idtmed[7], tubpar, 3);
673   gMC->Gspos("QA01", 1, "ZDCA", 0., 0., tubpar[2]+zd2, 0, "ONLY");
674   // Ch.debug
675   //printf("    QA01 TUBE centred in %f from z = %1.2f to z= %1.2f (IT begin)\n",tubpar[2]+zd2,zd2,2*tubpar[2]+zd2);
676   
677   zd2 += 2.*tubpar[2];  
678
679   // -- FIRST SECTION OF THE BEAM PIPE (from beginning of inner triplet to
680   //    beginning of D1)  
681   tubpar[0] = 6.3/2.;
682   tubpar[1] = 6.7/2.;
683   tubpar[2] = 3541.8/2. - dxNoOverlap;
684   gMC->Gsvolu("QA02", "TUBE", idtmed[7], tubpar, 3);
685   gMC->Gspos("QA02", 1, "ZDCA", 0., 0., tubpar[2]+zd2, 0, "ONLY");
686   // Ch.debug
687   //printf("    QA02 TUBE from z = %1.2f to z= %1.2f (D1 begin)\n",zd2,2*tubpar[2]+zd2);
688   
689   zd2 += 2.*tubpar[2]; 
690   
691     
692   // -- SECOND SECTION OF THE BEAM PIPE (from the beginning of D1 to the beginning of D2)
693   //
694   //  FROM (MAGNETIC) BEGINNING OF D1 TO THE (MAGNETIC) END OF D1 + 126.5 cm
695   //  CYLINDRICAL PIPE of diameter increasing from 6.75 cm up to 8.0 cm
696   //  from magnetic end :
697   //  1) 80.1 cm still with ID = 6.75 radial beam screen
698   //  2) 2.5 cm conical section from ID = 6.75 to ID = 8.0 cm
699   //  3) 43.9 cm straight section (tube) with ID = 8.0 cm
700
701   tubpar[0] = 6.75/2.;
702   tubpar[1] = 7.15/2.;
703   tubpar[2] = (945.0+80.1)/2.;
704   gMC->Gsvolu("QA03", "TUBE", idtmed[7], tubpar, 3);
705   gMC->Gspos("QA03", 1, "ZDCA", 0., 0., tubpar[2]+zd2, 0, "ONLY");
706   // Ch.debug
707   //printf("    QA03 TUBE from z = %1.2f to z= %1.2f\n",zd2,2*tubpar[2]+zd2);
708   
709   zd2 += 2.*tubpar[2];
710
711   // Transition Cone from ID=67.5 mm  to ID=80 mm
712   conpar[0] = 2.5/2.;
713   conpar[1] = 6.75/2.;
714   conpar[2] = 7.15/2.;
715   conpar[3] = 8.0/2.;
716   conpar[4] = 8.4/2.;
717   gMC->Gsvolu("QA04", "CONE", idtmed[7], conpar, 5);
718   gMC->Gspos("QA04", 1, "ZDCA", 0., 0., conpar[0]+zd2, 0, "ONLY");
719   //printf("    QA04 CONE from z = %1.2f to z= %1.2f\n",zd2,2*conpar[0]+zd2);
720
721   zd2 += 2.*conpar[0];
722   
723   tubpar[0] = 8.0/2.;
724   tubpar[1] = 8.4/2.;
725   tubpar[2] = (43.9+20.+28.5+28.5)/2.;
726   gMC->Gsvolu("QA05", "TUBE", idtmed[7], tubpar, 3);
727   gMC->Gspos("QA05", 1, "ZDCA", 0., 0., tubpar[2]+zd2, 0, "ONLY");
728   // Ch.debug
729   //printf("    QA05 TUBE from z = %1.2f to z= %1.2f\n",zd2,2*tubpar[2]+zd2);
730   
731   zd2 += 2.*tubpar[2];
732
733   // Second section of VAEHI (transition cone from ID=80mm to ID=98mm)
734   conpar[0] = 4.0/2.;
735   conpar[1] = 8.0/2.;
736   conpar[2] = 8.4/2.;
737   conpar[3] = 9.8/2.;
738   conpar[4] = 10.2/2.;
739   gMC->Gsvolu("QAV1", "CONE", idtmed[7], conpar, 5);
740   gMC->Gspos("QAV1", 1, "ZDCA", 0., 0., conpar[0]+zd2, 0, "ONLY");
741   //printf("    QAV1 CONE from z = %1.2f to z= %1.2f\n",zd2,2*conpar[0]+zd2);
742
743   zd2 += 2.*conpar[0];
744   
745   //Third section of VAEHI (transition cone from ID=98mm to ID=90mm)
746   conpar[0] = 1.0/2.;
747   conpar[1] = 9.8/2.;
748   conpar[2] = 10.2/2.;
749   conpar[3] = 9.0/2.;
750   conpar[4] = 9.4/2.;
751   gMC->Gsvolu("QAV2", "CONE", idtmed[7], conpar, 5);
752   gMC->Gspos("QAV2", 1, "ZDCA", 0., 0., conpar[0]+zd2, 0, "ONLY");
753   //printf("    QAV2 CONE from z = %1.2f to z= %1.2f\n",zd2,2*conpar[0]+zd2);
754
755   zd2 += 2.*conpar[0];
756  
757   // Fourth section of VAEHI (tube ID=90mm)    
758   tubpar[0] = 9.0/2.;
759   tubpar[1] = 9.4/2.;
760   tubpar[2] = 31.0/2.;
761   gMC->Gsvolu("QAV3", "TUBE", idtmed[7], tubpar, 3);
762   gMC->Gspos("QAV3", 1, "ZDCA", 0., 0., tubpar[2]+zd2, 0, "ONLY");
763   // Ch.debug
764   //printf("    QAV3 TUBE from z = %1.2f to z= %1.2f\n",zd2,2*tubpar[2]+zd2);
765   
766   zd2 += 2.*tubpar[2]; 
767
768   //---------------------------- TCDD beginning ----------------------------------    
769   // space for the insertion of the collimator TCDD (2 m)
770   // TCDD ZONE - 1st volume
771   conpar[0] = 1.3/2.;
772   conpar[1] = 9.0/2.;
773   conpar[2] = 13.0/2.;
774   conpar[3] = 9.6/2.;
775   conpar[4] = 13.0/2.;
776   gMC->Gsvolu("Q01T", "CONE", idtmed[7], conpar, 5);
777   gMC->Gspos("Q01T", 1, "ZDCA", 0., 0., conpar[0]+zd2, 0, "ONLY");
778   //printf("    Q01T CONE from z = %1.2f to z= %1.2f\n",zd2,2*conpar[0]+zd2);
779
780   zd2 += 2.*conpar[0];  
781
782   // TCDD ZONE - 2nd volume    
783   tubpar[0] = 9.6/2.;
784   tubpar[1] = 10.0/2.;
785   tubpar[2] = 1.0/2.;
786   gMC->Gsvolu("Q02T", "TUBE", idtmed[7], tubpar, 3);
787   gMC->Gspos("Q02T", 1, "ZDCA", 0., 0., tubpar[2]+zd2, 0, "ONLY");
788   // Ch.debug
789   //printf("    Q02T TUBE from z = %1.2f to z= %1.2f\n",zd2,2*tubpar[2]+zd2);
790   
791   zd2 += 2.*tubpar[2]; 
792
793   // TCDD ZONE - third volume
794   conpar[0] = 9.04/2.;
795   conpar[1] = 9.6/2.;
796   conpar[2] = 10.0/2.;
797   conpar[3] = 13.8/2.;
798   conpar[4] = 14.2/2.;
799   gMC->Gsvolu("Q03T", "CONE", idtmed[7], conpar, 5);
800   gMC->Gspos("Q03T", 1, "ZDCA", 0., 0., conpar[0]+zd2, 0, "ONLY");
801   //printf("    Q03T CONE from z = %1.2f to z= %1.2f\n",zd2,2*conpar[0]+zd2);
802
803   zd2 += 2.*conpar[0];  
804
805   // TCDD ZONE - 4th volume    
806   tubpar[0] = 13.8/2.;
807   tubpar[1] = 14.2/2.;
808   tubpar[2] = 38.6/2.;
809   gMC->Gsvolu("Q04T", "TUBE", idtmed[7], tubpar, 3);
810   gMC->Gspos("Q04T", 1, "ZDCA", 0., 0., tubpar[2]+zd2, 0, "ONLY");
811   // Ch.debug
812   //printf("    Q04T TUBE from z = %1.2f to z= %1.2f\n",zd2,2*tubpar[2]+zd2);
813   
814   zd2 += 2.*tubpar[2]; 
815
816   // TCDD ZONE - 5th volume    
817   tubpar[0] = 21.0/2.;
818   tubpar[1] = 21.4/2.;
819   tubpar[2] = 100.12/2.;
820   gMC->Gsvolu("Q05T", "TUBE", idtmed[7], tubpar, 3);
821   gMC->Gspos("Q05T", 1, "ZDCA", 0., 0., tubpar[2]+zd2, 0, "ONLY");
822   // Ch.debug
823   //printf("    Q05T TUBE from z = %1.2f to z= %1.2f\n",zd2,2*tubpar[2]+zd2);
824
825   zd2 += 2.*tubpar[2]; 
826  
827   // TCDD ZONE - 6th volume    
828   tubpar[0] = 13.8/2.;
829   tubpar[1] = 14.2/2.;
830   tubpar[2] = 38.6/2.;
831   gMC->Gsvolu("Q06T", "TUBE", idtmed[7], tubpar, 3);
832   gMC->Gspos("Q06T", 1, "ZDCA", 0., 0., tubpar[2]+zd2, 0, "ONLY");
833   // Ch.debug
834   //printf("    Q06T TUBE from z = %1.2f to z= %1.2f\n",zd2,2*tubpar[2]+zd2);
835   
836   zd2 += 2.*tubpar[2];
837
838   // TCDD ZONE - 7th volume
839   conpar[0] = 11.34/2.;
840   conpar[1] = 13.8/2.;
841   conpar[2] = 14.2/2.;
842   conpar[3] = 18.0/2.;
843   conpar[4] = 18.4/2.;
844   gMC->Gsvolu("Q07T", "CONE", idtmed[7], conpar, 5);
845   gMC->Gspos("Q07T", 1, "ZDCA", 0., 0., conpar[0]+zd2, 0, "ONLY");
846   //printf("    Q07T CONE from z = %1.2f to z= %1.2f\n",zd2,2*conpar[0]+zd2);
847
848   zd2 += 2.*conpar[0];
849
850   // Upper section : one single phi segment of a tube 
851   //  5 parameters for tubs: inner radius = 0.,
852   //    outer radius = 7. cm, half length = 50 cm
853   //    phi1 = 0., phi2 = 180. 
854   tubspar[0] = 0.0/2.;
855   tubspar[1] = 14.0/2.;
856   tubspar[2] = 100.0/2.;
857   tubspar[3] = 0.;
858   tubspar[4] = 180.;  
859   gMC->Gsvolu("Q08T", "TUBS", idtmed[7], tubspar, 5);
860   // Ch.debug
861   //printf("    upper part : one single phi segment of a tube (Q08T)\n");  
862   
863   // rectangular beam pipe inside TCDD upper section (Vacuum)  
864   boxpar[0] = 7.0/2.;
865   boxpar[1] = 2.2/2.;
866   boxpar[2] = 100./2.;
867   gMC->Gsvolu("Q09T", "BOX ", idtmed[10], boxpar, 3);
868   // positioning vacuum box in the upper section of TCDD
869   gMC->Gspos("Q09T", 1, "Q08T", 0., 1.1,  0., 0, "ONLY");
870   
871   // lower section : one single phi segment of a tube       
872   tubspar[0] = 0.0/2.;
873   tubspar[1] = 14.0/2.;
874   tubspar[2] = 100.0/2.;
875   tubspar[3] = 180.;
876   tubspar[4] = 360.;  
877   gMC->Gsvolu("Q10T", "TUBS", idtmed[7], tubspar, 5);
878   // rectangular beam pipe inside TCDD lower section (Vacuum)  
879   boxpar[0] = 7.0/2.;
880   boxpar[1] = 2.2/2.;
881   boxpar[2] = 100./2.;
882   gMC->Gsvolu("Q11T", "BOX ", idtmed[10], boxpar, 3);
883   // positioning vacuum box in the lower section of TCDD
884   gMC->Gspos("Q11T", 1, "Q10T", 0., -1.1,  0., 0, "ONLY");  
885   
886   // positioning  TCDD elements in ZDCA, (inside TCDD volume)
887   gMC->Gspos("Q08T", 1, "ZDCA", 0., 2., -100.+zd2, 0, "ONLY");  
888   gMC->Gspos("Q10T", 1, "ZDCA", 0., -2., -100.+zd2, 0, "ONLY");  
889     
890   // RF screen 
891   boxpar[0] = 0.2/2.;
892   boxpar[1] = 4.0/2.;
893   boxpar[2] = 100./2.;
894   gMC->Gsvolu("Q12T", "BOX ", idtmed[7], boxpar, 3);  
895   // positioning RF screen at both sides of TCDD
896   gMC->Gspos("Q12T", 1, "ZDCA", tubspar[1]+boxpar[0], 0., -100.+zd2, 0, "ONLY");  
897   gMC->Gspos("Q12T", 2, "ZDCA", -tubspar[1]-boxpar[0], 0., -100.+zd2, 0, "ONLY");      
898   //---------------------------- TCDD end ---------------------------------------    
899
900   // The following elliptical tube 180 mm x 70 mm
901   // (obtained positioning the void QA09 in QA08)
902   // represents VMTSA (780 mm) + space reserved to the TCTVB (1480 mm)+ 
903   //            VMTSA (780 mm) + first part of VCTCP (93 mm)
904
905   tubpar[0] = 18.4/2.;
906   tubpar[1] = 7.4/2.;
907   tubpar[2] = 313.3/2.;
908   gMC->Gsvolu("QA06", "ELTU", idtmed[7], tubpar, 3);  
909   //printf("    QA06 TUBE from z = %1.2f to z= %1.2f\n",zd2,2*tubpar[2]+zd2);
910
911   tubpar[0] = 18.0/2.;
912   tubpar[1] = 7.0/2.;
913   tubpar[2] = 313.3/2.;
914   gMC->Gsvolu("QA07", "ELTU", idtmed[10], tubpar, 3);  
915   //printf("    QA07 TUBE from z = %1.2f to z= %1.2f\n",zd2,2*tubpar[2]+zd2);
916   gMC->Gspos("QA06", 1, "ZDCA", 0., 0., tubpar[2]+zd2, 0, "ONLY"); 
917   gMC->Gspos("QA07", 1, "QA06", 0., 0., 0., 0, "ONLY");  
918
919   zd2 += 2.*tubpar[2];
920       
921   // VCTCP second part: transition cone from ID=180 to ID=212.7 
922   conpar[0] = 31.5/2.;
923   conpar[1] = 18.0/2.;
924   conpar[2] = 18.6/2.;
925   conpar[3] = 21.27/2.;
926   conpar[4] = 21.87/2.;
927   gMC->Gsvolu("QA08", "CONE", idtmed[7], conpar, 5);
928   gMC->Gspos("QA08", 1, "ZDCA", 0., 0., conpar[0]+zd2, 0, "ONLY");
929   // Ch.debug  
930   //printf("    QA08 CONE from z = %Third part of VCTCR: tube (ID=196 mm) f to z = %f\n",zd2,2*conpar[0]+zd2);
931
932   zd2 += 2.*conpar[0];
933   
934   // Tube ID 212.7 mm
935   // Represents VCTCP third part (92 mm) + VCDWB (765 mm) + VMBGA (400 mm) +
936   //            VCDWE (300 mm) + VMBGA (400 mm)
937   tubpar[0] = 21.27/2.;
938   tubpar[1] = 21.87/2.;
939   tubpar[2] = 195.7/2.;
940   gMC->Gsvolu("QA09", "TUBE", idtmed[7], tubpar, 3);
941   gMC->Gspos("QA09", 1, "ZDCA", 0., 0., tubpar[2]+zd2, 0, "ONLY");
942   //printf("    QA09 TUBE from z = %1.2f to z= %1.2f\n",zd2,2*tubpar[2]+zd2);
943
944   zd2 += 2.*tubpar[2];
945
946   // skewed transition piece (ID=212.7 mm to 332 mm) (before TDI)   
947   conpar[0] = (50.0-0.73-1.13)/2.;
948   conpar[1] = 21.27/2.;
949   conpar[2] = 21.87/2.;
950   conpar[3] = 33.2/2.;
951   conpar[4] = 33.8/2.;
952   gMC->Gsvolu("QA10", "CONE", idtmed[7], conpar, 5);
953   gMC->Gspos("QA10", 1, "ZDCA", -1.66, 0., conpar[0]+0.73+zd2, irotpipe4, "ONLY");
954   // Ch.debug  
955   //printf("    QA10 skewed CONE from z = %1.2f to z= %1.2f\n",zd2,2*conpar[0]+0.73+1.13+zd2);
956
957   zd2 += 2.*conpar[0]+0.73+1.13;
958       
959   // Vacuum chamber containing TDI  
960   tubpar[0] = 0.;
961   tubpar[1] = 54.6/2.;
962   tubpar[2] = 540.0/2.;
963   gMC->Gsvolu("Q13TM", "TUBE", idtmed[10], tubpar, 3);
964   gMC->Gspos("Q13TM", 1, "ZDCA", 0., 0., tubpar[2]+zd2, 0, "ONLY");
965   tubpar[0] = 54.0/2.;
966   tubpar[1] = 54.6/2.;
967   tubpar[2] = 540.0/2.;
968   gMC->Gsvolu("Q13T", "TUBE", idtmed[7], tubpar, 3);
969   gMC->Gspos("Q13T", 1, "Q13TM", 0., 0., 0., 0, "ONLY");
970   // Ch.debug
971   //printf("    Q13T TUBE from z = %1.2f to z= %1.2f\n",zd2,2*tubpar[2]+zd2);
972
973   zd2 += 2.*tubpar[2];
974   
975   //---------------- INSERT TDI INSIDE Q13T -----------------------------------    
976   boxpar[0] = 11.0/2.;
977   boxpar[1] = 9.0/2.;
978   boxpar[2] = 540.0/2.;
979   gMC->Gsvolu("QTD1", "BOX ", idtmed[7], boxpar, 3);
980   gMC->Gspos("QTD1", 1, "Q13TM", -3.8, 10.5,  0., 0, "ONLY");
981   boxpar[0] = 11.0/2.;
982   boxpar[1] = 9.0/2.;
983   boxpar[2] = 540.0/2.;
984   gMC->Gsvolu("QTD2", "BOX ", idtmed[7], boxpar, 3);
985   gMC->Gspos("QTD2", 1, "Q13TM", -3.8, -10.5,  0., 0, "ONLY");  
986   boxpar[0] = 5.1/2.;
987   boxpar[1] = 0.2/2.;
988   boxpar[2] = 540.0/2.;
989   gMC->Gsvolu("QTD3", "BOX ", idtmed[7], boxpar, 3);
990   gMC->Gspos("QTD3", 1, "Q13TM", -3.8+5.5+boxpar[0], 6.1,  0., 0, "ONLY");  
991   gMC->Gspos("QTD3", 2, "Q13TM", -3.8+5.5+boxpar[0], -6.1,  0., 0, "ONLY"); 
992   gMC->Gspos("QTD3", 3, "Q13TM", -3.8-5.5-boxpar[0], 6.1,  0., 0, "ONLY");  
993   gMC->Gspos("QTD3", 4, "Q13TM", -3.8-5.5-boxpar[0], -6.1,  0., 0, "ONLY");  
994   //
995   tubspar[0] = 12.0/2.;
996   tubspar[1] = 12.4/2.;
997   tubspar[2] = 540.0/2.;
998   tubspar[3] = 90.;
999   tubspar[4] = 270.;  
1000   gMC->Gsvolu("QTD4", "TUBS", idtmed[7], tubspar, 5);
1001   gMC->Gspos("QTD4", 1, "Q13TM", -3.8-10.6, 0.,  0., 0, "ONLY");
1002   tubspar[0] = 12.0/2.;
1003   tubspar[1] = 12.4/2.;
1004   tubspar[2] = 540.0/2.;
1005   tubspar[3] = -90.;
1006   tubspar[4] = 90.;  
1007   gMC->Gsvolu("QTD5", "TUBS", idtmed[7], tubspar, 5);
1008   gMC->Gspos("QTD5", 1, "Q13TM", -3.8+10.6, 0.,  0., 0, "ONLY"); 
1009   //---------------- END DEFINING TDI INSIDE Q13T -------------------------------
1010   
1011   // VCTCG skewed transition piece (ID=332 mm to 212.7 mm) (after TDI)
1012   conpar[0] = (50.0-2.92-1.89)/2.;
1013   conpar[1] = 33.2/2.;
1014   conpar[2] = 33.8/2.;
1015   conpar[3] = 21.27/2.;
1016   conpar[4] = 21.87/2.;
1017   gMC->Gsvolu("QA11", "CONE", idtmed[7], conpar, 5);
1018   gMC->Gspos("QA11", 1, "ZDCA", 4.32-3.8, 0., conpar[0]+2.92+zd2, irotpipe5, "ONLY");
1019   // Ch.debug  
1020   //printf("    QA11 skewed CONE from z = %f to z =%f\n",zd2,2*conpar[0]+2.92+1.89+zd2);
1021
1022   zd2 += 2.*conpar[0]+2.92+1.89;
1023   
1024   // The following tube ID 212.7 mm  
1025   // represents VMBGA (400 mm) + VCDWE (300 mm) + VMBGA (400 mm) +
1026   //            BTVTS (600 mm) + VMLGB (400 mm)  
1027   tubpar[0] = 21.27/2.;
1028   tubpar[1] = 21.87/2.;
1029   tubpar[2] = 210.0/2.;
1030   gMC->Gsvolu("QA12", "TUBE", idtmed[7], tubpar, 3);
1031   gMC->Gspos("QA12", 1, "ZDCA", 4., 0., tubpar[2]+zd2, 0, "ONLY");
1032   // Ch.debug
1033   //printf("    QA12 TUBE from z = %1.2f to z= %1.2f\n",zd2,2*tubpar[2]+zd2);
1034
1035   zd2 += 2.*tubpar[2];  
1036   
1037   // First part of VCTCC
1038   // skewed transition cone from ID=212.7 mm to ID=797 mm
1039   conpar[0] = (121.0-0.37-1.35)/2.;
1040   conpar[1] = 21.27/2.;
1041   conpar[2] = 21.87/2.;
1042   conpar[3] = 79.7/2.;
1043   conpar[4] = 81.3/2.;
1044   gMC->Gsvolu("QA13", "CONE", idtmed[7], conpar, 5);
1045   gMC->Gspos("QA13", 1, "ZDCA", 4.-2., 0., conpar[0]+0.37+zd2, irotpipe3, "ONLY");
1046   // Ch.debug  
1047   //printf("    QA13 CONE from z = %1.2f to z= %1.2f\n",zd2,2*conpar[0]+0.37+1.35+zd2);
1048
1049   zd2 += 2.*conpar[0]+0.37+1.35;
1050   
1051   // The following tube ID 797 mm  --- (volume QA16)
1052   // represents the second part of VCTCC (4272 mm) + 
1053   //            4 x VCDGA (4 x 4272 mm) + 
1054   //            the first part of VCTCR (850 mm)
1055   tubpar[0] = 79.7/2.;
1056   tubpar[1] = 81.3/2.;
1057   tubpar[2] = 2221./2.;
1058   gMC->Gsvolu("QA14", "TUBE", idtmed[7], tubpar, 3);
1059   gMC->Gspos("QA14", 1, "ZDCA", 0., 0., tubpar[2]+zd2, 0, "ONLY");
1060   // Ch.debug  
1061   //printf("    QA14 TUBE from z = %1.2f to z= %1.2f\n",zd2,2*tubpar[2]+zd2);
1062
1063   zd2 += 2.*tubpar[2];
1064         
1065   // Second part of VCTCR
1066   // Transition from ID=797 mm to ID=196 mm:
1067   // in order to simulate the thin window opened in the transition cone
1068   // we divide the transition cone in three cones:
1069   // (1) 8 mm thick (2) 3 mm thick (3) the third 8 mm thick
1070   
1071   // (1) 8 mm thick
1072   conpar[0] = 9.09/2.; // 15 degree
1073   conpar[1] = 79.7/2.;
1074   conpar[2] = 81.3/2.; // thickness 8 mm  
1075   conpar[3] = 74.82868/2.;
1076   conpar[4] = 76.42868/2.; // thickness 8 mm 
1077   gMC->Gsvolu("QA15", "CONE", idtmed[7], conpar, 5);
1078   gMC->Gspos("QA15", 1, "ZDCA", 0., 0., conpar[0]+zd2, 0, "ONLY");
1079   //printf("    QA15 CONE from z = %1.2f to z= %1.2f\n",zd2,2*conpar[0]+zd2);
1080
1081   zd2 += 2.*conpar[0];  
1082
1083   // (2) 3 mm thick
1084   conpar[0] = 96.2/2.; // 15 degree
1085   conpar[1] = 74.82868/2.;
1086   conpar[2] = 75.42868/2.; // thickness 3 mm  
1087   conpar[3] = 23.19588/2.;
1088   conpar[4] = 23.79588/2.; // thickness 3 mm 
1089   gMC->Gsvolu("QA16", "CONE", idtmed[7], conpar, 5);
1090   gMC->Gspos("QA16", 1, "ZDCA", 0., 0., conpar[0]+zd2, 0, "ONLY");  
1091   //printf("    QA16 CONE from z = %1.2f to z= %1.2f\n",zd2,2*conpar[0]+zd2);
1092
1093   zd2 += 2.*conpar[0];
1094   
1095   // (3) 8 mm thick
1096   conpar[0] = 6.71/2.; // 15 degree
1097   conpar[1] = 23.19588/2.;
1098   conpar[2] = 24.79588/2.;// thickness 8 mm 
1099   conpar[3] = 19.6/2.;
1100   conpar[4] = 21.2/2.;// thickness 8 mm 
1101   gMC->Gsvolu("QA17", "CONE", idtmed[7], conpar, 5);
1102   gMC->Gspos("QA17", 1, "ZDCA", 0., 0., conpar[0]+zd2, 0, "ONLY");
1103   //printf("    QA19 CONE from z = %1.2f to z= %1.2f\n",zd2,2*conpar[0]+zd2);
1104
1105   zd2 += 2.*conpar[0];
1106  
1107   // Third part of VCTCR: tube (ID=196 mm)  
1108   tubpar[0] = 19.6/2.;
1109   tubpar[1] = 21.2/2.;
1110   tubpar[2] = 9.55/2.;
1111   gMC->Gsvolu("QA18", "TUBE", idtmed[7], tubpar, 3);
1112   gMC->Gspos("QA18", 1, "ZDCA", 0., 0., tubpar[2]+zd2, 0, "ONLY");
1113   // Ch.debug  
1114   //printf("    QA18 TUBE from z = %1.2f to z= %1.2f\n",zd2,2*tubpar[2]+zd2);
1115
1116   zd2 += 2.*tubpar[2];  
1117   
1118   // Flange (ID=196 mm) (last part of VCTCR and first part of VMZAR)
1119   tubpar[0] = 19.6/2.;
1120   tubpar[1] = 25.3/2.;
1121   tubpar[2] = 4.9/2.;
1122   gMC->Gsvolu("QF01", "TUBE", idtmed[7], tubpar, 3);
1123   gMC->Gspos("QF01", 1, "ZDCA", 0., 0., tubpar[2]+zd2, 0, "ONLY");
1124   // Ch.debug  
1125   //printf("    QF01  TUBE from z = %1.2f to z= %1.2f\n",zd2,2*tubpar[2]+zd2);
1126
1127   zd2 += 2.*tubpar[2];
1128   
1129   // VMZAR (5 volumes)  
1130   tubpar[0] = 20.2/2.;
1131   tubpar[1] = 20.6/2.;
1132   tubpar[2] = 2.15/2.;
1133   gMC->Gsvolu("QA19", "TUBE", idtmed[7], tubpar, 3);
1134   gMC->Gspos("QA19", 1, "ZDCA", 0., 0., tubpar[2]+zd2, 0, "ONLY");
1135   // Ch.debug  
1136   //printf("    QA19  TUBE from z = %1.2f to z= %1.2f\n",zd2,2*tubpar[2]+zd2);
1137
1138   zd2 += 2.*tubpar[2];
1139   
1140   conpar[0] = 6.9/2.;
1141   conpar[1] = 20.2/2.;
1142   conpar[2] = 20.6/2.;
1143   conpar[3] = 23.9/2.;
1144   conpar[4] = 24.3/2.;
1145   gMC->Gsvolu("QA20", "CONE", idtmed[7], conpar, 5);
1146   gMC->Gspos("QA20", 1, "ZDCA", 0., 0., conpar[0]+zd2, 0, "ONLY");
1147   // Ch.debug  
1148   //printf("    QA20 CONE from z = %1.2f to z= %1.2f\n",zd2,2*conpar[0]+zd2);
1149
1150   zd2 += 2.*conpar[0];
1151
1152   tubpar[0] = 23.9/2.;
1153   tubpar[1] = 25.5/2.;
1154   tubpar[2] = 17.0/2.;
1155   gMC->Gsvolu("QA21", "TUBE", idtmed[7], tubpar, 3);
1156   gMC->Gspos("QA21", 1, "ZDCA", 0., 0., tubpar[2]+zd2, 0, "ONLY");
1157   // Ch.debug  
1158   //printf("    QA21  TUBE from z = %1.2f to z= %1.2f\n",zd2,2*tubpar[2]+zd2);
1159
1160   zd2 += 2.*tubpar[2];
1161   
1162   conpar[0] = 6.9/2.;
1163   conpar[1] = 23.9/2.;
1164   conpar[2] = 24.3/2.;
1165   conpar[3] = 20.2/2.;
1166   conpar[4] = 20.6/2.;
1167   gMC->Gsvolu("QA22", "CONE", idtmed[7], conpar, 5);
1168   gMC->Gspos("QA22", 1, "ZDCA", 0., 0., conpar[0]+zd2, 0, "ONLY");
1169   // Ch.debug  
1170   //printf("    QA22 CONE from z = %1.2f to z= %1.2f\n",zd2,2*conpar[0]+zd2);
1171
1172   zd2 += 2.*conpar[0];
1173   
1174   tubpar[0] = 20.2/2.;
1175   tubpar[1] = 20.6/2.;
1176   tubpar[2] = 2.15/2.;
1177   gMC->Gsvolu("QA23", "TUBE", idtmed[7], tubpar, 3);
1178   gMC->Gspos("QA23", 1, "ZDCA", 0., 0., tubpar[2]+zd2, 0, "ONLY");
1179   // Ch.debug  
1180   //printf("    QA23  TUBE from z = %1.2f to z= %1.2f\n",zd2,2*tubpar[2]+zd2);
1181
1182   zd2 += 2.*tubpar[2];
1183   
1184   // Flange (ID=196 mm)(last part of VMZAR and first part of VCTYD)
1185   tubpar[0] = 19.6/2.;
1186   tubpar[1] = 25.3/2.;
1187   tubpar[2] = 4.9/2.;
1188   gMC->Gsvolu("QF02", "TUBE", idtmed[7], tubpar, 3);
1189   gMC->Gspos("QF02", 1, "ZDCA", 0., 0., tubpar[2]+zd2, 0, "ONLY");
1190   // Ch.debug  
1191   //printf("    QF02 TUBE from z = %1.2f to z= %1.2f\n",zd2,2*tubpar[2]+zd2);
1192
1193   zd2 += 2.*tubpar[2];
1194   
1195   // simulation of the trousers (VCTYB)     
1196   tubpar[0] = 19.6/2.;
1197   tubpar[1] = 20.0/2.;
1198   tubpar[2] = 3.9/2.;
1199   gMC->Gsvolu("QA24", "TUBE", idtmed[7], tubpar, 3);
1200   gMC->Gspos("QA24", 1, "ZDCA", 0., 0., tubpar[2]+zd2, 0, "ONLY");
1201   // Ch.debug
1202   //printf("    QA24  TUBE from z = %1.2f to z= %1.2f\n",zd2,2*tubpar[2]+zd2);
1203
1204   zd2 += 2.*tubpar[2];
1205
1206   // transition cone from ID=196. to ID=216.6
1207   conpar[0] = 32.55/2.;
1208   conpar[1] = 19.6/2.;
1209   conpar[2] = 20.0/2.;
1210   conpar[3] = 21.66/2.;
1211   conpar[4] = 22.06/2.;
1212   gMC->Gsvolu("QA25", "CONE", idtmed[7], conpar, 5);
1213   gMC->Gspos("QA25", 1, "ZDCA", 0., 0., conpar[0]+zd2, 0, "ONLY");
1214   // Ch.debug  
1215   //printf("    QA25 CONE from z = %1.2f to z= %1.2f\n",zd2,2*conpar[0]+zd2);
1216
1217   zd2 += 2.*conpar[0]; 
1218   
1219   // tube  
1220   tubpar[0] = 21.66/2.;
1221   tubpar[1] = 22.06/2.;
1222   tubpar[2] = 28.6/2.;
1223   gMC->Gsvolu("QA26", "TUBE", idtmed[7], tubpar, 3);
1224   gMC->Gspos("QA26", 1, "ZDCA", 0., 0., tubpar[2]+zd2, 0, "ONLY");
1225   // Ch.debug 
1226   //printf("    QA26  TUBE from z = %1.2f to z= %1.2f\n",zd2,2*tubpar[2]+zd2);
1227
1228   zd2 += 2.*tubpar[2];
1229
1230   // --------------------------------------------------------
1231   // RECOMBINATION CHAMBER IMPLEMENTED USING TGeo CLASSES!!!!
1232   // author: Chiara (June 2008)
1233   // --------------------------------------------------------
1234   // TRANSFORMATION MATRICES
1235   // Combi transformation: 
1236   dx = -3.970000;
1237   dy = 0.000000;
1238   dz = 0.0;
1239   // Rotation: 
1240   thx = 84.989100;   phx = 0.000000;
1241   thy = 90.000000;   phy = 90.000000;
1242   thz = 5.010900;    phz = 180.000000;
1243   TGeoRotation *rotMatrix1 = new TGeoRotation("",thx,phx,thy,phy,thz,phz);
1244   // Combi transformation: 
1245   dx = -3.970000;
1246   dy = 0.000000;
1247   dz = 0.0;
1248   TGeoCombiTrans *rotMatrix2 = new TGeoCombiTrans("ZDC_c1", dx,dy,dz,rotMatrix1);
1249   rotMatrix2->RegisterYourself();
1250   // Combi transformation: 
1251   dx = 3.970000;
1252   dy = 0.000000;
1253   dz = 0.0;
1254   // Rotation: 
1255   thx = 95.010900;   phx = 0.000000;
1256   thy = 90.000000;   phy = 90.000000;
1257   thz = 5.010900;    phz = 0.000000;
1258   TGeoRotation *rotMatrix3 = new TGeoRotation("",thx,phx,thy,phy,thz,phz);
1259   TGeoCombiTrans *rotMatrix4 = new TGeoCombiTrans("ZDC_c2", dx,dy,dz,rotMatrix3);
1260   rotMatrix4->RegisterYourself();
1261   
1262   
1263   // VOLUMES DEFINITION
1264   // Volume: ZDCA
1265   TGeoVolume *pZDCA = gGeoManager->GetVolume("ZDCA");
1266   
1267   conpar[0] = (90.1-0.95-0.26)/2.;
1268   conpar[1] = 0.0/2.;
1269   conpar[2] = 21.6/2.;
1270   conpar[3] = 0.0/2.;
1271   conpar[4] = 5.8/2.;
1272   new TGeoCone("QALext", conpar[0],conpar[1],conpar[2],conpar[3],conpar[4]);
1273   
1274   conpar[0] = (90.1-0.95-0.26)/2.;
1275   conpar[1] = 0.0/2.;
1276   conpar[2] = 21.2/2.;
1277   conpar[3] = 0.0/2.;
1278   conpar[4] = 5.4/2.;
1279   new TGeoCone("QALint", conpar[0],conpar[1],conpar[2],conpar[3],conpar[4]);
1280
1281   // Outer trousers
1282   TGeoCompositeShape *pOutTrousers = new TGeoCompositeShape("outTrousers", "QALext:ZDC_c1+QALext:ZDC_c2");
1283   
1284   // Volume: QALext
1285   //TGeoMedium *medZDCFe = gGeoManager->GetMedium("ZDC_ZIRON");
1286   TGeoVolume *pQALext = new TGeoVolume("QALext",pOutTrousers, medZDCFe);
1287   pQALext->SetLineColor(kBlue);
1288   pQALext->SetVisLeaves(kTRUE);
1289   //
1290   TGeoTranslation *tr1 = new TGeoTranslation(0., 0., (Double_t) conpar[0]+0.95+zd2);
1291   pZDCA->AddNode(pQALext, 1, tr1);
1292   // Inner trousers
1293   TGeoCompositeShape *pIntTrousers = new TGeoCompositeShape("intTrousers", "QALint:ZDC_c1+QALint:ZDC_c2");
1294   // Volume: QALint
1295   //TGeoMedium *medZDCvoid = gGeoManager->GetMedium("ZDC_ZVOID");
1296   TGeoVolume *pQALint = new TGeoVolume("QALint",pIntTrousers, medZDCvoid);
1297   pQALint->SetLineColor(kAzure);
1298   pQALint->SetVisLeaves(kTRUE);
1299   pQALext->AddNode(pQALint, 1);
1300     
1301   zd2 += 90.1;
1302   
1303   //  second section : 2 tubes (ID = 54. OD = 58.)  
1304   tubpar[0] = 5.4/2.;
1305   tubpar[1] = 5.8/2.;
1306   tubpar[2] = 40.0/2.;
1307   gMC->Gsvolu("QA27", "TUBE", idtmed[7], tubpar, 3);
1308   gMC->Gspos("QA27", 1, "ZDCA", -15.8/2., 0., tubpar[2]+zd2, 0, "ONLY");
1309   gMC->Gspos("QA27", 2, "ZDCA",  15.8/2., 0., tubpar[2]+zd2, 0, "ONLY");  
1310   // Ch.debug
1311   //printf("    QA27 TUBE from z = %1.2f to z= %1.2f\n",zd2,2*tubpar[2]+zd2);
1312   
1313   zd2 += 2.*tubpar[2];
1314  
1315   // transition x2zdc to recombination chamber : skewed cone  
1316   conpar[0] = (10.-1.)/2.;
1317   conpar[1] = 5.4/2.;
1318   conpar[2] = 5.8/2.;
1319   conpar[3] = 6.3/2.;
1320   conpar[4] = 7.0/2.;
1321   gMC->Gsvolu("QA28", "CONE", idtmed[7], conpar, 5); 
1322   gMC->Gspos("QA28", 1, "ZDCA", -7.9-0.175, 0., conpar[0]+0.5+zd2, irotpipe1, "ONLY");
1323   gMC->Gspos("QA28", 2, "ZDCA", 7.9+0.175, 0., conpar[0]+0.5+zd2, irotpipe2, "ONLY");
1324   //printf("    QA28 CONE from z = %1.2f to z= %1.2f\n",zd2,2*conpar[0]+0.2+zd2);
1325
1326   zd2 += 2.*conpar[0]+1.;
1327   
1328   // 2 tubes (ID = 63 mm OD=70 mm)      
1329   tubpar[0] = 6.3/2.;
1330   tubpar[1] = 7.0/2.;
1331   tubpar[2] = (342.5+498.3)/2.;
1332   gMC->Gsvolu("QA29", "TUBE", idtmed[7], tubpar, 3);
1333   gMC->Gspos("QA29", 1, "ZDCA", -16.5/2., 0., tubpar[2]+zd2, 0, "ONLY");
1334   gMC->Gspos("QA29", 2, "ZDCA",  16.5/2., 0., tubpar[2]+zd2, 0, "ONLY");
1335   //printf("    QA29 TUBE from z = %1.2f to z= %1.2f\n",zd2,2*tubpar[2]+zd2);  
1336
1337   zd2 += 2.*tubpar[2];
1338            
1339   // -- Luminometer (Cu box) in front of ZN - side A
1340   boxpar[0] = 8.0/2.;
1341   boxpar[1] = 8.0/2.;
1342   boxpar[2] = 15./2.;
1343   gMC->Gsvolu("QLUA", "BOX ", idtmed[9], boxpar, 3);
1344   gMC->Gspos("QLUA", 1, "ZDCA", 0., 0.,  fPosZNA[2]-66.-boxpar[2], 0, "ONLY");
1345   //printf("    QLUA LUMINOMETER from z = %1.2f to z= %1.2f\n\n",  fPosZNA[2]-66., fPosZNA[2]-66.-2*boxpar[2]);
1346
1347   //printf("    END OF BEAM PIPE VOLUME DEFINITION AT z = %f\n",zd2);
1348   
1349
1350   // ----------------------------------------------------------------
1351   // --  MAGNET DEFINITION  -> LHC OPTICS 6.5  
1352   // ----------------------------------------------------------------      
1353   // ***************************************************************  
1354   //            SIDE C - RB26  (dimuon side) 
1355   // ***************************************************************   
1356   // --  COMPENSATOR DIPOLE (MBXW)
1357   zCorrDip = 1972.5;   
1358   
1359   // --  GAP (VACUUM WITH MAGNETIC FIELD)
1360   tubpar[0] = 0.;
1361   tubpar[1] = 3.14;
1362   tubpar[2] = 153./2.;
1363   gMC->Gsvolu("MBXW", "TUBE", idtmed[11], tubpar, 3);
1364
1365   // --  YOKE 
1366   tubpar[0] = 4.5;
1367   tubpar[1] = 55.;
1368   tubpar[2] = 153./2.;
1369   gMC->Gsvolu("YMBX", "TUBE", idtmed[7], tubpar, 3);
1370
1371   gMC->Gspos("MBXW", 1, "ZDCC", 0., 0., -tubpar[2]-zCorrDip, 0, "ONLY");
1372   gMC->Gspos("YMBX", 1, "ZDCC", 0., 0., -tubpar[2]-zCorrDip, 0, "ONLY");
1373   
1374   
1375   // -- INNER TRIPLET 
1376   zInnTrip = 2296.5; 
1377
1378   // -- DEFINE MQXL AND MQX QUADRUPOLE ELEMENT 
1379   // --  MQXL 
1380   // --  GAP (VACUUM WITH MAGNETIC FIELD) 
1381   tubpar[0] = 0.;
1382   tubpar[1] = 3.14;
1383   tubpar[2] = 637./2.;
1384   gMC->Gsvolu("MQXL", "TUBE", idtmed[11], tubpar, 3);
1385     
1386   // --  YOKE 
1387   tubpar[0] = 3.5;
1388   tubpar[1] = 22.;
1389   tubpar[2] = 637./2.;
1390   gMC->Gsvolu("YMQL", "TUBE", idtmed[7], tubpar, 3);
1391   
1392   gMC->Gspos("MQXL", 1, "ZDCC", 0., 0., -tubpar[2]-zInnTrip, 0, "ONLY");
1393   gMC->Gspos("YMQL", 1, "ZDCC", 0., 0., -tubpar[2]-zInnTrip, 0, "ONLY");
1394   
1395   gMC->Gspos("MQXL", 2, "ZDCC", 0., 0., -tubpar[2]-zInnTrip-2400., 0, "ONLY");
1396   gMC->Gspos("YMQL", 2, "ZDCC", 0., 0., -tubpar[2]-zInnTrip-2400., 0, "ONLY");
1397   
1398   // --  MQX 
1399   // --  GAP (VACUUM WITH MAGNETIC FIELD) 
1400   tubpar[0] = 0.;
1401   tubpar[1] = 3.14;
1402   tubpar[2] = 550./2.;
1403   gMC->Gsvolu("MQX ", "TUBE", idtmed[11], tubpar, 3);
1404   
1405   // --  YOKE 
1406   tubpar[0] = 3.5;
1407   tubpar[1] = 22.;
1408   tubpar[2] = 550./2.;
1409   gMC->Gsvolu("YMQ ", "TUBE", idtmed[7], tubpar, 3);
1410   
1411   gMC->Gspos("MQX ", 1, "ZDCC", 0., 0., -tubpar[2]-zInnTrip-908.5,  0, "ONLY");
1412   gMC->Gspos("YMQ ", 1, "ZDCC", 0., 0., -tubpar[2]-zInnTrip-908.5,  0, "ONLY");
1413   
1414   gMC->Gspos("MQX ", 2, "ZDCC", 0., 0., -tubpar[2]-zInnTrip-1558.5, 0, "ONLY");
1415   gMC->Gspos("YMQ ", 2, "ZDCC", 0., 0., -tubpar[2]-zInnTrip-1558.5, 0, "ONLY");
1416   
1417   // -- SEPARATOR DIPOLE D1 
1418   zD1 = 5838.3001;
1419   
1420   // --  GAP (VACUUM WITH MAGNETIC FIELD) 
1421   tubpar[0] = 0.;
1422   tubpar[1] = 3.46;
1423   tubpar[2] = 945./2.;
1424   gMC->Gsvolu("MD1 ", "TUBE", idtmed[11], tubpar, 3);
1425   
1426   // --  Insert horizontal Cu plates inside D1 
1427   // --   (to simulate the vacuum chamber)
1428   boxpar[0] = TMath::Sqrt(tubpar[1]*tubpar[1]-(2.98+0.2)*(2.98+0.2)) - 0.05;
1429   boxpar[1] = 0.2/2.;
1430   boxpar[2] = 945./2.;
1431   gMC->Gsvolu("MD1V", "BOX ", idtmed[6], boxpar, 3);
1432   gMC->Gspos("MD1V", 1, "MD1 ", 0., 2.98+boxpar[1], 0., 0, "ONLY");
1433   gMC->Gspos("MD1V", 2, "MD1 ", 0., -2.98-boxpar[1], 0., 0, "ONLY");
1434     
1435   // --  YOKE 
1436   tubpar[0] = 3.68;
1437   tubpar[1] = 110./2.;
1438   tubpar[2] = 945./2.;
1439   gMC->Gsvolu("YD1 ", "TUBE", idtmed[7], tubpar, 3);
1440   
1441   gMC->Gspos("YD1 ", 1, "ZDCC", 0., 0., -tubpar[2]-zD1, 0, "ONLY");
1442   gMC->Gspos("MD1 ", 1, "ZDCC", 0., 0., -tubpar[2]-zD1, 0, "ONLY");
1443   // Ch debug
1444   //printf("    MD1 from z = %1.2f to z= %1.2f cm\n",-zD1, -zD1-2*tubpar[2]); 
1445   
1446   // -- DIPOLE D2 
1447   zD2 = 12167.8;
1448   // --  GAP (VACUUM WITH MAGNETIC FIELD) 
1449   tubpar[0] = 0.;
1450   tubpar[1] = 7.5/2.;
1451   tubpar[2] = 945./2.;
1452   gMC->Gsvolu("MD2 ", "TUBE", idtmed[11], tubpar, 3);
1453   
1454   // --  YOKE 
1455   tubpar[0] = 0.;
1456   tubpar[1] = 55.;
1457   tubpar[2] = 945./2.;
1458   gMC->Gsvolu("YD2 ", "TUBE", idtmed[7], tubpar, 3);
1459   
1460   gMC->Gspos("YD2 ", 1, "ZDCC", 0., 0., -tubpar[2]-zD2, 0, "ONLY");
1461   // Ch debug
1462   //printf("    YD2 from z = %1.2f to z= %1.2f cm\n",-zD2, -zD2-2*tubpar[2]); 
1463   
1464   gMC->Gspos("MD2 ", 1, "YD2 ", -9.4, 0., 0., 0, "ONLY");
1465   gMC->Gspos("MD2 ", 2, "YD2 ",  9.4, 0., 0., 0, "ONLY");
1466   
1467   // ***************************************************************  
1468   //            SIDE A - RB24 
1469   // ***************************************************************
1470   
1471   // COMPENSATOR DIPOLE (MCBWA) (2nd compensator)
1472   // --  GAP (VACUUM WITH MAGNETIC FIELD) 
1473   tubpar[0] = 0.;
1474   tubpar[1] = 3.;  
1475   tubpar[2] = 153./2.;
1476   gMC->Gsvolu("MCBW", "TUBE", idtmed[11], tubpar, 3);  
1477   gMC->Gspos("MCBW", 1, "ZDCA", 0., 0., tubpar[2]+zCorrDip, 0, "ONLY");
1478     
1479    // --  YOKE 
1480   tubpar[0] = 4.5;
1481   tubpar[1] = 55.;
1482   tubpar[2] = 153./2.;
1483   gMC->Gsvolu("YMCB", "TUBE", idtmed[7], tubpar, 3);
1484   gMC->Gspos("YMCB", 1, "ZDCA", 0., 0., tubpar[2]+zCorrDip, 0, "ONLY");  
1485   
1486    // -- INNER TRIPLET 
1487   // -- DEFINE MQX1 AND MQX2 QUADRUPOLE ELEMENT 
1488   // --  MQX1 
1489   // --  GAP (VACUUM WITH MAGNETIC FIELD) 
1490   tubpar[0] = 0.;
1491   tubpar[1] = 3.14;
1492   tubpar[2] = 637./2.;
1493   gMC->Gsvolu("MQX1", "TUBE", idtmed[11], tubpar, 3);
1494   gMC->Gsvolu("MQX4", "TUBE", idtmed[11], tubpar, 3);
1495     
1496   // --  YOKE 
1497   tubpar[0] = 3.5;
1498   tubpar[1] = 22.;
1499   tubpar[2] = 637./2.;
1500   gMC->Gsvolu("YMQ1", "TUBE", idtmed[7], tubpar, 3);
1501
1502   // -- Q1
1503   gMC->Gspos("MQX1", 1, "ZDCA", 0., 0., tubpar[2]+zInnTrip, 0, "ONLY");
1504   gMC->Gspos("YMQ1", 1, "ZDCA", 0., 0., tubpar[2]+zInnTrip, 0, "ONLY");
1505
1506    // -- BEAM SCREEN FOR Q1
1507    tubpar[0] = 4.78/2.;
1508    tubpar[1] = 5.18/2.;
1509    tubpar[2] = 637./2.;
1510    gMC->Gsvolu("QBS1", "TUBE", idtmed[6], tubpar, 3);
1511    gMC->Gspos("QBS1", 1, "MQX1", 0., 0., 0., 0, "ONLY");
1512    // INSERT VERTICAL PLATE INSIDE Q1
1513    boxpar[0] = 0.2/2.0;
1514    boxpar[1] = TMath::Sqrt(tubpar[0]*tubpar[0]-(1.9+0.2)*(1.9+0.2));
1515    boxpar[2] =637./2.;
1516    gMC->Gsvolu("QBS2", "BOX ", idtmed[6], boxpar, 3);
1517    gMC->Gspos("QBS2", 1, "MQX1", 1.9+boxpar[0], 0., 0., 0, "ONLY");
1518    gMC->Gspos("QBS2", 2, "MQX1", -1.9-boxpar[0], 0., 0., 0, "ONLY");
1519
1520    // -- Q3   
1521    gMC->Gspos("MQX4", 1, "ZDCA", 0., 0., tubpar[2]+zInnTrip+2400., 0, "ONLY");
1522    gMC->Gspos("YMQ1", 2, "ZDCA", 0., 0., tubpar[2]+zInnTrip+2400., 0, "ONLY");
1523
1524    // -- BEAM SCREEN FOR Q3
1525    tubpar[0] = 5.79/2.;
1526    tubpar[1] = 6.14/2.;
1527    tubpar[2] = 637./2.;
1528    gMC->Gsvolu("QBS3", "TUBE", idtmed[6], tubpar, 3);
1529    gMC->Gspos("QBS3", 1, "MQX4", 0., 0., 0., 0, "ONLY");
1530    // INSERT VERTICAL PLATE INSIDE Q3
1531    boxpar[0] = 0.2/2.0;
1532    boxpar[1] = TMath::Sqrt(tubpar[0]*tubpar[0]-(2.405+0.2)*(2.405+0.2));
1533    boxpar[2] =637./2.;
1534    gMC->Gsvolu("QBS4", "BOX ", idtmed[6], boxpar, 3);
1535    gMC->Gspos("QBS4", 1, "MQX4", 2.405+boxpar[0], 0., 0., 0, "ONLY");
1536    gMC->Gspos("QBS4", 2, "MQX4", -2.405-boxpar[0], 0., 0., 0, "ONLY");
1537     
1538   
1539   
1540   // --  MQX2
1541   // --  GAP (VACUUM WITH MAGNETIC FIELD) 
1542   tubpar[0] = 0.;
1543   tubpar[1] = 3.14;
1544   tubpar[2] = 550./2.;
1545   gMC->Gsvolu("MQX2", "TUBE", idtmed[11], tubpar, 3);
1546   gMC->Gsvolu("MQX3", "TUBE", idtmed[11], tubpar, 3);
1547   
1548   // --  YOKE 
1549   tubpar[0] = 3.5;
1550   tubpar[1] = 22.;
1551   tubpar[2] = 550./2.;
1552   gMC->Gsvolu("YMQ2", "TUBE", idtmed[7], tubpar, 3);
1553
1554    // -- BEAM SCREEN FOR Q2
1555    tubpar[0] = 5.79/2.;
1556    tubpar[1] = 6.14/2.;
1557    tubpar[2] = 550./2.;
1558    gMC->Gsvolu("QBS5", "TUBE", idtmed[6], tubpar, 3);
1559    //    VERTICAL PLATE INSIDE Q2
1560    boxpar[0] = 0.2/2.0;
1561    boxpar[1] = TMath::Sqrt(tubpar[0]*tubpar[0]-(2.405+0.2)*(2.405+0.2));
1562    boxpar[2] =550./2.;
1563    gMC->Gsvolu("QBS6", "BOX ", idtmed[6], boxpar, 3);
1564
1565   // -- Q2A
1566   gMC->Gspos("MQX2", 1, "ZDCA", 0., 0., tubpar[2]+zInnTrip+908.5,  0, "ONLY");
1567   gMC->Gspos("QBS5", 1, "MQX2", 0., 0., 0., 0, "ONLY");  
1568   gMC->Gspos("QBS6", 1, "MQX2", 2.405+boxpar[0], 0., 0., 0, "ONLY");
1569   gMC->Gspos("QBS6", 2, "MQX2", -2.405-boxpar[0], 0., 0., 0, "ONLY");  
1570   gMC->Gspos("YMQ2", 1, "ZDCA", 0., 0., tubpar[2]+zInnTrip+908.5,  0, "ONLY");
1571
1572   
1573   // -- Q2B
1574   gMC->Gspos("MQX3", 1, "ZDCA", 0., 0., tubpar[2]+zInnTrip+1558.5, 0, "ONLY");
1575   gMC->Gspos("QBS5", 2, "MQX3", 0., 0., 0., 0, "ONLY");  
1576   gMC->Gspos("QBS6", 3, "MQX3", 2.405+boxpar[0], 0., 0., 0, "ONLY");
1577   gMC->Gspos("QBS6", 4, "MQX3", -2.405-boxpar[0], 0., 0., 0, "ONLY");
1578   gMC->Gspos("YMQ2", 2, "ZDCA", 0., 0., tubpar[2]+zInnTrip+1558.5, 0, "ONLY");
1579
1580   // -- SEPARATOR DIPOLE D1 
1581   // --  GAP (VACUUM WITH MAGNETIC FIELD) 
1582   tubpar[0] = 0.;
1583   tubpar[1] = 6.75/2.;//3.375
1584   tubpar[2] = 945./2.;
1585   gMC->Gsvolu("MD1L", "TUBE", idtmed[11], tubpar, 3);
1586
1587   // --  The beam screen tube is provided by the beam pipe in D1 (QA03 volume)
1588   // --  Insert the beam screen horizontal Cu plates inside D1  
1589   // --   (to simulate the vacuum chamber)
1590   boxpar[0] = TMath::Sqrt(tubpar[1]*tubpar[1]-(2.885+0.2)*(2.885+0.2));
1591   boxpar[1] = 0.2/2.;
1592   boxpar[2] =945./2.;  
1593   gMC->Gsvolu("QBS7", "BOX ", idtmed[6], boxpar, 3);
1594   gMC->Gspos("QBS7", 1, "MD1L", 0., 2.885+boxpar[1],0., 0, "ONLY");
1595   gMC->Gspos("QBS7", 2, "MD1L", 0., -2.885-boxpar[1],0., 0, "ONLY");  
1596     
1597   // --  YOKE 
1598   tubpar[0] = 3.68;
1599   tubpar[1] = 110./2;
1600   tubpar[2] = 945./2.;
1601   gMC->Gsvolu("YD1L", "TUBE", idtmed[7], tubpar, 3);
1602   
1603   gMC->Gspos("YD1L", 1, "ZDCA", 0., 0., tubpar[2]+zD1, 0, "ONLY");  
1604   gMC->Gspos("MD1L", 1, "ZDCA", 0., 0., tubpar[2]+zD1, 0, "ONLY");  
1605   
1606   // -- DIPOLE D2 
1607   // --  GAP (VACUUM WITH MAGNETIC FIELD) 
1608   tubpar[0] = 0.;
1609   tubpar[1] = 7.5/2.; // this has to be checked
1610   tubpar[2] = 945./2.;
1611   gMC->Gsvolu("MD2L", "TUBE", idtmed[11], tubpar, 3);
1612   
1613   // --  YOKE 
1614   tubpar[0] = 0.;
1615   tubpar[1] = 55.;
1616   tubpar[2] = 945./2.;
1617   gMC->Gsvolu("YD2L", "TUBE", idtmed[7], tubpar, 3);
1618   
1619   gMC->Gspos("YD2L", 1, "ZDCA", 0., 0., tubpar[2]+zD2, 0, "ONLY");
1620   
1621   gMC->Gspos("MD2L", 1, "YD2L", -9.4, 0., 0., 0, "ONLY");
1622   gMC->Gspos("MD2L", 2, "YD2L",  9.4, 0., 0., 0, "ONLY");
1623   
1624   // -- END OF MAGNET DEFINITION     
1625 }
1626   
1627 //_____________________________________________________________________________
1628 void AliZDCv3::CreateZDC()
1629 {
1630  //
1631  // Create the various ZDCs (ZN + ZP)
1632  //
1633   
1634   Float_t dimPb[6], dimVoid[6];
1635   
1636   Int_t *idtmed = fIdtmed->GetArray();
1637
1638   // Parameters for hadronic calorimeters geometry
1639   // NB -> parameters used ONLY in CreateZDC()
1640   Float_t fGrvZN[3] = {0.03, 0.03, 50.};  // Grooves for neutron detector
1641   Float_t fGrvZP[3] = {0.04, 0.04, 75.};  // Grooves for proton detector
1642   Int_t   fDivZN[3] = {11, 11, 0};        // Division for neutron detector
1643   Int_t   fDivZP[3] = {7, 15, 0};         // Division for proton detector
1644   Int_t   fTowZN[2] = {2, 2};             // Tower for neutron detector
1645   Int_t   fTowZP[2] = {4, 1};             // Tower for proton detector
1646
1647   // Parameters for EM calorimeter geometry
1648   // NB -> parameters used ONLY in CreateZDC()
1649   Float_t kDimZEMPb  = 0.15*(TMath::Sqrt(2.));  // z-dimension of the Pb slice
1650   Float_t kFibRadZEM = 0.0315;                  // External fiber radius (including cladding)
1651   Int_t   fDivZEM[3] = {92, 0, 20};             // Divisions for EM detector
1652   Float_t fDimZEM[6] = {fZEMLength, 3.5, 3.5, 45., 0., 0.}; // Dimensions of EM detector
1653   Float_t fFibZEM2 = fDimZEM[2]/TMath::Sin(fDimZEM[3]*kDegrad)-kFibRadZEM;
1654   Float_t fFibZEM[3] = {0., 0.0275, fFibZEM2};  // Fibers for EM calorimeter
1655
1656   
1657   //-- Create calorimeters geometry
1658   
1659   // -------------------------------------------------------------------------------
1660   //--> Neutron calorimeter (ZN) 
1661   
1662   gMC->Gsvolu("ZNEU", "BOX ", idtmed[1], fDimZN, 3); // Passive material  
1663   gMC->Gsvolu("ZNF1", "TUBE", idtmed[3], fFibZN, 3); // Active material
1664   gMC->Gsvolu("ZNF2", "TUBE", idtmed[4], fFibZN, 3); 
1665   gMC->Gsvolu("ZNF3", "TUBE", idtmed[4], fFibZN, 3); 
1666   gMC->Gsvolu("ZNF4", "TUBE", idtmed[3], fFibZN, 3); 
1667   gMC->Gsvolu("ZNG1", "BOX ", idtmed[12], fGrvZN, 3); // Empty grooves 
1668   gMC->Gsvolu("ZNG2", "BOX ", idtmed[12], fGrvZN, 3); 
1669   gMC->Gsvolu("ZNG3", "BOX ", idtmed[12], fGrvZN, 3); 
1670   gMC->Gsvolu("ZNG4", "BOX ", idtmed[12], fGrvZN, 3); 
1671   
1672   // Divide ZNEU in towers (for hits purposes) 
1673   
1674   gMC->Gsdvn("ZNTX", "ZNEU", fTowZN[0], 1); // x-tower 
1675   gMC->Gsdvn("ZN1 ", "ZNTX", fTowZN[1], 2); // y-tower
1676   
1677   //-- Divide ZN1 in minitowers 
1678   //  fDivZN[0]= NUMBER OF FIBERS PER TOWER ALONG X-AXIS, 
1679   //  fDivZN[1]= NUMBER OF FIBERS PER TOWER ALONG Y-AXIS
1680   //  (4 fibres per minitower) 
1681   
1682   gMC->Gsdvn("ZNSL", "ZN1 ", fDivZN[1], 2); // Slices 
1683   gMC->Gsdvn("ZNST", "ZNSL", fDivZN[0], 1); // Sticks
1684   
1685   // --- Position the empty grooves in the sticks (4 grooves per stick)
1686   Float_t dx = fDimZN[0] / fDivZN[0] / 4.;
1687   Float_t dy = fDimZN[1] / fDivZN[1] / 4.;
1688   
1689   gMC->Gspos("ZNG1", 1, "ZNST", 0.-dx, 0.+dy, 0., 0, "ONLY");
1690   gMC->Gspos("ZNG2", 1, "ZNST", 0.+dx, 0.+dy, 0., 0, "ONLY");
1691   gMC->Gspos("ZNG3", 1, "ZNST", 0.-dx, 0.-dy, 0., 0, "ONLY");
1692   gMC->Gspos("ZNG4", 1, "ZNST", 0.+dx, 0.-dy, 0., 0, "ONLY");
1693   
1694   // --- Position the fibers in the grooves 
1695   gMC->Gspos("ZNF1", 1, "ZNG1", 0., 0., 0., 0, "ONLY");
1696   gMC->Gspos("ZNF2", 1, "ZNG2", 0., 0., 0., 0, "ONLY");
1697   gMC->Gspos("ZNF3", 1, "ZNG3", 0., 0., 0., 0, "ONLY");
1698   gMC->Gspos("ZNF4", 1, "ZNG4", 0., 0., 0., 0, "ONLY");
1699   
1700   // --- Position the neutron calorimeter in ZDC 
1701   // -- Rotation of ZDCs
1702   Int_t irotzdc;
1703   gMC->Matrix(irotzdc, 90., 180., 90., 90., 180., 0.);
1704   //
1705   gMC->Gspos("ZNEU", 1, "ZDCC", fPosZNC[0], fPosZNC[1], fPosZNC[2]-fDimZN[2], irotzdc, "ONLY");
1706   //Ch debug
1707   //printf("\n ZN -> %f < z < %f cm\n",fPosZN[2],fPosZN[2]-2*fDimZN[2]);
1708
1709   // --- Position the neutron calorimeter in ZDC2 (left line) 
1710   // -- No Rotation of ZDCs
1711   gMC->Gspos("ZNEU", 2, "ZDCA", fPosZNA[0], fPosZNA[1], fPosZNA[2]+fDimZN[2], 0, "ONLY");
1712   //Ch debug
1713   //printf("\n ZN left -> %f < z < %f cm\n",fPosZNl[2],fPosZNl[2]+2*fDimZN[2]);
1714
1715
1716   // -------------------------------------------------------------------------------
1717   //--> Proton calorimeter (ZP)  
1718   
1719   gMC->Gsvolu("ZPRO", "BOX ", idtmed[2], fDimZP, 3); // Passive material
1720   gMC->Gsvolu("ZPF1", "TUBE", idtmed[3], fFibZP, 3); // Active material
1721   gMC->Gsvolu("ZPF2", "TUBE", idtmed[4], fFibZP, 3); 
1722   gMC->Gsvolu("ZPF3", "TUBE", idtmed[4], fFibZP, 3); 
1723   gMC->Gsvolu("ZPF4", "TUBE", idtmed[3], fFibZP, 3); 
1724   gMC->Gsvolu("ZPG1", "BOX ", idtmed[12], fGrvZP, 3); // Empty grooves 
1725   gMC->Gsvolu("ZPG2", "BOX ", idtmed[12], fGrvZP, 3); 
1726   gMC->Gsvolu("ZPG3", "BOX ", idtmed[12], fGrvZP, 3); 
1727   gMC->Gsvolu("ZPG4", "BOX ", idtmed[12], fGrvZP, 3); 
1728     
1729   //-- Divide ZPRO in towers(for hits purposes) 
1730   
1731   gMC->Gsdvn("ZPTX", "ZPRO", fTowZP[0], 1); // x-tower 
1732   gMC->Gsdvn("ZP1 ", "ZPTX", fTowZP[1], 2); // y-tower
1733   
1734   
1735   //-- Divide ZP1 in minitowers 
1736   //  fDivZP[0]= NUMBER OF FIBERS ALONG X-AXIS PER MINITOWER, 
1737   //  fDivZP[1]= NUMBER OF FIBERS ALONG Y-AXIS PER MINITOWER
1738   //  (4 fiber per minitower) 
1739   
1740   gMC->Gsdvn("ZPSL", "ZP1 ", fDivZP[1], 2); // Slices 
1741   gMC->Gsdvn("ZPST", "ZPSL", fDivZP[0], 1); // Sticks
1742   
1743   // --- Position the empty grooves in the sticks (4 grooves per stick)
1744   dx = fDimZP[0] / fTowZP[0] / fDivZP[0] / 2.;
1745   dy = fDimZP[1] / fTowZP[1] / fDivZP[1] / 2.;
1746   
1747   gMC->Gspos("ZPG1", 1, "ZPST", 0.-dx, 0.+dy, 0., 0, "ONLY");
1748   gMC->Gspos("ZPG2", 1, "ZPST", 0.+dx, 0.+dy, 0., 0, "ONLY");
1749   gMC->Gspos("ZPG3", 1, "ZPST", 0.-dx, 0.-dy, 0., 0, "ONLY");
1750   gMC->Gspos("ZPG4", 1, "ZPST", 0.+dx, 0.-dy, 0., 0, "ONLY");
1751   
1752   // --- Position the fibers in the grooves 
1753   gMC->Gspos("ZPF1", 1, "ZPG1", 0., 0., 0., 0, "ONLY");
1754   gMC->Gspos("ZPF2", 1, "ZPG2", 0., 0., 0., 0, "ONLY");
1755   gMC->Gspos("ZPF3", 1, "ZPG3", 0., 0., 0., 0, "ONLY");
1756   gMC->Gspos("ZPF4", 1, "ZPG4", 0., 0., 0., 0, "ONLY");
1757   
1758
1759   // --- Position the proton calorimeter in ZDCC
1760   gMC->Gspos("ZPRO", 1, "ZDCC", fPosZPC[0], fPosZPC[1], fPosZPC[2]-fDimZP[2], irotzdc, "ONLY");
1761   //Ch debug
1762   //printf("\n ZP -> %f < z < %f cm\n",fPosZP[2],fPosZP[2]-2*fDimZP[2]);
1763   
1764   // --- Position the proton calorimeter in ZDCA
1765   // --- No rotation 
1766   gMC->Gspos("ZPRO", 2, "ZDCA", fPosZPA[0], fPosZPA[1], fPosZPA[2]+fDimZP[2], 0, "ONLY");
1767   //Ch debug
1768   //printf("\n ZP left -> %f < z < %f cm\n",fPosZPl[2],fPosZPl[2]+2*fDimZP[2]);  
1769     
1770   
1771   // -------------------------------------------------------------------------------
1772   // -> EM calorimeter (ZEM)  
1773   
1774   gMC->Gsvolu("ZEM ", "PARA", idtmed[10], fDimZEM, 6);
1775
1776   Int_t irot1, irot2;
1777   gMC->Matrix(irot1,0.,0.,90.,90.,-90.,0.);                    // Rotation matrix 1  
1778   gMC->Matrix(irot2,180.,0.,90.,fDimZEM[3]+90.,90.,fDimZEM[3]);// Rotation matrix 2
1779   //printf("irot1 = %d, irot2 = %d \n", irot1, irot2);
1780   
1781   gMC->Gsvolu("ZEMF", "TUBE", idtmed[3], fFibZEM, 3);   // Active material
1782
1783   gMC->Gsdvn("ZETR", "ZEM ", fDivZEM[2], 1);            // Tranches 
1784   
1785   dimPb[0] = kDimZEMPb;                                 // Lead slices 
1786   dimPb[1] = fDimZEM[2];
1787   dimPb[2] = fDimZEM[1];
1788   //dimPb[3] = fDimZEM[3]; //controllare
1789   dimPb[3] = 90.-fDimZEM[3]; //originale
1790   dimPb[4] = 0.;
1791   dimPb[5] = 0.;
1792   gMC->Gsvolu("ZEL0", "PARA", idtmed[5], dimPb, 6);
1793   gMC->Gsvolu("ZEL1", "PARA", idtmed[5], dimPb, 6);
1794   gMC->Gsvolu("ZEL2", "PARA", idtmed[5], dimPb, 6);
1795   
1796   // --- Position the lead slices in the tranche 
1797   Float_t zTran = fDimZEM[0]/fDivZEM[2]; 
1798   Float_t zTrPb = -zTran+kDimZEMPb;
1799   gMC->Gspos("ZEL0", 1, "ZETR", zTrPb, 0., 0., 0, "ONLY");
1800   gMC->Gspos("ZEL1", 1, "ZETR", kDimZEMPb, 0., 0., 0, "ONLY");
1801   
1802   // --- Vacuum zone (to be filled with fibres)
1803   dimVoid[0] = (zTran-2*kDimZEMPb)/2.;
1804   dimVoid[1] = fDimZEM[2];
1805   dimVoid[2] = fDimZEM[1];
1806   dimVoid[3] = 90.-fDimZEM[3];
1807   dimVoid[4] = 0.;
1808   dimVoid[5] = 0.;
1809   gMC->Gsvolu("ZEV0", "PARA", idtmed[10], dimVoid,6);
1810   gMC->Gsvolu("ZEV1", "PARA", idtmed[10], dimVoid,6);
1811   
1812   // --- Divide the vacuum slice into sticks along x axis
1813   gMC->Gsdvn("ZES0", "ZEV0", fDivZEM[0], 3); 
1814   gMC->Gsdvn("ZES1", "ZEV1", fDivZEM[0], 3); 
1815   
1816   // --- Positioning the fibers into the sticks
1817   gMC->Gspos("ZEMF", 1,"ZES0", 0., 0., 0., irot2, "ONLY");
1818   gMC->Gspos("ZEMF", 1,"ZES1", 0., 0., 0., irot2, "ONLY");
1819   
1820   // --- Positioning the vacuum slice into the tranche
1821   //Float_t displFib = fDimZEM[1]/fDivZEM[0];
1822   gMC->Gspos("ZEV0", 1,"ZETR", -dimVoid[0], 0., 0., 0, "ONLY");
1823   gMC->Gspos("ZEV1", 1,"ZETR", -dimVoid[0]+zTran, 0., 0., 0, "ONLY");
1824
1825   // --- Positioning the ZEM into the ZDC - rotation for 90 degrees  
1826   // NB -> ZEM is positioned in ALIC (instead of in ZDC) volume
1827   gMC->Gspos("ZEM ", 1,"ALIC", -fPosZEM[0], fPosZEM[1], fPosZEM[2]+fDimZEM[0], irot1, "ONLY");
1828   
1829   // Second EM ZDC (same side w.r.t. IP, just on the other side w.r.t. beam pipe)
1830   gMC->Gspos("ZEM ", 2,"ALIC", fPosZEM[0], fPosZEM[1], fPosZEM[2]+fDimZEM[0], irot1, "ONLY");
1831   
1832   // --- Adding last slice at the end of the EM calorimeter 
1833   Float_t zLastSlice = fPosZEM[2]+kDimZEMPb+2*fDimZEM[0];
1834   gMC->Gspos("ZEL2", 1,"ALIC", fPosZEM[0], fPosZEM[1], zLastSlice, irot1, "ONLY");
1835   //Ch debug
1836   //printf("\n ZEM lenght = %f cm\n",2*fZEMLength);
1837   //printf("\n ZEM -> %f < z < %f cm\n",fPosZEM[2],fPosZEM[2]+2*fZEMLength+zLastSlice+kDimZEMPb);
1838   
1839 }
1840  
1841 //_____________________________________________________________________________
1842 void AliZDCv3::DrawModule() const
1843 {
1844   //
1845   // Draw a shaded view of the Zero Degree Calorimeter version 1
1846   //
1847
1848   // Set everything unseen
1849   gMC->Gsatt("*", "seen", -1);
1850   // 
1851   // Set ALIC mother transparent
1852   gMC->Gsatt("ALIC","SEEN",0);
1853   //
1854   // Set the volumes visible
1855   gMC->Gsatt("ZDCC","SEEN",0);
1856   gMC->Gsatt("QT01","SEEN",1);
1857   gMC->Gsatt("QT02","SEEN",1);
1858   gMC->Gsatt("QT03","SEEN",1);
1859   gMC->Gsatt("QT04","SEEN",1);
1860   gMC->Gsatt("QT05","SEEN",1);
1861   gMC->Gsatt("QT06","SEEN",1);
1862   gMC->Gsatt("QT07","SEEN",1);
1863   gMC->Gsatt("QT08","SEEN",1);
1864   gMC->Gsatt("QT09","SEEN",1);
1865   gMC->Gsatt("QT10","SEEN",1);
1866   gMC->Gsatt("QT11","SEEN",1);
1867   gMC->Gsatt("QT12","SEEN",1);
1868   gMC->Gsatt("QT13","SEEN",1);
1869   gMC->Gsatt("QC01","SEEN",1);
1870   gMC->Gsatt("QC02","SEEN",1);
1871   gMC->Gsatt("QC03","SEEN",1);
1872   gMC->Gsatt("QC04","SEEN",1);
1873   gMC->Gsatt("QC05","SEEN",1);
1874   gMC->Gsatt("QC06","SEEN",1);
1875   gMC->Gsatt("QC07","SEEN",1);
1876   gMC->Gsatt("QC08","SEEN",1);
1877   gMC->Gsatt("QC09","SEEN",1);
1878   gMC->Gsatt("QC10","SEEN",1);
1879   gMC->Gsatt("MQXL","SEEN",1);
1880   gMC->Gsatt("YMQL","SEEN",1);
1881   gMC->Gsatt("MQX ","SEEN",1);
1882   gMC->Gsatt("YMQ ","SEEN",1);
1883   gMC->Gsatt("ZQYX","SEEN",1);
1884   gMC->Gsatt("MD1 ","SEEN",1);
1885   gMC->Gsatt("MD1V","SEEN",1);
1886   gMC->Gsatt("YD1 ","SEEN",1);
1887   gMC->Gsatt("MD2 ","SEEN",1);
1888   gMC->Gsatt("YD2 ","SEEN",1);
1889   gMC->Gsatt("ZNEU","SEEN",0);
1890   gMC->Gsatt("ZNF1","SEEN",0);
1891   gMC->Gsatt("ZNF2","SEEN",0);
1892   gMC->Gsatt("ZNF3","SEEN",0);
1893   gMC->Gsatt("ZNF4","SEEN",0);
1894   gMC->Gsatt("ZNG1","SEEN",0);
1895   gMC->Gsatt("ZNG2","SEEN",0);
1896   gMC->Gsatt("ZNG3","SEEN",0);
1897   gMC->Gsatt("ZNG4","SEEN",0);
1898   gMC->Gsatt("ZNTX","SEEN",0);
1899   gMC->Gsatt("ZN1 ","COLO",4); 
1900   gMC->Gsatt("ZN1 ","SEEN",1);
1901   gMC->Gsatt("ZNSL","SEEN",0);
1902   gMC->Gsatt("ZNST","SEEN",0);
1903   gMC->Gsatt("ZPRO","SEEN",0);
1904   gMC->Gsatt("ZPF1","SEEN",0);
1905   gMC->Gsatt("ZPF2","SEEN",0);
1906   gMC->Gsatt("ZPF3","SEEN",0);
1907   gMC->Gsatt("ZPF4","SEEN",0);
1908   gMC->Gsatt("ZPG1","SEEN",0);
1909   gMC->Gsatt("ZPG2","SEEN",0);
1910   gMC->Gsatt("ZPG3","SEEN",0);
1911   gMC->Gsatt("ZPG4","SEEN",0);
1912   gMC->Gsatt("ZPTX","SEEN",0);
1913   gMC->Gsatt("ZP1 ","COLO",6); 
1914   gMC->Gsatt("ZP1 ","SEEN",1);
1915   gMC->Gsatt("ZPSL","SEEN",0);
1916   gMC->Gsatt("ZPST","SEEN",0);
1917   gMC->Gsatt("ZEM ","COLO",7); 
1918   gMC->Gsatt("ZEM ","SEEN",1);
1919   gMC->Gsatt("ZEMF","SEEN",0);
1920   gMC->Gsatt("ZETR","SEEN",0);
1921   gMC->Gsatt("ZEL0","SEEN",0);
1922   gMC->Gsatt("ZEL1","SEEN",0);
1923   gMC->Gsatt("ZEL2","SEEN",0);
1924   gMC->Gsatt("ZEV0","SEEN",0);
1925   gMC->Gsatt("ZEV1","SEEN",0);
1926   gMC->Gsatt("ZES0","SEEN",0);
1927   gMC->Gsatt("ZES1","SEEN",0);
1928   //
1929   gMC->Gdopt("hide", "on");
1930   gMC->Gdopt("shad", "on");
1931   gMC->Gsatt("*", "fill", 7);
1932   gMC->SetClipBox(".");
1933   gMC->SetClipBox("*", 0, 100, -100, 100, 12000, 16000);
1934   gMC->DefaultRange();
1935   gMC->Gdraw("alic", 40, 30, 0, 488, 220, .07, .07);
1936   gMC->Gdhead(1111, "Zero Degree Calorimeter Version 3");
1937   gMC->Gdman(18, 4, "MAN");
1938 }
1939
1940 //_____________________________________________________________________________
1941 void AliZDCv3::CreateMaterials()
1942 {
1943   //
1944   // Create Materials for the Zero Degree Calorimeter
1945   //
1946   Float_t dens, ubuf[1], wmat[3], a[3], z[3];
1947
1948   // --- W alloy -> ZN passive material
1949   dens = 17.6;
1950   a[0] = 183.85;
1951   a[1] = 55.85;
1952   a[2] = 58.71;
1953   z[0] = 74.;
1954   z[1] = 26.;
1955   z[2] = 28.;
1956   wmat[0] = .93;
1957   wmat[1] = .03;
1958   wmat[2] = .04;
1959   AliMixture(1, "WALL", a, z, dens, 3, wmat);
1960
1961   // --- Brass (CuZn)  -> ZP passive material
1962   dens = 8.48;
1963   a[0] = 63.546;
1964   a[1] = 65.39;
1965   z[0] = 29.;
1966   z[1] = 30.;
1967   wmat[0] = .63;
1968   wmat[1] = .37;
1969   AliMixture(2, "BRASS", a, z, dens, 2, wmat);
1970   
1971   // --- SiO2 
1972   dens = 2.64;
1973   a[0] = 28.086;
1974   a[1] = 15.9994;
1975   z[0] = 14.;
1976   z[1] = 8.;
1977   wmat[0] = 1.;
1978   wmat[1] = 2.;
1979   AliMixture(3, "SIO2", a, z, dens, -2, wmat);  
1980   
1981   // --- Lead 
1982   ubuf[0] = 1.12;
1983   AliMaterial(5, "LEAD", 207.19, 82., 11.35, .56, 18.5, ubuf, 1);
1984
1985   // --- Copper (energy loss taken into account)
1986   ubuf[0] = 1.10;
1987   AliMaterial(6, "COPP0", 63.54, 29., 8.96, 1.4, 0., ubuf, 1);
1988
1989   // --- Copper 
1990   ubuf[0] = 1.10;
1991   AliMaterial(9, "COPP1", 63.54, 29., 8.96, 1.4, 0., ubuf, 1);
1992   
1993   // --- Iron (energy loss taken into account)
1994   ubuf[0] = 1.1;
1995   AliMaterial(7, "IRON0", 55.85, 26., 7.87, 1.76, 0., ubuf, 1);
1996   
1997   // --- Iron (no energy loss)
1998   ubuf[0] = 1.1;
1999   AliMaterial(8, "IRON1", 55.85, 26., 7.87, 1.76, 0., ubuf, 1);
2000     
2001   // ---------------------------------------------------------  
2002   Float_t aResGas[3]={1.008,12.0107,15.9994};
2003   Float_t zResGas[3]={1.,6.,8.};
2004   Float_t wResGas[3]={0.28,0.28,0.44};
2005   Float_t dResGas = 3.2E-14;
2006
2007   // --- Vacuum (no magnetic field) 
2008   AliMixture(10, "VOID", aResGas, zResGas, dResGas, 3, wResGas);
2009   
2010   // --- Vacuum (with magnetic field) 
2011   AliMixture(11, "VOIM", aResGas, zResGas, dResGas, 3, wResGas);
2012   
2013   // --- Air (no magnetic field)
2014   Float_t aAir[4]={12.0107,14.0067,15.9994,39.948};
2015   Float_t zAir[4]={6.,7.,8.,18.};
2016   Float_t wAir[4]={0.000124,0.755267,0.231781,0.012827};
2017   Float_t dAir = 1.20479E-3;
2018   //
2019   AliMixture(12, "Air    $", aAir, zAir, dAir, 4, wAir);
2020   
2021   // ---  Definition of tracking media: 
2022   
2023   // --- Tantalum = 1 ; 
2024   // --- Brass = 2 ; 
2025   // --- Fibers (SiO2) = 3 ; 
2026   // --- Fibers (SiO2) = 4 ; 
2027   // --- Lead = 5 ; 
2028   // --- Copper (with high thr.)= 6 ;
2029   // --- Copper (with low thr.)=  9;
2030   // --- Iron (with energy loss) = 7 ; 
2031   // --- Iron (without energy loss) = 8 ; 
2032   // --- Vacuum (no field) = 10 
2033   // --- Vacuum (with field) = 11 
2034   // --- Air (no field) = 12 
2035   
2036   // **************************************************** 
2037   //     Tracking media parameters
2038   //
2039   Float_t epsil  = 0.01;   // Tracking precision, 
2040   Float_t stmin  = 0.01;   // Min. value 4 max. step (cm)
2041   Float_t stemax = 1.;     // Max. step permitted (cm) 
2042   Float_t tmaxfd = 0.;     // Maximum angle due to field (degrees) 
2043   Float_t deemax = -1.;    // Maximum fractional energy loss
2044   Float_t nofieldm = 0.;   // Max. field value (no field)
2045   Float_t fieldm = 45.;    // Max. field value (with field)
2046   Int_t isvol = 0;         // ISVOL =0 -> not sensitive volume
2047   Int_t isvolActive = 1;   // ISVOL =1 -> sensitive volume
2048   Int_t inofld = 0;        // IFIELD=0 -> no magnetic field
2049   Int_t ifield =2;         // IFIELD=2 -> magnetic field defined in AliMagFC.h
2050   // *****************************************************
2051   
2052   AliMedium(1, "ZTANT", 1, isvolActive, inofld, nofieldm, tmaxfd, stemax, deemax, epsil, stmin);
2053   AliMedium(2, "ZBRASS",2, isvolActive, inofld, nofieldm, tmaxfd, stemax, deemax, epsil, stmin);
2054   AliMedium(3, "ZSIO2", 3, isvolActive, inofld, nofieldm, tmaxfd, stemax, deemax, epsil, stmin);
2055   AliMedium(4, "ZQUAR", 3, isvolActive, inofld, nofieldm, tmaxfd, stemax, deemax, epsil, stmin);
2056   AliMedium(5, "ZLEAD", 5, isvolActive, inofld, nofieldm, tmaxfd, stemax, deemax, epsil, stmin);
2057   AliMedium(6, "ZCOPP", 6, isvol, inofld, nofieldm, tmaxfd, stemax, deemax, epsil, stmin);
2058   AliMedium(7, "ZIRON", 7, isvol, inofld, nofieldm, tmaxfd, stemax, deemax, epsil, stmin);
2059   AliMedium(8, "ZIRONN",8, isvol, inofld, nofieldm, tmaxfd, stemax, deemax, epsil, stmin);
2060   AliMedium(9, "ZCOPL", 6, isvol, inofld, nofieldm, tmaxfd, stemax, deemax, epsil, stmin);
2061   AliMedium(10,"ZVOID",10, isvol, inofld, nofieldm, tmaxfd, stemax, deemax, epsil, stmin);
2062   AliMedium(11,"ZVOIM",11, isvol, ifield, fieldm, tmaxfd, stemax, deemax, epsil, stmin);
2063   AliMedium(12,"ZAIR", 12, isvolActive, inofld, nofieldm, tmaxfd, stemax, deemax, epsil, stmin);
2064
2065
2066
2067
2068 //_____________________________________________________________________________
2069 void AliZDCv3::AddAlignableVolumes() const
2070 {
2071  //
2072  // Create entries for alignable volumes associating the symbolic volume
2073  // name with the corresponding volume path. Needs to be syncronized with
2074  // eventual changes in the geometry.
2075  //
2076  TString volpath1 = "ALIC_1/ZDCC_1/ZNEU_1";
2077  TString volpath2 = "ALIC_1/ZDCC_1/ZPRO_1";
2078  TString volpath3 = "ALIC_1/ZDCA_1/ZNEU_2";
2079  TString volpath4 = "ALIC_1/ZDCA_1/ZPRO_2";
2080
2081  TString symname1="ZDC/NeutronZDC_C";
2082  TString symname2="ZDC/ProtonZDC_C";
2083  TString symname3="ZDC/NeutronZDC_A";
2084  TString symname4="ZDC/ProtonZDC_A";
2085
2086  if(!gGeoManager->SetAlignableEntry(symname1.Data(),volpath1.Data()))
2087      AliFatal(Form("Alignable entry %s not created. Volume path %s not valid",   symname1.Data(),volpath1.Data()));
2088
2089  if(!gGeoManager->SetAlignableEntry(symname2.Data(),volpath2.Data()))
2090      AliFatal(Form("Alignable entry %s not created. Volume path %s not valid",   symname2.Data(),volpath2.Data()));
2091
2092  if(!gGeoManager->SetAlignableEntry(symname3.Data(),volpath3.Data()))
2093      AliFatal(Form("Alignable entry %s not created. Volume path %s not valid",   symname1.Data(),volpath1.Data()));
2094
2095  if(!gGeoManager->SetAlignableEntry(symname4.Data(),volpath4.Data()))
2096      AliFatal(Form("Alignable entry %s not created. Volume path %s not valid",   symname2.Data(),volpath2.Data()));
2097
2098 }
2099
2100
2101 //_____________________________________________________________________________
2102 void AliZDCv3::Init()
2103 {
2104  InitTables();
2105   Int_t *idtmed = fIdtmed->GetArray();  
2106   Int_t i;
2107   // Thresholds for showering in the ZDCs 
2108   i = 1; //Wa lloy
2109   gMC->Gstpar(idtmed[i], "CUTGAM", .001);
2110   gMC->Gstpar(idtmed[i], "CUTELE", .001);
2111   gMC->Gstpar(idtmed[i], "CUTNEU", .01);
2112   gMC->Gstpar(idtmed[i], "CUTHAD", .01);
2113   i = 2; //brass
2114   gMC->Gstpar(idtmed[i], "CUTGAM", .001);
2115   gMC->Gstpar(idtmed[i], "CUTELE", .001);
2116   gMC->Gstpar(idtmed[i], "CUTNEU", .01);
2117   gMC->Gstpar(idtmed[i], "CUTHAD", .01);
2118   i = 5; //lead
2119   gMC->Gstpar(idtmed[i], "CUTGAM", .001);
2120   gMC->Gstpar(idtmed[i], "CUTELE", .001);
2121   gMC->Gstpar(idtmed[i], "CUTNEU", .01);
2122   gMC->Gstpar(idtmed[i], "CUTHAD", .01);
2123   
2124   // Avoid too detailed showering in TDI 
2125   i = 6; //copper
2126   gMC->Gstpar(idtmed[i], "CUTGAM", .1);
2127   gMC->Gstpar(idtmed[i], "CUTELE", .1);
2128   gMC->Gstpar(idtmed[i], "CUTNEU", 1.);
2129   gMC->Gstpar(idtmed[i], "CUTHAD", 1.);
2130   
2131   // Thresholds for showering in the luminometer
2132   i = 9; //copper
2133   gMC->Gstpar(idtmed[i], "CUTGAM", .001);
2134   gMC->Gstpar(idtmed[i], "CUTELE", .001);
2135   gMC->Gstpar(idtmed[i], "CUTNEU", .01);
2136   gMC->Gstpar(idtmed[i], "CUTHAD", .01);
2137   
2138   // Avoid too detailed showering along the beam line 
2139   i = 7; //iron with energy loss (ZIRON)
2140   gMC->Gstpar(idtmed[i], "CUTGAM", .1);
2141   gMC->Gstpar(idtmed[i], "CUTELE", .1);
2142   gMC->Gstpar(idtmed[i], "CUTNEU", 1.);
2143   gMC->Gstpar(idtmed[i], "CUTHAD", 1.);
2144   
2145   // Avoid too detailed showering along the beam line 
2146   i = 8; //iron without energy loss (ZIRONN)
2147   gMC->Gstpar(idtmed[i], "CUTGAM", .1);
2148   gMC->Gstpar(idtmed[i], "CUTELE", .1);
2149   gMC->Gstpar(idtmed[i], "CUTNEU", 1.);
2150   gMC->Gstpar(idtmed[i], "CUTHAD", 1.);
2151   
2152   // Avoid interaction in fibers (only energy loss allowed) 
2153   i = 3; //fibers (ZSI02)
2154   gMC->Gstpar(idtmed[i], "DCAY", 0.);
2155   gMC->Gstpar(idtmed[i], "MULS", 0.);
2156   gMC->Gstpar(idtmed[i], "PFIS", 0.);
2157   gMC->Gstpar(idtmed[i], "MUNU", 0.);
2158   gMC->Gstpar(idtmed[i], "LOSS", 1.);
2159   gMC->Gstpar(idtmed[i], "PHOT", 0.);
2160   gMC->Gstpar(idtmed[i], "COMP", 0.);
2161   gMC->Gstpar(idtmed[i], "PAIR", 0.);
2162   gMC->Gstpar(idtmed[i], "BREM", 0.);
2163   gMC->Gstpar(idtmed[i], "DRAY", 0.);
2164   gMC->Gstpar(idtmed[i], "ANNI", 0.);
2165   gMC->Gstpar(idtmed[i], "HADR", 0.);
2166   i = 4; //fibers (ZQUAR)
2167   gMC->Gstpar(idtmed[i], "DCAY", 0.);
2168   gMC->Gstpar(idtmed[i], "MULS", 0.);
2169   gMC->Gstpar(idtmed[i], "PFIS", 0.);
2170   gMC->Gstpar(idtmed[i], "MUNU", 0.);
2171   gMC->Gstpar(idtmed[i], "LOSS", 1.);
2172   gMC->Gstpar(idtmed[i], "PHOT", 0.);
2173   gMC->Gstpar(idtmed[i], "COMP", 0.);
2174   gMC->Gstpar(idtmed[i], "PAIR", 0.);
2175   gMC->Gstpar(idtmed[i], "BREM", 0.);
2176   gMC->Gstpar(idtmed[i], "DRAY", 0.);
2177   gMC->Gstpar(idtmed[i], "ANNI", 0.);
2178   gMC->Gstpar(idtmed[i], "HADR", 0.);
2179   
2180   // Avoid interaction in void 
2181   i = 11; //void with field
2182   gMC->Gstpar(idtmed[i], "DCAY", 0.);
2183   gMC->Gstpar(idtmed[i], "MULS", 0.);
2184   gMC->Gstpar(idtmed[i], "PFIS", 0.);
2185   gMC->Gstpar(idtmed[i], "MUNU", 0.);
2186   gMC->Gstpar(idtmed[i], "LOSS", 0.);
2187   gMC->Gstpar(idtmed[i], "PHOT", 0.);
2188   gMC->Gstpar(idtmed[i], "COMP", 0.);
2189   gMC->Gstpar(idtmed[i], "PAIR", 0.);
2190   gMC->Gstpar(idtmed[i], "BREM", 0.);
2191   gMC->Gstpar(idtmed[i], "DRAY", 0.);
2192   gMC->Gstpar(idtmed[i], "ANNI", 0.);
2193   gMC->Gstpar(idtmed[i], "HADR", 0.);
2194
2195   //
2196   fMedSensZN  = idtmed[1];  // Sensitive volume: ZN passive material
2197   fMedSensZP  = idtmed[2];  // Sensitive volume: ZP passive material
2198   fMedSensF1  = idtmed[3];  // Sensitive volume: fibres type 1
2199   fMedSensF2  = idtmed[4];  // Sensitive volume: fibres type 2
2200   fMedSensZEM = idtmed[5];  // Sensitive volume: ZEM passive material
2201   fMedSensTDI = idtmed[6];  // Sensitive volume: TDI Cu shield
2202   fMedSensPI  = idtmed[7];  // Sensitive volume: beam pipes
2203   fMedSensGR  = idtmed[12]; // Sensitive volume: air into the grooves
2204 }
2205
2206 //_____________________________________________________________________________
2207 void AliZDCv3::InitTables()
2208 {
2209  //
2210  // Read light tables for Cerenkov light production parameterization 
2211  //
2212
2213   Int_t k, j;
2214
2215   char *lightfName1,*lightfName2,*lightfName3,*lightfName4,
2216        *lightfName5,*lightfName6,*lightfName7,*lightfName8;
2217   FILE *fp1, *fp2, *fp3, *fp4, *fp5, *fp6, *fp7, *fp8;
2218
2219   //  --- Reading light tables for ZN 
2220   lightfName1 = gSystem->ExpandPathName("$ALICE_ROOT/ZDC/light22620362207s");
2221   if((fp1 = fopen(lightfName1,"r")) == NULL){
2222      printf("Cannot open file fp1 \n");
2223      return;
2224   }
2225   lightfName2 = gSystem->ExpandPathName("$ALICE_ROOT/ZDC/light22620362208s");
2226   if((fp2 = fopen(lightfName2,"r")) == NULL){
2227      printf("Cannot open file fp2 \n");
2228      return;
2229   }  
2230   lightfName3 = gSystem->ExpandPathName("$ALICE_ROOT/ZDC/light22620362209s");
2231   if((fp3 = fopen(lightfName3,"r")) == NULL){
2232      printf("Cannot open file fp3 \n");
2233      return;
2234   }
2235   lightfName4 = gSystem->ExpandPathName("$ALICE_ROOT/ZDC/light22620362210s");
2236   if((fp4 = fopen(lightfName4,"r")) == NULL){
2237      printf("Cannot open file fp4 \n");
2238      return;
2239   }
2240   
2241   int read=1;
2242   for(k=0; k<fNalfan; k++){
2243      for(j=0; j<fNben; j++){
2244        read = fscanf(fp1,"%f",&fTablen[0][k][j]);
2245        if(read==0) AliDebug(3, " Error in reading light table 1");
2246        read = fscanf(fp2,"%f",&fTablen[1][k][j]);
2247        if(read==0) AliDebug(3, " Error in reading light table 2");
2248        read = fscanf(fp3,"%f",&fTablen[2][k][j]);
2249        if(read==0) AliDebug(3, " Error in reading light table 3");
2250        read = fscanf(fp4,"%f",&fTablen[3][k][j]);
2251        if(read==0) AliDebug(3, " Error in reading light table 4");
2252      } 
2253   }
2254   fclose(fp1);
2255   fclose(fp2);
2256   fclose(fp3);
2257   fclose(fp4);
2258   
2259   //  --- Reading light tables for ZP and ZEM
2260   lightfName5 = gSystem->ExpandPathName("$ALICE_ROOT/ZDC/light22620552207s");
2261   if((fp5 = fopen(lightfName5,"r")) == NULL){
2262      printf("Cannot open file fp5 \n");
2263      return;
2264   }
2265   lightfName6 = gSystem->ExpandPathName("$ALICE_ROOT/ZDC/light22620552208s");
2266   if((fp6 = fopen(lightfName6,"r")) == NULL){
2267      printf("Cannot open file fp6 \n");
2268      return;
2269   }
2270   lightfName7 = gSystem->ExpandPathName("$ALICE_ROOT/ZDC/light22620552209s");
2271   if((fp7 = fopen(lightfName7,"r")) == NULL){
2272      printf("Cannot open file fp7 \n");
2273      return;
2274   }
2275   lightfName8 = gSystem->ExpandPathName("$ALICE_ROOT/ZDC/light22620552210s");
2276   if((fp8 = fopen(lightfName8,"r")) == NULL){
2277      printf("Cannot open file fp8 \n");
2278      return;
2279   }
2280   
2281   for(k=0; k<fNalfap; k++){
2282      for(j=0; j<fNbep; j++){
2283        read = fscanf(fp5,"%f",&fTablep[0][k][j]);
2284        if(read==0) AliDebug(3, " Error in reading light table 5");
2285        read = fscanf(fp6,"%f",&fTablep[1][k][j]);
2286        if(read==0) AliDebug(3, " Error in reading light table 6");
2287        read = fscanf(fp7,"%f",&fTablep[2][k][j]);
2288        if(read==0) AliDebug(3, " Error in reading light table 7");
2289        read = fscanf(fp8,"%f",&fTablep[3][k][j]);
2290        if(read==0) AliDebug(3, " Error in reading light table 8");
2291      } 
2292   }
2293   fclose(fp5);
2294   fclose(fp6);
2295   fclose(fp7);
2296   fclose(fp8);
2297 }
2298 //_____________________________________________________________________________
2299 void AliZDCv3::StepManager()
2300 {
2301   //
2302   // Routine called at every step in the Zero Degree Calorimeters
2303   //
2304   Int_t   j, vol[2]={0,0}, ibeta=0, ialfa=0, ibe=0, nphe=0;
2305   Float_t hits[13], x[3], xdet[3], um[3], ud[3];
2306   Float_t destep=0., be=0., out=0.;
2307   Double_t s[3], p[3];
2308   const char *knamed;
2309   //
2310   for(j=0;j<13;j++) hits[j]=-999.;
2311   //
2312   // --- This part is for no shower developement in beam pipe and TDI
2313   // If particle interacts with beam pipe or TDI -> return
2314   if((gMC->CurrentMedium() == fMedSensPI) || (gMC->CurrentMedium() == fMedSensTDI)){ 
2315     // If option NoShower is set -> StopTrack
2316     Int_t ipr = 0; 
2317     if(fNoShower==1){
2318       gMC->TrackPosition(s[0],s[1],s[2]);
2319       if(gMC->CurrentMedium() == fMedSensPI){
2320         knamed = gMC->CurrentVolName();
2321         if(!strncmp(knamed,"YMQ",3)){
2322           if(s[2]<0) fpLostITC += 1;
2323           else fpLostITA += 1;
2324           ipr=1;
2325         }
2326         else if(!strncmp(knamed,"YD1",3)){
2327           if(s[2]<0) fpLostD1C += 1;
2328           else fpLostD1A += 1;
2329           ipr=1;
2330         }
2331       }
2332       else if(gMC->CurrentMedium() == fMedSensTDI){ 
2333         knamed = gMC->CurrentVolName();
2334         if(!strncmp(knamed,"MD1",3)){
2335           if(s[2]<0) fpLostD1C += 1;
2336           else  fpLostD1A += 1;
2337           ipr=1;
2338         }
2339         else if(!strncmp(knamed,"QTD",3)) fpLostTDI += 1;
2340       }
2341       //
2342       //gMC->TrackMomentum(p[0], p[1], p[2], p[3]);
2343       //printf("\t Particle: mass = %1.3f, E = %1.3f GeV, pz = %1.2f GeV -> stopped in volume %s\n", 
2344       //     gMC->TrackMass(), p[3], p[2], gMC->CurrentVolName());
2345       //
2346       /*if(ipr!=0){
2347         printf("\n\t **********************************\n");
2348         printf("\t ********** Side C **********\n");
2349         printf("\t # of spectators in IT = %d\n",fpLostITC);
2350         printf("\t # of spectators in D1 = %d\n",fpLostD1C);
2351         printf("\t ********** Side A **********\n");
2352         printf("\t # of spectators in IT = %d\n",fpLostITA);
2353         printf("\t # of spectators in D1 = %d\n",fpLostD1A);
2354         printf("\t # of spectators in TDI = %d\n",fpLostTDI);
2355         printf("\t **********************************\n");
2356       }*/
2357       gMC->StopTrack();
2358     }
2359     return;
2360   }
2361   
2362
2363   if((gMC->CurrentMedium() == fMedSensZN) || (gMC->CurrentMedium() == fMedSensZP) ||
2364      (gMC->CurrentMedium() == fMedSensGR) || (gMC->CurrentMedium() == fMedSensF1) ||
2365      (gMC->CurrentMedium() == fMedSensF2) || (gMC->CurrentMedium() == fMedSensZEM)){
2366
2367     
2368   //Particle coordinates 
2369     gMC->TrackPosition(s[0],s[1],s[2]);
2370     for(j=0; j<=2; j++) x[j] = s[j];
2371     hits[0] = x[0];
2372     hits[1] = x[1];
2373     hits[2] = x[2];
2374
2375   // Determine in which ZDC the particle is
2376     knamed = gMC->CurrentVolName();
2377     if(!strncmp(knamed,"ZN",2)){
2378           if(x[2]<0.) vol[0]=1; // ZNC (dimuon side)
2379           else if(x[2]>0.) vol[0]=4; //ZNA
2380     }
2381     else if(!strncmp(knamed,"ZP",2)){ 
2382           if(x[2]<0.) vol[0]=2; //ZPC (dimuon side)
2383           else if(x[2]>0.) vol[0]=5; //ZPA  
2384     }
2385     else if(!strncmp(knamed,"ZE",2)) vol[0]=3; //ZEM
2386   
2387   // Determine in which quadrant the particle is
2388     if(vol[0]==1){      //Quadrant in ZNC
2389       // Calculating particle coordinates inside ZNC
2390       xdet[0] = x[0]-fPosZNC[0];
2391       xdet[1] = x[1]-fPosZNC[1];
2392       // Calculating quadrant in ZN
2393       if(xdet[0]<=0.){
2394         if(xdet[1]<=0.) vol[1]=1;
2395         else vol[1]=3;
2396       }
2397       else if(xdet[0]>0.){
2398         if(xdet[1]<=0.) vol[1]=2;
2399         else vol[1]=4;
2400       }
2401     }
2402     
2403     else if(vol[0]==2){ //Quadrant in ZPC
2404       // Calculating particle coordinates inside ZPC
2405       xdet[0] = x[0]-fPosZPC[0];
2406       xdet[1] = x[1]-fPosZPC[1];
2407       if(xdet[0]>=fDimZP[0])  xdet[0]=fDimZP[0]-0.01;
2408       if(xdet[0]<=-fDimZP[0]) xdet[0]=-fDimZP[0]+0.01;
2409       // Calculating tower in ZP
2410       Float_t xqZP = xdet[0]/(fDimZP[0]/2.);
2411       for(int i=1; i<=4; i++){
2412          if(xqZP>=(i-3) && xqZP<(i-2)){
2413            vol[1] = i;
2414            break;
2415          }
2416       }
2417     }
2418     //
2419     // Quadrant in ZEM: vol[1] = 1 -> particle in 1st ZEM (placed at x = 8.5 cm)
2420     //                  vol[1] = 2 -> particle in 2nd ZEM (placed at x = -8.5 cm)
2421     else if(vol[0] == 3){       
2422       if(x[0]>0.){
2423         vol[1] = 1;
2424         // Particle x-coordinate inside ZEM1
2425         xdet[0] = x[0]-fPosZEM[0];
2426       }
2427       else{
2428         vol[1] = 2;
2429         // Particle x-coordinate inside ZEM2
2430         xdet[0] = x[0]+fPosZEM[0];
2431       }
2432       xdet[1] = x[1]-fPosZEM[1];
2433     }
2434     //
2435     else if(vol[0]==4){ //Quadrant in ZNA
2436       // Calculating particle coordinates inside ZNA
2437       xdet[0] = x[0]-fPosZNA[0];
2438       xdet[1] = x[1]-fPosZNA[1];
2439       // Calculating quadrant in ZNA
2440       if(xdet[0]>=0.){
2441         if(xdet[1]<=0.) vol[1]=1;
2442         else vol[1]=3;
2443       }
2444       else if(xdet[0]<0.){
2445         if(xdet[1]<=0.) vol[1]=2;
2446         else vol[1]=4;
2447       }
2448     }    
2449     //
2450     else if(vol[0]==5){ //Quadrant in ZPA
2451       // Calculating particle coordinates inside ZPA
2452       xdet[0] = x[0]-fPosZPA[0];
2453       xdet[1] = x[1]-fPosZPA[1];
2454       if(xdet[0]>=fDimZP[0])  xdet[0]=fDimZP[0]-0.01;
2455       if(xdet[0]<=-fDimZP[0]) xdet[0]=-fDimZP[0]+0.01;
2456       // Calculating tower in ZP
2457       Float_t xqZP = -xdet[0]/(fDimZP[0]/2.);
2458       for(int i=1; i<=4; i++){
2459          if(xqZP>=(i-3) && xqZP<(i-2)){
2460            vol[1] = i;
2461            break;
2462          }
2463       }
2464     }    
2465     if((vol[1]!=1) && (vol[1]!=2) && (vol[1]!=3) && (vol[1]!=4))
2466       AliError(Form(" WRONG tower for det %d: tow %d with xdet=(%f, %f)\n",
2467                 vol[0], vol[1], xdet[0], xdet[1]));
2468     // Ch. debug
2469     //printf("\t *** det %d vol %d xdet(%f, %f)\n",vol[0], vol[1], xdet[0], xdet[1]);
2470     
2471     
2472     // Store impact point and kinetic energy of the ENTERING particle
2473     
2474     if(gMC->IsTrackEntering()){
2475       //Particle energy
2476       gMC->TrackMomentum(p[0],p[1],p[2],p[3]);
2477       hits[3] = p[3];
2478       // Impact point on ZDC
2479       // X takes into account the LHC x-axis sign
2480       // which is opposite to positive x on detcetor front face
2481       // for side A detectors (ZNA and ZPA)  
2482       if(vol[0]==4 || vol[0]==5){
2483         hits[4] = -xdet[0];
2484       }
2485       else{
2486         hits[4] = xdet[0];
2487       }
2488       hits[5] = xdet[1];
2489       hits[6] = 0;
2490       hits[7] = 0;
2491       hits[8] = 0;
2492       hits[9] = 0;
2493       //
2494       Int_t curTrackN = gAlice->GetMCApp()->GetCurrentTrackNumber();
2495       TParticle *part = gAlice->GetMCApp()->Particle(curTrackN);
2496       hits[10] = part->GetPdgCode();
2497       //printf("\t PDGCode = %d\n", part->GetPdgCode());
2498       //
2499       Int_t imo = part->GetFirstMother();
2500       if(imo>0){
2501         TParticle * pmot = gAlice->GetMCApp()->Particle(imo);
2502         hits[11] = pmot->GetPdgCode();
2503       }
2504       else hits[11]=0;
2505       //
2506       hits[12] = 1.0e09*gMC->TrackTime(); // in ns!
2507       //printf("\t TrackTime = %f\n", hits[12]);
2508
2509       AddHit(curTrackN, vol, hits);
2510
2511       if(fNoShower==1){
2512         //printf("\t VolName %s -> det %d quad %d - x = %f, y = %f, z = %f\n", 
2513           //knamed, vol[0], vol[1], x[0], x[1], x[2]);
2514         if(vol[0]==1){
2515           fnDetectedC += 1;
2516           printf("      # of particles in ZNC = %d\n\n",fnDetectedC);
2517         }
2518         else if(vol[0]==2){
2519           fpDetectedC += 1;
2520           printf("      # of particles in ZPC = %d\n\n",fpDetectedC);
2521         }
2522         else if(vol[0]==4){
2523           fnDetectedA += 1;
2524           printf("      # of particles in ZNA = %d\n\n",fnDetectedA);     
2525         }
2526         else if(vol[0]==5){
2527           fpDetectedA += 1;
2528           printf("      # of particles in ZPA = %d\n\n",fpDetectedA);      
2529         }
2530         //
2531         //printf("\t Particle: mass = %1.3f, E = %1.3f GeV, pz = %1.2f GeV -> stopped in volume %s\n", 
2532         //   gMC->TrackMass(), p[3], p[2], gMC->CurrentVolName());
2533         //
2534         gMC->StopTrack();
2535         return;
2536       }
2537     }
2538            
2539     // Particle energy loss
2540     if(gMC->Edep() != 0){
2541       hits[9] = gMC->Edep();
2542       hits[7] = 0.;
2543       hits[8] = 0.;
2544       AddHit(gAlice->GetMCApp()->GetCurrentTrackNumber(), vol, hits);
2545     }
2546   }
2547  
2548
2549   // *** Light production in fibres 
2550   if((gMC->CurrentMedium() == fMedSensF1) || (gMC->CurrentMedium() == fMedSensF2)){
2551
2552      //Select charged particles
2553      if((destep=gMC->Edep())){
2554
2555        // Particle velocity
2556        Float_t beta = 0.;
2557        gMC->TrackMomentum(p[0],p[1],p[2],p[3]);
2558        Float_t ptot=TMath::Sqrt(p[0]*p[0]+p[1]*p[1]+p[2]*p[2]);
2559        if(p[3] > 0.00001) beta =  ptot/p[3];
2560        else return;
2561        if(beta<0.67)return;
2562        else if((beta>=0.67) && (beta<=0.75)) ibeta = 0;
2563        else if((beta>0.75)  && (beta<=0.85)) ibeta = 1;
2564        else if((beta>0.85)  && (beta<=0.95)) ibeta = 2;
2565        else if(beta>0.95) ibeta = 3;
2566  
2567        // Angle between particle trajectory and fibre axis
2568        // 1 -> Momentum directions
2569        um[0] = p[0]/ptot;
2570        um[1] = p[1]/ptot;
2571        um[2] = p[2]/ptot;
2572        gMC->Gmtod(um,ud,2);
2573        // 2 -> Angle < limit angle
2574        Double_t alfar = TMath::ACos(ud[2]);
2575        Double_t alfa = alfar*kRaddeg;
2576        if(alfa>=110.) return;
2577        //
2578        ialfa = Int_t(1.+alfa/2.);
2579  
2580        // Distance between particle trajectory and fibre axis
2581        gMC->TrackPosition(s[0],s[1],s[2]);
2582        for(j=0; j<=2; j++){
2583           x[j] = s[j];
2584        }
2585        gMC->Gmtod(x,xdet,1);
2586        if(TMath::Abs(ud[0])>0.00001){
2587          Float_t dcoeff = ud[1]/ud[0];
2588          be = TMath::Abs((xdet[1]-dcoeff*xdet[0])/TMath::Sqrt(dcoeff*dcoeff+1.));
2589        }
2590        else{
2591          be = TMath::Abs(ud[0]);
2592        }
2593  
2594        ibe = Int_t(be*1000.+1);
2595        //if((vol[0]==1))      radius = fFibZN[1];
2596        //else if((vol[0]==2)) radius = fFibZP[1];
2597  
2598        //Looking into the light tables 
2599        Float_t charge = gMC->TrackCharge();
2600        
2601        if(vol[0]==1 || vol[0]==4) {     // (1)  ZN fibres
2602          if(ibe>fNben) ibe=fNben;
2603          out =  charge*charge*fTablen[ibeta][ialfa][ibe];
2604          nphe = gRandom->Poisson(out);
2605          // Ch. debug
2606          //if(ibeta==3) printf("\t %f \t %f \t %f\n",alfa, be, out);
2607          //printf("\t ibeta = %d, ialfa = %d, ibe = %d -> nphe = %d\n\n",ibeta,ialfa,ibe,nphe);
2608          if(gMC->CurrentMedium() == fMedSensF1){
2609            hits[7] = nphe;      //fLightPMQ
2610            hits[8] = 0;
2611            hits[9] = 0;
2612            AddHit(gAlice->GetMCApp()->GetCurrentTrackNumber(), vol, hits);
2613          }
2614          else{
2615            hits[7] = 0;
2616            hits[8] = nphe;      //fLightPMC
2617            hits[9] = 0;
2618            AddHit(gAlice->GetMCApp()->GetCurrentTrackNumber(), vol, hits);
2619          }
2620        } 
2621        else if(vol[0]==2 || vol[0]==5) {// (2) ZP fibres
2622          if(ibe>fNbep) ibe=fNbep;
2623          out =  charge*charge*fTablep[ibeta][ialfa][ibe];
2624          nphe = gRandom->Poisson(out);
2625          if(gMC->CurrentMedium() == fMedSensF1){
2626            hits[7] = nphe;      //fLightPMQ
2627            hits[8] = 0;
2628            hits[9] = 0;
2629            AddHit(gAlice->GetMCApp()->GetCurrentTrackNumber(), vol, hits);
2630          }
2631          else{
2632            hits[7] = 0;
2633            hits[8] = nphe;      //fLightPMC
2634            hits[9] = 0;
2635            AddHit(gAlice->GetMCApp()->GetCurrentTrackNumber(), vol, hits);
2636          }
2637        } 
2638        else if((vol[0]==3)) {   // (3) ZEM fibres
2639          if(ibe>fNbep) ibe=fNbep;
2640          out =  charge*charge*fTablep[ibeta][ialfa][ibe];
2641          gMC->TrackPosition(s[0],s[1],s[2]);
2642          Float_t xalic[3];
2643          for(j=0; j<3; j++){
2644             xalic[j] = s[j];
2645          }
2646          // z-coordinate from ZEM front face 
2647          // NB-> fPosZEM[2]+fZEMLength = -1000.+2*10.3 = 979.69 cm
2648          Float_t z = -xalic[2]+fPosZEM[2]+2*fZEMLength-xalic[1];
2649          //z = xalic[2]-fPosZEM[2]-fZEMLength-xalic[1]*(TMath::Tan(45.*kDegrad));
2650          //printf("     fPosZEM[2]+2*fZEMLength = %f", fPosZEM[2]+2*fZEMLength);
2651          //
2652          // Parametrization for light guide uniformity
2653          // NEW!!! Light guide tilted @ 51 degrees
2654          Float_t guiPar[4]={0.31,-0.0006305,0.01337,0.8895};
2655          Float_t guiEff = guiPar[0]*(guiPar[1]*z*z+guiPar[2]*z+guiPar[3]);
2656          out = out*guiEff;
2657          nphe = gRandom->Poisson(out);
2658          //printf("     out*guiEff = %f nphe = %d", out, nphe);
2659          if(vol[1] == 1){
2660            hits[7] = 0;         
2661            hits[8] = nphe;      //fLightPMC (ZEM1)
2662            hits[9] = 0;
2663            AddHit(gAlice->GetMCApp()->GetCurrentTrackNumber(), vol, hits);
2664          }
2665          else{
2666            hits[7] = nphe;      //fLightPMQ (ZEM2)
2667            hits[8] = 0;         
2668            hits[9] = 0;
2669            AddHit(gAlice->GetMCApp()->GetCurrentTrackNumber(), vol, hits);
2670          }
2671        }
2672      }
2673    }
2674 }