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