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