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