diff --git a/reco/tracking/lx/GenNoiseElectrons/GenNoiseElectrons.cxx b/reco/tracking/lx/GenNoiseElectrons/GenNoiseElectrons.cxx
index 46c43d4a9bba3a4bf8954a04e36a4ed699d10e46..0ab3812a31ede5ae0fa451b198a088c92e644609 100644
--- a/reco/tracking/lx/GenNoiseElectrons/GenNoiseElectrons.cxx
+++ b/reco/tracking/lx/GenNoiseElectrons/GenNoiseElectrons.cxx
@@ -36,6 +36,11 @@ static Double_t GetRMS(const char* name) {
   char fileName[128];
   sprintf(fileName, "%s.root", name);
   TFile* curFile = TFile::CurrentFile();
+
+  /// Save old global file and folder pointer to avoid messing with FairRoot
+  TFile* oldFile     = gFile;
+  TDirectory* oldDir = gDirectory;
+
   TFile* f       = new TFile(fileName);
 
   if (!f->IsZombie()) {
@@ -46,6 +51,11 @@ static Double_t GetRMS(const char* name) {
 
   delete f;
   TFile::CurrentFile() = curFile;
+
+  /// Restore old global file and folder pointer to avoid messing with FairRoot
+  gFile      = oldFile;
+  gDirectory = oldDir;
+
   return result;
 }
 
diff --git a/reco/tracking/lx/Simple/Lx.cxx b/reco/tracking/lx/Simple/Lx.cxx
index 21ba88b4e678a79a74daef1a27060aa10f8472f6..7f52c919fc669994bd739f450b2a36fa46511170 100644
--- a/reco/tracking/lx/Simple/Lx.cxx
+++ b/reco/tracking/lx/Simple/Lx.cxx
@@ -296,6 +296,11 @@ GetHistoRMS(const char* histoNameBase, Int_t histoNumber, scaltype& retVal) {
       sprintf(name, "%s/%s_%d.root", dir_name, histoNameBase, histoNumber);
 
     TFile* curFile = TFile::CurrentFile();
+
+    /// Save old global file and folder pointer to avoid messing with FairRoot
+    TFile* oldFile     = gFile;
+    TDirectory* oldDir = gDirectory;
+
     TFile* f       = new TFile(name);
 
     if (!f->IsZombie()) {
@@ -311,6 +316,10 @@ GetHistoRMS(const char* histoNameBase, Int_t histoNumber, scaltype& retVal) {
 
     delete f;
     TFile::CurrentFile() = curFile;
+
+    /// Restore old global file and folder pointer to avoid messing with FairRoot
+    gFile      = oldFile;
+    gDirectory = oldDir;
   }
   return result;
 }
@@ -328,6 +337,11 @@ static bool GetHistoCOV(const char* histoNameBase,
     sprintf(dir_name, "configuration.%s", lxFinderParticleType.Data());
     sprintf(name, "%s/%s_%d.root", dir_name, histoNameBase, histoNumber);
     TFile* curFile = TFile::CurrentFile();
+
+    /// Save old global file and folder pointer to avoid messing with FairRoot
+    TFile* oldFile     = gFile;
+    TDirectory* oldDir = gDirectory;
+
     TFile* f       = new TFile(name);
 
     if (!f->IsZombie()) {
@@ -339,6 +353,10 @@ static bool GetHistoCOV(const char* histoNameBase,
 
     delete f;
     TFile::CurrentFile() = curFile;
+
+    /// Restore old global file and folder pointer to avoid messing with FairRoot
+    gFile      = oldFile;
+    gDirectory = oldDir;
   }
   return result;
 }
diff --git a/reco/tracking/lx/TBBinned/LxTBTrdTask.cxx b/reco/tracking/lx/TBBinned/LxTBTrdTask.cxx
index 23b4d9266e22e542f9bf3d37baa5955202c5b414..6d326854f63c2a9172a09d4904d05796515a043e 100644
--- a/reco/tracking/lx/TBBinned/LxTBTrdTask.cxx
+++ b/reco/tracking/lx/TBBinned/LxTBTrdTask.cxx
@@ -148,6 +148,11 @@ static bool GetHistoRMS(const char* name, Double_t& retVal) {
   sprintf(fileName, "%s.root", name);
   bool result    = false;
   TFile* curFile = TFile::CurrentFile();
+
+  /// Save old global file and folder pointer to avoid messing with FairRoot
+  TFile* oldFile     = gFile;
+  TDirectory* oldDir = gDirectory;
+
   TFile* f       = new TFile(fileName);
 
   if (!f->IsZombie()) {
@@ -158,6 +163,11 @@ static bool GetHistoRMS(const char* name, Double_t& retVal) {
 
   delete f;
   TFile::CurrentFile() = curFile;
+
+  /// Restore old global file and folder pointer to avoid messing with FairRoot
+  gFile      = oldFile;
+  gDirectory = oldDir;
+
   return result;
 }
 
diff --git a/reco/tracking/lxTriplet/Lx.cxx b/reco/tracking/lxTriplet/Lx.cxx
index 61877229c023d65efc642a1d7f9be156e719355e..92333c590adc7b9ed63b354cb3b885118bd79076 100644
--- a/reco/tracking/lxTriplet/Lx.cxx
+++ b/reco/tracking/lxTriplet/Lx.cxx
@@ -139,6 +139,11 @@ GetHistoRMS(const char* histoNameBase, Int_t histoNumber, Double_t& retVal) {
   bool result = false;
   sprintf(name, "%s/%s_%d.root", dir_name, histoNameBase, histoNumber);
   TFile* curFile = TFile::CurrentFile();
+
+  /// Save old global file and folder pointer to avoid messing with FairRoot
+  TFile* oldFile     = gFile;
+  TDirectory* oldDir = gDirectory;
+
   TFile* f       = new TFile(name);
 
   if (!f->IsZombie()) {
@@ -150,6 +155,11 @@ GetHistoRMS(const char* histoNameBase, Int_t histoNumber, Double_t& retVal) {
 
   delete f;
   TFile::CurrentFile() = curFile;
+
+  /// Restore old global file and folder pointer to avoid messing with FairRoot
+  gFile      = oldFile;
+  gDirectory = oldDir;
+
   return result;
 }
 
@@ -162,6 +172,11 @@ static bool GetHistoCOV(const char* histoNameBase,
   bool result = false;
   sprintf(name, "configuration/%s_%d.root", histoNameBase, histoNumber);
   TFile* curFile = TFile::CurrentFile();
+
+  /// Save old global file and folder pointer to avoid messing with FairRoot
+  TFile* oldFile     = gFile;
+  TDirectory* oldDir = gDirectory;
+
   TFile* f       = new TFile(name);
 
   if (!f->IsZombie()) {
@@ -173,6 +188,11 @@ static bool GetHistoCOV(const char* histoNameBase,
 
   delete f;
   TFile::CurrentFile() = curFile;
+
+  /// Restore old global file and folder pointer to avoid messing with FairRoot
+  gFile      = oldFile;
+  gDirectory = oldDir;
+
   return result;
 }
 
diff --git a/reco/tracking/lxTriplet/LxTrackAnaSegments.cxx b/reco/tracking/lxTriplet/LxTrackAnaSegments.cxx
index f996fd52ecc6d328339366145ebb27769a466d40..e6a4d71c38d079be81ff235f0c13f6e2875c2059 100644
--- a/reco/tracking/lxTriplet/LxTrackAnaSegments.cxx
+++ b/reco/tracking/lxTriplet/LxTrackAnaSegments.cxx
@@ -62,6 +62,11 @@ GetHistoRMS(const char* histoNameBase, Int_t histoNumber, Double_t& retVal) {
   bool result = false;
   sprintf(name, "%s/%s_%d.root", dir_name, histoNameBase, histoNumber);
   TFile* curFile = TFile::CurrentFile();
+
+  /// Save old global file and folder pointer to avoid messing with FairRoot
+  TFile* oldFile     = gFile;
+  TDirectory* oldDir = gDirectory;
+
   TFile* f       = new TFile(name);
 
   if (!f->IsZombie()) {
@@ -73,6 +78,11 @@ GetHistoRMS(const char* histoNameBase, Int_t histoNumber, Double_t& retVal) {
 
   delete f;
   TFile::CurrentFile() = curFile;
+
+  /// Restore old global file and folder pointer to avoid messing with FairRoot
+  gFile      = oldFile;
+  gDirectory = oldDir;
+
   return result;
 }