Warning fixed
[u/mrichter/AliRoot.git] / VZERO / AliVZEROv7.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 /* $Id$ */
17
18 ///////////////////////////////////////////////////////////////////////
19 //                                                                   // 
20 //  (V-zero) detector  version 7 as designed by the Lyon and         //
21 //   Mexico groups and Carlos Perez Lara from Pontificia Universidad //
22 //   Catolica del Peru                                               // 
23 //   All comments should be sent to Brigitte CHEYNIS:                //
24 //                     b.cheynis@ipnl.in2p3.fr                       // 
25 //   Geometry of April 2006 done with ROOT geometrical modeler       //
26 //   V0R (now V0C) sits between Z values  -89.5 and  -84.8 cm        // 
27 //   V0L (now V0A) sits between Z values +325.0 and +330.0 cm        // 
28 //   New coordinate system has been implemented in october 2003      //
29 //   Revision of the V0A part by Lizardo Valencia  in July 2008      //
30 //                                                                   //
31 /////////////////////////////////////////////////////////////////////// 
32
33 // --- Standard libraries ---
34 #include <Riostream.h>
35
36 // --- ROOT libraries ---
37 #include <TClonesArray.h>
38 #include <TMath.h>
39 #include <TVirtualMC.h>
40 #include <TParticle.h>
41
42 #include <TGeoManager.h>
43 #include <TGeoMatrix.h>
44 #include <TGeoMaterial.h>
45 #include <TGeoMedium.h>
46 #include <TGeoVolume.h>
47 #include "TGeoTube.h"
48 #include "TGeoArb8.h"
49 #include "TGeoCompositeShape.h"
50
51 // --- AliRoot header files ---
52 #include "AliRun.h"
53 #include "AliMC.h"
54 #include "AliMagF.h"
55 #include "AliVZEROLoader.h"
56 #include "AliVZEROdigit.h"
57 #include "AliVZEROhit.h"
58 #include "AliVZEROv7.h"
59 #include "AliLog.h"
60  
61 ClassImp(AliVZEROv7)
62
63 //_____________________________________________________________________________
64 AliVZEROv7:: AliVZEROv7():AliVZERO(),
65    fCellId(0),
66    fTrackPosition(),
67    fTrackMomentum(), 
68    fV0CHeight1(2.5), 
69    fV0CHeight2(4.4), 
70    fV0CHeight3(7.4), 
71    fV0CHeight4(12.5),
72    fV0CRMin(4.6), 
73    fV0CRBox(38.0),
74    fV0CLidThickness(0.30),
75    fV0CCellThickness(2.00),
76    fV0CBoxThickness(4.70),
77    fV0COffsetFibers(1.0),
78    fV0CLightYield(93.75),
79    fV0CLightAttenuation(0.05),
80    fV0CnMeters(15.0),
81    fV0CFibToPhot(0.3),
82    fV0AR0(4.2), 
83    fV0AR1(7.6), 
84    fV0AR2(13.8), 
85    fV0AR3(22.7),
86    fV0AR4(41.3), 
87    fV0AR5(43.3), 
88    fV0AR6(72.6),
89    fV0AR7(92.0), // Distance from origin to outtermost intersection sector7 and sector8 
90    fV0ASciWd(2.5), 
91    fV0APlaWd(0.5), 
92    fV0APlaAl(0.06), 
93    fV0AOctWd(0.75), 
94    fV0AFraWd(0.2),
95    fV0AOctH1(1.0), 
96    fV0AOctH2(2.0), 
97    fV0ABasHt(2.0),
98    fV0AFibRd(0.1),
99    fV0APlaEx(4.4),
100    fV0APMBWd(24.6), 
101    fV0APMBHt(22.0), 
102    fV0APMBTh(7.1), 
103    fV0APMBWdW(0.3), 
104    fV0APMBHtW(1.0),
105    fV0APMBAng(30.0), 
106    fV0APMBThW(0.3), 
107    fV0APMTR1(2.44), 
108    fV0APMTR2(2.54), 
109    fV0APMTR3(2.54),
110    fV0APMTR4(2.70), 
111    fV0APMTH(10.0), 
112    fV0APMTB(1.0),
113    fV0AnMeters(fV0AR6*0.01),
114    fV0ALightYield(93.75),
115    fV0ALightAttenuation(0.05), 
116    fV0AFibToPhot(0.3),
117    fVersion(7)
118 {
119 // Standard default constructor 
120 }
121
122 //_____________________________________________________________________________
123 AliVZEROv7::AliVZEROv7(const char *name, const char *title):AliVZERO(name,title),
124    fCellId(0),
125    fTrackPosition(),
126    fTrackMomentum(), 
127    fV0CHeight1(2.5), 
128    fV0CHeight2(4.4), 
129    fV0CHeight3(7.4), 
130    fV0CHeight4(12.5),
131    fV0CRMin(4.6), 
132    fV0CRBox(38.0),
133    fV0CLidThickness(0.30),
134    fV0CCellThickness(2.00),
135    fV0CBoxThickness(4.70),
136    fV0COffsetFibers(1.0),
137    fV0CLightYield(93.75),
138    fV0CLightAttenuation(0.05),
139    fV0CnMeters(15.0),
140    fV0CFibToPhot(0.3),
141    fV0AR0(4.2), 
142    fV0AR1(7.6), 
143    fV0AR2(13.8), 
144    fV0AR3(22.7),
145    fV0AR4(41.3), 
146    fV0AR5(43.3), 
147    fV0AR6(72.6),
148    fV0AR7(92.0), // Distance from origin to outtermost intersection of sector7 and sector8 
149    fV0ASciWd(2.5), 
150    fV0APlaWd(0.5), 
151    fV0APlaAl(0.06), 
152    fV0AOctWd(0.75), 
153    fV0AFraWd(0.2),
154    fV0AOctH1(1.0), 
155    fV0AOctH2(2.0), 
156    fV0ABasHt(2.0),
157    fV0AFibRd(0.1),
158    fV0APlaEx(4.4),
159    fV0APMBWd(24.6), 
160    fV0APMBHt(22.0), 
161    fV0APMBTh(7.1), 
162    fV0APMBWdW(0.3), 
163    fV0APMBHtW(1.0),
164    fV0APMBAng(30.0), 
165    fV0APMBThW(0.3), 
166    fV0APMTR1(2.44), 
167    fV0APMTR2(2.54), 
168    fV0APMTR3(2.54),
169    fV0APMTR4(2.70), 
170    fV0APMTH(10.0), 
171    fV0APMTB(1.0),
172    fV0AnMeters(fV0AR6*0.01),
173    fV0ALightYield(93.75),
174    fV0ALightAttenuation(0.05),
175    fV0AFibToPhot(0.3),
176    fVersion(7)
177
178
179 {
180 // Standard constructor for V-zero Detector  version 7
181
182   AliDebug(2,"Create VZERO object ");
183
184 //  fVersion            =     7;  // version number
185
186 //   // V0C Parameters related to geometry: All in cm
187 //   fV0CHeight1         =    2.5; // height of cell 1
188 //   fV0CHeight2         =    4.4; // height of cell 2
189 //   fV0CHeight3         =    7.4; // height of cell 3
190 //   fV0CHeight4         =   12.5; // height of cell 4
191 //   fV0CRMin            =    4.6; // inner radius of box
192 //   fV0CRBox            =   38.0; // outer radius of box
193 //   fV0CLidThickness    =   0.30; // thickness of Carbon lid
194 //   fV0CCellThickness   =   2.00; // thickness of elementary cell
195 //   fV0CBoxThickness    =   4.70; // thickness of V0C Box
196 //   fV0COffsetFibers    =    1.0; // offset to output fibers
197 //   // V0C Parameters related to light output
198 //   fV0CLightYield         =  93.75; // Light yield in BC408 (93.75 eV per photon)
199 //   fV0CLightAttenuation   =   0.05; // Light attenuation in fiber (0.05 per meter)
200 //   fV0CnMeters            =   15.0; // Number of meters of clear fibers to PM
201 //   fV0CFibToPhot          =    0.3; // Attenuation at fiber-photocathode interface
202 // 
203 //   // V0A Parameters related to geometry: All in cm
204 //   fV0AR0     =  4.2;  // Radius of hole
205 //   fV0AR1     =  7.6;  // Maximun radius of 1st cell
206 //   fV0AR2     = 13.8; // Maximun radius of 2nd cell
207 //   fV0AR3     = 22.7; // Maximun radius of 3rd cell
208 //   fV0AR4     = 41.3; // Maximun radius of 4th cell
209 //   fV0AR5     = 43.3; // Radius circunscrite to innermost octagon
210 //   fV0AR6     = 68.0; // Radius circunscrite to outtermost octagon
211 //   fV0ASciWd  =  2.5;  // Scintillator thickness 
212 //   fV0APlaWd  =  0.5;  // Plates thinckness
213 //   fV0APlaAl  = 0.06; // Plates AlMg3 thinckness
214 //   fV0AOctWd  = 0.75; // Innermost octagon thickness
215 //   fV0AOctH1  =  1.0;  // Height of innermost octagon
216 //   fV0AOctH2  =  2.0;  // Height of outtermost octagon
217 //   fV0AFibRd  =  0.1;  // Radius of Fiber
218 //   fV0AFraWd  =  0.2;  // Support Frame thickness
219 //   fV0APMBWd  = 24.6;  // Width of PM Box
220 //   fV0APMBHt  = 22.0;  // Height of PM Box
221 //   fV0APMBTh  =  7.1;  // Thickness of PM Box
222 //   fV0APMBWdW =  0.3;  // Thickness of PM Box Side1 Wall
223 //   fV0APMBHtW =  1.0;  // Thickness of PM Box Side2 Wall
224 //   fV0APMBThW =  0.3;  // Thickness of PM Box Top Wall
225 //   fV0APMBAng = 30.0;  // Angle between PM Box and Support
226 //   fV0APMTR1  = 2.44;  // PMT Glass
227 //   fV0APMTR2  = 2.54;  // PMT Glass
228 //   fV0APMTR3  = 2.54;  // PMT Cover
229 //   fV0APMTR4  = 2.70;  // PMT Cover
230 //   fV0APMTH   = 10.0;  // PMT Height
231 //   fV0APMTB   =  1.0;  // PMT Basis
232 //   fV0APlaEx  =  4.4;  // Plates Extension height
233 //   fV0ABasHt  =  2.0;  // Basis Height
234 //   // V0A Parameters related to light output
235 //   fV0ALightYield         =  93.75;      // Light yield in BC404
236 //   fV0ALightAttenuation   =   0.05;      // Light attenuation in WLS fiber, per meter
237 //   fV0AnMeters            = fV0AR6*0.01; // Tentative value, in meters
238 //   fV0AFibToPhot          =    0.3;      // Attenuation at fiber-photocathode interface
239 }
240 //_____________________________________________________________________________
241
242 void AliVZEROv7::BuildGeometry()
243
244 }
245             
246 //_____________________________________________________________________________
247 void AliVZEROv7::CreateGeometry()
248 {
249 // Constructs TGeo geometry 
250
251   AliDebug(2,"VZERO ConstructGeometry");
252   TGeoVolume *top = gGeoManager->GetVolume("ALIC");
253
254   ///////////////////////////////////////////////////////////////////////////
255   // Construct the geometry of V0C Detector. Brigitte CHEYNIS
256   
257     const int kColorVZERO  = kGreen;
258     TGeoMedium *medV0CAlu = gGeoManager->GetMedium("VZERO_V0CAlu");
259     TGeoMedium *medV0CCar = gGeoManager->GetMedium("VZERO_V0CCar");
260     TGeoMedium *medV0CSci = gGeoManager->GetMedium("VZERO_V0CSci");
261     TGeoVolume *v0RI = new TGeoVolumeAssembly("V0RI");
262     Float_t heightRight, r4Right;
263     Float_t zdet = 90.0 - 0.5 - fV0CBoxThickness/2.0;
264     heightRight  = fV0CHeight1 + fV0CHeight2 + fV0CHeight3 + fV0CHeight4;
265     r4Right      = fV0CRMin + heightRight + 3.0*0.2; // 3 spacings of 2mm between rings
266
267     // Creation of  carbon lids (3.0 mm thick) to keep V0C box shut :
268     Float_t   partube[3];
269     partube[0] =   fV0CRMin;
270     partube[1] =   fV0CRBox;
271     partube[2] =   fV0CLidThickness/2.0;
272     TGeoTube   *sV0CA = new TGeoTube("V0CA", partube[0], partube[1], partube[2]);
273     TGeoVolume *v0CA  = new TGeoVolume("V0CA",sV0CA,medV0CCar);
274     TGeoTranslation *tr2 = new TGeoTranslation(0.,0., fV0CBoxThickness/2.0-partube[2]);
275     TGeoTranslation *tr3 = new TGeoTranslation(0.,0.,-fV0CBoxThickness/2.0+partube[2]);
276     v0RI->AddNode(v0CA,1,tr2);
277     v0RI->AddNode(v0CA,2,tr3);
278     v0CA->SetLineColor(kYellow);
279
280     // Creation of aluminum rings 3.0 mm thick to maintain the v0RI pieces : 
281     partube[0] =   fV0CRMin - 0.3;
282     partube[1] =   fV0CRMin;
283     partube[2] =   fV0CBoxThickness/2.0;
284     TGeoTube   *sV0IR = new TGeoTube("V0IR", partube[0], partube[1], partube[2]);
285     TGeoVolume *v0IR  = new TGeoVolume("V0IR",sV0IR,medV0CAlu);
286     v0RI->AddNode(v0IR,1,0);
287     v0IR->SetLineColor(kYellow);
288     partube[0] =   fV0CRBox;
289     partube[1] =   fV0CRBox + 0.3; 
290     partube[2] =   fV0CBoxThickness/2.0;
291     TGeoTube   *sV0ER = new TGeoTube("V0ER", partube[0], partube[1], partube[2]);
292     TGeoVolume *v0ER  = new TGeoVolume("V0ER",sV0ER,medV0CAlu);
293     v0RI->AddNode(v0ER,1,0);
294     v0ER->SetLineColor(kYellow);
295
296     // Creation of assembly V0R0 of scintillator cells within one sector
297     TGeoVolume *v0R0 = new TGeoVolumeAssembly("V0R0");                                            
298
299     // Elementary cell of ring 1  - right part - :
300     // (cells of ring 1 will be shifted by 2.0 cm backwards to output fibers)
301     Float_t   r1Right =  fV0CRMin + fV0CHeight1;
302     Float_t   offset  = fV0CBoxThickness/2.0 - fV0CLidThickness - fV0CCellThickness/2.0;   
303     Float_t   partubs[5];   
304     partubs[0]     =  fV0CRMin;
305     partubs[1]     =  r1Right;
306     partubs[2]     =  fV0CCellThickness/2.0;
307     partubs[3]     =  90.0-22.5;
308     partubs[4]     = 135.0-22.5;
309     TGeoTubeSeg *sV0R1 = new TGeoTubeSeg("V0R1", partubs[0], partubs[1], partubs[2],
310                                          partubs[3], partubs[4]);
311     TGeoVolume  *v0R1  = new TGeoVolume("V0R1",sV0R1,medV0CSci);                                       
312     TGeoTranslation *tr4 = new TGeoTranslation(0.,0.,-offset);
313     v0R0->AddNode(v0R1,1,tr4);
314     v0R1->SetLineColor(kColorVZERO);
315
316     // Elementary cell of ring 2 - right part - :
317     // (cells of ring 2 will be shifted by 1.0 cm backwards to output fibers)
318     Float_t   r2Right  =  r1Right + fV0CHeight2;  
319     partubs[0]     =  r1Right;  //  must be equal to 7.1
320     partubs[1]     =  r2Right;  //  must be equal to 11.5
321     TGeoTubeSeg *sV0R2 = new TGeoTubeSeg("V0R2", partubs[0], partubs[1], partubs[2],
322                                          partubs[3], partubs[4]);
323     TGeoVolume  *v0R2  = new TGeoVolume("V0R2",sV0R2,medV0CSci);
324     TGeoTranslation *tr5 = new TGeoTranslation(0.0,0.2,-offset + fV0COffsetFibers);
325     v0R0->AddNode(v0R2,1,tr5);
326     v0R2->SetLineColor(kColorVZERO);
327
328     // Ring 3 - right part -  :
329     r2Right  =  r2Right + 0.2;
330     Float_t   r3Right  =  r2Right + fV0CHeight3;     
331     partubs[0]     =  r2Right;  //  must be equal to 11.7
332     partubs[1]     =  r3Right;  //  must be equal to 19.1
333     partubs[3]     =  90.0-22.5;
334     partubs[4]     = 112.5-22.5;
335     TGeoTubeSeg *sV0R3 = new TGeoTubeSeg("V0R3", partubs[0], partubs[1], partubs[2],
336                                          partubs[3], partubs[4]);
337     TGeoVolume  *v0R3  = new TGeoVolume("V0R3",sV0R3,medV0CSci);
338     TGeoTranslation *tr6 = new TGeoTranslation(0.,0.2,-offset + 2.0*fV0COffsetFibers);
339     v0R0->AddNode(v0R3,1,tr6);
340     v0R3->SetLineColor(kColorVZERO);
341     partubs[3]     = 112.5-22.5;
342     partubs[4]     = 135.0-22.5;
343     TGeoTubeSeg *sV0R4 = new TGeoTubeSeg("V0R4", partubs[0], partubs[1], partubs[2],
344                                          partubs[3], partubs[4]);
345     TGeoVolume  *v0R4  = new TGeoVolume("V0R4",sV0R4,medV0CSci);
346     v0R0->AddNode(v0R4,1,tr6);
347     v0R4->SetLineColor(kColorVZERO);
348   
349     // Ring 4 - right part -  : 
350     Float_t x = TMath::ATan(3.5/257.5) * ((180./TMath::Pi()));
351     r3Right = r3Right + 0.2 + 0.2;   // + 0.2 because no shift in translation here !!
352     partubs[0]     =  r3Right;  //  must be equal to 19.5
353     partubs[1]     =  r4Right;  //  must be equal to 32.0
354     partubs[3]     =  90.0-22.5+x;
355     partubs[4]     = 112.5-22.5-x;
356     TGeoTubeSeg *sV0R5 = new TGeoTubeSeg("V0R5", partubs[0], partubs[1], partubs[2],
357                                          partubs[3], partubs[4]);
358     TGeoVolume  *v0R5  = new TGeoVolume("V0R5",sV0R5,medV0CSci);
359     TGeoTranslation *tr7 = new TGeoTranslation(0.,0.0,-offset + 2.0*fV0COffsetFibers);                                        
360     v0R0->AddNode(v0R5,1,tr7);
361     v0R5->SetLineColor(kColorVZERO);
362     partubs[3]     = 112.5-22.5+x;
363     partubs[4]     = 135.0-22.5-x;
364     TGeoTubeSeg *sV0R6 = new TGeoTubeSeg("V0R6", partubs[0], partubs[1], partubs[2],
365                                          partubs[3], partubs[4]);
366     TGeoVolume  *v0R6  = new TGeoVolume("V0R6",sV0R6,medV0CSci);
367     v0R0->AddNode(v0R6,1,tr7);
368     v0R6->SetLineColor(kColorVZERO);
369     Float_t  phi;
370     Float_t  phiDeg= 180./4.;
371     Int_t    nsecR = 1;     // number of sectors in right part of V0
372     for (phi = 22.5; phi < 360.0; phi = phi + phiDeg) {
373       TGeoRotation  *rot1 = new TGeoRotation("rot1", 90.0, +phi, 90., 90.+phi, 0.0, 0.0 ); 
374       v0RI->AddNode(v0R0,nsecR,rot1);    
375       nsecR++;        
376     }
377
378   ///////////////////////////////////////////////////////////////////////////
379   // Construct the geometry of V0A Detector. Carlos PEREZ, PUCP
380   // Revision by Lizardo VALENCIA, UNAM Mexico in July 2008
381
382     const int kV0AColorSci   = 5;
383     const int kV0AColorPlaIn = 3;
384     const int kV0AColorPlaOu = 41;
385     const int kV0AColorOct   = 7;
386     const int kV0AColorFra   = 6;
387     const int kV0AColorFib   = 11;
388     const int kV0AColorPMG   = 1;
389     const int kV0AColorPMA   = 2;
390     TGeoMedium *medV0ASci = gGeoManager->GetMedium("VZERO_V0ASci");
391     TGeoMedium *medV0APlaIn = gGeoManager->GetMedium("VZERO_V0APlaIn");
392     TGeoMedium *medV0APlaOu = gGeoManager->GetMedium("VZERO_V0APlaOu");
393     TGeoMedium *medV0ASup = gGeoManager->GetMedium("VZERO_V0ALuc");
394     TGeoMedium *medV0AFra = gGeoManager->GetMedium("VZERO_V0ALuc");
395     TGeoMedium *medV0AFib = gGeoManager->GetMedium("VZERO_V0AFib");
396     TGeoMedium *medV0APMGlass = gGeoManager->GetMedium("VZERO_V0APMG");
397     TGeoMedium *medV0APMAlum = gGeoManager->GetMedium("VZERO_V0APMA");
398     double pi = TMath::Pi();
399     double sin225   = TMath::Sin(pi/8.);
400     double cos225   = TMath::Cos(pi/8.);
401     double sin45    = TMath::Sin(pi/4.); // lucky: Sin45=Cos45
402     double cos45    = TMath::Cos(pi/4.); 
403     double v0APts[16];
404     double sin654   = TMath::Sin(1.14);
405     double cos654   = TMath::Cos(1.14);
406     
407     ////////////////////////////
408     /// Definition sector 1
409     TGeoVolume *v0ASec = new TGeoVolumeAssembly("V0ASec");
410         
411     /// For boolean sustraction
412     double preShape = 0.2;
413     for (int i=0;i<2;i++) {
414       v0APts[0+8*i] = fV0AR0-fV0AFraWd/2.-preShape;  v0APts[1+8*i] = -preShape;
415       v0APts[2+8*i] = fV0AR0-fV0AFraWd/2.-preShape;  v0APts[3+8*i] = fV0AFraWd/2.;
416       v0APts[4+8*i] = fV0AR4+fV0AFraWd/2.+preShape;  v0APts[5+8*i] = fV0AFraWd/2.;
417       v0APts[6+8*i] = fV0AR4+fV0AFraWd/2.+preShape;  v0APts[7+8*i] = -preShape;
418     }
419     new TGeoArb8("sV0ACha1",fV0ASciWd/1.5,v0APts);
420     for (int i=0;i<2;i++) {
421       v0APts[0+8*i] = fV0AR0*sin45-preShape;
422       v0APts[1+8*i] = (fV0AR0-fV0AFraWd)*sin45-preShape;
423       v0APts[2+8*i] = (fV0AR0-fV0AFraWd/2.)*sin45-preShape;
424       v0APts[3+8*i] = (fV0AR0-fV0AFraWd/2.)*sin45;
425       v0APts[4+8*i] = (fV0AR4+fV0AFraWd/2.)*sin45+preShape;
426       v0APts[5+8*i] = (fV0AR4+fV0AFraWd/2.)*sin45+2.*preShape;
427       v0APts[6+8*i] = (fV0AR4+fV0AFraWd)*sin45+preShape;
428       v0APts[7+8*i] = fV0AR4*sin45+preShape;
429     }
430     new TGeoArb8("sV0ACha2", fV0ASciWd/2.+2.*preShape, v0APts);
431     new TGeoCompositeShape("sV0ACha12","sV0ACha1+sV0ACha2");
432     new TGeoTube("sV0ANail1SciHole", 0.0, 0.4, 1.65);
433     TGeoTranslation *pos1 = new TGeoTranslation("pos1", 42.9, 0.51, 0.0);
434     pos1->RegisterYourself();
435     new TGeoTube("sV0ANail2SciHole", 0.0, 0.4, 1.65);
436     TGeoTranslation *pos2 = new TGeoTranslation("pos2", 30.73,29.98,0.0);
437     pos2->RegisterYourself();
438     new TGeoCompositeShape("sV0ANailsSciHoles","sV0ANail1SciHole:pos1+sV0ANail2SciHole:pos2");
439     new TGeoCompositeShape("sV0ACha","sV0ACha12+sV0ANailsSciHoles");
440     new TGeoTubeSeg("sV0AFicR5", fV0AR4+fV0AFraWd/2., fV0AR4 + fV0AR0, fV0ASciWd/2.+2*preShape, 0, 45);
441        
442     /// Frame
443     TGeoVolume *v0AFra = new TGeoVolumeAssembly("V0AFra");
444     for (int i=0;i<2;i++) {
445       v0APts[0+8*i] = fV0AR0-fV0AFraWd/2.;  v0APts[1+8*i] = 0.;
446       v0APts[2+8*i] = fV0AR0-fV0AFraWd/2.;  v0APts[3+8*i] = fV0AFraWd/2.;
447       v0APts[4+8*i] = fV0AR4+fV0AFraWd/2.;  v0APts[5+8*i] = fV0AFraWd/2.;
448       v0APts[6+8*i] = fV0AR4+fV0AFraWd/2.;  v0APts[7+8*i] = 0.;
449     }
450     TGeoArb8 *sV0AFraB1 = new TGeoArb8("sV0AFraB1",fV0ASciWd/2.,v0APts);
451     TGeoVolume *v0AFraB1 = new TGeoVolume("V0AFraB1",sV0AFraB1,medV0AFra);
452     for (int i=0;i<2;i++) {
453       v0APts[0+8*i] = fV0AR0*sin45;
454       v0APts[1+8*i] = (fV0AR0-fV0AFraWd)*sin45;
455       v0APts[2+8*i] = (fV0AR0-fV0AFraWd/2.)*sin45;
456       v0APts[3+8*i] = (fV0AR0-fV0AFraWd/2.)*sin45;
457       v0APts[4+8*i] = (fV0AR4+fV0AFraWd/2.)*sin45;
458       v0APts[5+8*i] = (fV0AR4+fV0AFraWd/2.)*sin45;
459       v0APts[6+8*i] = (fV0AR4+fV0AFraWd)*sin45;
460       v0APts[7+8*i] = fV0AR4*sin45;
461     }
462     TGeoArb8 *sV0AFraB2 = new TGeoArb8("sV0AFraB2", fV0ASciWd/2., v0APts);
463     TGeoVolume *v0AFraB2 = new TGeoVolume("V0AFraB2",sV0AFraB2,medV0AFra);
464     v0AFraB1->SetLineColor(kV0AColorFra); v0AFraB2->SetLineColor(kV0AColorFra);
465     v0AFra->AddNode(v0AFraB1,1);
466     v0AFra->AddNode(v0AFraB2,1);  
467     new TGeoTubeSeg( "sV0AFraR1b", fV0AR0-fV0AFraWd/2.,
468                      fV0AR0+fV0AFraWd/2., fV0ASciWd/2., 0, 45);
469     new TGeoTubeSeg( "sV0AFraR2b", fV0AR1-fV0AFraWd/2.,
470                      fV0AR1+fV0AFraWd/2., fV0ASciWd/2., 0, 45);
471     new TGeoTubeSeg( "sV0AFraR3b", fV0AR2-fV0AFraWd/2.,
472                      fV0AR2+fV0AFraWd/2., fV0ASciWd/2., 0, 45);
473     new TGeoTubeSeg( "sV0AFraR4b", fV0AR3-fV0AFraWd/2.,
474                      fV0AR3+fV0AFraWd/2., fV0ASciWd/2., 0, 45);
475     new TGeoTubeSeg( "sV0AFraR5b", fV0AR4-fV0AFraWd/2.,
476                      fV0AR4+fV0AFraWd/2., fV0ASciWd/2., 0, 45);
477     TGeoCompositeShape *sV0AFraR1 = new TGeoCompositeShape("sV0AFraR1","sV0AFraR1b-sV0ACha");
478     TGeoCompositeShape *sV0AFraR2 = new TGeoCompositeShape("sV0AFraR2","sV0AFraR2b-sV0ACha");
479     TGeoCompositeShape *sV0AFraR3 = new TGeoCompositeShape("sV0AFraR3","sV0AFraR3b-sV0ACha");
480     TGeoCompositeShape *sV0AFraR4 = new TGeoCompositeShape("sV0AFraR4","sV0AFraR4b-sV0ACha");
481     TGeoCompositeShape *sV0AFraR5 = new TGeoCompositeShape("sV0AFraR5","sV0AFraR5b-sV0ACha");
482     TGeoVolume *v0AFraR1 = new TGeoVolume("V0AFraR1",sV0AFraR1,medV0AFra);
483     TGeoVolume *v0AFraR2 = new TGeoVolume("V0AFraR2",sV0AFraR2,medV0AFra);
484     TGeoVolume *v0AFraR3 = new TGeoVolume("V0AFraR3",sV0AFraR3,medV0AFra);
485     TGeoVolume *v0AFraR4 = new TGeoVolume("V0AFraR4",sV0AFraR4,medV0AFra);
486     TGeoVolume *v0AFraR5 = new TGeoVolume("V0AFraR5",sV0AFraR5,medV0AFra);
487     v0AFraR1->SetLineColor(kV0AColorFra); v0AFraR2->SetLineColor(kV0AColorFra);
488     v0AFraR3->SetLineColor(kV0AColorFra); v0AFraR4->SetLineColor(kV0AColorFra);
489     v0AFraR5->SetLineColor(kV0AColorFra);
490     v0AFra->AddNode(v0AFraR1,1); 
491     v0AFra->AddNode(v0AFraR2,1);
492     v0AFra->AddNode(v0AFraR3,1); 
493     v0AFra->AddNode(v0AFraR4,1);
494     v0AFra->AddNode(v0AFraR5,1);
495     v0ASec->AddNode(v0AFra,1);
496
497     /// Sensitive scintilator
498     TGeoVolume *v0ASci = new TGeoVolumeAssembly("V0ASci");
499     new TGeoTubeSeg( "sV0AR1b", fV0AR0+fV0AFraWd/2.,
500                      fV0AR1-fV0AFraWd/2., fV0ASciWd/2., 0, 45);
501     new TGeoTubeSeg( "sV0AR2b", fV0AR1+fV0AFraWd/2.,
502                      fV0AR2-fV0AFraWd/2., fV0ASciWd/2., 0, 45);
503     new TGeoTubeSeg( "sV0AR3b", fV0AR2+fV0AFraWd/2.,
504                      fV0AR3-fV0AFraWd/2., fV0ASciWd/2., 0, 45);
505     new TGeoTubeSeg( "sV0AR4b", fV0AR3+fV0AFraWd/2.,
506                      fV0AR4-fV0AFraWd/2., fV0ASciWd/2., 0, 45);
507     TGeoCompositeShape *sV0AR1 = new TGeoCompositeShape("sV0AR1","sV0AR1b-sV0ACha");
508     TGeoCompositeShape *sV0AR2 = new TGeoCompositeShape("sV0AR2","sV0AR2b-sV0ACha");
509     TGeoCompositeShape *sV0AR3 = new TGeoCompositeShape("sV0AR3","sV0AR3b-sV0ACha");
510     TGeoCompositeShape *sV0AR4 = new TGeoCompositeShape("sV0AR4","sV0AR4b-sV0ACha");
511     TGeoVolume *v0L1 = new TGeoVolume("V0L1",sV0AR1,medV0ASci);
512     TGeoVolume *v0L2 = new TGeoVolume("V0L2",sV0AR2,medV0ASci);
513     TGeoVolume *v0L3 = new TGeoVolume("V0L3",sV0AR3,medV0ASci);
514     TGeoVolume *v0L4 = new TGeoVolume("V0L4",sV0AR4,medV0ASci);
515     v0L1->SetLineColor(kV0AColorSci); v0L2->SetLineColor(kV0AColorSci);
516     v0L3->SetLineColor(kV0AColorSci); v0L4->SetLineColor(kV0AColorSci);
517     v0ASec->AddNode(v0L1,1);
518     v0ASec->AddNode(v0L2,1);
519     v0ASec->AddNode(v0L3,1);
520     v0ASec->AddNode(v0L4,1);      
521     
522     /// Segment of octagon 
523     for (int i=0;i<2;i++) {
524     v0APts[0+8*i] =  fV0AR6-fV0AOctH2;  v0APts[1+8*i] = 0.;
525       v0APts[2+8*i] = (fV0AR6-fV0AOctH2)*sin45;  v0APts[3+8*i] = (fV0AR6-fV0AOctH2)*sin45;
526       v0APts[4+8*i] = fV0AR6*sin45;             v0APts[5+8*i] = fV0AR6*sin45;
527       v0APts[6+8*i] = fV0AR6;                   v0APts[7+8*i] = 0.;
528     }
529     TGeoArb8 *sV0AOct2 = new TGeoArb8("sV0AOct2", (fV0ASciWd+2*fV0AOctWd)/2., v0APts);
530     TGeoVolume *v0AOct2 = new TGeoVolume("V0AOct2", sV0AOct2,medV0ASup);
531     v0AOct2->SetLineColor(kV0AColorOct);
532     TGeoVolume *v0ASup = new TGeoVolumeAssembly("V0ASup");
533     v0ASup->AddNode(v0AOct2,1);
534     v0ASec->AddNode(v0ASup,1);
535
536     //Bunch of fibers
537     v0APts[ 0] = v0APts[ 2] = -13.0;
538     v0APts[ 1] = v0APts[ 7] = (fV0ASciWd+fV0AOctWd)/2.-0.01;
539     v0APts[ 3] = v0APts[ 5] = (fV0ASciWd+fV0AOctWd)/2.+0.01;
540     v0APts[ 4] = v0APts[ 6] = +13.0;
541     v0APts[ 8] = v0APts[10] = -10.0;
542     v0APts[ 9] = v0APts[15] = 0.;
543     v0APts[11] = v0APts[13] = 0.25;
544     v0APts[12] = v0APts[14] = +10.0;
545     new TGeoArb8("sV0AFib1", 11.5, v0APts);
546     TGeoRotation *rot = new TGeoRotation("rot");
547     rot->RotateX(-90);
548     rot->RotateZ(-90.+22.5);
549     TGeoCombiTrans *fibpos1 = new TGeoCombiTrans("fibpos1", (fV0AR6-fV0AOctH2+fV0AR5)*cos225/2. - 3.8, (fV0AR6-fV0AOctH2+fV0AR5)*sin225/2.-1.8, 0, rot);
550     fibpos1->RegisterYourself();
551     TGeoCompositeShape *sV0AFib1Hole = new TGeoCompositeShape("sV0AFib1Hole","sV0AFib1:fibpos1-sV0AFicR5"); 
552     TGeoVolume *v0AFib1Hole = new TGeoVolume("V0AFib1Hole",sV0AFib1Hole,medV0AFib);
553     v0AFib1Hole->SetLineColor(kV0AColorFib);
554     new TGeoArb8("sV0AFib2", 11.5, v0APts);
555     rot = new TGeoRotation("rot");
556     rot->RotateX(-90);
557     rot->RotateY(180);
558     rot->RotateZ(-90.+22.5);
559     TGeoCombiTrans *fibpos2 = new TGeoCombiTrans("fibpos2", (fV0AR6-fV0AOctH2+fV0AR5)*cos225/2. - 3.8, (fV0AR6-fV0AOctH2+fV0AR5)*sin225/2.-1.8, 0, rot);
560     fibpos2->RegisterYourself();
561     TGeoCompositeShape *sV0AFib2Hole = new TGeoCompositeShape("sV0AFib2Hole","sV0AFib2:fibpos2-sV0AFicR5");
562     TGeoVolume *v0AFib2Hole = new TGeoVolume("V0AFib2Hole",sV0AFib2Hole,medV0AFib);
563     v0AFib2Hole->SetLineColor(kV0AColorFib);
564     TGeoVolume *v0AFib = new TGeoVolumeAssembly("V0AFib");
565     v0AFib->AddNode(v0AFib1Hole,1);
566     v0AFib->AddNode(v0AFib2Hole,1);
567     v0ASec->AddNode(v0AFib,1); 
568     
569      /// Plates
570     new TGeoTube("sV0ANail1PlaInHole", 0.0, 0.4, (fV0APlaWd-2*fV0APlaAl)/2.);
571     new TGeoTube("sV0ANail2PlaInHole", 0.0, 0.4, (fV0APlaWd-2*fV0APlaAl)/2.);
572     new TGeoCompositeShape("sV0ANailsPlaInHoles","sV0ANail1PlaInHole:pos1+sV0ANail2PlaInHole:pos2");
573     new TGeoTube("sV0ANail1PlaOuHole", 0.0, 0.4, (fV0APlaAl)/2.);
574     new TGeoTube("sV0ANail2PlaOuHole", 0.0, 0.4, (fV0APlaAl)/2.);
575     new TGeoCompositeShape("sV0ANailsPlaOuHoles","sV0ANail1PlaOuHole:pos1+sV0ANail2PlaOuHole:pos2");
576     for (int i=0;i<2;i++) {
577       v0APts[0+8*i] = fV0AR0;                   v0APts[1+8*i] = 0.;
578       v0APts[2+8*i] = fV0AR0*sin45;             v0APts[3+8*i] = fV0AR0*sin45;
579       v0APts[4+8*i] = fV0AR6 * sin45;   v0APts[5+8*i] = fV0AR6*sin45;
580       v0APts[6+8*i] = fV0AR6;           v0APts[7+8*i] = 0.;
581     }
582     new TGeoArb8("sV0APlaIn", (fV0APlaWd-2*fV0APlaAl)/2., v0APts);
583     TGeoCompositeShape *sV0APlaInNailsHoles = new TGeoCompositeShape("sV0APlaInNailsHoles","sV0APlaIn-sV0ANailsPlaInHoles");
584     TGeoVolume *v0APlaInNailsHoles = new TGeoVolume("V0APlaInNailsHoles", sV0APlaInNailsHoles, medV0APlaIn);
585     new TGeoArb8("sV0APlaOu", fV0APlaAl/2., v0APts);
586     TGeoCompositeShape *sV0APlaOuNailsHoles = new TGeoCompositeShape("sV0APlaOuNailsHoles","sV0APlaOu-sV0ANailsPlaOuHoles"); 
587     TGeoVolume *v0APlaOuNailsHoles = new TGeoVolume("V0APlaOuNailsHoles", sV0APlaOuNailsHoles, medV0APlaOu);
588     v0APlaInNailsHoles->SetLineColor(kV0AColorPlaIn); v0APlaOuNailsHoles->SetLineColor(kV0AColorPlaOu);
589     TGeoVolume *v0APla = new TGeoVolumeAssembly("V0APla");
590     v0APla->AddNode(v0APlaInNailsHoles,1);
591     v0APla->AddNode(v0APlaOuNailsHoles,1,new TGeoTranslation(0,0,(fV0APlaWd-fV0APlaAl)/2.));
592     v0APla->AddNode(v0APlaOuNailsHoles,2,new TGeoTranslation(0,0,-(fV0APlaWd-fV0APlaAl)/2.));
593     v0ASec->AddNode(v0APla,1,new TGeoTranslation(0,0,(fV0ASciWd+2*fV0AOctWd+fV0APlaWd)/2.));
594     v0ASec->AddNode(v0APla,2,new TGeoTranslation(0,0,-(fV0ASciWd+2*fV0AOctWd+fV0APlaWd)/2.));
595     
596      /// Non-sensitive scintilator
597     new TGeoTubeSeg("sV0AR5S2", fV0AR4+fV0AFraWd/2., fV0AR4 + fV0AR0, fV0ASciWd/2.+2*preShape, 0, 45);
598     TGeoCompositeShape *sV0AR5 = new TGeoCompositeShape("V0AR5","sV0AR5S2 - sV0ACha");
599     TGeoVolume *v0AR5 = new TGeoVolume("V0AR5",sV0AR5,medV0ASci);
600     v0AR5->SetLineColor(kV0AColorSci);
601     v0ASci->AddNode(v0AR5,1);
602     v0ASec->AddNode(v0ASci,1); 
603
604     /// PMBox
605     TGeoVolume* v0APM = new TGeoVolumeAssembly("V0APM");
606     new TGeoBBox("sV0APMB1", fV0APMBWd/2., fV0APMBHt/2., fV0APMBTh/2.);
607     new TGeoBBox("sV0APMB2", fV0APMBWd/2.-fV0APMBWdW, fV0APMBHt/2.-fV0APMBHtW, fV0APMBTh/2.-fV0APMBThW);
608     TGeoCompositeShape *sV0APMB = new TGeoCompositeShape("sV0APMB","sV0APMB1-sV0APMB2");
609     TGeoVolume *v0APMB = new TGeoVolume("V0APMB",sV0APMB, medV0APMAlum);
610     v0APMB->SetLineColor(kV0AColorPMA);
611     v0APM->AddNode(v0APMB,1);
612
613     /// PMTubes
614     TGeoTube *sV0APMT1 = new TGeoTube("sV0APMT1", fV0APMTR1, fV0APMTR2, fV0APMTH/2.);
615     TGeoVolume *v0APMT1 = new TGeoVolume("V0APMT1", sV0APMT1, medV0APMGlass);
616     TGeoTube *sV0APMT2 = new TGeoTube("sV0APMT2", fV0APMTR3, fV0APMTR4, fV0APMTH/2.);
617     TGeoVolume *v0APMT2 = new TGeoVolume("V0APMT2", sV0APMT2, medV0APMAlum);
618     TGeoVolume *v0APMT = new TGeoVolumeAssembly("V0APMT");
619     TGeoTube *sV0APMTT = new TGeoTube("sV0APMTT", 0., fV0APMTR4, fV0APMTB/2.);
620     TGeoVolume *v0APMTT = new TGeoVolume("V0APMTT", sV0APMTT, medV0APMAlum);
621     v0APMT1->SetLineColor(kV0AColorPMG);
622     v0APMT2->SetLineColor(kV0AColorPMA);
623     v0APMTT->SetLineColor(kV0AColorPMA);
624     rot = new TGeoRotation("rot", 90, 0, 180, 0, 90, 90);
625     v0APMT->AddNode(v0APMT1,1,rot);
626     v0APMT->AddNode(v0APMT2,1,rot);
627     v0APMT->AddNode(v0APMTT,1,new TGeoCombiTrans(0,-(fV0APMTH+fV0APMTB)/2.,0,rot));
628     double autoShift = (fV0APMBWd-2*fV0APMBWdW)/4.;
629     v0APM->AddNode(v0APMT, 1, new TGeoTranslation(-1.5*autoShift, 0, 0));
630     v0APM->AddNode(v0APMT, 2, new TGeoTranslation(-0.5*autoShift, 0, 0));
631     v0APM->AddNode(v0APMT, 3, new TGeoTranslation(+0.5*autoShift, 0, 0));
632     v0APM->AddNode(v0APMT, 4, new TGeoTranslation(+1.5*autoShift, 0, 0));
633
634     /// PM
635     rot = new TGeoRotation("rot");
636     rot->RotateX(90-fV0APMBAng);
637     rot->RotateZ(-90.+22.5);
638     double cosAngPMB = TMath::Cos(fV0APMBAng*TMath::DegToRad());
639     double sinAngPMB = TMath::Sin(fV0APMBAng*TMath::DegToRad());
640     double shiftZ = fV0APMBHt/2. * cosAngPMB
641       -   ( fV0ASciWd + 2 * fV0AOctWd + 2 * fV0APlaWd )/2.   -   fV0APMBTh/2. * sinAngPMB;
642     double shiftR = fV0AR6  +  fV0AOctH2 + fV0APlaAl;
643     v0ASec->AddNode(v0APM,1, new TGeoCombiTrans( shiftR*cos225+1.07, shiftR*sin225, shiftZ, rot));
644     
645     // Aluminium nails 
646     TGeoTube *sV0ANail1 = new TGeoTube("sV0ANail1", 0.0, 0.4, 5.09/2.);
647     TGeoVolume *v0ANail1 = new TGeoVolume("V0ANail1", sV0ANail1, medV0APMAlum);
648     v0ANail1->SetLineColor(kV0AColorPMA);// this is the color for aluminium
649     v0ASec->AddNode(v0ANail1,1,new TGeoTranslation(42.9, 0.51, 0.0));
650     TGeoTube *sV0ANail2 = new TGeoTube("sV0ANail2", 0.0, 0.4, 5.09/2.);
651     TGeoVolume *v0ANail2 = new TGeoVolume("V0ANail2", sV0ANail2, medV0APMAlum);
652     v0ANail2->SetLineColor(kV0AColorPMA);
653     v0ASec->AddNode(v0ANail2,1,new TGeoTranslation(30.73,29.98,0.0));
654         
655     /// Replicate sectors and adding sector to v0LE volume
656     TGeoVolume *v0LE = new TGeoVolumeAssembly("V0LE");
657     for(int i=0; i<4; i++) {
658        TGeoRotation *rotation = new TGeoRotation("rotation", 90., i*45., 90., 90.+i*45., 0., 0.);
659        v0LE->AddNode(v0ASec,i+1,rotation);  
660     }
661    
662     //Upper supports
663     for (int i=0;i<2;i++){
664     v0APts[0+8*i] = 0.0;            v0APts[1+8*i] = 45.5;  
665     v0APts[2+8*i] = 0.0;            v0APts[3+8*i] = 70.4;   
666     v0APts[4+8*i] = 4.0;            v0APts[5+8*i] = 68.9;
667     v0APts[6+8*i] = 4.0;            v0APts[7+8*i] = 45.5;  
668     }
669     TGeoArb8 *sV0ASuppur = new TGeoArb8("sV0ASuppur", 1.65, v0APts);    
670     TGeoVolume *v0ASuppur = new TGeoVolume("V0ASuppur", sV0ASuppur, medV0ASup);
671     v0ASuppur->SetLineColor(kV0AColorOct);
672     v0LE->AddNode(v0ASuppur,1);
673     for (int i=0;i<2;i++){
674     v0APts[0+8*i] = -0.0;           v0APts[1+8*i] = 45.5;
675     v0APts[2+8*i] = -0.0;           v0APts[3+8*i] = 70.4;
676     v0APts[4+8*i] = -4.0;           v0APts[5+8*i] = 68.9;
677     v0APts[6+8*i] = -4.0;           v0APts[7+8*i] = 45.5;
678     }
679     TGeoArb8 *sV0ASuppul = new TGeoArb8("sV0ASuppul", 1.65, v0APts);    
680     TGeoVolume *v0ASuppul = new TGeoVolume("V0ASuppul", sV0ASuppul, medV0ASup);
681     v0ASuppul->SetLineColor(kV0AColorOct);
682     v0LE->AddNode(v0ASuppul,1);
683   
684
685     //Definition of sector 5
686     TGeoVolume *v0ASec5 = new TGeoVolumeAssembly("V0ASec5"); 
687
688     /// For boolean sustraction
689     double preShape5 = 0.2;
690     for (int i=0;i<2;i++) {
691       v0APts[0+8*i] = -fV0AR0+fV0AFraWd/2.-preShape5;  v0APts[1+8*i] = -preShape5;
692       v0APts[2+8*i] = -fV0AR0+fV0AFraWd/2.-preShape5;  v0APts[3+8*i] = fV0AFraWd/2.;
693       v0APts[4+8*i] = -fV0AR4-fV0AFraWd/2.+preShape5;  v0APts[5+8*i] = fV0AFraWd/2.;
694       v0APts[6+8*i] = -fV0AR4-fV0AFraWd/2.+preShape5;  v0APts[7+8*i] = -preShape5;
695     }
696     new TGeoArb8("sV0ACha15",fV0ASciWd/1.5,v0APts);
697     for (int i=0;i<2;i++) {
698       v0APts[0+8*i] = -fV0AR0*cos45+preShape;
699       v0APts[1+8*i] = -(fV0AR0-fV0AFraWd)*sin45+preShape;
700       v0APts[2+8*i] = -(fV0AR0-fV0AFraWd/2.)*cos45+preShape;
701       v0APts[3+8*i] = -(fV0AR0-fV0AFraWd/2.)*sin45;
702       v0APts[4+8*i] = -(fV0AR4+fV0AFraWd/2.)*cos45-preShape;
703       v0APts[5+8*i] = -(fV0AR4+fV0AFraWd/2.)*sin45-2.*preShape;
704       v0APts[6+8*i] = -(fV0AR4+fV0AFraWd)*cos45-preShape;
705       v0APts[7+8*i] = -fV0AR4*sin45-preShape;
706     }
707     new TGeoArb8("sV0ACha25", fV0ASciWd/2.+2.*preShape5, v0APts);
708     new TGeoCompositeShape("sV0ACha125","sV0ACha15+sV0ACha25");
709     new TGeoTube("sV0ANail15Hole", 0.0, 0.4, 1.65);
710     TGeoTranslation *pos15 = new TGeoTranslation("pos15", -42.9, -0.51, 0.0);
711     pos15->RegisterYourself();
712     new TGeoTube("sV0ANail25Hole", 0.0, 0.4, 1.65);
713     TGeoTranslation *pos25 = new TGeoTranslation("pos25",-30.8,-30.04,0.0); 
714     pos25->RegisterYourself();
715     TGeoTranslation *pos35 = new TGeoTranslation("pos35",-30.05,-30.79,0.0);  
716     pos35->RegisterYourself();
717     new TGeoCompositeShape("sV0ANailsHoles5","sV0ANail15Hole:pos15+sV0ANail25Hole:pos25");
718     new TGeoCompositeShape("sV0ACha5","sV0ACha125+sV0ANailsHoles5");
719     new TGeoTubeSeg("sV0AFicR55", fV0AR4+fV0AFraWd/2., fV0AR4 + fV0AR0, fV0ASciWd/2. +2*preShape, 180.0, 225.0);
720     new TGeoTube("sV0ANail1PlaInHole5", 0.0, 0.4, (fV0APlaWd-2*fV0APlaAl)/2.);
721     new TGeoTube("sV0ANail2PlaInHole5", 0.0, 0.4, (fV0APlaWd-2*fV0APlaAl)/2.);
722     new TGeoTube("sV0ANail3PlaInHole5", 0.0, 0.4, (fV0APlaWd-2*fV0APlaAl)/2.);
723     new TGeoCompositeShape("sV0ANailsPlaInHoles5","sV0ANail1PlaInHole5:pos15+sV0ANail2PlaInHole5:pos25+sV0ANail3PlaInHole5:pos35");
724     new TGeoTube("sV0ANail1PlaOuHole5", 0.0, 0.4, (fV0APlaAl)/2.);
725     new TGeoTube("sV0ANail2PlaOuHole5", 0.0, 0.4, (fV0APlaAl)/2.);
726     new TGeoTube("sV0ANail3PlaOuHole5", 0.0, 0.4, (fV0APlaAl)/2.);
727     new TGeoCompositeShape("sV0ANailsPlaOuHoles5","sV0ANail1PlaOuHole5:pos15+sV0ANail2PlaOuHole5:pos25+sV0ANail3PlaOuHole5:pos35");
728
729     /// Frame
730     TGeoVolume *v0AFra5 = new TGeoVolumeAssembly("V0AFra5");
731     for (int i=0;i<2;i++) {
732       v0APts[0+8*i] = -fV0AR0+fV0AFraWd/2.;  v0APts[1+8*i] = 0.0;
733       v0APts[2+8*i] = -fV0AR0+fV0AFraWd/2.;  v0APts[3+8*i] = fV0AFraWd/2.;
734       v0APts[4+8*i] = -fV0AR4-fV0AFraWd/2.;  v0APts[5+8*i] = fV0AFraWd/2.;
735       v0APts[6+8*i] = -fV0AR4-fV0AFraWd/2.;  v0APts[7+8*i] = 0.0;
736     }    
737     TGeoArb8 *sV0AFraB15 = new TGeoArb8("sV0AFraB15",fV0ASciWd/2.,v0APts);
738     TGeoVolume *v0AFraB15 = new TGeoVolume("V0AFraB15",sV0AFraB15,medV0AFra);
739     for (int i=0;i<2;i++) {
740       v0APts[0+8*i] = -fV0AR0*cos45;
741       v0APts[1+8*i] = -(fV0AR0-fV0AFraWd)*sin45;
742       v0APts[2+8*i] = -(fV0AR0-fV0AFraWd/2.)*cos45;
743       v0APts[3+8*i] = -(fV0AR0-fV0AFraWd/2.)*sin45;
744       v0APts[4+8*i] = -(fV0AR4+fV0AFraWd/2.)*cos45;
745       v0APts[5+8*i] = -(fV0AR4+fV0AFraWd/2.)*sin45;
746       v0APts[6+8*i] = -(fV0AR4+fV0AFraWd)*cos45;
747       v0APts[7+8*i] = -fV0AR4*sin45;
748     }
749     TGeoArb8 *sV0AFraB25 = new TGeoArb8("sV0AFraB25", fV0ASciWd/2., v0APts);
750     TGeoVolume *v0AFraB25 = new TGeoVolume("V0AFraB25",sV0AFraB25,medV0AFra);
751     v0AFraB15->SetLineColor(kV0AColorFra); v0AFraB25->SetLineColor(kV0AColorFra);
752     v0AFra5->AddNode(v0AFraB15,1);
753     v0AFra5->AddNode(v0AFraB25,1);  // Prefer 2 GeoObjects insted of 3 GeoMovements
754     new TGeoTubeSeg( "sV0AFraR1b5", fV0AR0-fV0AFraWd/2.,
755                      fV0AR0+fV0AFraWd/2., fV0ASciWd/2., 180.0, 225.0);
756     new TGeoTubeSeg( "sV0AFraR2b5", fV0AR1-fV0AFraWd/2.,
757                      fV0AR1+fV0AFraWd/2., fV0ASciWd/2., 180.0, 225.0);
758     new TGeoTubeSeg( "sV0AFraR3b5", fV0AR2-fV0AFraWd/2.,
759                      fV0AR2+fV0AFraWd/2., fV0ASciWd/2., 180.0, 225.0);
760     new TGeoTubeSeg( "sV0AFraR4b5", fV0AR3-fV0AFraWd/2.,
761                      fV0AR3+fV0AFraWd/2., fV0ASciWd/2., 180.0, 225.0);
762     new TGeoTubeSeg( "sV0AFraR5b5", fV0AR4-fV0AFraWd/2.,
763                      fV0AR4+fV0AFraWd/2., fV0ASciWd/2., 180.0, 225.0);
764     TGeoCompositeShape *sV0AFraR15 = new TGeoCompositeShape("sV0AFraR15","sV0AFraR1b5-sV0ACha5");
765     TGeoCompositeShape *sV0AFraR25 = new TGeoCompositeShape("sV0AFraR25","sV0AFraR2b5-sV0ACha5");
766     TGeoCompositeShape *sV0AFraR35 = new TGeoCompositeShape("sV0AFraR35","sV0AFraR3b5-sV0ACha5");
767     TGeoCompositeShape *sV0AFraR45 = new TGeoCompositeShape("sV0AFraR45","sV0AFraR4b5-sV0ACha5");
768     TGeoCompositeShape *sV0AFraR55 = new TGeoCompositeShape("sV0AFraR55","sV0AFraR5b5-sV0ACha5");
769     TGeoVolume *v0AFraR15 = new TGeoVolume("V0AFraR15",sV0AFraR15,medV0AFra);
770     TGeoVolume *v0AFraR25 = new TGeoVolume("V0AFraR25",sV0AFraR25,medV0AFra);
771     TGeoVolume *v0AFraR35 = new TGeoVolume("V0AFraR35",sV0AFraR35,medV0AFra);
772     TGeoVolume *v0AFraR45 = new TGeoVolume("V0AFraR45",sV0AFraR45,medV0AFra);
773     TGeoVolume *v0AFraR55 = new TGeoVolume("V0AFraR55",sV0AFraR55,medV0AFra);
774     v0AFraR15->SetLineColor(kV0AColorFra); v0AFraR25->SetLineColor(kV0AColorFra);
775     v0AFraR35->SetLineColor(kV0AColorFra); v0AFraR45->SetLineColor(kV0AColorFra);
776     v0AFraR55->SetLineColor(kV0AColorFra);
777     v0AFra5->AddNode(v0AFraR15,1);
778     v0AFra5->AddNode(v0AFraR25,1);
779     v0AFra5->AddNode(v0AFraR35,1);
780     v0AFra5->AddNode(v0AFraR45,1);
781     v0AFra5->AddNode(v0AFraR55,1);
782     v0ASec5->AddNode(v0AFra5,1);
783
784     /// Sensitive scintilator
785     TGeoVolume *v0ASci5 = new TGeoVolumeAssembly("V0ASci5");
786     new TGeoTubeSeg( "sV0AR1b5", fV0AR0+fV0AFraWd/2.,
787                      fV0AR1-fV0AFraWd/2., fV0ASciWd/2., 180.0, 225.0);
788     new TGeoTubeSeg( "sV0AR2b5", fV0AR1+fV0AFraWd/2.,
789                      fV0AR2-fV0AFraWd/2., fV0ASciWd/2., 180.0, 225.0);
790     new TGeoTubeSeg( "sV0AR3b5", fV0AR2+fV0AFraWd/2.,
791                      fV0AR3-fV0AFraWd/2., fV0ASciWd/2., 180.0, 225.0);
792     new TGeoTubeSeg( "sV0AR4b5", fV0AR3+fV0AFraWd/2.,
793                      fV0AR4-fV0AFraWd/2., fV0ASciWd/2., 180.0, 225.0);
794     TGeoCompositeShape *sV0AR15 = new TGeoCompositeShape("sV0AR15","sV0AR1b5-sV0ACha5");
795     TGeoCompositeShape *sV0AR25 = new TGeoCompositeShape("sV0AR25","sV0AR2b5-sV0ACha5");
796     TGeoCompositeShape *sV0AR35 = new TGeoCompositeShape("sV0AR35","sV0AR3b5-sV0ACha5");
797     TGeoCompositeShape *sV0AR45 = new TGeoCompositeShape("sV0AR45","sV0AR4b5-sV0ACha5");
798     TGeoVolume *v0L15 = new TGeoVolume("V0L15",sV0AR15,medV0ASci);
799     TGeoVolume *v0L25 = new TGeoVolume("V0L25",sV0AR25,medV0ASci);
800     TGeoVolume *v0L35 = new TGeoVolume("V0L35",sV0AR35,medV0ASci);
801     TGeoVolume *v0L45 = new TGeoVolume("V0L45",sV0AR45,medV0ASci);
802     v0L15->SetLineColor(kV0AColorSci); v0L25->SetLineColor(kV0AColorSci);
803     v0L35->SetLineColor(kV0AColorSci); v0L45->SetLineColor(kV0AColorSci);
804     v0ASci5->AddNode(v0L15,1);
805     v0ASci5->AddNode(v0L25,1);
806     v0ASci5->AddNode(v0L35,1);
807     v0ASci5->AddNode(v0L45,1);
808
809      /// Segment of octagon  
810     for (int i=0;i<2;i++) {
811     v0APts[0+8*i] = -fV0AR6+fV0AOctH2;           v0APts[1+8*i] = 0.;
812     v0APts[2+8*i] = -(fV0AR7-fV0AOctH2)*cos654;   v0APts[3+8*i] = -(fV0AR7-fV0AOctH2)*sin654;
813     v0APts[4+8*i] = -fV0AR7*cos654;              v0APts[5+8*i] = -fV0AR7*sin654;
814     v0APts[6+8*i] = -fV0AR6;                     v0APts[7+8*i] = 0.;
815     }
816     TGeoArb8 *sV0AOct25 = new TGeoArb8("sV0AOct25", (fV0ASciWd+2*fV0AOctWd)/2., v0APts);
817     TGeoVolume *v0AOct25 = new TGeoVolume("V0AOct25", sV0AOct25,medV0ASup);
818     v0AOct25->SetLineColor(kV0AColorOct);
819     TGeoVolume *v0ASup5 = new TGeoVolumeAssembly("V0ASup5");
820     v0ASup5->AddNode(v0AOct25,1);
821     v0ASec5->AddNode(v0ASup5,1);
822
823     //Bunch of fibers
824     v0APts[ 0] = v0APts[ 2] = -14.0;
825     v0APts[ 1] = v0APts[ 7] = (fV0ASciWd+fV0AOctWd)/2.-0.01;
826     v0APts[ 3] = v0APts[ 5] = (fV0ASciWd+fV0AOctWd)/2.+0.01;
827     v0APts[ 4] = v0APts[ 6] = +14.0;
828     v0APts[ 8] = v0APts[10] = -10.0;
829     v0APts[ 9] = v0APts[15] = 0.;
830     v0APts[11] = v0APts[13] = 0.25;
831     v0APts[12] = v0APts[14] = +10.0;
832     new TGeoArb8("sV0AFib15", 11.8, v0APts); 
833     rot = new TGeoRotation("rot");
834     rot->RotateX(-90);
835     rot->RotateZ(90+22.5);
836     TGeoCombiTrans *fib15pos = new TGeoCombiTrans("fib15pos", -(fV0AR6-fV0AOctH2+fV0AR5)*cos225/2. +
837     3.3, -(fV0AR6-fV0AOctH2+fV0AR5)*sin225/2. + 1.5, 0, rot);
838     fib15pos->RegisterYourself();
839     TGeoCompositeShape *sV0AFib15Hole = new TGeoCompositeShape("sV0AFib15Hole", "sV0AFib15:fib15pos-sV0AFicR55");
840     TGeoVolume *v0AFib15Hole = new TGeoVolume("V0AFib15",sV0AFib15Hole,medV0AFib);
841     v0AFib15Hole->SetLineColor(kV0AColorFib);
842     new TGeoArb8("sV0AFib25", 11.8, v0APts);
843     rot = new TGeoRotation("rot");
844     rot->RotateX(-90);
845     rot->RotateY(180);
846     rot->RotateZ(90+22.5);
847     TGeoCombiTrans *fib25pos = new TGeoCombiTrans("fib25pos", -(fV0AR6-fV0AOctH2+fV0AR5)*cos225/2. +
848     3.3, -(fV0AR6-fV0AOctH2+fV0AR5)*sin225/2. + 1.5, 0, rot);
849     fib25pos->RegisterYourself();
850     TGeoCompositeShape *sV0AFib25Hole = new TGeoCompositeShape("sV0AFib25Hole","sV0AFib25:fib25pos-sV0AFicR55");
851     TGeoVolume *v0AFib25Hole = new TGeoVolume("V0AFib25Hole",sV0AFib25Hole,medV0AFib);
852     v0AFib25Hole->SetLineColor(kV0AColorFib);
853     TGeoVolume *v0AFib5 = new TGeoVolumeAssembly("V0AFib5");    
854     v0AFib5->AddNode(v0AFib15Hole,1);
855     v0AFib5->AddNode(v0AFib25Hole,1);
856     v0ASec5->AddNode(v0AFib5,1);
857             
858     /// Non-sensitive scintilator
859     new TGeoTubeSeg("sV0AR5S25", fV0AR4+fV0AFraWd/2., fV0AR4 + fV0AR0, fV0ASciWd/2.+2*preShape, 180.0, 225.0);
860     TGeoCompositeShape *sV0AR55 = new TGeoCompositeShape("V0AR55","sV0AR5S25 - sV0ACha5");
861     TGeoVolume *v0AR55 = new TGeoVolume("V0AR55",sV0AR55,medV0ASci);
862     v0AR55->SetLineColor(kV0AColorSci);
863     v0ASci5->AddNode(v0AR55,1);
864     v0ASec5->AddNode(v0ASci5,1);
865
866     /// Plates 
867     for (int i=0;i<2;i++) {
868       v0APts[0+8*i] = -fV0AR0;                  v0APts[1+8*i] = 0.;
869       v0APts[2+8*i] = -fV0AR0*cos654;           v0APts[3+8*i] = -fV0AR0*sin654;
870       v0APts[4+8*i] = -fV0AR7*cos654;           v0APts[5+8*i] = -fV0AR7*sin654;
871       v0APts[6+8*i] = -fV0AR6;                  v0APts[7+8*i] = 0.;
872     }
873     new TGeoArb8("sV0APlaIn5", (fV0APlaWd-2*fV0APlaAl)/2., v0APts);
874     TGeoCompositeShape *sV0APlaInNailsHoles5 = new TGeoCompositeShape("sV0APlaInNailsHoles5","sV0APlaIn5-sV0ANailsPlaInHoles5");
875     TGeoVolume *v0APlaInNailsHoles5 = new TGeoVolume("V0APlaInNailsHoles5", sV0APlaInNailsHoles5, medV0APlaIn);
876     new TGeoArb8("sV0APlaOu5", fV0APlaAl/2., v0APts);
877     TGeoCompositeShape *sV0APlaOuNailsHoles5 = new TGeoCompositeShape("sV0APlaOuNailsHoles5","sV0APlaOu5-sV0ANailsPlaOuHoles5");  
878     TGeoVolume *v0APlaOuNailsHoles5 = new TGeoVolume("V0APlaOuNailsHoles5", sV0APlaOuNailsHoles5, medV0APlaOu);
879     v0APlaInNailsHoles5->SetLineColor(kV0AColorPlaIn); v0APlaOuNailsHoles5->SetLineColor(kV0AColorPlaOu);
880     TGeoVolume *v0APla5 = new TGeoVolumeAssembly("V0APla5");
881     v0APla5->AddNode(v0APlaInNailsHoles5,1);
882     v0APla5->AddNode(v0APlaOuNailsHoles5,1,new TGeoTranslation(0,0,(fV0APlaWd-fV0APlaAl)/2.));
883     v0APla5->AddNode(v0APlaOuNailsHoles5,2,new TGeoTranslation(0,0,-(fV0APlaWd-fV0APlaAl)/2.));
884     v0ASec5->AddNode(v0APla5,1,new TGeoTranslation(0,0,(fV0ASciWd+2*fV0AOctWd+fV0APlaWd)/2.));
885     v0ASec5->AddNode(v0APla5,2,new TGeoTranslation(0,0,-(fV0ASciWd+2*fV0AOctWd+fV0APlaWd)/2.));
886     
887     /// PMBox 
888     TGeoVolume* v0APM5 = new TGeoVolumeAssembly("V0APM5");
889     new TGeoBBox("sV0APMB15", fV0APMBWd/2., fV0APMBHt/2., fV0APMBTh/2.);
890     new TGeoBBox("sV0APMB25", fV0APMBWd/2.-fV0APMBWdW, fV0APMBHt/2.-fV0APMBHtW, fV0APMBTh/2.-fV0APMBThW);
891     TGeoCompositeShape *sV0APMB5 = new TGeoCompositeShape("sV0APMB5","sV0APMB15-sV0APMB25");
892     TGeoVolume *v0APMB5 = new TGeoVolume("V0APMB5",sV0APMB5, medV0APMAlum);
893     v0APMB5->SetLineColor(kV0AColorPMA);
894     v0APM5->AddNode(v0APMB5,1);
895
896     /// PMTubes 
897     TGeoTube *sV0APMT15 = new TGeoTube("sV0APMT15", fV0APMTR1, fV0APMTR2, fV0APMTH/2.);
898     TGeoVolume *v0APMT15 = new TGeoVolume("V0APMT15", sV0APMT15, medV0APMGlass);
899     TGeoTube *sV0APMT25 = new TGeoTube("sV0APMT25", fV0APMTR3, fV0APMTR4, fV0APMTH/2.);
900     TGeoVolume *v0APMT25 = new TGeoVolume("V0APMT25", sV0APMT25, medV0APMAlum);
901     TGeoVolume *v0APMT5 = new TGeoVolumeAssembly("V0APMT5");
902     TGeoTube *sV0APMTT5 = new TGeoTube("sV0APMTT5", 0., fV0APMTR4, fV0APMTB/2.);
903     TGeoVolume *v0APMTT5 = new TGeoVolume("V0APMTT5", sV0APMTT5, medV0APMAlum);
904     v0APMT5->SetLineColor(kV0AColorPMG);
905     v0APMT25->SetLineColor(kV0AColorPMA);
906     v0APMTT5->SetLineColor(kV0AColorPMA);
907     rot = new TGeoRotation("rot", 90, 0, 180, 0, 90, 90);
908     v0APMT5->AddNode(v0APMT15,1,rot);
909     v0APMT5->AddNode(v0APMT25,1,rot);
910     v0APMT5->AddNode(v0APMTT5,1,new TGeoCombiTrans(0,(fV0APMTH+fV0APMTB)/2.,0,rot));
911     double autoShift5 = (fV0APMBWd-2*fV0APMBWdW)/4.;
912     v0APM5->AddNode(v0APMT5, 1, new TGeoTranslation(-1.5*autoShift5, 0, 0));
913     v0APM5->AddNode(v0APMT5, 2, new TGeoTranslation(-0.5*autoShift5, 0, 0));
914     v0APM5->AddNode(v0APMT5, 3, new TGeoTranslation(+0.5*autoShift5, 0, 0));
915     v0APM5->AddNode(v0APMT5, 4, new TGeoTranslation(+1.5*autoShift5, 0, 0));
916
917     /// PM 
918     rot = new TGeoRotation("rot");
919     rot->RotateX(-90+30);
920     rot->RotateY(0); 
921     rot->RotateZ(-65-3);
922     double cosAngPMB5 = TMath::Cos(fV0APMBAng*TMath::DegToRad());
923     double sinAngPMB5 = TMath::Sin(fV0APMBAng*TMath::DegToRad());
924     double shiftZ5 = fV0APMBHt/2. * cosAngPMB5
925       -   ( fV0ASciWd + 2 * fV0AOctWd + 2 * fV0APlaWd )/2.   -   fV0APMBTh/2. * sinAngPMB5;
926     double shiftR5 = fV0AR6  +  fV0AOctH2 + fV0APlaAl;
927     v0ASec5->AddNode(v0APM5,1, new TGeoCombiTrans( -shiftR5*cos225-1.3, -shiftR5*sin225, shiftZ5, rot));
928
929     // Aluminium nails
930     TGeoTube *sV0ANail51 = new TGeoTube("sV0ANail51", 0.0, 0.4, 5.09/2.);
931     TGeoVolume *v0ANail51 = new TGeoVolume("V0ANail51", sV0ANail51, medV0APMAlum);
932     v0ANail51->SetLineColor(kV0AColorPMA);// this is the color for aluminium
933     v0ASec5->AddNode(v0ANail51,1,new TGeoTranslation(-42.9,-0.51,0.0));
934     TGeoTube *sV0ANail52 = new TGeoTube("sV0ANail52", 0.0, 0.4, 5.09/2.);
935     TGeoVolume *v0ANail52 = new TGeoVolume("V0ANail52", sV0ANail52, medV0APMAlum);
936     v0ANail52->SetLineColor(kV0AColorPMA);
937     v0ASec5->AddNode(v0ANail52,1,new TGeoTranslation(-30.8,-30.04,0.0)); 
938             
939     // Adding sector to v0LE volume
940     v0LE->AddNode(v0ASec5, 1);  
941     
942
943     //Definition of  sector 6
944     TGeoVolume *v0ASec6 = new TGeoVolumeAssembly("V0ASec6");
945
946     /// For boolean sustraction
947     double preShape6 = 0.2;
948     for (int i=0;i<2;i++) {
949     v0APts[0+8*i] = -preShape6;                      v0APts[1+8*i] = -fV0AR0+fV0AFraWd/2.-preShape6;
950     v0APts[2+8*i] = -fV0AFraWd/2.;                    v0APts[3+8*i] = -fV0AR0+fV0AFraWd/2.-preShape6;
951     v0APts[4+8*i] = -fV0AFraWd/2.;                    v0APts[5+8*i] = -fV0AR4-fV0AFraWd/2.+preShape6;
952     v0APts[6+8*i] = -preShape6;                      v0APts[7+8*i] = -fV0AR4-fV0AFraWd/2.+preShape6;
953     }
954     new TGeoArb8("sV0ACha16",fV0ASciWd/1.5,v0APts);
955     for (int i=0;i<2;i++) {
956     v0APts[0+8*i] = -fV0AR0*cos45+preShape;
957     v0APts[1+8*i] = -(fV0AR0-fV0AFraWd)*sin45+preShape;
958     v0APts[2+8*i] = -(fV0AR0-fV0AFraWd/2.)*cos45+preShape;
959     v0APts[3+8*i] = -(fV0AR0-fV0AFraWd/2.)*sin45;
960     v0APts[4+8*i] = -(fV0AR4+fV0AFraWd/2.)*cos45-preShape;
961     v0APts[5+8*i] = -(fV0AR4+fV0AFraWd/2.)*sin45-preShape;
962     v0APts[6+8*i] = -(fV0AR4+fV0AFraWd)*cos45-preShape;
963     v0APts[7+8*i] = -fV0AR4*sin45-preShape;
964     }
965     new TGeoArb8("sV0ACha26", fV0ASciWd/2.+2.*preShape, v0APts);
966     new TGeoCompositeShape("sV0ACha126","sV0ACha16+sV0ACha26");
967     new TGeoTube("sV0ANail16Hole", 0.0, 0.4, 1.65);
968     TGeoTranslation *pos16 = new TGeoTranslation("pos16",-0.51,-42.9,0.0);
969     pos16->RegisterYourself();
970     new TGeoTube("sV0ANail26Hole", 0.0, 0.4, 1.65);
971     TGeoTranslation *pos26 = new TGeoTranslation("pos26",-30.05,-30.79,0.0);  
972     pos26->RegisterYourself();
973     new TGeoCompositeShape("sV0ANailsHoles6","sV0ANail16Hole:pos16+sV0ANail26Hole:pos26");
974     new TGeoCompositeShape("sV0ACha6","sV0ACha126+sV0ANailsHoles6");
975     new TGeoTubeSeg("sV0AFicR56", fV0AR4+fV0AFraWd/2., fV0AR4 + fV0AR0, fV0ASciWd/2.+2*preShape, 225, 270.0);
976     new TGeoTube("sV0ANail1PlaInHole6", 0.0, 0.4, (fV0APlaWd-2*fV0APlaAl)/2.);    
977     new TGeoTube("sV0ANail1PlaOuHole6", 0.0, 0.4, (fV0APlaAl)/2.);
978       
979     /// Frame
980     TGeoVolume *v0AFra6 = new TGeoVolumeAssembly("V0AFra6");
981     for (int i=0;i<2;i++) {
982     v0APts[0+8*i] = 0.;                              v0APts[1+8*i] = -fV0AR0+fV0AFraWd/2.;
983     v0APts[2+8*i] = -fV0AFraWd/2.;                    v0APts[3+8*i] = -fV0AR0+fV0AFraWd/2.;
984     v0APts[4+8*i] = -fV0AFraWd/2.;                    v0APts[5+8*i] = -fV0AR4-fV0AFraWd/2.;
985     v0APts[6+8*i] = 0.;                              v0APts[7+8*i] = -fV0AR4-fV0AFraWd/2.;
986     }
987     TGeoArb8 *sV0AFraB16 = new TGeoArb8("sV0AFraB16",fV0ASciWd/2.,v0APts);
988     TGeoVolume *v0AFraB16 = new TGeoVolume("V0AFraB16",sV0AFraB16,medV0AFra);
989     for (int i=0;i<2;i++) {
990     v0APts[0+8*i] = -fV0AR0*cos45;
991     v0APts[1+8*i] = -(fV0AR0+fV0AFraWd)*sin45;
992     v0APts[2+8*i] = -(fV0AR0+fV0AFraWd/2.)*cos45;
993     v0APts[3+8*i] = -(fV0AR0+fV0AFraWd/2.)*sin45;
994     v0APts[4+8*i] = -(fV0AR4-fV0AFraWd/2.)*cos45;
995     v0APts[5+8*i] = -(fV0AR4-fV0AFraWd/2.)*sin45;
996     v0APts[6+8*i] = -(fV0AR4-fV0AFraWd)*cos45;
997     v0APts[7+8*i] = -fV0AR4*sin45;
998     }
999     TGeoArb8 *sV0AFraB26 = new TGeoArb8("sV0AFraB26", fV0ASciWd/2., v0APts);
1000     TGeoVolume *v0AFraB26 = new TGeoVolume("V0AFraB26",sV0AFraB26,medV0AFra);
1001     v0AFraB16->SetLineColor(kV0AColorFra); v0AFraB26->SetLineColor(kV0AColorFra);
1002     v0AFra6->AddNode(v0AFraB16,1);
1003     v0AFra6->AddNode(v0AFraB26,1);  // Prefer 2 GeoObjects insted of 3 GeoMovements
1004     new TGeoTubeSeg( "sV0AFraR1b6", fV0AR0-fV0AFraWd/2.,
1005              fV0AR0+fV0AFraWd/2., fV0ASciWd/2., 225.0, 270.0);
1006     new TGeoTubeSeg( "sV0AFraR2b6", fV0AR1-fV0AFraWd/2.,
1007              fV0AR1+fV0AFraWd/2., fV0ASciWd/2., 225.0, 270.0);
1008     new TGeoTubeSeg( "sV0AFraR3b6", fV0AR2-fV0AFraWd/2.,
1009              fV0AR2+fV0AFraWd/2., fV0ASciWd/2., 225.0, 270.0);
1010     new TGeoTubeSeg( "sV0AFraR4b6", fV0AR3-fV0AFraWd/2.,
1011              fV0AR3+fV0AFraWd/2., fV0ASciWd/2., 225.0, 270.0);
1012     new TGeoTubeSeg( "sV0AFraR5b6", fV0AR4-fV0AFraWd/2.,
1013              fV0AR4+fV0AFraWd/2., fV0ASciWd/2., 225.0, 270.0);
1014     TGeoCompositeShape *sV0AFraR16 = new TGeoCompositeShape("sV0AFraR16","sV0AFraR1b6-sV0ACha6");
1015     TGeoCompositeShape *sV0AFraR26 = new TGeoCompositeShape("sV0AFraR26","sV0AFraR2b6-sV0ACha6");
1016     TGeoCompositeShape *sV0AFraR36 = new TGeoCompositeShape("sV0AFraR36","sV0AFraR3b6-sV0ACha6");
1017     TGeoCompositeShape *sV0AFraR46 = new TGeoCompositeShape("sV0AFraR46","sV0AFraR4b6-sV0ACha6");
1018     TGeoCompositeShape *sV0AFraR56 = new TGeoCompositeShape("sV0AFraR56","sV0AFraR5b6-sV0ACha6");
1019     TGeoVolume *v0AFraR16 = new TGeoVolume("V0AFraR16",sV0AFraR16,medV0AFra);
1020     TGeoVolume *v0AFraR26 = new TGeoVolume("V0AFraR26",sV0AFraR26,medV0AFra);
1021     TGeoVolume *v0AFraR36 = new TGeoVolume("V0AFraR36",sV0AFraR36,medV0AFra);
1022     TGeoVolume *v0AFraR46 = new TGeoVolume("V0AFraR46",sV0AFraR46,medV0AFra);
1023     TGeoVolume *v0AFraR56 = new TGeoVolume("V0AFraR56",sV0AFraR56,medV0AFra);
1024     v0AFraR16->SetLineColor(kV0AColorFra); v0AFraR26->SetLineColor(kV0AColorFra);
1025     v0AFraR36->SetLineColor(kV0AColorFra); v0AFraR46->SetLineColor(kV0AColorFra);
1026     v0AFraR56->SetLineColor(kV0AColorFra);
1027     v0AFra6->AddNode(v0AFraR16,1);
1028     v0AFra6->AddNode(v0AFraR26,1);
1029     v0AFra6->AddNode(v0AFraR36,1);
1030     v0AFra6->AddNode(v0AFraR46,1);
1031     v0AFra6->AddNode(v0AFraR56,1);
1032     v0ASec6->AddNode(v0AFra6,1);
1033
1034     /// Sensitive scintilator
1035     TGeoVolume *v0ASci6 = new TGeoVolumeAssembly("V0ASci6");
1036     new TGeoTubeSeg( "sV0AR1b6", fV0AR0+fV0AFraWd/2.,
1037                      fV0AR1-fV0AFraWd/2., fV0ASciWd/2., 225.0, 270.0);
1038     new TGeoTubeSeg( "sV0AR2b6", fV0AR1+fV0AFraWd/2.,
1039              fV0AR2-fV0AFraWd/2., fV0ASciWd/2., 225.0, 270.0);
1040     new TGeoTubeSeg( "sV0AR3b6", fV0AR2+fV0AFraWd/2.,
1041              fV0AR3-fV0AFraWd/2., fV0ASciWd/2., 225.0, 270.0);
1042     new TGeoTubeSeg( "sV0AR4b6", fV0AR3+fV0AFraWd/2.,
1043              fV0AR4-fV0AFraWd/2., fV0ASciWd/2., 225.0, 270.0);
1044     TGeoCompositeShape *sV0AR16 = new TGeoCompositeShape("sV0AR16","sV0AR1b6-sV0ACha6");
1045     TGeoCompositeShape *sV0AR26 = new TGeoCompositeShape("sV0AR26","sV0AR2b6-sV0ACha6");
1046     TGeoCompositeShape *sV0AR36 = new TGeoCompositeShape("sV0AR36","sV0AR3b6-sV0ACha6");
1047     TGeoCompositeShape *sV0AR46 = new TGeoCompositeShape("sV0AR46","sV0AR4b6-sV0ACha6");
1048     TGeoVolume *v0L16 = new TGeoVolume("V0L16",sV0AR16,medV0ASci);
1049     TGeoVolume *v0L26 = new TGeoVolume("V0L26",sV0AR26,medV0ASci);
1050     TGeoVolume *v0L36 = new TGeoVolume("V0L36",sV0AR36,medV0ASci);
1051     TGeoVolume *v0L46 = new TGeoVolume("V0L46",sV0AR46,medV0ASci);
1052     v0L16->SetLineColor(kV0AColorSci); v0L26->SetLineColor(kV0AColorSci);
1053     v0L36->SetLineColor(kV0AColorSci); v0L46->SetLineColor(kV0AColorSci);
1054     v0ASci6->AddNode(v0L16,1);
1055     v0ASci6->AddNode(v0L26,1);
1056     v0ASci6->AddNode(v0L36,1);
1057     v0ASci6->AddNode(v0L46,1);
1058     
1059     // Bunch of fibers
1060     for (int i=0;i<2;i++) {
1061     v0APts[0+8*i] = -10.0;          v0APts[1+8*i] = 13.1;  
1062     v0APts[2+8*i] = 10.0;           v0APts[3+8*i] = 13.1;   
1063     v0APts[4+8*i] = 8.0;            v0APts[5+8*i] = -29.0;  
1064     v0APts[6+8*i] = -12.0;          v0APts[7+8*i] = -12.0;  
1065     }   
1066     new TGeoArb8("sV0AFib16", 0.01, v0APts);      
1067     rot = new TGeoRotation("rot");
1068     rot->RotateX(2.0); 
1069     rot->RotateY(180.0);
1070     rot->RotateZ(90+22.5);
1071     TGeoCombiTrans *fib16pos = new TGeoCombiTrans("fib16pos", -40.0 + 3.3, -50.0 + 1.5, 0.5, rot);
1072     fib16pos->RegisterYourself();
1073     TGeoCompositeShape *sV0AFib16Hole = new TGeoCompositeShape("sV0AFib16Hole", "sV0AFib16:fib16pos-sV0AFicR56");
1074     TGeoVolume *v0AFib16Hole = new TGeoVolume("V0AFib16Hole",sV0AFib16Hole,medV0AFib);
1075     v0AFib16Hole->SetLineColor(kV0AColorFib);
1076     new TGeoArb8("sV0AFib26", 0.01, v0APts);      
1077     rot = new TGeoRotation("rot");
1078     rot->RotateX(-2.0); 
1079     rot->RotateY(180.0); 
1080     rot->RotateZ(90+22.5);
1081     TGeoCombiTrans *fib26pos = new TGeoCombiTrans("fib26pos", -40.0 + 3.3, -50.0 + 1.5, -0.5, rot);
1082     fib26pos->RegisterYourself();
1083     TGeoCompositeShape *sV0AFib26Hole = new TGeoCompositeShape("sV0AFib26Hole", "sV0AFib26:fib26pos-sV0AFicR56");
1084     TGeoVolume *v0AFib26Hole = new TGeoVolume("V0AFib26Hole",sV0AFib26Hole,medV0AFib);
1085     v0AFib26Hole->SetLineColor(kV0AColorFib);
1086     TGeoVolume *v0AFib6 = new TGeoVolumeAssembly("V0AFib6");
1087     v0AFib6->AddNode(v0AFib16Hole,1); 
1088     v0AFib6->AddNode(v0AFib26Hole,1);
1089     v0ASec6->AddNode(v0AFib6,1);
1090
1091     /// Non-sensitive scintilator
1092     new TGeoTubeSeg("sV0AR5S26", fV0AR4+fV0AFraWd/2., fV0AR4 + fV0AR0, fV0ASciWd/2.+2*preShape, 225.0, 270.0);
1093     TGeoCompositeShape *sV0AR56 = new TGeoCompositeShape("V0AR56","sV0AR5S26 - sV0ACha6");
1094     TGeoVolume *v0AR56 = new TGeoVolume("V0AR56",sV0AR56,medV0ASci);
1095     v0AR56->SetLineColor(kV0AColorSci);
1096     v0ASci6->AddNode(v0AR56,1);
1097     v0ASec6->AddNode(v0ASci6,1);
1098
1099     /// Segment of octagon   
1100     for (int i=0;i<2;i++) {
1101     v0APts[0+8*i] = 0.;                          v0APts[1+8*i] = -(fV0AR7-fV0AOctH2)*sin654;
1102     v0APts[2+8*i] = 0.;                          v0APts[3+8*i] = -fV0AR7*sin654;
1103     v0APts[4+8*i] = -fV0AR7*cos654;              v0APts[5+8*i] = -fV0AR7*sin654;
1104     v0APts[6+8*i] = -(fV0AR7-fV0AOctH2)*cos654;  v0APts[7+8*i] = -(fV0AR7-fV0AOctH2)*sin654;
1105     }
1106     TGeoArb8 *sV0AOct26 = new TGeoArb8("sV0AOct26", (fV0ASciWd+2*fV0AOctWd)/2., v0APts);
1107     TGeoVolume *v0AOct26 = new TGeoVolume("V0AOct26", sV0AOct26,medV0ASup);
1108     v0AOct26->SetLineColor(kV0AColorOct);
1109     TGeoVolume *v0ASup6 = new TGeoVolumeAssembly("V0ASup6");
1110     v0ASup6->AddNode(v0AOct26,1);
1111     v0ASec6->AddNode(v0ASup6,1);
1112
1113     /// Plates
1114     for (int i=0;i<2;i++) {
1115     v0APts[0+8*i] = 0.;                 v0APts[1+8*i] = -fV0AR0;
1116     v0APts[2+8*i] = 0.;                 v0APts[3+8*i] = -fV0AR7*sin654;
1117     v0APts[4+8*i] = -fV0AR7*cos654;     v0APts[5+8*i] = -fV0AR7*sin654;
1118     v0APts[6+8*i] = -fV0AR0*cos654;             v0APts[7+8*i] = -fV0AR0*sin654;
1119     }
1120     new TGeoArb8("sV0APlaIn6", (fV0APlaWd-2*fV0APlaAl)/2., v0APts);
1121     TGeoCompositeShape *sV0APlaInNailsHoles6 = new TGeoCompositeShape("sV0APlaInNailsHoles6","sV0APlaIn6-sV0ANail1PlaInHole6:pos16");
1122     TGeoVolume *v0APlaInNailsHoles6 = new TGeoVolume("V0APlaInNailsHoles6", sV0APlaInNailsHoles6, medV0APlaIn);
1123     new TGeoArb8("sV0APlaOu6", fV0APlaAl/2., v0APts);
1124     TGeoCompositeShape *sV0APlaOuNailsHoles6 = new TGeoCompositeShape("sV0APlaOuNailsHoles6","sV0APlaOu6-sV0ANail1PlaOuHole6:pos16"); 
1125     TGeoVolume *v0APlaOuNailsHoles6 = new TGeoVolume("V0APlaOuNailsHoles6", sV0APlaOuNailsHoles6, medV0APlaOu);
1126     v0APlaInNailsHoles6->SetLineColor(kV0AColorPlaIn); v0APlaOuNailsHoles6->SetLineColor(kV0AColorPlaOu);
1127     TGeoVolume *v0APla6 = new TGeoVolumeAssembly("V0APla6");
1128     v0APla6->AddNode(v0APlaInNailsHoles6,1);
1129     v0APla6->AddNode(v0APlaOuNailsHoles6,1,new TGeoTranslation(0,0,(fV0APlaWd-fV0APlaAl)/2.));
1130     v0APla6->AddNode(v0APlaOuNailsHoles6,2,new TGeoTranslation(0,0,-(fV0APlaWd-fV0APlaAl)/2.));
1131     v0ASec6->AddNode(v0APla6,1,new TGeoTranslation(0,0,(fV0ASciWd+2*fV0AOctWd+fV0APlaWd)/2.));
1132     v0ASec6->AddNode(v0APla6,2,new TGeoTranslation(0,0,-(fV0ASciWd+2*fV0AOctWd+fV0APlaWd)/2.));
1133     
1134     /// PMBox  
1135     TGeoVolume* v0APM6 = new TGeoVolumeAssembly("V0APM6");
1136     new TGeoBBox("sV0APMB16", fV0APMBWd/2., fV0APMBHt/2., fV0APMBTh/2.);
1137     new TGeoBBox("sV0APMB26", fV0APMBWd/2.-fV0APMBWdW, fV0APMBHt/2.-fV0APMBHtW, fV0APMBTh/2.-fV0APMBThW);
1138     TGeoCompositeShape *sV0APMB6 = new TGeoCompositeShape("sV0APMB6","sV0APMB16-sV0APMB26");
1139     TGeoVolume *v0APMB6 = new TGeoVolume("V0APMB6",sV0APMB6, medV0APMAlum);
1140     v0APMB6->SetLineColor(kV0AColorPMA);
1141     v0APM6->AddNode(v0APMB6,1);
1142
1143     /// PMTubes 
1144     TGeoTube *sV0APMT16 = new TGeoTube("sV0APMT16", fV0APMTR1, fV0APMTR2, fV0APMTH/2.);
1145     TGeoVolume *v0APMT16 = new TGeoVolume("V0APMT16", sV0APMT16, medV0APMGlass);
1146     TGeoTube *sV0APMT26 = new TGeoTube("sV0APMT26", fV0APMTR3, fV0APMTR4, fV0APMTH/2.);
1147     TGeoVolume *v0APMT26 = new TGeoVolume("V0APMT26", sV0APMT26, medV0APMAlum);
1148     TGeoVolume *v0APMT6 = new TGeoVolumeAssembly("V0APMT6"); 
1149     TGeoTube *sV0APMTT6 = new TGeoTube("sV0APMTT6", 0., fV0APMTR4, fV0APMTB/2.);
1150     TGeoVolume *v0APMTT6 = new TGeoVolume("V0APMTT6", sV0APMTT6, medV0APMAlum);
1151     v0APMT6->SetLineColor(kV0AColorPMG);
1152     v0APMT26->SetLineColor(kV0AColorPMA);
1153     v0APMTT6->SetLineColor(kV0AColorPMA);
1154     rot = new TGeoRotation("rot", 90, 0, 180, 0, 90, 90);
1155     v0APMT6->AddNode(v0APMT16,1,rot);
1156     v0APMT6->AddNode(v0APMT26,1,rot);
1157     v0APMT6->AddNode(v0APMTT6,1,new TGeoCombiTrans(0,(fV0APMTH+fV0APMTB)/2.,0,rot));
1158     double autoShift6 = (fV0APMBWd-2*fV0APMBWdW)/4.;
1159     v0APM6->AddNode(v0APMT6, 1, new TGeoTranslation(-1.5*autoShift6, 0, 0));
1160     v0APM6->AddNode(v0APMT6, 2, new TGeoTranslation(-0.5*autoShift6, 0, 0));
1161     v0APM6->AddNode(v0APMT6, 3, new TGeoTranslation(+0.5*autoShift6, 0, 0));
1162     v0APM6->AddNode(v0APMT6, 4, new TGeoTranslation(+1.5*autoShift6, 0, 0));
1163
1164     /// PM 
1165     rot = new TGeoRotation("rot");
1166     rot->RotateX(-90+30);
1167     rot->RotateY(0);
1168     rot->RotateZ(-65-3);
1169     double cosAngPMB6 = TMath::Cos(fV0APMBAng*TMath::DegToRad());
1170     double sinAngPMB6 = TMath::Sin(fV0APMBAng*TMath::DegToRad());
1171     double shiftZ6 = fV0APMBHt/2. * cosAngPMB6
1172       -   ( fV0ASciWd + 2 * fV0AOctWd + 2 * fV0APlaWd )/2.   -   fV0APMBTh/2. * sinAngPMB6;
1173     double shiftR6 = fV0AR6  + fV0AR1 + fV0AOctWd + fV0APlaAl/3.;
1174     v0ASec6->AddNode(v0APM6,1, new TGeoCombiTrans( -shiftR6*cos45-1.3, -shiftR6*sin45, shiftZ6, rot));   
1175     
1176     /// Support
1177     TGeoBBox *sV0ASuppbl = new TGeoBBox("sV0ASuppbl", 2.0, 18.13, fV0ASciWd/2.);       
1178     TGeoVolume *v0ASuppbl = new TGeoVolume("V0ASuppbl", sV0ASuppbl, medV0ASup);
1179     v0ASuppbl->SetLineColor(kV0AColorOct);
1180     v0ASec6->AddNode(v0ASuppbl,1,new TGeoTranslation(-2.0,-63.64,0.0));
1181     
1182     // Aluminium nail
1183     TGeoTube *sV0ANail61 = new TGeoTube("sV0ANail61", 0.0, 0.4, 5.09/2.);
1184     TGeoVolume *v0ANail61 = new TGeoVolume("V0ANail61", sV0ANail61, medV0APMAlum);
1185     v0ANail61->SetLineColor(kV0AColorPMA);// this is the color for aluminium
1186     v0ASec6->AddNode(v0ANail61,1,new TGeoTranslation(-0.51,-42.9,0.0));  
1187     TGeoTube *sV0ANail62 = new TGeoTube("sV0ANail62", 0.0, 0.4, 5.09/2.);
1188     TGeoVolume *v0ANail62 = new TGeoVolume("V0ANail62", sV0ANail62, medV0APMAlum);
1189     v0ANail62->SetLineColor(kV0AColorPMA);
1190     v0ASec6->AddNode(v0ANail62,1,new TGeoTranslation(-30.05,-30.79,0.0));  
1191
1192     // Adding sector to v0LE volume
1193     v0LE->AddNode(v0ASec6, 1); 
1194  
1195      
1196      //Definition of sector 7
1197     TGeoVolume *v0ASec7 = new TGeoVolumeAssembly("V0ASec7");
1198
1199     /// For boolean sustraction
1200     double preShape7 = 0.2;
1201     for (int i=0;i<2;i++) {
1202     v0APts[0+8*i] = 0.0;                      v0APts[1+8*i] = -fV0AR0+fV0AFraWd/2.-preShape7;
1203     v0APts[2+8*i] = fV0AFraWd/2.;                    v0APts[3+8*i] = -fV0AR0+fV0AFraWd/2.-preShape7;
1204     v0APts[4+8*i] = fV0AFraWd/2.;                    v0APts[5+8*i] = -fV0AR4-fV0AFraWd/2.+preShape7;
1205     v0APts[6+8*i] = 0.0;                      v0APts[7+8*i] = -fV0AR4-fV0AFraWd/2.+preShape7;
1206     }
1207     new TGeoArb8("sV0ACha17",fV0ASciWd/1.5,v0APts);
1208     for (int i=0;i<2;i++) {
1209     v0APts[0+8*i] = fV0AR0*cos45-preShape7;
1210     v0APts[1+8*i] = -(fV0AR0-fV0AFraWd)*sin45+preShape7;
1211     v0APts[2+8*i] = (fV0AR0-fV0AFraWd/2.)*cos45-preShape7;
1212     v0APts[3+8*i] = -(fV0AR0-fV0AFraWd/2.)*sin45;
1213     v0APts[4+8*i] = (fV0AR4+fV0AFraWd/2.)*cos45+preShape7;
1214     v0APts[5+8*i] = -(fV0AR4+fV0AFraWd/2.)*sin45-2.*preShape7;
1215     v0APts[6+8*i] = (fV0AR4+fV0AFraWd)*cos45+preShape7;
1216     v0APts[7+8*i] = -fV0AR4*sin45-preShape7;
1217     }
1218     new TGeoArb8("sV0ACha27", fV0ASciWd/2.+2.*preShape, v0APts);
1219     new TGeoCompositeShape("sV0ACha127","sV0ACha17+sV0ACha27");
1220     new TGeoTube("sV0ANail17Hole", 0.0, 0.4, 1.65);
1221     TGeoTranslation *pos17 = new TGeoTranslation("pos17",0.51,-42.9,0.0);
1222     pos17->RegisterYourself();
1223     new TGeoTube("sV0ANail27Hole", 0.0, 0.4, 1.65);
1224     TGeoTranslation *pos27 = new TGeoTranslation("pos27",30.05,-30.79,0.0);   
1225     pos27->RegisterYourself();
1226     new TGeoCompositeShape("sV0ANailsHoles7","sV0ANail17Hole:pos17+sV0ANail27Hole:pos27");
1227     new TGeoCompositeShape("sV0ACha7","sV0ACha127+sV0ANailsHoles7");
1228     new TGeoTubeSeg("sV0AFicR57", fV0AR4+fV0AFraWd/2., fV0AR4 + fV0AR0, fV0ASciWd/2.+2*preShape, 270.0, 315.0);
1229     new TGeoTube("sV0ANail1PlaInHole7", 0.0, 0.4, (fV0APlaWd-2*fV0APlaAl)/2.);    
1230     new TGeoTube("sV0ANail1PlaOuHole7", 0.0, 0.4, (fV0APlaAl)/2.); 
1231
1232     /// Frame
1233     TGeoVolume *v0AFra7 = new TGeoVolumeAssembly("V0AFra7");
1234     for (int i=0;i<2;i++) {
1235     v0APts[0+8*i] = 0.;                              v0APts[1+8*i] = -fV0AR0-fV0AFraWd/2.;
1236     v0APts[2+8*i] = fV0AFraWd/2.;                    v0APts[3+8*i] = -fV0AR0-fV0AFraWd/2.;
1237     v0APts[4+8*i] = fV0AFraWd/2.;                    v0APts[5+8*i] = -fV0AR4+fV0AFraWd/2.;
1238     v0APts[6+8*i] = 0.;                              v0APts[7+8*i] = -fV0AR4+fV0AFraWd/2.;
1239     }
1240     TGeoArb8 *sV0AFraB17 = new TGeoArb8("sV0AFraB17",fV0ASciWd/2.,v0APts);
1241     TGeoVolume *v0AFraB17 = new TGeoVolume("V0AFraB17",sV0AFraB17,medV0AFra);
1242     for (int i=0;i<2;i++) {
1243     v0APts[0+8*i] = fV0AR0*cos45;
1244     v0APts[1+8*i] = -(fV0AR0-fV0AFraWd)*sin45;
1245     v0APts[2+8*i] = (fV0AR0-fV0AFraWd/2.)*cos45;
1246     v0APts[3+8*i] = -(fV0AR0-fV0AFraWd/2.)*sin45;
1247     v0APts[4+8*i] = (fV0AR4+fV0AFraWd/2.)*cos45/2.;
1248     v0APts[5+8*i] = -(fV0AR4+fV0AFraWd/2.)*sin45/2.;
1249     v0APts[6+8*i] = (fV0AR4+fV0AFraWd)*cos45/2.;
1250     v0APts[7+8*i] = -fV0AR4*sin45/2.;
1251     }
1252     TGeoArb8 *sV0AFraB27 = new TGeoArb8("sV0AFraB27", fV0ASciWd/2., v0APts);
1253     TGeoVolume *v0AFraB27 = new TGeoVolume("V0AFraB27",sV0AFraB27,medV0AFra);
1254     v0AFraB17->SetLineColor(kV0AColorFra); v0AFraB27->SetLineColor(kV0AColorFra);
1255     v0AFra7->AddNode(v0AFraB17,1);
1256     v0AFra7->AddNode(v0AFraB27,1);  // Prefer 2 GeoObjects insted of 3 GeoMovements
1257     new TGeoTubeSeg( "sV0AFraR1b7", fV0AR0-fV0AFraWd/2.,
1258              fV0AR0+fV0AFraWd/2., fV0ASciWd/2., 270.0, 315.0);
1259     new TGeoTubeSeg( "sV0AFraR2b7", fV0AR1-fV0AFraWd/2.,
1260              fV0AR1+fV0AFraWd/2., fV0ASciWd/2., 270.0, 315.0);
1261     new TGeoTubeSeg( "sV0AFraR3b7", fV0AR2-fV0AFraWd/2.,
1262              fV0AR2+fV0AFraWd/2., fV0ASciWd/2., 270.0, 315.0);
1263     new TGeoTubeSeg( "sV0AFraR4b7", fV0AR3-fV0AFraWd/2.,
1264              fV0AR3+fV0AFraWd/2., fV0ASciWd/2., 270.0, 315.0);
1265     new TGeoTubeSeg( "sV0AFraR5b7", fV0AR4-fV0AFraWd/2.,
1266              fV0AR4+fV0AFraWd/2., fV0ASciWd/2., 270.0, 315.0);
1267     TGeoCompositeShape *sV0AFraR17 = new TGeoCompositeShape("sV0AFraR17","sV0AFraR1b7-sV0ACha7");
1268     TGeoCompositeShape *sV0AFraR27 = new TGeoCompositeShape("sV0AFraR27","sV0AFraR2b7-sV0ACha7");
1269     TGeoCompositeShape *sV0AFraR37 = new TGeoCompositeShape("sV0AFraR37","sV0AFraR3b7-sV0ACha7");
1270     TGeoCompositeShape *sV0AFraR47 = new TGeoCompositeShape("sV0AFraR47","sV0AFraR4b7-sV0ACha7");
1271     TGeoCompositeShape *sV0AFraR57 = new TGeoCompositeShape("sV0AFraR57","sV0AFraR5b7-sV0ACha7");
1272     TGeoVolume *v0AFraR17 = new TGeoVolume("V0AFraR17",sV0AFraR17,medV0AFra);
1273     TGeoVolume *v0AFraR27 = new TGeoVolume("V0AFraR27",sV0AFraR27,medV0AFra);
1274     TGeoVolume *v0AFraR37 = new TGeoVolume("V0AFraR37",sV0AFraR37,medV0AFra);
1275     TGeoVolume *v0AFraR47 = new TGeoVolume("V0AFraR47",sV0AFraR47,medV0AFra);
1276     TGeoVolume *v0AFraR57 = new TGeoVolume("V0AFraR57",sV0AFraR57,medV0AFra);
1277     v0AFraR17->SetLineColor(kV0AColorFra); v0AFraR27->SetLineColor(kV0AColorFra);
1278     v0AFraR37->SetLineColor(kV0AColorFra); v0AFraR47->SetLineColor(kV0AColorFra);
1279     v0AFraR57->SetLineColor(kV0AColorFra);
1280     v0AFra7->AddNode(v0AFraR17,1);
1281     v0AFra7->AddNode(v0AFraR27,1);
1282     v0AFra7->AddNode(v0AFraR37,1);
1283     v0AFra7->AddNode(v0AFraR47,1);
1284     v0AFra7->AddNode(v0AFraR57,1);
1285     v0ASec7->AddNode(v0AFra7,1);
1286
1287     /// Sensitive scintilator
1288     TGeoVolume *v0ASci7 = new TGeoVolumeAssembly("V0ASci7");
1289     new TGeoTubeSeg( "sV0AR1b7", fV0AR0+fV0AFraWd/2.,
1290              fV0AR1-fV0AFraWd/2., fV0ASciWd/2., 270.0, 315.0);
1291     new TGeoTubeSeg( "sV0AR2b7", fV0AR1+fV0AFraWd/2.,
1292              fV0AR2-fV0AFraWd/2., fV0ASciWd/2., 270.0, 315.0);
1293     new TGeoTubeSeg( "sV0AR3b7", fV0AR2+fV0AFraWd/2.,
1294              fV0AR3-fV0AFraWd/2., fV0ASciWd/2., 270.0, 315.0);
1295     new TGeoTubeSeg( "sV0AR4b7", fV0AR3+fV0AFraWd/2.,
1296              fV0AR4-fV0AFraWd/2., fV0ASciWd/2., 270.0, 315.0);
1297     TGeoCompositeShape *sV0AR17 = new TGeoCompositeShape("sV0AR17","sV0AR1b7-sV0ACha7");
1298     TGeoCompositeShape *sV0AR27 = new TGeoCompositeShape("sV0AR27","sV0AR2b7-sV0ACha7");
1299     TGeoCompositeShape *sV0AR37 = new TGeoCompositeShape("sV0AR37","sV0AR3b7-sV0ACha7");
1300     TGeoCompositeShape *sV0AR47 = new TGeoCompositeShape("sV0AR47","sV0AR4b7-sV0ACha7");
1301     TGeoVolume *v0L17 = new TGeoVolume("V0L17",sV0AR17,medV0ASci);
1302     TGeoVolume *v0L27 = new TGeoVolume("V0L27",sV0AR27,medV0ASci);
1303     TGeoVolume *v0L37 = new TGeoVolume("V0L37",sV0AR37,medV0ASci);
1304     TGeoVolume *v0L47 = new TGeoVolume("V0L47",sV0AR47,medV0ASci);
1305     v0L17->SetLineColor(kV0AColorSci); v0L27->SetLineColor(kV0AColorSci);
1306     v0L37->SetLineColor(kV0AColorSci); v0L47->SetLineColor(kV0AColorSci);
1307     v0ASci7->AddNode(v0L17,1);
1308     v0ASci7->AddNode(v0L27,1);
1309     v0ASci7->AddNode(v0L37,1);
1310     v0ASci7->AddNode(v0L47,1);
1311     
1312     // Bunch of fibers
1313     for (int i=0;i<2;i++) {
1314     v0APts[0+8*i] = -10.0;            v0APts[1+8*i] = 13.1;
1315     v0APts[2+8*i] = 10.0;            v0APts[3+8*i] = 13.1;
1316     v0APts[4+8*i] = 8.0;            v0APts[5+8*i] = -29.0;
1317     v0APts[6+8*i] = -12.0;            v0APts[7+8*i] = -12.0;
1318     }   
1319     new TGeoArb8("sV0AFib17", 0.01, v0APts);      
1320     rot = new TGeoRotation("rot");
1321     rot->RotateX(-2.0); 
1322     rot->RotateY(0.0);
1323     rot->RotateZ(248.0);
1324     TGeoCombiTrans *fib17pos = new TGeoCombiTrans("fib17pos", 40.0 - 3.3, -50.0 + 1.5, 0.5, rot);
1325     fib17pos->RegisterYourself();
1326     TGeoCompositeShape *sV0AFib17Hole = new TGeoCompositeShape("sV0AFib17Hole", "sV0AFib17:fib17pos-sV0AFicR57");
1327     TGeoVolume *v0AFib17Hole = new TGeoVolume("V0AFib17Hole",sV0AFib17Hole,medV0AFib);
1328     v0AFib17Hole->SetLineColor(kV0AColorFib);
1329     new TGeoArb8("sV0AFib27", 0.01, v0APts);      
1330     rot = new TGeoRotation("rot");
1331     rot->RotateX(2.0); 
1332     rot->RotateY(0.0);
1333     rot->RotateZ(248.0);
1334     TGeoCombiTrans *fib27pos = new TGeoCombiTrans("fib27pos", 40.0 - 3.3, -50.0 + 1.5, -0.5, rot);
1335     fib27pos->RegisterYourself();
1336     TGeoCompositeShape *sV0AFib27Hole = new TGeoCompositeShape("sV0AFib27Hole", "sV0AFib27:fib27pos-sV0AFicR57");
1337     TGeoVolume *v0AFib27Hole = new TGeoVolume("V0AFib27Hole",sV0AFib27Hole,medV0AFib);
1338     v0AFib27Hole->SetLineColor(kV0AColorFib);
1339     TGeoVolume *v0AFib7 = new TGeoVolumeAssembly("V0AFib7");
1340     v0AFib7->AddNode(v0AFib17Hole,1); 
1341     v0AFib7->AddNode(v0AFib27Hole,1);
1342     v0ASec7->AddNode(v0AFib7,1);
1343
1344     /// Non-sensitive scintilator
1345     new TGeoTubeSeg("sV0AR5S27", fV0AR4+fV0AFraWd/2., fV0AR4 + fV0AR0, fV0ASciWd/2.+2*preShape, 270.0, 315.0);
1346     TGeoCompositeShape *sV0AR57 = new TGeoCompositeShape("V0AR57","sV0AR5S27 - sV0ACha7");
1347     TGeoVolume *v0AR57 = new TGeoVolume("V0AR57",sV0AR57,medV0ASci);
1348     v0AR57->SetLineColor(kV0AColorSci);
1349     v0ASci7->AddNode(v0AR57,1);
1350     v0ASec7->AddNode(v0ASci7,1);
1351
1352     /// Segment of octagon   
1353     for (int i=0;i<2;i++) {
1354     v0APts[0+8*i] = 0.;                          v0APts[1+8*i] = -(fV0AR7-fV0AOctH2)*sin654;
1355     v0APts[2+8*i] = 0.;                          v0APts[3+8*i] = -fV0AR7*sin654;
1356     v0APts[4+8*i] = fV0AR7*cos654;               v0APts[5+8*i] = -fV0AR7*sin654;
1357     v0APts[6+8*i] = (fV0AR7-fV0AOctH2)*cos654;   v0APts[7+8*i] = -(fV0AR7-fV0AOctH2)*sin654;
1358     }
1359     TGeoArb8 *sV0AOct27 = new TGeoArb8("sV0AOct27", (fV0ASciWd+2*fV0AOctWd)/2., v0APts);
1360     TGeoVolume *v0AOct27 = new TGeoVolume("V0AOct27", sV0AOct27,medV0ASup);
1361     v0AOct27->SetLineColor(kV0AColorOct);
1362     TGeoVolume *v0ASup7 = new TGeoVolumeAssembly("V0ASup7");
1363     v0ASup7->AddNode(v0AOct27,1);
1364     v0ASec7->AddNode(v0ASup7,1);
1365
1366     /// Plates
1367     for (int i=0;i<2;i++) {
1368     v0APts[0+8*i] = 0.;                 v0APts[1+8*i] = -fV0AR0;
1369     v0APts[2+8*i] = 0.;                 v0APts[3+8*i] = -fV0AR7*sin654;
1370     v0APts[4+8*i] = fV0AR7*cos654;      v0APts[5+8*i] = -fV0AR7*sin654;
1371     v0APts[6+8*i] = fV0AR0*cos654;              v0APts[7+8*i] = -fV0AR0*sin654;
1372     }
1373     new TGeoArb8("sV0APlaIn7", (fV0APlaWd-2*fV0APlaAl)/2., v0APts);
1374     TGeoCompositeShape *sV0APlaInNailsHoles7 = new TGeoCompositeShape("sV0APlaInNailsHoles7","sV0APlaIn7-sV0ANail1PlaInHole7:pos17");
1375     TGeoVolume *v0APlaInNailsHoles7 = new TGeoVolume("V0APlaInNailsHoles7", sV0APlaInNailsHoles7, medV0APlaIn);
1376     new TGeoArb8("sV0APlaOu7", fV0APlaAl/2., v0APts);
1377     TGeoCompositeShape *sV0APlaOuNailsHoles7 = new TGeoCompositeShape("sV0APlaOuNailsHoles7","sV0APlaOu7-sV0ANail1PlaOuHole7:pos17"); 
1378     TGeoVolume *v0APlaOuNailsHoles7 = new TGeoVolume("V0APlaOuNailsHoles7", sV0APlaOuNailsHoles7, medV0APlaOu);
1379     v0APlaInNailsHoles7->SetLineColor(kV0AColorPlaIn); v0APlaOuNailsHoles7->SetLineColor(kV0AColorPlaOu);
1380     TGeoVolume *v0APla7 = new TGeoVolumeAssembly("V0APla7");
1381     v0APla7->AddNode(v0APlaInNailsHoles7,1);
1382     v0APla7->AddNode(v0APlaOuNailsHoles7,1,new TGeoTranslation(0,0,(fV0APlaWd-fV0APlaAl)/2.));
1383     v0APla7->AddNode(v0APlaOuNailsHoles7,2,new TGeoTranslation(0,0,-(fV0APlaWd-fV0APlaAl)/2.));
1384     v0ASec7->AddNode(v0APla7,1,new TGeoTranslation(0,0,(fV0ASciWd+2*fV0AOctWd+fV0APlaWd)/2.));
1385     v0ASec7->AddNode(v0APla7,2,new TGeoTranslation(0,0,-(fV0ASciWd+2*fV0AOctWd+fV0APlaWd)/2.));
1386     
1387     /// PMBox  
1388     TGeoVolume* v0APM7 = new TGeoVolumeAssembly("V0APM7");
1389     new TGeoBBox("sV0APMB17", fV0APMBWd/2., fV0APMBHt/2., fV0APMBTh/2.);
1390     new TGeoBBox("sV0APMB27", fV0APMBWd/2.-fV0APMBWdW, fV0APMBHt/2.-fV0APMBHtW, fV0APMBTh/2.-fV0APMBThW);
1391     TGeoCompositeShape *sV0APMB7 = new TGeoCompositeShape("sV0APMB7","sV0APMB17-sV0APMB27");
1392     TGeoVolume *v0APMB7 = new TGeoVolume("V0APMB7",sV0APMB7, medV0APMAlum);
1393     v0APMB7->SetLineColor(kV0AColorPMA);
1394     v0APM7->AddNode(v0APMB7,1);
1395     
1396     /// PMTubes 
1397     TGeoTube *sV0APMT17 = new TGeoTube("sV0APMT17", fV0APMTR1, fV0APMTR2, fV0APMTH/2.);
1398     TGeoVolume *v0APMT17 = new TGeoVolume("V0APMT17", sV0APMT17, medV0APMGlass);
1399     TGeoTube *sV0APMT27 = new TGeoTube("sV0APMT27", fV0APMTR3, fV0APMTR4, fV0APMTH/2.);
1400     TGeoVolume *v0APMT27 = new TGeoVolume("V0APMT27", sV0APMT27, medV0APMAlum);
1401     TGeoVolume *v0APMT7 = new TGeoVolumeAssembly("V0APMT7"); // pk si no choca con la 752 o con la 794
1402     TGeoTube *sV0APMTT7 = new TGeoTube("sV0APMTT7", 0., fV0APMTR4, fV0APMTB/2.);
1403     TGeoVolume *v0APMTT7 = new TGeoVolume("V0APMTT7", sV0APMTT7, medV0APMAlum);
1404     v0APMT7->SetLineColor(kV0AColorPMG);
1405     v0APMT27->SetLineColor(kV0AColorPMA);
1406     v0APMTT7->SetLineColor(kV0AColorPMA);
1407     rot = new TGeoRotation("rot", 90, 0, 180, 0, 90, 90);
1408     v0APMT7->AddNode(v0APMT17,1,rot);
1409     v0APMT7->AddNode(v0APMT27,1,rot);
1410     v0APMT7->AddNode(v0APMTT7,1,new TGeoCombiTrans(0,(fV0APMTH+fV0APMTB)/2.,0,rot));
1411     v0APM7->AddNode(v0APMT7, 1, new TGeoTranslation(-1.5*autoShift, 0, 0));
1412     v0APM7->AddNode(v0APMT7, 2, new TGeoTranslation(-0.5*autoShift, 0, 0));
1413     v0APM7->AddNode(v0APMT7, 3, new TGeoTranslation(+0.5*autoShift, 0, 0));
1414     v0APM7->AddNode(v0APMT7, 4, new TGeoTranslation(+1.5*autoShift, 0, 0));
1415
1416     /// PM 
1417     rot = new TGeoRotation("rot");
1418     rot->RotateX(-90+30);
1419     rot->RotateY(0);
1420     rot->RotateZ(65+3);
1421     double shiftZ7 = fV0APMBHt/2. * cosAngPMB
1422       -   ( fV0ASciWd + 2 * fV0AOctWd + 2 * fV0APlaWd )/2.   -   fV0APMBTh/2. * sinAngPMB;
1423     double shiftR7 = fV0AR6  + fV0AR1 + fV0AOctWd + fV0APlaAl/3.;
1424     v0ASec7->AddNode(v0APM7,1, new TGeoCombiTrans( shiftR7*cos45+1.3, -shiftR7*sin45, shiftZ7, rot)); 
1425     
1426     // Aluminium nail
1427     TGeoTube *sV0ANail71 = new TGeoTube("sV0ANail71", 0.0, 0.4, 5.09/2.);
1428     TGeoVolume *v0ANail71 = new TGeoVolume("V0ANail71", sV0ANail71, medV0APMAlum);
1429     v0ANail71->SetLineColor(kV0AColorPMA);// this is the color for aluminium
1430     v0ASec7->AddNode(v0ANail71,1,new TGeoTranslation(0.51,-42.9,0.0));
1431     TGeoTube *sV0ANail72 = new TGeoTube("sV0ANail72", 0.0, 0.4, 5.09/2.);
1432     TGeoVolume *v0ANail72 = new TGeoVolume("V0ANail72", sV0ANail72, medV0APMAlum);
1433     v0ANail72->SetLineColor(kV0AColorPMA);
1434     v0ASec7->AddNode(v0ANail72,1,new TGeoTranslation(30.05,-30.79,0.0));  
1435
1436     // Support
1437     TGeoBBox *sV0ASuppbr = new TGeoBBox("sV0ASuppbr", 2.0, 18.13, fV0ASciWd/2.);      
1438     TGeoVolume *v0ASuppbr = new TGeoVolume("V0ASuppbr", sV0ASuppbr, medV0ASup);
1439     v0ASuppbr->SetLineColor(kV0AColorOct);
1440     v0ASec7->AddNode(v0ASuppbr,1,new TGeoTranslation(2.0,-63.64,0.0));
1441     
1442     // Adding sector to v0LE volume 
1443     v0LE->AddNode(v0ASec7,1);
1444     
1445
1446    //Definition of sector 8
1447    TGeoVolume *v0ASec8 = new TGeoVolumeAssembly("V0ASec8"); 
1448   
1449   /// For boolean sustraction
1450       for (int i=0;i<2;i++) {
1451       v0APts[0+8*i] = fV0AR0-fV0AFraWd/2.+preShape;  v0APts[1+8*i] = 0.0;
1452       v0APts[2+8*i] = fV0AR0-fV0AFraWd/2.+preShape;  v0APts[3+8*i] = -preShape;
1453       v0APts[4+8*i] = fV0AR4+fV0AFraWd/2.-preShape;  v0APts[5+8*i] = -preShape;
1454       v0APts[6+8*i] = fV0AR4+fV0AFraWd/2.-preShape;  v0APts[7+8*i] = 0.0;
1455     }
1456     new TGeoArb8("sV0ACha18",fV0ASciWd/1.5,v0APts);
1457     for (int i=0;i<2;i++) {
1458       v0APts[0+8*i] = fV0AR0*sin45-fV0AFraWd/2.-preShape;
1459       v0APts[1+8*i] = -(fV0AR0-fV0AFraWd)*sin45+preShape;
1460       v0APts[2+8*i] = (fV0AR0-fV0AFraWd/2.)*sin45-preShape;
1461       v0APts[3+8*i] = -(fV0AR0-fV0AFraWd/2.)*sin45;
1462       v0APts[4+8*i] = (fV0AR4+fV0AFraWd/2.)*sin45+preShape; 
1463       v0APts[5+8*i] = -(fV0AR4+fV0AFraWd/2.)*sin45-2.*preShape;
1464       v0APts[6+8*i] = (fV0AR4+fV0AFraWd)*sin45+preShape;
1465       v0APts[7+8*i] = -fV0AR4*sin45-preShape;
1466     }
1467     new TGeoArb8("sV0ACha28", fV0ASciWd/2.+2.*preShape, v0APts);
1468     new TGeoCompositeShape("sV0ACha128","sV0ACha18+sV0ACha28");
1469     new TGeoTube("sV0ANail18Hole", 0.0, 0.4, 1.65);
1470     TGeoTranslation *pos18 = new TGeoTranslation("pos18",42.9,-.51,0.0);
1471     pos18->RegisterYourself();
1472     new TGeoTube("sV0ANail28Hole", 0.0, 0.4, 1.65);
1473     TGeoTranslation *pos28 = new TGeoTranslation("pos28",30.8,-30.04,0.0);
1474     pos28->RegisterYourself();    
1475     TGeoTranslation *pos38 = new TGeoTranslation("pos38",30.05,-30.79,0.0);  
1476     pos38->RegisterYourself();
1477     new TGeoCompositeShape("sV0ANailsHoles8","sV0ANail18Hole:pos18+sV0ANail28Hole:pos28");
1478     new TGeoCompositeShape("sV0ACha8","sV0ACha128+sV0ANailsHoles8");
1479     new TGeoTubeSeg("sV0AFicR58", fV0AR4+fV0AFraWd/2., fV0AR4 + fV0AR0, fV0ASciWd/2. +2*preShape, 315.0, 360.0);
1480     new TGeoTube("sV0ANail1PlaInHole8", 0.0, 0.4, (fV0APlaWd-2*fV0APlaAl)/2.);
1481     new TGeoTube("sV0ANail2PlaInHole8", 0.0, 0.4, (fV0APlaWd-2*fV0APlaAl)/2.);
1482     new TGeoTube("sV0ANail3PlaInHole8", 0.0, 0.4, (fV0APlaWd-2*fV0APlaAl)/2.);
1483     new TGeoCompositeShape("sV0ANailsPlaInHoles8","sV0ANail1PlaInHole8:pos18+sV0ANail2PlaInHole8:pos28+sV0ANail3PlaInHole8:pos38");
1484     new TGeoTube("sV0ANail1PlaOuHole8", 0.0, 0.4, (fV0APlaAl)/2.);
1485     new TGeoTube("sV0ANail2PlaOuHole8", 0.0, 0.4, (fV0APlaAl)/2.);
1486     new TGeoTube("sV0ANail3PlaOuHole8", 0.0, 0.4, (fV0APlaAl)/2.);
1487     new TGeoCompositeShape("sV0ANailsPlaOuHoles8","sV0ANail1PlaOuHole8:pos18+sV0ANail2PlaOuHole8:pos28+sV0ANail3PlaOuHole8:pos38");
1488     
1489     /// Frame 
1490     TGeoVolume *v0AFra8 = new TGeoVolumeAssembly("V0AFra8"); 
1491     for (int i=0;i<2;i++) {
1492       v0APts[0+8*i] = fV0AR0-fV0AFraWd/2.;  v0APts[1+8*i] = 0.0;
1493       v0APts[2+8*i] = fV0AR0-fV0AFraWd/2.;  v0APts[3+8*i] = -fV0AFraWd/8.; 
1494       v0APts[4+8*i] = fV0AR4+fV0AFraWd/2.;  v0APts[5+8*i] = -fV0AFraWd/8.;
1495       v0APts[6+8*i] = fV0AR4+fV0AFraWd/2.;  v0APts[7+8*i] = 0.0;
1496     }    
1497     TGeoArb8 *sV0AFraB18 = new TGeoArb8("sV0AFraB18",fV0ASciWd/2.,v0APts);
1498     TGeoVolume *v0AFraB18 = new TGeoVolume("V0AFraB18",sV0AFraB18,medV0AFra);  
1499     for (int i=0;i<2;i++) {
1500       v0APts[0+8*i] = fV0AR0*sin45-fV0AFraWd/2.;
1501       v0APts[1+8*i] = -(fV0AR0-fV0AFraWd)*sin45; 
1502       v0APts[2+8*i] = (fV0AR0-fV0AFraWd/2.)*sin45;
1503       v0APts[3+8*i] = -(fV0AR0-fV0AFraWd/2.)*sin45;
1504       v0APts[4+8*i] = (fV0AR4+fV0AFraWd/2.)*sin45/2.;
1505       v0APts[5+8*i] = -(fV0AR4+fV0AFraWd/2.)*sin45/2.;
1506       v0APts[6+8*i] = (fV0AR4+fV0AFraWd)*sin45/2.;
1507       v0APts[7+8*i] = -fV0AR4*sin45/2.;
1508     }
1509     TGeoArb8 *sV0AFraB28 = new TGeoArb8("sV0AFraB28", fV0ASciWd/2., v0APts);
1510     TGeoVolume *v0AFraB28 = new TGeoVolume("V0AFraB28",sV0AFraB28,medV0AFra);
1511     v0AFraB18->SetLineColor(kV0AColorFra); v0AFraB28->SetLineColor(kV0AColorFra);
1512     v0AFra8->AddNode(v0AFraB18,1);
1513     v0AFra8->AddNode(v0AFraB28,1);  // Prefer 2 GeoObjects insted of 3 GeoMovements
1514     new TGeoTubeSeg( "sV0AFraR1b8", fV0AR0-fV0AFraWd/2.,
1515                      fV0AR0+fV0AFraWd/2., fV0ASciWd/2., 315.0, 360.0);
1516     new TGeoTubeSeg( "sV0AFraR2b8", fV0AR1-fV0AFraWd/2.,
1517                      fV0AR1+fV0AFraWd/2., fV0ASciWd/2., 315.0, 360.0);
1518     new TGeoTubeSeg( "sV0AFraR3b8", fV0AR2-fV0AFraWd/2.,
1519                      fV0AR2+fV0AFraWd/2., fV0ASciWd/2., 315.0, 360.0);
1520     new TGeoTubeSeg( "sV0AFraR4b8", fV0AR3-fV0AFraWd/2.,
1521                      fV0AR3+fV0AFraWd/2., fV0ASciWd/2., 315.0, 360.0);
1522     new TGeoTubeSeg( "sV0AFraR5b8", fV0AR4-fV0AFraWd/2.,
1523                      fV0AR4+fV0AFraWd/2., fV0ASciWd/2., 315.0, 360.0);
1524     TGeoCompositeShape *sV0AFraR18 = new TGeoCompositeShape("sV0AFraR18","sV0AFraR1b8-sV0ACha8");
1525     TGeoCompositeShape *sV0AFraR28 = new TGeoCompositeShape("sV0AFraR28","sV0AFraR2b8-sV0ACha8");
1526     TGeoCompositeShape *sV0AFraR38 = new TGeoCompositeShape("sV0AFraR38","sV0AFraR3b8-sV0ACha8");
1527     TGeoCompositeShape *sV0AFraR48 = new TGeoCompositeShape("sV0AFraR48","sV0AFraR4b8-sV0ACha8");
1528     TGeoCompositeShape *sV0AFraR58 = new TGeoCompositeShape("sV0AFraR58","sV0AFraR5b8-sV0ACha8");
1529     TGeoVolume *v0AFraR18 = new TGeoVolume("V0AFraR18",sV0AFraR18,medV0AFra);
1530     TGeoVolume *v0AFraR28 = new TGeoVolume("V0AFraR28",sV0AFraR28,medV0AFra);
1531     TGeoVolume *v0AFraR38 = new TGeoVolume("V0AFraR38",sV0AFraR38,medV0AFra);
1532     TGeoVolume *v0AFraR48 = new TGeoVolume("V0AFraR48",sV0AFraR48,medV0AFra);
1533     TGeoVolume *v0AFraR58 = new TGeoVolume("V0AFraR58",sV0AFraR58,medV0AFra);
1534     v0AFraR18->SetLineColor(kV0AColorFra); v0AFraR28->SetLineColor(kV0AColorFra);
1535     v0AFraR38->SetLineColor(kV0AColorFra); v0AFraR48->SetLineColor(kV0AColorFra);
1536     v0AFraR58->SetLineColor(kV0AColorFra);
1537     v0AFra8->AddNode(v0AFraR18,1);
1538     v0AFra8->AddNode(v0AFraR28,1);
1539     v0AFra8->AddNode(v0AFraR38,1);
1540     v0AFra8->AddNode(v0AFraR48,1);
1541     v0AFra8->AddNode(v0AFraR58,1);
1542     v0ASec8->AddNode(v0AFra8,1);
1543
1544     /// Sensitive scintilator
1545     TGeoVolume *v0ASci8 = new TGeoVolumeAssembly("V0ASci8");
1546     new TGeoTubeSeg( "sV0AR1b8", fV0AR0+fV0AFraWd/2.,
1547                      fV0AR1-fV0AFraWd/2., fV0ASciWd/2., 315.0, 360.0);
1548     new TGeoTubeSeg( "sV0AR2b8", fV0AR1+fV0AFraWd/2.,
1549                      fV0AR2-fV0AFraWd/2., fV0ASciWd/2., 315.0, 360.0);
1550     new TGeoTubeSeg( "sV0AR3b8", fV0AR2+fV0AFraWd/2.,
1551                      fV0AR3-fV0AFraWd/2., fV0ASciWd/2., 315.0, 360.0);
1552     new TGeoTubeSeg( "sV0AR4b8", fV0AR3+fV0AFraWd/2.,
1553                      fV0AR4-fV0AFraWd/2., fV0ASciWd/2., 315.0, 360.0);
1554     TGeoCompositeShape *sV0AR18 = new TGeoCompositeShape("sV0AR18","sV0AR1b8-sV0ACha8");
1555     TGeoCompositeShape *sV0AR28 = new TGeoCompositeShape("sV0AR28","sV0AR2b8-sV0ACha8");
1556     TGeoCompositeShape *sV0AR38 = new TGeoCompositeShape("sV0AR38","sV0AR3b8-sV0ACha8");
1557     TGeoCompositeShape *sV0AR48 = new TGeoCompositeShape("sV0AR48","sV0AR4b8-sV0ACha8");
1558     TGeoVolume *v0L18 = new TGeoVolume("V0L18",sV0AR18,medV0ASci);
1559     TGeoVolume *v0L28 = new TGeoVolume("V0L28",sV0AR28,medV0ASci);
1560     TGeoVolume *v0L38 = new TGeoVolume("V0L38",sV0AR38,medV0ASci);
1561     TGeoVolume *v0L48 = new TGeoVolume("V0L48",sV0AR48,medV0ASci);
1562     v0L18->SetLineColor(kV0AColorSci); v0L28->SetLineColor(kV0AColorSci);
1563     v0L38->SetLineColor(kV0AColorSci); v0L48->SetLineColor(kV0AColorSci);
1564     v0ASci8->AddNode(v0L18,1);
1565     v0ASci8->AddNode(v0L28,1);
1566     v0ASci8->AddNode(v0L38,1);
1567     v0ASci8->AddNode(v0L48,1); 
1568
1569     /// Segment of octagon   
1570     for (int i=0;i<2;i++) {
1571     v0APts[0+8*i] = fV0AR6-fV0AOctH2;            v0APts[1+8*i] = 0.;
1572     v0APts[2+8*i] = (fV0AR7-fV0AOctH2)*cos654;   v0APts[3+8*i] = -(fV0AR7-fV0AOctH2)*sin654;
1573     v0APts[4+8*i] = fV0AR7*cos654;               v0APts[5+8*i] = -fV0AR7*sin654;
1574     v0APts[6+8*i] = fV0AR6;                      v0APts[7+8*i] = 0.;
1575     }
1576     TGeoArb8 *sV0AOct28 = new TGeoArb8("sV0AOct28", (fV0ASciWd+2*fV0AOctWd)/2., v0APts);
1577     TGeoVolume *v0AOct28 = new TGeoVolume("V0AOct28", sV0AOct28,medV0ASup);
1578     v0AOct28->SetLineColor(kV0AColorOct);
1579     TGeoVolume *v0ASup8 = new TGeoVolumeAssembly("V0ASup8");
1580     v0ASup8->AddNode(v0AOct28,1);
1581     v0ASec8->AddNode(v0ASup8,1);
1582
1583     //Bunch of fibers
1584     v0APts[ 0] = v0APts[ 2] = -14.0;
1585     v0APts[ 1] = v0APts[ 7] = (fV0ASciWd+fV0AOctWd)/2.-0.01;
1586     v0APts[ 3] = v0APts[ 5] = (fV0ASciWd+fV0AOctWd)/2.+0.01;
1587     v0APts[ 4] = v0APts[ 6] = +14.0;
1588     v0APts[ 8] = v0APts[10] = -10.0;
1589     v0APts[ 9] = v0APts[15] = 0.;
1590     v0APts[11] = v0APts[13] = 0.25;
1591     v0APts[12] = v0APts[14] = +10.0;
1592     new TGeoArb8("sV0AFib18", 11.8, v0APts); 
1593     rot = new TGeoRotation("rot");
1594     rot->RotateX(-90);
1595     rot->RotateZ(-90-22.5);
1596     TGeoCombiTrans *fib18pos = new TGeoCombiTrans("fib18pos", (fV0AR6-fV0AOctH2+fV0AR5)*cos225/2. - 3.3, -(fV0AR6-fV0AOctH2+fV0AR5)*sin225/2. + 1.5, 0, rot);
1597     fib18pos->RegisterYourself();
1598     TGeoCompositeShape *sV0AFib18Hole = new TGeoCompositeShape("sV0AFib18Hole", "sV0AFib18:fib18pos-sV0AFicR58");
1599     TGeoVolume *v0AFib18Hole = new TGeoVolume("V0AFib18",sV0AFib18Hole,medV0AFib);
1600     v0AFib18Hole->SetLineColor(kV0AColorFib);
1601     new TGeoArb8("sV0AFib28", 11.8, v0APts);
1602     rot = new TGeoRotation("rot");
1603     rot->RotateX(-90);
1604     rot->RotateY(180);
1605     rot->RotateZ(-90-22.5);
1606     TGeoCombiTrans *fib28pos = new TGeoCombiTrans("fib28pos", (fV0AR6-fV0AOctH2+fV0AR5)*cos225/2. - 3.3, -(fV0AR6-fV0AOctH2+fV0AR5)*sin225/2. + 1.5, 0, rot);
1607     fib28pos->RegisterYourself();
1608     TGeoCompositeShape *sV0AFib28Hole = new TGeoCompositeShape("sV0AFib28Hole", "sV0AFib28:fib28pos-sV0AFicR58");
1609     TGeoVolume *v0AFib28Hole = new TGeoVolume("V0AFib28Hole",sV0AFib28Hole,medV0AFib);
1610     v0AFib28Hole->SetLineColor(kV0AColorFib);
1611     TGeoVolume *v0AFib8 = new TGeoVolumeAssembly("V0AFib8");    
1612     v0AFib8->AddNode(v0AFib18Hole,1);
1613     v0AFib8->AddNode(v0AFib28Hole,1);
1614     v0ASec8->AddNode(v0AFib8,1);
1615              
1616     /// Non-sensitive scintilator   
1617     new TGeoTubeSeg("sV0AR5S28", fV0AR4+fV0AFraWd/2., fV0AR4 + fV0AR0, fV0ASciWd/2.+2*preShape, 315.0, 360.0);
1618     TGeoCompositeShape *sV0AR58 = new TGeoCompositeShape("V0AR58","sV0AR5S28 - sV0ACha8");
1619     TGeoVolume *v0AR58 = new TGeoVolume("V0AR58",sV0AR58,medV0ASci);
1620     v0AR58->SetLineColor(kV0AColorSci);
1621     v0ASci8->AddNode(v0AR58,1);
1622     v0ASec8->AddNode(v0ASci8,1); 
1623     
1624     /// Plates
1625     for (int i=0;i<2;i++) {
1626       v0APts[0+8*i] = fV0AR0;                   v0APts[1+8*i] = 0.;
1627       v0APts[2+8*i] = fV0AR0*cos654;            v0APts[3+8*i] = -fV0AR0*sin654;
1628       v0APts[4+8*i] = fV0AR7*cos654;            v0APts[5+8*i] = -fV0AR7*sin654;
1629       v0APts[6+8*i] = fV0AR6;                   v0APts[7+8*i] = 0.;
1630     }
1631     new TGeoArb8("sV0APlaIn8", (fV0APlaWd-2*fV0APlaAl)/2., v0APts);
1632     TGeoCompositeShape *sV0APlaInNailsHoles8 = new TGeoCompositeShape("sV0APlaInNailsHoles8","sV0APlaIn8-sV0ANailsPlaInHoles8");
1633     TGeoVolume *v0APlaInNailsHoles8 = new TGeoVolume("V0APlaInNailsHoles8", sV0APlaInNailsHoles8, medV0APlaIn);
1634     new TGeoArb8("sV0APlaOu8", fV0APlaAl/2., v0APts);
1635     TGeoCompositeShape *sV0APlaOuNailsHoles8 = new TGeoCompositeShape("sV0APlaOuNailsHoles8","sV0APlaOu8-sV0ANailsPlaOuHoles8"); 
1636     TGeoVolume *v0APlaOuNailsHoles8 = new TGeoVolume("V0APlaOuNailsHoles8", sV0APlaOuNailsHoles8, medV0APlaOu);
1637     v0APlaInNailsHoles8->SetLineColor(kV0AColorPlaIn); v0APlaOuNailsHoles8->SetLineColor(kV0AColorPlaOu);
1638     TGeoVolume *v0APla8 = new TGeoVolumeAssembly("V0APla8");
1639     v0APla8->AddNode(v0APlaInNailsHoles8,1);
1640     v0APla8->AddNode(v0APlaOuNailsHoles8,1,new TGeoTranslation(0,0,(fV0APlaWd-fV0APlaAl)/2.));
1641     v0APla8->AddNode(v0APlaOuNailsHoles8,2,new TGeoTranslation(0,0,-(fV0APlaWd-fV0APlaAl)/2.));
1642     v0ASec8->AddNode(v0APla8,1,new TGeoTranslation(0,0,(fV0ASciWd+2*fV0AOctWd+fV0APlaWd)/2.));
1643     v0ASec8->AddNode(v0APla8,2,new TGeoTranslation(0,0,-(fV0ASciWd+2*fV0AOctWd+fV0APlaWd)/2.));
1644
1645     /// PMBox 
1646     TGeoVolume* v0APM8 = new TGeoVolumeAssembly("V0APM1");
1647     new TGeoBBox("sV0APMB18", fV0APMBWd/2., fV0APMBHt/2., fV0APMBTh/2.);
1648     new TGeoBBox("sV0APMB28", fV0APMBWd/2.-fV0APMBWdW, fV0APMBHt/2.-fV0APMBHtW, fV0APMBTh/2.-fV0APMBThW);
1649     TGeoCompositeShape *sV0APMB8 = new TGeoCompositeShape("sV0APMB8","sV0APMB18-sV0APMB28");
1650     TGeoVolume *v0APMB8 = new TGeoVolume("V0APMB8",sV0APMB8, medV0APMAlum);
1651     v0APMB8->SetLineColor(kV0AColorPMA);
1652     v0APM8->AddNode(v0APMB8,1);
1653
1654     /// PMTubes 
1655     TGeoTube *sV0APMT18 = new TGeoTube("sV0APMT18", fV0APMTR1, fV0APMTR2, fV0APMTH/2.);
1656     TGeoVolume *v0APMT18 = new TGeoVolume("V0APMT18", sV0APMT18, medV0APMGlass);
1657     TGeoTube *sV0APMT28 = new TGeoTube("sV0APMT28", fV0APMTR3, fV0APMTR4, fV0APMTH/2.);
1658     TGeoVolume *v0APMT28 = new TGeoVolume("V0APMT28", sV0APMT28, medV0APMAlum);
1659     TGeoVolume *v0APMT8 = new TGeoVolumeAssembly("V0APMT8");
1660     TGeoTube *sV0APMTT8 = new TGeoTube("sV0APMTT8", 0., fV0APMTR4, fV0APMTB/2.);
1661     TGeoVolume *v0APMTT8 = new TGeoVolume("V0APMTT8", sV0APMTT8, medV0APMAlum);
1662     v0APMT8->SetLineColor(kV0AColorPMG);
1663     v0APMT28->SetLineColor(kV0AColorPMA);
1664     v0APMTT8->SetLineColor(kV0AColorPMA);
1665     rot = new TGeoRotation("rot", 90, 0, 180, 0, 90, 90);
1666     v0APMT8->AddNode(v0APMT18,1,rot);
1667     v0APMT8->AddNode(v0APMT28,1,rot);
1668     v0APMT8->AddNode(v0APMTT8,1,new TGeoCombiTrans(0,(fV0APMTH+fV0APMTB)/2.,0,rot));
1669     double autoShift8 = (fV0APMBWd-2*fV0APMBWdW)/4.;
1670     v0APM8->AddNode(v0APMT8, 1, new TGeoTranslation(-1.5*autoShift8, 0, 0));
1671     v0APM8->AddNode(v0APMT8, 2, new TGeoTranslation(-0.5*autoShift8, 0, 0));
1672     v0APM8->AddNode(v0APMT8, 3, new TGeoTranslation(+0.5*autoShift8, 0, 0));
1673     v0APM8->AddNode(v0APMT8, 4, new TGeoTranslation(+1.5*autoShift8, 0, 0));
1674
1675     /// PM 
1676     rot = new TGeoRotation("rot");
1677     rot->RotateX(-90+30);
1678     rot->RotateY(0);
1679     rot->RotateZ(65+3);
1680     double shiftZ8 = fV0APMBHt/2. * cosAngPMB
1681       -   ( fV0ASciWd + 2 * fV0AOctWd + 2 * fV0APlaWd )/2.   -   fV0APMBTh/2. * sinAngPMB;
1682     double shiftR8 = fV0AR6  +  fV0AOctH2 + fV0APlaAl;
1683     v0ASec8->AddNode(v0APM8,1, new TGeoCombiTrans( shiftR8*cos225 + 1.3, -shiftR8*sin225, shiftZ8, rot));
1684
1685     // Aluminium nails
1686     TGeoTube *sV0ANail81 = new TGeoTube("sV0ANail81", 0.0, 0.4, 5.09/2.);
1687     TGeoVolume *v0ANail81 = new TGeoVolume("V0ANail81", sV0ANail81, medV0APMAlum);
1688     v0ANail81->SetLineColor(kV0AColorPMA);// this is the color for aluminium
1689     v0ASec8->AddNode(v0ANail81,1,new TGeoTranslation(42.9,-.51,0.0));
1690     TGeoTube *sV0ANail82 = new TGeoTube("sV0ANail82", 0.0, 0.4, 5.09/2.);
1691     TGeoVolume *v0ANail82 = new TGeoVolume("V0ANail82", sV0ANail82, medV0APMAlum); 
1692     v0ANail82->SetLineColor(kV0AColorPMA);
1693     v0ASec8->AddNode(v0ANail82,1,new TGeoTranslation(30.8,-30.04,0.0));  
1694       
1695     // Adding sector to v0LE volume 
1696     v0LE->AddNode(v0ASec8, 1);
1697     
1698       
1699     // Adding detectors to top volume
1700     TGeoVolume *vZERO = new TGeoVolumeAssembly("VZERO");
1701     vZERO->AddNode(v0RI,1,new TGeoTranslation(0, 0, -zdet));
1702     vZERO->AddNode(v0LE,1,new TGeoTranslation(0, 0, +327.5));
1703     top->AddNode(vZERO,1);
1704 }
1705
1706 //_____________________________________________________________________________
1707 void AliVZEROv7::AddAlignableVolumes() const
1708 {
1709   //
1710   // Create entries for alignable volumes associating the symbolic volume
1711   // name with the corresponding volume path. Needs to be syncronized with
1712   // eventual changes in the geometry.
1713   // 
1714   TString vpC = "/ALIC_1/VZERO_1/V0RI_1";
1715   TString vpA = "/ALIC_1/VZERO_1/V0LE_1";
1716   TString snC = "VZERO/V0C";
1717   TString snA = "VZERO/V0A";
1718   
1719   if(!gGeoManager->SetAlignableEntry(snC.Data(),vpC.Data()))
1720     AliFatal(Form("Alignable entry %s not created. Volume path %s not valid", snC.Data(),vpC.Data()));
1721   if(!gGeoManager->SetAlignableEntry(snA.Data(),vpA.Data()))
1722     AliFatal(Form("Alignable entry %s not created. Volume path %s not valid", snA.Data(),vpA.Data()));
1723
1724
1725
1726 //_____________________________________________________________________________
1727 void AliVZEROv7::CreateMaterials()
1728 {
1729
1730 // Creates materials used for geometry 
1731
1732   AliDebug(2,"Create materials");
1733   // Parameters for simulation scope
1734   Int_t     fieldType       = gAlice->Field()->Integ();     // Field type 
1735   Double_t  maxField        = gAlice->Field()->Max();       // Field max.
1736   Double_t  maxBending      = 10;    // Max Angle
1737   Double_t  maxStepSize     = 0.01;  // Max step size 
1738   Double_t  maxEnergyLoss   = 1;     // Max Delta E
1739   Double_t  precision       = 0.003; // Precision
1740   Double_t  minStepSize     = 0.003; // Minimum step size 
1741
1742   Int_t    id;
1743   Double_t a, z, radLength, absLength;
1744   Float_t density, as[4], zs[4], ws[4];
1745
1746 // Parameters  for V0CPrePlates: Aluminium
1747    a = 26.98; 
1748    z = 13.00;
1749    density     = 2.7;
1750    radLength   = 8.9;
1751    absLength   = 37.2;
1752    id = 2;
1753    AliMaterial( id, "V0CAlu", a, z, density, radLength, absLength, 0, 0);
1754    AliMedium(id, "V0CAlu", id, 1, fieldType, maxField, maxBending, maxStepSize,
1755              maxEnergyLoss, precision, minStepSize);
1756                     
1757 // Parameters  for V0CPlates: Carbon 
1758    a = 12.01; 
1759    z =  6.00;
1760    density   = 2.265;
1761    radLength = 18.8;
1762    absLength = 49.9;
1763    id = 3;
1764    AliMaterial(id, "V0CCar",  a, z, density, radLength, absLength, 0, 0);
1765    AliMedium(id, "V0CCar", id, 1, fieldType, maxField, maxBending, maxStepSize,
1766              maxEnergyLoss, precision, minStepSize);
1767             
1768 // Parameters  for V0Cscintillator: BC408
1769    as[0] = 1.00794;     as[1] = 12.011;
1770    zs[0] = 1.;          zs[1] = 6.;
1771    ws[0] = 1.;          ws[1] = 1.;
1772    density      = 1.032;
1773    id           = 4;
1774    AliMixture(id, "V0CSci", as, zs, density, -2, ws);
1775    AliMedium(id,"V0CSci", id, 1, fieldType, maxField, maxBending, maxStepSize,
1776              maxEnergyLoss, precision, minStepSize);
1777
1778 // Parameters for V0Ascintilator: BC404
1779    as[0] = 1.00794;     as[1] = 12.011;
1780    zs[0] = 1.;          zs[1] = 6.;
1781    ws[0] = 5.21;        ws[1] = 4.74;
1782    density      = 1.032;
1783    id           = 5;
1784    AliMixture(id, "V0ASci", as, zs, density, -2, ws);
1785    AliMedium(id,  "V0ASci", id, 1, fieldType, maxField, maxBending, maxStepSize,
1786              maxEnergyLoss, precision, minStepSize);
1787
1788 // Parameters for V0ALuc: Lucita but for the simulation BC404
1789    as[0] = 1.00794;     as[1] = 12.011;
1790    zs[0] = 1.;          zs[1] = 6.;
1791    ws[0] = 5.21;        ws[1] = 4.74;
1792    density      = 1.032;
1793    id           = 6;
1794    AliMixture(id, "V0ALuc", as, zs, density, -2, ws);
1795    AliMedium(id, "V0ALuc", id, 1, fieldType, maxField, maxBending, maxStepSize,
1796              maxEnergyLoss, precision, minStepSize);
1797
1798 // Parameters for V0Aplate: EuroComposite - EC-PI 626 PS - AlMg3
1799    as[0] = 26.982;      as[1] = 24.305;
1800    zs[0] = 13.;         zs[1] = 12.;
1801    ws[0] = 1.;          ws[1] = 3.;
1802    density      = 3.034;
1803    id           = 7;
1804    AliMixture(id, "V0APlaOu", as, zs, density, -2, ws);
1805    AliMedium(id, "V0APlaOu", id, 1, fieldType, maxField, maxBending, maxStepSize,
1806              maxEnergyLoss, precision, minStepSize);
1807
1808 // Parameters for V0Aplate: EuroComposite - EC-PI 626 PS - EC-PI 6.4-42
1809    as[0] = 1.00794;     as[1] = 12.011;
1810    zs[0] = 1.;          zs[1] = 6.;
1811    ws[0] = 5.21;        ws[1] = 4.74;
1812    density      = 0.042;
1813    id           = 8;
1814    AliMixture(id, "V0APlaIn", as, zs, density, -2, ws);
1815    AliMedium(id, "V0APlaIn", id, 1, fieldType, maxField, maxBending, maxStepSize,
1816              maxEnergyLoss, precision, minStepSize);
1817
1818 // Parameters for V0Afiber: BC9929AMC Plastic Scintillating Fiber from Saint-Gobain
1819    as[0] = 1.00794;     as[1] = 12.011;
1820    zs[0] = 1.;          zs[1] = 6.;
1821    ws[0] = 4.82;        ws[1] = 4.85;
1822    density      = 1.05;
1823    id           = 9;
1824    AliMixture(id, "V0AFib", as, zs, density, -2, ws);
1825    AliMedium(id, "V0AFib", id, 1, fieldType, maxField, maxBending, maxStepSize,
1826              maxEnergyLoss, precision, minStepSize);
1827
1828 // Parameters for V0APMA: Aluminium
1829    a = 26.98; 
1830    z = 13.00;
1831    density     = 2.7;
1832    radLength   = 8.9;
1833    absLength   = 37.2;
1834    id = 10;
1835    AliMaterial(id, "V0APMA",  a, z, density, radLength, absLength, 0, 0);
1836    AliMedium(id, "V0APMA", id, 1, fieldType, maxField, maxBending, maxStepSize,
1837              maxEnergyLoss, precision, minStepSize);
1838
1839 // Parameters for V0APMG: Glass for the simulation Aluminium
1840    a = 26.98; 
1841    z = 13.00;
1842    density   = 2.7;
1843    radLength = 8.9;
1844    absLength = 37.2;
1845    id = 11;
1846    AliMaterial(id, "V0APMG",  a, z, density, radLength, absLength, 0, 0);
1847    AliMedium(id, "V0APMG", id, 1, fieldType, maxField, maxBending, maxStepSize,
1848              maxEnergyLoss, precision, minStepSize);
1849 }
1850
1851 //_____________________________________________________________________________
1852 void AliVZEROv7::DrawModule() const
1853 {
1854 //  Drawing is done in DrawVZERO.C
1855
1856    AliDebug(2,"DrawModule");
1857 }
1858
1859
1860 //_____________________________________________________________________________
1861 void AliVZEROv7::DrawGeometry() 
1862 {
1863 //  Drawing of V0 geometry done in DrawV0.C
1864
1865    AliDebug(2,"DrawGeometry");
1866 }
1867
1868 //_____________________________________________________________________________
1869 void AliVZEROv7::Init()
1870 {
1871 // Initialises version of the VZERO Detector given in Config
1872 // Just prints an information message
1873
1874 //   AliInfo(Form("VZERO version %d initialized \n",IsVersion()));
1875    
1876    AliDebug(1,"VZERO version 7 initialized");
1877    AliVZERO::Init();  
1878 }
1879
1880 //_____________________________________________________________________________
1881 void AliVZEROv7::StepManager()
1882 {
1883 // Step Manager, called at each step  
1884
1885   Int_t     copy;
1886   static    Int_t   vol[4];
1887   static    Float_t hits[21];
1888   static    Float_t eloss, tlength;
1889   static    Int_t   nPhotonsInStep = 0;
1890   static    Int_t   nPhotons = 0; 
1891   static    Int_t   numStep = 0;
1892   Int_t     ringNumber;
1893   Float_t   destep, step;
1894   numStep += 1; 
1895
1896   //   We keep only charged tracks : 
1897   if ( !gMC->TrackCharge() || !gMC->IsTrackAlive() ) return;
1898
1899   vol[0]    = gMC->CurrentVolOffID(1, vol[1]);
1900   vol[2]    = gMC->CurrentVolID(copy);
1901   vol[3]    = copy;
1902   static Int_t idV0R1 = gMC->VolId("V0R1");
1903   static Int_t idV0L1 = gMC->VolId("V0L1");
1904   static Int_t idV0L15 = gMC->VolId("V0L15");
1905   static Int_t idV0L16 = gMC->VolId("V0L16");
1906   static Int_t idV0L17 = gMC->VolId("V0L17");
1907   static Int_t idV0L18 = gMC->VolId("V0L18");  
1908   static Int_t idV0R2 = gMC->VolId("V0R2");
1909   static Int_t idV0L2 = gMC->VolId("V0L2");
1910   static Int_t idV0L25 = gMC->VolId("V0L25");
1911   static Int_t idV0L26 = gMC->VolId("V0L26");
1912   static Int_t idV0L27 = gMC->VolId("V0L27");
1913   static Int_t idV0L28 = gMC->VolId("V0L28");
1914   static Int_t idV0R3 = gMC->VolId("V0R3");
1915   static Int_t idV0L3 = gMC->VolId("V0L3");
1916   static Int_t idV0L35 = gMC->VolId("V0L35");
1917   static Int_t idV0L36 = gMC->VolId("V0L36");
1918   static Int_t idV0L37 = gMC->VolId("V0L37");
1919   static Int_t idV0L38 = gMC->VolId("V0L38");
1920   static Int_t idV0R4 = gMC->VolId("V0R4");
1921   static Int_t idV0L4 = gMC->VolId("V0L4");
1922   static Int_t idV0L45 = gMC->VolId("V0L45");
1923   static Int_t idV0L46 = gMC->VolId("V0L46");
1924   static Int_t idV0L47 = gMC->VolId("V0L47");
1925   static Int_t idV0L48 = gMC->VolId("V0L48");
1926   static Int_t idV0R5 = gMC->VolId("V0R5");
1927   static Int_t idV0R6 = gMC->VolId("V0R6");
1928   bool   hitOnV0C = true;
1929   double lightYield;
1930   double lightAttenuation;
1931   double nMeters; 
1932   double fibToPhot;
1933   if      ( gMC->CurrentVolID(copy) == idV0R1 || gMC->CurrentVolID(copy) == idV0L1 || gMC->CurrentVolID(copy) == idV0L15 ||  gMC->CurrentVolID(copy) == idV0L16  || gMC->CurrentVolID(copy) == idV0L17  || gMC->CurrentVolID(copy) == idV0L18  )
1934     ringNumber = 1;
1935   else if ( gMC->CurrentVolID(copy) == idV0R2 || gMC->CurrentVolID(copy) == idV0L2 || gMC->CurrentVolID(copy) == idV0L25 || gMC->CurrentVolID(copy) == idV0L26 || gMC->CurrentVolID(copy) == idV0L27 || gMC->CurrentVolID(copy) == idV0L28 )
1936     ringNumber = 2;  
1937   else if ( gMC->CurrentVolID(copy) == idV0R3 || gMC->CurrentVolID(copy) == idV0R4
1938             || gMC->CurrentVolID(copy) == idV0L3 || gMC->CurrentVolID(copy) == idV0L35 || gMC->CurrentVolID(copy) == idV0L36 || gMC->CurrentVolID(copy) == idV0L37 || gMC->CurrentVolID(copy) == idV0L38 ) ringNumber = 3;
1939   else if ( gMC->CurrentVolID(copy) == idV0R5 || gMC->CurrentVolID(copy) == idV0R6
1940             || gMC->CurrentVolID(copy) == idV0L4 || gMC->CurrentVolID(copy) == idV0L45 || gMC->CurrentVolID(copy) == idV0L46 || gMC->CurrentVolID(copy) == idV0L47 || gMC->CurrentVolID(copy) == idV0L48 ) ringNumber = 4;             
1941   else ringNumber = 0;
1942   if  (ringNumber) {
1943     if (gMC->CurrentVolID(copy) == idV0L1 || gMC->CurrentVolID(copy) == idV0L15  || gMC->CurrentVolID(copy) == idV0L16  || gMC->CurrentVolID(copy) == idV0L17 || gMC->CurrentVolID(copy) == idV0L18 || gMC->CurrentVolID(copy) == idV0L2 || gMC->CurrentVolID(copy) == idV0L25 || gMC->CurrentVolID(copy) == idV0L26  || gMC->CurrentVolID(copy) == idV0L27  || gMC->CurrentVolID(copy) == idV0L28 || gMC->CurrentVolID(copy) == idV0L3 || gMC->CurrentVolID(copy) == idV0L35 || gMC->CurrentVolID(copy) == idV0L36 || gMC->CurrentVolID(copy) == idV0L37 || gMC->CurrentVolID(copy) == idV0L38 || gMC->CurrentVolID(copy) == idV0L4 || gMC->CurrentVolID(copy) == idV0L45 || gMC->CurrentVolID(copy) == idV0L46 || gMC->CurrentVolID(copy) == idV0L47 || gMC->CurrentVolID(copy) == idV0L48)
1944       hitOnV0C = false;
1945     destep = gMC->Edep();
1946     step   = gMC->TrackStep();
1947     if (hitOnV0C) {
1948       lightYield = fV0CLightYield;
1949       lightAttenuation = fV0CLightAttenuation;
1950       nMeters = fV0CnMeters;
1951       fibToPhot = fV0CFibToPhot;
1952     } else {
1953       lightYield = fV0ALightYield;
1954       lightAttenuation = fV0ALightAttenuation;
1955       nMeters = fV0AnMeters;
1956       fibToPhot = fV0AFibToPhot;
1957     }
1958     nPhotonsInStep  = Int_t(destep / (lightYield *1e-9) );      
1959     nPhotonsInStep  = gRandom->Poisson(nPhotonsInStep);
1960     eloss    += destep;
1961     tlength  += step;    
1962     if ( gMC->IsTrackEntering() ) { 
1963       nPhotons  =  nPhotonsInStep;
1964       gMC->TrackPosition(fTrackPosition);
1965       gMC->TrackMomentum(fTrackMomentum);
1966       Float_t pt  = TMath::Sqrt( fTrackMomentum.Px() * fTrackMomentum.Px()
1967                                  + fTrackMomentum.Py() * fTrackMomentum.Py() );
1968       TParticle *par = gAlice->GetMCApp()->Particle(gAlice->GetMCApp()->GetCurrentTrackNumber());
1969       hits[0]  = fTrackPosition.X();
1970       hits[1]  = fTrackPosition.Y();
1971       hits[2]  = fTrackPosition.Z();             
1972       hits[3]  = Float_t (gMC->TrackPid()); 
1973       hits[4]  = gMC->TrackTime();
1974       hits[5]  = gMC->TrackCharge();
1975       hits[6]  = fTrackMomentum.Theta()*TMath::RadToDeg();
1976       hits[7]  = fTrackMomentum.Phi()*TMath::RadToDeg();
1977       hits[8]  = ringNumber;
1978       hits[9]  = pt;
1979       hits[10] = fTrackMomentum.P();
1980       hits[11] = fTrackMomentum.Px();
1981       hits[12] = fTrackMomentum.Py();
1982       hits[13] = fTrackMomentum.Pz();
1983       hits[14] = par->Vx();
1984       hits[15] = par->Vy();
1985       hits[16] = par->Vz();
1986       tlength  = 0.0;
1987       eloss    = 0.0;       
1988
1989       //////////////////////////
1990       ///// Display V0A geometry
1991       //      if (!hitOnV0C) {
1992       //        FILE *of;
1993       //        of = fopen("V0A.out", "a");
1994       //        // x, y, z, ringnumber, cellid
1995       //        fprintf( of, "%f %f %f %f %d \n",  hits[0], hits[1], hits[2], hits[8], GetCellId (vol, hits) );
1996       //        fclose(of);
1997       //      }
1998       //////////////////////////
1999     }
2000     nPhotons  = nPhotons + nPhotonsInStep;
2001     if( gMC->IsTrackExiting() || gMC->IsTrackStop() || gMC->IsTrackDisappeared()){
2002       nPhotons = nPhotons - Int_t((Float_t(nPhotons) * lightAttenuation * nMeters));
2003       nPhotons = nPhotons - Int_t( Float_t(nPhotons) * fibToPhot);
2004       hits[17] = eloss;
2005       hits[18] = tlength;
2006       hits[19] = nPhotons;
2007       hits[20] = GetCellId (vol, hits);
2008       AddHit(gAlice->GetMCApp()->GetCurrentTrackNumber(), vol, hits);
2009       tlength         = 0.0;
2010       eloss           = 0.0; 
2011       nPhotons        = 0;
2012       nPhotonsInStep  = 0;
2013       numStep         = 0;  
2014     }
2015   }
2016 }
2017
2018 //_____________________________________________________________________________
2019 void AliVZEROv7::AddHit(Int_t track, Int_t *vol, Float_t *hits)
2020 {
2021 //  Adds a VZERO hit
2022
2023   TClonesArray &lhits = *fHits;
2024   new(lhits[fNhits++]) AliVZEROhit(fIshunt,track,vol,hits);
2025 }
2026
2027 //_____________________________________________________________________________
2028 void AliVZEROv7::AddDigits(Int_t *tracks, Int_t* digits) 
2029 {
2030 //  Adds a VZERO digit
2031
2032    TClonesArray  &ldigits = *fDigits;
2033    new(ldigits[fNdigits++]) AliVZEROdigit(tracks, digits);
2034 }
2035
2036 //_____________________________________________________________________________
2037 void AliVZEROv7::MakeBranch(Option_t *option)
2038 {
2039 // Creates new branches in the current Root Tree
2040     
2041   char branchname[10];
2042   sprintf(branchname,"%s",GetName());
2043   AliDebug(2,Form("fBufferSize = %d",fBufferSize));
2044   const char *cH = strstr(option,"H");
2045   if (fHits   && TreeH() && cH) {
2046     TreeH()->Branch(branchname,&fHits, fBufferSize);
2047     AliDebug(2,Form("Making Branch %s for hits",branchname));
2048   }     
2049   const char *cD = strstr(option,"D");
2050   if (fDigits   && fLoader->TreeD() && cD) {
2051     fLoader->TreeD()->Branch(branchname,&fDigits, fBufferSize);
2052     AliDebug(2,Form("Making Branch %s for digits",branchname));
2053   }  
2054 }
2055
2056 //_____________________________________________________________________________
2057 Int_t AliVZEROv7::GetCellId(Int_t *vol, Float_t *hits) 
2058 {
2059   //   Returns Id of scintillator cell
2060   //   Right side from  0 to 47 
2061   //   Left  side from 48 to 79
2062   //   hits[8] = ring number (1 to 4)
2063   //   vol[1]  = copy number (1 to 8)
2064
2065   Int_t index      = vol[1];
2066   Int_t ringNumber = Int_t(hits[8]);
2067   fCellId          = 0;
2068
2069   Float_t phi = Float_t(TMath::ATan2(Double_t(hits[1]),Double_t(hits[0])) ); 
2070   Float_t kRaddeg = 180.0/TMath::Pi();
2071   phi = kRaddeg * phi;
2072
2073   if (index < 7) index = index + 8;
2074
2075   if (hits[2] < 0.0) {
2076     if(ringNumber < 3) {
2077       index = (index - 7) + ( ( ringNumber - 1 ) * 8);
2078     } else if (ringNumber >= 3) { 
2079       if ( gMC->CurrentVolID(vol[1]) == gMC->VolId("V0R3") || gMC->CurrentVolID(vol[1])
2080            == gMC->VolId("V0R5") )  index = (index*2-14)+((ringNumber-2)*16);
2081       if ( gMC->CurrentVolID(vol[1]) == gMC->VolId("V0R4") || gMC->CurrentVolID(vol[1])
2082            == gMC->VolId("V0R6") )  index = (index*2-13)+((ringNumber-2)*16);
2083     }
2084     fCellId   = index;           
2085   } else if (hits[2] > 0.0) {
2086     //    cout << " vol[0] = " << vol[0] << " copy : " << vol[1] 
2087     //   << " called " << gMC->VolName(vol[0]) << endl;
2088     // cout << " vol[2] = " << vol[2] << " copy : " << vol[3] 
2089     //   << " called " << gMC->VolName(vol[2]) << endl;
2090     if (gMC->CurrentVolID(vol[2]) == gMC->VolId("V0L1")) fCellId = vol[1]+47;
2091     if (gMC->CurrentVolID(vol[2]) == gMC->VolId("V0L2")) fCellId = 8+vol[1]+47;
2092     if (gMC->CurrentVolID(vol[2]) == gMC->VolId("V0L3")) fCellId = 16+vol[1]+47;
2093     if (gMC->CurrentVolID(vol[2]) == gMC->VolId("V0L4")) fCellId = 24+vol[1]+47;
2094     if (gMC->CurrentVolID(vol[2]) == gMC->VolId("V0L15")) fCellId = 48+4;
2095     if (gMC->CurrentVolID(vol[2]) == gMC->VolId("V0L16")) fCellId = 48+5;
2096     if (gMC->CurrentVolID(vol[2]) == gMC->VolId("V0L17")) fCellId = 48+6;
2097     if (gMC->CurrentVolID(vol[2]) == gMC->VolId("V0L18")) fCellId = 48+7;
2098     if (gMC->CurrentVolID(vol[2]) == gMC->VolId("V0L25")) fCellId = 8+48+4;
2099     if (gMC->CurrentVolID(vol[2]) == gMC->VolId("V0L26")) fCellId = 8+48+5;
2100     if (gMC->CurrentVolID(vol[2]) == gMC->VolId("V0L27")) fCellId = 8+48+6;
2101     if (gMC->CurrentVolID(vol[2]) == gMC->VolId("V0L28")) fCellId = 8+48+7;
2102     if (gMC->CurrentVolID(vol[2]) == gMC->VolId("V0L35")) fCellId = 16+48+4;
2103     if (gMC->CurrentVolID(vol[2]) == gMC->VolId("V0L36")) fCellId = 16+48+5;
2104     if (gMC->CurrentVolID(vol[2]) == gMC->VolId("V0L37")) fCellId = 16+48+6;
2105     if (gMC->CurrentVolID(vol[2]) == gMC->VolId("V0L38")) fCellId = 16+48+7;
2106     if (gMC->CurrentVolID(vol[2]) == gMC->VolId("V0L45")) fCellId = 24+48+4;
2107     if (gMC->CurrentVolID(vol[2]) == gMC->VolId("V0L46")) fCellId = 24+48+5;
2108     if (gMC->CurrentVolID(vol[2]) == gMC->VolId("V0L47")) fCellId = 24+48+6;
2109     if (gMC->CurrentVolID(vol[2]) == gMC->VolId("V0L48")) fCellId = 24+48+7;
2110   }
2111
2112   return fCellId;
2113 }
2114