Skip to content

Commit d13e18a

Browse files
committed
ITS3: alignment
Signed-off-by: Felix Schlepper <felix.schlepper@cern.ch>
1 parent 22759e0 commit d13e18a

File tree

13 files changed

+1405
-18
lines changed

13 files changed

+1405
-18
lines changed

Detectors/Upgrades/ITS3/alignment/CMakeLists.txt

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,18 +9,41 @@
99
# granted to it by virtue of its status as an Intergovernmental Organization
1010
# or submit itself to any jurisdiction.
1111

12+
# add_compile_options(-O0 -g -fPIC -fno-omit-frame-pointer)
1213
o2_add_library(ITS3Align
14+
TARGETVARNAME targetName
1315
SOURCES src/MisalignmentParameters.cxx
1416
src/MisalignmentHits.cxx
1517
src/MisalignmentManager.cxx
1618
src/Deformations.cxx
19+
src/AlignmentSpec.cxx
20+
src/AlignmentParams.cxx
21+
src/AlignmentTypes.cxx
22+
src/AlignmentHierarchy.cxx
1723
PUBLIC_LINK_LIBRARIES O2::MathUtils
1824
O2::Steer
1925
O2::ITSBase
20-
O2::ITSMFTSimulation)
26+
O2::ITSMFTSimulation
27+
O2::Framework
28+
O2::GlobalTrackingWorkflowReaders
29+
O2::GlobalTrackingWorkflowHelpers
30+
O2::DataFormatsGlobalTracking
31+
O2::DetectorsVertexing
32+
GBL::GBL)
33+
if (OpenMP_CXX_FOUND)
34+
target_compile_definitions(${targetName} PRIVATE WITH_OPENMP)
35+
target_link_libraries(${targetName} PRIVATE OpenMP::OpenMP_CXX)
36+
endif()
2137

2238
o2_target_root_dictionary(ITS3Align
2339
HEADERS include/ITS3Align/MisalignmentParameters.h
2440
include/ITS3Align/MisalignmentHits.h
25-
include/ITS3Align/MisalignmentHits.h
26-
include/ITS3Align/Deformations.h)
41+
include/ITS3Align/Deformations.h
42+
include/ITS3Align/AlignmentParams.h
43+
include/ITS3Align/AlignmentTypes.h)
44+
45+
46+
o2_add_executable(alignment-workflow
47+
SOURCES src/alignment-workflow.cxx
48+
COMPONENT_NAME its3
49+
PUBLIC_LINK_LIBRARIES O2::ITS3Align)
Lines changed: 161 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,161 @@
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+
#include <memory>
13+
#include <utility>
14+
#include <vector>
15+
#include <ostream>
16+
17+
#include <TGeoMatrix.h>
18+
#include <TGeoPhysicalNode.h>
19+
20+
namespace o2::its3::align
21+
{
22+
23+
using RigidBodyDOFMask = uint8_t;
24+
constexpr RigidBodyDOFMask DOF_BIT(RigidBodyDOFMask d) { return RigidBodyDOFMask(1) << d; }
25+
enum RigidBodyDOF : RigidBodyDOFMask {
26+
TX = 0, // Translation X
27+
TY, // Translation Y
28+
TZ, // Translation Z
29+
RZ, // Rotation around Z (phi)
30+
RY, // Rotation around y' (theta)
31+
RX, // Rotation around x'' (psi)
32+
NDOF, // number of DOFs
33+
};
34+
constexpr RigidBodyDOFMask RigidBodyDOFTra = DOF_BIT(TX) | DOF_BIT(TY) | DOF_BIT(TZ);
35+
constexpr RigidBodyDOFMask RigidBodyDOFRot = DOF_BIT(RX) | DOF_BIT(RY) | DOF_BIT(RZ);
36+
constexpr RigidBodyDOFMask RigidBodyDOFAll = RigidBodyDOFTra | RigidBodyDOFRot;
37+
constexpr RigidBodyDOFMask RigidBodyDOFNone = 0;
38+
constexpr RigidBodyDOFMask RigidBodyDOFPseudo = std::numeric_limits<RigidBodyDOFMask>::max(); // special value representing that the volume itself does not have any dofs but should not curtail the parent's ones
39+
static constexpr const char* RigidBodyDOFNames[RigidBodyDOF::NDOF] = {"TX", "TY", "TZ", "RZ", "RY", "RX"};
40+
inline bool hasRigidBodyDOF(RigidBodyDOFMask m, RigidBodyDOFMask d)
41+
{
42+
return (m == RigidBodyDOFPseudo) || (m & DOF_BIT(d));
43+
}
44+
inline void enableRigidBodyDOF(RigidBodyDOFMask& m, RigidBodyDOFMask d)
45+
{
46+
m |= DOF_BIT(d);
47+
}
48+
inline void disableRigidBodyDOF(RigidBodyDOFMask& m, RigidBodyDOFMask d)
49+
{
50+
m &= ~DOF_BIT(d);
51+
}
52+
53+
class GlobalLabel
54+
{
55+
public:
56+
using T = uint32_t;
57+
static constexpr int DOF_BITS = 5; // 0...4
58+
static constexpr int ID_BITS = 23; // 5...27
59+
static constexpr int TOTAL_BITS = sizeof(T) * 8;
60+
static constexpr int DET_BITS = TOTAL_BITS - (DOF_BITS + ID_BITS);
61+
static constexpr T bitMask(int b) noexcept
62+
{
63+
return (T(1) << b) - T(1);
64+
}
65+
static constexpr int DOF_SHIFT = 0;
66+
static constexpr T DOF_MAX = (T(1) << DOF_BITS) - T(1);
67+
static constexpr T DOF_MASK = DOF_MAX << DOF_SHIFT;
68+
static constexpr int ID_SHIFT = DOF_BITS;
69+
static constexpr T ID_MAX = (T(1) << ID_BITS) - T(1);
70+
static constexpr T ID_MASK = ID_MAX << ID_SHIFT;
71+
static constexpr int DET_SHIFT = DOF_BITS + ID_BITS;
72+
static constexpr T DET_MAX = (T(1) << DET_BITS) - T(1);
73+
static constexpr T DET_MASK = DET_MAX << DET_SHIFT;
74+
75+
GlobalLabel(T det, T id) : mID(((id & ID_MAX) << ID_SHIFT) | ((det & DET_MAX) << DET_SHIFT))
76+
{
77+
}
78+
79+
constexpr T raw(T dof) const noexcept { return (mID & ~DOF_MASK) | ((dof & DOF_MAX) << DOF_SHIFT); }
80+
constexpr T id() const noexcept
81+
{
82+
return (mID & ID_MASK) >> ID_SHIFT;
83+
}
84+
constexpr T det() const noexcept
85+
{
86+
return (mID & DET_MASK) >> DET_SHIFT;
87+
}
88+
89+
private:
90+
T mID{0};
91+
};
92+
93+
// Rigid body constraints for the parents
94+
class HierarchyConstraint
95+
{
96+
public:
97+
HierarchyConstraint(std::string name, double value) : mName(std::move(name)), mValue(value) {}
98+
void add(uint32_t lab, double coeff)
99+
{
100+
mLabels.push_back(lab);
101+
mCoeff.push_back(coeff);
102+
}
103+
void write(std::ostream& os) const;
104+
105+
private:
106+
std::string mName; // name of the constraint
107+
double mValue{0.0}; // constraint value
108+
std::vector<uint32_t> mLabels; // parameter labels
109+
std::vector<double> mCoeff; // their coefficients
110+
};
111+
112+
class AlignableVolume
113+
{
114+
using Ptr = std::unique_ptr<AlignableVolume>;
115+
116+
public:
117+
AlignableVolume(const char* symName, uint32_t label, uint32_t det, RigidBodyDOFMask dof);
118+
119+
void finalise();
120+
121+
// steering file output
122+
void writeRigidBodyConstraints(std::ostream& os) const;
123+
void writeTree(std::ostream& os, int indent = 0) const;
124+
125+
// tree-like
126+
bool isRoot() const noexcept { return mParent == nullptr; }
127+
bool isLeaf() const noexcept { return mChildren.empty(); }
128+
AlignableVolume* addChild(const char* symName, uint32_t label, uint32_t det, RigidBodyDOFMask dof)
129+
{
130+
auto c = std::make_unique<AlignableVolume>(symName, label, det, dof);
131+
c->mParent = this;
132+
mChildren.push_back(std::move(c));
133+
return mChildren.back().get();
134+
}
135+
// bfs traversal
136+
void traverse(const std::function<void(AlignableVolume*)>& visitor)
137+
{
138+
visitor(this);
139+
for (auto& c : mChildren) {
140+
c->traverse(visitor);
141+
}
142+
}
143+
144+
std::string getSymName() const noexcept { return mSymName; }
145+
GlobalLabel getLabel() const noexcept { return mLabel; }
146+
AlignableVolume* getParent() const { return mParent; }
147+
size_t getNChildren() const noexcept { return mChildren.size(); }
148+
RigidBodyDOFMask getRigidBodyDOF() const noexcept { return mDOF; }
149+
150+
private:
151+
std::string mSymName; // unique symbolic name
152+
GlobalLabel mLabel; // internal global idetenifier
153+
RigidBodyDOFMask mDOF{RigidBodyDOFAll}; // allowed dofs
154+
AlignableVolume* mParent{nullptr}; // parent
155+
TGeoPNEntry* mPNE{nullptr}; // physical entry
156+
TGeoPhysicalNode* mPN{nullptr}; // physical node
157+
158+
std::vector<Ptr> mChildren; // children
159+
};
160+
161+
} // namespace o2::its3::align
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
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+
#ifndef ALICEO2_ITS3_ALIGNMENTPARAMS_H_
12+
#define ALICEO2_ITS3_ALIGNMENTPARAMS_H_
13+
14+
#include "CommonUtils/ConfigurableParam.h"
15+
#include "CommonUtils/ConfigurableParamHelper.h"
16+
#include "DetectorsBase/Propagator.h"
17+
18+
namespace o2::its3::align
19+
{
20+
struct AlignmentParams : public o2::conf::ConfigurableParamHelper<AlignmentParams> {
21+
// Track selection
22+
float minPt = 1.f; // minimum pt required
23+
int minITSCls = 7; // minimum number of ITS clusters
24+
float maxITSChi2Ndf = 1.2; // maximum ITS track chi2
25+
26+
// propagation opt
27+
double maxSnp = 0.85;
28+
double maxStep = 2.0;
29+
// o2::base::PropagatorD::MatCorrType matCorrType = o2::base::PropagatorD::MatCorrType::USEMatCorrTGeo;
30+
o2::base::PropagatorD::MatCorrType matCorrType = o2::base::PropagatorD::MatCorrType::USEMatCorrLUT;
31+
32+
double radiusIBOBComp = 12.0; // radius where IB&OB track are compared
33+
bool useStableRefit = true; // use input tracks as linearization point
34+
float minMS = 1e-6f; // minimum scattering to account for
35+
float maxChi2Ndf = 10; // maximum Chi2/Ndf allowed for GBL fit
36+
37+
// Ridder options
38+
int ridderMaxExtrap = 10;
39+
double ridderRelIniStep[5] = {0.01, 0.01, 0.02, 0.02, 0.02};
40+
double ridderMaxIniStep[5] = {0.1, 0.1, 0.05, 0.05, 0.05};
41+
double ridderShrinkFac = 2.0;
42+
double ridderEps = 1e-16;
43+
double ridderMaxJacDiagTol = 0.1; // max tolerance of diagonal elements away from 1
44+
45+
// MillePede output
46+
std::string milleFileName = "mille.data";
47+
48+
O2ParamDef(AlignmentParams, "ITS3AlignmentParams");
49+
};
50+
} // namespace o2::its3::align
51+
52+
#endif
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
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 O2_ITS3_ALIGNMENT_H
13+
#define O2_ITS3_ALIGNMENT_H
14+
15+
#include "ReconstructionDataFormats/GlobalTrackID.h"
16+
#include "Framework/DataProcessorSpec.h"
17+
18+
namespace o2::its3::align
19+
{
20+
o2::framework::DataProcessorSpec getAlignmentSpec(o2::dataformats::GlobalTrackID::mask_t srcTracks, o2::dataformats::GlobalTrackID::mask_t srcClus, bool useMC, bool withPV, bool withITS3);
21+
} // namespace o2::its3::align
22+
23+
#endif
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
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 O2_ITS3_ALIGNMENT_TYPES_H
13+
#define O2_ITS3_ALIGNMENT_TYPES_H
14+
15+
#include <string>
16+
#include "ReconstructionDataFormats/Track.h"
17+
#include "DataFormatsITS/TrackITS.h"
18+
19+
namespace o2::its3::align
20+
{
21+
22+
struct Measurement final {
23+
double dy = 0.f;
24+
double dz = 0.f;
25+
double sig2y = 0.f;
26+
double sig2z = 0.f;
27+
double phi = 0.f;
28+
double z = 0.f;
29+
ClassDefNV(Measurement, 1)
30+
};
31+
32+
struct FrameInfoExt final {
33+
int16_t sens = -1;
34+
int8_t lr = -1; // -1 = vtx
35+
o2::math_utils::Point3D<float> trk;
36+
o2::math_utils::Point3D<float> loc;
37+
o2::math_utils::Point3D<float> glo;
38+
float x{-999.f};
39+
float alpha{-999.f};
40+
std::array<double, 2> positionTrackingFrame = {999., 999.};
41+
std::array<double, 3> covarianceTrackingFrame = {999., 999., 999.};
42+
43+
std::string asString() const;
44+
45+
ClassDefNV(FrameInfoExt, 1)
46+
};
47+
48+
struct FitInfo final {
49+
float chi2Ndf{-1}; // Chi2/Ndf of track refit
50+
float chi2{-1}; // Chi2
51+
int ndf; // ndf
52+
ClassDefNV(FitInfo, 1)
53+
};
54+
55+
struct Track {
56+
o2::its::TrackITS its; // original ITS track
57+
o2::track::TrackParCovD track; // track at innermost update point, refitted from outwards seed
58+
FitInfo kfFit; // kf fit information
59+
FitInfo gblFit; // gbl fit information
60+
std::vector<Measurement> points; // measurment point
61+
std::vector<FrameInfoExt> info; // frame info
62+
ClassDefNV(Track, 1)
63+
};
64+
65+
} // namespace o2::its3::align
66+
67+
#endif

0 commit comments

Comments
 (0)