Skip to content

Commit 1e1f2df

Browse files
shahor02sawenzel
authored andcommitted
Moved data definition classes to DetaFormats/... directories (#808)
* Moved data definition classes to DetaFormats/... directories To avoid circular dependencies moved some classes from O2/Detectors/Base to O2/DetaFormats/... Also some math utilities were moved to O2/Common/MathUtils as well as constants moved to O2/Common/Constants The massive change of multiple files is mostly due to the fixes of headers and namespaces * Set of fixes and methods needed for ITS-TPC matching Static method to init Bfield from propagator, MagFieldFact ownership fix: Bug fix: MagFieldFact factory class cannot own the field it created: since the FairRunAna and TGeoGlobalMagField delete the field created by the factor, we have to use naked new in the factory, which cannot own the field Apply material correction in backpropagation fit (CookedTracker) Bug fix: CookedTrack::getChi2 should return float (CookedTrack) Use double for all error matrix calc. + fix in array init + extra getters (Track) Add comparison methods to MCCompLabel Fix: add ClassDefNV for TrackTPC + make getter const Added method to load geometry from file (GeometryManager) Separate methods for field and geom inits (initSimGeomAndField.C)
1 parent 2ef37db commit 1e1f2df

File tree

104 files changed

+4825
-4743
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

104 files changed

+4825
-4743
lines changed
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
// Copyright CERN and copyright holders of ALICE O2. This software is
2+
// distributed under the terms of the GNU General Public License v3 (GPL
3+
// Version 3), copied verbatim in the file "COPYING".
4+
//
5+
// See http://alice-o2.web.cern.ch/license for full licensing information.
6+
//
7+
// In applying this license CERN does not waive the privileges and immunities
8+
// granted to it by virtue of its status as an Intergovernmental Organization
9+
// or submit itself to any jurisdiction.
10+
11+
/// \file MathConstants.h
12+
/// \brief useful math constants
13+
/// \author ruben.shahoyan@cern.ch
14+
15+
#ifndef ALICEO2_COMMON_MATH_CONSTANTS_
16+
#define ALICEO2_COMMON_MATH_CONSTANTS_
17+
18+
namespace o2
19+
{
20+
namespace constants
21+
{
22+
namespace math
23+
{
24+
constexpr float Almost0 = 1.17549e-38;
25+
constexpr float Almost1 = 1.f - Almost0;
26+
constexpr float VeryBig = 1.f / Almost0;
27+
28+
constexpr float PI = 3.14159274101257324e+00f;
29+
constexpr float TwoPI = 2.f * PI;
30+
constexpr float PIHalf = 0.5f * PI;
31+
constexpr float Rad2Deg = 180.f / PI;
32+
constexpr float Deg2Rad = PI / 180.f;
33+
34+
constexpr int NSectors = 18;
35+
constexpr float SectorSpanDeg = 360. / NSectors;
36+
constexpr float SectorSpanRad = SectorSpanDeg * Deg2Rad;
37+
38+
// conversion from B(kGaus) to curvature for 1GeV pt
39+
constexpr float B2C = -0.299792458e-3;
40+
}
41+
}
42+
}
43+
#endif

Common/Field/include/Field/MagFieldFact.h

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -12,39 +12,36 @@
1212
/// \brief Definition of the MagFieldFact: factory for ALIDE mag. field from MagFieldParam
1313
/// \author ruben.shahoyan@cern.ch
1414

15-
1615
#ifndef ALICEO2_FIELD_MAGFIELDFACT_H
1716
#define ALICEO2_FIELD_MAGFIELDFACT_H
1817

1918
#include "FairFieldFactory.h"
2019
#include "Field/MagneticField.h"
21-
#include <memory>
20+
2221
class FairField;
2322

24-
namespace o2 {
25-
namespace field {
26-
23+
namespace o2
24+
{
25+
namespace field
26+
{
2727
class MagFieldParam;
2828

29-
class MagFieldFact : public FairFieldFactory
29+
class MagFieldFact : public FairFieldFactory
3030
{
31-
3231
public:
3332
MagFieldFact();
3433
~MagFieldFact() override;
3534
FairField* createFairField() override;
3635
void SetParm() override;
37-
36+
3837
private:
3938
MagFieldFact(const MagFieldFact&);
4039
MagFieldFact& operator=(const MagFieldFact&);
4140

4241
MagFieldParam* mFieldPar;
43-
std::unique_ptr<MagneticField> mField; // the resource-owning handle to a field
4442

45-
ClassDefOverride(MagFieldFact,2)
43+
ClassDefOverride(MagFieldFact, 2)
4644
};
47-
4845
}
4946
}
5047

Common/Field/src/MagFieldFact.cxx

Lines changed: 13 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,11 @@
99
// or submit itself to any jurisdiction.
1010

1111
#include "Field/MagFieldFact.h"
12+
#include "FairField.h"
13+
#include "FairLogger.h"
14+
#include "FairRuntimeDb.h"
1215
#include "Field/MagFieldParam.h"
1316
#include "Field/MagneticField.h"
14-
#include "FairRuntimeDb.h"
15-
#include "FairField.h"
1617

1718
#include <iostream>
1819
using std::cout;
@@ -21,39 +22,28 @@ using std::endl;
2122

2223
using namespace o2::field;
2324

24-
2525
ClassImp(MagFieldFact)
2626

27+
static MagFieldFact gMagFieldFact;
2728

28-
static MagFieldFact gMagFieldFact;
29-
30-
MagFieldFact::MagFieldFact()
31-
:FairFieldFactory(),
32-
mFieldPar(nullptr),
33-
mField()
34-
{
35-
fCreator=this;
36-
}
37-
38-
MagFieldFact::~MagFieldFact()
39-
= default;
29+
MagFieldFact::MagFieldFact() : FairFieldFactory(), mFieldPar(nullptr) { fCreator = this; }
30+
MagFieldFact::~MagFieldFact() = default;
4031

4132
void MagFieldFact::SetParm()
4233
{
4334
auto RunDB = FairRuntimeDb::instance();
44-
mFieldPar = (MagFieldParam*) RunDB->getContainer("MagFieldParam");
35+
mFieldPar = (MagFieldParam*)RunDB->getContainer("MagFieldParam");
4536
}
4637

4738
FairField* MagFieldFact::createFairField()
48-
{
49-
if ( !mFieldPar ) {
39+
{
40+
if (!mFieldPar) {
5041
LOG(ERROR) << "MagFieldFact::createFairField: No field parameters available";
5142
return nullptr;
5243
}
5344
// since we have just 1 field class, we don't need to consider fFieldPar->GetType()
54-
mField = std::make_unique<MagneticField>(*mFieldPar);
55-
std::cerr << "creating the field\n";
56-
return mField.get();
45+
std::cerr << "creating the field as unmanaged pointer\n";
46+
// we have to use naked "new" here since the FairRootAna or TGeoGlobalMagField expect
47+
// bare pointer on the field which they eventually destroy
48+
return new MagneticField(*mFieldPar);
5749
}
58-
59-

Common/MathUtils/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ set(SRCS
1212
)
1313

1414
set(HEADERS
15+
include/${MODULE_NAME}/Utils.h
1516
include/${MODULE_NAME}/Chebyshev3D.h
1617
include/${MODULE_NAME}/Chebyshev3DCalc.h
1718
include/${MODULE_NAME}/MathBase.h

Common/MathUtils/include/MathUtils/Cartesian3D.h

Lines changed: 31 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -15,16 +15,15 @@
1515
#ifndef ALICEO2_CARTESIAN3D_H
1616
#define ALICEO2_CARTESIAN3D_H
1717

18+
#include <Math/GenVector/DisplacementVector3D.h>
19+
#include <Math/GenVector/PositionVector3D.h>
1820
#include <Math/GenVector/Rotation3D.h>
1921
#include <Math/GenVector/Transform3D.h>
2022
#include <Math/GenVector/Translation3D.h>
2123
#include <Rtypes.h>
2224
#include <TGeoMatrix.h>
23-
#include <Math/GenVector/DisplacementVector3D.h>
24-
#include <Math/GenVector/PositionVector3D.h>
25-
#include "MathUtils/Cartesian2D.h"
2625
#include <iostream>
27-
26+
#include "MathUtils/Cartesian2D.h"
2827

2928
template <typename T>
3029
using Point3D = ROOT::Math::PositionVector3D<ROOT::Math::Cartesian3D<T>, ROOT::Math::DefaultCoordinateSystemTag>;
@@ -34,27 +33,22 @@ using Vector3D = ROOT::Math::DisplacementVector3D<ROOT::Math::Cartesian3D<T>, RO
3433

3534
namespace o2
3635
{
37-
namespace Base
38-
{
39-
40-
/// predefined transformations: Tracking->Local, Tracking->Global, Local->Global etc
36+
/// predefined transformations: Tracking->Local, Tracking->Global, Local->Global etc
4137
/// The IDs must be < 32
4238

4339
struct TransformType {
4440
static constexpr int L2G = 0;
4541
static constexpr int T2L = 1;
4642
static constexpr int T2G = 2;
47-
static constexpr int T2GRot = 3;
48-
}; /// transformation types
49-
43+
static constexpr int T2GRot = 3;
44+
}; /// transformation types
5045

5146
class Rotation2D
5247
{
5348
//
5449
// class to perform rotation of 3D (around Z) and 2D points
5550

5651
public:
57-
5852
Rotation2D() = default;
5953
Rotation2D(float cs, float sn) : mCos(cs), mSin(sn) {}
6054
Rotation2D(float phiZ) : mCos(cos(phiZ)), mSin(sin(phiZ)) {}
@@ -74,68 +68,67 @@ class Rotation2D
7468
mSin = sn;
7569
}
7670

77-
void getComponents(float& cs, float &sn) const
71+
void getComponents(float& cs, float& sn) const
7872
{
7973
cs = mCos;
8074
sn = mSin;
8175
}
82-
76+
8377
template <typename T>
8478
Point3D<T> operator()(const Point3D<T>& v) const
8579
{ // local->master
86-
return Point3D<T>( v.X()*mCos - v.Y()*mSin, v.X()*mSin + v.Y()*mCos, v.Z() );
80+
return Point3D<T>(v.X() * mCos - v.Y() * mSin, v.X() * mSin + v.Y() * mCos, v.Z());
8781
}
8882

8983
template <typename T>
9084
Point3D<T> operator^(const Point3D<T>& v) const
9185
{ // master->local
92-
return Point3D<T>( v.X()*mCos + v.Y()*mSin, -v.X()*mSin + v.Y()*mCos, v.Z() );
86+
return Point3D<T>(v.X() * mCos + v.Y() * mSin, -v.X() * mSin + v.Y() * mCos, v.Z());
9387
}
9488

9589
template <typename T>
9690
Vector3D<T> operator()(const Vector3D<T>& v) const
9791
{ // local->master
98-
return Vector3D<T>( v.X()*mCos - v.Y()*mSin, v.X()*mSin + v.Y()*mCos, v.Z() );
92+
return Vector3D<T>(v.X() * mCos - v.Y() * mSin, v.X() * mSin + v.Y() * mCos, v.Z());
9993
}
10094

10195
template <typename T>
10296
Vector3D<T> operator^(const Vector3D<T>& v) const
10397
{ // master->local
104-
return Vector3D<T>( v.X()*mCos + v.Y()*mSin, -v.X()*mSin + v.Y()*mCos, v.Z() );
98+
return Vector3D<T>(v.X() * mCos + v.Y() * mSin, -v.X() * mSin + v.Y() * mCos, v.Z());
10599
}
106100

107101
template <typename T>
108102
Point2D<T> operator()(const Point2D<T>& v) const
109103
{ // local->master
110-
return Point2D<T>( v.X()*mCos - v.Y()*mSin, v.X()*mSin + v.Y()*mCos );
104+
return Point2D<T>(v.X() * mCos - v.Y() * mSin, v.X() * mSin + v.Y() * mCos);
111105
}
112106

113107
template <typename T>
114108
Point2D<T> operator^(const Point2D<T>& v) const
115109
{ // master->local
116-
return Point2D<T>( v.X()*mCos + v.Y()*mSin, -v.X()*mSin + v.Y()*mCos );
110+
return Point2D<T>(v.X() * mCos + v.Y() * mSin, -v.X() * mSin + v.Y() * mCos);
117111
}
118112

119113
template <typename T>
120114
Vector2D<T> operator()(const Vector2D<T>& v) const
121115
{ // local->master
122-
return Vector2D<T>( v.X()*mCos - v.Y()*mSin, v.X()*mSin + v.Y()*mCos );
116+
return Vector2D<T>(v.X() * mCos - v.Y() * mSin, v.X() * mSin + v.Y() * mCos);
123117
}
124118

125119
template <typename T>
126120
Vector2D<T> operator^(const Vector2D<T>& v) const
127121
{ // master->local
128-
return Vector2D<T>( v.X()*mCos + v.Y()*mSin, -v.X()*mSin + v.Y()*mCos );
122+
return Vector2D<T>(v.X() * mCos + v.Y() * mSin, -v.X() * mSin + v.Y() * mCos);
129123
}
130-
124+
131125
private:
132-
133-
float mCos = 1.f; ///< cos of rotation angle
134-
float mSin = 0.f; ///< sin of rotation angle
126+
float mCos = 1.f; ///< cos of rotation angle
127+
float mSin = 0.f; ///< sin of rotation angle
135128

136-
ClassDefNV(Rotation2D,1);
129+
ClassDefNV(Rotation2D, 1);
137130
};
138-
131+
139132
class Transform3D : public ROOT::Math::Transform3D
140133
{
141134
//
@@ -154,25 +147,28 @@ class Transform3D : public ROOT::Math::Transform3D
154147

155148
// inherit assignment operators of the base class
156149
using ROOT::Math::Transform3D::operator=;
157-
150+
158151
// to avoid conflict between the base Transform3D(const ForeignMatrix & m) and
159152
// Transform3D(const TGeoMatrix &m) constructors we cannot inherit base c-tors,
160153
// therefore we redefine them here
161154
Transform3D(const ROOT::Math::Rotation3D& r, const Vector& v) : ROOT::Math::Transform3D(r, v) {}
162155
Transform3D(const ROOT::Math::Rotation3D& r, const ROOT::Math::Translation3D& t) : ROOT::Math::Transform3D(r, t) {}
163156
template <class IT>
164-
Transform3D(IT begin, IT end) : ROOT::Math::Transform3D(begin, end) {}
157+
Transform3D(IT begin, IT end) : ROOT::Math::Transform3D(begin, end)
158+
{
159+
}
165160

166161
// conversion operator to TGeoHMatrix
167-
operator TGeoHMatrix&() const {
162+
operator TGeoHMatrix&() const
163+
{
168164
static TGeoHMatrix tmp;
169-
double rot[9],tra[3];
170-
GetComponents(rot[0],rot[1],rot[2],tra[0],rot[3],rot[4],rot[5],tra[1],rot[6],rot[7],rot[8],tra[2]);
165+
double rot[9], tra[3];
166+
GetComponents(rot[0], rot[1], rot[2], tra[0], rot[3], rot[4], rot[5], tra[1], rot[6], rot[7], rot[8], tra[2]);
171167
tmp.SetRotation(rot);
172168
tmp.SetTranslation(tra);
173169
return tmp;
174170
}
175-
171+
176172
void set(const TGeoMatrix& m); // set parameters from TGeoMatrix
177173

178174
using ROOT::Math::Transform3D::operator();
@@ -227,9 +223,7 @@ class Transform3D : public ROOT::Math::Transform3D
227223
ClassDefNV(Transform3D, 1)
228224
};
229225
}
230-
}
231-
232-
std::ostream &operator<<(std::ostream &os, const o2::Base::Rotation2D &t);
233226

227+
std::ostream& operator<<(std::ostream& os, const o2::Rotation2D& t);
234228

235229
#endif

0 commit comments

Comments
 (0)