R3BROOT
R3B analysis software
Loading...
Searching...
No Matches
R3BNeulandOnlineSpectra2.cxx
Go to the documentation of this file.
1/******************************************************************************
2 * Copyright (C) 2019 GSI Helmholtzzentrum für Schwerionenforschung GmbH *
3 * Copyright (C) 2019-2023 Members of R3B Collaboration *
4 * *
5 * This software is distributed under the terms of the *
6 * GNU General Public Licence (GPL) version 3, *
7 * copied verbatim in the file "LICENSE". *
8 * *
9 * In applying this license GSI does not waive the privileges and immunities *
10 * granted to it by virtue of its status as an Intergovernmental Organization *
11 * or submit itself to any jurisdiction. *
12 ******************************************************************************/
13
15#include "R3BLogger.h"
18#include <FairRootManager.h>
19#include <FairRunOnline.h>
20#include <FairRuntimeDb.h>
21#include <R3BDataMonitor.h>
22#include <R3BUcesbSource2.h>
23#include <Rtypes.h>
24#include <THttpServer.h>
25#include <fmt/core.h>
26#include <string_view>
27
28namespace R3B::Neuland
29{
30 OnlineSpectra::OnlineSpectra(std::string_view name, int iVerbose)
31 : CalibrationTask(name, iVerbose)
32 {
33 }
35
37 {
38 ActionToSpectra([&histograms](OnlineCanvas* spec) { spec->CanvasInit(histograms); });
39
40 histograms.draw_canvases();
41 if (auto* run = FairRunOnline::Instance(); run != nullptr)
42 {
43 histograms.register_canvases(run);
44 }
45 }
46
47 void OnlineSpectra::ExtraInit(FairRootManager* /*rootMan*/)
48 {
49 ActionToSpectra([](OnlineCanvas* spec) { spec->DataInit(); });
50
51 if (auto* run = FairRunOnline::Instance(); run != nullptr)
52 {
54 }
55 }
56
57 void OnlineSpectra::SetExtraPar(FairRuntimeDb* rtdb) {}
58
60 {
61 auto& histograms = GetHistMonitor();
63 [&histograms](OnlineCanvas* spec)
64 {
65 if (spec->IsTriggered())
66 {
67 spec->CanvasFill(histograms);
68 }
69 });
70 }
71
72 void OnlineSpectra::init_http_server(FairRunOnline* run)
73 {
74 const auto reset_neuland_cmd = fmt::format(R"(/Tasks/{}/->ResetHistos())", GetName());
75 const auto reset_neuland_mapped_cmd = fmt::format(R"(/Tasks/{}/->ResetHistosMapped())", GetName());
76 const auto save_neuland_hists_cmd = fmt::format(R"(/Tasks/{}/->SaveAll())", GetName());
77 const auto restart_server_cmd = fmt::format(R"(/Tasks/{}/->RestartUcesbServer())", GetName());
78 const auto graph_view_full = fmt::format(R"(/Tasks/{}/->SetCountRateFullView())", GetName());
79 const auto graph_view_two_hours = fmt::format(R"(/Tasks/{}/->SetCountRateViewTwoHours())", GetName());
80 const auto graph_view_four_hours = fmt::format(R"(/Tasks/{}/->SetCountRateViewfourHours())", GetName());
81
82 run->GetHttpServer()->Register("/Tasks", this);
83 run->GetHttpServer()->RegisterCommand("/Tasks/Reset_Neuland", reset_neuland_cmd.c_str());
84 run->GetHttpServer()->RegisterCommand("/Tasks/Reset_Neuland_Mapped", reset_neuland_mapped_cmd.c_str());
85 run->GetHttpServer()->RegisterCommand("/Tasks/save_all_histograms", save_neuland_hists_cmd.c_str());
86 run->GetHttpServer()->RegisterCommand("/Tasks/restart_ucesb_server", restart_server_cmd.c_str());
87 run->GetHttpServer()->RegisterCommand("/Tasks/graph_full_view", graph_view_full.c_str());
88 run->GetHttpServer()->RegisterCommand("/Tasks/graph_two_hours_view", graph_view_two_hours.c_str());
89 run->GetHttpServer()->RegisterCommand("/Tasks/graph_four_hours_view", graph_view_four_hours.c_str());
90 }
91
93 {
94 SaveAll();
95 GetHistMonitor().reset_all_hists();
96 }
97
98 void OnlineSpectra::ResetHistosMapped() { GetHistMonitor().get_canvas("NeulandMapped").reset(); }
99 void OnlineSpectra::SaveAll() { GetHistMonitor().save_to_file(); }
101 {
102 if (ucesb_source_ == nullptr)
103 {
104 R3BLOG(warn, "Ucesb source is not set. Cannot restart the server.");
105 return;
106 }
107 ucesb_source_->RestartUcesbServer();
108 }
109} // namespace R3B::Neuland
110
#define R3BLOG(severity, x)
Definition R3BLogger.h:32
ClassImp(R3B::Neuland::Cal2HitPar)
void register_canvases(FairRun *run)
virtual void DataInit()=0
virtual void CanvasInit(DataMonitor &histograms)=0
virtual void CanvasFill(DataMonitor &histograms)=0
void HistogramInit(DataMonitor &histograms) override
void init_http_server(FairRunOnline *run)
void ExtraInit(FairRootManager *rootMan) override
OnlineSpectra(std::string_view name="R3BNeulandOnlineSpectra", int iVerbose=1)
void SetExtraPar(FairRuntimeDb *rtdb) override
Simulation of NeuLAND Bar/Paddle.