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