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