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