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