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