]> git.uio.no Git - u/mrichter/AliRoot.git/blob - TRD/AliTRDpadPlane.cxx
bugfix: '-nextevent' command in configuration file for publisher inserted correctly...
[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     return *this;
167   }
168
169   fLayer           = p.fLayer;
170   fStack           = p.fStack;
171   fLength          = p.fLength;
172   fWidth           = p.fWidth;
173   fLengthRim       = p.fLengthRim;
174   fWidthRim        = p.fLengthRim;
175   fLengthOPad      = p.fLengthOPad;
176   fWidthOPad       = p.fWidthOPad;
177   fLengthIPad      = p.fLengthIPad;
178   fWidthIPad       = p.fWidthIPad;
179   fRowSpacing      = p.fRowSpacing;
180   fColSpacing      = p.fColSpacing;
181   fNrows           = p.fNrows;
182   fNcols           = p.fNcols;
183   fTiltingAngle    = p.fTiltingAngle;
184   fTiltingTan      = p.fTiltingTan;
185   fPadRow          = 0;
186   fPadCol          = 0;
187   fPadRowSMOffset  = p.fPadRowSMOffset;
188   fAnodeWireOffset = p.fAnodeWireOffset;
189
190   Int_t iBin = 0;
191
192   if (fPadRow) {
193     delete [] fPadRow;
194   }
195   fPadRow = new Double_t[fNrows];
196   for (iBin = 0; iBin < fNrows; iBin++) {
197     fPadRow[iBin] = ((AliTRDpadPlane &) p).fPadRow[iBin];
198   }                                                                             
199
200   if (fPadCol) {
201     delete [] fPadCol;
202   }
203   fPadCol = new Double_t[fNrows];
204   for (iBin = 0; iBin < fNrows; iBin++) {
205     fPadCol[iBin] = ((AliTRDpadPlane &) p).fPadCol[iBin];
206   }                                                                             
207
208   return *this;
209
210 }
211
212 //_____________________________________________________________________________
213 void AliTRDpadPlane::Copy(TObject &p) const
214 {
215   //
216   // Copy function
217   //
218
219   Int_t iBin = 0;
220
221   ((AliTRDpadPlane &) p).fLayer           = fLayer;
222   ((AliTRDpadPlane &) p).fStack           = fStack;
223
224   ((AliTRDpadPlane &) p).fLength          = fLength;
225   ((AliTRDpadPlane &) p).fWidth           = fWidth;
226   ((AliTRDpadPlane &) p).fLengthRim       = fLengthRim;
227   ((AliTRDpadPlane &) p).fWidthRim        = fWidthRim;
228   ((AliTRDpadPlane &) p).fLengthOPad      = fLengthOPad;
229   ((AliTRDpadPlane &) p).fWidthOPad       = fWidthOPad;
230   ((AliTRDpadPlane &) p).fLengthIPad      = fLengthIPad;
231   ((AliTRDpadPlane &) p).fWidthIPad       = fWidthIPad;
232
233   ((AliTRDpadPlane &) p).fRowSpacing      = fRowSpacing;
234   ((AliTRDpadPlane &) p).fColSpacing      = fColSpacing;
235
236   ((AliTRDpadPlane &) p).fNrows           = fNrows;
237   ((AliTRDpadPlane &) p).fNcols           = fNcols;
238
239   ((AliTRDpadPlane &) p).fTiltingAngle    = fTiltingAngle;
240   ((AliTRDpadPlane &) p).fTiltingTan      = fTiltingTan;
241
242   ((AliTRDpadPlane &) p).fPadRowSMOffset  = fPadRowSMOffset;
243   ((AliTRDpadPlane &) p).fAnodeWireOffset = fAnodeWireOffset;
244
245   if (((AliTRDpadPlane &) p).fPadRow) {
246     delete [] ((AliTRDpadPlane &) p).fPadRow;
247   }
248   ((AliTRDpadPlane &) p).fPadRow = new Double_t[fNrows];
249   for (iBin = 0; iBin < fNrows; iBin++) {
250     ((AliTRDpadPlane &) p).fPadRow[iBin] = fPadRow[iBin];
251   }                                                                             
252
253   if (((AliTRDpadPlane &) p).fPadCol) {
254     delete [] ((AliTRDpadPlane &) p).fPadCol;
255   }
256   ((AliTRDpadPlane &) p).fPadCol = new Double_t[fNrows];
257   for (iBin = 0; iBin < fNrows; iBin++) {
258     ((AliTRDpadPlane &) p).fPadCol[iBin] = fPadCol[iBin];
259   }                                                                             
260
261   TObject::Copy(p);
262
263 }
264
265 //_____________________________________________________________________________
266 void AliTRDpadPlane::SetTiltingAngle(Double_t t)
267 {
268   //
269   // Set the tilting angle of the pads
270   //
271  
272   fTiltingAngle = t; 
273   fTiltingTan   = TMath::Tan(TMath::Pi()/180.0 * fTiltingAngle); 
274
275 }
276
277 //_____________________________________________________________________________
278 Int_t AliTRDpadPlane::GetPadRowNumber(Double_t z) const
279 {
280   //
281   // Finds the pad row number for a given z-position in local supermodule system
282   //
283
284   Int_t row    = 0;
285   Int_t nabove = 0;
286   Int_t nbelow = 0;
287   Int_t middle = 0;
288
289   if ((z > GetRow0()  ) || 
290       (z < GetRowEnd())) {
291
292     row = -1;
293
294   }
295   else {
296
297     nabove = fNrows + 1;
298     nbelow = 0;
299     while (nabove - nbelow > 1) {
300       middle = (nabove + nbelow) / 2;
301       if (z == (fPadRow[middle-1] + fPadRowSMOffset)) {
302         row    = middle;
303       }
304       if (z  > (fPadRow[middle-1] + fPadRowSMOffset)) {
305         nabove = middle;
306       }
307       else {
308         nbelow = middle;
309       }
310     }
311     row = nbelow - 1;
312
313   }
314
315   return row;
316
317 }
318
319 //_____________________________________________________________________________
320 Int_t AliTRDpadPlane::GetPadRowNumberROC(Double_t z) const
321 {
322   //
323   // Finds the pad row number for a given z-position in local ROC system
324   //
325
326   Int_t row    = 0;
327   Int_t nabove = 0;
328   Int_t nbelow = 0;
329   Int_t middle = 0;
330
331   if ((z > GetRow0ROC()  ) || 
332       (z < GetRowEndROC())) {
333
334     row = -1;
335
336   }
337   else {
338
339     nabove = fNrows + 1;
340     nbelow = 0;
341     while (nabove - nbelow > 1) {
342       middle = (nabove + nbelow) / 2;
343       if (z == fPadRow[middle-1]) {
344         row    = middle;
345       }
346       if (z  > fPadRow[middle-1]) {
347         nabove = middle;
348       }
349       else {
350         nbelow = middle;
351       }
352     }
353     row = nbelow - 1;
354
355   }
356
357   return row;
358
359 }
360
361 //_____________________________________________________________________________
362 Int_t AliTRDpadPlane::GetPadColNumber(Double_t rphi) const
363 {
364   //
365   // Finds the pad column number for a given rphi-position
366   //
367
368   Int_t col    = 0;
369   Int_t nabove = 0;
370   Int_t nbelow = 0;
371   Int_t middle = 0;
372
373   if ((rphi < GetCol0()  ) || 
374       (rphi > GetColEnd())) {
375
376     col = -1;
377
378   }
379   else {
380
381     nabove = fNcols;
382     nbelow = 0;
383     while (nabove - nbelow > 1) {
384       middle = (nabove + nbelow) / 2;
385       if (rphi == fPadCol[middle]) {
386         col    = middle;
387       }
388       if (rphi  > fPadCol[middle]) {
389         nbelow = middle;
390       }
391       else {
392         nabove = middle;
393       }
394     }
395     col = nbelow;
396
397   }
398
399   return col;
400
401 }