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