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