]> git.uio.no Git - u/mrichter/AliRoot.git/blame - TPC/AliTPCkineGrid.cxx
stdlib.h included to declare exit() on HP
[u/mrichter/AliRoot.git] / TPC / AliTPCkineGrid.cxx
CommitLineData
33049b0a 1/**************************************************************************
2 * Copyright(c) 2001-2002, 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$
19364939 18Revision 1.2 2002/10/14 14:57:43 hristov
19Merging the VirtualMC branch to the main development branch (HEAD)
20
b9d0a01d 21Revision 1.1.6.1 2002/06/10 15:26:12 hristov
22Merged with v3-08-02
23
24Revision 1.1 2002/05/08 18:19:50 kowal2
25New class by Andrea Dainese. It deals with the parameters used by
26AliTPCtrackerParam (efficiences, pulls etc)
27
33049b0a 28*/
29
30////////////////////////////////////////////////////////////////////////
31// Class used by TPC tracking parameterization to handle to tracking
32// parameters (efficiencies, etc...) on a kinematic grid [pt,eta].
33// User has to provide the grid steps and the values of the parameter
34// in the points of the grid. The function GetValueAt(pt,eta) returns
35// the result of a linear interpolation at the point [pt,eta].
36//
37// Origin: Andrea Dainese, Padova - e-mail: andrea.dainese@pd.infn.it
38////////////////////////////////////////////////////////////////////////
39
19364939 40#include <Riostream.h>
33049b0a 41#include <TMatrixD.h>
42#include <TArrayD.h>
43#include "AliTPCkineGrid.h"
44
45ClassImp(AliTPCkineGrid)
46
47//------------------------------------------------------------------------
48AliTPCkineGrid::AliTPCkineGrid() {
49//------------------------------------------------------------------------
50// Default constructor
51//------------------------------------------------------------------------
52 fNpt = 0;
53 fNeta = 0;
54 fPt = 0;
55 fEta = 0;
56 fParams = 0;
57}
58//------------------------------------------------------------------------
59AliTPCkineGrid::AliTPCkineGrid(Int_t npt,Int_t neta,
60 Double_t* pt,Double_t* eta) {
61//------------------------------------------------------------------------
62// Standard constructor
63//------------------------------------------------------------------------
64 fNpt = npt;
65 fNeta = neta;
66
67 fPt = new TArrayD(fNpt);
68 fEta = new TArrayD(fNeta);
69
70 for(Int_t i=0; i<npt; i++) (*fPt)[i] = pt[i];
71 for(Int_t i=0; i<neta; i++) (*fEta)[i] = eta[i];
72
73 fParams = new TMatrixD(fNpt,fNeta);
74}
75//-------------------------------------------------------------------------
76AliTPCkineGrid::AliTPCkineGrid(const AliTPCkineGrid& grid) {
77//-------------------------------------------------------------------------
78// Copy constructor
79//-------------------------------------------------------------------------
80 fNpt = grid.fNpt;
81 fNeta = grid.fNeta;
82 fPt = new TArrayD(fNpt);
83 for(Int_t i=0; i<fNpt; i++) (*fPt)[i] = grid.fPt->At(i);
84 fEta = new TArrayD(fNeta);
85 for(Int_t i=0; i<fNeta; i++) (*fEta)[i] = grid.fEta->At(i);
86
87 fParams = new TMatrixD(fNpt,fNeta);
88 for(Int_t i=0; i<fNpt; i++) {
89 for(Int_t j=0; j<fNeta; j++) (*fParams)(i,j)=(*grid.fParams)(i,j);
90 }
91}
92//--------------------------------------------------------------------------
93AliTPCkineGrid::~AliTPCkineGrid() {
94//--------------------------------------------------------------------------
95// Destructor
96//--------------------------------------------------------------------------
97 delete fPt;
98 delete fEta;
99 delete fParams;
100}
101//--------------------------------------------------------------------------
102void AliTPCkineGrid::GetArrayEta(Double_t* eta) const {
103//--------------------------------------------------------------------------
104// This functions returns an array with the eta points
105//--------------------------------------------------------------------------
106 for(Int_t i=0;i<fNeta;i++) eta[i] = fEta->At(i);
107 return;
108}
109//--------------------------------------------------------------------------
110void AliTPCkineGrid::GetArrayPt(Double_t* pt) const {
111//--------------------------------------------------------------------------
112// This functions returns an array with the pt points
113//--------------------------------------------------------------------------
114 for(Int_t i=0;i<fNpt;i++) pt[i] = fPt->At(i);
115 return;
116}
117//--------------------------------------------------------------------------
118Int_t AliTPCkineGrid::GetBin(Double_t pt,Double_t eta) const {
119//--------------------------------------------------------------------------
120// This functions tells in which bin of the grid a certain point falls
121//--------------------------------------------------------------------------
122
123 Int_t etaBin=0,ptBin=0,bin=0;
124 eta = TMath::Abs(eta);
125
126 /* this is how bins are numbered
127
128 ... ... .
129 ---+---+---
130 ^ 6 | 7 | 8
131 | ---+---+---
132 3 | 4 | 5
133 Pt ---+---+---
134 0 | 1 | 2
135
136 eta ->
137 */
138
139 if(eta < fEta->At(0)) {
140 etaBin = 0;
141 } else if(eta > fEta->At(fNeta-1)) {
142 etaBin = fNeta;
143 } else {
144 for(Int_t i=0; i<fNeta; i++) {
145 if(eta < fEta->At(i)) {
146 etaBin = i;
147 break;
148 }
149 }
150 }
151 if(pt < fPt->At(0)) {
152 ptBin = 0;
153 } else if(pt > fPt->At(fNpt-1)) {
154 ptBin = fNpt;
155 } else {
156 for(Int_t i=0; i<fNpt; i++) {
157 if(pt < fPt->At(i)) {
158 ptBin = i;
159 break;
160 }
161 }
162 }
163
164 bin = ptBin*(fNeta+1) + etaBin;
165
166 return bin;
167}
168//--------------------------------------------------------------------------
169Double_t AliTPCkineGrid::GetParam(Int_t i) const {
170//--------------------------------------------------------------------------
171// This functions allows to get parameters using only one index
172//--------------------------------------------------------------------------
173 Int_t ipt = (Int_t)i/fNeta;
174 Int_t ieta = i-ipt*fNeta;
175 return GetParam(ipt,ieta);
176}
177//--------------------------------------------------------------------------
178Double_t AliTPCkineGrid::GetValueAt(Double_t pt,Double_t eta) const {
179//--------------------------------------------------------------------------
180// This functions makes a linear interpolation at the point [pt,eta]
181//--------------------------------------------------------------------------
182
183 // determine the points to be used in the interpolation:
184 //
185 // eta
186 eta = TMath::Abs(eta);
187 Int_t etaLow=0,etaUp=0;
188 if(eta < fEta->At(0)) {
189 etaLow = 0;
190 etaUp = 1;
191 } else if(eta >= fEta->At(fNeta-1)) {
192 etaLow = fNeta-2;
193 etaUp = fNeta-1;
194 } else {
195 for(Int_t i=0; i<fNeta; i++) {
196 if(eta < fEta->At(i)) {
197 etaLow = i-1;
198 etaUp = i;
199 break;
200 }
201 }
202 }
203 //
204 // pt
205 Int_t ptLow=0,ptUp=0;
206 if(pt < fPt->At(0)) {
207 ptLow = 0;
208 ptUp = 1;
209 } else if(pt >= fPt->At(fNpt-1)) {
210 ptLow = fNpt-2;
211 ptUp = fNpt-1;
212 } else {
213 for(Int_t i=0; i<fNpt; i++) {
214 if(pt < fPt->At(i)) {
215 ptLow = i-1;
216 ptUp = i;
217 break;
218 }
219 }
220 }
221
222 //cerr<<" Pt = ("<<ptLow<<","<<ptUp<<") Eta = ("<<etaLow<<","<<etaUp<<")\n";
223
224 Double_t intValue=0,intValueEtaLow=0,intValueEtaUp=0;
225 // interpolate, at etaLow, between ptLow and ptUp
226 intValueEtaLow = (*fParams)(ptLow,etaLow)+
227 ((*fParams)(ptUp,etaLow)-(*fParams)(ptLow,etaLow))/
228 (fPt->At(ptUp)-fPt->At(ptLow))*(pt-fPt->At(ptLow));
229 // interpolate, at etaUp, between ptLow and ptUp
230 intValueEtaUp = (*fParams)(ptLow,etaUp)+
231 ((*fParams)(ptUp,etaUp)-(*fParams)(ptLow,etaUp))/
232 (fPt->At(ptUp)-fPt->At(ptLow))*(pt-fPt->At(ptLow));
233 // interpolate, at pt, between etaLow and etaUp
234 intValue = intValueEtaLow+
235 (intValueEtaUp-intValueEtaLow)/
236 (fEta->At(etaUp)-fEta->At(etaLow))*(eta-fEta->At(etaLow));
237
238 if(intValue<0.) intValue=0.;
239 return intValue;
240}
241//--------------------------------------------------------------------------
242void AliTPCkineGrid::SetParam(Int_t i,Double_t par) {
243//--------------------------------------------------------------------------
244// This functions allows to set parameters using only one index
245//--------------------------------------------------------------------------
246 Int_t ipt = (Int_t)i/fNeta;
247 Int_t ieta = i-ipt*fNeta;
248 SetParam(ipt,ieta,par);
249
250 return;
251}
252
253
254
255
256
257
258
259
260
261
262
263
264
265