Skip to content

Commit 762cef7

Browse files
authored
[EMCAL-689] EMCAL/Geometry: Add function to load alignment matrix from CCDB (#14237)
- Add function `SetMisalMatrixFromCcdb` to set the missalignment matrices for the EMCal via the CCDB. This way they are not laoded from the GeoManager. The function expects a path inside the ccdb, which by default is set to `"Users/m/mhemmer/EMCAL/Config/GeometryAligned"` and the timestamp. Currently in the CCDB we only have the old Run 2 alignment object. Once we have the new alignment objects we can uplaod them and via the correct time stamp load them fittingly.
1 parent e7d217a commit 762cef7

File tree

2 files changed

+36
-4
lines changed

2 files changed

+36
-4
lines changed

Detectors/EMCAL/base/include/EMCALBase/Geometry.h

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,9 @@
2222
#include <TNamed.h>
2323
#include <TParticle.h>
2424
#include <TVector3.h>
25+
#include <TObjArray.h>
2526

27+
#include "CCDB/BasicCCDBManager.h"
2628
#include "DataFormatsEMCAL/Constants.h"
2729
#include "EMCALBase/GeometryBase.h"
2830
#include "MathUtils/Cartesian.h"
@@ -57,7 +59,7 @@ class Geometry
5759
/// | EMCAL_COMPLETE12SMV1_DCAL | Full EMCAL, 10 DCAL Supermodules (not used in practice) |
5860
/// | EMCAL_COMPLETE12SMV1_DCAL_8SM | Full EMCAL, 8 DCAL Supermodules (run2) |
5961
/// | EMCAL_COMPLETE12SMV1_DCAL_DEV | Full EMCAL, DCAL development geometry (not used) |
60-
Geometry(const std::string_view name, const std::string_view mcname = "", const std::string_view mctitle = "");
62+
explicit Geometry(const std::string_view name, const std::string_view mcname = "", const std::string_view mctitle = "");
6163

6264
/// \brief Copy constructor.
6365
Geometry(const Geometry& geom);
@@ -564,6 +566,11 @@ class Geometry
564566
///
565567
void SetMisalMatrix(const TGeoHMatrix* m, Int_t smod) const;
566568

569+
///
570+
/// Method to set shift-rotational matrixes from CCDB
571+
///
572+
void SetMisalMatrixFromCcdb(const char* path = "Users/m/mhemmer/EMCAL/Config/GeometryAligned", int timestamp = 10000) const;
573+
567574
///
568575
/// Transform clusters cell position into global with alternative method, taking into account the depth calculation.
569576
/// Input are:

Detectors/EMCAL/base/src/Geometry.cxx

Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,21 @@
88
// In applying this license CERN does not waive the privileges and immunities
99
// granted to it by virtue of its status as an Intergovernmental Organization
1010
// or submit itself to any jurisdiction.
11+
#include "EMCALBase/Geometry.h"
12+
13+
#include <fairlogger/Logger.h>
14+
1115
#include <iomanip>
16+
#include <string>
17+
#include <algorithm>
18+
#include <cstdio>
19+
#include <tuple>
1220

1321
#include <TGeoBBox.h>
1422
#include <TGeoManager.h>
1523
#include <TGeoMatrix.h>
1624
#include <TList.h>
1725

18-
#include <fairlogger/Logger.h>
19-
20-
#include "EMCALBase/Geometry.h"
2126
#include "EMCALBase/ShishKebabTrd1Module.h"
2227

2328
#include <boost/algorithm/string/predicate.hpp>
@@ -1557,6 +1562,7 @@ const TGeoHMatrix* Geometry::GetMatrixForSuperModule(Int_t smod) const
15571562

15581563
if (!SMODULEMATRIX[smod]) {
15591564
if (gGeoManager) {
1565+
LOG(info) << "Loading EMCAL misalignment matrix for SM " << smod << " from GeoManager.";
15601566
SetMisalMatrix(GetMatrixForSuperModuleFromGeoManager(smod), smod);
15611567
} else {
15621568
LOG(fatal) << "Cannot find EMCAL misalignment matrices! Recover them either: \n"
@@ -1762,6 +1768,25 @@ void Geometry::SetMisalMatrix(const TGeoHMatrix* m, Int_t smod) const
17621768
}
17631769
}
17641770

1771+
void Geometry::SetMisalMatrixFromCcdb(const char* path, int timestamp) const
1772+
{
1773+
LOG(info) << "Using CCDB to obtain EMCal alignment.";
1774+
o2::ccdb::CcdbApi api;
1775+
map<string, string> metadata; // can be empty
1776+
api.init("http://alice-ccdb.cern.ch");
1777+
TObjArray* matrices = api.retrieveFromTFileAny<TObjArray>(path, metadata, timestamp);
1778+
1779+
for (int iSM = 0; iSM < mNumberOfSuperModules; ++iSM) {
1780+
TGeoHMatrix* mat = reinterpret_cast<TGeoHMatrix*>(matrices->At(iSM));
1781+
if (mat) {
1782+
1783+
SetMisalMatrix(mat, iSM);
1784+
} else {
1785+
LOG(info) << "Could not obtain Alignment Matrix for SM " << iSM;
1786+
}
1787+
}
1788+
}
1789+
17651790
Bool_t Geometry::IsDCALSM(Int_t iSupMod) const
17661791
{
17671792
if (mEMCSMSystem[iSupMod] == DCAL_STANDARD || mEMCSMSystem[iSupMod] == DCAL_EXT) {

0 commit comments

Comments
 (0)