1 ///////////////////////////////////////////////////////////////////////
2 // Manager and of geomety classes for set: TPC //
4 // !sectors are numbered from 0 //
5 // !pad rows are numbered from 0 //
7 // 12.6. changed z relative
8 // Origin: Marian Ivanov, Uni. of Bratislava, ivanov@fmph.uniba.sk //
10 ///////////////////////////////////////////////////////////////////////
16 #include "AliTPCSecGeo.h"
17 #include <AliTPCParam.h>
22 const static Int_t kMaxRows=600;
26 const static Int_t kMaxTBin =512;
29 const static Float_t kInnerRadiusLow = 89.45;
30 const static Float_t kOuterRadiusLow = 143.725;
31 const static Float_t kInnerRadiusUp = 134.55;
32 const static Float_t kOuterRadiusUp = 248.275;
34 const static Float_t kInnerAngle = 0.523598775; // 30 degrees
35 const static Float_t kInnerAngleShift = 0;
36 const static Float_t kOuterAngle = 0.261799387; // 15 degrees
37 const static Float_t kOuterAngleShift = 0;
39 const static Float_t kPadPitchLength = 2.05;
40 const static Float_t kPadPitchWidth = 0.35;
41 const static Float_t kPadLength = 2.05;
42 const static Float_t kPadWidth = 0.35;
44 // Number of wires per pad and wire-wire pitch
45 const static Int_t knWires = 5;
46 const static Float_t kDiffT = 2.2e-2;
47 const static Float_t kDiffL = 2.2e-2;
48 const static Float_t kDriftV =2.85e6;
50 const static Float_t kOmegaTau = 0.145;
51 const static Float_t kAttCoef = 250.;
52 const static Float_t kOxyCont = 5.e-6;
55 const static Float_t kChipGain = 24;
56 const static Float_t kGasGain = 1e4;
57 const static Float_t kTSample = 2.e-7; //TSAMPLE
58 const static Float_t kTFWHM = 2.5e-7; //fwhm of charge distribution
60 const static Float_t kNoise = 500; //default noise = 1000 el
61 const static Int_t kZeroSup=5;
62 const static Float_t kPadCoupling=0.5;
64 const static Float_t kEdgeSectorSpace = 1.15;
65 const static Float_t kDegtoRad = 0.01745329251994;
66 const static Float_t kRadtoDeg = 57.29577951309;
71 //___________________________________________
72 AliTPCParam::AliTPCParam()
74 //constructor set the default parameters
79 void AliTPCParam::SetSectorAngles(Float_t innerangle, Float_t innershift, Float_t outerangle,
80 Float_t outershift, Bool_t inDegree)
84 fInnerAngle = innerangle; //opening angle of Inner sector
85 fInnerAngleShift = innershift; //shift of first inner sector center to the 0
86 fOuterAngle = outerangle; //opening angle of outer sector
87 fOuterAngleShift = outershift; //shift of first sector center to the 0
89 fInnerAngle *=kDegtoRad;
90 fInnerAngleShift *=kDegtoRad;
91 fOuterAngle *=kDegtoRad;
92 fOuterAngleShift *=kDegtoRad;
97 void AliTPCParam::CRXYZtoXYZ(Float_t *xyz,
98 const Int_t §or, const Int_t & padrow, Int_t option) const
100 //transform relative coordinates to absolute
101 Bool_t rel = ( (option&2)!=0);
103 row_first = (sector<=fNInnerSector) ? fPadRowLow[0] : fPadRowUp[0];
104 if (rel==kTRUE) //if the position is relative to pad row
107 xyz[0]+=(Int_t) padrow*fPadPitchLength;
111 if (sector<fNInnerSector) {
112 if ( sector>=(fNInnerSector>>1)) xyz[2]*=-1.;
114 if ( (sector-fNInnerSector) >= (fNOuterSector>>1) ) xyz[2]*=-1;
120 AdjustAngles(sector,cos,sin);
121 xyz[0]= x1*cos - y1*sin;
122 xyz[1]= x1*sin + y1*cos;
125 void AliTPCParam::XYZtoCRXYZ(Float_t *xyz,
126 Int_t §or, Int_t & padrow, Int_t option)
128 //transform global position to the position relative to the sector padrow
129 //if option=0 X calculate absolute calculate sector
130 //if option=1 X absolute use input sector
131 //if option=2 X relative to pad row calculate sector
132 //if option=3 X relative use input sector
133 //!!!!!!!!! WE start to calculate rows from row = 0
135 Bool_t rel = ( (option&2)!=0);
136 //option 0 and 2 means that we don't have information about sector
137 //we calculate sector
140 Float_t r = TMath::Sqrt(xyz[0]*xyz[0]+xyz[1]*xyz[1]);
141 if ((xyz[0]==0)&&(xyz[1]==0)) angle = 0;
144 angle =TMath::ASin(xyz[1]/r);
145 if (xyz[0]<0) angle=TMath::Pi()-angle;
146 if ( (xyz[0]>0) && (xyz[1]<0) ) angle=2*TMath::Pi()+angle;
148 //transform global position to the position relative to the sector padrow
149 //fistly calculate xyz[0] radius for lover sector
150 //bacause in this moment we dont know in which sector we are
151 sector=Int_t((angle-fInnerAngleShift)/fInnerAngle);
154 //firstly we suppose that we are in inner sector
156 AdjustAngles(sector,cos,sin);
158 x1=xyz[0]*cos + xyz[1]*sin;
159 y1=-xyz[0]*sin + xyz[1]*cos;
160 if (x1>fOuterRadiusLow)
162 sector=Int_t((angle-fOuterAngleShift)/fOuterAngle)+fNInnerSector;
163 AdjustAngles(sector,cos,sin);
164 x1=xyz[0]*cos + xyz[1]*sin;
165 y1=-xyz[0]*sin + xyz[1]*cos;
166 if (xyz[2]<0) sector+=(fNOuterSector>>1);
169 if (xyz[2]<0) sector+=(fNInnerSector>>1);
171 if (x1<fOuterRadiusLow)
172 padrow =Int_t( (x1-fPadRowLow[0])/fPadPitchLength+0.5);
174 padrow = Int_t( (x1-fPadRowUp[0])/fPadPitchLength+0.5);
176 if (x1<fOuterRadiusLow) x1-=padrow*fPadPitchLength+fPadRowLow[0];
178 x1-=padrow*fPadPitchLength+fPadRowUp[0];
181 xyz[2]=z_end-TMath::Abs(xyz[2]);
182 } //endif we don't have information about sector
184 //if we have information about sector
186 AdjustAngles(sector,cos,sin);
189 //rotate to given sector
190 x1=xyz[0]*cos + xyz[1]*sin;
191 y1=-xyz[0]*sin + xyz[1]*cos;
192 //calculate pad row number
193 if (sector<fNInnerSector) {
194 padrow =Int_t( (x1-fPadRowLow[0])/fPadPitchLength+1.5)-1;
197 padrow =Int_t( (x1-fPadRowUp[0])/fPadPitchLength+1.5)-1;
199 //if we store relative position calculate position relative to pad row
201 if (sector<fNInnerSector)
202 x1-=padrow*fPadPitchLength+fPadRowLow[0];
204 x1-=padrow*fPadPitchLength+fPadRowUp[0];
208 xyz[2]=z_end-TMath::Abs(xyz[2]);
212 void AliTPCParam::CRYZtoTimePad(const Float_t &y, const Float_t &z,
213 Float_t &time, Float_t &pad,
214 Int_t sector, Int_t padrow)
216 //transform position in cm to position in time slices and pads
217 Float_t nofpads = GetNPads(sector,padrow);
218 Float_t padc=(nofpads+1)/2; // this is the "central" pad for a row
219 pad = y/(fPadPitchWidth)+padc;
222 void AliTPCParam::CRTimePadtoYZ(Float_t &y, Float_t &z,
223 const Float_t &time, const Float_t &pad,
224 Int_t sector, Int_t padrow)
226 //transform position in time slices and pads to cm
227 Float_t nofpads = GetNPads(sector,padrow);
228 Float_t padc=(nofpads+1)/2; // this is the "central" pad for a row
229 y=(pad-padc)*fPadPitchWidth;
233 Int_t AliTPCParam::GetWire(Float_t & x)
236 //return wire number of pad for electron at relative position x
237 //to the center of the pad
238 //and adjust x to the wire position
239 //we suppose that if the wire number is even the center wire
240 //is at center of pad
242 Float_t xrel= x/fWWPitch;
243 if ((fnWires>>1)==0) xrel+=1;
245 Int_t nw=Int_t(xrel);
249 if ((fnWires>>1)==0) x-=fWWPitch/2.;
253 Int_t AliTPCParam::GetIndex(Int_t sector, Int_t row)
256 //give index of the given sector and pad row
257 //no control if the sectors and rows are reasonable !!!
259 if (sector<fNInnerSector) return sector*fnRowLow+row;
260 return (fNInnerSector*fnRowLow)+(sector-fNInnerSector)*fnRowUp+row;
263 Bool_t AliTPCParam::AdjustSectorRow(Int_t index, Int_t & sector, Int_t &row)
266 //return sector and padrow for given index
267 //if index is reasonable return true else return false
269 if ( (index<0) || (index>fNtRows)) return kFALSE;
270 Int_t outindex = fNInnerSector*fnRowLow;
271 if (index<outindex) {
272 sector = index/fnRowLow;
273 row = index - sector*fnRowLow;
277 sector = index/fnRowUp;
278 row = index - sector*fnRowUp;
284 Int_t AliTPCParam::GetPadRow(Int_t isec, Float_t &x)
287 //return the pad row for given x (transformed)
289 Float_t row_first=GetPadRowRadii(isec,0);
290 Int_t row = Int_t(( x-row_first+1.5*fPadPitchLength)/fPadPitchLength)-1;
291 //Int_t will make from -0.5 0 but we want to make -1 so we add and after substract 1
292 x -=row* fPadPitchLength+row_first;
293 if ( (row<0)||(row>=GetNRow(isec))) return -1;
297 void AliTPCParam::SetDefault()
299 //set default TPC param
301 //set sector parameters
302 fInnerRadiusLow = kInnerRadiusLow;
303 fOuterRadiusLow = kOuterRadiusLow;
304 fInnerRadiusUp = kInnerRadiusUp;
305 fOuterRadiusUp = kOuterRadiusUp;
306 SetSectorAngles(kInnerAngle,kInnerAngleShift, kOuterAngle, kOuterAngleShift);
307 // set default pad size and shape
308 fPadPitchLength = kPadPitchLength;
309 fPadPitchWidth = kPadPitchWidth;
310 fPadLength = kPadLength;
311 fPadWidth = kPadWidth;
314 fWWPitch= kPadPitchLength/Float_t(knWires);
317 fOmegaTau = kOmegaTau;
321 fChipGain = kChipGain;
324 fPadCoupling= kPadCoupling;
326 fTSigma =kTFWHM/2.35;
332 void AliTPCParam::AdjustAngles(Int_t isec, Float_t &cos, Float_t &sin) const
335 //set cosinus and sinus of rotation angles for sector isec
337 cos=fRotAngle[isec*2];
338 sin=fRotAngle[isec*2+1];
341 Bool_t AliTPCParam::Update()
344 // update some calculated parameter which must be updated after changing "base"
346 // for example we can change size of pads and according this recalculate number
347 // of pad rows, number of of pads in given row ....
351 Int_t i,j; //loop variables because HP
352 //-----------------Sector section------------------------------------------
353 //calclulate number of sectors
354 fNInnerSector = Int_t(4*TMath::Pi()/fInnerAngle+0.2); // number of inner sectors - factor 0.2 to don't
355 //be influnced by inprecision
356 if (fNInnerSector%2) return kFALSE;
357 fNOuterSector = Int_t(4*TMath::Pi()/fOuterAngle+0.2);
358 if (fNOuterSector%2) return kFALSE;
359 fNSector = fNInnerSector+fNOuterSector;
360 //calculate sin and cosine of rotations angle
361 //sectors angles numbering from 0
363 Float_t angle = fInnerAngleShift;
364 for (i=0; i<fNInnerSector*2; i+=2, j+=2 , angle +=fInnerAngle){
365 fRotAngle[i]=TMath::Cos(angle);
366 fRotAngle[i+1]=TMath::Sin(angle);
367 fRotAngle[j] = fRotAngle[i];
368 fRotAngle[j+1] = fRotAngle[i+1];
370 angle = fOuterAngleShift;
371 j=(fNInnerSector+fNOuterSector/2)*2;
372 for (i=fNInnerSector*2; i<fNSector*2; i+=2,j+=2, angle +=fOuterAngle){
373 fRotAngle[i]=TMath::Cos(angle);
374 fRotAngle[i+1]=TMath::Sin(angle);
375 fRotAngle[j] = fRotAngle[i];
376 fRotAngle[j+1] = fRotAngle[i+1];
380 //----------------PAD section------------------------------------
381 //recalculate and check some geometric parameters
382 if (0.001>fPadPitchLength){
383 cout<<"ERROR !!! Small pad pitch length \n"<<flush;
386 if (fPadPitchLength<fPadLength) {
387 cout<<"ERROR !!! Pitch length smaller then length of pad \n"<<flush;
390 fnRowUp = Int_t((0.01+fOuterRadiusUp-fOuterRadiusLow)/fPadPitchLength)+1;
391 if ( kMaxRows<fnRowUp) fnRowUp = kMaxRows;
392 if (1>fnRowUp) return kFALSE;
394 fnRowLow = Int_t((0.01+fInnerRadiusUp-fInnerRadiusLow)/fPadPitchLength)+1;
395 if ( kMaxRows<fnRowLow) fnRowUp = kMaxRows;
396 if (1>fnRowLow) return kFALSE;
397 // adjust upper sectors pad row positions and pad numbers
398 for (i = 0;i<fnRowUp;i++)
400 Float_t x = fOuterRadiusLow +fPadPitchLength*(Float_t)i;
401 //Float_t y = x*2*tan(alpha_up/2)-kEdgeSectorSpace;
402 Float_t y = (x-0.5*fPadPitchLength)*tan(fOuterAngle/2)-kEdgeSectorSpace
405 fnPadsUp[i] = 1+2*(Int_t)(y/fPadPitchWidth) ;
408 // adjust lower sectors pad row positions and pad numbers
409 for (i = 0;i<fnRowLow;i++)
411 Float_t x = fInnerRadiusLow +fPadPitchLength*(Float_t)i;
412 // Float_t y = x*2*tan(alpha_low/2)-kEdgeSectorSpace;
413 Float_t y = (x-0.5*fPadPitchLength)*tan(fInnerAngle/2)-kEdgeSectorSpace
416 fnPadsLow[i] = 1+2*(Int_t)(y/fPadPitchWidth) ;
420 //that variable are not writen to the file there are calculated
422 fWWPitch= fPadPitchLength/Float_t(fnWires);
423 fZWidth = fTSample*fDriftV;
424 fNtRows = fNInnerSector*fnRowLow+fNOuterSector*fnRowUp;
431 Bool_t AliTPCParam::GetStatus()
433 //get information about object consistency
437 Int_t AliTPCParam::GetNRowLow() const
439 //get the number of pad rows in low sector
442 Int_t AliTPCParam::GetNRowUp() const
444 //get the number of pad rows in up sector
447 Float_t AliTPCParam::GetPadRowRadiiLow(Int_t irow) const
449 //get the pad row (irow) radii
450 if ( !(irow<0) && (irow<fnRowLow) )
451 return fPadRowLow[irow];
456 Float_t AliTPCParam::GetPadRowRadiiUp(Int_t irow) const
458 //get the pad row (irow) radii
459 if ( !(irow<0) && (irow<fnRowUp) )
460 return fPadRowUp[irow];
465 Int_t AliTPCParam::GetNPadsLow(Int_t irow) const
467 //get the number of pads in row irow
468 if ( !(irow<0) && (irow<fnRowLow) )
469 return fnPadsLow[irow];
475 Int_t AliTPCParam::GetNPadsUp(Int_t irow) const
477 //get the number of pads in row irow
478 if ( !(irow<0) && (irow<fnRowUp) )
479 return fnPadsUp[irow];
485 void AliTPCParam::Streamer(TBuffer &R__b)
487 // Stream an object of class AliTPC.
489 if (R__b.IsReading()) {
490 Version_t R__v = R__b.ReadVersion(); if (R__v) { }
491 TObject::Streamer(R__b);
492 if (R__v < 2) return;
494 R__b >> fInnerRadiusLow;
495 R__b >> fInnerRadiusUp;
496 R__b >> fOuterRadiusLow;
497 R__b >> fOuterRadiusUp;
499 R__b >> fInnerAngleShift;
501 R__b >> fOuterAngleShift;
503 R__b >> fPadPitchLength;
504 R__b >> fPadPitchWidth;
528 R__b.WriteVersion(AliTPCParam::IsA());
529 TObject::Streamer(R__b);
530 R__b << fInnerRadiusLow;
531 R__b << fInnerRadiusUp;
532 R__b << fOuterRadiusLow;
533 R__b << fOuterRadiusUp;
535 R__b << fInnerAngleShift;
537 R__b << fOuterAngleShift;
539 R__b << fPadPitchLength;
540 R__b << fPadPitchWidth;