Skip to content

Commit 8c0dc71

Browse files
committed
something with ITS3
Signed-off-by: Felix Schlepper <[email protected]>
1 parent 7331b97 commit 8c0dc71

File tree

17 files changed

+412
-571
lines changed

17 files changed

+412
-571
lines changed

Detectors/ITSMFT/ITS/simulation/include/ITSSimulation/Detector.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ class Detector : public o2::base::DetImpl<Detector>
216216

217217
/// Return Chip Volume UID
218218
/// \param id volume id
219-
Int_t chipVolUID(Int_t id) const { return o2::base::GeometryManager::getSensID(o2::detectors::DetID::ITS, id); }
219+
Int_t chipVolUID(Int_t id) const { return o2::base::GeometryManager::getSensID(o2::detectors::DetID(GetName()), id); }
220220

221221
void EndOfEvent() override;
222222

Detectors/Upgrades/ITS3/alignment/include/ITS3Align/Deformations.h

Lines changed: 19 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414

1515
#include "ITS3Align/MisalignmentParameters.h"
1616
#include "MathUtils/LegendrePols.h"
17+
#include "GPUCommonMath.h"
1718

1819
#include <filesystem>
1920

@@ -26,57 +27,31 @@ class Deformations
2627
// init deformations from the parameter file
2728
void init(const std::filesystem::path&);
2829

29-
double getDeformationX(unsigned int id, double u, double v) const { return getDeformation<0>(id, u, v); }
30-
double getDeformationY(unsigned int id, double u, double v) const { return getDeformation<1>(id, u, v); }
31-
double getDeformationZ(unsigned int id, double u, double v) const { return getDeformation<2>(id, u, v); }
32-
double getDeformation(unsigned int id, unsigned int axis, double u, double v) const
30+
std::tuple<double, double, double> getDeformation(unsigned int id, double radius, double phi, double z, double u, double v, double fac = 1.0) const
3331
{
34-
if (axis == 0) {
35-
return mLegX[id](u, v);
36-
} else if (axis == 1) {
37-
return mLegY[id](u, v);
38-
} else {
39-
return mLegZ[id](u, v);
40-
}
32+
// Calculate f_def(phi,z) = ((r+dr)*cos(phi), (r+dr)*sin(phi), z)^T + (dx, dy, dz)^T
33+
const double dr = mLegendre[id](u, v);
34+
const double drr = radius + dr * fac;
35+
double sn, cs;
36+
o2::gpu::GPUCommonMath::SinCosd(phi, sn, cs);
37+
const auto& global = mParams.getGlobal(id);
38+
return {drr * cs + global.getX() * fac, drr * sn + global.getY() * fac, z + global.getZ() * fac};
4139
}
42-
std::array<double, 3> getDeformation(unsigned int id, double u, double v) const
43-
{
44-
return {getDeformation<0>(id, u, v),
45-
getDeformation<1>(id, u, v),
46-
getDeformation<2>(id, u, v)};
47-
}
48-
std::array<unsigned int, 3> getOrders(unsigned int id) const
49-
{
50-
return {mLegX[id].NOrder(), mLegY[id].NOrder(), mLegZ[id].NOrder()};
51-
}
52-
const o2::math_utils::Legendre2DPolynominal& getLegendre(unsigned int id, unsigned int axis) const
40+
41+
double getDeformation(unsigned int id, double u, double v)
5342
{
54-
if (axis == 0) {
55-
return mLegX[id];
56-
} else if (axis == 1) {
57-
return mLegY[id];
58-
} else {
59-
return mLegZ[id];
60-
}
43+
return mLegendre[id](u, v);
6144
}
6245

46+
const o2::math_utils::Legendre2DPolynominal& getLegendre(unsigned int id) { return mLegendre[id]; }
47+
48+
unsigned int getOrder(unsigned int id) { return mLegendre[id].NOrder(); }
49+
6350
private:
64-
template <int axis>
65-
double getDeformation(unsigned int id, double u, double v) const
66-
{
67-
if constexpr (axis == 0) {
68-
return mLegX[id](u, v);
69-
} else if constexpr (axis == 1) {
70-
return mLegY[id](u, v);
71-
} else {
72-
return mLegZ[id](u, v);
73-
}
74-
}
51+
MisalignmentParameters mParams;
7552

76-
// 3 Legendre polynominals to model deformations in x,y,z; parameterized by normalized phi (u) and z (v) coordinates
77-
std::array<o2::math_utils::Legendre2DPolynominal, 6> mLegX;
78-
std::array<o2::math_utils::Legendre2DPolynominal, 6> mLegY;
79-
std::array<o2::math_utils::Legendre2DPolynominal, 6> mLegZ;
53+
// Legendre polynominals to model deformations in radius; parameterized by normalized phi (u) and z (v) coordinates
54+
std::array<o2::math_utils::Legendre2DPolynominal, 6> mLegendre;
8055
};
8156

8257
} // namespace o2::its3::align

Detectors/Upgrades/ITS3/alignment/include/ITS3Align/MisalignmentHits.h

Lines changed: 0 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,6 @@ namespace o2::its3::align
3535
class MisAlignmentHits
3636
{
3737
public:
38-
enum class PropMethod {
39-
Propagator,
40-
Line,
41-
};
42-
4338
void init();
4439

4540
std::optional<o2::itsmft::Hit> processHit(int iEvent, const o2::itsmft::Hit& hit);
@@ -50,7 +45,6 @@ class MisAlignmentHits
5045
private:
5146
Deformations mDeformations;
5247
std::unique_ptr<ROOT::Math::Minimizer> mMinimizer;
53-
PropMethod mMethod{PropMethod::Line};
5448
o2::its::GeometryTGeo* mGeo{nullptr};
5549
std::unique_ptr<o2::steer::MCKinematicsReader> mMCReader;
5650

@@ -120,11 +114,6 @@ class MisAlignmentHits
120114

121115
bool deformHit(WorkingHit::HitType t);
122116

123-
auto getDeformation(unsigned int id, double u, double v) const
124-
{
125-
return mDeformations.getDeformation(id, u, v);
126-
}
127-
128117
// Mimize function assuming a straight line
129118
// given in the parametric representation by y_v = t * d_x + x_s
130119
// assuming no offset is needed
@@ -151,30 +140,6 @@ class MisAlignmentHits
151140
StraightLine mLine{this};
152141
void prepareLineMethod(WorkingHit::HitType from);
153142

154-
// Mimize function using the MCTrack
155-
class Propagator : public ROOT::Math::IBaseFunctionMultiDim
156-
{
157-
public:
158-
Propagator(const MisAlignmentHits* m) : mMis(m) {}
159-
160-
o2::track::TrackPar mTrack;
161-
float mBz;
162-
unsigned int mSensorID;
163-
double mRadius;
164-
const MisAlignmentHits* mMis;
165-
166-
double mPhiTot;
167-
double mPhi1;
168-
169-
unsigned int NDim() const override { return 3; }
170-
ROOT::Math::IBaseFunctionMultiDim* Clone() const override { return nullptr; }
171-
172-
private:
173-
double DoEval(const double* x) const override;
174-
};
175-
Propagator mPropagator{this};
176-
bool preparePropagatorMethod(WorkingHit::HitType from);
177-
178143
enum Stats : uint8_t {
179144
kHitTotal = 0,
180145
kHitIsOB,
@@ -204,8 +169,6 @@ class MisAlignmentHits
204169
kMinimizerEDM,
205170
kMinimizerLimit,
206171
kMinimizerOther,
207-
kPropTrackNull,
208-
kPropPDGNull,
209172
kALL,
210173
};
211174
std::array<ULong64_t, Stats::kALL> mStats;

Detectors/Upgrades/ITS3/alignment/include/ITS3Align/MisalignmentParameters.h

Lines changed: 13 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
#define ITS3_MISALIGNMENTPARAMETERS_H_
1717

1818
#include "ITS3Base/SpecsV2.h"
19+
#include "DetectorsCommonDataFormats/AlignParam.h"
1920

2021
#include "TNamed.h"
2122
#include "TFile.h"
@@ -31,37 +32,23 @@ class MisalignmentParameters : public TNamed
3132
{
3233
public:
3334
MisalignmentParameters();
35+
MisalignmentParameters(const MisalignmentParameters&) = default;
36+
MisalignmentParameters(MisalignmentParameters&&) = delete;
37+
MisalignmentParameters& operator=(MisalignmentParameters&&) = delete;
38+
MisalignmentParameters& operator=(const MisalignmentParameters& o);
3439

3540
// IO
3641
bool store(const std::string& file) const;
3742
static MisalignmentParameters* load(const std::string& file);
3843

3944
/// Global getters
40-
double getGloTransX(unsigned int detID) const { return mGloTransX[detID]; }
41-
double getGloTransY(unsigned int detID) const { return mGloTransY[detID]; }
42-
double getGloTransZ(unsigned int detID) const { return mGloTransZ[detID]; }
43-
double getGloRotX(unsigned int detID) const { return mGloRotX[detID]; }
44-
double getGloRotY(unsigned int detID) const { return mGloRotY[detID]; }
45-
double getGloRotZ(unsigned int detID) const { return mGloRotZ[detID]; }
46-
/// Global setters
47-
void setGloTransX(unsigned int detID, double v) { mGloTransX[detID] = v; }
48-
void setGloTransY(unsigned int detID, double v) { mGloTransY[detID] = v; }
49-
void setGloTransZ(unsigned int detID, double v) { mGloTransZ[detID] = v; }
50-
void setGloRotX(unsigned int detID, double v) { mGloRotX[detID] = v; }
51-
void setGloRotY(unsigned int detID, double v) { mGloRotY[detID] = v; }
52-
void setGloRotZ(unsigned int detID, double v) { mGloRotZ[detID] = v; }
53-
54-
/// Legendre Coeff. getters
55-
const TMatrixD& getLegendreCoeffX(unsigned int sensorID) const { return mLegCoeffX[sensorID]; }
56-
const TMatrixD& getLegendreCoeffY(unsigned int sensorID) const { return mLegCoeffY[sensorID]; }
57-
const TMatrixD& getLegendreCoeffZ(unsigned int sensorID) const { return mLegCoeffZ[sensorID]; }
58-
/// Legendre Coeff. setters
59-
void setLegendreCoeffX(unsigned int sensorID, const TMatrixD& m) { setMatrix(mLegCoeffX[sensorID], m); }
60-
void setLegendreCoeffY(unsigned int sensorID, const TMatrixD& m) { setMatrix(mLegCoeffY[sensorID], m); }
61-
void setLegendreCoeffZ(unsigned int sensorID, const TMatrixD& m) { setMatrix(mLegCoeffZ[sensorID], m); }
45+
const o2::detectors::AlignParam& getGlobal(unsigned int detID) const { return mGlobal[detID]; }
46+
void setGlobal(unsigned int detID, const o2::detectors::AlignParam& param) { mGlobal[detID] = param; }
47+
48+
const TMatrixD& getLegendreCoeff(unsigned int sensorID) const { return mLegCoeff[sensorID]; }
49+
void setLegendreCoeff(unsigned int sensorID, const TMatrixD& m) { setMatrix(mLegCoeff[sensorID], m); }
6250

6351
void printParams(unsigned int detID) const;
64-
void printLegendreParams(unsigned int sensorID) const;
6552

6653
private:
6754
inline void setMatrix(TMatrixD& o, const TMatrixD& n)
@@ -71,21 +58,10 @@ class MisalignmentParameters : public TNamed
7158
}
7259

7360
static constexpr unsigned int nDetectors{constants::detID::nChips}; ///! for now just the IB
61+
std::array<o2::detectors::AlignParam, nDetectors> mGlobal; ///< Array to hold the global misalignment
62+
std::array<TMatrixD, constants::nSensorsIB> mLegCoeff; // Legendre Polynominals coefficients
7463

75-
// Global parameters
76-
std::array<double, nDetectors> mGloTransX; ///< Array to hold the global misalignment in x-direction
77-
std::array<double, nDetectors> mGloTransY; ///< Array to hold the global misalignment in y-direction
78-
std::array<double, nDetectors> mGloTransZ; ///< Array to hold the global misalignment in z-direction
79-
std::array<double, nDetectors> mGloRotX; ///< Array to hold the global misalignment in x-direction
80-
std::array<double, nDetectors> mGloRotY; ///< Array to hold the global misalignment in y-direction
81-
std::array<double, nDetectors> mGloRotZ; ///< Array to hold the global misalignment in z-direction
82-
83-
// Legendre Polynominals coefficients
84-
std::array<TMatrixD, constants::nSensorsIB> mLegCoeffX;
85-
std::array<TMatrixD, constants::nSensorsIB> mLegCoeffY;
86-
std::array<TMatrixD, constants::nSensorsIB> mLegCoeffZ;
87-
88-
ClassDefOverride(MisalignmentParameters, 1);
64+
ClassDefOverride(MisalignmentParameters, 2);
8965
};
9066

9167
} // namespace o2::its3::align

Detectors/Upgrades/ITS3/alignment/src/Deformations.cxx

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,12 @@ void Deformations::init(const fs::path& path)
2727
LOGP(fatal, "File {} does not exists!", path.c_str());
2828
}
2929

30-
auto params = MisalignmentParameters::load(path.string());
30+
mParams = *MisalignmentParameters::load(path.string());
3131
LOGP(info, "Loaded Parameters");
3232

3333
// Set the legendre pols
3434
for (int iSensor{0}; iSensor < 6; ++iSensor) {
35-
mLegX[iSensor] = o2::math_utils::Legendre2DPolynominal(params->getLegendreCoeffX(iSensor));
36-
mLegY[iSensor] = o2::math_utils::Legendre2DPolynominal(params->getLegendreCoeffY(iSensor));
37-
mLegZ[iSensor] = o2::math_utils::Legendre2DPolynominal(params->getLegendreCoeffZ(iSensor));
35+
mLegendre[iSensor] = o2::math_utils::Legendre2DPolynominal(mParams.getLegendreCoeff(iSensor));
3836
}
3937
}
4038

0 commit comments

Comments
 (0)