Major upgrade of AliRoot code
[u/mrichter/AliRoot.git] / TRD / AliTRD.cxx
CommitLineData
4c039060 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$Log$
793ff80c 18
19Revision 1.17.2.6 2000/10/15 23:29:08 cblume
20Introduced more detailed geometry for the display
21
22Revision 1.17.2.5 2000/10/06 16:49:46 cblume
23Made Getters const
24
25Revision 1.17.2.4 2000/10/04 16:34:57 cblume
26Replace include files by forward declarations
27
28Revision 1.17.2.3 2000/09/22 14:45:17 cblume
29Included changes for the tracking
30
31Revision 1.17.2.2 2000/09/18 13:25:13 cblume
32Included LoadPoints() method to display the TR photons
33
34Revision 1.22 2000/10/02 21:28:19 fca
35Removal of useless dependecies via forward declarations
36
37Revision 1.21 2000/06/09 11:10:07 cblume
38Compiler warnings and coding conventions, next round
39
40Revision 1.20 2000/06/08 18:32:57 cblume
41Make code compliant to coding conventions
42
43Revision 1.19 2000/06/07 16:25:37 cblume
44Try to remove compiler warnings on Sun and HP
45
46Revision 1.18 2000/05/08 16:17:27 cblume
47Merge TRD-develop
48
94de3818 49Revision 1.21 2000/06/09 11:10:07 cblume
50Compiler warnings and coding conventions, next round
51
dd9a6ee3 52Revision 1.20 2000/06/08 18:32:57 cblume
53Make code compliant to coding conventions
54
8230f242 55Revision 1.19 2000/06/07 16:25:37 cblume
56Try to remove compiler warnings on Sun and HP
57
9d0b222b 58Revision 1.18 2000/05/08 16:17:27 cblume
59Merge TRD-develop
60
6f1e466d 61Revision 1.17.2.1 2000/05/08 14:28:59 cblume
62Introduced SetPHOShole() and SetRICHhole(). AliTRDrecPoint container is now a TObjArray
63
64Revision 1.17 2000/02/28 19:10:26 cblume
65Include the new TRD classes
66
851d3db9 67Revision 1.16.2.2 2000/02/28 17:53:24 cblume
68Introduce TRD geometry classes
69
70Revision 1.16.2.1 2000/02/28 17:04:19 cblume
71Include functions and data members for AliTRDrecPoint
72
73Revision 1.16 2000/01/19 17:17:35 fca
74Introducing a list of lists of hits -- more hits allowed for detector now
75
1cedd08a 76Revision 1.15 1999/11/02 17:04:25 fca
77Small syntax change for HP compiler
78
94c641ff 79Revision 1.14 1999/11/02 16:57:02 fca
80Avoid non ansi warnings on HP compilers
81
8459a454 82Revision 1.13 1999/11/02 16:35:56 fca
83New version of TRD introduced
84
5c7f4665 85Revision 1.12 1999/11/01 20:41:51 fca
86Added protections against using the wrong version of FRAME
87
ab76897d 88Revision 1.11 1999/09/29 09:24:34 fca
89Introduction of the Copyright and cvs Log
90
4c039060 91*/
92
fe4da5cc 93///////////////////////////////////////////////////////////////////////////////
94// //
95// Transition Radiation Detector //
96// This class contains the basic functions for the Transition Radiation //
6f1e466d 97// Detector. //
fe4da5cc 98// //
99///////////////////////////////////////////////////////////////////////////////
100
5c7f4665 101#include <stdlib.h>
102
fe4da5cc 103#include <TMath.h>
fe4da5cc 104#include <TNode.h>
94de3818 105#include <TGeometry.h>
793ff80c 106#include <TTree.h>
107#include <TPGON.h>
fe4da5cc 108
fe4da5cc 109#include "AliRun.h"
d3f347ff 110#include "AliConst.h"
793ff80c 111#include "AliDigit.h"
112#include "AliMagF.h"
113#include "AliMC.h"
114
115#include "AliTRD.h"
116#include "AliTRDhit.h"
117#include "AliTRDpoints.h"
118#include "AliTRDdigit.h"
851d3db9 119#include "AliTRDdigitizer.h"
120#include "AliTRDclusterizer.h"
121#include "AliTRDgeometryHole.h"
122#include "AliTRDgeometryFull.h"
123#include "AliTRDrecPoint.h"
793ff80c 124
fe4da5cc 125ClassImp(AliTRD)
126
127//_____________________________________________________________________________
128AliTRD::AliTRD()
129{
130 //
131 // Default constructor
132 //
82bbf98a 133
d3f347ff 134 fIshunt = 0;
135 fGasMix = 0;
99d5402e 136 fHits = 0;
137 fDigits = 0;
5c7f4665 138
851d3db9 139 fRecPoints = 0;
140 fNRecPoints = 0;
5c7f4665 141
851d3db9 142 fGeometry = 0;
82bbf98a 143
793ff80c 144 fGasDensity = 0;
145 fFoilDensity = 0;
146
147 fDrawTR = 0;
148 fDisplayType = 0;
149
fe4da5cc 150}
151
152//_____________________________________________________________________________
153AliTRD::AliTRD(const char *name, const char *title)
154 : AliDetector(name,title)
155{
156 //
157 // Standard constructor for the TRD
158 //
159
5c7f4665 160 // Check that FRAME is there otherwise we have no place where to
161 // put TRD
8230f242 162 AliModule* frame = gAlice->GetModule("FRAME");
163 if (!frame) {
5c7f4665 164 Error("Ctor","TRD needs FRAME to be present\n");
165 exit(1);
166 }
167
168 // Define the TRD geometry according to the FRAME geometry
8230f242 169 if (frame->IsVersion() == 0) {
851d3db9 170 // Geometry with hole
171 fGeometry = new AliTRDgeometryHole();
172 }
8230f242 173 else if (frame->IsVersion() == 1) {
851d3db9 174 // Geometry without hole
175 fGeometry = new AliTRDgeometryFull();
176 }
177 else {
178 Error("Ctor","Could not find valid FRAME version\n");
179 exit(1);
180 }
5c7f4665 181
fe4da5cc 182 // Allocate the hit array
793ff80c 183 fHits = new TClonesArray("AliTRDhit" ,405);
1cedd08a 184 gAlice->AddHitList(fHits);
99d5402e 185
186 // Allocate the digits array
793ff80c 187 fDigits = 0;
5c7f4665 188
851d3db9 189 // Allocate the rec point array
793ff80c 190 fRecPoints = new TObjArray(400);
191 fNRecPoints = 0;
99d5402e 192
793ff80c 193 fIshunt = 0;
194 fGasMix = 0;
195
196 fGasDensity = 0;
197 fFoilDensity = 0;
198
199 fDrawTR = 0;
200 fDisplayType = 0;
82bbf98a 201
fe4da5cc 202 SetMarkerColor(kWhite);
82bbf98a 203
fe4da5cc 204}
99d5402e 205
206//_____________________________________________________________________________
dd9a6ee3 207AliTRD::AliTRD(const AliTRD &trd)
8230f242 208{
209 //
210 // Copy constructor
211 //
212
dd9a6ee3 213 ((AliTRD &) trd).Copy(*this);
8230f242 214
215}
216
217//_____________________________________________________________________________
99d5402e 218AliTRD::~AliTRD()
219{
220 //
221 // TRD destructor
222 //
223
224 fIshunt = 0;
225
851d3db9 226 delete fGeometry;
99d5402e 227 delete fHits;
851d3db9 228 delete fRecPoints;
5c7f4665 229
230}
231
232//_____________________________________________________________________________
793ff80c 233void AliTRD::AddRecPoint(Float_t *pos, Int_t *digits, Int_t det, Float_t amp
234 , Int_t *tracks)
5c7f4665 235{
236 //
851d3db9 237 // Add a reconstructed point for the TRD
238 //
793ff80c 239
8230f242 240 AliTRDrecPoint *recPoint = new AliTRDrecPoint();
851d3db9 241 TVector3 posVec(pos[0],pos[1],pos[2]);
8230f242 242 recPoint->SetLocalPosition(posVec);
243 recPoint->SetDetector(det);
244 recPoint->SetEnergy(amp);
851d3db9 245 for (Int_t iDigit = 0; iDigit < 3; iDigit++) {
8230f242 246 recPoint->AddDigit(digits[iDigit]);
851d3db9 247 }
99d5402e 248
793ff80c 249 recPoint->AddTrackIndex(tracks);
250
251 recPoint->SetTrackingYZ(0.,0.); // variance values set inside
8230f242 252 fRecPoints->Add(recPoint);
6f1e466d 253
99d5402e 254}
255
256//_____________________________________________________________________________
9d0b222b 257void AliTRD::AddDigit(Int_t *digits, Int_t *amp)
99d5402e 258{
259 //
260 // Add a digit for the TRD
261 //
262
263 TClonesArray &ldigits = *fDigits;
9d0b222b 264 new(ldigits[fNdigits++]) AliTRDdigit(kFALSE,digits,amp);
99d5402e 265
266}
267
fe4da5cc 268//_____________________________________________________________________________
793ff80c 269void AliTRD::AddHit(Int_t track, Int_t det, Float_t *hits, Int_t q)
fe4da5cc 270{
271 //
272 // Add a hit for the TRD
273 //
82bbf98a 274
fe4da5cc 275 TClonesArray &lhits = *fHits;
793ff80c 276 new(lhits[fNhits++]) AliTRDhit(fIshunt,track,det,hits,q);
82bbf98a 277
fe4da5cc 278}
279
280//_____________________________________________________________________________
281void AliTRD::BuildGeometry()
282{
283 //
284 // Create the ROOT TNode geometry for the TRD
285 //
82bbf98a 286
8230f242 287 TNode *node, *top;
fe4da5cc 288 TPGON *pgon;
793ff80c 289
290 Float_t rmin, rmax;
291 Float_t zmax1, zmax2;
292
fe4da5cc 293 const Int_t kColorTRD = 46;
d3f347ff 294
fe4da5cc 295 // Find the top node alice
8230f242 296 top = gAlice->GetGeometry()->GetNode("alice");
d3f347ff 297
793ff80c 298 switch (fDisplayType) {
299
300 case 0:
301
302 pgon = new TPGON("S_TRD","TRD","void",0,360,AliTRDgeometry::Nsect(),4);
303 rmin = AliTRDgeometry::Rmin();
304 rmax = AliTRDgeometry::Rmax();
305 pgon->DefineSection(0,-AliTRDgeometry::Zmax1(),rmax,rmax);
306 pgon->DefineSection(1,-AliTRDgeometry::Zmax2(),rmin,rmax);
307 pgon->DefineSection(2, AliTRDgeometry::Zmax2(),rmin,rmax);
308 pgon->DefineSection(3, AliTRDgeometry::Zmax1(),rmax,rmax);
309 top->cd();
310 node = new TNode("TRD","TRD","S_TRD",0,0,0,"");
311 node->SetLineColor(kColorTRD);
312 fNodes->Add(node);
313
314 break;
315
316 case 1:
317
318 Float_t slope = (AliTRDgeometry::Zmax1() - AliTRDgeometry::Zmax2())
319 / (AliTRDgeometry::Rmax() - AliTRDgeometry::Rmin());
320
321 rmin = AliTRDgeometry::Rmin() + AliTRDgeometry::RaThick();
322 rmax = rmin + AliTRDgeometry::DrThick();
323 zmax2 = AliTRDgeometry::Zmax2() + slope * AliTRDgeometry::RaThick();
324 zmax1 = zmax2 + slope * AliTRDgeometry::DrThick();
325 Char_t name[7];
326
327 for (Int_t iPlan = 0; iPlan < AliTRDgeometry::Nplan(); iPlan++) {
328
329 sprintf(name,"S_TRD%d",iPlan);
330 pgon = new TPGON(name,"TRD","void",0,360,AliTRDgeometry::Nsect(),4);
331 pgon->DefineSection(0,-zmax1,rmax,rmax);
332 pgon->DefineSection(1,-zmax2,rmin,rmax);
333 pgon->DefineSection(2, zmax2,rmin,rmax);
334 pgon->DefineSection(3, zmax1,rmax,rmax);
335 top->cd();
336 node = new TNode("TRD","TRD",name,0,0,0,"");
337 node->SetLineColor(kColorTRD);
338 fNodes->Add(node);
339
340 Float_t height = AliTRDgeometry::Cheight() + AliTRDgeometry::Cspace();
341 rmin = rmin + height;
342 rmax = rmax + height;
343 zmax1 = zmax1 + slope * height;
344 zmax2 = zmax2 + slope * height;
345
346 }
347
348 break;
349
350 };
d3f347ff 351
fe4da5cc 352}
353
354//_____________________________________________________________________________
dd9a6ee3 355void AliTRD::Copy(TObject &trd)
8230f242 356{
357 //
358 // Copy function
359 //
360
793ff80c 361 ((AliTRD &) trd).fGasMix = fGasMix;
362 ((AliTRD &) trd).fGeometry = fGeometry;
363 ((AliTRD &) trd).fRecPoints = fRecPoints;
364 ((AliTRD &) trd).fNRecPoints = fNRecPoints;
365 ((AliTRD &) trd).fGasDensity = fGasDensity;
366 ((AliTRD &) trd).fFoilDensity = fFoilDensity;
367 ((AliTRD &) trd).fDrawTR = fDrawTR;
368 ((AliTRD &) trd).fDisplayType = fDisplayType;
8230f242 369
370 //AliDetector::Copy(trd);
371
372}
373
374//_____________________________________________________________________________
82bbf98a 375void AliTRD::CreateGeometry()
fe4da5cc 376{
82bbf98a 377 //
378 // Creates the volumes for the TRD chambers
379 //
82bbf98a 380
381 // Check that FRAME is there otherwise we have no place where to put the TRD
8230f242 382 AliModule* frame = gAlice->GetModule("FRAME");
383 if (!frame) {
851d3db9 384 printf(" The TRD needs the FRAME to be defined first\n");
385 return;
82bbf98a 386 }
d3f347ff 387
851d3db9 388 fGeometry->CreateGeometry(fIdtmed->GetArray() - 1299);
5c7f4665 389
82bbf98a 390}
391
392//_____________________________________________________________________________
393void AliTRD::CreateMaterials()
394{
fe4da5cc 395 //
396 // Create the materials for the TRD
397 // Origin Y.Foka
398 //
399
8230f242 400 Int_t isxfld = gAlice->Field()->Integ();
401 Float_t sxmgmx = gAlice->Field()->Max();
fe4da5cc 402
d3f347ff 403 // For polyethilene (CH2)
404 Float_t ape[2] = { 12., 1. };
405 Float_t zpe[2] = { 6., 1. };
406 Float_t wpe[2] = { 1., 2. };
407 Float_t dpe = 0.95;
408
409 // For mylar (C5H4O2)
410 Float_t amy[3] = { 12., 1., 16. };
411 Float_t zmy[3] = { 6., 1., 8. };
412 Float_t wmy[3] = { 5., 4., 2. };
fe4da5cc 413 Float_t dmy = 1.39;
d3f347ff 414
415 // For CO2
416 Float_t aco[2] = { 12., 16. };
417 Float_t zco[2] = { 6., 8. };
418 Float_t wco[2] = { 1., 2. };
419 Float_t dco = 0.001977;
420
421 // For water
422 Float_t awa[2] = { 1., 16. };
423 Float_t zwa[2] = { 1., 8. };
424 Float_t wwa[2] = { 2., 1. };
425 Float_t dwa = 1.0;
426
427 // For isobutane (C4H10)
428 Float_t ais[2] = { 12., 1. };
429 Float_t zis[2] = { 6., 1. };
430 Float_t wis[2] = { 4., 10. };
431 Float_t dis = 0.00267;
432
433 // For Xe/CO2-gas-mixture
434 // Xe-content of the Xe/CO2-mixture (90% / 10%)
435 Float_t fxc = .90;
436 // Xe-content of the Xe/Isobutane-mixture (97% / 3%)
437 Float_t fxi = .97;
fe4da5cc 438 Float_t dxe = .005858;
439
d3f347ff 440 // General tracking parameter
fe4da5cc 441 Float_t tmaxfd = -10.;
442 Float_t stemax = -1e10;
d3f347ff 443 Float_t deemax = -0.1;
444 Float_t epsil = 1e-4;
445 Float_t stmin = -0.001;
fe4da5cc 446
447 Float_t absl, radl, d, buf[1];
793ff80c 448 Float_t agm[2], zgm[2], wgm[2];
449 Float_t dgm1, dgm2;
d3f347ff 450 Int_t nbuf;
fe4da5cc 451
d3f347ff 452 //////////////////////////////////////////////////////////////////////////
fe4da5cc 453 // Define Materials
d3f347ff 454 //////////////////////////////////////////////////////////////////////////
455
456 AliMaterial( 1, "Al $", 26.98, 13.0, 2.7 , 8.9 , 37.2);
457 AliMaterial( 2, "Air$", 14.61, 7.3, 0.001205, 30420.0 , 67500.0);
458 AliMaterial( 4, "Xe $", 131.29, 54.0, dxe , 1447.59, 0.0);
459 AliMaterial( 5, "Cu $", 63.54, 29.0, 8.96 , 1.43, 14.8);
460 AliMaterial( 6, "C $", 12.01, 6.0, 2.265 , 18.8 , 74.4);
461 AliMaterial(12, "G10$", 20.00, 10.0, 1.7 , 19.4 , 999.0);
462
463 // Mixtures
464 AliMixture(3, "Polyethilene$", ape, zpe, dpe, -2, wpe);
465 AliMixture(7, "Mylar$", amy, zmy, dmy, -3, wmy);
466 AliMixture(8, "CO2$", aco, zco, dco, -2, wco);
467 AliMixture(9, "Isobutane$", ais, zis, dis, -2, wis);
82bbf98a 468 AliMixture(13,"Water$", awa, zwa, dwa, -2, wwa);
d3f347ff 469
470 // Gas mixtures
82bbf98a 471 Char_t namate[21];
d3f347ff 472 // Xe/CO2-mixture
473 // Get properties of Xe
cfce8870 474 gMC->Gfmate((*fIdmate)[4], namate, agm[0], zgm[0], d, radl, absl, buf, nbuf);
d3f347ff 475 // Get properties of CO2
cfce8870 476 gMC->Gfmate((*fIdmate)[8], namate, agm[1], zgm[1], d, radl, absl, buf, nbuf);
d3f347ff 477 // Create gas mixture
478 wgm[0] = fxc;
479 wgm[1] = 1. - fxc;
793ff80c 480 dgm1 = wgm[0] * dxe + wgm[1] * dco;
481 AliMixture(10, "Gas mixture 1$", agm, zgm, dgm1, 2, wgm);
d3f347ff 482 // Xe/Isobutane-mixture
483 // Get properties of Xe
cfce8870 484 gMC->Gfmate((*fIdmate)[4], namate, agm[0], zgm[0], d, radl, absl, buf, nbuf);
d3f347ff 485 // Get properties of Isobutane
cfce8870 486 gMC->Gfmate((*fIdmate)[9], namate, agm[1], zgm[1], d, radl, absl, buf, nbuf);
d3f347ff 487 // Create gas mixture
488 wgm[0] = fxi;
489 wgm[1] = 1. - fxi;
793ff80c 490 dgm2 = wgm[0] * dxe + wgm[1] * dis;
491 AliMixture(11, "Gas mixture 2$", agm, zgm, dgm2, 2, wgm);
d3f347ff 492
493 //////////////////////////////////////////////////////////////////////////
fe4da5cc 494 // Tracking Media Parameters
d3f347ff 495 //////////////////////////////////////////////////////////////////////////
496
497 // Al Frame
8230f242 498 AliMedium(1, "Al Frame$", 1, 0, isxfld, sxmgmx
d3f347ff 499 , tmaxfd, stemax, deemax, epsil, stmin);
500 // Air
8230f242 501 AliMedium(2, "Air$", 2, 0, isxfld, sxmgmx
d3f347ff 502 , tmaxfd, stemax, deemax, epsil, stmin);
503 // Polyethilene
8230f242 504 AliMedium(3, "Radiator$", 3, 0, isxfld, sxmgmx
d3f347ff 505 , tmaxfd, stemax, deemax, epsil, stmin);
506 // Xe
8230f242 507 AliMedium(4, "Xe$", 4, 1, isxfld, sxmgmx
d3f347ff 508 , tmaxfd, stemax, deemax, epsil, stmin);
509 // Cu pads
8230f242 510 AliMedium(5, "Padplane$", 5, 1, isxfld, sxmgmx
d3f347ff 511 , tmaxfd, stemax, deemax, epsil, stmin);
512 // Fee + cables
8230f242 513 AliMedium(6, "Readout$", 1, 0, isxfld, sxmgmx
d3f347ff 514 , tmaxfd, stemax, deemax, epsil, stmin);
515 // C frame
8230f242 516 AliMedium(7, "C Frame$", 6, 0, isxfld, sxmgmx
d3f347ff 517 , tmaxfd, stemax, deemax, epsil, stmin);
518 // Mylar foils
8230f242 519 AliMedium(8, "Mylar$", 7, 0, isxfld, sxmgmx
d3f347ff 520 , tmaxfd, stemax, deemax, epsil, stmin);
521 if (fGasMix == 1) {
522 // Gas-mixture (Xe/CO2)
8230f242 523 AliMedium(9, "Gas-mix$", 10, 1, isxfld, sxmgmx
d3f347ff 524 , tmaxfd, stemax, deemax, epsil, stmin);
525 }
526 else {
527 // Gas-mixture (Xe/Isobutane)
8230f242 528 AliMedium(9, "Gas-mix$", 11, 1, isxfld, sxmgmx
d3f347ff 529 , tmaxfd, stemax, deemax, epsil, stmin);
530 }
531 // Nomex-honeycomb (use carbon for the time being)
8230f242 532 AliMedium(10, "Nomex$", 6, 0, isxfld, sxmgmx
d3f347ff 533 , tmaxfd, stemax, deemax, epsil, stmin);
534 // Kapton foils (use Mylar for the time being)
8230f242 535 AliMedium(11, "Kapton$", 7, 0, isxfld, sxmgmx
d3f347ff 536 , tmaxfd, stemax, deemax, epsil, stmin);
537 // Gas-filling of the radiator
8230f242 538 AliMedium(12, "CO2$", 8, 0, isxfld, sxmgmx
d3f347ff 539 , tmaxfd, stemax, deemax, epsil, stmin);
540 // G10-plates
8230f242 541 AliMedium(13, "G10-plates$",12, 0, isxfld, sxmgmx
d3f347ff 542 , tmaxfd, stemax, deemax, epsil, stmin);
543 // Cooling water
8230f242 544 AliMedium(14, "Water$", 13, 0, isxfld, sxmgmx
d3f347ff 545 , tmaxfd, stemax, deemax, epsil, stmin);
546
793ff80c 547 // Save the density values for the TRD absorbtion
548 fFoilDensity = dmy;
549 if (fGasMix == 1)
550 fGasDensity = dgm1;
551 else
552 fGasDensity = dgm2;
553
fe4da5cc 554}
555
556//_____________________________________________________________________________
82bbf98a 557void AliTRD::DrawModule()
558{
559 //
560 // Draw a shaded view of the Transition Radiation Detector version 0
561 //
562
563 // Set everything unseen
564 gMC->Gsatt("*" ,"SEEN",-1);
565
566 // Set ALIC mother transparent
567 gMC->Gsatt("ALIC","SEEN", 0);
568
569 // Set the volumes visible
851d3db9 570 if (fGeometry->IsVersion() == 0) {
5c7f4665 571 gMC->Gsatt("B071","SEEN", 0);
572 gMC->Gsatt("B074","SEEN", 0);
573 gMC->Gsatt("B075","SEEN", 0);
574 gMC->Gsatt("B077","SEEN", 0);
575 gMC->Gsatt("BTR1","SEEN", 0);
576 gMC->Gsatt("BTR2","SEEN", 0);
577 gMC->Gsatt("BTR3","SEEN", 0);
578 gMC->Gsatt("TRD1","SEEN", 0);
579 gMC->Gsatt("TRD2","SEEN", 0);
580 gMC->Gsatt("TRD3","SEEN", 0);
581 }
582 else {
583 gMC->Gsatt("B071","SEEN", 0);
584 gMC->Gsatt("B074","SEEN", 0);
585 gMC->Gsatt("B075","SEEN", 0);
586 gMC->Gsatt("B077","SEEN", 0);
587 gMC->Gsatt("BTR1","SEEN", 0);
588 gMC->Gsatt("BTR2","SEEN", 0);
589 gMC->Gsatt("BTR3","SEEN", 0);
590 gMC->Gsatt("TRD1","SEEN", 0);
6f1e466d 591 if (fGeometry->GetPHOShole())
592 gMC->Gsatt("TRD2","SEEN", 0);
593 if (fGeometry->GetRICHhole())
594 gMC->Gsatt("TRD3","SEEN", 0);
5c7f4665 595 }
82bbf98a 596 gMC->Gsatt("UCII","SEEN", 0);
597 gMC->Gsatt("UCIM","SEEN", 0);
598 gMC->Gsatt("UCIO","SEEN", 0);
599 gMC->Gsatt("UL02","SEEN", 1);
600 gMC->Gsatt("UL05","SEEN", 1);
601 gMC->Gsatt("UL06","SEEN", 1);
602
603 gMC->Gdopt("hide", "on");
604 gMC->Gdopt("shad", "on");
605 gMC->Gsatt("*", "fill", 7);
606 gMC->SetClipBox(".");
607 gMC->SetClipBox("*", 0, 2000, -2000, 2000, -2000, 2000);
608 gMC->DefaultRange();
609 gMC->Gdraw("alic", 40, 30, 0, 12, 9.4, .021, .021);
610 gMC->Gdhead(1111, "Transition Radiation Detector");
611 gMC->Gdman(18, 4, "MAN");
612
613}
614
615//_____________________________________________________________________________
fe4da5cc 616Int_t AliTRD::DistancetoPrimitive(Int_t , Int_t )
617{
618 //
619 // Distance between the mouse and the TRD detector on the screen
620 // Dummy routine
82bbf98a 621
622 return 9999;
623
fe4da5cc 624}
625
626//_____________________________________________________________________________
627void AliTRD::Init()
628{
629 //
851d3db9 630 // Initialize the TRD detector after the geometry has been created
fe4da5cc 631 //
82bbf98a 632
5c7f4665 633 Int_t i;
851d3db9 634
5c7f4665 635 printf("\n");
851d3db9 636 for (i = 0; i < 35; i++) printf("*");
5c7f4665 637 printf(" TRD_INIT ");
851d3db9 638 for (i = 0; i < 35; i++) printf("*");
639 printf("\n");
5c7f4665 640 printf("\n");
5c7f4665 641
851d3db9 642 if (fGeometry->IsVersion() == 0) {
6f1e466d 643 printf(" Geometry for spaceframe with holes initialized.\n\n");
851d3db9 644 }
645 else if (fGeometry->IsVersion() == 1) {
6f1e466d 646 printf(" Geometry for spaceframe without holes initialized.\n");
647 if (fGeometry->GetPHOShole())
648 printf(" Leave space in front of PHOS free.\n");
649 if (fGeometry->GetRICHhole())
650 printf(" Leave space in front of RICH free.\n");
651 printf("\n");
5c7f4665 652 }
653
851d3db9 654 if (fGasMix == 1)
655 printf(" Gas Mixture: 90%% Xe + 10%% CO2\n\n");
656 else
657 printf(" Gas Mixture: 97%% Xe + 3%% Isobutane\n\n");
5c7f4665 658
659}
660
661//_____________________________________________________________________________
793ff80c 662void AliTRD::LoadPoints(Int_t track)
663{
664 //
665 // Store x, y, z of all hits in memory.
666 // Hit originating from TR photons are given a different color
667 //
668
669 if (!fDrawTR) {
670 AliDetector::LoadPoints(track);
671 return;
672 }
673
674 if (fHits == 0) return;
675
676 Int_t nhits = fHits->GetEntriesFast();
677 if (nhits == 0) return;
678
679 Int_t tracks = gAlice->GetNtrack();
680 if (fPoints == 0) fPoints = new TObjArray(tracks);
681
682 AliTRDhit *ahit;
683
684 Int_t *ntrkE = new Int_t[tracks];
685 Int_t *ntrkT = new Int_t[tracks];
686 Int_t *limiE = new Int_t[tracks];
687 Int_t *limiT = new Int_t[tracks];
688 Float_t **coorE = new Float_t*[tracks];
689 Float_t **coorT = new Float_t*[tracks];
690 for(Int_t i = 0; i < tracks; i++) {
691 ntrkE[i] = 0;
692 ntrkT[i] = 0;
693 coorE[i] = 0;
694 coorT[i] = 0;
695 limiE[i] = 0;
696 limiT[i] = 0;
697 }
698
699 AliTRDpoints *points = 0;
700 Float_t *fp = 0;
701 Int_t trk;
702 Int_t chunk = nhits / 4 + 1;
703
704 // Loop over all the hits and store their position
705 for (Int_t hit = 0; hit < nhits; hit++) {
706
707 ahit = (AliTRDhit *) fHits->UncheckedAt(hit);
708
709 // dEdx hits
710 if (ahit->GetCharge() >= 0) {
711
712 trk = ahit->GetTrack();
713 if (ntrkE[trk] == limiE[trk]) {
714 // Initialise a new track
715 fp = new Float_t[3*(limiE[trk]+chunk)];
716 if (coorE[trk]) {
717 memcpy(fp,coorE[trk],sizeof(Float_t)*3*limiE[trk]);
718 delete [] coorE[trk];
719 }
720 limiE[trk] += chunk;
721 coorE[trk] = fp;
722 }
723 else {
724 fp = coorE[trk];
725 }
726 fp[3*ntrkE[trk] ] = ahit->X();
727 fp[3*ntrkE[trk]+1] = ahit->Y();
728 fp[3*ntrkE[trk]+2] = ahit->Z();
729 ntrkE[trk]++;
730
731 }
732 // TR photon hits
733 else {
734
735 trk = ahit->GetTrack();
736 if (ntrkT[trk] == limiT[trk]) {
737 // Initialise a new track
738 fp = new Float_t[3*(limiT[trk]+chunk)];
739 if (coorT[trk]) {
740 memcpy(fp,coorT[trk],sizeof(Float_t)*3*limiT[trk]);
741 delete [] coorT[trk];
742 }
743 limiT[trk] += chunk;
744 coorT[trk] = fp;
745 }
746 else {
747 fp = coorT[trk];
748 }
749 fp[3*ntrkT[trk] ] = ahit->X();
750 fp[3*ntrkT[trk]+1] = ahit->Y();
751 fp[3*ntrkT[trk]+2] = ahit->Z();
752 ntrkT[trk]++;
753
754 }
755
756 }
757
758 for (trk = 0; trk < tracks; ++trk) {
759
760 if (ntrkE[trk] || ntrkT[trk]) {
761
762 points = new AliTRDpoints();
763 points->SetDetector(this);
764 points->SetParticle(trk);
765
766 // Set the dEdx points
767 if (ntrkE[trk]) {
768 points->SetMarkerColor(GetMarkerColor());
769 points->SetMarkerSize(GetMarkerSize());
770 points->SetPolyMarker(ntrkE[trk],coorE[trk],GetMarkerStyle());
771 delete [] coorE[trk];
772 coorE[trk] = 0;
773 }
774
775 // Set the TR photon points
776 if (ntrkT[trk]) {
777 points->SetTRpoints(ntrkT[trk],coorT[trk]);
778 delete [] coorT[trk];
779 coorT[trk] = 0;
780 }
781
782 fPoints->AddAt(points,trk);
783
784 }
785
786 }
787
788 delete [] coorE;
789 delete [] coorT;
790 delete [] ntrkE;
791 delete [] ntrkT;
792 delete [] limiE;
793 delete [] limiT;
794
795}
796
797//_____________________________________________________________________________
5c7f4665 798void AliTRD::MakeBranch(Option_t* option)
799{
800 //
801 // Create Tree branches for the TRD digits and cluster.
802 //
803
793ff80c 804 //Int_t buffersize = 4000;
805 //Char_t branchname[15];
5c7f4665 806
807 AliDetector::MakeBranch(option);
808
793ff80c 809 //Char_t *r = strstr(option,"R");
810 //sprintf(branchname,"%srecPoints",GetName());
811 //if (fRecPoints && gAlice->TreeR() && r) {
812 // gAlice->TreeR()->Branch(branchname,fRecPoints->IsA()->GetName()
813 // ,&fRecPoints,buffersize,0);
814 // printf("* AliTRD::MakeBranch * Making Branch %s for points in TreeR\n",branchname);
815 //}
5c7f4665 816
851d3db9 817}
818
819//_____________________________________________________________________________
820void AliTRD::ResetRecPoints()
821{
822 //
823 // Reset number of reconstructed points and the point array
824 //
825
793ff80c 826 if(fRecPoints) {
827 fNRecPoints = 0;
828 Int_t nentr = fRecPoints->GetEntriesFast();
829 for(Int_t i = 0; i < nentr; i++) delete fRecPoints->RemoveAt(i);
830 }
5c7f4665 831
832}
833
834//_____________________________________________________________________________
835void AliTRD::SetTreeAddress()
836{
837 //
838 // Set the branch addresses for the trees.
839 //
840
841 Char_t branchname[15];
842
843 AliDetector::SetTreeAddress();
844
845 TBranch *branch;
851d3db9 846 TTree *treeR = gAlice->TreeR();
847
848 if (treeR) {
849 sprintf(branchname,"%srecPoints",GetName());
850 if (fRecPoints) {
851 branch = treeR->GetBranch(branchname);
852 if (branch) {
853 branch->SetAddress(&fRecPoints);
854 }
5c7f4665 855 }
856 }
857
fe4da5cc 858}
859
d3f347ff 860//_____________________________________________________________________________
b060c36f 861void AliTRD::SetGasMix(Int_t imix)
d3f347ff 862{
82bbf98a 863 //
864 // Defines the gas mixture (imix=0: Xe/Isobutane imix=1: Xe/CO2)
865 //
866
d3f347ff 867 if ((imix < 0) || (imix > 1)) {
868 printf("Wrong input value: %d\n",imix);
869 printf("Use standard setting\n");
870 fGasMix = 0;
871 return;
872 }
873
874 fGasMix = imix;
875
876}
877
dd9a6ee3 878//_____________________________________________________________________________
793ff80c 879void AliTRD::SetPHOShole()
880{
881 //
882 // Selects a geometry with a hole in front of the PHOS
883 //
884
885 fGeometry->SetPHOShole();
886
887}
888
889//_____________________________________________________________________________
890void AliTRD::SetRICHhole()
891{
892 //
893 // Selects a geometry with a hole in front of the RICH
894 //
895
896 fGeometry->SetRICHhole();
897
898}
899
900//_____________________________________________________________________________
dd9a6ee3 901AliTRD &AliTRD::operator=(const AliTRD &trd)
902{
903 //
904 // Assignment operator
905 //
906
907 if (this != &trd) ((AliTRD &) trd).Copy(*this);
908 return *this;
909
910}