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