]> git.uio.no Git - u/mrichter/AliRoot.git/blob - VZERO/AliVZEROv7.cxx
removing tasks with the old name from the svn repo
[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 <TGeoGlobalMagField.h>
39 #include <TMath.h>
40 #include <TParticle.h>
41 #include <TVirtualMC.h>
42
43 #include <TGeoManager.h>
44 #include <TGeoMatrix.h>
45 #include <TGeoMaterial.h>
46 #include <TGeoMedium.h>
47 #include <TGeoVolume.h>
48 #include "TGeoTube.h"
49 #include "TGeoArb8.h"
50 #include "TGeoCompositeShape.h"
51 #include <TTree.h>
52
53 // --- AliRoot header files ---
54 #include "AliRun.h"
55 #include "AliMC.h"
56 #include "AliMagF.h"
57 #include "AliVZEROLoader.h"
58 #include "AliVZEROdigit.h"
59 #include "AliVZEROhit.h"
60 #include "AliVZEROv7.h"
61 #include "AliLog.h"
62 #include "AliTrackReference.h"
63  
64 ClassImp(AliVZEROv7)
65
66 //_____________________________________________________________________________
67 AliVZEROv7:: AliVZEROv7():AliVZERO(),
68    fCellId(0),
69    fTrackPosition(),
70    fTrackMomentum(), 
71    fV0CHeight1(2.5), 
72    fV0CHeight2(4.4), 
73    fV0CHeight3(7.4), 
74    fV0CHeight4(12.5),
75    fV0CRMin(4.6), 
76    fV0CRBox(38.0),
77    fV0CLidThickness(0.30),
78    fV0CCellThickness(2.00),
79    fV0CBoxThickness(4.70),
80    fV0COffsetFibers(1.125),
81    fV0CLightYield(93.75),
82    fV0CLightAttenuation(0.05),
83    fV0CnMeters(15.0),
84    fV0CFibToPhot(0.3),
85    fV0AR0(4.2),
86    fV0AR1(7.6), 
87    fV0AR2(13.8), 
88    fV0AR3(22.7),
89    fV0AR4(41.3), 
90    fV0AR5(43.3), 
91    fV0AR6(72.6),
92    fV0AR7(92.0), // Distance from origin to outtermost intersection sector7 and sector8 
93    fV0ASciWd(2.5), 
94    fV0APlaWd(0.5), 
95    fV0APlaAl(0.06), 
96    fV0AOctWd(0.75), 
97    fV0AFraWd(0.2),
98    fV0AOctH1(1.0), 
99    fV0AOctH2(2.0), 
100    fV0ABasHt(2.0),
101    fV0AFibRd(0.1),
102    fV0APlaEx(4.4),
103    fV0APMBWd(24.6), 
104    fV0APMBHt(22.0), 
105    fV0APMBTh(7.1), 
106    fV0APMBWdW(0.3), 
107    fV0APMBHtW(1.0),
108    fV0APMBAng(30.0), 
109    fV0APMBThW(0.3), 
110    fV0APMTR1(2.44), 
111    fV0APMTR2(2.54), 
112    fV0APMTR3(2.54),
113    fV0APMTR4(2.70), 
114    fV0APMTH(10.0), 
115    fV0APMTB(1.0),
116    fV0AFEEBWd(26.5),
117    fV0AFEEBHt(20.5),
118    fV0AFEEBTh(7.5),
119    fV0AnMeters(fV0AR6*0.01),
120    fV0ALightYield(93.75),
121    fV0ALightAttenuation(0.05), 
122    fV0AFibToPhot(0.3),
123    fVersion(7)
124 {
125 // Standard default constructor 
126 }
127
128 //_____________________________________________________________________________
129 AliVZEROv7::AliVZEROv7(const char *name, const char *title):AliVZERO(name,title),
130    fCellId(0),
131    fTrackPosition(),
132    fTrackMomentum(), 
133    fV0CHeight1(2.5), 
134    fV0CHeight2(4.4), 
135    fV0CHeight3(7.4), 
136    fV0CHeight4(12.5),
137    fV0CRMin(4.6), 
138    fV0CRBox(38.0),
139    fV0CLidThickness(0.30),
140    fV0CCellThickness(2.00),
141    fV0CBoxThickness(4.70),
142    fV0COffsetFibers(1.125),
143    fV0CLightYield(93.75),
144    fV0CLightAttenuation(0.05),
145    fV0CnMeters(15.0),
146    fV0CFibToPhot(0.3),
147    fV0AR0(4.2),    
148    fV0AR1(7.6), 
149    fV0AR2(13.8), 
150    fV0AR3(22.7),
151    fV0AR4(41.3), 
152    fV0AR5(43.3), 
153    fV0AR6(72.6),
154    fV0AR7(92.0), // Distance from origin to outtermost intersection of sector7 and sector8 
155    fV0ASciWd(2.5), 
156    fV0APlaWd(0.5), 
157    fV0APlaAl(0.06), 
158    fV0AOctWd(0.75), 
159    fV0AFraWd(0.2),
160    fV0AOctH1(1.0), 
161    fV0AOctH2(2.0), 
162    fV0ABasHt(2.0),
163    fV0AFibRd(0.1),
164    fV0APlaEx(4.4),
165    fV0APMBWd(24.6), 
166    fV0APMBHt(22.0), 
167    fV0APMBTh(7.1), 
168    fV0APMBWdW(0.3), 
169    fV0APMBHtW(1.0),
170    fV0APMBAng(30.0), 
171    fV0APMBThW(0.3), 
172    fV0APMTR1(2.44), 
173    fV0APMTR2(2.54), 
174    fV0APMTR3(2.54),
175    fV0APMTR4(2.70), 
176    fV0APMTH(10.0), 
177    fV0APMTB(1.0),
178    fV0AFEEBWd(26.5),
179    fV0AFEEBHt(20.5),
180    fV0AFEEBTh(7.5),                
181    fV0AnMeters(fV0AR6*0.01),
182    fV0ALightYield(93.75),
183    fV0ALightAttenuation(0.05),
184    fV0AFibToPhot(0.3),
185    fVersion(7)
186
187
188 {
189 // Standard constructor for V-zero Detector  version 7
190
191   AliDebug(2,"Create VZERO object ");
192
193 //  fVersion            =     7;  // version number
194
195 //   // V0C Parameters related to geometry: All in cm
196 //   fV0CHeight1         =    2.5; // height of cell 1
197 //   fV0CHeight2         =    4.4; // height of cell 2
198 //   fV0CHeight3         =    7.4; // height of cell 3
199 //   fV0CHeight4         =   12.5; // height of cell 4
200 //   fV0CRMin            =    4.6; // inner radius of box
201 //   fV0CRBox            =   38.0; // outer radius of box
202 //   fV0CLidThickness    =   0.30; // thickness of Carbon lid
203 //   fV0CCellThickness   =   2.00; // thickness of elementary cell
204 //   fV0CBoxThickness    =   4.70; // thickness of V0C Box
205 //   fV0COffsetFibers    =    1.0; // offset to output fibers
206 //   // V0C Parameters related to light output
207 //   fV0CLightYield         =  93.75; // Light yield in BC408 (93.75 eV per photon)
208 //   fV0CLightAttenuation   =   0.05; // Light attenuation in fiber (0.05 per meter)
209 //   fV0CnMeters            =   15.0; // Number of meters of clear fibers to PM
210 //   fV0CFibToPhot          =    0.3; // Attenuation at fiber-photocathode interface
211 // 
212 //   // V0A Parameters related to geometry: All in cm
213 //   fV0AR0     =  4.2;  // Radius of hole
214 //   fV0AR1     =  7.6;  // Maximun radius of 1st cell
215 //   fV0AR2     = 13.8; // Maximun radius of 2nd cell
216 //   fV0AR3     = 22.7; // Maximun radius of 3rd cell
217 //   fV0AR4     = 41.3; // Maximun radius of 4th cell
218 //   fV0AR5     = 43.3; // Radius circunscrite to innermost octagon
219 //   fV0AR6     = 68.0; // Radius circunscrite to outtermost octagon
220 //   fV0ASciWd  =  2.5;  // Scintillator thickness 
221 //   fV0APlaWd  =  0.5;  // Plates thinckness
222 //   fV0APlaAl  = 0.06; // Plates AlMg3 thinckness
223 //   fV0AOctWd  = 0.75; // Innermost octagon thickness
224 //   fV0AOctH1  =  1.0;  // Height of innermost octagon
225 //   fV0AOctH2  =  2.0;  // Height of outtermost octagon
226 //   fV0AFibRd  =  0.1;  // Radius of Fiber
227 //   fV0AFraWd  =  0.2;  // Support Frame thickness
228 //   fV0APMBWd  = 24.6;  // Width of PM Box
229 //   fV0APMBHt  = 22.0;  // Height of PM Box
230 //   fV0APMBTh  =  7.1;  // Thickness of PM Box
231 //   fV0APMBWdW =  0.3;  // Thickness of PM Box Side1 Wall
232 //   fV0APMBHtW =  1.0;  // Thickness of PM Box Side2 Wall
233 //   fV0APMBThW =  0.3;  // Thickness of PM Box Top Wall
234 //   fV0APMBAng = 30.0;  // Angle between PM Box and Support
235 //   fV0APMTR1  = 2.44;  // PMT Glass
236 //   fV0APMTR2  = 2.54;  // PMT Glass
237 //   fV0APMTR3  = 2.54;  // PMT Cover
238 //   fV0APMTR4  = 2.70;  // PMT Cover
239 //   fV0APMTH   = 10.0;  // PMT Height
240 //   fV0APMTB   =  1.0;  // PMT Basis
241 //   fV0APlaEx  =  4.4;  // Plates Extension height
242 //   fV0ABasHt  =  2.0;  // Basis Height
243 //   // V0A Parameters related to light output
244 //   fV0ALightYield         =  93.75;      // Light yield in BC404
245 //   fV0ALightAttenuation   =   0.05;      // Light attenuation in WLS fiber, per meter
246 //   fV0AnMeters            = fV0AR6*0.01; // Tentative value, in meters
247 //   fV0AFibToPhot          =    0.3;      // Attenuation at fiber-photocathode interface
248 }
249
250 //_____________________________________________________________________________
251 void AliVZEROv7::CreateGeometry()
252 {
253 // Constructs TGeo geometry 
254
255   AliDebug(2,"VZERO ConstructGeometry");
256   TGeoVolume *top = gGeoManager->GetVolume("ALIC");
257
258   ///////////////////////////////////////////////////////////////////////////
259   // Construct the geometry of V0C Detector. Brigitte CHEYNIS
260   
261     const int kColorVZERO  = kGreen;
262     TGeoMedium *medV0CAlu = gGeoManager->GetMedium("VZERO_V0CAlu");
263     TGeoMedium *medV0CCar = gGeoManager->GetMedium("VZERO_V0CCar");
264     TGeoMedium *medV0CSci = gGeoManager->GetMedium("VZERO_V0CSci");
265     TGeoVolume *v0RI = new TGeoVolumeAssembly("V0RI");
266     Float_t heightRight, r4Right;
267     Float_t zdet = 90.0 - 0.5 - fV0CBoxThickness/2.0;
268     heightRight  = fV0CHeight1 + fV0CHeight2 + fV0CHeight3 + fV0CHeight4;
269     r4Right      = fV0CRMin + heightRight + 3.0*0.2; // 3 spacings of 2mm between rings
270
271     // Creation of  carbon lids (3.0 mm thick) to keep V0C box shut :
272     Float_t   partube[3];
273     partube[0] =   fV0CRMin;
274     partube[1] =   fV0CRBox;
275     partube[2] =   fV0CLidThickness/2.0;
276     //    TGeoTube   *sV0CA = new TGeoTube("V0CA", partube[0], partube[1], partube[2]);
277     //    TGeoVolume *v0CA  = new TGeoVolume("V0CA",sV0CA,medV0CCar);
278     //    TGeoTranslation *tr2 = new TGeoTranslation(0.,0., fV0CBoxThickness/2.0-partube[2]);
279     //    TGeoTranslation *tr3 = new TGeoTranslation(0.,0.,-fV0CBoxThickness/2.0+partube[2]);
280     //    v0RI->AddNode(v0CA,1,tr2);
281     //    v0RI->AddNode(v0CA,2,tr3);
282     //    v0CA->SetLineColor(kYellow);
283
284     Float_t rInt1 = 11.5, rOut1 = 20.0, rInt2 = 9.0;
285
286     TGeoTube   *sV0CA4 = new TGeoTube("V0CA4", partube[0], rInt2, partube[2] - 0.1);
287     TGeoVolume *v0CA4  = new TGeoVolume("V0CA4",sV0CA4,medV0CCar);
288     TGeoTranslation *tr21 = new TGeoTranslation(0.,0., fV0CBoxThickness/2.0-partube[2] + 0.1);
289     v0RI->AddNode(v0CA4,1,tr21);
290     v0CA4->SetLineColor(kYellow);
291
292     TGeoTube   *sV0CA5 = new TGeoTube("V0CA5", rInt2, partube[1], partube[2]);
293     TGeoVolume *v0CA5  = new TGeoVolume("V0CA5",sV0CA5,medV0CCar);
294     TGeoTranslation *tr22 = new TGeoTranslation(0.,0., fV0CBoxThickness/2.0-partube[2]);
295     v0RI->AddNode(v0CA5,1,tr22);
296     v0CA5->SetLineColor(kYellow);
297
298     TGeoTube   *sV0CA1 = new TGeoTube("V0CA1",partube[0], rInt1, partube[2]);
299     TGeoVolume *v0CA1  = new TGeoVolume("V0CA1",sV0CA1,medV0CCar);
300     TGeoTranslation *tr31 = new TGeoTranslation(0.,0.,-fV0CBoxThickness/2.0+partube[2]);
301     v0RI->AddNode(v0CA1,1,tr31);
302     v0CA1->SetLineColor(kYellow);
303
304     TGeoTube   *sV0CA2 = new TGeoTube("V0CA2", rInt1, rOut1, partube[2] - 0.1);
305     TGeoVolume *v0CA2  = new TGeoVolume("V0CA2",sV0CA2,medV0CCar);
306     TGeoTranslation *tr32 = new TGeoTranslation(0.,0.,-fV0CBoxThickness/2.0+partube[2] - 0.1);
307     v0RI->AddNode(v0CA2,1,tr32);
308     v0CA2->SetLineColor(kYellow);
309
310     TGeoTube   *sV0CA3 = new TGeoTube("V0CA3", rOut1, partube[1], partube[2]);
311     TGeoVolume *v0CA3  = new TGeoVolume("V0CA3",sV0CA3,medV0CCar);
312     TGeoTranslation *tr33 = new TGeoTranslation(0.,0.,-fV0CBoxThickness/2.0+partube[2]);
313     v0RI->AddNode(v0CA3,1,tr33);
314     v0CA3->SetLineColor(kYellow);
315
316     // Creation of aluminum rings 3.0 mm thick to maintain the v0RI pieces : 
317     partube[0] =   fV0CRMin - 0.3;
318     partube[1] =   fV0CRMin;
319     partube[2] =   fV0CBoxThickness/2.0;
320     TGeoTube   *sV0IR = new TGeoTube("V0IR", partube[0], partube[1], partube[2]);
321     TGeoVolume *v0IR  = new TGeoVolume("V0IR",sV0IR,medV0CAlu);
322     v0RI->AddNode(v0IR,1,0);
323     v0IR->SetLineColor(kYellow);
324     partube[0] =   fV0CRBox;
325     partube[1] =   fV0CRBox + 0.3; 
326     partube[2] =   fV0CBoxThickness/2.0;
327     TGeoTube   *sV0ER = new TGeoTube("V0ER", partube[0], partube[1], partube[2]);
328     TGeoVolume *v0ER  = new TGeoVolume("V0ER",sV0ER,medV0CAlu);
329     v0RI->AddNode(v0ER,1,0);
330     v0ER->SetLineColor(kYellow);
331
332     // Creation of assembly V0R0 of scintillator cells within one sector
333     TGeoVolume *v0R0 = new TGeoVolumeAssembly("V0R0");                                            
334
335     // Elementary cell of ring 1  - right part - :
336     // (cells of ring 1 will be shifted by 2.0 cm backwards to output fibers)
337     Float_t   r1Right =  fV0CRMin + fV0CHeight1;
338     Float_t   offset  = fV0CBoxThickness/2.0 - fV0CLidThickness - fV0CCellThickness/2.0;   
339     Float_t   partubs[5];   
340     partubs[0]     =  fV0CRMin;
341     partubs[1]     =  r1Right;
342     partubs[2]     =  fV0CCellThickness/2.0;
343     partubs[3]     =  90.0-22.5;
344     partubs[4]     = 135.0-22.5;
345     TGeoTubeSeg *sV0R1 = new TGeoTubeSeg("V0R1", partubs[0], partubs[1], partubs[2],
346                                          partubs[3], partubs[4]);
347     TGeoVolume  *v0R1  = new TGeoVolume("V0R1",sV0R1,medV0CSci);                                       
348     TGeoTranslation *tr4 = new TGeoTranslation(0.,0., offset);
349     v0R0->AddNode(v0R1,1,tr4);
350     v0R1->SetLineColor(kColorVZERO);
351
352     // Elementary cell of ring 2 - right part - :
353     // (cells of ring 2 will be shifted by 1.0 cm backwards to output fibers)
354     Float_t   r2Right  =  r1Right + fV0CHeight2;  
355     partubs[0]     =  r1Right;  //  must be equal to 7.1
356     partubs[1]     =  r2Right;  //  must be equal to 11.5
357     TGeoTubeSeg *sV0R2 = new TGeoTubeSeg("V0R2", partubs[0], partubs[1], partubs[2],
358                                          partubs[3], partubs[4]);
359     TGeoVolume  *v0R2  = new TGeoVolume("V0R2",sV0R2,medV0CSci);
360     TGeoTranslation *tr5 = new TGeoTranslation(0.0,0.2, offset - fV0COffsetFibers);
361     v0R0->AddNode(v0R2,1,tr5);
362     v0R2->SetLineColor(kColorVZERO);
363
364     // Ring 3 - right part -  :
365     r2Right  =  r2Right + 0.2;
366     Float_t   r3Right  =  r2Right + fV0CHeight3;     
367     partubs[0]     =  r2Right;  //  must be equal to 11.7
368     partubs[1]     =  r3Right;  //  must be equal to 19.1
369     partubs[3]     =  90.0-22.5;
370     partubs[4]     = 112.5-22.5;
371     TGeoTubeSeg *sV0R3 = new TGeoTubeSeg("V0R3", partubs[0], partubs[1], partubs[2],
372                                          partubs[3], partubs[4]);
373     TGeoVolume  *v0R3  = new TGeoVolume("V0R3",sV0R3,medV0CSci);
374     TGeoTranslation *tr6 = new TGeoTranslation(0.,0.2, offset - 2.0*fV0COffsetFibers);
375     v0R0->AddNode(v0R3,1,tr6);
376     v0R3->SetLineColor(kColorVZERO);
377     partubs[3]     = 112.5-22.5;
378     partubs[4]     = 135.0-22.5;
379     TGeoTubeSeg *sV0R4 = new TGeoTubeSeg("V0R4", partubs[0], partubs[1], partubs[2],
380                                          partubs[3], partubs[4]);
381     TGeoVolume  *v0R4  = new TGeoVolume("V0R4",sV0R4,medV0CSci);
382     v0R0->AddNode(v0R4,1,tr6);
383     v0R4->SetLineColor(kColorVZERO);
384   
385     // Ring 4 - right part -  : 
386     Float_t x = TMath::ATan(3.5/257.5) * ((180./TMath::Pi()));
387     r3Right = r3Right + 0.2 + 0.2;   // + 0.2 because no shift in translation here !!
388     partubs[0]     =  r3Right;  //  must be equal to 19.5
389     partubs[1]     =  r4Right;  //  must be equal to 32.0
390     partubs[3]     =  90.0-22.5+x;
391     partubs[4]     = 112.5-22.5-x;
392     TGeoTubeSeg *sV0R5 = new TGeoTubeSeg("V0R5", partubs[0], partubs[1], partubs[2],
393                                          partubs[3], partubs[4]);
394     TGeoVolume  *v0R5  = new TGeoVolume("V0R5",sV0R5,medV0CSci);
395     TGeoTranslation *tr7 = new TGeoTranslation(0.,0.0, offset - 2.0*fV0COffsetFibers + 0.25);                                         
396     v0R0->AddNode(v0R5,1,tr7);
397     v0R5->SetLineColor(kColorVZERO);
398     partubs[3]     = 112.5-22.5+x;
399     partubs[4]     = 135.0-22.5-x;
400     TGeoTubeSeg *sV0R6 = new TGeoTubeSeg("V0R6", partubs[0], partubs[1], partubs[2],
401                                          partubs[3], partubs[4]);
402     TGeoVolume  *v0R6  = new TGeoVolume("V0R6",sV0R6,medV0CSci);
403     v0R0->AddNode(v0R6,1,tr7);
404     v0R6->SetLineColor(kColorVZERO);
405     Float_t  phi;
406     Float_t  phiDeg= 180./4.;
407     Int_t    nsecR = 1;     // number of sectors in right part of V0
408     for (phi = 22.5; phi < 360.0; phi = phi + phiDeg) {
409       TGeoRotation  *rot1 = new TGeoRotation("rot1", 90.0, +phi, 90., 90.+phi, 0.0, 0.0 ); 
410       v0RI->AddNode(v0R0,nsecR,rot1);    
411       nsecR++;        
412     }
413
414   ///////////////////////////////////////////////////////////////////////////
415   // Construct the geometry of V0A Detector. Carlos PEREZ, PUCP
416   // Revision by Lizardo VALENCIA, UNAM Mexico in July 2008
417
418     const int kV0AColorSci   = 5;
419     const int kV0AColorPlaIn = 3;
420     const int kV0AColorPlaOu = 41;
421     const int kV0AColorOct   = 7;
422     const int kV0AColorFra   = 6;
423     const int kV0AColorFib   = 11;
424     const int kV0AColorPMG   = 1;
425     const int kV0AColorPMA   = 2;
426     const int kV0AColorFibGlass = 4; 
427     TGeoMedium *medV0ASci = gGeoManager->GetMedium("VZERO_V0ASci");
428     TGeoMedium *medV0APlaIn = gGeoManager->GetMedium("VZERO_V0APlaIn");
429     TGeoMedium *medV0APlaOu = gGeoManager->GetMedium("VZERO_V0APlaOu");
430     TGeoMedium *medV0ASup = gGeoManager->GetMedium("VZERO_V0APMA");
431     TGeoMedium *medV0AFra = gGeoManager->GetMedium("VZERO_V0ALuc");
432     TGeoMedium *medV0AFib = gGeoManager->GetMedium("VZERO_V0AFib");
433     TGeoMedium *medV0APMGlass = gGeoManager->GetMedium("VZERO_V0APMG");
434     TGeoMedium *medV0APMAlum = gGeoManager->GetMedium("VZERO_V0APMA");
435     TGeoMedium *medV0AFibGlass = gGeoManager->GetMedium("VZERO_V0AFibGlass");
436     double pi = TMath::Pi();
437     double sin225   = TMath::Sin(pi/8.);
438     double cos225   = TMath::Cos(pi/8.);
439     double sin45    = TMath::Sin(pi/4.); // lucky: Sin45=Cos45
440     double cos45    = TMath::Cos(pi/4.); 
441     double v0APts[16];
442     double sin654   = TMath::Sin(1.14);
443     double cos654   = TMath::Cos(1.14);
444     
445     //Defining the master volume for V0A
446     TGeoVolume *v0LE = new TGeoVolumeAssembly("V0LE");
447
448     /// Definition sector 1
449     TGeoVolume *v0ASec1 = new TGeoVolumeAssembly("V0ASec1");
450         
451     /// For boolean sustraction
452     double preShapeSec1 = 0.2;
453     for (int i=0;i<2;i++) {
454       v0APts[0+8*i] = fV0AR0-fV0AFraWd/2.-preShapeSec1;  v0APts[1+8*i] = -preShapeSec1;
455       v0APts[2+8*i] = fV0AR0-fV0AFraWd/2.-preShapeSec1;  v0APts[3+8*i] = fV0AFraWd/2.;
456       v0APts[4+8*i] = fV0AR4+fV0AFraWd/2.+preShapeSec1;  v0APts[5+8*i] = fV0AFraWd/2.;
457       v0APts[6+8*i] = fV0AR4+fV0AFraWd/2.+preShapeSec1;  v0APts[7+8*i] = -preShapeSec1;
458     }
459     new TGeoArb8("sV0ACha1Sec1",fV0ASciWd/1.5,v0APts);
460     for (int i=0;i<2;i++) {
461       v0APts[0+8*i] = fV0AR0*sin45-preShapeSec1;
462       v0APts[1+8*i] = (fV0AR0-fV0AFraWd)*sin45-preShapeSec1;
463       v0APts[2+8*i] = (fV0AR0-fV0AFraWd/2.)*sin45-preShapeSec1;
464       v0APts[3+8*i] = (fV0AR0-fV0AFraWd/2.)*sin45;
465       v0APts[4+8*i] = (fV0AR4+fV0AFraWd/2.)*sin45+preShapeSec1;
466       v0APts[5+8*i] = (fV0AR4+fV0AFraWd/2.)*sin45+2.*preShapeSec1;
467       v0APts[6+8*i] = (fV0AR4+fV0AFraWd)*sin45+preShapeSec1;
468       v0APts[7+8*i] = fV0AR4*sin45+preShapeSec1;
469     }
470     new TGeoArb8("sV0ACha2Sec1", fV0ASciWd/2.+2.*preShapeSec1, v0APts);
471     new TGeoCompositeShape("sV0ACha12Sec1","sV0ACha1Sec1+sV0ACha2Sec1");
472     new TGeoTube("sV0ANail1SciHoleSec1", 0.0, 0.4, 1.65);
473     TGeoTranslation *pos1Sec1 = new TGeoTranslation("pos1Sec1", 42.9, 0.51, 0.0);
474     pos1Sec1->RegisterYourself();
475     new TGeoTube("sV0ANail2SciHoleSec1", 0.0, 0.4, 1.65);
476     TGeoTranslation *pos2Sec1 = new TGeoTranslation("pos2Sec1", 30.73,29.98,0.0);
477     pos2Sec1->RegisterYourself();
478     new TGeoCompositeShape("sV0ANailsSciHolesSec1","sV0ANail1SciHoleSec1:pos1Sec1+sV0ANail2SciHoleSec1:pos2Sec1");
479     new TGeoCompositeShape("sV0AChaSec1","sV0ACha12Sec1+sV0ANailsSciHolesSec1");
480     new TGeoTubeSeg("sV0AFicR5Sec1", fV0AR4+fV0AFraWd/2., fV0AR4 + fV0AR0, fV0ASciWd/2.+2*preShapeSec1, 0, 45);
481     new TGeoBBox("sV0AFicFEEBSec1", fV0AFEEBWd/2., fV0AFEEBHt/2., fV0AFEEBTh/2.);
482     TGeoRotation *rot = new TGeoRotation("rot");
483     rot->RotateX(90);
484     rot->RotateZ(-90.0);
485     double aFEEshiftR2Sec1 = fV0AR6  +  fV0AOctH2 + fV0APlaAl;
486     TGeoCombiTrans *posFicFEEBSec1 = new TGeoCombiTrans("posFicFEEBSec1", aFEEshiftR2Sec1*cos225 + 2.0, 0, 7.5, rot);
487     posFicFEEBSec1->RegisterYourself();
488     rot = new TGeoRotation("rot");
489     rot->RotateX(90);
490     rot->RotateZ(-90.0+45.0);
491     TGeoCombiTrans *posFicFEEBUpSec1 = new TGeoCombiTrans("posFicFEEBUpSec1", (aFEEshiftR2Sec1*cos225 + 2.0 )*cos45, (aFEEshiftR2Sec1*cos225 + 2.0 )*sin45, 7.5, rot);
492     posFicFEEBUpSec1->RegisterYourself();
493     for (int i=0;i<2;i++) {
494     v0APts[0+8*i] = fV0AOctH2/2.;              v0APts[1+8*i] = fV0AFEEBHt/2. + 2.5;
495     v0APts[2+8*i] = fV0AOctH2/2.;              v0APts[3+8*i] = -fV0AFEEBHt/2.- 2.5;
496     v0APts[4+8*i] = -fV0AOctH2/2.;             v0APts[5+8*i] = -fV0AFEEBHt/2.- 2.5;
497     v0APts[6+8*i] = -fV0AOctH2/2.;             v0APts[7+8*i] = fV0AFEEBHt/2.+ 2.5;
498     }
499     new TGeoArb8("sV0AFicOct2Sec1", (fV0ASciWd+2*fV0AOctWd)/2., v0APts);
500     TGeoTranslation *posFicOct2Sec1 = new TGeoTranslation("posFicOct2Sec1",(aFEEshiftR2Sec1*cos225 + 2.0) - fV0AFEEBTh/2. - 1.0,0.0,0.0);
501     posFicOct2Sec1->RegisterYourself();  
502     rot = new TGeoRotation("rot");
503     rot->RotateZ(-90.0+45.0+90.0);
504     TGeoCombiTrans *posFicOct2UpSec1 = new TGeoCombiTrans("posFicOct2UpSec1",((aFEEshiftR2Sec1*cos225 + 2.0) - fV0AFEEBTh/2. - 1.0)*cos45,((aFEEshiftR2Sec1*cos225 + 2.0) - fV0AFEEBTh/2. - 1.0)*sin45,0.0,rot);
505     posFicOct2UpSec1->RegisterYourself(); 
506
507     /// Frame
508     TGeoVolume *v0AFraSec1 = new TGeoVolumeAssembly("V0AFraSec1");
509     for (int i=0;i<2;i++) {
510       v0APts[0+8*i] = fV0AR0-fV0AFraWd/2.;  v0APts[1+8*i] = 0.;
511       v0APts[2+8*i] = fV0AR0-fV0AFraWd/2.;  v0APts[3+8*i] = fV0AFraWd/2.;
512       v0APts[4+8*i] = fV0AR4+fV0AFraWd/2.;  v0APts[5+8*i] = fV0AFraWd/2.;
513       v0APts[6+8*i] = fV0AR4+fV0AFraWd/2.;  v0APts[7+8*i] = 0.;
514     }
515     TGeoArb8 *sV0AFraB1Sec1 = new TGeoArb8("sV0AFraB1Sec1",fV0ASciWd/2.,v0APts);
516     TGeoVolume *v0AFraB1Sec1 = new TGeoVolume("V0AFraB1Sec1",sV0AFraB1Sec1,medV0AFra);
517     for (int i=0;i<2;i++) {
518       v0APts[0+8*i] = fV0AR0*sin45;
519       v0APts[1+8*i] = (fV0AR0-fV0AFraWd)*sin45;
520       v0APts[2+8*i] = (fV0AR0-fV0AFraWd/2.)*sin45;
521       v0APts[3+8*i] = (fV0AR0-fV0AFraWd/2.)*sin45;
522       v0APts[4+8*i] = (fV0AR4+fV0AFraWd/2.)*sin45;
523       v0APts[5+8*i] = (fV0AR4+fV0AFraWd/2.)*sin45;
524       v0APts[6+8*i] = (fV0AR4+fV0AFraWd)*sin45;
525       v0APts[7+8*i] = fV0AR4*sin45;
526     }
527     TGeoArb8 *sV0AFraB2Sec1 = new TGeoArb8("sV0AFraB2Sec1", fV0ASciWd/2., v0APts);
528     TGeoVolume *v0AFraB2Sec1 = new TGeoVolume("V0AFraB2Sec1",sV0AFraB2Sec1,medV0AFra);
529     v0AFraB1Sec1->SetLineColor(kV0AColorFra); v0AFraB2Sec1->SetLineColor(kV0AColorFra);
530     v0AFraSec1->AddNode(v0AFraB1Sec1,1);
531     v0AFraSec1->AddNode(v0AFraB2Sec1,1);  
532     new TGeoTubeSeg( "sV0AFraR1bSec1", fV0AR0-fV0AFraWd/2.,
533                      fV0AR0+fV0AFraWd/2., fV0ASciWd/2., 0, 45);
534     new TGeoTubeSeg( "sV0AFraR2bSec1", fV0AR1-fV0AFraWd/2.,
535                      fV0AR1+fV0AFraWd/2., fV0ASciWd/2., 0, 45);
536     new TGeoTubeSeg( "sV0AFraR3bSec1", fV0AR2-fV0AFraWd/2.,
537                      fV0AR2+fV0AFraWd/2., fV0ASciWd/2., 0, 45);
538     new TGeoTubeSeg( "sV0AFraR4bSec1", fV0AR3-fV0AFraWd/2.,
539                      fV0AR3+fV0AFraWd/2., fV0ASciWd/2., 0, 45);
540     new TGeoTubeSeg( "sV0AFraR5bSec1", fV0AR4-fV0AFraWd/2.,
541                      fV0AR4+fV0AFraWd/2., fV0ASciWd/2., 0, 45);
542     TGeoCompositeShape *sV0AFraR1Sec1 = new TGeoCompositeShape("sV0AFraR1Sec1","sV0AFraR1bSec1-sV0AChaSec1");
543     TGeoCompositeShape *sV0AFraR2Sec1 = new TGeoCompositeShape("sV0AFraR2Sec1","sV0AFraR2bSec1-sV0AChaSec1");
544     TGeoCompositeShape *sV0AFraR3Sec1 = new TGeoCompositeShape("sV0AFraR3Sec1","sV0AFraR3bSec1-sV0AChaSec1");
545     TGeoCompositeShape *sV0AFraR4Sec1 = new TGeoCompositeShape("sV0AFraR4Sec1","sV0AFraR4bSec1-sV0AChaSec1");
546     TGeoCompositeShape *sV0AFraR5Sec1 = new TGeoCompositeShape("sV0AFraR5Sec1","sV0AFraR5bSec1-sV0AChaSec1");
547     TGeoVolume *v0AFraR1Sec1 = new TGeoVolume("V0AFraR1Sec1",sV0AFraR1Sec1,medV0AFra);
548     TGeoVolume *v0AFraR2Sec1 = new TGeoVolume("V0AFraR2Sec1",sV0AFraR2Sec1,medV0AFra);
549     TGeoVolume *v0AFraR3Sec1 = new TGeoVolume("V0AFraR3Sec1",sV0AFraR3Sec1,medV0AFra);
550     TGeoVolume *v0AFraR4Sec1 = new TGeoVolume("V0AFraR4Sec1",sV0AFraR4Sec1,medV0AFra);
551     TGeoVolume *v0AFraR5Sec1 = new TGeoVolume("V0AFraR5Sec1",sV0AFraR5Sec1,medV0AFra);
552     v0AFraR1Sec1->SetLineColor(kV0AColorFra); v0AFraR2Sec1->SetLineColor(kV0AColorFra);
553     v0AFraR3Sec1->SetLineColor(kV0AColorFra); v0AFraR4Sec1->SetLineColor(kV0AColorFra);
554     v0AFraR5Sec1->SetLineColor(kV0AColorFra);
555     v0AFraSec1->AddNode(v0AFraR1Sec1,1); 
556     v0AFraSec1->AddNode(v0AFraR2Sec1,1);
557     v0AFraSec1->AddNode(v0AFraR3Sec1,1); 
558     v0AFraSec1->AddNode(v0AFraR4Sec1,1);
559     v0AFraSec1->AddNode(v0AFraR5Sec1,1);
560     v0ASec1->AddNode(v0AFraSec1,1);
561     
562     /// Sensitive scintilator
563     TGeoVolume *v0ASciSec1 = new TGeoVolumeAssembly("V0ASciSec1");
564     new TGeoTubeSeg( "sV0AR1bSec1", fV0AR0+fV0AFraWd/2.,
565                      fV0AR1-fV0AFraWd/2., fV0ASciWd/2., 0, 45);
566     new TGeoTubeSeg( "sV0AR2bSec1", fV0AR1+fV0AFraWd/2.,
567                      fV0AR2-fV0AFraWd/2., fV0ASciWd/2., 0, 45);
568     new TGeoTubeSeg( "sV0AR3bSec1", fV0AR2+fV0AFraWd/2.,
569                      fV0AR3-fV0AFraWd/2., fV0ASciWd/2., 0, 45);
570     new TGeoTubeSeg( "sV0AR4bSec1", fV0AR3+fV0AFraWd/2.,
571                      fV0AR4-fV0AFraWd/2., fV0ASciWd/2., 0, 45);
572     TGeoCompositeShape *sV0AR1Sec1 = new TGeoCompositeShape("sV0AR1Sec1","sV0AR1bSec1-sV0AChaSec1");
573     TGeoCompositeShape *sV0AR2Sec1 = new TGeoCompositeShape("sV0AR2Sec1","sV0AR2bSec1-sV0AChaSec1");
574     TGeoCompositeShape *sV0AR3Sec1 = new TGeoCompositeShape("sV0AR3Sec1","sV0AR3bSec1-sV0AChaSec1");
575     TGeoCompositeShape *sV0AR4Sec1 = new TGeoCompositeShape("sV0AR4Sec1","sV0AR4bSec1-sV0AChaSec1");
576     TGeoVolume *v0L1Sec1 = new TGeoVolume("V0L1Sec1",sV0AR1Sec1,medV0ASci);
577     TGeoVolume *v0L2Sec1 = new TGeoVolume("V0L2Sec1",sV0AR2Sec1,medV0ASci);
578     TGeoVolume *v0L3Sec1 = new TGeoVolume("V0L3Sec1",sV0AR3Sec1,medV0ASci);
579     TGeoVolume *v0L4Sec1 = new TGeoVolume("V0L4Sec1",sV0AR4Sec1,medV0ASci);
580     v0L1Sec1->SetLineColor(kV0AColorSci); v0L2Sec1->SetLineColor(kV0AColorSci);
581     v0L3Sec1->SetLineColor(kV0AColorSci); v0L4Sec1->SetLineColor(kV0AColorSci);
582     v0ASec1->AddNode(v0L1Sec1,1);
583     v0ASec1->AddNode(v0L2Sec1,1);
584     v0ASec1->AddNode(v0L3Sec1,1);
585     v0ASec1->AddNode(v0L4Sec1,1);      
586     
587     /// Segment of octagon 
588     for (int i=0;i<2;i++) {
589     v0APts[0+8*i] =  fV0AR6-fV0AOctH2;           v0APts[1+8*i] = 0.;
590       v0APts[2+8*i] = (fV0AR6-fV0AOctH2)*sin45;  v0APts[3+8*i] = (fV0AR6-fV0AOctH2)*sin45;
591       v0APts[4+8*i] = fV0AR6*sin45;              v0APts[5+8*i] = fV0AR6*sin45;
592       v0APts[6+8*i] = fV0AR6;                    v0APts[7+8*i] = 0.;
593     }
594     new TGeoArb8("sV0AOct2Sec1", (fV0ASciWd+2*fV0AOctWd)/2., v0APts);
595     TGeoCompositeShape *sV0AOct2FEEBSec1 = new TGeoCompositeShape("sV0AOct2FEEBSec1","sV0AOct2Sec1-sV0AFicFEEBSec1:posFicFEEBSec1-sV0AFicFEEBSec1:posFicFEEBUpSec1-sV0AFicOct2Sec1:posFicOct2Sec1-sV0AFicOct2Sec1:posFicOct2UpSec1");
596     TGeoVolume *v0AOct2Sec1 = new TGeoVolume("V0AOct2Sec1", sV0AOct2FEEBSec1,medV0ASup);
597     v0AOct2Sec1->SetLineColor(kV0AColorOct);
598     TGeoVolume *v0ASupSec1 = new TGeoVolumeAssembly("V0ASupSec1");
599     v0ASupSec1->AddNode(v0AOct2Sec1,1);
600     v0ASec1->AddNode(v0ASupSec1,1);
601
602     //Bunch of fibers
603     v0APts[ 0] = v0APts[ 2] = -13.0;
604     v0APts[ 1] = v0APts[ 7] = (fV0ASciWd+fV0AOctWd)/2.-0.01;
605     v0APts[ 3] = v0APts[ 5] = (fV0ASciWd+fV0AOctWd)/2.+0.01;
606     v0APts[ 4] = v0APts[ 6] = +13.0;
607     v0APts[ 8] = v0APts[10] = -10.0;
608     v0APts[ 9] = v0APts[15] = 0.;
609     v0APts[11] = v0APts[13] = 0.25;
610     v0APts[12] = v0APts[14] = +10.0;
611     new TGeoArb8("sV0AFib1Sec1", 11.5, v0APts);
612     rot = new TGeoRotation("rot");
613     rot->RotateX(-90);
614     rot->RotateZ(-90.+22.5);
615     TGeoCombiTrans *fibpos1Sec1 = new TGeoCombiTrans("fibpos1Sec1", (fV0AR6-fV0AOctH2+fV0AR5)*cos225/2. - 3.8, (fV0AR6-fV0AOctH2+fV0AR5)*sin225/2.-1.8, 0, rot);
616     fibpos1Sec1->RegisterYourself();
617     TGeoCompositeShape *sV0AFib1HoleSec1 = new TGeoCompositeShape("sV0AFib1HoleSec1","sV0AFib1Sec1:fibpos1Sec1-sV0AFicR5Sec1"); 
618     TGeoVolume *v0AFib1HoleSec1 = new TGeoVolume("V0AFib1HoleSec1",sV0AFib1HoleSec1,medV0AFib);
619     v0AFib1HoleSec1->SetLineColor(kV0AColorFib);
620     new TGeoArb8("sV0AFib2Sec1", 11.5, v0APts);
621     rot = new TGeoRotation("rot");
622     rot->RotateX(-90);
623     rot->RotateY(180);
624     rot->RotateZ(-90.+22.5);
625     TGeoCombiTrans *fibpos2Sec1 = new TGeoCombiTrans("fibpos2Sec1", (fV0AR6-fV0AOctH2+fV0AR5)*cos225/2. - 3.8, (fV0AR6-fV0AOctH2+fV0AR5)*sin225/2.-1.8, 0, rot);
626     fibpos2Sec1->RegisterYourself();
627     TGeoCompositeShape *sV0AFib2HoleSec1 = new TGeoCompositeShape("sV0AFib2HoleSec1","sV0AFib2Sec1:fibpos2Sec1-sV0AFicR5Sec1");
628     TGeoVolume *v0AFib2HoleSec1 = new TGeoVolume("V0AFib2HoleSec1",sV0AFib2HoleSec1,medV0AFib);
629     v0AFib2HoleSec1->SetLineColor(kV0AColorFib);
630     TGeoVolume *v0AFibSec1 = new TGeoVolumeAssembly("V0AFibSec1");
631     v0AFibSec1->AddNode(v0AFib1HoleSec1,1);
632     v0AFibSec1->AddNode(v0AFib2HoleSec1,1);
633     v0ASec1->AddNode(v0AFibSec1,1); 
634     
635      /// Plates
636     new TGeoTube("sV0ANail1PlaInHoleSec1", 0.0, 0.4, (fV0APlaWd-2*fV0APlaAl)/2.);
637     new TGeoTube("sV0ANail2PlaInHoleSec1", 0.0, 0.4, (fV0APlaWd-2*fV0APlaAl)/2.);
638     new TGeoCompositeShape("sV0ANailsPlaInHolesSec1","sV0ANail1PlaInHoleSec1:pos1Sec1+sV0ANail2PlaInHoleSec1:pos2Sec1");
639     new TGeoTube("sV0ANail1PlaOuHoleSec1", 0.0, 0.4, (fV0APlaAl)/2.);
640     new TGeoTube("sV0ANail2PlaOuHoleSec1", 0.0, 0.4, (fV0APlaAl)/2.);
641     new TGeoCompositeShape("sV0ANailsPlaOuHolesSec1","sV0ANail1PlaOuHoleSec1:pos1Sec1+sV0ANail2PlaOuHoleSec1:pos2Sec1");
642     for (int i=0;i<2;i++) {
643       v0APts[0+8*i] = fV0AR0;                   v0APts[1+8*i] = 0.;
644       v0APts[2+8*i] = fV0AR0*sin45;             v0APts[3+8*i] = fV0AR0*sin45;
645       v0APts[4+8*i] = fV0AR6 * sin45;   v0APts[5+8*i] = fV0AR6*sin45;
646       v0APts[6+8*i] = fV0AR6;           v0APts[7+8*i] = 0.;
647     }
648     new TGeoArb8("sV0APlaInSec1", (fV0APlaWd-2*fV0APlaAl)/2., v0APts);
649     TGeoCompositeShape *sV0APlaInNailsHolesSec1 = new TGeoCompositeShape("sV0APlaInNailsHolesSec1","sV0APlaInSec1-sV0ANailsPlaInHolesSec1-sV0AFicFEEBSec1:posFicFEEBSec1-sV0AFicFEEBSec1:posFicFEEBUpSec1");
650     TGeoVolume *v0APlaInNailsHolesSec1 = new TGeoVolume("V0APlaInNailsHolesSec1", sV0APlaInNailsHolesSec1, medV0APlaIn);
651     new TGeoArb8("sV0APlaOuSec1", fV0APlaAl/2., v0APts);
652     TGeoCompositeShape *sV0APlaOuNailsHolesSec1 = new TGeoCompositeShape("sV0APlaOuNailsHolesSec1","sV0APlaOuSec1-sV0ANailsPlaOuHolesSec1-sV0AFicFEEBSec1:posFicFEEBSec1-sV0AFicFEEBSec1:posFicFEEBUpSec1"); 
653     TGeoVolume *v0APlaOuNailsHolesSec1 = new TGeoVolume("V0APlaOuNailsHolesSec1", sV0APlaOuNailsHolesSec1, medV0APlaOu);
654     v0APlaInNailsHolesSec1->SetLineColor(kV0AColorPlaIn); v0APlaOuNailsHolesSec1->SetLineColor(kV0AColorPlaOu);
655     TGeoVolume *v0APlaSec1 = new TGeoVolumeAssembly("V0APlaSec1");
656     v0APlaSec1->AddNode(v0APlaInNailsHolesSec1,1);
657     v0APlaSec1->AddNode(v0APlaOuNailsHolesSec1,1,new TGeoTranslation(0,0,(fV0APlaWd-fV0APlaAl)/2.));
658     v0APlaSec1->AddNode(v0APlaOuNailsHolesSec1,2,new TGeoTranslation(0,0,-(fV0APlaWd-fV0APlaAl)/2.));
659     v0ASec1->AddNode(v0APlaSec1,1,new TGeoTranslation(0,0,(fV0ASciWd+2*fV0AOctWd+fV0APlaWd)/2.));
660     v0ASec1->AddNode(v0APlaSec1,2,new TGeoTranslation(0,0,-(fV0ASciWd+2*fV0AOctWd+fV0APlaWd)/2.));
661     
662      /// Non-sensitive scintilator
663     new TGeoTubeSeg("sV0AR5S2Sec1", fV0AR4+fV0AFraWd/2., fV0AR4 + fV0AR0, fV0ASciWd/2.+2*preShapeSec1, 0, 45);
664     TGeoCompositeShape *sV0AR5Sec1 = new TGeoCompositeShape("V0AR5Sec1","sV0AR5S2Sec1 - sV0AChaSec1");
665     TGeoVolume *v0AR5Sec1 = new TGeoVolume("V0AR5Sec1",sV0AR5Sec1,medV0ASci);
666     v0AR5Sec1->SetLineColor(kV0AColorSci);
667     v0ASciSec1->AddNode(v0AR5Sec1,1);
668     v0ASec1->AddNode(v0ASciSec1,1); 
669
670     /// PMBox
671     TGeoVolume* v0APMSec1 = new TGeoVolumeAssembly("V0APMSec1");
672     new TGeoBBox("sV0APMB1Sec1", fV0APMBWd/2., fV0APMBHt/2., fV0APMBTh/2.);
673     new TGeoBBox("sV0APMB2Sec1", fV0APMBWd/2.-fV0APMBWdW, fV0APMBHt/2.-fV0APMBHtW, fV0APMBTh/2.-fV0APMBThW);
674     TGeoCompositeShape *sV0APMBSec1 = new TGeoCompositeShape("sV0APMBSec1","sV0APMB1Sec1-sV0APMB2Sec1");
675     TGeoVolume *v0APMBSec1 = new TGeoVolume("V0APMBSec1",sV0APMBSec1, medV0APMAlum);
676     v0APMBSec1->SetLineColor(kV0AColorPMA);
677     v0APMSec1->AddNode(v0APMBSec1,1);
678
679     /// PMTubes
680     TGeoTube *sV0APMT1Sec1 = new TGeoTube("sV0APMT1Sec1", fV0APMTR1, fV0APMTR2, fV0APMTH/2.);
681     TGeoVolume *v0APMT1Sec1 = new TGeoVolume("V0APMT1Sec1", sV0APMT1Sec1, medV0APMGlass);
682     TGeoTube *sV0APMT2Sec1 = new TGeoTube("sV0APMT2Sec1", fV0APMTR3, fV0APMTR4, fV0APMTH/2.);
683     TGeoVolume *v0APMT2Sec1 = new TGeoVolume("V0APMT2Sec1", sV0APMT2Sec1, medV0APMAlum);
684     TGeoVolume *v0APMTSec1 = new TGeoVolumeAssembly("V0APMTSec1");
685     TGeoTube *sV0APMTTSec1 = new TGeoTube("sV0APMTTSec1", 0., fV0APMTR4, fV0APMTB/2.);
686     TGeoVolume *v0APMTTSec1 = new TGeoVolume("V0APMTTSec1", sV0APMTTSec1, medV0APMAlum);
687     v0APMT1Sec1->SetLineColor(kV0AColorPMG);
688     v0APMT2Sec1->SetLineColor(kV0AColorPMA);
689     v0APMTTSec1->SetLineColor(kV0AColorPMA);
690     rot = new TGeoRotation("rot", 90, 0, 180, 0, 90, 90);
691     v0APMTSec1->AddNode(v0APMT1Sec1,1,rot);
692     v0APMTSec1->AddNode(v0APMT2Sec1,1,rot);
693     v0APMTSec1->AddNode(v0APMTTSec1,1,new TGeoCombiTrans(0,-(fV0APMTH+fV0APMTB)/2.,0,rot));
694     double autoShiftSec1 = (fV0APMBWd-2*fV0APMBWdW)/4.;
695     v0APMSec1->AddNode(v0APMTSec1, 1, new TGeoTranslation(-1.5*autoShiftSec1, 0, 0));
696     v0APMSec1->AddNode(v0APMTSec1, 2, new TGeoTranslation(-0.5*autoShiftSec1, 0, 0));
697     v0APMSec1->AddNode(v0APMTSec1, 3, new TGeoTranslation(+0.5*autoShiftSec1, 0, 0));
698     v0APMSec1->AddNode(v0APMTSec1, 4, new TGeoTranslation(+1.5*autoShiftSec1, 0, 0));
699
700     // PM
701     rot = new TGeoRotation("rot");
702     rot->RotateX(90-fV0APMBAng);
703     rot->RotateZ(-90.+22.5);
704     double cosAngPMBSec1 = TMath::Cos(fV0APMBAng*TMath::DegToRad());
705     double sinAngPMBSec1 = TMath::Sin(fV0APMBAng*TMath::DegToRad());
706     double shiftZSec1 = fV0APMBHt/2. * cosAngPMBSec1
707       -   ( fV0ASciWd + 2 * fV0AOctWd + 2 * fV0APlaWd )/2.   -   fV0APMBTh/2. * sinAngPMBSec1;
708     double shiftRSec1 = fV0AR6  +  fV0AOctH2 + fV0APlaAl;
709     v0ASec1->AddNode(v0APMSec1,1, new TGeoCombiTrans( shiftRSec1*cos225+1.07, shiftRSec1*sin225, shiftZSec1, rot));
710     
711     // Aluminium nails 
712     TGeoTube *sV0ANail1Sec1 = new TGeoTube("sV0ANail1Sec1", 0.0, 0.4, 5.09/2.);
713     TGeoVolume *v0ANail1Sec1 = new TGeoVolume("V0ANail1Sec1", sV0ANail1Sec1, medV0APMAlum);
714     v0ANail1Sec1->SetLineColor(kV0AColorPMA);// this is the color for aluminium
715     v0ASec1->AddNode(v0ANail1Sec1,1,new TGeoTranslation(42.9, 0.51, 0.0));
716     TGeoTube *sV0ANail2Sec1 = new TGeoTube("sV0ANail2Sec1", 0.0, 0.4, 5.09/2.);
717     TGeoVolume *v0ANail2Sec1 = new TGeoVolume("V0ANail2Sec1", sV0ANail2Sec1, medV0APMAlum);
718     v0ANail2Sec1->SetLineColor(kV0AColorPMA);
719     v0ASec1->AddNode(v0ANail2Sec1,1,new TGeoTranslation(30.73,29.98,0.0)); 
720         
721     /// Adding sector to v0LE volume
722     for(int i=0; i<1; i++) {
723        TGeoRotation *rotation = new TGeoRotation("rotation", 90., i*45., 90., 90.+i*45., 0., 0.);
724        v0LE->AddNode(v0ASec1,i+1,rotation);  
725     }
726
727     //Front end electronics for sector 1
728
729     //FEEBox
730     TGeoVolume* v0AFEE = new TGeoVolumeAssembly("V0AFEE");
731     new TGeoBBox("sV0AFEEB1", fV0AFEEBWd/2., fV0AFEEBHt/2., fV0AFEEBTh/2.);
732     new TGeoBBox("sV0AFEEB2", fV0AFEEBWd/2.-fV0APMBWdW, fV0AFEEBHt/2.-fV0APMBHtW, fV0AFEEBTh/2.-fV0APMBThW);
733     TGeoCompositeShape *sV0AFEEB = new TGeoCompositeShape("sV0AFEEB","sV0AFEEB1-sV0AFEEB2");
734     TGeoVolume *v0AFEEB = new TGeoVolume("V0AFEEB",sV0AFEEB, medV0APMAlum);
735     v0AFEEB->SetLineColor(kV0AColorPMA);
736     v0AFEE->AddNode(v0AFEEB,1);
737
738     //Mother and daughter boards
739     for (int i=0;i<2;i++) {
740     v0APts[0+8*i] = -fV0APMBHtW/10.;           v0APts[1+8*i] = fV0AFEEBTh/2.-fV0APMTB;
741     v0APts[2+8*i] = fV0APMBHtW/10.;             v0APts[3+8*i] = fV0AFEEBTh/2.-fV0APMTB;
742     v0APts[4+8*i] = fV0APMBHtW/10.;            v0APts[5+8*i] = -fV0AFEEBTh/2.+fV0APMTB;
743     v0APts[6+8*i] = -fV0APMBHtW/10.;           v0APts[7+8*i] = -fV0AFEEBTh/2.+fV0APMTB;
744     }
745     TGeoArb8 *sV0AFEEDaughter = new TGeoArb8("sV0AFEEDaughter", fV0AFEEBTh/2.-fV0APMTB, v0APts);
746     TGeoVolume *v0AFEEDaughter = new TGeoVolume("V0AFEEDaughter", sV0AFEEDaughter, medV0AFibGlass);
747     v0AFEEDaughter->SetLineColor(kV0AColorFibGlass);
748     double spacing = fV0APMBHtW;
749     v0AFEE->AddNode(v0AFEEDaughter, 1, new TGeoTranslation(9.0*spacing, fV0AFEEBTh/2.+2.0*fV0APMTB, fV0APMBHtW/2.));
750     v0AFEE->AddNode(v0AFEEDaughter, 2, new TGeoTranslation(6.0*spacing, fV0AFEEBTh/2.+2.0*fV0APMTB, fV0APMBHtW/2.));
751     v0AFEE->AddNode(v0AFEEDaughter, 3, new TGeoTranslation(3.0*spacing, fV0AFEEBTh/2.+2.0*fV0APMTB, fV0APMBHtW/2.));
752     v0AFEE->AddNode(v0AFEEDaughter, 4, new TGeoTranslation(0.0*spacing, fV0AFEEBTh/2.+2.0*fV0APMTB, fV0APMBHtW/2.));
753     v0AFEE->AddNode(v0AFEEDaughter, 5, new TGeoTranslation(-3.0*spacing, fV0AFEEBTh/2.+2.0*fV0APMTB, fV0APMBHtW/2.));
754     v0AFEE->AddNode(v0AFEEDaughter, 6, new TGeoTranslation(-6.0*spacing, fV0AFEEBTh/2.+2.0*fV0APMTB, fV0APMBHtW/2.));
755     v0AFEE->AddNode(v0AFEEDaughter, 7, new TGeoTranslation(-9.0*spacing, fV0AFEEBTh/2.+2.0*fV0APMTB, fV0APMBHtW/2.));
756     v0AFEE->AddNode(v0AFEEDaughter, 8, new TGeoTranslation(-12.0*spacing, fV0AFEEBTh/2.+2.0*fV0APMTB, fV0APMBHtW/2.));   
757     for (int i=0;i<2;i++) {
758     v0APts[0+8*i] = -fV0AFEEBWd/2.+fV0APMBWdW;         v0APts[1+8*i] = fV0AFEEBTh+fV0APMTB;
759     v0APts[2+8*i] = fV0AFEEBWd/2.-fV0APMBWdW;          v0APts[3+8*i] = fV0AFEEBTh+fV0APMTB;
760     v0APts[4+8*i] = fV0AFEEBWd/2.-fV0APMBWdW;          v0APts[5+8*i] = -fV0AFEEBTh-fV0APMTB;
761     v0APts[6+8*i] = -fV0AFEEBWd/2.+fV0APMBWdW;         v0APts[7+8*i] = -fV0AFEEBTh-fV0APMTB;
762     }
763     TGeoArb8 *sV0AFEEMother = new TGeoArb8("sV0AFEEMother", fV0APMBHtW/10., v0APts);
764     TGeoVolume *v0AFEEMother = new TGeoVolume("V0AFEEMother", sV0AFEEMother, medV0AFibGlass);
765     v0AFEEMother->SetLineColor(kV0AColorFibGlass);
766     v0AFEE->AddNode(v0AFEEMother, 1, new TGeoTranslation(0.0, 0.0, -fV0AFEEBTh/2.+fV0APMBThW+fV0APMBHtW));
767     for (int i=0;i<2;i++) {
768       v0APts[0+8*i] = -fV0AFEEBWd/2.+fV0APMBWdW;               v0APts[1+8*i] = (fV0AFEEBTh+fV0APMTB)/2.;
769       v0APts[2+8*i] = fV0AFEEBWd/2.-fV0APMBWdW;                v0APts[3+8*i] = (fV0AFEEBTh+fV0APMTB)/2.;
770       v0APts[4+8*i] = fV0AFEEBWd/2.-fV0APMBWdW;                v0APts[5+8*i] = (-fV0AFEEBTh-fV0APMTB)/2.;
771       v0APts[6+8*i] = -fV0AFEEBWd/2.+fV0APMBWdW;               v0APts[7+8*i] = (-fV0AFEEBTh-fV0APMTB)/2.; 
772     }
773     TGeoArb8 *sV0AFEEHalfMother = new TGeoArb8("sV0AFEEHalfMother", fV0APMBHtW/10., v0APts);
774     TGeoVolume *v0AFEEHalfMother = new TGeoVolume("V0AFEEHalfMother", sV0AFEEHalfMother, medV0AFibGlass);
775     v0AFEEHalfMother->SetLineColor(kV0AColorFibGlass);
776     v0AFEE->AddNode(v0AFEEHalfMother, 1, new TGeoTranslation(0.0, -(fV0AFEEBTh+fV0APMTB)/2., -2.0*spacing));
777
778
779     //FEE
780     rot = new TGeoRotation("rot");
781     rot->RotateX(90);
782     rot->RotateZ(+90.0);
783     double aFEEshiftR = fV0AR6  +  fV0AOctH2 + fV0APlaAl;
784     v0LE->AddNode(v0AFEE,1, new TGeoCombiTrans( aFEEshiftR*cos225+2.0, 0, 7.5, rot));
785     for (int i=0;i<2;i++) {
786     v0APts[0+8*i] = fV0AOctH2/2.;              v0APts[1+8*i] = fV0AFEEBHt/2. + 2.5;
787     v0APts[2+8*i] = fV0AOctH2/2.;              v0APts[3+8*i] = -fV0AFEEBHt/2.- 2.5;
788     v0APts[4+8*i] = -fV0AOctH2/2.;             v0APts[5+8*i] = -fV0AFEEBHt/2.- 2.5;
789     v0APts[6+8*i] = -fV0AOctH2/2.;             v0APts[7+8*i] = fV0AFEEBHt/2.+ 2.5;
790     }
791     TGeoArb8 *sV0AFEEOct2 = new TGeoArb8("sV0AFEEOct2", (fV0ASciWd+2*fV0AOctWd)/2., v0APts);
792     TGeoVolume *v0AFEEOct2 = new TGeoVolume("V0AFEEOct2",sV0AFEEOct2, medV0ASup);
793     v0AFEEOct2->SetLineColor(kV0AColorOct);
794     v0LE->AddNode(v0AFEEOct2,1, new TGeoTranslation((aFEEshiftR2Sec1*cos225 + 2.0) - fV0AFEEBTh/2. - 1.0,0.0,0.0));
795
796
797     /// Definition sector 2
798     TGeoVolume *v0ASec2 = new TGeoVolumeAssembly("V0ASec2");
799         
800     /// For boolean sustraction
801     double preShapeSec2 = 0.2;
802     for (int i=0;i<2;i++) {
803       v0APts[0+8*i] = fV0AR0-fV0AFraWd/2.-preShapeSec2;  v0APts[1+8*i] = -preShapeSec2;
804       v0APts[2+8*i] = fV0AR0-fV0AFraWd/2.-preShapeSec2;  v0APts[3+8*i] = fV0AFraWd/2.;
805       v0APts[4+8*i] = fV0AR4+fV0AFraWd/2.+preShapeSec2;  v0APts[5+8*i] = fV0AFraWd/2.;
806       v0APts[6+8*i] = fV0AR4+fV0AFraWd/2.+preShapeSec2;  v0APts[7+8*i] = -preShapeSec2;
807     }
808     new TGeoArb8("sV0ACha1Sec2",fV0ASciWd/1.5,v0APts);
809     for (int i=0;i<2;i++) {
810       v0APts[0+8*i] = fV0AR0*sin45-preShapeSec2;
811       v0APts[1+8*i] = (fV0AR0-fV0AFraWd)*sin45-preShapeSec2;
812       v0APts[2+8*i] = (fV0AR0-fV0AFraWd/2.)*sin45-preShapeSec2;
813       v0APts[3+8*i] = (fV0AR0-fV0AFraWd/2.)*sin45;
814       v0APts[4+8*i] = (fV0AR4+fV0AFraWd/2.)*sin45+preShapeSec2;
815       v0APts[5+8*i] = (fV0AR4+fV0AFraWd/2.)*sin45+2.*preShapeSec2;
816       v0APts[6+8*i] = (fV0AR4+fV0AFraWd)*sin45+preShapeSec2;
817       v0APts[7+8*i] = fV0AR4*sin45+preShapeSec2;
818     }
819     new TGeoArb8("sV0ACha2Sec2", fV0ASciWd/2.+2.*preShapeSec2, v0APts);
820     new TGeoCompositeShape("sV0ACha12Sec2","sV0ACha1Sec2+sV0ACha2Sec2");
821     new TGeoTube("sV0ANail1SciHoleSec2", 0.0, 0.4, 1.65);
822     TGeoTranslation *pos1Sec2 = new TGeoTranslation("pos1Sec2", 42.9, 0.51, 0.0);
823     pos1Sec2->RegisterYourself();
824     new TGeoTube("sV0ANail2SciHoleSec2", 0.0, 0.4, 1.65);
825     TGeoTranslation *pos2Sec2 = new TGeoTranslation("pos2Sec2", 30.73,29.98,0.0);
826     pos2Sec2->RegisterYourself();
827     new TGeoCompositeShape("sV0ANailsSciHolesSec2","sV0ANail1SciHoleSec2:pos1Sec2+sV0ANail2SciHoleSec2:pos2Sec2");
828     new TGeoCompositeShape("sV0AChaSec2","sV0ACha12Sec2+sV0ANailsSciHolesSec2");
829     new TGeoTubeSeg("sV0AFicR5Sec2", fV0AR4+fV0AFraWd/2., fV0AR4 + fV0AR0, fV0ASciWd/2.+2*preShapeSec2, 0, 45);
830     new TGeoBBox("sV0AFicFEEBSec2", fV0AFEEBWd/2., fV0AFEEBHt/2., fV0AFEEBTh/2.);
831     rot = new TGeoRotation("rot");
832     rot->RotateX(90);
833     rot->RotateZ(-90.0);
834     double aFEEshiftR2Sec2 = fV0AR6  +  fV0AOctH2 + fV0APlaAl;
835     TGeoCombiTrans *posFicFEEBSec2 = new TGeoCombiTrans("posFicFEEBSec2", aFEEshiftR2Sec2*cos225 + 2.0, 0, 7.5, rot);
836     posFicFEEBSec2->RegisterYourself();
837     for (int i=0;i<2;i++) {
838     v0APts[0+8*i] = fV0AOctH2/2.;              v0APts[1+8*i] = fV0AFEEBHt/2. + 2.5;
839     v0APts[2+8*i] = fV0AOctH2/2.;              v0APts[3+8*i] = -fV0AFEEBHt/2.- 2.5;
840     v0APts[4+8*i] = -fV0AOctH2/2.;             v0APts[5+8*i] = -fV0AFEEBHt/2.- 2.5;
841     v0APts[6+8*i] = -fV0AOctH2/2.;             v0APts[7+8*i] = fV0AFEEBHt/2.+ 2.5;
842     }
843     new TGeoArb8("sV0AFicOct2Sec2", (fV0ASciWd+2*fV0AOctWd)/2., v0APts);
844     TGeoTranslation *posFicOct2Sec2 = new TGeoTranslation("posFicOct2Sec2",(aFEEshiftR2Sec2*cos225 + 2.0) - fV0AFEEBTh/2. - 1.0,0.0,0.0);
845     posFicOct2Sec2->RegisterYourself();  
846
847     /// Frame
848     TGeoVolume *v0AFraSec2 = new TGeoVolumeAssembly("V0AFraSec2");
849     for (int i=0;i<2;i++) {
850       v0APts[0+8*i] = fV0AR0-fV0AFraWd/2.;  v0APts[1+8*i] = 0.;
851       v0APts[2+8*i] = fV0AR0-fV0AFraWd/2.;  v0APts[3+8*i] = fV0AFraWd/2.;
852       v0APts[4+8*i] = fV0AR4+fV0AFraWd/2.;  v0APts[5+8*i] = fV0AFraWd/2.;
853       v0APts[6+8*i] = fV0AR4+fV0AFraWd/2.;  v0APts[7+8*i] = 0.;
854     }
855     TGeoArb8 *sV0AFraB1Sec2 = new TGeoArb8("sV0AFraB1Sec2",fV0ASciWd/2.,v0APts);
856     TGeoVolume *v0AFraB1Sec2 = new TGeoVolume("V0AFraB1Sec2",sV0AFraB1Sec2,medV0AFra);
857     for (int i=0;i<2;i++) {
858       v0APts[0+8*i] = fV0AR0*sin45;
859       v0APts[1+8*i] = (fV0AR0-fV0AFraWd)*sin45;
860       v0APts[2+8*i] = (fV0AR0-fV0AFraWd/2.)*sin45;
861       v0APts[3+8*i] = (fV0AR0-fV0AFraWd/2.)*sin45;
862       v0APts[4+8*i] = (fV0AR4+fV0AFraWd/2.)*sin45;
863       v0APts[5+8*i] = (fV0AR4+fV0AFraWd/2.)*sin45;
864       v0APts[6+8*i] = (fV0AR4+fV0AFraWd)*sin45;
865       v0APts[7+8*i] = fV0AR4*sin45;
866     }
867     TGeoArb8 *sV0AFraB2Sec2 = new TGeoArb8("sV0AFraB2Sec2", fV0ASciWd/2., v0APts);
868     TGeoVolume *v0AFraB2Sec2 = new TGeoVolume("V0AFraB2Sec2",sV0AFraB2Sec2,medV0AFra);
869     v0AFraB1Sec2->SetLineColor(kV0AColorFra); v0AFraB2Sec2->SetLineColor(kV0AColorFra);
870     v0AFraSec2->AddNode(v0AFraB1Sec2,1);
871     v0AFraSec2->AddNode(v0AFraB2Sec2,1);  
872     new TGeoTubeSeg( "sV0AFraR1bSec2", fV0AR0-fV0AFraWd/2.,
873                      fV0AR0+fV0AFraWd/2., fV0ASciWd/2., 0, 45);
874     new TGeoTubeSeg( "sV0AFraR2bSec2", fV0AR1-fV0AFraWd/2.,
875                      fV0AR1+fV0AFraWd/2., fV0ASciWd/2., 0, 45);
876     new TGeoTubeSeg( "sV0AFraR3bSec2", fV0AR2-fV0AFraWd/2.,
877                      fV0AR2+fV0AFraWd/2., fV0ASciWd/2., 0, 45);
878     new TGeoTubeSeg( "sV0AFraR4bSec2", fV0AR3-fV0AFraWd/2.,
879                      fV0AR3+fV0AFraWd/2., fV0ASciWd/2., 0, 45);
880     new TGeoTubeSeg( "sV0AFraR5bSec2", fV0AR4-fV0AFraWd/2.,
881                      fV0AR4+fV0AFraWd/2., fV0ASciWd/2., 0, 45);
882     TGeoCompositeShape *sV0AFraR1Sec2 = new TGeoCompositeShape("sV0AFraR1Sec2","sV0AFraR1bSec2-sV0AChaSec2");
883     TGeoCompositeShape *sV0AFraR2Sec2 = new TGeoCompositeShape("sV0AFraR2Sec2","sV0AFraR2bSec2-sV0AChaSec2");
884     TGeoCompositeShape *sV0AFraR3Sec2 = new TGeoCompositeShape("sV0AFraR3Sec2","sV0AFraR3bSec2-sV0AChaSec2");
885     TGeoCompositeShape *sV0AFraR4Sec2 = new TGeoCompositeShape("sV0AFraR4Sec2","sV0AFraR4bSec2-sV0AChaSec2");
886     TGeoCompositeShape *sV0AFraR5Sec2 = new TGeoCompositeShape("sV0AFraR5Sec2","sV0AFraR5bSec2-sV0AChaSec2");
887     TGeoVolume *v0AFraR1Sec2 = new TGeoVolume("V0AFraR1Sec2",sV0AFraR1Sec2,medV0AFra);
888     TGeoVolume *v0AFraR2Sec2 = new TGeoVolume("V0AFraR2Sec2",sV0AFraR2Sec2,medV0AFra);
889     TGeoVolume *v0AFraR3Sec2 = new TGeoVolume("V0AFraR3Sec2",sV0AFraR3Sec2,medV0AFra);
890     TGeoVolume *v0AFraR4Sec2 = new TGeoVolume("V0AFraR4Sec2",sV0AFraR4Sec2,medV0AFra);
891     TGeoVolume *v0AFraR5Sec2 = new TGeoVolume("V0AFraR5Sec2",sV0AFraR5Sec2,medV0AFra);
892     v0AFraR1Sec2->SetLineColor(kV0AColorFra); v0AFraR2Sec2->SetLineColor(kV0AColorFra);
893     v0AFraR3Sec2->SetLineColor(kV0AColorFra); v0AFraR4Sec2->SetLineColor(kV0AColorFra);
894     v0AFraR5Sec2->SetLineColor(kV0AColorFra);
895     v0AFraSec2->AddNode(v0AFraR1Sec2,1); 
896     v0AFraSec2->AddNode(v0AFraR2Sec2,1);
897     v0AFraSec2->AddNode(v0AFraR3Sec2,1); 
898     v0AFraSec2->AddNode(v0AFraR4Sec2,1);
899     v0AFraSec2->AddNode(v0AFraR5Sec2,1);
900     v0ASec2->AddNode(v0AFraSec2,1);
901     
902     /// Sensitive scintilator
903     TGeoVolume *v0ASciSec2 = new TGeoVolumeAssembly("V0ASciSec2");
904     new TGeoTubeSeg( "sV0AR1bSec2", fV0AR0+fV0AFraWd/2.,
905                      fV0AR1-fV0AFraWd/2., fV0ASciWd/2., 0, 45);
906     new TGeoTubeSeg( "sV0AR2bSec2", fV0AR1+fV0AFraWd/2.,
907                      fV0AR2-fV0AFraWd/2., fV0ASciWd/2., 0, 45);
908     new TGeoTubeSeg( "sV0AR3bSec2", fV0AR2+fV0AFraWd/2.,
909                      fV0AR3-fV0AFraWd/2., fV0ASciWd/2., 0, 45);
910     new TGeoTubeSeg( "sV0AR4bSec2", fV0AR3+fV0AFraWd/2.,
911                      fV0AR4-fV0AFraWd/2., fV0ASciWd/2., 0, 45);
912     TGeoCompositeShape *sV0AR1Sec2 = new TGeoCompositeShape("sV0AR1Sec2","sV0AR1bSec2-sV0AChaSec2");
913     TGeoCompositeShape *sV0AR2Sec2 = new TGeoCompositeShape("sV0AR2Sec2","sV0AR2bSec2-sV0AChaSec2");
914     TGeoCompositeShape *sV0AR3Sec2 = new TGeoCompositeShape("sV0AR3Sec2","sV0AR3bSec2-sV0AChaSec2");
915     TGeoCompositeShape *sV0AR4Sec2 = new TGeoCompositeShape("sV0AR4Sec2","sV0AR4bSec2-sV0AChaSec2");
916     TGeoVolume *v0L1Sec2 = new TGeoVolume("V0L1Sec2",sV0AR1Sec2,medV0ASci);
917     TGeoVolume *v0L2Sec2 = new TGeoVolume("V0L2Sec2",sV0AR2Sec2,medV0ASci);
918     TGeoVolume *v0L3Sec2 = new TGeoVolume("V0L3Sec2",sV0AR3Sec2,medV0ASci);
919     TGeoVolume *v0L4Sec2 = new TGeoVolume("V0L4Sec2",sV0AR4Sec2,medV0ASci);
920     v0L1Sec2->SetLineColor(kV0AColorSci); v0L2Sec2->SetLineColor(kV0AColorSci);
921     v0L3Sec2->SetLineColor(kV0AColorSci); v0L4Sec2->SetLineColor(kV0AColorSci);
922     v0ASec2->AddNode(v0L1Sec2,1);
923     v0ASec2->AddNode(v0L2Sec2,1);
924     v0ASec2->AddNode(v0L3Sec2,1);
925     v0ASec2->AddNode(v0L4Sec2,1);      
926     
927     /// Segment of octagon 
928     for (int i=0;i<2;i++) {
929     v0APts[0+8*i] =  fV0AR6-fV0AOctH2;           v0APts[1+8*i] = 0.;
930       v0APts[2+8*i] = (fV0AR6-fV0AOctH2)*sin45;  v0APts[3+8*i] = (fV0AR6-fV0AOctH2)*sin45;
931       v0APts[4+8*i] = fV0AR6*sin45;              v0APts[5+8*i] = fV0AR6*sin45;
932       v0APts[6+8*i] = fV0AR6;                    v0APts[7+8*i] = 0.;
933     }
934     new TGeoArb8("sV0AOct2Sec2", (fV0ASciWd+2*fV0AOctWd)/2., v0APts);
935     TGeoCompositeShape *sV0AOct2FEEBSec2 = new TGeoCompositeShape("sV0AOct2FEEBSec2","sV0AOct2Sec2-sV0AFicFEEBSec2:posFicFEEBSec2-sV0AFicOct2Sec2:posFicOct2Sec2");
936     TGeoVolume *v0AOct2Sec2 = new TGeoVolume("V0AOct2Sec2", sV0AOct2FEEBSec2,medV0ASup);
937     v0AOct2Sec2->SetLineColor(kV0AColorOct);
938     TGeoVolume *v0ASupSec2 = new TGeoVolumeAssembly("V0ASupSec2");
939     v0ASupSec2->AddNode(v0AOct2Sec2,1);
940     v0ASec2->AddNode(v0ASupSec2,1);
941
942     //Bunch of fibers
943     v0APts[ 0] = v0APts[ 2] = -13.0;
944     v0APts[ 1] = v0APts[ 7] = (fV0ASciWd+fV0AOctWd)/2.-0.01;
945     v0APts[ 3] = v0APts[ 5] = (fV0ASciWd+fV0AOctWd)/2.+0.01;
946     v0APts[ 4] = v0APts[ 6] = +13.0;
947     v0APts[ 8] = v0APts[10] = -10.0;
948     v0APts[ 9] = v0APts[15] = 0.;
949     v0APts[11] = v0APts[13] = 0.25;
950     v0APts[12] = v0APts[14] = +10.0;
951     new TGeoArb8("sV0AFib1Sec2", 11.5, v0APts);
952     rot = new TGeoRotation("rot");
953     rot->RotateX(-90);
954     rot->RotateZ(-90.+22.5);
955     TGeoCombiTrans *fibpos1Sec2 = new TGeoCombiTrans("fibpos1Sec2", (fV0AR6-fV0AOctH2+fV0AR5)*cos225/2. - 3.8, (fV0AR6-fV0AOctH2+fV0AR5)*sin225/2.-1.8, 0, rot);
956     fibpos1Sec2->RegisterYourself();
957     TGeoCompositeShape *sV0AFib1HoleSec2 = new TGeoCompositeShape("sV0AFib1HoleSec2","sV0AFib1Sec2:fibpos1Sec2-sV0AFicR5Sec2"); 
958     TGeoVolume *v0AFib1HoleSec2 = new TGeoVolume("V0AFib1HoleSec2",sV0AFib1HoleSec2,medV0AFib);
959     v0AFib1HoleSec2->SetLineColor(kV0AColorFib);
960     new TGeoArb8("sV0AFib2Sec2", 11.5, v0APts);
961     rot = new TGeoRotation("rot");
962     rot->RotateX(-90);
963     rot->RotateY(180);
964     rot->RotateZ(-90.+22.5);
965     TGeoCombiTrans *fibpos2Sec2 = new TGeoCombiTrans("fibpos2Sec2", (fV0AR6-fV0AOctH2+fV0AR5)*cos225/2. - 3.8, (fV0AR6-fV0AOctH2+fV0AR5)*sin225/2.-1.8, 0, rot);
966     fibpos2Sec2->RegisterYourself();
967     TGeoCompositeShape *sV0AFib2HoleSec2 = new TGeoCompositeShape("sV0AFib2HoleSec2","sV0AFib2Sec2:fibpos2Sec2-sV0AFicR5Sec2");
968     TGeoVolume *v0AFib2HoleSec2 = new TGeoVolume("V0AFib2HoleSec2",sV0AFib2HoleSec2,medV0AFib);
969     v0AFib2HoleSec2->SetLineColor(kV0AColorFib);
970     TGeoVolume *v0AFibSec2 = new TGeoVolumeAssembly("V0AFibSec2");
971     v0AFibSec2->AddNode(v0AFib1HoleSec2,1);
972     v0AFibSec2->AddNode(v0AFib2HoleSec2,1);
973     v0ASec2->AddNode(v0AFibSec2,1); 
974     
975      /// Plates
976     new TGeoTube("sV0ANail1PlaInHoleSec2", 0.0, 0.4, (fV0APlaWd-2*fV0APlaAl)/2.);
977     new TGeoTube("sV0ANail2PlaInHoleSec2", 0.0, 0.4, (fV0APlaWd-2*fV0APlaAl)/2.);
978     new TGeoCompositeShape("sV0ANailsPlaInHolesSec2","sV0ANail1PlaInHoleSec2:pos1Sec2+sV0ANail2PlaInHoleSec2:pos2Sec2");
979     new TGeoTube("sV0ANail1PlaOuHoleSec2", 0.0, 0.4, (fV0APlaAl)/2.);
980     new TGeoTube("sV0ANail2PlaOuHoleSec2", 0.0, 0.4, (fV0APlaAl)/2.);
981     new TGeoCompositeShape("sV0ANailsPlaOuHolesSec2","sV0ANail1PlaOuHoleSec2:pos1Sec2+sV0ANail2PlaOuHoleSec2:pos2Sec2");
982     for (int i=0;i<2;i++) {
983       v0APts[0+8*i] = fV0AR0;                   v0APts[1+8*i] = 0.;
984       v0APts[2+8*i] = fV0AR0*sin45;             v0APts[3+8*i] = fV0AR0*sin45;
985       v0APts[4+8*i] = fV0AR6 * sin45;   v0APts[5+8*i] = fV0AR6*sin45;
986       v0APts[6+8*i] = fV0AR6;           v0APts[7+8*i] = 0.;
987     }
988     new TGeoArb8("sV0APlaInSec2", (fV0APlaWd-2*fV0APlaAl)/2., v0APts);
989     TGeoCompositeShape *sV0APlaInNailsHolesSec2 = new TGeoCompositeShape("sV0APlaInNailsHolesSec2","sV0APlaInSec2-sV0ANailsPlaInHolesSec2-sV0AFicFEEBSec2:posFicFEEBSec2");
990     TGeoVolume *v0APlaInNailsHolesSec2 = new TGeoVolume("V0APlaInNailsHolesSec2", sV0APlaInNailsHolesSec2, medV0APlaIn);
991     new TGeoArb8("sV0APlaOuSec2", fV0APlaAl/2., v0APts);
992     TGeoCompositeShape *sV0APlaOuNailsHolesSec2 = new TGeoCompositeShape("sV0APlaOuNailsHolesSec2","sV0APlaOuSec2-sV0ANailsPlaOuHolesSec2-sV0AFicFEEBSec2:posFicFEEBSec2"); 
993     TGeoVolume *v0APlaOuNailsHolesSec2 = new TGeoVolume("V0APlaOuNailsHolesSec2", sV0APlaOuNailsHolesSec2, medV0APlaOu);
994     v0APlaInNailsHolesSec2->SetLineColor(kV0AColorPlaIn); v0APlaOuNailsHolesSec2->SetLineColor(kV0AColorPlaOu);
995     TGeoVolume *v0APlaSec2 = new TGeoVolumeAssembly("V0APlaSec2");
996     v0APlaSec2->AddNode(v0APlaInNailsHolesSec2,1);
997     v0APlaSec2->AddNode(v0APlaOuNailsHolesSec2,1,new TGeoTranslation(0,0,(fV0APlaWd-fV0APlaAl)/2.));
998     v0APlaSec2->AddNode(v0APlaOuNailsHolesSec2,2,new TGeoTranslation(0,0,-(fV0APlaWd-fV0APlaAl)/2.));
999     v0ASec2->AddNode(v0APlaSec2,1,new TGeoTranslation(0,0,(fV0ASciWd+2*fV0AOctWd+fV0APlaWd)/2.));
1000     v0ASec2->AddNode(v0APlaSec2,2,new TGeoTranslation(0,0,-(fV0ASciWd+2*fV0AOctWd+fV0APlaWd)/2.));
1001     
1002      /// Non-sensitive scintilator
1003     new TGeoTubeSeg("sV0AR5S2Sec2", fV0AR4+fV0AFraWd/2., fV0AR4 + fV0AR0, fV0ASciWd/2.+2*preShapeSec2, 0, 45);
1004     TGeoCompositeShape *sV0AR5Sec2 = new TGeoCompositeShape("V0AR5Sec2","sV0AR5S2Sec2 - sV0AChaSec2");
1005     TGeoVolume *v0AR5Sec2 = new TGeoVolume("V0AR5Sec2",sV0AR5Sec2,medV0ASci);
1006     v0AR5Sec2->SetLineColor(kV0AColorSci);
1007     v0ASciSec2->AddNode(v0AR5Sec2,1);
1008     v0ASec2->AddNode(v0ASciSec2,1); 
1009
1010     /// PMBox
1011     TGeoVolume* v0APMSec2 = new TGeoVolumeAssembly("V0APMSec2");
1012     new TGeoBBox("sV0APMB1Sec2", fV0APMBWd/2., fV0APMBHt/2., fV0APMBTh/2.);
1013     new TGeoBBox("sV0APMB2Sec2", fV0APMBWd/2.-fV0APMBWdW, fV0APMBHt/2.-fV0APMBHtW, fV0APMBTh/2.-fV0APMBThW);
1014     TGeoCompositeShape *sV0APMBSec2 = new TGeoCompositeShape("sV0APMBSec2","sV0APMB1Sec2-sV0APMB2Sec2");
1015     TGeoVolume *v0APMBSec2 = new TGeoVolume("V0APMBSec2",sV0APMBSec2, medV0APMAlum);
1016     v0APMBSec2->SetLineColor(kV0AColorPMA);
1017     v0APMSec2->AddNode(v0APMBSec2,1);
1018
1019     /// PMTubes
1020     TGeoTube *sV0APMT1Sec2 = new TGeoTube("sV0APMT1Sec2", fV0APMTR1, fV0APMTR2, fV0APMTH/2.);
1021     TGeoVolume *v0APMT1Sec2 = new TGeoVolume("V0APMT1Sec2", sV0APMT1Sec2, medV0APMGlass);
1022     TGeoTube *sV0APMT2Sec2 = new TGeoTube("sV0APMT2Sec2", fV0APMTR3, fV0APMTR4, fV0APMTH/2.);
1023     TGeoVolume *v0APMT2Sec2 = new TGeoVolume("V0APMT2Sec2", sV0APMT2Sec2, medV0APMAlum);
1024     TGeoVolume *v0APMTSec2 = new TGeoVolumeAssembly("V0APMTSec2");
1025     TGeoTube *sV0APMTTSec2 = new TGeoTube("sV0APMTTSec2", 0., fV0APMTR4, fV0APMTB/2.);
1026     TGeoVolume *v0APMTTSec2 = new TGeoVolume("V0APMTTSec2", sV0APMTTSec2, medV0APMAlum);
1027     v0APMT1Sec2->SetLineColor(kV0AColorPMG);
1028     v0APMT2Sec2->SetLineColor(kV0AColorPMA);
1029     v0APMTTSec2->SetLineColor(kV0AColorPMA);
1030     rot = new TGeoRotation("rot", 90, 0, 180, 0, 90, 90);
1031     v0APMTSec2->AddNode(v0APMT1Sec2,1,rot);
1032     v0APMTSec2->AddNode(v0APMT2Sec2,1,rot);
1033     v0APMTSec2->AddNode(v0APMTTSec2,1,new TGeoCombiTrans(0,-(fV0APMTH+fV0APMTB)/2.,0,rot));
1034     double autoShiftSec2 = (fV0APMBWd-2*fV0APMBWdW)/4.;
1035     v0APMSec2->AddNode(v0APMTSec2, 1, new TGeoTranslation(-1.5*autoShiftSec2, 0, 0));
1036     v0APMSec2->AddNode(v0APMTSec2, 2, new TGeoTranslation(-0.5*autoShiftSec2, 0, 0));
1037     v0APMSec2->AddNode(v0APMTSec2, 3, new TGeoTranslation(+0.5*autoShiftSec2, 0, 0));
1038     v0APMSec2->AddNode(v0APMTSec2, 4, new TGeoTranslation(+1.5*autoShiftSec2, 0, 0));
1039
1040     // PM
1041     rot = new TGeoRotation("rot");
1042     rot->RotateX(90-fV0APMBAng);
1043     rot->RotateZ(-90.+22.5);
1044     double cosAngPMBSec2 = TMath::Cos(fV0APMBAng*TMath::DegToRad());
1045     double sinAngPMBSec2 = TMath::Sin(fV0APMBAng*TMath::DegToRad());
1046     double shiftZSec2 = fV0APMBHt/2. * cosAngPMBSec2
1047       -   ( fV0ASciWd + 2 * fV0AOctWd + 2 * fV0APlaWd )/2.   -   fV0APMBTh/2. * sinAngPMBSec2;
1048     double shiftRSec2 = fV0AR6  +  fV0AOctH2 + fV0APlaAl;
1049     v0ASec2->AddNode(v0APMSec2,1, new TGeoCombiTrans( shiftRSec2*cos225+1.07, shiftRSec2*sin225, shiftZSec2, rot));
1050     
1051     // Aluminium nails 
1052     TGeoTube *sV0ANail1Sec2 = new TGeoTube("sV0ANail1Sec2", 0.0, 0.4, 5.09/2.);
1053     TGeoVolume *v0ANail1Sec2 = new TGeoVolume("V0ANail1Sec2", sV0ANail1Sec2, medV0APMAlum);
1054     v0ANail1Sec2->SetLineColor(kV0AColorPMA);// this is the color for aluminium
1055     v0ASec2->AddNode(v0ANail1Sec2,1,new TGeoTranslation(42.9, 0.51, 0.0));
1056     TGeoTube *sV0ANail2Sec2 = new TGeoTube("sV0ANail2Sec2", 0.0, 0.4, 5.09/2.);
1057     TGeoVolume *v0ANail2Sec2 = new TGeoVolume("V0ANail2Sec2", sV0ANail2Sec2, medV0APMAlum);
1058     v0ANail2Sec2->SetLineColor(kV0AColorPMA);
1059     v0ASec2->AddNode(v0ANail2Sec2,1,new TGeoTranslation(30.73,29.98,0.0)); 
1060         
1061     /// Adding sector to v0LE volume
1062     for(int i=1; i<2; i++) {
1063        TGeoRotation *rotation = new TGeoRotation("rotation", 90., i*45., 90., 90.+i*45., 0., 0.);
1064        v0LE->AddNode(v0ASec2,i+1,rotation);  
1065     }
1066
1067     //FEEBox
1068     TGeoVolume* v0AFEE2 = new TGeoVolumeAssembly("V0AFEE2");
1069     v0AFEE2->AddNode(v0AFEEB,1);
1070
1071     //Mother and daughter boards
1072     v0AFEE2->AddNode(v0AFEEDaughter, 1, new TGeoTranslation(9.0*spacing, fV0AFEEBTh/2.+2.0*fV0APMTB, fV0APMBHtW/2.));
1073     v0AFEE2->AddNode(v0AFEEDaughter, 2, new TGeoTranslation(6.0*spacing, fV0AFEEBTh/2.+2.0*fV0APMTB, fV0APMBHtW/2.));
1074     v0AFEE2->AddNode(v0AFEEDaughter, 3, new TGeoTranslation(3.0*spacing, fV0AFEEBTh/2.+2.0*fV0APMTB, fV0APMBHtW/2.));
1075     v0AFEE2->AddNode(v0AFEEDaughter, 4, new TGeoTranslation(0.0*spacing, fV0AFEEBTh/2.+2.0*fV0APMTB, fV0APMBHtW/2.));
1076     v0AFEE2->AddNode(v0AFEEDaughter, 5, new TGeoTranslation(-3.0*spacing, fV0AFEEBTh/2.+2.0*fV0APMTB, fV0APMBHtW/2.));
1077     v0AFEE2->AddNode(v0AFEEDaughter, 6, new TGeoTranslation(-6.0*spacing, fV0AFEEBTh/2.+2.0*fV0APMTB, fV0APMBHtW/2.));
1078     v0AFEE2->AddNode(v0AFEEDaughter, 7, new TGeoTranslation(-9.0*spacing, fV0AFEEBTh/2.+2.0*fV0APMTB, fV0APMBHtW/2.));
1079     v0AFEE2->AddNode(v0AFEEDaughter, 8, new TGeoTranslation(-12.0*spacing, fV0AFEEBTh/2.+2.0*fV0APMTB, fV0APMBHtW/2.));   
1080     v0AFEE2->AddNode(v0AFEEMother, 1, new TGeoTranslation(0.0, 0.0, -fV0AFEEBTh/2.+fV0APMBThW+fV0APMBHtW));
1081     v0AFEE2->AddNode(v0AFEEHalfMother, 1, new TGeoTranslation(0.0, -(fV0AFEEBTh+fV0APMTB)/2., -2.0*spacing));
1082
1083     //FEE
1084     rot = new TGeoRotation("rot");
1085     rot->RotateX(90);
1086     rot->RotateZ(+90.0-45.0+90);
1087     v0LE->AddNode(v0AFEE2,1, new TGeoCombiTrans( (aFEEshiftR2Sec1*cos225 + 2.0)*cos45, (aFEEshiftR2Sec1*cos225 + 2.0)*sin45, 7.5, rot));
1088     rot = new TGeoRotation("rot");
1089     rot->RotateZ(-90.0+45.0+90.0);
1090     v0LE->AddNode(v0AFEEOct2,2, new TGeoCombiTrans(((aFEEshiftR2Sec1*cos225 + 2.0) - fV0AFEEBTh/2. - 1.0)*cos45,((aFEEshiftR2Sec1*cos225 + 2.0) - fV0AFEEBTh/2. - 1.0)*sin45,0.0,rot));
1091
1092    
1093     //Upper supports
1094     for (int i=0;i<2;i++){
1095     v0APts[0+8*i] = 0.0;            v0APts[1+8*i] = 45.5;  
1096     v0APts[2+8*i] = 0.0;            v0APts[3+8*i] = 70.4;   
1097     v0APts[4+8*i] = 4.0;            v0APts[5+8*i] = 68.9;
1098     v0APts[6+8*i] = 4.0;            v0APts[7+8*i] = 45.5;  
1099     }
1100     TGeoArb8 *sV0ASuppur = new TGeoArb8("sV0ASuppur", 1.65, v0APts);    
1101     TGeoVolume *v0ASuppur = new TGeoVolume("V0ASuppur", sV0ASuppur, medV0ASup);
1102     v0ASuppur->SetLineColor(kV0AColorOct);
1103     v0LE->AddNode(v0ASuppur,1);
1104     for (int i=0;i<2;i++){
1105     v0APts[0+8*i] = -0.0;           v0APts[1+8*i] = 70.4;
1106     v0APts[2+8*i] = -0.0;           v0APts[3+8*i] = 45.5;
1107     v0APts[4+8*i] = -4.0;           v0APts[5+8*i] = 45.5;
1108     v0APts[6+8*i] = -4.0;           v0APts[7+8*i] = 68.9;
1109     }
1110     TGeoArb8 *sV0ASuppul = new TGeoArb8("sV0ASuppul", 1.65, v0APts);    
1111     TGeoVolume *v0ASuppul = new TGeoVolume("V0ASuppul", sV0ASuppul, medV0ASup);
1112     v0ASuppul->SetLineColor(kV0AColorOct);
1113     v0LE->AddNode(v0ASuppul,1);
1114
1115     /// Definition sector 3
1116     TGeoVolume *v0ASec3 = new TGeoVolumeAssembly("V0ASec3");
1117         
1118     /// For boolean sustraction
1119     double preShapeSec3 = 0.2;
1120     for (int i=0;i<2;i++) {
1121       v0APts[0+8*i] = fV0AR0-fV0AFraWd/2.-preShapeSec3;  v0APts[1+8*i] = -preShapeSec3;
1122       v0APts[2+8*i] = fV0AR0-fV0AFraWd/2.-preShapeSec3;  v0APts[3+8*i] = fV0AFraWd/2.;
1123       v0APts[4+8*i] = fV0AR4+fV0AFraWd/2.+preShapeSec3;  v0APts[5+8*i] = fV0AFraWd/2.;
1124       v0APts[6+8*i] = fV0AR4+fV0AFraWd/2.+preShapeSec3;  v0APts[7+8*i] = -preShapeSec3;
1125     }
1126     new TGeoArb8("sV0ACha1Sec3",fV0ASciWd/1.5,v0APts);
1127     for (int i=0;i<2;i++) {
1128       v0APts[0+8*i] = fV0AR0*sin45-preShapeSec3;
1129       v0APts[1+8*i] = (fV0AR0-fV0AFraWd)*sin45-preShapeSec3;
1130       v0APts[2+8*i] = (fV0AR0-fV0AFraWd/2.)*sin45-preShapeSec3;
1131       v0APts[3+8*i] = (fV0AR0-fV0AFraWd/2.)*sin45;
1132       v0APts[4+8*i] = (fV0AR4+fV0AFraWd/2.)*sin45+preShapeSec3;
1133       v0APts[5+8*i] = (fV0AR4+fV0AFraWd/2.)*sin45+2.*preShapeSec3;
1134       v0APts[6+8*i] = (fV0AR4+fV0AFraWd)*sin45+preShapeSec3;
1135       v0APts[7+8*i] = fV0AR4*sin45+preShapeSec3;
1136     }
1137     new TGeoArb8("sV0ACha2Sec3", fV0ASciWd/2.+2.*preShapeSec3, v0APts);
1138     new TGeoCompositeShape("sV0ACha12Sec3","sV0ACha1Sec3+sV0ACha2Sec3");
1139     new TGeoTube("sV0ANail1SciHoleSec3", 0.0, 0.4, 1.65);
1140     TGeoTranslation *pos1Sec3 = new TGeoTranslation("pos1Sec3", 42.9, 0.51, 0.0);
1141     pos1Sec3->RegisterYourself();
1142     new TGeoTube("sV0ANail2SciHoleSec3", 0.0, 0.4, 1.65);
1143     TGeoTranslation *pos2Sec3 = new TGeoTranslation("pos2Sec3", 30.73,29.98,0.0);
1144     pos2Sec3->RegisterYourself();
1145     new TGeoCompositeShape("sV0ANailsSciHolesSec3","sV0ANail1SciHoleSec3:pos1Sec3+sV0ANail2SciHoleSec3:pos2Sec3");
1146     new TGeoCompositeShape("sV0AChaSec3","sV0ACha12Sec3+sV0ANailsSciHolesSec3");
1147     new TGeoTubeSeg("sV0AFicR5Sec3", fV0AR4+fV0AFraWd/2., fV0AR4 + fV0AR0, fV0ASciWd/2.+2*preShapeSec3, 0, 45);
1148     new TGeoBBox("sV0AFicFEEBSec3", fV0AFEEBWd/2., fV0AFEEBHt/2., fV0AFEEBTh/2.);
1149     double aFEEshiftR2Sec3 = fV0AR6  +  fV0AOctH2 + fV0APlaAl;
1150     rot = new TGeoRotation("rot");
1151     rot->RotateX(90);
1152     rot->RotateZ(-90.0+45.0);
1153     TGeoCombiTrans *posFicFEEBSec3 = new TGeoCombiTrans("posFicFEEBSec3", (aFEEshiftR2Sec3*cos225 + 2.0 )*cos45, (aFEEshiftR2Sec3*cos225 + 2.0 )*sin45, 7.5, rot);
1154     posFicFEEBSec3->RegisterYourself();
1155     for (int i=0;i<2;i++) {
1156     v0APts[0+8*i] = fV0AOctH2/2.;              v0APts[1+8*i] = fV0AFEEBHt/2. + 2.5;
1157     v0APts[2+8*i] = fV0AOctH2/2.;              v0APts[3+8*i] = -fV0AFEEBHt/2.- 2.5;
1158     v0APts[4+8*i] = -fV0AOctH2/2.;             v0APts[5+8*i] = -fV0AFEEBHt/2.- 2.5;
1159     v0APts[6+8*i] = -fV0AOctH2/2.;             v0APts[7+8*i] = fV0AFEEBHt/2.+ 2.5;
1160     }
1161     new TGeoArb8("sV0AFicOct2Sec3", (fV0ASciWd+2*fV0AOctWd)/2., v0APts); 
1162     rot = new TGeoRotation("rot");
1163     rot->RotateZ(-90.0+45.0+90.0);
1164     TGeoCombiTrans *posFicOct2UpSec3 = new TGeoCombiTrans("posFicOct2UpSec3",((aFEEshiftR2Sec3*cos225 + 2.0) - fV0AFEEBTh/2. - 1.0)*cos45,((aFEEshiftR2Sec3*cos225 + 2.0) - fV0AFEEBTh/2. - 1.0)*sin45,0.0,rot);
1165     posFicOct2UpSec3->RegisterYourself();
1166
1167     /// Frame
1168     TGeoVolume *v0AFraSec3 = new TGeoVolumeAssembly("V0AFraSec3");
1169     for (int i=0;i<2;i++) {
1170       v0APts[0+8*i] = fV0AR0-fV0AFraWd/2.;  v0APts[1+8*i] = 0.;
1171       v0APts[2+8*i] = fV0AR0-fV0AFraWd/2.;  v0APts[3+8*i] = fV0AFraWd/2.;
1172       v0APts[4+8*i] = fV0AR4+fV0AFraWd/2.;  v0APts[5+8*i] = fV0AFraWd/2.;
1173       v0APts[6+8*i] = fV0AR4+fV0AFraWd/2.;  v0APts[7+8*i] = 0.;
1174     }
1175     TGeoArb8 *sV0AFraB1Sec3 = new TGeoArb8("sV0AFraB1Sec3",fV0ASciWd/2.,v0APts);
1176     TGeoVolume *v0AFraB1Sec3 = new TGeoVolume("V0AFraB1Sec3",sV0AFraB1Sec3,medV0AFra);
1177     for (int i=0;i<2;i++) {
1178       v0APts[0+8*i] = fV0AR0*sin45;
1179       v0APts[1+8*i] = (fV0AR0-fV0AFraWd)*sin45;
1180       v0APts[2+8*i] = (fV0AR0-fV0AFraWd/2.)*sin45;
1181       v0APts[3+8*i] = (fV0AR0-fV0AFraWd/2.)*sin45;
1182       v0APts[4+8*i] = (fV0AR4+fV0AFraWd/2.)*sin45;
1183       v0APts[5+8*i] = (fV0AR4+fV0AFraWd/2.)*sin45;
1184       v0APts[6+8*i] = (fV0AR4+fV0AFraWd)*sin45;
1185       v0APts[7+8*i] = fV0AR4*sin45;
1186     }
1187     TGeoArb8 *sV0AFraB2Sec3 = new TGeoArb8("sV0AFraB2Sec3", fV0ASciWd/2., v0APts);
1188     TGeoVolume *v0AFraB2Sec3 = new TGeoVolume("V0AFraB2Sec3",sV0AFraB2Sec3,medV0AFra);
1189     v0AFraB1Sec3->SetLineColor(kV0AColorFra); v0AFraB2Sec3->SetLineColor(kV0AColorFra);
1190     v0AFraSec3->AddNode(v0AFraB1Sec3,1);
1191     v0AFraSec3->AddNode(v0AFraB2Sec3,1);  
1192     new TGeoTubeSeg( "sV0AFraR1bSec3", fV0AR0-fV0AFraWd/2.,
1193                      fV0AR0+fV0AFraWd/2., fV0ASciWd/2., 0, 45);
1194     new TGeoTubeSeg( "sV0AFraR2bSec3", fV0AR1-fV0AFraWd/2.,
1195                      fV0AR1+fV0AFraWd/2., fV0ASciWd/2., 0, 45);
1196     new TGeoTubeSeg( "sV0AFraR3bSec3", fV0AR2-fV0AFraWd/2.,
1197                      fV0AR2+fV0AFraWd/2., fV0ASciWd/2., 0, 45);
1198     new TGeoTubeSeg( "sV0AFraR4bSec3", fV0AR3-fV0AFraWd/2.,
1199                      fV0AR3+fV0AFraWd/2., fV0ASciWd/2., 0, 45);
1200     new TGeoTubeSeg( "sV0AFraR5bSec3", fV0AR4-fV0AFraWd/2.,
1201                      fV0AR4+fV0AFraWd/2., fV0ASciWd/2., 0, 45);
1202     TGeoCompositeShape *sV0AFraR1Sec3 = new TGeoCompositeShape("sV0AFraR1Sec3","sV0AFraR1bSec3-sV0AChaSec3");
1203     TGeoCompositeShape *sV0AFraR2Sec3 = new TGeoCompositeShape("sV0AFraR2Sec3","sV0AFraR2bSec3-sV0AChaSec3");
1204     TGeoCompositeShape *sV0AFraR3Sec3 = new TGeoCompositeShape("sV0AFraR3Sec3","sV0AFraR3bSec3-sV0AChaSec3");
1205     TGeoCompositeShape *sV0AFraR4Sec3 = new TGeoCompositeShape("sV0AFraR4Sec3","sV0AFraR4bSec3-sV0AChaSec3");
1206     TGeoCompositeShape *sV0AFraR5Sec3 = new TGeoCompositeShape("sV0AFraR5Sec3","sV0AFraR5bSec3-sV0AChaSec3");
1207     TGeoVolume *v0AFraR1Sec3 = new TGeoVolume("V0AFraR1Sec3",sV0AFraR1Sec3,medV0AFra);
1208     TGeoVolume *v0AFraR2Sec3 = new TGeoVolume("V0AFraR2Sec3",sV0AFraR2Sec3,medV0AFra);
1209     TGeoVolume *v0AFraR3Sec3 = new TGeoVolume("V0AFraR3Sec3",sV0AFraR3Sec3,medV0AFra);
1210     TGeoVolume *v0AFraR4Sec3 = new TGeoVolume("V0AFraR4Sec3",sV0AFraR4Sec3,medV0AFra);
1211     TGeoVolume *v0AFraR5Sec3 = new TGeoVolume("V0AFraR5Sec3",sV0AFraR5Sec3,medV0AFra);
1212     v0AFraR1Sec3->SetLineColor(kV0AColorFra); v0AFraR2Sec3->SetLineColor(kV0AColorFra);
1213     v0AFraR3Sec3->SetLineColor(kV0AColorFra); v0AFraR4Sec3->SetLineColor(kV0AColorFra);
1214     v0AFraR5Sec3->SetLineColor(kV0AColorFra);
1215     v0AFraSec3->AddNode(v0AFraR1Sec3,1); 
1216     v0AFraSec3->AddNode(v0AFraR2Sec3,1);
1217     v0AFraSec3->AddNode(v0AFraR3Sec3,1); 
1218     v0AFraSec3->AddNode(v0AFraR4Sec3,1);
1219     v0AFraSec3->AddNode(v0AFraR5Sec3,1);
1220     v0ASec3->AddNode(v0AFraSec3,1);
1221     
1222     /// Sensitive scintilator
1223     TGeoVolume *v0ASciSec3 = new TGeoVolumeAssembly("V0ASciSec3");
1224     new TGeoTubeSeg( "sV0AR1bSec3", fV0AR0+fV0AFraWd/2.,
1225                      fV0AR1-fV0AFraWd/2., fV0ASciWd/2., 0, 45);
1226     new TGeoTubeSeg( "sV0AR2bSec3", fV0AR1+fV0AFraWd/2.,
1227                      fV0AR2-fV0AFraWd/2., fV0ASciWd/2., 0, 45);
1228     new TGeoTubeSeg( "sV0AR3bSec3", fV0AR2+fV0AFraWd/2.,
1229                      fV0AR3-fV0AFraWd/2., fV0ASciWd/2., 0, 45);
1230     new TGeoTubeSeg( "sV0AR4bSec3", fV0AR3+fV0AFraWd/2.,
1231                      fV0AR4-fV0AFraWd/2., fV0ASciWd/2., 0, 45);
1232     TGeoCompositeShape *sV0AR1Sec3 = new TGeoCompositeShape("sV0AR1Sec3","sV0AR1bSec3-sV0AChaSec3");
1233     TGeoCompositeShape *sV0AR2Sec3 = new TGeoCompositeShape("sV0AR2Sec3","sV0AR2bSec3-sV0AChaSec3");
1234     TGeoCompositeShape *sV0AR3Sec3 = new TGeoCompositeShape("sV0AR3Sec3","sV0AR3bSec3-sV0AChaSec3");
1235     TGeoCompositeShape *sV0AR4Sec3 = new TGeoCompositeShape("sV0AR4Sec3","sV0AR4bSec3-sV0AChaSec3");
1236     TGeoVolume *v0L1Sec3 = new TGeoVolume("V0L1Sec3",sV0AR1Sec3,medV0ASci);
1237     TGeoVolume *v0L2Sec3 = new TGeoVolume("V0L2Sec3",sV0AR2Sec3,medV0ASci);
1238     TGeoVolume *v0L3Sec3 = new TGeoVolume("V0L3Sec3",sV0AR3Sec3,medV0ASci);
1239     TGeoVolume *v0L4Sec3 = new TGeoVolume("V0L4Sec3",sV0AR4Sec3,medV0ASci);
1240     v0L1Sec3->SetLineColor(kV0AColorSci); v0L2Sec3->SetLineColor(kV0AColorSci);
1241     v0L3Sec3->SetLineColor(kV0AColorSci); v0L4Sec3->SetLineColor(kV0AColorSci);
1242     v0ASec3->AddNode(v0L1Sec3,1);
1243     v0ASec3->AddNode(v0L2Sec3,1);
1244     v0ASec3->AddNode(v0L3Sec3,1);
1245     v0ASec3->AddNode(v0L4Sec3,1);      
1246     
1247     /// Segment of octagon 
1248     for (int i=0;i<2;i++) {
1249     v0APts[0+8*i] =  fV0AR6-fV0AOctH2;           v0APts[1+8*i] = 0.;
1250       v0APts[2+8*i] = (fV0AR6-fV0AOctH2)*sin45;  v0APts[3+8*i] = (fV0AR6-fV0AOctH2)*sin45;
1251       v0APts[4+8*i] = fV0AR6*sin45;              v0APts[5+8*i] = fV0AR6*sin45;
1252       v0APts[6+8*i] = fV0AR6;                    v0APts[7+8*i] = 0.;
1253     }
1254     new TGeoArb8("sV0AOct2Sec3", (fV0ASciWd+2*fV0AOctWd)/2., v0APts);
1255     TGeoCompositeShape *sV0AOct2FEEBSec3 = new TGeoCompositeShape("sV0AOct2FEEBSec3","sV0AOct2Sec3-sV0AFicOct2Sec3:posFicOct2UpSec3-sV0AFicFEEBSec3:posFicFEEBSec3");
1256     TGeoVolume *v0AOct2Sec3 = new TGeoVolume("V0AOct2Sec3", sV0AOct2FEEBSec3,medV0ASup);
1257     v0AOct2Sec3->SetLineColor(kV0AColorOct);
1258     TGeoVolume *v0ASupSec3 = new TGeoVolumeAssembly("V0ASupSec3");
1259     v0ASupSec3->AddNode(v0AOct2Sec3,1);
1260     v0ASec3->AddNode(v0ASupSec3,1);
1261
1262     //Bunch of fibers
1263     v0APts[ 0] = v0APts[ 2] = -13.0;
1264     v0APts[ 1] = v0APts[ 7] = (fV0ASciWd+fV0AOctWd)/2.-0.01;
1265     v0APts[ 3] = v0APts[ 5] = (fV0ASciWd+fV0AOctWd)/2.+0.01;
1266     v0APts[ 4] = v0APts[ 6] = +13.0;
1267     v0APts[ 8] = v0APts[10] = -10.0;
1268     v0APts[ 9] = v0APts[15] = 0.;
1269     v0APts[11] = v0APts[13] = 0.25;
1270     v0APts[12] = v0APts[14] = +10.0;
1271     new TGeoArb8("sV0AFib1Sec3", 11.5, v0APts);
1272     rot = new TGeoRotation("rot");
1273     rot->RotateX(-90);
1274     rot->RotateZ(-90.+22.5);
1275     TGeoCombiTrans *fibpos1Sec3 = new TGeoCombiTrans("fibpos1Sec3", (fV0AR6-fV0AOctH2+fV0AR5)*cos225/2. - 3.8, (fV0AR6-fV0AOctH2+fV0AR5)*sin225/2.-1.8, 0, rot);
1276     fibpos1Sec3->RegisterYourself();
1277     TGeoCompositeShape *sV0AFib1HoleSec3 = new TGeoCompositeShape("sV0AFib1HoleSec3","sV0AFib1Sec3:fibpos1Sec3-sV0AFicR5Sec3"); 
1278     TGeoVolume *v0AFib1HoleSec3 = new TGeoVolume("V0AFib1HoleSec3",sV0AFib1HoleSec3,medV0AFib);
1279     v0AFib1HoleSec3->SetLineColor(kV0AColorFib);
1280     new TGeoArb8("sV0AFib2Sec3", 11.5, v0APts);
1281     rot = new TGeoRotation("rot");
1282     rot->RotateX(-90);
1283     rot->RotateY(180);
1284     rot->RotateZ(-90.+22.5);
1285     TGeoCombiTrans *fibpos2Sec3 = new TGeoCombiTrans("fibpos2Sec3", (fV0AR6-fV0AOctH2+fV0AR5)*cos225/2. - 3.8, (fV0AR6-fV0AOctH2+fV0AR5)*sin225/2.-1.8, 0, rot);
1286     fibpos2Sec3->RegisterYourself();
1287     TGeoCompositeShape *sV0AFib2HoleSec3 = new TGeoCompositeShape("sV0AFib2HoleSec3","sV0AFib2Sec3:fibpos2Sec3-sV0AFicR5Sec3");
1288     TGeoVolume *v0AFib2HoleSec3 = new TGeoVolume("V0AFib2HoleSec3",sV0AFib2HoleSec3,medV0AFib);
1289     v0AFib2HoleSec3->SetLineColor(kV0AColorFib);
1290     TGeoVolume *v0AFibSec3 = new TGeoVolumeAssembly("V0AFibSec3");
1291     v0AFibSec3->AddNode(v0AFib1HoleSec3,1);
1292     v0AFibSec3->AddNode(v0AFib2HoleSec3,1);
1293     v0ASec3->AddNode(v0AFibSec3,1); 
1294     
1295      /// Plates
1296     new TGeoTube("sV0ANail1PlaInHoleSec3", 0.0, 0.4, (fV0APlaWd-2*fV0APlaAl)/2.);
1297     new TGeoTube("sV0ANail2PlaInHoleSec3", 0.0, 0.4, (fV0APlaWd-2*fV0APlaAl)/2.);
1298     new TGeoCompositeShape("sV0ANailsPlaInHolesSec3","sV0ANail1PlaInHoleSec3:pos1Sec3+sV0ANail2PlaInHoleSec3:pos2Sec3");
1299     new TGeoTube("sV0ANail1PlaOuHoleSec3", 0.0, 0.4, (fV0APlaAl)/2.);
1300     new TGeoTube("sV0ANail2PlaOuHoleSec3", 0.0, 0.4, (fV0APlaAl)/2.);
1301     new TGeoCompositeShape("sV0ANailsPlaOuHolesSec3","sV0ANail1PlaOuHoleSec3:pos1Sec3+sV0ANail2PlaOuHoleSec3:pos2Sec3");
1302     for (int i=0;i<2;i++) {
1303       v0APts[0+8*i] = fV0AR0;                   v0APts[1+8*i] = 0.;
1304       v0APts[2+8*i] = fV0AR0*sin45;             v0APts[3+8*i] = fV0AR0*sin45;
1305       v0APts[4+8*i] = fV0AR6 * sin45;   v0APts[5+8*i] = fV0AR6*sin45;
1306       v0APts[6+8*i] = fV0AR6;           v0APts[7+8*i] = 0.;
1307     }
1308     new TGeoArb8("sV0APlaInSec3", (fV0APlaWd-2*fV0APlaAl)/2., v0APts);
1309     TGeoCompositeShape *sV0APlaInNailsHolesSec3 = new TGeoCompositeShape("sV0APlaInNailsHolesSec3","sV0APlaInSec3-sV0ANailsPlaInHolesSec3-sV0AFicFEEBSec3:posFicFEEBSec3");
1310     TGeoVolume *v0APlaInNailsHolesSec3 = new TGeoVolume("V0APlaInNailsHolesSec3", sV0APlaInNailsHolesSec3, medV0APlaIn);
1311     new TGeoArb8("sV0APlaOuSec3", fV0APlaAl/2., v0APts);
1312     TGeoCompositeShape *sV0APlaOuNailsHolesSec3 = new TGeoCompositeShape("sV0APlaOuNailsHolesSec3","sV0APlaOuSec3-sV0ANailsPlaOuHolesSec3-sV0AFicFEEBSec3:posFicFEEBSec3"); 
1313     TGeoVolume *v0APlaOuNailsHolesSec3 = new TGeoVolume("V0APlaOuNailsHolesSec3", sV0APlaOuNailsHolesSec3, medV0APlaOu);
1314     v0APlaInNailsHolesSec3->SetLineColor(kV0AColorPlaIn); v0APlaOuNailsHolesSec3->SetLineColor(kV0AColorPlaOu);
1315     TGeoVolume *v0APlaSec3 = new TGeoVolumeAssembly("V0APlaSec3");
1316     v0APlaSec3->AddNode(v0APlaInNailsHolesSec3,1);
1317     v0APlaSec3->AddNode(v0APlaOuNailsHolesSec3,1,new TGeoTranslation(0,0,(fV0APlaWd-fV0APlaAl)/2.));
1318     v0APlaSec3->AddNode(v0APlaOuNailsHolesSec3,2,new TGeoTranslation(0,0,-(fV0APlaWd-fV0APlaAl)/2.));
1319     v0ASec3->AddNode(v0APlaSec3,1,new TGeoTranslation(0,0,(fV0ASciWd+2*fV0AOctWd+fV0APlaWd)/2.));
1320     v0ASec3->AddNode(v0APlaSec3,2,new TGeoTranslation(0,0,-(fV0ASciWd+2*fV0AOctWd+fV0APlaWd)/2.));
1321     
1322      /// Non-sensitive scintilator
1323     new TGeoTubeSeg("sV0AR5S2Sec3", fV0AR4+fV0AFraWd/2., fV0AR4 + fV0AR0, fV0ASciWd/2.+2*preShapeSec3, 0, 45);
1324     TGeoCompositeShape *sV0AR5Sec3 = new TGeoCompositeShape("V0AR5Sec3","sV0AR5S2Sec3 - sV0AChaSec3");
1325     TGeoVolume *v0AR5Sec3 = new TGeoVolume("V0AR5Sec3",sV0AR5Sec3,medV0ASci);
1326     v0AR5Sec3->SetLineColor(kV0AColorSci);
1327     v0ASciSec3->AddNode(v0AR5Sec3,1);
1328     v0ASec3->AddNode(v0ASciSec3,1); 
1329
1330     /// PMBox
1331     TGeoVolume* v0APMSec3 = new TGeoVolumeAssembly("V0APMSec3");
1332     new TGeoBBox("sV0APMB1Sec3", fV0APMBWd/2., fV0APMBHt/2., fV0APMBTh/2.);
1333     new TGeoBBox("sV0APMB2Sec3", fV0APMBWd/2.-fV0APMBWdW, fV0APMBHt/2.-fV0APMBHtW, fV0APMBTh/2.-fV0APMBThW);
1334     TGeoCompositeShape *sV0APMBSec3 = new TGeoCompositeShape("sV0APMBSec3","sV0APMB1Sec3-sV0APMB2Sec3");
1335     TGeoVolume *v0APMBSec3 = new TGeoVolume("V0APMBSec3",sV0APMBSec3, medV0APMAlum);
1336     v0APMBSec3->SetLineColor(kV0AColorPMA);
1337     v0APMSec3->AddNode(v0APMBSec3,1);
1338
1339     /// PMTubes
1340     TGeoTube *sV0APMT1Sec3 = new TGeoTube("sV0APMT1Sec3", fV0APMTR1, fV0APMTR2, fV0APMTH/2.);
1341     TGeoVolume *v0APMT1Sec3 = new TGeoVolume("V0APMT1Sec3", sV0APMT1Sec3, medV0APMGlass);
1342     TGeoTube *sV0APMT2Sec3 = new TGeoTube("sV0APMT2Sec3", fV0APMTR3, fV0APMTR4, fV0APMTH/2.);
1343     TGeoVolume *v0APMT2Sec3 = new TGeoVolume("V0APMT2Sec3", sV0APMT2Sec3, medV0APMAlum);
1344     TGeoVolume *v0APMTSec3 = new TGeoVolumeAssembly("V0APMTSec3");
1345     TGeoTube *sV0APMTTSec3 = new TGeoTube("sV0APMTTSec3", 0., fV0APMTR4, fV0APMTB/2.);
1346     TGeoVolume *v0APMTTSec3 = new TGeoVolume("V0APMTTSec3", sV0APMTTSec3, medV0APMAlum);
1347     v0APMT1Sec3->SetLineColor(kV0AColorPMG);
1348     v0APMT2Sec3->SetLineColor(kV0AColorPMA);
1349     v0APMTTSec3->SetLineColor(kV0AColorPMA);
1350     rot = new TGeoRotation("rot", 90, 0, 180, 0, 90, 90);
1351     v0APMTSec3->AddNode(v0APMT1Sec3,1,rot);
1352     v0APMTSec3->AddNode(v0APMT2Sec3,1,rot);
1353     v0APMTSec3->AddNode(v0APMTTSec3,1,new TGeoCombiTrans(0,-(fV0APMTH+fV0APMTB)/2.,0,rot));
1354     double autoShiftSec3 = (fV0APMBWd-2*fV0APMBWdW)/4.;
1355     v0APMSec3->AddNode(v0APMTSec3, 1, new TGeoTranslation(-1.5*autoShiftSec3, 0, 0));
1356     v0APMSec3->AddNode(v0APMTSec3, 2, new TGeoTranslation(-0.5*autoShiftSec3, 0, 0));
1357     v0APMSec3->AddNode(v0APMTSec3, 3, new TGeoTranslation(+0.5*autoShiftSec3, 0, 0));
1358     v0APMSec3->AddNode(v0APMTSec3, 4, new TGeoTranslation(+1.5*autoShiftSec3, 0, 0));
1359
1360     // PM
1361     rot = new TGeoRotation("rot");
1362     rot->RotateX(90-fV0APMBAng);
1363     rot->RotateZ(-90.+22.5);
1364     double cosAngPMBSec3 = TMath::Cos(fV0APMBAng*TMath::DegToRad());
1365     double sinAngPMBSec3 = TMath::Sin(fV0APMBAng*TMath::DegToRad());
1366     double shiftZSec3 = fV0APMBHt/2. * cosAngPMBSec3
1367       -   ( fV0ASciWd + 2 * fV0AOctWd + 2 * fV0APlaWd )/2.   -   fV0APMBTh/2. * sinAngPMBSec3;
1368     double shiftRSec3 = fV0AR6  +  fV0AOctH2 + fV0APlaAl;
1369     v0ASec3->AddNode(v0APMSec3,1, new TGeoCombiTrans( shiftRSec3*cos225+1.07, shiftRSec3*sin225, shiftZSec3, rot));
1370     
1371     // Aluminium nails 
1372     TGeoTube *sV0ANail1Sec3 = new TGeoTube("sV0ANail1Sec3", 0.0, 0.4, 5.09/2.);
1373     TGeoVolume *v0ANail1Sec3 = new TGeoVolume("V0ANail1Sec3", sV0ANail1Sec3, medV0APMAlum);
1374     v0ANail1Sec3->SetLineColor(kV0AColorPMA);// this is the color for aluminium
1375     v0ASec3->AddNode(v0ANail1Sec3,1,new TGeoTranslation(42.9, 0.51, 0.0));
1376     TGeoTube *sV0ANail2Sec3 = new TGeoTube("sV0ANail2Sec3", 0.0, 0.4, 5.09/2.);
1377     TGeoVolume *v0ANail2Sec3 = new TGeoVolume("V0ANail2Sec3", sV0ANail2Sec3, medV0APMAlum);
1378     v0ANail2Sec3->SetLineColor(kV0AColorPMA);
1379     v0ASec3->AddNode(v0ANail2Sec3,1,new TGeoTranslation(30.73,29.98,0.0)); 
1380         
1381     /// Adding sector to v0LE volume
1382     for(int i=2; i<3; i++) {
1383        TGeoRotation *rotation = new TGeoRotation("rotation", 90., i*45., 90., 90.+i*45., 0., 0.);
1384        v0LE->AddNode(v0ASec3,i+1,rotation);  
1385     }
1386
1387     //FEEBox
1388     TGeoVolume* v0AFEE3 = new TGeoVolumeAssembly("V0AFEE3");
1389     v0AFEE3->AddNode(v0AFEEB,1);
1390
1391     //Mother and daughter boards
1392     v0AFEE3->AddNode(v0AFEEDaughter, 1, new TGeoTranslation(9.0*spacing, fV0AFEEBTh/2.+2.0*fV0APMTB, fV0APMBHtW/2.));
1393     v0AFEE3->AddNode(v0AFEEDaughter, 2, new TGeoTranslation(6.0*spacing, fV0AFEEBTh/2.+2.0*fV0APMTB, fV0APMBHtW/2.));
1394     v0AFEE3->AddNode(v0AFEEDaughter, 3, new TGeoTranslation(3.0*spacing, fV0AFEEBTh/2.+2.0*fV0APMTB, fV0APMBHtW/2.));
1395     v0AFEE3->AddNode(v0AFEEDaughter, 4, new TGeoTranslation(0.0*spacing, fV0AFEEBTh/2.+2.0*fV0APMTB, fV0APMBHtW/2.));
1396     v0AFEE3->AddNode(v0AFEEDaughter, 5, new TGeoTranslation(-3.0*spacing, fV0AFEEBTh/2.+2.0*fV0APMTB, fV0APMBHtW/2.));
1397     v0AFEE3->AddNode(v0AFEEDaughter, 6, new TGeoTranslation(-6.0*spacing, fV0AFEEBTh/2.+2.0*fV0APMTB, fV0APMBHtW/2.));
1398     v0AFEE3->AddNode(v0AFEEDaughter, 7, new TGeoTranslation(-9.0*spacing, fV0AFEEBTh/2.+2.0*fV0APMTB, fV0APMBHtW/2.));
1399     v0AFEE3->AddNode(v0AFEEDaughter, 8, new TGeoTranslation(-12.0*spacing, fV0AFEEBTh/2.+2.0*fV0APMTB, fV0APMBHtW/2.));   
1400     v0AFEE3->AddNode(v0AFEEMother, 1, new TGeoTranslation(0.0, 0.0, -fV0AFEEBTh/2.+fV0APMBThW+fV0APMBHtW));
1401     v0AFEE3->AddNode(v0AFEEHalfMother, 1, new TGeoTranslation(0.0, -(fV0AFEEBTh+fV0APMTB)/2., -2.0*spacing));
1402
1403     //FEE
1404     rot = new TGeoRotation("rot");
1405     rot->RotateX(90);
1406     rot->RotateZ(-90.0+45.0-90);
1407     v0LE->AddNode(v0AFEE3,1, new TGeoCombiTrans( -(aFEEshiftR2Sec1*cos225 + 2.0)*cos45, (aFEEshiftR2Sec1*cos225 + 2.0)*sin45, 7.5, rot) );
1408     rot = new TGeoRotation("rot");
1409     rot->RotateZ(+90.0-45.0-90.0);
1410     v0LE->AddNode(v0AFEEOct2,3, new TGeoCombiTrans(-((aFEEshiftR2Sec1*cos225 + 2.0) - fV0AFEEBTh/2. - 1.0)*cos45,((aFEEshiftR2Sec1*cos225 + 2.0) - fV0AFEEBTh/2. - 1.0)*sin45,0.0,rot)); 
1411
1412
1413     /// Definition sector 4
1414     TGeoVolume *v0ASec4 = new TGeoVolumeAssembly("V0ASec4");
1415         
1416     /// For boolean sustraction
1417     double preShapeSec4 = 0.2;
1418     for (int i=0;i<2;i++) {
1419       v0APts[0+8*i] = fV0AR0-fV0AFraWd/2.-preShapeSec4;  v0APts[1+8*i] = -preShapeSec4;
1420       v0APts[2+8*i] = fV0AR0-fV0AFraWd/2.-preShapeSec4;  v0APts[3+8*i] = fV0AFraWd/2.;
1421       v0APts[4+8*i] = fV0AR4+fV0AFraWd/2.+preShapeSec4;  v0APts[5+8*i] = fV0AFraWd/2.;
1422       v0APts[6+8*i] = fV0AR4+fV0AFraWd/2.+preShapeSec4;  v0APts[7+8*i] = -preShapeSec4;
1423     }
1424     new TGeoArb8("sV0ACha1Sec4",fV0ASciWd/1.5,v0APts);
1425     for (int i=0;i<2;i++) {
1426       v0APts[0+8*i] = fV0AR0*sin45-preShapeSec4;
1427       v0APts[1+8*i] = (fV0AR0-fV0AFraWd)*sin45-preShapeSec4;
1428       v0APts[2+8*i] = (fV0AR0-fV0AFraWd/2.)*sin45-preShapeSec4;
1429       v0APts[3+8*i] = (fV0AR0-fV0AFraWd/2.)*sin45;
1430       v0APts[4+8*i] = (fV0AR4+fV0AFraWd/2.)*sin45+preShapeSec4;
1431       v0APts[5+8*i] = (fV0AR4+fV0AFraWd/2.)*sin45+2.*preShapeSec4;
1432       v0APts[6+8*i] = (fV0AR4+fV0AFraWd)*sin45+preShapeSec4;
1433       v0APts[7+8*i] = fV0AR4*sin45+preShapeSec4;
1434     }
1435     new TGeoArb8("sV0ACha2Sec4", fV0ASciWd/2.+2.*preShapeSec4, v0APts);
1436     new TGeoCompositeShape("sV0ACha12Sec4","sV0ACha1Sec4+sV0ACha2Sec4");
1437     new TGeoTube("sV0ANail1SciHoleSec4", 0.0, 0.4, 1.65);
1438     TGeoTranslation *pos1Sec4 = new TGeoTranslation("pos1Sec4", 42.9, 0.51, 0.0);
1439     pos1Sec4->RegisterYourself();
1440     new TGeoTube("sV0ANail2SciHoleSec4", 0.0, 0.4, 1.65);
1441     TGeoTranslation *pos2Sec4 = new TGeoTranslation("pos2Sec4", 30.73,29.98,0.0);
1442     pos2Sec4->RegisterYourself();
1443     new TGeoCompositeShape("sV0ANailsSciHolesSec4","sV0ANail1SciHoleSec4:pos1Sec4+sV0ANail2SciHoleSec4:pos2Sec4");
1444     new TGeoCompositeShape("sV0AChaSec4","sV0ACha12Sec4+sV0ANailsSciHolesSec4");
1445     new TGeoTubeSeg("sV0AFicR5Sec4", fV0AR4+fV0AFraWd/2., fV0AR4 + fV0AR0, fV0ASciWd/2.+2*preShapeSec4, 0, 45);
1446     new TGeoBBox("sV0AFicFEEBSec4", fV0AFEEBWd/2., fV0AFEEBHt/2., fV0AFEEBTh/2.);
1447     rot = new TGeoRotation("rot");
1448     rot->RotateX(90);
1449     rot->RotateZ(-90.0);
1450     double aFEEshiftR2Sec4 = fV0AR6  +  fV0AOctH2 + fV0APlaAl;
1451     TGeoCombiTrans *posFicFEEBSec4 = new TGeoCombiTrans("posFicFEEBSec4", aFEEshiftR2Sec4*cos225 + 2.0, 0, 7.5, rot);
1452     posFicFEEBSec4->RegisterYourself();
1453     rot = new TGeoRotation("rot");
1454     rot->RotateX(90);
1455     rot->RotateZ(-90.0+45.0);
1456     TGeoCombiTrans *posFicFEEBUpSec4 = new TGeoCombiTrans("posFicFEEBUpSec4", (aFEEshiftR2Sec4*cos225 + 2.0 )*cos45, (aFEEshiftR2Sec4*cos225 + 2.0 )*sin45, 7.5, rot);
1457     posFicFEEBUpSec4->RegisterYourself();
1458     for (int i=0;i<2;i++) {
1459     v0APts[0+8*i] = fV0AOctH2/2.;              v0APts[1+8*i] = fV0AFEEBHt/2. + 2.5;
1460     v0APts[2+8*i] = fV0AOctH2/2.;              v0APts[3+8*i] = -fV0AFEEBHt/2.- 2.5;
1461     v0APts[4+8*i] = -fV0AOctH2/2.;             v0APts[5+8*i] = -fV0AFEEBHt/2.- 2.5;
1462     v0APts[6+8*i] = -fV0AOctH2/2.;             v0APts[7+8*i] = fV0AFEEBHt/2.+ 2.5;
1463     }
1464     new TGeoArb8("sV0AFicOct2Sec4", (fV0ASciWd+2*fV0AOctWd)/2., v0APts);
1465     TGeoTranslation *posFicOct2Sec4 = new TGeoTranslation("posFicOct2Sec4",(aFEEshiftR2Sec4*cos225 + 2.0) - fV0AFEEBTh/2. - 1.0,0.0,0.0);
1466     posFicOct2Sec4->RegisterYourself();  
1467     rot = new TGeoRotation("rot");
1468     rot->RotateZ(-90.0+45.0+90.0);
1469     TGeoCombiTrans *posFicOct2UpSec4 = new TGeoCombiTrans("posFicOct2UpSec4",((aFEEshiftR2Sec4*cos225 + 2.0) - fV0AFEEBTh/2. - 1.0)*cos45,((aFEEshiftR2Sec4*cos225 + 2.0) - fV0AFEEBTh/2. - 1.0)*sin45,0.0,rot);
1470     posFicOct2UpSec4->RegisterYourself(); 
1471
1472     /// Frame
1473     TGeoVolume *v0AFraSec4 = new TGeoVolumeAssembly("V0AFraSec4");
1474     for (int i=0;i<2;i++) {
1475       v0APts[0+8*i] = fV0AR0-fV0AFraWd/2.;  v0APts[1+8*i] = 0.;
1476       v0APts[2+8*i] = fV0AR0-fV0AFraWd/2.;  v0APts[3+8*i] = fV0AFraWd/2.;
1477       v0APts[4+8*i] = fV0AR4+fV0AFraWd/2.;  v0APts[5+8*i] = fV0AFraWd/2.;
1478       v0APts[6+8*i] = fV0AR4+fV0AFraWd/2.;  v0APts[7+8*i] = 0.;
1479     }
1480     TGeoArb8 *sV0AFraB1Sec4 = new TGeoArb8("sV0AFraB1Sec4",fV0ASciWd/2.,v0APts);
1481     TGeoVolume *v0AFraB1Sec4 = new TGeoVolume("V0AFraB1Sec4",sV0AFraB1Sec4,medV0AFra);
1482     for (int i=0;i<2;i++) {
1483       v0APts[0+8*i] = fV0AR0*sin45;
1484       v0APts[1+8*i] = (fV0AR0-fV0AFraWd)*sin45;
1485       v0APts[2+8*i] = (fV0AR0-fV0AFraWd/2.)*sin45;
1486       v0APts[3+8*i] = (fV0AR0-fV0AFraWd/2.)*sin45;
1487       v0APts[4+8*i] = (fV0AR4+fV0AFraWd/2.)*sin45;
1488       v0APts[5+8*i] = (fV0AR4+fV0AFraWd/2.)*sin45;
1489       v0APts[6+8*i] = (fV0AR4+fV0AFraWd)*sin45;
1490       v0APts[7+8*i] = fV0AR4*sin45;
1491     }
1492     TGeoArb8 *sV0AFraB2Sec4 = new TGeoArb8("sV0AFraB2Sec4", fV0ASciWd/2., v0APts);
1493     TGeoVolume *v0AFraB2Sec4 = new TGeoVolume("V0AFraB2Sec4",sV0AFraB2Sec4,medV0AFra);
1494     v0AFraB1Sec4->SetLineColor(kV0AColorFra); v0AFraB2Sec4->SetLineColor(kV0AColorFra);
1495     v0AFraSec4->AddNode(v0AFraB1Sec4,1);
1496     v0AFraSec4->AddNode(v0AFraB2Sec4,1);  
1497     new TGeoTubeSeg( "sV0AFraR1bSec4", fV0AR0-fV0AFraWd/2.,
1498                      fV0AR0+fV0AFraWd/2., fV0ASciWd/2., 0, 45);
1499     new TGeoTubeSeg( "sV0AFraR2bSec4", fV0AR1-fV0AFraWd/2.,
1500                      fV0AR1+fV0AFraWd/2., fV0ASciWd/2., 0, 45);
1501     new TGeoTubeSeg( "sV0AFraR3bSec4", fV0AR2-fV0AFraWd/2.,
1502                      fV0AR2+fV0AFraWd/2., fV0ASciWd/2., 0, 45);
1503     new TGeoTubeSeg( "sV0AFraR4bSec4", fV0AR3-fV0AFraWd/2.,
1504                      fV0AR3+fV0AFraWd/2., fV0ASciWd/2., 0, 45);
1505     new TGeoTubeSeg( "sV0AFraR5bSec4", fV0AR4-fV0AFraWd/2.,
1506                      fV0AR4+fV0AFraWd/2., fV0ASciWd/2., 0, 45);
1507     TGeoCompositeShape *sV0AFraR1Sec4 = new TGeoCompositeShape("sV0AFraR1Sec4","sV0AFraR1bSec4-sV0AChaSec4");
1508     TGeoCompositeShape *sV0AFraR2Sec4 = new TGeoCompositeShape("sV0AFraR2Sec4","sV0AFraR2bSec4-sV0AChaSec4");
1509     TGeoCompositeShape *sV0AFraR3Sec4 = new TGeoCompositeShape("sV0AFraR3Sec4","sV0AFraR3bSec4-sV0AChaSec4");
1510     TGeoCompositeShape *sV0AFraR4Sec4 = new TGeoCompositeShape("sV0AFraR4Sec4","sV0AFraR4bSec4-sV0AChaSec4");
1511     TGeoCompositeShape *sV0AFraR5Sec4 = new TGeoCompositeShape("sV0AFraR5Sec4","sV0AFraR5bSec4-sV0AChaSec4");
1512     TGeoVolume *v0AFraR1Sec4 = new TGeoVolume("V0AFraR1Sec4",sV0AFraR1Sec4,medV0AFra);
1513     TGeoVolume *v0AFraR2Sec4 = new TGeoVolume("V0AFraR2Sec4",sV0AFraR2Sec4,medV0AFra);
1514     TGeoVolume *v0AFraR3Sec4 = new TGeoVolume("V0AFraR3Sec4",sV0AFraR3Sec4,medV0AFra);
1515     TGeoVolume *v0AFraR4Sec4 = new TGeoVolume("V0AFraR4Sec4",sV0AFraR4Sec4,medV0AFra);
1516     TGeoVolume *v0AFraR5Sec4 = new TGeoVolume("V0AFraR5Sec4",sV0AFraR5Sec4,medV0AFra);
1517     v0AFraR1Sec4->SetLineColor(kV0AColorFra); v0AFraR2Sec4->SetLineColor(kV0AColorFra);
1518     v0AFraR3Sec4->SetLineColor(kV0AColorFra); v0AFraR4Sec4->SetLineColor(kV0AColorFra);
1519     v0AFraR5Sec4->SetLineColor(kV0AColorFra);
1520     v0AFraSec4->AddNode(v0AFraR1Sec4,1); 
1521     v0AFraSec4->AddNode(v0AFraR2Sec4,1);
1522     v0AFraSec4->AddNode(v0AFraR3Sec4,1); 
1523     v0AFraSec4->AddNode(v0AFraR4Sec4,1);
1524     v0AFraSec4->AddNode(v0AFraR5Sec4,1);
1525     v0ASec4->AddNode(v0AFraSec4,1);
1526     
1527     /// Sensitive scintilator
1528     TGeoVolume *v0ASciSec4 = new TGeoVolumeAssembly("V0ASciSec4");
1529     new TGeoTubeSeg( "sV0AR1bSec4", fV0AR0+fV0AFraWd/2.,
1530                      fV0AR1-fV0AFraWd/2., fV0ASciWd/2., 0, 45);
1531     new TGeoTubeSeg( "sV0AR2bSec4", fV0AR1+fV0AFraWd/2.,
1532                      fV0AR2-fV0AFraWd/2., fV0ASciWd/2., 0, 45);
1533     new TGeoTubeSeg( "sV0AR3bSec4", fV0AR2+fV0AFraWd/2.,
1534                      fV0AR3-fV0AFraWd/2., fV0ASciWd/2., 0, 45);
1535     new TGeoTubeSeg( "sV0AR4bSec4", fV0AR3+fV0AFraWd/2.,
1536                      fV0AR4-fV0AFraWd/2., fV0ASciWd/2., 0, 45);
1537     TGeoCompositeShape *sV0AR1Sec4 = new TGeoCompositeShape("sV0AR1Sec4","sV0AR1bSec4-sV0AChaSec4");
1538     TGeoCompositeShape *sV0AR2Sec4 = new TGeoCompositeShape("sV0AR2Sec4","sV0AR2bSec4-sV0AChaSec4");
1539     TGeoCompositeShape *sV0AR3Sec4 = new TGeoCompositeShape("sV0AR3Sec4","sV0AR3bSec4-sV0AChaSec4");
1540     TGeoCompositeShape *sV0AR4Sec4 = new TGeoCompositeShape("sV0AR4Sec4","sV0AR4bSec4-sV0AChaSec4");
1541     TGeoVolume *v0L1Sec4 = new TGeoVolume("V0L1Sec4",sV0AR1Sec4,medV0ASci);
1542     TGeoVolume *v0L2Sec4 = new TGeoVolume("V0L2Sec4",sV0AR2Sec4,medV0ASci);
1543     TGeoVolume *v0L3Sec4 = new TGeoVolume("V0L3Sec4",sV0AR3Sec4,medV0ASci);
1544     TGeoVolume *v0L4Sec4 = new TGeoVolume("V0L4Sec4",sV0AR4Sec4,medV0ASci);
1545     v0L1Sec4->SetLineColor(kV0AColorSci); v0L2Sec4->SetLineColor(kV0AColorSci);
1546     v0L3Sec4->SetLineColor(kV0AColorSci); v0L4Sec4->SetLineColor(kV0AColorSci);
1547     v0ASec4->AddNode(v0L1Sec4,1);
1548     v0ASec4->AddNode(v0L2Sec4,1);
1549     v0ASec4->AddNode(v0L3Sec4,1);
1550     v0ASec4->AddNode(v0L4Sec4,1);      
1551     
1552     /// Segment of octagon 
1553     for (int i=0;i<2;i++) {
1554     v0APts[0+8*i] =  fV0AR6-fV0AOctH2;           v0APts[1+8*i] = 0.;
1555       v0APts[2+8*i] = (fV0AR6-fV0AOctH2)*sin45;  v0APts[3+8*i] = (fV0AR6-fV0AOctH2)*sin45;
1556       v0APts[4+8*i] = fV0AR6*sin45;              v0APts[5+8*i] = fV0AR6*sin45;
1557       v0APts[6+8*i] = fV0AR6;                    v0APts[7+8*i] = 0.;
1558     }
1559     new TGeoArb8("sV0AOct2Sec4", (fV0ASciWd+2*fV0AOctWd)/2., v0APts);
1560     TGeoCompositeShape *sV0AOct2FEEBSec4 = new TGeoCompositeShape("sV0AOct2FEEBSec4","sV0AOct2Sec4-sV0AFicFEEBSec4:posFicFEEBSec4-sV0AFicFEEBSec4:posFicFEEBUpSec4-sV0AFicOct2Sec4:posFicOct2Sec4-sV0AFicOct2Sec4:posFicOct2UpSec4");
1561     TGeoVolume *v0AOct2Sec4 = new TGeoVolume("V0AOct2Sec4", sV0AOct2FEEBSec4,medV0ASup);
1562     v0AOct2Sec4->SetLineColor(kV0AColorOct);
1563     TGeoVolume *v0ASupSec4 = new TGeoVolumeAssembly("V0ASupSec4");
1564     v0ASupSec4->AddNode(v0AOct2Sec4,1);
1565     v0ASec4->AddNode(v0ASupSec4,1);
1566
1567     //Bunch of fibers
1568     v0APts[ 0] = v0APts[ 2] = -13.0;
1569     v0APts[ 1] = v0APts[ 7] = (fV0ASciWd+fV0AOctWd)/2.-0.01;
1570     v0APts[ 3] = v0APts[ 5] = (fV0ASciWd+fV0AOctWd)/2.+0.01;
1571     v0APts[ 4] = v0APts[ 6] = +13.0;
1572     v0APts[ 8] = v0APts[10] = -10.0;
1573     v0APts[ 9] = v0APts[15] = 0.;
1574     v0APts[11] = v0APts[13] = 0.25;
1575     v0APts[12] = v0APts[14] = +10.0;
1576     new TGeoArb8("sV0AFib1Sec4", 11.5, v0APts);
1577     rot = new TGeoRotation("rot");
1578     rot->RotateX(-90);
1579     rot->RotateZ(-90.+22.5);
1580     TGeoCombiTrans *fibpos1Sec4 = new TGeoCombiTrans("fibpos1Sec4", (fV0AR6-fV0AOctH2+fV0AR5)*cos225/2. - 3.8, (fV0AR6-fV0AOctH2+fV0AR5)*sin225/2.-1.8, 0, rot);
1581     fibpos1Sec4->RegisterYourself();
1582     TGeoCompositeShape *sV0AFib1HoleSec4 = new TGeoCompositeShape("sV0AFib1HoleSec4","sV0AFib1Sec4:fibpos1Sec4-sV0AFicR5Sec4"); 
1583     TGeoVolume *v0AFib1HoleSec4 = new TGeoVolume("V0AFib1HoleSec4",sV0AFib1HoleSec4,medV0AFib);
1584     v0AFib1HoleSec4->SetLineColor(kV0AColorFib);
1585     new TGeoArb8("sV0AFib2Sec4", 11.5, v0APts);
1586     rot = new TGeoRotation("rot");
1587     rot->RotateX(-90);
1588     rot->RotateY(180);
1589     rot->RotateZ(-90.+22.5);
1590     TGeoCombiTrans *fibpos2Sec4 = new TGeoCombiTrans("fibpos2Sec4", (fV0AR6-fV0AOctH2+fV0AR5)*cos225/2. - 3.8, (fV0AR6-fV0AOctH2+fV0AR5)*sin225/2.-1.8, 0, rot);
1591     fibpos2Sec4->RegisterYourself();
1592     TGeoCompositeShape *sV0AFib2HoleSec4 = new TGeoCompositeShape("sV0AFib2HoleSec4","sV0AFib2Sec4:fibpos2Sec4-sV0AFicR5Sec4");
1593     TGeoVolume *v0AFib2HoleSec4 = new TGeoVolume("V0AFib2HoleSec4",sV0AFib2HoleSec4,medV0AFib);
1594     v0AFib2HoleSec4->SetLineColor(kV0AColorFib);
1595     TGeoVolume *v0AFibSec4 = new TGeoVolumeAssembly("V0AFibSec4");
1596     v0AFibSec4->AddNode(v0AFib1HoleSec4,1);
1597     v0AFibSec4->AddNode(v0AFib2HoleSec4,1);
1598     v0ASec4->AddNode(v0AFibSec4,1); 
1599     
1600      /// Plates
1601     new TGeoTube("sV0ANail1PlaInHoleSec4", 0.0, 0.4, (fV0APlaWd-2*fV0APlaAl)/2.);
1602     new TGeoTube("sV0ANail2PlaInHoleSec4", 0.0, 0.4, (fV0APlaWd-2*fV0APlaAl)/2.);
1603     new TGeoCompositeShape("sV0ANailsPlaInHolesSec4","sV0ANail1PlaInHoleSec4:pos1Sec4+sV0ANail2PlaInHoleSec4:pos2Sec4");
1604     new TGeoTube("sV0ANail1PlaOuHoleSec4", 0.0, 0.4, (fV0APlaAl)/2.);
1605     new TGeoTube("sV0ANail2PlaOuHoleSec4", 0.0, 0.4, (fV0APlaAl)/2.);
1606     new TGeoCompositeShape("sV0ANailsPlaOuHolesSec4","sV0ANail1PlaOuHoleSec4:pos1Sec4+sV0ANail2PlaOuHoleSec4:pos2Sec4");
1607     for (int i=0;i<2;i++) {
1608       v0APts[0+8*i] = fV0AR0;                   v0APts[1+8*i] = 0.;
1609       v0APts[2+8*i] = fV0AR0*sin45;             v0APts[3+8*i] = fV0AR0*sin45;
1610       v0APts[4+8*i] = fV0AR6 * sin45;   v0APts[5+8*i] = fV0AR6*sin45;
1611       v0APts[6+8*i] = fV0AR6;           v0APts[7+8*i] = 0.;
1612     }
1613     new TGeoArb8("sV0APlaInSec4", (fV0APlaWd-2*fV0APlaAl)/2., v0APts);
1614     TGeoCompositeShape *sV0APlaInNailsHolesSec4 = new TGeoCompositeShape("sV0APlaInNailsHolesSec4","sV0APlaInSec4-sV0ANailsPlaInHolesSec4-sV0AFicFEEBSec4:posFicFEEBSec4-sV0AFicFEEBSec4:posFicFEEBUpSec4");
1615     TGeoVolume *v0APlaInNailsHolesSec4 = new TGeoVolume("V0APlaInNailsHolesSec4", sV0APlaInNailsHolesSec4, medV0APlaIn);
1616     new TGeoArb8("sV0APlaOuSec4", fV0APlaAl/2., v0APts);
1617     TGeoCompositeShape *sV0APlaOuNailsHolesSec4 = new TGeoCompositeShape("sV0APlaOuNailsHolesSec4","sV0APlaOuSec4-sV0ANailsPlaOuHolesSec4-sV0AFicFEEBSec4:posFicFEEBSec4-sV0AFicFEEBSec4:posFicFEEBUpSec4");  
1618     TGeoVolume *v0APlaOuNailsHolesSec4 = new TGeoVolume("V0APlaOuNailsHolesSec4", sV0APlaOuNailsHolesSec4, medV0APlaOu);
1619     v0APlaInNailsHolesSec4->SetLineColor(kV0AColorPlaIn); v0APlaOuNailsHolesSec4->SetLineColor(kV0AColorPlaOu);
1620     TGeoVolume *v0APlaSec4 = new TGeoVolumeAssembly("V0APlaSec4");
1621     v0APlaSec4->AddNode(v0APlaInNailsHolesSec4,1);
1622     v0APlaSec4->AddNode(v0APlaOuNailsHolesSec4,1,new TGeoTranslation(0,0,(fV0APlaWd-fV0APlaAl)/2.));
1623     v0APlaSec4->AddNode(v0APlaOuNailsHolesSec4,2,new TGeoTranslation(0,0,-(fV0APlaWd-fV0APlaAl)/2.));
1624     v0ASec4->AddNode(v0APlaSec4,1,new TGeoTranslation(0,0,(fV0ASciWd+2*fV0AOctWd+fV0APlaWd)/2.));
1625     v0ASec4->AddNode(v0APlaSec4,2,new TGeoTranslation(0,0,-(fV0ASciWd+2*fV0AOctWd+fV0APlaWd)/2.));
1626     
1627      /// Non-sensitive scintilator
1628     new TGeoTubeSeg("sV0AR5S2Sec4", fV0AR4+fV0AFraWd/2., fV0AR4 + fV0AR0, fV0ASciWd/2.+2*preShapeSec4, 0, 45);
1629     TGeoCompositeShape *sV0AR5Sec4 = new TGeoCompositeShape("V0AR5Sec4","sV0AR5S2Sec4 - sV0AChaSec4");
1630     TGeoVolume *v0AR5Sec4 = new TGeoVolume("V0AR5Sec4",sV0AR5Sec4,medV0ASci);
1631     v0AR5Sec4->SetLineColor(kV0AColorSci);
1632     v0ASciSec4->AddNode(v0AR5Sec4,1);
1633     v0ASec4->AddNode(v0ASciSec4,1); 
1634
1635     /// PMBox
1636     TGeoVolume* v0APMSec4 = new TGeoVolumeAssembly("V0APMSec4");
1637     new TGeoBBox("sV0APMB1Sec4", fV0APMBWd/2., fV0APMBHt/2., fV0APMBTh/2.);
1638     new TGeoBBox("sV0APMB2Sec4", fV0APMBWd/2.-fV0APMBWdW, fV0APMBHt/2.-fV0APMBHtW, fV0APMBTh/2.-fV0APMBThW);
1639     TGeoCompositeShape *sV0APMBSec4 = new TGeoCompositeShape("sV0APMBSec4","sV0APMB1Sec4-sV0APMB2Sec4");
1640     TGeoVolume *v0APMBSec4 = new TGeoVolume("V0APMBSec4",sV0APMBSec4, medV0APMAlum);
1641     v0APMBSec4->SetLineColor(kV0AColorPMA);
1642     v0APMSec4->AddNode(v0APMBSec4,1);
1643
1644     /// PMTubes
1645     TGeoTube *sV0APMT1Sec4 = new TGeoTube("sV0APMT1Sec4", fV0APMTR1, fV0APMTR2, fV0APMTH/2.);
1646     TGeoVolume *v0APMT1Sec4 = new TGeoVolume("V0APMT1Sec4", sV0APMT1Sec4, medV0APMGlass);
1647     TGeoTube *sV0APMT2Sec4 = new TGeoTube("sV0APMT2Sec4", fV0APMTR3, fV0APMTR4, fV0APMTH/2.);
1648     TGeoVolume *v0APMT2Sec4 = new TGeoVolume("V0APMT2Sec4", sV0APMT2Sec4, medV0APMAlum);
1649     TGeoVolume *v0APMTSec4 = new TGeoVolumeAssembly("V0APMTSec4");
1650     TGeoTube *sV0APMTTSec4 = new TGeoTube("sV0APMTTSec4", 0., fV0APMTR4, fV0APMTB/2.);
1651     TGeoVolume *v0APMTTSec4 = new TGeoVolume("V0APMTTSec4", sV0APMTTSec4, medV0APMAlum);
1652     v0APMT1Sec4->SetLineColor(kV0AColorPMG);
1653     v0APMT2Sec4->SetLineColor(kV0AColorPMA);
1654     v0APMTTSec4->SetLineColor(kV0AColorPMA);
1655     rot = new TGeoRotation("rot", 90, 0, 180, 0, 90, 90);
1656     v0APMTSec4->AddNode(v0APMT1Sec4,1,rot);
1657     v0APMTSec4->AddNode(v0APMT2Sec4,1,rot);
1658     v0APMTSec4->AddNode(v0APMTTSec4,1,new TGeoCombiTrans(0,-(fV0APMTH+fV0APMTB)/2.,0,rot));
1659     double autoShiftSec4 = (fV0APMBWd-2*fV0APMBWdW)/4.;
1660     v0APMSec4->AddNode(v0APMTSec4, 1, new TGeoTranslation(-1.5*autoShiftSec4, 0, 0));
1661     v0APMSec4->AddNode(v0APMTSec4, 2, new TGeoTranslation(-0.5*autoShiftSec4, 0, 0));
1662     v0APMSec4->AddNode(v0APMTSec4, 3, new TGeoTranslation(+0.5*autoShiftSec4, 0, 0));
1663     v0APMSec4->AddNode(v0APMTSec4, 4, new TGeoTranslation(+1.5*autoShiftSec4, 0, 0));
1664
1665     // PM
1666     rot = new TGeoRotation("rot");
1667     rot->RotateX(90-fV0APMBAng);
1668     rot->RotateZ(-90.+22.5);
1669     double cosAngPMBSec4 = TMath::Cos(fV0APMBAng*TMath::DegToRad());
1670     double sinAngPMBSec4 = TMath::Sin(fV0APMBAng*TMath::DegToRad());
1671     double shiftZSec4 = fV0APMBHt/2. * cosAngPMBSec4
1672       -   ( fV0ASciWd + 2 * fV0AOctWd + 2 * fV0APlaWd )/2.   -   fV0APMBTh/2. * sinAngPMBSec4;
1673     double shiftRSec4 = fV0AR6  +  fV0AOctH2 + fV0APlaAl;
1674     v0ASec4->AddNode(v0APMSec4,1, new TGeoCombiTrans( shiftRSec4*cos225+1.07, shiftRSec4*sin225, shiftZSec4, rot));
1675     
1676     // Aluminium nails 
1677     TGeoTube *sV0ANail1Sec4 = new TGeoTube("sV0ANail1Sec4", 0.0, 0.4, 5.09/2.);
1678     TGeoVolume *v0ANail1Sec4 = new TGeoVolume("V0ANail1Sec4", sV0ANail1Sec4, medV0APMAlum);
1679     v0ANail1Sec4->SetLineColor(kV0AColorPMA);// this is the color for aluminium
1680     v0ASec4->AddNode(v0ANail1Sec4,1,new TGeoTranslation(42.9, 0.51, 0.0));
1681     TGeoTube *sV0ANail2Sec4 = new TGeoTube("sV0ANail2Sec4", 0.0, 0.4, 5.09/2.);
1682     TGeoVolume *v0ANail2Sec4 = new TGeoVolume("V0ANail2Sec4", sV0ANail2Sec4, medV0APMAlum);
1683     v0ANail2Sec4->SetLineColor(kV0AColorPMA);
1684     v0ASec4->AddNode(v0ANail2Sec4,1,new TGeoTranslation(30.73,29.98,0.0));     
1685         
1686     /// Adding sector to v0LE volume
1687     for(int i=3; i<4; i++) {
1688        TGeoRotation *rotation = new TGeoRotation("rotation", 90., i*45., 90., 90.+i*45., 0., 0.);
1689        v0LE->AddNode(v0ASec4,i+1,rotation);  
1690     }
1691
1692     //FEEBox
1693     TGeoVolume* v0AFEE4 = new TGeoVolumeAssembly("V0AFEE4"); 
1694     v0AFEE4->AddNode(v0AFEEB,1);
1695
1696     //Mother and daughter boards
1697     v0AFEE4->AddNode(v0AFEEDaughter, 1, new TGeoTranslation(9.0*spacing, fV0AFEEBTh/2.+2.0*fV0APMTB, fV0APMBHtW/2.));
1698     v0AFEE4->AddNode(v0AFEEDaughter, 2, new TGeoTranslation(6.0*spacing, fV0AFEEBTh/2.+2.0*fV0APMTB, fV0APMBHtW/2.));
1699     v0AFEE4->AddNode(v0AFEEDaughter, 3, new TGeoTranslation(3.0*spacing, fV0AFEEBTh/2.+2.0*fV0APMTB, fV0APMBHtW/2.));
1700     v0AFEE4->AddNode(v0AFEEDaughter, 4, new TGeoTranslation(0.0*spacing, fV0AFEEBTh/2.+2.0*fV0APMTB, fV0APMBHtW/2.));
1701     v0AFEE4->AddNode(v0AFEEDaughter, 5, new TGeoTranslation(-3.0*spacing, fV0AFEEBTh/2.+2.0*fV0APMTB, fV0APMBHtW/2.));
1702     v0AFEE4->AddNode(v0AFEEDaughter, 6, new TGeoTranslation(-6.0*spacing, fV0AFEEBTh/2.+2.0*fV0APMTB, fV0APMBHtW/2.));
1703     v0AFEE4->AddNode(v0AFEEDaughter, 7, new TGeoTranslation(-9.0*spacing, fV0AFEEBTh/2.+2.0*fV0APMTB, fV0APMBHtW/2.));
1704     v0AFEE4->AddNode(v0AFEEDaughter, 8, new TGeoTranslation(-12.0*spacing, fV0AFEEBTh/2.+2.0*fV0APMTB, fV0APMBHtW/2.));   
1705     v0AFEE4->AddNode(v0AFEEMother, 1, new TGeoTranslation(0.0, 0.0, -fV0AFEEBTh/2.+fV0APMBThW+fV0APMBHtW));
1706     v0AFEE4->AddNode(v0AFEEHalfMother, 1, new TGeoTranslation(0.0, -(fV0AFEEBTh+fV0APMTB)/2., -2.0*spacing));
1707
1708     //FEE
1709     rot = new TGeoRotation("rot");
1710     rot->RotateX(90);
1711     rot->RotateZ(-90.0);
1712     v0LE->AddNode(v0AFEE4,1, new TGeoCombiTrans( -aFEEshiftR2Sec1*cos225-2.0, 0, 7.5, rot));   
1713     v0LE->AddNode(v0AFEEOct2,4, new TGeoTranslation(-1.0*((aFEEshiftR2Sec1*cos225 + 2.0) - fV0AFEEBTh/2. - 1.0),0.0,0.0));
1714
1715
1716     //Definition of sector 5
1717     TGeoVolume *v0ASec5 = new TGeoVolumeAssembly("V0ASec5"); 
1718
1719     /// For boolean sustraction
1720     double preShape5 = 0.2;
1721     for (int i=0;i<2;i++) {
1722       v0APts[0+8*i] = -fV0AR0+fV0AFraWd/2.;  v0APts[1+8*i] = fV0AFraWd/2.;
1723       v0APts[2+8*i] = -fV0AR0+fV0AFraWd/2.;  v0APts[3+8*i] = -2*preShape5;
1724       v0APts[4+8*i] = -fV0AR4-fV0AFraWd/2.-preShape5;  v0APts[5+8*i] = -2*preShape5;
1725       v0APts[6+8*i] = -fV0AR4-fV0AFraWd/2.-preShape5;  v0APts[7+8*i] = fV0AFraWd/2.;
1726     }
1727     new TGeoArb8("sV0ACha15",fV0ASciWd/1.5,v0APts);
1728     for (int i=0;i<2;i++) {
1729       v0APts[0+8*i] = -fV0AR0*cos45+preShape5;
1730       v0APts[1+8*i] = -(fV0AR0-fV0AFraWd)*sin45+preShape5;
1731       v0APts[2+8*i] = -(fV0AR0-fV0AFraWd/2.)*cos45+preShape5;
1732       v0APts[3+8*i] = -(fV0AR0-fV0AFraWd/2.)*sin45;
1733       v0APts[4+8*i] = -(fV0AR4+fV0AFraWd/2.)*cos45-preShape5;
1734       v0APts[5+8*i] = -(fV0AR4+fV0AFraWd/2.)*sin45-2.*preShape5;
1735       v0APts[6+8*i] = -(fV0AR4+fV0AFraWd)*cos45-preShape5;
1736       v0APts[7+8*i] = -fV0AR4*sin45-preShape5;
1737     }
1738     new TGeoArb8("sV0ACha25", fV0ASciWd/2.+2.*preShape5, v0APts);
1739     new TGeoCompositeShape("sV0ACha125","sV0ACha15+sV0ACha25");
1740     new TGeoTube("sV0ANail15Hole", 0.0, 0.4, 1.65);
1741     TGeoTranslation *pos15 = new TGeoTranslation("pos15", -42.9, -0.51, 0.0);
1742     pos15->RegisterYourself();
1743     new TGeoTube("sV0ANail25Hole", 0.0, 0.4, 1.65);
1744     TGeoTranslation *pos25 = new TGeoTranslation("pos25",-30.8,-30.04,0.0); 
1745     pos25->RegisterYourself();
1746     TGeoTranslation *pos35 = new TGeoTranslation("pos35",-30.05,-30.79,0.0);  
1747     pos35->RegisterYourself();
1748     new TGeoCompositeShape("sV0ANailsHoles5","sV0ANail15Hole:pos15+sV0ANail25Hole:pos25");
1749     new TGeoCompositeShape("sV0ACha5","sV0ACha125+sV0ANailsHoles5");
1750     new TGeoTubeSeg("sV0AFicR55", fV0AR4+fV0AFraWd/2., fV0AR4 + fV0AR0, fV0ASciWd/2. +2*preShape5, 180.0, 225.0);
1751     new TGeoTube("sV0ANail1PlaInHole5", 0.0, 0.4, (fV0APlaWd-2*fV0APlaAl)/2.);
1752     new TGeoTube("sV0ANail2PlaInHole5", 0.0, 0.4, (fV0APlaWd-2*fV0APlaAl)/2.);
1753     new TGeoTube("sV0ANail3PlaInHole5", 0.0, 0.4, (fV0APlaWd-2*fV0APlaAl)/2.);
1754     new TGeoCompositeShape("sV0ANailsPlaInHoles5","sV0ANail1PlaInHole5:pos15+sV0ANail2PlaInHole5:pos25+sV0ANail3PlaInHole5:pos35");
1755     new TGeoTube("sV0ANail1PlaOuHole5", 0.0, 0.4, (fV0APlaAl)/2.);
1756     new TGeoTube("sV0ANail2PlaOuHole5", 0.0, 0.4, (fV0APlaAl)/2.);
1757     new TGeoTube("sV0ANail3PlaOuHole5", 0.0, 0.4, (fV0APlaAl)/2.);
1758     new TGeoCompositeShape("sV0ANailsPlaOuHoles5","sV0ANail1PlaOuHole5:pos15+sV0ANail2PlaOuHole5:pos25+sV0ANail3PlaOuHole5:pos35");
1759     rot = new TGeoRotation("rot");
1760     rot->RotateX(90);
1761     rot->RotateZ(-90.0);
1762     TGeoCombiTrans *posFicFEEBSec5 = new TGeoCombiTrans("posFicFEEBSec5", -aFEEshiftR2Sec1*cos225 - 2.0, 0, 7.5, rot);
1763     posFicFEEBSec5->RegisterYourself();
1764     TGeoTranslation *posFicOct2Sec5 = new TGeoTranslation("posFicOct2Sec5",-1.0*((aFEEshiftR2Sec1*cos225 + 2.0) - fV0AFEEBTh/2. - 1.0),0.0,0.0);
1765     posFicOct2Sec5->RegisterYourself(); 
1766
1767     /// Frame
1768     TGeoVolume *v0AFra5 = new TGeoVolumeAssembly("V0AFra5");
1769     for (int i=0;i<2;i++) { 
1770       v0APts[0+8*i] = -fV0AR0+fV0AFraWd/2.;  v0APts[1+8*i] = 0.0;
1771       v0APts[2+8*i] = -fV0AR0+fV0AFraWd/2.;  v0APts[3+8*i] = -fV0AFraWd/8.;
1772       v0APts[4+8*i] = -fV0AR4-fV0AFraWd/2.;  v0APts[5+8*i] = -fV0AFraWd/8.;
1773       v0APts[6+8*i] = -fV0AR4-fV0AFraWd/2.;  v0APts[7+8*i] = 0.0;
1774     }    
1775     TGeoArb8 *sV0AFraB15 = new TGeoArb8("sV0AFraB15",fV0ASciWd/2.,v0APts);
1776     TGeoVolume *v0AFraB15 = new TGeoVolume("V0AFraB15",sV0AFraB15,medV0AFra);
1777     for (int i=0;i<2;i++) {
1778       v0APts[0+8*i] = -fV0AR0*cos45;
1779       v0APts[1+8*i] = -(fV0AR0-fV0AFraWd)*sin45;
1780       v0APts[2+8*i] = -(fV0AR0-fV0AFraWd/2.)*cos45;
1781       v0APts[3+8*i] = -(fV0AR0-fV0AFraWd/2.)*sin45;
1782       v0APts[4+8*i] = -(fV0AR4+fV0AFraWd/2.)*cos45;
1783       v0APts[5+8*i] = -(fV0AR4+fV0AFraWd/2.)*sin45;
1784       v0APts[6+8*i] = -(fV0AR4+fV0AFraWd)*cos45;
1785       v0APts[7+8*i] = -fV0AR4*sin45;
1786     }
1787     TGeoArb8 *sV0AFraB25 = new TGeoArb8("sV0AFraB25", fV0ASciWd/2., v0APts);
1788     TGeoVolume *v0AFraB25 = new TGeoVolume("V0AFraB25",sV0AFraB25,medV0AFra);
1789     v0AFraB15->SetLineColor(kV0AColorFra); v0AFraB25->SetLineColor(kV0AColorFra);
1790     v0AFra5->AddNode(v0AFraB15,1);
1791     v0AFra5->AddNode(v0AFraB25,1);  // Prefer 2 GeoObjects insted of 3 GeoMovements
1792     new TGeoTubeSeg( "sV0AFraR1b5", fV0AR0-fV0AFraWd/2.,
1793                      fV0AR0+fV0AFraWd/2., fV0ASciWd/2., 180.0, 225.0);
1794     new TGeoTubeSeg( "sV0AFraR2b5", fV0AR1-fV0AFraWd/2.,
1795                      fV0AR1+fV0AFraWd/2., fV0ASciWd/2., 180.0, 225.0);
1796     new TGeoTubeSeg( "sV0AFraR3b5", fV0AR2-fV0AFraWd/2.,
1797                      fV0AR2+fV0AFraWd/2., fV0ASciWd/2., 180.0, 225.0);
1798     new TGeoTubeSeg( "sV0AFraR4b5", fV0AR3-fV0AFraWd/2.,
1799                      fV0AR3+fV0AFraWd/2., fV0ASciWd/2., 180.0, 225.0);
1800     new TGeoTubeSeg( "sV0AFraR5b5", fV0AR4-fV0AFraWd/2.,
1801                      fV0AR4+fV0AFraWd/2., fV0ASciWd/2., 180.0, 225.0);
1802     TGeoCompositeShape *sV0AFraR15 = new TGeoCompositeShape("sV0AFraR15","sV0AFraR1b5-sV0ACha5");
1803     TGeoCompositeShape *sV0AFraR25 = new TGeoCompositeShape("sV0AFraR25","sV0AFraR2b5-sV0ACha5");
1804     TGeoCompositeShape *sV0AFraR35 = new TGeoCompositeShape("sV0AFraR35","sV0AFraR3b5-sV0ACha5");
1805     TGeoCompositeShape *sV0AFraR45 = new TGeoCompositeShape("sV0AFraR45","sV0AFraR4b5-sV0ACha5");
1806     TGeoCompositeShape *sV0AFraR55 = new TGeoCompositeShape("sV0AFraR55","sV0AFraR5b5-sV0ACha5");
1807     TGeoVolume *v0AFraR15 = new TGeoVolume("V0AFraR15",sV0AFraR15,medV0AFra);
1808     TGeoVolume *v0AFraR25 = new TGeoVolume("V0AFraR25",sV0AFraR25,medV0AFra);
1809     TGeoVolume *v0AFraR35 = new TGeoVolume("V0AFraR35",sV0AFraR35,medV0AFra);
1810     TGeoVolume *v0AFraR45 = new TGeoVolume("V0AFraR45",sV0AFraR45,medV0AFra);
1811     TGeoVolume *v0AFraR55 = new TGeoVolume("V0AFraR55",sV0AFraR55,medV0AFra);
1812     v0AFraR15->SetLineColor(kV0AColorFra); v0AFraR25->SetLineColor(kV0AColorFra);
1813     v0AFraR35->SetLineColor(kV0AColorFra); v0AFraR45->SetLineColor(kV0AColorFra);
1814     v0AFraR55->SetLineColor(kV0AColorFra);
1815     v0AFra5->AddNode(v0AFraR15,1);
1816     v0AFra5->AddNode(v0AFraR25,1);
1817     v0AFra5->AddNode(v0AFraR35,1);
1818     v0AFra5->AddNode(v0AFraR45,1);
1819     v0AFra5->AddNode(v0AFraR55,1);
1820     v0ASec5->AddNode(v0AFra5,1);
1821
1822     /// Sensitive scintilator
1823     TGeoVolume *v0ASci5 = new TGeoVolumeAssembly("V0ASci5");
1824     new TGeoTubeSeg( "sV0AR1b5", fV0AR0+fV0AFraWd/2.,
1825                      fV0AR1-fV0AFraWd/2., fV0ASciWd/2., 180.0, 225.0);
1826     new TGeoTubeSeg( "sV0AR2b5", fV0AR1+fV0AFraWd/2.,
1827                      fV0AR2-fV0AFraWd/2., fV0ASciWd/2., 180.0, 225.0);
1828     new TGeoTubeSeg( "sV0AR3b5", fV0AR2+fV0AFraWd/2.,
1829                      fV0AR3-fV0AFraWd/2., fV0ASciWd/2., 180.0, 225.0);
1830     new TGeoTubeSeg( "sV0AR4b5", fV0AR3+fV0AFraWd/2.,
1831                      fV0AR4-fV0AFraWd/2., fV0ASciWd/2., 180.0, 225.0);
1832     TGeoCompositeShape *sV0AR15 = new TGeoCompositeShape("sV0AR15","sV0AR1b5-sV0ACha5");
1833     TGeoCompositeShape *sV0AR25 = new TGeoCompositeShape("sV0AR25","sV0AR2b5-sV0ACha5");
1834     TGeoCompositeShape *sV0AR35 = new TGeoCompositeShape("sV0AR35","sV0AR3b5-sV0ACha5");
1835     TGeoCompositeShape *sV0AR45 = new TGeoCompositeShape("sV0AR45","sV0AR4b5-sV0ACha5");
1836     TGeoVolume *v0L15 = new TGeoVolume("V0L15",sV0AR15,medV0ASci);
1837     TGeoVolume *v0L25 = new TGeoVolume("V0L25",sV0AR25,medV0ASci);
1838     TGeoVolume *v0L35 = new TGeoVolume("V0L35",sV0AR35,medV0ASci);
1839     TGeoVolume *v0L45 = new TGeoVolume("V0L45",sV0AR45,medV0ASci);
1840     v0L15->SetLineColor(kV0AColorSci); v0L25->SetLineColor(kV0AColorSci);
1841     v0L35->SetLineColor(kV0AColorSci); v0L45->SetLineColor(kV0AColorSci);
1842     v0ASci5->AddNode(v0L15,1);
1843     v0ASci5->AddNode(v0L25,1);
1844     v0ASci5->AddNode(v0L35,1);
1845     v0ASci5->AddNode(v0L45,1);
1846
1847      /// Segment of octagon  
1848     for (int i=0;i<2;i++) {
1849     v0APts[0+8*i] = -fV0AR6+fV0AOctH2;           v0APts[1+8*i] = 0.;
1850     v0APts[2+8*i] = -(fV0AR7-fV0AOctH2)*cos654;   v0APts[3+8*i] = -(fV0AR7-fV0AOctH2)*sin654;
1851     v0APts[4+8*i] = -fV0AR7*cos654;              v0APts[5+8*i] = -fV0AR7*sin654;
1852     v0APts[6+8*i] = -fV0AR6;                     v0APts[7+8*i] = 0.;
1853     }
1854     new TGeoArb8("sV0AOct25", (fV0ASciWd+2*fV0AOctWd)/2., v0APts);
1855     TGeoCompositeShape *sV0AOct2FEEB5 = new TGeoCompositeShape("sV0AOct2FEEB5","sV0AOct25-sV0AFicFEEBSec1:posFicFEEBSec5-sV0AFicOct2Sec1:posFicOct2Sec5");
1856     TGeoVolume *v0AOct25 = new TGeoVolume("V0AOct25", sV0AOct2FEEB5,medV0ASup);
1857     v0AOct25->SetLineColor(kV0AColorOct);
1858     TGeoVolume *v0ASup5 = new TGeoVolumeAssembly("V0ASup5");
1859     v0ASup5->AddNode(v0AOct25,1);
1860     v0ASec5->AddNode(v0ASup5,1);
1861
1862     //Bunch of fibers
1863     v0APts[ 0] = v0APts[ 2] = -14.0;
1864     v0APts[ 1] = v0APts[ 7] = (fV0ASciWd+fV0AOctWd)/2.-0.01;
1865     v0APts[ 3] = v0APts[ 5] = (fV0ASciWd+fV0AOctWd)/2.+0.01;
1866     v0APts[ 4] = v0APts[ 6] = +14.0;
1867     v0APts[ 8] = v0APts[10] = -10.0;
1868     v0APts[ 9] = v0APts[15] = 0.;
1869     v0APts[11] = v0APts[13] = 0.25;
1870     v0APts[12] = v0APts[14] = +10.0;
1871     new TGeoArb8("sV0AFib15", 11.8, v0APts); 
1872     rot = new TGeoRotation("rot");
1873     rot->RotateX(-90);
1874     rot->RotateZ(90+22.5);
1875     TGeoCombiTrans *fib15pos = new TGeoCombiTrans("fib15pos", -(fV0AR6-fV0AOctH2+fV0AR5)*cos225/2. +
1876     3.3, -(fV0AR6-fV0AOctH2+fV0AR5)*sin225/2. + 1.5, 0, rot);
1877     fib15pos->RegisterYourself();
1878     TGeoCompositeShape *sV0AFib15Hole = new TGeoCompositeShape("sV0AFib15Hole", "sV0AFib15:fib15pos-sV0AFicR55");
1879     TGeoVolume *v0AFib15Hole = new TGeoVolume("V0AFib15",sV0AFib15Hole,medV0AFib);
1880     v0AFib15Hole->SetLineColor(kV0AColorFib);
1881     new TGeoArb8("sV0AFib25", 11.8, v0APts);
1882     rot = new TGeoRotation("rot");
1883     rot->RotateX(-90);
1884     rot->RotateY(180);
1885     rot->RotateZ(90+22.5);
1886     TGeoCombiTrans *fib25pos = new TGeoCombiTrans("fib25pos", -(fV0AR6-fV0AOctH2+fV0AR5)*cos225/2. +
1887     3.3, -(fV0AR6-fV0AOctH2+fV0AR5)*sin225/2. + 1.5, 0, rot);
1888     fib25pos->RegisterYourself();
1889     TGeoCompositeShape *sV0AFib25Hole = new TGeoCompositeShape("sV0AFib25Hole","sV0AFib25:fib25pos-sV0AFicR55");
1890     TGeoVolume *v0AFib25Hole = new TGeoVolume("V0AFib25Hole",sV0AFib25Hole,medV0AFib);
1891     v0AFib25Hole->SetLineColor(kV0AColorFib);
1892     TGeoVolume *v0AFib5 = new TGeoVolumeAssembly("V0AFib5");    
1893     v0AFib5->AddNode(v0AFib15Hole,1);
1894     v0AFib5->AddNode(v0AFib25Hole,1);
1895     v0ASec5->AddNode(v0AFib5,1);
1896             
1897     /// Non-sensitive scintilator
1898     new TGeoTubeSeg("sV0AR5S25", fV0AR4+fV0AFraWd/2., fV0AR4 + fV0AR0, fV0ASciWd/2.+2*preShape5, 180.0, 225.0);
1899     TGeoCompositeShape *sV0AR55 = new TGeoCompositeShape("V0AR55","sV0AR5S25 - sV0ACha5");
1900     TGeoVolume *v0AR55 = new TGeoVolume("V0AR55",sV0AR55,medV0ASci);
1901     v0AR55->SetLineColor(kV0AColorSci);
1902     v0ASci5->AddNode(v0AR55,1);
1903     v0ASec5->AddNode(v0ASci5,1);
1904
1905     /// Plates 
1906     for (int i=0;i<2;i++) {
1907       v0APts[0+8*i] = -fV0AR0;                  v0APts[1+8*i] = 0.;
1908       v0APts[2+8*i] = -fV0AR0*cos654;           v0APts[3+8*i] = -fV0AR0*sin654;
1909       v0APts[4+8*i] = -fV0AR7*cos654;           v0APts[5+8*i] = -fV0AR7*sin654;
1910       v0APts[6+8*i] = -fV0AR6;                  v0APts[7+8*i] = 0.;
1911     }
1912     new TGeoArb8("sV0APlaIn5", (fV0APlaWd-2*fV0APlaAl)/2., v0APts);
1913     TGeoCompositeShape *sV0APlaInNailsHoles5 = new TGeoCompositeShape("sV0APlaInNailsHoles5","sV0APlaIn5-sV0ANailsPlaInHoles5-sV0AFicFEEBSec1:posFicFEEBSec5");
1914     TGeoVolume *v0APlaInNailsHoles5 = new TGeoVolume("V0APlaInNailsHoles5", sV0APlaInNailsHoles5, medV0APlaIn);
1915     new TGeoArb8("sV0APlaOu5", fV0APlaAl/2., v0APts);
1916     TGeoCompositeShape *sV0APlaOuNailsHoles5 = new TGeoCompositeShape("sV0APlaOuNailsHoles5","sV0APlaOu5-sV0ANailsPlaOuHoles5-sV0AFicFEEBSec1:posFicFEEBSec5");  
1917     TGeoVolume *v0APlaOuNailsHoles5 = new TGeoVolume("V0APlaOuNailsHoles5", sV0APlaOuNailsHoles5, medV0APlaOu);
1918     v0APlaInNailsHoles5->SetLineColor(kV0AColorPlaIn); v0APlaOuNailsHoles5->SetLineColor(kV0AColorPlaOu);
1919     TGeoVolume *v0APla5 = new TGeoVolumeAssembly("V0APla5");
1920     v0APla5->AddNode(v0APlaInNailsHoles5,1);
1921     v0APla5->AddNode(v0APlaOuNailsHoles5,1,new TGeoTranslation(0,0,(fV0APlaWd-fV0APlaAl)/2.));
1922     v0APla5->AddNode(v0APlaOuNailsHoles5,2,new TGeoTranslation(0,0,-(fV0APlaWd-fV0APlaAl)/2.));
1923     v0ASec5->AddNode(v0APla5,1,new TGeoTranslation(0,0,(fV0ASciWd+2*fV0AOctWd+fV0APlaWd)/2.));
1924     v0ASec5->AddNode(v0APla5,2,new TGeoTranslation(0,0,-(fV0ASciWd+2*fV0AOctWd+fV0APlaWd)/2.));
1925     
1926     /// PMBox 
1927     TGeoVolume* v0APM5 = new TGeoVolumeAssembly("V0APM5");
1928     new TGeoBBox("sV0APMB15", fV0APMBWd/2., fV0APMBHt/2., fV0APMBTh/2.);
1929     new TGeoBBox("sV0APMB25", fV0APMBWd/2.-fV0APMBWdW, fV0APMBHt/2.-fV0APMBHtW, fV0APMBTh/2.-fV0APMBThW);
1930     TGeoCompositeShape *sV0APMB5 = new TGeoCompositeShape("sV0APMB5","sV0APMB15-sV0APMB25");
1931     TGeoVolume *v0APMB5 = new TGeoVolume("V0APMB5",sV0APMB5, medV0APMAlum);
1932     v0APMB5->SetLineColor(kV0AColorPMA);
1933     v0APM5->AddNode(v0APMB5,1);
1934
1935     /// PMTubes 
1936     TGeoTube *sV0APMT15 = new TGeoTube("sV0APMT15", fV0APMTR1, fV0APMTR2, fV0APMTH/2.);
1937     TGeoVolume *v0APMT15 = new TGeoVolume("V0APMT15", sV0APMT15, medV0APMGlass);
1938     TGeoTube *sV0APMT25 = new TGeoTube("sV0APMT25", fV0APMTR3, fV0APMTR4, fV0APMTH/2.);
1939     TGeoVolume *v0APMT25 = new TGeoVolume("V0APMT25", sV0APMT25, medV0APMAlum);
1940     TGeoVolume *v0APMT5 = new TGeoVolumeAssembly("V0APMT5");
1941     TGeoTube *sV0APMTT5 = new TGeoTube("sV0APMTT5", 0., fV0APMTR4, fV0APMTB/2.);
1942     TGeoVolume *v0APMTT5 = new TGeoVolume("V0APMTT5", sV0APMTT5, medV0APMAlum);
1943     v0APMT5->SetLineColor(kV0AColorPMG);
1944     v0APMT25->SetLineColor(kV0AColorPMA);
1945     v0APMTT5->SetLineColor(kV0AColorPMA);
1946     rot = new TGeoRotation("rot", 90, 0, 180, 0, 90, 90);
1947     v0APMT5->AddNode(v0APMT15,1,rot);
1948     v0APMT5->AddNode(v0APMT25,1,rot);
1949     v0APMT5->AddNode(v0APMTT5,1,new TGeoCombiTrans(0,(fV0APMTH+fV0APMTB)/2.,0,rot));
1950     double autoShift5 = (fV0APMBWd-2*fV0APMBWdW)/4.;
1951     v0APM5->AddNode(v0APMT5, 1, new TGeoTranslation(-1.5*autoShift5, 0, 0));
1952     v0APM5->AddNode(v0APMT5, 2, new TGeoTranslation(-0.5*autoShift5, 0, 0));
1953     v0APM5->AddNode(v0APMT5, 3, new TGeoTranslation(+0.5*autoShift5, 0, 0));
1954     v0APM5->AddNode(v0APMT5, 4, new TGeoTranslation(+1.5*autoShift5, 0, 0));
1955
1956     /// PM 
1957     rot = new TGeoRotation("rot");
1958     rot->RotateX(-90+30);
1959     rot->RotateY(0); 
1960     rot->RotateZ(-65-3);
1961     double cosAngPMB5 = TMath::Cos(fV0APMBAng*TMath::DegToRad());
1962     double sinAngPMB5 = TMath::Sin(fV0APMBAng*TMath::DegToRad());
1963     double shiftZ5 = fV0APMBHt/2. * cosAngPMB5
1964       -   ( fV0ASciWd + 2 * fV0AOctWd + 2 * fV0APlaWd )/2.   -   fV0APMBTh/2. * sinAngPMB5;
1965     double shiftR5 = fV0AR6  +  fV0AOctH2 + fV0APlaAl;
1966     v0ASec5->AddNode(v0APM5,1, new TGeoCombiTrans( -shiftR5*cos225-1.3, -shiftR5*sin225, shiftZ5, rot));
1967
1968     // Aluminium nails
1969     TGeoTube *sV0ANail51 = new TGeoTube("sV0ANail51", 0.0, 0.4, 5.09/2.);
1970     TGeoVolume *v0ANail51 = new TGeoVolume("V0ANail51", sV0ANail51, medV0APMAlum);
1971     v0ANail51->SetLineColor(kV0AColorPMA);// this is the color for aluminium
1972     v0ASec5->AddNode(v0ANail51,1,new TGeoTranslation(-42.9,-0.51,0.0));
1973     TGeoTube *sV0ANail52 = new TGeoTube("sV0ANail52", 0.0, 0.4, 5.09/2.);
1974     TGeoVolume *v0ANail52 = new TGeoVolume("V0ANail52", sV0ANail52, medV0APMAlum);
1975     v0ANail52->SetLineColor(kV0AColorPMA);
1976     v0ASec5->AddNode(v0ANail52,1,new TGeoTranslation(-30.8,-30.04,0.0)); 
1977             
1978     // Adding sector to v0LE volume
1979     v0LE->AddNode(v0ASec5, 1);  
1980     
1981
1982     //Definition of  sector 6
1983     TGeoVolume *v0ASec6 = new TGeoVolumeAssembly("V0ASec6");
1984
1985     /// For boolean sustraction
1986     double preShape6 = 0.2;
1987     for (int i=0;i<2;i++) {
1988     v0APts[0+8*i] = -preShape6;                      v0APts[1+8*i] = -fV0AR0+fV0AFraWd/2.-preShape6;
1989     v0APts[2+8*i] = 0.0;                    v0APts[3+8*i] = -fV0AR0+fV0AFraWd/2.-preShape6;
1990     v0APts[4+8*i] = 0.0;                    v0APts[5+8*i] = -fV0AR4-fV0AFraWd/2.+preShape6;
1991     v0APts[6+8*i] = -preShape6;                      v0APts[7+8*i] = -fV0AR4-fV0AFraWd/2.+preShape6;
1992     }
1993     new TGeoArb8("sV0ACha16",fV0ASciWd/1.5,v0APts);
1994     for (int i=0;i<2;i++) {
1995     v0APts[0+8*i] = -fV0AR0*cos45+preShape6;
1996     v0APts[1+8*i] = -(fV0AR0-fV0AFraWd)*sin45+preShape6;
1997     v0APts[2+8*i] = -(fV0AR0-fV0AFraWd/2.)*cos45+preShape6;
1998     v0APts[3+8*i] = -(fV0AR0-fV0AFraWd/2.)*sin45;
1999     v0APts[4+8*i] = -(fV0AR4+fV0AFraWd/2.)*cos45-preShape6;
2000     v0APts[5+8*i] = -(fV0AR4+fV0AFraWd/2.)*sin45-preShape6;
2001     v0APts[6+8*i] = -(fV0AR4+fV0AFraWd)*cos45-preShape6;
2002     v0APts[7+8*i] = -fV0AR4*sin45-preShape6;
2003     }
2004     new TGeoArb8("sV0ACha26", fV0ASciWd/2.+2.*preShape6, v0APts);
2005     new TGeoCompositeShape("sV0ACha126","sV0ACha16+sV0ACha26");
2006     new TGeoTube("sV0ANail16Hole", 0.0, 0.4, 1.65);
2007     TGeoTranslation *pos16 = new TGeoTranslation("pos16",-0.51,-42.9,0.0);
2008     pos16->RegisterYourself();
2009     new TGeoTube("sV0ANail26Hole", 0.0, 0.4, 1.65);
2010     TGeoTranslation *pos26 = new TGeoTranslation("pos26",-30.05,-30.79,0.0);  
2011     pos26->RegisterYourself();
2012     new TGeoCompositeShape("sV0ANailsHoles6","sV0ANail16Hole:pos16+sV0ANail26Hole:pos26");
2013     new TGeoCompositeShape("sV0ACha6","sV0ACha126+sV0ANailsHoles6");
2014     new TGeoTubeSeg("sV0AFicR56", fV0AR4+fV0AFraWd/2., fV0AR4 + fV0AR0, fV0ASciWd/2.+2*preShape6, 225, 270.0);
2015     new TGeoTube("sV0ANail1PlaInHole6", 0.0, 0.4, (fV0APlaWd-2*fV0APlaAl)/2.);    
2016     new TGeoTube("sV0ANail1PlaOuHole6", 0.0, 0.4, (fV0APlaAl)/2.);
2017       
2018     /// Frame
2019     TGeoVolume *v0AFra6 = new TGeoVolumeAssembly("V0AFra6");
2020     for (int i=0;i<2;i++) {
2021     v0APts[0+8*i] = -fV0AFraWd/2.;         v0APts[1+8*i] = -fV0AR0-fV0AFraWd/2.;
2022     v0APts[2+8*i] = 0.;                    v0APts[3+8*i] = -fV0AR0-fV0AFraWd/2.;
2023     v0APts[4+8*i] = 0.;                    v0APts[5+8*i] = -fV0AR4+fV0AFraWd/2.;
2024     v0APts[6+8*i] = -fV0AFraWd/2.;         v0APts[7+8*i] = -fV0AR4+fV0AFraWd/2.;
2025     }
2026     TGeoArb8 *sV0AFraB16 = new TGeoArb8("sV0AFraB16",fV0ASciWd/2.,v0APts);
2027     TGeoVolume *v0AFraB16 = new TGeoVolume("V0AFraB16",sV0AFraB16,medV0AFra);
2028     for (int i=0;i<2;i++) {
2029     v0APts[0+8*i] = -(fV0AR0+fV0AFraWd/2.)*cos45;
2030     v0APts[1+8*i] = -(fV0AR0+fV0AFraWd/2.)*sin45;
2031     v0APts[2+8*i] = -fV0AR0*cos45;
2032     v0APts[3+8*i] = -(fV0AR0+fV0AFraWd)*sin45;
2033     v0APts[4+8*i] = -(fV0AR4-fV0AFraWd/6.)*cos45;
2034     v0APts[5+8*i] = -fV0AR4*sin45;
2035     v0APts[6+8*i] = -(fV0AR4-fV0AFraWd)*cos45;
2036     v0APts[7+8*i] = -(fV0AR4-fV0AFraWd/2.)*sin45;
2037     }
2038     TGeoArb8 *sV0AFraB26 = new TGeoArb8("sV0AFraB26", fV0ASciWd/2., v0APts);
2039     TGeoVolume *v0AFraB26 = new TGeoVolume("V0AFraB26",sV0AFraB26,medV0AFra);
2040     v0AFraB16->SetLineColor(kV0AColorFra); v0AFraB26->SetLineColor(kV0AColorFra);
2041     v0AFra6->AddNode(v0AFraB16,1);
2042     v0AFra6->AddNode(v0AFraB26,1);  // Prefer 2 GeoObjects insted of 3 GeoMovements
2043     new TGeoTubeSeg( "sV0AFraR1b6", fV0AR0-fV0AFraWd/2.,
2044              fV0AR0+fV0AFraWd/2., fV0ASciWd/2., 225.0, 270.0);
2045     new TGeoTubeSeg( "sV0AFraR2b6", fV0AR1-fV0AFraWd/2.,
2046              fV0AR1+fV0AFraWd/2., fV0ASciWd/2., 225.0, 270.0);
2047     new TGeoTubeSeg( "sV0AFraR3b6", fV0AR2-fV0AFraWd/2.,
2048              fV0AR2+fV0AFraWd/2., fV0ASciWd/2., 225.0, 270.0);
2049     new TGeoTubeSeg( "sV0AFraR4b6", fV0AR3-fV0AFraWd/2.,
2050              fV0AR3+fV0AFraWd/2., fV0ASciWd/2., 225.0, 270.0);
2051     new TGeoTubeSeg( "sV0AFraR5b6", fV0AR4-fV0AFraWd/2.,
2052              fV0AR4+fV0AFraWd/2., fV0ASciWd/2., 225.0, 270.0);
2053     TGeoCompositeShape *sV0AFraR16 = new TGeoCompositeShape("sV0AFraR16","sV0AFraR1b6-sV0ACha6");
2054     TGeoCompositeShape *sV0AFraR26 = new TGeoCompositeShape("sV0AFraR26","sV0AFraR2b6-sV0ACha6");
2055     TGeoCompositeShape *sV0AFraR36 = new TGeoCompositeShape("sV0AFraR36","sV0AFraR3b6-sV0ACha6");
2056     TGeoCompositeShape *sV0AFraR46 = new TGeoCompositeShape("sV0AFraR46","sV0AFraR4b6-sV0ACha6");
2057     TGeoCompositeShape *sV0AFraR56 = new TGeoCompositeShape("sV0AFraR56","sV0AFraR5b6-sV0ACha6");
2058     TGeoVolume *v0AFraR16 = new TGeoVolume("V0AFraR16",sV0AFraR16,medV0AFra);
2059     TGeoVolume *v0AFraR26 = new TGeoVolume("V0AFraR26",sV0AFraR26,medV0AFra);
2060     TGeoVolume *v0AFraR36 = new TGeoVolume("V0AFraR36",sV0AFraR36,medV0AFra);
2061     TGeoVolume *v0AFraR46 = new TGeoVolume("V0AFraR46",sV0AFraR46,medV0AFra);
2062     TGeoVolume *v0AFraR56 = new TGeoVolume("V0AFraR56",sV0AFraR56,medV0AFra);
2063     v0AFraR16->SetLineColor(kV0AColorFra); v0AFraR26->SetLineColor(kV0AColorFra);
2064     v0AFraR36->SetLineColor(kV0AColorFra); v0AFraR46->SetLineColor(kV0AColorFra);
2065     v0AFraR56->SetLineColor(kV0AColorFra);
2066     v0AFra6->AddNode(v0AFraR16,1);
2067     v0AFra6->AddNode(v0AFraR26,1);
2068     v0AFra6->AddNode(v0AFraR36,1);
2069     v0AFra6->AddNode(v0AFraR46,1);
2070     v0AFra6->AddNode(v0AFraR56,1);
2071     v0ASec6->AddNode(v0AFra6,1);
2072
2073     /// Sensitive scintilator
2074     TGeoVolume *v0ASci6 = new TGeoVolumeAssembly("V0ASci6");
2075     new TGeoTubeSeg( "sV0AR1b6", fV0AR0+fV0AFraWd/2.,
2076                      fV0AR1-fV0AFraWd/2., fV0ASciWd/2., 225.0, 270.0);
2077     new TGeoTubeSeg( "sV0AR2b6", fV0AR1+fV0AFraWd/2.,
2078              fV0AR2-fV0AFraWd/2., fV0ASciWd/2., 225.0, 270.0);
2079     new TGeoTubeSeg( "sV0AR3b6", fV0AR2+fV0AFraWd/2.,
2080              fV0AR3-fV0AFraWd/2., fV0ASciWd/2., 225.0, 270.0);
2081     new TGeoTubeSeg( "sV0AR4b6", fV0AR3+fV0AFraWd/2.,
2082              fV0AR4-fV0AFraWd/2., fV0ASciWd/2., 225.0, 270.0);
2083     TGeoCompositeShape *sV0AR16 = new TGeoCompositeShape("sV0AR16","sV0AR1b6-sV0ACha6");
2084     TGeoCompositeShape *sV0AR26 = new TGeoCompositeShape("sV0AR26","sV0AR2b6-sV0ACha6");
2085     TGeoCompositeShape *sV0AR36 = new TGeoCompositeShape("sV0AR36","sV0AR3b6-sV0ACha6");
2086     TGeoCompositeShape *sV0AR46 = new TGeoCompositeShape("sV0AR46","sV0AR4b6-sV0ACha6");
2087     TGeoVolume *v0L16 = new TGeoVolume("V0L16",sV0AR16,medV0ASci);
2088     TGeoVolume *v0L26 = new TGeoVolume("V0L26",sV0AR26,medV0ASci);
2089     TGeoVolume *v0L36 = new TGeoVolume("V0L36",sV0AR36,medV0ASci);
2090     TGeoVolume *v0L46 = new TGeoVolume("V0L46",sV0AR46,medV0ASci);
2091     v0L16->SetLineColor(kV0AColorSci); v0L26->SetLineColor(kV0AColorSci);
2092     v0L36->SetLineColor(kV0AColorSci); v0L46->SetLineColor(kV0AColorSci);
2093     v0ASci6->AddNode(v0L16,1);
2094     v0ASci6->AddNode(v0L26,1);
2095     v0ASci6->AddNode(v0L36,1);
2096     v0ASci6->AddNode(v0L46,1);
2097     
2098     // Bunch of fibers
2099     for (int i=0;i<2;i++) {
2100     v0APts[0+8*i] = -10.0;          v0APts[1+8*i] = 13.1;  
2101     v0APts[2+8*i] = 10.0;           v0APts[3+8*i] = 13.1;   
2102     v0APts[4+8*i] = 8.0;            v0APts[5+8*i] = -29.0;  
2103     v0APts[6+8*i] = -12.0;          v0APts[7+8*i] = -12.0;  
2104     }   
2105     new TGeoArb8("sV0AFib16", 0.01, v0APts);      
2106     rot = new TGeoRotation("rot");
2107     rot->RotateX(2.0); 
2108     rot->RotateY(180.0);
2109     rot->RotateZ(90+22.5);
2110     TGeoCombiTrans *fib16pos = new TGeoCombiTrans("fib16pos", -40.0 + 3.3, -50.0 + 1.5, 0.5, rot);
2111     fib16pos->RegisterYourself();
2112     TGeoCompositeShape *sV0AFib16Hole = new TGeoCompositeShape("sV0AFib16Hole", "sV0AFib16:fib16pos-sV0AFicR56");
2113     TGeoVolume *v0AFib16Hole = new TGeoVolume("V0AFib16Hole",sV0AFib16Hole,medV0AFib);
2114     v0AFib16Hole->SetLineColor(kV0AColorFib);
2115     new TGeoArb8("sV0AFib26", 0.01, v0APts);      
2116     rot = new TGeoRotation("rot");
2117     rot->RotateX(-2.0); 
2118     rot->RotateY(180.0); 
2119     rot->RotateZ(90+22.5);
2120     TGeoCombiTrans *fib26pos = new TGeoCombiTrans("fib26pos", -40.0 + 3.3, -50.0 + 1.5, -0.5, rot);
2121     fib26pos->RegisterYourself();
2122     TGeoCompositeShape *sV0AFib26Hole = new TGeoCompositeShape("sV0AFib26Hole", "sV0AFib26:fib26pos-sV0AFicR56");
2123     TGeoVolume *v0AFib26Hole = new TGeoVolume("V0AFib26Hole",sV0AFib26Hole,medV0AFib);
2124     v0AFib26Hole->SetLineColor(kV0AColorFib);
2125     TGeoVolume *v0AFib6 = new TGeoVolumeAssembly("V0AFib6");
2126     v0AFib6->AddNode(v0AFib16Hole,1); 
2127     v0AFib6->AddNode(v0AFib26Hole,1);
2128     v0ASec6->AddNode(v0AFib6,1);
2129
2130     /// Non-sensitive scintilator
2131     new TGeoTubeSeg("sV0AR5S26", fV0AR4+fV0AFraWd/2., fV0AR4 + fV0AR0, fV0ASciWd/2.+2*preShape6, 225.0, 270.0);
2132     TGeoCompositeShape *sV0AR56 = new TGeoCompositeShape("V0AR56","sV0AR5S26 - sV0ACha6");
2133     TGeoVolume *v0AR56 = new TGeoVolume("V0AR56",sV0AR56,medV0ASci);
2134     v0AR56->SetLineColor(kV0AColorSci);
2135     v0ASci6->AddNode(v0AR56,1);
2136     v0ASec6->AddNode(v0ASci6,1);
2137
2138     /// Segment of octagon   
2139     for (int i=0;i<2;i++) {
2140     v0APts[0+8*i] = 0.;                          v0APts[1+8*i] = -(fV0AR7-fV0AOctH2)*sin654;
2141     v0APts[2+8*i] = 0.;                          v0APts[3+8*i] = -fV0AR7*sin654;
2142     v0APts[4+8*i] = -fV0AR7*cos654;              v0APts[5+8*i] = -fV0AR7*sin654;
2143     v0APts[6+8*i] = -(fV0AR7-fV0AOctH2)*cos654;  v0APts[7+8*i] = -(fV0AR7-fV0AOctH2)*sin654;
2144     }
2145     TGeoArb8 *sV0AOct26 = new TGeoArb8("sV0AOct26", (fV0ASciWd+2*fV0AOctWd)/2., v0APts);
2146     TGeoVolume *v0AOct26 = new TGeoVolume("V0AOct26", sV0AOct26,medV0ASup);
2147     v0AOct26->SetLineColor(kV0AColorOct);
2148     TGeoVolume *v0ASup6 = new TGeoVolumeAssembly("V0ASup6");
2149     v0ASup6->AddNode(v0AOct26,1);
2150     v0ASec6->AddNode(v0ASup6,1);
2151
2152     /// Plates
2153     for (int i=0;i<2;i++) {
2154     v0APts[0+8*i] = 0.;                 v0APts[1+8*i] = -fV0AR0;
2155     v0APts[2+8*i] = 0.;                 v0APts[3+8*i] = -fV0AR7*sin654;
2156     v0APts[4+8*i] = -fV0AR7*cos654;     v0APts[5+8*i] = -fV0AR7*sin654;
2157     v0APts[6+8*i] = -fV0AR0*cos654;             v0APts[7+8*i] = -fV0AR0*sin654;
2158     }
2159     new TGeoArb8("sV0APlaIn6", (fV0APlaWd-2*fV0APlaAl)/2., v0APts);
2160     TGeoCompositeShape *sV0APlaInNailsHoles6 = new TGeoCompositeShape("sV0APlaInNailsHoles6","sV0APlaIn6-sV0ANail1PlaInHole6:pos16");
2161     TGeoVolume *v0APlaInNailsHoles6 = new TGeoVolume("V0APlaInNailsHoles6", sV0APlaInNailsHoles6, medV0APlaIn);
2162     new TGeoArb8("sV0APlaOu6", fV0APlaAl/2., v0APts);
2163     TGeoCompositeShape *sV0APlaOuNailsHoles6 = new TGeoCompositeShape("sV0APlaOuNailsHoles6","sV0APlaOu6-sV0ANail1PlaOuHole6:pos16"); 
2164     TGeoVolume *v0APlaOuNailsHoles6 = new TGeoVolume("V0APlaOuNailsHoles6", sV0APlaOuNailsHoles6, medV0APlaOu);
2165     v0APlaInNailsHoles6->SetLineColor(kV0AColorPlaIn); v0APlaOuNailsHoles6->SetLineColor(kV0AColorPlaOu);
2166     TGeoVolume *v0APla6 = new TGeoVolumeAssembly("V0APla6");
2167     v0APla6->AddNode(v0APlaInNailsHoles6,1);
2168     v0APla6->AddNode(v0APlaOuNailsHoles6,1,new TGeoTranslation(0,0,(fV0APlaWd-fV0APlaAl)/2.));
2169     v0APla6->AddNode(v0APlaOuNailsHoles6,2,new TGeoTranslation(0,0,-(fV0APlaWd-fV0APlaAl)/2.));
2170     v0ASec6->AddNode(v0APla6,1,new TGeoTranslation(0,0,(fV0ASciWd+2*fV0AOctWd+fV0APlaWd)/2.));
2171     v0ASec6->AddNode(v0APla6,2,new TGeoTranslation(0,0,-(fV0ASciWd+2*fV0AOctWd+fV0APlaWd)/2.));
2172     
2173     /// PMBox  
2174     TGeoVolume* v0APM6 = new TGeoVolumeAssembly("V0APM6");
2175     new TGeoBBox("sV0APMB16", fV0APMBWd/2., fV0APMBHt/2., fV0APMBTh/2.);
2176     new TGeoBBox("sV0APMB26", fV0APMBWd/2.-fV0APMBWdW, fV0APMBHt/2.-fV0APMBHtW, fV0APMBTh/2.-fV0APMBThW);
2177     TGeoCompositeShape *sV0APMB6 = new TGeoCompositeShape("sV0APMB6","sV0APMB16-sV0APMB26");
2178     TGeoVolume *v0APMB6 = new TGeoVolume("V0APMB6",sV0APMB6, medV0APMAlum);
2179     v0APMB6->SetLineColor(kV0AColorPMA);
2180     v0APM6->AddNode(v0APMB6,1);
2181
2182     /// PMTubes 
2183     TGeoTube *sV0APMT16 = new TGeoTube("sV0APMT16", fV0APMTR1, fV0APMTR2, fV0APMTH/2.);
2184     TGeoVolume *v0APMT16 = new TGeoVolume("V0APMT16", sV0APMT16, medV0APMGlass);
2185     TGeoTube *sV0APMT26 = new TGeoTube("sV0APMT26", fV0APMTR3, fV0APMTR4, fV0APMTH/2.);
2186     TGeoVolume *v0APMT26 = new TGeoVolume("V0APMT26", sV0APMT26, medV0APMAlum);
2187     TGeoVolume *v0APMT6 = new TGeoVolumeAssembly("V0APMT6"); 
2188     TGeoTube *sV0APMTT6 = new TGeoTube("sV0APMTT6", 0., fV0APMTR4, fV0APMTB/2.);
2189     TGeoVolume *v0APMTT6 = new TGeoVolume("V0APMTT6", sV0APMTT6, medV0APMAlum);
2190     v0APMT6->SetLineColor(kV0AColorPMG);
2191     v0APMT26->SetLineColor(kV0AColorPMA);
2192     v0APMTT6->SetLineColor(kV0AColorPMA);
2193     rot = new TGeoRotation("rot", 90, 0, 180, 0, 90, 90);
2194     v0APMT6->AddNode(v0APMT16,1,rot);
2195     v0APMT6->AddNode(v0APMT26,1,rot);
2196     v0APMT6->AddNode(v0APMTT6,1,new TGeoCombiTrans(0,(fV0APMTH+fV0APMTB)/2.,0,rot));
2197     double autoShift6 = (fV0APMBWd-2*fV0APMBWdW)/4.;
2198     v0APM6->AddNode(v0APMT6, 1, new TGeoTranslation(-1.5*autoShift6, 0, 0));
2199     v0APM6->AddNode(v0APMT6, 2, new TGeoTranslation(-0.5*autoShift6, 0, 0));
2200     v0APM6->AddNode(v0APMT6, 3, new TGeoTranslation(+0.5*autoShift6, 0, 0));
2201     v0APM6->AddNode(v0APMT6, 4, new TGeoTranslation(+1.5*autoShift6, 0, 0));
2202
2203     /// PM 
2204     rot = new TGeoRotation("rot");
2205     rot->RotateX(-90+30);
2206     rot->RotateY(0);
2207     rot->RotateZ(-65-3);
2208     double cosAngPMB6 = TMath::Cos(fV0APMBAng*TMath::DegToRad());
2209     double sinAngPMB6 = TMath::Sin(fV0APMBAng*TMath::DegToRad());
2210     double shiftZ6 = fV0APMBHt/2. * cosAngPMB6
2211       -   ( fV0ASciWd + 2 * fV0AOctWd + 2 * fV0APlaWd )/2.   -   fV0APMBTh/2. * sinAngPMB6;
2212     double shiftR6 = fV0AR6  + fV0AR1 + fV0AOctWd + fV0APlaAl/3.;
2213     v0ASec6->AddNode(v0APM6,1, new TGeoCombiTrans( -shiftR6*cos45-1.3, -shiftR6*sin45, shiftZ6, rot));   
2214     
2215     /// Support
2216     TGeoBBox *sV0ASuppbl = new TGeoBBox("sV0ASuppbl", 2.0, 18.13, fV0ASciWd/2.);       
2217     TGeoVolume *v0ASuppbl = new TGeoVolume("V0ASuppbl", sV0ASuppbl, medV0ASup);
2218     v0ASuppbl->SetLineColor(kV0AColorOct);
2219     v0ASec6->AddNode(v0ASuppbl,1,new TGeoTranslation(-2.0,-63.64,0.0));
2220     
2221     // Aluminium nail
2222     TGeoTube *sV0ANail61 = new TGeoTube("sV0ANail61", 0.0, 0.4, 5.09/2.);
2223     TGeoVolume *v0ANail61 = new TGeoVolume("V0ANail61", sV0ANail61, medV0APMAlum);
2224     v0ANail61->SetLineColor(kV0AColorPMA);// this is the color for aluminium
2225     v0ASec6->AddNode(v0ANail61,1,new TGeoTranslation(-0.51,-42.9,0.0));  
2226     TGeoTube *sV0ANail62 = new TGeoTube("sV0ANail62", 0.0, 0.4, 5.09/2.);
2227     TGeoVolume *v0ANail62 = new TGeoVolume("V0ANail62", sV0ANail62, medV0APMAlum);
2228     v0ANail62->SetLineColor(kV0AColorPMA);
2229     v0ASec6->AddNode(v0ANail62,1,new TGeoTranslation(-30.05,-30.79,0.0));  
2230
2231     // Adding sector to v0LE volume
2232     v0LE->AddNode(v0ASec6, 1); 
2233  
2234      
2235      //Definition of sector 7
2236     TGeoVolume *v0ASec7 = new TGeoVolumeAssembly("V0ASec7");
2237
2238     /// For boolean sustraction
2239     double preShape7 = 0.2;
2240     for (int i=0;i<2;i++) {
2241     v0APts[0+8*i] = 0.0;                      v0APts[1+8*i] = -fV0AR0+fV0AFraWd/2.-preShape7;
2242     v0APts[2+8*i] = fV0AFraWd/2.;                    v0APts[3+8*i] = -fV0AR0+fV0AFraWd/2.-preShape7;
2243     v0APts[4+8*i] = fV0AFraWd/2.;                    v0APts[5+8*i] = -fV0AR4-fV0AFraWd/2.+preShape7;
2244     v0APts[6+8*i] = 0.0;                      v0APts[7+8*i] = -fV0AR4-fV0AFraWd/2.+preShape7;
2245     }
2246     new TGeoArb8("sV0ACha17",fV0ASciWd/1.5,v0APts);
2247     for (int i=0;i<2;i++) {
2248     v0APts[0+8*i] = (fV0AR0-fV0AFraWd/2.)*cos45-preShape7;
2249     v0APts[1+8*i] =  -(fV0AR0-fV0AFraWd/2.)*sin45;
2250     v0APts[2+8*i] = fV0AR0*cos45-preShape7;
2251     v0APts[3+8*i] =  -(fV0AR0-fV0AFraWd)*sin45+preShape7;
2252     v0APts[4+8*i] = (fV0AR4+fV0AFraWd)*cos45+preShape7;
2253     v0APts[5+8*i] =  -fV0AR4*sin45-preShape7;
2254     v0APts[6+8*i] = (fV0AR4+fV0AFraWd/2.)*cos45+preShape7;
2255     v0APts[7+8*i] =  -(fV0AR4+fV0AFraWd/2.)*sin45-2.*preShape7;
2256     }
2257     new TGeoArb8("sV0ACha27", fV0ASciWd/2.+2.*preShape7, v0APts);
2258     new TGeoCompositeShape("sV0ACha127","sV0ACha17+sV0ACha27");
2259     new TGeoTube("sV0ANail17Hole", 0.0, 0.4, 1.65);
2260     TGeoTranslation *pos17 = new TGeoTranslation("pos17",0.51,-42.9,0.0);
2261     pos17->RegisterYourself();
2262     new TGeoTube("sV0ANail27Hole", 0.0, 0.4, 1.65);
2263     TGeoTranslation *pos27 = new TGeoTranslation("pos27",30.05,-30.79,0.0);   
2264     pos27->RegisterYourself();
2265     new TGeoCompositeShape("sV0ANailsHoles7","sV0ANail17Hole:pos17+sV0ANail27Hole:pos27");
2266     new TGeoCompositeShape("sV0ACha7","sV0ACha127+sV0ANailsHoles7");
2267     new TGeoTubeSeg("sV0AFicR57", fV0AR4+fV0AFraWd/2., fV0AR4 + fV0AR0, fV0ASciWd/2.+2*preShape7, 270.0, 315.0);
2268     new TGeoTube("sV0ANail1PlaInHole7", 0.0, 0.4, (fV0APlaWd-2*fV0APlaAl)/2.);    
2269     new TGeoTube("sV0ANail1PlaOuHole7", 0.0, 0.4, (fV0APlaAl)/2.); 
2270
2271     /// Frame
2272     TGeoVolume *v0AFra7 = new TGeoVolumeAssembly("V0AFra7");
2273     for (int i=0;i<2;i++) {
2274     v0APts[0+8*i] = 0.;                              v0APts[1+8*i] = -fV0AR0-fV0AFraWd/2.;
2275     v0APts[2+8*i] = fV0AFraWd/2.;                    v0APts[3+8*i] = -fV0AR0-fV0AFraWd/2.;
2276     v0APts[4+8*i] = fV0AFraWd/2.;                    v0APts[5+8*i] = -fV0AR4+fV0AFraWd/2.;
2277     v0APts[6+8*i] = 0.;                              v0APts[7+8*i] = -fV0AR4+fV0AFraWd/2.;
2278     }
2279     TGeoArb8 *sV0AFraB17 = new TGeoArb8("sV0AFraB17",fV0ASciWd/2.,v0APts);
2280     TGeoVolume *v0AFraB17 = new TGeoVolume("V0AFraB17",sV0AFraB17,medV0AFra);
2281     for (int i=0;i<2;i++) {
2282     v0APts[0+8*i] = fV0AR0*cos45-fV0AFraWd;
2283     v0APts[1+8*i] =  -(fV0AR0-fV0AFraWd)*sin45;
2284     v0APts[2+8*i] = (fV0AR0-fV0AFraWd/2.)*cos45;
2285     v0APts[3+8*i] = -(fV0AR0-fV0AFraWd/2.)*sin45;
2286     v0APts[4+8*i] = (fV0AR4+fV0AFraWd/2.)*cos45/2.;
2287     v0APts[5+8*i] = -fV0AR4*sin45/2.;
2288     v0APts[6+8*i] = (fV0AR4+fV0AFraWd/4.)*cos45/2.;
2289     v0APts[7+8*i] = -(fV0AR4+fV0AFraWd/2.)*sin45/2.;
2290     }
2291     TGeoArb8 *sV0AFraB27 = new TGeoArb8("sV0AFraB27", fV0ASciWd/2., v0APts);
2292     TGeoVolume *v0AFraB27 = new TGeoVolume("V0AFraB27",sV0AFraB27,medV0AFra);
2293     v0AFraB17->SetLineColor(kV0AColorFra); v0AFraB27->SetLineColor(kV0AColorFra);
2294     v0AFra7->AddNode(v0AFraB17,1);
2295     v0AFra7->AddNode(v0AFraB27,1);  // Prefer 2 GeoObjects insted of 3 GeoMovements
2296     new TGeoTubeSeg( "sV0AFraR1b7", fV0AR0-fV0AFraWd/2.,
2297              fV0AR0+fV0AFraWd/2., fV0ASciWd/2., 270.0, 315.0);
2298     new TGeoTubeSeg( "sV0AFraR2b7", fV0AR1-fV0AFraWd/2.,
2299              fV0AR1+fV0AFraWd/2., fV0ASciWd/2., 270.0, 315.0);
2300     new TGeoTubeSeg( "sV0AFraR3b7", fV0AR2-fV0AFraWd/2.,
2301              fV0AR2+fV0AFraWd/2., fV0ASciWd/2., 270.0, 315.0);
2302     new TGeoTubeSeg( "sV0AFraR4b7", fV0AR3-fV0AFraWd/2.,
2303              fV0AR3+fV0AFraWd/2., fV0ASciWd/2., 270.0, 315.0);
2304     new TGeoTubeSeg( "sV0AFraR5b7", fV0AR4-fV0AFraWd/2.,
2305              fV0AR4+fV0AFraWd/2., fV0ASciWd/2., 270.0, 315.0);
2306     TGeoCompositeShape *sV0AFraR17 = new TGeoCompositeShape("sV0AFraR17","sV0AFraR1b7-sV0ACha7");
2307     TGeoCompositeShape *sV0AFraR27 = new TGeoCompositeShape("sV0AFraR27","sV0AFraR2b7-sV0ACha7");
2308     TGeoCompositeShape *sV0AFraR37 = new TGeoCompositeShape("sV0AFraR37","sV0AFraR3b7-sV0ACha7");
2309     TGeoCompositeShape *sV0AFraR47 = new TGeoCompositeShape("sV0AFraR47","sV0AFraR4b7-sV0ACha7");
2310     TGeoCompositeShape *sV0AFraR57 = new TGeoCompositeShape("sV0AFraR57","sV0AFraR5b7-sV0ACha7");
2311     TGeoVolume *v0AFraR17 = new TGeoVolume("V0AFraR17",sV0AFraR17,medV0AFra);
2312     TGeoVolume *v0AFraR27 = new TGeoVolume("V0AFraR27",sV0AFraR27,medV0AFra);
2313     TGeoVolume *v0AFraR37 = new TGeoVolume("V0AFraR37",sV0AFraR37,medV0AFra);
2314     TGeoVolume *v0AFraR47 = new TGeoVolume("V0AFraR47",sV0AFraR47,medV0AFra);
2315     TGeoVolume *v0AFraR57 = new TGeoVolume("V0AFraR57",sV0AFraR57,medV0AFra);
2316     v0AFraR17->SetLineColor(kV0AColorFra); v0AFraR27->SetLineColor(kV0AColorFra);
2317     v0AFraR37->SetLineColor(kV0AColorFra); v0AFraR47->SetLineColor(kV0AColorFra);
2318     v0AFraR57->SetLineColor(kV0AColorFra);
2319     v0AFra7->AddNode(v0AFraR17,1);
2320     v0AFra7->AddNode(v0AFraR27,1);
2321     v0AFra7->AddNode(v0AFraR37,1);
2322     v0AFra7->AddNode(v0AFraR47,1);
2323     v0AFra7->AddNode(v0AFraR57,1);
2324     v0ASec7->AddNode(v0AFra7,1);
2325
2326     /// Sensitive scintilator
2327     TGeoVolume *v0ASci7 = new TGeoVolumeAssembly("V0ASci7");
2328     new TGeoTubeSeg( "sV0AR1b7", fV0AR0+fV0AFraWd/2.,
2329              fV0AR1-fV0AFraWd/2., fV0ASciWd/2., 270.0, 315.0);
2330     new TGeoTubeSeg( "sV0AR2b7", fV0AR1+fV0AFraWd/2.,
2331              fV0AR2-fV0AFraWd/2., fV0ASciWd/2., 270.0, 315.0);
2332     new TGeoTubeSeg( "sV0AR3b7", fV0AR2+fV0AFraWd/2.,
2333              fV0AR3-fV0AFraWd/2., fV0ASciWd/2., 270.0, 315.0);
2334     new TGeoTubeSeg( "sV0AR4b7", fV0AR3+fV0AFraWd/2.,
2335              fV0AR4-fV0AFraWd/2., fV0ASciWd/2., 270.0, 315.0);
2336     TGeoCompositeShape *sV0AR17 = new TGeoCompositeShape("sV0AR17","sV0AR1b7-sV0ACha7");
2337     TGeoCompositeShape *sV0AR27 = new TGeoCompositeShape("sV0AR27","sV0AR2b7-sV0ACha7");
2338     TGeoCompositeShape *sV0AR37 = new TGeoCompositeShape("sV0AR37","sV0AR3b7-sV0ACha7");
2339     TGeoCompositeShape *sV0AR47 = new TGeoCompositeShape("sV0AR47","sV0AR4b7-sV0ACha7");
2340     TGeoVolume *v0L17 = new TGeoVolume("V0L17",sV0AR17,medV0ASci);
2341     TGeoVolume *v0L27 = new TGeoVolume("V0L27",sV0AR27,medV0ASci);
2342     TGeoVolume *v0L37 = new TGeoVolume("V0L37",sV0AR37,medV0ASci);
2343     TGeoVolume *v0L47 = new TGeoVolume("V0L47",sV0AR47,medV0ASci);
2344     v0L17->SetLineColor(kV0AColorSci); v0L27->SetLineColor(kV0AColorSci);
2345     v0L37->SetLineColor(kV0AColorSci); v0L47->SetLineColor(kV0AColorSci);
2346     v0ASci7->AddNode(v0L17,1);
2347     v0ASci7->AddNode(v0L27,1);
2348     v0ASci7->AddNode(v0L37,1);
2349     v0ASci7->AddNode(v0L47,1);
2350     
2351     // Bunch of fibers
2352     for (int i=0;i<2;i++) {
2353     v0APts[0+8*i] = -10.0;            v0APts[1+8*i] = 13.1;
2354     v0APts[2+8*i] = 10.0;            v0APts[3+8*i] = 13.1;
2355     v0APts[4+8*i] = 8.0;            v0APts[5+8*i] = -29.0;
2356     v0APts[6+8*i] = -12.0;            v0APts[7+8*i] = -12.0;
2357     }   
2358     new TGeoArb8("sV0AFib17", 0.01, v0APts);      
2359     rot = new TGeoRotation("rot");
2360     rot->RotateX(-2.0); 
2361     rot->RotateY(0.0);
2362     rot->RotateZ(248.0);
2363     TGeoCombiTrans *fib17pos = new TGeoCombiTrans("fib17pos", 40.0 - 3.3, -50.0 + 1.5, 0.5, rot);
2364     fib17pos->RegisterYourself();
2365     TGeoCompositeShape *sV0AFib17Hole = new TGeoCompositeShape("sV0AFib17Hole", "sV0AFib17:fib17pos-sV0AFicR57");
2366     TGeoVolume *v0AFib17Hole = new TGeoVolume("V0AFib17Hole",sV0AFib17Hole,medV0AFib);
2367     v0AFib17Hole->SetLineColor(kV0AColorFib);
2368     new TGeoArb8("sV0AFib27", 0.01, v0APts);      
2369     rot = new TGeoRotation("rot");
2370     rot->RotateX(2.0); 
2371     rot->RotateY(0.0);
2372     rot->RotateZ(248.0);
2373     TGeoCombiTrans *fib27pos = new TGeoCombiTrans("fib27pos", 40.0 - 3.3, -50.0 + 1.5, -0.5, rot);
2374     fib27pos->RegisterYourself();
2375     TGeoCompositeShape *sV0AFib27Hole = new TGeoCompositeShape("sV0AFib27Hole", "sV0AFib27:fib27pos-sV0AFicR57");
2376     TGeoVolume *v0AFib27Hole = new TGeoVolume("V0AFib27Hole",sV0AFib27Hole,medV0AFib);
2377     v0AFib27Hole->SetLineColor(kV0AColorFib);
2378     TGeoVolume *v0AFib7 = new TGeoVolumeAssembly("V0AFib7");
2379     v0AFib7->AddNode(v0AFib17Hole,1); 
2380     v0AFib7->AddNode(v0AFib27Hole,1);
2381     v0ASec7->AddNode(v0AFib7,1);
2382
2383     /// Non-sensitive scintilator
2384     new TGeoTubeSeg("sV0AR5S27", fV0AR4+fV0AFraWd/2., fV0AR4 + fV0AR0, fV0ASciWd/2.+2*preShape7, 270.0, 315.0);
2385     TGeoCompositeShape *sV0AR57 = new TGeoCompositeShape("V0AR57","sV0AR5S27 - sV0ACha7");
2386     TGeoVolume *v0AR57 = new TGeoVolume("V0AR57",sV0AR57,medV0ASci);
2387     v0AR57->SetLineColor(kV0AColorSci);
2388     v0ASci7->AddNode(v0AR57,1);
2389     v0ASec7->AddNode(v0ASci7,1);
2390
2391     /// Segment of octagon   
2392     for (int i=0;i<2;i++) {
2393     v0APts[0+8*i] = 0.;                          v0APts[1+8*i] = -fV0AR7*sin654;
2394     v0APts[2+8*i] = 0.;                          v0APts[3+8*i] = -(fV0AR7-fV0AOctH2)*sin654;
2395     v0APts[4+8*i] = (fV0AR7-fV0AOctH2)*cos654;   v0APts[5+8*i] = -(fV0AR7-fV0AOctH2)*sin654;
2396     v0APts[6+8*i] = fV0AR7*cos654;               v0APts[7+8*i] = -fV0AR7*sin654;
2397     }
2398     TGeoArb8 *sV0AOct27 = new TGeoArb8("sV0AOct27", (fV0ASciWd+2*fV0AOctWd)/2., v0APts);
2399     TGeoVolume *v0AOct27 = new TGeoVolume("V0AOct27", sV0AOct27,medV0ASup);
2400     v0AOct27->SetLineColor(kV0AColorOct);
2401     TGeoVolume *v0ASup7 = new TGeoVolumeAssembly("V0ASup7");
2402     v0ASup7->AddNode(v0AOct27,1);
2403     v0ASec7->AddNode(v0ASup7,1);
2404
2405     /// Plates
2406     for (int i=0;i<2;i++) {
2407     v0APts[0+8*i] = 0.;                 v0APts[1+8*i] = -fV0AR7*sin654;
2408     v0APts[2+8*i] = 0.;                 v0APts[3+8*i] = -fV0AR0;
2409     v0APts[4+8*i] = fV0AR0*cos654;      v0APts[5+8*i] = -fV0AR0*sin654;
2410     v0APts[6+8*i] = fV0AR7*cos654;      v0APts[7+8*i] = -fV0AR7*sin654;
2411     }
2412     new TGeoArb8("sV0APlaIn7", (fV0APlaWd-2*fV0APlaAl)/2., v0APts);
2413     TGeoCompositeShape *sV0APlaInNailsHoles7 = new TGeoCompositeShape("sV0APlaInNailsHoles7","sV0APlaIn7-sV0ANail1PlaInHole7:pos17");
2414     TGeoVolume *v0APlaInNailsHoles7 = new TGeoVolume("V0APlaInNailsHoles7", sV0APlaInNailsHoles7, medV0APlaIn);
2415     new TGeoArb8("sV0APlaOu7", fV0APlaAl/2., v0APts);
2416     TGeoCompositeShape *sV0APlaOuNailsHoles7 = new TGeoCompositeShape("sV0APlaOuNailsHoles7","sV0APlaOu7-sV0ANail1PlaOuHole7:pos17"); 
2417     TGeoVolume *v0APlaOuNailsHoles7 = new TGeoVolume("V0APlaOuNailsHoles7", sV0APlaOuNailsHoles7, medV0APlaOu);
2418     v0APlaInNailsHoles7->SetLineColor(kV0AColorPlaIn); v0APlaOuNailsHoles7->SetLineColor(kV0AColorPlaOu);
2419     TGeoVolume *v0APla7 = new TGeoVolumeAssembly("V0APla7");
2420     v0APla7->AddNode(v0APlaInNailsHoles7,1);
2421     v0APla7->AddNode(v0APlaOuNailsHoles7,1,new TGeoTranslation(0,0,(fV0APlaWd-fV0APlaAl)/2.));
2422     v0APla7->AddNode(v0APlaOuNailsHoles7,2,new TGeoTranslation(0,0,-(fV0APlaWd-fV0APlaAl)/2.));
2423     v0ASec7->AddNode(v0APla7,1,new TGeoTranslation(0,0,(fV0ASciWd+2*fV0AOctWd+fV0APlaWd)/2.));
2424     v0ASec7->AddNode(v0APla7,2,new TGeoTranslation(0,0,-(fV0ASciWd+2*fV0AOctWd+fV0APlaWd)/2.));
2425     
2426     /// PMBox  
2427     TGeoVolume* v0APM7 = new TGeoVolumeAssembly("V0APM7");
2428     new TGeoBBox("sV0APMB17", fV0APMBWd/2., fV0APMBHt/2., fV0APMBTh/2.);
2429     new TGeoBBox("sV0APMB27", fV0APMBWd/2.-fV0APMBWdW, fV0APMBHt/2.-fV0APMBHtW, fV0APMBTh/2.-fV0APMBThW);
2430     TGeoCompositeShape *sV0APMB7 = new TGeoCompositeShape("sV0APMB7","sV0APMB17-sV0APMB27");
2431     TGeoVolume *v0APMB7 = new TGeoVolume("V0APMB7",sV0APMB7, medV0APMAlum);
2432     v0APMB7->SetLineColor(kV0AColorPMA);
2433     v0APM7->AddNode(v0APMB7,1);
2434     
2435     /// PMTubes 
2436     TGeoTube *sV0APMT17 = new TGeoTube("sV0APMT17", fV0APMTR1, fV0APMTR2, fV0APMTH/2.);
2437     TGeoVolume *v0APMT17 = new TGeoVolume("V0APMT17", sV0APMT17, medV0APMGlass);
2438     TGeoTube *sV0APMT27 = new TGeoTube("sV0APMT27", fV0APMTR3, fV0APMTR4, fV0APMTH/2.);
2439     TGeoVolume *v0APMT27 = new TGeoVolume("V0APMT27", sV0APMT27, medV0APMAlum);
2440     TGeoVolume *v0APMT7 = new TGeoVolumeAssembly("V0APMT7"); // pk si no choca con la 752 o con la 794
2441     TGeoTube *sV0APMTT7 = new TGeoTube("sV0APMTT7", 0., fV0APMTR4, fV0APMTB/2.);
2442     TGeoVolume *v0APMTT7 = new TGeoVolume("V0APMTT7", sV0APMTT7, medV0APMAlum);
2443     v0APMT7->SetLineColor(kV0AColorPMG);
2444     v0APMT27->SetLineColor(kV0AColorPMA);
2445     v0APMTT7->SetLineColor(kV0AColorPMA);
2446     rot = new TGeoRotation("rot", 90, 0, 180, 0, 90, 90);
2447     v0APMT7->AddNode(v0APMT17,1,rot);
2448     v0APMT7->AddNode(v0APMT27,1,rot);
2449     v0APMT7->AddNode(v0APMTT7,1,new TGeoCombiTrans(0,(fV0APMTH+fV0APMTB)/2.,0,rot));
2450     v0APM7->AddNode(v0APMT7, 1, new TGeoTranslation(-1.5*autoShiftSec1, 0, 0));
2451     v0APM7->AddNode(v0APMT7, 2, new TGeoTranslation(-0.5*autoShiftSec1, 0, 0));
2452     v0APM7->AddNode(v0APMT7, 3, new TGeoTranslation(+0.5*autoShiftSec1, 0, 0));
2453     v0APM7->AddNode(v0APMT7, 4, new TGeoTranslation(+1.5*autoShiftSec1, 0, 0));
2454
2455     /// PM 
2456     rot = new TGeoRotation("rot");
2457     rot->RotateX(-90+30);
2458     rot->RotateY(0);
2459     rot->RotateZ(65+3);
2460     double shiftZ7 = fV0APMBHt/2. * cosAngPMBSec1
2461       -   ( fV0ASciWd + 2 * fV0AOctWd + 2 * fV0APlaWd )/2.   -   fV0APMBTh/2. * sinAngPMBSec1;
2462     double shiftR7 = fV0AR6  + fV0AR1 + fV0AOctWd + fV0APlaAl/3.;
2463     v0ASec7->AddNode(v0APM7,1, new TGeoCombiTrans( shiftR7*cos45+1.3, -shiftR7*sin45, shiftZ7, rot)); 
2464     
2465     // Aluminium nail
2466     TGeoTube *sV0ANail71 = new TGeoTube("sV0ANail71", 0.0, 0.4, 5.09/2.);
2467     TGeoVolume *v0ANail71 = new TGeoVolume("V0ANail71", sV0ANail71, medV0APMAlum);
2468     v0ANail71->SetLineColor(kV0AColorPMA);// this is the color for aluminium
2469     v0ASec7->AddNode(v0ANail71,1,new TGeoTranslation(0.51,-42.9,0.0));
2470     TGeoTube *sV0ANail72 = new TGeoTube("sV0ANail72", 0.0, 0.4, 5.09/2.);
2471     TGeoVolume *v0ANail72 = new TGeoVolume("V0ANail72", sV0ANail72, medV0APMAlum);
2472     v0ANail72->SetLineColor(kV0AColorPMA);
2473     v0ASec7->AddNode(v0ANail72,1,new TGeoTranslation(30.05,-30.79,0.0));  
2474
2475     // Support
2476     TGeoBBox *sV0ASuppbr = new TGeoBBox("sV0ASuppbr", 2.0, 18.13, fV0ASciWd/2.);      
2477     TGeoVolume *v0ASuppbr = new TGeoVolume("V0ASuppbr", sV0ASuppbr, medV0ASup);
2478     v0ASuppbr->SetLineColor(kV0AColorOct);
2479     v0ASec7->AddNode(v0ASuppbr,1,new TGeoTranslation(2.0,-63.64,0.0));
2480     
2481     // Adding sector to v0LE volume 
2482     v0LE->AddNode(v0ASec7,1);
2483     
2484
2485    //Definition of sector 8
2486    TGeoVolume *v0ASec8 = new TGeoVolumeAssembly("V0ASec8"); 
2487   
2488   /// For boolean sustraction
2489       double preShape8 = 0.2;
2490       for (int i=0;i<2;i++) {
2491       v0APts[0+8*i] = fV0AR0-fV0AFraWd/2.;  v0APts[1+8*i] = -2*preShape8;
2492       v0APts[2+8*i] = fV0AR0-fV0AFraWd/2.;  v0APts[3+8*i] = 0.0;
2493       v0APts[4+8*i] = fV0AR4+fV0AFraWd/2.;  v0APts[5+8*i] = 0.0;
2494       v0APts[6+8*i] = fV0AR4+fV0AFraWd/2.;  v0APts[7+8*i] = -2*preShape8;
2495     }
2496     new TGeoArb8("sV0ACha18",fV0ASciWd/1.5,v0APts);
2497     for (int i=0;i<2;i++) {
2498       v0APts[0+8*i] = (fV0AR0-fV0AFraWd/2.)*sin45-preShape8;
2499       v0APts[1+8*i] = -(fV0AR0-fV0AFraWd/2.)*sin45;
2500       v0APts[2+8*i] = fV0AR0*sin45-fV0AFraWd/2.-preShape8;
2501       v0APts[3+8*i] = -(fV0AR0-fV0AFraWd)*sin45+preShape8;
2502       v0APts[4+8*i] = (fV0AR4+3*fV0AFraWd/2.)*sin45+preShape8;
2503       v0APts[5+8*i] = -fV0AR4*sin45-preShape8;
2504       v0APts[6+8*i] = (fV0AR4+fV0AFraWd)*sin45+preShape8; 
2505       v0APts[7+8*i] = -(fV0AR4+fV0AFraWd/2.)*sin45-2.*preShape8;
2506     }
2507     new TGeoArb8("sV0ACha28", fV0ASciWd/2.+2.*preShape8, v0APts);
2508     new TGeoCompositeShape("sV0ACha128","sV0ACha18+sV0ACha28");
2509     new TGeoTube("sV0ANail18Hole", 0.0, 0.4, 1.65);
2510     TGeoTranslation *pos18 = new TGeoTranslation("pos18",42.9,-.51,0.0);
2511     pos18->RegisterYourself();
2512     new TGeoTube("sV0ANail28Hole", 0.0, 0.4, 1.65);
2513     TGeoTranslation *pos28 = new TGeoTranslation("pos28",30.8,-30.04,0.0);
2514     pos28->RegisterYourself();    
2515     TGeoTranslation *pos38 = new TGeoTranslation("pos38",30.05,-30.79,0.0);  
2516     pos38->RegisterYourself();
2517     new TGeoCompositeShape("sV0ANailsHoles8","sV0ANail18Hole:pos18+sV0ANail28Hole:pos28");
2518     new TGeoCompositeShape("sV0ACha8","sV0ACha128+sV0ANailsHoles8");
2519     new TGeoTubeSeg("sV0AFicR58", fV0AR4+fV0AFraWd/2., fV0AR4 + fV0AR0, fV0ASciWd/2. +2*preShape8, 315.0, 360.0);
2520     new TGeoTube("sV0ANail1PlaInHole8", 0.0, 0.4, (fV0APlaWd-2*fV0APlaAl)/2.);
2521     new TGeoTube("sV0ANail2PlaInHole8", 0.0, 0.4, (fV0APlaWd-2*fV0APlaAl)/2.);
2522     new TGeoTube("sV0ANail3PlaInHole8", 0.0, 0.4, (fV0APlaWd-2*fV0APlaAl)/2.);
2523     new TGeoCompositeShape("sV0ANailsPlaInHoles8","sV0ANail1PlaInHole8:pos18+sV0ANail2PlaInHole8:pos28+sV0ANail3PlaInHole8:pos38");
2524     new TGeoTube("sV0ANail1PlaOuHole8", 0.0, 0.4, (fV0APlaAl)/2.);
2525     new TGeoTube("sV0ANail2PlaOuHole8", 0.0, 0.4, (fV0APlaAl)/2.);
2526     new TGeoTube("sV0ANail3PlaOuHole8", 0.0, 0.4, (fV0APlaAl)/2.);
2527     new TGeoCompositeShape("sV0ANailsPlaOuHoles8","sV0ANail1PlaOuHole8:pos18+sV0ANail2PlaOuHole8:pos28+sV0ANail3PlaOuHole8:pos38");
2528     
2529     /// Frame 
2530     TGeoVolume *v0AFra8 = new TGeoVolumeAssembly("V0AFra8"); 
2531     for (int i=0;i<2;i++) {
2532       v0APts[0+8*i] = fV0AR0-fV0AFraWd/2.;  v0APts[1+8*i] = 0.0;
2533       v0APts[2+8*i] = fV0AR4+fV0AFraWd/2.;  v0APts[3+8*i] = 0.0;
2534       v0APts[4+8*i] = fV0AR4+fV0AFraWd/2.;  v0APts[5+8*i] = -fV0AFraWd/8.;
2535       v0APts[6+8*i] = fV0AR0-fV0AFraWd/2.;  v0APts[7+8*i] = -fV0AFraWd/8.;
2536     }    
2537     TGeoArb8 *sV0AFraB18 = new TGeoArb8("sV0AFraB18",fV0ASciWd/2.,v0APts);
2538     TGeoVolume *v0AFraB18 = new TGeoVolume("V0AFraB18",sV0AFraB18,medV0AFra);  
2539     for (int i=0;i<2;i++) {
2540       v0APts[0+8*i] = (fV0AR0-fV0AFraWd/4.)*sin45;
2541       v0APts[1+8*i] = -(fV0AR0-fV0AFraWd/2.)*sin45; 
2542       v0APts[2+8*i] = fV0AR0*sin45-fV0AFraWd/2.; 
2543       v0APts[3+8*i] = -(fV0AR0-fV0AFraWd)*sin45;
2544       v0APts[4+8*i] = (fV0AR4+3*fV0AFraWd/2.)*sin45/2.;
2545       v0APts[5+8*i] = -fV0AR4*sin45/2.;
2546       v0APts[6+8*i] = (fV0AR4+fV0AFraWd)*sin45/2.;
2547       v0APts[7+8*i] = -(fV0AR4+fV0AFraWd/2.)*sin45/2.;
2548     }
2549     TGeoArb8 *sV0AFraB28 = new TGeoArb8("sV0AFraB28", fV0ASciWd/2., v0APts);
2550     TGeoVolume *v0AFraB28 = new TGeoVolume("V0AFraB28",sV0AFraB28,medV0AFra);
2551     v0AFraB18->SetLineColor(kV0AColorFra); v0AFraB28->SetLineColor(kV0AColorFra);
2552     v0AFra8->AddNode(v0AFraB18,1);
2553     v0AFra8->AddNode(v0AFraB28,1);  // Prefer 2 GeoObjects insted of 3 GeoMovements
2554     new TGeoTubeSeg( "sV0AFraR1b8", fV0AR0-fV0AFraWd/2.,
2555                      fV0AR0+fV0AFraWd/2., fV0ASciWd/2., 315.0, 360.0);
2556     new TGeoTubeSeg( "sV0AFraR2b8", fV0AR1-fV0AFraWd/2.,
2557                      fV0AR1+fV0AFraWd/2., fV0ASciWd/2., 315.0, 360.0);
2558     new TGeoTubeSeg( "sV0AFraR3b8", fV0AR2-fV0AFraWd/2.,
2559                      fV0AR2+fV0AFraWd/2., fV0ASciWd/2., 315.0, 360.0);
2560     new TGeoTubeSeg( "sV0AFraR4b8", fV0AR3-fV0AFraWd/2.,
2561                      fV0AR3+fV0AFraWd/2., fV0ASciWd/2., 315.0, 360.0);
2562     new TGeoTubeSeg( "sV0AFraR5b8", fV0AR4-fV0AFraWd/2.,
2563                      fV0AR4+fV0AFraWd/2., fV0ASciWd/2., 315.0, 360.0);
2564     TGeoCompositeShape *sV0AFraR18 = new TGeoCompositeShape("sV0AFraR18","sV0AFraR1b8-sV0ACha8");
2565     TGeoCompositeShape *sV0AFraR28 = new TGeoCompositeShape("sV0AFraR28","sV0AFraR2b8-sV0ACha8");
2566     TGeoCompositeShape *sV0AFraR38 = new TGeoCompositeShape("sV0AFraR38","sV0AFraR3b8-sV0ACha8");
2567     TGeoCompositeShape *sV0AFraR48 = new TGeoCompositeShape("sV0AFraR48","sV0AFraR4b8-sV0ACha8");
2568     TGeoCompositeShape *sV0AFraR58 = new TGeoCompositeShape("sV0AFraR58","sV0AFraR5b8-sV0ACha8");
2569     TGeoVolume *v0AFraR18 = new TGeoVolume("V0AFraR18",sV0AFraR18,medV0AFra);
2570     TGeoVolume *v0AFraR28 = new TGeoVolume("V0AFraR28",sV0AFraR28,medV0AFra);
2571     TGeoVolume *v0AFraR38 = new TGeoVolume("V0AFraR38",sV0AFraR38,medV0AFra);
2572     TGeoVolume *v0AFraR48 = new TGeoVolume("V0AFraR48",sV0AFraR48,medV0AFra);
2573     TGeoVolume *v0AFraR58 = new TGeoVolume("V0AFraR58",sV0AFraR58,medV0AFra);
2574     v0AFraR18->SetLineColor(kV0AColorFra); v0AFraR28->SetLineColor(kV0AColorFra);
2575     v0AFraR38->SetLineColor(kV0AColorFra); v0AFraR48->SetLineColor(kV0AColorFra);
2576     v0AFraR58->SetLineColor(kV0AColorFra);
2577     v0AFra8->AddNode(v0AFraR18,1);
2578     v0AFra8->AddNode(v0AFraR28,1);
2579     v0AFra8->AddNode(v0AFraR38,1);
2580     v0AFra8->AddNode(v0AFraR48,1);
2581     v0AFra8->AddNode(v0AFraR58,1);
2582     v0ASec8->AddNode(v0AFra8,1);
2583
2584     /// Sensitive scintilator
2585     TGeoVolume *v0ASci8 = new TGeoVolumeAssembly("V0ASci8");
2586     new TGeoTubeSeg( "sV0AR1b8", fV0AR0+fV0AFraWd/2.,
2587                      fV0AR1-fV0AFraWd/2., fV0ASciWd/2., 315.0, 360.0);
2588     new TGeoTubeSeg( "sV0AR2b8", fV0AR1+fV0AFraWd/2.,
2589                      fV0AR2-fV0AFraWd/2., fV0ASciWd/2., 315.0, 360.0);
2590     new TGeoTubeSeg( "sV0AR3b8", fV0AR2+fV0AFraWd/2.,
2591                      fV0AR3-fV0AFraWd/2., fV0ASciWd/2., 315.0, 360.0);
2592     new TGeoTubeSeg( "sV0AR4b8", fV0AR3+fV0AFraWd/2.,
2593                      fV0AR4-fV0AFraWd/2., fV0ASciWd/2., 315.0, 360.0);
2594     TGeoCompositeShape *sV0AR18 = new TGeoCompositeShape("sV0AR18","sV0AR1b8-sV0ACha8");
2595     TGeoCompositeShape *sV0AR28 = new TGeoCompositeShape("sV0AR28","sV0AR2b8-sV0ACha8");
2596     TGeoCompositeShape *sV0AR38 = new TGeoCompositeShape("sV0AR38","sV0AR3b8-sV0ACha8");
2597     TGeoCompositeShape *sV0AR48 = new TGeoCompositeShape("sV0AR48","sV0AR4b8-sV0ACha8");
2598     TGeoVolume *v0L18 = new TGeoVolume("V0L18",sV0AR18,medV0ASci);
2599     TGeoVolume *v0L28 = new TGeoVolume("V0L28",sV0AR28,medV0ASci);
2600     TGeoVolume *v0L38 = new TGeoVolume("V0L38",sV0AR38,medV0ASci);
2601     TGeoVolume *v0L48 = new TGeoVolume("V0L48",sV0AR48,medV0ASci);
2602     v0L18->SetLineColor(kV0AColorSci); v0L28->SetLineColor(kV0AColorSci);
2603     v0L38->SetLineColor(kV0AColorSci); v0L48->SetLineColor(kV0AColorSci);
2604     v0ASci8->AddNode(v0L18,1);
2605     v0ASci8->AddNode(v0L28,1);
2606     v0ASci8->AddNode(v0L38,1);
2607     v0ASci8->AddNode(v0L48,1); 
2608
2609     /// Segment of octagon   
2610     for (int i=0;i<2;i++) {
2611     v0APts[0+8*i] = fV0AR6;                      v0APts[1+8*i] = 0.;
2612     v0APts[2+8*i] = fV0AR7*cos654;               v0APts[3+8*i] = -fV0AR7*sin654;
2613     v0APts[4+8*i] = (fV0AR7-fV0AOctH2)*cos654;   v0APts[5+8*i] = -(fV0AR7-fV0AOctH2)*sin654;
2614     v0APts[6+8*i] = fV0AR6-fV0AOctH2;            v0APts[7+8*i] = 0.;
2615     }
2616     new TGeoArb8("sV0AOct28", (fV0ASciWd+2*fV0AOctWd)/2., v0APts);
2617     TGeoCompositeShape *sV0AOct2FEEB8 = new TGeoCompositeShape("sV0AOct2FEEB8","sV0AOct28-sV0AFicFEEBSec1:posFicFEEBSec1-sV0AFicOct2Sec1:posFicOct2Sec1");
2618     TGeoVolume *v0AOct28 = new TGeoVolume("V0AOct28", sV0AOct2FEEB8,medV0ASup);
2619     v0AOct28->SetLineColor(kV0AColorOct);
2620     TGeoVolume *v0ASup8 = new TGeoVolumeAssembly("V0ASup8");
2621     v0ASup8->AddNode(v0AOct28,1);
2622     v0ASec8->AddNode(v0ASup8,1);
2623
2624     //Bunch of fibers
2625     v0APts[ 0] = v0APts[ 2] = -14.0;
2626     v0APts[ 1] = v0APts[ 7] = (fV0ASciWd+fV0AOctWd)/2.-0.01;
2627     v0APts[ 3] = v0APts[ 5] = (fV0ASciWd+fV0AOctWd)/2.+0.01;
2628     v0APts[ 4] = v0APts[ 6] = +14.0;
2629     v0APts[ 8] = v0APts[10] = -10.0;
2630     v0APts[ 9] = v0APts[15] = 0.;
2631     v0APts[11] = v0APts[13] = 0.25;
2632     v0APts[12] = v0APts[14] = +10.0;
2633     new TGeoArb8("sV0AFib18", 11.8, v0APts); 
2634     rot = new TGeoRotation("rot");
2635     rot->RotateX(-90);
2636     rot->RotateZ(-90-22.5);
2637     TGeoCombiTrans *fib18pos = new TGeoCombiTrans("fib18pos", (fV0AR6-fV0AOctH2+fV0AR5)*cos225/2. - 3.3, -(fV0AR6-fV0AOctH2+fV0AR5)*sin225/2. + 1.5, 0, rot);
2638     fib18pos->RegisterYourself();
2639     TGeoCompositeShape *sV0AFib18Hole = new TGeoCompositeShape("sV0AFib18Hole", "sV0AFib18:fib18pos-sV0AFicR58");
2640     TGeoVolume *v0AFib18Hole = new TGeoVolume("V0AFib18",sV0AFib18Hole,medV0AFib);
2641     v0AFib18Hole->SetLineColor(kV0AColorFib);
2642     new TGeoArb8("sV0AFib28", 11.8, v0APts);
2643     rot = new TGeoRotation("rot");
2644     rot->RotateX(-90);
2645     rot->RotateY(180);
2646     rot->RotateZ(-90-22.5);
2647     TGeoCombiTrans *fib28pos = new TGeoCombiTrans("fib28pos", (fV0AR6-fV0AOctH2+fV0AR5)*cos225/2. - 3.3, -(fV0AR6-fV0AOctH2+fV0AR5)*sin225/2. + 1.5, 0, rot);
2648     fib28pos->RegisterYourself();
2649     TGeoCompositeShape *sV0AFib28Hole = new TGeoCompositeShape("sV0AFib28Hole", "sV0AFib28:fib28pos-sV0AFicR58");
2650     TGeoVolume *v0AFib28Hole = new TGeoVolume("V0AFib28Hole",sV0AFib28Hole,medV0AFib);
2651     v0AFib28Hole->SetLineColor(kV0AColorFib);
2652     TGeoVolume *v0AFib8 = new TGeoVolumeAssembly("V0AFib8");    
2653     v0AFib8->AddNode(v0AFib18Hole,1);
2654     v0AFib8->AddNode(v0AFib28Hole,1);
2655     v0ASec8->AddNode(v0AFib8,1);
2656              
2657     /// Non-sensitive scintilator   
2658     new TGeoTubeSeg("sV0AR5S28", fV0AR4+fV0AFraWd/2., fV0AR4 + fV0AR0, fV0ASciWd/2.+2*preShape8, 315.0, 360.0);
2659     TGeoCompositeShape *sV0AR58 = new TGeoCompositeShape("V0AR58","sV0AR5S28 - sV0ACha8");
2660     TGeoVolume *v0AR58 = new TGeoVolume("V0AR58",sV0AR58,medV0ASci);
2661     v0AR58->SetLineColor(kV0AColorSci);
2662     v0ASci8->AddNode(v0AR58,1);
2663     v0ASec8->AddNode(v0ASci8,1); 
2664     
2665     /// Plates
2666     for (int i=0;i<2;i++) {
2667       v0APts[0+8*i] = fV0AR0;                   v0APts[1+8*i] = 0.;
2668       v0APts[2+8*i] = fV0AR6;                   v0APts[3+8*i] = 0.;
2669       v0APts[4+8*i] = fV0AR7*cos654;            v0APts[5+8*i] = -fV0AR7*sin654;
2670       v0APts[6+8*i] = fV0AR0*cos654;            v0APts[7+8*i] = -fV0AR0*sin654;
2671     }
2672     new TGeoArb8("sV0APlaIn8", (fV0APlaWd-2*fV0APlaAl)/2., v0APts);
2673     TGeoCompositeShape *sV0APlaInNailsHoles8 = new TGeoCompositeShape("sV0APlaInNailsHoles8","sV0APlaIn8-sV0ANailsPlaInHoles8-sV0AFicFEEBSec1:posFicFEEBSec1");
2674     TGeoVolume *v0APlaInNailsHoles8 = new TGeoVolume("V0APlaInNailsHoles8", sV0APlaInNailsHoles8, medV0APlaIn);
2675     new TGeoArb8("sV0APlaOu8", fV0APlaAl/2., v0APts);
2676     TGeoCompositeShape *sV0APlaOuNailsHoles8 = new TGeoCompositeShape("sV0APlaOuNailsHoles8","sV0APlaOu8-sV0ANailsPlaOuHoles8-sV0AFicFEEBSec1:posFicFEEBSec1"); 
2677     TGeoVolume *v0APlaOuNailsHoles8 = new TGeoVolume("V0APlaOuNailsHoles8", sV0APlaOuNailsHoles8, medV0APlaOu);
2678     v0APlaInNailsHoles8->SetLineColor(kV0AColorPlaIn); v0APlaOuNailsHoles8->SetLineColor(kV0AColorPlaOu);
2679     TGeoVolume *v0APla8 = new TGeoVolumeAssembly("V0APla8");
2680     v0APla8->AddNode(v0APlaInNailsHoles8,1);
2681     v0APla8->AddNode(v0APlaOuNailsHoles8,1,new TGeoTranslation(0,0,(fV0APlaWd-fV0APlaAl)/2.));
2682     v0APla8->AddNode(v0APlaOuNailsHoles8,2,new TGeoTranslation(0,0,-(fV0APlaWd-fV0APlaAl)/2.));
2683     v0ASec8->AddNode(v0APla8,1,new TGeoTranslation(0,0,(fV0ASciWd+2*fV0AOctWd+fV0APlaWd)/2.));
2684     v0ASec8->AddNode(v0APla8,2,new TGeoTranslation(0,0,-(fV0ASciWd+2*fV0AOctWd+fV0APlaWd)/2.));
2685
2686     /// PMBox 
2687     TGeoVolume* v0APM8 = new TGeoVolumeAssembly("V0APM1");
2688     new TGeoBBox("sV0APMB18", fV0APMBWd/2., fV0APMBHt/2., fV0APMBTh/2.);
2689     new TGeoBBox("sV0APMB28", fV0APMBWd/2.-fV0APMBWdW, fV0APMBHt/2.-fV0APMBHtW, fV0APMBTh/2.-fV0APMBThW);
2690     TGeoCompositeShape *sV0APMB8 = new TGeoCompositeShape("sV0APMB8","sV0APMB18-sV0APMB28");
2691     TGeoVolume *v0APMB8 = new TGeoVolume("V0APMB8",sV0APMB8, medV0APMAlum);
2692     v0APMB8->SetLineColor(kV0AColorPMA);
2693     v0APM8->AddNode(v0APMB8,1);
2694
2695     /// PMTubes 
2696     TGeoTube *sV0APMT18 = new TGeoTube("sV0APMT18", fV0APMTR1, fV0APMTR2, fV0APMTH/2.);
2697     TGeoVolume *v0APMT18 = new TGeoVolume("V0APMT18", sV0APMT18, medV0APMGlass);
2698     TGeoTube *sV0APMT28 = new TGeoTube("sV0APMT28", fV0APMTR3, fV0APMTR4, fV0APMTH/2.);
2699     TGeoVolume *v0APMT28 = new TGeoVolume("V0APMT28", sV0APMT28, medV0APMAlum);
2700     TGeoVolume *v0APMT8 = new TGeoVolumeAssembly("V0APMT8");
2701     TGeoTube *sV0APMTT8 = new TGeoTube("sV0APMTT8", 0., fV0APMTR4, fV0APMTB/2.);
2702     TGeoVolume *v0APMTT8 = new TGeoVolume("V0APMTT8", sV0APMTT8, medV0APMAlum);
2703     v0APMT8->SetLineColor(kV0AColorPMG);
2704     v0APMT28->SetLineColor(kV0AColorPMA);
2705     v0APMTT8->SetLineColor(kV0AColorPMA);
2706     rot = new TGeoRotation("rot", 90, 0, 180, 0, 90, 90);
2707     v0APMT8->AddNode(v0APMT18,1,rot);
2708     v0APMT8->AddNode(v0APMT28,1,rot);
2709     v0APMT8->AddNode(v0APMTT8,1,new TGeoCombiTrans(0,(fV0APMTH+fV0APMTB)/2.,0,rot));
2710     double autoShift8 = (fV0APMBWd-2*fV0APMBWdW)/4.;
2711     v0APM8->AddNode(v0APMT8, 1, new TGeoTranslation(-1.5*autoShift8, 0, 0));
2712     v0APM8->AddNode(v0APMT8, 2, new TGeoTranslation(-0.5*autoShift8, 0, 0));
2713     v0APM8->AddNode(v0APMT8, 3, new TGeoTranslation(+0.5*autoShift8, 0, 0));
2714     v0APM8->AddNode(v0APMT8, 4, new TGeoTranslation(+1.5*autoShift8, 0, 0));
2715
2716     /// PM 
2717     rot = new TGeoRotation("rot");
2718     rot->RotateX(-90+30);
2719     rot->RotateY(0);
2720     rot->RotateZ(65+3);
2721     double shiftZ8 = fV0APMBHt/2. * cosAngPMBSec1
2722       -   ( fV0ASciWd + 2 * fV0AOctWd + 2 * fV0APlaWd )/2.   -   fV0APMBTh/2. * sinAngPMBSec1;
2723     double shiftR8 = fV0AR6  +  fV0AOctH2 + fV0APlaAl;
2724     v0ASec8->AddNode(v0APM8,1, new TGeoCombiTrans( shiftR8*cos225 + 1.3, -shiftR8*sin225, shiftZ8, rot));
2725
2726     // Aluminium nails
2727     TGeoTube *sV0ANail81 = new TGeoTube("sV0ANail81", 0.0, 0.4, 5.09/2.);
2728     TGeoVolume *v0ANail81 = new TGeoVolume("V0ANail81", sV0ANail81, medV0APMAlum);
2729     v0ANail81->SetLineColor(kV0AColorPMA);// this is the color for aluminium
2730     v0ASec8->AddNode(v0ANail81,1,new TGeoTranslation(42.9,-.51,0.0));
2731     TGeoTube *sV0ANail82 = new TGeoTube("sV0ANail82", 0.0, 0.4, 5.09/2.);
2732     TGeoVolume *v0ANail82 = new TGeoVolume("V0ANail82", sV0ANail82, medV0APMAlum); 
2733     v0ANail82->SetLineColor(kV0AColorPMA);
2734     v0ASec8->AddNode(v0ANail82,1,new TGeoTranslation(30.8,-30.04,0.0));  
2735       
2736     // Adding sector to v0LE volume 
2737     v0LE->AddNode(v0ASec8, 1);    
2738       
2739     // Adding detectors to top volume
2740     TGeoVolume *vZERO = new TGeoVolumeAssembly("VZERO");
2741     vZERO->AddNode(v0RI,1,new TGeoTranslation(0, 0, -zdet));
2742     vZERO->AddNode(v0LE,1,new TGeoTranslation(0, 0, +329.0));
2743     top->AddNode(vZERO,1);
2744 }
2745
2746 //_____________________________________________________________________________
2747 void AliVZEROv7::AddAlignableVolumes() const
2748 {
2749   //
2750   // Create entries for alignable volumes associating the symbolic volume
2751   // name with the corresponding volume path. Needs to be syncronized with
2752   // eventual changes in the geometry.
2753   // 
2754   TString vpC = "/ALIC_1/VZERO_1/V0RI_1";
2755   TString vpA = "/ALIC_1/VZERO_1/V0LE_1";
2756   TString snC = "VZERO/V0C";
2757   TString snA = "VZERO/V0A";
2758   
2759   if(!gGeoManager->SetAlignableEntry(snC.Data(),vpC.Data()))
2760     AliFatal(Form("Alignable entry %s not created. Volume path %s not valid", snC.Data(),vpC.Data()));
2761   if(!gGeoManager->SetAlignableEntry(snA.Data(),vpA.Data()))
2762     AliFatal(Form("Alignable entry %s not created. Volume path %s not valid", snA.Data(),vpA.Data()));
2763
2764
2765
2766 //_____________________________________________________________________________
2767 void AliVZEROv7::CreateMaterials()
2768 {
2769
2770 // Creates materials used for geometry 
2771
2772   AliDebug(2,"Create materials");
2773   // Parameters for simulation scope
2774   Int_t     fieldType       = ((AliMagF*)TGeoGlobalMagField::Instance()->GetField())->Integ();     // Field type 
2775   Double_t  maxField        = ((AliMagF*)TGeoGlobalMagField::Instance()->GetField())->Max();       // Field max.
2776   Double_t  maxBending      = 10;    // Max Angle
2777   Double_t  maxStepSize     = 0.01;  // Max step size 
2778   Double_t  maxEnergyLoss   = 1;     // Max Delta E
2779   Double_t  precision       = 0.003; // Precision
2780   Double_t  minStepSize     = 0.003; // Minimum step size 
2781
2782   Int_t    id;
2783   Double_t a, z, radLength, absLength;
2784   Float_t density, as[4], zs[4], ws[4];
2785
2786 // Parameters  for V0CPrePlates: Aluminium
2787    a = 26.98; 
2788    z = 13.00;
2789    density     = 2.7;
2790    radLength   = 8.9;
2791    absLength   = 37.2;
2792    id = 2;
2793    AliMaterial( id, "V0CAlu", a, z, density, radLength, absLength, 0, 0);
2794    AliMedium(id, "V0CAlu", id, 1, fieldType, maxField, maxBending, maxStepSize,
2795              maxEnergyLoss, precision, minStepSize);
2796                     
2797 // Parameters  for V0CPlates: Carbon 
2798    a = 12.01; 
2799    z =  6.00;
2800    density   = 2.265;
2801    radLength = 18.8;
2802    absLength = 49.9;
2803    id = 3;
2804    AliMaterial(id, "V0CCar",  a, z, density, radLength, absLength, 0, 0);
2805    AliMedium(id, "V0CCar", id, 1, fieldType, maxField, maxBending, maxStepSize,
2806              maxEnergyLoss, precision, minStepSize);
2807             
2808 // Parameters  for V0Cscintillator: BC408
2809    as[0] = 1.00794;     as[1] = 12.011;
2810    zs[0] = 1.;          zs[1] = 6.;
2811    ws[0] = 1.;          ws[1] = 1.;
2812    density      = 1.032;
2813    id           = 4;
2814    AliMixture(id, "V0CSci", as, zs, density, -2, ws);
2815    AliMedium(id,"V0CSci", id, 1, fieldType, maxField, maxBending, maxStepSize,
2816              maxEnergyLoss, precision, minStepSize);
2817
2818 // Parameters for V0Ascintilator: BC404
2819    as[0] = 1.00794;     as[1] = 12.011;
2820    zs[0] = 1.;          zs[1] = 6.;
2821    ws[0] = 5.21;        ws[1] = 4.74;
2822    density      = 1.032;
2823    id           = 5;
2824    AliMixture(id, "V0ASci", as, zs, density, -2, ws);
2825    AliMedium(id,  "V0ASci", id, 1, fieldType, maxField, maxBending, maxStepSize,
2826              maxEnergyLoss, precision, minStepSize);
2827
2828 // Parameters for V0ALuc: Lucita but for the simulation BC404
2829    as[0] = 1.00794;     as[1] = 12.011;
2830    zs[0] = 1.;          zs[1] = 6.;
2831    ws[0] = 5.21;        ws[1] = 4.74;
2832    density      = 1.032;
2833    id           = 6;
2834    AliMixture(id, "V0ALuc", as, zs, density, -2, ws);
2835    AliMedium(id, "V0ALuc", id, 1, fieldType, maxField, maxBending, maxStepSize,
2836              maxEnergyLoss, precision, minStepSize);
2837
2838 // Parameters for V0Aplate: EuroComposite - EC-PI 626 PS - AlMg3
2839    as[0] = 26.982;      as[1] = 24.305;
2840    zs[0] = 13.;         zs[1] = 12.;
2841    ws[0] = 1.;          ws[1] = 3.;
2842    density      = 3.034;
2843    id           = 7;
2844    AliMixture(id, "V0APlaOu", as, zs, density, -2, ws);
2845    AliMedium(id, "V0APlaOu", id, 1, fieldType, maxField, maxBending, maxStepSize,
2846              maxEnergyLoss, precision, minStepSize);
2847
2848 // Parameters for V0Aplate: EuroComposite - EC-PI 626 PS - EC-PI 6.4-42
2849    as[0] = 1.00794;     as[1] = 12.011;
2850    zs[0] = 1.;          zs[1] = 6.;
2851    ws[0] = 5.21;        ws[1] = 4.74;
2852    density      = 0.042;
2853    id           = 8;
2854    AliMixture(id, "V0APlaIn", as, zs, density, -2, ws);
2855    AliMedium(id, "V0APlaIn", id, 1, fieldType, maxField, maxBending, maxStepSize,
2856              maxEnergyLoss, precision, minStepSize);
2857
2858 // Parameters for V0Afiber: BC9929AMC Plastic Scintillating Fiber from Saint-Gobain
2859    as[0] = 1.00794;     as[1] = 12.011;
2860    zs[0] = 1.;          zs[1] = 6.;
2861    ws[0] = 4.82;        ws[1] = 4.85;
2862    density      = 1.05;
2863    id           = 9;
2864    AliMixture(id, "V0AFib", as, zs, density, -2, ws);
2865    AliMedium(id, "V0AFib", id, 1, fieldType, maxField, maxBending, maxStepSize,
2866              maxEnergyLoss, precision, minStepSize);
2867
2868 // Parameters for V0APMA: Aluminium
2869    a = 26.98; 
2870    z = 13.00;
2871    density     = 2.7;
2872    radLength   = 8.9;
2873    absLength   = 37.2;
2874    id = 10;
2875    AliMaterial(id, "V0APMA",  a, z, density, radLength, absLength, 0, 0);
2876    AliMedium(id, "V0APMA", id, 1, fieldType, maxField, maxBending, maxStepSize,
2877              maxEnergyLoss, precision, minStepSize);
2878
2879 // Parameters for V0APMG: Glass for the simulation Aluminium
2880    a = 26.98; 
2881    z = 13.00;
2882    density   = 2.7;
2883    radLength = 8.9;
2884    absLength = 37.2;
2885    id = 11;
2886    AliMaterial(id, "V0APMG",  a, z, density, radLength, absLength, 0, 0);
2887    AliMedium(id, "V0APMG", id, 1, fieldType, maxField, maxBending, maxStepSize,
2888              maxEnergyLoss, precision, minStepSize);
2889
2890 // Parameters for V0AFiberGlass: Material for mother and daughter boards
2891    as[0] = 1.00794;     as[1] = 12.011;       as[2] = 16.0;          as[3] = 28.09;
2892    zs[0] = 1.;          zs[1] = 6.;           zs[2] = 8.;            zs[3] = 14.;
2893    ws[0] = 736.0;       ws[1] = 462.0;        ws[2] = 292.0;         ws[3] = 68.0;
2894    density      = 1.9;
2895    id           = 12;
2896    AliMixture(id, "V0AFibGlass", as, zs, density, -4, ws);
2897    AliMedium(id, "V0AFibGlass", id, 1, fieldType, maxField, maxBending, maxStepSize,
2898              maxEnergyLoss, precision, minStepSize); 
2899    
2900 }
2901
2902 //_____________________________________________________________________________
2903 void AliVZEROv7::DrawGeometry() 
2904 {
2905 //  Drawing of V0 geometry done in DrawV0.C
2906
2907    AliDebug(2,"DrawGeometry");
2908 }
2909
2910 //_____________________________________________________________________________
2911 void AliVZEROv7::Init()
2912 {
2913 // Initialises version of the VZERO Detector given in Config
2914 // Just prints an information message
2915
2916 //   AliInfo(Form("VZERO version %d initialized \n",IsVersion()));
2917    
2918    AliDebug(1,"VZERO version 7 initialized");
2919    AliVZERO::Init();  
2920 }
2921
2922 //_____________________________________________________________________________
2923 void AliVZEROv7::StepManager()
2924 {
2925 // Step Manager, called at each step  
2926
2927   Int_t     copy;
2928   static    Int_t   vol[4];
2929   static    Float_t hits[21];
2930   static    Float_t eloss, tlength;
2931   static    Int_t   nPhotonsInStep = 0;
2932   static    Int_t   nPhotons = 0; 
2933   static    Int_t   numStep = 0;
2934   Int_t     ringNumber;
2935   Float_t   destep, step;
2936   numStep += 1; 
2937
2938   //   We keep only charged tracks : 
2939   if ( !gMC->TrackCharge() || !gMC->IsTrackAlive() ) return;
2940
2941   vol[0]    = gMC->CurrentVolOffID(1, vol[1]);
2942   vol[2]    = gMC->CurrentVolID(copy);
2943   vol[3]    = copy;
2944   static Int_t idV0R1 = gMC->VolId("V0R1");
2945
2946   static Int_t idV0L11 = gMC->VolId("V0L1Sec1");
2947   static Int_t idV0L12 = gMC->VolId("V0L1Sec2");
2948   static Int_t idV0L13 = gMC->VolId("V0L1Sec3");
2949   static Int_t idV0L14 = gMC->VolId("V0L1Sec4");
2950   static Int_t idV0L15 = gMC->VolId("V0L15");
2951   static Int_t idV0L16 = gMC->VolId("V0L16");
2952   static Int_t idV0L17 = gMC->VolId("V0L17");
2953   static Int_t idV0L18 = gMC->VolId("V0L18");  
2954   static Int_t idV0R2 = gMC->VolId("V0R2");
2955
2956   static Int_t idV0L21 = gMC->VolId("V0L2Sec1");
2957   static Int_t idV0L22 = gMC->VolId("V0L2Sec2");
2958   static Int_t idV0L23 = gMC->VolId("V0L2Sec3");
2959   static Int_t idV0L24 = gMC->VolId("V0L2Sec4");
2960   static Int_t idV0L25 = gMC->VolId("V0L25");
2961   static Int_t idV0L26 = gMC->VolId("V0L26");
2962   static Int_t idV0L27 = gMC->VolId("V0L27");
2963   static Int_t idV0L28 = gMC->VolId("V0L28");
2964   static Int_t idV0R3 = gMC->VolId("V0R3");
2965
2966   static Int_t idV0L31 = gMC->VolId("V0L3Sec1");
2967   static Int_t idV0L32 = gMC->VolId("V0L3Sec2");
2968   static Int_t idV0L33 = gMC->VolId("V0L3Sec3");
2969   static Int_t idV0L34 = gMC->VolId("V0L3Sec4");
2970   static Int_t idV0L35 = gMC->VolId("V0L35");
2971   static Int_t idV0L36 = gMC->VolId("V0L36");
2972   static Int_t idV0L37 = gMC->VolId("V0L37");
2973   static Int_t idV0L38 = gMC->VolId("V0L38");
2974   static Int_t idV0R4 = gMC->VolId("V0R4");
2975
2976   static Int_t idV0L41 = gMC->VolId("V0L4Sec1");
2977   static Int_t idV0L42 = gMC->VolId("V0L4Sec2");
2978   static Int_t idV0L43 = gMC->VolId("V0L4Sec3");
2979   static Int_t idV0L44 = gMC->VolId("V0L4Sec4");
2980   static Int_t idV0L45 = gMC->VolId("V0L45");
2981   static Int_t idV0L46 = gMC->VolId("V0L46");
2982   static Int_t idV0L47 = gMC->VolId("V0L47");
2983   static Int_t idV0L48 = gMC->VolId("V0L48");
2984   static Int_t idV0R5 = gMC->VolId("V0R5");
2985   static Int_t idV0R6 = gMC->VolId("V0R6");
2986   bool   hitOnV0C = true;
2987   double lightYield;
2988   double lightAttenuation;
2989   double nMeters; 
2990   double fibToPhot;
2991   if      ( gMC->CurrentVolID(copy) == idV0R1   || 
2992             gMC->CurrentVolID(copy) == idV0L11  || 
2993             gMC->CurrentVolID(copy) == idV0L12  || 
2994             gMC->CurrentVolID(copy) == idV0L13  || 
2995             gMC->CurrentVolID(copy) == idV0L14  || 
2996             gMC->CurrentVolID(copy) == idV0L15  ||  
2997             gMC->CurrentVolID(copy) == idV0L16  || 
2998             gMC->CurrentVolID(copy) == idV0L17  || 
2999             gMC->CurrentVolID(copy) == idV0L18  
3000       )
3001       ringNumber = 1;
3002   
3003   else if ( gMC->CurrentVolID(copy) == idV0R2  || 
3004             gMC->CurrentVolID(copy) == idV0L21 || 
3005             gMC->CurrentVolID(copy) == idV0L22 || 
3006             gMC->CurrentVolID(copy) == idV0L23 || 
3007             gMC->CurrentVolID(copy) == idV0L24 || 
3008             gMC->CurrentVolID(copy) == idV0L25 || 
3009             gMC->CurrentVolID(copy) == idV0L26 || 
3010             gMC->CurrentVolID(copy) == idV0L27 || 
3011             gMC->CurrentVolID(copy) == idV0L28 
3012       )
3013       ringNumber = 2; 
3014   
3015   else if ( gMC->CurrentVolID(copy) == idV0R3  || 
3016             gMC->CurrentVolID(copy) == idV0R4  || 
3017             gMC->CurrentVolID(copy) == idV0L31 || 
3018             gMC->CurrentVolID(copy) == idV0L32 || 
3019             gMC->CurrentVolID(copy) == idV0L33 || 
3020             gMC->CurrentVolID(copy) == idV0L34 || 
3021             gMC->CurrentVolID(copy) == idV0L35 || 
3022             gMC->CurrentVolID(copy) == idV0L36 || 
3023             gMC->CurrentVolID(copy) == idV0L37 || 
3024             gMC->CurrentVolID(copy) == idV0L38 
3025       ) 
3026       ringNumber = 3;
3027   else if ( gMC->CurrentVolID(copy) == idV0R5  || 
3028             gMC->CurrentVolID(copy) == idV0R6  || 
3029             gMC->CurrentVolID(copy) == idV0L41 || 
3030             gMC->CurrentVolID(copy) == idV0L42 || 
3031             gMC->CurrentVolID(copy) == idV0L43 || 
3032             gMC->CurrentVolID(copy) == idV0L44 || 
3033             gMC->CurrentVolID(copy) == idV0L45 || 
3034             gMC->CurrentVolID(copy) == idV0L46 || 
3035             gMC->CurrentVolID(copy) == idV0L47 || 
3036             gMC->CurrentVolID(copy) == idV0L48 
3037       ) ringNumber = 4;        
3038   
3039   else ringNumber = 0;
3040   
3041   if  (ringNumber) {
3042       if (
3043           gMC->CurrentVolID(copy) == idV0L11 || 
3044           gMC->CurrentVolID(copy) == idV0L12 || 
3045           gMC->CurrentVolID(copy) == idV0L13 || 
3046           gMC->CurrentVolID(copy) == idV0L14 || 
3047           gMC->CurrentVolID(copy) == idV0L15 || 
3048           gMC->CurrentVolID(copy) == idV0L16 || 
3049           gMC->CurrentVolID(copy) == idV0L17 || 
3050           gMC->CurrentVolID(copy) == idV0L18 || 
3051           gMC->CurrentVolID(copy) == idV0L21 || 
3052           gMC->CurrentVolID(copy) == idV0L22 || 
3053           gMC->CurrentVolID(copy) == idV0L23 || 
3054           gMC->CurrentVolID(copy) == idV0L24 || 
3055           gMC->CurrentVolID(copy) == idV0L25 || 
3056           gMC->CurrentVolID(copy) == idV0L26 || 
3057           gMC->CurrentVolID(copy) == idV0L27 || 
3058           gMC->CurrentVolID(copy) == idV0L28 || 
3059           gMC->CurrentVolID(copy) == idV0L31 || 
3060           gMC->CurrentVolID(copy) == idV0L32 || 
3061           gMC->CurrentVolID(copy) == idV0L33 || 
3062           gMC->CurrentVolID(copy) == idV0L34 || 
3063           gMC->CurrentVolID(copy) == idV0L35 || 
3064           gMC->CurrentVolID(copy) == idV0L36 || 
3065           gMC->CurrentVolID(copy) == idV0L37 || 
3066           gMC->CurrentVolID(copy) == idV0L38 || 
3067           gMC->CurrentVolID(copy) == idV0L41 || 
3068           gMC->CurrentVolID(copy) == idV0L42 || 
3069           gMC->CurrentVolID(copy) == idV0L43 || 
3070           gMC->CurrentVolID(copy) == idV0L44 || 
3071           gMC->CurrentVolID(copy) == idV0L45 || 
3072           gMC->CurrentVolID(copy) == idV0L46 || 
3073           gMC->CurrentVolID(copy) == idV0L47 || 
3074           gMC->CurrentVolID(copy) == idV0L48
3075           )
3076           hitOnV0C = false;
3077
3078     destep = gMC->Edep();
3079     step   = gMC->TrackStep();
3080     if (hitOnV0C) {
3081       lightYield = fV0CLightYield;
3082       lightAttenuation = fV0CLightAttenuation;
3083       nMeters = fV0CnMeters;
3084       fibToPhot = fV0CFibToPhot;
3085     } else {
3086       lightYield = fV0ALightYield;
3087       lightAttenuation = fV0ALightAttenuation;
3088       nMeters = fV0AnMeters;
3089       fibToPhot = fV0AFibToPhot;
3090     }
3091     nPhotonsInStep  = Int_t(destep / (lightYield *1e-9) );      
3092     nPhotonsInStep  = gRandom->Poisson(nPhotonsInStep);
3093     eloss    += destep;
3094     tlength  += step;    
3095     if ( gMC->IsTrackEntering() ) { 
3096       nPhotons  =  nPhotonsInStep;
3097       gMC->TrackPosition(fTrackPosition);
3098       gMC->TrackMomentum(fTrackMomentum);
3099       Float_t pt  = TMath::Sqrt( fTrackMomentum.Px() * fTrackMomentum.Px()
3100                                  + fTrackMomentum.Py() * fTrackMomentum.Py() );
3101       TParticle *par = gAlice->GetMCApp()->Particle(gAlice->GetMCApp()->GetCurrentTrackNumber());
3102       hits[0]  = fTrackPosition.X();
3103       hits[1]  = fTrackPosition.Y();
3104       hits[2]  = fTrackPosition.Z();             
3105       hits[3]  = Float_t (gMC->TrackPid()); 
3106       hits[4]  = gMC->TrackTime();
3107       hits[5]  = gMC->TrackCharge();
3108       hits[6]  = fTrackMomentum.Theta()*TMath::RadToDeg();
3109       hits[7]  = fTrackMomentum.Phi()*TMath::RadToDeg();
3110       hits[8]  = ringNumber;
3111       hits[9]  = pt;
3112       hits[10] = fTrackMomentum.P();
3113       hits[11] = fTrackMomentum.Px();
3114       hits[12] = fTrackMomentum.Py();
3115       hits[13] = fTrackMomentum.Pz();
3116       hits[14] = par->Vx();
3117       hits[15] = par->Vy();
3118       hits[16] = par->Vz();
3119       tlength  = 0.0;
3120       eloss    = 0.0;       
3121
3122       //////////////////////////
3123       ///// Display V0A geometry
3124       //      if (!hitOnV0C) {
3125       //        FILE *of;
3126       //        of = fopen("V0A.out", "a");
3127       //        // x, y, z, ringnumber, cellid
3128       //        fprintf( of, "%f %f %f %f %d \n",  hits[0], hits[1], hits[2], hits[8], GetCellId (vol, hits) );
3129       //        fclose(of);
3130       //      }
3131       //////////////////////////
3132     }
3133     nPhotons  = nPhotons + nPhotonsInStep;
3134     if( gMC->IsTrackExiting() || gMC->IsTrackStop() || gMC->IsTrackDisappeared()){
3135       nPhotons = nPhotons - Int_t((Float_t(nPhotons) * lightAttenuation * nMeters));
3136       nPhotons = nPhotons - Int_t( Float_t(nPhotons) * fibToPhot);
3137       hits[17] = eloss;
3138       hits[18] = tlength;
3139       hits[19] = nPhotons;
3140       hits[20] = GetCellId (vol, hits);
3141       AddHit(gAlice->GetMCApp()->GetCurrentTrackNumber(), vol, hits);
3142       tlength         = 0.0;
3143       eloss           = 0.0; 
3144       nPhotons        = 0;
3145       nPhotonsInStep  = 0;
3146       numStep         = 0;  
3147     }
3148     if( gMC->IsTrackEntering() || gMC->IsTrackExiting() ) {
3149       AddTrackReference(gAlice->GetMCApp()->GetCurrentTrackNumber(), AliTrackReference::kVZERO);
3150     }
3151   }
3152 }
3153
3154 //_____________________________________________________________________________
3155 void AliVZEROv7::AddHit(Int_t track, Int_t *vol, Float_t *hits)
3156 {
3157 //  Adds a VZERO hit
3158
3159   TClonesArray &lhits = *fHits;
3160   new(lhits[fNhits++]) AliVZEROhit(fIshunt,track,vol,hits);
3161 }
3162
3163 //_____________________________________________________________________________
3164 void AliVZEROv7::MakeBranch(Option_t *option)
3165 {
3166 // Creates new branches in the current Root Tree
3167     
3168   TString branchname(Form("%s",GetName()));
3169   AliDebug(2,Form("fBufferSize = %d",fBufferSize));
3170   const char *cH = strstr(option,"H");
3171   if (fHits   && fLoader->TreeH() && cH) {
3172     fLoader->TreeH()->Branch(branchname.Data(),&fHits, fBufferSize);
3173     AliDebug(2,Form("Making Branch %s for hits",branchname.Data()));
3174   }     
3175   const char *cD = strstr(option,"D");
3176   if (fDigits   && fLoader->TreeD() && cD) {
3177     fLoader->TreeD()->Branch(branchname.Data(),&fDigits, fBufferSize);
3178     AliDebug(2,Form("Making Branch %s for digits",branchname.Data()));
3179   }  
3180 }
3181
3182 //_____________________________________________________________________________
3183 Int_t AliVZEROv7::GetCellId(Int_t *vol, Float_t *hits) 
3184 {
3185   //   Returns Id of scintillator cell
3186   //   Right side from  0 to 47 
3187   //   Left  side from 48 to 79
3188   //   hits[8] = ring number (1 to 4)
3189   //   vol[1]  = copy number (1 to 8)
3190
3191   Int_t index      = vol[1];
3192   Int_t ringNumber = Int_t(hits[8]);
3193   fCellId          = 0;
3194
3195   Float_t phi = Float_t(TMath::ATan2(Double_t(hits[1]),Double_t(hits[0])) ); 
3196   Float_t kRaddeg = 180.0/TMath::Pi();
3197   phi = kRaddeg * phi;
3198
3199   if (index < 7) index = index + 8;
3200
3201   if (hits[2] < 0.0) {
3202     if(ringNumber < 3) {
3203       index = (index - 7) + ( ( ringNumber - 1 ) * 8);
3204     } else if (ringNumber >= 3) { 
3205       if ( gMC->CurrentVolID(vol[1]) == gMC->VolId("V0R3") || gMC->CurrentVolID(vol[1])
3206            == gMC->VolId("V0R5") )  index = (index*2-14)+((ringNumber-2)*16);
3207       if ( gMC->CurrentVolID(vol[1]) == gMC->VolId("V0R4") || gMC->CurrentVolID(vol[1])
3208            == gMC->VolId("V0R6") )  index = (index*2-13)+((ringNumber-2)*16);
3209     }
3210     fCellId   = index;           
3211   } else if (hits[2] > 0.0) {
3212     //    cout << " vol[0] = " << vol[0] << " copy : " << vol[1] 
3213     //   << " called " << gMC->VolName(vol[0]) << endl;
3214     // cout << " vol[2] = " << vol[2] << " copy : " << vol[3] 
3215     //   << " called " << gMC->VolName(vol[2]) << endl;
3216     // upper half
3217
3218       if (gMC->CurrentVolID(vol[2]) == gMC->VolId("V0L1Sec1")) fCellId =  47 + 1;
3219       if (gMC->CurrentVolID(vol[2]) == gMC->VolId("V0L1Sec2")) fCellId =  47 + 2;
3220       if (gMC->CurrentVolID(vol[2]) == gMC->VolId("V0L1Sec3")) fCellId =  47 + 3;
3221       if (gMC->CurrentVolID(vol[2]) == gMC->VolId("V0L1Sec4")) fCellId =  47 + 4;
3222
3223       if (gMC->CurrentVolID(vol[2]) == gMC->VolId("V0L2Sec1")) fCellId =  47 +  9;
3224       if (gMC->CurrentVolID(vol[2]) == gMC->VolId("V0L2Sec2")) fCellId =  47 + 10;
3225       if (gMC->CurrentVolID(vol[2]) == gMC->VolId("V0L2Sec3")) fCellId =  47 + 11;
3226       if (gMC->CurrentVolID(vol[2]) == gMC->VolId("V0L2Sec4")) fCellId =  47 + 12;
3227
3228       if (gMC->CurrentVolID(vol[2]) == gMC->VolId("V0L3Sec1")) fCellId =  47 + 17;
3229       if (gMC->CurrentVolID(vol[2]) == gMC->VolId("V0L3Sec2")) fCellId =  47 + 18;
3230       if (gMC->CurrentVolID(vol[2]) == gMC->VolId("V0L3Sec3")) fCellId =  47 + 19;
3231       if (gMC->CurrentVolID(vol[2]) == gMC->VolId("V0L3Sec4")) fCellId =  47 + 20;
3232
3233       if (gMC->CurrentVolID(vol[2]) == gMC->VolId("V0L4Sec1")) fCellId =  47 + 25;
3234       if (gMC->CurrentVolID(vol[2]) == gMC->VolId("V0L4Sec2")) fCellId =  47 + 26;
3235       if (gMC->CurrentVolID(vol[2]) == gMC->VolId("V0L4Sec3")) fCellId =  47 + 27;
3236       if (gMC->CurrentVolID(vol[2]) == gMC->VolId("V0L4Sec4")) fCellId =  47 + 28;
3237
3238     // lower half 
3239       if (gMC->CurrentVolID(vol[2]) == gMC->VolId("V0L15")) fCellId = 48+4;
3240       if (gMC->CurrentVolID(vol[2]) == gMC->VolId("V0L16")) fCellId = 48+5;
3241       if (gMC->CurrentVolID(vol[2]) == gMC->VolId("V0L17")) fCellId = 48+6;
3242       if (gMC->CurrentVolID(vol[2]) == gMC->VolId("V0L18")) fCellId = 48+7;
3243       if (gMC->CurrentVolID(vol[2]) == gMC->VolId("V0L25")) fCellId = 8+48+4;
3244       if (gMC->CurrentVolID(vol[2]) == gMC->VolId("V0L26")) fCellId = 8+48+5;
3245       if (gMC->CurrentVolID(vol[2]) == gMC->VolId("V0L27")) fCellId = 8+48+6;
3246       if (gMC->CurrentVolID(vol[2]) == gMC->VolId("V0L28")) fCellId = 8+48+7;
3247       if (gMC->CurrentVolID(vol[2]) == gMC->VolId("V0L35")) fCellId = 16+48+4;
3248       if (gMC->CurrentVolID(vol[2]) == gMC->VolId("V0L36")) fCellId = 16+48+5;
3249       if (gMC->CurrentVolID(vol[2]) == gMC->VolId("V0L37")) fCellId = 16+48+6;
3250       if (gMC->CurrentVolID(vol[2]) == gMC->VolId("V0L38")) fCellId = 16+48+7;
3251       if (gMC->CurrentVolID(vol[2]) == gMC->VolId("V0L45")) fCellId = 24+48+4;
3252       if (gMC->CurrentVolID(vol[2]) == gMC->VolId("V0L46")) fCellId = 24+48+5;
3253       if (gMC->CurrentVolID(vol[2]) == gMC->VolId("V0L47")) fCellId = 24+48+6;
3254       if (gMC->CurrentVolID(vol[2]) == gMC->VolId("V0L48")) fCellId = 24+48+7;
3255   }
3256
3257   return fCellId;
3258 }
3259