Skip to content
Snippets Groups Projects
Commit 2823ca08 authored by Pierre-Alain Loizeau's avatar Pierre-Alain Loizeau
Browse files

In unpack monitors, protect hist/canv creation from current root folder pb

parent b007a2b4
No related branches found
No related tags found
No related merge requests found
......@@ -17,6 +17,7 @@
#include <TH2.h>
#include <THttpServer.h>
#include <TProfile.h>
#include <TROOT.h>
#include <cstdint>
#include <iomanip>
......@@ -880,6 +881,11 @@ Bool_t CbmMuchUnpackMonitor::Init(CbmMuchUnpackPar* parset)
// Get Infos from the parset
fNrElinksPerDpb = parset->GetNbElinkPerDpb();
/// Save old global file and folder pointer to avoid messing with FairRoot
TFile* oldFile = gFile;
TDirectory* oldDir = gDirectory;
gROOT->cd();
/// Trigger histo creation on all associated monitors
CreateHistograms(parset);
if (fDebugMode) CreateDebugHistograms(parset);
......@@ -887,6 +893,10 @@ Bool_t CbmMuchUnpackMonitor::Init(CbmMuchUnpackPar* parset)
/// Trigger Canvas creation on all associated monitors
DrawCanvases();
/// Restore old global file and folder pointer to avoid messing with FairRoot
gFile = oldFile;
gDirectory = oldDir;
/// Obtain vector of pointers on each histo from the algo (+ optionally desired folder)
std::vector<std::pair<TNamed*, std::string>> vHistos = GetHistoVector();
......
......@@ -16,6 +16,7 @@
#include <TH2.h>
#include <THttpServer.h>
#include <TProfile.h>
#include <TROOT.h>
#include <cstdint>
#include <iomanip>
......@@ -113,10 +114,20 @@ void CbmRichUnpackMonitor::PrintDebugInfo(const uint64_t MsStartTime, const size
Bool_t CbmRichUnpackMonitor::Init(CbmMcbm2018RichPar* parset)
{
pUnpackParameters = parset;
/// Save old global file and folder pointer to avoid messing with FairRoot
TFile* oldFile = gFile;
TDirectory* oldDir = gDirectory;
gROOT->cd();
/// Trigger histo creation on all associated monitors
CreateHistograms(parset);
if (fDebugMode) CreateDebugHistograms(parset);
/// Restore old global file and folder pointer to avoid messing with FairRoot
gFile = oldFile;
gDirectory = oldDir;
/// Obtain vector of pointers on each histo from the algo (+ optionally desired folder)
std::vector<std::pair<TNamed*, std::string>> vHistos = GetHistoVector();
......
......@@ -20,7 +20,12 @@ CbmStsUnpackConfig::CbmStsUnpackConfig(std::string detGeoSetupTag, UInt_t runid)
{
}
CbmStsUnpackConfig::~CbmStsUnpackConfig() {}
CbmStsUnpackConfig::~CbmStsUnpackConfig()
{
LOG(debug) << fName << "::~CbmStsUnpackConfig";
fWalkMap.clear();
LOG(debug) << fName << "::~CbmStsUnpackConfig done";
}
// ---- Init ----
void CbmStsUnpackConfig::InitAlgo()
......
......@@ -17,6 +17,7 @@
#include <TH2.h>
#include <THttpServer.h>
#include <TProfile.h>
#include <TROOT.h>
#include <cstdint>
#include <iomanip>
......@@ -879,6 +880,11 @@ Bool_t CbmStsUnpackMonitor::Init(CbmMcbm2018StsPar* parset)
// Get Infos from the parset
fNrElinksPerDpb = parset->GetNbElinkPerDpb();
/// Save old global file and folder pointer to avoid messing with FairRoot
TFile* oldFile = gFile;
TDirectory* oldDir = gDirectory;
gROOT->cd();
/// Trigger histo creation on all associated monitors
CreateHistograms(parset);
if (fDebugMode) CreateDebugHistograms(parset);
......@@ -886,6 +892,10 @@ Bool_t CbmStsUnpackMonitor::Init(CbmMcbm2018StsPar* parset)
/// Trigger Canvas creation on all associated monitors
DrawCanvases();
/// Restore old global file and folder pointer to avoid messing with FairRoot
gFile = oldFile;
gDirectory = oldDir;
/// Obtain vector of pointers on each histo from the algo (+ optionally desired folder)
std::vector<std::pair<TNamed*, std::string>> vHistos = GetHistoVector();
......
......@@ -20,6 +20,7 @@
#include <THttpServer.h>
#include <TPaveStats.h>
#include <TProfile.h>
#include <TROOT.h>
#include <cstdint>
#include <iomanip>
......@@ -1312,6 +1313,11 @@ Bool_t CbmTofUnpackMonitor::Init(CbmMcbm2018TofPar* parset)
fuNbOfChannelsPerComp = fuNbOfGet4PerComp * fuNbOfChannelsPerGet4;
fuNbOfGet4InSyst = fuNbOfComps * fuNbOfGet4PerComp;
/// Save old global file and folder pointer to avoid messing with FairRoot
TFile* oldFile = gFile;
TDirectory* oldDir = gDirectory;
gROOT->cd();
/// Trigger histo creation on all associated monitors
CreateHistograms();
DrawCanvases();
......@@ -1320,6 +1326,10 @@ Bool_t CbmTofUnpackMonitor::Init(CbmMcbm2018TofPar* parset)
DrawBmonCanvases();
}
/// Restore old global file and folder pointer to avoid messing with FairRoot
gFile = oldFile;
gDirectory = oldDir;
/// Obtain vector of pointers on each histo from the algo (+ optionally desired folder)
std::vector<std::pair<TNamed*, std::string>> vHistos = GetHistoVector();
......@@ -1402,6 +1412,16 @@ void CbmTofUnpackMonitor::Finish()
histoFile->Close();
delete histoFile;
/// Cleanup memory
for (auto iter = fvpAllHistoPointers.begin(); iter != fvpAllHistoPointers.end();) {
if (iter->first != nullptr) { delete iter->first; }
iter = fvpAllHistoPointers.erase(iter);
}
for (auto iter = fvpAllCanvasPointers.begin(); iter != fvpAllCanvasPointers.end();) {
if (iter->first != nullptr) { delete iter->first; }
iter = fvpAllCanvasPointers.erase(iter);
}
}
......
......@@ -18,6 +18,7 @@
#include <TH1.h>
#include <TH2.h>
#include <TProfile.h>
#include <TROOT.h>
#include <boost/math/special_functions/math_fwd.hpp>
......@@ -98,8 +99,18 @@ Bool_t CbmTrdUnpackFaspMonitor::Init()
else
it++;
}
/// Save old global file and folder pointer to avoid messing with FairRoot
TFile* oldFile = gFile;
TDirectory* oldDir = gDirectory;
gROOT->cd();
createHistos();
/// Restore old global file and folder pointer to avoid messing with FairRoot
gFile = oldFile;
gDirectory = oldDir;
return kTRUE;
}
......
......@@ -19,6 +19,7 @@
#include <TH1.h>
#include <TH2.h>
#include <TProfile.h>
#include <TROOT.h>
#include <boost/math/special_functions/math_fwd.hpp>
......@@ -176,8 +177,17 @@ Bool_t CbmTrdUnpackMonitor::Init(CbmTrdParSetDigi* digiParSet, CbmTrdParSetAsic*
fHistoServer = run->GetHttpServer();
}
/// Save old global file and folder pointer to avoid messing with FairRoot
TFile* oldFile = gFile;
TDirectory* oldDir = gDirectory;
gROOT->cd();
createHistos();
/// Restore old global file and folder pointer to avoid messing with FairRoot
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