]> git.uio.no Git - u/mrichter/AliRoot.git/blame - T0/AliT0v2.cxx
Fixing a possible leak, logics still flawed though...
[u/mrichter/AliRoot.git] / T0 / AliT0v2.cxx
CommitLineData
dc7ca31d 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// T0 ( T-zero) detector version 0 //
21//
22//Begin Html
23/*
24<img src="gif/AliT0v2Class.gif">
25*/
26//End Html
27// //
28// //
29//////////////////////////////////////////////////////////////////////
30
31#define RIGHT_ARRAY 1
32#define LEFT_ARRAY 2
33
34#include <Riostream.h>
35#include <stdlib.h>
36
dc7ca31d 37#include <TLorentzVector.h>
38#include <TMath.h>
dc7ca31d 39#include <TVirtualMC.h>
40
41#include "AliMagF.h"
42#include "AliRun.h"
43#include "AliT0hit.h"
44#include "AliT0v2.h"
45#include "AliMC.h"
dc7ca31d 46
47ClassImp(AliT0v2)
48
49
50//////////////////////////////////////////////////////////////////////
51// Standart constructor for T0 Detector version 2
52//////////////////////////////////////////////////////////////////////
53AliT0v2::AliT0v2(const char *name, const char *title):
54 AliT0(name,title)
55{
56 fIdSens1 = 0;
57// setBufferSize(128000);
58}
59
60
61//////////////////////////////////////////////////////////////////////
62// Create the geometry of T0 Detector version 2
63//////////////////////////////////////////////////////////////////////
64void AliT0v2::CreateGeometry()
65{
66 /*
67 <img src="gif/AliT0v2.gif">
68 */
69
70 Int_t *idtmed;
71 Int_t idrotm[999];
72 Int_t i, j;
73 Float_t x, y, z;
74 Float_t zRight;
75 Float_t zLeft;
76 Float_t phi[3];
77 Float_t theta;
78 Double_t angel;
79
80 Float_t pstart[3] = {4.5, 10.7, 5.3};
81 Float_t pinstart[3] = {0., 1.31, 5.25};
82 Float_t ppmt[3] = {0., 1.31, 3.5};
83 Float_t ptop[3] = {0., 1.3, 1.5};
84// Float_t preg[3] = {0., 1.3, 0.005};
85 Float_t preg[3] = {0., 0.875, 0.005};
86 Float_t pdes[3] = {0.875, 1.3, 0.005};
87
88
89 zRight = 75.;
90 zLeft = 350.;
91 theta = (180 / TMath::Pi()) * TMath::ATan(6.5 / zRight);
92 angel = 2 * TMath::Pi() / 12;
93 idtmed = fIdtmed->GetArray();
94
95
96 AliMatrix (idrotm[901], 90., 0., 90., 90., 180., 0.);
97
98 gMC->Gsvolu ("0RST", "TUBE", idtmed[3], pstart, 3);
99 gMC->Gsvolu ("0LST", "TUBE", idtmed[3], pstart, 3);
100 gMC->Gspos ("0RST", 1, "ALIC", 0., 0., -zRight, 0, "ONLY");
101 gMC->Gspos ("0LST", 1, "ALIC", 0., 0., zLeft, idrotm[901], "ONLY");
102
103// 12 unit: PMT + divider
104 gMC->Gsvolu("0INS", "TUBE", idtmed[3], pinstart, 3);
105 z = 0;
106 for (i = 0; i < 12; i++)
107 {
108 x = 6.5 * TMath::Sin(i * angel);
109 y = 6.5 * TMath::Cos(i * angel);
110
111 phi[0] = -30 * i;
112 phi[1] = 90 - i * 30;
113 phi[2] = 90 - i * 30;
114 for (j = 0; j < 3; j++)
115 if (phi[j] < 0) phi[j] += 360;
116
117 AliMatrix (idrotm[902 + i], 90., phi[0],
118 90. + theta, phi[1],
119 theta, phi[2]);
120
121 gMC->Gspos ("0INS", i + 1, "0RST", x, y, z, idrotm[902 + i], "ONLY");
122 gMC->Gspos ("0INS", i + 13, "0LST", x, y, z, 0, "ONLY");
123 }
124
125 gMC->Gsvolu ("0PMT", "TUBE", idtmed[1], ppmt, 3);
126 x = y = 0;
127 z = -pinstart[2] + ppmt[2];
128 gMC->Gspos ("0PMT", 1, "0INS", x, y, z, 0, "ONLY");
129
130// PMT
131 // Entry window (glass)
132 gMC->Gsvolu ("0TOP", "TUBE", idtmed[6], ptop, 3);
133 z = -ppmt[2] + ptop[2];
134 gMC->Gspos ("0TOP", 1, "0PMT", 0, 0, z, 0, "ONLY");
135
136 gMC->Gsvolu ("0REG", "TUBE", idtmed[6], preg, 3);
137 z = -ppmt[2] + 2 * ptop[2] + preg[2];
138 gMC->Gspos ("0REG", 1, "0PMT", 0, 0, z, 0, "ONLY");
139
140 gMC->Gsvolu ("0DES", "TUBE", idtmed[6], pdes, 3);
141 z = -ppmt[2] + 2 * ptop[2] + preg[2];
142 gMC->Gspos ("0DES", 1, "0PMT", 0, 0, z, 0, "ONLY");
143}
144
145
146//////////////////////////////////////////////////////////////////////
147// Definition of avaible T0 materials
148//////////////////////////////////////////////////////////////////////
149void AliT0v2::CreateMaterials()
150{
f7a1cc68 151 Int_t isxfld = ((AliMagF*)TGeoGlobalMagField::Instance()->GetField())->Integ();
152 Float_t sxmgmx = ((AliMagF*)TGeoGlobalMagField::Instance()->GetField())->Max();
dc7ca31d 153
f35a7b6f 154 Double_t a, z, d, radl, absl;
155 TArrayT par;
156
dc7ca31d 157
158// Scintillator CH
159 Float_t ascin[2] = {1.01, 12.01};
160 Float_t zscin[2] = {1., 6.};
161 Float_t wscin[2] = {1., 1.};
162 Float_t denscin = 1.03;
163
164// PMT glass SiO2
165 Float_t aglass[2] = {28.0855, 15.9994};
166 Float_t zglass[2] = {14., 8.};
167 Float_t wglass[2] = { 1., 2.};
168 Float_t dglass = 2.65;
169
170// Ceramic 97.2% Al2O3 , 2.8% SiO2
171 Float_t acer[2], zcer[2];
172 Float_t wcer[2] = { 0.972, 0.028};
173 Float_t aal2o3[2] = {26.981539, 15.9994 };
174 Float_t zal2o3[2] = {13., 8.};
175 Float_t wal2o3[2] = { 2., 3.};
176 Float_t denscer = 3.6;
177
178// Brass 80% Cu, 20% Zn
179 Float_t abrass[2] = {63.546, 65.39};
180 Float_t zbrass[2] = {29., 30.};
181 Float_t wbrass[2] = { 0.8, 0.2};
182 Float_t denbrass = 8.96;
183
184//Ribber C6H12S
185 Float_t aribber[3] = {12., 1., 32.};
186 Float_t zribber[3] = { 6., 1., 16.};
187 Float_t wribber[3] = { 6., 12., 1.};
188 Float_t denribber = 0.8;
189
dc7ca31d 190
191 AliMaterial (0, "T0 Steel$", 55.850, 26., 7.87, 1.76, 999);
192 AliMaterial (1, "T0 Vacuum$", 1.e-16, 1.e-16, 1.e-16, 1.e16, 999);
193 AliMaterial (2, "T0 Air$", 14.61, 7.3, .001205, 30423., 999);
194
195 AliMixture (3, "Al2O3 $", aal2o3, zal2o3, denscer, -2, wal2o3);
196 AliMixture (4, "PMT glass $", aglass, zglass, dglass, -2, wglass);
f35a7b6f 197 TString namate;
198 gMC->GetMaterial((*fIdmate)[3], namate, a, z, d, radl, absl, par);
dc7ca31d 199 acer[0] = a;
200 zcer[0] = z;
f35a7b6f 201 gMC->GetMaterial((*fIdmate)[4], namate, a, z, d, radl, absl, par);
dc7ca31d 202 acer[1] = a;
203 zcer[1] = z;
204
205 AliMixture (5, "Scintillator$",ascin,zscin,denscin,-2,wscin);
206 AliMixture (6, "Brass $", abrass, zbrass, denbrass, 2, wbrass);
207 AliMixture (7, "Ribber $",aribber,zribber,denribber,-3,wribber);
208 AliMixture (9, "Ceramic $", acer, zcer, denscer, 2, wcer);
209
210 AliMedium (1, "T0 Air$", 2, 0, isxfld, sxmgmx, 10., .1, 1., .003, .003);
211 AliMedium (2, "Scintillator$", 5, 1, isxfld, sxmgmx, 10., .01, 1., .003, .003);
212 AliMedium (3, "Vacuum$", 1, 0, isxfld, sxmgmx, 10., .01, .1, .003, .003);
213 AliMedium (4, "Ceramic$", 9, 0, isxfld, sxmgmx, 10., .01, .1, .003, .003);
214 AliMedium (6, "Glass$", 4, 0, isxfld, sxmgmx, 10., .01, .1, .003, .003);
215 AliMedium (8, "Steel$", 0, 0, isxfld, sxmgmx, 1., .001, 1., .001, .001);
216 AliMedium (9, "Ribber $", 7, 0, isxfld, sxmgmx, 10., .01, .1, .003, .003);
217 AliMedium(11, "Brass $", 6, 0, isxfld, sxmgmx, 10., .01, .1, .003, .003);
dc7ca31d 218}
219
220
dc7ca31d 221
dc7ca31d 222//////////////////////////////////////////////////////////////////////
661663fa 223// Definition of optical properties for the Forward Multiplicity Detector
dc7ca31d 224//////////////////////////////////////////////////////////////////////
661663fa 225void AliT0v2::DefineOpticalProperties()
dc7ca31d 226{
661663fa 227// Optical properties definition.
7235aed2 228// Definition Cherenkov parameters
229 const Int_t NUMENTRIES = 32;
230
231 Float_t ppckov[NUMENTRIES] =
232 { 2.034E-9, 2.068E-9, 2.103E-9, 2.139E-9,
233 2.177E-9, 2.216E-9, 2.256E-9, 2.298E-9,
234 2.341E-9, 2.386E-9, 2.433E-9, 2.481E-9,
235 2.532E-9, 2.585E-9, 2.640E-9, 2.697E-9,
236 2.757E-9, 2.820E-9, 2.885E-9, 2.954E-9,
237 3.026E-9, 3.102E-9, 3.181E-9, 3.265E-9,
238 3.353E-9, 3.446E-9, 3.545E-9, 3.649E-9,
239 3.760E-9, 3.877E-9, 4.002E-9, 4.136E-9 };
240
241 Float_t rindex_qwarz[NUMENTRIES] =
242 { 1.458, 1.458, 1.458, 1.458, 1.458, 1.458, 1.458,
243 1.458, 1.458, 1.458, 1.458, 1.458, 1.458, 1.458,
244 1.458, 1.458, 1.458, 1.458, 1.458, 1.458, 1.458,
245 1.458, 1.458, 1.458, 1.458, 1.458, 1.458, 1.458,
246 1.458, 1.458, 1.458, 1.458 };
247
248 Float_t rindex_air[NUMENTRIES] =
249 { 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1.,
250 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1.,
251 1., 1., 1., 1. };
252
253 Float_t effic_all[NUMENTRIES] =
254 { 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1.,
255 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1.,
256 1., 1., 1., 1. };
257
258 Float_t absor_qwarz[NUMENTRIES] =
259 { 2000., 2000., 2000., 2000., 2000., 2000., 2000.,
260 2000., 2000., 2000., 2000., 2000., 2000., 2000.,
261 2000., 2000., 2000., 2000., 2000., 2000., 2000.,
262 2000., 2000., 2000., 2000., 2000., 2000., 2000.,
263 2000., 2000., 2000., 2000. };
264
265 Float_t absor_air[NUMENTRIES] =
266 { 200., 200., 200., 200., 200., 200., 200.,
267 200., 200., 200., 200., 200., 200., 200.,
268 200., 200., 200., 200., 200., 200., 200.,
269 200., 200., 200., 200., 200., 200., 200.,
270 200., 200., 200., 200. };
271
272 Int_t *idtmed = fIdtmed->GetArray();
273
274 gMC->SetCerenkov (idtmed[6], NUMENTRIES, ppckov, absor_qwarz, effic_all, rindex_qwarz);
275 gMC->SetCerenkov (idtmed[1], NUMENTRIES, ppckov, absor_air, effic_all, rindex_air);
661663fa 276}
dc7ca31d 277
661663fa 278//////////////////////////////////////////////////////////////////////
279// Initialises version 2 of the Forward Multiplicity Detector
280//////////////////////////////////////////////////////////////////////
281void AliT0v2::Init()
282{
283 AliT0::Init();
284 fIdSens1 = gMC->VolId ("0REG");
dc7ca31d 285 printf ("*** T0 version 2 initialized ***\n");
286}
287
288
289//////////////////////////////////////////////////////////////////////
290// Called for every step in the T0 Detector
291//////////////////////////////////////////////////////////////////////
292void AliT0v2::StepManager()
293{
294 Int_t id;
295 Int_t copy;
296// Int_t copy1;
297 Float_t xyz[3];
298 Float_t XYZ[3];
299 Float_t hitPhoton[6];
300 static Float_t hits[7];
301 static Float_t edep;
302 static Int_t vol[2];
303 TLorentzVector pos;
304 TLorentzVector mom;
305
306
307 if(!gMC->IsTrackAlive()) return; // particle has disappeared
308
309// TGeant3 *g3 = (TGeant3*) gMC;
310// g3->Gpcxyz();
311
312 TClonesArray &lhits = *fHits;
313
314
315///////////////////////////////////////////////
316// If particles is photon then ...
317
318 if (gMC->TrackPid() == 50000050)
319 {
320 id = gMC->CurrentVolID(copy);
321
322 // Check the sensetive volume
323 if (id == fIdSens1)
324 {
325 if (gMC->IsTrackEntering())
326 {
327 gMC->CurrentVolOffID(2,copy);
328 if (copy < 13)
329 {
330 vol[0] = RIGHT_ARRAY;
331 vol[1] = copy;
332 }
333 else
334 {
335 vol[0] = LEFT_ARRAY;
336 vol[1] = copy - 12;
337 }
338
339 gMC->TrackPosition(pos);
340 gMC->TrackMomentum(mom);
341 XYZ[0] = pos[0];
342 XYZ[1] = pos[1];
343 XYZ[2] = pos[2];
344 gMC->Gmtod (XYZ, xyz, 1);
345
346 hitPhoton[0] = sqrt (xyz[0] * xyz[0] + xyz[1] * xyz[1]);
347 hitPhoton[1] = mom[0];
348 hitPhoton[2] = mom[1];
349 hitPhoton[3] = mom[2];
350 hitPhoton[4] = 1e9 * gMC->TrackTime();
351 hitPhoton[5] = 1e9 * gMC->Etot();
352
353 AddHitPhoton (gAlice->GetMCApp()->GetCurrentTrackNumber(), vol, hitPhoton);
354 }
355 gMC->StopTrack();
356 }
357 else
358 if (id == gMC->VolId ("0DES")) gMC->StopTrack();
359 }
360
361// end photon particalary
362///////////////////////////////////////////////
363
364
365///////////////////////////////////////////////
366// If particles is charge then ...
367
368 // Float_t charge = gMC->TrackCharge();
369 // if(TMath::Abs(charge) <= 0.) return;
370 id = gMC->CurrentVolID(copy);
371
372
373 // printf("gMC->ckine->ipart %d",gMC->ckine->ipart);
374 // Check the sensetive volume
375 if(id==gMC->VolId("0TOP") ) {
376 if(gMC->IsTrackEntering()) {
377 gMC->CurrentVolOffID(2,copy);
378 if (copy < 13)
379 {
380 vol[0] = RIGHT_ARRAY;
381 vol[1] = copy;
382 }
383 else
384 {
385 vol[0] = LEFT_ARRAY;
386 vol[1] = copy - 12;
387 }
388
389 gMC->TrackPosition(pos);
390 hits[0] = pos[0];
391 hits[1] = pos[1];
392 hits[2] = pos[2];
393 Float_t etot = gMC->Etot();
394 hits[4] = etot;
395 Int_t part = gMC->TrackPid();
396 hits[5] = part;
397 Float_t ttime = gMC->TrackTime();
398 hits[6] = ttime*1e9;
399 edep = 0;
400 }
401 if(gMC->IsTrackInside()) {
402 Float_t de = gMC->Edep();
403 edep = edep + de;
404 // printf ("E deposition %f\n",edep);
405 // for (i=0; i<=6; i++){
406 // printf(" HITS on T0 inside %f\n",hits[i]); }
407 }
408 if(gMC->IsTrackExiting()) {
409 Float_t de = gMC->Edep();
410 edep = edep + de;
411 hits[3] = edep * 1e3;
412
413 // for (i=0; i<=6; i++){
414 // printf(" HITS on T0 Exit %f\n",hits[i]); }
415 //for (i=0; i<=1; i++) { printf("T0 vol %d\n",vol[i]);}
416
417 new(lhits[fNhits++]) AliT0hit(fIshunt,gAlice->GetMCApp()->GetCurrentTrackNumber(),vol,hits);
418 }
419 }
420
421// end charge particles particalary
422///////////////////////////////////////////////
423
424}