1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
18 Revision 1.6 2002/02/25 11:02:56 kowal2
19 Changes towards speeding up the code. Thanks to Marian Ivanov.
21 Revision 1.5 2001/12/06 07:49:30 kowal2
22 corrected number of pads calculation
24 Revision 1.4 2000/11/02 07:33:15 kowal2
25 Improvements of the code.
27 Revision 1.3 2000/06/30 12:07:50 kowal2
28 Updated from the TPC-PreRelease branch
30 Revision 1.2.4.2 2000/06/14 16:48:24 kowal2
31 Parameter setting improved. Removed compiler warnings
33 Revision 1.2.4.1 2000/06/09 07:55:39 kowal2
37 Revision 1.2 2000/04/17 09:37:33 kowal2
38 removed obsolete AliTPCDigitsDisplay.C
40 Revision 1.1.4.2 2000/04/10 11:36:13 kowal2
42 New Detector parameters handling class
46 ///////////////////////////////////////////////////////////////////////
47 // Manager and of geomety classes for set: TPC //
49 // !sectors are numbered from 0 //
50 // !pad rows are numbered from 0 //
52 // 27.7. - AliTPCPaaramSr object for TPC
53 // TPC with straight pad rows
54 // Origin: Marian Ivanov, Uni. of Bratislava, ivanov@fmph.uniba.sk //
56 ///////////////////////////////////////////////////////////////////////
62 #include <AliTPCParamSR.h>
63 #include "AliTPCPRF2D.h"
64 #include "AliTPCRF1D.h"
68 ClassImp(AliTPCParamSR)
69 const static Int_t kMaxRows=600;
70 const static Float_t kEdgeSectorSpace = 2.5;
71 const static Float_t kFacSigmaPadRow=3.;
72 const static Float_t kFacSigmaPad=3.;
73 const static Float_t kFacSigmaTime=3.;
76 AliTPCParamSR::AliTPCParamSR()
79 //constructor set the default parameters
84 fFacSigmaPadRow = Float_t(kFacSigmaPadRow);
85 fFacSigmaPad = Float_t(kFacSigmaPad);
86 fFacSigmaTime = Float_t(kFacSigmaTime);
91 AliTPCParamSR::~AliTPCParamSR()
94 //destructor destroy some dynmicaly alocated variables
95 if (fInnerPRF != 0) delete fInnerPRF;
96 if (fOuter1PRF != 0) delete fOuter1PRF;
97 if (fOuter2PRF != 0) delete fOuter2PRF;
98 if (fTimeRF != 0) delete fTimeRF;
101 void AliTPCParamSR::SetDefault()
103 //set default TPC param
105 AliTPCParam::SetDefault();
108 Int_t AliTPCParamSR::CalcResponse(Float_t* xyz, Int_t * index, Int_t row)
111 //calculate bin response as function of the input position -x
112 //return number of valid response bin
114 //we suppose that coordinate is expressed in float digits
115 // it's mean coordinate system 8
116 //xyz[0] - float padrow xyz[1] is float pad (center pad is number 0) and xyz[2] is float time bin
117 if ( (fInnerPRF==0)||(fOuter1PRF==0)||(fOuter2PRF==0) ||(fTimeRF==0) ){
118 Error("AliTPCParamSR", "response function was not adjusted");
122 Float_t sfpadrow; // sigma of response function
123 Float_t sfpad; // sigma of
124 Float_t sftime= fFacSigmaTime*fTimeRF->GetSigma()/fZWidth; //3 sigma of time response
125 if (index[1]<fNInnerSector){
126 sfpadrow =fFacSigmaPadRow*fInnerPRF->GetSigmaY()/fInnerPadPitchLength;
127 sfpad =fFacSigmaPad*fInnerPRF->GetSigmaX()/fInnerPadPitchWidth;
131 sfpadrow =fFacSigmaPadRow*fOuter1PRF->GetSigmaY()/fOuter1PadPitchLength;
132 sfpad =fFacSigmaPad*fOuter1PRF->GetSigmaX()/fOuterPadPitchWidth;}
134 sfpadrow =fFacSigmaPadRow*fOuter2PRF->GetSigmaY()/fOuter2PadPitchLength;
135 sfpad =fFacSigmaPad*fOuter2PRF->GetSigmaX()/fOuterPadPitchWidth;
139 Int_t fpadrow = TMath::Max(TMath::Nint(index[2]+xyz[0]-sfpadrow),0); //"first" padrow
140 Int_t fpad = TMath::Nint(xyz[1]-sfpad); //first pad
141 Int_t ftime = TMath::Max(TMath::Nint(xyz[2]+GetZOffset()/GetZWidth()-sftime),0); // first time
142 Int_t lpadrow = TMath::Min(TMath::Nint(index[2]+xyz[0]+sfpadrow),fpadrow+19); //"last" padrow
143 lpadrow = TMath::Min(GetNRow(index[1])-1,lpadrow);
144 Int_t lpad = TMath::Min(TMath::Nint(xyz[1]+sfpad),fpad+19); //last pad
145 Int_t ltime = TMath::Min(TMath::Nint(xyz[2]+GetZOffset()/GetZWidth()+sftime),ftime+19); // last time
146 ltime = TMath::Min(ltime,GetMaxTBin()-1);
148 Int_t npads = GetNPads(index[1],row);
153 if (ftime<0) ftime=0;
155 if (row>=0) { //if we are interesting about given pad row
156 if (fpadrow<=row) fpadrow =row;
159 if (lpadrow>=row) lpadrow = row;
165 Float_t padres[20][20]; //I don't expect bigger number of bins
171 //calculate padresponse function
173 for (padrow = fpadrow;padrow<=lpadrow;padrow++)
174 for (pad = fpad;pad<=lpad;pad++){
175 Float_t dy = (xyz[0]+Float_t(index[2]-padrow));
176 Float_t dx = (xyz[1]+Float_t(pad));
177 if (index[1]<fNInnerSector)
178 padres[padrow-fpadrow][pad-fpad]=fInnerPRF->GetPRF(dx*fInnerPadPitchWidth,dy*fInnerPadPitchLength);
181 padres[padrow-fpadrow][pad-fpad]=fOuter1PRF->GetPRF(dx*fOuterPadPitchWidth,dy*fOuter1PadPitchLength);}
183 padres[padrow-fpadrow][pad-fpad]=fOuter2PRF->GetPRF(dx*fOuterPadPitchWidth,dy*fOuter2PadPitchLength);}}}
184 //calculate time response function
186 for (time = ftime;time<=ltime;time++)
187 timeres[time-ftime]= fTimeRF->GetRF((-xyz[2]+Float_t(time))*fZWidth);
188 //write over threshold values to stack
189 for (padrow = fpadrow;padrow<=lpadrow;padrow++)
190 for (pad = fpad;pad<=lpad;pad++)
191 for (time = ftime;time<=ltime;time++){
192 cweight = timeres[time-ftime]*padres[padrow-fpadrow][pad-fpad];
193 if (cweight>fResponseThreshold) {
194 fResponseBin[cindex3]=padrow;
195 fResponseBin[cindex3+1]=pad;
196 fResponseBin[cindex3+2]=time;
198 fResponseWeight[cindex]=cweight;
207 void AliTPCParamSR::TransformTo8(Float_t *xyz, Int_t *index) const
210 // transformate point to digit coordinate
212 if (index[0]==0) Transform0to1(xyz,index);
213 if (index[0]==1) Transform1to2(xyz,index);
214 if (index[0]==2) Transform2to3(xyz,index);
215 if (index[0]==3) Transform3to4(xyz,index);
216 if (index[0]==4) Transform4to8(xyz,index);
219 void AliTPCParamSR::TransformTo2(Float_t *xyz, Int_t *index) const
222 //transformate point to rotated coordinate
225 if (index[0]==0) Transform0to1(xyz,index);
226 if (index[0]==1) Transform1to2(xyz,index);
227 if (index[0]==4) Transform4to3(xyz,index);
228 if (index[0]==8) { //if we are in digit coordinate system transform to global
229 Transform8to4(xyz,index);
230 Transform4to3(xyz,index);
234 void AliTPCParamSR::CRXYZtoXYZ(Float_t *xyz,
235 const Int_t §or, const Int_t & padrow, Int_t option) const
237 //transform relative coordinates to absolute
238 Bool_t rel = ( (option&2)!=0);
239 Int_t index[2]={sector,padrow};
240 if (rel==kTRUE) Transform4to3(xyz,index);//if the position is relative to pad row
241 Transform2to1(xyz,index);
244 void AliTPCParamSR::XYZtoCRXYZ(Float_t *xyz,
245 Int_t §or, Int_t & padrow, Int_t option) const
247 //transform global position to the position relative to the sector padrow
248 //if option=0 X calculate absolute calculate sector
249 //if option=1 X absolute use input sector
250 //if option=2 X relative to pad row calculate sector
251 //if option=3 X relative use input sector
252 //!!!!!!!!! WE start to calculate rows from row = 0
254 Bool_t rel = ( (option&2)!=0);
256 //option 0 and 2 means that we don't have information about sector
257 if ((option&1)==0) Transform0to1(xyz,index); //we calculate sector number
260 Transform1to2(xyz,index);
261 Transform2to3(xyz,index);
262 //if we store relative position calculate position relative to pad row
263 if (rel==kTRUE) Transform3to4(xyz,index);
268 Float_t AliTPCParamSR::GetPrimaryLoss(Float_t *x, Int_t *index, Float_t *angle)
272 Float_t padlength=GetPadPitchLength(index[1]);
273 Float_t a1=TMath::Sin(angle[0]);
275 Float_t a2=TMath::Sin(angle[1]);
277 Float_t length =padlength*TMath::Sqrt(1+a1+a2);
278 return length*fNPrimLoss;
281 Float_t AliTPCParamSR::GetTotalLoss(Float_t *x, Int_t *index, Float_t *angle)
285 Float_t padlength=GetPadPitchLength(index[1]);
286 Float_t a1=TMath::Sin(angle[0]);
288 Float_t a2=TMath::Sin(angle[1]);
290 Float_t length =padlength*TMath::Sqrt(1+a1+a2);
291 return length*fNTotalLoss;
296 void AliTPCParamSR::GetClusterSize(Float_t *x, Int_t *index, Float_t *angle, Int_t mode, Float_t *sigma)
299 //return cluster sigma2 (x,y) for particle at position x
300 // in this case x coordinata is in drift direction
301 //and y in pad row direction
302 //we suppose that input coordinate system is digit system
305 Float_t lx[3] = {x[0],x[1],x[2]};
306 Int_t li[3] = {index[0],index[1],index[2]};
308 // Float_t sigmadiff;
312 xx = lx[2]; //calculate drift length in cm
314 sigma[0]+= xx*GetDiffL()*GetDiffL();
315 sigma[1]+= xx*GetDiffT()*GetDiffT();
319 //sigma[0]=sigma[1]=0;
320 if (GetTimeRF()!=0) sigma[0]+=GetTimeRF()->GetSigma()*GetTimeRF()->GetSigma();
321 if ( (index[1]<fNInnerSector) &&(GetInnerPRF()!=0))
322 sigma[1]+=GetInnerPRF()->GetSigmaX()*GetInnerPRF()->GetSigmaX();
323 if ( (index[1]>=fNInnerSector) &&(index[2]<fNRowUp1) && (GetOuter1PRF()!=0))
324 sigma[1]+=GetOuter1PRF()->GetSigmaX()*GetOuter1PRF()->GetSigmaX();
325 if( (index[1]>=fNInnerSector) &&(index[2]>=fNRowUp1) && (GetOuter2PRF()!=0))
326 sigma[1]+=GetOuter2PRF()->GetSigmaX()*GetOuter2PRF()->GetSigmaX();
329 sigma[0]/= GetZWidth()*GetZWidth();
330 sigma[1]/=GetPadPitchWidth(index[0])*GetPadPitchWidth(index[0]);
336 void AliTPCParamSR::GetSpaceResolution(Float_t *x, Int_t *index, Float_t *angle,
337 Float_t amplitude, Int_t mode, Float_t *sigma)
344 Float_t AliTPCParamSR::GetAmp(Float_t *x, Int_t *index, Float_t *angle)
352 Float_t * AliTPCParamSR::GetAnglesAccMomentum(Float_t *x, Int_t * index, Float_t* momentum, Float_t *angle)
355 //calculate angle of track to padrow at given position
356 // for given magnetic field and momentum of the particle
359 TransformTo2(x,index);
360 AliDetectorParam::GetAnglesAccMomentum(x,index,momentum,angle);
361 Float_t addangle = TMath::ASin(x[1]/GetPadRowRadii(index[1],index[2]));
367 Bool_t AliTPCParamSR::Update()
370 if (AliTPCParam::Update()==kFALSE) return kFALSE;
373 Float_t firstrow = fInnerRadiusLow + 2.225 ;
374 for( i= 0;i<fNRowLow;i++)
376 Float_t x = firstrow + fInnerPadPitchLength*(Float_t)i;
378 // number of pads per row
379 Float_t y = (x-0.5*fInnerPadPitchLength)*tan(fInnerAngle/2.)-fInnerWireMount-
380 fInnerPadPitchWidth/2.;
381 fYInner[i] = x*tan(fInnerAngle/2.)-fInnerWireMount;
382 fNPadsLow[i] = 1+2*(Int_t)(y/fInnerPadPitchWidth) ;
384 firstrow = fOuterRadiusLow + 1.6;
385 for(i=0;i<fNRowUp;i++)
388 Float_t x = firstrow + fOuter1PadPitchLength*(Float_t)i;
390 Float_t y =(x-0.5*fOuter1PadPitchLength)*tan(fOuterAngle/2.)-fOuterWireMount-
391 fOuterPadPitchWidth/2.;
392 fYOuter[i]= x*tan(fOuterAngle/2.)-fOuterWireMount;
393 fNPadsUp[i] = 1+2*(Int_t)(y/fOuterPadPitchWidth) ;
395 fLastWireUp1=fPadRowUp[i] +0.375;
396 firstrow = fPadRowUp[i] + 0.5*(fOuter1PadPitchLength+fOuter2PadPitchLength);
401 Float_t x = firstrow + fOuter2PadPitchLength*(Float_t)(i-64);
403 Float_t y =(x-0.5*fOuter2PadPitchLength)*tan(fOuterAngle/2.)-fOuterWireMount-
404 fOuterPadPitchWidth/2.;
405 fNPadsUp[i] = 1+2*(Int_t)(y/fOuterPadPitchWidth) ;
407 fYOuter[i] = fPadRowUp[i]*tan(fOuterAngle/2.)-fOuterWireMount;
409 fNtRows = fNInnerSector*fNRowLow+fNOuterSector*fNRowUp;
413 Float_t AliTPCParamSR::GetYInner(Int_t irow) const
415 return fYInner[irow];
417 Float_t AliTPCParamSR::GetYOuter(Int_t irow) const
419 return fYOuter[irow];
422 void AliTPCParamSR::Streamer(TBuffer &R__b)
424 // Stream an object of class AliTPC.
426 if (R__b.IsReading()) {
427 Version_t R__v = R__b.ReadVersion(); if (R__v) { }
428 // TObject::Streamer(R__b);
429 AliTPCParam::Streamer(R__b);
430 // if (R__v < 2) return;
433 R__b.WriteVersion(AliTPCParamSR::IsA());
434 //TObject::Streamer(R__b);
435 AliTPCParam::Streamer(R__b);
438 Int_t AliTPCParamSR::CalcResponseFast(Float_t* xyz, Int_t * index, Int_t row)
441 //calculate bin response as function of the input position -x
442 //return number of valid response bin
444 //we suppose that coordinate is expressed in float digits
445 // it's mean coordinate system 8
446 //xyz[0] - float padrow xyz[1] is float pad (center pad is number 0) and xyz[2] is float time bin
447 if ( (fInnerPRF==0)||(fOuter1PRF==0)||(fOuter2PRF==0) ||(fTimeRF==0) ){
448 Error("AliTPCParamSR", "response function was not adjusted");
452 const Int_t padn = 500;
453 const Float_t fpadn = 500.;
454 const Int_t timen = 500;
455 const Float_t ftimen = 500.;
456 const Int_t padrn = 500;
457 const Float_t fpadrn = 500.;
461 static Float_t prfinner[2*padrn][5*padn]; //pad divided by 50
462 static Float_t prfouter1[2*padrn][5*padn]; //prfouter division
463 static Float_t prfouter2[2*padrn][5*padn];
465 static Float_t rftime[5*timen]; //time division
466 static Int_t blabla=0;
467 static Float_t zoffset=0;
468 static Float_t zwidth=0;
469 static Float_t zoffset2=0;
470 static TH1F * hdiff=0;
471 static TH1F * hdiff1=0;
472 static TH1F * hdiff2=0;
474 if (blabla==0) { //calculate Response function - only at the begginning
475 hdiff =new TH1F("prf_diff","prf_diff",10000,-1,1);
476 hdiff1 =new TH1F("no_repsonse1","no_response1",10000,-1,1);
477 hdiff2 =new TH1F("no_response2","no_response2",10000,-1,1);
480 zoffset = GetZOffset();
482 zoffset2 = zoffset/zwidth;
483 for (Int_t i=0;i<5*timen;i++){
484 rftime[i] = fTimeRF->GetRF(((i-2.5*ftimen)/ftimen)*zwidth+zoffset);
486 for (Int_t i=0;i<5*padn;i++){
487 for (Int_t j=0;j<2*padrn;j++){
489 fInnerPRF->GetPRF((i-2.5*fpadn)/fpadn
490 *fInnerPadPitchWidth,(j-fpadrn)/fpadrn*fInnerPadPitchLength);
492 fOuter1PRF->GetPRF((i-2.5*fpadn)/fpadn
493 *fOuterPadPitchWidth,(j-fpadrn)/fpadrn*fOuter1PadPitchLength);
497 fOuter2PRF->GetPRF((i-2.5*fpadn)/fpadn
498 *fOuterPadPitchWidth,(j-fpadrn)/fpadrn*fOuter2PadPitchLength);
501 } // the above is calculated only once
503 // calculate central padrow, pad, time
504 Int_t npads = GetNPads(index[1],index[3]);
505 Int_t cpadrow = index[2]; // electrons are here
506 Int_t cpad = TMath::Nint(xyz[1]);
507 Int_t ctime = TMath::Nint(xyz[2]+zoffset2);
509 Float_t dpadrow = xyz[0];
510 Float_t dpad = xyz[1]-cpad;
511 Float_t dtime = xyz[2]+zoffset2-ctime;
514 Int_t maxt =GetMaxTBin();
519 if (row>=0) { //if we are interesting about given pad row
520 fpadrow = row-cpadrow;
521 lpadrow = row-cpadrow;
523 fpadrow = (index[2]>1) ? -1 :0;
524 lpadrow = (index[2]<GetNRow(index[1])-1) ? 1:0;
526 Int_t fpad = (cpad > -npads/2+1) ? -2: -npads/2-cpad;
527 Int_t lpad = (cpad < npads/2-1) ? 2: npads/2-cpad;
528 Int_t ftime = (ctime>1) ? -2: -ctime;
529 Int_t ltime = (ctime<maxt-2) ? 2: maxt-ctime-1;
531 // cross talk from long pad to short one
532 if(row==fNRowUp1-1 && fpadrow==-1) {
533 dpadrow *= fOuter2PadPitchLength;
534 dpadrow += fOuterWWPitch;
535 dpadrow /= fOuter1PadPitchLength;
537 // cross talk from short pad to long one
538 if(row==fNRowUp1 && fpadrow==1){
539 dpadrow *= fOuter1PadPitchLength;
540 if(dpadrow < -0.) dpadrow = -1.; //protection against 3rd wire
541 dpadrow += fOuterWWPitch;
542 dpadrow /= fOuter2PadPitchLength;
546 Int_t apadrow = TMath::Nint((dpadrow-fpadrow)*fpadrn+fpadrn);
547 for (Int_t ipadrow = fpadrow; ipadrow<=lpadrow;ipadrow++){
548 if ( (apadrow<0) || (apadrow>=2*padrn))
550 Int_t apad= TMath::Nint((dpad-fpad)*fpadn+2.5*fpadn);
551 for (Int_t ipad = fpad; ipad<=lpad;ipad++){
553 if (index[1]<fNInnerSector)
554 cweight=prfinner[apadrow][apad];
557 cweight=prfouter1[apadrow][apad];
558 else cweight=prfouter2[apadrow][apad];
561 // if (cweight<fResponseThreshold) continue;
562 Int_t atime = TMath::Nint((dtime-ftime)*ftimen+2.5*ftimen);
563 for (Int_t itime = ftime;itime<=ltime;itime++){
564 Float_t cweight2 = cweight*rftime[atime];
565 if (cweight2>fResponseThreshold) {
566 fResponseBin[cindex3++]=cpadrow+ipadrow;
567 fResponseBin[cindex3++]=cpad+ipad;
568 fResponseBin[cindex3++]=ctime+itime;
569 fResponseWeight[cindex++]=cweight2;
573 printf("Pici pici %d %f %d\n",ipad,dpad,apad);