Skip to content
Snippets Groups Projects
Commit 40963796 authored by Administrator's avatar Administrator
Browse files

sts: Add gFile + gDirectory protection

parent f1b4a1d4
No related branches found
No related tags found
1 merge request!282Sts fix tfile glob point
Pipeline #8999 passed
......@@ -19,6 +19,7 @@
#include <FairRun.h> // for FairRun
#include <TCollection.h> // for TIter
#include <TDirectory.h> // for TDirectory, gDirectory
#include <TFile.h> // for TFile
#include <TGeoManager.h> // for TGeoManager, gGeoManager
#include <TGeoMatrix.h> // for TGeoHMatrix
......@@ -33,6 +34,7 @@
#include <cassert> // for assert
#include <iomanip> // for setw, __iom_t6
#include <iostream> // for fstream, string, char_traits
#include <string.h> // for strcmp
using namespace std;
......@@ -375,10 +377,15 @@ Bool_t CbmStsSetup::ReadGeometry(const char* fileName) {
// Exit if a TGeoManager is already present
assert(!gGeoManager);
TFile* oldFile = gFile;
TDirectory* oldDir = gDirectory;
// --- Open geometry file
TFile geoFile(fileName);
if (!geoFile.IsOpen()) {
LOG(fatal) << GetName() << ": Could not open geometry file " << fileName;
gFile = oldFile;
gDirectory = oldDir;
return kFALSE;
}
......@@ -402,6 +409,8 @@ Bool_t CbmStsSetup::ReadGeometry(const char* fileName) {
}
if (!topVolume) {
LOG(fatal) << GetName() << ": No TOP volume in file!";
gFile = oldFile;
gDirectory = oldDir;
return kFALSE;
}
stsGeometry->SetTopVolume(topVolume);
......@@ -423,6 +432,8 @@ Bool_t CbmStsSetup::ReadGeometry(const char* fileName) {
}
if (!sts) {
LOG(error) << fName << ": No top STS node found in geometry!";
gFile = oldFile;
gDirectory = oldDir;
return kFALSE;
}
......@@ -446,6 +457,8 @@ Bool_t CbmStsSetup::ReadGeometry(const char* fileName) {
// --- Recursively initialise daughter elements
InitDaughters();
gFile = oldFile;
gDirectory = oldDir;
return kTRUE;
}
// -------------------------------------------------------------------------
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment