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