13 #include "FairLogger.h"
14 #include "FairParGenericSet.h"
15 #include "FairRootManager.h"
17 #include "FairRunOnline.h"
18 #include "FairRuntimeDb.h"
21 #include "THttpServer.h"
38 , fbDebugMonitorMode(kFALSE)
39 , fbIgnoreCriticalErrors(kFALSE)
40 , fuHistoryHistoSize(3600)
41 , fsHistoFileName(
"data/HistosMonitor.root")
46 , fMonitorAlgo(nullptr) {
53 LOG(info) <<
"CbmMcbm2018MonitorTaskTof::Init";
54 LOG(info) <<
"Initializing eTOF 2019 Monitor task";
60 LOG(info) <<
"Setting parameter containers for " << GetName();
64 for (Int_t iparC = 0; iparC < parCList->GetEntries(); ++iparC) {
65 FairParGenericSet* tempObj = (FairParGenericSet*) (parCList->At(iparC));
66 parCList->Remove(tempObj);
68 std::string sParamName {tempObj->GetName()};
69 FairParGenericSet* newObj =
dynamic_cast<FairParGenericSet*
>(
70 FairRun::Instance()->GetRuntimeDb()->getContainer(sParamName.data()));
72 if (
nullptr == newObj) {
73 LOG(error) <<
"Failed to obtain parameter container " << sParamName
74 <<
", for parameter index " << iparC;
78 parCList->AddAt(newObj, iparC);
84 LOG(info) <<
"Init parameter containers for " << GetName();
88 FairRun::Instance()->GetRuntimeDb()->getContainer(
"CbmMcbm2018TofPar"));
89 if (
nullptr == pUnpackPar) {
90 LOG(error) <<
"Failed to obtain parameter container CbmMcbm2018TofPar";
108 std::vector<std::pair<TNamed*, std::string>> vHistos =
111 std::vector<std::pair<TCanvas*, std::string>> vCanvases =
115 THttpServer* server = FairRunOnline::Instance()->GetHttpServer();
116 if (
nullptr != server) {
117 for (UInt_t uHisto = 0; uHisto < vHistos.size(); ++uHisto) {
120 server->Register(Form(
"/%s", vHistos[uHisto].second.data()),
121 vHistos[uHisto].first);
124 for (UInt_t uCanv = 0; uCanv < vCanvases.size(); ++uCanv) {
127 server->Register(Form(
"/%s", vCanvases[uCanv].second.data()),
128 gROOT->FindObject((vCanvases[uCanv].first)->GetName()));
131 server->RegisterCommand(
"/Reset_Moni_Hist",
132 "bMcbm2018MonitorTaskTofResetHistos=kTRUE");
133 server->RegisterCommand(
"/Save_Moni_Hist",
134 "bMcbm2018MonitorTaskTofSaveHistos=kTRUE");
136 server->Restrict(
"/Reset_Moni_Hist",
"allow=admin");
143 LOG(info) <<
"ReInit parameter containers for " << GetName();
150 UShort_t usDetectorId) {
157 LOG(info) <<
"Reset Monitor histos ";
163 LOG(info) <<
"Save Monitor histos & canvases";
169 LOG(error) <<
"Failed processing TS " << ts.index()
170 <<
" in unpacker algorithm class";
195 std::vector<std::pair<TNamed*, std::string>> vHistos =
197 std::vector<std::pair<TCanvas*, std::string>> vCanvas =
201 TDirectory* oldDir = NULL;
202 TFile* histoFile = NULL;
208 if (
nullptr == histoFile)
return kFALSE;
211 for (UInt_t uHisto = 0; uHisto < vHistos.size(); ++uHisto) {
213 TString sFolder = vHistos[uHisto].second.data();
214 if (
nullptr == gDirectory->Get(sFolder)) gDirectory->mkdir(sFolder);
215 gDirectory->cd(sFolder);
218 vHistos[uHisto].first->Write();
223 for (UInt_t uCanvas = 0; uCanvas < vCanvas.size(); ++uCanvas) {
225 TString sFolder = vCanvas[uCanvas].second.data();
226 if (
nullptr == gDirectory->Get(sFolder)) gDirectory->mkdir(sFolder);
227 gDirectory->cd(sFolder);
230 vCanvas[uCanvas].first->Write();