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