Removed a std::cout statement
[u/mrichter/AliRoot.git] / VZERO / AliVZEROv5.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 5  as designed by the Lyon group     //
21 //   All comments should be sent to Brigitte CHEYNIS :              //
22 //                                  b.cheynis@ipnl.in2p3.fr         // 
23 //   Geometry of the  16 th of june 2004                            //
24 //  (now 8 sectors instead of 12 sectors as in previous version)    // 
25 //   V0R (now V0C) sits between Z values  -89.6 and  -84.9 cm       //
26 //   V0L (now V0A) sits between Z values +339.0 and +341.0 cm       //
27 //   New coordinate system has been implemented in october 2003     //
28 //                                                                  //
29 //////////////////////////////////////////////////////////////////////
30
31 // --- Standard libraries ---
32 #include <Riostream.h>
33 #include <stdlib.h>
34 #include <string.h>
35
36 // --- ROOT libraries ---
37 #include <TClonesArray.h>
38 #include <TGeometry.h>
39 #include <TLorentzVector.h>
40 #include <TMath.h>
41 #include <TNode.h>
42 #include <TObjectTable.h>
43 #include <TTUBE.h>
44 #include <TTUBS.h>
45 #include <TVirtualMC.h>
46 #include <TParticle.h>
47
48 // --- AliRoot header files ---
49 #include "AliRun.h"
50 #include "AliMC.h"
51 #include "AliConst.h"
52 #include "AliMagF.h"
53 #include "AliVZEROLoader.h"
54 #include "AliVZEROdigit.h"
55 #include "AliVZEROhit.h"
56 #include "AliVZEROv5.h"
57 #include "AliLog.h"
58  
59 ClassImp(AliVZEROv5)
60
61 //_____________________________________________________________________________
62 AliVZEROv5:: AliVZEROv5():AliVZERO(),
63    fCellId(0),
64    fTrackPosition(),
65    fTrackMomentum(), 
66    fLightYield(93.75),
67    fLightAttenuation(0.05),
68    fnMeters(15.0),
69    fFibToPhot(0.3)
70 {
71 // Standard default constructor 
72 }
73
74 //_____________________________________________________________________________
75 AliVZEROv5::AliVZEROv5(const char *name, const char *title):
76    AliVZERO(name,title),
77    fCellId(0),
78    fTrackPosition(),
79    fTrackMomentum(),
80    fLightYield(93.75),
81    fLightAttenuation(0.05),
82    fnMeters(15.0),
83    fFibToPhot(0.3)    
84 {
85
86 // Standard constructor for V-zero Detector  version 5
87
88   AliDebug(2,"Create VZERO object ");
89 //       
90 //   fLightYield              =  93.75; // Light yield in BC408 (93.75 eV per photon)
91 //   fLightAttenuation        =   0.05; // Light attenuation in fiber (0.05 per meter)
92 //   fnMeters                 =   15.0; // Number of meters of clear fibers to PM
93 //   fFibToPhot               =    0.3; // Attenuation at fiber-photocathode interface
94 }
95
96 //_____________________________________________________________________________
97 void AliVZEROv5::CreateGeometry()
98 {
99
100 // Creates the GEANT geometry of the V-zero Detector  version 5
101   
102   AliDebug(2,"Create Geometry ");
103       
104   Int_t    *idtmed = fIdtmed->GetArray()-2999;
105
106   Int_t    ndetR = 1;
107   Int_t    ndetL = 1;
108  
109   Int_t    ncellsR = 1;
110   Int_t    ncellsL = 1;
111   
112   Int_t    idrotm[999];
113  
114   Float_t  height1Right, height2Right, height3Right, height4Right; 
115   Float_t  heightRight;
116   Float_t  theta;  
117   
118   Float_t  halfThickQua;
119   
120   Float_t  zdet;
121   Float_t  r0Right, r4Right, rBoxRight;
122   Float_t  pi = TMath::Pi();
123     
124   height1Right    =     2.6;  // height of cell 1, in cm
125   height2Right    =     4.6;  // height of cell 2, in cm
126   height3Right    =     7.6;  // height of cell 3, in cm
127   height4Right    =    12.7;  // height of cell 4, in cm
128   
129   theta       = pi/4.0/2.0;       // half angular opening = 22.5 degrees
130     
131   halfThickQua= fThickness1/2.0;  // half thickness of elementary cell (inner ring)
132   
133 // distance 0.6 cm in zdet accounts for the fact V0R box back lid sits 0.6 away from 
134 // absorber nose sitting at 90 cm. Will use -zdet later...
135 // size of V0R box (fThickness) is increased by 3 mm as compared to basic version  
136
137   fThickness  =    fThickness + 0.3;             // now 4.7 cm instead of 4.4 cm
138   zdet        =    90.0 - 0.6 - fThickness/2.0;  // distance to vertex (along Z axis)   
139   r0Right     =    4.20;          // closest distance to center of the beam pipe
140   heightRight =    height1Right + height2Right + height3Right + height4Right;
141   r4Right     =    r0Right + heightRight + 0.3;
142   rBoxRight   =    38.0;          // external radius of right box
143      
144 // Creation of mother volume v0LE - left part - :
145 // Entrance face at  +339.0 cm  (new coordinate system) ...
146
147    Float_t   partube[3];
148    
149    partube[0] =  4.3;
150    partube[1] = 44.0;
151    partube[2] = fThickness1/2.0;   
152     
153    gMC->Gsvolu("V0LE","TUBE",idtmed[3005],partube,3);
154      
155 // Creation of five rings - left part - :
156 // Entrance face at +339.0 cm  (new coordinate system) ... 
157
158 // Mother volume v0L0 in which will be set 5 scintillator cells 
159
160   Float_t   partubs[5];  
161     
162   Float_t   r0Left      =   4.3;   
163   Float_t   height1Left =   3.3;  
164   Float_t   height2Left =   6.2;  
165   Float_t   height3Left =   8.9; 
166   Float_t   height4Left =  20.9;  
167   Float_t   heightLeft  =   height1Left + height2Left + height3Left + height4Left; 
168                                       
169   Float_t   r4Left      =   r0Left  + heightLeft; 
170   
171   partubs[0]     =  r0Left;
172   partubs[1]     =  r4Left;
173   partubs[2]     =  fThickness1/2.0;
174   partubs[3]     =  90.0-22.5;
175   partubs[4]     = 135.0-22.5;
176
177   gMC->Gsvolu("V0L0","TUBS",idtmed[3010],partubs,5);  // air volume
178   
179   Float_t  r1Left =  r0Left + height1Left;        
180      
181   partubs[0]     =  r0Left;
182   partubs[1]     =  r1Left;
183
184   gMC->Gsvolu("V0L1","TUBS",idtmed[3005],partubs,5);  // quartz volume
185   gMC->Gspos("V0L1",1,"V0L0", 0.0, 0.0 , 0.0, 0,"ONLY"); 
186
187   Float_t  r2Left  =  r1Left + height2Left;       
188   
189   partubs[0]     =  r1Left;
190   partubs[1]     =  r2Left;
191
192   gMC->Gsvolu("V0L2","TUBS",idtmed[3005],partubs,5);  // quartz volume
193   gMC->Gspos("V0L2",1,"V0L0", 0.0, 0.0 , 0.0, 0,"ONLY"); 
194   
195   Float_t  r3Left  =  r2Left + height3Left;       
196       
197   partubs[0]     =  r2Left;
198   partubs[1]     =  r3Left;
199
200   gMC->Gsvolu("V0L3","TUBS",idtmed[3005],partubs,5);  // quartz volume
201   gMC->Gspos("V0L3",1,"V0L0", 0.0, 0.0 , 0.0, 0,"ONLY");
202
203   partubs[0]     =  r3Left;
204   partubs[1]     =  r4Left;
205
206   gMC->Gsvolu("V0L4","TUBS",idtmed[3005],partubs,5);  // quartz volume
207   gMC->Gspos("V0L4",1,"V0L0", 0.0, 0.0 , 0.0, 0,"ONLY");  
208
209 // Creation of mother volume v0RI - right part - :
210   
211   partube[0] = r0Right - 0.2;
212   partube[1] = r4Right + 1.0;
213   partube[2] = fThickness/2.0; 
214       
215   gMC->Gsvolu("V0RI","TUBE",idtmed[3010],partube,3);
216   
217 // Creation of  carbon lids (3.0 mm thick) to keep v0RI box shut...
218
219   Float_t  lidThickness = 0.30;
220  
221   partube[0] =   r0Right;
222   partube[1] =   rBoxRight;
223   partube[2] =   +lidThickness/2.0;
224     
225   gMC->Gsvolu("V0CA","TUBE",idtmed[3001],partube,3); 
226   gMC->Gspos("V0CA",1,"V0RI",0.0,0.0, fThickness/2.0-partube[2],0,"ONLY");
227   gMC->Gspos("V0CA",2,"V0RI",0.0,0.0,-fThickness/2.0+partube[2],0,"ONLY");
228   
229 // Creation of aluminum rings 3.0 mm thick to maintain the v0RI pieces ...
230
231   partube[0] =   r0Right;
232   partube[1] =   r0Right + 0.3;
233   partube[2] =   +fThickness/2.0;
234    
235   gMC->Gsvolu("V0IR","TUBE",idtmed[3003],partube,3);    
236   gMC->Gspos("V0IR",1,"V0RI",0.0,0.0,0.0,0,"ONLY");
237
238   partube[0] =   rBoxRight - 0.3;
239   partube[1] =   rBoxRight;
240   partube[2] =   +fThickness/2.0;
241  
242   gMC->Gsvolu("V0ER","TUBE",idtmed[3003],partube,3);    
243   gMC->Gspos("V0ER",1,"V0RI",0.0,0.0,0.0,0,"ONLY");
244   
245 // Mother volume v0R0 in which will be set 6 scintillator cells 
246   
247   partubs[0]      =  r0Right;
248   partubs[1]      =  r4Right;
249   partubs[2]      =  fThickness/2.0;
250   partubs[3]      =  90.0-22.5;
251   partubs[4]      = 135.0-22.5;
252
253   gMC->Gsvolu("V0R0","TUBS",idtmed[3010],partubs,5);  // air volume 
254
255 // Elementary cell of ring 1 :
256 // (cells of ring 1 will be shifted by 2.0 cm backwards to output fibers)
257    
258   Float_t   offsetFibers  =  1.0;
259   Float_t   offset        =  fThickness/2.0 - lidThickness - fThickness1/2.0; 
260   Float_t   r1Right       =  r0Right + 0.3 + height1Right;
261       
262   partubs[0]     =  r0Right + 0.3;
263   partubs[1]     =  r1Right;
264   partubs[2]     =  fThickness1/2.0;
265   
266   gMC->Gsvolu("V0R1","TUBS",idtmed[3005],partubs,5);  // scintillator volume
267   gMC->Gspos("V0R1",1,"V0R0", 0.0, 0.0 , -offset, 0,"ONLY"); 
268
269 // Elementary cell of ring 2 :
270 // (cells of ring 2 will be shifted by 1.0 cm backwards to output fibers)
271
272   Float_t   r2Right   =  r1Right + height2Right;       
273   
274   partubs[0]     =  r1Right;
275   partubs[1]     =  r2Right;
276
277   gMC->Gsvolu("V0R2","TUBS",idtmed[3005],partubs,5);  // scintillator volume
278   gMC->Gspos("V0R2",1,"V0R0", 0.0, 0.0 , -offset + offsetFibers, 0,"ONLY"); 
279
280 // Elementary cell of ring 3 :
281
282   Float_t   r3Right   =  r2Right + height3Right;   
283      
284   partubs[0]     =  r2Right;
285   partubs[1]     =  r3Right;
286   partubs[3]     =  90.0-22.5;
287   partubs[4]     = 112.5-22.5;
288
289   gMC->Gsvolu("V0R3","TUBS",idtmed[3005],partubs,5);  // scintillator volume
290   gMC->Gspos("V0R3",1,"V0R0", 0.0, 0.0 , -offset + 2.0 * offsetFibers, 0,"ONLY");
291   
292   partubs[3]     = 112.5-22.5;
293   partubs[4]     = 135.0-22.5;
294   gMC->Gsvolu("V0R4","TUBS",idtmed[3005],partubs,5);  // scintillator volume
295   gMC->Gspos("V0R4",1,"V0R0", 0.0, 0.0 , -offset + 2.0 * offsetFibers, 0,"ONLY");
296   
297 // Elementary cell of ring 4 :
298    
299   partubs[0]     =  r3Right;
300   partubs[1]     =  r4Right;
301   partubs[3]     =  90.0-22.5;
302   partubs[4]     = 112.5-22.5;
303
304   gMC->Gsvolu("V0R5","TUBS",idtmed[3005],partubs,5);  // scintillator volume
305   gMC->Gspos("V0R5",1,"V0R0", 0.0, 0.0 , -offset + 2.0 * offsetFibers, 0,"ONLY");
306   
307   partubs[3]     = 112.5-22.5;
308   partubs[4]     = 135.0-22.5;
309   gMC->Gsvolu("V0R6","TUBS",idtmed[3005],partubs,5);  // scintillator volume
310   gMC->Gspos("V0R6",1,"V0R0", 0.0, 0.0 , -offset + 2.0 * offsetFibers, 0,"ONLY");
311     
312   Float_t  phiDeg = 180./4.; 
313
314 // Right part : 
315  
316   for(Float_t  phi = 22.5; phi < 360.0; phi = phi + phiDeg)
317       {        
318         AliMatrix(idrotm[902], 90.0, phi, 90.0, 90.0 +phi, 0.0 , 0.0);
319         gMC->Gspos("V0R0",ndetR,"V0RI",0.0,
320                           0.0,0.0,idrotm[902],"ONLY");
321         ndetR++;
322        }
323
324   gMC->Gspos("V0RI",1,"ALIC",0.0,0.0,-zdet,0,"ONLY");
325  
326   ncellsR = (ndetR - 1) * 6;  
327   AliInfo(Form("Number of cells on Right side =   %d\n",  ncellsR));
328
329 // Left part :
330   
331   for(Float_t  phi = 22.5; phi < 360.0; phi = phi + phiDeg)
332       {       
333         AliMatrix(idrotm[902], 90.0, phi, 90.0, 90.0 +phi, 0.0 , 0.0);
334         gMC->Gspos("V0L0",ndetL,"V0LE",0.0,
335                           0.0,0.0,idrotm[902],"ONLY");
336         ndetL++;
337        }
338
339   gMC->Gspos("V0LE",1,"ALIC",0.0,0.0,339.0+fThickness1/2.0,0,"ONLY");
340  
341   ncellsL = (ndetL - 1) * 4;
342   AliInfo(Form("Number of cells on Left side  =   %d\n",  ncellsL));    
343            
344 }
345             
346 //_____________________________________________________________________________
347 void AliVZEROv5::BuildGeometry()
348 {
349   
350 // Builds simple ROOT TNode geometry for event display
351
352   AliDebug(2,"VZERO BuildGeometry");
353
354   TNode *top; 
355
356   TNode *v0Rnode,  *v0Rnode0, *v0Rnode7, *v0Rnode8, *v0Rnode9, *v0Rnode10;
357   TNode *v0Rnode1, *v0Rnode2, *v0Rnode3, *v0Rnode4, *v0Rnode5, *v0Rnode6;
358   TNode *v0Lnode, *v0Lnode0;
359   TNode *v0Lnode1, *v0Lnode2, *v0Lnode3, *v0Lnode4;
360    
361   const int kColorVZERO  = kGreen;
362  
363   top = gAlice->GetGeometry()->GetNode("alice");
364
365   Float_t  height1Right, height2Right, height3Right, height4Right; 
366   Float_t  heightRight;
367   Float_t  theta;  
368   
369   Float_t  halfThickQua;
370   Float_t  zdet;
371   Float_t  r0Right, r4Right, rBoxRight;
372   Float_t  pi = TMath::Pi();
373
374   height1Right      =     2.6;  // height of cell 1, in cm
375   height2Right      =     4.6;  // height of cell 2, in cm
376   height3Right      =     7.6;  // height of cell 3, in cm
377   height4Right      =    12.7;  // height of cell 4, in cm
378     
379   theta             =    pi/4.0/2.0;    
380    
381   halfThickQua      =    fThickness1/2.0; 
382   
383   zdet              =    90.0 - 0.6 - fThickness/2.0;   
384   r0Right           =    4.20;         
385   heightRight       =    height1Right + height2Right + height3Right + height4Right;
386   r4Right           =    r0Right + heightRight + 0.3;
387   rBoxRight         =    38.0;
388   
389   Int_t     ndiv    =     1;  
390
391   Float_t   partube[3];
392
393   partube[0] =  r0Right - 0.2;
394   partube[1] =  r4Right + 1.0;
395   partube[2] = fThickness/2.0;   
396   
397   TTUBE *v0RI = new TTUBE("V0RI", "V0RI", "void", partube[0], partube[1], partube[2]);
398                 
399   top->cd();
400   
401   v0Rnode = new TNode("V0RI","V0RI",v0RI,0.0,0.0,-zdet,0);
402   
403   v0Rnode->SetLineColor(kYellow);
404   fNodes->Add(v0Rnode);  
405   v0Rnode->SetVisibility(2);     
406  
407 // Rondelles de carbone (epaisseur 3.0 mm) de maintien des cellules ...
408
409   Float_t  lidThickness = 0.30;
410   
411   partube[0] =   r0Right;
412   partube[1] =   rBoxRight;
413   partube[2] =   +lidThickness/2.0;
414   
415   TTUBE  *v0CA = new TTUBE("V0CA", "V0CA", "void",partube[0], partube[1], partube[2]);
416   
417   v0Rnode->cd();
418   v0Rnode7 = new TNode("V0CA", "V0CA",v0CA,0.0,0.0, fThickness/2.0-partube[2],0);        
419   v0Rnode7->SetLineColor(kYellow);
420   fNodes->Add(v0Rnode7); 
421   v0Rnode->cd();
422   v0Rnode8 = new TNode("V0CA", "V0CA",v0CA,0.0,0.0,-fThickness/2.0+partube[2],0);        
423   v0Rnode8->SetLineColor(kYellow);
424   fNodes->Add(v0Rnode8);
425   
426   partube[0] =   r0Right;
427   partube[1] =   r0Right + 0.3;
428   partube[2] =   +fThickness/2.0;
429   
430   TTUBE *v0IR = new TTUBE("V0IR","V0IR","void", partube[0], partube[1], partube[2]);
431  
432   v0Rnode->cd();
433   v0Rnode9 = new TNode("V0IR", "V0IR",v0IR,0.0,0.0,0.0,0);
434   v0Rnode9->SetLineColor(kYellow);
435   fNodes->Add(v0Rnode9);
436
437   partube[0] =   rBoxRight - 0.3;
438   partube[1] =   rBoxRight; 
439   partube[2] =   +fThickness/2.0;
440
441   TTUBE  *v0ER = new TTUBE("V0ER","V0ER","void", partube[0], partube[1], partube[2]);
442   
443   v0Rnode->cd();
444   v0Rnode10 = new TNode("V0ER", "V0ER",v0ER,0.0,0.0,0.0,0);
445   v0Rnode10->SetLineColor(kYellow);
446   fNodes->Add(v0Rnode10);
447   
448   Float_t   partubs[5];
449  
450   partubs[0]      =  r0Right;
451   partubs[1]      =  r4Right;
452   partubs[2]      =  fThickness/2.0;
453   partubs[3]      =  90.0-22.5;
454   partubs[4]      = 135.0-22.5;
455
456   TTUBS  *v0R0 = new TTUBS("V0R0", "V0R0", "void",partubs[0], partubs[1], partubs[2], 
457                                                   partubs[3], partubs[4]); 
458                                                   
459   v0R0->SetNumberOfDivisions(ndiv);                                               
460
461   Float_t   r1Right =  r0Right + 0.3 + height1Right;
462   Float_t   offset  = fThickness/2.0 - lidThickness - fThickness1/2.0; 
463   Float_t   offsetFibers = 1.0;
464     
465   partubs[0]     =  r0Right + 0.3;
466   partubs[1]     =  r1Right;
467   partubs[2]     =  fThickness1/2.0;
468
469   TTUBS *v0R1 = new TTUBS("V0R1", "V0R1", "void", partubs[0], partubs[1], partubs[2], 
470                                                   partubs[3], partubs[4]);
471
472   v0R1->SetNumberOfDivisions(ndiv);
473   
474   Float_t   r2Right  =  r1Right + height2Right;       
475   
476   partubs[0]     =  r1Right;
477   partubs[1]     =  r2Right;
478
479   TTUBS *v0R2 = new TTUBS("V0R2", "V0R2", "void", partubs[0], partubs[1], partubs[2], 
480                                                   partubs[3], partubs[4]);
481
482   v0R2->SetNumberOfDivisions(ndiv);
483
484 // Ring 3 :
485
486   Float_t   r3Right  =  r2Right + height3Right;     
487    
488   partubs[0]     =  r2Right;
489   partubs[1]     =  r3Right;
490   partubs[3]     =  90.0-22.5;
491   partubs[4]     = 112.5-22.5;
492   
493   TTUBS *v0R3 = new TTUBS("V0R3", "V0R3", "void", partubs[0], partubs[1], partubs[2], 
494                                                   partubs[3], partubs[4]);
495   v0R3->SetNumberOfDivisions(ndiv);
496   
497   partubs[3]     = 112.5-22.5;
498   partubs[4]     = 135.0-22.5;
499   
500   TTUBS *v0R4 = new TTUBS("V0R4", "V0R4", "void", partubs[0], partubs[1], partubs[2], 
501                                                   partubs[3], partubs[4]);
502   v0R4->SetNumberOfDivisions(ndiv);
503   
504 // Ring 4 :  
505
506   partubs[0]     =  r3Right;
507   partubs[1]     =  r4Right;
508   partubs[3]     =  90.0-22.5;
509   partubs[4]     = 112.5-22.5;
510   
511   TTUBS *v0R5 = new TTUBS("V0R5", "V0R5", "void", partubs[0], partubs[1], partubs[2], 
512                                                   partubs[3], partubs[4]);
513   v0R5->SetNumberOfDivisions(ndiv);
514   
515   partubs[3]     = 112.5-22.5;
516   partubs[4]     = 135.0-22.5;
517   
518   TTUBS *v0R6 = new TTUBS("V0R6", "V0R6", "void", partubs[0], partubs[1], partubs[2], 
519                                                   partubs[3], partubs[4]);
520   v0R6->SetNumberOfDivisions(ndiv);
521         
522   Float_t  phi;
523   Float_t  phiDeg= 180./4.;
524     
525   Int_t    ndetR = 1; 
526
527   char     nameNode[12];  
528  
529   for (phi = 22.5; phi < 360.0; phi = phi + phiDeg)
530   
531   {     
532     TRotMatrix* mat920 = new TRotMatrix("rot920","rot920", 90.0, +phi, 90., 90.+phi, 0.0, 0.0 );        
533      
534     sprintf(nameNode,"SUBDER%d",ndetR);
535     
536     v0Rnode->cd();
537     v0Rnode0 = new TNode(nameNode,nameNode,v0R0,0.0,0.0, 0.0,mat920);    
538     v0Rnode0->SetLineColor(kYellow);
539     fNodes->Add(v0Rnode0);
540     ndetR++;
541     
542     sprintf(nameNode,"SUBDER%d",ndetR);
543     v0Rnode0->cd();    
544     v0Rnode1 = new TNode(nameNode,nameNode,v0R1,0.0,0.0, -offset ,0);    
545     v0Rnode1->SetLineColor(kColorVZERO);
546     fNodes->Add(v0Rnode1);
547     ndetR++;
548     
549     sprintf(nameNode,"SUBDER%d",ndetR);
550     v0Rnode0->cd();    
551     v0Rnode2 = new TNode(nameNode,nameNode,v0R2,0.0,0.0, -offset + offsetFibers,0);      
552     v0Rnode2->SetLineColor(kColorVZERO);
553     fNodes->Add(v0Rnode2);
554     ndetR++;
555
556     sprintf(nameNode,"SUBDER%d",ndetR);
557     v0Rnode0->cd();    
558     v0Rnode3 = new TNode(nameNode,nameNode,v0R3,0.0,0.0, -offset + 2.0*offsetFibers,0);  
559     v0Rnode3->SetLineColor(kColorVZERO);
560     fNodes->Add(v0Rnode3);
561     ndetR++;
562
563     sprintf(nameNode,"SUBDER%d",ndetR);
564     v0Rnode0->cd();    
565     v0Rnode4 = new TNode(nameNode,nameNode,v0R4,0.0,0.0, -offset + 2.0*offsetFibers,0);  
566     v0Rnode4->SetLineColor(kColorVZERO);
567     fNodes->Add(v0Rnode4);
568     ndetR++;
569     
570     sprintf(nameNode,"SUBDER%d",ndetR);
571     v0Rnode0->cd();    
572     v0Rnode5 = new TNode(nameNode,nameNode,v0R5,0.0,0.0, -offset + 2.0*offsetFibers,0);  
573     v0Rnode5->SetLineColor(kColorVZERO);
574     fNodes->Add(v0Rnode5);
575     ndetR++;
576     
577     sprintf(nameNode,"SUBDER%d",ndetR);
578     v0Rnode0->cd();    
579     v0Rnode6 = new TNode(nameNode,nameNode,v0R6,0.0,0.0, -offset + 2.0*offsetFibers,0);  
580     v0Rnode6->SetLineColor(kColorVZERO);
581     fNodes->Add(v0Rnode6);
582     ndetR++; 
583       
584     v0Rnode0->SetVisibility(2);    
585   }    
586
587 // Left side of VZERO :
588      
589   Float_t   r0Left      =    4.3;   
590   Float_t   height1Left =    3.3; 
591   Float_t   height2Left =    6.2;
592   Float_t   height3Left =    8.9; 
593   Float_t   height4Left =   20.9;     
594   Float_t   heightLeft  = height1Left + height2Left + height3Left + height4Left; 
595                                         
596   Float_t   r4Left      = r0Left  + heightLeft; 
597
598   partube[0] =  r0Left;
599   partube[1] =  r4Left;
600   partube[2] =  fThickness1/2.0; 
601   
602   TTUBE *v0LE = new TTUBE("V0LE", "V0LE", "void", partube[0], partube[1], partube[2]);
603                 
604   top->cd();
605   
606   v0Lnode = new TNode("V0LE","V0LE",v0LE,0.0,0.0,339.0+fThickness1/2.0,0);
607   
608   v0Lnode->SetLineColor(kBlue);
609   fNodes->Add(v0Lnode);
610   
611   v0Lnode->SetVisibility(2);
612
613   partubs[0]      =  r0Left;
614   partubs[1]      =  r4Left;
615   partubs[2]      =  fThickness1/2.0;
616   partubs[3]      =  90.0-22.5;
617   partubs[4]      = 135.0-22.5;
618   
619   TTUBS *v0L0 = new TTUBS("V0L0", "V0L0", "void", partubs[0], partubs[1], partubs[2], 
620                                                   partubs[3], partubs[4]);
621
622   v0L0->SetNumberOfDivisions(ndiv); 
623   v0L0->SetLineColor(7);
624   
625   Float_t   offsetLeft;
626   offsetLeft    = - fThickness1/2.0; 
627
628   Float_t   r1Left =  r0Left + height1Left;        
629       
630   partubs[0]     =  r0Left;
631   partubs[1]     =  r1Left;
632
633   TTUBS *v0L1 = new TTUBS("V0L1", "V0L1", "void", partubs[0], partubs[1], partubs[2], 
634                                                   partubs[3], partubs[4]);
635   v0L1->SetNumberOfDivisions(ndiv);
636   
637   Float_t   r2Left =  r1Left + height2Left;       
638   
639   partubs[0]     =  r1Left;
640   partubs[1]     =  r2Left;
641
642   TTUBS *v0L2 = new TTUBS("V0L2", "V0L2", "void", partubs[0], partubs[1], partubs[2], 
643                                                   partubs[3], partubs[4]);
644   v0L2->SetNumberOfDivisions(ndiv);
645
646   Float_t   r3Left =  r2Left + height3Left; 
647    
648   partubs[0]     =  r2Left;
649   partubs[1]     =  r3Left;
650   
651   TTUBS *v0L3 = new TTUBS("V0L3", "V0L3", "void", partubs[0], partubs[1], partubs[2], 
652                                                   partubs[3], partubs[4]);
653   v0L3->SetNumberOfDivisions(ndiv);
654
655   partubs[0]     =  r3Left;
656   partubs[1]     =  r4Left;
657   
658   TTUBS *v0L4 = new TTUBS("V0L4", "V0L4", "void", partubs[0], partubs[1], partubs[2], 
659                                                   partubs[3], partubs[4]);
660   v0L4->SetNumberOfDivisions(ndiv);
661  
662   Int_t    ndetL   = 1;
663  
664   for (phi = 22.5; phi < 360.0; phi = phi + phiDeg)
665   
666   {
667      
668     TRotMatrix* mat920 = new TRotMatrix("rot920","rot920", 90.0, +phi, 90., 90.+phi, 0.0, 0.0 );        
669      
670     sprintf(nameNode,"SUBDEL%d",ndetL);
671     
672     v0Lnode->cd();
673     v0Lnode0 = new TNode(nameNode,nameNode,v0L0,0.0,0.0, offsetLeft + halfThickQua,mat920);      
674     v0Lnode0->SetLineColor(kColorVZERO);
675     fNodes->Add(v0Lnode0);
676     ndetL++;
677     
678     sprintf(nameNode,"SUBDEL%d",ndetL);
679     v0Lnode0->cd();    
680     v0Lnode1 = new TNode(nameNode,nameNode,v0L1,0.0,0.0, 0.0,0);         
681     v0Lnode1->SetLineColor(kColorVZERO);
682     fNodes->Add(v0Lnode1);
683     ndetL++;
684     
685     sprintf(nameNode,"SUBDEL%d",ndetL);
686     v0Lnode0->cd();    
687     v0Lnode2 = new TNode(nameNode,nameNode,v0L2,0.0,0.0, 0.0,0);         
688     v0Lnode2->SetLineColor(kColorVZERO);
689     fNodes->Add(v0Lnode2);
690     ndetL++;
691
692     sprintf(nameNode,"SUBDEL%d",ndetL);
693     v0Lnode0->cd();    
694     v0Lnode3 = new TNode(nameNode,nameNode,v0L3,0.0,0.0, 0.0,0);         
695     v0Lnode3->SetLineColor(kColorVZERO);
696     fNodes->Add(v0Lnode3);
697     ndetL++;
698
699     sprintf(nameNode,"SUBDEL%d",ndetL);
700     v0Lnode0->cd();    
701     v0Lnode4 = new TNode(nameNode,nameNode,v0L4,0.0,0.0, 0.0,0);         
702     v0Lnode4->SetLineColor(kColorVZERO);
703     fNodes->Add(v0Lnode4);
704     ndetL++; 
705           
706     v0Lnode0->SetVisibility(2);    
707   }         
708 }  
709     
710 //_____________________________________________________________________________
711 void AliVZEROv5::CreateMaterials()
712 {
713
714 // Creates materials used for geometry 
715
716     AliDebug(2,"Create materials");
717     
718 /*
719     Float_t ppckov[14] = { 5.5e-9, 5.7e-9, 5.9e-9, 6.1e-9, 6.3e-9, 6.5e-9, 6.7e-9, 
720                            6.9e-9, 7.1e-9, 7.3e-9, 7.5e-9, 7.7e-9, 7.9e-9, 8.1e-9 };
721
722            
723     Float_t ppckov_alu[14] = { 5.5e-9, 5.7e-9, 5.9e-9, 6.1e-9, 6.3e-9, 6.5e-9, 6.7e-9, 
724                                6.9e-9, 7.1e-9, 7.3e-9, 7.5e-9, 7.7e-9, 7.9e-9, 8.1e-9 };
725                            
726     Float_t rindex_quarz[14] = { 1.52398,  1.53090, 1.53835, 1.54641, 1.55513, 1.56458, 
727                                  1.57488,  1.58611, 1.59842, 1.61197, 1.62696, 1.64362, 
728                                  1.662295, 1.68337 };
729                                  
730     Float_t absco_quarz[14] = { 105.8,  45.656, 35.665, 28.598, 25.007, 21.04, 17.525, 
731                                 14.177, 9.282, 4.0925, 1.149, 0.3627, 0.1497, 0.05 };   
732                                                                                         
733     Float_t effic_all[14]   = { 1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1. };
734     
735         
736     Float_t rindex_alu[14] = { 1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1. }; 
737     
738     
739     Float_t absco_alu[14]  = { 1e-4,1e-4,1e-4,1e-4,1e-4,1e-4,1e-4,1e-4,1e-4,1e-4,
740                                1e-4,1e-4,1e-4,1e-4 };
741     Float_t effic_alu[14]  = { 1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1. };
742
743 */        
744
745     Int_t *idtmed = fIdtmed->GetArray()-2999;
746     
747     
748 //  Parameters related to Quarz (SiO2) :
749  
750     Float_t aqua[2], zqua[2], densqua, wmatqua[2];
751     Int_t nlmatqua;
752     
753     aqua[0]    = 28.09;
754     aqua[1]    = 16.;
755     zqua[0]    = 14.;
756     zqua[1]    = 8.;
757     densqua    = 2.64;
758     nlmatqua   = -2;
759     wmatqua[0] = 1.;
760     wmatqua[1] = 2.;
761
762 // Parameters  related to aluminum sheets :
763     
764     Float_t  aal   = 26.98;
765     Float_t  zal   = 13.00; 
766     Float_t  densal=   2.7; 
767     Float_t  radlal=   8.9;
768        
769 // Parameters  related to scintillator CH :
770     
771     Float_t ascin[2] = {1.00794,12.011};
772     Float_t zscin[2] = {1.,6.};
773     Float_t wscin[2] = {1.,1.};
774     Float_t denscin  = 1.032;
775     
776 // AIR
777
778     Float_t aAir[4]={12.,14.,16.,36.};
779     Float_t zAir[4]={6.,7.,8.,18.};
780     Float_t wAir[4]={0.000124,0.755267,0.231781,0.012827};
781     Float_t dAir = 1.20479E-3;
782         
783 //  Definition of materials :
784        
785     AliMixture( 1, "AIR A$", aAir,zAir,dAir,4,wAir);
786     AliMixture(11, "AIR I$", aAir,zAir,dAir,4,wAir);
787     AliMaterial( 2, "CARBON$"  , 12.01, 6.0, 2.265, 18.8, 49.9, 0, 0);
788     AliMixture(  3, "QUA", aqua, zqua, densqua, nlmatqua, wmatqua);
789     AliMaterial( 4, "ALUMINIUM1$", 26.98, 13., 2.7, 8.9, 37.2, 0, 0);
790     AliMaterial( 5, "ALUMINIUM2$", aal, zal, densal, radlal, 0, 0, 0);
791  
792     AliMixture( 6, "Scintillator$",ascin,zscin,denscin,-2,wscin);
793     
794      
795     Int_t   iSXFLD = gAlice->Field()->Integ();
796     Float_t sXMGMX = gAlice->Field()->Max();
797     
798     Float_t tmaxfd, stemax, deemax, epsil, stmin;
799         
800     tmaxfd = 10.;
801     stemax = 0.1;
802     deemax = 0.1;     
803     epsil  = 0.001;
804     stmin  = 0.001;
805   
806 //  Active Air :    
807     AliMedium(1, "ACTIVE AIR$", 1, 1, iSXFLD, sXMGMX,
808               10.0, 1.0, 0.1, 0.1, 10.0, 0, 0) ;
809
810 //  Inactive air : 
811   
812     AliMedium(11, "INACTIVE AIR$", 11, 0, iSXFLD, sXMGMX,
813               10.0, 1.0, 0.1, 0.1, 10.0, 0, 0) ;
814     
815     AliMedium(2, "CARBON$ ", 2,  1, iSXFLD, sXMGMX,
816               tmaxfd, stemax, deemax, epsil, stmin, 0, 0);   
817
818     AliMedium(3, "QUARZ$", 3, 1, iSXFLD, sXMGMX,
819               tmaxfd, fMaxStepQua, fMaxDestepQua, epsil, stmin, 0, 0);
820     
821     AliMedium(4,"ALUMINUM1$",4, 1, iSXFLD, sXMGMX,
822               tmaxfd, fMaxStepAlu, fMaxDestepAlu, epsil, stmin, 0, 0);
823               
824
825     AliMedium(5,"ALUMINUM2$",5, 1, iSXFLD, sXMGMX,
826               tmaxfd, fMaxStepAlu, fMaxDestepAlu, epsil, stmin, 0, 0);    
827
828     AliMedium(6,"SCINTILLATOR$",6, 1, iSXFLD, sXMGMX, 10.0, 0.1, 0.1, 0.003, 0.003, 0, 0);
829
830     gMC->Gstpar(idtmed[3000], "LOSS", 1.);  //  [3000] = air ACTIF  [3010] = air INACTIF
831     gMC->Gstpar(idtmed[3000], "HADR", 1.);
832     gMC->Gstpar(idtmed[3000], "DCAY", 1.);
833     gMC->Gstpar(idtmed[3000], "DRAY", 1.);
834     
835     gMC->Gstpar(idtmed[3001], "LOSS", 1.);  //  [3001] = carbon
836     gMC->Gstpar(idtmed[3001], "HADR", 1.);
837     gMC->Gstpar(idtmed[3001], "DCAY", 1.);
838     gMC->Gstpar(idtmed[3001], "DRAY", 1.);
839
840     gMC->Gstpar(idtmed[3002], "LOSS", 1.);  //  [3002] = quartz
841     gMC->Gstpar(idtmed[3002], "HADR", 1.);
842     gMC->Gstpar(idtmed[3002], "DCAY", 1.);
843     gMC->Gstpar(idtmed[3002], "DRAY", 1.);  
844     gMC->Gstpar(idtmed[3002], "CUTGAM",0.5E-4) ; 
845     gMC->Gstpar(idtmed[3002], "CUTELE",1.0E-4) ;
846     
847     gMC->Gstpar(idtmed[3003], "LOSS", 1.);  //  [3003] = normal aluminum
848     gMC->Gstpar(idtmed[3003], "HADR", 1.);
849     gMC->Gstpar(idtmed[3003], "DCAY", 1.);
850     gMC->Gstpar(idtmed[3003], "DRAY", 1.);
851     
852     gMC->Gstpar(idtmed[3004], "LOSS", 1.);  //  [3004] = reflecting aluminum
853     gMC->Gstpar(idtmed[3004], "HADR", 1.);
854     gMC->Gstpar(idtmed[3004], "DCAY", 1.);
855     gMC->Gstpar(idtmed[3004], "DRAY", 1.);
856     gMC->Gstpar(idtmed[3004], "CUTGAM",0.5E-4) ; 
857     gMC->Gstpar(idtmed[3004], "CUTELE",1.0E-4) ;
858     
859     gMC->Gstpar(idtmed[3005], "LOSS", 1.);  //  [3005] = scintillator
860     gMC->Gstpar(idtmed[3005], "HADR", 1.);
861     gMC->Gstpar(idtmed[3005], "DCAY", 1.);
862     gMC->Gstpar(idtmed[3005], "DRAY", 1.); 
863     gMC->Gstpar(idtmed[3005], "CUTGAM",0.5E-4) ; 
864     gMC->Gstpar(idtmed[3005], "CUTELE",1.0E-4) ;
865       
866     
867 //    geant3->Gsckov(idtmed[3002], 14, ppckov, absco_quarz, effic_all,rindex_quarz);    
868 //    geant3->Gsckov(idtmed[3004], 14, ppckov_alu, absco_alu, effic_alu, rindex_alu);
869
870 //    gMC->SetCerenkov(idtmed[3002], 14, ppckov, absco_quarz, effic_all,rindex_quarz);    
871 //    gMC->SetCerenkov(idtmed[3004], 14, ppckov_alu, absco_alu, effic_alu, rindex_alu);
872                                        
873 }
874
875 //_____________________________________________________________________________
876 void AliVZEROv5::DrawModule() const
877 {
878
879 //  Drawing is done in DrawVZERO.C
880
881    AliDebug(2,"DrawModule");
882 }
883
884 //_____________________________________________________________________________
885 void AliVZEROv5::Init()
886 {
887 // Initialises version 2 of the VZERO Detector
888 // Just prints an information message
889   
890    AliInfo(Form("VZERO version %d initialized \n",IsVersion()));
891    
892 //   gMC->SetMaxStep(fMaxStepAlu);
893 //   gMC->SetMaxStep(fMaxStepQua);
894    
895     AliVZERO::Init();  
896 }
897
898 //_____________________________________________________________________________
899 void AliVZEROv5::StepManager()
900 {
901  
902 // Step Manager, called at each step 
903  
904      Int_t     copy;
905      static    Int_t   vol[4];
906      static    Float_t hits[21];
907      static    Float_t eloss, tlength;
908      static    Int_t   nPhotonsInStep;
909      static    Int_t   nPhotons; 
910      static    Int_t   numStep;
911      Float_t   ringNumber;
912      Float_t   destep, step;
913      
914      numStep += 1; 
915           
916 //   We keep only charged tracks :
917      
918      if ( !gMC->TrackCharge() || !gMC->IsTrackAlive() ) return; 
919
920      vol[0]    = gMC->CurrentVolOffID(1, vol[1]);
921      vol[2]    = gMC->CurrentVolID(copy);
922      vol[3]    = copy;
923      
924      static Int_t idV0R1 = gMC->VolId("V0R1");
925      static Int_t idV0L1 = gMC->VolId("V0L1");
926      static Int_t idV0R2 = gMC->VolId("V0R2");
927      static Int_t idV0L2 = gMC->VolId("V0L2");
928      static Int_t idV0R3 = gMC->VolId("V0R3");
929      static Int_t idV0L3 = gMC->VolId("V0L3");
930      static Int_t idV0R4 = gMC->VolId("V0R4");
931      static Int_t idV0L4 = gMC->VolId("V0L4");
932      static Int_t idV0R5 = gMC->VolId("V0R5");
933      static Int_t idV0R6 = gMC->VolId("V0R6");
934
935      if      ( gMC->CurrentVolID(copy) == idV0R1 ||
936                gMC->CurrentVolID(copy) == idV0L1 )
937                ringNumber = 1.0;
938      else if ( gMC->CurrentVolID(copy) == idV0R2 ||
939                gMC->CurrentVolID(copy) == idV0L2 ) 
940                ringNumber = 2.0;  
941      else if ( gMC->CurrentVolID(copy) == idV0R3 ||
942                gMC->CurrentVolID(copy) == idV0R4 ||
943                gMC->CurrentVolID(copy) == idV0L3 )
944                ringNumber = 3.0;
945      else if ( gMC->CurrentVolID(copy) == idV0R5 ||
946                gMC->CurrentVolID(copy) == idV0R6 ||
947                gMC->CurrentVolID(copy) == idV0L4 )
948                ringNumber = 4.0;               
949      else
950                ringNumber = 0.0;
951
952      if  (  ringNumber > 0.5  ) { 
953      
954         destep    = gMC->Edep();
955         step      = gMC->TrackStep();
956         
957         nPhotonsInStep  = Int_t(destep / (fLightYield *1e-9) ); 
958         nPhotonsInStep  = gRandom->Poisson(nPhotonsInStep);
959         
960         eloss    += destep;
961         tlength  += step;        
962         
963         if  ( gMC->IsTrackEntering()  )  { 
964          
965             nPhotons  =  nPhotonsInStep;       
966             gMC->TrackPosition(fTrackPosition);
967             gMC->TrackMomentum(fTrackMomentum);
968             
969             Float_t pt  = TMath::Sqrt( fTrackMomentum.Px() * fTrackMomentum.Px() +
970                                        fTrackMomentum.Py() * fTrackMomentum.Py() );
971                
972             hits[0]  = fTrackPosition.X();
973             hits[1]  = fTrackPosition.Y();
974             hits[2]  = fTrackPosition.Z();               
975             hits[3]  = Float_t (gMC->TrackPid()); 
976
977             hits[4]  = gMC->TrackTime();
978             hits[5]  = gMC->TrackCharge();
979             hits[6]  = fTrackMomentum.Theta()*TMath::RadToDeg();
980             hits[7]  = fTrackMomentum.Phi()*TMath::RadToDeg();
981             hits[8]  = ringNumber;
982          
983             hits[9]  = pt;
984             hits[10] = fTrackMomentum.P();
985             hits[11] = fTrackMomentum.Px();
986             hits[12] = fTrackMomentum.Py();
987             hits[13] = fTrackMomentum.Pz();
988             
989             TParticle *par = gAlice->GetMCApp()->Particle(gAlice->GetMCApp()->GetCurrentTrackNumber());
990             hits[14] = par->Vx();
991             hits[15] = par->Vy();
992             hits[16] = par->Vz();
993             
994             tlength  = 0.0;
995             eloss    = 0.0;         
996          }
997          
998          nPhotons  = nPhotons + nPhotonsInStep;
999          
1000          if( gMC->IsTrackExiting() || gMC->IsTrackStop() || gMC->IsTrackDisappeared()){
1001          
1002          nPhotons  = nPhotons - Int_t((Float_t(nPhotons) * fLightAttenuation * fnMeters));       
1003          nPhotons  = nPhotons - Int_t( Float_t(nPhotons) * fFibToPhot);  
1004          
1005          hits[17] =   eloss;
1006          hits[18] = tlength;
1007          hits[19] = nPhotons;
1008          hits[20] = GetCellId (vol, hits); 
1009                  
1010          AddHit(gAlice->GetMCApp()->GetCurrentTrackNumber(), vol, hits);
1011                  
1012          tlength         = 0.0;
1013          eloss           = 0.0; 
1014          nPhotons        =   0;
1015          nPhotonsInStep  =   0;
1016          
1017          numStep         =   0;  
1018          } 
1019     }
1020       
1021 }
1022
1023 //_____________________________________________________________________________
1024 void AliVZEROv5::AddHit(Int_t track, Int_t *vol, Float_t *hits)
1025 {
1026   
1027 //  Adds a VZERO hit
1028   
1029   TClonesArray &lhits = *fHits;
1030   new(lhits[fNhits++]) AliVZEROhit(fIshunt,track,vol,hits);
1031 }
1032
1033 //_____________________________________________________________________________
1034 void AliVZEROv5::AddDigits(Int_t *tracks, Int_t* digits) 
1035 {
1036
1037 //  Adds a VZERO digit
1038
1039    TClonesArray  &ldigits = *fDigits;
1040    new(ldigits[fNdigits++]) AliVZEROdigit(tracks, digits);
1041 }
1042
1043 //_____________________________________________________________________________
1044 void AliVZEROv5::MakeBranch(Option_t *option)
1045 {
1046   
1047 // Creates new branches in the current Root Tree
1048     
1049   char branchname[10];
1050   sprintf(branchname,"%s",GetName());
1051   AliDebug(2,Form("fBufferSize = %d",fBufferSize));
1052   
1053   const char *cH = strstr(option,"H");
1054   
1055   if (fHits   && TreeH() && cH) {
1056     TreeH()->Branch(branchname,&fHits, fBufferSize);
1057     AliDebug(2,Form("Making Branch %s for hits",branchname));
1058   }     
1059
1060   const char *cD = strstr(option,"D");
1061   
1062   if (fDigits   && fLoader->TreeD() && cD) {
1063     fLoader->TreeD()->Branch(branchname,&fDigits, fBufferSize);
1064     AliDebug(2,Form("Making Branch %s for digits",branchname));
1065   }  
1066    
1067 }
1068
1069 //_____________________________________________________________________________
1070 Int_t AliVZEROv5::GetCellId(Int_t *vol, Float_t *hits) 
1071 {
1072
1073   //   Returns Id of scintillator cell
1074   //   Right side from  0 to 47
1075   //   Left  side from 48 to 95
1076   
1077   //   hits[8] = ring number (1 to 4)
1078   //   vol[1]  = copy number (1 to 8)
1079
1080    Int_t index      = vol[1];
1081    Int_t RingNumber = Int_t(hits[8]);   
1082    fCellId          = 0;
1083    
1084 //    cout << "volID = " << vol[0] << "  copy = " << vol[1] << endl;
1085 //    cout << "X     = " << hits[0] << "    Y = " << hits[1] << endl;
1086    
1087    Float_t phi = Float_t(TMath::ATan2(Double_t(hits[1]),Double_t(hits[0])) ); 
1088    Float_t kRaddeg = 180.0/TMath::Pi();
1089    phi = kRaddeg * phi;
1090     
1091    if (index < 7) index = index + 8; 
1092    
1093    if (hits[2] < 0.0) { 
1094       if(RingNumber < 3) {
1095          index = (index - 7) + ( ( RingNumber - 1 ) * 8);}
1096       else if(RingNumber >= 3){ 
1097        if(gMC->CurrentVolID(vol[1]) == gMC->VolId("V0R3")|| 
1098           gMC->CurrentVolID(vol[1]) == gMC->VolId("V0R5") ) 
1099          {index = (index*2 - 14) + ( ( RingNumber - 2 ) * 16); }
1100        if(gMC->CurrentVolID(vol[1]) == gMC->VolId("V0R4")||
1101           gMC->CurrentVolID(vol[1]) == gMC->VolId("V0R6") ) 
1102          {index = (index*2 - 13) + ( ( RingNumber - 2 ) * 16); }
1103       }
1104       fCellId   = index;           
1105    }
1106            
1107    else if (hits[2] > 0.0){
1108       index = (index - 7 + 48) + ( ( RingNumber - 1 ) * 8);
1109       fCellId   = index;}
1110              
1111 //    cout << " ring   = " << RingNumber << " phi = "<<  phi << endl; 
1112 //    cout << " cellID = " << fCellId <<  endl;
1113 //    cout <<  "**********" << endl;         
1114            
1115    return fCellId;
1116    
1117    
1118 }