Add track length to track references
[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
16/*
17$Log$
87128f38 18Revision 1.43 2002/11/21 22:38:47 alibrary
19Removing AliMC and AliMCProcess
20
4c475d27 21Revision 1.42 2002/10/22 15:53:08 alibrary
22Introducing Riostream.h
23
a2cb5b3d 24Revision 1.41 2002/10/14 14:57:43 hristov
25Merging the VirtualMC branch to the main development branch (HEAD)
26
b9d0a01d 27Revision 1.36.6.2 2002/07/24 10:09:30 alibrary
28Updating VirtualMC
29
30Revision 1.40 2002/06/13 08:11:56 cblume
31Add the track references
32
c61f1a66 33Revision 1.39 2002/06/12 09:54:35 cblume
34Update of tracking code provided by Sergei
35
5443e65e 36Revision 1.38 2002/03/28 14:59:07 cblume
37Coding conventions
38
0a29d0f1 39Revision 1.37 2002/03/25 20:01:49 cblume
40Introduce parameter class
41
17b26de4 42Revision 1.36 2002/02/11 14:25:27 cblume
43Geometry update, compressed hit structure
44
332e9569 45Revision 1.35 2001/11/14 12:08:44 cblume
46Remove unneccessary header files
47
faea7205 48Revision 1.34 2001/11/14 10:50:45 cblume
49Changes in digits IO. Add merging of summable digits
50
abaf1f1d 51Revision 1.33 2001/11/06 17:19:41 cblume
52Add detailed geometry and simple simulator
53
16bf9884 54Revision 1.32 2001/10/08 06:57:33 hristov
55Branches for TRD digits are created only during the digitisation
56
aa9d00f0 57Revision 1.31 2001/08/30 09:30:30 hristov
58The split level of branches is set to 99
59
40c7ef21 60Revision 1.30 2001/05/28 17:07:58 hristov
61Last minute changes; ExB correction in AliTRDclusterizerV1; taking into account of material in G10 TEC frames and material between TEC planes (C.Blume,S.Sedykh)
62
a819a5f7 63Revision 1.29 2001/05/21 16:45:47 hristov
64Last minute changes (C.Blume)
65
db30bf0f 66Revision 1.28 2001/05/16 14:57:27 alibrary
67New files for folders and Stack
68
69Revision 1.27 2001/05/08 07:05:02 hristov
70Loop variable declared once (HP, Sun)
71
ea01d9e4 72Revision 1.26 2001/05/07 08:03:22 cblume
73Generate also hits in the amplification region
74
f73816f5 75Revision 1.25 2001/03/13 09:30:35 cblume
76Update of digitization. Moved digit branch definition to AliTRD
77
6244debe 78Revision 1.24 2001/01/26 19:56:49 hristov
79Major upgrade of AliRoot code
80
2ab0c725 81Revision 1.23 2000/11/01 14:53:20 cblume
82Merge with TRD-develop
83
793ff80c 84Revision 1.17.2.6 2000/10/15 23:29:08 cblume
85Introduced more detailed geometry for the display
86
87Revision 1.17.2.5 2000/10/06 16:49:46 cblume
88Made Getters const
89
90Revision 1.17.2.4 2000/10/04 16:34:57 cblume
91Replace include files by forward declarations
92
93Revision 1.17.2.3 2000/09/22 14:45:17 cblume
94Included changes for the tracking
95
96Revision 1.17.2.2 2000/09/18 13:25:13 cblume
97Included LoadPoints() method to display the TR photons
98
99Revision 1.22 2000/10/02 21:28:19 fca
100Removal of useless dependecies via forward declarations
101
102Revision 1.21 2000/06/09 11:10:07 cblume
103Compiler warnings and coding conventions, next round
104
105Revision 1.20 2000/06/08 18:32:57 cblume
106Make code compliant to coding conventions
107
108Revision 1.19 2000/06/07 16:25:37 cblume
109Try to remove compiler warnings on Sun and HP
110
111Revision 1.18 2000/05/08 16:17:27 cblume
112Merge TRD-develop
113
94de3818 114Revision 1.21 2000/06/09 11:10:07 cblume
115Compiler warnings and coding conventions, next round
116
dd9a6ee3 117Revision 1.20 2000/06/08 18:32:57 cblume
118Make code compliant to coding conventions
119
8230f242 120Revision 1.19 2000/06/07 16:25:37 cblume
121Try to remove compiler warnings on Sun and HP
122
9d0b222b 123Revision 1.18 2000/05/08 16:17:27 cblume
124Merge TRD-develop
125
6f1e466d 126Revision 1.17.2.1 2000/05/08 14:28:59 cblume
127Introduced SetPHOShole() and SetRICHhole(). AliTRDrecPoint container is now a TObjArray
128
129Revision 1.17 2000/02/28 19:10:26 cblume
130Include the new TRD classes
131
851d3db9 132Revision 1.16.2.2 2000/02/28 17:53:24 cblume
133Introduce TRD geometry classes
134
135Revision 1.16.2.1 2000/02/28 17:04:19 cblume
136Include functions and data members for AliTRDrecPoint
137
138Revision 1.16 2000/01/19 17:17:35 fca
139Introducing a list of lists of hits -- more hits allowed for detector now
140
1cedd08a 141Revision 1.15 1999/11/02 17:04:25 fca
142Small syntax change for HP compiler
143
94c641ff 144Revision 1.14 1999/11/02 16:57:02 fca
145Avoid non ansi warnings on HP compilers
146
8459a454 147Revision 1.13 1999/11/02 16:35:56 fca
148New version of TRD introduced
149
5c7f4665 150Revision 1.12 1999/11/01 20:41:51 fca
151Added protections against using the wrong version of FRAME
152
ab76897d 153Revision 1.11 1999/09/29 09:24:34 fca
154Introduction of the Copyright and cvs Log
155
4c039060 156*/
157
fe4da5cc 158///////////////////////////////////////////////////////////////////////////////
159// //
160// Transition Radiation Detector //
161// This class contains the basic functions for the Transition Radiation //
6f1e466d 162// Detector. //
fe4da5cc 163// //
164///////////////////////////////////////////////////////////////////////////////
165
5c7f4665 166#include <stdlib.h>
a2cb5b3d 167#include <Riostream.h>
5c7f4665 168
fe4da5cc 169#include <TMath.h>
fe4da5cc 170#include <TNode.h>
94de3818 171#include <TGeometry.h>
793ff80c 172#include <TTree.h>
173#include <TPGON.h>
abaf1f1d 174#include <TFile.h>
175#include <TROOT.h>
332e9569 176#include <TParticle.h>
c61f1a66 177#include <TLorentzVector.h>
fe4da5cc 178
fe4da5cc 179#include "AliRun.h"
d3f347ff 180#include "AliConst.h"
793ff80c 181#include "AliDigit.h"
182#include "AliMagF.h"
4c475d27 183
c61f1a66 184#include "AliTrackReference.h"
793ff80c 185
186#include "AliTRD.h"
187#include "AliTRDhit.h"
188#include "AliTRDpoints.h"
189#include "AliTRDdigit.h"
851d3db9 190#include "AliTRDdigitizer.h"
191#include "AliTRDclusterizer.h"
192#include "AliTRDgeometryHole.h"
193#include "AliTRDgeometryFull.h"
194#include "AliTRDrecPoint.h"
f73816f5 195#include "AliTRDcluster.h"
2ab0c725 196#include "AliTRDdigitsManager.h"
332e9569 197#include "AliTRDtrackHits.h"
793ff80c 198
fe4da5cc 199ClassImp(AliTRD)
200
201//_____________________________________________________________________________
202AliTRD::AliTRD()
203{
204 //
205 // Default constructor
206 //
82bbf98a 207
6244debe 208 fIshunt = 0;
209 fGasMix = 0;
210 fHits = 0;
211 fDigits = 0;
5c7f4665 212
6244debe 213 fRecPoints = 0;
214 fNRecPoints = 0;
5c7f4665 215
6244debe 216 fGeometry = 0;
82bbf98a 217
6244debe 218 fGasDensity = 0;
219 fFoilDensity = 0;
793ff80c 220
6244debe 221 fDrawTR = 0;
332e9569 222 fDisplayType = 0;
223
224 fTrackHits = 0;
225 fHitType = 0;
6244debe 226
fe4da5cc 227}
228
229//_____________________________________________________________________________
230AliTRD::AliTRD(const char *name, const char *title)
231 : AliDetector(name,title)
232{
233 //
234 // Standard constructor for the TRD
235 //
236
5c7f4665 237 // Check that FRAME is there otherwise we have no place where to
238 // put TRD
8230f242 239 AliModule* frame = gAlice->GetModule("FRAME");
240 if (!frame) {
5c7f4665 241 Error("Ctor","TRD needs FRAME to be present\n");
242 exit(1);
243 }
244
245 // Define the TRD geometry according to the FRAME geometry
8230f242 246 if (frame->IsVersion() == 0) {
851d3db9 247 // Geometry with hole
248 fGeometry = new AliTRDgeometryHole();
249 }
8230f242 250 else if (frame->IsVersion() == 1) {
851d3db9 251 // Geometry without hole
252 fGeometry = new AliTRDgeometryFull();
253 }
254 else {
255 Error("Ctor","Could not find valid FRAME version\n");
256 exit(1);
257 }
5c7f4665 258
fe4da5cc 259 // Allocate the hit array
f73816f5 260 fHits = new TClonesArray("AliTRDhit" ,405);
1cedd08a 261 gAlice->AddHitList(fHits);
99d5402e 262
263 // Allocate the digits array
f73816f5 264 fDigits = 0;
5c7f4665 265
851d3db9 266 // Allocate the rec point array
6244debe 267 fRecPoints = new TObjArray(400);
268 fNRecPoints = 0;
99d5402e 269
6244debe 270 fIshunt = 0;
271 fGasMix = 1;
793ff80c 272
6244debe 273 fGasDensity = 0;
274 fFoilDensity = 0;
793ff80c 275
6244debe 276 fDrawTR = 0;
277 fDisplayType = 0;
278
332e9569 279 fTrackHits = 0;
280 fHitType = 2;
281
fe4da5cc 282 SetMarkerColor(kWhite);
82bbf98a 283
fe4da5cc 284}
99d5402e 285
8230f242 286//_____________________________________________________________________________
dd9a6ee3 287AliTRD::AliTRD(const AliTRD &trd)
8230f242 288{
289 //
290 // Copy constructor
291 //
292
dd9a6ee3 293 ((AliTRD &) trd).Copy(*this);
8230f242 294
295}
296
99d5402e 297//_____________________________________________________________________________
298AliTRD::~AliTRD()
299{
300 //
301 // TRD destructor
302 //
303
304 fIshunt = 0;
305
abaf1f1d 306 if (fGeometry) {
307 delete fGeometry;
332e9569 308 fGeometry = 0;
abaf1f1d 309 }
310 if (fHits) {
311 delete fHits;
332e9569 312 fHits = 0;
abaf1f1d 313 }
314 if (fRecPoints) {
315 delete fRecPoints;
332e9569 316 fRecPoints = 0;
317 }
318 if (fTrackHits) {
319 delete fTrackHits;
320 fTrackHits = 0;
6244debe 321 }
5c7f4665 322
323}
324
325//_____________________________________________________________________________
5443e65e 326void AliTRD::AddCluster(Float_t *pos, Int_t det, Float_t amp
327 , Int_t *tracks, Float_t *sig, Int_t iType)
5c7f4665 328{
329 //
f73816f5 330 // Add a cluster for the TRD
851d3db9 331 //
793ff80c 332
f73816f5 333 AliTRDcluster *c = new AliTRDcluster();
334
335 c->SetDetector(det);
336 c->AddTrackIndex(tracks);
f73816f5 337 c->SetQ(amp);
5443e65e 338 c->SetY(pos[0]);
339 c->SetZ(pos[1]);
340 c->SetSigmaY2(sig[0]);
341 c->SetSigmaZ2(sig[1]);
f73816f5 342 c->SetLocalTimeBin(((Int_t) pos[2]));
f73816f5 343
db30bf0f 344 switch (iType) {
345 case 0:
346 c->Set2pad();
347 break;
348 case 1:
349 c->Set3pad();
350 break;
351 case 2:
352 c->Set4pad();
353 break;
354 case 3:
355 c->Set5pad();
356 break;
357 case 4:
358 c->SetLarge();
359 break;
360 };
793ff80c 361
f73816f5 362 fRecPoints->Add(c);
6f1e466d 363
99d5402e 364}
6244debe 365
c61f1a66 366//_____________________________________________________________________________
87128f38 367void AliTRD::AddTrackReference(Int_t label, TLorentzVector p
368 , TLorentzVector x, Float_t length)
c61f1a66 369{
370 //
371 // Add a trackrefernce to the list
372 //
373
374 if (!fTrackReferences) {
375 Error("AddTrackReference","Container fTrackRefernce not active\n");
376 return;
377 }
378
379 Int_t nref = fTrackReferences->GetEntriesFast();
380 TClonesArray &lref = *fTrackReferences;
381 AliTrackReference * ref = new(lref[nref]) AliTrackReference();
382 ref->SetMomentum(p[0],p[1],p[2]);
383 ref->SetPosition(x[0],x[1],x[2]);
384 ref->SetTrack(label);
87128f38 385 ref->SetLength(length);
c61f1a66 386
387}
388
6244debe 389//_____________________________________________________________________________
390void AliTRD::Hits2Digits()
2ab0c725 391{
392 //
393 // Create digits
394 //
6244debe 395
396 AliTRDdigitizer *digitizer = new AliTRDdigitizer("TRDdigitizer"
397 ,"TRD digitizer class");
332e9569 398 digitizer->SetDebug(GetDebug());
9e1a0ddb 399 digitizer->SetEvent(gAlice->GetEvNumber());
abaf1f1d 400
6244debe 401 // Initialization
db30bf0f 402 digitizer->InitDetector();
6244debe 403
404 // Create the digits
405 digitizer->MakeDigits();
2ab0c725 406
6244debe 407 // Write the digits into the input file
abaf1f1d 408 if (digitizer->MakeBranch(fDigitsFile)) {
6244debe 409
410 digitizer->WriteDigits();
411
412 // Save the digitizer class in the AliROOT
413 digitizer->Write();
414
415 }
416
417}
418
419//_____________________________________________________________________________
420void AliTRD::Hits2SDigits()
421{
422 //
423 // Create summable digits
424 //
425
426 AliTRDdigitizer *digitizer = new AliTRDdigitizer("TRDdigitizer"
427 ,"TRD digitizer class");
332e9569 428 digitizer->SetDebug(GetDebug());
6244debe 429
430 // For the summable digits
431 digitizer->SetSDigits(kTRUE);
9e1a0ddb 432 digitizer->SetEvent(gAlice->GetEvNumber());
6244debe 433
434 // Initialization
db30bf0f 435 digitizer->InitDetector();
2ab0c725 436
abaf1f1d 437 // Create the TRD s-digits branch
6244debe 438 digitizer->MakeDigits();
2ab0c725 439
440 // Write the digits into the input file
abaf1f1d 441 if (digitizer->MakeBranch(fDigitsFile)) {
6244debe 442
443 digitizer->WriteDigits();
2ab0c725 444
445 // Save the digitizer class in the AliROOT
6244debe 446 digitizer->Write();
447
2ab0c725 448 }
6244debe 449
450}
451
452//_____________________________________________________________________________
453void AliTRD::SDigits2Digits()
454{
455 //
456 // Create final digits from summable digits
457 //
458
abaf1f1d 459 // Create the TRD digitizer
460 AliTRDdigitizer *digitizer = new AliTRDdigitizer("TRDdigitizer"
461 ,"TRD digitizer class");
332e9569 462 digitizer->SetDebug(GetDebug());
99d5402e 463
abaf1f1d 464 // Set the parameter
465 digitizer->SetEvent(gAlice->GetEvNumber());
466
467 // Initialization
468 digitizer->InitDetector();
469
470 // Read the s-digits via digits manager
471 AliTRDdigitsManager *sdigitsManager = new AliTRDdigitsManager();
332e9569 472 sdigitsManager->SetDebug(GetDebug());
abaf1f1d 473 sdigitsManager->SetSDigits(kTRUE);
474 if (fDigitsFile) {
475 sdigitsManager->Open(fDigitsFile);
476 }
477 sdigitsManager->CreateArrays();
478 sdigitsManager->ReadDigits();
479
480 // Add the s-digits to the input list
481 digitizer->AddSDigitsManager(sdigitsManager);
99d5402e 482
abaf1f1d 483 // Convert the s-digits to normal digits
484 digitizer->SDigits2Digits();
485
486 // Store the digits
487 if (digitizer->MakeBranch(fDigitsFile)) {
488
489 digitizer->WriteDigits();
490
491 }
99d5402e 492
493}
494
fe4da5cc 495//_____________________________________________________________________________
332e9569 496void AliTRD::AddHit(Int_t track, Int_t det, Float_t *hits, Int_t q
497 , Bool_t inDrift)
fe4da5cc 498{
499 //
500 // Add a hit for the TRD
332e9569 501 //
502 // The data structure is set according to fHitType:
503 // bit0: standard TClonesArray
504 // bit1: compressed trackHits structure
fe4da5cc 505 //
82bbf98a 506
332e9569 507 if (fHitType & 1) {
508 TClonesArray &lhits = *fHits;
509 new(lhits[fNhits++]) AliTRDhit(fIshunt,track,det,hits,q);
510 }
511
512 if (fHitType > 1) {
513 AddHit2(track,det,hits,q,inDrift);
514 }
82bbf98a 515
fe4da5cc 516}
517
518//_____________________________________________________________________________
519void AliTRD::BuildGeometry()
520{
521 //
522 // Create the ROOT TNode geometry for the TRD
523 //
82bbf98a 524
8230f242 525 TNode *node, *top;
fe4da5cc 526 TPGON *pgon;
793ff80c 527
528 Float_t rmin, rmax;
529 Float_t zmax1, zmax2;
db30bf0f 530
531 Int_t iPlan;
793ff80c 532
fe4da5cc 533 const Int_t kColorTRD = 46;
d3f347ff 534
fe4da5cc 535 // Find the top node alice
8230f242 536 top = gAlice->GetGeometry()->GetNode("alice");
d3f347ff 537
db30bf0f 538 if (fDisplayType == 0) {
793ff80c 539
540 pgon = new TPGON("S_TRD","TRD","void",0,360,AliTRDgeometry::Nsect(),4);
541 rmin = AliTRDgeometry::Rmin();
542 rmax = AliTRDgeometry::Rmax();
543 pgon->DefineSection(0,-AliTRDgeometry::Zmax1(),rmax,rmax);
544 pgon->DefineSection(1,-AliTRDgeometry::Zmax2(),rmin,rmax);
545 pgon->DefineSection(2, AliTRDgeometry::Zmax2(),rmin,rmax);
546 pgon->DefineSection(3, AliTRDgeometry::Zmax1(),rmax,rmax);
547 top->cd();
548 node = new TNode("TRD","TRD","S_TRD",0,0,0,"");
549 node->SetLineColor(kColorTRD);
550 fNodes->Add(node);
551
db30bf0f 552 }
553 else if (fDisplayType == 1) {
793ff80c 554
f73816f5 555 Char_t name[7];
556
793ff80c 557 Float_t slope = (AliTRDgeometry::Zmax1() - AliTRDgeometry::Zmax2())
558 / (AliTRDgeometry::Rmax() - AliTRDgeometry::Rmin());
559
332e9569 560 rmin = AliTRDgeometry::Rmin() + AliTRDgeometry::CraHght();
561 rmax = rmin + AliTRDgeometry::CdrHght();
f73816f5 562
563 Float_t thickness = rmin - AliTRDgeometry::Rmin();
564 zmax2 = AliTRDgeometry::Zmax2() + slope * thickness;
793ff80c 565 zmax1 = zmax2 + slope * AliTRDgeometry::DrThick();
793ff80c 566
db30bf0f 567 for (iPlan = 0; iPlan < AliTRDgeometry::Nplan(); iPlan++) {
793ff80c 568
f73816f5 569 sprintf(name,"S_TR1%d",iPlan);
570 pgon = new TPGON(name,"TRD","void",0,360,AliTRDgeometry::Nsect(),4);
571 pgon->DefineSection(0,-zmax1,rmax,rmax);
572 pgon->DefineSection(1,-zmax2,rmin,rmax);
573 pgon->DefineSection(2, zmax2,rmin,rmax);
574 pgon->DefineSection(3, zmax1,rmax,rmax);
575 top->cd();
576 node = new TNode("TRD","TRD",name,0,0,0,"");
577 node->SetLineColor(kColorTRD);
578 fNodes->Add(node);
579
580 Float_t height = AliTRDgeometry::Cheight() + AliTRDgeometry::Cspace();
581 rmin = rmin + height;
582 rmax = rmax + height;
583 zmax1 = zmax1 + slope * height;
584 zmax2 = zmax2 + slope * height;
585
586 }
587
588 thickness += AliTRDgeometry::DrThick();
589 rmin = AliTRDgeometry::Rmin() + thickness;
590 rmax = rmin + AliTRDgeometry::AmThick();
591 zmax2 = AliTRDgeometry::Zmax2() + slope * thickness;
592 zmax1 = zmax2 + slope * AliTRDgeometry::AmThick();
593
db30bf0f 594 for (iPlan = 0; iPlan < AliTRDgeometry::Nplan(); iPlan++) {
f73816f5 595
596 sprintf(name,"S_TR2%d",iPlan);
793ff80c 597 pgon = new TPGON(name,"TRD","void",0,360,AliTRDgeometry::Nsect(),4);
598 pgon->DefineSection(0,-zmax1,rmax,rmax);
599 pgon->DefineSection(1,-zmax2,rmin,rmax);
600 pgon->DefineSection(2, zmax2,rmin,rmax);
601 pgon->DefineSection(3, zmax1,rmax,rmax);
602 top->cd();
603 node = new TNode("TRD","TRD",name,0,0,0,"");
604 node->SetLineColor(kColorTRD);
605 fNodes->Add(node);
606
607 Float_t height = AliTRDgeometry::Cheight() + AliTRDgeometry::Cspace();
608 rmin = rmin + height;
609 rmax = rmax + height;
610 zmax1 = zmax1 + slope * height;
611 zmax2 = zmax2 + slope * height;
612
613 }
614
db30bf0f 615 }
d3f347ff 616
fe4da5cc 617}
618
8230f242 619//_____________________________________________________________________________
dd9a6ee3 620void AliTRD::Copy(TObject &trd)
8230f242 621{
622 //
623 // Copy function
624 //
625
793ff80c 626 ((AliTRD &) trd).fGasMix = fGasMix;
627 ((AliTRD &) trd).fGeometry = fGeometry;
628 ((AliTRD &) trd).fRecPoints = fRecPoints;
629 ((AliTRD &) trd).fNRecPoints = fNRecPoints;
630 ((AliTRD &) trd).fGasDensity = fGasDensity;
631 ((AliTRD &) trd).fFoilDensity = fFoilDensity;
632 ((AliTRD &) trd).fDrawTR = fDrawTR;
633 ((AliTRD &) trd).fDisplayType = fDisplayType;
332e9569 634 ((AliTRD &) trd).fHitType = fHitType;
8230f242 635
636 //AliDetector::Copy(trd);
637
638}
639
fe4da5cc 640//_____________________________________________________________________________
82bbf98a 641void AliTRD::CreateGeometry()
fe4da5cc 642{
82bbf98a 643 //
644 // Creates the volumes for the TRD chambers
645 //
82bbf98a 646
647 // Check that FRAME is there otherwise we have no place where to put the TRD
8230f242 648 AliModule* frame = gAlice->GetModule("FRAME");
649 if (!frame) {
851d3db9 650 printf(" The TRD needs the FRAME to be defined first\n");
651 return;
82bbf98a 652 }
d3f347ff 653
851d3db9 654 fGeometry->CreateGeometry(fIdtmed->GetArray() - 1299);
5c7f4665 655
82bbf98a 656}
657
658//_____________________________________________________________________________
659void AliTRD::CreateMaterials()
660{
fe4da5cc 661 //
662 // Create the materials for the TRD
663 // Origin Y.Foka
664 //
665
8230f242 666 Int_t isxfld = gAlice->Field()->Integ();
667 Float_t sxmgmx = gAlice->Field()->Max();
fe4da5cc 668
d3f347ff 669 // For polyethilene (CH2)
670 Float_t ape[2] = { 12., 1. };
671 Float_t zpe[2] = { 6., 1. };
672 Float_t wpe[2] = { 1., 2. };
673 Float_t dpe = 0.95;
674
675 // For mylar (C5H4O2)
676 Float_t amy[3] = { 12., 1., 16. };
677 Float_t zmy[3] = { 6., 1., 8. };
678 Float_t wmy[3] = { 5., 4., 2. };
fe4da5cc 679 Float_t dmy = 1.39;
d3f347ff 680
681 // For CO2
682 Float_t aco[2] = { 12., 16. };
683 Float_t zco[2] = { 6., 8. };
684 Float_t wco[2] = { 1., 2. };
685 Float_t dco = 0.001977;
686
687 // For water
688 Float_t awa[2] = { 1., 16. };
689 Float_t zwa[2] = { 1., 8. };
690 Float_t wwa[2] = { 2., 1. };
691 Float_t dwa = 1.0;
692
693 // For isobutane (C4H10)
694 Float_t ais[2] = { 12., 1. };
695 Float_t zis[2] = { 6., 1. };
696 Float_t wis[2] = { 4., 10. };
697 Float_t dis = 0.00267;
698
db30bf0f 699 // For plexiglas (C5H8O2)
700 Float_t apg[3] = { 12.011 , 1.0 , 15.9994 };
701 Float_t zpg[3] = { 6.0 , 1.0 , 8.0 };
702 Float_t wpg[3] = { 5.0 , 8.0 , 2.0 };
703 Float_t dpg = 1.18;
704
d3f347ff 705 // For Xe/CO2-gas-mixture
db30bf0f 706 // Xe-content of the Xe/CO2-mixture (85% / 15%)
707 Float_t fxc = .85;
d3f347ff 708 // Xe-content of the Xe/Isobutane-mixture (97% / 3%)
709 Float_t fxi = .97;
fe4da5cc 710 Float_t dxe = .005858;
711
d3f347ff 712 // General tracking parameter
fe4da5cc 713 Float_t tmaxfd = -10.;
714 Float_t stemax = -1e10;
d3f347ff 715 Float_t deemax = -0.1;
716 Float_t epsil = 1e-4;
717 Float_t stmin = -0.001;
fe4da5cc 718
719 Float_t absl, radl, d, buf[1];
793ff80c 720 Float_t agm[2], zgm[2], wgm[2];
721 Float_t dgm1, dgm2;
d3f347ff 722 Int_t nbuf;
fe4da5cc 723
d3f347ff 724 //////////////////////////////////////////////////////////////////////////
fe4da5cc 725 // Define Materials
d3f347ff 726 //////////////////////////////////////////////////////////////////////////
727
16bf9884 728 AliMaterial( 1, "Al" , 26.98, 13.0, 2.7 , 8.9 , 37.2);
729 AliMaterial( 2, "Air" , 14.61, 7.3, 0.001205, 30420.0 , 67500.0);
730 AliMaterial( 4, "Xe" , 131.29, 54.0, dxe , 1447.59, 0.0);
731 AliMaterial( 5, "Cu" , 63.54, 29.0, 8.96 , 1.43, 14.8);
732 AliMaterial( 6, "C" , 12.01, 6.0, 2.265 , 18.8 , 74.4);
733 AliMaterial(12, "G10" , 20.00, 10.0, 1.7 , 19.4 , 999.0);
734 AliMaterial(15, "Sn" , 118.71, 50.0, 7.31 , 1.21, 14.8);
735 AliMaterial(16, "Si" , 28.09, 14.0, 2.33 , 9.36, 37.2);
736 AliMaterial(17, "Epoxy", 17.75, 8.9, 1.8 , 21.82, 999.0);
d3f347ff 737
738 // Mixtures
db30bf0f 739 AliMixture(3, "Polyethilene", ape, zpe, dpe, -2, wpe);
740 AliMixture(7, "Mylar", amy, zmy, dmy, -3, wmy);
741 AliMixture(8, "CO2", aco, zco, dco, -2, wco);
742 AliMixture(9, "Isobutane", ais, zis, dis, -2, wis);
743 AliMixture(13,"Water", awa, zwa, dwa, -2, wwa);
744 AliMixture(14,"Plexiglas", apg, zpg, dpg, -3, wpg);
d3f347ff 745
746 // Gas mixtures
82bbf98a 747 Char_t namate[21];
d3f347ff 748 // Xe/CO2-mixture
749 // Get properties of Xe
cfce8870 750 gMC->Gfmate((*fIdmate)[4], namate, agm[0], zgm[0], d, radl, absl, buf, nbuf);
d3f347ff 751 // Get properties of CO2
cfce8870 752 gMC->Gfmate((*fIdmate)[8], namate, agm[1], zgm[1], d, radl, absl, buf, nbuf);
d3f347ff 753 // Create gas mixture
754 wgm[0] = fxc;
755 wgm[1] = 1. - fxc;
793ff80c 756 dgm1 = wgm[0] * dxe + wgm[1] * dco;
db30bf0f 757 AliMixture(10, "Gas mixture 1", agm, zgm, dgm1, 2, wgm);
d3f347ff 758 // Xe/Isobutane-mixture
759 // Get properties of Xe
cfce8870 760 gMC->Gfmate((*fIdmate)[4], namate, agm[0], zgm[0], d, radl, absl, buf, nbuf);
d3f347ff 761 // Get properties of Isobutane
cfce8870 762 gMC->Gfmate((*fIdmate)[9], namate, agm[1], zgm[1], d, radl, absl, buf, nbuf);
d3f347ff 763 // Create gas mixture
764 wgm[0] = fxi;
765 wgm[1] = 1. - fxi;
793ff80c 766 dgm2 = wgm[0] * dxe + wgm[1] * dis;
db30bf0f 767 AliMixture(11, "Gas mixture 2", agm, zgm, dgm2, 2, wgm);
d3f347ff 768
769 //////////////////////////////////////////////////////////////////////////
fe4da5cc 770 // Tracking Media Parameters
d3f347ff 771 //////////////////////////////////////////////////////////////////////////
772
773 // Al Frame
db30bf0f 774 AliMedium(1, "Al Frame", 1, 0, isxfld, sxmgmx
d3f347ff 775 , tmaxfd, stemax, deemax, epsil, stmin);
776 // Air
db30bf0f 777 AliMedium(2, "Air", 2, 0, isxfld, sxmgmx
d3f347ff 778 , tmaxfd, stemax, deemax, epsil, stmin);
779 // Polyethilene
db30bf0f 780 AliMedium(3, "Radiator", 3, 0, isxfld, sxmgmx
d3f347ff 781 , tmaxfd, stemax, deemax, epsil, stmin);
782 // Xe
db30bf0f 783 AliMedium(4, "Xe", 4, 1, isxfld, sxmgmx
d3f347ff 784 , tmaxfd, stemax, deemax, epsil, stmin);
785 // Cu pads
db30bf0f 786 AliMedium(5, "Padplane", 5, 1, isxfld, sxmgmx
d3f347ff 787 , tmaxfd, stemax, deemax, epsil, stmin);
788 // Fee + cables
db30bf0f 789 AliMedium(6, "Readout", 1, 0, isxfld, sxmgmx
d3f347ff 790 , tmaxfd, stemax, deemax, epsil, stmin);
791 // C frame
db30bf0f 792 AliMedium(7, "C Frame", 6, 0, isxfld, sxmgmx
d3f347ff 793 , tmaxfd, stemax, deemax, epsil, stmin);
794 // Mylar foils
db30bf0f 795 AliMedium(8, "Mylar", 7, 0, isxfld, sxmgmx
d3f347ff 796 , tmaxfd, stemax, deemax, epsil, stmin);
797 if (fGasMix == 1) {
798 // Gas-mixture (Xe/CO2)
db30bf0f 799 AliMedium(9, "Gas-mix", 10, 1, isxfld, sxmgmx
d3f347ff 800 , tmaxfd, stemax, deemax, epsil, stmin);
801 }
802 else {
803 // Gas-mixture (Xe/Isobutane)
db30bf0f 804 AliMedium(9, "Gas-mix", 11, 1, isxfld, sxmgmx
d3f347ff 805 , tmaxfd, stemax, deemax, epsil, stmin);
806 }
807 // Nomex-honeycomb (use carbon for the time being)
db30bf0f 808 AliMedium(10, "Nomex", 6, 0, isxfld, sxmgmx
d3f347ff 809 , tmaxfd, stemax, deemax, epsil, stmin);
810 // Kapton foils (use Mylar for the time being)
db30bf0f 811 AliMedium(11, "Kapton", 7, 0, isxfld, sxmgmx
d3f347ff 812 , tmaxfd, stemax, deemax, epsil, stmin);
813 // Gas-filling of the radiator
db30bf0f 814 AliMedium(12, "CO2", 8, 0, isxfld, sxmgmx
d3f347ff 815 , tmaxfd, stemax, deemax, epsil, stmin);
816 // G10-plates
db30bf0f 817 AliMedium(13, "G10-plates",12, 0, isxfld, sxmgmx
d3f347ff 818 , tmaxfd, stemax, deemax, epsil, stmin);
819 // Cooling water
db30bf0f 820 AliMedium(14, "Water", 13, 0, isxfld, sxmgmx
821 , tmaxfd, stemax, deemax, epsil, stmin);
822 // Rohacell (plexiglas) for the radiator
823 AliMedium(15, "Rohacell", 14, 0, isxfld, sxmgmx
d3f347ff 824 , tmaxfd, stemax, deemax, epsil, stmin);
16bf9884 825 // Al layer in MCMs
826 AliMedium(16, "MCM-Al" , 1, 0, isxfld, sxmgmx
827 , tmaxfd, stemax, deemax, epsil, stmin);
828 // Sn layer in MCMs
829 AliMedium(17, "MCM-Sn" , 15, 0, isxfld, sxmgmx
830 , tmaxfd, stemax, deemax, epsil, stmin);
831 // Cu layer in MCMs
832 AliMedium(18, "MCM-Cu" , 5, 0, isxfld, sxmgmx
833 , tmaxfd, stemax, deemax, epsil, stmin);
834 // G10 layer in MCMs
835 AliMedium(19, "MCM-G10" , 12, 0, isxfld, sxmgmx
836 , tmaxfd, stemax, deemax, epsil, stmin);
837 // Si in readout chips
838 AliMedium(20, "Chip-Si" , 16, 0, isxfld, sxmgmx
839 , tmaxfd, stemax, deemax, epsil, stmin);
840 // Epoxy in readout chips
841 AliMedium(21, "Chip-Ep" , 17, 0, isxfld, sxmgmx
842 , tmaxfd, stemax, deemax, epsil, stmin);
843 // PE in connectors
844 AliMedium(22, "Conn-PE" , 3, 0, isxfld, sxmgmx
845 , tmaxfd, stemax, deemax, epsil, stmin);
846 // Cu in connectors
847 AliMedium(23, "Chip-Cu" , 5, 0, isxfld, sxmgmx
848 , tmaxfd, stemax, deemax, epsil, stmin);
849 // Al of cooling pipes
850 AliMedium(24, "Cooling" , 1, 0, isxfld, sxmgmx
851 , tmaxfd, stemax, deemax, epsil, stmin);
d3f347ff 852
793ff80c 853 // Save the density values for the TRD absorbtion
854 fFoilDensity = dmy;
855 if (fGasMix == 1)
856 fGasDensity = dgm1;
857 else
858 fGasDensity = dgm2;
859
fe4da5cc 860}
861
82bbf98a 862//_____________________________________________________________________________
0a29d0f1 863void AliTRD::DrawModule() const
82bbf98a 864{
865 //
866 // Draw a shaded view of the Transition Radiation Detector version 0
867 //
868
869 // Set everything unseen
870 gMC->Gsatt("*" ,"SEEN",-1);
871
872 // Set ALIC mother transparent
873 gMC->Gsatt("ALIC","SEEN", 0);
874
875 // Set the volumes visible
851d3db9 876 if (fGeometry->IsVersion() == 0) {
5c7f4665 877 gMC->Gsatt("B071","SEEN", 0);
878 gMC->Gsatt("B074","SEEN", 0);
879 gMC->Gsatt("B075","SEEN", 0);
880 gMC->Gsatt("B077","SEEN", 0);
881 gMC->Gsatt("BTR1","SEEN", 0);
882 gMC->Gsatt("BTR2","SEEN", 0);
883 gMC->Gsatt("BTR3","SEEN", 0);
332e9569 884 gMC->Gsatt("UTR1","SEEN", 0);
885 gMC->Gsatt("UTR2","SEEN", 0);
886 gMC->Gsatt("UTR3","SEEN", 0);
5c7f4665 887 }
888 else {
889 gMC->Gsatt("B071","SEEN", 0);
890 gMC->Gsatt("B074","SEEN", 0);
891 gMC->Gsatt("B075","SEEN", 0);
892 gMC->Gsatt("B077","SEEN", 0);
893 gMC->Gsatt("BTR1","SEEN", 0);
894 gMC->Gsatt("BTR2","SEEN", 0);
895 gMC->Gsatt("BTR3","SEEN", 0);
332e9569 896 gMC->Gsatt("UTR1","SEEN", 0);
6f1e466d 897 if (fGeometry->GetPHOShole())
332e9569 898 gMC->Gsatt("UTR2","SEEN", 0);
6f1e466d 899 if (fGeometry->GetRICHhole())
332e9569 900 gMC->Gsatt("UTR3","SEEN", 0);
5c7f4665 901 }
332e9569 902// gMC->Gsatt("UCII","SEEN", 0);
903// gMC->Gsatt("UCIM","SEEN", 0);
904// gMC->Gsatt("UCIO","SEEN", 0);
905// gMC->Gsatt("UL02","SEEN", 1);
906// gMC->Gsatt("UL05","SEEN", 1);
907// gMC->Gsatt("UL06","SEEN", 1);
82bbf98a 908
909 gMC->Gdopt("hide", "on");
910 gMC->Gdopt("shad", "on");
911 gMC->Gsatt("*", "fill", 7);
912 gMC->SetClipBox(".");
913 gMC->SetClipBox("*", 0, 2000, -2000, 2000, -2000, 2000);
914 gMC->DefaultRange();
915 gMC->Gdraw("alic", 40, 30, 0, 12, 9.4, .021, .021);
916 gMC->Gdhead(1111, "Transition Radiation Detector");
917 gMC->Gdman(18, 4, "MAN");
918
919}
920
fe4da5cc 921//_____________________________________________________________________________
0a29d0f1 922Int_t AliTRD::DistancetoPrimitive(Int_t , Int_t ) const
fe4da5cc 923{
924 //
925 // Distance between the mouse and the TRD detector on the screen
926 // Dummy routine
82bbf98a 927
928 return 9999;
929
fe4da5cc 930}
931
932//_____________________________________________________________________________
933void AliTRD::Init()
934{
935 //
851d3db9 936 // Initialize the TRD detector after the geometry has been created
fe4da5cc 937 //
82bbf98a 938
5c7f4665 939 Int_t i;
851d3db9 940
abaf1f1d 941 if (fDebug) {
9e1a0ddb 942 printf("\n%s: ",ClassName());
943 for (i = 0; i < 35; i++) printf("*");
944 printf(" TRD_INIT ");
945 for (i = 0; i < 35; i++) printf("*");
946 printf("\n");
947 }
5c7f4665 948
851d3db9 949 if (fGeometry->IsVersion() == 0) {
9e1a0ddb 950 printf("%s: Geometry for spaceframe with holes initialized\n",ClassName());
851d3db9 951 }
952 else if (fGeometry->IsVersion() == 1) {
9e1a0ddb 953 printf("%s: Geometry for spaceframe without holes initialized\n",ClassName());
6f1e466d 954 if (fGeometry->GetPHOShole())
9e1a0ddb 955 printf("%s: Leave space in front of PHOS free\n",ClassName());
6f1e466d 956 if (fGeometry->GetRICHhole())
9e1a0ddb 957 printf("%s: Leave space in front of RICH free\n",ClassName());
5c7f4665 958 }
9e1a0ddb 959
abaf1f1d 960 if (fGasMix == 1) {
db30bf0f 961 printf("%s: Gas Mixture: 85%% Xe + 15%% CO2\n",ClassName());
abaf1f1d 962 }
963 else {
9e1a0ddb 964 printf("%s: Gas Mixture: 97%% Xe + 3%% Isobutane\n",ClassName());
abaf1f1d 965 }
5c7f4665 966
967}
968
793ff80c 969//_____________________________________________________________________________
970void AliTRD::LoadPoints(Int_t track)
971{
972 //
973 // Store x, y, z of all hits in memory.
974 // Hit originating from TR photons are given a different color
975 //
976
332e9569 977 //if (!fDrawTR) {
978 // AliDetector::LoadPoints(track);
979 // return;
980 //}
793ff80c 981
332e9569 982 if ((fHits == 0) && (fTrackHits == 0)) return;
793ff80c 983
332e9569 984 Int_t nhits;
985 if (fHitType < 2) {
986 nhits = fHits->GetEntriesFast();
987 }
988 else {
989 nhits = fTrackHits->GetEntriesFast();
990 }
793ff80c 991 if (nhits == 0) return;
992
993 Int_t tracks = gAlice->GetNtrack();
994 if (fPoints == 0) fPoints = new TObjArray(tracks);
995
996 AliTRDhit *ahit;
997
998 Int_t *ntrkE = new Int_t[tracks];
999 Int_t *ntrkT = new Int_t[tracks];
1000 Int_t *limiE = new Int_t[tracks];
1001 Int_t *limiT = new Int_t[tracks];
1002 Float_t **coorE = new Float_t*[tracks];
1003 Float_t **coorT = new Float_t*[tracks];
1004 for(Int_t i = 0; i < tracks; i++) {
1005 ntrkE[i] = 0;
1006 ntrkT[i] = 0;
1007 coorE[i] = 0;
1008 coorT[i] = 0;
1009 limiE[i] = 0;
1010 limiT[i] = 0;
1011 }
1012
332e9569 1013 AliTRDpoints *points = 0;
1014 Float_t *fp = 0;
1015 Int_t trk;
1016 Int_t chunk = nhits / 4 + 1;
793ff80c 1017
1018 // Loop over all the hits and store their position
332e9569 1019 ahit = (AliTRDhit *) FirstHit(-1);
1020 while (ahit) {
793ff80c 1021
1022 // dEdx hits
332e9569 1023 if (ahit->GetCharge() >= 0) {
793ff80c 1024
1025 trk = ahit->GetTrack();
1026 if (ntrkE[trk] == limiE[trk]) {
1027 // Initialise a new track
1028 fp = new Float_t[3*(limiE[trk]+chunk)];
1029 if (coorE[trk]) {
1030 memcpy(fp,coorE[trk],sizeof(Float_t)*3*limiE[trk]);
1031 delete [] coorE[trk];
1032 }
1033 limiE[trk] += chunk;
1034 coorE[trk] = fp;
1035 }
1036 else {
1037 fp = coorE[trk];
1038 }
1039 fp[3*ntrkE[trk] ] = ahit->X();
1040 fp[3*ntrkE[trk]+1] = ahit->Y();
1041 fp[3*ntrkE[trk]+2] = ahit->Z();
1042 ntrkE[trk]++;
1043
1044 }
1045 // TR photon hits
332e9569 1046 else if ((ahit->GetCharge() < 0) && (fDrawTR)) {
793ff80c 1047
1048 trk = ahit->GetTrack();
1049 if (ntrkT[trk] == limiT[trk]) {
1050 // Initialise a new track
1051 fp = new Float_t[3*(limiT[trk]+chunk)];
1052 if (coorT[trk]) {
1053 memcpy(fp,coorT[trk],sizeof(Float_t)*3*limiT[trk]);
1054 delete [] coorT[trk];
1055 }
1056 limiT[trk] += chunk;
1057 coorT[trk] = fp;
1058 }
1059 else {
1060 fp = coorT[trk];
1061 }
1062 fp[3*ntrkT[trk] ] = ahit->X();
1063 fp[3*ntrkT[trk]+1] = ahit->Y();
1064 fp[3*ntrkT[trk]+2] = ahit->Z();
1065 ntrkT[trk]++;
1066
1067 }
1068
332e9569 1069 ahit = (AliTRDhit *) NextHit();
1070
793ff80c 1071 }
1072
1073 for (trk = 0; trk < tracks; ++trk) {
1074
1075 if (ntrkE[trk] || ntrkT[trk]) {
1076
1077 points = new AliTRDpoints();
1078 points->SetDetector(this);
1079 points->SetParticle(trk);
1080
1081 // Set the dEdx points
1082 if (ntrkE[trk]) {
1083 points->SetMarkerColor(GetMarkerColor());
1084 points->SetMarkerSize(GetMarkerSize());
1085 points->SetPolyMarker(ntrkE[trk],coorE[trk],GetMarkerStyle());
1086 delete [] coorE[trk];
1087 coorE[trk] = 0;
1088 }
1089
1090 // Set the TR photon points
1091 if (ntrkT[trk]) {
1092 points->SetTRpoints(ntrkT[trk],coorT[trk]);
1093 delete [] coorT[trk];
1094 coorT[trk] = 0;
1095 }
1096
1097 fPoints->AddAt(points,trk);
1098
1099 }
1100
1101 }
1102
1103 delete [] coorE;
1104 delete [] coorT;
1105 delete [] ntrkE;
1106 delete [] ntrkT;
1107 delete [] limiE;
1108 delete [] limiT;
1109
1110}
1111
5c7f4665 1112//_____________________________________________________________________________
9e1a0ddb 1113void AliTRD::MakeBranch(Option_t* option, const char *file)
5c7f4665 1114{
1115 //
abaf1f1d 1116 // Create Tree branches for the TRD digits.
5c7f4665 1117 //
1118
abaf1f1d 1119 Int_t buffersize = 4000;
1120 Char_t branchname[15];
1121 sprintf(branchname,"%s",GetName());
5c7f4665 1122
aa9d00f0 1123 const char *cD = strstr(option,"D");
1124
2ab0c725 1125 AliDetector::MakeBranch(option,file);
5c7f4665 1126
abaf1f1d 1127 if (fDigits && gAlice->TreeD() && cD) {
1128 MakeBranchInTree(gAlice->TreeD(),branchname,&fDigits,buffersize,file);
1129 }
1130
332e9569 1131 if (fHitType > 1) {
1132 MakeBranch2(option,file);
1133 }
1134
851d3db9 1135}
1136
6244debe 1137//_____________________________________________________________________________
1138void AliTRD::ResetDigits()
1139{
1140 //
abaf1f1d 1141 // Reset number of digits and the digits array for this detector
6244debe 1142 //
1143
abaf1f1d 1144 fNdigits = 0;
1145 if (fDigits) fDigits->Clear();
6244debe 1146
1147}
1148
851d3db9 1149//_____________________________________________________________________________
1150void AliTRD::ResetRecPoints()
1151{
1152 //
1153 // Reset number of reconstructed points and the point array
1154 //
1155
f73816f5 1156 if (fRecPoints) {
793ff80c 1157 fNRecPoints = 0;
1158 Int_t nentr = fRecPoints->GetEntriesFast();
f73816f5 1159 for (Int_t i = 0; i < nentr; i++) delete fRecPoints->RemoveAt(i);
793ff80c 1160 }
5c7f4665 1161
1162}
1163
1164//_____________________________________________________________________________
1165void AliTRD::SetTreeAddress()
1166{
1167 //
1168 // Set the branch addresses for the trees.
1169 //
1170
1171 Char_t branchname[15];
1172
1173 AliDetector::SetTreeAddress();
1174
1175 TBranch *branch;
851d3db9 1176 TTree *treeR = gAlice->TreeR();
1177
1178 if (treeR) {
f73816f5 1179 sprintf(branchname,"%scluster",GetName());
851d3db9 1180 if (fRecPoints) {
1181 branch = treeR->GetBranch(branchname);
1182 if (branch) {
1183 branch->SetAddress(&fRecPoints);
1184 }
5c7f4665 1185 }
1186 }
1187
332e9569 1188 if (fHitType > 0) {
1189 SetTreeAddress2();
1190 }
1191
fe4da5cc 1192}
1193
d3f347ff 1194//_____________________________________________________________________________
b060c36f 1195void AliTRD::SetGasMix(Int_t imix)
d3f347ff 1196{
82bbf98a 1197 //
1198 // Defines the gas mixture (imix=0: Xe/Isobutane imix=1: Xe/CO2)
1199 //
1200
d3f347ff 1201 if ((imix < 0) || (imix > 1)) {
1202 printf("Wrong input value: %d\n",imix);
1203 printf("Use standard setting\n");
6244debe 1204 fGasMix = 1;
d3f347ff 1205 return;
1206 }
1207
1208 fGasMix = imix;
1209
1210}
1211
793ff80c 1212//_____________________________________________________________________________
1213void AliTRD::SetPHOShole()
1214{
1215 //
1216 // Selects a geometry with a hole in front of the PHOS
1217 //
1218
1219 fGeometry->SetPHOShole();
1220
1221}
1222
1223//_____________________________________________________________________________
1224void AliTRD::SetRICHhole()
1225{
1226 //
1227 // Selects a geometry with a hole in front of the RICH
1228 //
1229
1230 fGeometry->SetRICHhole();
1231
1232}
1233
dd9a6ee3 1234//_____________________________________________________________________________
1235AliTRD &AliTRD::operator=(const AliTRD &trd)
1236{
1237 //
1238 // Assignment operator
1239 //
1240
1241 if (this != &trd) ((AliTRD &) trd).Copy(*this);
1242 return *this;
1243
f73816f5 1244}
abaf1f1d 1245
332e9569 1246//_____________________________________________________________________________
1247void AliTRD::FinishPrimary()
1248{
1249 //
1250 // Store the hits in the containers after all primaries are finished
1251 //
1252
1253 if (fTrackHits) {
1254 fTrackHits->FlushHitStack();
1255 }
1256
1257}
1258
1259//_____________________________________________________________________________
1260void AliTRD::RemapTrackHitIDs(Int_t *map)
1261{
1262 //
1263 // Remap the track IDs
1264 //
1265
1266 if (!fTrackHits) {
1267 return;
1268 }
1269
1270 if (fTrackHits) {
1271 TClonesArray *arr = fTrackHits->GetArray();;
1272 for (Int_t i = 0; i < arr->GetEntriesFast(); i++){
1273 AliTrackHitsParamV2 *info = (AliTrackHitsParamV2 *) (arr->At(i));
1274 info->fTrackID = map[info->fTrackID];
1275 }
1276 }
1277
1278}
1279
1280//_____________________________________________________________________________
1281void AliTRD::ResetHits()
1282{
1283 //
1284 // Reset the hits
1285 //
1286
1287 AliDetector::ResetHits();
1288 if (fTrackHits) {
1289 fTrackHits->Clear();
1290 }
1291
1292}
1293
1294//_____________________________________________________________________________
1295AliHit* AliTRD::FirstHit(Int_t track)
1296{
1297 //
1298 // Return the first hit of a track
1299 //
1300
1301 if (fHitType > 1) {
1302 return FirstHit2(track);
1303 }
abaf1f1d 1304
332e9569 1305 return AliDetector::FirstHit(track);
abaf1f1d 1306
332e9569 1307}
1308
1309//_____________________________________________________________________________
1310AliHit* AliTRD::NextHit()
1311{
1312 //
1313 // Returns the next hit of a track
1314 //
1315
1316 if (fHitType > 1) {
1317 return NextHit2();
1318 }
1319
1320 return AliDetector::NextHit();
1321
1322}
1323
1324//_____________________________________________________________________________
0a29d0f1 1325AliHit* AliTRD::FirstHit2(Int_t track)
332e9569 1326{
1327 //
1328 // Initializes the hit iterator.
1329 // Returns the address of the first hit of a track.
1330 // If <track> >= 0 the track is read from disk,
1331 // while if <track> < 0 the first hit of the current
1332 // track is returned.
1333 //
1334
1335 if (track >= 0) {
1336 gAlice->ResetHits();
1337 gAlice->TreeH()->GetEvent(track);
1338 }
1339
1340 if (fTrackHits) {
1341 fTrackHits->First();
1342 return (AliHit*) fTrackHits->GetHit();
1343 }
1344 else {
1345 return 0;
1346 }
1347
1348}
1349
1350//_____________________________________________________________________________
1351AliHit* AliTRD::NextHit2()
1352{
1353 //
1354 // Returns the next hit of the current track
1355 //
1356
1357 if (fTrackHits) {
1358 fTrackHits->Next();
1359 return (AliHit *) fTrackHits->GetHit();
1360 }
1361 else {
1362 return 0;
1363 }
1364
1365}
1366
1367//_____________________________________________________________________________
1368void AliTRD::MakeBranch2(Option_t *option, const char *file)
1369{
1370 //
1371 // Create a new branch in the current Root tree.
1372 // The branch of fHits is automatically split.
1373 //
1374
1375 if (fHitType < 2) {
1376 return;
1377 }
1378
1379 char branchname[10];
1380 sprintf(branchname,"%s2",GetName());
1381
1382 // Get the pointer to the header
1383 const char *cH = strstr(option,"H");
1384
1385 if (!fTrackHits) {
1386 fTrackHits = new AliTRDtrackHits();
1387 }
1388
1389 if (fTrackHits && gAlice->TreeH() && cH) {
1390
1391 gAlice->TreeH()->Branch(branchname,"AliTRDtrackHits"
1392 ,&fTrackHits
1393 ,fBufferSize,99);
1394
1395 if (GetDebug() > 1) {
1396 printf("<AliTRD::MakeBranch2> Making Branch %s for trackhits\n"
1397 ,branchname);
1398 }
1399
0a29d0f1 1400 const char kFolder[] = "RunMC/Event/Data";
332e9569 1401
1402 if (GetDebug()) {
1403 printf("<AliTRD::MakeBranch2> %15s: Publishing %s to %s\n"
0a29d0f1 1404 ,ClassName(),branchname,kFolder);
332e9569 1405 }
1406
0a29d0f1 1407 Publish(kFolder,&fTrackHits,branchname);
332e9569 1408
1409 if (file) {
1410 TBranch *b = gAlice->TreeH()->GetBranch(branchname);
1411 TDirectory *wd = gDirectory;
1412 b->SetFile(file);
1413 TIter next(b->GetListOfBranches());
1414 while ((b = (TBranch*) next())) {
1415 b->SetFile(file);
1416 }
1417 wd->cd();
1418 if (GetDebug() > 1) {
1419 printf("<AliTRD::MakeBranch2> Diverting branch %s to file %s\n"
1420 ,branchname,file);
1421 }
1422 }
1423
1424 }
1425
1426}
1427
1428//_____________________________________________________________________________
1429void AliTRD::SetTreeAddress2()
1430{
1431 //
1432 // Set the branch address for the trackHits tree
1433 //
1434
1435 TBranch *branch;
1436
1437 char branchname[20];
1438
1439 sprintf(branchname,"%s2",GetName());
1440
1441 // Branch address for hit tree
1442 TTree *treeH = gAlice->TreeH();
1443 if ((treeH) && (fHitType > 0)) {
1444 branch = treeH->GetBranch(branchname);
1445 if (branch) {
1446 branch->SetAddress(&fTrackHits);
1447 }
1448 }
1449
1450}
1451
1452//_____________________________________________________________________________
1453void AliTRD::AddHit2(Int_t track, Int_t det, Float_t *hits, Int_t q
1454 , Bool_t inDrift)
1455{
1456 //
1457 // Add a hit to the list
1458 //
1459
1460 Int_t rtrack;
1461
1462 if (fIshunt) {
1463 Int_t primary = gAlice->GetPrimary(track);
1464 gAlice->Particle(primary)->SetBit(kKeepBit);
1465 rtrack = primary;
1466 }
1467 else {
1468 rtrack = track;
1469 gAlice->FlagTrack(track);
1470 }
1471
1472 if ((fTrackHits) && (fHitType > 0)) {
1473 fTrackHits->AddHitTRD(det,rtrack,hits[0],hits[1],hits[2],q,inDrift);
1474 }
1475
1476}
abaf1f1d 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
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815