Project
Loading...
Searching...
No Matches
IndexTableUtils.h
Go to the documentation of this file.
1// Copyright 2019-2020 CERN and copyright holders of ALICE O2.
2// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
3// All rights not expressly granted are reserved.
4//
5// This software is distributed under the terms of the GNU General Public
6// License v3 (GPL Version 3), copied verbatim in the file "COPYING".
7//
8// In applying this license CERN does not waive the privileges and immunities
9// granted to it by virtue of its status as an Intergovernmental Organization
10// or submit itself to any jurisdiction.
11
15#ifndef STRTRACKING_INCLUDE_INDEXTABLEUTILS_H_
16#define STRTRACKING_INCLUDE_INDEXTABLEUTILS_H_
17
18#include "TMath.h"
19
20namespace o2
21{
22namespace strangeness_tracking
23{
24
26 int getEtaBin(float eta);
27 int getPhiBin(float phi);
28 int getBinIndex(float eta, float phi);
29 std::vector<int> getBinRect(float eta, float phi, float deltaEta, float deltaPhi);
30 int mEtaBins = 128, mPhiBins = 128;
31 float minEta = -1.5, maxEta = 1.5;
32 float minPhi = 0., maxPhi = 2 * TMath::Pi();
33};
34
35inline int IndexTableUtils::getEtaBin(float eta)
36{
37 float deltaEta = (maxEta - minEta) / (mEtaBins);
38 int bEta = (eta - minEta) / deltaEta; // bins recentered to 0
39 return bEta;
40};
41
42inline int IndexTableUtils::getPhiBin(float phi)
43{
44 float deltaPhi = (maxPhi - minPhi) / (mPhiBins);
45 int bPhi = (phi - minPhi) / deltaPhi; // bin recentered to 0
46 return bPhi;
47}
48
49inline int IndexTableUtils::getBinIndex(float eta, float phi)
50{
51 float deltaPhi = (maxPhi - minPhi) / (mPhiBins);
52 float deltaEta = (maxEta - minEta) / (mEtaBins);
53 int bEta = getEtaBin(eta);
54 int bPhi = getPhiBin(phi);
55 return (bEta >= mEtaBins || bPhi >= mPhiBins || bEta < 0 || bPhi < 0) ? mEtaBins * mPhiBins : bEta + mEtaBins * bPhi;
56}
57
58inline std::vector<int> IndexTableUtils::getBinRect(float eta, float phi, float deltaEta, float deltaPhi)
59{
60 std::vector<int> idxVec;
61 int centralBin = getBinIndex(eta, phi);
62 if (centralBin == mPhiBins * mEtaBins) { // condition for overflows
63 idxVec.push_back(centralBin);
64 return idxVec;
65 }
66 int minEtaBin = TMath::Max(0, getEtaBin(eta - deltaEta));
67 int maxEtaBin = getEtaBin(eta + deltaEta);
68 int minPhiBin = TMath::Max(0, getPhiBin(phi - deltaPhi));
69 int maxPhiBin = getPhiBin(phi + deltaPhi);
70
71 for (int iPhi{minPhiBin}; iPhi <= maxPhiBin; iPhi++) {
72 if (iPhi >= mPhiBins) {
73 break;
74 }
75 for (int iEta{minEtaBin}; iEta <= maxEtaBin; iEta++) {
76 if (iEta >= mEtaBins) {
77 break;
78 }
79 idxVec.push_back(iEta + mEtaBins * iPhi);
80 }
81 }
82 return idxVec;
83};
84
85} // namespace strangeness_tracking
86} // namespace o2
87
88#endif
a couple of static helper functions to create timestamp values for CCDB queries or override obsolete ...
std::vector< int > getBinRect(float eta, float phi, float deltaEta, float deltaPhi)