Set max. pT to 1.e10.
[u/mrichter/AliRoot.git] / TPC / AliTPCParamSR.cxx
CommitLineData
cc80f89e 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$
de61d5d5 18Revision 1.5 2001/12/06 07:49:30 kowal2
19corrected number of pads calculation
20
73477b37 21Revision 1.4 2000/11/02 07:33:15 kowal2
22Improvements of the code.
23
c11cb93f 24Revision 1.3 2000/06/30 12:07:50 kowal2
25Updated from the TPC-PreRelease branch
26
73042f01 27Revision 1.2.4.2 2000/06/14 16:48:24 kowal2
28Parameter setting improved. Removed compiler warnings
29
30Revision 1.2.4.1 2000/06/09 07:55:39 kowal2
31
32Updated defaults
33
34Revision 1.2 2000/04/17 09:37:33 kowal2
35removed obsolete AliTPCDigitsDisplay.C
36
cc80f89e 37Revision 1.1.4.2 2000/04/10 11:36:13 kowal2
38
39New Detector parameters handling class
40
41*/
42
43///////////////////////////////////////////////////////////////////////
44// Manager and of geomety classes for set: TPC //
45// //
46// !sectors are numbered from 0 //
47// !pad rows are numbered from 0 //
48//
49// 27.7. - AliTPCPaaramSr object for TPC
50// TPC with straight pad rows
51// Origin: Marian Ivanov, Uni. of Bratislava, ivanov@fmph.uniba.sk //
52// //
53///////////////////////////////////////////////////////////////////////
54
55
56#include <iostream.h>
57#include <TMath.h>
58#include <TObject.h>
59#include <AliTPCParamSR.h>
73042f01 60#include "AliTPCPRF2D.h"
61#include "AliTPCRF1D.h"
de61d5d5 62#include "TH1.h"
cc80f89e 63
64
65ClassImp(AliTPCParamSR)
66const static Int_t kMaxRows=600;
67const static Float_t kEdgeSectorSpace = 2.5;
73042f01 68const static Float_t kFacSigmaPadRow=3.;
cc80f89e 69const static Float_t kFacSigmaPad=3.;
70const static Float_t kFacSigmaTime=3.;
71
72
73AliTPCParamSR::AliTPCParamSR()
74{
75 //
76 //constructor set the default parameters
77 fInnerPRF=0;
78 fOuterPRF=0;
79 fTimeRF = 0;
80 fFacSigmaPadRow = Float_t(kFacSigmaPadRow);
81 fFacSigmaPad = Float_t(kFacSigmaPad);
82 fFacSigmaTime = Float_t(kFacSigmaTime);
cc80f89e 83 SetDefault();
84 Update();
85}
86
87AliTPCParamSR::~AliTPCParamSR()
88{
89 //
90 //destructor destroy some dynmicaly alocated variables
91 if (fInnerPRF != 0) delete fInnerPRF;
92 if (fOuterPRF != 0) delete fOuterPRF;
93 if (fTimeRF != 0) delete fTimeRF;
94}
95
96void AliTPCParamSR::SetDefault()
97{
98 //set default TPC param
99 fbStatus = kFALSE;
100 AliTPCParam::SetDefault();
101}
102
103Int_t AliTPCParamSR::CalcResponse(Float_t* xyz, Int_t * index, Int_t row)
104{
105 //
106 //calculate bin response as function of the input position -x
107 //return number of valid response bin
108 //
109 //we suppose that coordinate is expressed in float digits
110 // it's mean coordinate system 8
111 //xyz[0] - float padrow xyz[1] is float pad (center pad is number 0) and xyz[2] is float time bin
112 if ( (fInnerPRF==0)||(fOuterPRF==0)||(fTimeRF==0) ){
113 Error("AliTPCParamSR", "response function was not adjusted");
114 return -1;
115 }
116
117 Float_t sfpadrow; // sigma of response function
118 Float_t sfpad; // sigma of
119 Float_t sftime= fFacSigmaTime*fTimeRF->GetSigma()/fZWidth; //3 sigma of time response
120 if (index[1]<fNInnerSector){
121 sfpadrow =fFacSigmaPadRow*fInnerPRF->GetSigmaY()/fInnerPadPitchLength;
122 sfpad =fFacSigmaPad*fInnerPRF->GetSigmaX()/fInnerPadPitchWidth;
123 }else{
124 sfpadrow =fFacSigmaPadRow*fOuterPRF->GetSigmaY()/fOuterPadPitchLength;
125 sfpad =fFacSigmaPad*fOuterPRF->GetSigmaX()/fOuterPadPitchWidth;
126 }
127
128 Int_t fpadrow = TMath::Max(TMath::Nint(index[2]+xyz[0]-sfpadrow),0); //"first" padrow
129 Int_t fpad = TMath::Nint(xyz[1]-sfpad); //first pad
130 Int_t ftime = TMath::Max(TMath::Nint(xyz[2]+GetZOffset()/GetZWidth()-sftime),0); // first time
131 Int_t lpadrow = TMath::Min(TMath::Nint(index[2]+xyz[0]+sfpadrow),fpadrow+19); //"last" padrow
132 lpadrow = TMath::Min(GetNRow(index[1])-1,lpadrow);
133 Int_t lpad = TMath::Min(TMath::Nint(xyz[1]+sfpad),fpad+19); //last pad
134 Int_t ltime = TMath::Min(TMath::Nint(xyz[2]+GetZOffset()/GetZWidth()+sftime),ftime+19); // last time
135 ltime = TMath::Min(ltime,GetMaxTBin()-1);
de61d5d5 136 //
137 Int_t npads = GetNPads(index[1],row);
138 if (fpad<-npads/2)
139 fpad = -npads/2;
140 if (lpad>npads/2)
141 lpad= npads/2;
142 if (ftime<0) ftime=0;
143 //
cc80f89e 144 if (row>=0) { //if we are interesting about given pad row
145 if (fpadrow<=row) fpadrow =row;
146 else
147 return 0;
148 if (lpadrow>=row) lpadrow = row;
149 else
150 return 0;
151 }
152
153
154 Float_t padres[20][20]; //I don't expect bigger number of bins
155 Float_t timeres[20];
156 Int_t cindex3=0;
157 Int_t cindex=0;
158 Float_t cweight = 0;
159 if (fpadrow>=0) {
160 //calculate padresponse function
161 Int_t padrow, pad;
162 for (padrow = fpadrow;padrow<=lpadrow;padrow++)
163 for (pad = fpad;pad<=lpad;pad++){
164 Float_t dy = (-xyz[0]+Float_t(index[2]-padrow));
165 Float_t dx = (-xyz[1]+Float_t(pad));
166 if (index[1]<fNInnerSector)
167 padres[padrow-fpadrow][pad-fpad]=fInnerPRF->GetPRF(dx*fInnerPadPitchWidth,dy*fInnerPadPitchLength);
168 else
169 padres[padrow-fpadrow][pad-fpad]=fOuterPRF->GetPRF(dx*fOuterPadPitchWidth,dy*fOuterPadPitchLength); }
170 //calculate time response function
171 Int_t time;
172 for (time = ftime;time<=ltime;time++)
173 timeres[time-ftime]= fTimeRF->GetRF((-xyz[2]+Float_t(time))*fZWidth);
174 //write over threshold values to stack
175 for (padrow = fpadrow;padrow<=lpadrow;padrow++)
176 for (pad = fpad;pad<=lpad;pad++)
177 for (time = ftime;time<=ltime;time++){
178 cweight = timeres[time-ftime]*padres[padrow-fpadrow][pad-fpad];
179 if (cweight>fResponseThreshold) {
180 fResponseBin[cindex3]=padrow;
181 fResponseBin[cindex3+1]=pad;
182 fResponseBin[cindex3+2]=time;
183 cindex3+=3;
184 fResponseWeight[cindex]=cweight;
185 cindex++;
186 }
187 }
188 }
189 fCurrentMax=cindex;
190 return fCurrentMax;
191}
192
193void AliTPCParamSR::TransformTo8(Float_t *xyz, Int_t *index) const
194{
195 //
196 // transformate point to digit coordinate
197 //
198 if (index[0]==0) Transform0to1(xyz,index);
199 if (index[0]==1) Transform1to2(xyz,index);
200 if (index[0]==2) Transform2to3(xyz,index);
201 if (index[0]==3) Transform3to4(xyz,index);
202 if (index[0]==4) Transform4to8(xyz,index);
203}
204
205void AliTPCParamSR::TransformTo2(Float_t *xyz, Int_t *index) const
206{
207 //
208 //transformate point to rotated coordinate
209 //
210 //we suppose that
211 if (index[0]==0) Transform0to1(xyz,index);
212 if (index[0]==1) Transform1to2(xyz,index);
213 if (index[0]==4) Transform4to3(xyz,index);
214 if (index[0]==8) { //if we are in digit coordinate system transform to global
215 Transform8to4(xyz,index);
216 Transform4to3(xyz,index);
217 }
218}
219
220void AliTPCParamSR::CRXYZtoXYZ(Float_t *xyz,
221 const Int_t &sector, const Int_t & padrow, Int_t option) const
222{
223 //transform relative coordinates to absolute
224 Bool_t rel = ( (option&2)!=0);
225 Int_t index[2]={sector,padrow};
226 if (rel==kTRUE) Transform4to3(xyz,index);//if the position is relative to pad row
227 Transform2to1(xyz,index);
228}
229
230void AliTPCParamSR::XYZtoCRXYZ(Float_t *xyz,
231 Int_t &sector, Int_t & padrow, Int_t option) const
232{
233 //transform global position to the position relative to the sector padrow
234 //if option=0 X calculate absolute calculate sector
235 //if option=1 X absolute use input sector
236 //if option=2 X relative to pad row calculate sector
237 //if option=3 X relative use input sector
238 //!!!!!!!!! WE start to calculate rows from row = 0
239 Int_t index[2];
240 Bool_t rel = ( (option&2)!=0);
241
242 //option 0 and 2 means that we don't have information about sector
243 if ((option&1)==0) Transform0to1(xyz,index); //we calculate sector number
244 else
245 index[0]=sector;
246 Transform1to2(xyz,index);
247 Transform2to3(xyz,index);
248 //if we store relative position calculate position relative to pad row
249 if (rel==kTRUE) Transform3to4(xyz,index);
250 sector = index[0];
251 padrow = index[1];
252}
253
254Float_t AliTPCParamSR::GetPrimaryLoss(Float_t *x, Int_t *index, Float_t *angle)
255{
256 //
257 //
258 Float_t padlength=GetPadPitchLength(index[1]);
259 Float_t a1=TMath::Sin(angle[0]);
260 a1*=a1;
261 Float_t a2=TMath::Sin(angle[1]);
262 a2*=a2;
263 Float_t length =padlength*TMath::Sqrt(1+a1+a2);
264 return length*fNPrimLoss;
265}
266
267Float_t AliTPCParamSR::GetTotalLoss(Float_t *x, Int_t *index, Float_t *angle)
268{
269 //
270 //
271 Float_t padlength=GetPadPitchLength(index[1]);
272 Float_t a1=TMath::Sin(angle[0]);
273 a1*=a1;
274 Float_t a2=TMath::Sin(angle[1]);
275 a2*=a2;
276 Float_t length =padlength*TMath::Sqrt(1+a1+a2);
277 return length*fNTotalLoss;
278
279}
280
281
282void AliTPCParamSR::GetClusterSize(Float_t *x, Int_t *index, Float_t *angle, Int_t mode, Float_t *sigma)
283{
284 //
285 //return cluster sigma2 (x,y) for particle at position x
286 // in this case x coordinata is in drift direction
287 //and y in pad row direction
288 //we suppose that input coordinate system is digit system
289
290 Float_t xx;
291 Float_t lx[3] = {x[0],x[1],x[2]};
292 Int_t li[3] = {index[0],index[1],index[2]};
293 TransformTo2(lx,li);
294 // Float_t sigmadiff;
295 sigma[0]=0;
296 sigma[1]=0;
297
298 xx = lx[2]; //calculate drift length in cm
299 if (xx>0) {
300 sigma[0]+= xx*GetDiffL()*GetDiffL();
301 sigma[1]+= xx*GetDiffT()*GetDiffT();
302 }
303
304
305 //sigma[0]=sigma[1]=0;
306 if (GetTimeRF()!=0) sigma[0]+=GetTimeRF()->GetSigma()*GetTimeRF()->GetSigma();
307 if ( (index[1]<fNInnerSector) &&(GetInnerPRF()!=0))
308 sigma[1]+=GetInnerPRF()->GetSigmaX()*GetInnerPRF()->GetSigmaX();
309 if ( (index[1]>=fNInnerSector) && (GetOuterPRF()!=0))
310 sigma[1]+=GetOuterPRF()->GetSigmaX()*GetOuterPRF()->GetSigmaX();
311
312
313 sigma[0]/= GetZWidth()*GetZWidth();
314 sigma[1]/=GetPadPitchWidth(index[0])*GetPadPitchWidth(index[0]);
315}
316
317
318
319
320void AliTPCParamSR::GetSpaceResolution(Float_t *x, Int_t *index, Float_t *angle,
321 Float_t amplitude, Int_t mode, Float_t *sigma)
322{
323 //
324 //
325 //
326
327}
328Float_t AliTPCParamSR::GetAmp(Float_t *x, Int_t *index, Float_t *angle)
329{
330 //
331 //
332 //
333 return 0;
334}
335
336Float_t * AliTPCParamSR::GetAnglesAccMomentum(Float_t *x, Int_t * index, Float_t* momentum, Float_t *angle)
337{
338 //
339 //calculate angle of track to padrow at given position
340 // for given magnetic field and momentum of the particle
341 //
342
343 TransformTo2(x,index);
344 AliDetectorParam::GetAnglesAccMomentum(x,index,momentum,angle);
345 Float_t addangle = TMath::ASin(x[1]/GetPadRowRadii(index[1],index[2]));
346 angle[1] +=addangle;
347 return angle;
348}
349
350
351Bool_t AliTPCParamSR::Update()
352{
353
354 //
355 // update some calculated parameter which must be updated after changing "base"
356 // parameters
357 // for example we can change size of pads and according this recalculate number
358 // of pad rows, number of of pads in given row ....
359 Int_t i;
360 if (AliTPCParam::Update()==kFALSE) return kFALSE;
361 fbStatus = kFALSE;
362
363 // adjust lower sectors pad row positions and pad numbers
364 fNRowLow = (Int_t(1.001+((fRInnerLastWire-fRInnerFirstWire)/fInnerWWPitch))
365 -2*fInnerDummyWire)/fNInnerWiresPerPad;
366 if ( kMaxRows<fNRowLow) fNRowUp = kMaxRows;
367 if (1>fNRowLow) return kFALSE;
368
369 //Float_t firstpad = fRInnerFirstWire+(fInnerDummyWire-0.5)*fInnerWWPitch
370 // +fInnerPadPitchLength/2.;
371 Float_t lastpad = fRInnerLastWire-(fInnerDummyWire-0.5)*fInnerWWPitch
372 -fInnerPadPitchLength/2.;
c11cb93f 373 Float_t firstpad = lastpad-Float_t(fNRowLow-1)*fInnerPadPitchLength;
cc80f89e 374 for (i = 0;i<fNRowLow;i++)
375 {
376 Float_t x = firstpad +fInnerPadPitchLength*(Float_t)i;
377 Float_t y = (x-0.5*fInnerPadPitchLength)*tan(fInnerAngle/2.)-fInnerWireMount-
378 fInnerPadPitchWidth/2.;
379 fPadRowLow[i] = x;
380 fNPadsLow[i] = 1+2*(Int_t)(y/fInnerPadPitchWidth) ;
381 }
382
383 // adjust upper sectors pad row positions and pad numbers
384 fNRowUp = (Int_t(1.001+((fROuterLastWire-fROuterFirstWire)/fOuterWWPitch))
385 -2*fOuterDummyWire)/fNOuterWiresPerPad;
386 if ( kMaxRows<fNRowUp) fNRowUp = kMaxRows;
387 if (1>fNRowUp) return kFALSE;
388 firstpad = fROuterFirstWire+(fOuterDummyWire-0.5)*fOuterWWPitch
389 +fOuterPadPitchLength/2.;
390
391 for (i = 0;i<fNRowUp;i++)
392 {
393 Float_t x = firstpad + fOuterPadPitchLength*(Float_t)i;
394 Float_t y = (x-0.5*fOuterPadPitchLength)*tan(fOuterAngle/2.)-fOuterWireMount-
73477b37 395 fOuterPadPitchWidth/2.;
cc80f89e 396 fPadRowUp[i] = x;
397 fNPadsUp[i] = 1+2*(Int_t)(y/fOuterPadPitchWidth) ;
398 }
399 fNtRows = fNInnerSector*fNRowLow+fNOuterSector*fNRowUp;
c11cb93f 400 fbStatus = kTRUE;
cc80f89e 401 return kTRUE;
402}
403
404
cc80f89e 405void AliTPCParamSR::Streamer(TBuffer &R__b)
406{
407 // Stream an object of class AliTPC.
408
409 if (R__b.IsReading()) {
410 Version_t R__v = R__b.ReadVersion(); if (R__v) { }
411 // TObject::Streamer(R__b);
412 AliTPCParam::Streamer(R__b);
413 // if (R__v < 2) return;
414 Update();
415 } else {
416 R__b.WriteVersion(AliTPCParamSR::IsA());
417 //TObject::Streamer(R__b);
418 AliTPCParam::Streamer(R__b);
419 }
420}
de61d5d5 421Int_t AliTPCParamSR::CalcResponseFast(Float_t* xyz, Int_t * index, Int_t row)
422{
423 //
424 //calculate bin response as function of the input position -x
425 //return number of valid response bin
426 //
427 //we suppose that coordinate is expressed in float digits
428 // it's mean coordinate system 8
429 //xyz[0] - float padrow xyz[1] is float pad (center pad is number 0) and xyz[2] is float time bin
430 if ( (fInnerPRF==0)||(fOuterPRF==0)||(fTimeRF==0) ){
431 Error("AliTPCParamSR", "response function was not adjusted");
432 return -1;
433 }
434
435 const Int_t padn = 500;
436 const Float_t fpadn = 500.;
437 const Int_t timen = 500;
438 const Float_t ftimen = 500.;
439 const Int_t padrn = 500;
440 const Float_t fpadrn = 500.;
441
442
cc80f89e 443
de61d5d5 444 static Float_t prfinner[2*padrn][5*padn]; //pad divided by 50
445 static Float_t prfouter[2*padrn][5*padn]; //prfouter division
446
447 static Float_t rftime[5*timen]; //time division
448 static Int_t blabla=0;
449 static Float_t zoffset=0;
450 static Float_t zwidth=0;
451 static Float_t zoffset2=0;
452 static TH1F * hdiff=0;
453 static TH1F * hdiff1=0;
454 static TH1F * hdiff2=0;
455
456 if (blabla==0) { //calculate Response function - only at the begginning
457 hdiff =new TH1F("prf_diff","prf_diff",10000,-1,1);
458 hdiff1 =new TH1F("no_repsonse1","no_response1",10000,-1,1);
459 hdiff2 =new TH1F("no_response2","no_response2",10000,-1,1);
460
461 blabla=1;
462 zoffset = GetZOffset();
463 zwidth = fZWidth;
464 zoffset2 = zoffset/zwidth;
465 for (Int_t i=0;i<5*timen;i++){
466 rftime[i] = fTimeRF->GetRF(((i-2.5*ftimen)/ftimen)*zwidth+zoffset);
467 }
468 for (Int_t i=0;i<5*padn;i++){
469 for (Int_t j=0;j<2*padrn;j++){
470 prfinner[j][i] =
471 fInnerPRF->GetPRF((i-2.5*fpadn)/fpadn
472 *fInnerPadPitchWidth,(j-fpadrn)/fpadrn*fInnerPadPitchLength);
473 prfouter[j][i] =
474 fOuterPRF->GetPRF((i-2.5*fpadn)/fpadn
475 *fOuterPadPitchWidth,(j-fpadrn)/fpadrn*fOuterPadPitchLength);
476 }
477 }
478 }
479 // calculate central padrow, pad, time
480 Int_t npads = GetNPads(index[1],index[2]);
481 Int_t cpadrow = index[2];
482 Int_t cpad = TMath::Nint(xyz[1]);
483 Int_t ctime = TMath::Nint(xyz[2]+zoffset2);
484 //calulate deviation
485 Float_t dpadrow = xyz[0];
486 Float_t dpad = xyz[1]-cpad;
487 Float_t dtime = xyz[2]+zoffset2-ctime;
488 Int_t cindex =0;
489 Int_t cindex3 =0;
490 Int_t maxt =GetMaxTBin();
491
492 Int_t fpadrow;
493 Int_t lpadrow;
494
495 if (row>=0) { //if we are interesting about given pad row
496 fpadrow = row-cpadrow;
497 lpadrow = row-cpadrow;
498 }else{
499 fpadrow = (index[2]>1) ? -1 :0;
500 lpadrow = (index[2]<GetNRow(index[1])-1) ? 1:0;
501 }
502 Int_t fpad = (cpad > -npads/2+1) ? -2: -npads/2-cpad;
503 Int_t lpad = (cpad < npads/2-1) ? 2: npads/2-cpad;
504 Int_t ftime = (ctime>1) ? -2: -ctime;
505 Int_t ltime = (ctime<maxt-2) ? 2: maxt-ctime-1;
506
507 Int_t apadrow= TMath::Nint((dpadrow-fpadrow)*fpadrn+fpadrn);
508 //Int_t apadrow= TMath::Nint((-dpadrow-fpadrow)*fpadrn+fpadrn);
509
510 for (Int_t ipadrow = fpadrow; ipadrow<=lpadrow;ipadrow++){
511 if ( (apadrow<0) || (apadrow>=2*padrn))
512 continue;
513 Int_t apad= TMath::Nint((dpad-fpad)*fpadn+2.5*fpadn);
514 for (Int_t ipad = fpad; ipad<=lpad;ipad++){
515 Float_t cweight;
516 if (index[1]<fNInnerSector)
517 cweight=prfinner[apadrow][apad];
518 else
519 cweight=prfouter[apadrow][apad];
520 // if (cweight<fResponseThreshold) continue;
521 Int_t atime = TMath::Nint((dtime-ftime)*ftimen+2.5*ftimen);
522 for (Int_t itime = ftime;itime<=ltime;itime++){
523 Float_t cweight2 = cweight*rftime[atime];
524 if (cweight2>fResponseThreshold) {
525 fResponseBin[cindex3++]=cpadrow+ipadrow;
526 fResponseBin[cindex3++]=cpad+ipad;
527 fResponseBin[cindex3++]=ctime+itime;
528 fResponseWeight[cindex++]=cweight2;
529
530 if (cweight2>100)
531 {
532 printf("Pici pici %d %f %d\n",ipad,dpad,apad);
533 }
534
535 }
536 atime-=timen;
537 }
538 apad-= padn;
539 }
540 apadrow-=padrn;
541 }
542 fCurrentMax=cindex;
543 return fCurrentMax;
544
545}
cc80f89e 546
547
548
c11cb93f 549
550
551
552