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