Skip to content

Commit a476338

Browse files
fuhlig1dennisklein
authored andcommitted
Fix TGeo unit system to be the ROOT one
Fix the unit system to the ROOT one which was the default before ROOT v6.18.02. With ROOT v6.18.02 the ROOT team introduced a new unit system (taken from Geant4) for the geometry manager. This change was reverted with ROOT v6.25.1. Before version v6.18.2 and after v6.25.1 the units are correct by default.
1 parent 3c7df5a commit a476338

File tree

1 file changed

+26
-1
lines changed

1 file changed

+26
-1
lines changed

base/steer/FairRun.cxx

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,12 @@
2121
#include "FairRuntimeDb.h" // for FairRuntimeDb
2222
#include "FairTask.h" // for FairTask
2323

24-
#include <TFile.h> // for TFile
24+
#include <RVersion.h> // for ROOT_VERSION_CODE and ROOT_VERSION
25+
#include <TFile.h> // for TFile
26+
#include <TGeoManager.h> // for gGeoManager, TGeoManager
27+
#if ROOT_VERSION_CODE >= ROOT_VERSION(6, 18, 2) && ROOT_VERSION_CODE <= ROOT_VERSION(6, 22, 6)
28+
#include <TGeoSystemOfUnits.h> // for TGeoUnit::kTGeoUnits
29+
#endif
2530
#include <TList.h> // for TList
2631
#include <TObject.h> // for TObject
2732
#include <cassert> // for... well, assert
@@ -50,8 +55,28 @@ FairRun::FairRun(Bool_t isMaster)
5055
Fatal("FairRun", "Singleton instance already exists.");
5156
return;
5257
}
58+
5359
fRunInstance = this;
5460

61+
// Fix the unit system to the ROOT one which was the default before ROOT v6.18.02.
62+
// With ROOT v6.18.02 the ROOT team introduced a new unit system (taken from Geant4)
63+
// for the geometry manager. The change was reverted with ROOT v6.25.1.
64+
// Unfortunately the way to set the default units to the ROOT one is
65+
// different for different ROOT versions such that the code needs some
66+
// preprocessor statements.
67+
// Before version v6.18.2 and after v6.25.1 the units are correct
68+
// by default
69+
70+
#if ROOT_VERSION_CODE >= ROOT_VERSION(6, 18, 2) && ROOT_VERSION_CODE <= ROOT_VERSION(6, 22, 6)
71+
TGeoUnit::setUnitType(TGeoUnit::kTGeoUnits);
72+
#endif
73+
74+
#if ROOT_VERSION_CODE >= ROOT_VERSION(6, 22, 8) && ROOT_VERSION_CODE <= ROOT_VERSION(6, 25, 1)
75+
TGeoManager::LockDefaultUnits(false);
76+
TGeoManager::SetDefaultUnits(TGeoManager::EDefaultUnits::kRootUnits);
77+
TGeoManager::LockDefaultUnits(true);
78+
#endif
79+
5580
fRootManager = FairRootManager::Instance();
5681

5782
new FairLinkManager();

0 commit comments

Comments
 (0)