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