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