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