]> git.uio.no Git - u/mrichter/AliRoot.git/blame - TRD/AliTRD.cxx
Loop variables declared once (needed on HP)
[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$
40c7ef21 18Revision 1.30 2001/05/28 17:07:58 hristov
19Last minute changes; ExB correction in AliTRDclusterizerV1; taking into account of material in G10 TEC frames and material between TEC planes (C.Blume,S.Sedykh)
20
a819a5f7 21Revision 1.29 2001/05/21 16:45:47 hristov
22Last minute changes (C.Blume)
23
db30bf0f 24Revision 1.28 2001/05/16 14:57:27 alibrary
25New files for folders and Stack
26
27Revision 1.27 2001/05/08 07:05:02 hristov
28Loop variable declared once (HP, Sun)
29
ea01d9e4 30Revision 1.26 2001/05/07 08:03:22 cblume
31Generate also hits in the amplification region
32
f73816f5 33Revision 1.25 2001/03/13 09:30:35 cblume
34Update of digitization. Moved digit branch definition to AliTRD
35
6244debe 36Revision 1.24 2001/01/26 19:56:49 hristov
37Major upgrade of AliRoot code
38
2ab0c725 39Revision 1.23 2000/11/01 14:53:20 cblume
40Merge with TRD-develop
41
793ff80c 42Revision 1.17.2.6 2000/10/15 23:29:08 cblume
43Introduced more detailed geometry for the display
44
45Revision 1.17.2.5 2000/10/06 16:49:46 cblume
46Made Getters const
47
48Revision 1.17.2.4 2000/10/04 16:34:57 cblume
49Replace include files by forward declarations
50
51Revision 1.17.2.3 2000/09/22 14:45:17 cblume
52Included changes for the tracking
53
54Revision 1.17.2.2 2000/09/18 13:25:13 cblume
55Included LoadPoints() method to display the TR photons
56
57Revision 1.22 2000/10/02 21:28:19 fca
58Removal of useless dependecies via forward declarations
59
60Revision 1.21 2000/06/09 11:10:07 cblume
61Compiler warnings and coding conventions, next round
62
63Revision 1.20 2000/06/08 18:32:57 cblume
64Make code compliant to coding conventions
65
66Revision 1.19 2000/06/07 16:25:37 cblume
67Try to remove compiler warnings on Sun and HP
68
69Revision 1.18 2000/05/08 16:17:27 cblume
70Merge TRD-develop
71
94de3818 72Revision 1.21 2000/06/09 11:10:07 cblume
73Compiler warnings and coding conventions, next round
74
dd9a6ee3 75Revision 1.20 2000/06/08 18:32:57 cblume
76Make code compliant to coding conventions
77
8230f242 78Revision 1.19 2000/06/07 16:25:37 cblume
79Try to remove compiler warnings on Sun and HP
80
9d0b222b 81Revision 1.18 2000/05/08 16:17:27 cblume
82Merge TRD-develop
83
6f1e466d 84Revision 1.17.2.1 2000/05/08 14:28:59 cblume
85Introduced SetPHOShole() and SetRICHhole(). AliTRDrecPoint container is now a TObjArray
86
87Revision 1.17 2000/02/28 19:10:26 cblume
88Include the new TRD classes
89
851d3db9 90Revision 1.16.2.2 2000/02/28 17:53:24 cblume
91Introduce TRD geometry classes
92
93Revision 1.16.2.1 2000/02/28 17:04:19 cblume
94Include functions and data members for AliTRDrecPoint
95
96Revision 1.16 2000/01/19 17:17:35 fca
97Introducing a list of lists of hits -- more hits allowed for detector now
98
1cedd08a 99Revision 1.15 1999/11/02 17:04:25 fca
100Small syntax change for HP compiler
101
94c641ff 102Revision 1.14 1999/11/02 16:57:02 fca
103Avoid non ansi warnings on HP compilers
104
8459a454 105Revision 1.13 1999/11/02 16:35:56 fca
106New version of TRD introduced
107
5c7f4665 108Revision 1.12 1999/11/01 20:41:51 fca
109Added protections against using the wrong version of FRAME
110
ab76897d 111Revision 1.11 1999/09/29 09:24:34 fca
112Introduction of the Copyright and cvs Log
113
4c039060 114*/
115
fe4da5cc 116///////////////////////////////////////////////////////////////////////////////
117// //
118// Transition Radiation Detector //
119// This class contains the basic functions for the Transition Radiation //
6f1e466d 120// Detector. //
fe4da5cc 121// //
122///////////////////////////////////////////////////////////////////////////////
123
5c7f4665 124#include <stdlib.h>
2ab0c725 125#include <iostream.h>
5c7f4665 126
fe4da5cc 127#include <TMath.h>
fe4da5cc 128#include <TNode.h>
94de3818 129#include <TGeometry.h>
793ff80c 130#include <TTree.h>
131#include <TPGON.h>
fe4da5cc 132
fe4da5cc 133#include "AliRun.h"
d3f347ff 134#include "AliConst.h"
793ff80c 135#include "AliDigit.h"
136#include "AliMagF.h"
137#include "AliMC.h"
138
139#include "AliTRD.h"
140#include "AliTRDhit.h"
141#include "AliTRDpoints.h"
142#include "AliTRDdigit.h"
851d3db9 143#include "AliTRDdigitizer.h"
144#include "AliTRDclusterizer.h"
145#include "AliTRDgeometryHole.h"
146#include "AliTRDgeometryFull.h"
147#include "AliTRDrecPoint.h"
f73816f5 148#include "AliTRDcluster.h"
2ab0c725 149#include "AliTRDdigitsManager.h"
6244debe 150#include "AliTRDdataArrayI.h"
151#include "AliTRDsegmentArray.h"
793ff80c 152
fe4da5cc 153ClassImp(AliTRD)
154
155//_____________________________________________________________________________
156AliTRD::AliTRD()
157{
158 //
159 // Default constructor
160 //
82bbf98a 161
6244debe 162 fIshunt = 0;
163 fGasMix = 0;
164 fHits = 0;
165 fDigits = 0;
5c7f4665 166
6244debe 167 fRecPoints = 0;
168 fNRecPoints = 0;
5c7f4665 169
6244debe 170 fGeometry = 0;
82bbf98a 171
6244debe 172 fGasDensity = 0;
173 fFoilDensity = 0;
793ff80c 174
6244debe 175 fDrawTR = 0;
176 fDisplayType = 0;
177
178 fDigitsArray = 0;
179 for (Int_t iDict = 0; iDict < AliTRDdigitsManager::NDict(); iDict++) {
180 fDictionaryArray[iDict] = 0;
181 }
793ff80c 182
fe4da5cc 183}
184
185//_____________________________________________________________________________
186AliTRD::AliTRD(const char *name, const char *title)
187 : AliDetector(name,title)
188{
189 //
190 // Standard constructor for the TRD
191 //
192
5c7f4665 193 // Check that FRAME is there otherwise we have no place where to
194 // put TRD
8230f242 195 AliModule* frame = gAlice->GetModule("FRAME");
196 if (!frame) {
5c7f4665 197 Error("Ctor","TRD needs FRAME to be present\n");
198 exit(1);
199 }
200
201 // Define the TRD geometry according to the FRAME geometry
8230f242 202 if (frame->IsVersion() == 0) {
851d3db9 203 // Geometry with hole
204 fGeometry = new AliTRDgeometryHole();
205 }
8230f242 206 else if (frame->IsVersion() == 1) {
851d3db9 207 // Geometry without hole
208 fGeometry = new AliTRDgeometryFull();
209 }
210 else {
211 Error("Ctor","Could not find valid FRAME version\n");
212 exit(1);
213 }
5c7f4665 214
fe4da5cc 215 // Allocate the hit array
f73816f5 216 fHits = new TClonesArray("AliTRDhit" ,405);
1cedd08a 217 gAlice->AddHitList(fHits);
99d5402e 218
219 // Allocate the digits array
f73816f5 220 fDigits = 0;
5c7f4665 221
851d3db9 222 // Allocate the rec point array
6244debe 223 fRecPoints = new TObjArray(400);
224 fNRecPoints = 0;
99d5402e 225
6244debe 226 fIshunt = 0;
227 fGasMix = 1;
793ff80c 228
6244debe 229 fGasDensity = 0;
230 fFoilDensity = 0;
793ff80c 231
6244debe 232 fDrawTR = 0;
233 fDisplayType = 0;
234
235 fDigitsArray = 0;
236 for (Int_t iDict = 0; iDict < AliTRDdigitsManager::NDict(); iDict++) {
237 fDictionaryArray[iDict] = 0;
238 }
82bbf98a 239
fe4da5cc 240 SetMarkerColor(kWhite);
82bbf98a 241
fe4da5cc 242}
99d5402e 243
8230f242 244//_____________________________________________________________________________
dd9a6ee3 245AliTRD::AliTRD(const AliTRD &trd)
8230f242 246{
247 //
248 // Copy constructor
249 //
250
dd9a6ee3 251 ((AliTRD &) trd).Copy(*this);
8230f242 252
253}
254
99d5402e 255//_____________________________________________________________________________
256AliTRD::~AliTRD()
257{
258 //
259 // TRD destructor
260 //
261
262 fIshunt = 0;
263
851d3db9 264 delete fGeometry;
99d5402e 265 delete fHits;
851d3db9 266 delete fRecPoints;
6244debe 267 if (fDigitsArray) delete fDigitsArray;
268 for (Int_t iDict = 0; iDict < AliTRDdigitsManager::NDict(); iDict++) {
269 if (fDictionaryArray[iDict]) delete fDictionaryArray[iDict];
270 }
5c7f4665 271
272}
273
274//_____________________________________________________________________________
f73816f5 275void AliTRD::AddCluster(Float_t *pos, Int_t *digits, Int_t det, Float_t amp
a819a5f7 276 , Int_t *tracks, Float_t sigmaY2, Int_t iType)
5c7f4665 277{
278 //
f73816f5 279 // Add a cluster for the TRD
851d3db9 280 //
793ff80c 281
f73816f5 282 Int_t pla = fGeometry->GetPlane(det);
283 Int_t cha = fGeometry->GetChamber(det);
284 Int_t sec = fGeometry->GetSector(det);
285
286 Float_t padRow = pos[0];
287 Float_t padCol = pos[1];
288 Float_t row0 = fGeometry->GetRow0(pla,cha,sec);
289 Float_t col0 = fGeometry->GetCol0(pla);
290 Float_t rowSize = fGeometry->GetRowPadSize(pla,cha,sec);
291 Float_t colSize = fGeometry->GetColPadSize(pla);
292
293 AliTRDcluster *c = new AliTRDcluster();
294
295 c->SetDetector(det);
296 c->AddTrackIndex(tracks);
99d5402e 297
f73816f5 298 c->SetQ(amp);
299
300 c->SetLocalTimeBin(((Int_t) pos[2]));
301 c->SetY(- (col0 + padCol * colSize));
302 c->SetZ( row0 + padRow * rowSize);
303
a819a5f7 304 c->SetSigmaY2((sigmaY2 + 1./12.) * colSize*colSize);
f73816f5 305 c->SetSigmaZ2(rowSize * rowSize / 12.);
306
db30bf0f 307 switch (iType) {
308 case 0:
309 c->Set2pad();
310 break;
311 case 1:
312 c->Set3pad();
313 break;
314 case 2:
315 c->Set4pad();
316 break;
317 case 3:
318 c->Set5pad();
319 break;
320 case 4:
321 c->SetLarge();
322 break;
323 };
793ff80c 324
f73816f5 325 fRecPoints->Add(c);
6f1e466d 326
99d5402e 327}
6244debe 328
329//_____________________________________________________________________________
330void AliTRD::Hits2Digits()
2ab0c725 331{
332 //
333 // Create digits
334 //
6244debe 335
336 AliTRDdigitizer *digitizer = new AliTRDdigitizer("TRDdigitizer"
337 ,"TRD digitizer class");
2ab0c725 338
339 // Set the parameter
6244debe 340 digitizer->SetDiffusion();
341 digitizer->SetExB();
9e1a0ddb 342 digitizer->SetEvent(gAlice->GetEvNumber());
6244debe 343 // Initialization
db30bf0f 344 digitizer->InitDetector();
6244debe 345
346 // Create the digits
347 digitizer->MakeDigits();
2ab0c725 348
6244debe 349 // Write the digits into the input file
350 if (digitizer->Digits()->MakeBranch(fDigitsFile)) {
351
352 digitizer->WriteDigits();
353
354 // Save the digitizer class in the AliROOT
355 digitizer->Write();
356
357 }
358
359}
360
361//_____________________________________________________________________________
362void AliTRD::Hits2SDigits()
363{
364 //
365 // Create summable digits
366 //
367
368 AliTRDdigitizer *digitizer = new AliTRDdigitizer("TRDdigitizer"
369 ,"TRD digitizer class");
370
371 // For the summable digits
372 digitizer->SetSDigits(kTRUE);
2ab0c725 373
6244debe 374 // Set the parameter
375 digitizer->SetDiffusion();
376 digitizer->SetExB();
9e1a0ddb 377 digitizer->SetEvent(gAlice->GetEvNumber());
6244debe 378
379 // Initialization
db30bf0f 380 digitizer->InitDetector();
2ab0c725 381
382 // Create the digits
6244debe 383 digitizer->MakeDigits();
2ab0c725 384
385 // Write the digits into the input file
6244debe 386 if (digitizer->Digits()->MakeBranch(fDigitsFile)) {
387
388 digitizer->WriteDigits();
2ab0c725 389
390 // Save the digitizer class in the AliROOT
6244debe 391 digitizer->Write();
392
2ab0c725 393 }
6244debe 394
395}
396
397//_____________________________________________________________________________
398void AliTRD::SDigits2Digits()
399{
400 //
401 // Create final digits from summable digits
402 //
403
2ab0c725 404}
99d5402e 405
406//_____________________________________________________________________________
9d0b222b 407void AliTRD::AddDigit(Int_t *digits, Int_t *amp)
99d5402e 408{
409 //
410 // Add a digit for the TRD
411 //
412
413 TClonesArray &ldigits = *fDigits;
9d0b222b 414 new(ldigits[fNdigits++]) AliTRDdigit(kFALSE,digits,amp);
99d5402e 415
416}
417
fe4da5cc 418//_____________________________________________________________________________
793ff80c 419void AliTRD::AddHit(Int_t track, Int_t det, Float_t *hits, Int_t q)
fe4da5cc 420{
421 //
422 // Add a hit for the TRD
423 //
82bbf98a 424
fe4da5cc 425 TClonesArray &lhits = *fHits;
793ff80c 426 new(lhits[fNhits++]) AliTRDhit(fIshunt,track,det,hits,q);
82bbf98a 427
fe4da5cc 428}
429
430//_____________________________________________________________________________
431void AliTRD::BuildGeometry()
432{
433 //
434 // Create the ROOT TNode geometry for the TRD
435 //
82bbf98a 436
8230f242 437 TNode *node, *top;
fe4da5cc 438 TPGON *pgon;
793ff80c 439
440 Float_t rmin, rmax;
441 Float_t zmax1, zmax2;
db30bf0f 442
443 Int_t iPlan;
793ff80c 444
fe4da5cc 445 const Int_t kColorTRD = 46;
d3f347ff 446
fe4da5cc 447 // Find the top node alice
8230f242 448 top = gAlice->GetGeometry()->GetNode("alice");
d3f347ff 449
db30bf0f 450 if (fDisplayType == 0) {
793ff80c 451
452 pgon = new TPGON("S_TRD","TRD","void",0,360,AliTRDgeometry::Nsect(),4);
453 rmin = AliTRDgeometry::Rmin();
454 rmax = AliTRDgeometry::Rmax();
455 pgon->DefineSection(0,-AliTRDgeometry::Zmax1(),rmax,rmax);
456 pgon->DefineSection(1,-AliTRDgeometry::Zmax2(),rmin,rmax);
457 pgon->DefineSection(2, AliTRDgeometry::Zmax2(),rmin,rmax);
458 pgon->DefineSection(3, AliTRDgeometry::Zmax1(),rmax,rmax);
459 top->cd();
460 node = new TNode("TRD","TRD","S_TRD",0,0,0,"");
461 node->SetLineColor(kColorTRD);
462 fNodes->Add(node);
463
db30bf0f 464 }
465 else if (fDisplayType == 1) {
793ff80c 466
f73816f5 467 Char_t name[7];
468
793ff80c 469 Float_t slope = (AliTRDgeometry::Zmax1() - AliTRDgeometry::Zmax2())
470 / (AliTRDgeometry::Rmax() - AliTRDgeometry::Rmin());
471
f73816f5 472 rmin = AliTRDgeometry::Rmin() + AliTRDgeometry::Ccframe()/2.
473 + AliTRDgeometry::DrZpos()
474 - AliTRDgeometry::DrThick()/2.;
793ff80c 475 rmax = rmin + AliTRDgeometry::DrThick();
f73816f5 476
477 Float_t thickness = rmin - AliTRDgeometry::Rmin();
478 zmax2 = AliTRDgeometry::Zmax2() + slope * thickness;
793ff80c 479 zmax1 = zmax2 + slope * AliTRDgeometry::DrThick();
793ff80c 480
db30bf0f 481 for (iPlan = 0; iPlan < AliTRDgeometry::Nplan(); iPlan++) {
793ff80c 482
f73816f5 483 sprintf(name,"S_TR1%d",iPlan);
484 pgon = new TPGON(name,"TRD","void",0,360,AliTRDgeometry::Nsect(),4);
485 pgon->DefineSection(0,-zmax1,rmax,rmax);
486 pgon->DefineSection(1,-zmax2,rmin,rmax);
487 pgon->DefineSection(2, zmax2,rmin,rmax);
488 pgon->DefineSection(3, zmax1,rmax,rmax);
489 top->cd();
490 node = new TNode("TRD","TRD",name,0,0,0,"");
491 node->SetLineColor(kColorTRD);
492 fNodes->Add(node);
493
494 Float_t height = AliTRDgeometry::Cheight() + AliTRDgeometry::Cspace();
495 rmin = rmin + height;
496 rmax = rmax + height;
497 zmax1 = zmax1 + slope * height;
498 zmax2 = zmax2 + slope * height;
499
500 }
501
502 thickness += AliTRDgeometry::DrThick();
503 rmin = AliTRDgeometry::Rmin() + thickness;
504 rmax = rmin + AliTRDgeometry::AmThick();
505 zmax2 = AliTRDgeometry::Zmax2() + slope * thickness;
506 zmax1 = zmax2 + slope * AliTRDgeometry::AmThick();
507
db30bf0f 508 for (iPlan = 0; iPlan < AliTRDgeometry::Nplan(); iPlan++) {
f73816f5 509
510 sprintf(name,"S_TR2%d",iPlan);
793ff80c 511 pgon = new TPGON(name,"TRD","void",0,360,AliTRDgeometry::Nsect(),4);
512 pgon->DefineSection(0,-zmax1,rmax,rmax);
513 pgon->DefineSection(1,-zmax2,rmin,rmax);
514 pgon->DefineSection(2, zmax2,rmin,rmax);
515 pgon->DefineSection(3, zmax1,rmax,rmax);
516 top->cd();
517 node = new TNode("TRD","TRD",name,0,0,0,"");
518 node->SetLineColor(kColorTRD);
519 fNodes->Add(node);
520
521 Float_t height = AliTRDgeometry::Cheight() + AliTRDgeometry::Cspace();
522 rmin = rmin + height;
523 rmax = rmax + height;
524 zmax1 = zmax1 + slope * height;
525 zmax2 = zmax2 + slope * height;
526
527 }
528
db30bf0f 529 }
d3f347ff 530
fe4da5cc 531}
532
8230f242 533//_____________________________________________________________________________
dd9a6ee3 534void AliTRD::Copy(TObject &trd)
8230f242 535{
536 //
537 // Copy function
538 //
539
793ff80c 540 ((AliTRD &) trd).fGasMix = fGasMix;
541 ((AliTRD &) trd).fGeometry = fGeometry;
542 ((AliTRD &) trd).fRecPoints = fRecPoints;
543 ((AliTRD &) trd).fNRecPoints = fNRecPoints;
544 ((AliTRD &) trd).fGasDensity = fGasDensity;
545 ((AliTRD &) trd).fFoilDensity = fFoilDensity;
546 ((AliTRD &) trd).fDrawTR = fDrawTR;
547 ((AliTRD &) trd).fDisplayType = fDisplayType;
8230f242 548
549 //AliDetector::Copy(trd);
550
551}
552
fe4da5cc 553//_____________________________________________________________________________
82bbf98a 554void AliTRD::CreateGeometry()
fe4da5cc 555{
82bbf98a 556 //
557 // Creates the volumes for the TRD chambers
558 //
82bbf98a 559
560 // Check that FRAME is there otherwise we have no place where to put the TRD
8230f242 561 AliModule* frame = gAlice->GetModule("FRAME");
562 if (!frame) {
851d3db9 563 printf(" The TRD needs the FRAME to be defined first\n");
564 return;
82bbf98a 565 }
d3f347ff 566
851d3db9 567 fGeometry->CreateGeometry(fIdtmed->GetArray() - 1299);
5c7f4665 568
82bbf98a 569}
570
571//_____________________________________________________________________________
572void AliTRD::CreateMaterials()
573{
fe4da5cc 574 //
575 // Create the materials for the TRD
576 // Origin Y.Foka
577 //
578
8230f242 579 Int_t isxfld = gAlice->Field()->Integ();
580 Float_t sxmgmx = gAlice->Field()->Max();
fe4da5cc 581
d3f347ff 582 // For polyethilene (CH2)
583 Float_t ape[2] = { 12., 1. };
584 Float_t zpe[2] = { 6., 1. };
585 Float_t wpe[2] = { 1., 2. };
586 Float_t dpe = 0.95;
587
588 // For mylar (C5H4O2)
589 Float_t amy[3] = { 12., 1., 16. };
590 Float_t zmy[3] = { 6., 1., 8. };
591 Float_t wmy[3] = { 5., 4., 2. };
fe4da5cc 592 Float_t dmy = 1.39;
d3f347ff 593
594 // For CO2
595 Float_t aco[2] = { 12., 16. };
596 Float_t zco[2] = { 6., 8. };
597 Float_t wco[2] = { 1., 2. };
598 Float_t dco = 0.001977;
599
600 // For water
601 Float_t awa[2] = { 1., 16. };
602 Float_t zwa[2] = { 1., 8. };
603 Float_t wwa[2] = { 2., 1. };
604 Float_t dwa = 1.0;
605
606 // For isobutane (C4H10)
607 Float_t ais[2] = { 12., 1. };
608 Float_t zis[2] = { 6., 1. };
609 Float_t wis[2] = { 4., 10. };
610 Float_t dis = 0.00267;
611
db30bf0f 612 // For plexiglas (C5H8O2)
613 Float_t apg[3] = { 12.011 , 1.0 , 15.9994 };
614 Float_t zpg[3] = { 6.0 , 1.0 , 8.0 };
615 Float_t wpg[3] = { 5.0 , 8.0 , 2.0 };
616 Float_t dpg = 1.18;
617
d3f347ff 618 // For Xe/CO2-gas-mixture
db30bf0f 619 // Xe-content of the Xe/CO2-mixture (85% / 15%)
620 Float_t fxc = .85;
d3f347ff 621 // Xe-content of the Xe/Isobutane-mixture (97% / 3%)
622 Float_t fxi = .97;
fe4da5cc 623 Float_t dxe = .005858;
624
d3f347ff 625 // General tracking parameter
fe4da5cc 626 Float_t tmaxfd = -10.;
627 Float_t stemax = -1e10;
d3f347ff 628 Float_t deemax = -0.1;
629 Float_t epsil = 1e-4;
630 Float_t stmin = -0.001;
fe4da5cc 631
632 Float_t absl, radl, d, buf[1];
793ff80c 633 Float_t agm[2], zgm[2], wgm[2];
634 Float_t dgm1, dgm2;
d3f347ff 635 Int_t nbuf;
fe4da5cc 636
d3f347ff 637 //////////////////////////////////////////////////////////////////////////
fe4da5cc 638 // Define Materials
d3f347ff 639 //////////////////////////////////////////////////////////////////////////
640
db30bf0f 641 AliMaterial( 1, "Al ", 26.98, 13.0, 2.7 , 8.9 , 37.2);
642 AliMaterial( 2, "Air", 14.61, 7.3, 0.001205, 30420.0 , 67500.0);
643 AliMaterial( 4, "Xe ", 131.29, 54.0, dxe , 1447.59, 0.0);
644 AliMaterial( 5, "Cu ", 63.54, 29.0, 8.96 , 1.43, 14.8);
645 AliMaterial( 6, "C ", 12.01, 6.0, 2.265 , 18.8 , 74.4);
646 AliMaterial(12, "G10", 20.00, 10.0, 1.7 , 19.4 , 999.0);
d3f347ff 647
648 // Mixtures
db30bf0f 649 AliMixture(3, "Polyethilene", ape, zpe, dpe, -2, wpe);
650 AliMixture(7, "Mylar", amy, zmy, dmy, -3, wmy);
651 AliMixture(8, "CO2", aco, zco, dco, -2, wco);
652 AliMixture(9, "Isobutane", ais, zis, dis, -2, wis);
653 AliMixture(13,"Water", awa, zwa, dwa, -2, wwa);
654 AliMixture(14,"Plexiglas", apg, zpg, dpg, -3, wpg);
d3f347ff 655
656 // Gas mixtures
82bbf98a 657 Char_t namate[21];
d3f347ff 658 // Xe/CO2-mixture
659 // Get properties of Xe
cfce8870 660 gMC->Gfmate((*fIdmate)[4], namate, agm[0], zgm[0], d, radl, absl, buf, nbuf);
d3f347ff 661 // Get properties of CO2
cfce8870 662 gMC->Gfmate((*fIdmate)[8], namate, agm[1], zgm[1], d, radl, absl, buf, nbuf);
d3f347ff 663 // Create gas mixture
664 wgm[0] = fxc;
665 wgm[1] = 1. - fxc;
793ff80c 666 dgm1 = wgm[0] * dxe + wgm[1] * dco;
db30bf0f 667 AliMixture(10, "Gas mixture 1", agm, zgm, dgm1, 2, wgm);
d3f347ff 668 // Xe/Isobutane-mixture
669 // Get properties of Xe
cfce8870 670 gMC->Gfmate((*fIdmate)[4], namate, agm[0], zgm[0], d, radl, absl, buf, nbuf);
d3f347ff 671 // Get properties of Isobutane
cfce8870 672 gMC->Gfmate((*fIdmate)[9], namate, agm[1], zgm[1], d, radl, absl, buf, nbuf);
d3f347ff 673 // Create gas mixture
674 wgm[0] = fxi;
675 wgm[1] = 1. - fxi;
793ff80c 676 dgm2 = wgm[0] * dxe + wgm[1] * dis;
db30bf0f 677 AliMixture(11, "Gas mixture 2", agm, zgm, dgm2, 2, wgm);
d3f347ff 678
679 //////////////////////////////////////////////////////////////////////////
fe4da5cc 680 // Tracking Media Parameters
d3f347ff 681 //////////////////////////////////////////////////////////////////////////
682
683 // Al Frame
db30bf0f 684 AliMedium(1, "Al Frame", 1, 0, isxfld, sxmgmx
d3f347ff 685 , tmaxfd, stemax, deemax, epsil, stmin);
686 // Air
db30bf0f 687 AliMedium(2, "Air", 2, 0, isxfld, sxmgmx
d3f347ff 688 , tmaxfd, stemax, deemax, epsil, stmin);
689 // Polyethilene
db30bf0f 690 AliMedium(3, "Radiator", 3, 0, isxfld, sxmgmx
d3f347ff 691 , tmaxfd, stemax, deemax, epsil, stmin);
692 // Xe
db30bf0f 693 AliMedium(4, "Xe", 4, 1, isxfld, sxmgmx
d3f347ff 694 , tmaxfd, stemax, deemax, epsil, stmin);
695 // Cu pads
db30bf0f 696 AliMedium(5, "Padplane", 5, 1, isxfld, sxmgmx
d3f347ff 697 , tmaxfd, stemax, deemax, epsil, stmin);
698 // Fee + cables
db30bf0f 699 AliMedium(6, "Readout", 1, 0, isxfld, sxmgmx
d3f347ff 700 , tmaxfd, stemax, deemax, epsil, stmin);
701 // C frame
db30bf0f 702 AliMedium(7, "C Frame", 6, 0, isxfld, sxmgmx
d3f347ff 703 , tmaxfd, stemax, deemax, epsil, stmin);
704 // Mylar foils
db30bf0f 705 AliMedium(8, "Mylar", 7, 0, isxfld, sxmgmx
d3f347ff 706 , tmaxfd, stemax, deemax, epsil, stmin);
707 if (fGasMix == 1) {
708 // Gas-mixture (Xe/CO2)
db30bf0f 709 AliMedium(9, "Gas-mix", 10, 1, isxfld, sxmgmx
d3f347ff 710 , tmaxfd, stemax, deemax, epsil, stmin);
711 }
712 else {
713 // Gas-mixture (Xe/Isobutane)
db30bf0f 714 AliMedium(9, "Gas-mix", 11, 1, isxfld, sxmgmx
d3f347ff 715 , tmaxfd, stemax, deemax, epsil, stmin);
716 }
717 // Nomex-honeycomb (use carbon for the time being)
db30bf0f 718 AliMedium(10, "Nomex", 6, 0, isxfld, sxmgmx
d3f347ff 719 , tmaxfd, stemax, deemax, epsil, stmin);
720 // Kapton foils (use Mylar for the time being)
db30bf0f 721 AliMedium(11, "Kapton", 7, 0, isxfld, sxmgmx
d3f347ff 722 , tmaxfd, stemax, deemax, epsil, stmin);
723 // Gas-filling of the radiator
db30bf0f 724 AliMedium(12, "CO2", 8, 0, isxfld, sxmgmx
d3f347ff 725 , tmaxfd, stemax, deemax, epsil, stmin);
726 // G10-plates
db30bf0f 727 AliMedium(13, "G10-plates",12, 0, isxfld, sxmgmx
d3f347ff 728 , tmaxfd, stemax, deemax, epsil, stmin);
729 // Cooling water
db30bf0f 730 AliMedium(14, "Water", 13, 0, isxfld, sxmgmx
731 , tmaxfd, stemax, deemax, epsil, stmin);
732 // Rohacell (plexiglas) for the radiator
733 AliMedium(15, "Rohacell", 14, 0, isxfld, sxmgmx
d3f347ff 734 , tmaxfd, stemax, deemax, epsil, stmin);
735
793ff80c 736 // Save the density values for the TRD absorbtion
737 fFoilDensity = dmy;
738 if (fGasMix == 1)
739 fGasDensity = dgm1;
740 else
741 fGasDensity = dgm2;
742
fe4da5cc 743}
744
82bbf98a 745//_____________________________________________________________________________
746void AliTRD::DrawModule()
747{
748 //
749 // Draw a shaded view of the Transition Radiation Detector version 0
750 //
751
752 // Set everything unseen
753 gMC->Gsatt("*" ,"SEEN",-1);
754
755 // Set ALIC mother transparent
756 gMC->Gsatt("ALIC","SEEN", 0);
757
758 // Set the volumes visible
851d3db9 759 if (fGeometry->IsVersion() == 0) {
5c7f4665 760 gMC->Gsatt("B071","SEEN", 0);
761 gMC->Gsatt("B074","SEEN", 0);
762 gMC->Gsatt("B075","SEEN", 0);
763 gMC->Gsatt("B077","SEEN", 0);
764 gMC->Gsatt("BTR1","SEEN", 0);
765 gMC->Gsatt("BTR2","SEEN", 0);
766 gMC->Gsatt("BTR3","SEEN", 0);
767 gMC->Gsatt("TRD1","SEEN", 0);
768 gMC->Gsatt("TRD2","SEEN", 0);
769 gMC->Gsatt("TRD3","SEEN", 0);
770 }
771 else {
772 gMC->Gsatt("B071","SEEN", 0);
773 gMC->Gsatt("B074","SEEN", 0);
774 gMC->Gsatt("B075","SEEN", 0);
775 gMC->Gsatt("B077","SEEN", 0);
776 gMC->Gsatt("BTR1","SEEN", 0);
777 gMC->Gsatt("BTR2","SEEN", 0);
778 gMC->Gsatt("BTR3","SEEN", 0);
779 gMC->Gsatt("TRD1","SEEN", 0);
6f1e466d 780 if (fGeometry->GetPHOShole())
781 gMC->Gsatt("TRD2","SEEN", 0);
782 if (fGeometry->GetRICHhole())
783 gMC->Gsatt("TRD3","SEEN", 0);
5c7f4665 784 }
82bbf98a 785 gMC->Gsatt("UCII","SEEN", 0);
786 gMC->Gsatt("UCIM","SEEN", 0);
787 gMC->Gsatt("UCIO","SEEN", 0);
788 gMC->Gsatt("UL02","SEEN", 1);
789 gMC->Gsatt("UL05","SEEN", 1);
790 gMC->Gsatt("UL06","SEEN", 1);
791
792 gMC->Gdopt("hide", "on");
793 gMC->Gdopt("shad", "on");
794 gMC->Gsatt("*", "fill", 7);
795 gMC->SetClipBox(".");
796 gMC->SetClipBox("*", 0, 2000, -2000, 2000, -2000, 2000);
797 gMC->DefaultRange();
798 gMC->Gdraw("alic", 40, 30, 0, 12, 9.4, .021, .021);
799 gMC->Gdhead(1111, "Transition Radiation Detector");
800 gMC->Gdman(18, 4, "MAN");
801
802}
803
fe4da5cc 804//_____________________________________________________________________________
805Int_t AliTRD::DistancetoPrimitive(Int_t , Int_t )
806{
807 //
808 // Distance between the mouse and the TRD detector on the screen
809 // Dummy routine
82bbf98a 810
811 return 9999;
812
fe4da5cc 813}
814
815//_____________________________________________________________________________
816void AliTRD::Init()
817{
818 //
851d3db9 819 // Initialize the TRD detector after the geometry has been created
fe4da5cc 820 //
82bbf98a 821
5c7f4665 822 Int_t i;
851d3db9 823
9e1a0ddb 824 if(fDebug) {
825 printf("\n%s: ",ClassName());
826 for (i = 0; i < 35; i++) printf("*");
827 printf(" TRD_INIT ");
828 for (i = 0; i < 35; i++) printf("*");
829 printf("\n");
830 }
5c7f4665 831
851d3db9 832 if (fGeometry->IsVersion() == 0) {
9e1a0ddb 833 printf("%s: Geometry for spaceframe with holes initialized\n",ClassName());
851d3db9 834 }
835 else if (fGeometry->IsVersion() == 1) {
9e1a0ddb 836 printf("%s: Geometry for spaceframe without holes initialized\n",ClassName());
6f1e466d 837 if (fGeometry->GetPHOShole())
9e1a0ddb 838 printf("%s: Leave space in front of PHOS free\n",ClassName());
6f1e466d 839 if (fGeometry->GetRICHhole())
9e1a0ddb 840 printf("%s: Leave space in front of RICH free\n",ClassName());
5c7f4665 841 }
9e1a0ddb 842
851d3db9 843 if (fGasMix == 1)
db30bf0f 844 printf("%s: Gas Mixture: 85%% Xe + 15%% CO2\n",ClassName());
851d3db9 845 else
9e1a0ddb 846 printf("%s: Gas Mixture: 97%% Xe + 3%% Isobutane\n",ClassName());
5c7f4665 847
848}
849
793ff80c 850//_____________________________________________________________________________
851void AliTRD::LoadPoints(Int_t track)
852{
853 //
854 // Store x, y, z of all hits in memory.
855 // Hit originating from TR photons are given a different color
856 //
857
858 if (!fDrawTR) {
859 AliDetector::LoadPoints(track);
860 return;
861 }
862
863 if (fHits == 0) return;
864
865 Int_t nhits = fHits->GetEntriesFast();
866 if (nhits == 0) return;
867
868 Int_t tracks = gAlice->GetNtrack();
869 if (fPoints == 0) fPoints = new TObjArray(tracks);
870
871 AliTRDhit *ahit;
872
873 Int_t *ntrkE = new Int_t[tracks];
874 Int_t *ntrkT = new Int_t[tracks];
875 Int_t *limiE = new Int_t[tracks];
876 Int_t *limiT = new Int_t[tracks];
877 Float_t **coorE = new Float_t*[tracks];
878 Float_t **coorT = new Float_t*[tracks];
879 for(Int_t i = 0; i < tracks; i++) {
880 ntrkE[i] = 0;
881 ntrkT[i] = 0;
882 coorE[i] = 0;
883 coorT[i] = 0;
884 limiE[i] = 0;
885 limiT[i] = 0;
886 }
887
888 AliTRDpoints *points = 0;
889 Float_t *fp = 0;
890 Int_t trk;
891 Int_t chunk = nhits / 4 + 1;
892
893 // Loop over all the hits and store their position
894 for (Int_t hit = 0; hit < nhits; hit++) {
895
896 ahit = (AliTRDhit *) fHits->UncheckedAt(hit);
897
898 // dEdx hits
f73816f5 899 if (ahit->FromDrift() || ahit->FromAmplification()) {
793ff80c 900
901 trk = ahit->GetTrack();
902 if (ntrkE[trk] == limiE[trk]) {
903 // Initialise a new track
904 fp = new Float_t[3*(limiE[trk]+chunk)];
905 if (coorE[trk]) {
906 memcpy(fp,coorE[trk],sizeof(Float_t)*3*limiE[trk]);
907 delete [] coorE[trk];
908 }
909 limiE[trk] += chunk;
910 coorE[trk] = fp;
911 }
912 else {
913 fp = coorE[trk];
914 }
915 fp[3*ntrkE[trk] ] = ahit->X();
916 fp[3*ntrkE[trk]+1] = ahit->Y();
917 fp[3*ntrkE[trk]+2] = ahit->Z();
918 ntrkE[trk]++;
919
920 }
921 // TR photon hits
f73816f5 922 else if (ahit->FromTRphoton()) {
793ff80c 923
924 trk = ahit->GetTrack();
925 if (ntrkT[trk] == limiT[trk]) {
926 // Initialise a new track
927 fp = new Float_t[3*(limiT[trk]+chunk)];
928 if (coorT[trk]) {
929 memcpy(fp,coorT[trk],sizeof(Float_t)*3*limiT[trk]);
930 delete [] coorT[trk];
931 }
932 limiT[trk] += chunk;
933 coorT[trk] = fp;
934 }
935 else {
936 fp = coorT[trk];
937 }
938 fp[3*ntrkT[trk] ] = ahit->X();
939 fp[3*ntrkT[trk]+1] = ahit->Y();
940 fp[3*ntrkT[trk]+2] = ahit->Z();
941 ntrkT[trk]++;
942
943 }
944
945 }
946
947 for (trk = 0; trk < tracks; ++trk) {
948
949 if (ntrkE[trk] || ntrkT[trk]) {
950
951 points = new AliTRDpoints();
952 points->SetDetector(this);
953 points->SetParticle(trk);
954
955 // Set the dEdx points
956 if (ntrkE[trk]) {
957 points->SetMarkerColor(GetMarkerColor());
958 points->SetMarkerSize(GetMarkerSize());
959 points->SetPolyMarker(ntrkE[trk],coorE[trk],GetMarkerStyle());
960 delete [] coorE[trk];
961 coorE[trk] = 0;
962 }
963
964 // Set the TR photon points
965 if (ntrkT[trk]) {
966 points->SetTRpoints(ntrkT[trk],coorT[trk]);
967 delete [] coorT[trk];
968 coorT[trk] = 0;
969 }
970
971 fPoints->AddAt(points,trk);
972
973 }
974
975 }
976
977 delete [] coorE;
978 delete [] coorT;
979 delete [] ntrkE;
980 delete [] ntrkT;
981 delete [] limiE;
982 delete [] limiT;
983
984}
985
5c7f4665 986//_____________________________________________________________________________
9e1a0ddb 987void AliTRD::MakeBranch(Option_t* option, const char *file)
5c7f4665 988{
989 //
990 // Create Tree branches for the TRD digits and cluster.
991 //
992
793ff80c 993 //Int_t buffersize = 4000;
994 //Char_t branchname[15];
5c7f4665 995
2ab0c725 996 AliDetector::MakeBranch(option,file);
5c7f4665 997
6244debe 998 Int_t buffersize = 64000;
999
1000 fDigitsArray = new AliTRDdataArrayI();
9e1a0ddb 1001 MakeBranchInTree(gAlice->TreeD()
1002 ,"TRDdigits", fDigitsArray->IsA()->GetName()
40c7ef21 1003 ,&fDigitsArray,buffersize,99,file);
6244debe 1004
1005 for (Int_t iDict = 0; iDict < AliTRDdigitsManager::NDict(); iDict++) {
1006 Char_t branchname[15];
1007 sprintf(branchname,"TRDdictionary%d",iDict);
1008 fDictionaryArray[iDict] = new AliTRDdataArrayI();
9e1a0ddb 1009 MakeBranchInTree(gAlice->TreeD()
1010 ,branchname,fDictionaryArray[iDict]->IsA()->GetName()
40c7ef21 1011 ,&fDictionaryArray[iDict],buffersize,99,file);
6244debe 1012 }
851d3db9 1013}
1014
6244debe 1015//_____________________________________________________________________________
1016void AliTRD::ResetDigits()
1017{
1018 //
1019 // Resets the digits
1020 //
1021
1022 if (gAlice->TreeD()) {
1023 TBranch *branch;
1024 branch = gAlice->TreeD()->GetBranch("TRDdigits");
1025 if (branch) {
1026 branch->Reset();
1027 for (Int_t iDict = 0; iDict < AliTRDdigitsManager::NDict(); iDict++) {
1028 Char_t branchname[15];
1029 sprintf(branchname,"TRDdictionary%d",iDict);
1030 branch = gAlice->TreeD()->GetBranch(branchname);
1031 branch->Reset();
1032 }
1033 }
1034 }
1035
1036}
1037
851d3db9 1038//_____________________________________________________________________________
1039void AliTRD::ResetRecPoints()
1040{
1041 //
1042 // Reset number of reconstructed points and the point array
1043 //
1044
f73816f5 1045 if (fRecPoints) {
793ff80c 1046 fNRecPoints = 0;
1047 Int_t nentr = fRecPoints->GetEntriesFast();
f73816f5 1048 for (Int_t i = 0; i < nentr; i++) delete fRecPoints->RemoveAt(i);
793ff80c 1049 }
5c7f4665 1050
1051}
1052
1053//_____________________________________________________________________________
1054void AliTRD::SetTreeAddress()
1055{
1056 //
1057 // Set the branch addresses for the trees.
1058 //
1059
1060 Char_t branchname[15];
1061
1062 AliDetector::SetTreeAddress();
1063
1064 TBranch *branch;
851d3db9 1065 TTree *treeR = gAlice->TreeR();
1066
1067 if (treeR) {
f73816f5 1068 sprintf(branchname,"%scluster",GetName());
851d3db9 1069 if (fRecPoints) {
1070 branch = treeR->GetBranch(branchname);
1071 if (branch) {
1072 branch->SetAddress(&fRecPoints);
1073 }
5c7f4665 1074 }
1075 }
1076
fe4da5cc 1077}
1078
d3f347ff 1079//_____________________________________________________________________________
b060c36f 1080void AliTRD::SetGasMix(Int_t imix)
d3f347ff 1081{
82bbf98a 1082 //
1083 // Defines the gas mixture (imix=0: Xe/Isobutane imix=1: Xe/CO2)
1084 //
1085
d3f347ff 1086 if ((imix < 0) || (imix > 1)) {
1087 printf("Wrong input value: %d\n",imix);
1088 printf("Use standard setting\n");
6244debe 1089 fGasMix = 1;
d3f347ff 1090 return;
1091 }
1092
1093 fGasMix = imix;
1094
1095}
1096
793ff80c 1097//_____________________________________________________________________________
1098void AliTRD::SetPHOShole()
1099{
1100 //
1101 // Selects a geometry with a hole in front of the PHOS
1102 //
1103
1104 fGeometry->SetPHOShole();
1105
1106}
1107
1108//_____________________________________________________________________________
1109void AliTRD::SetRICHhole()
1110{
1111 //
1112 // Selects a geometry with a hole in front of the RICH
1113 //
1114
1115 fGeometry->SetRICHhole();
1116
1117}
1118
dd9a6ee3 1119//_____________________________________________________________________________
1120AliTRD &AliTRD::operator=(const AliTRD &trd)
1121{
1122 //
1123 // Assignment operator
1124 //
1125
1126 if (this != &trd) ((AliTRD &) trd).Copy(*this);
1127 return *this;
1128
f73816f5 1129}