]> git.uio.no Git - u/mrichter/AliRoot.git/blame - TRD/AliTRD.cxx
Summ of G10 components normalized to one
[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
88cb7938 16/* $Id$ */
4c039060 17
fe4da5cc 18///////////////////////////////////////////////////////////////////////////////
19// //
20// Transition Radiation Detector //
21// This class contains the basic functions for the Transition Radiation //
6f1e466d 22// Detector. //
fe4da5cc 23// //
24///////////////////////////////////////////////////////////////////////////////
25
5c7f4665 26#include <stdlib.h>
a2cb5b3d 27#include <Riostream.h>
5c7f4665 28
88cb7938 29#include <TFile.h>
30#include <TGeometry.h>
31#include <TLorentzVector.h>
fe4da5cc 32#include <TMath.h>
fe4da5cc 33#include <TNode.h>
793ff80c 34#include <TPGON.h>
332e9569 35#include <TParticle.h>
88cb7938 36#include <TROOT.h>
37#include <TTree.h>
38#include <TVirtualMC.h>
39
d3f347ff 40#include "AliConst.h"
793ff80c 41#include "AliDigit.h"
88cb7938 42#include "AliLoader.h"
793ff80c 43#include "AliMagF.h"
88cb7938 44#include "AliRun.h"
793ff80c 45#include "AliTRD.h"
793ff80c 46#include "AliTRDdigit.h"
851d3db9 47#include "AliTRDdigitizer.h"
88cb7938 48#include "AliTRDdigitsManager.h"
851d3db9 49#include "AliTRDgeometryFull.h"
88cb7938 50#include "AliTRDgeometryHole.h"
51#include "AliTRDhit.h"
52#include "AliTRDpoints.h"
b864d801 53#include "AliTRDrawData.h"
88cb7938 54#include "AliTrackReference.h"
5d12ce38 55#include "AliMC.h"
793ff80c 56
fe4da5cc 57ClassImp(AliTRD)
58
59//_____________________________________________________________________________
60AliTRD::AliTRD()
61{
62 //
63 // Default constructor
64 //
82bbf98a 65
6244debe 66 fIshunt = 0;
67 fGasMix = 0;
68 fHits = 0;
69 fDigits = 0;
5c7f4665 70
6244debe 71 fGeometry = 0;
82bbf98a 72
6244debe 73 fGasDensity = 0;
74 fFoilDensity = 0;
793ff80c 75
6244debe 76 fDrawTR = 0;
332e9569 77 fDisplayType = 0;
78
fe4da5cc 79}
80
81//_____________________________________________________________________________
82AliTRD::AliTRD(const char *name, const char *title)
83 : AliDetector(name,title)
84{
85 //
86 // Standard constructor for the TRD
87 //
88
5c7f4665 89 // Check that FRAME is there otherwise we have no place where to
90 // put TRD
8230f242 91 AliModule* frame = gAlice->GetModule("FRAME");
92 if (!frame) {
5c7f4665 93 Error("Ctor","TRD needs FRAME to be present\n");
94 exit(1);
95 }
96
d37eec5e 97 // Define the TRD geometry
98 if ((frame->IsVersion() == 0) ||
99 (frame->IsVersion() == 1)) {
851d3db9 100 fGeometry = new AliTRDgeometryFull();
101 }
102 else {
103 Error("Ctor","Could not find valid FRAME version\n");
104 exit(1);
105 }
5c7f4665 106
bdbb05bb 107 // Save the geometry
108 TDirectory* saveDir = gDirectory;
109 gAlice->GetRunLoader()->CdGAFile();
110 fGeometry->Write("TRDgeometry");
111 saveDir->cd();
112
fe4da5cc 113 // Allocate the hit array
f73816f5 114 fHits = new TClonesArray("AliTRDhit" ,405);
5d12ce38 115 gAlice->GetMCApp()->AddHitList(fHits);
99d5402e 116
117 // Allocate the digits array
f73816f5 118 fDigits = 0;
5c7f4665 119
6244debe 120 fIshunt = 0;
121 fGasMix = 1;
793ff80c 122
6244debe 123 fGasDensity = 0;
124 fFoilDensity = 0;
793ff80c 125
6244debe 126 fDrawTR = 0;
127 fDisplayType = 0;
128
fe4da5cc 129 SetMarkerColor(kWhite);
82bbf98a 130
fe4da5cc 131}
99d5402e 132
8230f242 133//_____________________________________________________________________________
73ae7b59 134AliTRD::AliTRD(const AliTRD &trd):AliDetector(trd)
8230f242 135{
136 //
137 // Copy constructor
138 //
139
dd9a6ee3 140 ((AliTRD &) trd).Copy(*this);
8230f242 141
142}
143
99d5402e 144//_____________________________________________________________________________
145AliTRD::~AliTRD()
146{
147 //
148 // TRD destructor
149 //
150
151 fIshunt = 0;
152
abaf1f1d 153 if (fGeometry) {
154 delete fGeometry;
332e9569 155 fGeometry = 0;
abaf1f1d 156 }
157 if (fHits) {
158 delete fHits;
332e9569 159 fHits = 0;
abaf1f1d 160 }
5c7f4665 161
162}
163
6244debe 164//_____________________________________________________________________________
165void AliTRD::Hits2Digits()
2ab0c725 166{
167 //
168 // Create digits
169 //
be385a87 170 AliTRDdigitizer digitizer("TRDdigitizer","TRD digitizer class");
171 digitizer.SetDebug(GetDebug());
88cb7938 172
6244debe 173 // Initialization
be385a87 174 digitizer.InitDetector();
6244debe 175
85a5290f 176 if (!fLoader->TreeH()) fLoader->LoadHits("read");
177 fLoader->LoadDigits("recreate");
178 AliRunLoader* runLoader = fLoader->GetRunLoader();
6244debe 179
85a5290f 180 for (Int_t iEvent = 0; iEvent < runLoader->GetNumberOfEvents(); iEvent++) {
be385a87 181 digitizer.Open(runLoader->GetFileName().Data(), iEvent);
182 digitizer.MakeDigits();
183 digitizer.WriteDigits();
6244debe 184 }
185
85a5290f 186 fLoader->UnloadHits();
187 fLoader->UnloadDigits();
a328fff9 188
6244debe 189}
190
191//_____________________________________________________________________________
192void AliTRD::Hits2SDigits()
193{
194 //
195 // Create summable digits
196 //
a328fff9 197
be385a87 198 AliTRDdigitizer digitizer("TRDdigitizer","TRD digitizer class");
6244debe 199 // For the summable digits
be385a87 200 digitizer.SetSDigits(kTRUE);
201 digitizer.SetDebug(GetDebug());
6244debe 202
203 // Initialization
be385a87 204 digitizer.InitDetector();
2ab0c725 205
85a5290f 206 if (!fLoader->TreeH()) fLoader->LoadHits("read");
207 fLoader->LoadSDigits("recreate");
208 AliRunLoader* runLoader = fLoader->GetRunLoader();
6244debe 209
85a5290f 210 for (Int_t iEvent = 0; iEvent < runLoader->GetNumberOfEvents(); iEvent++) {
be385a87 211 digitizer.Open(runLoader->GetFileName().Data(), iEvent);
212 digitizer.MakeDigits();
213 digitizer.WriteDigits();
85a5290f 214 }
2ab0c725 215
85a5290f 216 fLoader->UnloadHits();
217 fLoader->UnloadSDigits();
a328fff9 218
219}
6244debe 220
85a5290f 221//_____________________________________________________________________________
c92eb8ad 222AliDigitizer* AliTRD::CreateDigitizer(AliRunDigitizer* manager) const
85a5290f 223{
a328fff9 224 //
225 // Creates a new digitizer object
226 //
227
85a5290f 228 return new AliTRDdigitizer(manager);
a328fff9 229
6244debe 230}
231
232//_____________________________________________________________________________
233void AliTRD::SDigits2Digits()
234{
235 //
236 // Create final digits from summable digits
237 //
238
abaf1f1d 239 // Create the TRD digitizer
be385a87 240 AliTRDdigitizer digitizer("TRDdigitizer","TRD digitizer class");
241 digitizer.SetDebug(GetDebug());
99d5402e 242
abaf1f1d 243 // Set the parameter
be385a87 244 digitizer.SetEvent(gAlice->GetEvNumber());
abaf1f1d 245
246 // Initialization
be385a87 247 digitizer.InitDetector();
abaf1f1d 248
249 // Read the s-digits via digits manager
be385a87 250 AliTRDdigitsManager sdigitsManager;
88cb7938 251
be385a87 252 sdigitsManager.SetDebug(GetDebug());
253 sdigitsManager.SetSDigits(kTRUE);
254 sdigitsManager.CreateArrays();
88cb7938 255
256 if (!fLoader->TreeS())
257 if (fLoader->LoadSDigits("read"))
258 {
259 Error("SDigits2Digits","Error while reading SDigits for event %d",gAlice->GetEvNumber());
260 return;
261 }
262 if (!fLoader->TreeS()) return;
263
be385a87 264 sdigitsManager.ReadDigits(fLoader->TreeS());
abaf1f1d 265
266 // Add the s-digits to the input list
be385a87 267 digitizer.AddSDigitsManager(&sdigitsManager);
99d5402e 268
abaf1f1d 269 // Convert the s-digits to normal digits
be385a87 270 digitizer.SDigits2Digits();
abaf1f1d 271
272 // Store the digits
88cb7938 273 if (!fLoader->TreeD()) fLoader->MakeTree("D");
be385a87 274 if (digitizer.MakeBranch(fLoader->TreeD())){
275 digitizer.WriteDigits();
abaf1f1d 276 }
99d5402e 277
278}
279
b864d801 280//_____________________________________________________________________________
281void AliTRD::Digits2Raw()
282{
283 //
284 // convert digits of the current event to raw data
285 //
286
287 fLoader->LoadDigits();
288 TTree* digits = fLoader->TreeD();
289 if (!digits) {
290 Error("Digits2Raw", "no digits tree");
291 return;
292 }
293
294 AliTRDrawData rawWriter;
295// rawWriter.SetDebug(2);
296 if (!rawWriter.Digits2Raw(digits)) {
297 Error("AliTRD::Digits2Raw","The raw writer could not load the digits tree");
298 }
299
300 fLoader->UnloadDigits();
301
302}
303
fe4da5cc 304//_____________________________________________________________________________
332e9569 305void AliTRD::AddHit(Int_t track, Int_t det, Float_t *hits, Int_t q
306 , Bool_t inDrift)
fe4da5cc 307{
308 //
309 // Add a hit for the TRD
332e9569 310 //
82bbf98a 311
a328fff9 312 TClonesArray &lhits = *fHits;
313 AliTRDhit *hit = new(lhits[fNhits++]) AliTRDhit(fIshunt,track,det,hits,q);
314 if (inDrift) {
315 hit->SetDrift();
332e9569 316 }
a328fff9 317 else {
318 hit->SetAmplification();
319 }
320 if (q < 0) {
321 hit->SetTRphoton();
332e9569 322 }
82bbf98a 323
fe4da5cc 324}
325
326//_____________________________________________________________________________
327void AliTRD::BuildGeometry()
328{
329 //
330 // Create the ROOT TNode geometry for the TRD
331 //
82bbf98a 332
8230f242 333 TNode *node, *top;
fe4da5cc 334 TPGON *pgon;
793ff80c 335
336 Float_t rmin, rmax;
337 Float_t zmax1, zmax2;
db30bf0f 338
339 Int_t iPlan;
793ff80c 340
fe4da5cc 341 const Int_t kColorTRD = 46;
d3f347ff 342
fe4da5cc 343 // Find the top node alice
8230f242 344 top = gAlice->GetGeometry()->GetNode("alice");
d3f347ff 345
db30bf0f 346 if (fDisplayType == 0) {
793ff80c 347
348 pgon = new TPGON("S_TRD","TRD","void",0,360,AliTRDgeometry::Nsect(),4);
349 rmin = AliTRDgeometry::Rmin();
350 rmax = AliTRDgeometry::Rmax();
351 pgon->DefineSection(0,-AliTRDgeometry::Zmax1(),rmax,rmax);
352 pgon->DefineSection(1,-AliTRDgeometry::Zmax2(),rmin,rmax);
353 pgon->DefineSection(2, AliTRDgeometry::Zmax2(),rmin,rmax);
354 pgon->DefineSection(3, AliTRDgeometry::Zmax1(),rmax,rmax);
355 top->cd();
356 node = new TNode("TRD","TRD","S_TRD",0,0,0,"");
357 node->SetLineColor(kColorTRD);
358 fNodes->Add(node);
359
db30bf0f 360 }
361 else if (fDisplayType == 1) {
793ff80c 362
f73816f5 363 Char_t name[7];
364
793ff80c 365 Float_t slope = (AliTRDgeometry::Zmax1() - AliTRDgeometry::Zmax2())
366 / (AliTRDgeometry::Rmax() - AliTRDgeometry::Rmin());
367
332e9569 368 rmin = AliTRDgeometry::Rmin() + AliTRDgeometry::CraHght();
369 rmax = rmin + AliTRDgeometry::CdrHght();
f73816f5 370
371 Float_t thickness = rmin - AliTRDgeometry::Rmin();
372 zmax2 = AliTRDgeometry::Zmax2() + slope * thickness;
793ff80c 373 zmax1 = zmax2 + slope * AliTRDgeometry::DrThick();
793ff80c 374
db30bf0f 375 for (iPlan = 0; iPlan < AliTRDgeometry::Nplan(); iPlan++) {
793ff80c 376
f73816f5 377 sprintf(name,"S_TR1%d",iPlan);
378 pgon = new TPGON(name,"TRD","void",0,360,AliTRDgeometry::Nsect(),4);
379 pgon->DefineSection(0,-zmax1,rmax,rmax);
380 pgon->DefineSection(1,-zmax2,rmin,rmax);
381 pgon->DefineSection(2, zmax2,rmin,rmax);
382 pgon->DefineSection(3, zmax1,rmax,rmax);
383 top->cd();
384 node = new TNode("TRD","TRD",name,0,0,0,"");
385 node->SetLineColor(kColorTRD);
386 fNodes->Add(node);
387
388 Float_t height = AliTRDgeometry::Cheight() + AliTRDgeometry::Cspace();
389 rmin = rmin + height;
390 rmax = rmax + height;
391 zmax1 = zmax1 + slope * height;
392 zmax2 = zmax2 + slope * height;
393
394 }
395
396 thickness += AliTRDgeometry::DrThick();
397 rmin = AliTRDgeometry::Rmin() + thickness;
398 rmax = rmin + AliTRDgeometry::AmThick();
399 zmax2 = AliTRDgeometry::Zmax2() + slope * thickness;
400 zmax1 = zmax2 + slope * AliTRDgeometry::AmThick();
401
db30bf0f 402 for (iPlan = 0; iPlan < AliTRDgeometry::Nplan(); iPlan++) {
f73816f5 403
404 sprintf(name,"S_TR2%d",iPlan);
793ff80c 405 pgon = new TPGON(name,"TRD","void",0,360,AliTRDgeometry::Nsect(),4);
406 pgon->DefineSection(0,-zmax1,rmax,rmax);
407 pgon->DefineSection(1,-zmax2,rmin,rmax);
408 pgon->DefineSection(2, zmax2,rmin,rmax);
409 pgon->DefineSection(3, zmax1,rmax,rmax);
410 top->cd();
411 node = new TNode("TRD","TRD",name,0,0,0,"");
412 node->SetLineColor(kColorTRD);
413 fNodes->Add(node);
414
415 Float_t height = AliTRDgeometry::Cheight() + AliTRDgeometry::Cspace();
416 rmin = rmin + height;
417 rmax = rmax + height;
418 zmax1 = zmax1 + slope * height;
419 zmax2 = zmax2 + slope * height;
420
421 }
422
db30bf0f 423 }
d3f347ff 424
fe4da5cc 425}
426
8230f242 427//_____________________________________________________________________________
dd9a6ee3 428void AliTRD::Copy(TObject &trd)
8230f242 429{
430 //
431 // Copy function
432 //
433
793ff80c 434 ((AliTRD &) trd).fGasMix = fGasMix;
435 ((AliTRD &) trd).fGeometry = fGeometry;
793ff80c 436 ((AliTRD &) trd).fGasDensity = fGasDensity;
437 ((AliTRD &) trd).fFoilDensity = fFoilDensity;
438 ((AliTRD &) trd).fDrawTR = fDrawTR;
439 ((AliTRD &) trd).fDisplayType = fDisplayType;
8230f242 440
441 //AliDetector::Copy(trd);
442
443}
444
fe4da5cc 445//_____________________________________________________________________________
82bbf98a 446void AliTRD::CreateGeometry()
fe4da5cc 447{
82bbf98a 448 //
449 // Creates the volumes for the TRD chambers
450 //
82bbf98a 451
452 // Check that FRAME is there otherwise we have no place where to put the TRD
8230f242 453 AliModule* frame = gAlice->GetModule("FRAME");
454 if (!frame) {
851d3db9 455 printf(" The TRD needs the FRAME to be defined first\n");
456 return;
82bbf98a 457 }
d3f347ff 458
851d3db9 459 fGeometry->CreateGeometry(fIdtmed->GetArray() - 1299);
5c7f4665 460
82bbf98a 461}
462
463//_____________________________________________________________________________
464void AliTRD::CreateMaterials()
465{
fe4da5cc 466 //
467 // Create the materials for the TRD
468 // Origin Y.Foka
469 //
470
8230f242 471 Int_t isxfld = gAlice->Field()->Integ();
472 Float_t sxmgmx = gAlice->Field()->Max();
fe4da5cc 473
d3f347ff 474 // For polyethilene (CH2)
475 Float_t ape[2] = { 12., 1. };
476 Float_t zpe[2] = { 6., 1. };
477 Float_t wpe[2] = { 1., 2. };
478 Float_t dpe = 0.95;
479
480 // For mylar (C5H4O2)
481 Float_t amy[3] = { 12., 1., 16. };
482 Float_t zmy[3] = { 6., 1., 8. };
483 Float_t wmy[3] = { 5., 4., 2. };
fe4da5cc 484 Float_t dmy = 1.39;
d3f347ff 485
486 // For CO2
487 Float_t aco[2] = { 12., 16. };
488 Float_t zco[2] = { 6., 8. };
489 Float_t wco[2] = { 1., 2. };
490 Float_t dco = 0.001977;
491
492 // For water
493 Float_t awa[2] = { 1., 16. };
494 Float_t zwa[2] = { 1., 8. };
495 Float_t wwa[2] = { 2., 1. };
496 Float_t dwa = 1.0;
497
498 // For isobutane (C4H10)
499 Float_t ais[2] = { 12., 1. };
500 Float_t zis[2] = { 6., 1. };
501 Float_t wis[2] = { 4., 10. };
502 Float_t dis = 0.00267;
503
db30bf0f 504 // For plexiglas (C5H8O2)
505 Float_t apg[3] = { 12.011 , 1.0 , 15.9994 };
506 Float_t zpg[3] = { 6.0 , 1.0 , 8.0 };
507 Float_t wpg[3] = { 5.0 , 8.0 , 2.0 };
508 Float_t dpg = 1.18;
08ca3951 509
510 // For epoxy (C18H19O3)
511 Float_t aEpoxy[3] = { 15.9994 , 1.00794 , 12.0107 };
512 Float_t zEpoxy[3] = { 8.0 , 1.0 , 6.0 };
513 Float_t wEpoxy[3] = { 3.0 , 19.0 , 18.0 };
514 Float_t dEpoxy = 1.8 ;
515
516 // For air
517 Float_t aAir[4] = { 12.0 , 14.0 , 16.0 , 36.0 };
518 Float_t zAir[4] = { 6.0 , 7.0 , 8.0 , 18.0 };
519 Float_t wAir[4] = { 0.000124 , 0.755267 , 0.231781 , 0.012827};
520 Float_t dAir = 1.20479E-3;
521
522 // For G10
523 Float_t aG10[4] = { 1.0 , 12.011 , 15.9994 , 28.086 };
524 Float_t zG10[4] = { 1.0 , 6.0 , 8.0 , 14.0 };
7ddbf30e 525 //PH Float_t wG10[4] = { 0.148648649 , 0.104054054 , 0.483499056 , 0.241666667 };
526 Float_t wG10[4]={0.15201,0.10641,0.49444,0.24714};
08ca3951 527 Float_t dG10 = 1.7;
db30bf0f 528
d3f347ff 529 // For Xe/CO2-gas-mixture
08ca3951 530 Float_t aXeCO2[3] = { 39.948, 12.0107, 15.9994 };
531 Float_t zXeCO2[3] = { 18.0, 6.0, 8.0 };
532 Float_t wXeCO2[3] = { 0.85, 0.0375, 0.1125 };
db30bf0f 533 // Xe-content of the Xe/CO2-mixture (85% / 15%)
534 Float_t fxc = .85;
d3f347ff 535 // Xe-content of the Xe/Isobutane-mixture (97% / 3%)
536 Float_t fxi = .97;
fe4da5cc 537 Float_t dxe = .005858;
538
d3f347ff 539 // General tracking parameter
fe4da5cc 540 Float_t tmaxfd = -10.;
541 Float_t stemax = -1e10;
d3f347ff 542 Float_t deemax = -0.1;
543 Float_t epsil = 1e-4;
544 Float_t stmin = -0.001;
fe4da5cc 545
546 Float_t absl, radl, d, buf[1];
793ff80c 547 Float_t agm[2], zgm[2], wgm[2];
548 Float_t dgm1, dgm2;
d3f347ff 549 Int_t nbuf;
fe4da5cc 550
d3f347ff 551 //////////////////////////////////////////////////////////////////////////
fe4da5cc 552 // Define Materials
d3f347ff 553 //////////////////////////////////////////////////////////////////////////
554
16bf9884 555 AliMaterial( 1, "Al" , 26.98, 13.0, 2.7 , 8.9 , 37.2);
08ca3951 556 //AliMaterial( 2, "Air" , 14.61, 7.3, 0.001205, 30420.0 , 67500.0);
16bf9884 557 AliMaterial( 4, "Xe" , 131.29, 54.0, dxe , 1447.59, 0.0);
558 AliMaterial( 5, "Cu" , 63.54, 29.0, 8.96 , 1.43, 14.8);
559 AliMaterial( 6, "C" , 12.01, 6.0, 2.265 , 18.8 , 74.4);
08ca3951 560 //AliMaterial(12, "G10" , 20.00, 10.0, 1.7 , 19.4 , 999.0);
16bf9884 561 AliMaterial(15, "Sn" , 118.71, 50.0, 7.31 , 1.21, 14.8);
562 AliMaterial(16, "Si" , 28.09, 14.0, 2.33 , 9.36, 37.2);
08ca3951 563 //AliMaterial(17, "Epoxy", 17.75, 8.9, 1.8 , 21.82, 999.0);
d3f347ff 564
565 // Mixtures
08ca3951 566 AliMixture(2, "Air" , aAir, zAir, dAir, 4, wAir);
567 AliMixture(3, "Polyethilene", ape, zpe, dpe, -2, wpe);
568 AliMixture(7, "Mylar", amy, zmy, dmy, -3, wmy);
569 AliMixture(8, "CO2", aco, zco, dco, -2, wco);
570 AliMixture(9, "Isobutane", ais, zis, dis, -2, wis);
571 AliMixture(12,"G10", aG10, zG10, dG10, 4, wG10);
572 AliMixture(13,"Water", awa, zwa, dwa, -2, wwa);
573 AliMixture(14,"Plexiglas", apg, zpg, dpg, -3, wpg);
574 AliMixture(17,"Epoxy", aEpoxy,zEpoxy,dEpoxy, -3, wEpoxy);
d3f347ff 575
576 // Gas mixtures
00d6d986 577 Char_t namate[21]="";
d3f347ff 578 // Xe/CO2-mixture
579 // Get properties of Xe
08ca3951 580 //gMC->Gfmate((*fIdmate)[4], namate, agm[0], zgm[0], d, radl, absl, buf, nbuf);
d3f347ff 581 // Get properties of CO2
08ca3951 582 //gMC->Gfmate((*fIdmate)[8], namate, agm[1], zgm[1], d, radl, absl, buf, nbuf);
d3f347ff 583 // Create gas mixture
584 wgm[0] = fxc;
585 wgm[1] = 1. - fxc;
793ff80c 586 dgm1 = wgm[0] * dxe + wgm[1] * dco;
08ca3951 587 AliMixture(10, "Gas mixture 1", aXeCO2, zXeCO2, dgm1, 3, wXeCO2);
588
d3f347ff 589 // Xe/Isobutane-mixture
590 // Get properties of Xe
cfce8870 591 gMC->Gfmate((*fIdmate)[4], namate, agm[0], zgm[0], d, radl, absl, buf, nbuf);
d3f347ff 592 // Get properties of Isobutane
cfce8870 593 gMC->Gfmate((*fIdmate)[9], namate, agm[1], zgm[1], d, radl, absl, buf, nbuf);
d3f347ff 594 // Create gas mixture
595 wgm[0] = fxi;
596 wgm[1] = 1. - fxi;
793ff80c 597 dgm2 = wgm[0] * dxe + wgm[1] * dis;
db30bf0f 598 AliMixture(11, "Gas mixture 2", agm, zgm, dgm2, 2, wgm);
d3f347ff 599
600 //////////////////////////////////////////////////////////////////////////
fe4da5cc 601 // Tracking Media Parameters
d3f347ff 602 //////////////////////////////////////////////////////////////////////////
603
604 // Al Frame
db30bf0f 605 AliMedium(1, "Al Frame", 1, 0, isxfld, sxmgmx
d3f347ff 606 , tmaxfd, stemax, deemax, epsil, stmin);
607 // Air
db30bf0f 608 AliMedium(2, "Air", 2, 0, isxfld, sxmgmx
d3f347ff 609 , tmaxfd, stemax, deemax, epsil, stmin);
610 // Polyethilene
db30bf0f 611 AliMedium(3, "Radiator", 3, 0, isxfld, sxmgmx
d3f347ff 612 , tmaxfd, stemax, deemax, epsil, stmin);
613 // Xe
db30bf0f 614 AliMedium(4, "Xe", 4, 1, isxfld, sxmgmx
d3f347ff 615 , tmaxfd, stemax, deemax, epsil, stmin);
616 // Cu pads
db30bf0f 617 AliMedium(5, "Padplane", 5, 1, isxfld, sxmgmx
d3f347ff 618 , tmaxfd, stemax, deemax, epsil, stmin);
619 // Fee + cables
db30bf0f 620 AliMedium(6, "Readout", 1, 0, isxfld, sxmgmx
d3f347ff 621 , tmaxfd, stemax, deemax, epsil, stmin);
622 // C frame
db30bf0f 623 AliMedium(7, "C Frame", 6, 0, isxfld, sxmgmx
d3f347ff 624 , tmaxfd, stemax, deemax, epsil, stmin);
625 // Mylar foils
db30bf0f 626 AliMedium(8, "Mylar", 7, 0, isxfld, sxmgmx
d3f347ff 627 , tmaxfd, stemax, deemax, epsil, stmin);
628 if (fGasMix == 1) {
629 // Gas-mixture (Xe/CO2)
db30bf0f 630 AliMedium(9, "Gas-mix", 10, 1, isxfld, sxmgmx
d3f347ff 631 , tmaxfd, stemax, deemax, epsil, stmin);
632 }
633 else {
634 // Gas-mixture (Xe/Isobutane)
db30bf0f 635 AliMedium(9, "Gas-mix", 11, 1, isxfld, sxmgmx
d3f347ff 636 , tmaxfd, stemax, deemax, epsil, stmin);
637 }
638 // Nomex-honeycomb (use carbon for the time being)
db30bf0f 639 AliMedium(10, "Nomex", 6, 0, isxfld, sxmgmx
d3f347ff 640 , tmaxfd, stemax, deemax, epsil, stmin);
641 // Kapton foils (use Mylar for the time being)
db30bf0f 642 AliMedium(11, "Kapton", 7, 0, isxfld, sxmgmx
d3f347ff 643 , tmaxfd, stemax, deemax, epsil, stmin);
644 // Gas-filling of the radiator
db30bf0f 645 AliMedium(12, "CO2", 8, 0, isxfld, sxmgmx
d3f347ff 646 , tmaxfd, stemax, deemax, epsil, stmin);
647 // G10-plates
db30bf0f 648 AliMedium(13, "G10-plates",12, 0, isxfld, sxmgmx
d3f347ff 649 , tmaxfd, stemax, deemax, epsil, stmin);
650 // Cooling water
db30bf0f 651 AliMedium(14, "Water", 13, 0, isxfld, sxmgmx
652 , tmaxfd, stemax, deemax, epsil, stmin);
653 // Rohacell (plexiglas) for the radiator
654 AliMedium(15, "Rohacell", 14, 0, isxfld, sxmgmx
d3f347ff 655 , tmaxfd, stemax, deemax, epsil, stmin);
16bf9884 656 // Al layer in MCMs
657 AliMedium(16, "MCM-Al" , 1, 0, isxfld, sxmgmx
658 , tmaxfd, stemax, deemax, epsil, stmin);
659 // Sn layer in MCMs
660 AliMedium(17, "MCM-Sn" , 15, 0, isxfld, sxmgmx
661 , tmaxfd, stemax, deemax, epsil, stmin);
662 // Cu layer in MCMs
663 AliMedium(18, "MCM-Cu" , 5, 0, isxfld, sxmgmx
664 , tmaxfd, stemax, deemax, epsil, stmin);
665 // G10 layer in MCMs
666 AliMedium(19, "MCM-G10" , 12, 0, isxfld, sxmgmx
667 , tmaxfd, stemax, deemax, epsil, stmin);
668 // Si in readout chips
669 AliMedium(20, "Chip-Si" , 16, 0, isxfld, sxmgmx
670 , tmaxfd, stemax, deemax, epsil, stmin);
671 // Epoxy in readout chips
672 AliMedium(21, "Chip-Ep" , 17, 0, isxfld, sxmgmx
673 , tmaxfd, stemax, deemax, epsil, stmin);
674 // PE in connectors
675 AliMedium(22, "Conn-PE" , 3, 0, isxfld, sxmgmx
676 , tmaxfd, stemax, deemax, epsil, stmin);
677 // Cu in connectors
678 AliMedium(23, "Chip-Cu" , 5, 0, isxfld, sxmgmx
679 , tmaxfd, stemax, deemax, epsil, stmin);
680 // Al of cooling pipes
681 AliMedium(24, "Cooling" , 1, 0, isxfld, sxmgmx
682 , tmaxfd, stemax, deemax, epsil, stmin);
73ae7b59 683 // Cu in services
684 AliMedium(25, "Serv-Cu" , 5, 0, isxfld, sxmgmx
685 , tmaxfd, stemax, deemax, epsil, stmin);
d3f347ff 686
793ff80c 687 // Save the density values for the TRD absorbtion
688 fFoilDensity = dmy;
689 if (fGasMix == 1)
690 fGasDensity = dgm1;
691 else
692 fGasDensity = dgm2;
693
fe4da5cc 694}
695
82bbf98a 696//_____________________________________________________________________________
0a29d0f1 697void AliTRD::DrawModule() const
82bbf98a 698{
699 //
700 // Draw a shaded view of the Transition Radiation Detector version 0
701 //
702
703 // Set everything unseen
704 gMC->Gsatt("*" ,"SEEN",-1);
705
706 // Set ALIC mother transparent
707 gMC->Gsatt("ALIC","SEEN", 0);
708
709 // Set the volumes visible
851d3db9 710 if (fGeometry->IsVersion() == 0) {
5c7f4665 711 gMC->Gsatt("B071","SEEN", 0);
712 gMC->Gsatt("B074","SEEN", 0);
713 gMC->Gsatt("B075","SEEN", 0);
714 gMC->Gsatt("B077","SEEN", 0);
715 gMC->Gsatt("BTR1","SEEN", 0);
716 gMC->Gsatt("BTR2","SEEN", 0);
717 gMC->Gsatt("BTR3","SEEN", 0);
332e9569 718 gMC->Gsatt("UTR1","SEEN", 0);
719 gMC->Gsatt("UTR2","SEEN", 0);
720 gMC->Gsatt("UTR3","SEEN", 0);
5c7f4665 721 }
722 else {
723 gMC->Gsatt("B071","SEEN", 0);
724 gMC->Gsatt("B074","SEEN", 0);
725 gMC->Gsatt("B075","SEEN", 0);
726 gMC->Gsatt("B077","SEEN", 0);
727 gMC->Gsatt("BTR1","SEEN", 0);
728 gMC->Gsatt("BTR2","SEEN", 0);
729 gMC->Gsatt("BTR3","SEEN", 0);
332e9569 730 gMC->Gsatt("UTR1","SEEN", 0);
6f1e466d 731 if (fGeometry->GetPHOShole())
332e9569 732 gMC->Gsatt("UTR2","SEEN", 0);
6f1e466d 733 if (fGeometry->GetRICHhole())
332e9569 734 gMC->Gsatt("UTR3","SEEN", 0);
5c7f4665 735 }
332e9569 736// gMC->Gsatt("UCII","SEEN", 0);
737// gMC->Gsatt("UCIM","SEEN", 0);
738// gMC->Gsatt("UCIO","SEEN", 0);
739// gMC->Gsatt("UL02","SEEN", 1);
740// gMC->Gsatt("UL05","SEEN", 1);
741// gMC->Gsatt("UL06","SEEN", 1);
82bbf98a 742
743 gMC->Gdopt("hide", "on");
744 gMC->Gdopt("shad", "on");
745 gMC->Gsatt("*", "fill", 7);
746 gMC->SetClipBox(".");
747 gMC->SetClipBox("*", 0, 2000, -2000, 2000, -2000, 2000);
748 gMC->DefaultRange();
749 gMC->Gdraw("alic", 40, 30, 0, 12, 9.4, .021, .021);
750 gMC->Gdhead(1111, "Transition Radiation Detector");
751 gMC->Gdman(18, 4, "MAN");
752
753}
754
fe4da5cc 755//_____________________________________________________________________________
0a29d0f1 756Int_t AliTRD::DistancetoPrimitive(Int_t , Int_t ) const
fe4da5cc 757{
758 //
759 // Distance between the mouse and the TRD detector on the screen
760 // Dummy routine
82bbf98a 761
762 return 9999;
763
fe4da5cc 764}
765
766//_____________________________________________________________________________
767void AliTRD::Init()
768{
769 //
851d3db9 770 // Initialize the TRD detector after the geometry has been created
fe4da5cc 771 //
82bbf98a 772
5c7f4665 773 Int_t i;
851d3db9 774
abaf1f1d 775 if (fDebug) {
9e1a0ddb 776 printf("\n%s: ",ClassName());
777 for (i = 0; i < 35; i++) printf("*");
778 printf(" TRD_INIT ");
779 for (i = 0; i < 35; i++) printf("*");
780 printf("\n");
781 }
5c7f4665 782
d37eec5e 783 if (fGeometry->IsVersion() == 1) {
784 printf("%s: Full geometry version initialized\n",ClassName());
6f1e466d 785 if (fGeometry->GetPHOShole())
9e1a0ddb 786 printf("%s: Leave space in front of PHOS free\n",ClassName());
6f1e466d 787 if (fGeometry->GetRICHhole())
9e1a0ddb 788 printf("%s: Leave space in front of RICH free\n",ClassName());
5c7f4665 789 }
d37eec5e 790 else {
791 printf("%s: Not a valid geometry\n",ClassName());
792 }
9e1a0ddb 793
abaf1f1d 794 if (fGasMix == 1) {
db30bf0f 795 printf("%s: Gas Mixture: 85%% Xe + 15%% CO2\n",ClassName());
abaf1f1d 796 }
797 else {
9e1a0ddb 798 printf("%s: Gas Mixture: 97%% Xe + 3%% Isobutane\n",ClassName());
abaf1f1d 799 }
5c7f4665 800
801}
802
793ff80c 803//_____________________________________________________________________________
73ae7b59 804void AliTRD::LoadPoints(Int_t )
793ff80c 805{
806 //
807 // Store x, y, z of all hits in memory.
808 // Hit originating from TR photons are given a different color
809 //
810
332e9569 811 //if (!fDrawTR) {
812 // AliDetector::LoadPoints(track);
813 // return;
814 //}
793ff80c 815
a328fff9 816 if (fHits == 0) return;
793ff80c 817
a328fff9 818 Int_t nhits = fHits->GetEntriesFast();
793ff80c 819 if (nhits == 0) return;
820
5d12ce38 821 Int_t tracks = gAlice->GetMCApp()->GetNtrack();
793ff80c 822 if (fPoints == 0) fPoints = new TObjArray(tracks);
823
824 AliTRDhit *ahit;
825
826 Int_t *ntrkE = new Int_t[tracks];
827 Int_t *ntrkT = new Int_t[tracks];
828 Int_t *limiE = new Int_t[tracks];
829 Int_t *limiT = new Int_t[tracks];
830 Float_t **coorE = new Float_t*[tracks];
831 Float_t **coorT = new Float_t*[tracks];
832 for(Int_t i = 0; i < tracks; i++) {
833 ntrkE[i] = 0;
834 ntrkT[i] = 0;
835 coorE[i] = 0;
836 coorT[i] = 0;
837 limiE[i] = 0;
838 limiT[i] = 0;
839 }
840
332e9569 841 AliTRDpoints *points = 0;
842 Float_t *fp = 0;
843 Int_t trk;
844 Int_t chunk = nhits / 4 + 1;
793ff80c 845
846 // Loop over all the hits and store their position
332e9569 847 ahit = (AliTRDhit *) FirstHit(-1);
848 while (ahit) {
793ff80c 849
850 // dEdx hits
332e9569 851 if (ahit->GetCharge() >= 0) {
793ff80c 852
853 trk = ahit->GetTrack();
854 if (ntrkE[trk] == limiE[trk]) {
855 // Initialise a new track
856 fp = new Float_t[3*(limiE[trk]+chunk)];
857 if (coorE[trk]) {
858 memcpy(fp,coorE[trk],sizeof(Float_t)*3*limiE[trk]);
859 delete [] coorE[trk];
860 }
861 limiE[trk] += chunk;
862 coorE[trk] = fp;
863 }
864 else {
865 fp = coorE[trk];
866 }
867 fp[3*ntrkE[trk] ] = ahit->X();
868 fp[3*ntrkE[trk]+1] = ahit->Y();
869 fp[3*ntrkE[trk]+2] = ahit->Z();
870 ntrkE[trk]++;
871
872 }
873 // TR photon hits
332e9569 874 else if ((ahit->GetCharge() < 0) && (fDrawTR)) {
793ff80c 875
876 trk = ahit->GetTrack();
877 if (ntrkT[trk] == limiT[trk]) {
878 // Initialise a new track
879 fp = new Float_t[3*(limiT[trk]+chunk)];
880 if (coorT[trk]) {
881 memcpy(fp,coorT[trk],sizeof(Float_t)*3*limiT[trk]);
882 delete [] coorT[trk];
883 }
884 limiT[trk] += chunk;
885 coorT[trk] = fp;
886 }
887 else {
888 fp = coorT[trk];
889 }
890 fp[3*ntrkT[trk] ] = ahit->X();
891 fp[3*ntrkT[trk]+1] = ahit->Y();
892 fp[3*ntrkT[trk]+2] = ahit->Z();
893 ntrkT[trk]++;
894
895 }
896
332e9569 897 ahit = (AliTRDhit *) NextHit();
898
793ff80c 899 }
900
901 for (trk = 0; trk < tracks; ++trk) {
902
903 if (ntrkE[trk] || ntrkT[trk]) {
904
905 points = new AliTRDpoints();
906 points->SetDetector(this);
907 points->SetParticle(trk);
908
909 // Set the dEdx points
910 if (ntrkE[trk]) {
911 points->SetMarkerColor(GetMarkerColor());
912 points->SetMarkerSize(GetMarkerSize());
913 points->SetPolyMarker(ntrkE[trk],coorE[trk],GetMarkerStyle());
914 delete [] coorE[trk];
915 coorE[trk] = 0;
916 }
917
918 // Set the TR photon points
919 if (ntrkT[trk]) {
920 points->SetTRpoints(ntrkT[trk],coorT[trk]);
921 delete [] coorT[trk];
922 coorT[trk] = 0;
923 }
924
925 fPoints->AddAt(points,trk);
926
927 }
928
929 }
930
931 delete [] coorE;
932 delete [] coorT;
933 delete [] ntrkE;
934 delete [] ntrkT;
935 delete [] limiE;
936 delete [] limiT;
937
938}
939
5c7f4665 940//_____________________________________________________________________________
88cb7938 941void AliTRD::MakeBranch(Option_t* option)
5c7f4665 942{
943 //
abaf1f1d 944 // Create Tree branches for the TRD digits.
5c7f4665 945 //
946
abaf1f1d 947 Int_t buffersize = 4000;
948 Char_t branchname[15];
949 sprintf(branchname,"%s",GetName());
5c7f4665 950
aa9d00f0 951 const char *cD = strstr(option,"D");
952
88cb7938 953 AliDetector::MakeBranch(option);
5c7f4665 954
abaf1f1d 955 if (fDigits && gAlice->TreeD() && cD) {
88cb7938 956 MakeBranchInTree(gAlice->TreeD(),branchname,&fDigits,buffersize,0);
abaf1f1d 957 }
958
851d3db9 959}
960
6244debe 961//_____________________________________________________________________________
962void AliTRD::ResetDigits()
963{
964 //
abaf1f1d 965 // Reset number of digits and the digits array for this detector
6244debe 966 //
967
abaf1f1d 968 fNdigits = 0;
969 if (fDigits) fDigits->Clear();
6244debe 970
971}
972
5c7f4665 973//_____________________________________________________________________________
974void AliTRD::SetTreeAddress()
975{
976 //
977 // Set the branch addresses for the trees.
978 //
979
a328fff9 980 if ( fLoader->TreeH() && (fHits == 0x0)) {
981 fHits = new TClonesArray("AliTRDhit",405);
332e9569 982 }
a328fff9 983 AliDetector::SetTreeAddress();
332e9569 984
fe4da5cc 985}
986
d3f347ff 987//_____________________________________________________________________________
b060c36f 988void AliTRD::SetGasMix(Int_t imix)
d3f347ff 989{
82bbf98a 990 //
991 // Defines the gas mixture (imix=0: Xe/Isobutane imix=1: Xe/CO2)
992 //
993
d3f347ff 994 if ((imix < 0) || (imix > 1)) {
995 printf("Wrong input value: %d\n",imix);
996 printf("Use standard setting\n");
6244debe 997 fGasMix = 1;
d3f347ff 998 return;
999 }
1000
1001 fGasMix = imix;
1002
1003}
1004
793ff80c 1005//_____________________________________________________________________________
1006void AliTRD::SetPHOShole()
1007{
1008 //
1009 // Selects a geometry with a hole in front of the PHOS
1010 //
1011
1012 fGeometry->SetPHOShole();
1013
1014}
1015
1016//_____________________________________________________________________________
1017void AliTRD::SetRICHhole()
1018{
1019 //
1020 // Selects a geometry with a hole in front of the RICH
1021 //
1022
1023 fGeometry->SetRICHhole();
1024
1025}
1026
dd9a6ee3 1027//_____________________________________________________________________________
1028AliTRD &AliTRD::operator=(const AliTRD &trd)
1029{
1030 //
1031 // Assignment operator
1032 //
1033
1034 if (this != &trd) ((AliTRD &) trd).Copy(*this);
1035 return *this;
1036
f73816f5 1037}
abaf1f1d 1038
abaf1f1d 1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372