]>
Commit | Line | Data |
---|---|---|
4a01bb2c | 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 | /* $Id: AliJetGrid.cxx,v 1.0 07/09/2006 */ | |
17 | ||
18 | //========================================================================= | |
19 | // *** 07 September 2006 | |
20 | // This class allows to fill a really general grid in (eta,phi) | |
21 | // Two types of grid can be setted : | |
22 | // if fGrid==0 -> the complete acceptance of a rectangular detector acceptance is filled | |
23 | // if fGrid==1 -> the previous grid - an other rectangular detector acceptance is filled | |
24 | // A (eta,phi(rad)) position can be extracted from an index value without looping over all entries | |
25 | // An index position can be extracted from a (eta,phi(rad)) position without looping over all entries | |
26 | // | |
27 | // How to run it : | |
28 | // > AliJetGrid *grid = new AliJetGrid((NbinPhi-1),(NbinEta-1),PhiMin,PhiMax,EtaMin,EtaMax); | |
29 | // > grid->SetGridType(...); // 0 or 1 for the moment | |
30 | // > grid->SetMatrixIndexes(); | |
31 | // > grid->SetIndexIJ(); | |
32 | // | |
8838ab7a | 33 | // Author : magali.estienne@subatech.in2p3.fr |
4a01bb2c | 34 | //========================================================================= |
35 | ||
36 | // Standard headers | |
37 | #include <Riostream.h> | |
38 | // Root headers | |
37b09b91 | 39 | #include <TMath.h> |
4a01bb2c | 40 | #include <TMatrixD.h> |
41 | #include <TArrayD.h> | |
42 | #include <TArrayI.h> | |
43 | // AliRoot headers | |
44 | #include "AliJetGrid.h" | |
45 | ||
87f40625 | 46 | ClassImp(AliJetGrid) |
4a01bb2c | 47 | |
b92e2ccf | 48 | //__________________________________________________________ |
49 | AliJetGrid::AliJetGrid(): | |
8838ab7a | 50 | fGrid(0), |
51 | fNphi(0), | |
52 | fNeta(0), | |
53 | fPhi(0), | |
54 | fEta(0), | |
55 | fIndex(0), | |
56 | fIndexI(0), | |
57 | fIndexJ(0), | |
58 | fPhiMin(0), | |
59 | fPhiMax(0), | |
60 | fEtaMin(0), | |
61 | fEtaMax(0), | |
62 | fEtaBinInTPCAcc(0), | |
63 | fPhiBinInTPCAcc(0), | |
64 | fEtaBinInEMCalAcc(0), | |
65 | fPhiBinInEMCalAcc(0), | |
66 | fNbinEta(0), | |
67 | fNbinPhi(0), | |
68 | fMaxPhi(0), | |
69 | fMinPhi(0), | |
70 | fMaxEta(0), | |
71 | fMinEta(0), | |
72 | fDebug(1) | |
73 | { | |
4a01bb2c | 74 | // Default constructor |
4a01bb2c | 75 | } |
76 | ||
77 | //__________________________________________________________ | |
b92e2ccf | 78 | AliJetGrid::AliJetGrid(Int_t nphi,Int_t neta,Double_t phiMin,Double_t phiMax,Double_t etaMin,Double_t etaMax): |
8838ab7a | 79 | fGrid(0), |
80 | fNphi(nphi), | |
81 | fNeta(neta), | |
82 | fPhi(0), | |
83 | fEta(0), | |
84 | fIndex(0), | |
85 | fIndexI(0), | |
86 | fIndexJ(0), | |
87 | fPhiMin(0), | |
88 | fPhiMax(0), | |
89 | fEtaMin(0), | |
90 | fEtaMax(0), | |
91 | fEtaBinInTPCAcc(0), | |
92 | fPhiBinInTPCAcc(0), | |
93 | fEtaBinInEMCalAcc(0), | |
94 | fPhiBinInEMCalAcc(0), | |
95 | fNbinEta(0), | |
96 | fNbinPhi(0), | |
97 | fMaxPhi(phiMax), | |
98 | fMinPhi(phiMin), | |
99 | fMaxEta(etaMax), | |
100 | fMinEta(etaMin), | |
101 | fDebug(1) | |
102 | { | |
4a01bb2c | 103 | // Standard constructor |
b92e2ccf | 104 | fPhi = new TArrayD(fNphi+1); |
105 | fEta = new TArrayD(fNeta+1); | |
4a01bb2c | 106 | fIndexI = new TArrayI((fNeta+1)*(fNphi+1)+1); |
107 | fIndexJ = new TArrayI((fNeta+1)*(fNphi+1)+1); | |
b92e2ccf | 108 | |
8838ab7a | 109 | for(Int_t i=0; i<fNphi+1; i++) { |
110 | if(fNphi!=0) (*fPhi)[i] = (phiMax-phiMin)/fNphi*i+phiMin; | |
111 | else (*fPhi)[i] = phiMin+(phiMax-phiMin)/2; | |
112 | } | |
113 | for(Int_t i=0; i<fNeta+1; i++) { | |
114 | if(fNeta!=0) (*fEta)[i] = (etaMax-etaMin)/fNeta*i+etaMin; | |
115 | else (*fEta)[i] = etaMin+(etaMax-etaMin)/2; | |
116 | } | |
b92e2ccf | 117 | |
4a01bb2c | 118 | if(fDebug > 3){ |
b92e2ccf | 119 | for(Int_t i=0; i<(fNphi+1); i++) cout << (*fPhi)[i] << endl; |
120 | for(Int_t i=0; i<(fNeta+1); i++) cout << (*fEta)[i] << endl; | |
4a01bb2c | 121 | } |
b92e2ccf | 122 | |
4a01bb2c | 123 | fIndex = new TMatrixD(fNphi+1,fNeta+1); |
b92e2ccf | 124 | |
4a01bb2c | 125 | } |
126 | ||
127 | //__________________________________________________________ | |
8838ab7a | 128 | AliJetGrid::AliJetGrid(const AliJetGrid& grid) : |
129 | TNamed(grid), | |
130 | fGrid(grid.fGrid), | |
131 | fNphi(grid.fNphi), | |
132 | fNeta(grid.fNeta), | |
133 | fPhi(0), | |
134 | fEta(0), | |
135 | fIndex(0), | |
136 | fIndexI(grid.fIndexI), | |
137 | fIndexJ(grid.fIndexJ), | |
138 | fPhiMin(grid.fPhiMin), | |
139 | fPhiMax(grid.fPhiMax), | |
140 | fEtaMin(grid.fEtaMin), | |
141 | fEtaMax(grid.fEtaMax), | |
142 | fEtaBinInTPCAcc(grid.fEtaBinInTPCAcc), | |
143 | fPhiBinInTPCAcc(grid.fPhiBinInTPCAcc), | |
144 | fEtaBinInEMCalAcc(grid.fEtaBinInEMCalAcc), | |
145 | fPhiBinInEMCalAcc(grid.fPhiBinInEMCalAcc), | |
146 | fNbinEta(grid.fNbinEta), | |
147 | fNbinPhi(grid.fNbinPhi), | |
148 | fMaxPhi(grid.fMaxPhi), | |
149 | fMinPhi(grid.fMinPhi), | |
150 | fMaxEta(grid.fMaxEta), | |
151 | fMinEta(grid.fMinEta), | |
152 | fDebug(grid.fDebug) | |
9e4cc50d | 153 | { |
4a01bb2c | 154 | |
155 | // Copy constructor | |
156 | ||
4a01bb2c | 157 | fPhi = new TArrayD(fNphi+1); |
158 | for(Int_t i=0; i<fNphi+1; i++) (*fPhi)[i] = grid.fPhi->At(i); | |
159 | fEta = new TArrayD(fNeta+1); | |
160 | for(Int_t i=0; i<fNeta+1; i++) (*fEta)[i] = grid.fEta->At(i); | |
161 | ||
162 | fIndex = new TMatrixD(fNphi+1,fNeta+1); | |
163 | for(Int_t i=0; i<fNphi+1; i++) { | |
164 | for(Int_t j=0; j<fNeta+1; j++) (*fIndex)(i,j)=(*grid.fIndex)(i,j); | |
165 | } | |
166 | } | |
167 | ||
9e4cc50d | 168 | |
169 | AliJetGrid& AliJetGrid::operator=(const AliJetGrid& other) | |
170 | { | |
8838ab7a | 171 | // Assignment |
53cf790b | 172 | if (this != &other) { |
173 | fGrid = other.fGrid; | |
174 | fNphi = other.fNphi; | |
175 | fNeta = other.fNeta; | |
176 | fPhi = 0; | |
177 | fEta = 0; | |
178 | fIndex = 0; | |
179 | fIndexI = other.fIndexI; | |
180 | fIndexJ = other.fIndexJ; | |
181 | fPhiMin = other.fPhiMin; | |
182 | fPhiMax = other.fPhiMax; | |
183 | fEtaMin = other.fEtaMin; | |
184 | fEtaMax = other.fEtaMax; | |
185 | fEtaBinInTPCAcc = other.fEtaBinInTPCAcc; | |
186 | fPhiBinInTPCAcc = other.fPhiBinInTPCAcc; | |
187 | fEtaBinInEMCalAcc = other.fEtaBinInEMCalAcc; | |
188 | fPhiBinInEMCalAcc = other.fPhiBinInEMCalAcc; | |
189 | fNbinEta = other.fNbinEta; | |
190 | fNbinPhi = other.fNbinPhi; | |
191 | fMaxPhi = other.fMaxPhi; | |
192 | fMinPhi = other.fMinPhi; | |
193 | fMaxEta = other.fMaxEta; | |
194 | fMinEta = other.fMinEta; | |
195 | fDebug = other.fDebug; | |
196 | fPhi = new TArrayD(fNphi+1); | |
197 | for(Int_t i=0; i<fNphi+1; i++) (*fPhi)[i] = other.fPhi->At(i); | |
198 | fEta = new TArrayD(fNeta+1); | |
199 | for(Int_t i=0; i<fNeta+1; i++) (*fEta)[i] = other.fEta->At(i); | |
8838ab7a | 200 | |
53cf790b | 201 | fIndex = new TMatrixD(fNphi+1,fNeta+1); |
202 | for(Int_t i=0; i<fNphi+1; i++) { | |
203 | for(Int_t j=0; j<fNeta+1; j++) (*fIndex)(i,j)=(*other.fIndex)(i,j); | |
204 | } | |
205 | } | |
206 | ||
207 | return *this; | |
9e4cc50d | 208 | } |
209 | ||
4a01bb2c | 210 | //__________________________________________________________ |
211 | AliJetGrid::~AliJetGrid() { | |
212 | ||
213 | // Destructor | |
214 | delete fPhi; | |
215 | delete fEta; | |
216 | delete fIndexI; | |
217 | delete fIndexJ; | |
218 | delete fIndex; | |
219 | } | |
220 | ||
221 | //__________________________________________________________ | |
222 | void AliJetGrid::InitParams(Double_t phiMinCal,Double_t phiMaxCal,Double_t etaMinCal,Double_t etaMaxCal) | |
d980dfdb | 223 | { |
224 | // To set initial parameters | |
4a01bb2c | 225 | |
226 | fPhiMin = phiMinCal; // rad | |
227 | fPhiMax = phiMaxCal; // rad | |
228 | fEtaMin = etaMinCal; | |
229 | fEtaMax = etaMaxCal; | |
230 | fNbinPhi = static_cast<int>(fPhiMin/(2*TMath::Pi()/fNphi)); | |
231 | ||
232 | // Define some binning numbers | |
233 | if(fGrid==0){ | |
234 | for(Int_t i=0; i<fNphi+1; i++) fPhiBinInTPCAcc++; | |
235 | fPhiBinInEMCalAcc = 0; | |
236 | ||
237 | for(Int_t i=0; i<fNeta+1; i++) fEtaBinInTPCAcc++; | |
238 | fEtaBinInEMCalAcc = 0; | |
239 | } | |
240 | ||
241 | if(fGrid==1){ | |
242 | for(Int_t i=0; i<fNphi+1; i++) { | |
243 | fPhiBinInTPCAcc++; | |
244 | if(fPhi->At(i) >= fPhiMin && | |
245 | fPhi->At(i) <= fPhiMax) | |
246 | fPhiBinInEMCalAcc++; | |
247 | } | |
248 | for(Int_t i=0; i<fNeta+1; i++) { | |
249 | fEtaBinInTPCAcc++; | |
250 | if((fEta->At(i) >= fEtaMin) && | |
251 | (fEta->At(i) <= fEtaMax)) | |
252 | fEtaBinInEMCalAcc++; | |
253 | } | |
254 | } | |
255 | ||
256 | } | |
257 | ||
258 | //__________________________________________________________ | |
259 | TArrayD* AliJetGrid::GetArrayEta() | |
d980dfdb | 260 | { |
261 | // Returns an array with the eta points | |
4a01bb2c | 262 | |
263 | return fEta; | |
264 | ||
265 | } | |
266 | ||
267 | //__________________________________________________________ | |
268 | TArrayD* AliJetGrid::GetArrayPhi() | |
d980dfdb | 269 | { |
270 | // Returns an array with the phi points | |
4a01bb2c | 271 | |
272 | return fPhi; | |
273 | ||
274 | } | |
275 | ||
276 | //__________________________________________________________ | |
277 | TMatrixD* AliJetGrid::GetIndexObject() | |
d980dfdb | 278 | { |
279 | // Returns a pointer to the matrix | |
4a01bb2c | 280 | |
281 | return fIndex; | |
282 | ||
283 | } | |
284 | ||
285 | //__________________________________________________________ | |
286 | void AliJetGrid::GetAccParam(Int_t &nphi, Int_t &neta, Float_t &minphi, Float_t &maxphi, | |
d980dfdb | 287 | Float_t &mineta, Float_t &maxeta) const |
288 | { | |
289 | // Returns EMCAL acceptance initially setted | |
4a01bb2c | 290 | |
291 | nphi = fNphi; | |
292 | neta = fNeta; | |
293 | minphi = fPhiMin; | |
294 | maxphi = fPhiMax; | |
295 | mineta = fEtaMin; | |
296 | maxeta = fEtaMax; | |
297 | } | |
298 | ||
299 | //__________________________________________________________ | |
300 | void AliJetGrid::GetBinParam(Int_t &phibintpc, Int_t &etabintpc, | |
d980dfdb | 301 | Int_t &phibinemc, Int_t &etabinemc, Int_t &nbinphi) const |
302 | { | |
303 | // Returns number of bins in TPC and EMCAL geometry | |
4a01bb2c | 304 | |
305 | etabintpc = fEtaBinInTPCAcc; | |
306 | phibintpc = fPhiBinInTPCAcc; | |
307 | etabinemc = fEtaBinInEMCalAcc; | |
308 | phibinemc = fPhiBinInEMCalAcc; | |
309 | nbinphi = fNbinPhi; | |
310 | } | |
311 | ||
312 | //__________________________________________________________ | |
313 | Int_t AliJetGrid::GetIndexFromEtaPhi(Double_t phi,Double_t eta) const | |
d980dfdb | 314 | { |
315 | // Tells the index value of a corresponding (eta,phi) real position | |
316 | // Loop over all entries -> takes time. | |
317 | // Used one time at the begining to fill the grids | |
4a01bb2c | 318 | |
319 | /* this is how bins are numbered | |
320 | ||
321 | in all TPC or in TPC - EMCAL | |
322 | ... ... ... .. | |
323 | --------------- | |
324 | ... ... . 10 | | | 11 | |
325 | ---+---+--- --------------- | |
326 | ^ 6 | 7 | 8 or 8 | | | 9 | |
327 | | ---+---+--- --------------- | |
328 | 3 | 4 | 5 4 | 5 | 6 | 7 | |
329 | phi ---+---+--- --------------- | |
330 | 0 | 1 | 2 0 | 1 | 2 | 3 | |
331 | ||
332 | ||
333 | eta -> | |
334 | */ | |
335 | ||
336 | Int_t etaBin=0,phiBin=0,absID=0; | |
337 | Int_t etaBin2=0,etaBin3=0; | |
338 | ||
339 | // Fill all the grid in eta/phi (all TPC acceptance) | |
340 | //----------------------------------------------------- | |
341 | if(fGrid==0){ | |
342 | if(eta <= fEta->At(0)) { | |
343 | etaBin = 0; | |
344 | } else if(eta >= fEta->At(fNeta)) { | |
345 | etaBin = fNeta; | |
346 | } else { | |
347 | for(Int_t i=0; i<fNeta+1; i++) { | |
348 | if(eta < fEta->At(i)) { | |
349 | etaBin = i-1; | |
350 | break; | |
351 | } | |
352 | } | |
353 | } | |
354 | if(phi <= fPhi->At(0)) { | |
355 | phiBin = 0; | |
356 | } else if(phi >= fPhi->At(fNphi)) { | |
357 | phiBin = fNphi; | |
358 | } else { | |
359 | for(Int_t i=0; i<fNphi+1; i++) { | |
360 | if(phi < fPhi->At(i)) { | |
361 | phiBin = i-1; | |
362 | break; | |
363 | } | |
364 | } | |
365 | } | |
366 | ||
367 | // Calculate absolute id | |
368 | absID = phiBin*(fNeta+1) + etaBin; | |
369 | ||
370 | } | |
371 | ||
372 | // Fill the grid but do not count id in EMCal acceptance | |
373 | //------------------------------------------------------ | |
374 | if((eta >= fEtaMin && eta <= fEtaMax) && | |
375 | (phi >= fPhiMin && phi <= fPhiMax)){ | |
376 | etaBin = etaBin2 = etaBin3 = -1; | |
377 | phiBin = -1; | |
378 | } | |
379 | ||
380 | if(fGrid == 1){ | |
381 | if(phi<fPhiMin) { | |
382 | if(eta <= fEta->At(0)) { | |
383 | etaBin = 0; | |
384 | } else if(eta >= fEta->At(fNeta)) { | |
385 | etaBin = fNeta; | |
386 | } else { | |
387 | for(Int_t i=0; i<fNeta+1; i++) { | |
388 | if(eta < fEta->At(i)) { | |
389 | etaBin = i-1; | |
390 | break; | |
391 | } | |
392 | } | |
393 | } | |
394 | } | |
395 | else { | |
396 | if((phi>=fPhiMin) && (phi<=fPhiMax)) { | |
397 | if(eta <= fEta->At(0)) { | |
398 | etaBin2 = 0; | |
399 | } else if(eta >= fEta->At(fNeta)) { | |
400 | etaBin2 = fNeta-fEtaBinInEMCalAcc; | |
401 | } else { | |
402 | for(Int_t i=0; i<fNeta+1; i++) { | |
403 | if(eta < fEta->At(i) && ((fEta->At(0)<eta && eta<fEtaMin) || | |
404 | (fEtaMax<eta && eta<fEta->At(fNeta)))) { | |
405 | // cout << "i : " << i << endl; | |
406 | if(eta<fEtaMin) | |
407 | etaBin2 = i-1; | |
408 | else etaBin2 = i-1-fEtaBinInEMCalAcc; | |
409 | break; | |
410 | } | |
411 | } | |
412 | } | |
413 | } | |
414 | else { | |
415 | if(eta <= fEta->At(0)) { | |
416 | etaBin3 = 0; | |
417 | } else if(eta >= fEta->At(fNeta)) { | |
418 | etaBin3 = fNeta; | |
419 | } else { | |
420 | for(Int_t i=0; i<fNeta+1; i++) { | |
421 | if(eta < fEta->At(i)) { | |
422 | etaBin3 = i-1; | |
423 | break; | |
424 | } | |
425 | } | |
426 | } | |
427 | } | |
428 | } | |
429 | ||
430 | if(phi <= fPhi->At(0)) { | |
431 | phiBin = 0; | |
432 | } else if(phi >= fPhi->At(fNphi)) { | |
433 | phiBin = fNphi; | |
434 | } else { | |
435 | for(Int_t i=0; i<fNphi+1; i++) { | |
436 | if(phi < fPhi->At(i)) { | |
437 | phiBin = i-1; | |
438 | break; | |
439 | } | |
440 | } | |
441 | } | |
442 | ||
443 | // Calculate absID | |
444 | //------------------------------------------------------- | |
445 | if(phi<fPhiMin) | |
446 | absID = phiBin*(fNeta+1) + etaBin; | |
447 | if(phi>=fPhiMin && phi<=fPhiMax) { | |
448 | if(eta >= fEtaMin && eta <= fEtaMax) absID = -1; | |
449 | else{ | |
450 | absID = (fNbinPhi+1)*(fNeta+1) | |
451 | + (phiBin-fNbinPhi-1)*((fEtaBinInTPCAcc-fEtaBinInEMCalAcc)) | |
452 | + etaBin2; | |
453 | } | |
454 | } | |
455 | if(phi>fPhiMax) | |
456 | absID = (fNbinPhi+1)*(fNeta+1) | |
457 | + fPhiBinInEMCalAcc*((fEtaBinInTPCAcc-fEtaBinInEMCalAcc)) | |
458 | + (phiBin-(fNbinPhi+1+fPhiBinInEMCalAcc))*(fNeta+1) | |
459 | + etaBin3; | |
460 | ||
461 | } // END OPTION==1 | |
462 | ||
463 | return absID; | |
464 | ||
465 | } | |
466 | ||
467 | //__________________________________________________________ | |
468 | void AliJetGrid::GetEtaPhiFromIndex(Int_t index, Float_t &eta, Float_t &phi) | |
d980dfdb | 469 | { |
470 | // Get (eta,phi) position for a given index BUT loop over all entries (takes time) | |
4a01bb2c | 471 | |
472 | for(Int_t j=0; j<fNphi+1; j++) { | |
473 | for(Int_t i=0; i<fNeta+1; i++) { | |
474 | ||
475 | // TPC grid only | |
476 | //------------------------------------- | |
477 | if(fGrid==0) { | |
478 | if(j*(fNeta+1)+i == index) { | |
479 | eta = fEta->At(i); | |
480 | phi = fPhi->At(j); | |
481 | } | |
482 | } | |
483 | ||
484 | // TPC-EMCAL grid | |
485 | //------------------------------------- | |
486 | Int_t ii = 0; | |
487 | if(i==0) ii = 0; | |
488 | if(i>0 && i<(fEtaBinInTPCAcc-fEtaBinInEMCalAcc)/2) ii = i; | |
489 | if(i>=(fEtaBinInTPCAcc+fEtaBinInEMCalAcc)/2 && i<fNeta+1) ii = i-fEtaBinInEMCalAcc; | |
490 | ||
491 | if(fGrid==1) { | |
492 | if(j<(fNbinPhi+1) && j*(fNeta+1)+i == index) { | |
493 | eta = fEta->At(i); | |
494 | phi = fPhi->At(j); | |
495 | } | |
496 | ||
497 | if((j>=(fNbinPhi+1) && j<(fNbinPhi+1+fPhiBinInEMCalAcc)) && | |
498 | ((fNbinPhi+1)*(fNeta+1) + (j-fNbinPhi-1)*(fEtaBinInTPCAcc-fEtaBinInEMCalAcc) + ii)== index ) { | |
499 | if(ii==0) {Int_t ind = 0; eta = fEta->At(ind);} | |
500 | else eta = fEta->At(i); | |
501 | phi = fPhi->At(j); | |
502 | } | |
503 | ||
504 | if(j>=(fNbinPhi+1+fPhiBinInEMCalAcc) && | |
505 | ((fNbinPhi+1)*(fNeta+1)+fPhiBinInEMCalAcc*((fEtaBinInTPCAcc-fEtaBinInEMCalAcc)) | |
506 | +(j-(fNbinPhi+1+fPhiBinInEMCalAcc))*(fNeta+1)+i == index)) { | |
507 | eta = fEta->At(i); | |
508 | phi = fPhi->At(j); | |
509 | } | |
510 | } | |
511 | } | |
512 | } | |
513 | } | |
514 | ||
515 | //__________________________________________________________ | |
516 | Int_t AliJetGrid::GetIndex(Double_t phi, Double_t eta) | |
d980dfdb | 517 | { |
518 | // Get index value for a (eta,phi) position - Direct value | |
4a01bb2c | 519 | |
520 | Int_t ieta = GetIndexJFromEta(eta); | |
521 | Int_t iphi = GetIndexIFromPhi(phi); | |
522 | ||
523 | Int_t index = GetMatrixIndex(iphi,ieta); | |
524 | ||
525 | if(fDebug>10){ | |
526 | cout << "(phi,eta) : " << phi << ", " << eta << endl; | |
527 | cout << "index : " << index << endl; | |
528 | } | |
529 | return index; | |
530 | ||
531 | } | |
532 | ||
533 | //__________________________________________________________ | |
534 | Int_t AliJetGrid::GetIndexJFromEta(Double_t eta) | |
d980dfdb | 535 | { |
536 | // Get eta id | |
537 | // Eta discretized | |
4a01bb2c | 538 | |
539 | Int_t idEta =0; | |
540 | Double_t temp = (eta+fMaxEta)/(fMaxEta-fMinEta)*fNeta; | |
541 | if(fDebug>20) | |
542 | { | |
543 | cout << "eta : " << eta << endl; | |
544 | cout << "fMaxEta : " << fMaxEta << endl; | |
545 | cout << "fMinEta : " << fMinEta << endl; | |
546 | cout << "fNeta : " << fNeta << endl; | |
547 | cout << "temp eta before cast : " << temp << endl; | |
548 | } | |
549 | idEta = static_cast<Int_t>(temp+0.5); | |
550 | if(fDebug>20) cout << "temp eta after cast : " << idEta << endl; | |
551 | return idEta; | |
552 | } | |
553 | //__________________________________________________________ | |
554 | Int_t AliJetGrid::GetIndexIFromPhi(Double_t phi) | |
d980dfdb | 555 | { |
556 | // Get phi id | |
557 | // Phi discretized | |
4a01bb2c | 558 | |
559 | Int_t idPhi = 0; | |
560 | Double_t temp = 0.; | |
561 | if(fMinPhi==0) temp = phi/(fMaxPhi-fMinPhi)*fNphi; | |
562 | else temp = (phi-fMinPhi)/(fMaxPhi-fMinPhi)*fNphi; | |
563 | ||
564 | if(fDebug>20) | |
565 | { | |
566 | cout << "phi : " << phi << endl; | |
567 | cout << "fMaxPhi : " << fMaxPhi << endl; | |
568 | cout << "fMinPhi : " << fMinPhi << endl; | |
569 | cout << "fNphi : " << fNphi << endl; | |
570 | cout << "temp phi before cast : " << temp << endl; | |
571 | } | |
572 | idPhi = static_cast<Int_t>(temp+0.5); | |
573 | if(fDebug>20) cout << "temp phi after cast : " << idPhi << endl; | |
574 | return idPhi; | |
575 | ||
576 | ||
577 | } | |
578 | ||
579 | //__________________________________________________________ | |
580 | void AliJetGrid::SetMatrixIndex(Int_t i,Double_t par) | |
d980dfdb | 581 | { |
582 | // Allows to set parameters using only one index (if fGrid==0) !! | |
583 | // Not used ! | |
4a01bb2c | 584 | |
585 | Int_t iphi = (Int_t)i/fNeta; | |
586 | Int_t ieta = i-iphi*fNeta; | |
587 | SetMatrixIndex(iphi,ieta,par); | |
588 | ||
589 | return; | |
590 | } | |
591 | ||
592 | //__________________________________________________________ | |
593 | void AliJetGrid::SetMatrixIndexes() | |
d980dfdb | 594 | { |
595 | // Fill the final matrix object with the corresponding index in eta/phi | |
4a01bb2c | 596 | |
597 | for(Int_t i=0; i<fNphi+1; i++){ | |
598 | for(Int_t j=0; j<fNeta+1; j++){ | |
599 | (*fIndex)(i,j) = GetIndexFromEtaPhi(fPhi->At(i),fEta->At(j))+1; | |
600 | if(fDebug>2){ | |
601 | cout << "(*fIndex)(" << i << "," << j << ") : " << (*fIndex)(i,j) << | |
602 | ", phi : " << fPhi->At(i) << ", eta : " << fEta->At(j) << endl; | |
603 | } | |
604 | } | |
605 | } | |
606 | printf("##########################################################\n"); | |
607 | printf("TMatrix object filled !\n"); | |
608 | printf("Size of the object : phi x eta = (fNphi+1) x (fNeta+1) = %d\n",(fNphi+1)*(fNeta+1)); | |
609 | printf("##########################################################\n"); | |
610 | } | |
611 | ||
612 | //__________________________________________________________ | |
613 | void AliJetGrid::SetIndexIJ() | |
d980dfdb | 614 | { |
615 | // Set the grid index | |
4a01bb2c | 616 | |
617 | for(Int_t i=0; i<fNphi+1; i++){ | |
618 | for(Int_t j=0; j<fNeta+1; j++){ | |
619 | Int_t id = static_cast<Int_t>((*fIndex)(i,j)); | |
620 | ||
621 | if(id!=-1) | |
622 | { | |
623 | (*fIndexI)[id] = i; | |
624 | (*fIndexJ)[id] = j; | |
625 | } | |
626 | } | |
627 | } | |
628 | ||
629 | printf("##########################################################\n"); | |
630 | printf(" In SetIndexIJ - Grid indexes setted !\n"); | |
631 | printf("##########################################################\n"); | |
632 | } | |
633 | ||
634 | //__________________________________________________________ | |
69f1d947 | 635 | void AliJetGrid::GetIJFromIndex(Int_t index, Int_t& i, Int_t& j) const |
d980dfdb | 636 | { |
637 | // Returns i position id of eta and j position id of phi for a given grid index | |
4a01bb2c | 638 | i = (*fIndexI)[index]; |
639 | j = (*fIndexJ)[index]; | |
640 | } | |
641 | ||
642 | //__________________________________________________________ | |
643 | void AliJetGrid::GetEtaPhiFromIndex2(Int_t index, Float_t &phi, Float_t &eta) | |
d980dfdb | 644 | { |
645 | // Returns eta, phi values for a given grid index | |
4a01bb2c | 646 | |
647 | phi = fPhi->At((*fIndexI)[index]); | |
648 | eta = fEta->At((*fIndexJ)[index]); | |
649 | } | |
650 | ||
651 | //__________________________________________________________ | |
652 | Int_t AliJetGrid::GetNEntries() | |
d980dfdb | 653 | { |
654 | // Returns the number of entries of the grid | |
4a01bb2c | 655 | |
656 | if(fDebug>20){ | |
657 | cout << "fMaxPhi : " << fMaxPhi << endl; | |
658 | cout << "fMaxEta : " << fMaxEta << endl; | |
659 | } | |
660 | ||
661 | Int_t indexNum = GetIndex(fMaxPhi,fMaxEta); | |
662 | if(fDebug>20) cout << "indexNum : " << indexNum << endl; | |
663 | return indexNum; | |
664 | ||
665 | } | |
666 | ||
667 | //__________________________________________________________ | |
668 | Int_t AliJetGrid::GetNEntries2() | |
d980dfdb | 669 | { |
670 | // Returns the number of entries of the grid | |
4a01bb2c | 671 | |
672 | Int_t indexNum = GetIndex(fMaxPhi-1.,fMaxEta-0.5); | |
673 | if(fDebug>20) cout << "indexNum : " << indexNum << endl; | |
674 | return indexNum; | |
675 | ||
676 | } | |
677 | ||
678 | ||
679 | ||
680 | ||
681 | ||
682 |