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