Major upgrade of AliRoot code
[u/mrichter/AliRoot.git] / TPC / AliTPCParamCR.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$
c11cb93f 18Revision 1.3 2000/06/30 12:07:50 kowal2
19Updated from the TPC-PreRelease branch
20
73042f01 21Revision 1.2.4.1 2000/06/14 16:48:24 kowal2
22Parameter setting improved. Removed compiler warnings
23
24Revision 1.2 2000/04/17 09:37:33 kowal2
25removed obsolete AliTPCDigitsDisplay.C
26
cc80f89e 27Revision 1.1.4.2 2000/04/10 11:36:13 kowal2
28
29New Detector parameters handling class
30
31*/
32
33///////////////////////////////////////////////////////////////////////
34// Manager and of geomety classes for set: TPC //
35// //
36// !sectors are numbered from 0 //
37// !pad rows are numbered from 0 //
38//
39// 27.7. - AliTPCPaaramSr object for TPC
40// TPC with straight pad rows
41// Origin: Marian Ivanov, Uni. of Bratislava, ivanov@fmph.uniba.sk //
42// //
43///////////////////////////////////////////////////////////////////////
44
45
46#include <iostream.h>
47#include <TMath.h>
48#include <TObject.h>
49#include <AliTPCParamCR.h>
73042f01 50#include "AliTPCPRF2D.h"
51#include "AliTPCRF1D.h"
cc80f89e 52
53
54
55ClassImp(AliTPCParamCR)
56const static Int_t kMaxRows=600;
57const static Float_t kEdgeSectorSpace = 2.5;
58
59AliTPCParamCR::AliTPCParamCR()
60{
61 //
62 //constructor set the default parameters
63 fInnerPRF=0;
64 fOuterPRF=0;
65 fTimeRF = 0;
66 fFacSigma = Float_t(2.);
67 SetDefault();
68 Update();
69}
70
71AliTPCParamCR::~AliTPCParamCR()
72{
73 //
74 //destructor destroy some dynmicaly alocated variables
75 if (fInnerPRF != 0) delete fInnerPRF;
76 if (fOuterPRF != 0) delete fOuterPRF;
77 if (fTimeRF != 0) delete fTimeRF;
78}
79
80void AliTPCParamCR::SetDefault()
81{
82 //set default TPC param
83 fbStatus = kFALSE;
84 AliTPCParam::SetDefault();
85}
86
73042f01 87Int_t AliTPCParamCR::CalcResponse(Float_t* xyz, Int_t * index, Int_t dummy)
cc80f89e 88{
89 //
90 //calculate bin response as function of the input position -x
91 //return number of valid response bin
92 //
93 //we suppose that coordinata is expressed in float digits
94 // it's mean coordinate system 8
95 //xyz[0] - float padrow xyz[1] is float pad (center pad is number 0) and xyz[2] is float time bin
96 if ( (fInnerPRF==0)||(fOuterPRF==0)||(fTimeRF==0) ){
97 Error("AliTPCParamCR", "response function were not adjusted");
98 return -1;
99 }
100
101 Float_t sfpadrow; // sigma of response function
102 Float_t sfpad; // sigma of
103 Float_t sftime= fFacSigma*fTimeRF->GetSigma()/fZWidth; //3 sigma of time response
104 if (index[1]<fNInnerSector){
105 sfpadrow =fFacSigma*fInnerPRF->GetSigmaY()/fInnerPadPitchLength;
106 sfpad =fFacSigma*fInnerPRF->GetSigmaX()/fInnerPadPitchWidth;
107 }else{
108 sfpadrow =fFacSigma*fOuterPRF->GetSigmaY()/fOuterPadPitchLength;
109 sfpad =fFacSigma*fOuterPRF->GetSigmaX()/fOuterPadPitchWidth;
110 }
111
112 Int_t fpadrow = TMath::Nint(xyz[0]-sfpadrow); //"first" padrow
113 Int_t fpad = TMath::Nint(xyz[1]-sfpad); //first pad
114 Int_t ftime = TMath::Nint(xyz[2]+fTimeRF->GetOffset()-sftime); // first time
115 Int_t lpadrow = TMath::Min(TMath::Nint(xyz[0]+sfpadrow),fpadrow+19); //"last" padrow
116 Int_t lpad = TMath::Min(TMath::Nint(xyz[1]+sfpad),fpad+19); //last pad
117 Int_t ltime = TMath::Min(TMath::Nint(xyz[2]+fTimeRF->GetOffset()+sftime),ftime+19); // last time
118
119 Float_t padres[20][20]; //I don't expect bigger number of bins
120 Float_t timeres[20];
121 //calculate padresponse function
122 Int_t padrow;
123 for (padrow = fpadrow;padrow<=lpadrow;padrow++)
124 for (Int_t pad = fpad;pad<=lpad;pad++){
125 Float_t dy = (xyz[0]-Float_t(padrow));
126 Float_t dx = (xyz[1]-Float_t(pad));
127 if (index[1]<fNInnerSector)
128 padres[padrow-fpadrow][pad-fpad]=fInnerPRF->GetPRF(dx*fInnerPadPitchWidth,dy*fInnerPadPitchLength);
129 else
130 padres[padrow-fpadrow][pad-fpad]=fOuterPRF->GetPRF(dx*fOuterPadPitchWidth,dy*fOuterPadPitchLength);
131 }
132 //calculate time response function
133
134 Int_t time;
135 for (time = ftime;time<=ltime;time++) timeres[time-ftime]= fTimeRF->GetRF((xyz[2]-Float_t(time))*fZWidth);
136
137 //write over threshold values to stack
138 Int_t cindex3=-1;
139 Int_t cindex=0;
140 Float_t cweight = 0;
141 for (padrow = fpadrow;padrow<=lpadrow;padrow++)
142 for (Int_t pad = fpad;pad<=lpad;pad++)
143 for (time = ftime;time<=ltime;time++){
144 cweight = timeres[time-ftime]*padres[padrow-fpadrow][pad-fpad];
145 if (cweight>fResponseThreshold) {
146 fResponseBin[++cindex3]=padrow;
147 fResponseBin[++cindex3]=pad;
148 fResponseBin[++cindex3]=time;
149 fResponseWeight[++cindex]=cweight;
150 }
151 }
152 fCurrentMax=cindex;
153 return fCurrentMax;
154}
155
156void AliTPCParamCR::CRXYZtoXYZ(Float_t *xyz,
157 const Int_t &sector, const Int_t & padrow, Int_t option) const
158{
159 //transform relative coordinates to absolute
160 Bool_t rel = ( (option&2)!=0);
161 Int_t index[2]={sector,padrow};
162 if (rel==kTRUE) Transform4to3(xyz,index);//if the position is relative to pad row
163 Transform2to1(xyz,index);
164}
165
166void AliTPCParamCR::XYZtoCRXYZ(Float_t *xyz,
167 Int_t &sector, Int_t & padrow, Int_t option) const
168{
169 //transform global position to the position relative to the sector padrow
170 //if option=0 X calculate absolute calculate sector
171 //if option=1 X absolute use input sector
172 //if option=2 X relative to pad row calculate sector
173 //if option=3 X relative use input sector
174 //!!!!!!!!! WE start to calculate rows from row = 0
175 Int_t index[2];
176 Bool_t rel = ( (option&2)!=0);
177
178 //option 0 and 2 means that we don't have information about sector
179 if ((option&1)==0) Transform0to1(xyz,index); //we calculate sector number
180 else
181 index[0]=sector;
182 Transform1to2(xyz,index);
183 Transform2to3(xyz,index);
184 //if we store relative position calculate position relative to pad row
185 if (rel==kTRUE) Transform3to4(xyz,index);
186 sector = index[0];
187 padrow = index[1];
188}
189
190
191
192Bool_t AliTPCParamCR::Update()
193{
194
195 //
196 // update some calculated parameter which must be updated after changing "base"
197 // parameters
198 // for example we can change size of pads and according this recalculate number
199 // of pad rows, number of of pads in given row ....
200 Int_t i;
201 if (AliTPCParam::Update()==kFALSE) return kFALSE;
202 fbStatus = kFALSE;
203
204 // adjust lower sectors pad row positions and pad numbers
205 fNRowLow = (Int_t(1.0001*(fRInnerLastWire-fRInnerFirstWire)/fInnerWWPitch)
206 -2*fInnerDummyWire)/fNInnerWiresPerPad;
207 if ( kMaxRows<fNRowLow) fNRowUp = kMaxRows;
208 if (1>fNRowLow) return kFALSE;
209 Float_t firstpad = fRInnerFirstWire+(fInnerDummyWire-0.5)*fInnerWWPitch
210 +fInnerPadPitchLength/2.;
211
212 for (i = 0;i<fNRowLow;i++)
213 {
214 Float_t x = firstpad +fInnerPadPitchLength*(Float_t)i;
215 Float_t y = (x-0.5*fInnerPadPitchLength)*tan(fInnerAngle/2.)-fInnerFrameSpace-
216 fInnerPadPitchWidth/2.;
217 fPadRowLow[i] = x;
218 fNPadsLow[i] = 1+2*(Int_t)(y/fInnerPadPitchWidth) ;
219 }
220
221 // adjust upper sectors pad row positions and pad numbers
222 fNRowUp = (Int_t((fROuterLastWire-fROuterFirstWire+0.001)/fOuterWWPitch)
223 -2*fOuterDummyWire)/fNOuterWiresPerPad;
224 if ( kMaxRows<fNRowUp) fNRowUp = kMaxRows;
225 if (1>fNRowUp) return kFALSE;
226 firstpad = fROuterFirstWire+(fOuterDummyWire-0.5)*fOuterWWPitch
227 +fOuterPadPitchLength/2.;
228
229 for (i = 0;i<fNRowUp;i++)
230 {
231 Float_t x = firstpad + fOuterPadPitchLength*(Float_t)i;
232 Float_t y = (x-0.5*fOuterPadPitchLength)*tan(fOuterAngle/2.)-fOuterFrameSpace-
233 fInnerPadPitchWidth/2.;
234 fPadRowUp[i] = x;
235 fNPadsUp[i] = 1+2*(Int_t)(y/fOuterPadPitchWidth) ;
236 }
237 fNtRows = fNInnerSector*fNRowLow+fNOuterSector*fNRowUp;
c11cb93f 238 fbStatus = kTRUE;
cc80f89e 239 return kTRUE;
240}
241
242
243
244void AliTPCParamCR::Streamer(TBuffer &R__b)
245{
246 // Stream an object of class AliTPC.
247
248 if (R__b.IsReading()) {
249 Version_t R__v = R__b.ReadVersion(); if (R__v) { }
250 // TObject::Streamer(R__b);
251 AliTPCParam::Streamer(R__b);
252 // if (R__v < 2) return;
253 Update();
254 } else {
255 R__b.WriteVersion(AliTPCParamCR::IsA());
256 //TObject::Streamer(R__b);
257 AliTPCParam::Streamer(R__b);
258 }
259}
260
261
262
263
c11cb93f 264
265
266
267
268
269