Project
Loading...
Searching...
No Matches
BaseCluster.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
12#ifndef ALICEO2_BASE_BASECLUSTER_H
13#define ALICEO2_BASE_BASECLUSTER_H
14
15#include <MathUtils/Cartesian.h>
16#include "GPUCommonRtypes.h"
17#ifndef GPUCA_GPUCODE
19#include <bitset>
20#include <iomanip>
21#include <ios>
22#include <iosfwd>
23#endif
24
25namespace o2
26{
27// Basic cluster class with X,Y,Z position detector ID information + user fields
28// The position is ALWAYS stored in tracking frame and is misaligned (in opposite
29// to AliRoot). The errors are defined in *ideal* tracking frame
30// DetectorID should correspond to continuous (no jumps between detector layers
31// planes etc.) internal sensor ID within detector
32template <typename T>
34{
35 private:
36 math_utils::Point3D<T> mPos; // cartesian position
37 T mSigmaY2; // error in Y direction (usually rphi)
38 T mSigmaZ2; // error in Z direction (usually Z)
39 T mSigmaYZ; // non-diagonal term of error matrix
40 std::uint16_t mSensorID = 0; // the sensor id
41 std::int8_t mCount = 0; // user field reserved for counting
42 std::uint8_t mBits = 0; // user field reserved for bit flags
43 enum masks_t : std::int32_t { kUserBitsMask = 0xff };
44
45 public:
46 BaseCluster() = default;
47 ~BaseCluster() = default;
48
49 // constructor
50 BaseCluster(std::uint16_t sensid, const math_utils::Point3D<T>& xyz) : mPos(xyz), mSensorID(sensid) {}
51 BaseCluster(std::uint16_t sensid, T x, T y, T z) : mPos(x, y, z), mSensorID(sensid) {}
52 BaseCluster(std::uint16_t sensid, const math_utils::Point3D<T>& xyz, T sy2, T sz2, T syz)
53 : mPos(xyz), mSigmaY2(sy2), mSigmaZ2(sz2), mSigmaYZ(syz), mSensorID(sensid)
54 {
55 }
56 BaseCluster(std::int16_t sensid, T x, T y, T z, T sy2, T sz2, T syz)
57 : mPos(x, y, z), mSigmaY2(sy2), mSigmaZ2(sz2), mSigmaYZ(syz), mSensorID(sensid)
58 {
59 }
60
61 // getting the cartesian coordinates and errors
62 T getX() const { return mPos.X(); }
63 T getY() const { return mPos.Y(); }
64 T getZ() const { return mPos.Z(); }
65 T getSigmaY2() const { return mSigmaY2; }
66 T getSigmaZ2() const { return mSigmaZ2; }
67 T getSigmaYZ() const { return mSigmaYZ; }
68 math_utils::Point3D<T> getXYZ() const { return mPos; }
69 math_utils::Point3D<T>& getXYZ() { return mPos; }
70#ifndef GPUCA_GPUCODE
71 // position in local frame, no check for matrices cache validity
72 math_utils::Point3D<T> getXYZLoc(const o2::detectors::DetMatrixCache& dm) const { return dm.getMatrixT2L(mSensorID)(mPos); }
73 // position in global frame, no check for matrices cache validity
74 math_utils::Point3D<T> getXYZGlo(const o2::detectors::DetMatrixCache& dm) const { return dm.getMatrixT2G(mSensorID)(mPos); }
75 // position in global frame obtained as simple rotation from tracking one:
76 // much faster for barrel detectors than using full 3D matrix.
77 // no check for matrices cache validity
79#endif
80 // get sensor id
81 std::int16_t getSensorID() const { return mSensorID; }
82 // get count field
83 std::int8_t getCount() const { return mCount; }
84 // get bit field
85 std::uint8_t getBits() const { return mBits; }
86 bool isBitSet(int bit) const { return mBits & (0xff & (0x1 << bit)); }
87 // cast to Point3D
88 operator math_utils::Point3D<T>&() { return mPos; }
89 // modifiers
90
91 // set sensor id
92 void setSensorID(std::int16_t sid) { mSensorID = sid; }
93 // set count field
94 void setCount(std::int8_t c) { mCount = c; }
95 // set bit field
96 void setBits(std::uint8_t b) { mBits = b; }
97 void setBit(int bit) { mBits |= kUserBitsMask & (0x1 << bit); }
98 void resetBit(int bit) { mBits &= ~(kUserBitsMask & (0x1 << bit)); }
99 // set position and errors
100 void setX(T x) { mPos.SetX(x); }
101 void setY(T y) { mPos.SetY(y); }
102 void setZ(T z) { mPos.SetZ(z); }
103 void setXYZ(T x, T y, T z)
104 {
105 setX(x);
106 setY(y);
107 setZ(z);
108 }
109 void setPos(const math_utils::Point3D<T>& p) { mPos = p; }
110 void setSigmaY2(T v) { mSigmaY2 = v; }
111 void setSigmaZ2(T v) { mSigmaZ2 = v; }
112 void setSigmaYZ(T v) { mSigmaYZ = v; }
113 void setErrors(T sy2, T sz2, T syz)
114 {
115 setSigmaY2(sy2);
116 setSigmaZ2(sz2);
117 setSigmaYZ(syz);
118 }
119
120 protected:
122};
123
124#ifndef GPUCA_GPUCODE
125template <class T>
126std::ostream& operator<<(std::ostream& os, const BaseCluster<T>& c)
127{
128 // stream itself
129 os << "SId" << std::setw(5) << c.getSensorID() << " (" << std::showpos << std::scientific
130 << c.getX() << "," << c.getY() << "," << c.getZ() << ")/("
131 << c.getSigmaY2() << "," << c.getSigmaYZ() << "," << c.getSigmaZ2()
132 << ") cnt:" << std::setw(4) << +c.getCount() << " bits:" << std::bitset<8>(c.getBits());
133 return os;
134}
135#endif
136} // namespace o2
137#endif
uint32_t c
Definition RawData.h:2
void setSigmaZ2(T v)
void setBits(std::uint8_t b)
Definition BaseCluster.h:96
T getSigmaYZ() const
Definition BaseCluster.h:67
math_utils::Point3D< T > getXYZ() const
Definition BaseCluster.h:68
T getSigmaZ2() const
Definition BaseCluster.h:66
BaseCluster(std::uint16_t sensid, const math_utils::Point3D< T > &xyz, T sy2, T sz2, T syz)
Definition BaseCluster.h:52
void setCount(std::int8_t c)
Definition BaseCluster.h:94
std::int8_t getCount() const
Definition BaseCluster.h:83
void setBit(int bit)
Definition BaseCluster.h:97
math_utils::Point3D< T > getXYZGlo(const o2::detectors::DetMatrixCache &dm) const
Definition BaseCluster.h:74
BaseCluster()=default
ClassDefNV(BaseCluster, 2)
void setSigmaY2(T v)
void setSigmaYZ(T v)
void setSensorID(std::int16_t sid)
Definition BaseCluster.h:92
std::uint8_t getBits() const
Definition BaseCluster.h:85
math_utils::Point3D< T > getXYZGloRot(const o2::detectors::DetMatrixCache &dm) const
Definition BaseCluster.h:78
BaseCluster(std::int16_t sensid, T x, T y, T z, T sy2, T sz2, T syz)
Definition BaseCluster.h:56
T getX() const
Definition BaseCluster.h:62
void setPos(const math_utils::Point3D< T > &p)
T getSigmaY2() const
Definition BaseCluster.h:65
math_utils::Point3D< T > getXYZLoc(const o2::detectors::DetMatrixCache &dm) const
Definition BaseCluster.h:72
void resetBit(int bit)
Definition BaseCluster.h:98
BaseCluster(std::uint16_t sensid, T x, T y, T z)
Definition BaseCluster.h:51
T getY() const
Definition BaseCluster.h:63
math_utils::Point3D< T > & getXYZ()
Definition BaseCluster.h:69
BaseCluster(std::uint16_t sensid, const math_utils::Point3D< T > &xyz)
Definition BaseCluster.h:50
bool isBitSet(int bit) const
Definition BaseCluster.h:86
void setXYZ(T x, T y, T z)
std::int16_t getSensorID() const
Definition BaseCluster.h:81
~BaseCluster()=default
void setErrors(T sy2, T sz2, T syz)
T getZ() const
Definition BaseCluster.h:64
const Mat3D & getMatrixT2L(int sensID) const
const Rot2D & getMatrixT2GRot(int sensID) const
const Mat3D & getMatrixT2G(int sensID) const
GLint GLenum GLint x
Definition glcorearb.h:403
const GLdouble * v
Definition glcorearb.h:832
GLboolean GLboolean GLboolean b
Definition glcorearb.h:1233
GLdouble GLdouble GLdouble z
Definition glcorearb.h:843
a couple of static helper functions to create timestamp values for CCDB queries or override obsolete ...
std::ostream & operator<<(std::ostream &stream, o2::InteractionRecord const &ir)