Coding convention: RS1 violation -> suppression
[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
124//_____________________________________________________________________________
99d5402e 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
143//_____________________________________________________________________________
6244debe 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
fe4da5cc 272//_____________________________________________________________________________
b864d801 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
295//_____________________________________________________________________________
332e9569 296void AliTRD::AddHit(Int_t track, Int_t det, Float_t *hits, Int_t q
2fa01832 297 , Float_t time, Bool_t inDrift)
fe4da5cc 298{
299 //
300 // Add a hit for the TRD
332e9569 301 //
82bbf98a 302
a328fff9 303 TClonesArray &lhits = *fHits;
2fa01832 304 AliTRDhit *hit = new(lhits[fNhits++]) AliTRDhit(fIshunt
305 ,track
306 ,det
307 ,hits
308 ,q
309 ,time);
310
a328fff9 311 if (inDrift) {
312 hit->SetDrift();
332e9569 313 }
a328fff9 314 else {
315 hit->SetAmplification();
316 }
030b4415 317
a328fff9 318 if (q < 0) {
319 hit->SetTRphoton();
332e9569 320 }
82bbf98a 321
fe4da5cc 322}
323
324//_____________________________________________________________________________
325void AliTRD::BuildGeometry()
326{
327 //
328 // Create the ROOT TNode geometry for the TRD
329 //
82bbf98a 330
0c5a8090 331 TNode *node;
332 TNode *top;
fe4da5cc 333 TPGON *pgon;
793ff80c 334
0c5a8090 335 // The dimensions of the TRD super module
336 const Float_t kRmin = 291.0;
337 const Float_t kRmax = 369.0;
338 const Float_t kZmax1 = 378.35;
339 const Float_t kZmax2 = 302.0;
340
030b4415 341 Float_t rmin;
342 Float_t rmax;
343 Float_t zmax1;
344 Float_t zmax2;
db30bf0f 345
346 Int_t iPlan;
793ff80c 347
fe4da5cc 348 const Int_t kColorTRD = 46;
d3f347ff 349
fe4da5cc 350 // Find the top node alice
8230f242 351 top = gAlice->GetGeometry()->GetNode("alice");
d3f347ff 352
db30bf0f 353 if (fDisplayType == 0) {
793ff80c 354
355 pgon = new TPGON("S_TRD","TRD","void",0,360,AliTRDgeometry::Nsect(),4);
0c5a8090 356 rmin = kRmin;
357 rmax = kRmax;
358 pgon->DefineSection(0,-kZmax1,rmax,rmax);
359 pgon->DefineSection(1,-kZmax2,rmin,rmax);
360 pgon->DefineSection(2, kZmax2,rmin,rmax);
361 pgon->DefineSection(3, kZmax1,rmax,rmax);
793ff80c 362 top->cd();
363 node = new TNode("TRD","TRD","S_TRD",0,0,0,"");
364 node->SetLineColor(kColorTRD);
365 fNodes->Add(node);
366
db30bf0f 367 }
368 else if (fDisplayType == 1) {
793ff80c 369
f73816f5 370 Char_t name[7];
371
0c5a8090 372 Float_t slope = (kZmax1 - kZmax2) / (kRmax - kRmin);
793ff80c 373
0c5a8090 374 rmin = kRmin + AliTRDgeometry::CraHght();
375 rmax = rmin + AliTRDgeometry::CdrHght();
f73816f5 376
0c5a8090 377 Float_t thickness = rmin - kRmin;
378 zmax2 = kZmax2 + slope * thickness;
793ff80c 379 zmax1 = zmax2 + slope * AliTRDgeometry::DrThick();
793ff80c 380
db30bf0f 381 for (iPlan = 0; iPlan < AliTRDgeometry::Nplan(); iPlan++) {
793ff80c 382
f73816f5 383 sprintf(name,"S_TR1%d",iPlan);
384 pgon = new TPGON(name,"TRD","void",0,360,AliTRDgeometry::Nsect(),4);
385 pgon->DefineSection(0,-zmax1,rmax,rmax);
386 pgon->DefineSection(1,-zmax2,rmin,rmax);
387 pgon->DefineSection(2, zmax2,rmin,rmax);
388 pgon->DefineSection(3, zmax1,rmax,rmax);
389 top->cd();
390 node = new TNode("TRD","TRD",name,0,0,0,"");
391 node->SetLineColor(kColorTRD);
392 fNodes->Add(node);
393
394 Float_t height = AliTRDgeometry::Cheight() + AliTRDgeometry::Cspace();
395 rmin = rmin + height;
396 rmax = rmax + height;
397 zmax1 = zmax1 + slope * height;
398 zmax2 = zmax2 + slope * height;
399
400 }
401
402 thickness += AliTRDgeometry::DrThick();
0c5a8090 403 rmin = kRmin + thickness;
404 rmax = rmin + AliTRDgeometry::AmThick();
405 zmax2 = kZmax2 + slope * thickness;
406 zmax1 = zmax2 + slope * AliTRDgeometry::AmThick();
f73816f5 407
db30bf0f 408 for (iPlan = 0; iPlan < AliTRDgeometry::Nplan(); iPlan++) {
f73816f5 409
410 sprintf(name,"S_TR2%d",iPlan);
793ff80c 411 pgon = new TPGON(name,"TRD","void",0,360,AliTRDgeometry::Nsect(),4);
412 pgon->DefineSection(0,-zmax1,rmax,rmax);
413 pgon->DefineSection(1,-zmax2,rmin,rmax);
414 pgon->DefineSection(2, zmax2,rmin,rmax);
415 pgon->DefineSection(3, zmax1,rmax,rmax);
416 top->cd();
417 node = new TNode("TRD","TRD",name,0,0,0,"");
418 node->SetLineColor(kColorTRD);
419 fNodes->Add(node);
420
421 Float_t height = AliTRDgeometry::Cheight() + AliTRDgeometry::Cspace();
422 rmin = rmin + height;
423 rmax = rmax + height;
424 zmax1 = zmax1 + slope * height;
425 zmax2 = zmax2 + slope * height;
426
427 }
428
db30bf0f 429 }
d3f347ff 430
fe4da5cc 431}
432
433//_____________________________________________________________________________
82bbf98a 434void AliTRD::CreateGeometry()
fe4da5cc 435{
82bbf98a 436 //
437 // Creates the volumes for the TRD chambers
438 //
82bbf98a 439
440 // Check that FRAME is there otherwise we have no place where to put the TRD
030b4415 441 AliModule *frame = gAlice->GetModule("FRAME");
8230f242 442 if (!frame) {
45160b1f 443 AliFatal("The TRD needs the FRAME to be defined first");
82bbf98a 444 }
d3f347ff 445
851d3db9 446 fGeometry->CreateGeometry(fIdtmed->GetArray() - 1299);
5c7f4665 447
82bbf98a 448}
449
450//_____________________________________________________________________________
451void AliTRD::CreateMaterials()
452{
fe4da5cc 453 //
454 // Create the materials for the TRD
fe4da5cc 455 //
456
8230f242 457 Int_t isxfld = gAlice->Field()->Integ();
458 Float_t sxmgmx = gAlice->Field()->Max();
fe4da5cc 459
d3f347ff 460 // For polyethilene (CH2)
030b4415 461 Float_t ape[2] = { 12.011 , 1.0079 };
462 Float_t zpe[2] = { 6.0 , 1.0 };
463 Float_t wpe[2] = { 1.0 , 2.0 };
464 Float_t dpe = 0.95;
d3f347ff 465
d3f347ff 466 // For CO2
030b4415 467 Float_t aco[2] = { 12.011 , 15.9994 };
468 Float_t zco[2] = { 6.0 , 8.0 };
469 Float_t wco[2] = { 1.0 , 2.0 };
470 Float_t dco = 0.00186;
d3f347ff 471
472 // For water
030b4415 473 Float_t awa[2] = { 1.0079, 15.9994 };
474 Float_t zwa[2] = { 1.0 , 8.0 };
475 Float_t wwa[2] = { 2.0 , 1.0 };
476 Float_t dwa = 1.0;
d3f347ff 477
478 // For isobutane (C4H10)
030b4415 479 Float_t ais[2] = { 12.011 , 1.0079 };
480 Float_t zis[2] = { 6.0 , 1.0 };
481 Float_t wis[2] = { 4.0 , 10.0 };
482 Float_t dis = 0.00267;
d3f347ff 483
db30bf0f 484 // For plexiglas (C5H8O2)
030b4415 485 Float_t apg[3] = { 12.011 , 1.0079, 15.9994 };
486 Float_t zpg[3] = { 6.0 , 1.0 , 8.0 };
487 Float_t wpg[3] = { 5.0 , 8.0 , 2.0 };
488 Float_t dpg = 1.18;
08ca3951 489
490 // For epoxy (C18H19O3)
3dac2b2d 491 Float_t aEpoxy[3] = { 15.9994, 1.0079, 12.011 };
492 Float_t zEpoxy[3] = { 8.0 , 1.0 , 6.0 };
493 Float_t wEpoxy[3] = { 3.0 , 19.0 , 18.0 };
08ca3951 494 Float_t dEpoxy = 1.8 ;
495
0c5a8090 496 // For Araldite, low density epoxy (C18H19O3)
497 Float_t aAral[3] = { 15.9994, 1.0079, 12.011 };
498 Float_t zAral[3] = { 8.0 , 1.0 , 6.0 };
499 Float_t wAral[3] = { 3.0 , 19.0 , 18.0 };
500 Float_t dAral = 1.05;
501
08ca3951 502 // For air
3dac2b2d 503 Float_t aAir[4] = { 12.011 , 14.0 , 15.9994 , 36.0 };
504 Float_t zAir[4] = { 6.0 , 7.0 , 8.0 , 18.0 };
505 Float_t wAir[4] = { 0.000124, 0.755267, 0.231781, 0.012827 };
0c5a8090 506 Float_t dAir = 1.20479e-03;
08ca3951 507
508 // For G10
3dac2b2d 509 Float_t aG10[4] = { 1.0079 , 12.011 , 15.9994 , 28.086 };
510 Float_t zG10[4] = { 1.0 , 6.0 , 8.0 , 14.0 };
511 Float_t wG10[4] = { 0.15201 , 0.10641 , 0.49444 , 0.24714 };
08ca3951 512 Float_t dG10 = 1.7;
db30bf0f 513
d3f347ff 514 // For Xe/CO2-gas-mixture
3dac2b2d 515 Float_t aXeCO2[3] = { 131.29 , 12.0107 , 15.9994 };
516 Float_t zXeCO2[3] = { 54.0 , 6.0 , 8.0 };
330bfc2f 517 Float_t wXeCO2[3] = { 8.5 , 1.5 , 3.0 };
db30bf0f 518 // Xe-content of the Xe/CO2-mixture (85% / 15%)
3dac2b2d 519 Float_t fxc = 0.85;
520 Float_t dxe = 0.00549;
521 Float_t dgm = fxc * dxe + (1.0 - fxc) * dco;
fe4da5cc 522
d3f347ff 523 // General tracking parameter
030b4415 524 Float_t tmaxfd = -10.0;
525 Float_t stemax = -1.0e10;
526 Float_t deemax = -0.1;
527 Float_t epsil = 1.0e-4;
528 Float_t stmin = -0.001;
fe4da5cc 529
d3f347ff 530 //////////////////////////////////////////////////////////////////////////
fe4da5cc 531 // Define Materials
d3f347ff 532 //////////////////////////////////////////////////////////////////////////
533
16bf9884 534 AliMaterial( 1, "Al" , 26.98, 13.0, 2.7 , 8.9 , 37.2);
3dac2b2d 535 AliMaterial( 4, "Xe" , 131.29, 54.0, dxe , 1546.16, 0.0);
16bf9884 536 AliMaterial( 5, "Cu" , 63.54, 29.0, 8.96 , 1.43, 14.8);
537 AliMaterial( 6, "C" , 12.01, 6.0, 2.265 , 18.8 , 74.4);
16bf9884 538 AliMaterial(15, "Sn" , 118.71, 50.0, 7.31 , 1.21, 14.8);
539 AliMaterial(16, "Si" , 28.09, 14.0, 2.33 , 9.36, 37.2);
0c5a8090 540 AliMaterial(18, "Fe" , 55.85, 26.0, 7.87 , 1.76, 14.8);
d3f347ff 541
542 // Mixtures
3dac2b2d 543 AliMixture(2, "Air" , aAir, zAir, dAir, 4, wAir );
544 AliMixture(3, "Polyethilene", ape, zpe, dpe, -2, wpe );
3dac2b2d 545 AliMixture(8, "CO2", aco, zco, dco, -2, wco );
546 AliMixture(9, "Isobutane", ais, zis, dis, -2, wis );
330bfc2f 547 AliMixture(10,"Gas mixture", aXeCO2, zXeCO2, dgm, -3, wXeCO2);
3dac2b2d 548 AliMixture(12,"G10", aG10, zG10, dG10, 4, wG10 );
549 AliMixture(13,"Water", awa, zwa, dwa, -2, wwa );
550 AliMixture(14,"Plexiglas", apg, zpg, dpg, -3, wpg );
551 AliMixture(17,"Epoxy", aEpoxy, zEpoxy, dEpoxy, -3, wEpoxy);
0c5a8090 552 AliMixture(19,"Araldite", aAral, zAral, dAral, -3, wAral );
3dac2b2d 553
d3f347ff 554 //////////////////////////////////////////////////////////////////////////
fe4da5cc 555 // Tracking Media Parameters
d3f347ff 556 //////////////////////////////////////////////////////////////////////////
557
558 // Al Frame
0c5a8090 559 AliMedium( 1,"Al Frame" , 1,0,isxfld,sxmgmx
560 ,tmaxfd,stemax,deemax,epsil,stmin);
d3f347ff 561 // Air
0c5a8090 562 AliMedium( 2,"Air" , 2,0,isxfld,sxmgmx
563 ,tmaxfd,stemax,deemax,epsil,stmin);
564 // Wires
565 AliMedium( 3,"Wires" , 5,0,isxfld,sxmgmx
566 ,tmaxfd,stemax,deemax,epsil,stmin);
567 // All other ROB materials (caps, etc.)
568 AliMedium( 4,"ROB Other" , 5,0,isxfld,sxmgmx
569 ,tmaxfd,stemax,deemax,epsil,stmin);
d3f347ff 570 // Cu pads
0c5a8090 571 AliMedium( 5,"Padplane" , 5,1,isxfld,sxmgmx
572 ,tmaxfd,stemax,deemax,epsil,stmin);
d3f347ff 573 // Fee + cables
0c5a8090 574 AliMedium( 6,"Readout" , 5,0,isxfld,sxmgmx
575 ,tmaxfd,stemax,deemax,epsil,stmin);
d3f347ff 576 // C frame
0c5a8090 577 AliMedium( 7,"C Frame" , 6,0,isxfld,sxmgmx
578 ,tmaxfd,stemax,deemax,epsil,stmin);
579 // INOX of cooling bus bars
580 AliMedium( 8,"Cooling bus",18,0,isxfld,sxmgmx
581 ,tmaxfd,stemax,deemax,epsil,stmin);
3dac2b2d 582 // Gas-mixture (Xe/CO2)
0c5a8090 583 AliMedium( 9,"Gas-mix" ,10,1,isxfld,sxmgmx
584 ,tmaxfd,stemax,deemax,epsil,stmin);
585 // Nomex-honeycomb
586 AliMedium(10,"Nomex" ,12,0,isxfld,sxmgmx
587 ,tmaxfd,stemax,deemax,epsil,stmin);
588 // Araldite glue
589 AliMedium(11,"Glue" ,19,0,isxfld,sxmgmx
590 ,tmaxfd,stemax,deemax,epsil,stmin);
d3f347ff 591 // G10-plates
0c5a8090 592 AliMedium(13,"G10-plates" ,12,0,isxfld,sxmgmx
593 ,tmaxfd,stemax,deemax,epsil,stmin);
d3f347ff 594 // Cooling water
0c5a8090 595 AliMedium(14,"Water" ,13,0,isxfld,sxmgmx
596 ,tmaxfd,stemax,deemax,epsil,stmin);
db30bf0f 597 // Rohacell (plexiglas) for the radiator
0c5a8090 598 AliMedium(15,"Rohacell" ,14,0,isxfld,sxmgmx
599 ,tmaxfd,stemax,deemax,epsil,stmin);
16bf9884 600 // Al layer in MCMs
0c5a8090 601 AliMedium(16,"MCM-Al" , 1,0,isxfld,sxmgmx
602 ,tmaxfd,stemax,deemax,epsil,stmin);
16bf9884 603 // Sn layer in MCMs
0c5a8090 604 AliMedium(17,"MCM-Sn" ,15,0,isxfld,sxmgmx
605 ,tmaxfd,stemax,deemax,epsil,stmin);
16bf9884 606 // Cu layer in MCMs
0c5a8090 607 AliMedium(18,"MCM-Cu" , 5,0,isxfld,sxmgmx
608 ,tmaxfd,stemax,deemax,epsil,stmin);
16bf9884 609 // G10 layer in MCMs
0c5a8090 610 AliMedium(19,"MCM-G10" ,12,0,isxfld,sxmgmx
611 ,tmaxfd,stemax,deemax,epsil,stmin);
16bf9884 612 // Si in readout chips
0c5a8090 613 AliMedium(20,"Chip-Si" ,16,0,isxfld,sxmgmx
614 ,tmaxfd,stemax,deemax,epsil,stmin);
16bf9884 615 // Epoxy in readout chips
0c5a8090 616 AliMedium(21,"Chip-Ep" ,17,0,isxfld,sxmgmx
617 ,tmaxfd,stemax,deemax,epsil,stmin);
16bf9884 618 // PE in connectors
0c5a8090 619 AliMedium(22,"Conn-PE" , 3,0,isxfld,sxmgmx
620 ,tmaxfd,stemax,deemax,epsil,stmin);
16bf9884 621 // Cu in connectors
0c5a8090 622 AliMedium(23,"Chip-Cu" , 5,0,isxfld,sxmgmx
623 ,tmaxfd,stemax,deemax,epsil,stmin);
16bf9884 624 // Al of cooling pipes
0c5a8090 625 AliMedium(24,"Cooling" , 1,0,isxfld,sxmgmx
626 ,tmaxfd,stemax,deemax,epsil,stmin);
73ae7b59 627 // Cu in services
0c5a8090 628 AliMedium(25,"Serv-Cu" , 5,0,isxfld,sxmgmx
629 ,tmaxfd,stemax,deemax,epsil,stmin);
d3f347ff 630
793ff80c 631 // Save the density values for the TRD absorbtion
0c5a8090 632 Float_t dmy = 1.39;
793ff80c 633 fFoilDensity = dmy;
3dac2b2d 634 fGasDensity = dgm;
793ff80c 635
fe4da5cc 636}
637
638//_____________________________________________________________________________
ba380e33 639void AliTRD::DrawModule() const
82bbf98a 640{
641 //
642 // Draw a shaded view of the Transition Radiation Detector version 0
643 //
644
645 // Set everything unseen
646 gMC->Gsatt("*" ,"SEEN",-1);
647
648 // Set ALIC mother transparent
649 gMC->Gsatt("ALIC","SEEN", 0);
650
651 // Set the volumes visible
851d3db9 652 if (fGeometry->IsVersion() == 0) {
5c7f4665 653 gMC->Gsatt("B071","SEEN", 0);
654 gMC->Gsatt("B074","SEEN", 0);
655 gMC->Gsatt("B075","SEEN", 0);
656 gMC->Gsatt("B077","SEEN", 0);
657 gMC->Gsatt("BTR1","SEEN", 0);
658 gMC->Gsatt("BTR2","SEEN", 0);
659 gMC->Gsatt("BTR3","SEEN", 0);
332e9569 660 gMC->Gsatt("UTR1","SEEN", 0);
661 gMC->Gsatt("UTR2","SEEN", 0);
662 gMC->Gsatt("UTR3","SEEN", 0);
5c7f4665 663 }
664 else {
665 gMC->Gsatt("B071","SEEN", 0);
666 gMC->Gsatt("B074","SEEN", 0);
667 gMC->Gsatt("B075","SEEN", 0);
668 gMC->Gsatt("B077","SEEN", 0);
669 gMC->Gsatt("BTR1","SEEN", 0);
670 gMC->Gsatt("BTR2","SEEN", 0);
671 gMC->Gsatt("BTR3","SEEN", 0);
332e9569 672 gMC->Gsatt("UTR1","SEEN", 0);
5c7f4665 673 }
82bbf98a 674
675 gMC->Gdopt("hide", "on");
676 gMC->Gdopt("shad", "on");
677 gMC->Gsatt("*", "fill", 7);
678 gMC->SetClipBox(".");
679 gMC->SetClipBox("*", 0, 2000, -2000, 2000, -2000, 2000);
680 gMC->DefaultRange();
681 gMC->Gdraw("alic", 40, 30, 0, 12, 9.4, .021, .021);
682 gMC->Gdhead(1111, "Transition Radiation Detector");
683 gMC->Gdman(18, 4, "MAN");
684
685}
686
687//_____________________________________________________________________________
e0d47c25 688Int_t AliTRD::DistancetoPrimitive(Int_t , Int_t )
fe4da5cc 689{
690 //
691 // Distance between the mouse and the TRD detector on the screen
692 // Dummy routine
030b4415 693 //
82bbf98a 694
695 return 9999;
696
fe4da5cc 697}
698
699//_____________________________________________________________________________
700void AliTRD::Init()
701{
702 //
851d3db9 703 // Initialize the TRD detector after the geometry has been created
fe4da5cc 704 //
82bbf98a 705
45160b1f 706 AliDebug(1,"++++++++++++++++++++++++++++++++++++++++++++++");
5c7f4665 707
bd0f8685 708 if (fGeometry->IsVersion() != 1) {
45160b1f 709 AliError("Not a valid geometry");
d37eec5e 710 }
7235aed2 711 // Special tracking options for charged particles for XeCO2
712 gMC->Gstpar((* fIdtmed)[9],"DRAY",1.0);
713 gMC->Gstpar((* fIdtmed)[9],"STRA",1.0);
9e1a0ddb 714
5c7f4665 715}
716
717//_____________________________________________________________________________
73ae7b59 718void AliTRD::LoadPoints(Int_t )
793ff80c 719{
720 //
721 // Store x, y, z of all hits in memory.
722 // Hit originating from TR photons are given a different color
723 //
724
030b4415 725 if (fHits == 0) {
726 return;
727 }
793ff80c 728
030b4415 729 Int_t nhits = fHits->GetEntriesFast();
730 if (nhits == 0) {
731 return;
732 }
793ff80c 733
5d12ce38 734 Int_t tracks = gAlice->GetMCApp()->GetNtrack();
030b4415 735 if (fPoints == 0) {
736 fPoints = new TObjArray(tracks);
737 }
793ff80c 738
739 AliTRDhit *ahit;
740
741 Int_t *ntrkE = new Int_t[tracks];
742 Int_t *ntrkT = new Int_t[tracks];
743 Int_t *limiE = new Int_t[tracks];
744 Int_t *limiT = new Int_t[tracks];
745 Float_t **coorE = new Float_t*[tracks];
746 Float_t **coorT = new Float_t*[tracks];
747 for(Int_t i = 0; i < tracks; i++) {
748 ntrkE[i] = 0;
749 ntrkT[i] = 0;
750 coorE[i] = 0;
751 coorT[i] = 0;
752 limiE[i] = 0;
753 limiT[i] = 0;
754 }
755
332e9569 756 AliTRDpoints *points = 0;
757 Float_t *fp = 0;
758 Int_t trk;
759 Int_t chunk = nhits / 4 + 1;
793ff80c 760
761 // Loop over all the hits and store their position
332e9569 762 ahit = (AliTRDhit *) FirstHit(-1);
763 while (ahit) {
793ff80c 764
765 // dEdx hits
332e9569 766 if (ahit->GetCharge() >= 0) {
793ff80c 767
768 trk = ahit->GetTrack();
769 if (ntrkE[trk] == limiE[trk]) {
770 // Initialise a new track
771 fp = new Float_t[3*(limiE[trk]+chunk)];
772 if (coorE[trk]) {
773 memcpy(fp,coorE[trk],sizeof(Float_t)*3*limiE[trk]);
774 delete [] coorE[trk];
775 }
776 limiE[trk] += chunk;
777 coorE[trk] = fp;
778 }
779 else {
780 fp = coorE[trk];
781 }
782 fp[3*ntrkE[trk] ] = ahit->X();
783 fp[3*ntrkE[trk]+1] = ahit->Y();
784 fp[3*ntrkE[trk]+2] = ahit->Z();
785 ntrkE[trk]++;
786
787 }
788 // TR photon hits
030b4415 789 else if ((ahit->GetCharge() < 0) &&
790 (fDrawTR)) {
793ff80c 791
792 trk = ahit->GetTrack();
793 if (ntrkT[trk] == limiT[trk]) {
794 // Initialise a new track
795 fp = new Float_t[3*(limiT[trk]+chunk)];
796 if (coorT[trk]) {
797 memcpy(fp,coorT[trk],sizeof(Float_t)*3*limiT[trk]);
798 delete [] coorT[trk];
799 }
800 limiT[trk] += chunk;
801 coorT[trk] = fp;
802 }
803 else {
804 fp = coorT[trk];
805 }
806 fp[3*ntrkT[trk] ] = ahit->X();
807 fp[3*ntrkT[trk]+1] = ahit->Y();
808 fp[3*ntrkT[trk]+2] = ahit->Z();
809 ntrkT[trk]++;
810
811 }
812
332e9569 813 ahit = (AliTRDhit *) NextHit();
814
793ff80c 815 }
816
817 for (trk = 0; trk < tracks; ++trk) {
818
819 if (ntrkE[trk] || ntrkT[trk]) {
820
821 points = new AliTRDpoints();
822 points->SetDetector(this);
823 points->SetParticle(trk);
824
825 // Set the dEdx points
826 if (ntrkE[trk]) {
e939a978 827 points->SetMarkerColor(kWhite); //PH This is the default color in TRD
828 points->SetMarkerSize(1); //PH Default size=1
829 points->SetPolyMarker(ntrkE[trk],coorE[trk],1); //PH Default style=1
793ff80c 830 delete [] coorE[trk];
831 coorE[trk] = 0;
832 }
833
834 // Set the TR photon points
835 if (ntrkT[trk]) {
836 points->SetTRpoints(ntrkT[trk],coorT[trk]);
837 delete [] coorT[trk];
838 coorT[trk] = 0;
839 }
840
841 fPoints->AddAt(points,trk);
842
843 }
844
845 }
846
847 delete [] coorE;
848 delete [] coorT;
849 delete [] ntrkE;
850 delete [] ntrkT;
851 delete [] limiE;
852 delete [] limiT;
853
854}
855
856//_____________________________________________________________________________
030b4415 857void AliTRD::MakeBranch(Option_t *option)
5c7f4665 858{
859 //
abaf1f1d 860 // Create Tree branches for the TRD digits.
5c7f4665 861 //
862
abaf1f1d 863 Int_t buffersize = 4000;
864 Char_t branchname[15];
865 sprintf(branchname,"%s",GetName());
5c7f4665 866
030b4415 867 const Char_t *cD = strstr(option,"D");
aa9d00f0 868
88cb7938 869 AliDetector::MakeBranch(option);
5c7f4665 870
030b4415 871 if (fDigits &&
872 gAlice->TreeD() &&
873 cD) {
88cb7938 874 MakeBranchInTree(gAlice->TreeD(),branchname,&fDigits,buffersize,0);
030b4415 875 }
abaf1f1d 876
851d3db9 877}
878
879//_____________________________________________________________________________
6244debe 880void AliTRD::ResetDigits()
881{
882 //
abaf1f1d 883 // Reset number of digits and the digits array for this detector
6244debe 884 //
885
abaf1f1d 886 fNdigits = 0;
030b4415 887
888 if (fDigits) {
889 fDigits->Clear();
890 }
6244debe 891
892}
893
894//_____________________________________________________________________________
5c7f4665 895void AliTRD::SetTreeAddress()
896{
897 //
898 // Set the branch addresses for the trees.
899 //
900
030b4415 901 if (fLoader->TreeH() &&
902 (fHits == 0x0)) {
a328fff9 903 fHits = new TClonesArray("AliTRDhit",405);
332e9569 904 }
a328fff9 905 AliDetector::SetTreeAddress();
332e9569 906
fe4da5cc 907}
908
d3f347ff 909//_____________________________________________________________________________
dd9a6ee3 910AliTRD &AliTRD::operator=(const AliTRD &trd)
911{
912 //
913 // Assignment operator
914 //
915
0c5a8090 916 if (this != &trd) {
917 ((AliTRD &) trd).Copy(*this);
918 }
030b4415 919
dd9a6ee3 920 return *this;
921
f73816f5 922}
abaf1f1d 923
abaf1f1d 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
1254
1255
1256
1257