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