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