1 /**************************************************************************
2 * Copyright(c) 2001-2002, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
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].
25 // Origin: Andrea Dainese, Padova - e-mail: andrea.dainese@pd.infn.it
26 ////////////////////////////////////////////////////////////////////////
28 //-- standard headers -----
29 #include "Riostream.h"
30 //--- Root headers --------
33 //-- AliRoot headers ------
34 #include "AliTPCkineGrid.h"
35 //-------------------------
37 ClassImp(AliTPCkineGrid)
39 //------------------------------------------------------------------------
40 AliTPCkineGrid::AliTPCkineGrid()
48 //------------------------------------------------------------------------
49 // Default constructor
50 //------------------------------------------------------------------------
53 //------------------------------------------------------------------------
54 AliTPCkineGrid::AliTPCkineGrid(Int_t npt,Int_t neta,
55 Double_t* pt,Double_t* eta)
63 //------------------------------------------------------------------------
64 // Standard constructor
65 //------------------------------------------------------------------------
68 fPt = new TArrayD(fNpt);
69 fEta = new TArrayD(fNeta);
71 for(Int_t i=0; i<npt; i++) (*fPt)[i] = pt[i];
72 for(Int_t i=0; i<neta; i++) (*fEta)[i] = eta[i];
74 fParams = new TMatrixD(fNpt,fNeta);
76 //-------------------------------------------------------------------------
77 AliTPCkineGrid::AliTPCkineGrid(const AliTPCkineGrid& grid):TNamed(grid),
84 //-------------------------------------------------------------------------
86 //-------------------------------------------------------------------------
89 fPt = new TArrayD(fNpt);
90 for(Int_t i=0; i<fNpt; i++) (*fPt)[i] = grid.fPt->At(i);
91 fEta = new TArrayD(fNeta);
92 for(Int_t i=0; i<fNeta; i++) (*fEta)[i] = grid.fEta->At(i);
94 fParams = new TMatrixD(fNpt,fNeta);
95 for(Int_t i=0; i<fNpt; i++) {
96 for(Int_t j=0; j<fNeta; j++) (*fParams)(i,j)=(*grid.fParams)(i,j);
99 //--------------------------------------------------------------------------
100 AliTPCkineGrid::~AliTPCkineGrid() {
101 //--------------------------------------------------------------------------
103 //--------------------------------------------------------------------------
108 //__________________________________________________________________________
109 AliTPCkineGrid & AliTPCkineGrid::operator =(const AliTPCkineGrid & param)
112 // assignment operator - dummy
117 //--------------------------------------------------------------------------
118 void AliTPCkineGrid::GetArrayEta(Double_t* eta) const {
119 //--------------------------------------------------------------------------
120 // This functions returns an array with the eta points
121 //--------------------------------------------------------------------------
122 for(Int_t i=0;i<fNeta;i++) eta[i] = fEta->At(i);
125 //--------------------------------------------------------------------------
126 void AliTPCkineGrid::GetArrayPt(Double_t* pt) const {
127 //--------------------------------------------------------------------------
128 // This functions returns an array with the pt points
129 //--------------------------------------------------------------------------
130 for(Int_t i=0;i<fNpt;i++) pt[i] = fPt->At(i);
133 //--------------------------------------------------------------------------
134 Int_t AliTPCkineGrid::GetBin(Double_t pt,Double_t eta) const {
135 //--------------------------------------------------------------------------
136 // This functions tells in which bin of the grid a certain point falls
137 //--------------------------------------------------------------------------
139 Int_t etaBin=0,ptBin=0,bin=0;
140 eta = TMath::Abs(eta);
142 /* this is how bins are numbered
155 if(eta < fEta->At(0)) {
157 } else if(eta > fEta->At(fNeta-1)) {
160 for(Int_t i=0; i<fNeta; i++) {
161 if(eta < fEta->At(i)) {
167 if(pt < fPt->At(0)) {
169 } else if(pt > fPt->At(fNpt-1)) {
172 for(Int_t i=0; i<fNpt; i++) {
173 if(pt < fPt->At(i)) {
180 bin = ptBin*(fNeta+1) + etaBin;
184 //--------------------------------------------------------------------------
185 Double_t AliTPCkineGrid::GetParam(Int_t i) const {
186 //--------------------------------------------------------------------------
187 // This functions allows to get parameters using only one index
188 //--------------------------------------------------------------------------
189 Int_t ipt = (Int_t)i/fNeta;
190 Int_t ieta = i-ipt*fNeta;
191 return GetParam(ipt,ieta);
193 //--------------------------------------------------------------------------
194 Double_t AliTPCkineGrid::GetValueAt(Double_t pt,Double_t eta) const {
195 //--------------------------------------------------------------------------
196 // This functions makes a linear interpolation at the point [pt,eta]
197 //--------------------------------------------------------------------------
199 // determine the points to be used in the interpolation:
202 eta = TMath::Abs(eta);
203 Int_t etaLow=0,etaUp=0;
204 if(eta < fEta->At(0)) {
207 } else if(eta >= fEta->At(fNeta-1)) {
211 for(Int_t i=0; i<fNeta; i++) {
212 if(eta < fEta->At(i)) {
221 Int_t ptLow=0,ptUp=0;
222 if(pt < fPt->At(0)) {
225 } else if(pt >= fPt->At(fNpt-1)) {
229 for(Int_t i=0; i<fNpt; i++) {
230 if(pt < fPt->At(i)) {
238 //cerr<<" Pt = ("<<ptLow<<","<<ptUp<<") Eta = ("<<etaLow<<","<<etaUp<<")\n";
240 Double_t intValue=0,intValueEtaLow=0,intValueEtaUp=0;
241 // interpolate, at etaLow, between ptLow and ptUp
242 intValueEtaLow = (*fParams)(ptLow,etaLow)+
243 ((*fParams)(ptUp,etaLow)-(*fParams)(ptLow,etaLow))/
244 (fPt->At(ptUp)-fPt->At(ptLow))*(pt-fPt->At(ptLow));
245 // interpolate, at etaUp, between ptLow and ptUp
246 intValueEtaUp = (*fParams)(ptLow,etaUp)+
247 ((*fParams)(ptUp,etaUp)-(*fParams)(ptLow,etaUp))/
248 (fPt->At(ptUp)-fPt->At(ptLow))*(pt-fPt->At(ptLow));
249 // interpolate, at pt, between etaLow and etaUp
250 intValue = intValueEtaLow+
251 (intValueEtaUp-intValueEtaLow)/
252 (fEta->At(etaUp)-fEta->At(etaLow))*(eta-fEta->At(etaLow));
254 if(intValue<0.) intValue=0.;
257 //--------------------------------------------------------------------------
258 void AliTPCkineGrid::SetParam(Int_t i,Double_t par) {
259 //--------------------------------------------------------------------------
260 // This functions allows to set parameters using only one index
261 //--------------------------------------------------------------------------
262 Int_t ipt = (Int_t)i/fNeta;
263 Int_t ieta = i-ipt*fNeta;
264 SetParam(ipt,ieta,par);