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