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