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