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 <FairRunOnline.h>
16#include <R3BDataMonitor.h>
17#include <R3BUcesbSource2.h>
18#include <TH2.h>
19#include <THttpServer.h>
20#include <fmt/format.h>
21
22namespace R3B::Neuland
23{
24 OnlineSpectra::OnlineSpectra(std::string_view name, int iVerbose)
25 : CalibrationTask(name, iVerbose)
26 {
27 }
29
31 {
32 ActionToSpectra([&histograms](OnlineCanvas* spec) { spec->CanvasInit(histograms); });
33
34 histograms.draw_canvases();
35 if (auto* run = FairRunOnline::Instance(); run != nullptr)
36 {
37 histograms.register_canvases(run);
38 }
39 }
40
41 void OnlineSpectra::ExtraInit(FairRootManager* /*rootMan*/)
42 {
43 ActionToSpectra([](OnlineCanvas* spec) { spec->DataInit(); });
44
45 if (auto* run = FairRunOnline::Instance(); run != nullptr)
46 {
47 init_http_server(run);
48 }
49 }
50
51 void OnlineSpectra::SetExtraPar(FairRuntimeDb* rtdb) {}
52
54 {
55 auto& histograms = GetHistMonitor();
57 [&histograms](OnlineCanvas* spec)
58 {
59 if (spec->IsTriggered())
60 {
61 spec->CanvasFill(histograms);
62 }
63 });
64 }
65
66 void OnlineSpectra::init_http_server(FairRunOnline* run)
67 {
68 const auto reset_neuland_cmd = fmt::format(R"(/Tasks/{}/->ResetHistos())", GetName());
69 const auto reset_neuland_mapped_cmd = fmt::format(R"(/Tasks/{}/->ResetHistosMapped())", GetName());
70 const auto save_neuland_hists_cmd = fmt::format(R"(/Tasks/{}/->SaveAll())", GetName());
71 const auto restart_server_cmd = fmt::format(R"(/Tasks/{}/->RestartUcesbServer())", GetName());
72 const auto graph_view_full = fmt::format(R"(/Tasks/{}/->SetCountRateFullView())", GetName());
73 const auto graph_view_two_hours = fmt::format(R"(/Tasks/{}/->SetCountRateViewTwoHours())", GetName());
74 const auto graph_view_four_hours = fmt::format(R"(/Tasks/{}/->SetCountRateViewfourHours())", GetName());
75
76 run->GetHttpServer()->Register("/Tasks", this);
77 run->GetHttpServer()->RegisterCommand("/Tasks/Reset_Neuland", reset_neuland_cmd.c_str());
78 run->GetHttpServer()->RegisterCommand("/Tasks/Reset_Neuland_Mapped", reset_neuland_mapped_cmd.c_str());
79 run->GetHttpServer()->RegisterCommand("/Tasks/save_all_histograms", save_neuland_hists_cmd.c_str());
80 run->GetHttpServer()->RegisterCommand("/Tasks/restart_ucesb_server", restart_server_cmd.c_str());
81 run->GetHttpServer()->RegisterCommand("/Tasks/graph_full_view", graph_view_full.c_str());
82 run->GetHttpServer()->RegisterCommand("/Tasks/graph_two_hours_view", graph_view_two_hours.c_str());
83 run->GetHttpServer()->RegisterCommand("/Tasks/graph_four_hours_view", graph_view_four_hours.c_str());
84 }
85
87 {
88 SaveAll();
89 GetHistMonitor().reset_all_hists();
90 }
91
92 void OnlineSpectra::ResetHistosMapped() { GetHistMonitor().get_canvas("NeulandMapped").reset(); }
93 void OnlineSpectra::SaveAll() { GetHistMonitor().save_to_file(); }
95 {
96 if (ucesb_source_ == nullptr)
97 {
98 R3BLOG(warn, "Ucesb source is not set. Cannot restart the server.");
99 return;
100 }
101 ucesb_source_->RestartUcesbServer();
102 }
103} // namespace R3B::Neuland
104
#define R3BLOG(severity, x)
Definition R3BLogger.h:35
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 ExtraInit(FairRootManager *rootMan) override
OnlineSpectra(std::string_view name="R3BNeulandOnlineSpectra", int iVerbose=1)
void SetExtraPar(FairRuntimeDb *rtdb) override
Simulation of NeuLAND Bar/Paddle.