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