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