]> git.uio.no Git - u/mrichter/AliRoot.git/blob - TPC/AliTPCParamSR.cxx
Maximal number of good tracks increased to 20000.
[u/mrichter/AliRoot.git] / TPC / AliTPCParamSR.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.3  2000/06/30 12:07:50  kowal2
19 Updated from the TPC-PreRelease branch
20
21 Revision 1.2.4.2  2000/06/14 16:48:24  kowal2
22 Parameter setting improved. Removed compiler warnings
23
24 Revision 1.2.4.1  2000/06/09 07:55:39  kowal2
25
26 Updated defaults
27
28 Revision 1.2  2000/04/17 09:37:33  kowal2
29 removed obsolete AliTPCDigitsDisplay.C
30
31 Revision 1.1.4.2  2000/04/10 11:36:13  kowal2
32
33 New Detector parameters handling class
34
35 */
36
37 ///////////////////////////////////////////////////////////////////////
38 //  Manager and of geomety  classes for set: TPC                     //
39 //                                                                   //
40 //  !sectors are numbered from  0                                     //
41 //  !pad rows are numbered from 0                                     //
42 //  
43 //  27.7.   - AliTPCPaaramSr object for TPC 
44 //            TPC with straight pad rows 
45 //  Origin:  Marian Ivanov, Uni. of Bratislava, ivanov@fmph.uniba.sk // 
46 //                                                                   //  
47 ///////////////////////////////////////////////////////////////////////
48
49
50 #include <iostream.h>
51 #include <TMath.h>
52 #include <TObject.h>
53 #include <AliTPCParamSR.h>
54 #include "AliTPCPRF2D.h"
55 #include "AliTPCRF1D.h"
56
57
58
59 ClassImp(AliTPCParamSR)
60 const static  Int_t kMaxRows=600;
61 const static  Float_t  kEdgeSectorSpace = 2.5;
62 const static Float_t kFacSigmaPadRow=3.;
63 const static Float_t kFacSigmaPad=3.;
64 const static Float_t kFacSigmaTime=3.;
65
66
67 AliTPCParamSR::AliTPCParamSR()
68 {   
69   //
70   //constructor set the default parameters
71   fInnerPRF=0;
72   fOuterPRF=0;
73   fTimeRF = 0;
74   fFacSigmaPadRow = Float_t(kFacSigmaPadRow);
75   fFacSigmaPad = Float_t(kFacSigmaPad);
76   fFacSigmaTime = Float_t(kFacSigmaTime);
77   SetDefault();
78   Update();
79 }
80
81 AliTPCParamSR::~AliTPCParamSR()
82 {
83   //
84   //destructor destroy some dynmicaly alocated variables
85   if (fInnerPRF != 0) delete fInnerPRF;
86   if (fOuterPRF != 0) delete fOuterPRF;
87   if (fTimeRF != 0) delete fTimeRF;
88 }
89
90 void AliTPCParamSR::SetDefault()
91 {
92   //set default TPC param   
93   fbStatus = kFALSE;
94   AliTPCParam::SetDefault();  
95 }  
96
97 Int_t  AliTPCParamSR::CalcResponse(Float_t* xyz, Int_t * index, Int_t row)
98 {
99   //
100   //calculate bin response as function of the input position -x 
101   //return number of valid response bin
102   //
103   //we suppose that coordinate is expressed in float digits 
104   // it's mean coordinate system 8
105   //xyz[0] - float padrow xyz[1] is float pad  (center pad is number 0) and xyz[2] is float time bin
106   if ( (fInnerPRF==0)||(fOuterPRF==0)||(fTimeRF==0) ){ 
107     Error("AliTPCParamSR", "response function was not adjusted");
108     return -1;
109   }
110   
111   Float_t sfpadrow;   // sigma of response function
112   Float_t sfpad;      // sigma  of 
113   Float_t sftime= fFacSigmaTime*fTimeRF->GetSigma()/fZWidth;     //3 sigma of time response
114   if (index[1]<fNInnerSector){
115     sfpadrow =fFacSigmaPadRow*fInnerPRF->GetSigmaY()/fInnerPadPitchLength;
116     sfpad    =fFacSigmaPad*fInnerPRF->GetSigmaX()/fInnerPadPitchWidth;
117   }else{
118     sfpadrow =fFacSigmaPadRow*fOuterPRF->GetSigmaY()/fOuterPadPitchLength;
119     sfpad    =fFacSigmaPad*fOuterPRF->GetSigmaX()/fOuterPadPitchWidth;
120   }
121
122   Int_t fpadrow = TMath::Max(TMath::Nint(index[2]+xyz[0]-sfpadrow),0);  //"first" padrow
123   Int_t fpad    = TMath::Nint(xyz[1]-sfpad);     //first pad
124   Int_t ftime   = TMath::Max(TMath::Nint(xyz[2]+GetZOffset()/GetZWidth()-sftime),0);  // first time
125   Int_t lpadrow = TMath::Min(TMath::Nint(index[2]+xyz[0]+sfpadrow),fpadrow+19);  //"last" padrow
126   lpadrow       = TMath::Min(GetNRow(index[1])-1,lpadrow);
127   Int_t lpad    = TMath::Min(TMath::Nint(xyz[1]+sfpad),fpad+19);     //last pad
128   Int_t ltime   = TMath::Min(TMath::Nint(xyz[2]+GetZOffset()/GetZWidth()+sftime),ftime+19);    // last time
129   ltime         = TMath::Min(ltime,GetMaxTBin()-1); 
130  
131   if (row>=0) { //if we are interesting about given pad row
132     if (fpadrow<=row) fpadrow =row;
133     else 
134       return 0;
135     if (lpadrow>=row) lpadrow = row;
136     else 
137       return 0;
138   }
139
140  
141   Float_t  padres[20][20];  //I don't expect bigger number of bins
142   Float_t  timeres[20];     
143   Int_t cindex3=0;
144   Int_t cindex=0;
145   Float_t cweight = 0;
146   if (fpadrow>=0) {
147   //calculate padresponse function    
148   Int_t padrow, pad;
149   for (padrow = fpadrow;padrow<=lpadrow;padrow++)
150     for (pad = fpad;pad<=lpad;pad++){
151       Float_t dy = (-xyz[0]+Float_t(index[2]-padrow));
152       Float_t dx = (-xyz[1]+Float_t(pad));
153       if (index[1]<fNInnerSector)
154         padres[padrow-fpadrow][pad-fpad]=fInnerPRF->GetPRF(dx*fInnerPadPitchWidth,dy*fInnerPadPitchLength);
155       else
156         padres[padrow-fpadrow][pad-fpad]=fOuterPRF->GetPRF(dx*fOuterPadPitchWidth,dy*fOuterPadPitchLength);          }
157   //calculate time response function
158   Int_t time;
159   for (time = ftime;time<=ltime;time++) 
160     timeres[time-ftime]= fTimeRF->GetRF((-xyz[2]+Float_t(time))*fZWidth);     
161   //write over threshold values to stack
162   for (padrow = fpadrow;padrow<=lpadrow;padrow++)
163     for (pad = fpad;pad<=lpad;pad++)
164       for (time = ftime;time<=ltime;time++){
165         cweight = timeres[time-ftime]*padres[padrow-fpadrow][pad-fpad];
166         if (cweight>fResponseThreshold) {
167           fResponseBin[cindex3]=padrow;
168           fResponseBin[cindex3+1]=pad;
169           fResponseBin[cindex3+2]=time;
170           cindex3+=3;  
171           fResponseWeight[cindex]=cweight;
172           cindex++;
173         }
174       }
175   }
176   fCurrentMax=cindex;   
177   return fCurrentMax;
178 }
179
180 void AliTPCParamSR::TransformTo8(Float_t *xyz, Int_t *index) const
181 {
182   //
183   // transformate point to digit coordinate
184   //
185   if (index[0]==0) Transform0to1(xyz,index);
186   if (index[0]==1) Transform1to2(xyz,index);
187   if (index[0]==2) Transform2to3(xyz,index);
188   if (index[0]==3) Transform3to4(xyz,index);
189   if (index[0]==4) Transform4to8(xyz,index);
190 }
191
192 void AliTPCParamSR::TransformTo2(Float_t *xyz, Int_t *index) const
193 {
194   //
195   //transformate point to rotated coordinate
196   //
197   //we suppose that   
198   if (index[0]==0) Transform0to1(xyz,index);
199   if (index[0]==1) Transform1to2(xyz,index);
200   if (index[0]==4) Transform4to3(xyz,index);
201   if (index[0]==8) {  //if we are in digit coordinate system transform to global
202     Transform8to4(xyz,index);
203     Transform4to3(xyz,index);  
204   }
205 }
206
207 void AliTPCParamSR::CRXYZtoXYZ(Float_t *xyz,
208                const Int_t &sector, const Int_t & padrow, Int_t option) const  
209 {  
210   //transform relative coordinates to absolute
211   Bool_t rel = ( (option&2)!=0);
212   Int_t index[2]={sector,padrow};
213   if (rel==kTRUE)      Transform4to3(xyz,index);//if the position is relative to pad row  
214   Transform2to1(xyz,index);
215 }
216
217 void AliTPCParamSR::XYZtoCRXYZ(Float_t *xyz,
218                              Int_t &sector, Int_t & padrow, Int_t option) const
219 {
220    //transform global position to the position relative to the sector padrow
221   //if option=0  X calculate absolute            calculate sector
222   //if option=1  X           absolute            use input sector
223   //if option=2  X           relative to pad row calculate sector
224   //if option=3  X           relative            use input sector
225   //!!!!!!!!! WE start to calculate rows from row = 0
226   Int_t index[2];
227   Bool_t rel = ( (option&2)!=0);  
228
229   //option 0 and 2  means that we don't have information about sector
230   if ((option&1)==0)   Transform0to1(xyz,index);  //we calculate sector number 
231   else
232     index[0]=sector;
233   Transform1to2(xyz,index);
234   Transform2to3(xyz,index);
235   //if we store relative position calculate position relative to pad row
236   if (rel==kTRUE) Transform3to4(xyz,index);
237   sector = index[0];
238   padrow = index[1];
239 }
240
241 Float_t AliTPCParamSR::GetPrimaryLoss(Float_t *x, Int_t *index, Float_t *angle)
242 {
243   //
244   //
245   Float_t padlength=GetPadPitchLength(index[1]);
246   Float_t a1=TMath::Sin(angle[0]);
247   a1*=a1;
248   Float_t a2=TMath::Sin(angle[1]);
249   a2*=a2;
250   Float_t length =padlength*TMath::Sqrt(1+a1+a2);
251   return length*fNPrimLoss;
252 }
253
254 Float_t AliTPCParamSR::GetTotalLoss(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*fNTotalLoss;
265   
266 }
267
268
269 void AliTPCParamSR::GetClusterSize(Float_t *x, Int_t *index, Float_t *angle, Int_t mode, Float_t *sigma)
270 {
271   //
272   //return cluster sigma2 (x,y) for particle at position x
273   // in this case x coordinata is in drift direction
274   //and y in pad row direction
275   //we suppose that input coordinate system is digit system
276    
277   Float_t  xx;
278   Float_t lx[3] = {x[0],x[1],x[2]};
279   Int_t   li[3] = {index[0],index[1],index[2]};
280   TransformTo2(lx,li);
281   //  Float_t  sigmadiff;
282   sigma[0]=0;
283   sigma[1]=0;
284   
285   xx = lx[2];  //calculate drift length in cm
286   if (xx>0) {
287     sigma[0]+= xx*GetDiffL()*GetDiffL();
288     sigma[1]+= xx*GetDiffT()*GetDiffT(); 
289   }
290
291
292   //sigma[0]=sigma[1]=0;
293   if (GetTimeRF()!=0) sigma[0]+=GetTimeRF()->GetSigma()*GetTimeRF()->GetSigma();
294   if ( (index[1]<fNInnerSector) &&(GetInnerPRF()!=0))   
295     sigma[1]+=GetInnerPRF()->GetSigmaX()*GetInnerPRF()->GetSigmaX();
296   if ( (index[1]>=fNInnerSector) && (GetOuterPRF()!=0))
297     sigma[1]+=GetOuterPRF()->GetSigmaX()*GetOuterPRF()->GetSigmaX();
298
299
300   sigma[0]/= GetZWidth()*GetZWidth();
301   sigma[1]/=GetPadPitchWidth(index[0])*GetPadPitchWidth(index[0]);
302 }
303
304
305
306
307 void AliTPCParamSR::GetSpaceResolution(Float_t *x, Int_t *index, Float_t *angle, 
308                                        Float_t amplitude, Int_t mode, Float_t *sigma)
309 {
310   //
311   //
312   //
313   
314 }
315 Float_t  AliTPCParamSR::GetAmp(Float_t *x, Int_t *index, Float_t *angle)
316 {
317   //
318   //
319   //
320   return 0;
321 }
322
323 Float_t * AliTPCParamSR::GetAnglesAccMomentum(Float_t *x, Int_t * index, Float_t* momentum, Float_t *angle)
324 {
325   //
326   //calculate angle of track to padrow at given position
327   // for given magnetic field and momentum of the particle
328   //
329
330   TransformTo2(x,index);
331   AliDetectorParam::GetAnglesAccMomentum(x,index,momentum,angle);    
332   Float_t addangle = TMath::ASin(x[1]/GetPadRowRadii(index[1],index[2]));
333   angle[1] +=addangle;
334   return angle;                          
335 }
336
337          
338 Bool_t AliTPCParamSR::Update()
339 {
340   
341   //
342   // update some calculated parameter which must be updated after changing "base"
343   // parameters 
344   // for example we can change size of pads and according this recalculate number
345   // of pad rows, number of of pads in given row ....
346   Int_t i;
347   if (AliTPCParam::Update()==kFALSE) return kFALSE;
348   fbStatus = kFALSE;
349
350   // adjust lower sectors pad row positions and pad numbers 
351   fNRowLow   =  (Int_t(1.001+((fRInnerLastWire-fRInnerFirstWire)/fInnerWWPitch))
352                -2*fInnerDummyWire)/fNInnerWiresPerPad;  
353   if ( kMaxRows<fNRowLow) fNRowUp = kMaxRows;
354   if (1>fNRowLow) return kFALSE;
355  
356   //Float_t firstpad = fRInnerFirstWire+(fInnerDummyWire-0.5)*fInnerWWPitch
357   //    +fInnerPadPitchLength/2.;
358   Float_t lastpad = fRInnerLastWire-(fInnerDummyWire-0.5)*fInnerWWPitch
359     -fInnerPadPitchLength/2.;
360   Float_t firstpad = lastpad-Float_t(fNRowLow-1)*fInnerPadPitchLength;  
361   for (i = 0;i<fNRowLow;i++) 
362     {
363        Float_t x  = firstpad +fInnerPadPitchLength*(Float_t)i;       
364        Float_t y = (x-0.5*fInnerPadPitchLength)*tan(fInnerAngle/2.)-fInnerWireMount-
365                     fInnerPadPitchWidth/2.;
366        fPadRowLow[i] = x;
367        fNPadsLow[i] = 1+2*(Int_t)(y/fInnerPadPitchWidth) ;
368        }
369
370   // adjust upper sectors pad row positions and pad numbers
371   fNRowUp   = (Int_t(1.001+((fROuterLastWire-fROuterFirstWire)/fOuterWWPitch))
372                -2*fOuterDummyWire)/fNOuterWiresPerPad; 
373   if ( kMaxRows<fNRowUp) fNRowUp = kMaxRows;
374   if (1>fNRowUp) return kFALSE;
375   firstpad = fROuterFirstWire+(fOuterDummyWire-0.5)*fOuterWWPitch
376     +fOuterPadPitchLength/2.;
377  
378   for (i = 0;i<fNRowUp;i++) 
379     {
380        Float_t x  = firstpad + fOuterPadPitchLength*(Float_t)i;      
381        Float_t y = (x-0.5*fOuterPadPitchLength)*tan(fOuterAngle/2.)-fOuterWireMount-
382                     fInnerPadPitchWidth/2.;
383        fPadRowUp[i] = x;
384        fNPadsUp[i] = 1+2*(Int_t)(y/fOuterPadPitchWidth) ;
385     }
386   fNtRows = fNInnerSector*fNRowLow+fNOuterSector*fNRowUp;
387   fbStatus = kTRUE;
388   return kTRUE;
389 }
390
391
392 void AliTPCParamSR::Streamer(TBuffer &R__b)
393 {
394    // Stream an object of class AliTPC.
395
396    if (R__b.IsReading()) {
397       Version_t R__v = R__b.ReadVersion(); if (R__v) { }
398       //      TObject::Streamer(R__b);
399       AliTPCParam::Streamer(R__b);
400       //      if (R__v < 2) return;
401        Update();
402    } else {
403       R__b.WriteVersion(AliTPCParamSR::IsA());
404       //TObject::Streamer(R__b);  
405       AliTPCParam::Streamer(R__b);    
406    }
407 }
408
409
410
411
412
413
414
415