Project
Loading...
Searching...
No Matches
AlignmentDOF.h
Go to the documentation of this file.
1// Copyright 2019-2026 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 O2_ITS3_ALIGNMENT_DOF_H
13#define O2_ITS3_ALIGNMENT_DOF_H
14
15#include <algorithm>
16#include <cstdint>
17#include <format>
18#include <stdexcept>
19#include <string>
20#include <vector>
21
22#include <Eigen/Dense>
23
25 int sensorID{-1};
26 int layerID{-1};
27 double measX{0.};
28 double measAlpha{0.};
29 double measZ{0.};
30 double trkY{0.};
31 double trkZ{0.};
32 double snp{0.};
33 double tgl{0.};
34 double dydx{0.};
35 double dzdx{0.};
36};
37
38// Generic set of DOF
39class DOFSet
40{
41 public:
42 enum class Type : uint8_t {
46 };
47 virtual ~DOFSet() = default;
48 virtual Type type() const = 0;
49 int nDOFs() const { return static_cast<int>(mFree.size()); }
50 virtual std::string dofName(int idx) const = 0;
51 virtual void fillDerivatives(const DerivativeContext& ctx, Eigen::Ref<Eigen::MatrixXd> out) const = 0;
52 bool isFree(int idx) const { return mFree[idx]; }
53 void setFree(int idx, bool f) { mFree[idx] = f; }
54 void setAllFree(bool f) { std::fill(mFree.begin(), mFree.end(), f); }
55 int nFreeDOFs() const
56 {
57 int n = 0;
58 for (bool f : mFree) {
59 n += f;
60 }
61 return n;
62 }
63
64 protected:
65 DOFSet(int n) : mFree(n, true) {}
66 std::vector<bool> mFree;
67};
68
69// Rigid body set
70class RigidBodyDOFSet final : public DOFSet
71{
72 public:
73 // indices for rigid body parameters in LOC frame
74 enum RigidBodyDOF : uint8_t {
75 TX = 0,
82 };
83 static constexpr const char* RigidBodyDOFNames[RigidBodyDOF::NDOF] = {"TX", "TY", "TZ", "RX", "RY", "RZ"};
84
86 // mask: bitmask of free DOFs (bit i = DOF i is free)
87 explicit RigidBodyDOFSet(uint8_t mask) : DOFSet(NDOF)
88 {
89 for (int i = 0; i < NDOF; ++i) {
90 mFree[i] = (mask >> i) & 1;
91 }
92 }
93 Type type() const override { return Type::RigidBody; }
94 std::string dofName(int idx) const override { return RigidBodyDOFNames[idx]; }
95 void fillDerivatives(const DerivativeContext& ctx, Eigen::Ref<Eigen::MatrixXd> out) const override;
96 uint8_t mask() const
97 {
98 uint8_t m = 0;
99 for (int i = 0; i < NDOF; ++i) {
100 m |= (uint8_t(mFree[i]) << i);
101 }
102 return m;
103 }
104};
105
106// Legendre DOFs
107// Describing radial misplacement
108class LegendreDOFSet final : public DOFSet
109{
110 public:
111 explicit LegendreDOFSet(int order) : DOFSet((order + 1) * (order + 2) / 2), mOrder(order) {}
112 Type type() const override { return Type::Legendre; }
113 int order() const { return mOrder; }
114 std::string dofName(int idx) const override
115 {
116 int i = 0;
117 while ((i + 1) * (i + 2) / 2 <= idx) {
118 ++i;
119 }
120 int j = idx - (i * (i + 1) / 2);
121 return std::format("L({},{})", i, j);
122 }
123 void fillDerivatives(const DerivativeContext& ctx, Eigen::Ref<Eigen::MatrixXd> out) const override;
124
125 private:
126 int mOrder;
127};
128
129// In-extensional deformation DOFs for cylindrical half-shells
130// Fourier modes n=2..N: 4 params each (a_n, b_n, c_n, d_n)
131// Plus 2 non-periodic modes (alpha, beta) for the half-cylinder open edges
132// Total: 4*(N-1) + 2
133class InextensionalDOFSet final : public DOFSet
134{
135 public:
136 explicit InextensionalDOFSet(int maxOrder) : DOFSet((4 * (maxOrder - 1)) + 2), mMaxOrder(maxOrder)
137 {
138 if (maxOrder < 2) {
139 // the rest is eq. to rigid body
140 throw std::invalid_argument("InextensionalDOFSet requires maxOrder >= 2");
141 }
142 }
143 Type type() const override { return Type::Inextensional; }
144 int maxOrder() const { return mMaxOrder; }
145
146 // number of periodic DOFs (before alpha, beta)
147 int nPeriodic() const { return 4 * (mMaxOrder - 1); }
148
149 // flat index layout: [a_2, b_2, c_2, d_2, a_3, b_3, c_3, d_3, ..., alpha, beta]
150 // index of first DOF for mode n
151 static int modeOffset(int n) { return 4 * (n - 2); }
152
153 // indices of the non-periodic modes
154 int alphaIdx() const { return nPeriodic(); }
155 int betaIdx() const { return nPeriodic() + 1; }
156
157 std::string dofName(int idx) const override
158 {
159 if (idx == alphaIdx()) {
160 return "alpha";
161 }
162 if (idx == betaIdx()) {
163 return "beta";
164 }
165 int n = (idx / 4) + 2;
166 int sub = idx % 4;
167 static constexpr const char* subNames[] = {"a", "b", "c", "d"};
168 return std::format("{}_{}", subNames[sub], n);
169 }
170 void fillDerivatives(const DerivativeContext& ctx, Eigen::Ref<Eigen::MatrixXd> out) const override;
171
172 private:
173 int mMaxOrder;
174};
175
176#endif
int32_t i
uint32_t j
Definition RawData.h:0
virtual Type type() const =0
bool isFree(int idx) const
int nFreeDOFs() const
virtual void fillDerivatives(const DerivativeContext &ctx, Eigen::Ref< Eigen::MatrixXd > out) const =0
DOFSet(int n)
void setAllFree(bool f)
void setFree(int idx, bool f)
virtual ~DOFSet()=default
std::vector< bool > mFree
virtual std::string dofName(int idx) const =0
int nDOFs() const
int nPeriodic() const
static int modeOffset(int n)
Type type() const override
void fillDerivatives(const DerivativeContext &ctx, Eigen::Ref< Eigen::MatrixXd > out) const override
InextensionalDOFSet(int maxOrder)
std::string dofName(int idx) const override
Type type() const override
LegendreDOFSet(int order)
int order() const
void fillDerivatives(const DerivativeContext &ctx, Eigen::Ref< Eigen::MatrixXd > out) const override
std::string dofName(int idx) const override
std::string dofName(int idx) const override
uint8_t mask() const
RigidBodyDOFSet(uint8_t mask)
void fillDerivatives(const DerivativeContext &ctx, Eigen::Ref< Eigen::MatrixXd > out) const override
static constexpr const char * RigidBodyDOFNames[RigidBodyDOF::NDOF]
Type type() const override
GLdouble n
Definition glcorearb.h:1982
const GLfloat * m
Definition glcorearb.h:4066
GLdouble f
Definition glcorearb.h:310
GLint GLuint mask
Definition glcorearb.h:291