]> git.uio.no Git - u/mrichter/AliRoot.git/blob - TRD/AliTRD.cxx
Make code compliant to coding conventions
[u/mrichter/AliRoot.git] / TRD / AliTRD.cxx
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$
18 Revision 1.19  2000/06/07 16:25:37  cblume
19 Try to remove compiler warnings on Sun and HP
20
21 Revision 1.18  2000/05/08 16:17:27  cblume
22 Merge TRD-develop
23
24 Revision 1.17.2.1  2000/05/08 14:28:59  cblume
25 Introduced SetPHOShole() and SetRICHhole(). AliTRDrecPoint container is now a TObjArray
26
27 Revision 1.17  2000/02/28 19:10:26  cblume
28 Include the new TRD classes
29
30 Revision 1.16.2.2  2000/02/28 17:53:24  cblume
31 Introduce TRD geometry classes
32
33 Revision 1.16.2.1  2000/02/28 17:04:19  cblume
34 Include functions and data members for AliTRDrecPoint
35
36 Revision 1.16  2000/01/19 17:17:35  fca
37 Introducing a list of lists of hits -- more hits allowed for detector now
38
39 Revision 1.15  1999/11/02 17:04:25  fca
40 Small syntax change for HP compiler
41
42 Revision 1.14  1999/11/02 16:57:02  fca
43 Avoid non ansi warnings on HP compilers
44
45 Revision 1.13  1999/11/02 16:35:56  fca
46 New version of TRD introduced
47
48 Revision 1.12  1999/11/01 20:41:51  fca
49 Added protections against using the wrong version of FRAME
50
51 Revision 1.11  1999/09/29 09:24:34  fca
52 Introduction of the Copyright and cvs Log
53
54 */
55
56 ///////////////////////////////////////////////////////////////////////////////
57 //                                                                           //
58 //  Transition Radiation Detector                                            //
59 //  This class contains the basic functions for the Transition Radiation     //
60 //  Detector.                                                                //
61 //                                                                           //
62 ///////////////////////////////////////////////////////////////////////////////
63
64 #include <stdlib.h>
65
66 #include <TMath.h>
67 #include <TNode.h>
68 #include <TPGON.h> 
69
70 #include "AliTRD.h"
71 #include "AliRun.h"
72 #include "AliConst.h"
73 #include "AliTRDdigitizer.h"
74 #include "AliTRDclusterizer.h"
75 #include "AliTRDgeometryHole.h"
76 #include "AliTRDgeometryFull.h"
77 #include "AliTRDrecPoint.h"
78  
79 ClassImp(AliTRD)
80  
81 //_____________________________________________________________________________
82 AliTRD::AliTRD()
83 {
84   //
85   // Default constructor
86   //
87
88   fIshunt      = 0;
89   fGasMix      = 0;
90   fHits        = 0;
91   fDigits      = 0;
92
93   fRecPoints   = 0;
94   fNRecPoints  = 0;
95
96   fGeometry    = 0;
97
98 }
99  
100 //_____________________________________________________________________________
101 AliTRD::AliTRD(const char *name, const char *title)
102        : AliDetector(name,title)
103 {
104   //
105   // Standard constructor for the TRD
106   //
107
108   // Check that FRAME is there otherwise we have no place where to
109   // put TRD
110   AliModule* frame = gAlice->GetModule("FRAME");
111   if (!frame) {
112     Error("Ctor","TRD needs FRAME to be present\n");
113     exit(1);
114   } 
115
116   // Define the TRD geometry according to the FRAME geometry
117   if      (frame->IsVersion() == 0) {
118     // Geometry with hole
119     fGeometry = new AliTRDgeometryHole();
120   }
121   else if (frame->IsVersion() == 1) {
122     // Geometry without hole
123     fGeometry = new AliTRDgeometryFull();
124   }
125   else {
126     Error("Ctor","Could not find valid FRAME version\n");
127     exit(1);
128   }
129
130   // Allocate the hit array
131   fHits       = new TClonesArray("AliTRDhit"     ,405);
132   gAlice->AddHitList(fHits);
133
134   // Allocate the digits array
135   fDigits     = 0;
136
137   // Allocate the rec point array
138   fRecPoints  = new TObjArray(400);
139   fNRecPoints = 0;
140    
141   fIshunt = 0;
142   fGasMix = 0;
143
144   SetMarkerColor(kWhite);   
145
146 }
147
148 //_____________________________________________________________________________
149 AliTRD::AliTRD(AliTRD &trd)
150 {
151   //
152   // Copy constructor
153   //
154
155   trd.Copy(*this);
156
157 }
158
159 //_____________________________________________________________________________
160 AliTRD::~AliTRD()
161 {
162   //
163   // TRD destructor
164   //
165
166   fIshunt = 0;
167
168   delete fGeometry;
169   delete fHits;
170   delete fRecPoints;
171
172 }
173
174 //_____________________________________________________________________________
175 void AliTRD::AddRecPoint(Float_t *pos, Int_t *digits, Int_t det, Float_t amp)
176 {
177   //
178   // Add a reconstructed point for the TRD
179   //
180   
181   AliTRDrecPoint *recPoint = new AliTRDrecPoint();
182   TVector3        posVec(pos[0],pos[1],pos[2]);
183   recPoint->SetLocalPosition(posVec);
184   recPoint->SetDetector(det);
185   recPoint->SetEnergy(amp);
186   for (Int_t iDigit = 0; iDigit < 3; iDigit++) {
187     recPoint->AddDigit(digits[iDigit]);
188   }
189
190   fRecPoints->Add(recPoint);
191
192 }
193
194 //_____________________________________________________________________________
195 void AliTRD::AddDigit(Int_t *digits, Int_t *amp)
196 {
197   //
198   // Add a digit for the TRD
199   //
200
201   TClonesArray &ldigits = *fDigits;
202   new(ldigits[fNdigits++]) AliTRDdigit(kFALSE,digits,amp);
203
204 }
205
206 //_____________________________________________________________________________
207 void AliTRD::AddHit(Int_t track, Int_t *det, Float_t *hits)
208 {
209   //
210   // Add a hit for the TRD
211   //
212
213   TClonesArray &lhits = *fHits;
214   new(lhits[fNhits++]) AliTRDhit(fIshunt,track,det,hits);
215
216 }
217
218 //_____________________________________________________________________________
219 void AliTRD::BuildGeometry()
220 {
221   //
222   // Create the ROOT TNode geometry for the TRD
223   //
224
225   TNode *node, *top;
226   TPGON *pgon;
227   const Int_t kColorTRD = 46;
228   
229   // Find the top node alice
230   top = gAlice->GetGeometry()->GetNode("alice");
231   
232   pgon = new TPGON("S_TRD","TRD","void",0,360,kNsect,4);
233   Float_t ff    = TMath::Cos(kDegrad * 180 / kNsect);
234   Float_t rrmin = kRmin / ff;
235   Float_t rrmax = kRmax / ff;
236   pgon->DefineSection(0,-kZmax1,rrmax,rrmax);
237   pgon->DefineSection(1,-kZmax2,rrmin,rrmax);
238   pgon->DefineSection(2, kZmax2,rrmin,rrmax);
239   pgon->DefineSection(3, kZmax1,rrmax,rrmax);
240   top->cd();
241   node = new TNode("TRD","TRD","S_TRD",0,0,0,"");
242   node->SetLineColor(kColorTRD);
243   fNodes->Add(node);
244
245 }
246  
247 //_____________________________________________________________________________
248 void AliTRD::Copy(AliTRD &trd)
249 {
250   //
251   // Copy function
252   //
253
254   trd.fGasMix     = fGasMix;
255   trd.fGeometry   = fGeometry;
256   trd.fRecPoints  = fRecPoints;
257   trd.fNRecPoints = fNRecPoints;
258
259   //AliDetector::Copy(trd);
260
261 }
262
263 //_____________________________________________________________________________
264 void AliTRD::CreateGeometry()
265 {
266   //
267   // Creates the volumes for the TRD chambers
268   //
269
270   // Check that FRAME is there otherwise we have no place where to put the TRD
271   AliModule* frame = gAlice->GetModule("FRAME");
272   if (!frame) {
273     printf(" The TRD needs the FRAME to be defined first\n");
274     return;
275   }
276
277   fGeometry->CreateGeometry(fIdtmed->GetArray() - 1299);
278
279 }
280  
281 //_____________________________________________________________________________
282 void AliTRD::CreateMaterials()
283 {
284   //
285   // Create the materials for the TRD
286   // Origin Y.Foka
287   //
288
289   Int_t   isxfld = gAlice->Field()->Integ();
290   Float_t sxmgmx = gAlice->Field()->Max();
291   
292   // For polyethilene (CH2) 
293   Float_t ape[2] = { 12., 1. };
294   Float_t zpe[2] = {  6., 1. };
295   Float_t wpe[2] = {  1., 2. };
296   Float_t dpe    = 0.95;
297
298   // For mylar (C5H4O2) 
299   Float_t amy[3] = { 12., 1., 16. };
300   Float_t zmy[3] = {  6., 1.,  8. };
301   Float_t wmy[3] = {  5., 4.,  2. };
302   Float_t dmy    = 1.39;
303
304   // For CO2 
305   Float_t aco[2] = { 12., 16. };
306   Float_t zco[2] = {  6.,  8. };
307   Float_t wco[2] = {  1.,  2. };
308   Float_t dco    = 0.001977;
309
310   // For water
311   Float_t awa[2] = {  1., 16. };
312   Float_t zwa[2] = {  1.,  8. };
313   Float_t wwa[2] = {  2.,  1. };
314   Float_t dwa    = 1.0;
315
316   // For isobutane (C4H10)
317   Float_t ais[2] = { 12.,  1. };
318   Float_t zis[2] = {  6.,  1. };
319   Float_t wis[2] = {  4., 10. };
320   Float_t dis    = 0.00267;
321
322   // For Xe/CO2-gas-mixture 
323   // Xe-content of the Xe/CO2-mixture (90% / 10%) 
324   Float_t fxc    = .90;
325   // Xe-content of the Xe/Isobutane-mixture (97% / 3%) 
326   Float_t fxi    = .97;
327   Float_t dxe    = .005858;
328   
329   // General tracking parameter
330   Float_t tmaxfd = -10.;
331   Float_t stemax = -1e10;
332   Float_t deemax = -0.1;
333   Float_t epsil  =  1e-4;
334   Float_t stmin  = -0.001;
335   
336   Float_t absl, radl, d, buf[1];
337   Float_t agm[2], dgm, zgm[2], wgm[2];
338   Int_t   nbuf;
339   
340   //////////////////////////////////////////////////////////////////////////
341   //     Define Materials 
342   //////////////////////////////////////////////////////////////////////////
343
344   AliMaterial( 1, "Al $",  26.98, 13.0, 2.7     ,     8.9 ,    37.2);
345   AliMaterial( 2, "Air$",  14.61,  7.3, 0.001205, 30420.0 , 67500.0);
346   AliMaterial( 4, "Xe $", 131.29, 54.0, dxe     ,  1447.59,     0.0);
347   AliMaterial( 5, "Cu $",  63.54, 29.0, 8.96    ,     1.43,    14.8);
348   AliMaterial( 6, "C  $",  12.01,  6.0, 2.265   ,    18.8 ,    74.4);
349   AliMaterial(12, "G10$",  20.00, 10.0, 1.7     ,    19.4 ,   999.0);
350
351   // Mixtures 
352   AliMixture(3, "Polyethilene$",   ape, zpe, dpe, -2, wpe);
353   AliMixture(7, "Mylar$",          amy, zmy, dmy, -3, wmy);
354   AliMixture(8, "CO2$",            aco, zco, dco, -2, wco);
355   AliMixture(9, "Isobutane$",      ais, zis, dis, -2, wis);
356   AliMixture(13,"Water$",          awa, zwa, dwa, -2, wwa);
357
358   // Gas mixtures
359   Char_t namate[21];
360   // Xe/CO2-mixture
361   // Get properties of Xe 
362   gMC->Gfmate((*fIdmate)[4], namate, agm[0], zgm[0], d, radl, absl, buf, nbuf);
363   // Get properties of CO2 
364   gMC->Gfmate((*fIdmate)[8], namate, agm[1], zgm[1], d, radl, absl, buf, nbuf);
365   // Create gas mixture 
366   wgm[0] = fxc;
367   wgm[1] = 1. - fxc;
368   dgm    = wgm[0] * dxe + wgm[1] * dco;
369   AliMixture(10, "Gas mixture 1$", agm, zgm, dgm,  2, wgm);
370   // Xe/Isobutane-mixture
371   // Get properties of Xe 
372   gMC->Gfmate((*fIdmate)[4], namate, agm[0], zgm[0], d, radl, absl, buf, nbuf);
373   // Get properties of Isobutane
374   gMC->Gfmate((*fIdmate)[9], namate, agm[1], zgm[1], d, radl, absl, buf, nbuf);
375   // Create gas mixture 
376   wgm[0] = fxi;
377   wgm[1] = 1. - fxi;
378   dgm    = wgm[0] * dxe + wgm[1] * dis;
379   AliMixture(11, "Gas mixture 2$", agm, zgm, dgm,  2, wgm);
380  
381   //////////////////////////////////////////////////////////////////////////
382   //     Tracking Media Parameters 
383   //////////////////////////////////////////////////////////////////////////
384
385   // Al Frame 
386   AliMedium(1, "Al Frame$",   1, 0, isxfld, sxmgmx
387                 , tmaxfd, stemax, deemax, epsil, stmin);
388   // Air 
389   AliMedium(2, "Air$",        2, 0, isxfld, sxmgmx
390                 , tmaxfd, stemax, deemax, epsil, stmin);
391   // Polyethilene 
392   AliMedium(3, "Radiator$",   3, 0, isxfld, sxmgmx
393                 , tmaxfd, stemax, deemax, epsil, stmin);
394   // Xe 
395   AliMedium(4, "Xe$",         4, 1, isxfld, sxmgmx
396                 , tmaxfd, stemax, deemax, epsil, stmin);
397   // Cu pads 
398   AliMedium(5, "Padplane$",   5, 1, isxfld, sxmgmx
399                 , tmaxfd, stemax, deemax, epsil, stmin);
400   // Fee + cables 
401   AliMedium(6, "Readout$",    1, 0, isxfld, sxmgmx
402                 , tmaxfd, stemax, deemax, epsil, stmin);
403   // C frame 
404   AliMedium(7, "C Frame$",    6, 0, isxfld, sxmgmx
405                 , tmaxfd, stemax, deemax, epsil, stmin);
406   // Mylar foils 
407   AliMedium(8, "Mylar$",      7, 0, isxfld, sxmgmx
408                 , tmaxfd, stemax, deemax, epsil, stmin);
409   if (fGasMix == 1) {
410     // Gas-mixture (Xe/CO2) 
411     AliMedium(9, "Gas-mix$",   10, 1, isxfld, sxmgmx
412                   , tmaxfd, stemax, deemax, epsil, stmin);
413   }
414   else {
415     // Gas-mixture (Xe/Isobutane) 
416     AliMedium(9, "Gas-mix$",   11, 1, isxfld, sxmgmx
417                   , tmaxfd, stemax, deemax, epsil, stmin);
418   }
419   // Nomex-honeycomb (use carbon for the time being) 
420   AliMedium(10, "Nomex$",      6, 0, isxfld, sxmgmx
421                 , tmaxfd, stemax, deemax, epsil, stmin);
422   // Kapton foils (use Mylar for the time being) 
423   AliMedium(11, "Kapton$",     7, 0, isxfld, sxmgmx
424                 , tmaxfd, stemax, deemax, epsil, stmin);
425   // Gas-filling of the radiator 
426   AliMedium(12, "CO2$",        8, 0, isxfld, sxmgmx
427                 , tmaxfd, stemax, deemax, epsil, stmin);
428   // G10-plates
429   AliMedium(13, "G10-plates$",12, 0, isxfld, sxmgmx
430                 , tmaxfd, stemax, deemax, epsil, stmin);
431   // Cooling water
432   AliMedium(14, "Water$",     13, 0, isxfld, sxmgmx
433                 , tmaxfd, stemax, deemax, epsil, stmin);
434
435 }
436
437 //_____________________________________________________________________________
438 void AliTRD::DrawModule()
439 {
440   //
441   // Draw a shaded view of the Transition Radiation Detector version 0
442   //
443
444   // Set everything unseen
445   gMC->Gsatt("*"   ,"SEEN",-1);
446   
447   // Set ALIC mother transparent
448   gMC->Gsatt("ALIC","SEEN", 0);
449   
450   // Set the volumes visible
451   if (fGeometry->IsVersion() == 0) {
452     gMC->Gsatt("B071","SEEN", 0);
453     gMC->Gsatt("B074","SEEN", 0);
454     gMC->Gsatt("B075","SEEN", 0);
455     gMC->Gsatt("B077","SEEN", 0);
456     gMC->Gsatt("BTR1","SEEN", 0);
457     gMC->Gsatt("BTR2","SEEN", 0);
458     gMC->Gsatt("BTR3","SEEN", 0);
459     gMC->Gsatt("TRD1","SEEN", 0);
460     gMC->Gsatt("TRD2","SEEN", 0);
461     gMC->Gsatt("TRD3","SEEN", 0);
462   }
463   else {
464     gMC->Gsatt("B071","SEEN", 0);
465     gMC->Gsatt("B074","SEEN", 0);
466     gMC->Gsatt("B075","SEEN", 0);
467     gMC->Gsatt("B077","SEEN", 0);
468     gMC->Gsatt("BTR1","SEEN", 0);
469     gMC->Gsatt("BTR2","SEEN", 0);
470     gMC->Gsatt("BTR3","SEEN", 0);
471     gMC->Gsatt("TRD1","SEEN", 0);
472     if (fGeometry->GetPHOShole())
473       gMC->Gsatt("TRD2","SEEN", 0);
474     if (fGeometry->GetRICHhole())
475       gMC->Gsatt("TRD3","SEEN", 0);
476   }
477   gMC->Gsatt("UCII","SEEN", 0);
478   gMC->Gsatt("UCIM","SEEN", 0);
479   gMC->Gsatt("UCIO","SEEN", 0);
480   gMC->Gsatt("UL02","SEEN", 1);
481   gMC->Gsatt("UL05","SEEN", 1);
482   gMC->Gsatt("UL06","SEEN", 1);
483   
484   gMC->Gdopt("hide", "on");
485   gMC->Gdopt("shad", "on");
486   gMC->Gsatt("*", "fill", 7);
487   gMC->SetClipBox(".");
488   gMC->SetClipBox("*", 0, 2000, -2000, 2000, -2000, 2000);
489   gMC->DefaultRange();
490   gMC->Gdraw("alic", 40, 30, 0, 12, 9.4, .021, .021);
491   gMC->Gdhead(1111, "Transition Radiation Detector");
492   gMC->Gdman(18, 4, "MAN");
493
494 }
495
496 //_____________________________________________________________________________
497 Int_t AliTRD::DistancetoPrimitive(Int_t , Int_t )
498 {
499   //
500   // Distance between the mouse and the TRD detector on the screen
501   // Dummy routine
502   
503   return 9999;
504
505 }
506  
507 //_____________________________________________________________________________
508 void AliTRD::Init()
509 {
510   //
511   // Initialize the TRD detector after the geometry has been created
512   //
513
514   Int_t i;
515
516   printf("\n");
517   for (i = 0; i < 35; i++) printf("*");
518   printf(" TRD_INIT ");
519   for (i = 0; i < 35; i++) printf("*");
520   printf("\n");
521   printf("\n");
522
523   if      (fGeometry->IsVersion() == 0) {
524     printf("          Geometry for spaceframe with holes initialized.\n\n");
525   }
526   else if (fGeometry->IsVersion() == 1) {
527     printf("          Geometry for spaceframe without holes initialized.\n");
528     if (fGeometry->GetPHOShole())
529       printf("          Leave space in front of PHOS free.\n");
530     if (fGeometry->GetRICHhole())
531       printf("          Leave space in front of RICH free.\n");
532     printf("\n");
533   }
534
535   if (fGasMix == 1)
536     printf("          Gas Mixture: 90%% Xe + 10%% CO2\n\n");
537   else
538     printf("          Gas Mixture: 97%% Xe + 3%% Isobutane\n\n");
539
540 }
541
542 //_____________________________________________________________________________
543 void AliTRD::MakeBranch(Option_t* option)
544 {
545   //
546   // Create Tree branches for the TRD digits and cluster.
547   //
548
549   Int_t  buffersize = 4000;
550   Char_t branchname[15];
551
552   AliDetector::MakeBranch(option);
553
554   Char_t *r = strstr(option,"R");
555   sprintf(branchname,"%srecPoints",GetName());
556   if (fRecPoints && gAlice->TreeR() && r) {
557     gAlice->TreeR()->Branch(branchname,fRecPoints->IsA()->GetName()
558                            ,&fRecPoints,buffersize,0);
559     printf("* AliTRD::MakeBranch * Making Branch %s for points in TreeR\n",branchname);
560   }
561
562 }
563
564 //_____________________________________________________________________________
565 void AliTRD::ResetRecPoints()
566 {
567   //
568   // Reset number of reconstructed points and the point array
569   //
570
571   fNRecPoints = 0;
572   if (fRecPoints) fRecPoints->Delete();
573
574 }
575
576 //_____________________________________________________________________________
577 void AliTRD::SetTreeAddress()
578 {
579   //
580   // Set the branch addresses for the trees.
581   //
582
583   Char_t branchname[15];
584
585   AliDetector::SetTreeAddress();
586
587   TBranch *branch;
588   TTree   *treeR = gAlice->TreeR();
589
590   if (treeR) {
591     sprintf(branchname,"%srecPoints",GetName());
592     if (fRecPoints) {
593       branch = treeR->GetBranch(branchname);
594       if (branch) {
595         branch->SetAddress(&fRecPoints);
596       }
597     }
598   }
599
600 }
601
602 //_____________________________________________________________________________
603 void AliTRD::SetGasMix(Int_t imix)
604 {
605   //
606   // Defines the gas mixture (imix=0:  Xe/Isobutane imix=1: Xe/CO2)
607   //
608   
609   if ((imix < 0) || (imix > 1)) {
610     printf("Wrong input value: %d\n",imix);
611     printf("Use standard setting\n");
612     fGasMix = 0;
613     return;
614   }
615
616   fGasMix = imix;
617
618 }
619