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