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