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