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