]> git.uio.no Git - u/mrichter/AliRoot.git/blob - TRD/AliTRDCommonParam.cxx
Remove obsolete macros
[u/mrichter/AliRoot.git] / TRD / AliTRDCommonParam.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 /* $Id$ */
17
18 ///////////////////////////////////////////////////////////////////////////////
19 //                                                                           //
20 // Class containing constant common parameters                           //
21 //                                                                           //
22 // Request an instance with AliTRDCommonParam::Instance()                 //
23 // Then request the needed values                                            //
24 //                                                                           //
25 ///////////////////////////////////////////////////////////////////////////////
26
27 #include "AliRun.h"
28
29 #include "AliTRDCommonParam.h"
30 #include "AliTRDpadPlane.h"
31
32
33 ClassImp(AliTRDCommonParam)
34
35 AliTRDCommonParam* AliTRDCommonParam::fgInstance = 0;
36 Bool_t AliTRDCommonParam::fgTerminated = kFALSE;
37
38 //_ singleton implementation __________________________________________________
39 AliTRDCommonParam* AliTRDCommonParam::Instance()
40 {
41   //
42   // Singleton implementation
43   // Returns an instance of this class, it is created if neccessary
44   // 
45   
46   if (fgTerminated != kFALSE)
47     return 0;
48
49   if (fgInstance == 0)
50     fgInstance = new AliTRDCommonParam();
51   
52   return fgInstance;
53 }
54
55 void AliTRDCommonParam::Terminate()
56 {
57   //
58   // Singleton implementation
59   // Deletes the instance of this class and sets the terminated flag, instances cannot be requested anymore
60   // This function can be called several times.
61   //
62   
63   fgTerminated = kTRUE;
64   
65   if (fgInstance != 0)
66   {
67     delete fgInstance;
68     fgInstance = 0;
69   }
70 }
71
72 //_____________________________________________________________________________
73 AliTRDCommonParam::AliTRDCommonParam()
74 {
75   //
76   // constructor
77   //
78   
79   fField              = 0.0;
80
81   fExBOn              = kFALSE;
82   
83   fPadPlaneArray      = 0;
84   
85   Init();
86 }
87
88 //_____________________________________________________________________________
89 void AliTRDCommonParam::Init()
90 {
91   //
92   // constructor helper
93   //
94   
95   // E x B effects
96   fExBOn          = kTRUE;
97
98   // The magnetic field strength in Tesla
99   Double_t x[3] = { 0.0, 0.0, 0.0 };
100   Double_t b[3];
101   gAlice->Field(x,b);  // b[] is in kilo Gauss
102   fField = b[2] * 0.1; // Tesla
103   
104   // ----------------------------------------------------------------------------
105   // The pad planes
106   // ----------------------------------------------------------------------------
107   
108   fPadPlaneArray = new TObjArray(kNplan * kNcham);
109   
110   for (Int_t iplan = 0; iplan < kNplan; iplan++) {
111     for (Int_t icham = 0; icham < kNcham; icham++) {
112       Int_t ipp = iplan + icham * kNplan;
113       fPadPlaneArray->AddAt(new AliTRDpadPlane(iplan,icham),ipp);
114     }
115   }
116 }
117
118 //_____________________________________________________________________________
119 AliTRDCommonParam::~AliTRDCommonParam() 
120 {
121   //
122   // destructor
123   //
124   
125   if (fPadPlaneArray) {
126     fPadPlaneArray->Delete();
127     delete fPadPlaneArray;
128     fPadPlaneArray = 0;
129   }
130 }
131
132 //_____________________________________________________________________________
133 AliTRDCommonParam::AliTRDCommonParam(const AliTRDCommonParam &p):TObject(p)
134 {
135   //
136   // copy constructor
137   //
138
139   ((AliTRDCommonParam &) p).Copy(*this);
140 }
141
142
143 //_____________________________________________________________________________
144 AliTRDCommonParam &AliTRDCommonParam::operator=(const AliTRDCommonParam &p)
145 {
146   //
147   // Assignment operator
148   //
149
150   if (this != &p) ((AliTRDCommonParam &) p).Copy(*this);
151   return *this;
152 }
153
154 //_____________________________________________________________________________
155 void AliTRDCommonParam::Copy(TObject &p) const
156 {
157   //
158   // Copy function
159   //
160   
161   AliTRDCommonParam* target = dynamic_cast<AliTRDCommonParam*> (&p);
162   if (!target)
163     return;
164   
165   target->fExBOn              = fExBOn;
166   target->fField              = fField;
167 }
168
169 //_____________________________________________________________________________
170 AliTRDpadPlane *AliTRDCommonParam::GetPadPlane(Int_t p, Int_t c) const
171 {
172   //
173   // Returns the pad plane for a given plane <p> and chamber <c> number
174   //
175
176   Int_t ipp = p + c * kNplan;
177   return ((AliTRDpadPlane *) fPadPlaneArray->At(ipp));
178
179 }
180
181 //_____________________________________________________________________________
182 Int_t AliTRDCommonParam::GetRowMax(Int_t p, Int_t c, Int_t /*s*/) const
183 {
184   //
185   // Returns the number of rows on the pad plane
186   //
187
188   return GetPadPlane(p,c)->GetNrows();
189
190 }
191
192 //_____________________________________________________________________________
193 Int_t AliTRDCommonParam::GetColMax(Int_t p) const
194 {
195   //
196   // Returns the number of rows on the pad plane
197   //
198
199   return GetPadPlane(p,0)->GetNcols();
200
201 }
202
203 //_____________________________________________________________________________
204 Double_t AliTRDCommonParam::GetRow0(Int_t p, Int_t c, Int_t /*s*/) const
205 {
206   //
207   // Returns the position of the border of the first pad in a row
208   //
209
210   return GetPadPlane(p,c)->GetRow0();
211
212 }
213
214 //_____________________________________________________________________________
215 Double_t AliTRDCommonParam::GetCol0(Int_t p) const
216 {
217   //
218   // Returns the position of the border of the first pad in a column
219   //
220
221   return GetPadPlane(p,0)->GetCol0();
222
223 }