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