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