]> git.uio.no Git - u/mrichter/AliRoot.git/blob - VZERO/AliVZEROv5.cxx
macro and flowevent maker to run part of the code in root
[u/mrichter/AliRoot.git] / VZERO / AliVZEROv5.cxx
1 /**************************************************************************
2  * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3  *                                                                        *
4  * Author: The ALICE Off-line Project.                                    *
5  * Contributors are mentioned in the code where appropriate.              *
6  *                                                                        *
7  * Permission to use, copy, modify and distribute this software and its   *
8  * documentation strictly for non-commercial purposes is hereby granted   *
9  * without fee, provided that the above copyright notice appears in all   *
10  * copies and that both the copyright notice and this permission notice   *
11  * appear in the supporting documentation. The authors make no claims     *
12  * about the suitability of this software for any purpose. It is          *
13  * provided "as is" without express or implied warranty.                  *
14  **************************************************************************/
15
16 /* $Id$ */
17
18 //////////////////////////////////////////////////////////////////////
19 //                                                                  //
20 //  (V-zero) detector  version 5  as designed by the Lyon group     //
21 //   All comments should be sent to Brigitte CHEYNIS :              //
22 //                                  b.cheynis@ipnl.in2p3.fr         // 
23 //   Geometry of the  16 th of june 2004                            //
24 //  (now 8 sectors instead of 12 sectors as in previous version)    // 
25 //   V0R (now V0C) sits between Z values  -89.6 and  -84.9 cm       //
26 //   V0L (now V0A) sits between Z values +339.0 and +341.0 cm       //
27 //   New coordinate system has been implemented in october 2003     //
28 //                                                                  //
29 //////////////////////////////////////////////////////////////////////
30
31 // --- Standard libraries ---
32 #include <Riostream.h>
33 #include <stdlib.h>
34 #include <string.h>
35
36 // --- ROOT libraries ---
37 #include <TClonesArray.h>
38 #include <TLorentzVector.h>
39 #include <TMath.h>
40 #include <TObjectTable.h>
41 #include <TVirtualMC.h>
42 #include <TParticle.h>
43
44 // --- AliRoot header files ---
45 #include "AliRun.h"
46 #include "AliMC.h"
47 #include "AliConst.h"
48 #include "AliMagF.h"
49 #include "AliVZEROLoader.h"
50 #include "AliVZEROdigit.h"
51 #include "AliVZEROhit.h"
52 #include "AliVZEROv5.h"
53 #include "AliLog.h"
54  
55 ClassImp(AliVZEROv5)
56
57 //_____________________________________________________________________________
58 AliVZEROv5:: AliVZEROv5():AliVZERO(),
59    fCellId(0),
60    fTrackPosition(),
61    fTrackMomentum(), 
62    fLightYield(93.75),
63    fLightAttenuation(0.05),
64    fnMeters(15.0),
65    fFibToPhot(0.3)
66 {
67 // Standard default constructor 
68 }
69
70 //_____________________________________________________________________________
71 AliVZEROv5::AliVZEROv5(const char *name, const char *title):
72    AliVZERO(name,title),
73    fCellId(0),
74    fTrackPosition(),
75    fTrackMomentum(),
76    fLightYield(93.75),
77    fLightAttenuation(0.05),
78    fnMeters(15.0),
79    fFibToPhot(0.3)    
80 {
81
82 // Standard constructor for V-zero Detector  version 5
83
84   AliDebug(2,"Create VZERO object ");
85 //       
86 //   fLightYield              =  93.75; // Light yield in BC408 (93.75 eV per photon)
87 //   fLightAttenuation        =   0.05; // Light attenuation in fiber (0.05 per meter)
88 //   fnMeters                 =   15.0; // Number of meters of clear fibers to PM
89 //   fFibToPhot               =    0.3; // Attenuation at fiber-photocathode interface
90 }
91
92 //_____________________________________________________________________________
93 void AliVZEROv5::CreateGeometry()
94 {
95
96 // Creates the GEANT geometry of the V-zero Detector  version 5
97   
98   AliDebug(2,"Create Geometry ");
99       
100   Int_t    *idtmed = fIdtmed->GetArray()-2999;
101
102   Int_t    ndetR = 1;
103   Int_t    ndetL = 1;
104  
105   Int_t    ncellsR = 1;
106   Int_t    ncellsL = 1;
107   
108   Int_t    idrotm[999];
109  
110   Float_t  height1Right, height2Right, height3Right, height4Right; 
111   Float_t  heightRight;
112   Float_t  theta;  
113   
114   Float_t  halfThickQua;
115   
116   Float_t  zdet;
117   Float_t  r0Right, r4Right, rBoxRight;
118   Float_t  pi = TMath::Pi();
119     
120   height1Right    =     2.6;  // height of cell 1, in cm
121   height2Right    =     4.6;  // height of cell 2, in cm
122   height3Right    =     7.6;  // height of cell 3, in cm
123   height4Right    =    12.7;  // height of cell 4, in cm
124   
125   theta       = pi/4.0/2.0;       // half angular opening = 22.5 degrees
126     
127   halfThickQua= fThickness1/2.0;  // half thickness of elementary cell (inner ring)
128   
129 // distance 0.6 cm in zdet accounts for the fact V0R box back lid sits 0.6 away from 
130 // absorber nose sitting at 90 cm. Will use -zdet later...
131 // size of V0R box (fThickness) is increased by 3 mm as compared to basic version  
132
133   fThickness  =    fThickness + 0.3;             // now 4.7 cm instead of 4.4 cm
134   zdet        =    90.0 - 0.6 - fThickness/2.0;  // distance to vertex (along Z axis)   
135   r0Right     =    4.20;          // closest distance to center of the beam pipe
136   heightRight =    height1Right + height2Right + height3Right + height4Right;
137   r4Right     =    r0Right + heightRight + 0.3;
138   rBoxRight   =    38.0;          // external radius of right box
139      
140 // Creation of mother volume v0LE - left part - :
141 // Entrance face at  +339.0 cm  (new coordinate system) ...
142
143    Float_t   partube[3];
144    
145    partube[0] =  4.3;
146    partube[1] = 44.0;
147    partube[2] = fThickness1/2.0;   
148     
149    gMC->Gsvolu("V0LE","TUBE",idtmed[3005],partube,3);
150      
151 // Creation of five rings - left part - :
152 // Entrance face at +339.0 cm  (new coordinate system) ... 
153
154 // Mother volume v0L0 in which will be set 5 scintillator cells 
155
156   Float_t   partubs[5];  
157     
158   Float_t   r0Left      =   4.3;   
159   Float_t   height1Left =   3.3;  
160   Float_t   height2Left =   6.2;  
161   Float_t   height3Left =   8.9; 
162   Float_t   height4Left =  20.9;  
163   Float_t   heightLeft  =   height1Left + height2Left + height3Left + height4Left; 
164                                       
165   Float_t   r4Left      =   r0Left  + heightLeft; 
166   
167   partubs[0]     =  r0Left;
168   partubs[1]     =  r4Left;
169   partubs[2]     =  fThickness1/2.0;
170   partubs[3]     =  90.0-22.5;
171   partubs[4]     = 135.0-22.5;
172
173   gMC->Gsvolu("V0L0","TUBS",idtmed[3010],partubs,5);  // air volume
174   
175   Float_t  r1Left =  r0Left + height1Left;        
176      
177   partubs[0]     =  r0Left;
178   partubs[1]     =  r1Left;
179
180   gMC->Gsvolu("V0L1","TUBS",idtmed[3005],partubs,5);  // quartz volume
181   gMC->Gspos("V0L1",1,"V0L0", 0.0, 0.0 , 0.0, 0,"ONLY"); 
182
183   Float_t  r2Left  =  r1Left + height2Left;       
184   
185   partubs[0]     =  r1Left;
186   partubs[1]     =  r2Left;
187
188   gMC->Gsvolu("V0L2","TUBS",idtmed[3005],partubs,5);  // quartz volume
189   gMC->Gspos("V0L2",1,"V0L0", 0.0, 0.0 , 0.0, 0,"ONLY"); 
190   
191   Float_t  r3Left  =  r2Left + height3Left;       
192       
193   partubs[0]     =  r2Left;
194   partubs[1]     =  r3Left;
195
196   gMC->Gsvolu("V0L3","TUBS",idtmed[3005],partubs,5);  // quartz volume
197   gMC->Gspos("V0L3",1,"V0L0", 0.0, 0.0 , 0.0, 0,"ONLY");
198
199   partubs[0]     =  r3Left;
200   partubs[1]     =  r4Left;
201
202   gMC->Gsvolu("V0L4","TUBS",idtmed[3005],partubs,5);  // quartz volume
203   gMC->Gspos("V0L4",1,"V0L0", 0.0, 0.0 , 0.0, 0,"ONLY");  
204
205 // Creation of mother volume v0RI - right part - :
206   
207   partube[0] = r0Right - 0.2;
208   partube[1] = r4Right + 1.0;
209   partube[2] = fThickness/2.0; 
210       
211   gMC->Gsvolu("V0RI","TUBE",idtmed[3010],partube,3);
212   
213 // Creation of  carbon lids (3.0 mm thick) to keep v0RI box shut...
214
215   Float_t  lidThickness = 0.30;
216  
217   partube[0] =   r0Right;
218   partube[1] =   rBoxRight;
219   partube[2] =   +lidThickness/2.0;
220     
221   gMC->Gsvolu("V0CA","TUBE",idtmed[3001],partube,3); 
222   gMC->Gspos("V0CA",1,"V0RI",0.0,0.0, fThickness/2.0-partube[2],0,"ONLY");
223   gMC->Gspos("V0CA",2,"V0RI",0.0,0.0,-fThickness/2.0+partube[2],0,"ONLY");
224   
225 // Creation of aluminum rings 3.0 mm thick to maintain the v0RI pieces ...
226
227   partube[0] =   r0Right;
228   partube[1] =   r0Right + 0.3;
229   partube[2] =   +fThickness/2.0;
230    
231   gMC->Gsvolu("V0IR","TUBE",idtmed[3003],partube,3);    
232   gMC->Gspos("V0IR",1,"V0RI",0.0,0.0,0.0,0,"ONLY");
233
234   partube[0] =   rBoxRight - 0.3;
235   partube[1] =   rBoxRight;
236   partube[2] =   +fThickness/2.0;
237  
238   gMC->Gsvolu("V0ER","TUBE",idtmed[3003],partube,3);    
239   gMC->Gspos("V0ER",1,"V0RI",0.0,0.0,0.0,0,"ONLY");
240   
241 // Mother volume v0R0 in which will be set 6 scintillator cells 
242   
243   partubs[0]      =  r0Right;
244   partubs[1]      =  r4Right;
245   partubs[2]      =  fThickness/2.0;
246   partubs[3]      =  90.0-22.5;
247   partubs[4]      = 135.0-22.5;
248
249   gMC->Gsvolu("V0R0","TUBS",idtmed[3010],partubs,5);  // air volume 
250
251 // Elementary cell of ring 1 :
252 // (cells of ring 1 will be shifted by 2.0 cm backwards to output fibers)
253    
254   Float_t   offsetFibers  =  1.0;
255   Float_t   offset        =  fThickness/2.0 - lidThickness - fThickness1/2.0; 
256   Float_t   r1Right       =  r0Right + 0.3 + height1Right;
257       
258   partubs[0]     =  r0Right + 0.3;
259   partubs[1]     =  r1Right;
260   partubs[2]     =  fThickness1/2.0;
261   
262   gMC->Gsvolu("V0R1","TUBS",idtmed[3005],partubs,5);  // scintillator volume
263   gMC->Gspos("V0R1",1,"V0R0", 0.0, 0.0 , -offset, 0,"ONLY"); 
264
265 // Elementary cell of ring 2 :
266 // (cells of ring 2 will be shifted by 1.0 cm backwards to output fibers)
267
268   Float_t   r2Right   =  r1Right + height2Right;       
269   
270   partubs[0]     =  r1Right;
271   partubs[1]     =  r2Right;
272
273   gMC->Gsvolu("V0R2","TUBS",idtmed[3005],partubs,5);  // scintillator volume
274   gMC->Gspos("V0R2",1,"V0R0", 0.0, 0.0 , -offset + offsetFibers, 0,"ONLY"); 
275
276 // Elementary cell of ring 3 :
277
278   Float_t   r3Right   =  r2Right + height3Right;   
279      
280   partubs[0]     =  r2Right;
281   partubs[1]     =  r3Right;
282   partubs[3]     =  90.0-22.5;
283   partubs[4]     = 112.5-22.5;
284
285   gMC->Gsvolu("V0R3","TUBS",idtmed[3005],partubs,5);  // scintillator volume
286   gMC->Gspos("V0R3",1,"V0R0", 0.0, 0.0 , -offset + 2.0 * offsetFibers, 0,"ONLY");
287   
288   partubs[3]     = 112.5-22.5;
289   partubs[4]     = 135.0-22.5;
290   gMC->Gsvolu("V0R4","TUBS",idtmed[3005],partubs,5);  // scintillator volume
291   gMC->Gspos("V0R4",1,"V0R0", 0.0, 0.0 , -offset + 2.0 * offsetFibers, 0,"ONLY");
292   
293 // Elementary cell of ring 4 :
294    
295   partubs[0]     =  r3Right;
296   partubs[1]     =  r4Right;
297   partubs[3]     =  90.0-22.5;
298   partubs[4]     = 112.5-22.5;
299
300   gMC->Gsvolu("V0R5","TUBS",idtmed[3005],partubs,5);  // scintillator volume
301   gMC->Gspos("V0R5",1,"V0R0", 0.0, 0.0 , -offset + 2.0 * offsetFibers, 0,"ONLY");
302   
303   partubs[3]     = 112.5-22.5;
304   partubs[4]     = 135.0-22.5;
305   gMC->Gsvolu("V0R6","TUBS",idtmed[3005],partubs,5);  // scintillator volume
306   gMC->Gspos("V0R6",1,"V0R0", 0.0, 0.0 , -offset + 2.0 * offsetFibers, 0,"ONLY");
307     
308   Float_t  phiDeg = 180./4.; 
309
310 // Right part : 
311  
312   for(Float_t  phi = 22.5; phi < 360.0; phi = phi + phiDeg)
313       {        
314         AliMatrix(idrotm[902], 90.0, phi, 90.0, 90.0 +phi, 0.0 , 0.0);
315         gMC->Gspos("V0R0",ndetR,"V0RI",0.0,
316                           0.0,0.0,idrotm[902],"ONLY");
317         ndetR++;
318        }
319
320   gMC->Gspos("V0RI",1,"ALIC",0.0,0.0,-zdet,0,"ONLY");
321  
322   ncellsR = (ndetR - 1) * 6;  
323   AliInfo(Form("Number of cells on Right side =   %d\n",  ncellsR));
324
325 // Left part :
326   
327   for(Float_t  phi = 22.5; phi < 360.0; phi = phi + phiDeg)
328       {       
329         AliMatrix(idrotm[902], 90.0, phi, 90.0, 90.0 +phi, 0.0 , 0.0);
330         gMC->Gspos("V0L0",ndetL,"V0LE",0.0,
331                           0.0,0.0,idrotm[902],"ONLY");
332         ndetL++;
333        }
334
335   gMC->Gspos("V0LE",1,"ALIC",0.0,0.0,339.0+fThickness1/2.0,0,"ONLY");
336  
337   ncellsL = (ndetL - 1) * 4;
338   AliInfo(Form("Number of cells on Left side  =   %d\n",  ncellsL));    
339            
340 }
341             
342 //_____________________________________________________________________________
343 void AliVZEROv5::CreateMaterials()
344 {
345
346 // Creates materials used for geometry 
347
348     AliDebug(2,"Create materials");
349     
350 /*
351     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, 
352                            6.9e-9, 7.1e-9, 7.3e-9, 7.5e-9, 7.7e-9, 7.9e-9, 8.1e-9 };
353
354            
355     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, 
356                                6.9e-9, 7.1e-9, 7.3e-9, 7.5e-9, 7.7e-9, 7.9e-9, 8.1e-9 };
357                            
358     Float_t rindex_quarz[14] = { 1.52398,  1.53090, 1.53835, 1.54641, 1.55513, 1.56458, 
359                                  1.57488,  1.58611, 1.59842, 1.61197, 1.62696, 1.64362, 
360                                  1.662295, 1.68337 };
361                                  
362     Float_t absco_quarz[14] = { 105.8,  45.656, 35.665, 28.598, 25.007, 21.04, 17.525, 
363                                 14.177, 9.282, 4.0925, 1.149, 0.3627, 0.1497, 0.05 };   
364                                                                                         
365     Float_t effic_all[14]   = { 1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1. };
366     
367         
368     Float_t rindex_alu[14] = { 1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1. }; 
369     
370     
371     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,
372                                1e-4,1e-4,1e-4,1e-4 };
373     Float_t effic_alu[14]  = { 1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1. };
374
375 */        
376
377     Int_t *idtmed = fIdtmed->GetArray()-2999;
378     
379     
380 //  Parameters related to Quarz (SiO2) :
381  
382     Float_t aqua[2], zqua[2], densqua, wmatqua[2];
383     Int_t nlmatqua;
384     
385     aqua[0]    = 28.09;
386     aqua[1]    = 16.;
387     zqua[0]    = 14.;
388     zqua[1]    = 8.;
389     densqua    = 2.64;
390     nlmatqua   = -2;
391     wmatqua[0] = 1.;
392     wmatqua[1] = 2.;
393
394 // Parameters  related to aluminum sheets :
395     
396     Float_t  aal   = 26.98;
397     Float_t  zal   = 13.00; 
398     Float_t  densal=   2.7; 
399     Float_t  radlal=   8.9;
400        
401 // Parameters  related to scintillator CH :
402     
403     Float_t ascin[2] = {1.00794,12.011};
404     Float_t zscin[2] = {1.,6.};
405     Float_t wscin[2] = {1.,1.};
406     Float_t denscin  = 1.032;
407     
408 // AIR
409
410     Float_t aAir[4]={12.,14.,16.,36.};
411     Float_t zAir[4]={6.,7.,8.,18.};
412     Float_t wAir[4]={0.000124,0.755267,0.231781,0.012827};
413     Float_t dAir = 1.20479E-3;
414         
415 //  Definition of materials :
416        
417     AliMixture( 1, "AIR A$", aAir,zAir,dAir,4,wAir);
418     AliMixture(11, "AIR I$", aAir,zAir,dAir,4,wAir);
419     AliMaterial( 2, "CARBON$"  , 12.01, 6.0, 2.265, 18.8, 49.9, 0, 0);
420     AliMixture(  3, "QUA", aqua, zqua, densqua, nlmatqua, wmatqua);
421     AliMaterial( 4, "ALUMINIUM1$", 26.98, 13., 2.7, 8.9, 37.2, 0, 0);
422     AliMaterial( 5, "ALUMINIUM2$", aal, zal, densal, radlal, 0, 0, 0);
423  
424     AliMixture( 6, "Scintillator$",ascin,zscin,denscin,-2,wscin);
425     
426      
427     Int_t   iSXFLD = gAlice->Field()->Integ();
428     Float_t sXMGMX = gAlice->Field()->Max();
429     
430     Float_t tmaxfd, stemax, deemax, epsil, stmin;
431         
432     tmaxfd = 10.;
433     stemax = 0.1;
434     deemax = 0.1;     
435     epsil  = 0.001;
436     stmin  = 0.001;
437   
438 //  Active Air :    
439     AliMedium(1, "ACTIVE AIR$", 1, 1, iSXFLD, sXMGMX,
440               10.0, 1.0, 0.1, 0.1, 10.0, 0, 0) ;
441
442 //  Inactive air : 
443   
444     AliMedium(11, "INACTIVE AIR$", 11, 0, iSXFLD, sXMGMX,
445               10.0, 1.0, 0.1, 0.1, 10.0, 0, 0) ;
446     
447     AliMedium(2, "CARBON$ ", 2,  1, iSXFLD, sXMGMX,
448               tmaxfd, stemax, deemax, epsil, stmin, 0, 0);   
449
450     AliMedium(3, "QUARZ$", 3, 1, iSXFLD, sXMGMX,
451               tmaxfd, fMaxStepQua, fMaxDestepQua, epsil, stmin, 0, 0);
452     
453     AliMedium(4,"ALUMINUM1$",4, 1, iSXFLD, sXMGMX,
454               tmaxfd, fMaxStepAlu, fMaxDestepAlu, epsil, stmin, 0, 0);
455               
456
457     AliMedium(5,"ALUMINUM2$",5, 1, iSXFLD, sXMGMX,
458               tmaxfd, fMaxStepAlu, fMaxDestepAlu, epsil, stmin, 0, 0);    
459
460     AliMedium(6,"SCINTILLATOR$",6, 1, iSXFLD, sXMGMX, 10.0, 0.1, 0.1, 0.003, 0.003, 0, 0);
461
462     gMC->Gstpar(idtmed[3000], "LOSS", 1.);  //  [3000] = air ACTIF  [3010] = air INACTIF
463     gMC->Gstpar(idtmed[3000], "HADR", 1.);
464     gMC->Gstpar(idtmed[3000], "DCAY", 1.);
465     gMC->Gstpar(idtmed[3000], "DRAY", 1.);
466     
467     gMC->Gstpar(idtmed[3001], "LOSS", 1.);  //  [3001] = carbon
468     gMC->Gstpar(idtmed[3001], "HADR", 1.);
469     gMC->Gstpar(idtmed[3001], "DCAY", 1.);
470     gMC->Gstpar(idtmed[3001], "DRAY", 1.);
471
472     gMC->Gstpar(idtmed[3002], "LOSS", 1.);  //  [3002] = quartz
473     gMC->Gstpar(idtmed[3002], "HADR", 1.);
474     gMC->Gstpar(idtmed[3002], "DCAY", 1.);
475     gMC->Gstpar(idtmed[3002], "DRAY", 1.);  
476     gMC->Gstpar(idtmed[3002], "CUTGAM",0.5E-4) ; 
477     gMC->Gstpar(idtmed[3002], "CUTELE",1.0E-4) ;
478     
479     gMC->Gstpar(idtmed[3003], "LOSS", 1.);  //  [3003] = normal aluminum
480     gMC->Gstpar(idtmed[3003], "HADR", 1.);
481     gMC->Gstpar(idtmed[3003], "DCAY", 1.);
482     gMC->Gstpar(idtmed[3003], "DRAY", 1.);
483     
484     gMC->Gstpar(idtmed[3004], "LOSS", 1.);  //  [3004] = reflecting aluminum
485     gMC->Gstpar(idtmed[3004], "HADR", 1.);
486     gMC->Gstpar(idtmed[3004], "DCAY", 1.);
487     gMC->Gstpar(idtmed[3004], "DRAY", 1.);
488     gMC->Gstpar(idtmed[3004], "CUTGAM",0.5E-4) ; 
489     gMC->Gstpar(idtmed[3004], "CUTELE",1.0E-4) ;
490     
491     gMC->Gstpar(idtmed[3005], "LOSS", 1.);  //  [3005] = scintillator
492     gMC->Gstpar(idtmed[3005], "HADR", 1.);
493     gMC->Gstpar(idtmed[3005], "DCAY", 1.);
494     gMC->Gstpar(idtmed[3005], "DRAY", 1.); 
495     gMC->Gstpar(idtmed[3005], "CUTGAM",0.5E-4) ; 
496     gMC->Gstpar(idtmed[3005], "CUTELE",1.0E-4) ;
497       
498     
499 //    geant3->Gsckov(idtmed[3002], 14, ppckov, absco_quarz, effic_all,rindex_quarz);    
500 //    geant3->Gsckov(idtmed[3004], 14, ppckov_alu, absco_alu, effic_alu, rindex_alu);
501
502 //    gMC->SetCerenkov(idtmed[3002], 14, ppckov, absco_quarz, effic_all,rindex_quarz);    
503 //    gMC->SetCerenkov(idtmed[3004], 14, ppckov_alu, absco_alu, effic_alu, rindex_alu);
504                                        
505 }
506
507 //_____________________________________________________________________________
508 void AliVZEROv5::DrawModule() const
509 {
510
511 //  Drawing is done in DrawVZERO.C
512
513    AliDebug(2,"DrawModule");
514 }
515
516 //_____________________________________________________________________________
517 void AliVZEROv5::Init()
518 {
519 // Initialises version 2 of the VZERO Detector
520 // Just prints an information message
521   
522    AliInfo(Form("VZERO version %d initialized \n",IsVersion()));
523    
524 //   gMC->SetMaxStep(fMaxStepAlu);
525 //   gMC->SetMaxStep(fMaxStepQua);
526    
527     AliVZERO::Init();  
528 }
529
530 //_____________________________________________________________________________
531 void AliVZEROv5::StepManager()
532 {
533  
534 // Step Manager, called at each step 
535  
536      Int_t     copy;
537      static    Int_t   vol[4];
538      static    Float_t hits[21];
539      static    Float_t eloss, tlength;
540      static    Int_t   nPhotonsInStep;
541      static    Int_t   nPhotons; 
542      static    Int_t   numStep;
543      Float_t   ringNumber;
544      Float_t   destep, step;
545      
546      numStep += 1; 
547           
548 //   We keep only charged tracks :
549      
550      if ( !gMC->TrackCharge() || !gMC->IsTrackAlive() ) return; 
551
552      vol[0]    = gMC->CurrentVolOffID(1, vol[1]);
553      vol[2]    = gMC->CurrentVolID(copy);
554      vol[3]    = copy;
555      
556      static Int_t idV0R1 = gMC->VolId("V0R1");
557      static Int_t idV0L1 = gMC->VolId("V0L1");
558      static Int_t idV0R2 = gMC->VolId("V0R2");
559      static Int_t idV0L2 = gMC->VolId("V0L2");
560      static Int_t idV0R3 = gMC->VolId("V0R3");
561      static Int_t idV0L3 = gMC->VolId("V0L3");
562      static Int_t idV0R4 = gMC->VolId("V0R4");
563      static Int_t idV0L4 = gMC->VolId("V0L4");
564      static Int_t idV0R5 = gMC->VolId("V0R5");
565      static Int_t idV0R6 = gMC->VolId("V0R6");
566
567      if      ( gMC->CurrentVolID(copy) == idV0R1 ||
568                gMC->CurrentVolID(copy) == idV0L1 )
569                ringNumber = 1.0;
570      else if ( gMC->CurrentVolID(copy) == idV0R2 ||
571                gMC->CurrentVolID(copy) == idV0L2 ) 
572                ringNumber = 2.0;  
573      else if ( gMC->CurrentVolID(copy) == idV0R3 ||
574                gMC->CurrentVolID(copy) == idV0R4 ||
575                gMC->CurrentVolID(copy) == idV0L3 )
576                ringNumber = 3.0;
577      else if ( gMC->CurrentVolID(copy) == idV0R5 ||
578                gMC->CurrentVolID(copy) == idV0R6 ||
579                gMC->CurrentVolID(copy) == idV0L4 )
580                ringNumber = 4.0;               
581      else
582                ringNumber = 0.0;
583
584      if  (  ringNumber > 0.5  ) { 
585      
586         destep    = gMC->Edep();
587         step      = gMC->TrackStep();
588         
589         nPhotonsInStep  = Int_t(destep / (fLightYield *1e-9) ); 
590         nPhotonsInStep  = gRandom->Poisson(nPhotonsInStep);
591         
592         eloss    += destep;
593         tlength  += step;        
594         
595         if  ( gMC->IsTrackEntering()  )  { 
596          
597             nPhotons  =  nPhotonsInStep;       
598             gMC->TrackPosition(fTrackPosition);
599             gMC->TrackMomentum(fTrackMomentum);
600             
601             Float_t pt  = TMath::Sqrt( fTrackMomentum.Px() * fTrackMomentum.Px() +
602                                        fTrackMomentum.Py() * fTrackMomentum.Py() );
603                
604             hits[0]  = fTrackPosition.X();
605             hits[1]  = fTrackPosition.Y();
606             hits[2]  = fTrackPosition.Z();               
607             hits[3]  = Float_t (gMC->TrackPid()); 
608
609             hits[4]  = gMC->TrackTime();
610             hits[5]  = gMC->TrackCharge();
611             hits[6]  = fTrackMomentum.Theta()*TMath::RadToDeg();
612             hits[7]  = fTrackMomentum.Phi()*TMath::RadToDeg();
613             hits[8]  = ringNumber;
614          
615             hits[9]  = pt;
616             hits[10] = fTrackMomentum.P();
617             hits[11] = fTrackMomentum.Px();
618             hits[12] = fTrackMomentum.Py();
619             hits[13] = fTrackMomentum.Pz();
620             
621             TParticle *par = gAlice->GetMCApp()->Particle(gAlice->GetMCApp()->GetCurrentTrackNumber());
622             hits[14] = par->Vx();
623             hits[15] = par->Vy();
624             hits[16] = par->Vz();
625             
626             tlength  = 0.0;
627             eloss    = 0.0;         
628          }
629          
630          nPhotons  = nPhotons + nPhotonsInStep;
631          
632          if( gMC->IsTrackExiting() || gMC->IsTrackStop() || gMC->IsTrackDisappeared()){
633          
634          nPhotons  = nPhotons - Int_t((Float_t(nPhotons) * fLightAttenuation * fnMeters));       
635          nPhotons  = nPhotons - Int_t( Float_t(nPhotons) * fFibToPhot);  
636          
637          hits[17] =   eloss;
638          hits[18] = tlength;
639          hits[19] = nPhotons;
640          hits[20] = GetCellId (vol, hits); 
641                  
642          AddHit(gAlice->GetMCApp()->GetCurrentTrackNumber(), vol, hits);
643                  
644          tlength         = 0.0;
645          eloss           = 0.0; 
646          nPhotons        =   0;
647          nPhotonsInStep  =   0;
648          
649          numStep         =   0;  
650          } 
651     }
652       
653 }
654
655 //_____________________________________________________________________________
656 void AliVZEROv5::AddHit(Int_t track, Int_t *vol, Float_t *hits)
657 {
658   
659 //  Adds a VZERO hit
660   
661   TClonesArray &lhits = *fHits;
662   new(lhits[fNhits++]) AliVZEROhit(fIshunt,track,vol,hits);
663 }
664
665 //_____________________________________________________________________________
666 void AliVZEROv5::AddDigits(Int_t *tracks, Int_t* digits) 
667 {
668
669 //  Adds a VZERO digit
670
671    TClonesArray  &ldigits = *fDigits;
672    new(ldigits[fNdigits++]) AliVZEROdigit(tracks, digits);
673 }
674
675 //_____________________________________________________________________________
676 void AliVZEROv5::MakeBranch(Option_t *option)
677 {
678   
679 // Creates new branches in the current Root Tree
680     
681   char branchname[10];
682   sprintf(branchname,"%s",GetName());
683   AliDebug(2,Form("fBufferSize = %d",fBufferSize));
684   
685   const char *cH = strstr(option,"H");
686   
687   if (fHits   && fLoader->TreeH() && cH) {
688     fLoader->TreeH()->Branch(branchname,&fHits, fBufferSize);
689     AliDebug(2,Form("Making Branch %s for hits",branchname));
690   }     
691
692   const char *cD = strstr(option,"D");
693   
694   if (fDigits   && fLoader->TreeD() && cD) {
695     fLoader->TreeD()->Branch(branchname,&fDigits, fBufferSize);
696     AliDebug(2,Form("Making Branch %s for digits",branchname));
697   }  
698    
699 }
700
701 //_____________________________________________________________________________
702 Int_t AliVZEROv5::GetCellId(Int_t *vol, Float_t *hits) 
703 {
704
705   //   Returns Id of scintillator cell
706   //   Right side from  0 to 47
707   //   Left  side from 48 to 95
708   
709   //   hits[8] = ring number (1 to 4)
710   //   vol[1]  = copy number (1 to 8)
711
712    Int_t index      = vol[1];
713    Int_t RingNumber = Int_t(hits[8]);   
714    fCellId          = 0;
715    
716 //    cout << "volID = " << vol[0] << "  copy = " << vol[1] << endl;
717 //    cout << "X     = " << hits[0] << "    Y = " << hits[1] << endl;
718    
719    Float_t phi = Float_t(TMath::ATan2(Double_t(hits[1]),Double_t(hits[0])) ); 
720    phi = kRaddeg * phi;
721     
722    if (index < 7) index = index + 8; 
723    
724    if (hits[2] < 0.0) { 
725       if(RingNumber < 3) {
726          index = (index - 7) + ( ( RingNumber - 1 ) * 8);}
727       else if(RingNumber >= 3){ 
728        if(gMC->CurrentVolID(vol[1]) == gMC->VolId("V0R3")|| 
729           gMC->CurrentVolID(vol[1]) == gMC->VolId("V0R5") ) 
730          {index = (index*2 - 14) + ( ( RingNumber - 2 ) * 16); }
731        if(gMC->CurrentVolID(vol[1]) == gMC->VolId("V0R4")||
732           gMC->CurrentVolID(vol[1]) == gMC->VolId("V0R6") ) 
733          {index = (index*2 - 13) + ( ( RingNumber - 2 ) * 16); }
734       }
735       fCellId   = index;           
736    }
737            
738    else if (hits[2] > 0.0){
739       index = (index - 7 + 48) + ( ( RingNumber - 1 ) * 8);
740       fCellId   = index;}
741              
742 //    cout << " ring   = " << RingNumber << " phi = "<<  phi << endl; 
743 //    cout << " cellID = " << fCellId <<  endl;
744 //    cout <<  "**********" << endl;         
745            
746    return fCellId;
747    
748    
749 }