]> git.uio.no Git - u/mrichter/AliRoot.git/blob - VZERO/AliVZEROv6.cxx
reorganize ClearPackage, UploadPackage EnablePackage
[u/mrichter/AliRoot.git] / VZERO / AliVZEROv6.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 6  as designed by the Lyon group     //
21 //   All comments should be sent to Brigitte CHEYNIS :              //
22 //                                  b.cheynis@ipnl.in2p3.fr         // 
23 //   Geometry of september 2005 done with ROOT geometrical modeler  //                                  //
24 //   V0R (now V0C) sits between Z values  -89.5 and  -84.8 cm       //
25 //   V0L (now V0A) sits between Z values +339.0 and +341.0 cm       //
26 //   New coordinate system has been implemented in october 2003     //
27 //                                                                  //
28 //////////////////////////////////////////////////////////////////////
29
30 #include <TGeoGlobalMagField.h>
31
32 #include "AliVZEROv6.h"
33  
34 ClassImp(AliVZEROv6)
35
36 //_____________________________________________________________________________
37 AliVZEROv6:: AliVZEROv6():AliVZERO(),
38    fCellId(0),
39    fTrackPosition(),
40    fTrackMomentum(), 
41    fV0CHeight1(2.5), 
42    fV0CHeight2(4.4), 
43    fV0CHeight3(7.4), 
44    fV0CHeight4(12.5),
45    fV0CRMin(4.6), 
46    fV0CRBox(38.0),
47    fV0CLidThickness(0.30),
48    fV0CCellThickness(2.00),
49    fV0CBoxThickness(4.70),
50    fV0COffsetFibers(1.0),
51    fV0AHeight1(3.3), 
52    fV0AHeight2(6.2), 
53    fV0AHeight3(8.9), 
54    fV0AHeight4(20.9),
55    fV0ARMin(4.30),
56    fV0ACellThickness(2.00),
57    fLightYield(93.75),
58    fLightAttenuation(0.05),
59    fnMeters(15.0),
60    fFibToPhot(0.3),
61    fVersion(6)
62 {
63 // Standard default constructor 
64 }
65
66 //_____________________________________________________________________________
67 AliVZEROv6::AliVZEROv6(const char *name, const char *title):
68    AliVZERO(name,title),
69    fCellId(0),
70    fTrackPosition(),
71    fTrackMomentum(), 
72    fV0CHeight1(2.5), 
73    fV0CHeight2(4.4), 
74    fV0CHeight3(7.4), 
75    fV0CHeight4(12.5),
76    fV0CRMin(4.6), 
77    fV0CRBox(38.0),
78    fV0CLidThickness(0.30),
79    fV0CCellThickness(2.00),
80    fV0CBoxThickness(4.70),
81    fV0COffsetFibers(1.0),
82    fV0AHeight1(3.3), 
83    fV0AHeight2(6.2), 
84    fV0AHeight3(8.9), 
85    fV0AHeight4(20.9),
86    fV0ARMin(4.30),
87    fV0ACellThickness(2.00),
88    fLightYield(93.75),
89    fLightAttenuation(0.05),
90    fnMeters(15.0),
91    fFibToPhot(0.3),
92    fVersion(6)
93 {
94
95 // Standard constructor for V-zero Detector  version 6
96
97   AliDebug(2,"Create VZERO object ");
98   
99   fVersion            =     6;  // version number
100   
101 // Parameters related to geometry :
102 // V0 part in front of muon arm absorber 
103
104 //   fV0CHeight1         =    2.5; // height of cell 1, in cm
105 //   fV0CHeight2         =    4.4; // height of cell 2, in cm
106 //   fV0CHeight3         =    7.4; // height of cell 3, in cm
107 //   fV0CHeight4         =   12.5; // height of cell 4, in cm
108 //   fV0CRMin            =    4.6; 
109 //   fV0CRBox            =   38.0; // outer radius of box, in cm
110 //   fV0CLidThickness    =   0.30; // thickness of Carbon lid
111 //   fV0CCellThickness   =   2.00; // thickness of elementary cell
112 //   fV0CBoxThickness    =   4.70; // thickness of V0C Box
113 //   fV0COffsetFibers    =    1.0; // offset to output fibers, in cm
114
115 // V0 part on the other side with respect to Interaction Point
116
117 //   fV0AHeight1         =    3.3; // height of cell 1, in cm
118 //   fV0AHeight2         =    6.2; // height of cell 2, in cm
119 //   fV0AHeight3         =    8.9; // height of cell 3, in cm
120 //   fV0AHeight4         =   20.9; // height of cell 4, in cm
121 //   fV0ARMin            =   4.30; 
122 //   fV0ACellThickness   =   2.00; // thickness of elementary cell  
123 //   
124 // Parameters related to light output :
125          
126 //   fLightYield         =  93.75; // Light yield in BC408 (93.75 eV per photon)
127 //   fLightAttenuation   =   0.05; // Light attenuation in fiber (0.05 per meter)
128 //   fnMeters            =   15.0; // Number of meters of clear fibers to PM
129 //   fFibToPhot          =    0.3; // Attenuation at fiber-photocathode interface
130 }
131      
132 //_____________________________________________________________________________
133 void AliVZEROv6::CreateGeometry()
134 {
135   
136 // Constructs TGeo geometry 
137
138   const int kColorVZERO  = kGreen;  
139   
140   AliDebug(2,"VZERO ConstructGeometry");
141   
142 //  TGeoMedium  *medAir = gGeoManager->GetMedium("VZERO_Air"); 
143   TGeoMedium  *medAlu = gGeoManager->GetMedium("VZERO_Aluminum");
144   TGeoMedium  *medCar = gGeoManager->GetMedium("VZERO_Carbon");
145   TGeoMedium  *medSci = gGeoManager->GetMedium("VZERO_Scintillator");
146     
147   TGeoVolume *top = gGeoManager->GetVolume("ALIC");
148   
149   Float_t  heightRight, r4Right;
150   
151   Float_t  zdet   =    90.0 - 0.5 - fV0CBoxThickness/2.0;
152   heightRight     =    fV0CHeight1 + fV0CHeight2 + fV0CHeight3 + fV0CHeight4;
153   r4Right         =    fV0CRMin + heightRight + 3.0*0.2;  // 3 spacings of 2mm between rings
154
155 // Creation of assembly V0RI - right part - :
156
157   TGeoVolume *v0RI = new TGeoVolumeAssembly("V0RI");  
158   TGeoTranslation *tr1 = new TGeoTranslation(0.,0.,-zdet);
159   top->AddNode(v0RI,1,tr1);
160
161 // Creation of  carbon lids (3.0 mm thick) to keep V0C box shut :
162     
163   Float_t   partube[3];
164   
165   partube[0] =   fV0CRMin;
166   partube[1] =   fV0CRBox;
167   partube[2] =   fV0CLidThickness/2.0;
168   
169   TGeoTube   *sV0CA = new TGeoTube("V0CA", partube[0], partube[1], partube[2]);
170   TGeoVolume *v0CA  = new TGeoVolume("V0CA",sV0CA,medCar);
171   TGeoTranslation *tr2 = new TGeoTranslation(0.,0., fV0CBoxThickness/2.0-partube[2]);
172   TGeoTranslation *tr3 = new TGeoTranslation(0.,0.,-fV0CBoxThickness/2.0+partube[2]);
173   v0RI->AddNode(v0CA,1,tr2);
174   v0RI->AddNode(v0CA,2,tr3);
175   v0CA->SetLineColor(kYellow);
176   
177 // Creation of aluminum rings 3.0 mm thick to maintain the v0RI pieces : 
178  
179   partube[0] =   fV0CRMin - 0.3;
180   partube[1] =   fV0CRMin;
181   partube[2] =   fV0CBoxThickness/2.0;
182   
183   TGeoTube   *sV0IR = new TGeoTube("V0IR", partube[0], partube[1], partube[2]);
184   TGeoVolume *v0IR  = new TGeoVolume("V0IR",sV0IR,medAlu);
185   v0RI->AddNode(v0IR,1,0);
186   v0IR->SetLineColor(kYellow);
187   
188   partube[0] =   fV0CRBox;
189   partube[1] =   fV0CRBox + 0.3; 
190   partube[2] =   fV0CBoxThickness/2.0;
191
192   TGeoTube   *sV0ER = new TGeoTube("V0ER", partube[0], partube[1], partube[2]);
193   TGeoVolume *v0ER  = new TGeoVolume("V0ER",sV0ER,medAlu);
194   v0RI->AddNode(v0ER,1,0);
195   v0ER->SetLineColor(kYellow);
196   
197 // Creation of assembly V0R0 of scintillator cells within one sector
198  
199   TGeoVolume *v0R0 = new TGeoVolumeAssembly("V0R0");                                      
200                                                  
201 // Elementary cell of ring 1  - right part - :
202 // (cells of ring 1 will be shifted by 2.0 cm backwards to output fibers)
203                                                   
204   Float_t   r1Right =  fV0CRMin + fV0CHeight1;
205   Float_t   offset  = fV0CBoxThickness/2.0 - fV0CLidThickness - fV0CCellThickness/2.0;   
206
207   Float_t   partubs[5];   
208      
209   partubs[0]     =  fV0CRMin;
210   partubs[1]     =  r1Right;
211   partubs[2]     =  fV0CCellThickness/2.0;
212   partubs[3]      =  90.0-22.5;
213   partubs[4]      = 135.0-22.5;
214   
215   TGeoTubeSeg  *sV0R1 = new TGeoTubeSeg("V0R1", partubs[0], partubs[1], partubs[2], 
216                                                 partubs[3], partubs[4]);
217   TGeoVolume   *v0R1  =  new TGeoVolume("V0R1",sV0R1,medSci);                                  
218   TGeoTranslation *tr4 = new TGeoTranslation(0.,0.,-offset);
219   v0R0->AddNode(v0R1,1,tr4);
220   v0R1->SetLineColor(kColorVZERO);
221
222 // Elementary cell of ring 2 - right part - :
223 // (cells of ring 2 will be shifted by 1.0 cm backwards to output fibers)
224
225   Float_t   r2Right  =  r1Right + fV0CHeight2;  
226
227   partubs[0]     =  r1Right;  //  must be equal to 7.1
228   partubs[1]     =  r2Right;  //  must be equal to 11.5
229   TGeoTubeSeg *sV0R2 = new TGeoTubeSeg("V0R2", partubs[0], partubs[1], partubs[2], 
230                                                partubs[3], partubs[4]);
231   TGeoVolume  *v0R2  = new TGeoVolume("V0R2",sV0R2,medSci);                                                   
232   TGeoTranslation *tr5 = new TGeoTranslation(0.0,0.2,-offset + fV0COffsetFibers);                                             
233   v0R0->AddNode(v0R2,1,tr5);
234   v0R2->SetLineColor(kColorVZERO);
235    
236 // Ring 3 - right part -  :
237
238 //  Float_t   x = TMath::ATan(1.0/156.0) * ((180./TMath::Pi()));
239   
240   r2Right  =  r2Right + 0.2;
241   Float_t   r3Right  =  r2Right + fV0CHeight3;     
242 //  printf(" r2 = %f, r3 = %f \n\n", r2Right,r3Right); 
243   
244   partubs[0]     =  r2Right;  //  must be equal to 11.7
245   partubs[1]     =  r3Right;  //  must be equal to 19.1
246   partubs[3]     =  90.0-22.5;
247   partubs[4]     = 112.5-22.5;
248   
249   TGeoTubeSeg *sV0R3 = new TGeoTubeSeg("V0R3", partubs[0], partubs[1], partubs[2], 
250                                                partubs[3], partubs[4]); 
251   TGeoVolume  *v0R3  = new TGeoVolume("V0R3",sV0R3,medSci);                                           
252   TGeoTranslation *tr6 = new TGeoTranslation(0.,0.2,-offset + 2.0*fV0COffsetFibers);                                           
253   v0R0->AddNode(v0R3,1,tr6);
254   v0R3->SetLineColor(kColorVZERO);
255  
256   partubs[3]     = 112.5-22.5;
257   partubs[4]     = 135.0-22.5;
258   
259   TGeoTubeSeg *sV0R4 = new TGeoTubeSeg("V0R4", partubs[0], partubs[1], partubs[2], 
260                                                partubs[3], partubs[4]);  
261   TGeoVolume  *v0R4  = new TGeoVolume("V0R4",sV0R4,medSci);                                                                                   
262   v0R0->AddNode(v0R4,1,tr6);
263   v0R4->SetLineColor(kColorVZERO);
264   
265 // Ring 4 - right part -  : 
266
267   Float_t x = TMath::ATan(3.5/257.5) * ((180./TMath::Pi()));
268   r3Right = r3Right + 0.2 + 0.2;   // + 0.2 because no shift in translation here !!
269    
270   partubs[0]     =  r3Right;  //  must be equal to 19.5
271   partubs[1]     =  r4Right;  //  must be equal to 32.0
272   partubs[3]     =  90.0-22.5+x;
273   partubs[4]     = 112.5-22.5-x;
274   
275   TGeoTubeSeg *sV0R5 = new TGeoTubeSeg("V0R5", partubs[0], partubs[1], partubs[2], 
276                                                partubs[3], partubs[4]);
277   TGeoVolume  *v0R5  = new TGeoVolume("V0R5",sV0R5,medSci);
278   TGeoTranslation *tr7 = new TGeoTranslation(0.,0.0,-offset + 2.0*fV0COffsetFibers);                                          
279   v0R0->AddNode(v0R5,1,tr7);
280   v0R5->SetLineColor(kColorVZERO);
281   
282   partubs[3]     = 112.5-22.5+x;
283   partubs[4]     = 135.0-22.5-x;
284   
285   TGeoTubeSeg *sV0R6 = new TGeoTubeSeg("V0R6", partubs[0], partubs[1], partubs[2], 
286                                                partubs[3], partubs[4]);
287   TGeoVolume  *v0R6  = new TGeoVolume("V0R6",sV0R6,medSci);                                                   
288   v0R0->AddNode(v0R6,1,tr7);
289   v0R6->SetLineColor(kColorVZERO);
290   
291   Float_t  phi;
292   Float_t  phiDeg= 180./4.;
293     
294   Int_t    nsecR = 1;     // number of sectors in right part of V0
295   Int_t    ncellsR;       // number of scintillating cells 
296  
297   for (phi = 22.5; phi < 360.0; phi = phi + phiDeg)
298   
299   {              
300     TGeoRotation  *rot1 = new TGeoRotation("rot1", 90.0, +phi, 90., 90.+phi, 0.0, 0.0 ); 
301     
302     v0RI->AddNode(v0R0,nsecR,rot1);    
303     nsecR++;        
304   } 
305      
306   ncellsR = (nsecR - 1) * 6;    // 6 cells per sector (2 cells in  ring 3 and 4)  
307   AliInfo(Form("Number of cells on Right side  - V0C =   %d",  ncellsR)); 
308   
309 // Creation of assembly v0LE - left part - :
310 // Entrance face at  +339.0 cm  (new coordinate system) ...
311           
312   Float_t   heightLeft  = fV0AHeight1 + fV0AHeight2 + fV0AHeight3 + fV0AHeight4;   
313   Float_t   r4Left      = fV0ARMin + heightLeft; 
314  
315   TGeoVolume *v0LE = new TGeoVolumeAssembly("V0LE"); 
316    
317   TGeoTranslation *tr8 = new TGeoTranslation(0.,0.,339.0 + fV0ACellThickness/2.0);
318   top->AddNode(v0LE,1,tr8);
319   
320 // Creation of assembly V0L0 of scintillator cells within one sector 
321   
322   TGeoVolume *v0L0 = new TGeoVolumeAssembly("V0L0");                                      
323    
324   Float_t   offsetLeft;
325   offsetLeft    = - fV0ACellThickness/2.0; 
326
327   Float_t   r1Left =  fV0ARMin + fV0AHeight1;        
328       
329   partubs[0]     =  fV0ARMin;
330   partubs[1]     =  r1Left;
331   partubs[2]      =  fV0ACellThickness/2.0;
332   partubs[3]      =  90.0-22.5;
333   partubs[4]      = 135.0-22.5;
334   
335   TGeoTubeSeg  *sV0L1 = new TGeoTubeSeg("V0L1", partubs[0], partubs[1], partubs[2], 
336                                                 partubs[3], partubs[4]);
337   TGeoVolume   *v0L1  =  new TGeoVolume("V0L1",sV0L1,medSci);                                  
338   v0L0->AddNode(v0L1,1,gGeoIdentity);
339   v0L1->SetLineColor(kColorVZERO);
340   v0L1->SetVisibility(kTRUE);
341          
342   Float_t   r2Left =  r1Left + fV0AHeight2;       
343   
344   partubs[0]     =  r1Left;
345   partubs[1]     =  r2Left;
346   
347   TGeoTubeSeg  *sV0L2 = new TGeoTubeSeg("V0L2", partubs[0], partubs[1], partubs[2], 
348                                                 partubs[3], partubs[4]);
349   TGeoVolume   *v0L2  =  new TGeoVolume("V0L2",sV0L2,medSci);                                  
350   v0L0->AddNode(v0L2,1,gGeoIdentity);
351   v0L2->SetLineColor(kColorVZERO);
352   v0L2->SetVisibility(kTRUE);
353
354   Float_t   r3Left =  r2Left + fV0AHeight3; 
355    
356   partubs[0]     =  r2Left;
357   partubs[1]     =  r3Left;
358   
359   TGeoTubeSeg  *sV0L3 = new TGeoTubeSeg("V0L3", partubs[0], partubs[1], partubs[2], 
360                                                 partubs[3], partubs[4]);
361   TGeoVolume   *v0L3  =  new TGeoVolume("V0L3",sV0L3,medSci);                                  
362   v0L0->AddNode(v0L3,1,gGeoIdentity);
363   v0L3->SetLineColor(kColorVZERO);
364   v0L3->SetVisibility(kTRUE);
365
366   partubs[0]     =  r3Left;
367   partubs[1]     =  r4Left;
368
369   TGeoTubeSeg  *sV0L4 = new TGeoTubeSeg("V0L4", partubs[0], partubs[1], partubs[2], 
370                                                 partubs[3], partubs[4]);
371   TGeoVolume   *v0L4  =  new TGeoVolume("V0L4",sV0L4,medSci);                                  
372   v0L0->AddNode(v0L4,1,gGeoIdentity);
373   v0L4->SetLineColor(kColorVZERO);
374   v0L4->SetVisibility(kTRUE);
375
376   Int_t    nsecL = 1;     // number of sectors in left part of V0
377   Int_t    ncellsL;       // number of scintillating cells 
378   
379   for (phi = 22.5; phi < 360.0; phi = phi + phiDeg)
380   
381   {                  
382     TGeoRotation  *rot1 = new TGeoRotation("rot1", 90.0, +phi, 90., 90.+phi, 0.0, 0.0 ); 
383     v0LE->AddNode(v0L0,nsecL,rot1);    
384     nsecL++;        
385   } 
386      
387   ncellsL = (nsecL - 1) * 4;    // 4 cells per sector
388   AliInfo(Form("Number of cells on Left  side  - V0A =   %d\n",  ncellsL));
389
390   gGeoManager->SetTopVolume(top); 
391   gGeoManager->CloseGeometry();  
392 //  gGeoManager-> SetVisLevel(4);
393 }  
394     
395 //_____________________________________________________________________________
396 void AliVZEROv6::CreateMaterials()
397 {
398
399 // Creates materials used for geometry 
400
401    AliDebug(2,"Create materials");
402
403 //   Int_t  *idtmed = fIdtmed->GetArray()-2999;
404       
405    Int_t     fieldType       = ((AliMagF*)TGeoGlobalMagField::Instance()->GetField())->Integ();     // Field type 
406    Double_t  maxField        = ((AliMagF*)TGeoGlobalMagField::Instance()->GetField())->Max();       // Field max.
407    Double_t  maxBending      = 0;     // Max Angle
408    Double_t  maxStepSize     = 0.001; // Max step size 
409    Double_t  maxEnergyLoss   = 1;     // Max Delta E
410    Double_t  precision       = 0.001; // Precision
411    Double_t  minStepSize     = 0.001; // Minimum step size 
412    Int_t     id;
413    Double_t  a, z, density, radLength, absLength; 
414    Float_t   tmaxfd, stemax, deemax, epsil, stmin;
415    
416    a = 0.0; z = 0.0; 
417    density    = 0.0;
418    radLength  = 0.0; 
419    absLength  = 999.0;
420    tmaxfd     = 10.;
421    stemax     = 0.1;
422    deemax     = 0.1;     
423    epsil      = 0.001;
424    stmin      = 0.001;
425    
426 // Parameters  for Air (=  0.01% C + 75% N + 23% O + 1% Ar )
427
428     Float_t aa[] = { 12.0107, 14.0067,   15.9994,  39.948 };
429     Float_t za[] = {  6.,      7.,       8.,       18. };
430     Float_t wa[] = { 0.000124, 0.755267, 0.231781, 0.012827 }; 
431     density      = 0.00120479;
432     maxBending   = 1;
433     maxStepSize  = .001;
434     precision    = .001;
435     minStepSize  = .001;
436     id           = 1;
437     AliMixture(id, "Air", aa, za, density, 4, wa);
438     AliMedium(id, "Air", id, 1, fieldType, maxField, maxBending,
439                          maxStepSize, maxEnergyLoss, precision, minStepSize);
440                         
441 // Parameters  for Aluminum
442  
443     a = 26.98; 
444     z = 13.00;
445     density    = 2.7;
446     radLength  = 8.9;
447     maxBending  = 10;
448     maxStepSize = .01;
449     precision   = .003;
450     minStepSize = .003;
451     id = 2;
452     AliMaterial( id, "Aluminum", a, z, density, radLength, 37.2, 0, 0);
453     AliMedium(id, "Aluminum", id, 1, fieldType, maxField, maxBending,
454                               maxStepSize, maxEnergyLoss, precision, minStepSize);
455                     
456 // Parameters  for Carbon 
457
458     a = 12.01; 
459     z =  6.00;
460     density     = 2.265;
461     radLength   = 18.8;
462     id = 3;
463     AliMaterial(id, "Carbon",  a, z, density, radLength, 49.9, 0, 0);
464     AliMedium(id,   "Carbon", id, 1, fieldType, maxField, maxBending,
465                               maxStepSize, maxEnergyLoss, precision, minStepSize);
466                     
467 // Parameters  for scintillator 
468
469     Float_t as[] = { 1.00794, 12.011};
470     Float_t zs[] = { 1.,  6.};
471     Float_t ws[] = { 1.,  1.};
472     density      = 1.032;
473     maxBending   = 10;
474     maxStepSize  = .01;
475     precision    = .003;
476     minStepSize  = .003;
477     id           = 4;
478     AliMixture(id, "Scintillator", as, zs, density, -2, ws);
479     AliMedium(id,  "Scintillator", id, 1, fieldType, maxField, maxBending,
480                                    maxStepSize,maxEnergyLoss,precision,minStepSize);
481
482                                                              
483 }
484
485 //_____________________________________________________________________________
486 void AliVZEROv6::DrawModule() const
487 {
488
489 //  Drawing is done in DrawVZERO.C
490
491    AliDebug(2,"DrawModule");
492 }
493
494
495 //_____________________________________________________________________________
496 void AliVZEROv6::DrawGeometry() 
497 {
498
499 //  Drawing of V0 geometry done in DrawV0.C
500
501    AliDebug(2,"DrawGeometry");
502  
503 //  Here is  DrawV0.C :
504
505 // void DrawV0()
506 // {
507 //    TGeoVolume *top = gGeoManager->GetMasterVolume();
508 //    gGeoManager->SetNsegments(80);
509 //    Int_t nd = top->GetNdaughters();
510 //    for (Int_t i=0; i<nd; i++) top->GetNode(i)->GetVolume()->InvisibleAll();
511 //    TGeoVolume *v0ri = gGeoManager->GetVolume("V0RI");  
512 //    TGeoVolume *v0le = gGeoManager->GetVolume("V0LE");
513 //    v0ri->SetVisibility(kTRUE);
514 //    v0ri->VisibleDaughters(kTRUE);
515 //    v0le->SetVisibility(kTRUE);
516 //    v0le->VisibleDaughters(kTRUE);
517 //    top->SetVisibility(kTRUE);
518 //    top->Draw();
519 // }
520    
521 }
522
523 //_____________________________________________________________________________
524 void AliVZEROv6::Init()
525 {
526 // Initialises version of the VZERO Detector given in Config
527 // Just prints an information message
528   
529    AliInfo(Form("VZERO version %d initialized \n",IsVersion()));
530    
531    AliVZERO::Init();  
532 }
533
534 //_____________________________________________________________________________
535 void AliVZEROv6::StepManager()
536 {
537  
538 // Step Manager, called at each step 
539  
540      Int_t     copy;
541      static    Int_t   vol[4];
542      static    Float_t hits[21];
543      static    Float_t eloss, tlength;
544      static    Int_t   nPhotonsInStep;
545      static    Int_t   nPhotons; 
546      static    Int_t   numStep;
547      Float_t   ringNumber;
548      Float_t   destep, step;
549      
550      numStep += 1; 
551           
552 //   We keep only charged tracks :
553      
554      if ( !gMC->TrackCharge() || !gMC->IsTrackAlive() ) return; 
555
556      vol[0]    = gMC->CurrentVolOffID(1, vol[1]);
557      vol[2]    = gMC->CurrentVolID(copy);
558      vol[3]    = copy;
559      
560      static Int_t idV0R1 = gMC->VolId("V0R1");
561      static Int_t idV0L1 = gMC->VolId("V0L1");
562      static Int_t idV0R2 = gMC->VolId("V0R2");
563      static Int_t idV0L2 = gMC->VolId("V0L2");
564      static Int_t idV0R3 = gMC->VolId("V0R3");
565      static Int_t idV0L3 = gMC->VolId("V0L3");
566      static Int_t idV0R4 = gMC->VolId("V0R4");
567      static Int_t idV0L4 = gMC->VolId("V0L4");
568      static Int_t idV0R5 = gMC->VolId("V0R5");
569      static Int_t idV0R6 = gMC->VolId("V0R6");
570    
571      if      ( gMC->CurrentVolID(copy) == idV0R1 ||
572                gMC->CurrentVolID(copy) == idV0L1 )
573                ringNumber = 1.0;
574      else if ( gMC->CurrentVolID(copy) == idV0R2 ||
575                gMC->CurrentVolID(copy) == idV0L2 ) 
576                ringNumber = 2.0;  
577      else if ( gMC->CurrentVolID(copy) == idV0R3 ||
578                gMC->CurrentVolID(copy) == idV0R4 ||
579                gMC->CurrentVolID(copy) == idV0L3 )
580                ringNumber = 3.0;
581      else if ( gMC->CurrentVolID(copy) == idV0R5 ||
582                gMC->CurrentVolID(copy) == idV0R6 ||
583                gMC->CurrentVolID(copy) == idV0L4 )
584                ringNumber = 4.0;               
585      else
586                ringNumber = 0.0;
587                
588  
589      if  (  ringNumber > 0.5  ) { 
590      
591         destep    = gMC->Edep();
592         step      = gMC->TrackStep();
593         
594         nPhotonsInStep  = Int_t(destep / (fLightYield *1e-9) ); 
595         nPhotonsInStep  = gRandom->Poisson(nPhotonsInStep);
596         
597         eloss    += destep;
598         tlength  += step;        
599         
600         if  ( gMC->IsTrackEntering()  )  { 
601          
602             nPhotons  =  nPhotonsInStep;       
603             gMC->TrackPosition(fTrackPosition);
604             gMC->TrackMomentum(fTrackMomentum);
605             
606             Float_t pt  = TMath::Sqrt( fTrackMomentum.Px() * fTrackMomentum.Px() +
607                                        fTrackMomentum.Py() * fTrackMomentum.Py() );
608                
609             hits[0]  = fTrackPosition.X();
610             hits[1]  = fTrackPosition.Y();
611             hits[2]  = fTrackPosition.Z();               
612             hits[3]  = Float_t (gMC->TrackPid()); 
613
614             hits[4]  = gMC->TrackTime();
615             hits[5]  = gMC->TrackCharge();
616             hits[6]  = fTrackMomentum.Theta()*TMath::RadToDeg();
617             hits[7]  = fTrackMomentum.Phi()*TMath::RadToDeg();
618             hits[8]  = ringNumber;
619          
620             hits[9]  = pt;
621             hits[10] = fTrackMomentum.P();
622             hits[11] = fTrackMomentum.Px();
623             hits[12] = fTrackMomentum.Py();
624             hits[13] = fTrackMomentum.Pz();
625             
626             TParticle *par = gAlice->GetMCApp()->Particle(gAlice->GetMCApp()->GetCurrentTrackNumber());
627             hits[14] = par->Vx();
628             hits[15] = par->Vy();
629             hits[16] = par->Vz();
630             
631             tlength  = 0.0;
632             eloss    = 0.0;         
633          }
634          
635          nPhotons  = nPhotons + nPhotonsInStep;
636          
637          if( gMC->IsTrackExiting() || gMC->IsTrackStop() || gMC->IsTrackDisappeared()){
638          
639          nPhotons  = nPhotons - Int_t((Float_t(nPhotons) * fLightAttenuation * fnMeters));       
640          nPhotons  = nPhotons - Int_t( Float_t(nPhotons) * fFibToPhot);  
641          
642          hits[17] =   eloss;
643          hits[18] = tlength;
644          hits[19] = nPhotons;
645          hits[20] = GetCellId (vol, hits); 
646                  
647          AddHit(gAlice->GetMCApp()->GetCurrentTrackNumber(), vol, hits);
648                  
649          tlength         = 0.0;
650          eloss           = 0.0; 
651          nPhotons        =   0;
652          nPhotonsInStep  =   0;
653          
654          numStep         =   0;  
655          } 
656     }
657       
658 }
659
660 //_____________________________________________________________________________
661 void AliVZEROv6::AddHit(Int_t track, Int_t *vol, Float_t *hits)
662 {
663   
664 //  Adds a VZERO hit
665   
666   TClonesArray &lhits = *fHits;
667   new(lhits[fNhits++]) AliVZEROhit(fIshunt,track,vol,hits);
668 }
669
670 //_____________________________________________________________________________
671 void AliVZEROv6::AddDigits(Int_t *tracks, Int_t* digits) 
672 {
673
674 //  Adds a VZERO digit
675
676    TClonesArray  &ldigits = *fDigits;
677    new(ldigits[fNdigits++]) AliVZEROdigit(tracks, digits);
678 }
679
680 //_____________________________________________________________________________
681 void AliVZEROv6::MakeBranch(Option_t *option)
682 {
683   
684 // Creates new branches in the current Root Tree
685     
686   char branchname[10];
687   sprintf(branchname,"%s",GetName());
688   AliDebug(2,Form("fBufferSize = %d",fBufferSize));
689   
690   const char *cH = strstr(option,"H");
691   
692   if (fHits   && fLoader->TreeH() && cH) {
693     fLoader->TreeH()->Branch(branchname,&fHits, fBufferSize);
694     AliDebug(2,Form("Making Branch %s for hits",branchname));
695   }     
696
697   const char *cD = strstr(option,"D");
698   
699   if (fDigits   && fLoader->TreeD() && cD) {
700     fLoader->TreeD()->Branch(branchname,&fDigits, fBufferSize);
701     AliDebug(2,Form("Making Branch %s for digits",branchname));
702   }  
703    
704 }
705
706 //_____________________________________________________________________________
707 Int_t AliVZEROv6::GetCellId(Int_t *vol, Float_t *hits) 
708 {
709
710   //   Returns Id of scintillator cell
711   //   Right side from  0 to 47
712   //   Left  side from 48 to 95
713   
714   //   hits[8] = ring number (1 to 4)
715   //   vol[1]  = copy number (1 to 8)
716
717    Int_t index      = vol[1];
718    Int_t ringNumber = Int_t(hits[8]);   
719    fCellId          = 0;
720    
721 //    cout << "volID = " << vol[0] << "  copy = " << vol[1] << endl;
722 //    cout << "X     = " << hits[0] << "    Y = " << hits[1] << endl;
723    
724    Float_t phi = Float_t(TMath::ATan2(Double_t(hits[1]),Double_t(hits[0])) ); 
725    phi = kRaddeg * phi;
726     
727    if (index < 7) index = index + 8; 
728    
729    if (hits[2] < 0.0) { 
730       if(ringNumber < 3) {
731          index = (index - 7) + ( ( ringNumber - 1 ) * 8);}
732       else if(ringNumber >= 3){ 
733        if(gMC->CurrentVolID(vol[1]) == gMC->VolId("V0R3")|| 
734           gMC->CurrentVolID(vol[1]) == gMC->VolId("V0R5") ) 
735          {index = (index*2 - 14) + ( ( ringNumber - 2 ) * 16); }
736        if(gMC->CurrentVolID(vol[1]) == gMC->VolId("V0R4")||
737           gMC->CurrentVolID(vol[1]) == gMC->VolId("V0R6") ) 
738          {index = (index*2 - 13) + ( ( ringNumber - 2 ) * 16); }
739       }
740       fCellId   = index;           
741    }
742            
743    else if (hits[2] > 0.0){
744       index = (index - 7 + 48) + ( ( ringNumber - 1 ) * 8);
745       fCellId   = index;}
746              
747 //    cout << " ring   = " << ringNumber << " phi = "<<  phi << endl; 
748 //    cout << " cellID = " << fCellId <<  endl;
749 //    cout <<  "**********" << endl;         
750            
751    return fCellId;
752    
753    
754 }