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