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