303cd50738a2a3817f0da764cc8ab4b30cc91ec1
[u/mrichter/AliRoot.git] / VZERO / AliVZEROv0.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 //                                                                  //
20 //  (V-zero) detector  version 0  as designed by the Lyon group     //
21 //   All comments should be sent to Brigitte CHEYNIS :              //
22 //                                  b.cheynis@ipnl.in2p3.fr         // 
23 //                                                                  //
24 //////////////////////////////////////////////////////////////////////
25
26 #include <TMath.h>
27 #include <TGeometry.h>
28 #include <TTRD2.h>
29 #include <TCONE.h>
30 #include <TPGON.h>
31 #include <TPCON.h>
32 #include <TSPHE.h>
33 #include <TTRAP.h>
34 #include <TBRIK.h>
35 #include <TBox.h>
36
37 #include <TShape.h>
38 #include <TNode.h>
39 #include <TClonesArray.h>
40 #include <TH1.h>
41 #include <string.h>
42 #include <iostream.h>
43
44 #include "AliVZEROv0.h"
45 #include "AliRun.h"
46 #include "AliMC.h"
47 #include "AliVZEROhit.h"
48 #include "AliVZEROdigit.h"
49 #include <iostream.h>
50 #include <fstream.h>
51
52 #include <TGeant3.h>
53 #include <stdlib.h>
54 #include "TObjectTable.h"
55
56 #include "AliConst.h"
57 #include "ABSOSHILConst.h"
58 #include "ABSOConst.h"
59
60 ClassImp(AliVZEROv0)
61
62 //--------------------------------------------------------------------
63 AliVZEROv0:: AliVZEROv0():AliVZERO()
64 {
65   fRootFile = 0;
66   fhMultiplicity = 0;
67   fhGEANTcode = 0;
68   fhCerenkov = 0;
69   fhToF = 0;
70 }
71 //--------------------------------------------------------------------
72 AliVZEROv0::AliVZEROv0(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<35;i++) printf("*");
83   printf(" create VZERO object");
84   for(i=0;i<35;i++) printf("*");
85   printf("\n");
86   
87 }
88 //-------------------------------------------------------------------------
89 void AliVZEROv0::CreateGeometry()
90 {
91
92 // Creates the Geant geometry of the V-zeroR Detector (right part) version 0
93
94   
95   Int_t i;
96   
97   printf("\n");
98   for(i=0;i<35;i++) printf("*");
99   printf(" VZERO Create Geometry ");
100   for(i=0;i<35;i++) printf("*");
101   printf("\n");
102     
103   
104   Int_t    *idtmed = fIdtmed->GetArray()-2999;
105
106   Int_t    n_detec = 1;
107   Int_t    n_cells = 1;
108
109   Int_t    idrotm[999];
110  
111   Float_t  height1, height2, height3, height4, height5; 
112   Float_t  height;
113   Float_t  theta;  
114   Float_t  half_thick_alu;
115   Float_t  half_thick_qua1,half_thick_qua2,half_thick_qua3;
116   Float_t  half_thick_qua4,half_thick_qua5;
117   Float_t  zdet;
118   Float_t  r0, r5;
119   Float_t  pi = TMath::Pi();
120   Float_t  thick_alu;
121   
122   height1           =     2.3;           // height of cell 1, in cm
123   height2           =     3.7;           // height of cell 2, in cm
124   height3           =     6.2;           // height of cell 3, in cm
125   height4           =    10.5;           // height of cell 4, in cm
126   height5           =    10.5;           // height of cell 5, in cm
127   
128   theta             = pi/12.0/2.0;       // half angular opening = 7.5 degrees
129   half_thick_alu    = 0.0025;            // half thickness of aluminum foil, in cm
130   thick_alu         = 2.0 * half_thick_alu; 
131   half_thick_qua1   = fThickness1/2.0;   // half thickness of WRAPPED quartz cell (inner ring)
132   half_thick_qua2   = half_thick_qua1  - 0.25;
133   half_thick_qua3   = half_thick_qua2  - 0.25;
134   half_thick_qua4   = half_thick_qua3  - 0.25;
135   half_thick_qua5   = half_thick_qua4  - 0.25;
136   
137   zdet              =    86.9 +fThickness/2.0;  // distance to vertex (along Z axis)
138   r0                =    3.4;            // 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 V0RI :
144
145   Float_t   partube[3];
146   
147   partube[0] = r0 - 0.2;
148   partube[1] = (r5 + 1.0) / TMath::Cos(theta);
149   partube[2] = fThickness/2.0; 
150   
151     
152   gMC->Gsvolu("V0RI","TUBE",idtmed[3010],partube,3);
153   
154 // Creation of  carbon lids (1 mm thick) to keep V0RI box shut...
155
156   Float_t   parbox[10];
157   
158   parbox[0] =    0.;
159   parbox[1] =  360.;
160   parbox[2] =    24;
161   parbox[3] =     2;
162   parbox[4] =  -0.1/2.0;
163   parbox[5] =  r0;
164   parbox[6] =  r5;     
165   parbox[7] =  +0.1/2.0;
166   parbox[8] =  r0;
167   parbox[9] =  r5;  
168   
169   
170   gMC->Gsvolu("V0CA","PGON",idtmed[3001],parbox,10); 
171   gMC->Gspos("V0CA",1,"V0RI",0.0,0.0, fThickness/2.0-parbox[7],0,"ONLY");
172   gMC->Gspos("V0CA",2,"V0RI",0.0,0.0,-fThickness/2.0+parbox[7],0,"ONLY");
173   
174 // Creation of aluminum rings to maintain the V0RI pieces ...
175
176   parbox[4] =  -fThickness/2.0;
177   parbox[5] =  r0 -0.2;
178   parbox[6] =  r0;     
179   parbox[7] =  +fThickness/2.0;
180   parbox[8] =  r0 -0.2;
181   parbox[9] =  r0; 
182   
183   gMC->Gsvolu("V0IR","PGON",idtmed[3003],parbox,10);    
184   gMC->Gspos("V0IR",1,"V0RI",0.0,0.0,0.0,0,"ONLY");
185   
186   parbox[4] =  -fThickness/2.0;
187   parbox[5] =  r5;
188   parbox[6] =  r5 + 1.0;     
189   parbox[7] =  +fThickness/2.0;
190   parbox[8] =  r5;
191   parbox[9] =  r5 + 1.0; 
192  
193   gMC->Gsvolu("V0ER","PGON",idtmed[3003],parbox,10);    
194   gMC->Gspos("V0ER",1,"V0RI",0.0,0.0,0.0,0,"ONLY");
195   
196 // Mother volume V0R0 in which will be set 5  quartz cells 
197 // each one  WRAPPED in reflecting aluminum : 
198   
199   Float_t   dist0; 
200   Float_t   par[11];   
201     
202   dist0     =  r0 + height / 2.0;
203   thick_alu =  2.0*half_thick_alu;
204   
205   par[0]    =  half_thick_qua1;
206   par[1]    =  0.0;
207   par[2]    =  0.0;
208   par[3]    =  height / 2.0 ;
209   par[4]    =  TMath::Tan(theta) * r0;
210   par[5]    =  TMath::Tan(theta) * r5;
211   par[6]    =  0.0;
212   par[7]    =  height / 2.0 ;
213   par[8]    =  TMath::Tan(theta) * r0;
214   par[9]    =  TMath::Tan(theta) * r5;
215   par[10]   =  0.0;
216
217
218   gMC->Gsvolu("V0R0","TRAP",idtmed[3010],par,11);  // air volume
219
220 // Elementary cell of ring 1 :
221  
222   Float_t   dist1;
223   Float_t   r1;
224   Float_t   offset;
225      
226   dist1     =  (- height + height1) /2.0; 
227   r1        =  r0 + height1;
228   offset    = - fThickness/2.0 + 0.1; 
229    
230   par[0]    =  half_thick_qua1 - thick_alu;
231   par[3]    =  height1 / 2.0 - thick_alu;
232   par[4]    =  TMath::Tan(theta) * r0 - thick_alu;
233   par[5]    =  TMath::Tan(theta) * r1- thick_alu;
234   par[7]    =  height1 / 2.0 - thick_alu;
235   par[8]    =  TMath::Tan(theta) * r0 - thick_alu;
236   par[9]    =  TMath::Tan(theta) * r1 - thick_alu;
237
238
239   gMC->Gsvolu("V0R1","TRAP",idtmed[3002],par,11);  // quartz volume
240   gMC->Gspos("V0R1",1,"V0R0", 0.0, dist1 , 0.0, 0,"ONLY");
241   
242   par[0]    =  half_thick_alu;
243
244   gMC->Gsvolu("V0A1","TRAP",idtmed[3004],par,11);  // aluminum trap-shaped foil
245   gMC->Gspos("V0A1",1,"V0R1",0.0,0.0, - half_thick_qua1 + half_thick_alu,0,"ONLY");  
246   gMC->Gspos("V0A1",2,"V0R1",0.0,0.0, + half_thick_qua1 - half_thick_alu,0,"ONLY");  
247
248   parbox[0] = half_thick_alu;
249   parbox[1] = height1 / TMath::Cos(theta)/ 2.0;
250   parbox[2] = half_thick_qua1;
251   
252   gMC->Gsvolu("V0A2","BOX",idtmed[3004],parbox,3);   // aluminum rectangular foil
253   Float_t  theta_deg = 180./12./2.0; 
254   Float_t h1;
255   h1 = TMath::Tan(theta) * (r0 + height1/2.0);  
256   AliMatrix(idrotm[911],90.0,+theta_deg,90.0,90.+theta_deg,0.0,0.);  
257   gMC->Gspos("V0A2",1,"V0R1",-h1 + half_thick_alu,0.0,0.0,idrotm[911],"ONLY"); 
258   AliMatrix(idrotm[912],90.0,-theta_deg,90.0,90.-theta_deg,0.0,0.);  
259   gMC->Gspos("V0A2",2,"V0R1",+h1 - half_thick_alu,0.0,0.0,idrotm[912],"ONLY"); 
260
261   parbox[0] = TMath::Tan(theta) * r0;
262   parbox[1] = half_thick_alu;
263   parbox[2] = half_thick_qua1;
264   gMC->Gsvolu("V0A3","BOX",idtmed[3004],parbox,3);
265   gMC->Gspos("V0A3",1,"V0R1",0.0, - (height1/2.0) + half_thick_alu ,0.0,0,"ONLY");
266     
267
268   parbox[0] = TMath::Tan(theta) * (r0 + height1);
269   parbox[1] = half_thick_alu;
270   parbox[2] = half_thick_qua1;
271   gMC->Gsvolu("V0A4","BOX",idtmed[3004],parbox,3);
272   gMC->Gspos("V0A4",1,"V0R1",0.0, (height1/2.0) - half_thick_alu,0.0,0,"ONLY");
273
274   
275 //  Elementary cell of ring 2 : 
276  
277   Float_t   dist2;
278   Float_t   r2; 
279     
280   dist2     =    (- height + height2) /2.0 + height1;
281   r2        =       r1 + height2; 
282   
283   par[0]    =  half_thick_qua2 - thick_alu;   
284   par[3]    =  height2 / 2.0 - thick_alu;
285   par[4]    =  TMath::Tan(theta) * r1 - thick_alu;
286   par[5]    =  TMath::Tan(theta) * r2 - thick_alu;
287   par[7]    =  height2 / 2.0 - thick_alu;
288   par[8]    =  TMath::Tan(theta) * r1 - thick_alu;
289   par[9]    =  TMath::Tan(theta) * r2 - thick_alu;
290
291   gMC->Gsvolu("V0R2","TRAP",idtmed[3002],par,11);  // quartz volume
292   gMC->Gspos("V0R2",1,"V0R0", 0.0, dist2 , - half_thick_qua1 + half_thick_qua2, 0,"ONLY");
293
294   par[0]    =  half_thick_alu;
295
296   gMC->Gsvolu("V0B1","TRAP",idtmed[3004],par,11);  // aluminum trap-shaped foil
297   gMC->Gspos("V0B1",1,"V0R2",0.0,0.0, - half_thick_qua2 + half_thick_alu,0,"ONLY");  
298   gMC->Gspos("V0B1",2,"V0R2",0.0,0.0, + half_thick_qua2 - half_thick_alu,0,"ONLY");  
299
300   parbox[0] = half_thick_alu;
301   parbox[1] = height2 / TMath::Cos(theta)/ 2.0;
302   parbox[2] = half_thick_qua2;
303   
304   gMC->Gsvolu("V0B2","BOX",idtmed[3004],parbox,3);   // aluminum rectangular foil
305   Float_t h2;
306   h2 = TMath::Tan(theta) * (r0  + height1 + height2/2.0);  
307   gMC->Gspos("V0B2",1,"V0R2",-h2 + half_thick_alu,0.0,0.0,idrotm[911],"ONLY"); 
308   gMC->Gspos("V0B2",2,"V0R2",+h2 - half_thick_alu,0.0,0.0,idrotm[912],"ONLY"); 
309
310   parbox[0] = TMath::Tan(theta) * (r0 + height1);
311   parbox[1] = half_thick_alu;
312   parbox[2] = half_thick_qua2;
313   gMC->Gsvolu("V0B3","BOX",idtmed[3004],parbox,3);
314   gMC->Gspos("V0B3",1,"V0R2",0.0, - (height2/2.0) + half_thick_alu ,0.0,0,"ONLY");
315     
316
317   parbox[0] = TMath::Tan(theta) * (r0 + height1 +  height2);
318   parbox[1] = half_thick_alu;
319   parbox[2] = half_thick_qua2;
320   gMC->Gsvolu("V0B4","BOX",idtmed[3004],parbox,3);
321   gMC->Gspos("V0B4",1,"V0R2",0.0, (height2/2.0) - half_thick_alu,0.0,0,"ONLY");
322   
323
324 // Elementary cell  ring 3 :   
325   
326   Float_t   dist3;
327   Float_t   r3; 
328     
329   dist3     =    (- height + height3) /2.0 + height1 + height2;
330   r3        =       r2 + height3; 
331    
332   par[0]    =  half_thick_qua3 - thick_alu;   
333   par[3]    =  height3 / 2.0 - thick_alu;
334   par[4]    =  TMath::Tan(theta) * r2 - thick_alu;
335   par[5]    =  TMath::Tan(theta) * r3 - thick_alu;
336   par[7]    =  height3 / 2.0 - thick_alu;
337   par[8]    =  TMath::Tan(theta) * r2 - thick_alu;
338   par[9]    =  TMath::Tan(theta) * r3 - thick_alu;
339
340   gMC->Gsvolu("V0R3","TRAP",idtmed[3002],par,11);  // quartz volume
341   gMC->Gspos("V0R3",1,"V0R0", 0.0, dist3 , - half_thick_qua1 +  half_thick_qua3, 0,"ONLY");
342
343
344   par[0]    =  half_thick_alu;
345
346   gMC->Gsvolu("V0C1","TRAP",idtmed[3004],par,11);  // aluminum trap-shaped foil
347   gMC->Gspos("V0C1",1,"V0R3",0.0,0.0, - half_thick_qua3 + half_thick_alu,0,"ONLY");  
348   gMC->Gspos("V0C1",2,"V0R3",0.0,0.0, + half_thick_qua3 - half_thick_alu,0,"ONLY");  
349
350   parbox[0] = half_thick_alu;
351   parbox[1] = height3 / TMath::Cos(theta)/ 2.0;
352   parbox[2] = half_thick_qua3;
353   
354   gMC->Gsvolu("V0C2","BOX",idtmed[3004],parbox,3);   // aluminum rectangular foil
355   Float_t h3;
356   h3 = TMath::Tan(theta) * (r0  + height1 + height2 + height3/2.0);  
357   gMC->Gspos("V0C2",1,"V0R3",-h3 + half_thick_alu,0.0,0.0,idrotm[911],"ONLY"); 
358   gMC->Gspos("V0C2",2,"V0R3",+h3 - half_thick_alu,0.0,0.0,idrotm[912],"ONLY"); 
359
360   parbox[0] = TMath::Tan(theta) * (r0 + height1 + height2);
361   parbox[1] = half_thick_alu;
362   parbox[2] = half_thick_qua3;
363   gMC->Gsvolu("V0C3","BOX",idtmed[3004],parbox,3);
364   gMC->Gspos("V0C3",1,"V0R3",0.0, - (height3/2.0) + half_thick_alu ,0.0,0,"ONLY");
365     
366
367   parbox[0] = TMath::Tan(theta) * (r0 + height1 + height2 + height3);
368   parbox[1] = half_thick_alu;
369   parbox[2] = half_thick_qua3;
370   gMC->Gsvolu("V0C4","BOX",idtmed[3004],parbox,3);
371   gMC->Gspos("V0C4",1,"V0R3",0.0, (height3/2.0) - half_thick_alu,0.0,0,"ONLY");
372
373
374 // Elementary cell  ring 4 :  
375
376   Float_t   dist4;
377   Float_t   r4; 
378     
379   dist4     =    (- height + height4) /2.0 + height1 + height2 + height3;
380   r4        =       r3 + height4; 
381    
382   par[0]    =  half_thick_qua4 - thick_alu;   
383   par[3]    =  height4 / 2.0 - thick_alu;
384   par[4]    =  TMath::Tan(theta) * r3 - thick_alu;
385   par[5]    =  TMath::Tan(theta) * r4 - thick_alu;
386   par[7]    =  height4 / 2.0 - thick_alu;
387   par[8]    =  TMath::Tan(theta) * r3 - thick_alu;
388   par[9]    =  TMath::Tan(theta) * r4 - thick_alu;
389
390   gMC->Gsvolu("V0R4","TRAP",idtmed[3002],par,11);  // quartz volume
391   gMC->Gspos("V0R4",1,"V0R0", 0.0, dist4 , - half_thick_qua1 + half_thick_qua4, 0,"ONLY"); 
392
393
394   par[0]    =  half_thick_alu;
395
396   gMC->Gsvolu("V0D1","TRAP",idtmed[3004],par,11);  // aluminum trap-shaped foil
397   gMC->Gspos("V0D1",1,"V0R4",0.0,0.0, - half_thick_qua4 + half_thick_alu,0,"ONLY");  
398   gMC->Gspos("V0D1",2,"V0R4",0.0,0.0, + half_thick_qua4 - half_thick_alu,0,"ONLY");  
399
400   parbox[0] = half_thick_alu;
401   parbox[1] = height4 / TMath::Cos(theta)/ 2.0;
402   parbox[2] = half_thick_qua4;
403   
404   gMC->Gsvolu("V0D2","BOX",idtmed[3004],parbox,3);   // aluminum rectangular foil
405   Float_t h4;
406   h4 = TMath::Tan(theta) * (r0  + height1 + height2 + height3 + height4/2.0);  
407   gMC->Gspos("V0D2",1,"V0R4",-h4 + half_thick_alu,0.0,0.0,idrotm[911],"ONLY"); 
408   gMC->Gspos("V0D2",2,"V0R4",+h4 - half_thick_alu,0.0,0.0,idrotm[912],"ONLY"); 
409
410   parbox[0] = TMath::Tan(theta) * (r0 + height1 + height2 + height3);
411   parbox[1] = half_thick_alu;
412   parbox[2] = half_thick_qua4;
413   gMC->Gsvolu("V0D3","BOX",idtmed[3004],parbox,3);
414   gMC->Gspos("V0D3",1,"V0R4",0.0, - (height4/2.0) + half_thick_alu ,0.0,0,"ONLY");
415     
416
417   parbox[0] = TMath::Tan(theta) * (r0 + height1 + height2 + height3 + height4);
418   parbox[1] = half_thick_alu;
419   parbox[2] = half_thick_qua4;
420   gMC->Gsvolu("V0D4","BOX",idtmed[3004],parbox,3);
421   gMC->Gspos("V0D4",1,"V0R4",0.0, (height4/2.0) - half_thick_alu,0.0,0,"ONLY");
422
423
424 // Elementary cell  ring 5 :  
425
426   Float_t   dist5;
427       
428   dist5     =    (- height + height5) /2.0 + height1 + height2 + height3 + height4;
429   
430   par[0]    =  half_thick_qua5 - thick_alu;      
431   par[3]    =  height5 / 2.0 - thick_alu;
432   par[4]    =  TMath::Tan(theta) * r4 - thick_alu;
433   par[5]    =  TMath::Tan(theta) * r5 - thick_alu;
434   par[7]    =  height5 / 2.0 - thick_alu;
435   par[8]    =  TMath::Tan(theta) * r4 - thick_alu;
436   par[9]    =  TMath::Tan(theta) * r5 - thick_alu;
437
438   gMC->Gsvolu("V0R5","TRAP",idtmed[3002],par,11);  // quartz volume
439   gMC->Gspos("V0R5",1,"V0R0", 0.0, dist5 , - half_thick_qua1 +  half_thick_qua5, 0,"ONLY"); 
440
441
442   par[0]    =  half_thick_alu;
443
444   gMC->Gsvolu("V0E1","TRAP",idtmed[3004],par,11);  // aluminum trap-shaped foil
445   gMC->Gspos("V0E1",1,"V0R5",0.0,0.0, - half_thick_qua5 + half_thick_alu,0,"ONLY");  
446   gMC->Gspos("V0E1",2,"V0R5",0.0,0.0, + half_thick_qua5 - half_thick_alu,0,"ONLY");  
447
448   parbox[0] = half_thick_alu;
449   parbox[1] = height5 / TMath::Cos(theta)/ 2.0;
450   parbox[2] = half_thick_qua5;
451   
452   gMC->Gsvolu("V0E2","BOX",idtmed[3004],parbox,3);   // aluminum rectangular foil
453   Float_t h5;
454   h5 = TMath::Tan(theta) * (r0  + height1 + height2 + height3 + height4 + height5/2.0);  
455   gMC->Gspos("V0E2",1,"V0R5",-h5 + half_thick_alu,0.0,0.0,idrotm[911],"ONLY"); 
456   gMC->Gspos("V0E2",2,"V0R5",+h5 - half_thick_alu,0.0,0.0,idrotm[912],"ONLY"); 
457
458   parbox[0] = TMath::Tan(theta) * (r0 + height1 + height2 + height3 + height4);
459   parbox[1] = half_thick_alu;
460   parbox[2] = half_thick_qua5;
461   gMC->Gsvolu("V0E3","BOX",idtmed[3004],parbox,3);
462   gMC->Gspos("V0E3",1,"V0R5",0.0, - (height5/2.0) + half_thick_alu ,0.0,0,"ONLY");
463     
464
465   parbox[0] = TMath::Tan(theta) * r5;
466   parbox[1] = half_thick_alu;
467   parbox[2] = half_thick_qua5;
468   gMC->Gsvolu("V0E4","BOX",idtmed[3004],parbox,3);
469   gMC->Gspos("V0E4",1,"V0R5",0.0, (height5/2.0) - half_thick_alu,0.0,0,"ONLY");
470
471
472   Float_t  phi_rad ;  
473   Float_t  phi_deg = 180./12.; 
474
475   
476   for(Float_t  phi = 7.5; phi < 360.0; phi = phi + phi_deg)
477       {
478         phi_rad = phi*pi/180.;
479         AliMatrix(idrotm[902], 90.0, phi, 90.0, 90.0 +phi, 0.0 , 0.0);
480         gMC->Gspos("V0R0",n_detec,"V0RI",-dist0*TMath::Sin(phi_rad),
481                           dist0*TMath::Cos(phi_rad),offset + half_thick_qua1,idrotm[902],"ONLY");
482         n_detec++;
483        }
484
485
486   gMC->Gspos("V0RI",1,"alic",0.0,0.0,zdet,0,"ONLY");
487  
488   n_cells = (n_detec - 1) * 5;
489   printf(" \n\n\n"); 
490   printf(" Number of cells =   %d\n\n",  n_cells);    
491          
492 }
493     
494     
495 //_____________________________________________________________________________
496 void AliVZEROv0::BuildGeometry()
497 {
498   
499   // Builds simple ROOT TNode geometry for event display
500   
501   
502   Int_t i;
503
504   printf("\n");
505   for(i=0;i<35;i++) printf("*");
506   printf(" VZERO BuildGeometry ");
507   for(i=0;i<35;i++) printf("*");
508   printf("\n");
509   
510   TNode *Top, *Node0, *Node1, *Node2;
511   TNode *Node3, *Node4 , *Node5, *Node6 , *Node7;
512   TNode *V0Rnode, *V0Rnode0, *V0Rnode6 , *V0Rnode7, *V0Rnode8, *V0Rnode9;
513   TNode *V0Rnode1, *V0Rnode2, *V0Rnode3, *V0Rnode4, *V0Rnode5;
514   const int kColorVZERO  = kGreen;
515   
516   Top = gAlice->GetGeometry()->GetNode("alice");
517
518   Float_t  height1, height2, height3, height4, height5; 
519   Float_t  height;
520   Float_t  theta;  
521   Float_t  half_thick_alu;
522   Float_t  half_thick_qua1,half_thick_qua2,half_thick_qua3;
523   Float_t  half_thick_qua4,half_thick_qua5;
524   Float_t  zdet;
525   Float_t  r0, r5;
526   Float_t  pi = TMath::Pi();
527   Float_t  thick_alu;
528   
529   height1           =     2.3;         
530   height2           =     3.7; 
531   height3           =     6.2;
532   height4           =    10.5;
533   height5           =    10.5;
534   
535   theta             = pi/12.0/2.0;    
536   half_thick_alu    = 0.0025;        
537   thick_alu         = 2.0 * half_thick_alu; 
538   half_thick_qua1   = fThickness1/2.0; 
539   half_thick_qua2   = half_thick_qua1  - 0.25;
540   half_thick_qua3   = half_thick_qua2  - 0.25;
541   half_thick_qua4   = half_thick_qua3  - 0.25;
542   half_thick_qua5   = half_thick_qua4  - 0.25;
543   
544   zdet              =    86.9 +fThickness/2.0;   
545   r0                =    3.4;         
546   height            =    height1 + height2 + height3 + height4 + height5;
547   r5                =    r0 + height;
548
549   Float_t   partube[3];
550
551   partube[0] =  r0 - 0.2;
552   partube[1] = (r5 + 1.0) / TMath::Cos(theta);
553   partube[2] = fThickness/2.0;   
554   
555   TTUBE *V0RI = new TTUBE("V0RI", "V0RI", "void", partube[0], partube[1], partube[2]);
556                 
557   Top->cd();
558   
559   V0Rnode = new TNode("V0RI","V0RI",V0RI,0.0,0.0,+zdet,0);
560   
561   V0Rnode->SetLineColor(kBlue);
562   fNodes->Add(V0Rnode);
563   
564   V0Rnode->SetVisibility(2);
565         
566  
567 // Rondelles de carbone (epaisseur 1 mm) de maintien des cellules ...
568  
569
570   Float_t   parbox[10];
571  
572   parbox[0] =    0.;
573   parbox[1] =  360.;
574   parbox[2] =    24;
575   parbox[3] =     2;
576   parbox[4] =  -0.1/2.0;
577   parbox[5] =  r0;
578   parbox[6] =  r5;     
579   parbox[7] =  +0.1/2.0;
580   parbox[8] =  r0;
581   parbox[9] =  r5;  
582   
583   
584   TPGON *V0CA = new TPGON("V0CA", "V0CA", "void",parbox[0], parbox[1],
585                             parbox[2],parbox[3]);
586                             
587   V0CA->DefineSection( 0, parbox[4], parbox[5], parbox[6] );
588   V0CA->DefineSection( 1, parbox[7], parbox[8], parbox[9] ); 
589    
590   V0Rnode->cd();
591   V0Rnode6 = new TNode("V0CA", "V0CA",V0CA,0.0,0.0, fThickness/2.0-parbox[7],0);         
592   V0Rnode6->SetLineColor(kYellow);
593   fNodes->Add(V0Rnode6); 
594   V0Rnode->cd();
595   V0Rnode7 = new TNode("V0CA", "V0CA",V0CA,0.0,0.0,-fThickness/2.0+parbox[7],0);         
596   V0Rnode7->SetLineColor(kYellow);
597   fNodes->Add(V0Rnode7);
598   
599   parbox[4] =  -fThickness/2.0;
600   parbox[5] =  r0 - 0.2;
601   parbox[6] =  r0;     
602   parbox[7] =  +fThickness/2.0;
603   parbox[8] =  r0 - 0.2;
604   parbox[9] =  r0; 
605
606   TPGON  *V0IR = new TPGON("V0IR","V0IR","void",  parbox[0], parbox[1],
607                             parbox[2],parbox[3]);
608   V0IR->DefineSection( 0, parbox[4], parbox[5], parbox[6] );
609   V0IR->DefineSection( 1, parbox[7], parbox[8], parbox[9] );
610   
611   V0Rnode->cd();
612   V0Rnode8 = new TNode("V0IR", "V0IR",V0IR,0.0,0.0,0.0,0);
613   V0Rnode8->SetLineColor(kYellow);
614   fNodes->Add(V0Rnode8);
615  
616   parbox[4] =  -fThickness/2.0;
617   parbox[5] =  r5;
618   parbox[6] =  r5 + 1.0;     
619   parbox[7] =  +fThickness/2.0;
620   parbox[8] =  r5;
621   parbox[9] =  r5 + 1.0; 
622
623   TPGON  *V0ER = new TPGON("V0ER","V0ER","void",  parbox[0], parbox[1],
624                             parbox[2],parbox[3]);
625   V0ER->DefineSection( 0, parbox[4], parbox[5], parbox[6] );
626   V0ER->DefineSection( 1, parbox[7], parbox[8], parbox[9] );
627   
628   V0Rnode->cd();
629   V0Rnode9 = new TNode("V0ER", "V0ER",V0ER,0.0,0.0,0.0,0);
630   V0Rnode9->SetLineColor(kYellow);
631   fNodes->Add(V0Rnode9);
632
633   Float_t   dist0; 
634   Float_t   par[11];   
635     
636   dist0     =  r0 + height / 2.0;
637   thick_alu =  2.0*half_thick_alu;
638   
639   par[0]    =  half_thick_qua1;
640   par[1]    =  0.0;
641   par[2]    =  0.0;
642   par[3]    =  height / 2.0 ;
643   par[4]    =  TMath::Tan(theta) * r0;
644   par[5]    =  TMath::Tan(theta) * r5;
645   par[6]    =  0.0;
646   par[7]    =  height / 2.0 ;
647   par[8]    =  TMath::Tan(theta) * r0;
648   par[9]    =  TMath::Tan(theta) * r5;
649   par[10]   =  0.0;
650     
651   TTRAP *V0R0 = new TTRAP("V0R0", "V0R0", "void", par[0], par[1], par[2], par[3],
652                 par[4], par[5], par[6], par[7], par[8], par[9], par[10]);
653                 
654   Float_t   dist1;
655   Float_t   r1;
656   Float_t   offset; 
657     
658   dist1     =  (- height + height1) /2.0; 
659   r1        =  r0 + height1;
660   offset    = - fThickness/2.0 + 0.1; 
661    
662   par[0]    =  half_thick_qua1 - thick_alu;
663   par[3]    =  height1 / 2.0 - thick_alu;
664   par[4]    =  TMath::Tan(theta) * r0 - thick_alu;
665   par[5]    =  TMath::Tan(theta) * r1- thick_alu;
666   par[7]    =  height1 / 2.0 - thick_alu;
667   par[8]    =  TMath::Tan(theta) * r0 - thick_alu;
668   par[9]    =  TMath::Tan(theta) * r1 - thick_alu;
669   
670   TTRAP *V0R1 = new TTRAP("V0R1", "V0R1", "void", par[0], par[1], par[2], par[3],
671                 par[4], par[5], par[6], par[7], par[8], par[9], par[10]);
672                 
673
674   Float_t   dist2;
675   Float_t   r2; 
676     
677   dist2     =    (- height + height2) /2.0 + height1;
678   r2        =       r1 + height2; 
679   
680   par[0]    =  half_thick_qua2 - thick_alu;   
681   par[3]    =  height2 / 2.0 - thick_alu;
682   par[4]    =  TMath::Tan(theta) * r1 - thick_alu;
683   par[5]    =  TMath::Tan(theta) * r2 - thick_alu;
684   par[7]    =  height2 / 2.0 - thick_alu;
685   par[8]    =  TMath::Tan(theta) * r1 - thick_alu;
686   par[9]    =  TMath::Tan(theta) * r2 - thick_alu;
687
688
689   TTRAP *V0R2 = new TTRAP("V0R2", "V0R2", "void", par[0], par[1], par[2], par[3],
690                 par[4], par[5], par[6], par[7], par[8], par[9], par[10]);
691  
692
693   Float_t   dist3;
694   Float_t   r3; 
695     
696   dist3     =    (- height + height3) /2.0 + height1 + height2;
697   r3        =       r2 + height3; 
698    
699   par[0]    =  half_thick_qua3 - thick_alu;   
700   par[3]    =  height3 / 2.0 - thick_alu;
701   par[4]    =  TMath::Tan(theta) * r2 - thick_alu;
702   par[5]    =  TMath::Tan(theta) * r3 - thick_alu;
703   par[7]    =  height3 / 2.0 - thick_alu;
704   par[8]    =  TMath::Tan(theta) * r2 - thick_alu;
705   par[9]    =  TMath::Tan(theta) * r3 - thick_alu;
706
707
708   TTRAP *V0R3 = new TTRAP("V0R3", "V0R3", "void", par[0], par[1], par[2], par[3],
709                 par[4], par[5], par[6], par[7], par[8], par[9], par[10]);
710  
711
712   Float_t   dist4;
713   Float_t   r4; 
714     
715   dist4     =    (- height + height4) /2.0 + height1 + height2 + height3;
716   r4        =       r3 + height4; 
717    
718   par[0]    =  half_thick_qua4 - thick_alu;   
719   par[3]    =  height4 / 2.0 - thick_alu;
720   par[4]    =  TMath::Tan(theta) * r3 - thick_alu;
721   par[5]    =  TMath::Tan(theta) * r4 - thick_alu;
722   par[7]    =  height4 / 2.0 - thick_alu;
723   par[8]    =  TMath::Tan(theta) * r3 - thick_alu;
724   par[9]    =  TMath::Tan(theta) * r4 - thick_alu;
725
726
727   TTRAP *V0R4 = new TTRAP("V0R4", "V0R4", "void", par[0], par[1], par[2], par[3],
728                 par[4], par[5], par[6], par[7], par[8], par[9], par[10]);
729
730
731   Float_t   dist5;
732     
733   dist5     =    (- height + height5) /2.0 + height1 + height2 + height3 + height4;
734   
735   par[0]    =  half_thick_qua5 - thick_alu;      
736   par[3]    =  height5 / 2.0 - thick_alu;
737   par[4]    =  TMath::Tan(theta) * r4 - thick_alu;
738   par[5]    =  TMath::Tan(theta) * r5 - thick_alu;
739   par[7]    =  height5 / 2.0 - thick_alu;
740   par[8]    =  TMath::Tan(theta) * r4 - thick_alu;
741   par[9]    =  TMath::Tan(theta) * r5 - thick_alu;
742
743
744   TTRAP *V0R5 = new TTRAP("V0R5", "V0R5", "void", par[0], par[1], par[2], par[3],
745                 par[4], par[5], par[6], par[7], par[8], par[9], par[10]);
746
747                 
748   Float_t  phi;
749   Float_t  phi_deg= 180./12.;
750   Float_t  phi_rad;
751   Float_t  xdet,ydet;
752   Int_t    n_detec = 1; 
753   char     NameNode[12];  
754
755  
756   for (phi = 7.5; phi < 360.0; phi = phi + phi_deg) 
757   {
758      
759     TRotMatrix* mat920 = new TRotMatrix("rot920","rot920", 90.0, +phi, 90., 90.+phi, 0.0, 0.0 );        
760     
761     phi_rad = phi*pi/180.;
762     xdet = dist0*TMath::Sin(phi_rad);
763     ydet = dist0*TMath::Cos(phi_rad);
764     
765   
766     sprintf(NameNode,"SUBDET%d",n_detec);
767     
768     V0Rnode->cd();
769     V0Rnode0 = new TNode(NameNode,NameNode,V0R0,-xdet,ydet, offset + half_thick_qua1,mat920);    
770     V0Rnode0->SetLineColor(kColorVZERO);
771     fNodes->Add(V0Rnode0);
772     n_detec++;
773     
774     sprintf(NameNode,"SUBDET%d",n_detec);
775     V0Rnode0->cd();    
776     V0Rnode1 = new TNode(NameNode,NameNode,V0R1,0.0,dist1, 0.0,0);       
777     V0Rnode1->SetLineColor(kColorVZERO);
778     fNodes->Add(V0Rnode1);
779     n_detec++;
780     
781     sprintf(NameNode,"SUBDET%d",n_detec);
782     V0Rnode0->cd();    
783     V0Rnode2 = new TNode(NameNode,NameNode,V0R2,0.0,dist2, - half_thick_qua1 + half_thick_qua2,0);       
784     V0Rnode2->SetLineColor(kColorVZERO);
785     fNodes->Add(V0Rnode2);
786     n_detec++;
787
788
789     sprintf(NameNode,"SUBDET%d",n_detec);
790     V0Rnode0->cd();    
791     V0Rnode3 = new TNode(NameNode,NameNode,V0R3,0.0,dist3, - half_thick_qua1 + half_thick_qua3,0);       
792     V0Rnode3->SetLineColor(kColorVZERO);
793     fNodes->Add(V0Rnode3);
794     n_detec++;
795
796     sprintf(NameNode,"SUBDET%d",n_detec);
797     V0Rnode0->cd();    
798     V0Rnode4 = new TNode(NameNode,NameNode,V0R4,0.0,dist4, - half_thick_qua1 + half_thick_qua4,0);       
799     V0Rnode4->SetLineColor(kColorVZERO);
800     fNodes->Add(V0Rnode4);
801     n_detec++;
802      
803     sprintf(NameNode,"SUBDET%d",n_detec);
804     V0Rnode0->cd();    
805     V0Rnode5 = new TNode(NameNode,NameNode,V0R5,0.0,dist5, - half_thick_qua1 + half_thick_qua5,0);       
806     V0Rnode5->SetLineColor(kColorVZERO);
807     fNodes->Add(V0Rnode5);
808     n_detec++;
809        
810     V0Rnode0->SetVisibility(2);
811     
812   }  
813   
814
815 //  Here I add the enveloppe of the  FRONTAL ABSORBER defined by Andreas Morsch 
816 //  in   AliABSOv0::CreateGeometry()  :
817
818     Float_t parm[24];
819     Float_t dz;
820     
821     Top->cd();
822   
823     parm[0]  = 0.;
824     parm[1]  = 360.;
825     parm[2]  = 7.;
826
827     parm[3]  = -(zRear-zAbsStart)/2.;
828     parm[4]  = rAbs;
829     parm[5]  = zAbsStart * TMath::Tan(theta1);
830
831     parm[6]  = parm[3]+(zNose-zAbsStart);
832     parm[7]  = rAbs;
833     parm[8]  = zNose * TMath::Tan(theta1);
834
835     parm[9]  = parm[3]+(zConeTPC-zAbsStart);
836     parm[10] = rAbs;
837     parm[11] = parm[8] + (parm[9] - parm[6]) * TMath::Tan(theta2);
838
839     parm[12] = parm[3]+(zOpen-zAbsStart);
840     parm[13] = rAbs;
841     parm[14] = parm[11] + (parm[12] - parm[9]) * TMath::Tan(accMax);
842
843     parm[15] = parm[3]+(zRear-dRear-zAbsStart);
844     parm[16] = rAbs   + (parm[15] - parm[12]) * TMath::Tan(thetaOpen1) ;
845     parm[17] = parm[14] + (parm[15] - parm[12]) * TMath::Tan(accMax);
846
847     parm[18] = parm[3]+(zRear-dRear-zAbsStart);
848     parm[19] = (zRear-dRear) * TMath::Tan(accMin);
849     parm[20] = parm[14] + (parm[18] - parm[12]) * TMath::Tan(accMax);
850
851     parm[21] = -parm[3];
852     parm[22] = zRear* TMath::Tan(accMin);
853     parm[23] = parm[20] + (parm[21] - parm[18]) * TMath::Tan(accMax);
854   
855     printf(" zRear, zAbsStart,  rAbs =  %f , %f , %f \n\n", 
856              zRear, zAbsStart,  rAbs ); 
857               
858    
859     TPCON *abs0 = new TPCON("abs0", "abs0", "void", parm[0], parm[1], parm[2]);
860     
861     
862     abs0->DefineSection(0, parm[3],  parm[4],  parm[5] );
863     abs0->DefineSection(1, parm[6],  parm[7],  parm[8] );
864     abs0->DefineSection(2, parm[9], parm[10], parm[11] );
865     abs0->DefineSection(3,parm[12], parm[13], parm[14] );
866     abs0->DefineSection(4,parm[15], parm[16], parm[17] );
867     abs0->DefineSection(5,parm[18], parm[19], parm[20] );
868     abs0->DefineSection(6,parm[21], parm[22], parm[23] );
869
870     dz = (zRear-zAbsStart)/2.+zAbsStart;
871     
872     TRotMatrix* mat921 = new TRotMatrix("rot921","rot921",90.0,0.0,90.,90.0,180.0,0.0);
873     
874     Node0 = new TNode("abs0","abs0",abs0,0.0,0.0,dz,0);
875     Node0->SetLineColor(38);    
876     fNodes->Add(Node0);
877     
878     
879     Float_t cpar[5];
880     
881     cpar[0] = (zNose - zAbsStart) / 2.;
882     cpar[1] = zAbsStart * TMath::Tan(accMax);
883     cpar[2] = zAbsStart * TMath::Tan(theta1)-dSteel;
884     cpar[3] = zNose * TMath::Tan(accMax);
885     cpar[4] = zNose * TMath::Tan(theta1)-dSteel;    
886
887     dz = -(zRear-zAbsStart)/2.+cpar[0];
888     
889     TCONE *abs1 =  new TCONE("abs1", "abs1", "void", cpar[0], cpar[1], cpar[2], 
890                               cpar[3], cpar[4]);        
891     
892     Node0->cd();
893   
894     Node1 = new TNode("abs1","abs1",abs1,0.0,0.0,dz,0);
895     Node1->SetLineColor(7);     
896     fNodes->Add(Node1);
897     
898 //  Here I add a reference box to visualise the vertex zone :
899     
900     Top->cd();
901     
902     Float_t  paref[3];
903     
904     paref[0]  =  10.0;
905     paref[1]  =  15.0; 
906     paref[2]  =   5.6;
907     
908     TBRIK *aref = new TBRIK("aref","aref", "void", paref[0],paref[1],paref[2]);
909                             
910     Node2 = new TNode("aref","aref",aref,0.0,0.0,0.0,0);
911     Node2->SetLineColor(kBlue); 
912     fNodes->Add(Node2);    
913       
914 //  Here I add the  mother volume  QBPM
915 //  and the flanges  QB29, QB22 et QB24 defined by Andreas Morsch 
916 //  in   AliPIPEv0::CreateGeometry()  :
917  
918
919     Float_t parp[36];
920     
921 //  Mother Volume QBPM :
922
923     parp[0]  =    0;
924     parp[1]  =  360;
925     parp[2]  =   11;
926  
927     parp[3]  = - 90;
928     parp[4]  =    0;
929     parp[5]  =    5.8;
930
931     parp[6]  = - 81.0;
932     parp[7]  =    0.;
933     parp[8]  =    5.8;
934
935     parp[9]  = - 81.;
936     parp[10]  =    0.;
937     parp[11] =    4.22;
938
939     parp[12] = - 28.00;
940     parp[13] =    0;
941     parp[14] =    4.22;
942
943     parp[15] = - 28.00;
944     parp[16] =    0;
945     parp[17] =    3.2;
946
947     parp[18] =    0;
948     parp[19] =    0;
949     parp[20] =    3.2;
950
951     parp[21] =   28.00;
952     parp[22] =    0;
953     parp[23] =    3.2;
954
955     parp[24] =   28.00;
956     parp[25] =    0;
957     parp[26] =    4.22;
958
959     parp[27] =  250;
960     parp[28] =    0;
961     parp[29] =   4.22;
962
963     parp[30] =  250;
964     parp[31] =    0;
965     parp[32] =    5;
966
967     parp[33] =  800;
968     parp[34] =    0;
969     parp[35] =    5;
970     
971     TPCON *pip0 = new TPCON("pip0", "pip0", "void", parp[0], parp[1], parp[2]);
972      
973     pip0->DefineSection( 0, parp[3],  parp[4],  parp[5] );
974     pip0->DefineSection( 1, parp[6],  parp[7],  parp[8] );
975     pip0->DefineSection( 2, parp[9], parp[10], parp[11] );
976     pip0->DefineSection( 3,parp[12], parp[13], parp[14] );
977     pip0->DefineSection( 4,parp[15], parp[16], parp[17] );
978     pip0->DefineSection( 5,parp[18], parp[19], parp[20] );
979     pip0->DefineSection( 6,parp[21], parp[22], parp[23] );
980     pip0->DefineSection( 7,parp[24], parp[25], parp[26] );
981     pip0->DefineSection( 8,parp[27], parp[28], parp[29] );
982     pip0->DefineSection( 9,parp[30], parp[31], parp[32] );
983     pip0->DefineSection(10,parp[33], parp[34], parp[35] );
984     
985     dz = 0.0;
986     
987     Top->cd();
988     
989     Node3 = new TNode("pip0","pip0",pip0,0.0,0.0,dz,mat921);
990     Node3->SetLineColor(10);    
991     fNodes->Add(Node3);
992     Node3->SetVisibility(2);
993     
994 //  Flanges QB29 at  654.8  and   254.8  cms :
995
996     Float_t  ptube[3];
997     
998     ptube[0] = 3.0;
999     ptube[1] = 4.9;
1000     ptube[2] = 2.2; 
1001     
1002     TTUBE *pip1 = new TTUBE("pip1", "pip1", "void", ptube[0], ptube[1], ptube[2]);  
1003      
1004     Node3->cd();
1005        
1006     
1007     Node4 = new TNode("pip1","pip1",pip1,0.0,0.0,254.8,0);
1008     Node4->SetLineColor(6);     
1009     fNodes->Add(Node4);
1010     
1011     TTUBE *pip2 = new TTUBE("pip2", "pip2", "void", ptube[0], ptube[1], ptube[2]);  
1012     
1013     Node3->cd();
1014     
1015     Node5 = new TNode("pip2","pip2",pip2,0.0,0.0,654.8,0);
1016     Node5->SetLineColor(6);     
1017     fNodes->Add(Node5);
1018     
1019
1020 //  Al-Be  section QBAB at 335.0 cm  (LEFT side) :
1021     
1022     ptube[0] =  2.90;
1023     ptube[1] =  3.05;
1024     ptube[2] = 171.0;
1025
1026     TTUBE *pip3 = new TTUBE("pip3", "pip3", "void", ptube[0], ptube[1], ptube[2]); 
1027      
1028     Node3->cd();
1029
1030     Node6 = new TNode("pip3","pip3",pip3,0.0,0.0,335.0+ptube[2],0);
1031     Node6->SetLineColor(6);
1032     fNodes->Add(Node6);
1033     
1034 // Here I add the flange which is sitting on beam line 
1035 // right in front of V0R detector, and which I found on CERN drawing 
1036 // entitled : ALICE BEAM VACCUM CHAMBER - RB26 version III :  
1037
1038     ptube[0] = 3.0;
1039     ptube[1] = 5.675;
1040     ptube[2] = 0.9; 
1041     
1042     TTUBE *pip4 = new TTUBE("pip4", "pip4", "void", ptube[0], ptube[1], ptube[2]);  
1043      
1044     Node3->cd();
1045     
1046     
1047     Node7 = new TNode("pip4","pip4",pip4,0.0,0.0,-85.0-0.9,0);
1048     Node7->SetLineColor(6);
1049     fNodes->Add(Node7);   
1050          
1051  }  
1052     
1053
1054 //------------------------------------------------------------------------
1055 void AliVZEROv0::CreateMaterials()
1056 {
1057   Int_t i;
1058
1059   printf("\n");
1060   for(i=0;i<35;i++) printf("*");
1061   printf(" VZERO create materials ");
1062   for(i=0;i<35;i++) printf("*");
1063   printf("\n");
1064
1065 /* ...................  OLD VALUES  ( used in RICH) ............................   
1066     Float_t ppckov[14] = { 5.63e-9,5.77e-9,5.9e-9,6.05e-9,6.2e-9,6.36e-9,6.52e-9,
1067                            6.7e-9,6.88e-9,7.08e-9,7.3e-9,7.51e-9,7.74e-9,8e-9 };                           
1068     Float_t rindex_quarz[14] = { 1.528309,1.533333,
1069                                  1.538243,1.544223,1.550568,1.55777,
1070                                  1.565463,1.574765,1.584831,1.597027,
1071                                  1.611858,1.6277,1.6472,1.6724 };
1072     Float_t absco_quarz[14] = { 20.126,16.27,13.49,11.728,9.224,8.38,7.44,7.17,
1073                                 6.324,4.483,1.6,.323,.073,0. }; 
1074 ...................................................................................... */                               
1075
1076              
1077     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, 
1078                            6.9e-9, 7.1e-9, 7.3e-9, 7.5e-9, 7.7e-9, 7.9e-9, 8.1e-9 };
1079                            
1080     Float_t rindex_quarz[14] = { 1.52398,  1.53090, 1.53835, 1.54641, 1.55513, 1.56458, 
1081                                  1.57488,  1.58611, 1.59842, 1.61197, 1.62696, 1.64362, 
1082                                  1.662295, 1.68337 };
1083                                  
1084     Float_t absco_quarz[14] = { 105.8,  45.656, 35.665, 28.598, 25.007, 21.04, 17.525, 
1085                                 14.177, 9.282, 4.0925, 1.149, 0.3627, 0.1497, 0.05 };   
1086                                                                                         
1087     Float_t effic_all[14]   = { 1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1. };
1088     
1089         
1090     Float_t rindex_alu[14] = { 1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1. }; 
1091
1092     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,
1093                                1e-4,1e-4,1e-4,1e-4 };
1094     Float_t effic_alu[14]  = { 1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1. };
1095     
1096
1097     Int_t *idtmed = fIdtmed->GetArray()-2999;
1098     
1099     TGeant3 *geant3 = (TGeant3*) gMC;
1100     
1101 //  Parameters related to Quarz (SiO2) :
1102  
1103     Float_t aqua[2], zqua[2], densqua, wmatqua[2];
1104     Int_t nlmatqua;
1105     
1106     aqua[0]    = 28.09;
1107     aqua[1]    = 16.;
1108     zqua[0]    = 14.;
1109     zqua[1]    = 8.;
1110     densqua    = 2.64;
1111     nlmatqua   = -2;
1112     wmatqua[0] = 1.;
1113     wmatqua[1] = 2.;
1114
1115 // Parameters  related to aluminum sheets :
1116     
1117     Float_t  aal   = 26.98;
1118     Float_t  zal   = 13.00; 
1119     Float_t  densal=   2.7; 
1120     Float_t  radlal=   8.9;
1121        
1122 // Parameters  related to scintillator CH :
1123     
1124     Float_t ascin[2] = {1.01,12.01};
1125     Float_t zscin[2] = {1,6};
1126     Float_t wscin[2] = {1,1};
1127     Float_t denscin  = 1.03;
1128     
1129 //  Definition of materials :
1130        
1131     AliMaterial( 1, "AIR A$", 14.61, 7.3, .001205, 30420., 67500);
1132     AliMaterial(11, "AIR I$", 14.61, 7.3, .001205, 30420., 67500);
1133     AliMaterial( 2, "CARBON$"  , 12.01, 6.0, 2.265, 18.8, 49.9);
1134     AliMixture(  3, "QUA", aqua, zqua, densqua, nlmatqua, wmatqua);
1135     AliMaterial( 4, "ALUMINIUM1$", 26.98, 13., 2.7, 8.9, 37.2);
1136     AliMaterial( 5, "ALUMINIUM2$", aal, zal, densal, radlal, 0);
1137     
1138     
1139     AliMixture( 6, "Scintillator$",ascin,zscin,denscin,-2,wscin);
1140     
1141      
1142     Int_t   ISXFLD = gAlice->Field()->Integ();
1143     Float_t SXMGMX = gAlice->Field()->Max();
1144     
1145     Float_t tmaxfd, stemax, deemax, epsil, stmin;
1146     
1147     tmaxfd = -10.;
1148     stemax = -0.1;
1149     deemax = -0.1;
1150     epsil  = -0.01;
1151     stmin  = -0.001;
1152     
1153
1154 //  Active Air :    
1155     AliMedium(1, "ACTIVE AIR$", 1, 1, ISXFLD, SXMGMX, tmaxfd, stemax, deemax, epsil, stmin);
1156
1157 //  Inactive air : 
1158   
1159     AliMedium(11, "INACTIVE AIR$", 11, 0, ISXFLD, SXMGMX, tmaxfd, stemax, deemax, epsil, stmin);
1160     
1161     AliMedium(2, "CARBON$ ", 2,  1, ISXFLD, SXMGMX, tmaxfd, stemax, deemax, epsil, stmin);   
1162
1163     AliMedium(3, "QUARZ$", 3, 1, ISXFLD, SXMGMX, tmaxfd, fMaxStepQua, fMaxDestepQua, epsil, stmin);
1164     
1165     AliMedium(4,"ALUMINUM1$",4, 1, ISXFLD, SXMGMX, tmaxfd, fMaxStepAlu, fMaxDestepAlu, epsil, stmin);
1166     AliMedium(5,"ALUMINUM2$",5, 1, ISXFLD, SXMGMX, tmaxfd, fMaxStepAlu, fMaxDestepAlu, epsil, stmin);    
1167     AliMedium(6,"SCINTILLATOR$",6, 1, ISXFLD, SXMGMX, 10., .01, 1., .003, .003);
1168
1169     gMC->Gstpar(idtmed[3000], "LOSS", 1.);  //  [3000] = air ACTIF  [3010] = air INACTIF
1170     gMC->Gstpar(idtmed[3000], "HADR", 1.);
1171     gMC->Gstpar(idtmed[3000], "DCAY", 1.);
1172     gMC->Gstpar(idtmed[3000], "DRAY", 1.);
1173     
1174     gMC->Gstpar(idtmed[3001], "LOSS", 1.);  //  [3001] = carbon
1175     gMC->Gstpar(idtmed[3001], "HADR", 1.);
1176     gMC->Gstpar(idtmed[3001], "DCAY", 1.);
1177     gMC->Gstpar(idtmed[3001], "DRAY", 1.);
1178
1179     gMC->Gstpar(idtmed[3002], "LOSS", 1.);  //  [3002] = quartz
1180     gMC->Gstpar(idtmed[3002], "HADR", 1.);
1181     gMC->Gstpar(idtmed[3002], "DCAY", 1.);
1182     gMC->Gstpar(idtmed[3002], "DRAY", 1.);
1183     
1184     gMC->Gstpar(idtmed[3003], "LOSS", 1.);  //  [3003] = normal aluminum
1185     gMC->Gstpar(idtmed[3003], "HADR", 1.);
1186     gMC->Gstpar(idtmed[3003], "DCAY", 1.);
1187     gMC->Gstpar(idtmed[3003], "DRAY", 1.);
1188     
1189     gMC->Gstpar(idtmed[3004], "LOSS", 1.);  //  [3004] = reflecting aluminum
1190     gMC->Gstpar(idtmed[3004], "HADR", 1.);
1191     gMC->Gstpar(idtmed[3004], "DCAY", 1.);
1192     gMC->Gstpar(idtmed[3004], "DRAY", 1.);
1193     
1194     gMC->Gstpar(idtmed[3005], "LOSS", 1.);  //  [3005] = scintillator
1195     gMC->Gstpar(idtmed[3005], "HADR", 1.);
1196     gMC->Gstpar(idtmed[3005], "DCAY", 1.);
1197     gMC->Gstpar(idtmed[3005], "DRAY", 1.);    
1198     
1199     geant3->Gsckov(idtmed[3002], 14, ppckov, absco_quarz, effic_all,rindex_quarz);
1200     
1201     geant3->Gsckov(idtmed[3004], 14, ppckov, absco_alu, effic_alu, rindex_alu);
1202
1203 }
1204 //---------------------------------------------------------------------
1205 void AliVZEROv0::DrawModule()
1206 {
1207
1208 //  Drawing is done in DrawVZERO.C
1209
1210    Int_t i;
1211
1212    printf("\n");
1213    for(i=0;i<35;i++) printf("*");
1214    printf(" VZERO DrawModule ");
1215    for(i=0;i<35;i++) printf("*");
1216    printf("\n");
1217
1218
1219 }
1220
1221 //-------------------------------------------------------------------
1222 void AliVZEROv0::Init()
1223 {
1224 // Initialises version 0 of the VZERO Detector
1225 // Just prints an information message
1226   
1227    Int_t i;
1228
1229    printf("\n");
1230    for(i=0;i<35;i++) printf("*");
1231    printf(" VZERO_Init \n");
1232    for(i=0;i<35;i++) printf("*");
1233    printf("\n");
1234   
1235    fMulti       = 0;
1236    fNCerenkovs  = 0;
1237    fNGCerenkovs = 0;
1238    fNdead       = 0;
1239   
1240    BookingHistograms();
1241    
1242 }
1243
1244 //-------------------------------------------------------------------
1245
1246 void AliVZEROv0::StepManager()
1247 {
1248   
1249 //   Minimal version of StepManager :
1250 //   Everything has been removed, I only AddHit whenever hit is in 
1251 //   volume V0RI.  
1252   
1253      Int_t          copy;
1254      Int_t          vol[4];  // (box, layer, row, column) indices
1255      Float_t        hits[19];  // position wrt MRS,   energies...
1256      
1257      TLorentzVector pos;
1258      Float_t        global[3];
1259      Float_t        local[3];
1260      
1261      TLorentzVector momentum;
1262      Float_t        theta;
1263      Float_t        phi;
1264      Float_t        mom[4];
1265      Float_t        kRaddeg = 180/TMath::Pi();
1266      
1267      Float_t        TrackEnters = 0.0;
1268      Float_t        TrackExits  = 0.0;
1269      Float_t        Cerenkov    = 0.0;
1270      
1271      gMC->SetMaxStep(fMaxStepAlu);
1272      gMC->SetMaxStep(fMaxStepQua);
1273      
1274      if (!gMC->IsTrackAlive()) return;
1275      
1276      if (gMC->IsTrackEntering())       TrackEnters = 1.0;
1277      if (gMC->IsTrackExiting() )       TrackExits  = 1.0;
1278      if (gMC->TrackPid() == 50000050)  Cerenkov    = 1.0;
1279      
1280   
1281         
1282      gMC->TrackPosition(pos);
1283      gMC->TrackMomentum(momentum);
1284      
1285      mom[0] = momentum[0];
1286      mom[1] = momentum[1];
1287      mom[2] = momentum[2];
1288      mom[3] = momentum[3];
1289      
1290      Double_t tc = mom[0]*mom[0]+mom[1]*mom[1];
1291      Double_t rt = TMath::Sqrt(tc);
1292      theta   = Float_t(TMath::ATan2(rt,Double_t(mom[2])))*kRaddeg;
1293      phi     = Float_t(TMath::ATan2(Double_t(mom[1]),Double_t(mom[0])))*kRaddeg;
1294     
1295      global[0] = pos[0];
1296      global[1] = pos[1];
1297      global[2] = pos[2];
1298      
1299      
1300      gMC->Gmtod(global,local,1);
1301      
1302      hits[0]   = global[0];
1303      hits[1]   = global[1];
1304      hits[2]   = global[2];
1305      hits[3]   = local[0];
1306      hits[4]   = local[1];
1307      hits[5]   = local[2];
1308      hits[6]   = gMC->Edep();
1309      hits[7]   = gMC->Etot();
1310      hits[8]   = Float_t (gMC->TrackPid());
1311      hits[9]   = Float_t (gMC->IdFromPDG(gMC->TrackPid()));
1312      hits[10]  = gMC->TrackTime();
1313      hits[11]  = TrackEnters;
1314      hits[12]  = TrackExits;
1315      hits[13]  = gMC->TrackCharge();
1316      hits[14]  = Cerenkov;  
1317      
1318      hits[16]  = theta;
1319      hits[17]  = phi; 
1320    
1321      vol[0]    = gMC->CurrentVolOffID(1, vol[1]);
1322      vol[2]    = gMC->CurrentVolID(copy);
1323      vol[3]    = copy;
1324
1325
1326      if (gMC->CurrentVolID(copy) >= gMC->VolId("V0RI") &&
1327          gMC->CurrentVolID(copy) <= gMC->VolId("V0E4"))  
1328      {
1329          AddHit(gAlice->CurrentTrack(), vol, hits);
1330         }       
1331
1332   }
1333  
1334 //---------------------------------------------------------------------
1335 void AliVZEROv0::AddHit(Int_t track, Int_t* vol, Float_t* hits)
1336 {
1337   
1338   // Adds a  hit 
1339   
1340   
1341    TClonesArray  &lhits = *fHits;
1342    
1343    new(lhits[fNhits++]) AliVZEROhit(fIshunt, track, vol, hits);
1344
1345 }
1346
1347 //---------------------------------------------------------------------
1348 void AliVZEROv0::FinishEvent()
1349 {
1350    
1351    printf("\n");
1352    for(int i=0;i<30;i++) printf("*");
1353    printf(" VZERO_finishevent");
1354    for(int i=0;i<30;i++) printf("*");
1355    printf("\n");
1356    
1357      AddDigit(tracks, digits);
1358      
1359      
1360      if(fMulti > 0) fhMultiplicity->Fill(fMulti); 
1361      fhCerenkov->Fill(fNCerenkovs); 
1362
1363      fMulti       = 0;
1364      fNCerenkovs  = 0;
1365      fNGCerenkovs = 0;
1366      fNdead       = 0;
1367      
1368 }
1369
1370 //---------------------------------------------------------------------
1371 void AliVZEROv0::AddDigit(Int_t *tracks, Int_t* digits) 
1372 {
1373
1374    TClonesArray  &ldigits = *fDigits;
1375
1376    new(ldigits[fNdigits++]) AliVZEROdigit(tracks, digits);
1377
1378 }
1379
1380
1381 //---------------------------------------------------------------------
1382 void AliVZEROv0::MakeBranch(Option_t *option)
1383 {
1384   
1385   // Creates new branches in the current Root Tree
1386   
1387   
1388   char branchname[10];
1389   sprintf(branchname,"%s",GetName());
1390   
1391   
1392   char *H = strstr(option,"H");
1393   
1394   if (fHits   && gAlice->TreeH() && H) {
1395     gAlice->TreeH()->Branch(branchname,&fHits, fBufferSize);
1396     printf("* AliDetector::MakeBranch * Making Branch %s for hits\n",branchname);
1397   }     
1398
1399   char *D = strstr(option,"D");
1400   //
1401   if (fDigits   && gAlice->TreeD() && D) {
1402     gAlice->TreeD()->Branch(branchname,&fDigits, fBufferSize);
1403     printf("* AliDetector::MakeBranch * Making Branch %s for digits\n",branchname);
1404   }     
1405
1406
1407 }
1408
1409 //---------------------------------------------------------------------
1410 void AliVZEROv0::BookingHistograms()
1411 {
1412
1413   if (fhMultiplicity)         
1414     delete fhMultiplicity;
1415     
1416   if (fhGEANTcode) 
1417     delete fhGEANTcode;
1418     
1419   if (fhCerenkov)
1420     delete fhCerenkov; 
1421      
1422   if (fhToF)
1423     delete fhToF;    
1424
1425 //  fhMultiplicity = new TH1F("hMultiplicity", "hMultiplicity", 350,  0. , 350.); 
1426
1427   fhMultiplicity = new TH1F("hMultiplicity", "hMultiplicity", 100,  1. , 100.);
1428   fhGEANTcode    = new TH1F("hGEANTcode", "hGEANTcode", 50,  1., 50.);
1429   fhCerenkov     = new TH1F("hCerenkov", "hCerenkov", 100, 1., 100000.);
1430   fhToF          = new TH1F("hToF", "hToF",150,2.0,7.0);
1431   
1432 }
1433   
1434 //---------------------------------------------------------------------
1435 void AliVZEROv0::FinishRun()
1436 {
1437
1438    SavingHistograms();
1439 }
1440
1441
1442
1443 //---------------------------------------------------------------------
1444 void AliVZEROv0::SavingHistograms()
1445 {
1446
1447 //  Saves the histograms in a root file named "name.save" 
1448
1449
1450   Text_t outputname[8] ;
1451   outputname = "Fileout";
1452   TFile output(outputname,"RECREATE");
1453   output.cd();
1454   
1455   if (fhMultiplicity)         
1456     fhMultiplicity->Write();
1457   if (fhGEANTcode)
1458     fhGEANTcode->Write(); 
1459   if (fhCerenkov)
1460     fhCerenkov->Write();
1461   if (fhToF)
1462     fhToF->Write();   
1463 }