Project
Loading...
Searching...
No Matches
MisalignmentHits.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 ITS3_MISALIGNMENTHITS_H_
13#define ITS3_MISALIGNMENTHITS_H_
14
15#include "Math/IFunction.h"
16#include "Math/Minimizer.h"
17
22#include "MathUtils/Cartesian.h"
23#include "MathUtils/Utils.h"
25
26#include <regex>
27#include <memory>
28#include <array>
29#include <optional>
30#include <tuple>
31
32namespace o2::its3::align
33{
34
36{
37 public:
38 enum class PropMethod {
40 Line,
41 };
42
43 void init();
44
45 std::optional<o2::itsmft::Hit> processHit(int iEvent, const o2::itsmft::Hit& hit);
46
47 void resetStats() { mStats.fill(0ull); }
48 void printStats() const;
49
50 private:
51 Deformations mDeformations;
52 std::unique_ptr<ROOT::Math::Minimizer> mMinimizer;
54 o2::its::GeometryTGeo* mGeo{nullptr};
55 std::unique_ptr<o2::steer::MCKinematicsReader> mMCReader;
56
57 short getDetID(const o2::math_utils::Point3D<float>& point);
58 short getDetIDFromCords(const o2::math_utils::Point3D<float>& point);
59 short getDetIDFromPath(const std::string& path) const;
60
61 // We treat each hit as two separate hits', one for the entering and one for the exiting hit
62 struct WorkingHit {
63 enum HitType : uint8_t {
64 kEntering = 0,
65 kExiting,
66 kTypes,
67 };
68
69 WorkingHit() = default;
70
71 WorkingHit(int eventID, HitType t, const o2::itsmft::Hit& hit) : mEvent(eventID),
72 mTrackID(hit.GetTrackID()),
73 mType(t),
74 mDetID(hit.GetDetectorID()),
75 mLayerID(constants::detID::getDetID2Layer(mDetID)),
76 mSensorID(constants::detID::getSensorID(mDetID))
77 {
78 if (mType == kEntering) {
79 mRadius = constants::radiiInner[mLayerID];
80 mPoint = hit.GetPosStart();
81 } else {
82 mRadius = constants::radiiOuter[mLayerID];
83 mPoint = hit.GetPos();
84 }
85
86 // Pre-calculate the normalized u,v coordinates as starting parameters
87 const bool isTop = mSensorID % 2 == 0;
88 mPhi = o2::math_utils::to02Pi(std::atan2(mPoint.Y(), mPoint.X()));
89 mPhiBorder1 = o2::math_utils::to02Pi(((isTop) ? 0.f : 1.f) * TMath::Pi() + std::asin(constants::equatorialGap / 2.f / mRadius));
90 mPhiBorder2 = o2::math_utils::to02Pi(((isTop) ? 1.f : 2.f) * TMath::Pi() - std::asin(constants::equatorialGap / 2.f / mRadius));
91 mU = ((mPhi - mPhiBorder1) * 2.f) / (mPhiBorder2 - mPhiBorder1) - 1.f;
92 mV = (2.f * mPoint.Z() + constants::segment::lengthSensitive) / constants::segment::lengthSensitive - 1.f;
93 }
94
95 void recalculateIdeal(float phi, float z)
96 {
97 mPointDef.SetX(mRadius * std::cos(phi));
98 mPointDef.SetY(mRadius * std::sin(phi));
99 mPointDef.SetZ(z);
100 }
101
102 int mEvent;
103 int mTrackID;
104 HitType mType;
105 short mDetID;
106 int mLayerID;
107 int mSensorID;
108 float mRadius;
109 float mPhi;
112 float mU; // u is normalized phi
113 float mV; // u is normalized z
114
115 float mPhiBorder1;
116 float mPhiBorder2;
117 };
118 std::array<WorkingHit, WorkingHit::kTypes> mCurWorkingHits;
119 o2::itsmft::Hit mCurHit;
120
121 bool deformHit(WorkingHit::HitType t);
122
123 auto getDeformation(unsigned int id, double u, double v) const
124 {
125 return mDeformations.getDeformation(id, u, v);
126 }
127
128 // Mimize function assuming a straight line
129 // given in the parametric representation by y_v = t * d_x + x_s
130 // assuming no offset is needed
131 class StraightLine : public ROOT::Math::IBaseFunctionMultiDim
132 {
133 public:
134 StraightLine(const MisAlignmentHits* m) : mMis(m) {}
135
136 std::array<double, 3> mD;
138 unsigned int mSensorID;
139 double mRadius;
140 const MisAlignmentHits* mMis;
141
142 double mPhiTot;
143 double mPhi1;
144
145 unsigned int NDim() const override { return 3; }
146 ROOT::Math::IBaseFunctionMultiDim* Clone() const override { return nullptr; }
147
148 private:
149 double DoEval(const double* x) const override;
150 };
151 StraightLine mLine{this};
152 void prepareLineMethod(WorkingHit::HitType from);
153
154 // Mimize function using the MCTrack
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
178 enum Stats : uint8_t {
179 kHitTotal = 0,
180 kHitIsOB,
181 kHitIsIB,
182 kHitDead,
183 kHitAlive,
184 kHitSuccess,
185 kHitMigrated,
186 kHitNotMigrated,
187 kHitEntBoundary,
188 kHitExtBoundary,
189 kHitNoBoundary,
190 kHitSameBoundary,
191 kFindNodeFailed,
192 kFindNodeSuccess,
193 kProjSensitive,
194 kProjNonSensitive,
195 kDetIDOk,
196 kDetIDBad,
197 kMinimizerStatusOk,
198 kMinimizerStatusBad,
199 kMinimizerValueOk,
200 kMinimizerValueBad,
201 kMinimizerConverged,
202 kMinimizerCovPos,
203 kMinimizerHesse,
204 kMinimizerEDM,
205 kMinimizerLimit,
206 kMinimizerOther,
207 kPropTrackNull,
208 kPropPDGNull,
209 kALL,
210 };
211 std::array<ULong64_t, Stats::kALL> mStats;
212};
213
214} // namespace o2::its3::align
215
216#endif
General auxilliary methods.
Base track model for the Barrel, params only, w/o covariance.
Definition of the ITSMFT Hit class.
Definition of the GeometryTGeo class.
math_utils::Point3D< T > GetPos() const
Definition BaseHits.h:67
double getDeformation(unsigned int id, unsigned int axis, double u, double v) const
std::optional< o2::itsmft::Hit > processHit(int iEvent, const o2::itsmft::Hit &hit)
math_utils::Point3D< Float_t > GetPosStart() const
Definition Hit.h:60
GLint GLenum GLint x
Definition glcorearb.h:403
const GLfloat * m
Definition glcorearb.h:4066
const GLdouble * v
Definition glcorearb.h:832
GLsizei const GLchar *const * path
Definition glcorearb.h:3591
GLdouble GLdouble GLdouble z
Definition glcorearb.h:843
uint8_t itsSharedClusterMap uint8_t
PropagatorF Propagator
Definition Propagator.h:182
constexpr std::array< float, nLayers > radiiOuter
Definition SpecsV2.h:118
constexpr float equatorialGap
Definition SpecsV2.h:112
constexpr std::array< float, nLayers > radiiInner
Definition SpecsV2.h:117
constexpr float Pi
Definition Constants.h:43
Defining DataPointCompositeObject explicitly as copiable.