13 #include "FairLogger.h"
14 #include "FairParGenericSet.h"
15 #include "FairRootManager.h"
17 #include "FairRunOnline.h"
18 #include "FairRuntimeDb.h"
21 #include "TClonesArray.h"
22 #include "THttpServer.h"
38 , fbDebugMonitorMode(kFALSE)
39 , fbIgnoreCriticalErrors(kFALSE)
40 , fuHistoryHistoSize(3600)
41 , fsHistoFileName(
"data/HistosMonitor.root")
47 , fMonitorAlgo(nullptr) {
54 LOG(info) <<
"CbmStar2019MonitorTask::Init";
55 LOG(info) <<
"Initializing eTOF 2019 Monitor task";
61 LOG(info) <<
"Setting parameter containers for " << GetName();
65 for (Int_t iparC = 0; iparC <
fParCList->GetEntries(); ++iparC) {
66 FairParGenericSet* tempObj = (FairParGenericSet*) (
fParCList->At(iparC));
69 std::string sParamName {tempObj->GetName()};
70 FairParGenericSet* newObj =
dynamic_cast<FairParGenericSet*
>(
71 FairRun::Instance()->GetRuntimeDb()->getContainer(sParamName.data()));
73 if (
nullptr == newObj) {
74 LOG(error) <<
"Failed to obtain parameter container " << sParamName
75 <<
", for parameter index " << iparC;
85 LOG(info) <<
"Init parameter containers for " << GetName();
89 FairRun::Instance()->GetRuntimeDb()->getContainer(
"CbmStar2019TofPar"));
90 if (
nullptr == pUnpackPar) {
91 LOG(error) <<
"Failed to obtain parameter container CbmStar2019TofPar";
109 std::vector<std::pair<TNamed*, std::string>> vHistos =
112 std::vector<std::pair<TCanvas*, std::string>> vCanvases =
116 THttpServer* server = FairRunOnline::Instance()->GetHttpServer();
117 if (
nullptr != server) {
118 for (UInt_t uHisto = 0; uHisto < vHistos.size(); ++uHisto) {
121 server->Register(Form(
"/%s", vHistos[uHisto].second.data()),
122 vHistos[uHisto].first);
125 for (UInt_t uCanv = 0; uCanv < vCanvases.size(); ++uCanv) {
128 server->Register(Form(
"/%s", vCanvases[uCanv].second.data()),
129 gROOT->FindObject((vCanvases[uCanv].first)->GetName()));
132 server->RegisterCommand(
"/Reset_Moni_Hist",
133 "bStar2019MonitorTaskResetHistos=kTRUE");
134 server->RegisterCommand(
"/Save_Moni_Hist",
135 "bStar2019MonitorTaskSaveHistos=kTRUE");
137 server->Restrict(
"/Reset_Moni_Hist",
"allow=admin");
144 LOG(info) <<
"ReInit parameter containers for " << GetName();
151 UShort_t usDetectorId) {
158 LOG(info) <<
"Reset Monitor histos ";
164 LOG(info) <<
"Save Monitor histos & canvases";
170 LOG(error) <<
"Failed processing TS " << ts.index()
171 <<
" in unpacker algorithm class";
200 std::vector<std::pair<TNamed*, std::string>> vHistos =
202 std::vector<std::pair<TCanvas*, std::string>> vCanvas =
206 TDirectory* oldDir = NULL;
207 TFile* histoFile = NULL;
213 if (
nullptr == histoFile)
return kFALSE;
215 LOG(info) <<
"Saving " << vHistos.size() <<
" monitor histograms ";
218 for (UInt_t uHisto = 0; uHisto < vHistos.size(); ++uHisto) {
220 TString sFolder = vHistos[uHisto].second.data();
221 if (
nullptr == gDirectory->Get(sFolder)) gDirectory->mkdir(sFolder);
222 gDirectory->cd(sFolder);
225 vHistos[uHisto].first->Write();
231 for (UInt_t uCanvas = 0; uCanvas < vCanvas.size(); ++uCanvas) {
233 TString sFolder = vCanvas[uCanvas].second.data();
234 if (
nullptr == gDirectory->Get(sFolder)) gDirectory->mkdir(sFolder);
235 gDirectory->cd(sFolder);
238 vCanvas[uCanvas].first->Write();