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