]> git.uio.no Git - u/mrichter/AliRoot.git/blob - TPC/AliTPCParam.cxx
Set Getters to be const and general fixed up and added some extra setters
[u/mrichter/AliRoot.git] / TPC / AliTPCParam.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 //  Manager and of geomety  classes for set: TPC                     //
20 //                                                                   //
21 //  !sectors are numbered from  0                                     //
22 //  !pad rows are numbered from 0                                     //
23 //  
24 //  12.6.   changed z relative 
25 //  Origin:  Marian Ivanov, Uni. of Bratislava, ivanov@fmph.uniba.sk // 
26 //                                                                   //  
27 ///////////////////////////////////////////////////////////////////////
28
29 //
30
31 #include <Riostream.h>
32 #include <TMath.h>
33 #include <TObject.h>
34 #include <TRandom.h>
35 #include <AliTPCParam.h>
36
37
38
39
40 ClassImp(AliTPCParam)
41
42
43 //___________________________________________
44 AliTPCParam::AliTPCParam()
45 {   
46   //
47   //constructor sets the default parameters
48   //
49
50   fResponseBin = 0;
51   fResponseWeight = 0;
52   fRotAngle = 0;
53   SetTitle("75x40_100x60_150x60");
54   SetDefault();  
55 }
56
57 AliTPCParam::~AliTPCParam()
58 {
59   //
60   //destructor deletes some dynamicaly alocated variables
61   //
62
63   if (fResponseBin!=0)    delete [] fResponseBin;
64   if (fResponseWeight!=0) delete [] fResponseWeight;
65   if (fRotAngle      !=0) delete [] fRotAngle;
66
67 }
68
69
70
71
72 Int_t  AliTPCParam::Transform0to1(Float_t *xyz, Int_t * index)  const
73 {
74   //
75   // calculates sector number (index[1], undefined on input)
76   // xyz intact
77   //
78
79   Float_t angle,x1;
80   Int_t sector;
81   Float_t r = TMath::Sqrt(xyz[0]*xyz[0]+xyz[1]*xyz[1]);
82   if ((xyz[0]==0)&&(xyz[1]==0)) angle = 0.;
83   else
84     {
85       angle =TMath::ASin(xyz[1]/r);
86       if   (xyz[0]<0)   angle=TMath::Pi()-angle;
87       if ( (xyz[0]>0) && (xyz[1]<0) ) angle=2*TMath::Pi()+angle;
88     }
89
90   sector=Int_t(TMath::Nint((angle-fInnerAngleShift)/fInnerAngle));      
91  
92   Float_t cos,sin;
93   AdjustCosSin(sector,cos,sin);
94   x1=xyz[0]*cos + xyz[1]*sin;
95
96   if (x1>fOuterRadiusLow)
97     {
98       sector=Int_t(TMath::Nint((angle-fOuterAngleShift)/fOuterAngle))+fNInnerSector;      
99       if (xyz[2]<0)     sector+=(fNOuterSector>>1);            
100     }
101     else   
102       if (xyz[2]<0) sector+=(fNInnerSector>>1);    
103   index[1]=sector; // calculated sector number
104   index[0]=1; // indicates system after transformation
105   return sector;
106 }
107
108 Bool_t  AliTPCParam::Transform(Float_t *xyz, Int_t *index, Int_t* oindex)
109 {
110   //transformation from input coodination system to output coordination system
111   switch (index[0]){
112   case 0:
113     break;
114   };
115
116   return kFALSE;
117
118 }
119
120 Int_t AliTPCParam::GetPadRow(Float_t *xyz, Int_t *index) const 
121 {
122   //
123   //calculates pad row of point xyz - transformation to system 8 (digit system)
124   //
125   Int_t system = index[0];
126   if (0==system) {
127     Transform0to1(xyz,index); 
128     system=1;
129   }
130   if (1==system) {
131     Transform1to2(xyz,index); 
132     system=2;
133   }
134     
135   if (fGeometryType==0){ //straight row    
136     if (2==system) {
137       Transform2to3(xyz,index);       
138       system=3;
139     } 
140     if (3==system) {
141       Transform3to4(xyz,index);
142       system=4; 
143     }
144     if (4==system) {
145       Transform4to8(xyz,index);
146       system=8;     
147     }
148     if (8==system) {
149       index[0]=8;
150       return index[2];
151     } 
152   }
153
154   if (fGeometryType==1){ //cylindrical geometry    
155     if (2==system) {
156       Transform2to5(xyz,index);       
157       system=5;
158     } 
159     if (5==system) {
160       Transform2to3(xyz,index);
161       system=6;
162     }
163     if (6==system) {
164       Transform3to4(xyz,index); 
165       system=7;
166     }
167     if (8==system) {
168       index[0]=8;
169       return index[2];
170     }
171   } 
172   index[0]=system;
173   return -1; //if no reasonable system     
174 }
175
176 void  AliTPCParam::SetSectorAngles(Float_t innerangle, Float_t innershift, Float_t outerangle,
177                         Float_t outershift)
178 {
179   //
180   // set opening angles  
181   const static  Float_t  kDegtoRad = 0.01745329251994;
182   fInnerAngle = innerangle;       //opening angle of Inner sector
183   fInnerAngleShift = innershift;  //shift of first inner sector center to the 0
184   fOuterAngle = outerangle;       //opening angle of outer sector
185   fOuterAngleShift = outershift;  //shift of first sector center to the 0  
186   fInnerAngle *=kDegtoRad;
187   fInnerAngleShift *=kDegtoRad;
188   fOuterAngle *=kDegtoRad;
189   fOuterAngleShift *=kDegtoRad;
190 }
191
192 Float_t  AliTPCParam::GetInnerAngle() const
193 {
194   //return angle 
195   return fInnerAngle;
196
197 }
198
199 Float_t  AliTPCParam::GetInnerAngleShift() const
200 {  
201   //return angle   
202   return fInnerAngleShift;  
203 }
204 Float_t  AliTPCParam::GetOuterAngle() const
205
206   //return angle 
207   return fOuterAngle;
208
209 Float_t  AliTPCParam::GetOuterAngleShift() const
210
211   //return angle 
212
213      return fOuterAngleShift;
214
215
216
217 Int_t AliTPCParam::GetIndex(Int_t sector, Int_t row) const
218 {
219   //
220   //give index of the given sector and pad row 
221   //no control if the sectors and rows  are reasonable !!!
222   //
223   if (sector<fNInnerSector) return sector*fNRowLow+row;
224   return (fNInnerSector*fNRowLow)+(sector-fNInnerSector)*fNRowUp+row;  
225 }
226
227 Bool_t   AliTPCParam::AdjustSectorRow(Int_t index, Int_t & sector, Int_t &row) const
228 {
229   //
230   //return sector and padrow for given index
231   //if index is reasonable returns true else return false
232   //
233   if ( (index<0) || (index>fNtRows))  return kFALSE;
234   Int_t outindex = fNInnerSector*fNRowLow;
235   if (index<outindex) {
236     sector = index/fNRowLow;
237     row    = index - sector*fNRowLow;
238     return kTRUE;
239   }
240   index-= outindex;
241   sector = index/fNRowUp;
242   row    = index - sector*fNRowUp;
243   sector += fNInnerSector;
244   return kTRUE;         
245
246
247 void AliTPCParam::SetDefault()
248 {
249   //
250   //set default parameters
251   //
252   //const static  Int_t kMaxRows=600; 
253   //
254   //sector default parameters
255   //
256   const static  Float_t kInnerRadiusLow = 82.97;
257   const static  Float_t kInnerRadiusUp  = 133.17;
258   const static  Float_t kOuterRadiusLow = 133.58;
259   const static  Float_t kOuterRadiusUp  = 247.78;
260   const static  Float_t kInnerAngle = 20; // 20 degrees
261   const static  Float_t kInnerAngleShift = 10;
262   const static  Float_t kOuterAngle = 20; //  20 degrees
263   const static  Float_t kOuterAngleShift = 10;
264   const static  Float_t kInnerFrameSpace = 1.5;
265   const static  Float_t kOuterFrameSpace = 1.5;
266   const static  Float_t kInnerWireMount = 1.370825926;
267   const static  Float_t kOuterWireMount = 1.370825926;
268   const static  Float_t kZLength =250.;
269   const static  Int_t   kGeometryType = 0; //straight rows 
270   const static Int_t kNRowLow = 63;
271   const static Int_t kNRowUp1 = 64;
272   const static Int_t kNRowUp2 = 32;
273   const static Int_t  kNRowUp = 96;
274   //
275   //wires default parameters
276   //
277   const static Int_t    kNInnerWiresPerPad = 3;
278   const static Int_t    kInnerDummyWire = 2;
279   const static Float_t  kInnerWWPitch = 0.25;
280   const static Float_t  kRInnerFirstWire = 84.445;
281   const static Float_t  kRInnerLastWire = 132.445;
282   const static Float_t  kInnerOffWire = 0.5;
283   const static Int_t    kNOuter1WiresPerPad = 4;
284   const static Int_t    kNOuter2WiresPerPad = 6;
285   const static Float_t  kOuterWWPitch = 0.25;  
286   const static Float_t  kROuterFirstWire = 134.305;
287   const static Float_t  kROuterLastWire = 247.055;
288   const static Int_t    kOuterDummyWire = 2;
289   const static Float_t  kOuterOffWire = 0.5;
290   //
291   //pad default parameters
292   // 
293   const static Float_t  kInnerPadPitchLength = 0.75;
294   const static Float_t  kInnerPadPitchWidth = 0.40;
295   const static Float_t  kInnerPadLength = 0.75;
296   const static Float_t  kInnerPadWidth = 0.40;
297   const static Float_t  kOuter1PadPitchLength = 1.0;
298   const static Float_t  kOuterPadPitchWidth = 0.6;
299   const static Float_t  kOuter1PadLength = 1.0;
300   const static Float_t  kOuterPadWidth = 0.6;
301   const static Float_t  kOuter2PadPitchLength = 1.5;
302   const static Float_t  kOuter2PadLength = 1.5;
303
304   const static Bool_t   kBMWPCReadout = kTRUE; //MWPC readout - another possibility GEM 
305   const static Int_t    kNCrossRows = 1; //number of rows to cross-talk
306   
307   //
308   //gas default parameters
309   //
310   const static  Float_t  kDiffT = 2.2e-2; 
311   const static  Float_t  kDiffL = 2.2e-2;
312   const static  Float_t  kGasGain = 2.e4;
313   const static  Float_t  kDriftV  =2.83e6;
314   const static  Float_t  kOmegaTau = 0.145;
315   const static  Float_t  kAttCoef = 250.;
316   const static  Float_t  kOxyCont = 5.e-6;
317   //
318   //electronic default parameters
319   //
320   const static  Float_t  kPadCoupling=0.5;
321   const static  Int_t    kZeroSup=2;
322   const static  Float_t  kNoise = 1000;                            
323   const static  Float_t  kChipGain = 12;
324   const static  Float_t  kChipNorm = 0.4;
325   const static  Float_t  kTSample = 2.e-7; 
326   const static  Float_t  kTFWHM   = 1.9e-7;  //fwhm of charge distribution
327   const static  Int_t    kMaxTBin =445;  
328   const static  Int_t    kADCSat  =1024;  
329   const static  Float_t  kADCDynRange =2000.;  
330   //
331   //
332   //
333   const static  Float_t kBField =0.2; 
334   const static  Float_t kNPrimLoss =10.9;
335   const static  Float_t kNTotalLoss =39.9;
336   // 
337   //response constants
338   //
339   const static Int_t     kNResponseMax=100;
340   const static Float_t   kResponseThreshold=0.01;     
341   fbStatus = kFALSE;
342   //
343   //set sector parameters
344   //
345   SetInnerRadiusLow(kInnerRadiusLow);
346   SetOuterRadiusLow(kOuterRadiusLow);
347   SetInnerRadiusUp(kInnerRadiusUp);
348   SetOuterRadiusUp(kOuterRadiusUp);
349   SetInnerFrameSpace(kInnerFrameSpace);
350   SetOuterFrameSpace(kOuterFrameSpace);
351   SetInnerWireMount(kInnerWireMount);
352   SetOuterWireMount(kOuterWireMount);
353   SetSectorAngles(kInnerAngle,kInnerAngleShift,kOuterAngle,kOuterAngleShift);
354   SetZLength(kZLength);
355   SetGeometryType(kGeometryType);
356   SetRowNLow(kNRowLow);
357   SetRowNUp1 (kNRowUp1);
358   SetRowNUp2(kNRowUp2);
359   SetRowNUp(kNRowUp);
360   //
361   //set wire parameters
362   //
363   SetInnerNWires(kNInnerWiresPerPad);
364   SetInnerDummyWire(kInnerDummyWire);
365   SetInnerOffWire(kInnerOffWire);
366   SetOuter1NWires(kNOuter1WiresPerPad);
367   SetOuter2NWire(kNOuter2WiresPerPad);
368   SetOuterDummyWire(kOuterDummyWire);
369   SetOuterOffWire(kOuterOffWire);
370   SetInnerWWPitch(kInnerWWPitch);
371   SetRInnerFirstWire(kRInnerFirstWire);
372   SetRInnerLastWire(kRInnerLastWire);
373   SetOuterWWPitch(kOuterWWPitch);
374   SetROuterFirstWire(kROuterFirstWire);
375   SetROuterLastWire(kROuterLastWire);  
376   //
377   //set pad parameter
378   //
379   SetInnerPadPitchLength(kInnerPadPitchLength);
380   SetInnerPadPitchWidth(kInnerPadPitchWidth);
381   SetInnerPadLength(kInnerPadLength);
382   SetInnerPadWidth(kInnerPadWidth);
383   SetOuter1PadPitchLength(kOuter1PadPitchLength); 
384   SetOuter2PadPitchLength(kOuter2PadPitchLength);
385   SetOuterPadPitchWidth(kOuterPadPitchWidth);
386   SetOuter1PadLength(kOuter1PadLength);
387   SetOuter2PadLength(kOuter2PadLength);
388   SetOuterPadWidth(kOuterPadWidth); 
389   SetMWPCReadout(kBMWPCReadout);
390   SetNCrossRows(kNCrossRows);
391   //
392   //set gas paremeters
393   //
394   SetDiffT(kDiffT);
395   SetDiffL(kDiffL);
396   SetGasGain(kGasGain);
397   SetDriftV(kDriftV);
398   SetOmegaTau(kOmegaTau);
399   SetAttCoef(kAttCoef);
400   SetOxyCont(kOxyCont);
401   //
402   //set electronivc parameters  
403   //
404   SetPadCoupling(kPadCoupling);
405   SetZeroSup(kZeroSup);
406   SetNoise(kNoise);
407   SetChipGain(kChipGain);
408   SetChipNorm(kChipNorm);   
409   SetTSample(kTSample);
410   SetTFWHM(kTFWHM);
411   SetMaxTBin(kMaxTBin);
412   SetADCSat(kADCSat);
413   SetADCDynRange(kADCDynRange);
414   //set magnetic field
415   SetBField(kBField);
416   SetNPrimLoss(kNPrimLoss);
417   SetNTotalLoss(kNTotalLoss);
418   //
419   //set response  parameters  
420   //
421   SetNResponseMax(kNResponseMax); 
422   SetResponseThreshold(static_cast<int>(kResponseThreshold));
423 }
424
425           
426 Bool_t AliTPCParam::Update()
427 {
428   //
429   // update some calculated parameter which must be updated after changing "base"
430   // parameters 
431   // for example we can change size of pads and according this recalculate number
432   // of pad rows, number of of pads in given row ....
433   //
434   const Float_t kQel = 1.602e-19; // elementary charge
435   fbStatus = kFALSE;
436
437   Int_t i,j;  //loop variables because HP 
438   //-----------------Sector section------------------------------------------
439   //calclulate number of sectors
440   fNInnerSector = Int_t(4*TMath::Pi()/fInnerAngle+0.2); 
441        // number of inner sectors - factor 0.2 to don't be influnced by inprecision
442   if (fNInnerSector%2) return kFALSE;
443   fNOuterSector = Int_t(4*TMath::Pi()/fOuterAngle+0.2); 
444   if (fNOuterSector%2) return kFALSE;
445   fNSector  = fNInnerSector+fNOuterSector;
446
447   if (fRotAngle!=0) delete [] fRotAngle;
448   fRotAngle = new Float_t[4*fNSector];
449   //calculate sin and cosine of rotations angle     
450   //sectors angles numbering from 0
451
452   j=fNInnerSector*2;
453   Float_t angle = fInnerAngleShift; 
454   for (i=0; j<fNInnerSector*4; i+=4, j+=4 , angle +=fInnerAngle){
455     fRotAngle[i]=TMath::Cos(angle);
456     fRotAngle[i+1]=TMath::Sin(angle);
457     fRotAngle[j] =  fRotAngle[i];
458     fRotAngle[j+1] =  fRotAngle[i+1];
459     fRotAngle[i+2] =angle;
460     fRotAngle[j+2] =angle;    
461   }
462   angle = fOuterAngleShift; 
463   j=(fNInnerSector+fNOuterSector/2)*4;
464   for (i=fNInnerSector*4; j<fNSector*4; i+=4,j+=4, angle +=fOuterAngle){
465     fRotAngle[i]=TMath::Cos(angle);
466     fRotAngle[i+1]=TMath::Sin(angle);
467     fRotAngle[j] =  fRotAngle[i];
468     fRotAngle[j+1] =  fRotAngle[i+1];
469     fRotAngle[i+2] =angle;
470     fRotAngle[j+2] =angle;    
471   }
472   fZWidth = fTSample*fDriftV;  
473   fTotalNormFac = fPadCoupling*fChipNorm*kQel*1.e15*fChipGain*fADCSat/fADCDynRange;
474   fNoiseNormFac = kQel*1.e15*fChipGain*fADCSat/fADCDynRange;
475   //wire section 
476   /*  Int_t nwire;
477   Float_t wspace; //available space for wire
478   Float_t dummyspace; //dummyspace for wire
479  
480   wspace =fInnerRadiusUp-fInnerRadiusLow-2*fInnerOffWire;
481   nwire = Int_t(wspace/fInnerWWPitch);
482   wspace = Float_t(nwire)*fInnerWWPitch;
483   dummyspace =(fInnerRadiusUp-fInnerRadiusLow-wspace)/2.;  
484   wspace =fOuterRadiusUp-fOuterRadiusLow-2*fOuterOffWire;
485   nwire = Int_t(wspace/fOuterWWPitch);
486   wspace = Float_t(nwire)*fOuterWWPitch;
487   dummyspace =(fOuterRadiusUp-fOuterRadiusLow-wspace)/2.; 
488   fROuterFirstWire = fOuterRadiusLow+dummyspace;
489   fROuterLastWire = fROuterFirstWire+fOuterWWPitch*(Float_t)(nwire);
490   */
491   
492   //
493   //response data
494   //
495   if (fResponseBin==0) delete [] fResponseBin;
496   if (fResponseWeight==0) delete [] fResponseBin;
497   fResponseBin    = new Int_t[3*fNResponseMax];
498   fResponseWeight = new Float_t[fNResponseMax];
499   
500   fbStatus = kTRUE;
501   return kTRUE;
502 }
503
504
505
506 Bool_t AliTPCParam::GetStatus()
507 {
508   //get information about object consistency
509   return fbStatus;
510 }
511
512 Int_t AliTPCParam::GetNRowLow() const
513 {
514   //get the number of pad rows in low sector
515   return fNRowLow;
516 }
517 Int_t AliTPCParam::GetNRowUp() const
518 {
519   //get the number of pad rows in up sector
520   return fNRowUp;
521 }
522 Int_t AliTPCParam::GetNRowUp1() const
523 {
524   //get the number of pad rows in up1 sector
525   return fNRowUp1;
526 }
527 Int_t AliTPCParam::GetNRowUp2() const
528 {
529   //get the number of pad rows in up2 sector
530   return fNRowUp2;
531 }
532 Float_t AliTPCParam::GetPadRowRadiiLow(Int_t irow) const
533 {
534   //get the pad row (irow) radii
535   if ( !(irow<0) && (irow<fNRowLow) ) 
536     return  fPadRowLow[irow];
537   else
538     return 0;
539 }
540
541 Float_t AliTPCParam::GetPadRowRadiiUp(Int_t irow) const
542 {
543   //get the pad row (irow) radii
544  if ( !(irow<0) && (irow<fNRowUp) ) 
545     return  fPadRowUp[irow];
546   else
547     return 0;
548 }
549
550 Int_t AliTPCParam::GetNPadsLow(Int_t irow) const
551 {
552   //get the number of pads in row irow
553   if ( !(irow<0) && (irow<fNRowLow) ) 
554     return  fNPadsLow[irow];
555   else
556     return 0;
557 }
558
559
560 Int_t AliTPCParam::GetNPadsUp(Int_t irow) const
561 {
562   //get the number of pads in row irow
563   if ( !(irow<0) && (irow<fNRowUp) ) 
564     return  fNPadsUp[irow];
565   else
566     return 0;
567 }
568 Float_t AliTPCParam::GetYInner(Int_t irow) const
569 {
570   return fYInner[irow];
571 }
572
573
574 Float_t AliTPCParam::GetYOuter(Int_t irow) const
575 {
576   return fYOuter[irow];
577 }
578
579
580
581
582
583
584
585