]> git.uio.no Git - u/mrichter/AliRoot.git/blob - TRD/AliTRDCommonParam.cxx
4abfffd3de2166c5fd1fb5aca26f4598682f96f2
[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   fPRFOn              = kFALSE;
83   
84   fPadPlaneArray      = 0;
85   
86   Init();
87 }
88
89 //_____________________________________________________________________________
90 void AliTRDCommonParam::Init()
91 {
92   //
93   // constructor helper
94   //
95   
96   // E x B effects
97   fExBOn          = kTRUE;
98
99   // The pad response function
100   fPRFOn          = kTRUE;
101
102   // The magnetic field strength in Tesla
103   Double_t x[3] = { 0.0, 0.0, 0.0 };
104   Double_t b[3];
105   gAlice->Field(x,b);  // b[] is in kilo Gauss
106   fField = b[2] * 0.1; // Tesla
107   
108   // ----------------------------------------------------------------------------
109   // The pad planes
110   // ----------------------------------------------------------------------------
111   
112   fPadPlaneArray = new TObjArray(kNplan * kNcham);
113   
114   for (Int_t iplan = 0; iplan < kNplan; iplan++) {
115     for (Int_t icham = 0; icham < kNcham; icham++) {
116       Int_t ipp = iplan + icham * kNplan;
117       fPadPlaneArray->AddAt(new AliTRDpadPlane(iplan,icham),ipp);
118     }
119   }
120 }
121
122 //_____________________________________________________________________________
123 AliTRDCommonParam::~AliTRDCommonParam() 
124 {
125   //
126   // destructor
127   //
128   
129   if (fPadPlaneArray) {
130     fPadPlaneArray->Delete();
131     delete fPadPlaneArray;
132     fPadPlaneArray = 0;
133   }
134 }
135
136 //_____________________________________________________________________________
137 AliTRDCommonParam::AliTRDCommonParam(const AliTRDCommonParam &p):TObject(p)
138 {
139   //
140   // copy constructor
141   //
142
143   ((AliTRDCommonParam &) p).Copy(*this);
144 }
145
146
147 //_____________________________________________________________________________
148 AliTRDCommonParam &AliTRDCommonParam::operator=(const AliTRDCommonParam &p)
149 {
150   //
151   // Assignment operator
152   //
153
154   if (this != &p) ((AliTRDCommonParam &) p).Copy(*this);
155   return *this;
156 }
157
158 //_____________________________________________________________________________
159 void AliTRDCommonParam::Copy(TObject &p) const
160 {
161   //
162   // Copy function
163   //
164   
165   AliTRDCommonParam* target = dynamic_cast<AliTRDCommonParam*> (&p);
166   if (!target)
167     return;
168   
169   target->fExBOn              = fExBOn;
170   target->fPRFOn              = fPRFOn;
171   /*target->fPRFbin             = fPRFbin;
172   target->fPRFlo              = fPRFlo;
173   target->fPRFhi              = fPRFhi;
174   target->fPRFwid             = fPRFwid;
175   target->fPRFpad             = fPRFpad;
176   if (target->fPRFsmp) delete [] target->fPRFsmp;
177   target->fPRFsmp = new Float_t[fPRFbin];
178   for (Int_t iBin = 0; iBin < fPRFbin; iBin++) {
179     target->fPRFsmp[iBin] = fPRFsmp[iBin];
180   }*/
181 }
182
183 //_____________________________________________________________________________
184 AliTRDpadPlane *AliTRDCommonParam::GetPadPlane(Int_t p, Int_t c) const
185 {
186   //
187   // Returns the pad plane for a given plane <p> and chamber <c> number
188   //
189
190   Int_t ipp = p + c * kNplan;
191   return ((AliTRDpadPlane *) fPadPlaneArray->At(ipp));
192
193 }
194
195 //_____________________________________________________________________________
196 Int_t AliTRDCommonParam::GetRowMax(Int_t p, Int_t c, Int_t /*s*/) const
197 {
198   //
199   // Returns the number of rows on the pad plane
200   //
201
202   return GetPadPlane(p,c)->GetNrows();
203
204 }
205
206 //_____________________________________________________________________________
207 Int_t AliTRDCommonParam::GetColMax(Int_t p) const
208 {
209   //
210   // Returns the number of rows on the pad plane
211   //
212
213   return GetPadPlane(p,0)->GetNcols();
214
215 }
216
217 //_____________________________________________________________________________
218 Double_t AliTRDCommonParam::GetRow0(Int_t p, Int_t c, Int_t /*s*/) const
219 {
220   //
221   // Returns the position of the border of the first pad in a row
222   //
223
224   return GetPadPlane(p,c)->GetRow0();
225
226 }
227
228 //_____________________________________________________________________________
229 Double_t AliTRDCommonParam::GetCol0(Int_t p) const
230 {
231   //
232   // Returns the position of the border of the first pad in a column
233   //
234
235   return GetPadPlane(p,0)->GetCol0();
236
237 }