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