]> git.uio.no Git - u/mrichter/AliRoot.git/blob - TRD/AliTRDpadPlane.cxx
New plots for trending injector efficiencies (Melinda)
[u/mrichter/AliRoot.git] / TRD / AliTRDpadPlane.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 //  Describes a pad plane of a TRD ROC                                       //
21 //                                                                           //
22 //  Contains the information on pad postions, pad dimensions,                //
23 //  tilting angle, etc.                                                      //
24 //  It also provides methods to identify the current pad number from         //
25 //  global coordinates.                                                      //
26 //  The numbering and coordinates should follow the official convention      //
27 //  (see David Emschermanns note on TRD convention                           //
28 //                                                                           //
29 ///////////////////////////////////////////////////////////////////////////////
30
31 #include <TMath.h>
32
33 #include "AliTRDpadPlane.h"
34
35 ClassImp(AliTRDpadPlane)
36
37 //_____________________________________________________________________________
38 AliTRDpadPlane::AliTRDpadPlane()
39   :TObject()
40   ,fLayer(0)
41   ,fStack(0)
42   ,fLength(0)
43   ,fWidth(0)
44   ,fLengthRim(0)
45   ,fWidthRim(0)
46   ,fLengthOPad(0)
47   ,fWidthOPad(0)
48   ,fLengthIPad(0)
49   ,fWidthIPad(0)
50   ,fRowSpacing(0)
51   ,fColSpacing(0)
52   ,fNrows(0)
53   ,fNcols(0)
54   ,fTiltingAngle(0)
55   ,fTiltingTan(0)
56   ,fPadRow(0)
57   ,fPadCol(0)
58   ,fPadRowSMOffset(0)
59   ,fAnodeWireOffset(0)
60 {
61   //
62   // Default constructor
63   //
64
65 }
66
67 //_____________________________________________________________________________
68 AliTRDpadPlane::AliTRDpadPlane(Int_t layer, Int_t stack)
69   :TObject()
70   ,fLayer(layer)
71   ,fStack(stack)
72   ,fLength(0)
73   ,fWidth(0)
74   ,fLengthRim(0)
75   ,fWidthRim(0)
76   ,fLengthOPad(0)
77   ,fWidthOPad(0)
78   ,fLengthIPad(0)
79   ,fWidthIPad(0)
80   ,fRowSpacing(0)
81   ,fColSpacing(0)
82   ,fNrows(0)
83   ,fNcols(0)
84   ,fTiltingAngle(0)
85   ,fTiltingTan(0)
86   ,fPadRow(0)
87   ,fPadCol(0)
88   ,fPadRowSMOffset(0)
89   ,fAnodeWireOffset(0)
90 {
91   //
92   // Constructor
93   //
94
95 }
96
97 //_____________________________________________________________________________
98 AliTRDpadPlane::AliTRDpadPlane(const AliTRDpadPlane &p)
99   :TObject(p)
100   ,fLayer(p.fLayer)
101   ,fStack(p.fStack)
102   ,fLength(p.fLength)
103   ,fWidth(p.fWidth)
104   ,fLengthRim(p.fLengthRim)
105   ,fWidthRim(p.fLengthRim)
106   ,fLengthOPad(p.fLengthOPad)
107   ,fWidthOPad(p.fWidthOPad)
108   ,fLengthIPad(p.fLengthIPad)
109   ,fWidthIPad(p.fWidthIPad)
110   ,fRowSpacing(p.fRowSpacing)
111   ,fColSpacing(p.fColSpacing)
112   ,fNrows(p.fNrows)
113   ,fNcols(p.fNcols)
114   ,fTiltingAngle(p.fTiltingAngle)
115   ,fTiltingTan(p.fTiltingTan)
116   ,fPadRow(0)
117   ,fPadCol(0)
118   ,fPadRowSMOffset(p.fPadRowSMOffset)
119   ,fAnodeWireOffset(p.fAnodeWireOffset)
120 {
121   //
122   // AliTRDpadPlane copy constructor
123   //
124
125   Int_t iBin = 0;
126
127   fPadRow = new Double_t[fNrows];
128   for (iBin = 0; iBin < fNrows; iBin++) {
129     fPadRow[iBin] = ((AliTRDpadPlane &) p).fPadRow[iBin];
130   }                                                                             
131
132   fPadCol = new Double_t[fNrows];
133   for (iBin = 0; iBin < fNrows; iBin++) {
134     fPadCol[iBin] = ((AliTRDpadPlane &) p).fPadCol[iBin];
135   }                                                                             
136
137 }
138
139 //_____________________________________________________________________________
140 AliTRDpadPlane::~AliTRDpadPlane()
141 {
142   //
143   // AliTRDpadPlane destructor
144   //
145
146   if (fPadRow) {
147     delete [] fPadRow;
148     fPadRow = 0;
149   }
150
151   if (fPadCol) {
152     delete [] fPadCol;
153     fPadCol = 0;
154   }
155
156 }
157
158 //_____________________________________________________________________________
159 AliTRDpadPlane &AliTRDpadPlane::operator=(const AliTRDpadPlane &p)
160 {
161   //
162   // Assignment operator
163   //
164
165   if (this != &p) {
166     ((AliTRDpadPlane &) p).Copy(*this);
167   }
168
169   return *this;
170
171 }
172
173 //_____________________________________________________________________________
174 void AliTRDpadPlane::Copy(TObject &p) const
175 {
176   //
177   // Copy function
178   //
179
180   Int_t iBin = 0;
181
182   ((AliTRDpadPlane &) p).fLayer           = fLayer;
183   ((AliTRDpadPlane &) p).fStack           = fStack;
184
185   ((AliTRDpadPlane &) p).fLength          = fLength;
186   ((AliTRDpadPlane &) p).fWidth           = fWidth;
187   ((AliTRDpadPlane &) p).fLengthRim       = fLengthRim;
188   ((AliTRDpadPlane &) p).fWidthRim        = fWidthRim;
189   ((AliTRDpadPlane &) p).fLengthOPad      = fLengthOPad;
190   ((AliTRDpadPlane &) p).fWidthOPad       = fWidthOPad;
191   ((AliTRDpadPlane &) p).fLengthIPad      = fLengthIPad;
192   ((AliTRDpadPlane &) p).fWidthIPad       = fWidthIPad;
193
194   ((AliTRDpadPlane &) p).fRowSpacing      = fRowSpacing;
195   ((AliTRDpadPlane &) p).fColSpacing      = fColSpacing;
196
197   ((AliTRDpadPlane &) p).fNrows           = fNrows;
198   ((AliTRDpadPlane &) p).fNcols           = fNcols;
199
200   ((AliTRDpadPlane &) p).fTiltingAngle    = fTiltingAngle;
201   ((AliTRDpadPlane &) p).fTiltingTan      = fTiltingTan;
202
203   ((AliTRDpadPlane &) p).fPadRowSMOffset  = fPadRowSMOffset;
204   ((AliTRDpadPlane &) p).fAnodeWireOffset = fAnodeWireOffset;
205
206   if (((AliTRDpadPlane &) p).fPadRow) {
207     delete [] ((AliTRDpadPlane &) p).fPadRow;
208   }
209   ((AliTRDpadPlane &) p).fPadRow = new Double_t[fNrows];
210   for (iBin = 0; iBin < fNrows; iBin++) {
211     ((AliTRDpadPlane &) p).fPadRow[iBin] = fPadRow[iBin];
212   }                                                                             
213
214   if (((AliTRDpadPlane &) p).fPadCol) {
215     delete [] ((AliTRDpadPlane &) p).fPadCol;
216   }
217   ((AliTRDpadPlane &) p).fPadCol = new Double_t[fNrows];
218   for (iBin = 0; iBin < fNrows; iBin++) {
219     ((AliTRDpadPlane &) p).fPadCol[iBin] = fPadCol[iBin];
220   }                                                                             
221
222   TObject::Copy(p);
223
224 }
225
226 //_____________________________________________________________________________
227 void AliTRDpadPlane::SetTiltingAngle(Double_t t)
228 {
229   //
230   // Set the tilting angle of the pads
231   //
232  
233   fTiltingAngle = t; 
234   fTiltingTan   = TMath::Tan(TMath::Pi()/180.0 * fTiltingAngle); 
235
236 }
237
238 //_____________________________________________________________________________
239 Int_t AliTRDpadPlane::GetPadRowNumber(Double_t z) const
240 {
241   //
242   // Finds the pad row number for a given z-position in local supermodule system
243   //
244
245   Int_t row    = 0;
246   Int_t nabove = 0;
247   Int_t nbelow = 0;
248   Int_t middle = 0;
249
250   if ((z > GetRow0()  ) || 
251       (z < GetRowEnd())) {
252
253     row = -1;
254
255   }
256   else {
257
258     nabove = fNrows + 1;
259     nbelow = 0;
260     while (nabove - nbelow > 1) {
261       middle = (nabove + nbelow) / 2;
262       if (z == (fPadRow[middle-1] + fPadRowSMOffset)) {
263         row    = middle;
264       }
265       if (z  > (fPadRow[middle-1] + fPadRowSMOffset)) {
266         nabove = middle;
267       }
268       else {
269         nbelow = middle;
270       }
271     }
272     row = nbelow - 1;
273
274   }
275
276   return row;
277
278 }
279
280 //_____________________________________________________________________________
281 Int_t AliTRDpadPlane::GetPadRowNumberROC(Double_t z) const
282 {
283   //
284   // Finds the pad row number for a given z-position in local ROC system
285   //
286
287   Int_t row    = 0;
288   Int_t nabove = 0;
289   Int_t nbelow = 0;
290   Int_t middle = 0;
291
292   if ((z > GetRow0ROC()  ) || 
293       (z < GetRowEndROC())) {
294
295     row = -1;
296
297   }
298   else {
299
300     nabove = fNrows + 1;
301     nbelow = 0;
302     while (nabove - nbelow > 1) {
303       middle = (nabove + nbelow) / 2;
304       if (z == fPadRow[middle-1]) {
305         row    = middle;
306       }
307       if (z  > fPadRow[middle-1]) {
308         nabove = middle;
309       }
310       else {
311         nbelow = middle;
312       }
313     }
314     row = nbelow - 1;
315
316   }
317
318   return row;
319
320 }
321
322 //_____________________________________________________________________________
323 Int_t AliTRDpadPlane::GetPadColNumber(Double_t rphi) const
324 {
325   //
326   // Finds the pad column number for a given rphi-position
327   //
328
329   Int_t col    = 0;
330   Int_t nabove = 0;
331   Int_t nbelow = 0;
332   Int_t middle = 0;
333
334   if ((rphi < GetCol0()  ) || 
335       (rphi > GetColEnd())) {
336
337     col = -1;
338
339   }
340   else {
341
342     nabove = fNcols;
343     nbelow = 0;
344     while (nabove - nbelow > 1) {
345       middle = (nabove + nbelow) / 2;
346       if (rphi == fPadCol[middle]) {
347         col    = middle;
348       }
349       if (rphi  > fPadCol[middle]) {
350         nbelow = middle;
351       }
352       else {
353         nabove = middle;
354       }
355     }
356     col = nbelow;
357
358   }
359
360   return col;
361
362 }