1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
18 ///////////////////////////////////////////////////////////////////////////////
20 // Class containing constant common parameters //
22 // Request an instance with AliTRDCommonParam::Instance() //
23 // Then request the needed values //
25 ///////////////////////////////////////////////////////////////////////////////
29 #include "AliTRDCommonParam.h"
30 #include "AliTRDpadPlane.h"
33 ClassImp(AliTRDCommonParam)
35 AliTRDCommonParam* AliTRDCommonParam::fgInstance = 0;
36 Bool_t AliTRDCommonParam::fgTerminated = kFALSE;
38 //_ singleton implementation __________________________________________________
39 AliTRDCommonParam* AliTRDCommonParam::Instance()
42 // Singleton implementation
43 // Returns an instance of this class, it is created if neccessary
46 if (fgTerminated != kFALSE)
50 fgInstance = new AliTRDCommonParam();
55 void AliTRDCommonParam::Terminate()
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.
72 //_____________________________________________________________________________
73 AliTRDCommonParam::AliTRDCommonParam()
88 //_____________________________________________________________________________
89 void AliTRDCommonParam::Init()
98 // The magnetic field strength in Tesla
99 Double_t x[3] = { 0.0, 0.0, 0.0 };
101 gAlice->Field(x,b); // b[] is in kilo Gauss
102 fField = b[2] * 0.1; // Tesla
104 // ----------------------------------------------------------------------------
106 // ----------------------------------------------------------------------------
108 fPadPlaneArray = new TObjArray(kNplan * kNcham);
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);
118 //_____________________________________________________________________________
119 AliTRDCommonParam::~AliTRDCommonParam()
125 if (fPadPlaneArray) {
126 fPadPlaneArray->Delete();
127 delete fPadPlaneArray;
132 //_____________________________________________________________________________
133 AliTRDCommonParam::AliTRDCommonParam(const AliTRDCommonParam &p):TObject(p)
139 ((AliTRDCommonParam &) p).Copy(*this);
143 //_____________________________________________________________________________
144 AliTRDCommonParam &AliTRDCommonParam::operator=(const AliTRDCommonParam &p)
147 // Assignment operator
150 if (this != &p) ((AliTRDCommonParam &) p).Copy(*this);
154 //_____________________________________________________________________________
155 void AliTRDCommonParam::Copy(TObject &p) const
161 AliTRDCommonParam* target = dynamic_cast<AliTRDCommonParam*> (&p);
165 target->fExBOn = fExBOn;
166 target->fField = fField;
169 //_____________________________________________________________________________
170 AliTRDpadPlane *AliTRDCommonParam::GetPadPlane(Int_t p, Int_t c) const
173 // Returns the pad plane for a given plane <p> and chamber <c> number
176 Int_t ipp = p + c * kNplan;
177 return ((AliTRDpadPlane *) fPadPlaneArray->At(ipp));
181 //_____________________________________________________________________________
182 Int_t AliTRDCommonParam::GetRowMax(Int_t p, Int_t c, Int_t /*s*/) const
185 // Returns the number of rows on the pad plane
188 return GetPadPlane(p,c)->GetNrows();
192 //_____________________________________________________________________________
193 Int_t AliTRDCommonParam::GetColMax(Int_t p) const
196 // Returns the number of rows on the pad plane
199 return GetPadPlane(p,0)->GetNcols();
203 //_____________________________________________________________________________
204 Double_t AliTRDCommonParam::GetRow0(Int_t p, Int_t c, Int_t /*s*/) const
207 // Returns the position of the border of the first pad in a row
210 return GetPadPlane(p,c)->GetRow0();
214 //_____________________________________________________________________________
215 Double_t AliTRDCommonParam::GetCol0(Int_t p) const
218 // Returns the position of the border of the first pad in a column
221 return GetPadPlane(p,0)->GetCol0();