16#include "FairParGenericSet.h"
17#include "FairRootManager.h"
19#include "FairRunOnline.h"
20#include "FairRuntimeDb.h"
23#include "THttpServer.h"
77 LOG(info) <<
"CbmStar2019EventBuilderEtof::Init";
78 LOG(info) <<
"Initializing STAR eTOF 2018 Event Builder";
80 FairRootManager* ioman = FairRootManager::Instance();
81 if (NULL == ioman) { LOG(fatal) <<
"No FairRootManager instance"; }
88 LOG(info) <<
"Setting parameter containers for " << GetName();
93 FairParGenericSet* tempObj = (FairParGenericSet*) (
fParCList->At(iparC));
96 std::string sParamName {tempObj->GetName()};
97 FairParGenericSet* newObj =
98 dynamic_cast<FairParGenericSet*
>(FairRun::Instance()->GetRuntimeDb()->getContainer(sParamName.data()));
100 if (
nullptr == newObj) {
101 LOG(error) <<
"Failed to obtain parameter container " << sParamName <<
", for parameter index " << iparC;
112 LOG(info) <<
"Init parameter containers for " << GetName();
116 dynamic_cast<CbmStar2019TofPar*
>(FairRun::Instance()->GetRuntimeDb()->getContainer(
"CbmStar2019TofPar"));
117 if (
nullptr == pUnpackPar) {
118 LOG(error) <<
"Failed to obtain parameter container CbmStar2019TofPar";
123 LOG(info) <<
"Monitor mode: " << (
fbMonitorMode ?
"ON" :
"OFF");
130 LOG(info) <<
"Timeslice parameters: each MS is " <<
fdMsSizeInNs <<
" ns";
146 std::vector<std::pair<TNamed*, std::string>> vHistos =
fEventBuilderAlgo->GetHistoVector();
148 std::vector<std::pair<TCanvas*, std::string>> vCanvases =
fEventBuilderAlgo->GetCanvasVector();
151 THttpServer* server = FairRunOnline::Instance()->GetHttpServer();
152 for (UInt_t uHisto = 0; uHisto < vHistos.size(); ++uHisto) {
153 server->Register(Form(
"/%s", vHistos[uHisto].second.data()), vHistos[uHisto].first);
156 for (UInt_t uCanv = 0; uCanv < vCanvases.size(); ++uCanv) {
159 server->Register(Form(
"/%s", vCanvases[uCanv].second.data()),
160 gROOT->FindObject((vCanvases[uCanv].first)->GetName()));
163 server->RegisterCommand(
"/Reset_EvtBuild_Hist",
"bStarEtof2019EventBuilderResetHistos=kTRUE");
164 server->Restrict(
"/Reset_EvtBuild_Hist",
"allow=admin");
168 "Realtime for processing a TS in event "
169 "builder; Realtime [ms]; TS nb []",
172 "Realtime Processing to duration ratio for processing a TS in event "
173 "builder vs TS index; TS []; Realtime ratio []; TS Nb []",
174 1000, 0, 100000, 10000, 0.0, 100.0);
177 "Mean Realtime Processing to duration ratio for processing a TS in "
178 "event builder vs TS index; TS []; Mean Realtime ratio []; TS Nb []",
193 LOG(info) <<
"ReInit parameter containers for " << GetName();
203 LOG(info) <<
"Enabling event dump to binary file which was disabled. "
204 "File will be opened.";
206 std::time_t cTimeCurrent = std::chrono::system_clock::to_time_t(std::chrono::system_clock::now());
208 std::strftime(tempBuff, 80,
"%Y_%m_%d_%H_%M_%S", localtime(&cTimeCurrent));
209 TString sFileName = Form(
"event_dump_%s.bin", tempBuff);
210 fpBinDumpFile =
new std::fstream(sFileName, std::ios::out | std::ios::binary);
213 LOG(fatal) <<
"Failed to open new binary file for event dump at " << sFileName;
216 LOG(info) <<
"Opened binary dump file at " << sFileName;
219 LOG(info) <<
"Disabling event dump to binary file which was enabled. "
220 "File will be closed.";
227 if (
fbEventDumpEna) LOG(info) <<
"Event dump to binary file is now ENABLED";
229 LOG(info) <<
"Event dump to binary file is now DISABLED";
247 LOG(info) <<
"FIXME ===> Jumping 1st TS as corrupted with current FW + "
248 "FLESNET combination";
254 LOG(info) <<
"Reset eTOF STAR histos ";
266 LOG(error) <<
"Failed processing TS " << ts.index() <<
" in event builder algorithm class";
270 std::vector<CbmTofStarSubevent2019>& eventBuffer =
fEventBuilderAlgo->GetEventBuffer();
272 for (UInt_t uEvent = 0; uEvent < eventBuffer.size(); ++uEvent) {
274 Int_t iBuffSzByte = 0;
275 void* pDataBuff = eventBuffer[uEvent].BuildOutput(iBuffSzByte);
276 if (NULL != pDataBuff) {
286 star_rhicf_write(eventBuffer[uEvent].GetTrigger().GetStarTrigerWord(), pDataBuff, iBuffSzByte);
289 LOG(debug) <<
"Sent STAR event with size " << iBuffSzByte <<
" Bytes"
290 <<
" and token " << eventBuffer[uEvent].GetTrigger().GetStarToken();
295 fpBinDumpFile->write(
reinterpret_cast<const char*
>(pDataBuff), iBuffSzByte);
300 LOG(error) <<
"Invalid STAR SubEvent Output, can only happen if trigger "
301 <<
" object was not set => Do Nothing more with it!!! ";
304 Double_t dRealT =
fTimer.RealTime();
306 LOG(debug2) << Form(
"Real time TS %12lu, Realtime: %12f ns",
static_cast<unsigned long>(
fulTsCounter),
315 LOG(debug) << Form(
"New min Real time TS %12lu, Real time: %9.6f ms Old "
316 "Min %9.6f Diff %.9f",
322 LOG(debug) << Form(
"New max Real time TS %12lu, Real time: %9.6f ms Old "
323 "Max %9.6f Diff %.9f",
332 LOG(info) << Form(
"Processed %12lu TS, Real time: %6.3f ms/TS (Min %6.3f, "
333 "Max %6.3f), Events: %12lu (%9lu since last print)",
352 LOG(info) <<
"Closing binary file used for event dump.";
363 std::vector<std::pair<TNamed*, std::string>> vHistos =
fEventBuilderAlgo->GetHistoVector();
364 std::vector<std::pair<TCanvas*, std::string>> vCanvas =
fEventBuilderAlgo->GetCanvasVector();
367 TDirectory* oldDir = NULL;
368 TFile* histoFile = NULL;
374 if (
nullptr == histoFile)
return kFALSE;
377 for (UInt_t uHisto = 0; uHisto < vHistos.size(); ++uHisto) {
379 TString sFolder = vHistos[uHisto].second.data();
380 if (
nullptr == gDirectory->Get(sFolder)) gDirectory->mkdir(sFolder);
381 gDirectory->cd(sFolder);
384 vHistos[uHisto].first->Write();
389 for (UInt_t uCanvas = 0; uCanvas < vCanvas.size(); ++uCanvas) {
391 TString sFolder = vCanvas[uCanvas].second.data();
392 if (
nullptr == gDirectory->Get(sFolder)) gDirectory->mkdir(sFolder);
393 gDirectory->cd(sFolder);
396 vCanvas[uCanvas].first->Write();
ClassImp(CbmConverterManager)
Bool_t bStarEtof2019EventBuilderResetHistos
int star_rhicf_write(unsigned int trg_word, void *dta, int bytes)
const UInt_t kuBinDumpBegWord
Bool_t fbSandboxMode
Switch ON the readout and insertion of STATUS pattern message (default is true)
TStopwatch fTimer
Total size of the core MS in a TS, [seconds].
TH2 * fhRealTimeEvo
Exclude from dictionary because ?!?!
Double_t fdTsCoreSizeInSec
Size of a single MS, [nanoseconds].
TProfile * fhMeanRealTimeEvo
Exclude from dictionary because ?!?!
virtual Bool_t DoUnpack(const fles::Timeslice &ts, size_t component)
Bool_t fbDebugMonitorMode
Switch ON the filling of a minimal set of histograms.
Double_t fdMsSizeInNs
Processing speed watch.
Bool_t ReInitContainers()
Bool_t fbEventDumpEna
Switch OFF the emission of data toward the STAR DAQ.
std::fstream * fpBinDumpFile
Exclude from dictionary because ?!?!
UInt_t fuMinTotPulser
User settings: Data selection parameters.
CbmStar2019EventBuilderEtofAlgo * fEventBuilderAlgo
Processing algo.
Double_t fdRealTimeMinAll
Double_t fdRealTimeMaxAll
Bool_t fbAddStatusToEvent
Switch ON the insertion of the LostEvent messages from GET4s with the critical errors.
virtual ~CbmStar2019EventBuilderEtof()
Bool_t fbStoreLostEventMsg
Switch ON the filling of a additional set of histograms.
void SetEventDumpEnable(Bool_t bDumpEna=kTRUE)
Bool_t fbMonitorMode
Control flags.
TList * fParCList
Switch ON the dumping of the events to a binary file.
CbmStar2019EventBuilderEtof(UInt_t uNbGdpb=1)
uint64_t fulNbEventsSinceLastPrintout
void AddMsComponentToList(size_t component, UShort_t usDetectorId)
Temp until we change from CbmMcbmUnpack to something else.
const UInt_t kuBinDumpEndWord
uint64_t fulTsCounter
Statistics & first TS rejection.