]> git.uio.no Git - u/mrichter/AliRoot.git/blame - TRD/AliTRD.cxx
Module numbering is corrected
[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
7ca4655f 29#include <TClonesArray.h>
88cb7938 30#include <TFile.h>
31#include <TGeometry.h>
32#include <TLorentzVector.h>
fe4da5cc 33#include <TMath.h>
fe4da5cc 34#include <TNode.h>
793ff80c 35#include <TPGON.h>
332e9569 36#include <TParticle.h>
88cb7938 37#include <TROOT.h>
38#include <TTree.h>
39#include <TVirtualMC.h>
40
d3f347ff 41#include "AliConst.h"
793ff80c 42#include "AliDigit.h"
88cb7938 43#include "AliLoader.h"
45160b1f 44#include "AliLog.h"
45#include "AliMC.h"
793ff80c 46#include "AliMagF.h"
88cb7938 47#include "AliRun.h"
030b4415 48#include "AliTrackReference.h"
49
793ff80c 50#include "AliTRD.h"
793ff80c 51#include "AliTRDdigit.h"
851d3db9 52#include "AliTRDdigitizer.h"
88cb7938 53#include "AliTRDdigitsManager.h"
bd0f8685 54#include "AliTRDgeometry.h"
88cb7938 55#include "AliTRDhit.h"
56#include "AliTRDpoints.h"
b864d801 57#include "AliTRDrawData.h"
3551db50 58#include "AliTRDSimParam.h"
59#include "AliTRDRecParam.h"
60#include "AliTRDCommonParam.h"
61#include "AliTRDcalibDB.h"
62
fe4da5cc 63ClassImp(AliTRD)
64
65//_____________________________________________________________________________
66AliTRD::AliTRD()
030b4415 67 :AliDetector()
68 ,fGeometry(0)
69 ,fGasDensity(0)
70 ,fFoilDensity(0)
71 ,fDrawTR(0)
72 ,fDisplayType(0)
fe4da5cc 73{
74 //
75 // Default constructor
76 //
332e9569 77
fe4da5cc 78}
79
80//_____________________________________________________________________________
81AliTRD::AliTRD(const char *name, const char *title)
030b4415 82 :AliDetector(name,title)
83 ,fGeometry(0)
84 ,fGasDensity(0)
85 ,fFoilDensity(0)
86 ,fDrawTR(0)
87 ,fDisplayType(0)
fe4da5cc 88{
89 //
90 // Standard constructor for the TRD
91 //
92
030b4415 93 // Check that FRAME is there otherwise we have no place where to put TRD
94 AliModule *frame = gAlice->GetModule("FRAME");
8230f242 95 if (!frame) {
030b4415 96 AliError("TRD needs FRAME to be present\n");
5c7f4665 97 exit(1);
98 }
99
d37eec5e 100 // Define the TRD geometry
101 if ((frame->IsVersion() == 0) ||
102 (frame->IsVersion() == 1)) {
bd0f8685 103 fGeometry = new AliTRDgeometry();
851d3db9 104 }
105 else {
030b4415 106 AliError("Could not find valid FRAME version\n");
851d3db9 107 exit(1);
108 }
5c7f4665 109
bdbb05bb 110 // Save the geometry
030b4415 111 TDirectory *saveDir = gDirectory;
bdbb05bb 112 gAlice->GetRunLoader()->CdGAFile();
113 fGeometry->Write("TRDgeometry");
114 saveDir->cd();
115
fe4da5cc 116 // Allocate the hit array
030b4415 117 fHits = new TClonesArray("AliTRDhit",405);
5d12ce38 118 gAlice->GetMCApp()->AddHitList(fHits);
99d5402e 119
e939a978 120 //PH SetMarkerColor(kWhite);
8230f242 121
8230f242 122}
123
99d5402e 124//_____________________________________________________________________________
125AliTRD::~AliTRD()
126{
127 //
128 // TRD destructor
129 //
130
abaf1f1d 131 if (fGeometry) {
132 delete fGeometry;
030b4415 133 fGeometry = 0;
abaf1f1d 134 }
030b4415 135
abaf1f1d 136 if (fHits) {
137 delete fHits;
030b4415 138 fHits = 0;
abaf1f1d 139 }
bd0f8685 140
5c7f4665 141}
142
6244debe 143//_____________________________________________________________________________
144void AliTRD::Hits2Digits()
2ab0c725 145{
146 //
147 // Create digits
148 //
bd0f8685 149
be385a87 150 AliTRDdigitizer digitizer("TRDdigitizer","TRD digitizer class");
45160b1f 151 AliLog::SetClassDebugLevel("TRDdigitizer",AliDebugLevel());
88cb7938 152
6244debe 153 // Initialization
be385a87 154 digitizer.InitDetector();
6244debe 155
030b4415 156 if (!fLoader->TreeH()) {
157 fLoader->LoadHits("read");
158 }
85a5290f 159 fLoader->LoadDigits("recreate");
95867fd1 160
030b4415 161 AliRunLoader *runLoader = fLoader->GetRunLoader();
6244debe 162
85a5290f 163 for (Int_t iEvent = 0; iEvent < runLoader->GetNumberOfEvents(); iEvent++) {
95867fd1 164 runLoader->GetEvent(iEvent);
165 digitizer.Open(runLoader,iEvent);
be385a87 166 digitizer.MakeDigits();
167 digitizer.WriteDigits();
6244debe 168 }
169
85a5290f 170 fLoader->UnloadHits();
171 fLoader->UnloadDigits();
a328fff9 172
6244debe 173}
174
175//_____________________________________________________________________________
176void AliTRD::Hits2SDigits()
177{
178 //
179 // Create summable digits
180 //
a328fff9 181
be385a87 182 AliTRDdigitizer digitizer("TRDdigitizer","TRD digitizer class");
6244debe 183 // For the summable digits
be385a87 184 digitizer.SetSDigits(kTRUE);
45160b1f 185 AliLog::SetClassDebugLevel("TRDdigitizer",AliDebugLevel());
6244debe 186
187 // Initialization
be385a87 188 digitizer.InitDetector();
2ab0c725 189
030b4415 190 if (!fLoader->TreeH()) {
191 fLoader->LoadHits("read");
192 }
85a5290f 193 fLoader->LoadSDigits("recreate");
95867fd1 194
195 AliRunLoader *runLoader = fLoader->GetRunLoader();
6244debe 196
85a5290f 197 for (Int_t iEvent = 0; iEvent < runLoader->GetNumberOfEvents(); iEvent++) {
95867fd1 198 runLoader->GetEvent(iEvent);
199 digitizer.Open(runLoader,iEvent);
be385a87 200 digitizer.MakeDigits();
201 digitizer.WriteDigits();
85a5290f 202 }
2ab0c725 203
85a5290f 204 fLoader->UnloadHits();
205 fLoader->UnloadSDigits();
a328fff9 206
207}
6244debe 208
85a5290f 209//_____________________________________________________________________________
95867fd1 210AliDigitizer *AliTRD::CreateDigitizer(AliRunDigitizer *manager) const
85a5290f 211{
a328fff9 212 //
213 // Creates a new digitizer object
214 //
215
85a5290f 216 return new AliTRDdigitizer(manager);
a328fff9 217
6244debe 218}
219
220//_____________________________________________________________________________
221void AliTRD::SDigits2Digits()
222{
223 //
224 // Create final digits from summable digits
225 //
226
bd0f8685 227 // Create the TRD digitizer
be385a87 228 AliTRDdigitizer digitizer("TRDdigitizer","TRD digitizer class");
45160b1f 229 AliLog::SetClassDebugLevel("TRDdigitizer",AliDebugLevel());
99d5402e 230
abaf1f1d 231 // Set the parameter
be385a87 232 digitizer.SetEvent(gAlice->GetEvNumber());
abaf1f1d 233
234 // Initialization
be385a87 235 digitizer.InitDetector();
abaf1f1d 236
237 // Read the s-digits via digits manager
be385a87 238 AliTRDdigitsManager sdigitsManager;
88cb7938 239
45160b1f 240 AliLog::SetClassDebugLevel("TRDdigitisManager",AliDebugLevel());
be385a87 241 sdigitsManager.SetSDigits(kTRUE);
242 sdigitsManager.CreateArrays();
88cb7938 243
030b4415 244 if (!fLoader->TreeS()) {
245 if (fLoader->LoadSDigits("read")) {
246 return;
247 }
248 }
249 if (!fLoader->TreeS()) {
250 AliError(Form("Error while reading SDigits for event %d",gAlice->GetEvNumber()));
251 return;
252 }
88cb7938 253
be385a87 254 sdigitsManager.ReadDigits(fLoader->TreeS());
abaf1f1d 255
256 // Add the s-digits to the input list
be385a87 257 digitizer.AddSDigitsManager(&sdigitsManager);
99d5402e 258
abaf1f1d 259 // Convert the s-digits to normal digits
be385a87 260 digitizer.SDigits2Digits();
abaf1f1d 261
262 // Store the digits
030b4415 263 if (!fLoader->TreeD()) {
264 fLoader->MakeTree("D");
265 }
be385a87 266 if (digitizer.MakeBranch(fLoader->TreeD())){
267 digitizer.WriteDigits();
abaf1f1d 268 }
99d5402e 269
270}
271
b864d801 272//_____________________________________________________________________________
273void AliTRD::Digits2Raw()
274{
275 //
030b4415 276 // Convert digits of the current event to raw data
b864d801 277 //
278
279 fLoader->LoadDigits();
030b4415 280 TTree *digits = fLoader->TreeD();
b864d801 281 if (!digits) {
030b4415 282 AliError("No digits tree");
b864d801 283 return;
284 }
285
286 AliTRDrawData rawWriter;
b864d801 287 if (!rawWriter.Digits2Raw(digits)) {
030b4415 288 AliError("The raw writer could not load the digits tree");
b864d801 289 }
290
291 fLoader->UnloadDigits();
292
293}
294
fe4da5cc 295//_____________________________________________________________________________
332e9569 296void AliTRD::AddHit(Int_t track, Int_t det, Float_t *hits, Int_t q
297 , Bool_t inDrift)
fe4da5cc 298{
299 //
300 // Add a hit for the TRD
332e9569 301 //
82bbf98a 302
a328fff9 303 TClonesArray &lhits = *fHits;
304 AliTRDhit *hit = new(lhits[fNhits++]) AliTRDhit(fIshunt,track,det,hits,q);
030b4415 305
a328fff9 306 if (inDrift) {
307 hit->SetDrift();
332e9569 308 }
a328fff9 309 else {
310 hit->SetAmplification();
311 }
030b4415 312
a328fff9 313 if (q < 0) {
314 hit->SetTRphoton();
332e9569 315 }
82bbf98a 316
fe4da5cc 317}
318
319//_____________________________________________________________________________
320void AliTRD::BuildGeometry()
321{
322 //
323 // Create the ROOT TNode geometry for the TRD
324 //
82bbf98a 325
0c5a8090 326 TNode *node;
327 TNode *top;
fe4da5cc 328 TPGON *pgon;
793ff80c 329
0c5a8090 330 // The dimensions of the TRD super module
331 const Float_t kRmin = 291.0;
332 const Float_t kRmax = 369.0;
333 const Float_t kZmax1 = 378.35;
334 const Float_t kZmax2 = 302.0;
335
030b4415 336 Float_t rmin;
337 Float_t rmax;
338 Float_t zmax1;
339 Float_t zmax2;
db30bf0f 340
341 Int_t iPlan;
793ff80c 342
fe4da5cc 343 const Int_t kColorTRD = 46;
d3f347ff 344
fe4da5cc 345 // Find the top node alice
8230f242 346 top = gAlice->GetGeometry()->GetNode("alice");
d3f347ff 347
db30bf0f 348 if (fDisplayType == 0) {
793ff80c 349
350 pgon = new TPGON("S_TRD","TRD","void",0,360,AliTRDgeometry::Nsect(),4);
0c5a8090 351 rmin = kRmin;
352 rmax = kRmax;
353 pgon->DefineSection(0,-kZmax1,rmax,rmax);
354 pgon->DefineSection(1,-kZmax2,rmin,rmax);
355 pgon->DefineSection(2, kZmax2,rmin,rmax);
356 pgon->DefineSection(3, kZmax1,rmax,rmax);
793ff80c 357 top->cd();
358 node = new TNode("TRD","TRD","S_TRD",0,0,0,"");
359 node->SetLineColor(kColorTRD);
360 fNodes->Add(node);
361
db30bf0f 362 }
363 else if (fDisplayType == 1) {
793ff80c 364
f73816f5 365 Char_t name[7];
366
0c5a8090 367 Float_t slope = (kZmax1 - kZmax2) / (kRmax - kRmin);
793ff80c 368
0c5a8090 369 rmin = kRmin + AliTRDgeometry::CraHght();
370 rmax = rmin + AliTRDgeometry::CdrHght();
f73816f5 371
0c5a8090 372 Float_t thickness = rmin - kRmin;
373 zmax2 = kZmax2 + slope * thickness;
793ff80c 374 zmax1 = zmax2 + slope * AliTRDgeometry::DrThick();
793ff80c 375
db30bf0f 376 for (iPlan = 0; iPlan < AliTRDgeometry::Nplan(); iPlan++) {
793ff80c 377
f73816f5 378 sprintf(name,"S_TR1%d",iPlan);
379 pgon = new TPGON(name,"TRD","void",0,360,AliTRDgeometry::Nsect(),4);
380 pgon->DefineSection(0,-zmax1,rmax,rmax);
381 pgon->DefineSection(1,-zmax2,rmin,rmax);
382 pgon->DefineSection(2, zmax2,rmin,rmax);
383 pgon->DefineSection(3, zmax1,rmax,rmax);
384 top->cd();
385 node = new TNode("TRD","TRD",name,0,0,0,"");
386 node->SetLineColor(kColorTRD);
387 fNodes->Add(node);
388
389 Float_t height = AliTRDgeometry::Cheight() + AliTRDgeometry::Cspace();
390 rmin = rmin + height;
391 rmax = rmax + height;
392 zmax1 = zmax1 + slope * height;
393 zmax2 = zmax2 + slope * height;
394
395 }
396
397 thickness += AliTRDgeometry::DrThick();
0c5a8090 398 rmin = kRmin + thickness;
399 rmax = rmin + AliTRDgeometry::AmThick();
400 zmax2 = kZmax2 + slope * thickness;
401 zmax1 = zmax2 + slope * AliTRDgeometry::AmThick();
f73816f5 402
db30bf0f 403 for (iPlan = 0; iPlan < AliTRDgeometry::Nplan(); iPlan++) {
f73816f5 404
405 sprintf(name,"S_TR2%d",iPlan);
793ff80c 406 pgon = new TPGON(name,"TRD","void",0,360,AliTRDgeometry::Nsect(),4);
407 pgon->DefineSection(0,-zmax1,rmax,rmax);
408 pgon->DefineSection(1,-zmax2,rmin,rmax);
409 pgon->DefineSection(2, zmax2,rmin,rmax);
410 pgon->DefineSection(3, zmax1,rmax,rmax);
411 top->cd();
412 node = new TNode("TRD","TRD",name,0,0,0,"");
413 node->SetLineColor(kColorTRD);
414 fNodes->Add(node);
415
416 Float_t height = AliTRDgeometry::Cheight() + AliTRDgeometry::Cspace();
417 rmin = rmin + height;
418 rmax = rmax + height;
419 zmax1 = zmax1 + slope * height;
420 zmax2 = zmax2 + slope * height;
421
422 }
423
db30bf0f 424 }
d3f347ff 425
fe4da5cc 426}
427
428//_____________________________________________________________________________
82bbf98a 429void AliTRD::CreateGeometry()
fe4da5cc 430{
82bbf98a 431 //
432 // Creates the volumes for the TRD chambers
433 //
82bbf98a 434
435 // Check that FRAME is there otherwise we have no place where to put the TRD
030b4415 436 AliModule *frame = gAlice->GetModule("FRAME");
8230f242 437 if (!frame) {
45160b1f 438 AliFatal("The TRD needs the FRAME to be defined first");
82bbf98a 439 }
d3f347ff 440
851d3db9 441 fGeometry->CreateGeometry(fIdtmed->GetArray() - 1299);
5c7f4665 442
82bbf98a 443}
444
445//_____________________________________________________________________________
446void AliTRD::CreateMaterials()
447{
fe4da5cc 448 //
449 // Create the materials for the TRD
fe4da5cc 450 //
451
8230f242 452 Int_t isxfld = gAlice->Field()->Integ();
453 Float_t sxmgmx = gAlice->Field()->Max();
fe4da5cc 454
d3f347ff 455 // For polyethilene (CH2)
030b4415 456 Float_t ape[2] = { 12.011 , 1.0079 };
457 Float_t zpe[2] = { 6.0 , 1.0 };
458 Float_t wpe[2] = { 1.0 , 2.0 };
459 Float_t dpe = 0.95;
d3f347ff 460
d3f347ff 461 // For CO2
030b4415 462 Float_t aco[2] = { 12.011 , 15.9994 };
463 Float_t zco[2] = { 6.0 , 8.0 };
464 Float_t wco[2] = { 1.0 , 2.0 };
465 Float_t dco = 0.00186;
d3f347ff 466
467 // For water
030b4415 468 Float_t awa[2] = { 1.0079, 15.9994 };
469 Float_t zwa[2] = { 1.0 , 8.0 };
470 Float_t wwa[2] = { 2.0 , 1.0 };
471 Float_t dwa = 1.0;
d3f347ff 472
473 // For isobutane (C4H10)
030b4415 474 Float_t ais[2] = { 12.011 , 1.0079 };
475 Float_t zis[2] = { 6.0 , 1.0 };
476 Float_t wis[2] = { 4.0 , 10.0 };
477 Float_t dis = 0.00267;
d3f347ff 478
db30bf0f 479 // For plexiglas (C5H8O2)
030b4415 480 Float_t apg[3] = { 12.011 , 1.0079, 15.9994 };
481 Float_t zpg[3] = { 6.0 , 1.0 , 8.0 };
482 Float_t wpg[3] = { 5.0 , 8.0 , 2.0 };
483 Float_t dpg = 1.18;
08ca3951 484
485 // For epoxy (C18H19O3)
3dac2b2d 486 Float_t aEpoxy[3] = { 15.9994, 1.0079, 12.011 };
487 Float_t zEpoxy[3] = { 8.0 , 1.0 , 6.0 };
488 Float_t wEpoxy[3] = { 3.0 , 19.0 , 18.0 };
08ca3951 489 Float_t dEpoxy = 1.8 ;
490
0c5a8090 491 // For Araldite, low density epoxy (C18H19O3)
492 Float_t aAral[3] = { 15.9994, 1.0079, 12.011 };
493 Float_t zAral[3] = { 8.0 , 1.0 , 6.0 };
494 Float_t wAral[3] = { 3.0 , 19.0 , 18.0 };
495 Float_t dAral = 1.05;
496
08ca3951 497 // For air
3dac2b2d 498 Float_t aAir[4] = { 12.011 , 14.0 , 15.9994 , 36.0 };
499 Float_t zAir[4] = { 6.0 , 7.0 , 8.0 , 18.0 };
500 Float_t wAir[4] = { 0.000124, 0.755267, 0.231781, 0.012827 };
0c5a8090 501 Float_t dAir = 1.20479e-03;
08ca3951 502
503 // For G10
3dac2b2d 504 Float_t aG10[4] = { 1.0079 , 12.011 , 15.9994 , 28.086 };
505 Float_t zG10[4] = { 1.0 , 6.0 , 8.0 , 14.0 };
506 Float_t wG10[4] = { 0.15201 , 0.10641 , 0.49444 , 0.24714 };
08ca3951 507 Float_t dG10 = 1.7;
db30bf0f 508
d3f347ff 509 // For Xe/CO2-gas-mixture
3dac2b2d 510 Float_t aXeCO2[3] = { 131.29 , 12.0107 , 15.9994 };
511 Float_t zXeCO2[3] = { 54.0 , 6.0 , 8.0 };
330bfc2f 512 Float_t wXeCO2[3] = { 8.5 , 1.5 , 3.0 };
db30bf0f 513 // Xe-content of the Xe/CO2-mixture (85% / 15%)
3dac2b2d 514 Float_t fxc = 0.85;
515 Float_t dxe = 0.00549;
516 Float_t dgm = fxc * dxe + (1.0 - fxc) * dco;
fe4da5cc 517
d3f347ff 518 // General tracking parameter
030b4415 519 Float_t tmaxfd = -10.0;
520 Float_t stemax = -1.0e10;
521 Float_t deemax = -0.1;
522 Float_t epsil = 1.0e-4;
523 Float_t stmin = -0.001;
fe4da5cc 524
d3f347ff 525 //////////////////////////////////////////////////////////////////////////
fe4da5cc 526 // Define Materials
d3f347ff 527 //////////////////////////////////////////////////////////////////////////
528
16bf9884 529 AliMaterial( 1, "Al" , 26.98, 13.0, 2.7 , 8.9 , 37.2);
3dac2b2d 530 AliMaterial( 4, "Xe" , 131.29, 54.0, dxe , 1546.16, 0.0);
16bf9884 531 AliMaterial( 5, "Cu" , 63.54, 29.0, 8.96 , 1.43, 14.8);
532 AliMaterial( 6, "C" , 12.01, 6.0, 2.265 , 18.8 , 74.4);
16bf9884 533 AliMaterial(15, "Sn" , 118.71, 50.0, 7.31 , 1.21, 14.8);
534 AliMaterial(16, "Si" , 28.09, 14.0, 2.33 , 9.36, 37.2);
0c5a8090 535 AliMaterial(18, "Fe" , 55.85, 26.0, 7.87 , 1.76, 14.8);
d3f347ff 536
537 // Mixtures
3dac2b2d 538 AliMixture(2, "Air" , aAir, zAir, dAir, 4, wAir );
539 AliMixture(3, "Polyethilene", ape, zpe, dpe, -2, wpe );
3dac2b2d 540 AliMixture(8, "CO2", aco, zco, dco, -2, wco );
541 AliMixture(9, "Isobutane", ais, zis, dis, -2, wis );
330bfc2f 542 AliMixture(10,"Gas mixture", aXeCO2, zXeCO2, dgm, -3, wXeCO2);
3dac2b2d 543 AliMixture(12,"G10", aG10, zG10, dG10, 4, wG10 );
544 AliMixture(13,"Water", awa, zwa, dwa, -2, wwa );
545 AliMixture(14,"Plexiglas", apg, zpg, dpg, -3, wpg );
546 AliMixture(17,"Epoxy", aEpoxy, zEpoxy, dEpoxy, -3, wEpoxy);
0c5a8090 547 AliMixture(19,"Araldite", aAral, zAral, dAral, -3, wAral );
3dac2b2d 548
d3f347ff 549 //////////////////////////////////////////////////////////////////////////
fe4da5cc 550 // Tracking Media Parameters
d3f347ff 551 //////////////////////////////////////////////////////////////////////////
552
553 // Al Frame
0c5a8090 554 AliMedium( 1,"Al Frame" , 1,0,isxfld,sxmgmx
555 ,tmaxfd,stemax,deemax,epsil,stmin);
d3f347ff 556 // Air
0c5a8090 557 AliMedium( 2,"Air" , 2,0,isxfld,sxmgmx
558 ,tmaxfd,stemax,deemax,epsil,stmin);
559 // Wires
560 AliMedium( 3,"Wires" , 5,0,isxfld,sxmgmx
561 ,tmaxfd,stemax,deemax,epsil,stmin);
562 // All other ROB materials (caps, etc.)
563 AliMedium( 4,"ROB Other" , 5,0,isxfld,sxmgmx
564 ,tmaxfd,stemax,deemax,epsil,stmin);
d3f347ff 565 // Cu pads
0c5a8090 566 AliMedium( 5,"Padplane" , 5,1,isxfld,sxmgmx
567 ,tmaxfd,stemax,deemax,epsil,stmin);
d3f347ff 568 // Fee + cables
0c5a8090 569 AliMedium( 6,"Readout" , 5,0,isxfld,sxmgmx
570 ,tmaxfd,stemax,deemax,epsil,stmin);
d3f347ff 571 // C frame
0c5a8090 572 AliMedium( 7,"C Frame" , 6,0,isxfld,sxmgmx
573 ,tmaxfd,stemax,deemax,epsil,stmin);
574 // INOX of cooling bus bars
575 AliMedium( 8,"Cooling bus",18,0,isxfld,sxmgmx
576 ,tmaxfd,stemax,deemax,epsil,stmin);
3dac2b2d 577 // Gas-mixture (Xe/CO2)
0c5a8090 578 AliMedium( 9,"Gas-mix" ,10,1,isxfld,sxmgmx
579 ,tmaxfd,stemax,deemax,epsil,stmin);
580 // Nomex-honeycomb
581 AliMedium(10,"Nomex" ,12,0,isxfld,sxmgmx
582 ,tmaxfd,stemax,deemax,epsil,stmin);
583 // Araldite glue
584 AliMedium(11,"Glue" ,19,0,isxfld,sxmgmx
585 ,tmaxfd,stemax,deemax,epsil,stmin);
d3f347ff 586 // G10-plates
0c5a8090 587 AliMedium(13,"G10-plates" ,12,0,isxfld,sxmgmx
588 ,tmaxfd,stemax,deemax,epsil,stmin);
d3f347ff 589 // Cooling water
0c5a8090 590 AliMedium(14,"Water" ,13,0,isxfld,sxmgmx
591 ,tmaxfd,stemax,deemax,epsil,stmin);
db30bf0f 592 // Rohacell (plexiglas) for the radiator
0c5a8090 593 AliMedium(15,"Rohacell" ,14,0,isxfld,sxmgmx
594 ,tmaxfd,stemax,deemax,epsil,stmin);
16bf9884 595 // Al layer in MCMs
0c5a8090 596 AliMedium(16,"MCM-Al" , 1,0,isxfld,sxmgmx
597 ,tmaxfd,stemax,deemax,epsil,stmin);
16bf9884 598 // Sn layer in MCMs
0c5a8090 599 AliMedium(17,"MCM-Sn" ,15,0,isxfld,sxmgmx
600 ,tmaxfd,stemax,deemax,epsil,stmin);
16bf9884 601 // Cu layer in MCMs
0c5a8090 602 AliMedium(18,"MCM-Cu" , 5,0,isxfld,sxmgmx
603 ,tmaxfd,stemax,deemax,epsil,stmin);
16bf9884 604 // G10 layer in MCMs
0c5a8090 605 AliMedium(19,"MCM-G10" ,12,0,isxfld,sxmgmx
606 ,tmaxfd,stemax,deemax,epsil,stmin);
16bf9884 607 // Si in readout chips
0c5a8090 608 AliMedium(20,"Chip-Si" ,16,0,isxfld,sxmgmx
609 ,tmaxfd,stemax,deemax,epsil,stmin);
16bf9884 610 // Epoxy in readout chips
0c5a8090 611 AliMedium(21,"Chip-Ep" ,17,0,isxfld,sxmgmx
612 ,tmaxfd,stemax,deemax,epsil,stmin);
16bf9884 613 // PE in connectors
0c5a8090 614 AliMedium(22,"Conn-PE" , 3,0,isxfld,sxmgmx
615 ,tmaxfd,stemax,deemax,epsil,stmin);
16bf9884 616 // Cu in connectors
0c5a8090 617 AliMedium(23,"Chip-Cu" , 5,0,isxfld,sxmgmx
618 ,tmaxfd,stemax,deemax,epsil,stmin);
16bf9884 619 // Al of cooling pipes
0c5a8090 620 AliMedium(24,"Cooling" , 1,0,isxfld,sxmgmx
621 ,tmaxfd,stemax,deemax,epsil,stmin);
73ae7b59 622 // Cu in services
0c5a8090 623 AliMedium(25,"Serv-Cu" , 5,0,isxfld,sxmgmx
624 ,tmaxfd,stemax,deemax,epsil,stmin);
d3f347ff 625
14d71e14 626 // Special tracking options for charged particles for XeCO2
627 gMC->Gstpar((* fIdtmed)[9],"DRAY",1.0);
628 gMC->Gstpar((* fIdtmed)[9],"STRA",1.0);
629
793ff80c 630 // Save the density values for the TRD absorbtion
0c5a8090 631 Float_t dmy = 1.39;
793ff80c 632 fFoilDensity = dmy;
3dac2b2d 633 fGasDensity = dgm;
793ff80c 634
fe4da5cc 635}
636
82bbf98a 637//_____________________________________________________________________________
ba380e33 638void AliTRD::DrawModule() const
82bbf98a 639{
640 //
641 // Draw a shaded view of the Transition Radiation Detector version 0
642 //
643
644 // Set everything unseen
645 gMC->Gsatt("*" ,"SEEN",-1);
646
647 // Set ALIC mother transparent
648 gMC->Gsatt("ALIC","SEEN", 0);
649
650 // Set the volumes visible
851d3db9 651 if (fGeometry->IsVersion() == 0) {
5c7f4665 652 gMC->Gsatt("B071","SEEN", 0);
653 gMC->Gsatt("B074","SEEN", 0);
654 gMC->Gsatt("B075","SEEN", 0);
655 gMC->Gsatt("B077","SEEN", 0);
656 gMC->Gsatt("BTR1","SEEN", 0);
657 gMC->Gsatt("BTR2","SEEN", 0);
658 gMC->Gsatt("BTR3","SEEN", 0);
332e9569 659 gMC->Gsatt("UTR1","SEEN", 0);
660 gMC->Gsatt("UTR2","SEEN", 0);
661 gMC->Gsatt("UTR3","SEEN", 0);
5c7f4665 662 }
663 else {
664 gMC->Gsatt("B071","SEEN", 0);
665 gMC->Gsatt("B074","SEEN", 0);
666 gMC->Gsatt("B075","SEEN", 0);
667 gMC->Gsatt("B077","SEEN", 0);
668 gMC->Gsatt("BTR1","SEEN", 0);
669 gMC->Gsatt("BTR2","SEEN", 0);
670 gMC->Gsatt("BTR3","SEEN", 0);
332e9569 671 gMC->Gsatt("UTR1","SEEN", 0);
5c7f4665 672 }
82bbf98a 673
674 gMC->Gdopt("hide", "on");
675 gMC->Gdopt("shad", "on");
676 gMC->Gsatt("*", "fill", 7);
677 gMC->SetClipBox(".");
678 gMC->SetClipBox("*", 0, 2000, -2000, 2000, -2000, 2000);
679 gMC->DefaultRange();
680 gMC->Gdraw("alic", 40, 30, 0, 12, 9.4, .021, .021);
681 gMC->Gdhead(1111, "Transition Radiation Detector");
682 gMC->Gdman(18, 4, "MAN");
683
684}
685
fe4da5cc 686//_____________________________________________________________________________
e0d47c25 687Int_t AliTRD::DistancetoPrimitive(Int_t , Int_t )
fe4da5cc 688{
689 //
690 // Distance between the mouse and the TRD detector on the screen
691 // Dummy routine
030b4415 692 //
82bbf98a 693
694 return 9999;
695
fe4da5cc 696}
697
698//_____________________________________________________________________________
699void AliTRD::Init()
700{
701 //
851d3db9 702 // Initialize the TRD detector after the geometry has been created
fe4da5cc 703 //
82bbf98a 704
45160b1f 705 AliDebug(1,"++++++++++++++++++++++++++++++++++++++++++++++");
5c7f4665 706
bd0f8685 707 if (fGeometry->IsVersion() != 1) {
45160b1f 708 AliError("Not a valid geometry");
d37eec5e 709 }
9e1a0ddb 710
5c7f4665 711}
712
793ff80c 713//_____________________________________________________________________________
73ae7b59 714void AliTRD::LoadPoints(Int_t )
793ff80c 715{
716 //
717 // Store x, y, z of all hits in memory.
718 // Hit originating from TR photons are given a different color
719 //
720
030b4415 721 if (fHits == 0) {
722 return;
723 }
793ff80c 724
030b4415 725 Int_t nhits = fHits->GetEntriesFast();
726 if (nhits == 0) {
727 return;
728 }
793ff80c 729
5d12ce38 730 Int_t tracks = gAlice->GetMCApp()->GetNtrack();
030b4415 731 if (fPoints == 0) {
732 fPoints = new TObjArray(tracks);
733 }
793ff80c 734
735 AliTRDhit *ahit;
736
737 Int_t *ntrkE = new Int_t[tracks];
738 Int_t *ntrkT = new Int_t[tracks];
739 Int_t *limiE = new Int_t[tracks];
740 Int_t *limiT = new Int_t[tracks];
741 Float_t **coorE = new Float_t*[tracks];
742 Float_t **coorT = new Float_t*[tracks];
743 for(Int_t i = 0; i < tracks; i++) {
744 ntrkE[i] = 0;
745 ntrkT[i] = 0;
746 coorE[i] = 0;
747 coorT[i] = 0;
748 limiE[i] = 0;
749 limiT[i] = 0;
750 }
751
332e9569 752 AliTRDpoints *points = 0;
753 Float_t *fp = 0;
754 Int_t trk;
755 Int_t chunk = nhits / 4 + 1;
793ff80c 756
757 // Loop over all the hits and store their position
332e9569 758 ahit = (AliTRDhit *) FirstHit(-1);
759 while (ahit) {
793ff80c 760
761 // dEdx hits
332e9569 762 if (ahit->GetCharge() >= 0) {
793ff80c 763
764 trk = ahit->GetTrack();
765 if (ntrkE[trk] == limiE[trk]) {
766 // Initialise a new track
767 fp = new Float_t[3*(limiE[trk]+chunk)];
768 if (coorE[trk]) {
769 memcpy(fp,coorE[trk],sizeof(Float_t)*3*limiE[trk]);
770 delete [] coorE[trk];
771 }
772 limiE[trk] += chunk;
773 coorE[trk] = fp;
774 }
775 else {
776 fp = coorE[trk];
777 }
778 fp[3*ntrkE[trk] ] = ahit->X();
779 fp[3*ntrkE[trk]+1] = ahit->Y();
780 fp[3*ntrkE[trk]+2] = ahit->Z();
781 ntrkE[trk]++;
782
783 }
784 // TR photon hits
030b4415 785 else if ((ahit->GetCharge() < 0) &&
786 (fDrawTR)) {
793ff80c 787
788 trk = ahit->GetTrack();
789 if (ntrkT[trk] == limiT[trk]) {
790 // Initialise a new track
791 fp = new Float_t[3*(limiT[trk]+chunk)];
792 if (coorT[trk]) {
793 memcpy(fp,coorT[trk],sizeof(Float_t)*3*limiT[trk]);
794 delete [] coorT[trk];
795 }
796 limiT[trk] += chunk;
797 coorT[trk] = fp;
798 }
799 else {
800 fp = coorT[trk];
801 }
802 fp[3*ntrkT[trk] ] = ahit->X();
803 fp[3*ntrkT[trk]+1] = ahit->Y();
804 fp[3*ntrkT[trk]+2] = ahit->Z();
805 ntrkT[trk]++;
806
807 }
808
332e9569 809 ahit = (AliTRDhit *) NextHit();
810
793ff80c 811 }
812
813 for (trk = 0; trk < tracks; ++trk) {
814
815 if (ntrkE[trk] || ntrkT[trk]) {
816
817 points = new AliTRDpoints();
818 points->SetDetector(this);
819 points->SetParticle(trk);
820
821 // Set the dEdx points
822 if (ntrkE[trk]) {
e939a978 823 points->SetMarkerColor(kWhite); //PH This is the default color in TRD
824 points->SetMarkerSize(1); //PH Default size=1
825 points->SetPolyMarker(ntrkE[trk],coorE[trk],1); //PH Default style=1
793ff80c 826 delete [] coorE[trk];
827 coorE[trk] = 0;
828 }
829
830 // Set the TR photon points
831 if (ntrkT[trk]) {
832 points->SetTRpoints(ntrkT[trk],coorT[trk]);
833 delete [] coorT[trk];
834 coorT[trk] = 0;
835 }
836
837 fPoints->AddAt(points,trk);
838
839 }
840
841 }
842
843 delete [] coorE;
844 delete [] coorT;
845 delete [] ntrkE;
846 delete [] ntrkT;
847 delete [] limiE;
848 delete [] limiT;
849
850}
851
5c7f4665 852//_____________________________________________________________________________
030b4415 853void AliTRD::MakeBranch(Option_t *option)
5c7f4665 854{
855 //
abaf1f1d 856 // Create Tree branches for the TRD digits.
5c7f4665 857 //
858
abaf1f1d 859 Int_t buffersize = 4000;
860 Char_t branchname[15];
861 sprintf(branchname,"%s",GetName());
5c7f4665 862
030b4415 863 const Char_t *cD = strstr(option,"D");
aa9d00f0 864
88cb7938 865 AliDetector::MakeBranch(option);
5c7f4665 866
030b4415 867 if (fDigits &&
868 gAlice->TreeD() &&
869 cD) {
88cb7938 870 MakeBranchInTree(gAlice->TreeD(),branchname,&fDigits,buffersize,0);
030b4415 871 }
abaf1f1d 872
851d3db9 873}
874
6244debe 875//_____________________________________________________________________________
876void AliTRD::ResetDigits()
877{
878 //
abaf1f1d 879 // Reset number of digits and the digits array for this detector
6244debe 880 //
881
abaf1f1d 882 fNdigits = 0;
030b4415 883
884 if (fDigits) {
885 fDigits->Clear();
886 }
6244debe 887
888}
889
5c7f4665 890//_____________________________________________________________________________
891void AliTRD::SetTreeAddress()
892{
893 //
894 // Set the branch addresses for the trees.
895 //
896
030b4415 897 if (fLoader->TreeH() &&
898 (fHits == 0x0)) {
a328fff9 899 fHits = new TClonesArray("AliTRDhit",405);
332e9569 900 }
a328fff9 901 AliDetector::SetTreeAddress();
332e9569 902
fe4da5cc 903}
904
dd9a6ee3 905//_____________________________________________________________________________
906AliTRD &AliTRD::operator=(const AliTRD &trd)
907{
908 //
909 // Assignment operator
910 //
911
0c5a8090 912 if (this != &trd) {
913 ((AliTRD &) trd).Copy(*this);
914 }
030b4415 915
dd9a6ee3 916 return *this;
917
f73816f5 918}
abaf1f1d 919
abaf1f1d 920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
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