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