]> git.uio.no Git - u/mrichter/AliRoot.git/blame - TRD/AliTRD.cxx
Using default task names. Cleaning the task in the destructor if it was posted
[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"
88cb7938 46#include "AliTRDcluster.h"
47#include "AliTRDclusterizer.h"
793ff80c 48#include "AliTRDdigit.h"
851d3db9 49#include "AliTRDdigitizer.h"
88cb7938 50#include "AliTRDdigitsManager.h"
851d3db9 51#include "AliTRDgeometryFull.h"
88cb7938 52#include "AliTRDgeometryHole.h"
53#include "AliTRDhit.h"
54#include "AliTRDpoints.h"
851d3db9 55#include "AliTRDrecPoint.h"
332e9569 56#include "AliTRDtrackHits.h"
88cb7938 57#include "AliTrackReference.h"
5d12ce38 58#include "AliMC.h"
596a855f 59#include "AliTRDclusterizerV1.h"
60#include "AliTRDparameter.h"
61#include "AliTRDtracker.h"
793ff80c 62
fe4da5cc 63ClassImp(AliTRD)
64
65//_____________________________________________________________________________
66AliTRD::AliTRD()
67{
68 //
69 // Default constructor
70 //
82bbf98a 71
6244debe 72 fIshunt = 0;
73 fGasMix = 0;
74 fHits = 0;
75 fDigits = 0;
5c7f4665 76
6244debe 77 fRecPoints = 0;
78 fNRecPoints = 0;
5c7f4665 79
6244debe 80 fGeometry = 0;
82bbf98a 81
6244debe 82 fGasDensity = 0;
83 fFoilDensity = 0;
793ff80c 84
6244debe 85 fDrawTR = 0;
332e9569 86 fDisplayType = 0;
87
88 fTrackHits = 0;
89 fHitType = 0;
6244debe 90
fe4da5cc 91}
92
93//_____________________________________________________________________________
94AliTRD::AliTRD(const char *name, const char *title)
95 : AliDetector(name,title)
96{
97 //
98 // Standard constructor for the TRD
99 //
100
5c7f4665 101 // Check that FRAME is there otherwise we have no place where to
102 // put TRD
8230f242 103 AliModule* frame = gAlice->GetModule("FRAME");
104 if (!frame) {
5c7f4665 105 Error("Ctor","TRD needs FRAME to be present\n");
106 exit(1);
107 }
108
109 // Define the TRD geometry according to the FRAME geometry
8230f242 110 if (frame->IsVersion() == 0) {
851d3db9 111 // Geometry with hole
112 fGeometry = new AliTRDgeometryHole();
113 }
8230f242 114 else if (frame->IsVersion() == 1) {
851d3db9 115 // Geometry without hole
116 fGeometry = new AliTRDgeometryFull();
117 }
118 else {
119 Error("Ctor","Could not find valid FRAME version\n");
120 exit(1);
121 }
5c7f4665 122
fe4da5cc 123 // Allocate the hit array
f73816f5 124 fHits = new TClonesArray("AliTRDhit" ,405);
5d12ce38 125 gAlice->GetMCApp()->AddHitList(fHits);
99d5402e 126
127 // Allocate the digits array
f73816f5 128 fDigits = 0;
5c7f4665 129
851d3db9 130 // Allocate the rec point array
6244debe 131 fRecPoints = new TObjArray(400);
132 fNRecPoints = 0;
99d5402e 133
6244debe 134 fIshunt = 0;
135 fGasMix = 1;
793ff80c 136
6244debe 137 fGasDensity = 0;
138 fFoilDensity = 0;
793ff80c 139
6244debe 140 fDrawTR = 0;
141 fDisplayType = 0;
142
332e9569 143 fTrackHits = 0;
144 fHitType = 2;
145
fe4da5cc 146 SetMarkerColor(kWhite);
82bbf98a 147
fe4da5cc 148}
99d5402e 149
8230f242 150//_____________________________________________________________________________
73ae7b59 151AliTRD::AliTRD(const AliTRD &trd):AliDetector(trd)
8230f242 152{
153 //
154 // Copy constructor
155 //
156
dd9a6ee3 157 ((AliTRD &) trd).Copy(*this);
8230f242 158
159}
160
99d5402e 161//_____________________________________________________________________________
162AliTRD::~AliTRD()
163{
164 //
165 // TRD destructor
166 //
167
168 fIshunt = 0;
169
abaf1f1d 170 if (fGeometry) {
171 delete fGeometry;
332e9569 172 fGeometry = 0;
abaf1f1d 173 }
174 if (fHits) {
175 delete fHits;
332e9569 176 fHits = 0;
abaf1f1d 177 }
178 if (fRecPoints) {
179 delete fRecPoints;
332e9569 180 fRecPoints = 0;
181 }
182 if (fTrackHits) {
183 delete fTrackHits;
184 fTrackHits = 0;
6244debe 185 }
5c7f4665 186
187}
188
189//_____________________________________________________________________________
5443e65e 190void AliTRD::AddCluster(Float_t *pos, Int_t det, Float_t amp
191 , Int_t *tracks, Float_t *sig, Int_t iType)
5c7f4665 192{
193 //
f73816f5 194 // Add a cluster for the TRD
851d3db9 195 //
793ff80c 196
f73816f5 197 AliTRDcluster *c = new AliTRDcluster();
198
199 c->SetDetector(det);
200 c->AddTrackIndex(tracks);
f73816f5 201 c->SetQ(amp);
5443e65e 202 c->SetY(pos[0]);
203 c->SetZ(pos[1]);
204 c->SetSigmaY2(sig[0]);
205 c->SetSigmaZ2(sig[1]);
f73816f5 206 c->SetLocalTimeBin(((Int_t) pos[2]));
f73816f5 207
db30bf0f 208 switch (iType) {
209 case 0:
210 c->Set2pad();
211 break;
212 case 1:
213 c->Set3pad();
214 break;
215 case 2:
216 c->Set4pad();
217 break;
218 case 3:
219 c->Set5pad();
220 break;
221 case 4:
222 c->SetLarge();
223 break;
224 };
793ff80c 225
f73816f5 226 fRecPoints->Add(c);
6f1e466d 227
99d5402e 228}
6244debe 229
230//_____________________________________________________________________________
231void AliTRD::Hits2Digits()
2ab0c725 232{
233 //
234 // Create digits
235 //
6244debe 236 AliTRDdigitizer *digitizer = new AliTRDdigitizer("TRDdigitizer"
237 ,"TRD digitizer class");
332e9569 238 digitizer->SetDebug(GetDebug());
88cb7938 239
6244debe 240 // Initialization
db30bf0f 241 digitizer->InitDetector();
6244debe 242
85a5290f 243 if (!fLoader->TreeH()) fLoader->LoadHits("read");
244 fLoader->LoadDigits("recreate");
245 AliRunLoader* runLoader = fLoader->GetRunLoader();
6244debe 246
85a5290f 247 for (Int_t iEvent = 0; iEvent < runLoader->GetNumberOfEvents(); iEvent++) {
248 digitizer->Open(runLoader->GetFileName().Data(), iEvent);
249 digitizer->MakeDigits();
6244debe 250 digitizer->WriteDigits();
6244debe 251 }
252
85a5290f 253 fLoader->UnloadHits();
254 fLoader->UnloadDigits();
6244debe 255}
256
257//_____________________________________________________________________________
258void AliTRD::Hits2SDigits()
259{
260 //
261 // Create summable digits
262 //
6244debe 263 AliTRDdigitizer *digitizer = new AliTRDdigitizer("TRDdigitizer"
264 ,"TRD digitizer class");
6244debe 265 // For the summable digits
266 digitizer->SetSDigits(kTRUE);
85a5290f 267 digitizer->SetDebug(GetDebug());
6244debe 268
269 // Initialization
db30bf0f 270 digitizer->InitDetector();
2ab0c725 271
85a5290f 272 if (!fLoader->TreeH()) fLoader->LoadHits("read");
273 fLoader->LoadSDigits("recreate");
274 AliRunLoader* runLoader = fLoader->GetRunLoader();
6244debe 275
85a5290f 276 for (Int_t iEvent = 0; iEvent < runLoader->GetNumberOfEvents(); iEvent++) {
277 digitizer->Open(runLoader->GetFileName().Data(), iEvent);
278 digitizer->MakeDigits();
6244debe 279 digitizer->WriteDigits();
85a5290f 280 }
2ab0c725 281
85a5290f 282 fLoader->UnloadHits();
283 fLoader->UnloadSDigits();
2ab0c725 284 }
6244debe 285
85a5290f 286//_____________________________________________________________________________
c92eb8ad 287AliDigitizer* AliTRD::CreateDigitizer(AliRunDigitizer* manager) const
85a5290f 288{
289 return new AliTRDdigitizer(manager);
6244debe 290}
291
292//_____________________________________________________________________________
293void AliTRD::SDigits2Digits()
294{
295 //
296 // Create final digits from summable digits
297 //
298
abaf1f1d 299 // Create the TRD digitizer
300 AliTRDdigitizer *digitizer = new AliTRDdigitizer("TRDdigitizer"
301 ,"TRD digitizer class");
332e9569 302 digitizer->SetDebug(GetDebug());
99d5402e 303
abaf1f1d 304 // Set the parameter
305 digitizer->SetEvent(gAlice->GetEvNumber());
306
307 // Initialization
308 digitizer->InitDetector();
309
310 // Read the s-digits via digits manager
311 AliTRDdigitsManager *sdigitsManager = new AliTRDdigitsManager();
88cb7938 312
332e9569 313 sdigitsManager->SetDebug(GetDebug());
abaf1f1d 314 sdigitsManager->SetSDigits(kTRUE);
abaf1f1d 315 sdigitsManager->CreateArrays();
88cb7938 316
317 if (!fLoader->TreeS())
318 if (fLoader->LoadSDigits("read"))
319 {
320 Error("SDigits2Digits","Error while reading SDigits for event %d",gAlice->GetEvNumber());
321 return;
322 }
323 if (!fLoader->TreeS()) return;
324
325 sdigitsManager->ReadDigits(fLoader->TreeS());
abaf1f1d 326
327 // Add the s-digits to the input list
328 digitizer->AddSDigitsManager(sdigitsManager);
99d5402e 329
abaf1f1d 330 // Convert the s-digits to normal digits
331 digitizer->SDigits2Digits();
332
333 // Store the digits
88cb7938 334 if (!fLoader->TreeD()) fLoader->MakeTree("D");
335 if (digitizer->MakeBranch(fLoader->TreeD())){
abaf1f1d 336 digitizer->WriteDigits();
abaf1f1d 337 }
99d5402e 338
339}
340
fe4da5cc 341//_____________________________________________________________________________
332e9569 342void AliTRD::AddHit(Int_t track, Int_t det, Float_t *hits, Int_t q
343 , Bool_t inDrift)
fe4da5cc 344{
345 //
346 // Add a hit for the TRD
332e9569 347 //
348 // The data structure is set according to fHitType:
349 // bit0: standard TClonesArray
350 // bit1: compressed trackHits structure
fe4da5cc 351 //
82bbf98a 352
332e9569 353 if (fHitType & 1) {
354 TClonesArray &lhits = *fHits;
355 new(lhits[fNhits++]) AliTRDhit(fIshunt,track,det,hits,q);
356 }
357
358 if (fHitType > 1) {
359 AddHit2(track,det,hits,q,inDrift);
360 }
82bbf98a 361
fe4da5cc 362}
363
364//_____________________________________________________________________________
365void AliTRD::BuildGeometry()
366{
367 //
368 // Create the ROOT TNode geometry for the TRD
369 //
82bbf98a 370
8230f242 371 TNode *node, *top;
fe4da5cc 372 TPGON *pgon;
793ff80c 373
374 Float_t rmin, rmax;
375 Float_t zmax1, zmax2;
db30bf0f 376
377 Int_t iPlan;
793ff80c 378
fe4da5cc 379 const Int_t kColorTRD = 46;
d3f347ff 380
fe4da5cc 381 // Find the top node alice
8230f242 382 top = gAlice->GetGeometry()->GetNode("alice");
d3f347ff 383
db30bf0f 384 if (fDisplayType == 0) {
793ff80c 385
386 pgon = new TPGON("S_TRD","TRD","void",0,360,AliTRDgeometry::Nsect(),4);
387 rmin = AliTRDgeometry::Rmin();
388 rmax = AliTRDgeometry::Rmax();
389 pgon->DefineSection(0,-AliTRDgeometry::Zmax1(),rmax,rmax);
390 pgon->DefineSection(1,-AliTRDgeometry::Zmax2(),rmin,rmax);
391 pgon->DefineSection(2, AliTRDgeometry::Zmax2(),rmin,rmax);
392 pgon->DefineSection(3, AliTRDgeometry::Zmax1(),rmax,rmax);
393 top->cd();
394 node = new TNode("TRD","TRD","S_TRD",0,0,0,"");
395 node->SetLineColor(kColorTRD);
396 fNodes->Add(node);
397
db30bf0f 398 }
399 else if (fDisplayType == 1) {
793ff80c 400
f73816f5 401 Char_t name[7];
402
793ff80c 403 Float_t slope = (AliTRDgeometry::Zmax1() - AliTRDgeometry::Zmax2())
404 / (AliTRDgeometry::Rmax() - AliTRDgeometry::Rmin());
405
332e9569 406 rmin = AliTRDgeometry::Rmin() + AliTRDgeometry::CraHght();
407 rmax = rmin + AliTRDgeometry::CdrHght();
f73816f5 408
409 Float_t thickness = rmin - AliTRDgeometry::Rmin();
410 zmax2 = AliTRDgeometry::Zmax2() + slope * thickness;
793ff80c 411 zmax1 = zmax2 + slope * AliTRDgeometry::DrThick();
793ff80c 412
db30bf0f 413 for (iPlan = 0; iPlan < AliTRDgeometry::Nplan(); iPlan++) {
793ff80c 414
f73816f5 415 sprintf(name,"S_TR1%d",iPlan);
416 pgon = new TPGON(name,"TRD","void",0,360,AliTRDgeometry::Nsect(),4);
417 pgon->DefineSection(0,-zmax1,rmax,rmax);
418 pgon->DefineSection(1,-zmax2,rmin,rmax);
419 pgon->DefineSection(2, zmax2,rmin,rmax);
420 pgon->DefineSection(3, zmax1,rmax,rmax);
421 top->cd();
422 node = new TNode("TRD","TRD",name,0,0,0,"");
423 node->SetLineColor(kColorTRD);
424 fNodes->Add(node);
425
426 Float_t height = AliTRDgeometry::Cheight() + AliTRDgeometry::Cspace();
427 rmin = rmin + height;
428 rmax = rmax + height;
429 zmax1 = zmax1 + slope * height;
430 zmax2 = zmax2 + slope * height;
431
432 }
433
434 thickness += AliTRDgeometry::DrThick();
435 rmin = AliTRDgeometry::Rmin() + thickness;
436 rmax = rmin + AliTRDgeometry::AmThick();
437 zmax2 = AliTRDgeometry::Zmax2() + slope * thickness;
438 zmax1 = zmax2 + slope * AliTRDgeometry::AmThick();
439
db30bf0f 440 for (iPlan = 0; iPlan < AliTRDgeometry::Nplan(); iPlan++) {
f73816f5 441
442 sprintf(name,"S_TR2%d",iPlan);
793ff80c 443 pgon = new TPGON(name,"TRD","void",0,360,AliTRDgeometry::Nsect(),4);
444 pgon->DefineSection(0,-zmax1,rmax,rmax);
445 pgon->DefineSection(1,-zmax2,rmin,rmax);
446 pgon->DefineSection(2, zmax2,rmin,rmax);
447 pgon->DefineSection(3, zmax1,rmax,rmax);
448 top->cd();
449 node = new TNode("TRD","TRD",name,0,0,0,"");
450 node->SetLineColor(kColorTRD);
451 fNodes->Add(node);
452
453 Float_t height = AliTRDgeometry::Cheight() + AliTRDgeometry::Cspace();
454 rmin = rmin + height;
455 rmax = rmax + height;
456 zmax1 = zmax1 + slope * height;
457 zmax2 = zmax2 + slope * height;
458
459 }
460
db30bf0f 461 }
d3f347ff 462
fe4da5cc 463}
464
8230f242 465//_____________________________________________________________________________
dd9a6ee3 466void AliTRD::Copy(TObject &trd)
8230f242 467{
468 //
469 // Copy function
470 //
471
793ff80c 472 ((AliTRD &) trd).fGasMix = fGasMix;
473 ((AliTRD &) trd).fGeometry = fGeometry;
474 ((AliTRD &) trd).fRecPoints = fRecPoints;
475 ((AliTRD &) trd).fNRecPoints = fNRecPoints;
476 ((AliTRD &) trd).fGasDensity = fGasDensity;
477 ((AliTRD &) trd).fFoilDensity = fFoilDensity;
478 ((AliTRD &) trd).fDrawTR = fDrawTR;
479 ((AliTRD &) trd).fDisplayType = fDisplayType;
332e9569 480 ((AliTRD &) trd).fHitType = fHitType;
8230f242 481
482 //AliDetector::Copy(trd);
483
484}
485
fe4da5cc 486//_____________________________________________________________________________
82bbf98a 487void AliTRD::CreateGeometry()
fe4da5cc 488{
82bbf98a 489 //
490 // Creates the volumes for the TRD chambers
491 //
82bbf98a 492
493 // Check that FRAME is there otherwise we have no place where to put the TRD
8230f242 494 AliModule* frame = gAlice->GetModule("FRAME");
495 if (!frame) {
851d3db9 496 printf(" The TRD needs the FRAME to be defined first\n");
497 return;
82bbf98a 498 }
d3f347ff 499
851d3db9 500 fGeometry->CreateGeometry(fIdtmed->GetArray() - 1299);
5c7f4665 501
82bbf98a 502}
503
504//_____________________________________________________________________________
505void AliTRD::CreateMaterials()
506{
fe4da5cc 507 //
508 // Create the materials for the TRD
509 // Origin Y.Foka
510 //
511
8230f242 512 Int_t isxfld = gAlice->Field()->Integ();
513 Float_t sxmgmx = gAlice->Field()->Max();
fe4da5cc 514
d3f347ff 515 // For polyethilene (CH2)
516 Float_t ape[2] = { 12., 1. };
517 Float_t zpe[2] = { 6., 1. };
518 Float_t wpe[2] = { 1., 2. };
519 Float_t dpe = 0.95;
520
521 // For mylar (C5H4O2)
522 Float_t amy[3] = { 12., 1., 16. };
523 Float_t zmy[3] = { 6., 1., 8. };
524 Float_t wmy[3] = { 5., 4., 2. };
fe4da5cc 525 Float_t dmy = 1.39;
d3f347ff 526
527 // For CO2
528 Float_t aco[2] = { 12., 16. };
529 Float_t zco[2] = { 6., 8. };
530 Float_t wco[2] = { 1., 2. };
531 Float_t dco = 0.001977;
532
533 // For water
534 Float_t awa[2] = { 1., 16. };
535 Float_t zwa[2] = { 1., 8. };
536 Float_t wwa[2] = { 2., 1. };
537 Float_t dwa = 1.0;
538
539 // For isobutane (C4H10)
540 Float_t ais[2] = { 12., 1. };
541 Float_t zis[2] = { 6., 1. };
542 Float_t wis[2] = { 4., 10. };
543 Float_t dis = 0.00267;
544
db30bf0f 545 // For plexiglas (C5H8O2)
546 Float_t apg[3] = { 12.011 , 1.0 , 15.9994 };
547 Float_t zpg[3] = { 6.0 , 1.0 , 8.0 };
548 Float_t wpg[3] = { 5.0 , 8.0 , 2.0 };
549 Float_t dpg = 1.18;
550
d3f347ff 551 // For Xe/CO2-gas-mixture
db30bf0f 552 // Xe-content of the Xe/CO2-mixture (85% / 15%)
553 Float_t fxc = .85;
d3f347ff 554 // Xe-content of the Xe/Isobutane-mixture (97% / 3%)
555 Float_t fxi = .97;
fe4da5cc 556 Float_t dxe = .005858;
557
d3f347ff 558 // General tracking parameter
fe4da5cc 559 Float_t tmaxfd = -10.;
560 Float_t stemax = -1e10;
d3f347ff 561 Float_t deemax = -0.1;
562 Float_t epsil = 1e-4;
563 Float_t stmin = -0.001;
fe4da5cc 564
565 Float_t absl, radl, d, buf[1];
793ff80c 566 Float_t agm[2], zgm[2], wgm[2];
567 Float_t dgm1, dgm2;
d3f347ff 568 Int_t nbuf;
fe4da5cc 569
d3f347ff 570 //////////////////////////////////////////////////////////////////////////
fe4da5cc 571 // Define Materials
d3f347ff 572 //////////////////////////////////////////////////////////////////////////
573
16bf9884 574 AliMaterial( 1, "Al" , 26.98, 13.0, 2.7 , 8.9 , 37.2);
575 AliMaterial( 2, "Air" , 14.61, 7.3, 0.001205, 30420.0 , 67500.0);
576 AliMaterial( 4, "Xe" , 131.29, 54.0, dxe , 1447.59, 0.0);
577 AliMaterial( 5, "Cu" , 63.54, 29.0, 8.96 , 1.43, 14.8);
578 AliMaterial( 6, "C" , 12.01, 6.0, 2.265 , 18.8 , 74.4);
579 AliMaterial(12, "G10" , 20.00, 10.0, 1.7 , 19.4 , 999.0);
580 AliMaterial(15, "Sn" , 118.71, 50.0, 7.31 , 1.21, 14.8);
581 AliMaterial(16, "Si" , 28.09, 14.0, 2.33 , 9.36, 37.2);
582 AliMaterial(17, "Epoxy", 17.75, 8.9, 1.8 , 21.82, 999.0);
d3f347ff 583
584 // Mixtures
db30bf0f 585 AliMixture(3, "Polyethilene", ape, zpe, dpe, -2, wpe);
586 AliMixture(7, "Mylar", amy, zmy, dmy, -3, wmy);
587 AliMixture(8, "CO2", aco, zco, dco, -2, wco);
588 AliMixture(9, "Isobutane", ais, zis, dis, -2, wis);
589 AliMixture(13,"Water", awa, zwa, dwa, -2, wwa);
590 AliMixture(14,"Plexiglas", apg, zpg, dpg, -3, wpg);
d3f347ff 591
592 // Gas mixtures
00d6d986 593 Char_t namate[21]="";
d3f347ff 594 // Xe/CO2-mixture
595 // Get properties of Xe
cfce8870 596 gMC->Gfmate((*fIdmate)[4], namate, agm[0], zgm[0], d, radl, absl, buf, nbuf);
d3f347ff 597 // Get properties of CO2
cfce8870 598 gMC->Gfmate((*fIdmate)[8], namate, agm[1], zgm[1], d, radl, absl, buf, nbuf);
d3f347ff 599 // Create gas mixture
600 wgm[0] = fxc;
601 wgm[1] = 1. - fxc;
793ff80c 602 dgm1 = wgm[0] * dxe + wgm[1] * dco;
db30bf0f 603 AliMixture(10, "Gas mixture 1", agm, zgm, dgm1, 2, wgm);
d3f347ff 604 // Xe/Isobutane-mixture
605 // Get properties of Xe
cfce8870 606 gMC->Gfmate((*fIdmate)[4], namate, agm[0], zgm[0], d, radl, absl, buf, nbuf);
d3f347ff 607 // Get properties of Isobutane
cfce8870 608 gMC->Gfmate((*fIdmate)[9], namate, agm[1], zgm[1], d, radl, absl, buf, nbuf);
d3f347ff 609 // Create gas mixture
610 wgm[0] = fxi;
611 wgm[1] = 1. - fxi;
793ff80c 612 dgm2 = wgm[0] * dxe + wgm[1] * dis;
db30bf0f 613 AliMixture(11, "Gas mixture 2", agm, zgm, dgm2, 2, wgm);
d3f347ff 614
615 //////////////////////////////////////////////////////////////////////////
fe4da5cc 616 // Tracking Media Parameters
d3f347ff 617 //////////////////////////////////////////////////////////////////////////
618
619 // Al Frame
db30bf0f 620 AliMedium(1, "Al Frame", 1, 0, isxfld, sxmgmx
d3f347ff 621 , tmaxfd, stemax, deemax, epsil, stmin);
622 // Air
db30bf0f 623 AliMedium(2, "Air", 2, 0, isxfld, sxmgmx
d3f347ff 624 , tmaxfd, stemax, deemax, epsil, stmin);
625 // Polyethilene
db30bf0f 626 AliMedium(3, "Radiator", 3, 0, isxfld, sxmgmx
d3f347ff 627 , tmaxfd, stemax, deemax, epsil, stmin);
628 // Xe
db30bf0f 629 AliMedium(4, "Xe", 4, 1, isxfld, sxmgmx
d3f347ff 630 , tmaxfd, stemax, deemax, epsil, stmin);
631 // Cu pads
db30bf0f 632 AliMedium(5, "Padplane", 5, 1, isxfld, sxmgmx
d3f347ff 633 , tmaxfd, stemax, deemax, epsil, stmin);
634 // Fee + cables
db30bf0f 635 AliMedium(6, "Readout", 1, 0, isxfld, sxmgmx
d3f347ff 636 , tmaxfd, stemax, deemax, epsil, stmin);
637 // C frame
db30bf0f 638 AliMedium(7, "C Frame", 6, 0, isxfld, sxmgmx
d3f347ff 639 , tmaxfd, stemax, deemax, epsil, stmin);
640 // Mylar foils
db30bf0f 641 AliMedium(8, "Mylar", 7, 0, isxfld, sxmgmx
d3f347ff 642 , tmaxfd, stemax, deemax, epsil, stmin);
643 if (fGasMix == 1) {
644 // Gas-mixture (Xe/CO2)
db30bf0f 645 AliMedium(9, "Gas-mix", 10, 1, isxfld, sxmgmx
d3f347ff 646 , tmaxfd, stemax, deemax, epsil, stmin);
647 }
648 else {
649 // Gas-mixture (Xe/Isobutane)
db30bf0f 650 AliMedium(9, "Gas-mix", 11, 1, isxfld, sxmgmx
d3f347ff 651 , tmaxfd, stemax, deemax, epsil, stmin);
652 }
653 // Nomex-honeycomb (use carbon for the time being)
db30bf0f 654 AliMedium(10, "Nomex", 6, 0, isxfld, sxmgmx
d3f347ff 655 , tmaxfd, stemax, deemax, epsil, stmin);
656 // Kapton foils (use Mylar for the time being)
db30bf0f 657 AliMedium(11, "Kapton", 7, 0, isxfld, sxmgmx
d3f347ff 658 , tmaxfd, stemax, deemax, epsil, stmin);
659 // Gas-filling of the radiator
db30bf0f 660 AliMedium(12, "CO2", 8, 0, isxfld, sxmgmx
d3f347ff 661 , tmaxfd, stemax, deemax, epsil, stmin);
662 // G10-plates
db30bf0f 663 AliMedium(13, "G10-plates",12, 0, isxfld, sxmgmx
d3f347ff 664 , tmaxfd, stemax, deemax, epsil, stmin);
665 // Cooling water
db30bf0f 666 AliMedium(14, "Water", 13, 0, isxfld, sxmgmx
667 , tmaxfd, stemax, deemax, epsil, stmin);
668 // Rohacell (plexiglas) for the radiator
669 AliMedium(15, "Rohacell", 14, 0, isxfld, sxmgmx
d3f347ff 670 , tmaxfd, stemax, deemax, epsil, stmin);
16bf9884 671 // Al layer in MCMs
672 AliMedium(16, "MCM-Al" , 1, 0, isxfld, sxmgmx
673 , tmaxfd, stemax, deemax, epsil, stmin);
674 // Sn layer in MCMs
675 AliMedium(17, "MCM-Sn" , 15, 0, isxfld, sxmgmx
676 , tmaxfd, stemax, deemax, epsil, stmin);
677 // Cu layer in MCMs
678 AliMedium(18, "MCM-Cu" , 5, 0, isxfld, sxmgmx
679 , tmaxfd, stemax, deemax, epsil, stmin);
680 // G10 layer in MCMs
681 AliMedium(19, "MCM-G10" , 12, 0, isxfld, sxmgmx
682 , tmaxfd, stemax, deemax, epsil, stmin);
683 // Si in readout chips
684 AliMedium(20, "Chip-Si" , 16, 0, isxfld, sxmgmx
685 , tmaxfd, stemax, deemax, epsil, stmin);
686 // Epoxy in readout chips
687 AliMedium(21, "Chip-Ep" , 17, 0, isxfld, sxmgmx
688 , tmaxfd, stemax, deemax, epsil, stmin);
689 // PE in connectors
690 AliMedium(22, "Conn-PE" , 3, 0, isxfld, sxmgmx
691 , tmaxfd, stemax, deemax, epsil, stmin);
692 // Cu in connectors
693 AliMedium(23, "Chip-Cu" , 5, 0, isxfld, sxmgmx
694 , tmaxfd, stemax, deemax, epsil, stmin);
695 // Al of cooling pipes
696 AliMedium(24, "Cooling" , 1, 0, isxfld, sxmgmx
697 , tmaxfd, stemax, deemax, epsil, stmin);
73ae7b59 698 // Cu in services
699 AliMedium(25, "Serv-Cu" , 5, 0, isxfld, sxmgmx
700 , tmaxfd, stemax, deemax, epsil, stmin);
d3f347ff 701
793ff80c 702 // Save the density values for the TRD absorbtion
703 fFoilDensity = dmy;
704 if (fGasMix == 1)
705 fGasDensity = dgm1;
706 else
707 fGasDensity = dgm2;
708
fe4da5cc 709}
710
82bbf98a 711//_____________________________________________________________________________
0a29d0f1 712void AliTRD::DrawModule() const
82bbf98a 713{
714 //
715 // Draw a shaded view of the Transition Radiation Detector version 0
716 //
717
718 // Set everything unseen
719 gMC->Gsatt("*" ,"SEEN",-1);
720
721 // Set ALIC mother transparent
722 gMC->Gsatt("ALIC","SEEN", 0);
723
724 // Set the volumes visible
851d3db9 725 if (fGeometry->IsVersion() == 0) {
5c7f4665 726 gMC->Gsatt("B071","SEEN", 0);
727 gMC->Gsatt("B074","SEEN", 0);
728 gMC->Gsatt("B075","SEEN", 0);
729 gMC->Gsatt("B077","SEEN", 0);
730 gMC->Gsatt("BTR1","SEEN", 0);
731 gMC->Gsatt("BTR2","SEEN", 0);
732 gMC->Gsatt("BTR3","SEEN", 0);
332e9569 733 gMC->Gsatt("UTR1","SEEN", 0);
734 gMC->Gsatt("UTR2","SEEN", 0);
735 gMC->Gsatt("UTR3","SEEN", 0);
5c7f4665 736 }
737 else {
738 gMC->Gsatt("B071","SEEN", 0);
739 gMC->Gsatt("B074","SEEN", 0);
740 gMC->Gsatt("B075","SEEN", 0);
741 gMC->Gsatt("B077","SEEN", 0);
742 gMC->Gsatt("BTR1","SEEN", 0);
743 gMC->Gsatt("BTR2","SEEN", 0);
744 gMC->Gsatt("BTR3","SEEN", 0);
332e9569 745 gMC->Gsatt("UTR1","SEEN", 0);
6f1e466d 746 if (fGeometry->GetPHOShole())
332e9569 747 gMC->Gsatt("UTR2","SEEN", 0);
6f1e466d 748 if (fGeometry->GetRICHhole())
332e9569 749 gMC->Gsatt("UTR3","SEEN", 0);
5c7f4665 750 }
332e9569 751// gMC->Gsatt("UCII","SEEN", 0);
752// gMC->Gsatt("UCIM","SEEN", 0);
753// gMC->Gsatt("UCIO","SEEN", 0);
754// gMC->Gsatt("UL02","SEEN", 1);
755// gMC->Gsatt("UL05","SEEN", 1);
756// gMC->Gsatt("UL06","SEEN", 1);
82bbf98a 757
758 gMC->Gdopt("hide", "on");
759 gMC->Gdopt("shad", "on");
760 gMC->Gsatt("*", "fill", 7);
761 gMC->SetClipBox(".");
762 gMC->SetClipBox("*", 0, 2000, -2000, 2000, -2000, 2000);
763 gMC->DefaultRange();
764 gMC->Gdraw("alic", 40, 30, 0, 12, 9.4, .021, .021);
765 gMC->Gdhead(1111, "Transition Radiation Detector");
766 gMC->Gdman(18, 4, "MAN");
767
768}
769
fe4da5cc 770//_____________________________________________________________________________
0a29d0f1 771Int_t AliTRD::DistancetoPrimitive(Int_t , Int_t ) const
fe4da5cc 772{
773 //
774 // Distance between the mouse and the TRD detector on the screen
775 // Dummy routine
82bbf98a 776
777 return 9999;
778
fe4da5cc 779}
780
781//_____________________________________________________________________________
782void AliTRD::Init()
783{
784 //
851d3db9 785 // Initialize the TRD detector after the geometry has been created
fe4da5cc 786 //
82bbf98a 787
5c7f4665 788 Int_t i;
851d3db9 789
abaf1f1d 790 if (fDebug) {
9e1a0ddb 791 printf("\n%s: ",ClassName());
792 for (i = 0; i < 35; i++) printf("*");
793 printf(" TRD_INIT ");
794 for (i = 0; i < 35; i++) printf("*");
795 printf("\n");
796 }
5c7f4665 797
851d3db9 798 if (fGeometry->IsVersion() == 0) {
9e1a0ddb 799 printf("%s: Geometry for spaceframe with holes initialized\n",ClassName());
851d3db9 800 }
801 else if (fGeometry->IsVersion() == 1) {
9e1a0ddb 802 printf("%s: Geometry for spaceframe without holes initialized\n",ClassName());
6f1e466d 803 if (fGeometry->GetPHOShole())
9e1a0ddb 804 printf("%s: Leave space in front of PHOS free\n",ClassName());
6f1e466d 805 if (fGeometry->GetRICHhole())
9e1a0ddb 806 printf("%s: Leave space in front of RICH free\n",ClassName());
5c7f4665 807 }
9e1a0ddb 808
abaf1f1d 809 if (fGasMix == 1) {
db30bf0f 810 printf("%s: Gas Mixture: 85%% Xe + 15%% CO2\n",ClassName());
abaf1f1d 811 }
812 else {
9e1a0ddb 813 printf("%s: Gas Mixture: 97%% Xe + 3%% Isobutane\n",ClassName());
abaf1f1d 814 }
5c7f4665 815
816}
817
793ff80c 818//_____________________________________________________________________________
73ae7b59 819void AliTRD::LoadPoints(Int_t )
793ff80c 820{
821 //
822 // Store x, y, z of all hits in memory.
823 // Hit originating from TR photons are given a different color
824 //
825
332e9569 826 //if (!fDrawTR) {
827 // AliDetector::LoadPoints(track);
828 // return;
829 //}
793ff80c 830
332e9569 831 if ((fHits == 0) && (fTrackHits == 0)) return;
793ff80c 832
332e9569 833 Int_t nhits;
834 if (fHitType < 2) {
835 nhits = fHits->GetEntriesFast();
836 }
837 else {
838 nhits = fTrackHits->GetEntriesFast();
839 }
793ff80c 840 if (nhits == 0) return;
841
5d12ce38 842 Int_t tracks = gAlice->GetMCApp()->GetNtrack();
793ff80c 843 if (fPoints == 0) fPoints = new TObjArray(tracks);
844
845 AliTRDhit *ahit;
846
847 Int_t *ntrkE = new Int_t[tracks];
848 Int_t *ntrkT = new Int_t[tracks];
849 Int_t *limiE = new Int_t[tracks];
850 Int_t *limiT = new Int_t[tracks];
851 Float_t **coorE = new Float_t*[tracks];
852 Float_t **coorT = new Float_t*[tracks];
853 for(Int_t i = 0; i < tracks; i++) {
854 ntrkE[i] = 0;
855 ntrkT[i] = 0;
856 coorE[i] = 0;
857 coorT[i] = 0;
858 limiE[i] = 0;
859 limiT[i] = 0;
860 }
861
332e9569 862 AliTRDpoints *points = 0;
863 Float_t *fp = 0;
864 Int_t trk;
865 Int_t chunk = nhits / 4 + 1;
793ff80c 866
867 // Loop over all the hits and store their position
332e9569 868 ahit = (AliTRDhit *) FirstHit(-1);
869 while (ahit) {
793ff80c 870
871 // dEdx hits
332e9569 872 if (ahit->GetCharge() >= 0) {
793ff80c 873
874 trk = ahit->GetTrack();
875 if (ntrkE[trk] == limiE[trk]) {
876 // Initialise a new track
877 fp = new Float_t[3*(limiE[trk]+chunk)];
878 if (coorE[trk]) {
879 memcpy(fp,coorE[trk],sizeof(Float_t)*3*limiE[trk]);
880 delete [] coorE[trk];
881 }
882 limiE[trk] += chunk;
883 coorE[trk] = fp;
884 }
885 else {
886 fp = coorE[trk];
887 }
888 fp[3*ntrkE[trk] ] = ahit->X();
889 fp[3*ntrkE[trk]+1] = ahit->Y();
890 fp[3*ntrkE[trk]+2] = ahit->Z();
891 ntrkE[trk]++;
892
893 }
894 // TR photon hits
332e9569 895 else if ((ahit->GetCharge() < 0) && (fDrawTR)) {
793ff80c 896
897 trk = ahit->GetTrack();
898 if (ntrkT[trk] == limiT[trk]) {
899 // Initialise a new track
900 fp = new Float_t[3*(limiT[trk]+chunk)];
901 if (coorT[trk]) {
902 memcpy(fp,coorT[trk],sizeof(Float_t)*3*limiT[trk]);
903 delete [] coorT[trk];
904 }
905 limiT[trk] += chunk;
906 coorT[trk] = fp;
907 }
908 else {
909 fp = coorT[trk];
910 }
911 fp[3*ntrkT[trk] ] = ahit->X();
912 fp[3*ntrkT[trk]+1] = ahit->Y();
913 fp[3*ntrkT[trk]+2] = ahit->Z();
914 ntrkT[trk]++;
915
916 }
917
332e9569 918 ahit = (AliTRDhit *) NextHit();
919
793ff80c 920 }
921
922 for (trk = 0; trk < tracks; ++trk) {
923
924 if (ntrkE[trk] || ntrkT[trk]) {
925
926 points = new AliTRDpoints();
927 points->SetDetector(this);
928 points->SetParticle(trk);
929
930 // Set the dEdx points
931 if (ntrkE[trk]) {
932 points->SetMarkerColor(GetMarkerColor());
933 points->SetMarkerSize(GetMarkerSize());
934 points->SetPolyMarker(ntrkE[trk],coorE[trk],GetMarkerStyle());
935 delete [] coorE[trk];
936 coorE[trk] = 0;
937 }
938
939 // Set the TR photon points
940 if (ntrkT[trk]) {
941 points->SetTRpoints(ntrkT[trk],coorT[trk]);
942 delete [] coorT[trk];
943 coorT[trk] = 0;
944 }
945
946 fPoints->AddAt(points,trk);
947
948 }
949
950 }
951
952 delete [] coorE;
953 delete [] coorT;
954 delete [] ntrkE;
955 delete [] ntrkT;
956 delete [] limiE;
957 delete [] limiT;
958
959}
960
5c7f4665 961//_____________________________________________________________________________
88cb7938 962void AliTRD::MakeBranch(Option_t* option)
5c7f4665 963{
964 //
abaf1f1d 965 // Create Tree branches for the TRD digits.
5c7f4665 966 //
967
abaf1f1d 968 Int_t buffersize = 4000;
969 Char_t branchname[15];
970 sprintf(branchname,"%s",GetName());
5c7f4665 971
aa9d00f0 972 const char *cD = strstr(option,"D");
973
88cb7938 974 AliDetector::MakeBranch(option);
5c7f4665 975
abaf1f1d 976 if (fDigits && gAlice->TreeD() && cD) {
88cb7938 977 MakeBranchInTree(gAlice->TreeD(),branchname,&fDigits,buffersize,0);
abaf1f1d 978 }
979
332e9569 980 if (fHitType > 1) {
88cb7938 981 MakeBranch2(option,0);
332e9569 982 }
983
851d3db9 984}
985
6244debe 986//_____________________________________________________________________________
987void AliTRD::ResetDigits()
988{
989 //
abaf1f1d 990 // Reset number of digits and the digits array for this detector
6244debe 991 //
992
abaf1f1d 993 fNdigits = 0;
994 if (fDigits) fDigits->Clear();
6244debe 995
996}
997
851d3db9 998//_____________________________________________________________________________
999void AliTRD::ResetRecPoints()
1000{
1001 //
1002 // Reset number of reconstructed points and the point array
1003 //
1004
f73816f5 1005 if (fRecPoints) {
793ff80c 1006 fNRecPoints = 0;
1007 Int_t nentr = fRecPoints->GetEntriesFast();
f73816f5 1008 for (Int_t i = 0; i < nentr; i++) delete fRecPoints->RemoveAt(i);
793ff80c 1009 }
5c7f4665 1010
1011}
1012
1013//_____________________________________________________________________________
1014void AliTRD::SetTreeAddress()
1015{
1016 //
1017 // Set the branch addresses for the trees.
1018 //
1019
1020 Char_t branchname[15];
1021
88cb7938 1022 if ( fLoader->TreeH() && (fHits == 0x0)) fHits = new TClonesArray("AliTRDhit",405);
5c7f4665 1023 AliDetector::SetTreeAddress();
1024
1025 TBranch *branch;
88cb7938 1026 TTree *treeR = fLoader->TreeR();
851d3db9 1027
1028 if (treeR) {
f73816f5 1029 sprintf(branchname,"%scluster",GetName());
88cb7938 1030 if (fRecPoints == 0x0) fRecPoints = new TObjArray(400);
851d3db9 1031 if (fRecPoints) {
1032 branch = treeR->GetBranch(branchname);
1033 if (branch) {
1034 branch->SetAddress(&fRecPoints);
1035 }
5c7f4665 1036 }
1037 }
1038
332e9569 1039 if (fHitType > 0) {
1040 SetTreeAddress2();
1041 }
1042
fe4da5cc 1043}
1044
d3f347ff 1045//_____________________________________________________________________________
b060c36f 1046void AliTRD::SetGasMix(Int_t imix)
d3f347ff 1047{
82bbf98a 1048 //
1049 // Defines the gas mixture (imix=0: Xe/Isobutane imix=1: Xe/CO2)
1050 //
1051
d3f347ff 1052 if ((imix < 0) || (imix > 1)) {
1053 printf("Wrong input value: %d\n",imix);
1054 printf("Use standard setting\n");
6244debe 1055 fGasMix = 1;
d3f347ff 1056 return;
1057 }
1058
1059 fGasMix = imix;
1060
1061}
1062
793ff80c 1063//_____________________________________________________________________________
1064void AliTRD::SetPHOShole()
1065{
1066 //
1067 // Selects a geometry with a hole in front of the PHOS
1068 //
1069
1070 fGeometry->SetPHOShole();
1071
1072}
1073
1074//_____________________________________________________________________________
1075void AliTRD::SetRICHhole()
1076{
1077 //
1078 // Selects a geometry with a hole in front of the RICH
1079 //
1080
1081 fGeometry->SetRICHhole();
1082
1083}
1084
dd9a6ee3 1085//_____________________________________________________________________________
1086AliTRD &AliTRD::operator=(const AliTRD &trd)
1087{
1088 //
1089 // Assignment operator
1090 //
1091
1092 if (this != &trd) ((AliTRD &) trd).Copy(*this);
1093 return *this;
1094
f73816f5 1095}
abaf1f1d 1096
332e9569 1097//_____________________________________________________________________________
1098void AliTRD::FinishPrimary()
1099{
1100 //
1101 // Store the hits in the containers after all primaries are finished
1102 //
1103
1104 if (fTrackHits) {
1105 fTrackHits->FlushHitStack();
1106 }
1107
1108}
1109
1110//_____________________________________________________________________________
1111void AliTRD::RemapTrackHitIDs(Int_t *map)
1112{
1113 //
1114 // Remap the track IDs
1115 //
1116
1117 if (!fTrackHits) {
1118 return;
1119 }
1120
1121 if (fTrackHits) {
1122 TClonesArray *arr = fTrackHits->GetArray();;
1123 for (Int_t i = 0; i < arr->GetEntriesFast(); i++){
1124 AliTrackHitsParamV2 *info = (AliTrackHitsParamV2 *) (arr->At(i));
1125 info->fTrackID = map[info->fTrackID];
1126 }
1127 }
1128
1129}
1130
1131//_____________________________________________________________________________
1132void AliTRD::ResetHits()
1133{
1134 //
1135 // Reset the hits
1136 //
1137
1138 AliDetector::ResetHits();
1139 if (fTrackHits) {
1140 fTrackHits->Clear();
1141 }
1142
1143}
1144
1145//_____________________________________________________________________________
1146AliHit* AliTRD::FirstHit(Int_t track)
1147{
1148 //
1149 // Return the first hit of a track
1150 //
1151
1152 if (fHitType > 1) {
1153 return FirstHit2(track);
1154 }
abaf1f1d 1155
332e9569 1156 return AliDetector::FirstHit(track);
abaf1f1d 1157
332e9569 1158}
1159
1160//_____________________________________________________________________________
1161AliHit* AliTRD::NextHit()
1162{
1163 //
1164 // Returns the next hit of a track
1165 //
1166
1167 if (fHitType > 1) {
1168 return NextHit2();
1169 }
1170
1171 return AliDetector::NextHit();
1172
1173}
1174
1175//_____________________________________________________________________________
0a29d0f1 1176AliHit* AliTRD::FirstHit2(Int_t track)
332e9569 1177{
1178 //
1179 // Initializes the hit iterator.
1180 // Returns the address of the first hit of a track.
1181 // If <track> >= 0 the track is read from disk,
1182 // while if <track> < 0 the first hit of the current
1183 // track is returned.
1184 //
1185
1186 if (track >= 0) {
1187 gAlice->ResetHits();
88cb7938 1188 TreeH()->GetEvent(track);
332e9569 1189 }
1190
1191 if (fTrackHits) {
1192 fTrackHits->First();
1193 return (AliHit*) fTrackHits->GetHit();
1194 }
1195 else {
1196 return 0;
1197 }
1198
1199}
1200
1201//_____________________________________________________________________________
1202AliHit* AliTRD::NextHit2()
1203{
1204 //
1205 // Returns the next hit of the current track
1206 //
1207
1208 if (fTrackHits) {
1209 fTrackHits->Next();
1210 return (AliHit *) fTrackHits->GetHit();
1211 }
1212 else {
1213 return 0;
1214 }
1215
1216}
1217
1218//_____________________________________________________________________________
73ae7b59 1219void AliTRD::MakeBranch2(Option_t *option, const char* )
332e9569 1220{
1221 //
1222 // Create a new branch in the current Root tree.
1223 // The branch of fHits is automatically split.
1224 //
1225
1226 if (fHitType < 2) {
1227 return;
1228 }
1229
1230 char branchname[10];
1231 sprintf(branchname,"%s2",GetName());
1232
1233 // Get the pointer to the header
1234 const char *cH = strstr(option,"H");
1235
1236 if (!fTrackHits) {
1237 fTrackHits = new AliTRDtrackHits();
88cb7938 1238 }
332e9569 1239
332e9569 1240
88cb7938 1241 if (fTrackHits && TreeH() && cH)
1242 {
1243 TreeH()->Branch(branchname,"AliTRDtrackHits",&fTrackHits,fBufferSize,99);
1244 Info("MakeBranch2","Making Branch %s for trackhits",branchname);
1245 }
332e9569 1246}
1247
1248//_____________________________________________________________________________
1249void AliTRD::SetTreeAddress2()
1250{
1251 //
1252 // Set the branch address for the trackHits tree
1253 //
f2a509af 1254 if (GetDebug()) Info("SetTreeAddress2","");
332e9569 1255
1256 TBranch *branch;
332e9569 1257 char branchname[20];
332e9569 1258 sprintf(branchname,"%s2",GetName());
1259
1260 // Branch address for hit tree
88cb7938 1261 TTree *treeH = TreeH();
332e9569 1262 if ((treeH) && (fHitType > 0)) {
1263 branch = treeH->GetBranch(branchname);
88cb7938 1264 if (branch)
1265 {
1266 branch->SetAddress(&fTrackHits);
f2a509af 1267 if (GetDebug())
1268 Info("SetTreeAddress2","Success.");
88cb7938 1269 }
1270 else
1271 {
f2a509af 1272 if (GetDebug())
1273 Info("SetTreeAddress2","Can NOT get the branch %s",branchname);
88cb7938 1274 }
332e9569 1275 }
1276
1277}
1278
1279//_____________________________________________________________________________
1280void AliTRD::AddHit2(Int_t track, Int_t det, Float_t *hits, Int_t q
1281 , Bool_t inDrift)
1282{
1283 //
1284 // Add a hit to the list
1285 //
1286
1287 Int_t rtrack;
1288
1289 if (fIshunt) {
5d12ce38 1290 Int_t primary = gAlice->GetMCApp()->GetPrimary(track);
1291 gAlice->GetMCApp()->Particle(primary)->SetBit(kKeepBit);
332e9569 1292 rtrack = primary;
1293 }
1294 else {
1295 rtrack = track;
5d12ce38 1296 gAlice->GetMCApp()->FlagTrack(track);
332e9569 1297 }
1298
1299 if ((fTrackHits) && (fHitType > 0)) {
1300 fTrackHits->AddHitTRD(det,rtrack,hits[0],hits[1],hits[2],q,inDrift);
1301 }
1302
1303}
abaf1f1d 1304
1305
596a855f 1306//_____________________________________________________________________________
1307void AliTRD::Reconstruct() const
1308{
1309// reconstruct clusters
1310
1311 AliTRDclusterizerV1 clusterer("clusterer", "TRD clusterizer");
1312 AliRunLoader* runLoader = GetLoader()->GetRunLoader();
1313 runLoader->CdGAFile();
1314 AliTRDparameter* trdParam = (AliTRDparameter*) gFile->Get("TRDparameter");
1315 if (!trdParam) {
1316 Error("Reconstruct", "no TRD parameters found");
1317 return;
1318 }
1319 trdParam->ReInit();
1320 clusterer.SetParameter(trdParam);
1321 Int_t nEvents = runLoader->GetNumberOfEvents();
1322
1323 for (Int_t iEvent = 0; iEvent < nEvents; iEvent++) {
1324 clusterer.Open(runLoader->GetFileName(), iEvent);
1325 clusterer.ReadDigits();
1326 clusterer.MakeClusters();
1327 clusterer.WriteClusters(-1);
1328 }
1329}
1330
1331//_____________________________________________________________________________
1332AliTracker* AliTRD::CreateTracker() const
1333{
1334// create a TRD tracker
1335
1336 GetLoader()->GetRunLoader()->CdGAFile();
1337 return new AliTRDtracker(gFile);
1338}
abaf1f1d 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
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675