]> git.uio.no Git - u/mrichter/AliRoot.git/blob - TRD/AliTRDCommonParam.cxx
Adding include files where needed for latest ROOT
[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 <TObjArray.h>
28
29 #include "AliTracker.h"
30 #include "AliRun.h"
31
32 #include "AliTRDCommonParam.h"
33 #include "AliTRDpadPlane.h"
34
35
36 ClassImp(AliTRDCommonParam)
37
38 AliTRDCommonParam *AliTRDCommonParam::fgInstance = 0;
39 Bool_t AliTRDCommonParam::fgTerminated = kFALSE;
40
41 //_ singleton implementation __________________________________________________
42 AliTRDCommonParam* AliTRDCommonParam::Instance()
43 {
44   //
45   // Singleton implementation
46   // Returns an instance of this class, it is created if neccessary
47   // 
48   
49   if (fgTerminated != kFALSE) {
50     return 0;
51   }
52
53   if (fgInstance == 0) {
54     fgInstance = new AliTRDCommonParam();
55   }  
56
57   return fgInstance;
58
59 }
60
61 //_____________________________________________________________________________
62 void AliTRDCommonParam::Terminate()
63 {
64   //
65   // Singleton implementation
66   // Deletes the instance of this class and sets the terminated flag,
67   // instances cannot be requested anymore
68   // This function can be called several times.
69   //
70   
71   fgTerminated = kTRUE;
72   
73   if (fgInstance != 0) {
74     delete fgInstance;
75     fgInstance = 0;
76   }
77
78 }
79
80 //_____________________________________________________________________________
81 AliTRDCommonParam::AliTRDCommonParam()
82   :TObject()
83   ,fExBOn(kFALSE)
84   ,fPadPlaneArray(0)
85 {
86   //
87   // Default constructor
88   //
89   
90   Init();
91
92 }
93
94 //_____________________________________________________________________________
95 void AliTRDCommonParam::Init()
96 {
97   //
98   // Initialization
99   //
100   
101   // E x B effects
102   fExBOn         = kTRUE;
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 //_____________________________________________________________________________
120 AliTRDCommonParam::~AliTRDCommonParam() 
121 {
122   //
123   // Destructor
124   //
125   
126   if (fPadPlaneArray) {
127     fPadPlaneArray->Delete();
128     delete fPadPlaneArray;
129     fPadPlaneArray = 0;
130   }
131
132 }
133
134 //_____________________________________________________________________________
135 AliTRDCommonParam::AliTRDCommonParam(const AliTRDCommonParam &p)
136   :TObject(p)
137   ,fExBOn(p.fExBOn)
138   ,fPadPlaneArray(0)
139 {
140   //
141   // Copy constructor
142   //
143
144 }
145
146 //_____________________________________________________________________________
147 AliTRDCommonParam &AliTRDCommonParam::operator=(const AliTRDCommonParam &p)
148 {
149   //
150   // Assignment operator
151   //
152
153   if (this != &p) {
154     ((AliTRDCommonParam &) p).Copy(*this);
155   }
156
157   return *this;
158
159 }
160
161 //_____________________________________________________________________________
162 void AliTRDCommonParam::Copy(TObject &p) const
163 {
164   //
165   // Copy function
166   //
167   
168   AliTRDCommonParam *target = dynamic_cast<AliTRDCommonParam*> (&p);
169   if (!target) {
170     return;
171   }  
172
173   target->fExBOn = fExBOn;
174
175 }
176
177 //_____________________________________________________________________________
178 AliTRDpadPlane *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 //_____________________________________________________________________________
190 Int_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 //_____________________________________________________________________________
201 Int_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 //_____________________________________________________________________________
212 Double_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 //_____________________________________________________________________________
223 Double_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 }