coverity fix
[u/mrichter/AliRoot.git] / TPC / AliTPCROC.cxx
CommitLineData
7a0ff78e 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
17///////////////////////////////////////////////////////////////////////////////
18// //
19// Geometry class for a single ROC //
20// //
21// //
22///////////////////////////////////////////////////////////////////////////////
23#include "AliTPCROC.h"
24#include "TMath.h"
25
26ClassImp(AliTPCROC)
27
28
29AliTPCROC* AliTPCROC::fgInstance = 0;
30
31
32
33
34//_ singleton implementation __________________________________________________
35AliTPCROC* AliTPCROC::Instance()
36{
37 //
38 // Singleton implementation
39 // Returns an instance of this class, it is created if neccessary
40 //
41 if (fgInstance == 0){
42 fgInstance = new AliTPCROC();
43 fgInstance->Init();
44 }
45 return fgInstance;
46}
47
48
49
50
51void AliTPCROC::Init(){
52 //
53 // initialize static variables
54 //
55 if (AliTPCROC::fNSectorsAll>0) return;
56 fNSectorsAll =72;
57 fNSectors[0] =36;
58 fNSectors[1] =36;
59 //
60 fNRows[0]= 63;
61 fNRows[1]= 96;
62 //
63 // number of pads in padrow
c5bbaa2c 64 fNPads[0] = new UInt_t[fNRows[0]];
65 fNPads[1] = new UInt_t[fNRows[1]];
7a0ff78e 66 //
67 // padrow index in array
68 //
c5bbaa2c 69 fRowPosIndex[0] = new UInt_t[fNRows[0]];
70 fRowPosIndex[1] = new UInt_t[fNRows[1]];
7a0ff78e 71 //
72 // inner sectors
73 //
c5bbaa2c 74 UInt_t index =0;
75 for (UInt_t irow=0; irow<fNRows[0];irow++){
76 UInt_t npads = (irow==0) ? 68 : 2 *Int_t(Double_t(irow)/3. +33.67);
7a0ff78e 77 fNPads[0][irow] = npads;
78 fRowPosIndex[0][irow] = index;
79 index+=npads;
80 }
81 fNChannels[0] = index;
82 //
83 index =0;
84 Double_t k1 = 10.*TMath::Tan(10*TMath::DegToRad())/6.;
85 Double_t k2 = 15.*TMath::Tan(10*TMath::DegToRad())/6.;
c5bbaa2c 86 for (UInt_t irow=0; irow<fNRows[1];irow++){
87 UInt_t npads = (irow<64) ?
7a0ff78e 88 2*Int_t(k1*Double_t(irow)+37.75):
89 2*Int_t(k2*Double_t(irow-64)+56.66);
90 fNPads[1][irow] = npads;
91 fRowPosIndex[1][irow] = index;
92 index+=npads;
93 }
94 fNChannels[1] = index;
95 SetGeometry();
96}
97
98
99
100
101void AliTPCROC::SetGeometry()
102{
103 //
104 //set ROC geometry parameters
105 //
106 const Float_t kInnerRadiusLow = 83.65;
107 const Float_t kInnerRadiusUp = 133.3;
108 const Float_t kOuterRadiusLow = 133.5;
109 const Float_t kOuterRadiusUp = 247.7;
110 const Float_t kInnerFrameSpace = 1.5;
111 const Float_t kOuterFrameSpace = 1.5;
112 const Float_t kInnerWireMount = 1.2;
113 const Float_t kOuterWireMount = 1.4;
114 const Float_t kZLength =250.;
c5bbaa2c 115 const UInt_t kNRowLow = 63;
116 const UInt_t kNRowUp1 = 64;
117 const UInt_t kNRowUp2 = 32;
118 const UInt_t kNRowUp = 96;
7a0ff78e 119 const Float_t kInnerAngle = 20; // 20 degrees
120 const Float_t kOuterAngle = 20; // 20 degrees
121 //
122 // pad parameters
123 //
124 const Float_t kInnerPadPitchLength = 0.75;
125 const Float_t kInnerPadPitchWidth = 0.40;
126 const Float_t kInnerPadLength = 0.75;
127 const Float_t kInnerPadWidth = 0.40;
128 const Float_t kOuter1PadPitchLength = 1.0;
129 const Float_t kOuterPadPitchWidth = 0.6;
130 const Float_t kOuter1PadLength = 1.0;
131 const Float_t kOuterPadWidth = 0.6;
132 const Float_t kOuter2PadPitchLength = 1.5;
133 const Float_t kOuter2PadLength = 1.5;
134
135 //
136 //wires default parameters
137 //
c5bbaa2c 138// const UInt_t kNInnerWiresPerPad = 3;
139// const UInt_t kInnerDummyWire = 2;
7a0ff78e 140// const Float_t kInnerWWPitch = 0.25;
141// const Float_t kRInnerFirstWire = 84.475;
142// const Float_t kRInnerLastWire = 132.475;
143// const Float_t kInnerOffWire = 0.5;
c5bbaa2c 144// const UInt_t kNOuter1WiresPerPad = 4;
145// const UInt_t kNOuter2WiresPerPad = 6;
7a0ff78e 146// const Float_t kOuterWWPitch = 0.25;
147// const Float_t kROuterFirstWire = 134.225;
148// const Float_t kROuterLastWire = 246.975;
c5bbaa2c 149// const UInt_t kOuterDummyWire = 2;
7a0ff78e 150// const Float_t kOuterOffWire = 0.5;
151 //
152 //set sector parameters
153 //
154 fInnerRadiusLow = kInnerRadiusLow;
155 fOuterRadiusLow = kOuterRadiusLow;
156 fInnerRadiusUp = kInnerRadiusUp;
157 fOuterRadiusUp = kOuterRadiusUp;
158 fInnerFrameSpace = kInnerFrameSpace;
159 fOuterFrameSpace = kOuterFrameSpace;
160 fInnerWireMount = kInnerWireMount;
161 fOuterWireMount = kOuterWireMount;
162 fZLength = kZLength;
163 fInnerAngle = TMath::DegToRad()*kInnerAngle;
164 fOuterAngle = TMath::DegToRad()*kOuterAngle;
165
166 fNRowLow = kNRowLow;
167 fNRowUp1 = kNRowUp1;
168 fNRowUp2 = kNRowUp2;
169 fNRowUp = kNRowUp;
170 //
171 //set pad parameter
172 //
173 fInnerPadPitchLength = kInnerPadPitchLength;
174 fInnerPadPitchWidth = kInnerPadPitchWidth;
175 fInnerPadLength = kInnerPadLength;
176 fInnerPadWidth = kInnerPadWidth;
177 fOuter1PadPitchLength = kOuter1PadPitchLength;
178 fOuter2PadPitchLength = kOuter2PadPitchLength;
179 fOuterPadPitchWidth = kOuterPadPitchWidth;
180 fOuter1PadLength = kOuter1PadLength;
181 fOuter2PadLength = kOuter2PadLength;
182 fOuterPadWidth = kOuterPadWidth;
183
184 //
185 //set wire parameters
186 //
187 // SetInnerNWires(kNInnerWiresPerPad);
188 // SetInnerDummyWire(kInnerDummyWire);
189 // SetInnerOffWire(kInnerOffWire);
190 // SetOuter1NWires(kNOuter1WiresPerPad);
191 // SetOuter2NWire(kNOuter2WiresPerPad);
192 // SetOuterDummyWire(kOuterDummyWire);
193 // SetOuterOffWire(kOuterOffWire);
194 // SetInnerWWPitch(kInnerWWPitch);
195 // SetRInnerFirstWire(kRInnerFirstWire);
196 // SetRInnerLastWire(kRInnerLastWire);
197 // SetOuterWWPitch(kOuterWWPitch);
198 // SetROuterFirstWire(kROuterFirstWire);
199 // SetROuterLastWire(kROuterLastWire);
38bc857e 200
201 UInt_t i=0;
202 Float_t firstrow = fInnerRadiusLow + 1.575;
203 for( i= 0;i<fNRowLow;i++)
204 {
205 Float_t x = firstrow + fInnerPadPitchLength*(Float_t)i;
206 fPadRowLow[i]=x;
207 fYInner[i+1] = x*TMath::Tan(fInnerAngle/2.)-fInnerWireMount;
208 fNPadsLow[i] = GetNPads(0,i) ; // ROC implement
209 }
210 // cross talk rows
211 fYInner[0]=(fPadRowLow[0]-fInnerPadPitchLength)*TMath::Tan(fInnerAngle/2.)-fInnerWireMount;
212 fYInner[fNRowLow+1]=(fPadRowLow[fNRowLow-1]+fInnerPadPitchLength)*TMath::Tan(fInnerAngle/2.)-fInnerWireMount;
213 firstrow = fOuterRadiusLow + 1.6;
214 for(i=0;i<fNRowUp;i++)
215 {
216 if(i<fNRowUp1){
217 Float_t x = firstrow + fOuter1PadPitchLength*(Float_t)i;
218 fPadRowUp[i]=x;
219 fYOuter[i+1]= x*TMath::Tan(fOuterAngle/2.)-fOuterWireMount;
220 fNPadsUp[i] = GetNPads(36,i) ; // ROC implement
221 if(i==fNRowUp1-1) {
222 fLastWireUp1=fPadRowUp[i] +0.625;
223 firstrow = fPadRowUp[i] + 0.5*(fOuter1PadPitchLength+fOuter2PadPitchLength);
224 }
225 }
226 else
227 {
228 Float_t x = firstrow + fOuter2PadPitchLength*(Float_t)(i-64);
229 fPadRowUp[i]=x;
230 fNPadsUp[i] = GetNPads(36,i) ; // ROC implement
231 }
232 fYOuter[i+1] = fPadRowUp[i]*TMath::Tan(fOuterAngle/2.)-fOuterWireMount;
233 }
234
235
236
7a0ff78e 237}
238
239
240
241
242//_____________________________________________________________________________
179c6296 243AliTPCROC::AliTPCROC()
244 :TObject(),
245 fNSectorsAll(0),
246 fInnerRadiusLow(0.),
247 fInnerRadiusUp(0.),
248 fOuterRadiusUp(0.),
249 fOuterRadiusLow(0.),
250 fInnerFrameSpace(0.),
251 fOuterFrameSpace(0.),
252 fInnerWireMount(0.),
253 fOuterWireMount(0.),
254 fZLength(0.),
255 fInnerAngle(0.),
256 fOuterAngle(0.),
257 fNInnerWiresPerPad(0),
258 fInnerWWPitch(0.),
259 fInnerDummyWire(0),
260 fInnerOffWire(0.),
261 fRInnerFirstWire(0.),
262 fRInnerLastWire(0.),
263 fLastWireUp1(0.),
264 fNOuter1WiresPerPad(0),
265 fNOuter2WiresPerPad(0),
266 fOuterWWPitch(0.),
267 fOuterDummyWire(0),
268 fOuterOffWire(0),
269 fROuterFirstWire(0.),
270 fROuterLastWire(0),
271 fInnerPadPitchLength(0.),
272 fInnerPadPitchWidth(0.),
273 fInnerPadLength(0.),
274 fInnerPadWidth(0.),
275 fOuter1PadPitchLength(0.),
276 fOuter2PadPitchLength(0),
277 fOuterPadPitchWidth(0),
278 fOuter1PadLength(0.),
279 fOuter2PadLength(0),
280 fOuterPadWidth(0),
281 fNRowLow(0),
282 fNRowUp1(0),
283 fNRowUp2(0),
284 fNRowUp(0),
285 fNtRows(0)
7a0ff78e 286{
287 //
288 // Default constructor
c5bbaa2c 289 for (UInt_t i=0;i<2;i++){
7a0ff78e 290 fNSectors[i] = 0;
291 fNRows[i] = 0;
292 fNChannels[i] = 0;
293 fNPads[i] = 0;
294 fRowPosIndex[i]= 0;
295 }
9bbf714d 296
297 for (UInt_t i=0;i<100;++i){
298 fPadRowLow[i]=0.;
299 fPadRowUp[i]=0.;
300 fNPadsLow[i]=0;
301 fNPadsUp[i]=0;
302 fYInner[i]=0.;
303 fYOuter[i]=0.;
304 }
7a0ff78e 305}
306
307
308//_____________________________________________________________________________
179c6296 309AliTPCROC::AliTPCROC(const AliTPCROC &roc)
310 :TObject(roc),
311 fNSectorsAll(0),
312 fInnerRadiusLow(0.),
313 fInnerRadiusUp(0.),
314 fOuterRadiusUp(0.),
315 fOuterRadiusLow(0.),
316 fInnerFrameSpace(0.),
317 fOuterFrameSpace(0.),
318 fInnerWireMount(0.),
319 fOuterWireMount(0.),
320 fZLength(0.),
321 fInnerAngle(0.),
322 fOuterAngle(0.),
323 fNInnerWiresPerPad(0),
324 fInnerWWPitch(0.),
325 fInnerDummyWire(0),
326 fInnerOffWire(0.),
327 fRInnerFirstWire(0.),
328 fRInnerLastWire(0.),
329 fLastWireUp1(0.),
330 fNOuter1WiresPerPad(0),
331 fNOuter2WiresPerPad(0),
332 fOuterWWPitch(0.),
333 fOuterDummyWire(0),
334 fOuterOffWire(0),
335 fROuterFirstWire(0.),
336 fROuterLastWire(0),
337 fInnerPadPitchLength(0.),
338 fInnerPadPitchWidth(0.),
339 fInnerPadLength(0.),
340 fInnerPadWidth(0.),
341 fOuter1PadPitchLength(0.),
342 fOuter2PadPitchLength(0),
343 fOuterPadPitchWidth(0),
344 fOuter1PadLength(0.),
345 fOuter2PadLength(0),
346 fOuterPadWidth(0),
347 fNRowLow(0),
348 fNRowUp1(0),
349 fNRowUp2(0),
350 fNRowUp(0),
351 fNtRows(0)
352
7a0ff78e 353{
354 //
355 // AliTPCROC copy constructor
356 //
357 fNSectorsAll = roc.fNSectorsAll;
358 fNSectors[0] = roc.fNSectors[0];
359 fNSectors[1] = roc.fNSectors[1];
360 fNRows[0] = roc.fNRows[0];
361 fNRows[1] = roc.fNRows[1];
362 fNChannels[0]= roc.fNChannels[0];
363 fNChannels[1]= roc.fNChannels[1];
364 //
365 // number of pads in padrow
c5bbaa2c 366 fNPads[0] = new UInt_t[fNRows[0]];
367 fNPads[1] = new UInt_t[fNRows[1]];
7a0ff78e 368 //
369 // padrow index in array
370 //
c5bbaa2c 371 fRowPosIndex[0] = new UInt_t[fNRows[0]];
372 fRowPosIndex[1] = new UInt_t[fNRows[1]];
7a0ff78e 373 //
c5bbaa2c 374 for (UInt_t irow =0; irow<fNRows[0];irow++){
7a0ff78e 375 fNPads[0][irow] = roc.fNPads[0][irow];
376 fRowPosIndex[0][irow] = roc.fRowPosIndex[0][irow];
377 }
c5bbaa2c 378 for (UInt_t irow =0; irow<fNRows[1];irow++){
7a0ff78e 379 fNPads[1][irow] = roc.fNPads[1][irow];
380 fRowPosIndex[1][irow] = roc.fRowPosIndex[1][irow];
381 }
9bbf714d 382
383 for (UInt_t i=0;i<100;++i){
384 fPadRowLow[i]=roc.fPadRowLow[i];
385 fPadRowUp[i]=roc.fPadRowUp[i];
386 fNPadsLow[i]=roc.fNPadsLow[i];
387 fNPadsUp[i]=roc.fNPadsUp[i];
388 fYInner[i]=roc.fYInner[i];
389 fYOuter[i]=roc.fYOuter[i];
390 }
391
7a0ff78e 392}
179c6296 393//____________________________________________________________________________
394AliTPCROC & AliTPCROC::operator =(const AliTPCROC & roc)
395{
396 //
397 // assignment operator - dummy
398 //
399 fZLength = roc.fZLength;
400 return (*this);
401}
7a0ff78e 402//_____________________________________________________________________________
403AliTPCROC::~AliTPCROC()
404{
405 //
406 // AliTPCROC destructor
407 //
408 delete [] fNPads[0];
409 delete [] fNPads[1];
410 delete [] fRowPosIndex[0];
411 delete [] fRowPosIndex[1];
a411fffe 412 fgInstance = 0x0;
7a0ff78e 413
414}
415
38bc857e 416
417
418
419void AliTPCROC::GetPositionLocal(UInt_t sector, UInt_t row, UInt_t pad, Float_t *pos){
420 //
421 // get position of center of pad - ideal frame used
422 //
423 pos[2]=fZLength;
424 if (sector<36){
425 pos[0] = fPadRowLow[row];
b73ff567 426 pos[1] = fInnerPadPitchWidth*(Int_t(pad)+0.5-Int_t(fNPads[0][row])/2);
38bc857e 427 }else{
428 pos[0] = fPadRowUp[row];
b73ff567 429 pos[1] = fOuterPadPitchWidth*(Int_t(pad)+0.5-Int_t(fNPads[1][row])/2);
38bc857e 430 }
431 if ((sector%36)>=18){
432 pos[2] *= -1.;
433 pos[1] *= -1.;
434 }
435}
436
437
438void AliTPCROC::GetPositionGlobal(UInt_t sector, UInt_t row, UInt_t pad, Float_t *pos){
439 //
440 // get position of center of pad - ideal frame used
441 //
442 GetPositionLocal(sector,row,pad,pos);
443 Double_t alpha = TMath::DegToRad()*(10.+20.*(sector%18));
444 Float_t gx = pos[0]*TMath::Cos(alpha)-pos[1]*TMath::Sin(alpha);
445 Float_t gy = pos[1]*TMath::Cos(alpha)+pos[0]*TMath::Sin(alpha);
446 pos[0] = gx;
447 pos[1] = gy;
448}