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() {
41 //------------------------------------------------------------------------
42 // Default constructor
43 //------------------------------------------------------------------------
50 //------------------------------------------------------------------------
51 AliTPCkineGrid::AliTPCkineGrid(Int_t npt,Int_t neta,
52 Double_t* pt,Double_t* eta) {
53 //------------------------------------------------------------------------
54 // Standard constructor
55 //------------------------------------------------------------------------
59 fPt = new TArrayD(fNpt);
60 fEta = new TArrayD(fNeta);
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];
65 fParams = new TMatrixD(fNpt,fNeta);
67 //-------------------------------------------------------------------------
68 AliTPCkineGrid::AliTPCkineGrid(const AliTPCkineGrid& grid):TNamed(grid) {
69 //-------------------------------------------------------------------------
71 //-------------------------------------------------------------------------
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);
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);
84 //--------------------------------------------------------------------------
85 AliTPCkineGrid::~AliTPCkineGrid() {
86 //--------------------------------------------------------------------------
88 //--------------------------------------------------------------------------
93 //--------------------------------------------------------------------------
94 void 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);
101 //--------------------------------------------------------------------------
102 void 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);
109 //--------------------------------------------------------------------------
110 Int_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 //--------------------------------------------------------------------------
115 Int_t etaBin=0,ptBin=0,bin=0;
116 eta = TMath::Abs(eta);
118 /* this is how bins are numbered
131 if(eta < fEta->At(0)) {
133 } else if(eta > fEta->At(fNeta-1)) {
136 for(Int_t i=0; i<fNeta; i++) {
137 if(eta < fEta->At(i)) {
143 if(pt < fPt->At(0)) {
145 } else if(pt > fPt->At(fNpt-1)) {
148 for(Int_t i=0; i<fNpt; i++) {
149 if(pt < fPt->At(i)) {
156 bin = ptBin*(fNeta+1) + etaBin;
160 //--------------------------------------------------------------------------
161 Double_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);
169 //--------------------------------------------------------------------------
170 Double_t AliTPCkineGrid::GetValueAt(Double_t pt,Double_t eta) const {
171 //--------------------------------------------------------------------------
172 // This functions makes a linear interpolation at the point [pt,eta]
173 //--------------------------------------------------------------------------
175 // determine the points to be used in the interpolation:
178 eta = TMath::Abs(eta);
179 Int_t etaLow=0,etaUp=0;
180 if(eta < fEta->At(0)) {
183 } else if(eta >= fEta->At(fNeta-1)) {
187 for(Int_t i=0; i<fNeta; i++) {
188 if(eta < fEta->At(i)) {
197 Int_t ptLow=0,ptUp=0;
198 if(pt < fPt->At(0)) {
201 } else if(pt >= fPt->At(fNpt-1)) {
205 for(Int_t i=0; i<fNpt; i++) {
206 if(pt < fPt->At(i)) {
214 //cerr<<" Pt = ("<<ptLow<<","<<ptUp<<") Eta = ("<<etaLow<<","<<etaUp<<")\n";
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));
230 if(intValue<0.) intValue=0.;
233 //--------------------------------------------------------------------------
234 void 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);