R3BROOT
R3B analysis software
Loading...
Searching...
No Matches
R3BNeulandOnlineSpectra2.h
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
14#pragma once
15
16#include <R3BIOConnector.h>
17#include <R3BNeulandCalCanvas.h>
18#include <R3BNeulandCalData2.h>
22#include <R3BNeulandHit.h>
23#include <R3BNeulandHitCanvas.h>
32#include <TRandom.h>
33
34class FairRunOnline;
35
36namespace R3B
37{
38 class UcesbSource;
39}
40
41namespace R3B::Neuland
42{
44 {
45 public:
46 explicit OnlineSpectra(std::string_view name = "R3BNeulandOnlineSpectra", int iVerbose = 1);
47 OnlineSpectra(const OnlineSpectra&) = delete;
49 auto operator=(const OnlineSpectra&) -> OnlineSpectra& = delete;
51 ~OnlineSpectra() override;
52
53 // Getters:
54 auto GetRandomGenerator() -> TRandom* { return random_gen_; }
55 [[nodiscard]] auto GetDistanceToTarget() const { return distance_to_target_; }
56 [[nodiscard]] auto GetGraphViewMode() const { return graph_view_mode_.load(); }
57
58 // Setters:
59 void SetRandomGenerator(TRandom* rand)
60 {
61 if (rand != nullptr)
62 {
63 random_gen_ = rand;
64 }
65 }
66 void SetDistanceToTarget(double distance) { distance_to_target_ = distance; }
67 void SetUcesbSource(UcesbSource* source) { ucesb_source_ = source; }
68
69 template <typename SpecType, typename = std::enable_if_t<std::is_base_of_v<OnlineCanvas, SpecType>>>
70 auto AddCanvas(std::string_view name, CalTrigger trigger = CalTrigger::all) -> SpecType&
71 {
72 auto& spectrum = spectra_.emplace_back(std::make_unique<SpecType>(name));
73 spectrum->SetOnlineSpectra(this);
74 spectrum->SetTrigger(trigger);
75 return *static_cast<SpecType*>(spectrum.get());
76 }
77
78 template <typename UnaryOp>
79 inline void ActionToSpectra(UnaryOp&& optn)
80 {
81 for (auto& spectrum : spectra_)
82 {
83 optn(spectrum.get());
84 }
85 }
86
87 // Methods for https server:
88 void ResetHistos();
89 void ResetHistosMapped();
90 void SaveAll();
91 void RestartUcesbServer();
93 {
94 R3BLOG(info, "Graph is changed to full view!");
95 graph_view_mode_.store(CountRateCanvas::RangeViewMode::full);
96 }
98 {
99 R3BLOG(info, "Graph is changed to 2 hour view!");
100 graph_view_mode_.store(CountRateCanvas::RangeViewMode::two_hours);
101 }
103 {
104 R3BLOG(info, "Graph is changed to 4 hour view!");
105 graph_view_mode_.store(CountRateCanvas::RangeViewMode::four_hours);
106 }
107
108 // for backward compability
109 [[deprecated("Please use SetTrigger()")]] void SetCosmicTpat(UInt_t CosmicTpat = 0) {}
110
111 private:
112 double distance_to_target_ = 0.;
113 std::atomic<CountRateCanvas::RangeViewMode> graph_view_mode_ = CountRateCanvas::RangeViewMode::full;
114 std::vector<std::unique_ptr<OnlineCanvas>> spectra_;
115 UcesbSource* ucesb_source_ = nullptr;
116 TRandom* random_gen_ = gRandom; // non-owning
117
118 // virtual functions:
119 void HistogramInit(DataMonitor& histograms) override;
120 void ExtraInit(FairRootManager* rootMan) override;
121 void SetExtraPar(FairRuntimeDb* rtdb) override;
122 void TriggeredExec() override;
123 // void EndOfTask() override;
124 // [[nodiscard]] auto CheckConditions() const -> bool override;
125
126 // non-virtual member functions:
127 void init_http_server(FairRunOnline* run);
128
129 public:
131 };
132
133} // namespace R3B::Neuland
134
#define R3BLOG(severity, x)
Definition R3BLogger.h:35
R3B::Neuland::OnlineSpectra R3BNeulandOnlineSpectra2
ClassDefOverride(OnlineSpectra, 1)
OnlineSpectra(const OnlineSpectra &)=delete
void HistogramInit(DataMonitor &histograms) override
auto operator=(const OnlineSpectra &) -> OnlineSpectra &=delete
auto operator=(OnlineSpectra &&) -> OnlineSpectra &=delete
void SetDistanceToTarget(double distance)
OnlineSpectra(OnlineSpectra &&)=delete
void ExtraInit(FairRootManager *rootMan) override
void SetUcesbSource(UcesbSource *source)
OnlineSpectra(std::string_view name="R3BNeulandOnlineSpectra", int iVerbose=1)
auto AddCanvas(std::string_view name, CalTrigger trigger=CalTrigger::all) -> SpecType &
void SetCosmicTpat(UInt_t CosmicTpat=0)
void SetExtraPar(FairRuntimeDb *rtdb) override
Simulation of NeuLAND Bar/Paddle.