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>
@@ -265,8 +270,7 @@ Geometry* Geometry::GetInstanceFromRunNumber(Int_t runNumber, const std::string_
265270 " <<EMCAL_COMPLETE12SMV1>>" ;
266271 }
267272 return Geometry::GetInstance (" EMCAL_COMPLETE12SMV1" , mcname, mctitle);
268- } else // Run 2
269- {
273+ } else { // Run 2
270274 // EMCAL + DCAL geometry, 20 SM. Year 2015 and on
271275
272276 if (contains (geoName, " DCAL_8SM" ) && geoName != std::string (" " )) {
@@ -562,8 +566,8 @@ void Geometry::DefineEMC(std::string_view mcname, std::string_view mctitle)
562566 mNPhiSuperModule = 1 ;
563567 }
564568
565- mPhiTileSize = mPhiModuleSize / double (mNPHIdiv ) - mLateralSteelStrip ; // 13-may-05
566- mEtaTileSize = mEtaModuleSize / double (mNETAdiv ) - mLateralSteelStrip ; // 13-may-05
569+ mPhiTileSize = mPhiModuleSize / static_cast < double > (mNPHIdiv ) - mLateralSteelStrip ; // 13-may-05
570+ mEtaTileSize = mEtaModuleSize / static_cast < double > (mNETAdiv ) - mLateralSteelStrip ; // 13-may-05
567571
568572 mLongModuleSize = mNECLayers * (mECScintThick + mECPbRadThickness );
569573 if (contains (mGeoName , " V1" )) {
@@ -626,7 +630,7 @@ void Geometry::DefineEMC(std::string_view mcname, std::string_view mctitle)
626630 break ;
627631 default :
628632 break ;
629- };
633+ }
630634 }
631635 mPhiCentersOfSM [i] = (mPhiBoundariesOfSM [2 * i] + mPhiBoundariesOfSM [2 * i + 1 ]) / 2 .;
632636 mPhiCentersOfSMSec [i] = mPhiBoundariesOfSM [2 * i] + TMath::ATan2 (mParSM [1 ], mIPDistance );
@@ -665,7 +669,7 @@ void Geometry::DefineEMC(std::string_view mcname, std::string_view mctitle)
665669 default :
666670 LOG (error) << " Unkown SM Type!!\n " ;
667671 break ;
668- };
672+ }
669673 }
670674 // for compatible reason
671675 // if(fNumberOfSuperModules == 4) {fEMCALPhiMax = fArm1PhiMax ;}
@@ -762,7 +766,7 @@ int Geometry::GetAbsCellId(int supermoduleID, int moduleID, int phiInModule, int
762766 break ;
763767 default :
764768 throw InvalidSupermoduleTypeException ();
765- };
769+ }
766770 }
767771
768772 cellid += mNCellsInModule * moduleID;
@@ -947,7 +951,7 @@ Int_t Geometry::GetAbsCellIdFromEtaPhi(Double_t eta, Double_t phi) const
947951 default :
948952 // All other supermodules have full number of cells in phi
949953 break ;
950- };
954+ }
951955
952956 Double_t dmin = TMath::Abs (mPhiCentersOfCells [0 ] - phiLoc),
953957 d = 0 .;
@@ -1027,7 +1031,7 @@ std::tuple<int, int, int, int> Geometry::CalculateCellIndex(Int_t absId) const
10271031 break ;
10281032 default :
10291033 throw InvalidSupermoduleTypeException ();
1030- };
1034+ }
10311035 }
10321036
10331037 Int_t nModule = tmp / mNCellsInModule ;
@@ -1060,8 +1064,8 @@ std::tuple<int, int> Geometry::GetModulePhiEtaIndexInSModule(int supermoduleID,
10601064 default :
10611065 nModulesInPhi = mNPhi ; // full SM
10621066 break ;
1063- };
1064- return std::make_tuple (int (moduleID % nModulesInPhi), int (moduleID / nModulesInPhi));
1067+ }
1068+ return std::make_tuple (static_cast < int > (moduleID % nModulesInPhi), static_cast < int > (moduleID / nModulesInPhi));
10651069}
10661070
10671071std::tuple<int , int > Geometry::GetCellPhiEtaIndexInSModule (int supermoduleID, int moduleID, int phiInModule,
@@ -1334,8 +1338,8 @@ void Geometry::CreateListOfTrd1Modules()
13341338 auto indexinsm = GetCellPhiEtaIndexInSModule (0 , nModule, 0 , ic);
13351339 ieta = std::get<1 >(indexinsm);
13361340 }
1337- mCentersOfCellsXDir [ieta] = float (xr) - mParSM [0 ];
1338- mCentersOfCellsEtaDir [ieta] = float (zr) - mParSM [2 ];
1341+ mCentersOfCellsXDir [ieta] = static_cast < float > (xr) - mParSM [0 ];
1342+ mCentersOfCellsEtaDir [ieta] = static_cast < float > (zr) - mParSM [2 ];
13391343 // Define grid on eta direction for each bin in phi
13401344 for (int iphi = 0 ; iphi < mCentersOfCellsPhiDir .size (); iphi++) {
13411345 x = xr + trd1.GetRadius ();
@@ -1557,6 +1561,7 @@ const TGeoHMatrix* Geometry::GetMatrixForSuperModule(Int_t smod) const
15571561
15581562 if (!SMODULEMATRIX[smod]) {
15591563 if (gGeoManager ) {
1564+ LOG (info) << " Loading EMCAL misalignment matrix for SM " << smod << " from GeoManager." ;
15601565 SetMisalMatrix (GetMatrixForSuperModuleFromGeoManager (smod), smod);
15611566 } else {
15621567 LOG (fatal) << " Cannot find EMCAL misalignment matrices! Recover them either: \n "
@@ -1582,8 +1587,8 @@ const TGeoHMatrix* Geometry::GetMatrixForSuperModuleFromArray(Int_t smod) const
15821587
15831588const TGeoHMatrix* Geometry::GetMatrixForSuperModuleFromGeoManager (Int_t smod) const
15841589{
1585- const Int_t buffersize = 255 ;
1586- char path[buffersize ];
1590+ constexpr Int_t kBufferSize = 255 ;
1591+ char path[kBufferSize ];
15871592 Int_t tmpType = -1 ;
15881593 Int_t smOrder = 0 ;
15891594
@@ -1614,7 +1619,7 @@ const TGeoHMatrix* Geometry::GetMatrixForSuperModuleFromGeoManager(Int_t smod) c
16141619 LOG (error) << " Unkown SM Type!!\n " ;
16151620 }
16161621
1617- snprintf (path, buffersize , " /cave/barrel_1/%s_%d" , smName.Data (), smOrder);
1622+ snprintf (path, kBufferSize , " /cave/barrel_1/%s_%d" , smName.Data (), smOrder);
16181623
16191624 if (!gGeoManager ->cd (path)) {
16201625 LOG (fatal) << " Geo manager can not find path " << path << " !\n " ;
@@ -1690,7 +1695,7 @@ void Geometry::RecalculateTowerPosition(Float_t drow, Float_t dcol, const Int_t
16901695 return ;
16911696 }
16921697
1693- istrip = int ((dcol + 0.5 ) / 2 );
1698+ istrip = static_cast < int > ((dcol + 0.5 ) / 2 );
16941699
16951700 // tapering angle
16961701 teta1 = TMath::DegToRad () * istrip * 1.5 ;
@@ -1762,6 +1767,25 @@ void Geometry::SetMisalMatrix(const TGeoHMatrix* m, Int_t smod) const
17621767 }
17631768}
17641769
1770+ void Geometry::SetMisalMatrixFromCcdb (const char * path, int timestamp) const
1771+ {
1772+ LOG (info) << " Using CCDB to obtain EMCal alignment." ;
1773+ auto & mCcdbManager = o2::ccdb::BasicCCDBManager::instance ();
1774+ mCcdbManager .setURL (o2::base::NameConf::getCCDBServer ());
1775+ mCcdbManager .setTimestamp (timestamp);
1776+ TObjArray* matrices = mCcdbManager .get <TObjArray>(path);
1777+
1778+ for (int iSM = 0 ; iSM < mNumberOfSuperModules ; ++iSM) {
1779+ TGeoHMatrix* mat = reinterpret_cast <TGeoHMatrix*>(matrices->At (iSM));
1780+ if (mat) {
1781+
1782+ SetMisalMatrix (mat, iSM);
1783+ } else {
1784+ LOG (info) << " Could not obtain Alignment Matrix for SM " << iSM;
1785+ }
1786+ }
1787+ }
1788+
17651789Bool_t Geometry::IsDCALSM (Int_t iSupMod) const
17661790{
17671791 if (mEMCSMSystem [iSupMod] == DCAL_STANDARD || mEMCSMSystem [iSupMod] == DCAL_EXT) {
0 commit comments