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