Skip to content

Commit 98f5e90

Browse files
committed
Fixes for ITS/MFT GeometryTGeo, store them with create-aligned-geometry
1 parent 47a2172 commit 98f5e90

7 files changed

Lines changed: 64 additions & 18 deletions

File tree

Common/MathUtils/include/MathUtils/Cartesian.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,9 @@ class Rotation2D
9393
sn = mSin;
9494
}
9595

96+
value_t getCos() const { return mCos; }
97+
value_t getSin() const { return mSin; }
98+
9699
template <typename T>
97100
Point3D<T> operator()(const Point3D<T>& v) const
98101
{ // local->master

Detectors/GRP/workflows/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,8 @@ o2_add_executable(workflow
4747
O2::CommonUtils
4848
O2::CCDB
4949
O2::DetectorsRaw
50+
O2::ITSBase
51+
O2::MFTBase
5052
Boost::program_options)
5153

5254
o2_add_executable(grp-dcs-dps-sim-workflow

Detectors/GRP/workflows/src/create-aligned-geometry.cxx

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818
#include <TGeoManager.h>
1919
#include "DetectorsCommonDataFormats/DetID.h"
2020
#include "DetectorsBase/GRPGeomHelper.h"
21+
#include "MFTBase/GeometryTGeo.h"
22+
#include "ITSBase/GeometryTGeo.h"
2123
#include "Framework/Task.h"
2224
#include "Framework/DataProcessorSpec.h"
2325
#include "Framework/ConfigParamRegistry.h"
@@ -96,7 +98,29 @@ class AlignerTask : public Task
9698
gGeoManager->SetName(std::string(o2::base::NameConf::CCDBOBJECT).c_str());
9799
auto fnm = o2::base::NameConf::getAlignedGeomFileName();
98100
gGeoManager->Export(fnm.c_str());
99-
LOG(info) << "Stored to local file " << fnm;
101+
LOGP(info, "Stored aligned geometry to local file {}", fnm);
102+
103+
// create GeometryTGeo for detectors which support it
104+
{
105+
auto itsTGeo = o2::its::GeometryTGeo::Instance();
106+
itsTGeo->fillMatrixCache(o2::math_utils::bit2Mask(o2::math_utils::TransformType::T2L, o2::math_utils::TransformType::L2G, o2::math_utils::TransformType::T2GRot));
107+
TFile outF("its_GeometryTGeo.root", "recreate");
108+
outF.WriteObjectAny(itsTGeo, "o2::its::GeometryTGeo", "ccdb_object");
109+
LOGP(info, "Stored ITS geometry to {}", outF.GetName());
110+
outF.Close();
111+
itsTGeo->destroy();
112+
}
113+
{
114+
auto mftTGeo = o2::mft::GeometryTGeo::Instance();
115+
mftTGeo->fillMatrixCache(o2::math_utils::bit2Mask(o2::math_utils::TransformType::T2L, o2::math_utils::TransformType::L2G, o2::math_utils::TransformType::T2G));
116+
TFile outF("mft_GeometryTGeo.root", "recreate");
117+
outF.WriteObjectAny(mftTGeo, "o2::mft::GeometryTGeo", "ccdb_object");
118+
LOGP(info, "Stored MFT geometry to {}", outF.GetName());
119+
outF.Close();
120+
mftTGeo->destroy();
121+
}
122+
// consider upgrades?
123+
100124
pc.services().get<ControlService>().endOfStream();
101125
pc.services().get<ControlService>().readyToQuit(QuitRequest::Me);
102126
}

Detectors/ITSMFT/ITS/base/include/ITSBase/GeometryTGeo.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,16 +67,16 @@ class GeometryTGeo : public o2::itsmft::GeometryTGeo
6767

6868
// adopt the unique instance from external raw pointer (to be used only to read saved instance from file)
6969
static void adopt(GeometryTGeo* raw);
70-
7170
// constructor
7271
// ATTENTION: this class is supposed to behave as a singleton, but to make it root-persistent
7372
// we must define public default constructor.
7473
// NEVER use it, it will throw exception if the class instance was already created
7574
// Use GeometryTGeo::Instance() instead
7675
GeometryTGeo(bool build = kFALSE, int loadTrans = 0, bool isITS3 = false);
7776

78-
/// Default destructor
77+
/// Default destructor, don't use
7978
~GeometryTGeo() override;
79+
void destroy() { sInstance.reset(); }
8080

8181
GeometryTGeo(const GeometryTGeo& src) = delete;
8282
GeometryTGeo& operator=(const GeometryTGeo& geom) = delete;

Detectors/ITSMFT/ITS/base/src/GeometryTGeo.cxx

Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -555,20 +555,6 @@ void GeometryTGeo::fillMatrixCache(int mask)
555555
}
556556
}
557557

558-
if ((mask & o2::math_utils::bit2Mask(o2::math_utils::TransformType::T2G)) && !getCacheT2G().isFilled()) {
559-
LOG(warning) << "It is faster to use 2D rotation for T2G instead of full Transform3D matrices";
560-
// matrices for Tracking to Global frame transformation
561-
LOGP(info, "Loading {} T2G matrices from TGeo", getName());
562-
auto& cacheT2G = getCacheT2G();
563-
cacheT2G.setSize(mSize);
564-
565-
for (int i = 0; i < mSize; i++) {
566-
TGeoHMatrix& mat = createT2LMatrix(i);
567-
mat.MultiplyLeft(extractMatrixSensor(i));
568-
cacheT2G.setMatrix(Mat3D(mat), i);
569-
}
570-
}
571-
572558
if ((mask & o2::math_utils::bit2Mask(o2::math_utils::TransformType::T2GRot)) && !getCacheT2GRot().isFilled()) {
573559
// 2D rotation matrices for Tracking frame to Global rotations
574560
LOGP(info, "Loading {} T2G rotation 2D matrices", getName());
@@ -578,6 +564,25 @@ void GeometryTGeo::fillMatrixCache(int mask)
578564
cacheT2Gr.setMatrix(Rot2D(getSensorRefAlpha(i)), i);
579565
}
580566
}
567+
568+
if ((mask & o2::math_utils::bit2Mask(o2::math_utils::TransformType::T2G)) && !getCacheT2G().isFilled()) {
569+
LOG(debug) << "It is faster to use 2D rotation for T2G instead of full Transform3D matrices";
570+
// matrices for Tracking to Global frame transformation
571+
LOGP(info, "Creating {} T2G matrices from TGeo", getName());
572+
auto& cacheT2G = getCacheT2G();
573+
cacheT2G.setSize(mSize);
574+
575+
for (int i = 0; i < mSize; i++) {
576+
/*
577+
TGeoHMatrix& mat = createT2LMatrix(i);
578+
mat.MultiplyLeft(extractMatrixSensor(i));
579+
*/
580+
Rot2D r(getSensorRefAlpha(i));
581+
Mat3D mat{};
582+
mat.SetComponents(r.getCos(), -r.getSin(), 0., 0., r.getSin(), r.getCos(), 0., 0., 0., 0., 1., 0.);
583+
cacheT2G.setMatrix(mat, i);
584+
}
585+
}
581586
}
582587

583588
//__________________________________________________________________________

Detectors/ITSMFT/MFT/base/include/MFTBase/GeometryTGeo.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,12 +64,14 @@ class GeometryTGeo : public o2::itsmft::GeometryTGeo
6464
o2::math_utils::TransformType::L2G)*/
6565
);
6666

67-
/// Default destructor
67+
/// Default destructor, don't use
6868
~GeometryTGeo() override;
6969

7070
GeometryTGeo(const GeometryTGeo& src) = delete;
7171
GeometryTGeo& operator=(const GeometryTGeo& geom) = delete;
7272

73+
void destroy() { sInstance.reset(); }
74+
7375
// implement filling of the matrix cache
7476
using o2::itsmft::GeometryTGeo::fillMatrixCache;
7577
void fillMatrixCache(Int_t mask) override;

Detectors/ITSMFT/MFT/base/src/GeometryTGeo.cxx

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,16 @@ GeometryTGeo::GeometryTGeo(Bool_t build, Int_t loadTrans) : o2::itsmft::Geometry
7676
}
7777
}
7878

79+
//__________________________________________________________________________
80+
void GeometryTGeo::adopt(GeometryTGeo* raw)
81+
{
82+
// adopt the unique instance from external raw pointer (to be used only to read saved instance from file)
83+
if (sInstance) {
84+
LOG(fatal) << "No adoption: o2::mft::GeometryTGeo instance exists";
85+
}
86+
sInstance = std::unique_ptr<o2::mft::GeometryTGeo>(raw);
87+
}
88+
7989
//__________________________________________________________________________
8090
void GeometryTGeo::Build(Int_t loadTrans)
8191
{

0 commit comments

Comments
 (0)