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