]> git.uio.no Git - u/mrichter/AliRoot.git/blob - VZERO/AliVZEROv7.cxx
Interface to pad status map in clusterizer
[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 +338.5 and +342.5 cm        //
28 //   New coordinate system has been implemented in october 2003      //
29 //                                                                   //
30 ///////////////////////////////////////////////////////////////////////
31
32 // --- Standard libraries ---
33 #include <Riostream.h>
34
35 // --- ROOT libraries ---
36 #include <TClonesArray.h>
37 #include <TMath.h>
38 #include <TVirtualMC.h>
39 #include <TParticle.h>
40
41 #include <TGeoManager.h>
42 #include <TGeoMatrix.h>
43 #include <TGeoMaterial.h>
44 #include <TGeoMedium.h>
45 #include <TGeoVolume.h>
46 #include "TGeoTube.h"
47 #include "TGeoArb8.h"
48 #include "TGeoCompositeShape.h"
49
50 // --- AliRoot header files ---
51 #include "AliRun.h"
52 #include "AliMC.h"
53 #include "AliMagF.h"
54 #include "AliVZEROLoader.h"
55 #include "AliVZEROdigit.h"
56 #include "AliVZEROhit.h"
57 #include "AliVZEROv7.h"
58 #include "AliLog.h"
59  
60 ClassImp(AliVZEROv7)
61
62 //_____________________________________________________________________________
63 AliVZEROv7:: AliVZEROv7():AliVZERO(),
64    fCellId(0),
65    fTrackPosition(),
66    fTrackMomentum(), 
67    fV0CHeight1(2.5), 
68    fV0CHeight2(4.4), 
69    fV0CHeight3(7.4), 
70    fV0CHeight4(12.5),
71    fV0CRMin(4.6), 
72    fV0CRBox(38.0),
73    fV0CLidThickness(0.30),
74    fV0CCellThickness(2.00),
75    fV0CBoxThickness(4.70),
76    fV0COffsetFibers(1.0),
77    fV0CLightYield(93.75),
78    fV0CLightAttenuation(0.05),
79    fV0CnMeters(15.0),
80    fV0CFibToPhot(0.3),
81    fV0AR0(4.2), 
82    fV0AR1(7.6), 
83    fV0AR2(13.8), 
84    fV0AR3(22.7),
85    fV0AR4(41.3), 
86    fV0AR5(43.3), 
87    fV0AR6(68.0),
88    fV0ASciWd(2.5), 
89    fV0APlaWd(0.5), 
90    fV0APlaAl(0.06), 
91    fV0AOctWd(0.75), 
92    fV0AFraWd(0.2),
93    fV0AOctH1(1.0), 
94    fV0AOctH2(2.0), 
95    fV0ABasHt(2.0),
96    fV0AFibRd(0.1),
97    fV0APlaEx(4.4),
98    fV0APMBWd(24.6), 
99    fV0APMBHt(22.0), 
100    fV0APMBTh(7.1), 
101    fV0APMBWdW(0.3), 
102    fV0APMBHtW(1.0),
103    fV0APMBAng(30.0), 
104    fV0APMBThW(0.3), 
105    fV0APMTR1(2.44), 
106    fV0APMTR2(2.54), 
107    fV0APMTR3(2.54),
108    fV0APMTR4(2.70), 
109    fV0APMTH(10.0), 
110    fV0APMTB(1.0),
111    fV0AnMeters(fV0AR6*0.01),
112    fV0ALightYield(93.75),
113    fV0ALightAttenuation(0.05),
114    fV0AFibToPhot(0.3),
115    fVersion(7)
116 {
117 // Standard default constructor 
118 }
119
120 //_____________________________________________________________________________
121 AliVZEROv7::AliVZEROv7(const char *name, const char *title):AliVZERO(name,title),
122    fCellId(0),
123    fTrackPosition(),
124    fTrackMomentum(), 
125    fV0CHeight1(2.5), 
126    fV0CHeight2(4.4), 
127    fV0CHeight3(7.4), 
128    fV0CHeight4(12.5),
129    fV0CRMin(4.6), 
130    fV0CRBox(38.0),
131    fV0CLidThickness(0.30),
132    fV0CCellThickness(2.00),
133    fV0CBoxThickness(4.70),
134    fV0COffsetFibers(1.0),
135    fV0CLightYield(93.75),
136    fV0CLightAttenuation(0.05),
137    fV0CnMeters(15.0),
138    fV0CFibToPhot(0.3),
139    fV0AR0(4.2), 
140    fV0AR1(7.6), 
141    fV0AR2(13.8), 
142    fV0AR3(22.7),
143    fV0AR4(41.3), 
144    fV0AR5(43.3), 
145    fV0AR6(68.0),
146    fV0ASciWd(2.5), 
147    fV0APlaWd(0.5), 
148    fV0APlaAl(0.06), 
149    fV0AOctWd(0.75), 
150    fV0AFraWd(0.2),
151    fV0AOctH1(1.0), 
152    fV0AOctH2(2.0), 
153    fV0ABasHt(2.0),
154    fV0AFibRd(0.1),
155    fV0APlaEx(4.4),
156    fV0APMBWd(24.6), 
157    fV0APMBHt(22.0), 
158    fV0APMBTh(7.1), 
159    fV0APMBWdW(0.3), 
160    fV0APMBHtW(1.0),
161    fV0APMBAng(30.0), 
162    fV0APMBThW(0.3), 
163    fV0APMTR1(2.44), 
164    fV0APMTR2(2.54), 
165    fV0APMTR3(2.54),
166    fV0APMTR4(2.70), 
167    fV0APMTH(10.0), 
168    fV0APMTB(1.0),
169    fV0AnMeters(fV0AR6*0.01),
170    fV0ALightYield(93.75),
171    fV0ALightAttenuation(0.05),
172    fV0AFibToPhot(0.3),
173    fVersion(7)
174
175
176 {
177 // Standard constructor for V-zero Detector  version 7
178
179   AliDebug(2,"Create VZERO object ");
180
181 //  fVersion            =     7;  // version number
182
183 //   // V0C Parameters related to geometry: All in cm
184 //   fV0CHeight1         =    2.5; // height of cell 1
185 //   fV0CHeight2         =    4.4; // height of cell 2
186 //   fV0CHeight3         =    7.4; // height of cell 3
187 //   fV0CHeight4         =   12.5; // height of cell 4
188 //   fV0CRMin            =    4.6; // inner radius of box
189 //   fV0CRBox            =   38.0; // outer radius of box
190 //   fV0CLidThickness    =   0.30; // thickness of Carbon lid
191 //   fV0CCellThickness   =   2.00; // thickness of elementary cell
192 //   fV0CBoxThickness    =   4.70; // thickness of V0C Box
193 //   fV0COffsetFibers    =    1.0; // offset to output fibers
194 //   // V0C Parameters related to light output
195 //   fV0CLightYield         =  93.75; // Light yield in BC408 (93.75 eV per photon)
196 //   fV0CLightAttenuation   =   0.05; // Light attenuation in fiber (0.05 per meter)
197 //   fV0CnMeters            =   15.0; // Number of meters of clear fibers to PM
198 //   fV0CFibToPhot          =    0.3; // Attenuation at fiber-photocathode interface
199 // 
200 //   // V0A Parameters related to geometry: All in cm
201 //   fV0AR0     =  4.2;  // Radius of hole
202 //   fV0AR1     =  7.6;  // Maximun radius of 1st cell
203 //   fV0AR2     = 13.8; // Maximun radius of 2nd cell
204 //   fV0AR3     = 22.7; // Maximun radius of 3rd cell
205 //   fV0AR4     = 41.3; // Maximun radius of 4th cell
206 //   fV0AR5     = 43.3; // Radius circunscrite to innermost octagon
207 //   fV0AR6     = 68.0; // Radius circunscrite to outtermost octagon
208 //   fV0ASciWd  =  2.5;  // Scintillator thickness 
209 //   fV0APlaWd  =  0.5;  // Plates thinckness
210 //   fV0APlaAl  = 0.06; // Plates AlMg3 thinckness
211 //   fV0AOctWd  = 0.75; // Innermost octagon thickness
212 //   fV0AOctH1  =  1.0;  // Height of innermost octagon
213 //   fV0AOctH2  =  2.0;  // Height of outtermost octagon
214 //   fV0AFibRd  =  0.1;  // Radius of Fiber
215 //   fV0AFraWd  =  0.2;  // Support Frame thickness
216 //   fV0APMBWd  = 24.6;  // Width of PM Box
217 //   fV0APMBHt  = 22.0;  // Height of PM Box
218 //   fV0APMBTh  =  7.1;  // Thickness of PM Box
219 //   fV0APMBWdW =  0.3;  // Thickness of PM Box Side1 Wall
220 //   fV0APMBHtW =  1.0;  // Thickness of PM Box Side2 Wall
221 //   fV0APMBThW =  0.3;  // Thickness of PM Box Top Wall
222 //   fV0APMBAng = 30.0;  // Angle between PM Box and Support
223 //   fV0APMTR1  = 2.44;  // PMT Glass
224 //   fV0APMTR2  = 2.54;  // PMT Glass
225 //   fV0APMTR3  = 2.54;  // PMT Cover
226 //   fV0APMTR4  = 2.70;  // PMT Cover
227 //   fV0APMTH   = 10.0;  // PMT Height
228 //   fV0APMTB   =  1.0;  // PMT Basis
229 //   fV0APlaEx  =  4.4;  // Plates Extension height
230 //   fV0ABasHt  =  2.0;  // Basis Height
231 //   // V0A Parameters related to light output
232 //   fV0ALightYield         =  93.75;      // Light yield in BC404
233 //   fV0ALightAttenuation   =   0.05;      // Light attenuation in WLS fiber, per meter
234 //   fV0AnMeters            = fV0AR6*0.01; // Tentative value, in meters
235 //   fV0AFibToPhot          =    0.3;      // Attenuation at fiber-photocathode interface
236 }
237 //_____________________________________________________________________________
238
239 void AliVZEROv7::BuildGeometry()
240
241 }
242             
243 //_____________________________________________________________________________
244 void AliVZEROv7::CreateGeometry()
245 {
246 // Constructs TGeo geometry 
247
248   AliDebug(2,"VZERO ConstructGeometry");
249   TGeoVolume *top = gGeoManager->GetVolume("ALIC");
250
251   ///////////////////////////////////////////////////////////////////////////
252   // Construct the geometry of V0C Detector. Brigitte CHEYNIS
253   
254     const int kColorVZERO  = kGreen;
255     TGeoMedium *medV0CAlu = gGeoManager->GetMedium("VZERO_V0CAlu");
256     TGeoMedium *medV0CCar = gGeoManager->GetMedium("VZERO_V0CCar");
257     TGeoMedium *medV0CSci = gGeoManager->GetMedium("VZERO_V0CSci");
258     TGeoVolume *v0RI = new TGeoVolumeAssembly("V0RI");
259     Float_t heightRight, r4Right;
260     Float_t zdet = 90.0 - 0.5 - fV0CBoxThickness/2.0;
261     heightRight  = fV0CHeight1 + fV0CHeight2 + fV0CHeight3 + fV0CHeight4;
262     r4Right      = fV0CRMin + heightRight + 3.0*0.2; // 3 spacings of 2mm between rings
263
264     // Creation of  carbon lids (3.0 mm thick) to keep V0C box shut :
265     Float_t   partube[3];
266     partube[0] =   fV0CRMin;
267     partube[1] =   fV0CRBox;
268     partube[2] =   fV0CLidThickness/2.0;
269     TGeoTube   *sV0CA = new TGeoTube("V0CA", partube[0], partube[1], partube[2]);
270     TGeoVolume *v0CA  = new TGeoVolume("V0CA",sV0CA,medV0CCar);
271     TGeoTranslation *tr2 = new TGeoTranslation(0.,0., fV0CBoxThickness/2.0-partube[2]);
272     TGeoTranslation *tr3 = new TGeoTranslation(0.,0.,-fV0CBoxThickness/2.0+partube[2]);
273     v0RI->AddNode(v0CA,1,tr2);
274     v0RI->AddNode(v0CA,2,tr3);
275     v0CA->SetLineColor(kYellow);
276
277     // Creation of aluminum rings 3.0 mm thick to maintain the v0RI pieces : 
278     partube[0] =   fV0CRMin - 0.3;
279     partube[1] =   fV0CRMin;
280     partube[2] =   fV0CBoxThickness/2.0;
281     TGeoTube   *sV0IR = new TGeoTube("V0IR", partube[0], partube[1], partube[2]);
282     TGeoVolume *v0IR  = new TGeoVolume("V0IR",sV0IR,medV0CAlu);
283     v0RI->AddNode(v0IR,1,0);
284     v0IR->SetLineColor(kYellow);
285     partube[0] =   fV0CRBox;
286     partube[1] =   fV0CRBox + 0.3; 
287     partube[2] =   fV0CBoxThickness/2.0;
288     TGeoTube   *sV0ER = new TGeoTube("V0ER", partube[0], partube[1], partube[2]);
289     TGeoVolume *v0ER  = new TGeoVolume("V0ER",sV0ER,medV0CAlu);
290     v0RI->AddNode(v0ER,1,0);
291     v0ER->SetLineColor(kYellow);
292
293     // Creation of assembly V0R0 of scintillator cells within one sector
294     TGeoVolume *v0R0 = new TGeoVolumeAssembly("V0R0");                                            
295
296     // Elementary cell of ring 1  - right part - :
297     // (cells of ring 1 will be shifted by 2.0 cm backwards to output fibers)
298     Float_t   r1Right =  fV0CRMin + fV0CHeight1;
299     Float_t   offset  = fV0CBoxThickness/2.0 - fV0CLidThickness - fV0CCellThickness/2.0;   
300     Float_t   partubs[5];   
301     partubs[0]     =  fV0CRMin;
302     partubs[1]     =  r1Right;
303     partubs[2]     =  fV0CCellThickness/2.0;
304     partubs[3]     =  90.0-22.5;
305     partubs[4]     = 135.0-22.5;
306     TGeoTubeSeg *sV0R1 = new TGeoTubeSeg("V0R1", partubs[0], partubs[1], partubs[2],
307                                          partubs[3], partubs[4]);
308     TGeoVolume  *v0R1  = new TGeoVolume("V0R1",sV0R1,medV0CSci);                                       
309     TGeoTranslation *tr4 = new TGeoTranslation(0.,0.,-offset);
310     v0R0->AddNode(v0R1,1,tr4);
311     v0R1->SetLineColor(kColorVZERO);
312
313     // Elementary cell of ring 2 - right part - :
314     // (cells of ring 2 will be shifted by 1.0 cm backwards to output fibers)
315     Float_t   r2Right  =  r1Right + fV0CHeight2;  
316     partubs[0]     =  r1Right;  //  must be equal to 7.1
317     partubs[1]     =  r2Right;  //  must be equal to 11.5
318     TGeoTubeSeg *sV0R2 = new TGeoTubeSeg("V0R2", partubs[0], partubs[1], partubs[2],
319                                          partubs[3], partubs[4]);
320     TGeoVolume  *v0R2  = new TGeoVolume("V0R2",sV0R2,medV0CSci);
321     TGeoTranslation *tr5 = new TGeoTranslation(0.0,0.2,-offset + fV0COffsetFibers);
322     v0R0->AddNode(v0R2,1,tr5);
323     v0R2->SetLineColor(kColorVZERO);
324
325     // Ring 3 - right part -  :
326     r2Right  =  r2Right + 0.2;
327     Float_t   r3Right  =  r2Right + fV0CHeight3;     
328     partubs[0]     =  r2Right;  //  must be equal to 11.7
329     partubs[1]     =  r3Right;  //  must be equal to 19.1
330     partubs[3]     =  90.0-22.5;
331     partubs[4]     = 112.5-22.5;
332     TGeoTubeSeg *sV0R3 = new TGeoTubeSeg("V0R3", partubs[0], partubs[1], partubs[2],
333                                          partubs[3], partubs[4]);
334     TGeoVolume  *v0R3  = new TGeoVolume("V0R3",sV0R3,medV0CSci);
335     TGeoTranslation *tr6 = new TGeoTranslation(0.,0.2,-offset + 2.0*fV0COffsetFibers);
336     v0R0->AddNode(v0R3,1,tr6);
337     v0R3->SetLineColor(kColorVZERO);
338     partubs[3]     = 112.5-22.5;
339     partubs[4]     = 135.0-22.5;
340     TGeoTubeSeg *sV0R4 = new TGeoTubeSeg("V0R4", partubs[0], partubs[1], partubs[2],
341                                          partubs[3], partubs[4]);
342     TGeoVolume  *v0R4  = new TGeoVolume("V0R4",sV0R4,medV0CSci);
343     v0R0->AddNode(v0R4,1,tr6);
344     v0R4->SetLineColor(kColorVZERO);
345   
346     // Ring 4 - right part -  : 
347     Float_t x = TMath::ATan(3.5/257.5) * ((180./TMath::Pi()));
348     r3Right = r3Right + 0.2 + 0.2;   // + 0.2 because no shift in translation here !!
349     partubs[0]     =  r3Right;  //  must be equal to 19.5
350     partubs[1]     =  r4Right;  //  must be equal to 32.0
351     partubs[3]     =  90.0-22.5+x;
352     partubs[4]     = 112.5-22.5-x;
353     TGeoTubeSeg *sV0R5 = new TGeoTubeSeg("V0R5", partubs[0], partubs[1], partubs[2],
354                                          partubs[3], partubs[4]);
355     TGeoVolume  *v0R5  = new TGeoVolume("V0R5",sV0R5,medV0CSci);
356     TGeoTranslation *tr7 = new TGeoTranslation(0.,0.0,-offset + 2.0*fV0COffsetFibers);                                        
357     v0R0->AddNode(v0R5,1,tr7);
358     v0R5->SetLineColor(kColorVZERO);
359     partubs[3]     = 112.5-22.5+x;
360     partubs[4]     = 135.0-22.5-x;
361     TGeoTubeSeg *sV0R6 = new TGeoTubeSeg("V0R6", partubs[0], partubs[1], partubs[2],
362                                          partubs[3], partubs[4]);
363     TGeoVolume  *v0R6  = new TGeoVolume("V0R6",sV0R6,medV0CSci);
364     v0R0->AddNode(v0R6,1,tr7);
365     v0R6->SetLineColor(kColorVZERO);
366     Float_t  phi;
367     Float_t  phiDeg= 180./4.;
368     Int_t    nsecR = 1;     // number of sectors in right part of V0
369     for (phi = 22.5; phi < 360.0; phi = phi + phiDeg) {
370       TGeoRotation  *rot1 = new TGeoRotation("rot1", 90.0, +phi, 90., 90.+phi, 0.0, 0.0 ); 
371       v0RI->AddNode(v0R0,nsecR,rot1);    
372       nsecR++;        
373     }
374
375   ///////////////////////////////////////////////////////////////////////////
376   // Construct the geometry of V0A Detector. Carlos PEREZ, PUCP
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     const int kV0AColorBas   = 20;
387     TGeoMedium *medV0ASci = gGeoManager->GetMedium("VZERO_V0ASci");
388     TGeoMedium *medV0APlaIn = gGeoManager->GetMedium("VZERO_V0APlaIn");
389     TGeoMedium *medV0APlaOu = gGeoManager->GetMedium("VZERO_V0APlaOu");
390     TGeoMedium *medV0ASup = gGeoManager->GetMedium("VZERO_V0ALuc");
391     TGeoMedium *medV0AFra = gGeoManager->GetMedium("VZERO_V0ALuc");
392     TGeoMedium *medV0AFib = gGeoManager->GetMedium("VZERO_V0AFib");
393     TGeoMedium *medV0APMGlass = gGeoManager->GetMedium("VZERO_V0APMG");
394     TGeoMedium *medV0APMAlum = gGeoManager->GetMedium("VZERO_V0APMA");
395     TGeoMedium *medV0ABas = gGeoManager->GetMedium("VZERO_V0ALuc");
396     double pi = TMath::Pi();
397     double sin225   = TMath::Sin(pi/8.);
398     double cos225   = TMath::Cos(pi/8.);
399     double ctg225   = cos225/sin225;
400     double sin45    = TMath::Sin(pi/4.); // lucky: Sin45=Cos45
401     double v0APts[16];
402
403     ////////////////////////////
404     /// Definition of one sector
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("sV0ACha","sV0ACha1+sV0ACha2");
428
429     /// Frame
430     TGeoVolume *v0AFra = new TGeoVolumeAssembly("V0AFra");
431     for (int i=0;i<2;i++) {
432       v0APts[0+8*i] = fV0AR0-fV0AFraWd/2.;  v0APts[1+8*i] = 0.;
433       v0APts[2+8*i] = fV0AR0-fV0AFraWd/2.;  v0APts[3+8*i] = fV0AFraWd/2.;
434       v0APts[4+8*i] = fV0AR4+fV0AFraWd/2.;  v0APts[5+8*i] = fV0AFraWd/2.;
435       v0APts[6+8*i] = fV0AR4+fV0AFraWd/2.;  v0APts[7+8*i] = 0.;
436     }
437     TGeoArb8 *sV0AFraB1 = new TGeoArb8("sV0AFraB1",fV0ASciWd/2.,v0APts);
438     TGeoVolume *v0AFraB1 = new TGeoVolume("V0AFraB1",sV0AFraB1,medV0AFra);
439     for (int i=0;i<2;i++) {
440       v0APts[0+8*i] = fV0AR0*sin45;
441       v0APts[1+8*i] = (fV0AR0-fV0AFraWd)*sin45;
442       v0APts[2+8*i] = (fV0AR0-fV0AFraWd/2.)*sin45;
443       v0APts[3+8*i] = (fV0AR0-fV0AFraWd/2.)*sin45;
444       v0APts[4+8*i] = (fV0AR4+fV0AFraWd/2.)*sin45;
445       v0APts[5+8*i] = (fV0AR4+fV0AFraWd/2.)*sin45;
446       v0APts[6+8*i] = (fV0AR4+fV0AFraWd)*sin45;
447       v0APts[7+8*i] = fV0AR4*sin45;
448     }
449     TGeoArb8 *sV0AFraB2 = new TGeoArb8("sV0AFraB2", fV0ASciWd/2., v0APts);
450     TGeoVolume *v0AFraB2 = new TGeoVolume("V0AFraB2",sV0AFraB2,medV0AFra);
451     v0AFraB1->SetLineColor(kV0AColorFra); v0AFraB2->SetLineColor(kV0AColorFra);
452     v0AFra->AddNode(v0AFraB1,1);
453     v0AFra->AddNode(v0AFraB2,1);  // Prefer 2 GeoObjects insted of 3 GeoMovements
454     new TGeoTubeSeg( "sV0AFraR1b", fV0AR0-fV0AFraWd/2.,
455                      fV0AR0+fV0AFraWd/2., fV0ASciWd/2., 0, 45);
456     new TGeoTubeSeg( "sV0AFraR2b", fV0AR1-fV0AFraWd/2.,
457                      fV0AR1+fV0AFraWd/2., fV0ASciWd/2., 0, 45);
458     new TGeoTubeSeg( "sV0AFraR3b", fV0AR2-fV0AFraWd/2.,
459                      fV0AR2+fV0AFraWd/2., fV0ASciWd/2., 0, 45);
460     new TGeoTubeSeg( "sV0AFraR4b", fV0AR3-fV0AFraWd/2.,
461                      fV0AR3+fV0AFraWd/2., fV0ASciWd/2., 0, 45);
462     new TGeoTubeSeg( "sV0AFraR5b", fV0AR4-fV0AFraWd/2.,
463                      fV0AR4+fV0AFraWd/2., fV0ASciWd/2., 0, 45);
464     TGeoCompositeShape *sV0AFraR1 = new TGeoCompositeShape("sV0AFraR1","sV0AFraR1b-sV0ACha");
465     TGeoCompositeShape *sV0AFraR2 = new TGeoCompositeShape("sV0AFraR2","sV0AFraR2b-sV0ACha");
466     TGeoCompositeShape *sV0AFraR3 = new TGeoCompositeShape("sV0AFraR3","sV0AFraR3b-sV0ACha");
467     TGeoCompositeShape *sV0AFraR4 = new TGeoCompositeShape("sV0AFraR4","sV0AFraR4b-sV0ACha");
468     TGeoCompositeShape *sV0AFraR5 = new TGeoCompositeShape("sV0AFraR5","sV0AFraR5b-sV0ACha");
469     TGeoVolume *v0AFraR1 = new TGeoVolume("V0AFraR1",sV0AFraR1,medV0AFra);
470     TGeoVolume *v0AFraR2 = new TGeoVolume("V0AFraR2",sV0AFraR2,medV0AFra);
471     TGeoVolume *v0AFraR3 = new TGeoVolume("V0AFraR3",sV0AFraR3,medV0AFra);
472     TGeoVolume *v0AFraR4 = new TGeoVolume("V0AFraR4",sV0AFraR4,medV0AFra);
473     TGeoVolume *v0AFraR5 = new TGeoVolume("V0AFraR5",sV0AFraR5,medV0AFra);
474     v0AFraR1->SetLineColor(kV0AColorFra); v0AFraR2->SetLineColor(kV0AColorFra);
475     v0AFraR3->SetLineColor(kV0AColorFra); v0AFraR4->SetLineColor(kV0AColorFra);
476     v0AFraR5->SetLineColor(kV0AColorFra);
477     v0AFra->AddNode(v0AFraR1,1);
478     v0AFra->AddNode(v0AFraR2,1);
479     v0AFra->AddNode(v0AFraR3,1);
480     v0AFra->AddNode(v0AFraR4,1);
481     v0AFra->AddNode(v0AFraR5,1);
482     v0ASec->AddNode(v0AFra,1);
483
484     /// Sensitive scintilator
485     TGeoVolume *v0ASci = new TGeoVolumeAssembly("V0ASci");
486     new TGeoTubeSeg( "sV0AR1b", fV0AR0+fV0AFraWd/2.,
487                      fV0AR1-fV0AFraWd/2., fV0ASciWd/2., 0, 45);
488     new TGeoTubeSeg( "sV0AR2b", fV0AR1+fV0AFraWd/2.,
489                      fV0AR2-fV0AFraWd/2., fV0ASciWd/2., 0, 45);
490     new TGeoTubeSeg( "sV0AR3b", fV0AR2+fV0AFraWd/2.,
491                      fV0AR3-fV0AFraWd/2., fV0ASciWd/2., 0, 45);
492     new TGeoTubeSeg( "sV0AR4b", fV0AR3+fV0AFraWd/2.,
493                      fV0AR4-fV0AFraWd/2., fV0ASciWd/2., 0, 45);
494     TGeoCompositeShape *sV0AR1 = new TGeoCompositeShape("sV0AR1","sV0AR1b-sV0ACha");
495     TGeoCompositeShape *sV0AR2 = new TGeoCompositeShape("sV0AR2","sV0AR2b-sV0ACha");
496     TGeoCompositeShape *sV0AR3 = new TGeoCompositeShape("sV0AR3","sV0AR3b-sV0ACha");
497     TGeoCompositeShape *sV0AR4 = new TGeoCompositeShape("sV0AR4","sV0AR4b-sV0ACha");
498     TGeoVolume *v0L1 = new TGeoVolume("V0L1",sV0AR1,medV0ASci);
499     TGeoVolume *v0L2 = new TGeoVolume("V0L2",sV0AR2,medV0ASci);
500     TGeoVolume *v0L3 = new TGeoVolume("V0L3",sV0AR3,medV0ASci);
501     TGeoVolume *v0L4 = new TGeoVolume("V0L4",sV0AR4,medV0ASci);
502     v0L1->SetLineColor(kV0AColorSci); v0L2->SetLineColor(kV0AColorSci);
503     v0L3->SetLineColor(kV0AColorSci); v0L4->SetLineColor(kV0AColorSci);
504     v0ASec->AddNode(v0L1,1);
505     v0ASec->AddNode(v0L2,1);
506     v0ASec->AddNode(v0L3,1);
507     v0ASec->AddNode(v0L4,1);
508
509     /// Non-sensitive scintilator
510     for (int i=0;i<2;i++) {
511       v0APts[0+8*i] = fV0AR4;
512       v0APts[1+8*i] = fV0AFraWd/2.;
513       v0APts[2+8*i] = fV0AR4*sin45;
514       v0APts[3+8*i] = (fV0AR4-fV0AFraWd)*sin45;
515       v0APts[4+8*i] = fV0AR5/cos225*sin45+fV0AFraWd/2.*sin225;
516       v0APts[5+8*i] = fV0AR5/cos225*sin45-fV0AFraWd/2.*cos225;
517       v0APts[6+8*i] = fV0AR5/cos225-fV0AFraWd/2./ctg225;
518       v0APts[7+8*i] = fV0AFraWd/2.;
519     }
520     new TGeoArb8("sV0AR5S1", fV0ASciWd/2., v0APts);
521     new TGeoTubeSeg("sV0AR5S2", fV0AR4-(v0APts[6]-v0APts[0]),
522                     fV0AR4+fV0AFraWd/2., fV0ASciWd/2.+2*preShape, 0, 45);
523     TGeoCompositeShape *sV0AR5 = new TGeoCompositeShape("V0AR5","(sV0AR5S1 - sV0AR5S2)");
524     TGeoVolume *v0AR5 = new TGeoVolume("V0AR5",sV0AR5,medV0ASci);
525     v0AR5->SetLineColor(kV0AColorSci);
526     v0ASci->AddNode(v0AR5,1);
527     v0ASec->AddNode(v0ASci,1);
528
529     /// Segment of innermost octagon
530     TGeoVolume *v0ASup = new TGeoVolumeAssembly("V0ASup");
531     for (int i=0;i<2;i++) {
532       v0APts[0+8*i] = (fV0AR5-fV0AOctH1)/cos225;        v0APts[1+8*i] = 0.;
533       v0APts[2+8*i] = (fV0AR5-fV0AOctH1)/cos225*sin45;  v0APts[3+8*i] = (fV0AR5-fV0AOctH1)/cos225*sin45;
534       v0APts[4+8*i] = fV0AR5/cos225*sin45;              v0APts[5+8*i] = fV0AR5/cos225*sin45;
535       v0APts[6+8*i] = fV0AR5/cos225;                    v0APts[7+8*i] = 0.;
536     }
537     TGeoArb8 *sV0AOct1 = new TGeoArb8("sV0AOct1", fV0AOctWd/2., v0APts);
538     TGeoVolume *v0AOct1 = new TGeoVolume("V0AOct1",sV0AOct1,medV0ASup);
539     v0AOct1->SetLineColor(kV0AColorOct);
540     v0ASup->AddNode(v0AOct1,1,new TGeoTranslation(0,0,(fV0ASciWd+fV0AOctWd)/2.));
541     v0ASup->AddNode(v0AOct1,2,new TGeoTranslation(0,0,-(fV0ASciWd+fV0AOctWd)/2.));
542
543     /// Segment of outtermost octagon
544     for (int i=0;i<2;i++) {
545       v0APts[0+8*i] = (fV0AR6-fV0AOctH2)/cos225;        v0APts[1+8*i] = 0.;
546       v0APts[2+8*i] = (fV0AR6-fV0AOctH2)/cos225*sin45;  v0APts[3+8*i] = (fV0AR6-fV0AOctH2)/cos225*sin45;
547       v0APts[4+8*i] = fV0AR6/cos225*sin45;              v0APts[5+8*i] = fV0AR6/cos225*sin45;
548       v0APts[6+8*i] = fV0AR6/cos225;                    v0APts[7+8*i] = 0.;
549     }
550     TGeoArb8 *sV0AOct2 = new TGeoArb8("sV0AOct2", (fV0ASciWd+2*fV0AOctWd)/2., v0APts);
551     TGeoVolume *v0AOct2 = new TGeoVolume("V0AOct2", sV0AOct2,medV0ASup);
552     v0AOct2->SetLineColor(kV0AColorOct);
553     v0ASup->AddNode(v0AOct2,1);
554     v0ASec->AddNode(v0ASup,1);
555
556     /// Bunch of fibers
557     v0APts[ 0] = v0APts[ 2] = -12.5;
558     v0APts[ 1] = v0APts[ 7] = (fV0ASciWd+fV0AOctWd)/2.-0.01;
559     v0APts[ 3] = v0APts[ 5] = (fV0ASciWd+fV0AOctWd)/2.+0.01;
560     v0APts[ 4] = v0APts[ 6] = +12.5;
561     v0APts[ 8] = v0APts[10] = -0.5;
562     v0APts[ 9] = v0APts[15] = 0.;
563     v0APts[11] = v0APts[13] = 0.25;
564     v0APts[12] = v0APts[14] = +0.5;
565     TGeoArb8 *sV0AFib = new TGeoArb8("sV0AFib", (fV0AR6-fV0AR5-fV0AOctH2-0.006)/2., v0APts);
566     TGeoVolume *v0AFib1 = new TGeoVolume("V0AFib1",sV0AFib,medV0AFib);
567     TGeoVolume *v0AFib = new TGeoVolumeAssembly("V0AFib");
568     TGeoRotation *rot = new TGeoRotation("rot");
569     rot->RotateX(-90);
570     rot->RotateZ(-90.+22.5);
571     v0AFib->AddNode(v0AFib1,1,rot);
572     rot = new TGeoRotation("rot");
573     rot->RotateX(-90);
574     rot->RotateY(180);
575     rot->RotateZ(-90.+22.5);
576     v0AFib->SetLineColor(kV0AColorFib);
577     v0AFib->AddNode(v0AFib1,2,rot);
578     v0ASec->AddNode(v0AFib,1,new TGeoTranslation((fV0AR6-fV0AOctH2+fV0AR5)*cos225/2.,
579                                                  (fV0AR6-fV0AOctH2+fV0AR5)*sin225/2., 0));
580
581     /// Plates
582     for (int i=0;i<2;i++) {
583       v0APts[0+8*i] = fV0AR0;                   v0APts[1+8*i] = 0.;
584       v0APts[2+8*i] = fV0AR0*sin45;             v0APts[3+8*i] = fV0AR0*sin45;
585       v0APts[4+8*i] = fV0AR6/cos225 * sin45;    v0APts[5+8*i] = fV0AR6/cos225*sin45;
586       v0APts[6+8*i] = fV0AR6/cos225;            v0APts[7+8*i] = 0.;
587     }
588     TGeoArb8 *sV0APlaIn = new TGeoArb8("sV0APlaIn", (fV0APlaWd-2*fV0APlaAl)/2., v0APts);
589     TGeoVolume *v0APlaIn = new TGeoVolume("V0APlaIn", sV0APlaIn, medV0APlaIn);
590     TGeoArb8 *sV0APlaOu = new TGeoArb8("sV0APlaOu", fV0APlaAl/2., v0APts);
591     TGeoVolume *v0APlaOu = new TGeoVolume("V0APlaOu", sV0APlaOu, medV0APlaOu);
592     v0APlaIn->SetLineColor(kV0AColorPlaIn); v0APlaOu->SetLineColor(kV0AColorPlaOu);
593     TGeoVolume *v0APla = new TGeoVolumeAssembly("V0APla");
594     v0APla->AddNode(v0APlaIn,1);
595     v0APla->AddNode(v0APlaOu,1,new TGeoTranslation(0,0,(fV0APlaWd-fV0APlaAl)/2.));
596     v0APla->AddNode(v0APlaOu,2,new TGeoTranslation(0,0,-(fV0APlaWd-fV0APlaAl)/2.));
597     v0ASec->AddNode(v0APla,1,new TGeoTranslation(0,0,(fV0ASciWd+2*fV0AOctWd+fV0APlaWd)/2.));
598     v0ASec->AddNode(v0APla,2,new TGeoTranslation(0,0,-(fV0ASciWd+2*fV0AOctWd+fV0APlaWd)/2.));
599
600     /// 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  +  fV0APMBHt/2. * sinAngPMB  +  fV0APMBTh/2. * cosAngPMB;
639     v0ASec->AddNode(v0APM,1, new TGeoCombiTrans( shiftR*cos225, shiftR*sin225, shiftZ, rot));
640
641     /// End of sector definition
642     ////////////////////////////
643
644     /// Replicate sectors
645     TGeoVolume *v0LE = new TGeoVolumeAssembly("V0LE");
646     for(int i=0; i<8; i++) {
647       TGeoRotation *rot = new TGeoRotation("rot", 90., i*45.+90, 90., 90.+i*45.+90, 0., 0.);
648       v0LE->AddNode(v0ASec,i+1,rot);  /// modificacion +1 anhadido
649     }
650   
651     /// Basis Construction
652     rot = new TGeoRotation("rot"); rot->RotateX(90-fV0APMBAng); rot->RotateZ(-22.5);
653     TGeoCombiTrans *pos1 = new TGeoCombiTrans("pos1", shiftR*sin225, shiftR*cos225, shiftZ, rot);
654     pos1->RegisterYourself();
655     for (int i=0;i<2;i++) {
656       v0APts[0+8*i] = fV0AR6/cos225*sin45;  v0APts[1+8*i] = fV0AR6/cos225*sin45;
657       v0APts[2+8*i] = 0;                    v0APts[3+8*i] = fV0AR6/cos225;
658       v0APts[4+8*i] = 0;                    v0APts[5+8*i] = fV0AR6/cos225+fV0APlaEx;
659       v0APts[6+8*i] = fV0AR6/cos225-(fV0AR6/cos225+fV0APlaEx)/ctg225;
660       v0APts[7+8*i] = fV0AR6/cos225+fV0APlaEx;
661     }
662     new TGeoArb8("sV0APlaExIn1", (fV0APlaWd-2*fV0APlaAl)/2., v0APts);
663     new TGeoArb8("sV0APlaExOu1", fV0APlaAl/2., v0APts);
664     TGeoCompositeShape *sV0APlaExIn = new TGeoCompositeShape("sV0APlaExIn","sV0APlaExIn1-sV0APMB1:pos1");
665     TGeoVolume *v0APlaExIn = new TGeoVolume("V0APlaExIn", sV0APlaExIn, medV0APlaIn);
666     TGeoCompositeShape *sV0APlaExOu = new TGeoCompositeShape("sV0APlaExOu","sV0APlaExOu1-sV0APMB1:pos1");
667     TGeoVolume *v0APlaExOu = new TGeoVolume("V0APlaExOu", sV0APlaExOu, medV0APlaOu);
668     v0APlaExIn->SetLineColor(kV0AColorPlaIn); v0APlaExOu->SetLineColor(kV0AColorPlaOu);
669     TGeoVolume *v0APlaEx = new TGeoVolumeAssembly("V0APlaEx");
670     v0APlaEx->AddNode(v0APlaExIn,1);
671     v0APlaEx->AddNode(v0APlaExOu,1,new TGeoTranslation(0,0,(fV0APlaWd-fV0APlaAl)/2.));
672     v0APlaEx->AddNode(v0APlaExOu,2,new TGeoTranslation(0,0,-(fV0APlaWd-fV0APlaAl)/2.));
673     for (int i=0;i<2;i++) {
674       v0APts[0+8*i] = fV0AR6/cos225-(fV0AR6/cos225+fV0APlaEx)/ctg225-fV0ABasHt*sin45;
675       v0APts[1+8*i] = fV0AR6/cos225+fV0APlaEx-fV0ABasHt*sin45;
676       v0APts[2+8*i] = 0;  v0APts[3+8*i] = fV0AR6/cos225+fV0APlaEx-fV0ABasHt;
677       v0APts[4+8*i] = 0;  v0APts[5+8*i] = fV0AR6/cos225+fV0APlaEx;
678       v0APts[6+8*i] = fV0AR6/cos225-(fV0AR6/cos225+fV0APlaEx)/ctg225;
679       v0APts[7+8*i] = fV0AR6/cos225+fV0APlaEx;
680     }
681     new TGeoArb8("sV0ABas1", (fV0ASciWd+2*fV0AOctWd)/2., v0APts);
682     TGeoCompositeShape *sV0ABas = new TGeoCompositeShape("sV0ABas","sV0ABas1-sV0APMB1:pos1");
683     TGeoVolume *v0ABas = new TGeoVolume("V0ABas", sV0ABas, medV0ABas);
684     v0ABas->SetLineColor(kV0AColorBas);
685     TGeoVolume *v0ABasis = new TGeoVolumeAssembly("V0ABasis");
686     rot = new TGeoRotation("rot",90.,180.,90.,90.,0.,0.);
687     v0ABasis->AddNode(v0APlaEx,1, new TGeoTranslation(0,0,(fV0ASciWd+2*fV0AOctWd+fV0APlaWd)/2.));
688     v0ABasis->AddNode(v0APlaEx,2, new TGeoTranslation(0,0,-(fV0ASciWd+2*fV0AOctWd+fV0APlaWd)/2.));
689     v0ABasis->AddNode(v0APlaEx,3, new TGeoCombiTrans(0,0,(fV0ASciWd+2*fV0AOctWd+fV0APlaWd)/2.,rot));
690     v0ABasis->AddNode(v0APlaEx,4, new TGeoCombiTrans(0,0,-(fV0ASciWd+2*fV0AOctWd+fV0APlaWd)/2.,rot));
691     v0ABasis->AddNode(v0ABas,1);
692     v0ABasis->AddNode(v0ABas,2,rot);
693     rot = new TGeoRotation("rot");
694     rot->RotateZ(180);
695     v0LE->AddNode(v0ABasis,1,rot);
696
697     // Adding detectors to top volume
698     TGeoVolume *vZERO = new TGeoVolumeAssembly("VZERO");
699     vZERO->AddNode(v0RI,1,new TGeoTranslation(0, 0, -zdet));
700     // V0A position according to TB decision 13/12/2005 
701     vZERO->AddNode(v0LE,1,new TGeoTranslation(0, 0, +327.5));
702     top->AddNode(vZERO,1);
703 }
704
705 //_____________________________________________________________________________
706 void AliVZEROv7::AddAlignableVolumes() const
707 {
708   //
709   // Create entries for alignable volumes associating the symbolic volume
710   // name with the corresponding volume path. Needs to be syncronized with
711   // eventual changes in the geometry.
712   // 
713   TString vpC = "/ALIC_1/VZERO_1/V0RI_1";
714   TString vpA = "/ALIC_1/VZERO_1/V0LE_1";
715   TString snC = "VZERO/V0C";
716   TString snA = "VZERO/V0A";
717   
718   if(!gGeoManager->SetAlignableEntry(snC.Data(),vpC.Data()))
719     AliFatal(Form("Alignable entry %s not created. Volume path %s not valid", snC.Data(),vpC.Data()));
720   if(!gGeoManager->SetAlignableEntry(snA.Data(),vpA.Data()))
721     AliFatal(Form("Alignable entry %s not created. Volume path %s not valid", snA.Data(),vpA.Data()));
722
723
724
725 //_____________________________________________________________________________
726 void AliVZEROv7::CreateMaterials()
727 {
728
729 // Creates materials used for geometry 
730
731   AliDebug(2,"Create materials");
732   // Parameters for simulation scope
733   Int_t     fieldType       = gAlice->Field()->Integ();     // Field type 
734   Double_t  maxField        = gAlice->Field()->Max();       // Field max.
735   Double_t  maxBending      = 10;    // Max Angle
736   Double_t  maxStepSize     = 0.01;  // Max step size 
737   Double_t  maxEnergyLoss   = 1;     // Max Delta E
738   Double_t  precision       = 0.003; // Precision
739   Double_t  minStepSize     = 0.003; // Minimum step size 
740
741   Int_t    id;
742   Double_t a, z, radLength, absLength;
743   Float_t density, as[4], zs[4], ws[4];
744
745 // Parameters  for V0CPrePlates: Aluminium
746    a = 26.98; 
747    z = 13.00;
748    density     = 2.7;
749    radLength   = 8.9;
750    absLength   = 37.2;
751    id = 2;
752    AliMaterial( id, "V0CAlu", a, z, density, radLength, absLength, 0, 0);
753    AliMedium(id, "V0CAlu", id, 1, fieldType, maxField, maxBending, maxStepSize,
754              maxEnergyLoss, precision, minStepSize);
755                     
756 // Parameters  for V0CPlates: Carbon 
757    a = 12.01; 
758    z =  6.00;
759    density   = 2.265;
760    radLength = 18.8;
761    absLength = 49.9;
762    id = 3;
763    AliMaterial(id, "V0CCar",  a, z, density, radLength, absLength, 0, 0);
764    AliMedium(id, "V0CCar", id, 1, fieldType, maxField, maxBending, maxStepSize,
765              maxEnergyLoss, precision, minStepSize);
766             
767 // Parameters  for V0Cscintillator: BC408
768    as[0] = 1.00794;     as[1] = 12.011;
769    zs[0] = 1.;          zs[1] = 6.;
770    ws[0] = 1.;          ws[1] = 1.;
771    density      = 1.032;
772    id           = 4;
773    AliMixture(id, "V0CSci", as, zs, density, -2, ws);
774    AliMedium(id,"V0CSci", id, 1, fieldType, maxField, maxBending, maxStepSize,
775              maxEnergyLoss, precision, minStepSize);
776
777 // Parameters for V0Ascintilator: BC404
778    as[0] = 1.00794;     as[1] = 12.011;
779    zs[0] = 1.;          zs[1] = 6.;
780    ws[0] = 5.21;        ws[1] = 4.74;
781    density      = 1.032;
782    id           = 5;
783    AliMixture(id, "V0ASci", as, zs, density, -2, ws);
784    AliMedium(id,  "V0ASci", id, 1, fieldType, maxField, maxBending, maxStepSize,
785              maxEnergyLoss, precision, minStepSize);
786
787 // Parameters for V0ALuc: Lucita but for the simulation BC404
788    as[0] = 1.00794;     as[1] = 12.011;
789    zs[0] = 1.;          zs[1] = 6.;
790    ws[0] = 5.21;        ws[1] = 4.74;
791    density      = 1.032;
792    id           = 6;
793    AliMixture(id, "V0ALuc", as, zs, density, -2, ws);
794    AliMedium(id, "V0ALuc", id, 1, fieldType, maxField, maxBending, maxStepSize,
795              maxEnergyLoss, precision, minStepSize);
796
797 // Parameters for V0Aplate: EuroComposite - EC-PI 626 PS - AlMg3
798    as[0] = 26.982;      as[1] = 24.305;
799    zs[0] = 13.;         zs[1] = 12.;
800    ws[0] = 1.;          ws[1] = 3.;
801    density      = 3.034;
802    id           = 7;
803    AliMixture(id, "V0APlaOu", as, zs, density, -2, ws);
804    AliMedium(id, "V0APlaOu", id, 1, fieldType, maxField, maxBending, maxStepSize,
805              maxEnergyLoss, precision, minStepSize);
806
807 // Parameters for V0Aplate: EuroComposite - EC-PI 626 PS - EC-PI 6.4-42
808    as[0] = 1.00794;     as[1] = 12.011;
809    zs[0] = 1.;          zs[1] = 6.;
810    ws[0] = 5.21;        ws[1] = 4.74;
811    density      = 0.042;
812    id           = 8;
813    AliMixture(id, "V0APlaIn", as, zs, density, -2, ws);
814    AliMedium(id, "V0APlaIn", id, 1, fieldType, maxField, maxBending, maxStepSize,
815              maxEnergyLoss, precision, minStepSize);
816
817 // Parameters for V0Afiber: BC9929AMC Plastic Scintillating Fiber from Saint-Gobain
818    as[0] = 1.00794;     as[1] = 12.011;
819    zs[0] = 1.;          zs[1] = 6.;
820    ws[0] = 4.82;        ws[1] = 4.85;
821    density      = 1.05;
822    id           = 9;
823    AliMixture(id, "V0AFib", as, zs, density, -2, ws);
824    AliMedium(id, "V0AFib", id, 1, fieldType, maxField, maxBending, maxStepSize,
825              maxEnergyLoss, precision, minStepSize);
826
827 // Parameters for V0APMA: Aluminium
828    a = 26.98; 
829    z = 13.00;
830    density     = 2.7;
831    radLength   = 8.9;
832    absLength   = 37.2;
833    id = 10;
834    AliMaterial(id, "V0APMA",  a, z, density, radLength, absLength, 0, 0);
835    AliMedium(id, "V0APMA", id, 1, fieldType, maxField, maxBending, maxStepSize,
836              maxEnergyLoss, precision, minStepSize);
837
838 // Parameters for V0APMG: Glass for the simulation Aluminium
839    a = 26.98; 
840    z = 13.00;
841    density   = 2.7;
842    radLength = 8.9;
843    absLength = 37.2;
844    id = 11;
845    AliMaterial(id, "V0APMG",  a, z, density, radLength, absLength, 0, 0);
846    AliMedium(id, "V0APMG", id, 1, fieldType, maxField, maxBending, maxStepSize,
847              maxEnergyLoss, precision, minStepSize);
848 }
849
850 //_____________________________________________________________________________
851 void AliVZEROv7::DrawModule() const
852 {
853 //  Drawing is done in DrawVZERO.C
854
855    AliDebug(2,"DrawModule");
856 }
857
858
859 //_____________________________________________________________________________
860 void AliVZEROv7::DrawGeometry() 
861 {
862 //  Drawing of V0 geometry done in DrawV0.C
863
864    AliDebug(2,"DrawGeometry");
865 }
866
867 //_____________________________________________________________________________
868 void AliVZEROv7::Init()
869 {
870 // Initialises version of the VZERO Detector given in Config
871 // Just prints an information message
872
873 //   AliInfo(Form("VZERO version %d initialized \n",IsVersion()));
874    
875    AliDebug(1,"VZERO version 7 initialized");
876    AliVZERO::Init();  
877 }
878
879 //_____________________________________________________________________________
880 void AliVZEROv7::StepManager()
881 {
882   // Step Manager, called at each step 
883
884   Int_t     copy;
885   static    Int_t   vol[4];
886   static    Float_t hits[21];
887   static    Float_t eloss, tlength;
888   static    Int_t   nPhotonsInStep = 0;
889   static    Int_t   nPhotons = 0; 
890   static    Int_t   numStep = 0;
891   Int_t     ringNumber;
892   Float_t   destep, step;
893   numStep += 1; 
894
895   //   We keep only charged tracks :
896   if ( !gMC->TrackCharge() || !gMC->IsTrackAlive() ) return;
897
898   vol[0]    = gMC->CurrentVolOffID(1, vol[1]);
899   vol[2]    = gMC->CurrentVolID(copy);
900   vol[3]    = copy;
901   static Int_t idV0R1 = gMC->VolId("V0R1");
902   static Int_t idV0L1 = gMC->VolId("V0L1");
903   static Int_t idV0R2 = gMC->VolId("V0R2");
904   static Int_t idV0L2 = gMC->VolId("V0L2");
905   static Int_t idV0R3 = gMC->VolId("V0R3");
906   static Int_t idV0L3 = gMC->VolId("V0L3");
907   static Int_t idV0R4 = gMC->VolId("V0R4");
908   static Int_t idV0L4 = gMC->VolId("V0L4");
909   static Int_t idV0R5 = gMC->VolId("V0R5");
910   static Int_t idV0R6 = gMC->VolId("V0R6");
911   bool   hitOnV0C = true;
912   double lightYield;
913   double lightAttenuation;
914   double nMeters;
915   double fibToPhot;
916   if      ( gMC->CurrentVolID(copy) == idV0R1 || gMC->CurrentVolID(copy) == idV0L1 )
917     ringNumber = 1;
918   else if ( gMC->CurrentVolID(copy) == idV0R2 || gMC->CurrentVolID(copy) == idV0L2 )
919     ringNumber = 2;  
920   else if ( gMC->CurrentVolID(copy) == idV0R3 || gMC->CurrentVolID(copy) == idV0R4
921             || gMC->CurrentVolID(copy) == idV0L3 ) ringNumber = 3;
922   else if ( gMC->CurrentVolID(copy) == idV0R5 || gMC->CurrentVolID(copy) == idV0R6
923             || gMC->CurrentVolID(copy) == idV0L4 ) ringNumber = 4;             
924   else ringNumber = 0;
925   if  (ringNumber) {
926     if (gMC->CurrentVolID(copy) == idV0L1 || gMC->CurrentVolID(copy) == idV0L2 ||
927         gMC->CurrentVolID(copy) == idV0L3 || gMC->CurrentVolID(copy) == idV0L4)
928       hitOnV0C = false;
929     destep = gMC->Edep();
930     step   = gMC->TrackStep();
931     if (hitOnV0C) {
932       lightYield = fV0CLightYield;
933       lightAttenuation = fV0CLightAttenuation;
934       nMeters = fV0CnMeters;
935       fibToPhot = fV0CFibToPhot;
936     } else {
937       lightYield = fV0ALightYield;
938       lightAttenuation = fV0ALightAttenuation;
939       nMeters = fV0AnMeters;
940       fibToPhot = fV0AFibToPhot;
941     }
942     nPhotonsInStep  = Int_t(destep / (lightYield *1e-9) );      
943     nPhotonsInStep  = gRandom->Poisson(nPhotonsInStep);
944     eloss    += destep;
945     tlength  += step;    
946     if ( gMC->IsTrackEntering() ) { 
947       nPhotons  =  nPhotonsInStep;
948       gMC->TrackPosition(fTrackPosition);
949       gMC->TrackMomentum(fTrackMomentum);
950       Float_t pt  = TMath::Sqrt( fTrackMomentum.Px() * fTrackMomentum.Px()
951                                  + fTrackMomentum.Py() * fTrackMomentum.Py() );
952       TParticle *par = gAlice->GetMCApp()->Particle(gAlice->GetMCApp()->GetCurrentTrackNumber());
953       hits[0]  = fTrackPosition.X();
954       hits[1]  = fTrackPosition.Y();
955       hits[2]  = fTrackPosition.Z();             
956       hits[3]  = Float_t (gMC->TrackPid()); 
957       hits[4]  = gMC->TrackTime();
958       hits[5]  = gMC->TrackCharge();
959       hits[6]  = fTrackMomentum.Theta()*TMath::RadToDeg();
960       hits[7]  = fTrackMomentum.Phi()*TMath::RadToDeg();
961       hits[8]  = ringNumber;
962       hits[9]  = pt;
963       hits[10] = fTrackMomentum.P();
964       hits[11] = fTrackMomentum.Px();
965       hits[12] = fTrackMomentum.Py();
966       hits[13] = fTrackMomentum.Pz();
967       hits[14] = par->Vx();
968       hits[15] = par->Vy();
969       hits[16] = par->Vz();
970       tlength  = 0.0;
971       eloss    = 0.0;       
972
973       //////////////////////////
974       ///// Display V0A geometry
975       //      if (!hitOnV0C) {
976       //        FILE *of;
977       //        of = fopen("V0A.out", "a");
978       //        // x, y, z, ringnumber, cellid
979       //        fprintf( of, "%f %f %f %f %d \n",  hits[0], hits[1], hits[2], hits[8], GetCellId (vol, hits) );
980       //        fclose(of);
981       //      }
982       //////////////////////////
983     }
984     nPhotons  = nPhotons + nPhotonsInStep;
985     if( gMC->IsTrackExiting() || gMC->IsTrackStop() || gMC->IsTrackDisappeared()){
986       nPhotons = nPhotons - Int_t((Float_t(nPhotons) * lightAttenuation * nMeters));
987       nPhotons = nPhotons - Int_t( Float_t(nPhotons) * fibToPhot);
988       hits[17] = eloss;
989       hits[18] = tlength;
990       hits[19] = nPhotons;
991       hits[20] = GetCellId (vol, hits);
992       AddHit(gAlice->GetMCApp()->GetCurrentTrackNumber(), vol, hits);
993       tlength         = 0.0;
994       eloss           = 0.0; 
995       nPhotons        = 0;
996       nPhotonsInStep  = 0;
997       numStep         = 0;  
998     }
999   }
1000 }
1001
1002 //_____________________________________________________________________________
1003 void AliVZEROv7::AddHit(Int_t track, Int_t *vol, Float_t *hits)
1004 {
1005 //  Adds a VZERO hit
1006
1007   TClonesArray &lhits = *fHits;
1008   new(lhits[fNhits++]) AliVZEROhit(fIshunt,track,vol,hits);
1009 }
1010
1011 //_____________________________________________________________________________
1012 void AliVZEROv7::AddDigits(Int_t *tracks, Int_t* digits) 
1013 {
1014 //  Adds a VZERO digit
1015
1016    TClonesArray  &ldigits = *fDigits;
1017    new(ldigits[fNdigits++]) AliVZEROdigit(tracks, digits);
1018 }
1019
1020 //_____________________________________________________________________________
1021 void AliVZEROv7::MakeBranch(Option_t *option)
1022 {
1023 // Creates new branches in the current Root Tree
1024     
1025   char branchname[10];
1026   sprintf(branchname,"%s",GetName());
1027   AliDebug(2,Form("fBufferSize = %d",fBufferSize));
1028   const char *cH = strstr(option,"H");
1029   if (fHits   && TreeH() && cH) {
1030     TreeH()->Branch(branchname,&fHits, fBufferSize);
1031     AliDebug(2,Form("Making Branch %s for hits",branchname));
1032   }     
1033   const char *cD = strstr(option,"D");
1034   if (fDigits   && fLoader->TreeD() && cD) {
1035     fLoader->TreeD()->Branch(branchname,&fDigits, fBufferSize);
1036     AliDebug(2,Form("Making Branch %s for digits",branchname));
1037   }  
1038 }
1039
1040 //_____________________________________________________________________________
1041 Int_t AliVZEROv7::GetCellId(Int_t *vol, Float_t *hits) 
1042 {
1043   //   Returns Id of scintillator cell
1044   //   Right side from  0 to 47 
1045   //   Left  side from 48 to 79
1046   //   hits[8] = ring number (1 to 4)
1047   //   vol[1]  = copy number (1 to 8)
1048
1049   Int_t index      = vol[1];
1050   Int_t ringNumber = Int_t(hits[8]);
1051   fCellId          = 0;
1052
1053   Float_t phi = Float_t(TMath::ATan2(Double_t(hits[1]),Double_t(hits[0])) ); 
1054   Float_t kRaddeg = 180.0/TMath::Pi();
1055   phi = kRaddeg * phi;
1056
1057   if (index < 7) index = index + 8;
1058
1059   if (hits[2] < 0.0) {
1060     if(ringNumber < 3) {
1061       index = (index - 7) + ( ( ringNumber - 1 ) * 8);
1062     } else if (ringNumber >= 3) { 
1063       if ( gMC->CurrentVolID(vol[1]) == gMC->VolId("V0R3") || gMC->CurrentVolID(vol[1])
1064            == gMC->VolId("V0R5") )  index = (index*2-14)+((ringNumber-2)*16);
1065       if ( gMC->CurrentVolID(vol[1]) == gMC->VolId("V0R4") || gMC->CurrentVolID(vol[1])
1066            == gMC->VolId("V0R6") )  index = (index*2-13)+((ringNumber-2)*16);
1067     }
1068     fCellId   = index;           
1069   } else if (hits[2] > 0.0) {
1070     index = (index - 7 + 48) + ( ( ringNumber - 1 ) * 8);
1071     fCellId   = index;
1072   }
1073
1074   return fCellId;
1075 }