Project
Loading...
Searching...
No Matches
Sector.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
16
26
27#ifndef AliceO2_TPC_Sector_H
28#define AliceO2_TPC_Sector_H
29
31#include "DataFormatsTPC/Defs.h"
32//using namespace AliceO2::TPC;
33
34namespace o2
35{
36namespace tpc
37{
38// enum RocType {ISector=0, OSector=1};
39
40class Sector
41{
42 public:
43 // the number of sectors
44 static constexpr int MAXSECTOR = constants::MAXSECTOR;
45
47 Sector() = default;
48
51 Sector(unsigned char sec) : mSector(sec % MAXSECTOR) { ; }
52
56 static Sector getLeft(const Sector s);
57
61 static Sector getRight(const Sector s);
62
64 bool operator==(const Sector& other) const { return mSector == other.mSector; }
65
67 bool operator!=(const Sector& other) const { return mSector != other.mSector; }
68
70 bool operator<(const Sector& other) const { return mSector < other.mSector; }
71
77 {
78 mLoop = ++mSector >= MAXSECTOR;
79 mSector %= MAXSECTOR;
80 return mLoop;
81 }
82
85 operator int() const { return int(mSector); }
86
88 Sector& operator=(int sector)
89 {
90 mSector = sector % MAXSECTOR;
91 return *this;
92 }
93
94 unsigned char getSector() const { return mSector; }
95
96 Side side() const { return (mSector < MAXSECTOR / 2) ? Side::A : Side::C; }
97
98 bool looped() const { return mLoop; }
99
100 double phi() const { return (mSector % SECTORSPERSIDE) * SECPHIWIDTH + SECPHIWIDTH / 2.; }
101
106 template <typename T>
107 static int ToSector(T x, T y, T z)
108 {
109 static const T invangle(static_cast<T>(180) / static_cast<T>(M_PI * 20.)); // the angle describing one sector
110 // force positive angle for conversion
111 auto s = (std::atan2(-y, -x) + static_cast<T>(M_PI)) * invangle;
112 // detect if on C size
113 if (z < static_cast<T>(0.)) {
114 s += Sector::MAXSECTOR / 2;
115 }
116 return s;
117 }
118
125 template <typename T>
126 static int ToShiftedSector(T x, T y, T z)
127 {
128 // static int ToSector(T x, T y, T z) {
129 constexpr T invangle{180. / (M_PI * 20.)}; // the angle describing one sector
130 constexpr T offset{M_PI + M_PI / 180. * 10.};
131 // force positive angle for conversion
132 auto s = static_cast<int>((std::atan2(-y, -x) + offset) * invangle) % 18;
133 // detect if on C size
134 if (z < static_cast<T>(0.)) {
135 s += Sector::MAXSECTOR / 2;
136 }
137 return s;
138 }
139
140 private:
141 unsigned char mSector{};
142 bool mLoop{};
143};
144
145inline Sector Sector::getLeft(const Sector s) { return Sector((s + 1) % 18 + (s > 17) * 18); }
146
147inline Sector Sector::getRight(const Sector s) { return Sector((s + 18 - 1) % 18 + (s > 17) * 18); }
148} // namespace tpc
149} // namespace o2
150
151#endif
Side side() const
Definition Sector.h:96
Sector & operator=(int sector)
assignment operator with int
Definition Sector.h:88
static int ToShiftedSector(T x, T y, T z)
Definition Sector.h:126
unsigned char getSector() const
Definition Sector.h:94
static Sector getLeft(const Sector s)
Definition Sector.h:145
bool operator<(const Sector &other) const
smaller operator
Definition Sector.h:70
double phi() const
Definition Sector.h:100
bool operator!=(const Sector &other) const
unequal operator
Definition Sector.h:67
static Sector getRight(const Sector s)
Definition Sector.h:147
Sector()=default
constructor
bool looped() const
Definition Sector.h:98
static int ToSector(T x, T y, T z)
Definition Sector.h:107
bool operator++()
Definition Sector.h:76
static constexpr int MAXSECTOR
Definition Sector.h:44
Sector(unsigned char sec)
Definition Sector.h:51
bool operator==(const Sector &other) const
comparison operator
Definition Sector.h:64
GLint GLenum GLint x
Definition glcorearb.h:403
GLintptr offset
Definition glcorearb.h:660
GLdouble GLdouble GLdouble z
Definition glcorearb.h:843
constexpr int MAXSECTOR
Definition Constants.h:28
constexpr double SECPHIWIDTH
Definition Defs.h:45
constexpr unsigned char SECTORSPERSIDE
Definition Defs.h:40
Side
TPC readout sidE.
Definition Defs.h:35
@ A
Definition Defs.h:35
@ C
Definition Defs.h:36
a couple of static helper functions to create timestamp values for CCDB queries or override obsolete ...
VectorOfTObjectPtrs other