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