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