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