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