]> git.uio.no Git - u/mrichter/AliRoot.git/blob - VZERO/AliVZEROv2.cxx
Using capital letters for the volume names (ALIC)
[u/mrichter/AliRoot.git] / VZERO / AliVZEROv2.cxx
1 /**************************************************************************
2  * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3  *                                                                        *
4  * Author: The ALICE Off-line Project.                                    *
5  * Contributors are mentioned in the code where appropriate.              *
6  *                                                                        *
7  * Permission to use, copy, modify and distribute this software and its   *
8  * documentation strictly for non-commercial purposes is hereby granted   *
9  * without fee, provided that the above copyright notice appears in all   *
10  * copies and that both the copyright notice and this permission notice   *
11  * appear in the supporting documentation. The authors make no claims     *
12  * about the suitability of this software for any purpose. It is          *
13  * provided "as is" without express or implied warranty.                  *
14  **************************************************************************/
15
16
17 //////////////////////////////////////////////////////////////////////
18 //                                                                  //
19 //  (V-zero) detector  version 2  as designed by the Lyon group     //
20 //   All comments should be sent to Brigitte CHEYNIS :              //
21 //                                  b.cheynis@ipnl.in2p3.fr         // 
22 //   Geometry of the  4th of november 2002                          //
23 //  (circular instead of trapezoidal shapes as in previous versions //
24 //   plus changes in cell dimensions and offsets)                   // 
25 //                                                                  //
26 //////////////////////////////////////////////////////////////////////
27
28 #include <TMath.h>
29 #include <TTree.h>
30 #include <TParticle.h>
31 #include <TGeometry.h>
32 #include <TTRD2.h>
33 #include <TCONE.h>
34 #include <TPGON.h>
35 #include <TPCON.h>
36 #include <TSPHE.h>
37 #include <TTRAP.h>
38 #include <TTUBS.h>
39 #include <TTUBE.h>
40 #include <TBRIK.h>
41 #include <TBox.h>
42
43 #include <TShape.h>
44 #include <TNode.h>
45 #include <TClonesArray.h>
46 #include <TH1.h>
47 #include <string.h>
48 #include <Riostream.h>
49
50 #include "AliVZEROv2.h"
51 #include "AliRun.h"
52 #include "AliMagF.h"
53 #include "AliVZEROhit.h"
54 #include "AliVZEROdigit.h"
55 #include <Riostream.h>
56 #include <Riostream.h>
57
58 #include <TGeant3.h>
59 #include <stdlib.h>
60 #include "TObjectTable.h"
61
62 #include "AliConst.h"
63 #include "TLorentzVector.h"
64
65 ClassImp(AliVZEROv2)
66
67 //--------------------------------------------------------------------
68 AliVZEROv2:: AliVZEROv2():AliVZERO()
69 {
70
71 }
72 //--------------------------------------------------------------------
73 AliVZEROv2::AliVZEROv2(const char *name, const char *title):
74  AliVZERO(name,title)
75 {
76
77 // Standard constructor for V-zeroR Detector (right part)  version 0
78
79   Int_t i;
80
81   printf("\n");
82   for(i=0;i<26;i++) printf("*");
83   printf(" Create VZERO object ");
84   for(i=0;i<26;i++) printf("*");
85   printf("\n");
86   
87 }
88
89 //-------------------------------------------------------------------------
90 void AliVZEROv2::CreateGeometry()
91 {
92
93 // Creates the GEANT geometry of the V-zero Detector  version 2
94   
95   Int_t i;
96   
97   printf("\n");
98   for(i=0;i<26;i++) printf("*");
99   printf(" Create VZERO Geometry ");
100   for(i=0;i<26;i++) printf("*");
101   printf("\n");
102       
103   Int_t    *idtmed = fIdtmed->GetArray()-2999;
104
105   Int_t    n_detec_R = 1;
106   Int_t    n_detec_L = 1;
107  
108   Int_t    n_cells_R = 1;
109   Int_t    n_cells_L = 1;
110   
111   Int_t    idrotm[999];
112  
113   Float_t  height1, height2, height3, height4, height5; 
114   Float_t  height;
115   Float_t  theta;  
116   
117   Float_t  half_thick_qua;
118   
119   Float_t  zdet;
120   Float_t  r0, r5;
121   Float_t  pi = TMath::Pi();
122     
123   height1           =     1.82;           // height of cell 1, in cm
124   height2           =     3.81;           // height of cell 2, in cm
125   height3           =     4.72;           // height of cell 3, in cm
126   height4           =     7.12;           // height of cell 4, in cm
127   height5           =    10.83;           // height of cell 5, in cm
128   
129   theta             = pi/6.0/2.0;       // half angular opening = 15 degrees
130     
131   half_thick_qua    = fThickness1/2.0;   // half thickness of elementary cell (inner ring)
132     
133   zdet              =    90.0 - 0.6 -fThickness/2.0;  // distance to vertex (along Z axis)
134   r0                =    4.05;            // closest distance to center of the beam pipe
135   height            =    height1 + height2 + height3 + height4 + height5;
136   r5                =    r0 + height;
137
138 // Creation of mother volume V0LE - left part - :
139 // Entrance face at  -350.0 cm ...
140
141    Float_t   partube[3];
142    
143    partube[0] =  4.3;
144    partube[1] = 45.0;
145    partube[2] = fThickness1/2.0;   
146     
147    gMC->Gsvolu("V0LE","TUBE",idtmed[3005],partube,3);
148      
149 // Creation of five rings - left part - :
150 // Entrance face at -350.0 cm ... 
151
152 // Mother volume V0L0 in which will be set 5 scintillator cells 
153
154   Float_t   partubs[5];  
155     
156   Float_t   r0_left      =   4.3;   
157   Float_t   height1_left =   2.6; 
158   Float_t   height2_left =   4.1;
159   Float_t   height3_left =   6.4;
160   Float_t   height4_left =  10.2;
161   Float_t   height5_left =  16.9;
162   Float_t   height_left  = height1_left + height2_left + height3_left 
163                                         + height4_left + height5_left;
164   Float_t   r5_left      = r0_left  + height_left; 
165   
166   partubs[0]      =  r0_left;
167   partubs[1]      =  r5_left;
168   partubs[2]      =  fThickness1/2.0;
169   partubs[3]      =  90.0-15.0;
170   partubs[4]      = 120.0-15.0;
171
172   gMC->Gsvolu("V0L0","TUBS",idtmed[3010],partubs,5);  // air volume
173   
174   Float_t  r1_left =  r0_left + height1_left;        
175      
176   partubs[0]     =  r0_left;
177   partubs[1]     =  r1_left;
178
179   gMC->Gsvolu("V0L1","TUBS",idtmed[3005],partubs,5);  // quartz volume
180   gMC->Gspos("V0L1",1,"V0L0", 0.0, 0.0 , 0.0, 0,"ONLY"); 
181
182   Float_t   r2_left  =   r1_left + height2_left;       
183   
184   partubs[0]     =  r1_left;
185   partubs[1]     =  r2_left;
186
187   gMC->Gsvolu("V0L2","TUBS",idtmed[3005],partubs,5);  // quartz volume
188   gMC->Gspos("V0L2",1,"V0L0", 0.0, 0.0 , 0.0, 0,"ONLY"); 
189   
190   Float_t   r3_left =   r2_left + height3_left;
191    
192   partubs[0]     =  r2_left;
193   partubs[1]     =  r3_left;
194
195   gMC->Gsvolu("V0L3","TUBS",idtmed[3005],partubs,5);  // quartz volume
196   gMC->Gspos("V0L3",1,"V0L0", 0.0, 0.0 , 0.0, 0,"ONLY");
197   
198   Float_t   r4_left =  r3_left + height4_left;
199    
200   partubs[0]     =  r3_left;
201   partubs[1]     =  r4_left;
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   partubs[0]     =  r4_left;
207   partubs[1]     =  r5_left;
208   partubs[3]     =  90.0-15.0;
209   partubs[4]     = 120.0-30.0;
210   
211   gMC->Gsvolu("V0L5","TUBS",idtmed[3005],partubs,5);  // quartz volume
212   gMC->Gspos("V0L5",1,"V0L0", 0.0, 0.0 , 0.0, 0,"ONLY");
213   
214   partubs[3]     = 120.0-30.0;
215   partubs[4]     = 120.0-15.0;
216   
217   gMC->Gsvolu("V0L6","TUBS",idtmed[3005],partubs,5);  // quartz volume
218   gMC->Gspos("V0L6",1,"V0L0", 0.0, 0.0 , 0.0, 0,"ONLY");
219   
220
221 // Creation of mother volume V0RI - right part - :
222   
223   partube[0] = r0 - 0.2;
224   partube[1] = r5 + 1.0;
225   partube[2] = fThickness/2.0; 
226       
227   gMC->Gsvolu("V0RI","TUBE",idtmed[3010],partube,3);
228   
229 // Creation of  carbon lids (3 mm thick) to keep V0RI box shut...
230  
231   partube[0] =   r0;
232   partube[1] =   r5;
233   partube[2] =   +0.3/2.0;
234     
235   gMC->Gsvolu("V0CA","TUBE",idtmed[3001],partube,3); 
236   gMC->Gspos("V0CA",1,"V0RI",0.0,0.0, fThickness/2.0-partube[2],0,"ONLY");
237   gMC->Gspos("V0CA",2,"V0RI",0.0,0.0,-fThickness/2.0+partube[2],0,"ONLY");
238   
239 // Creation of aluminum rings to maintain the V0RI pieces ...
240
241   partube[0] =   r0 - 0.2;
242   partube[1] =   r0;
243   partube[2] =   +fThickness/2.0;
244    
245   gMC->Gsvolu("V0IR","TUBE",idtmed[3003],partube,3);    
246   gMC->Gspos("V0IR",1,"V0RI",0.0,0.0,0.0,0,"ONLY");
247
248   partube[0] =   r5;
249   partube[1] =   r5 + 1.0;
250   partube[2] =   +fThickness/2.0;
251  
252   gMC->Gsvolu("V0ER","TUBE",idtmed[3003],partube,3);    
253   gMC->Gspos("V0ER",1,"V0RI",0.0,0.0,0.0,0,"ONLY");
254   
255 // Mother volume V0R0 in which will be set 5  scintillator cells 
256   
257   partubs[0]      =  r0;
258   partubs[1]      =  r5;
259   partubs[2]      =  fThickness/2.0;
260   partubs[3]      =  90.0-15.0;
261   partubs[4]      = 120.0-15.0;
262
263   gMC->Gsvolu("V0R0","TUBS",idtmed[3010],partubs,5);  // air volume 
264
265 // Elementary cell of ring 1 :
266 // (the cells will be shifted by 3 mm to output fibers) 
267    
268   Float_t   offset_fibers =  0.7;
269   Float_t   offset        =  fThickness/2.0 - 0.3 - fThickness1/2.0; 
270   Float_t   r1            =  r0 + height1;
271       
272   partubs[0]     =  r0;
273   partubs[1]     =  r1;
274   partubs[2]     =  fThickness1/2.0;
275   
276   gMC->Gsvolu("V0R1","TUBS",idtmed[3005],partubs,5);  // scintillator volume
277   gMC->Gspos("V0R1",1,"V0R0", 0.0, 0.0 , offset, 0,"ONLY"); 
278
279 // Elementary cell of ring 2 :
280
281   Float_t   r2   =  r1 + height2;       
282   
283   partubs[0]     =  r1;
284   partubs[1]     =  r2;
285
286   gMC->Gsvolu("V0R2","TUBS",idtmed[3005],partubs,5);  // scintillator volume
287   gMC->Gspos("V0R2",1,"V0R0", 0.0, 0.0 , offset - offset_fibers, 0,"ONLY"); 
288
289
290 // Elementary cell of ring 3 :
291   
292   Float_t   r3   =  r2 + height3;
293    
294   partubs[0]     =  r2;
295   partubs[1]     =  r3;
296
297   gMC->Gsvolu("V0R3","TUBS",idtmed[3005],partubs,5);  // scintillator volume
298   gMC->Gspos("V0R3",1,"V0R0", 0.0, 0.0 , offset -  2.0 * offset_fibers, 0,"ONLY");
299
300 // Elementary cell of ring 4 :
301   
302   Float_t   r4   =  r3 + height4 ;
303   
304   partubs[0]     =  r3;
305   partubs[1]     =  r4;
306
307   gMC->Gsvolu("V0R4","TUBS",idtmed[3005],partubs,5);  // scintillator volume
308   gMC->Gspos("V0R4",1,"V0R0", 0.0, 0.0 ,  offset - 3.0 * offset_fibers, 0,"ONLY");
309
310 // Elementary cells of ring 5 :
311
312   partubs[0]     =  r4;
313   partubs[1]     =  r5;
314   partubs[3]     =  90.0-15.0;
315   partubs[4]     = 120.0-30.0;
316   
317   gMC->Gsvolu("V0R5","TUBS",idtmed[3005],partubs,5);  // scintillator volume
318   gMC->Gspos("V0R5",1,"V0R0", 0.0, 0.0 , offset - 4.0 * offset_fibers, 0,"ONLY");  
319
320   partubs[3]     = 120.0-30.0;
321   partubs[4]     = 120.0-15.0;
322   
323   gMC->Gsvolu("V0R6","TUBS",idtmed[3005],partubs,5);  // scintillator volume
324   gMC->Gspos("V0R6",1,"V0R0", 0.0, 0.0 ,  offset - 4.0 * offset_fibers, 0,"ONLY");
325    
326   Float_t  phi_deg = 180./6.; 
327
328 // Right part : 
329  
330   for(Float_t  phi = 15.0; phi < 360.0; phi = phi + phi_deg)
331       {        
332         AliMatrix(idrotm[902], 90.0, phi, 90.0, 90.0 +phi, 0.0 , 0.0);
333         gMC->Gspos("V0R0",n_detec_R,"V0RI",0.0,
334                           0.0,0.0,idrotm[902],"ONLY");
335         n_detec_R++;
336        }
337
338   gMC->Gspos("V0RI",1,"ALIC",0.0,0.0,zdet,0,"ONLY");
339  
340   n_cells_R = (n_detec_R - 1) * 6;  
341   printf("    Number of cells on Right side =   %d\n",  n_cells_R);    
342
343 // Left part :
344
345   for(Float_t  phi = 15.0; phi < 360.0; phi = phi + phi_deg)
346       {       
347         AliMatrix(idrotm[902], 90.0, phi, 90.0, 90.0 +phi, 0.0 , 0.0);
348         gMC->Gspos("V0L0",n_detec_L,"V0LE",0.0,
349                           0.0,0.0,idrotm[902],"ONLY");
350         n_detec_L++;
351        }
352
353   gMC->Gspos("V0LE",1,"ALIC",0.0,0.0,-350.0-fThickness1/2.0,0,"ONLY");
354  
355   n_cells_L = (n_detec_L - 1) * 6;
356   printf("    Number of cells on Left side  =   %d\n",  n_cells_L);    
357   for(i=0;i<75;i++) printf("*");
358   printf("\n");
359            
360 }
361             
362 //_____________________________________________________________________________
363 void AliVZEROv2::BuildGeometry()
364 {
365   
366 // Builds simple ROOT TNode geometry for event display
367
368   Int_t i;
369
370   printf("\n");
371   for(i=0;i<30;i++) printf("*");
372   printf(" VZERO BuildGeometry ");
373   for(i=0;i<30;i++) printf("*");
374   printf("\n");
375  
376   TNode *Top; 
377
378   TNode *V0Rnode, *V0Rnode0, *V0Rnode6 , *V0Rnode7, *V0Rnode8, *V0Rnode9;
379   TNode *V0Rnode1, *V0Rnode2, *V0Rnode3, *V0Rnode4, *V0Rnode5;
380   TNode *V0Lnode, *V0Lnode0;
381   TNode *V0Lnode1, *V0Lnode2, *V0Lnode3, *V0Lnode4, *V0Lnode5, *V0Lnode6;
382    
383   const int kColorVZERO  = kGreen;
384  
385   Top = gAlice->GetGeometry()->GetNode("alice");
386
387   Float_t  height1, height2, height3, height4, height5; 
388   Float_t  height;
389   Float_t  theta;  
390   
391   Float_t  half_thick_qua;
392   Float_t  zdet;
393   Float_t  r0, r5;
394   Float_t  pi = TMath::Pi();
395
396   height1           =     1.82;           // height of cell 1, in cm
397   height2           =     3.81;           // height of cell 2, in cm
398   height3           =     4.72;           // height of cell 3, in cm
399   height4           =     7.12;           // height of cell 4, in cm
400   height5           =    10.83;           // height of cell 5, in cm  
401
402   theta             =    pi/6.0/2.0;    
403    
404   half_thick_qua    =    fThickness1/2.0; 
405   
406   zdet              =    90.0 - 0.6 - fThickness/2.0;   
407   r0                =    4.05;         
408   height            =    height1 + height2 + height3 + height4 + height5;
409   r5                =    r0 + height;
410   
411   Int_t     ndiv    =     1;  
412
413   Float_t   partube[3];
414
415   partube[0] =  r0 - 0.2;
416   partube[1] =  r5 + 1.0;
417   partube[2] = fThickness/2.0;   
418   
419   TTUBE *V0RI = new TTUBE("V0RI", "V0RI", "void", partube[0], partube[1], partube[2]);
420                 
421   Top->cd();
422   
423   V0Rnode = new TNode("V0RI","V0RI",V0RI,0.0,0.0,+zdet,0);
424   
425   V0Rnode->SetLineColor(kYellow);
426   fNodes->Add(V0Rnode);  
427   V0Rnode->SetVisibility(2);     
428  
429 // Rondelles de carbone (epaisseur 3 mm) de maintien des cellules ...
430   
431   partube[0] =   r0;
432   partube[1] =   r5;
433   partube[2] =   +0.3/2.0;
434   
435   TTUBE  *V0CA = new TTUBE("V0CA", "V0CA", "void",partube[0], partube[1], partube[2]);
436   
437   V0Rnode->cd();
438   V0Rnode6 = new TNode("V0CA", "V0CA",V0CA,0.0,0.0, fThickness/2.0-partube[2],0);        
439   V0Rnode6->SetLineColor(kYellow);
440   fNodes->Add(V0Rnode6); 
441   V0Rnode->cd();
442   V0Rnode7 = new TNode("V0CA", "V0CA",V0CA,0.0,0.0,-fThickness/2.0+partube[2],0);        
443   V0Rnode7->SetLineColor(kYellow);
444   fNodes->Add(V0Rnode7);
445   
446   partube[0] =   r0 - 0.2;
447   partube[1] =   r0;
448   partube[2] =   +fThickness/2.0;
449   
450   TTUBE *V0IR = new TTUBE("V0IR","V0IR","void", partube[0], partube[1], partube[2]);
451  
452   V0Rnode->cd();
453   V0Rnode8 = new TNode("V0IR", "V0IR",V0IR,0.0,0.0,0.0,0);
454   V0Rnode8->SetLineColor(kYellow);
455   fNodes->Add(V0Rnode8);
456
457   partube[0] =   r5;
458   partube[1] =   r5 + 1.0; 
459   partube[2] =   +fThickness/2.0;
460
461   TTUBE  *V0ER = new TTUBE("V0ER","V0ER","void", partube[0], partube[1], partube[2]);
462   
463   V0Rnode->cd();
464   V0Rnode9 = new TNode("V0ER", "V0ER",V0ER,0.0,0.0,0.0,0);
465   V0Rnode9->SetLineColor(kYellow);
466   fNodes->Add(V0Rnode9);
467   
468   Float_t   partubs[5];
469  
470   partubs[0]      =  r0;
471   partubs[1]      =  r5;
472   partubs[2]      =  fThickness/2.0;
473   partubs[3]      =  90.0-15.0;
474   partubs[4]      = 120.0-15.0;
475
476   TTUBS  *V0R0 = new TTUBS("V0R0", "V0R0", "void",partubs[0], partubs[1], partubs[2], 
477                                                   partubs[3], partubs[4]); 
478                                                   
479   V0R0->SetNumberOfDivisions(ndiv);                                               
480
481   Float_t   r1     =  r0 + height1;
482   Float_t   offset = fThickness/2.0 - 0.3 - fThickness1/2.0; 
483   Float_t   offset_fibers = 0.7;
484     
485   partubs[0]     =  r0;
486   partubs[1]     =  r1;
487   partubs[2]     =  fThickness1/2.0;
488
489   TTUBS *V0R1 = new TTUBS("V0R1", "V0R1", "void", partubs[0], partubs[1], partubs[2], 
490                                                   partubs[3], partubs[4]);
491
492   V0R1->SetNumberOfDivisions(ndiv);
493   
494   Float_t   r2   =  r1 + height2;       
495   
496   partubs[0]     =  r1;
497   partubs[1]     =  r2;
498
499   TTUBS *V0R2 = new TTUBS("V0R2", "V0R2", "void", partubs[0], partubs[1], partubs[2], 
500                                                   partubs[3], partubs[4]);
501
502   V0R2->SetNumberOfDivisions(ndiv);
503   
504   Float_t   r3   =  r2 + height3;
505    
506   partubs[0]     =  r2;
507   partubs[1]     =  r3;
508   
509   TTUBS *V0R3 = new TTUBS("V0R3", "V0R3", "void", partubs[0], partubs[1], partubs[2], 
510                                                   partubs[3], partubs[4]);
511   V0R3->SetNumberOfDivisions(ndiv);
512  
513   Float_t   r4   =  r3 + height4;
514    
515   partubs[0]     =  r3;
516   partubs[1]     =  r4;
517
518   TTUBS *V0R4 = new TTUBS("V0R4", "V0R4", "void", partubs[0], partubs[1], partubs[2], 
519                                                   partubs[3], partubs[4]);
520
521   V0R4->SetNumberOfDivisions(ndiv);
522
523   partubs[0]     =  r4;
524   partubs[1]     =  r5;
525   partubs[3]     =  90.0-15.0;
526   partubs[4]     = 120.0-30.0;
527   
528   TTUBS *V0R5 = new TTUBS("V0R5", "V0R5", "void", partubs[0], partubs[1], partubs[2], 
529                                                   partubs[3], partubs[4]);
530
531   V0R5->SetNumberOfDivisions(ndiv);
532
533   partubs[3]     = 120.0-30.0;
534   partubs[4]     = 120.0-15.0;
535   
536   TTUBS *V0R6 = new TTUBS("V0R6", "V0R6", "void", partubs[0], partubs[1], partubs[2], 
537                                                   partubs[3], partubs[4]);
538                                                   
539   V0R6->SetNumberOfDivisions(ndiv);
540                 
541   Float_t  phi;
542   Float_t  phi_deg= 180./6.;
543     
544   Int_t    n_detec_R = 1; 
545
546   char     NameNode[12];  
547  
548   for (phi = 15.0; phi < 360.0; phi = phi + phi_deg)
549   
550   {
551      
552     TRotMatrix* mat920 = new TRotMatrix("rot920","rot920", 90.0, +phi, 90., 90.+phi, 0.0, 0.0 );        
553      
554     sprintf(NameNode,"SUBDER%d",n_detec_R);
555     
556     V0Rnode->cd();
557     V0Rnode0 = new TNode(NameNode,NameNode,V0R0,0.0,0.0, 0.0,mat920);    
558     V0Rnode0->SetLineColor(kYellow);
559     fNodes->Add(V0Rnode0);
560     n_detec_R++;
561     
562     sprintf(NameNode,"SUBDER%d",n_detec_R);
563     V0Rnode0->cd();    
564     V0Rnode1 = new TNode(NameNode,NameNode,V0R1,0.0,0.0, offset,0);      
565     V0Rnode1->SetLineColor(kColorVZERO);
566     fNodes->Add(V0Rnode1);
567     n_detec_R++;
568     
569     sprintf(NameNode,"SUBDER%d",n_detec_R);
570     V0Rnode0->cd();    
571     V0Rnode2 = new TNode(NameNode,NameNode,V0R2,0.0,0.0, offset - offset_fibers,0);      
572     V0Rnode2->SetLineColor(kColorVZERO);
573     fNodes->Add(V0Rnode2);
574     n_detec_R++;
575
576     sprintf(NameNode,"SUBDER%d",n_detec_R);
577     V0Rnode0->cd();    
578     V0Rnode3 = new TNode(NameNode,NameNode,V0R3,0.0,0.0, offset - 2.0*offset_fibers,0);  
579     V0Rnode3->SetLineColor(kColorVZERO);
580     fNodes->Add(V0Rnode3);
581     n_detec_R++;
582
583     sprintf(NameNode,"SUBDER%d",n_detec_R);
584     V0Rnode0->cd();    
585     V0Rnode4 = new TNode(NameNode,NameNode,V0R4,0.0,0.0, offset - 3.0*offset_fibers,0);  
586     V0Rnode4->SetLineColor(kColorVZERO);
587     fNodes->Add(V0Rnode4);
588     n_detec_R++;
589      
590     sprintf(NameNode,"SUBDER%d",n_detec_R);
591     V0Rnode0->cd();    
592     V0Rnode5 = new TNode(NameNode,NameNode,V0R5,0.0,0.0, offset - 4.0*offset_fibers,0);  
593     V0Rnode5->SetLineColor(kColorVZERO);
594     fNodes->Add(V0Rnode5);
595     n_detec_R++;
596     
597     sprintf(NameNode,"SUBDER%d",n_detec_R);
598     V0Rnode0->cd();    
599     V0Rnode6 = new TNode(NameNode,NameNode,V0R6,0.0,0.0, offset - 4.0*offset_fibers,0);  
600     V0Rnode6->SetLineColor(kColorVZERO);
601     fNodes->Add(V0Rnode6);
602     n_detec_R++;
603        
604     V0Rnode0->SetVisibility(2);
605     
606   }    
607
608 // Left side of VZERO :
609      
610   Float_t   r0_left      =   4.3;   
611   Float_t   height1_left =   2.6; 
612   Float_t   height2_left =   4.1;
613   Float_t   height3_left =   6.4;
614   Float_t   height4_left =  10.2;
615   Float_t   height5_left =  16.9;
616   Float_t   height_left  = height1_left + height2_left + height3_left 
617                                         + height4_left + height5_left;
618   Float_t   r5_left      = r0_left  + height_left; 
619
620   partube[0] =  r0_left;
621   partube[1] =  r5_left;
622   partube[2] =  fThickness1/2.0; 
623   
624   TTUBE *V0LE = new TTUBE("V0LE", "V0LE", "void", partube[0], partube[1], partube[2]);
625                 
626   Top->cd();
627   
628   V0Lnode = new TNode("V0LE","V0LE",V0LE,0.0,0.0,-350.0-fThickness1/2.0,0);
629   
630   V0Lnode->SetLineColor(kBlue);
631   fNodes->Add(V0Lnode);
632   
633   V0Lnode->SetVisibility(2);
634
635   partubs[0]      =  r0_left;
636   partubs[1]      =  r5_left;
637   partubs[2]      =  fThickness1/2.0;
638   partubs[3]      =  90.0-15.0;
639   partubs[4]      = 120.0-15.0;
640   
641   TTUBS *V0L0 = new TTUBS("V0L0", "V0L0", "void", partubs[0], partubs[1], partubs[2], 
642                                                   partubs[3], partubs[4]);
643
644   V0L0->SetNumberOfDivisions(ndiv); 
645   V0L0->SetLineColor(7);
646   
647   Float_t   offset_left;
648   offset_left    = - fThickness1/2.0; 
649
650   Float_t   r1_left =  r0_left + height1_left;        
651       
652   partubs[0]     =  r0_left;
653   partubs[1]     =  r1_left;
654
655   TTUBS *V0L1 = new TTUBS("V0L1", "V0L1", "void", partubs[0], partubs[1], partubs[2], 
656                                                   partubs[3], partubs[4]);
657
658   V0L1->SetNumberOfDivisions(ndiv);
659   
660   Float_t   r2_left =  r1_left + height2_left;       
661   
662   partubs[0]     =  r1_left;
663   partubs[1]     =  r2_left;
664
665   TTUBS *V0L2 = new TTUBS("V0L2", "V0L2", "void", partubs[0], partubs[1], partubs[2], 
666                                                   partubs[3], partubs[4]);
667
668   V0L2->SetNumberOfDivisions(ndiv);
669   
670   Float_t   r3_left  =  r2_left + height3_left;
671   
672   partubs[0]     =  r2_left;
673   partubs[1]     =  r3_left;
674   
675   TTUBS *V0L3 = new TTUBS("V0L3", "V0L3", "void", partubs[0], partubs[1], partubs[2], 
676                                                   partubs[3], partubs[4]);
677   V0L3->SetNumberOfDivisions(ndiv);
678  
679   Float_t   r4_left  =   r3_left + height4_left;
680   
681   partubs[0]     =  r3_left;
682   partubs[1]     =  r4_left;
683
684   TTUBS *V0L4 = new TTUBS("V0L4", "V0L4", "void", partubs[0], partubs[1], partubs[2], 
685                                                   partubs[3], partubs[4]);
686
687   V0L4->SetNumberOfDivisions(ndiv);
688
689   partubs[0]     =  r4_left;
690   partubs[1]     =  r5_left;
691   partubs[3]     =  90.0-15.0;
692   partubs[4]     = 120.0-30.0;
693   
694   TTUBS *V0L5 = new TTUBS("V0L5", "V0L5", "void", partubs[0], partubs[1], partubs[2], 
695                                                   partubs[3], partubs[4]);
696
697
698   V0L5->SetNumberOfDivisions(ndiv);
699
700   partubs[3]     = 120.0-30.0;
701   partubs[4]     = 120.0-15.0;
702   
703   TTUBS *V0L6 = new TTUBS("V0L6", "V0L6", "void", partubs[0], partubs[1], partubs[2], 
704                                                   partubs[3], partubs[4]);
705                                                   
706   V0L6->SetNumberOfDivisions(ndiv);
707
708   Int_t    n_detec_L   = 1;
709  
710   for (phi = 15.0; phi < 360.0; phi = phi + phi_deg)
711   
712   {
713      
714     TRotMatrix* mat920 = new TRotMatrix("rot920","rot920", 90.0, +phi, 90., 90.+phi, 0.0, 0.0 );        
715     
716  
717     sprintf(NameNode,"SUBDEL%d",n_detec_L);
718     
719     V0Lnode->cd();
720     V0Lnode0 = new TNode(NameNode,NameNode,V0L0,0.0,0.0, offset_left + half_thick_qua,mat920);   
721     V0Lnode0->SetLineColor(kColorVZERO);
722     fNodes->Add(V0Lnode0);
723     n_detec_L++;
724     
725     sprintf(NameNode,"SUBDEL%d",n_detec_L);
726     V0Lnode0->cd();    
727     V0Lnode1 = new TNode(NameNode,NameNode,V0L1,0.0,0.0, 0.0,0);         
728     V0Lnode1->SetLineColor(kColorVZERO);
729     fNodes->Add(V0Lnode1);
730     n_detec_L++;
731     
732     sprintf(NameNode,"SUBDEL%d",n_detec_L);
733     V0Lnode0->cd();    
734     V0Lnode2 = new TNode(NameNode,NameNode,V0L2,0.0,0.0, 0.0,0);         
735     V0Lnode2->SetLineColor(kColorVZERO);
736     fNodes->Add(V0Lnode2);
737     n_detec_L++;
738
739
740     sprintf(NameNode,"SUBDEL%d",n_detec_L);
741     V0Lnode0->cd();    
742     V0Lnode3 = new TNode(NameNode,NameNode,V0L3,0.0,0.0, 0.0,0);         
743     V0Lnode3->SetLineColor(kColorVZERO);
744     fNodes->Add(V0Lnode3);
745     n_detec_L++;
746
747     sprintf(NameNode,"SUBDEL%d",n_detec_L);
748     V0Lnode0->cd();    
749     V0Lnode4 = new TNode(NameNode,NameNode,V0L4,0.0,0.0, 0.0,0);         
750     V0Lnode4->SetLineColor(kColorVZERO);
751     fNodes->Add(V0Lnode4);
752     n_detec_L++;
753      
754     sprintf(NameNode,"SUBDEL%d",n_detec_L);
755     V0Lnode0->cd();    
756     V0Lnode5 = new TNode(NameNode,NameNode,V0L5,0.0,0.0, 0.0,0);         
757     V0Lnode5->SetLineColor(kColorVZERO);
758     fNodes->Add(V0Lnode5);
759     n_detec_L++;
760     
761     sprintf(NameNode,"SUBDEL%d",n_detec_L);
762     V0Lnode0->cd();    
763     V0Lnode6 = new TNode(NameNode,NameNode,V0L6,0.0,0.0, 0.0,0);         
764     V0Lnode6->SetLineColor(kColorVZERO);
765     fNodes->Add(V0Lnode6);
766     n_detec_L++;
767        
768     V0Lnode0->SetVisibility(2);
769     
770   }    
771       
772 }  
773     
774 //------------------------------------------------------------------------
775 void AliVZEROv2::CreateMaterials()
776 {
777     Int_t i;
778
779     printf("\n");
780     for(i=0;i<25;i++) printf("*");
781     printf(" VZERO create materials ");
782     for(i=0;i<26;i++) printf("*");
783     printf("\n");
784     
785 /*
786     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, 
787                            6.9e-9, 7.1e-9, 7.3e-9, 7.5e-9, 7.7e-9, 7.9e-9, 8.1e-9 };
788
789            
790     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, 
791                                6.9e-9, 7.1e-9, 7.3e-9, 7.5e-9, 7.7e-9, 7.9e-9, 8.1e-9 };
792                            
793     Float_t rindex_quarz[14] = { 1.52398,  1.53090, 1.53835, 1.54641, 1.55513, 1.56458, 
794                                  1.57488,  1.58611, 1.59842, 1.61197, 1.62696, 1.64362, 
795                                  1.662295, 1.68337 };
796                                  
797     Float_t absco_quarz[14] = { 105.8,  45.656, 35.665, 28.598, 25.007, 21.04, 17.525, 
798                                 14.177, 9.282, 4.0925, 1.149, 0.3627, 0.1497, 0.05 };   
799                                                                                         
800     Float_t effic_all[14]   = { 1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1. };
801     
802         
803     Float_t rindex_alu[14] = { 1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1. }; 
804     
805     
806     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,
807                                1e-4,1e-4,1e-4,1e-4 };
808     Float_t effic_alu[14]  = { 1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1. };
809
810 */        
811
812     Int_t *idtmed = fIdtmed->GetArray()-2999;
813     
814 //    TGeant3 *geant3 = (TGeant3*) gMC;
815     
816 //  Parameters related to Quarz (SiO2) :
817  
818     Float_t aqua[2], zqua[2], densqua, wmatqua[2];
819     Int_t nlmatqua;
820     
821     aqua[0]    = 28.09;
822     aqua[1]    = 16.;
823     zqua[0]    = 14.;
824     zqua[1]    = 8.;
825     densqua    = 2.64;
826     nlmatqua   = -2;
827     wmatqua[0] = 1.;
828     wmatqua[1] = 2.;
829
830 // Parameters  related to aluminum sheets :
831     
832     Float_t  aal   = 26.98;
833     Float_t  zal   = 13.00; 
834     Float_t  densal=   2.7; 
835     Float_t  radlal=   8.9;
836        
837 // Parameters  related to scintillator CH :
838     
839     Float_t ascin[2] = {1.00794,12.011};
840     Float_t zscin[2] = {1.,6.};
841     Float_t wscin[2] = {1.,1.};
842     Float_t denscin  = 1.032;
843     
844 //  Definition of materials :
845        
846     AliMaterial( 1, "AIR A$", 14.61, 7.3, .001205, 30420., 67500, 0, 0);
847     AliMaterial(11, "AIR I$", 14.61, 7.3, .001205, 30420., 67500, 0, 0);
848     AliMaterial( 2, "CARBON$"  , 12.01, 6.0, 2.265, 18.8, 49.9, 0, 0);
849     AliMixture(  3, "QUA", aqua, zqua, densqua, nlmatqua, wmatqua);
850     AliMaterial( 4, "ALUMINIUM1$", 26.98, 13., 2.7, 8.9, 37.2, 0, 0);
851     AliMaterial( 5, "ALUMINIUM2$", aal, zal, densal, radlal, 0, 0, 0);
852  
853     AliMixture( 6, "Scintillator$",ascin,zscin,denscin,-2,wscin);
854     
855      
856     Int_t   ISXFLD = gAlice->Field()->Integ();
857     Float_t SXMGMX = gAlice->Field()->Max();
858     
859     Float_t tmaxfd, stemax, deemax, epsil, stmin;
860         
861     tmaxfd = 10.;
862     stemax = 0.1;
863     deemax = 0.1;     
864     epsil  = 0.001;
865     stmin  = 0.001;
866   
867 //  Active Air :    
868     AliMedium(1, "ACTIVE AIR$", 1, 1, ISXFLD, SXMGMX,
869               10.0, 1.0, 0.1, 0.1, 10.0, 0, 0) ;
870
871 //  Inactive air : 
872   
873     AliMedium(11, "INACTIVE AIR$", 11, 0, ISXFLD, SXMGMX,
874               10.0, 1.0, 0.1, 0.1, 10.0, 0, 0) ;
875     
876     AliMedium(2, "CARBON$ ", 2,  1, ISXFLD, SXMGMX,
877               tmaxfd, stemax, deemax, epsil, stmin, 0, 0);   
878
879     AliMedium(3, "QUARZ$", 3, 1, ISXFLD, SXMGMX,
880               tmaxfd, fMaxStepQua, fMaxDestepQua, epsil, stmin, 0, 0);
881     
882     AliMedium(4,"ALUMINUM1$",4, 1, ISXFLD, SXMGMX,
883               tmaxfd, fMaxStepAlu, fMaxDestepAlu, epsil, stmin, 0, 0);
884               
885
886     AliMedium(5,"ALUMINUM2$",5, 1, ISXFLD, SXMGMX,
887               tmaxfd, fMaxStepAlu, fMaxDestepAlu, epsil, stmin, 0, 0);    
888
889     AliMedium(6,"SCINTILLATOR$",6, 1, ISXFLD, SXMGMX, 10.0, 0.1, 0.1, 0.003, 0.003, 0, 0);
890
891     gMC->Gstpar(idtmed[3000], "LOSS", 1.);  //  [3000] = air ACTIF  [3010] = air INACTIF
892     gMC->Gstpar(idtmed[3000], "HADR", 1.);
893     gMC->Gstpar(idtmed[3000], "DCAY", 1.);
894     gMC->Gstpar(idtmed[3000], "DRAY", 1.);
895     
896     gMC->Gstpar(idtmed[3001], "LOSS", 1.);  //  [3001] = carbon
897     gMC->Gstpar(idtmed[3001], "HADR", 1.);
898     gMC->Gstpar(idtmed[3001], "DCAY", 1.);
899     gMC->Gstpar(idtmed[3001], "DRAY", 1.);
900
901     gMC->Gstpar(idtmed[3002], "LOSS", 1.);  //  [3002] = quartz
902     gMC->Gstpar(idtmed[3002], "HADR", 1.);
903     gMC->Gstpar(idtmed[3002], "DCAY", 1.);
904     gMC->Gstpar(idtmed[3002], "DRAY", 1.);  
905     gMC->Gstpar(idtmed[3002], "CUTGAM",0.5E-4) ; 
906     gMC->Gstpar(idtmed[3002], "CUTELE",1.0E-4) ;
907     
908     gMC->Gstpar(idtmed[3003], "LOSS", 1.);  //  [3003] = normal aluminum
909     gMC->Gstpar(idtmed[3003], "HADR", 1.);
910     gMC->Gstpar(idtmed[3003], "DCAY", 1.);
911     gMC->Gstpar(idtmed[3003], "DRAY", 1.);
912     
913     gMC->Gstpar(idtmed[3004], "LOSS", 1.);  //  [3004] = reflecting aluminum
914     gMC->Gstpar(idtmed[3004], "HADR", 1.);
915     gMC->Gstpar(idtmed[3004], "DCAY", 1.);
916     gMC->Gstpar(idtmed[3004], "DRAY", 1.);
917     gMC->Gstpar(idtmed[3004], "CUTGAM",0.5E-4) ; 
918     gMC->Gstpar(idtmed[3004], "CUTELE",1.0E-4) ;
919     
920     gMC->Gstpar(idtmed[3005], "LOSS", 1.);  //  [3005] = scintillator
921     gMC->Gstpar(idtmed[3005], "HADR", 1.);
922     gMC->Gstpar(idtmed[3005], "DCAY", 1.);
923     gMC->Gstpar(idtmed[3005], "DRAY", 1.); 
924     gMC->Gstpar(idtmed[3005], "CUTGAM",0.5E-4) ; 
925     gMC->Gstpar(idtmed[3005], "CUTELE",1.0E-4) ;
926       
927     
928 //    geant3->Gsckov(idtmed[3002], 14, ppckov, absco_quarz, effic_all,rindex_quarz);    
929 //    geant3->Gsckov(idtmed[3004], 14, ppckov_alu, absco_alu, effic_alu, rindex_alu);
930
931 //    gMC->SetCerenkov(idtmed[3002], 14, ppckov, absco_quarz, effic_all,rindex_quarz);    
932 //    gMC->SetCerenkov(idtmed[3004], 14, ppckov_alu, absco_alu, effic_alu, rindex_alu);
933                                    
934     
935 }
936 //---------------------------------------------------------------------
937 void AliVZEROv2::DrawModule()
938 {
939
940 //  Drawing is done in DrawVZERO.C
941
942    Int_t i;
943
944    printf("\n");
945    for(i=0;i<30;i++) printf("*");
946    printf(" VZERO DrawModule ");
947    for(i=0;i<30;i++) printf("*");
948    printf("\n");
949
950
951 }
952
953 //-------------------------------------------------------------------
954 void AliVZEROv2::Init()
955 {
956 // Initialises version 1 of the VZERO Detector
957 // Just prints an information message
958   
959    printf(" VZERO version %d initialized \n",IsVersion());
960    
961 //   gMC->SetMaxStep(fMaxStepAlu);
962 //   gMC->SetMaxStep(fMaxStepQua);
963    
964     AliVZERO::Init();
965   
966 }
967
968 //-------------------------------------------------------------------
969
970 void AliVZEROv2::StepManager()
971 {
972    
973      Int_t     copy;
974      static    Int_t   vol[4];
975      static    Float_t hits[19];
976      static    Float_t eloss, tlength;
977      
978      TLorentzVector pos;     
979      TLorentzVector mom;
980      
981      Float_t        theta;
982      Float_t        phi;
983      Float_t        kRaddeg = 180/TMath::Pi();
984      Float_t        RingNumber;
985
986      Int_t          ipart;
987      Float_t        destep, step;
988           
989
990 //   We keep only charged tracks :
991      
992      if ( !gMC->TrackCharge() || !gMC->IsTrackAlive() ) return; 
993
994
995      vol[0]    = gMC->CurrentVolOffID(1, vol[1]);
996      vol[2]    = gMC->CurrentVolID(copy);
997      vol[3]    = copy;
998      
999
1000      if      ( gMC->CurrentVolID(copy) == gMC->VolId("V0R1") ||
1001                gMC->CurrentVolID(copy) == gMC->VolId("V0L1") )
1002                RingNumber = 1.0;
1003      else if ( gMC->CurrentVolID(copy) == gMC->VolId("V0R2") ||
1004                gMC->CurrentVolID(copy) == gMC->VolId("V0L2") ) 
1005                RingNumber = 2.0;  
1006      else if ( gMC->CurrentVolID(copy) == gMC->VolId("V0R3") ||
1007                gMC->CurrentVolID(copy) == gMC->VolId("V0L3") )
1008                RingNumber = 3.0;
1009      else if ( gMC->CurrentVolID(copy) == gMC->VolId("V0R4") ||
1010                gMC->CurrentVolID(copy) == gMC->VolId("V0L4") )   
1011                RingNumber = 4.0; 
1012      else if ( gMC->CurrentVolID(copy) == gMC->VolId("V0R5") ||
1013                gMC->CurrentVolID(copy) == gMC->VolId("V0L5") ||
1014                gMC->CurrentVolID(copy) == gMC->VolId("V0L6") ||
1015                gMC->CurrentVolID(copy) == gMC->VolId("V0R6") )    
1016                RingNumber = 5.0; 
1017      else
1018                RingNumber = 0.0;
1019
1020      if  (  RingNumber > 0.5  ) { 
1021      
1022         destep    = gMC->Edep();
1023         step      = gMC->TrackStep();
1024         eloss    += destep;
1025         tlength  += step; 
1026         
1027                  
1028         if  ( gMC->IsTrackEntering()  )  {  
1029        
1030             gMC->TrackPosition(pos);
1031      
1032             gMC->TrackMomentum(mom);      
1033             Double_t tc   = mom[0]*mom[0]+mom[1]*mom[1];
1034             Double_t Pt   = TMath::Sqrt(tc);
1035             Double_t Pmom = TMath::Sqrt(tc+mom[2]*mom[2]);
1036             theta   = Float_t(TMath::ATan2(Pt,Double_t(mom[2])))*kRaddeg;
1037             phi     = Float_t(TMath::ATan2(Double_t(mom[1]),Double_t(mom[0])))*kRaddeg;
1038      
1039             ipart  = gMC->TrackPid();
1040
1041             hits[0]  = pos[0];
1042             hits[1]  = pos[1];
1043             hits[2]  = pos[2];           
1044             hits[3]  =  Float_t (ipart); 
1045
1046             hits[4]  = gMC->TrackTime();
1047             hits[5]  = gMC->TrackCharge();
1048             hits[6]  = theta;
1049             hits[7]  = phi;
1050             hits[8]  = RingNumber;
1051          
1052             hits[9]  = Pt;
1053             hits[10] = Pmom;
1054             hits[11] = mom[0];
1055             hits[12] = mom[1];
1056             hits[13] = mom[2];
1057             
1058             TParticle *par = gAlice->Particle(gAlice->CurrentTrack());
1059             hits[14] = par->Vx();
1060             hits[15] = par->Vy();
1061             hits[16] = par->Vz();
1062             
1063             tlength  = 0.0;
1064             eloss    = 0.0;
1065             
1066          }
1067          
1068          if( gMC->IsTrackExiting() || gMC->IsTrackStop() || gMC->IsTrackDisappeared()){
1069          
1070          hits[17] =   eloss;
1071          hits[18] = tlength;
1072          
1073          AddHit(gAlice->CurrentTrack(), vol, hits);
1074                  
1075          tlength  = 0.0;
1076          eloss    = 0.0; 
1077
1078           
1079          } 
1080     }
1081       
1082 }
1083
1084 //_____________________________________________________________________________
1085 void AliVZEROv2::AddHit(Int_t track, Int_t *vol, Float_t *hits)
1086 {
1087   
1088   //  Add a VZERO hit
1089   
1090
1091   TClonesArray &lhits = *fHits;
1092   new(lhits[fNhits++]) AliVZEROhit(fIshunt,track,vol,hits);
1093 }
1094
1095 //---------------------------------------------------------------------
1096 void AliVZEROv2::AddDigits(Int_t *tracks, Int_t* digits) 
1097 {
1098
1099    TClonesArray  &ldigits = *fDigits;
1100    new(ldigits[fNdigits++]) AliVZEROdigit(tracks, digits);
1101 }
1102
1103 //---------------------------------------------------------------------
1104 void AliVZEROv2::MakeBranch(Option_t *option)
1105 {
1106   
1107   // Creates new branches in the current Root Tree
1108   
1109   
1110   char branchname[10];
1111   sprintf(branchname,"%s",GetName());
1112   printf(" fBufferSize = %d \n",fBufferSize);
1113   
1114   const char *H = strstr(option,"H");
1115   
1116   if (fHits   && gAlice->TreeH() && H) {
1117     gAlice->TreeH()->Branch(branchname,&fHits, fBufferSize);
1118     printf("* AliDetector::MakeBranch * Making Branch %s for hits\n",branchname);
1119   }     
1120
1121   const char *D = strstr(option,"D");
1122   //
1123   if (fDigits   && gAlice->TreeD() && D) {
1124     gAlice->TreeD()->Branch(branchname,&fDigits, fBufferSize);
1125     printf("* AliDetector::MakeBranch * Making Branch %s for digits\n",branchname);
1126   }  
1127    
1128 }