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