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