Adding TDC channel delays to the calib object.
[u/mrichter/AliRoot.git] / VZERO / AliVZEROv4.cxx
CommitLineData
79b41939 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/* $Id$ */
17
18//////////////////////////////////////////////////////////////////////
19// //
20// (V-zero) detector version 4 as designed by the Lyon group //
21// All comments should be sent to Brigitte CHEYNIS : //
22// b.cheynis@ipnl.in2p3.fr //
23// Geometry of the 24th of february 2004 //
24// (now 4 rings instead of 3 rings as in previous version) //
25// V0R (now V0C) sits between Z values -89.4 and -84.9 cm //
26// V0L (now V0A) sits between Z values +350.0 and +352.0 cm //
27// New coordinate system has been implemented in october 2003 //
28// //
29//////////////////////////////////////////////////////////////////////
30
31// --- Standard libraries ---
32#include <Riostream.h>
33#include <stdlib.h>
34#include <string.h>
35
36// --- ROOT libraries ---
37#include <TClonesArray.h>
f7a1cc68 38#include <TGeoGlobalMagField.h>
79b41939 39#include <TLorentzVector.h>
40#include <TMath.h>
79b41939 41#include <TObjectTable.h>
79b41939 42#include <TParticle.h>
f7a1cc68 43#include <TVirtualMC.h>
79b41939 44
45// --- AliRoot header files ---
46#include "AliRun.h"
47#include "AliMC.h"
48#include "AliConst.h"
254ef8f1 49#include "AliLog.h"
79b41939 50#include "AliMagF.h"
51#include "AliVZEROLoader.h"
52#include "AliVZEROdigit.h"
53#include "AliVZEROhit.h"
54#include "AliVZEROv4.h"
55
56ClassImp(AliVZEROv4)
57
58//_____________________________________________________________________________
0b2bea8b 59AliVZEROv4:: AliVZEROv4():AliVZERO(),
60 fCellId(0),
61 fTrackPosition(),
62 fTrackMomentum(),
63 fLightYield(93.75),
64 fLightAttenuation(0.05),
65 fnMeters(15.0),
66 fFibToPhot(0.3)
67
79b41939 68{
69// Standard default constructor
70}
71
72//_____________________________________________________________________________
73AliVZEROv4::AliVZEROv4(const char *name, const char *title):
0b2bea8b 74 AliVZERO(name,title),
75 fCellId(0),
76 fTrackPosition(),
77 fTrackMomentum(),
78 fLightYield(93.75),
79 fLightAttenuation(0.05),
80 fnMeters(15.0),
81 fFibToPhot(0.3)
82
79b41939 83{
84
85// Standard constructor for V-zero Detector version 2
86
254ef8f1 87 AliDebug(2,"Create VZERO object");
0b2bea8b 88//
89// fLightYield = 93.75; // Light yield in BC408 (93.75 eV per photon)
90// fLightAttenuation = 0.05; // Light attenuation in fiber (0.05 per meter)
91// fnMeters = 15.0; // Number of meters of clear fibers to PM
92// fFibToPhot = 0.3; // Attenuation at fiber-photocathode interface
79b41939 93}
94
95//_____________________________________________________________________________
96void AliVZEROv4::CreateGeometry()
97{
98
99// Creates the GEANT geometry of the V-zero Detector version 3
100
254ef8f1 101 AliDebug(2,"Create VZERO Geometry ");
79b41939 102
103 Int_t *idtmed = fIdtmed->GetArray()-2999;
104
105 Int_t ndetR = 1;
106 Int_t ndetL = 1;
107
108 Int_t ncellsR = 1;
109 Int_t ncellsL = 1;
110
111 Int_t idrotm[999];
112
113 Float_t height1Right, height2Right, height3Right, height4Right;
114 Float_t heightRight;
115 Float_t theta;
116
117 Float_t halfThickQua;
118
119 Float_t zdet;
120 Float_t r0Right, r4Right;
121 Float_t pi = TMath::Pi();
122
123 height1Right = 3.42; // height of cell 1, in cm
124 height2Right = 6.78; // height of cell 2, in cm
125 height3Right = 7.11; // height of cell 3, in cm
126 height4Right = 10.91; // height of cell 4, in cm
127
128 theta = pi/6.0/2.0; // half angular opening = 15 degrees
129
130 halfThickQua= fThickness1/2.0; // half thickness of elementary cell (inner ring)
131
132// distance 0.6 cm in zdet accounts for the fact V0R box back lid sits 0.6 away from
133// absorber nose sitting at 90 cm. Will use -zdet later...
134// size of V0R box (fThickness) is increased by 1 mm as compared to version v2
135
136 fThickness = fThickness + 0.1;
137 zdet = 90.0 - 0.6 - fThickness/2.0; // distance to vertex (along Z axis)
138 r0Right = 4.05; // closest distance to center of the beam pipe
139 heightRight = height1Right + height2Right + height3Right + height4Right;
140 r4Right = r0Right + heightRight;
141
142// Creation of mother volume v0LE - left part - :
143// Entrance face at +350.0 cm (new coordinate system) ...
144
145 Float_t partube[3];
146
147 partube[0] = 4.3;
148 partube[1] = 45.0;
149 partube[2] = fThickness1/2.0;
150
151 gMC->Gsvolu("V0LE","TUBE",idtmed[3005],partube,3);
152
153// Creation of five rings - left part - :
154// Entrance face at +350.0 cm (new coordinate system) ...
155
156// Mother volume v0L0 in which will be set 5 scintillator cells
157
158 Float_t partubs[5];
159
160 Float_t r0Left = 4.3;
161 Float_t height1Left = 3.6;
162 Float_t height2Left = 6.4;
163 Float_t height3Left = 14.9;
164 Float_t height4Left = 14.4;
165 Float_t heightLeft = height1Left + height2Left + height3Left + height4Left;
166
167 Float_t r4Left = r0Left + heightLeft;
168
169 partubs[0] = r0Left;
170 partubs[1] = r4Left;
171 partubs[2] = fThickness1/2.0;
172 partubs[3] = 90.0-15.0;
173 partubs[4] = 120.0-15.0;
174
175 gMC->Gsvolu("V0L0","TUBS",idtmed[3010],partubs,5); // air volume
176
177 Float_t r1Left = r0Left + height1Left;
178
179 partubs[0] = r0Left;
180 partubs[1] = r1Left;
181
182 gMC->Gsvolu("V0L1","TUBS",idtmed[3005],partubs,5); // quartz volume
183 gMC->Gspos("V0L1",1,"V0L0", 0.0, 0.0 , 0.0, 0,"ONLY");
184
185 Float_t r2Left = r1Left + height2Left;
186
187 partubs[0] = r1Left;
188 partubs[1] = r2Left;
189
190 gMC->Gsvolu("V0L2","TUBS",idtmed[3005],partubs,5); // quartz volume
191 gMC->Gspos("V0L2",1,"V0L0", 0.0, 0.0 , 0.0, 0,"ONLY");
192
193 Float_t r3Left = r2Left + height3Left;
194
195 partubs[0] = r2Left;
196 partubs[1] = r3Left;
197
198 gMC->Gsvolu("V0L3","TUBS",idtmed[3005],partubs,5); // quartz volume
199 gMC->Gspos("V0L3",1,"V0L0", 0.0, 0.0 , 0.0, 0,"ONLY");
200
201 partubs[0] = r3Left;
202 partubs[1] = r4Left;
203
204 gMC->Gsvolu("V0L4","TUBS",idtmed[3005],partubs,5); // quartz volume
205 gMC->Gspos("V0L4",1,"V0L0", 0.0, 0.0 , 0.0, 0,"ONLY");
206
207// Creation of mother volume v0RI - right part - :
208
209 partube[0] = r0Right - 0.2;
210 partube[1] = r4Right + 1.0;
211 partube[2] = fThickness/2.0;
212
213 gMC->Gsvolu("V0RI","TUBE",idtmed[3010],partube,3);
214
215// Creation of carbon lids (3.5 mm thick) to keep v0RI box shut...
216
217 Float_t lidThickness = 0.35;
218
219 partube[0] = r0Right;
220 partube[1] = r4Right;
221 partube[2] = +lidThickness/2.0;
222
223 gMC->Gsvolu("V0CA","TUBE",idtmed[3001],partube,3);
224 gMC->Gspos("V0CA",1,"V0RI",0.0,0.0, fThickness/2.0-partube[2],0,"ONLY");
225 gMC->Gspos("V0CA",2,"V0RI",0.0,0.0,-fThickness/2.0+partube[2],0,"ONLY");
226
227// Creation of aluminum rings to maintain the v0RI pieces ...
228
229 partube[0] = r0Right - 0.2;
230 partube[1] = r0Right;
231 partube[2] = +fThickness/2.0;
232
233 gMC->Gsvolu("V0IR","TUBE",idtmed[3003],partube,3);
234 gMC->Gspos("V0IR",1,"V0RI",0.0,0.0,0.0,0,"ONLY");
235
236 partube[0] = r4Right;
237 partube[1] = r4Right + 1.0;
238 partube[2] = +fThickness/2.0;
239
240 gMC->Gsvolu("V0ER","TUBE",idtmed[3003],partube,3);
241 gMC->Gspos("V0ER",1,"V0RI",0.0,0.0,0.0,0,"ONLY");
242
243// Mother volume v0R0 in which will be set 4 scintillator cells
244
245 partubs[0] = r0Right;
246 partubs[1] = r4Right;
247 partubs[2] = fThickness/2.0;
248 partubs[3] = 90.0-15.0;
249 partubs[4] = 120.0-15.0;
250
251 gMC->Gsvolu("V0R0","TUBS",idtmed[3010],partubs,5); // air volume
252
253// Elementary cell of ring 1 :
254// (cells of ring 1 will be shifted by 1.7 cm towards vertex to output fibers)
255
256 Float_t offsetFibers = 1.7;
257 Float_t offset = fThickness/2.0 - lidThickness - fThickness1/2.0;
258 Float_t r1Right = r0Right + height1Right;
259
260 partubs[0] = r0Right;
261 partubs[1] = r1Right;
262 partubs[2] = fThickness1/2.0;
263
264 gMC->Gsvolu("V0R1","TUBS",idtmed[3005],partubs,5); // scintillator volume
265 gMC->Gspos("V0R1",1,"V0R0", 0.0, 0.0 , -offset + offsetFibers, 0,"ONLY");
266
267// Elementary cell of ring 2 :
268
269 Float_t r2Right = r1Right + height2Right;
270
271 partubs[0] = r1Right;
272 partubs[1] = r2Right;
273
274 gMC->Gsvolu("V0R2","TUBS",idtmed[3005],partubs,5); // scintillator volume
275 gMC->Gspos("V0R2",1,"V0R0", 0.0, 0.0 , -offset, 0,"ONLY");
276
277
278// Elementary cell of ring 3 :
279
280 Float_t r3Right = r2Right + height3Right;
281
282 partubs[0] = r2Right;
283 partubs[1] = r3Right;
284
285 gMC->Gsvolu("V0R3","TUBS",idtmed[3005],partubs,5); // scintillator volume
286 gMC->Gspos("V0R3",1,"V0R0", 0.0, 0.0 , -offset, 0,"ONLY");
287
288// Elementary cell of ring 4 :
289
290 partubs[0] = r3Right;
291 partubs[1] = r4Right;
292
293 gMC->Gsvolu("V0R4","TUBS",idtmed[3005],partubs,5); // scintillator volume
294 gMC->Gspos("V0R4",1,"V0R0", 0.0, 0.0 , -offset, 0,"ONLY");
295
296 Float_t phiDeg = 180./6.;
297
298// Right part :
299
300 for(Float_t phi = 15.0 ; phi < 360.0; phi = phi + phiDeg)
301 {
302 AliMatrix(idrotm[902], 90.0, phi, 90.0, 90.0 +phi, 0.0 , 0.0);
303 gMC->Gspos("V0R0",ndetR,"V0RI",0.0,
304 0.0,0.0,idrotm[902],"ONLY");
305 ndetR++;
306 }
307
308 gMC->Gspos("V0RI",1,"ALIC",0.0,0.0,-zdet,0,"ONLY");
309
310 ncellsR = (ndetR - 1) * 4;
254ef8f1 311 AliInfo(Form("Number of cells on Right side = %d", ncellsR));
79b41939 312
313// Left part :
314
315 for(Float_t phi = 15.0 ; phi < 360.0; phi = phi + phiDeg)
316 {
317 AliMatrix(idrotm[902], 90.0, phi, 90.0, 90.0 +phi, 0.0 , 0.0);
318 gMC->Gspos("V0L0",ndetL,"V0LE",0.0,
319 0.0,0.0,idrotm[902],"ONLY");
320 ndetL++;
321 }
322
323 gMC->Gspos("V0LE",1,"ALIC",0.0,0.0,350.0+fThickness1/2.0,0,"ONLY");
324
325 ncellsL = (ndetL - 1) * 4;
254ef8f1 326 AliInfo(Form("Number of cells on Left side = %d", ncellsL));
79b41939 327
7dd2cbe4 328}
79b41939 329
330//_____________________________________________________________________________
331void AliVZEROv4::CreateMaterials()
332{
333
334// Creates materials used for geometry
335
254ef8f1 336 AliDebug(2,"VZERO create materials");
79b41939 337
338/*
339 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,
340 6.9e-9, 7.1e-9, 7.3e-9, 7.5e-9, 7.7e-9, 7.9e-9, 8.1e-9 };
341
342
343 Float_t ppckov_alu[14] = { 5.5e-9, 5.7e-9, 5.9e-9, 6.1e-9, 6.3e-9, 6.5e-9, 6.7e-9,
344 6.9e-9, 7.1e-9, 7.3e-9, 7.5e-9, 7.7e-9, 7.9e-9, 8.1e-9 };
345
346 Float_t rindex_quarz[14] = { 1.52398, 1.53090, 1.53835, 1.54641, 1.55513, 1.56458,
347 1.57488, 1.58611, 1.59842, 1.61197, 1.62696, 1.64362,
348 1.662295, 1.68337 };
349
350 Float_t absco_quarz[14] = { 105.8, 45.656, 35.665, 28.598, 25.007, 21.04, 17.525,
351 14.177, 9.282, 4.0925, 1.149, 0.3627, 0.1497, 0.05 };
352
353 Float_t effic_all[14] = { 1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1. };
354
355
356 Float_t rindex_alu[14] = { 1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1. };
357
358
359 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,
360 1e-4,1e-4,1e-4,1e-4 };
361 Float_t effic_alu[14] = { 1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1. };
362
363*/
364
365 Int_t *idtmed = fIdtmed->GetArray()-2999;
366
79b41939 367
368// Parameters related to Quarz (SiO2) :
369
370 Float_t aqua[2], zqua[2], densqua, wmatqua[2];
371 Int_t nlmatqua;
372
373 aqua[0] = 28.09;
374 aqua[1] = 16.;
375 zqua[0] = 14.;
376 zqua[1] = 8.;
377 densqua = 2.64;
378 nlmatqua = -2;
379 wmatqua[0] = 1.;
380 wmatqua[1] = 2.;
381
382// Parameters related to aluminum sheets :
383
384 Float_t aal = 26.98;
385 Float_t zal = 13.00;
386 Float_t densal= 2.7;
387 Float_t radlal= 8.9;
388
389// Parameters related to scintillator CH :
390
391 Float_t ascin[2] = {1.00794,12.011};
392 Float_t zscin[2] = {1.,6.};
393 Float_t wscin[2] = {1.,1.};
394 Float_t denscin = 1.032;
395
f7b3a79e 396// AIR
397
398 Float_t aAir[4]={12.,14.,16.,36.};
399 Float_t zAir[4]={6.,7.,8.,18.};
400 Float_t wAir[4]={0.000124,0.755267,0.231781,0.012827};
401 Float_t dAir = 1.20479E-3;
402
79b41939 403// Definition of materials :
f7b3a79e 404
405// AIR
406
407 AliMixture( 1, "AIR A$", aAir,zAir,dAir,4,wAir);
408 AliMixture(11, "AIR I$", aAir,zAir,dAir,4,wAir);
79b41939 409 AliMaterial( 2, "CARBON$" , 12.01, 6.0, 2.265, 18.8, 49.9, 0, 0);
410 AliMixture( 3, "QUA", aqua, zqua, densqua, nlmatqua, wmatqua);
411 AliMaterial( 4, "ALUMINIUM1$", 26.98, 13., 2.7, 8.9, 37.2, 0, 0);
412 AliMaterial( 5, "ALUMINIUM2$", aal, zal, densal, radlal, 0, 0, 0);
413
414 AliMixture( 6, "Scintillator$",ascin,zscin,denscin,-2,wscin);
415
416
f7a1cc68 417 Int_t iSXFLD = ((AliMagF*)TGeoGlobalMagField::Instance()->GetField())->Integ(); // Field type
418 Float_t sXMGMX = ((AliMagF*)TGeoGlobalMagField::Instance()->GetField())->Max(); // Field max.
79b41939 419
420 Float_t tmaxfd, stemax, deemax, epsil, stmin;
421
422 tmaxfd = 10.;
423 stemax = 0.1;
424 deemax = 0.1;
425 epsil = 0.001;
426 stmin = 0.001;
427
428// Active Air :
429 AliMedium(1, "ACTIVE AIR$", 1, 1, iSXFLD, sXMGMX,
430 10.0, 1.0, 0.1, 0.1, 10.0, 0, 0) ;
431
432// Inactive air :
433
434 AliMedium(11, "INACTIVE AIR$", 11, 0, iSXFLD, sXMGMX,
435 10.0, 1.0, 0.1, 0.1, 10.0, 0, 0) ;
436
437 AliMedium(2, "CARBON$ ", 2, 1, iSXFLD, sXMGMX,
438 tmaxfd, stemax, deemax, epsil, stmin, 0, 0);
439
440 AliMedium(3, "QUARZ$", 3, 1, iSXFLD, sXMGMX,
441 tmaxfd, fMaxStepQua, fMaxDestepQua, epsil, stmin, 0, 0);
442
443 AliMedium(4,"ALUMINUM1$",4, 1, iSXFLD, sXMGMX,
444 tmaxfd, fMaxStepAlu, fMaxDestepAlu, epsil, stmin, 0, 0);
445
446
447 AliMedium(5,"ALUMINUM2$",5, 1, iSXFLD, sXMGMX,
448 tmaxfd, fMaxStepAlu, fMaxDestepAlu, epsil, stmin, 0, 0);
449
450 AliMedium(6,"SCINTILLATOR$",6, 1, iSXFLD, sXMGMX, 10.0, 0.1, 0.1, 0.003, 0.003, 0, 0);
451
452 gMC->Gstpar(idtmed[3000], "LOSS", 1.); // [3000] = air ACTIF [3010] = air INACTIF
453 gMC->Gstpar(idtmed[3000], "HADR", 1.);
454 gMC->Gstpar(idtmed[3000], "DCAY", 1.);
455 gMC->Gstpar(idtmed[3000], "DRAY", 1.);
456
457 gMC->Gstpar(idtmed[3001], "LOSS", 1.); // [3001] = carbon
458 gMC->Gstpar(idtmed[3001], "HADR", 1.);
459 gMC->Gstpar(idtmed[3001], "DCAY", 1.);
460 gMC->Gstpar(idtmed[3001], "DRAY", 1.);
461
462 gMC->Gstpar(idtmed[3002], "LOSS", 1.); // [3002] = quartz
463 gMC->Gstpar(idtmed[3002], "HADR", 1.);
464 gMC->Gstpar(idtmed[3002], "DCAY", 1.);
465 gMC->Gstpar(idtmed[3002], "DRAY", 1.);
466 gMC->Gstpar(idtmed[3002], "CUTGAM",0.5E-4) ;
467 gMC->Gstpar(idtmed[3002], "CUTELE",1.0E-4) ;
468
469 gMC->Gstpar(idtmed[3003], "LOSS", 1.); // [3003] = normal aluminum
470 gMC->Gstpar(idtmed[3003], "HADR", 1.);
471 gMC->Gstpar(idtmed[3003], "DCAY", 1.);
472 gMC->Gstpar(idtmed[3003], "DRAY", 1.);
473
474 gMC->Gstpar(idtmed[3004], "LOSS", 1.); // [3004] = reflecting aluminum
475 gMC->Gstpar(idtmed[3004], "HADR", 1.);
476 gMC->Gstpar(idtmed[3004], "DCAY", 1.);
477 gMC->Gstpar(idtmed[3004], "DRAY", 1.);
478 gMC->Gstpar(idtmed[3004], "CUTGAM",0.5E-4) ;
479 gMC->Gstpar(idtmed[3004], "CUTELE",1.0E-4) ;
480
481 gMC->Gstpar(idtmed[3005], "LOSS", 1.); // [3005] = scintillator
482 gMC->Gstpar(idtmed[3005], "HADR", 1.);
483 gMC->Gstpar(idtmed[3005], "DCAY", 1.);
484 gMC->Gstpar(idtmed[3005], "DRAY", 1.);
485 gMC->Gstpar(idtmed[3005], "CUTGAM",0.5E-4) ;
486 gMC->Gstpar(idtmed[3005], "CUTELE",1.0E-4) ;
487
488
489// geant3->Gsckov(idtmed[3002], 14, ppckov, absco_quarz, effic_all,rindex_quarz);
490// geant3->Gsckov(idtmed[3004], 14, ppckov_alu, absco_alu, effic_alu, rindex_alu);
491
492// gMC->SetCerenkov(idtmed[3002], 14, ppckov, absco_quarz, effic_all,rindex_quarz);
493// gMC->SetCerenkov(idtmed[3004], 14, ppckov_alu, absco_alu, effic_alu, rindex_alu);
494
495}
496
497//_____________________________________________________________________________
ba380e33 498void AliVZEROv4::DrawModule() const
79b41939 499{
500
501// Drawing is done in DrawVZERO.C
502
254ef8f1 503 AliDebug(2,"VZERO DrawModule");
79b41939 504}
505
506//_____________________________________________________________________________
507void AliVZEROv4::Init()
508{
509// Initialises version 2 of the VZERO Detector
510// Just prints an information message
511
254ef8f1 512 AliDebug(2,Form("VZERO version %d initialized",IsVersion()));
79b41939 513
514// gMC->SetMaxStep(fMaxStepAlu);
515// gMC->SetMaxStep(fMaxStepQua);
516
517 AliVZERO::Init();
518}
519
520//_____________________________________________________________________________
521void AliVZEROv4::StepManager()
522{
523
524// Step Manager, called at each step
525
526 Int_t copy;
527 static Int_t vol[4];
528 static Float_t hits[21];
529 static Float_t eloss, tlength;
530 static Int_t nPhotonsInStep;
531 static Int_t nPhotons;
532 static Int_t numStep;
533 Float_t ringNumber;
534 Float_t destep, step;
535
536 numStep += 1;
537
538// We keep only charged tracks :
539
540 if ( !gMC->TrackCharge() || !gMC->IsTrackAlive() ) return;
541
542 vol[0] = gMC->CurrentVolOffID(1, vol[1]);
543 vol[2] = gMC->CurrentVolID(copy);
544 vol[3] = copy;
545
d6fb41ac 546 static Int_t idV0R1 = gMC->VolId("V0R1");
547 static Int_t idV0L1 = gMC->VolId("V0L1");
548 static Int_t idV0R2 = gMC->VolId("V0R2");
549 static Int_t idV0L2 = gMC->VolId("V0L2");
550 static Int_t idV0R3 = gMC->VolId("V0R3");
551 static Int_t idV0L3 = gMC->VolId("V0L3");
552 static Int_t idV0R4 = gMC->VolId("V0R4");
553 static Int_t idV0L4 = gMC->VolId("V0L4");
554
555 if ( gMC->CurrentVolID(copy) == idV0R1 ||
556 gMC->CurrentVolID(copy) == idV0L1 )
79b41939 557 ringNumber = 1.0;
d6fb41ac 558 else if ( gMC->CurrentVolID(copy) == idV0R2 ||
559 gMC->CurrentVolID(copy) == idV0L2 )
79b41939 560 ringNumber = 2.0;
d6fb41ac 561 else if ( gMC->CurrentVolID(copy) == idV0R3 ||
562 gMC->CurrentVolID(copy) == idV0L3 )
79b41939 563 ringNumber = 3.0;
d6fb41ac 564 else if ( gMC->CurrentVolID(copy) == idV0R4 ||
565 gMC->CurrentVolID(copy) == idV0L4 )
79b41939 566 ringNumber = 4.0;
567 else
568 ringNumber = 0.0;
569
570 if ( ringNumber > 0.5 ) {
571
572 destep = gMC->Edep();
573 step = gMC->TrackStep();
574
575 nPhotonsInStep = Int_t(destep / (fLightYield *1e-9) );
576 nPhotonsInStep = gRandom->Poisson(nPhotonsInStep);
577
578 eloss += destep;
579 tlength += step;
580
581 if ( gMC->IsTrackEntering() ) {
582
583 nPhotons = nPhotonsInStep;
584 gMC->TrackPosition(fTrackPosition);
585 gMC->TrackMomentum(fTrackMomentum);
586
587 Float_t pt = TMath::Sqrt( fTrackMomentum.Px() * fTrackMomentum.Px() +
588 fTrackMomentum.Py() * fTrackMomentum.Py() );
589
590 hits[0] = fTrackPosition.X();
591 hits[1] = fTrackPosition.Y();
592 hits[2] = fTrackPosition.Z();
593 hits[3] = Float_t (gMC->TrackPid());
594
595 hits[4] = gMC->TrackTime();
596 hits[5] = gMC->TrackCharge();
597 hits[6] = fTrackMomentum.Theta()*TMath::RadToDeg();
598 hits[7] = fTrackMomentum.Phi()*TMath::RadToDeg();
599 hits[8] = ringNumber;
600
601 hits[9] = pt;
602 hits[10] = fTrackMomentum.P();
603 hits[11] = fTrackMomentum.Px();
604 hits[12] = fTrackMomentum.Py();
605 hits[13] = fTrackMomentum.Pz();
606
607 TParticle *par = gAlice->GetMCApp()->Particle(gAlice->GetMCApp()->GetCurrentTrackNumber());
608 hits[14] = par->Vx();
609 hits[15] = par->Vy();
610 hits[16] = par->Vz();
611
612 tlength = 0.0;
613 eloss = 0.0;
614 }
615
616 nPhotons = nPhotons + nPhotonsInStep;
617
618 if( gMC->IsTrackExiting() || gMC->IsTrackStop() || gMC->IsTrackDisappeared()){
619
620 nPhotons = nPhotons - Int_t((Float_t(nPhotons) * fLightAttenuation * fnMeters));
621 nPhotons = nPhotons - Int_t( Float_t(nPhotons) * fFibToPhot);
622
623 hits[17] = eloss;
624 hits[18] = tlength;
625 hits[19] = nPhotons;
626 hits[20] = GetCellId (vol, hits);
627
628 AddHit(gAlice->GetMCApp()->GetCurrentTrackNumber(), vol, hits);
629
630 tlength = 0.0;
631 eloss = 0.0;
632 nPhotons = 0;
633 nPhotonsInStep = 0;
634
635 numStep = 0;
636 }
637 }
638
639}
640
641//_____________________________________________________________________________
642void AliVZEROv4::AddHit(Int_t track, Int_t *vol, Float_t *hits)
643{
644
645// Adds a VZERO hit
646
647 TClonesArray &lhits = *fHits;
648 new(lhits[fNhits++]) AliVZEROhit(fIshunt,track,vol,hits);
649}
650
651//_____________________________________________________________________________
652void AliVZEROv4::AddDigits(Int_t *tracks, Int_t* digits)
653{
654
655// Adds a VZERO digit
656
657 TClonesArray &ldigits = *fDigits;
658 new(ldigits[fNdigits++]) AliVZEROdigit(tracks, digits);
659}
660
661//_____________________________________________________________________________
662void AliVZEROv4::MakeBranch(Option_t *option)
663{
664
665// Creates new branches in the current Root Tree
666
667 char branchname[10];
668 sprintf(branchname,"%s",GetName());
254ef8f1 669 AliDebug(2,Form("fBufferSize = %d",fBufferSize));
79b41939 670
671 const char *cH = strstr(option,"H");
672
cb5b8b21 673 if (fHits && fLoader->TreeH() && cH) {
674 fLoader->TreeH()->Branch(branchname,&fHits, fBufferSize);
254ef8f1 675 AliDebug(2,Form("Making Branch %s for hits",branchname));
79b41939 676 }
677
678 const char *cD = strstr(option,"D");
679
680 if (fDigits && fLoader->TreeD() && cD) {
681 fLoader->TreeD()->Branch(branchname,&fDigits, fBufferSize);
254ef8f1 682 AliDebug(2,Form("Making Branch %s for digits",branchname));
79b41939 683 }
684
685}
686
687//_____________________________________________________________________________
688Int_t AliVZEROv4::GetCellId(Int_t *vol, Float_t *hits)
689{
690
691 // Returns Id of scintillator cell
692 // Right side from 0 to 47
693 // Left side from 48 to 95
694
695 Int_t index = vol[1];
696 fCellId = 0;
697
698 if (index < 10) index = index + 12;
699
700 if (hits[2] < 0.0) {
701 index = (index - 10) + ( ( Int_t(hits[8]) - 1 ) * 12);
702 fCellId = index;
703 }
704 else if (hits[2] > 0.0)
705 {
706 index = (index + 38) + ( ( Int_t(hits[8]) - 1 ) * 12);
707 fCellId = index;}
708
709 return fCellId;
710}