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