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