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 "R3BDataMonitor.h"
17#include "R3BLogger.h"
18#include <FairRootManager.h>
19#include <FairRuntimeDb.h>
24#include <Rtypes.h>
25#include <RtypesCore.h>
26#include <TRandom.h>
27#include <atomic>
28#include <memory>
29#include <string_view>
30#include <type_traits>
31#include <vector>
32
33class FairRunOnline;
34
35namespace R3B
36{
37 class UcesbSource;
38}
39
40namespace R3B::Neuland
41{
43 {
44 public:
45 explicit OnlineSpectra(std::string_view name = "R3BNeulandOnlineSpectra", int iVerbose = 1);
46 OnlineSpectra(const OnlineSpectra&) = delete;
48 auto operator=(const OnlineSpectra&) -> OnlineSpectra& = delete;
50 ~OnlineSpectra() override;
51
52 // Getters:
53 auto GetRandomGenerator() -> TRandom* { return random_gen_; }
54 [[nodiscard]] auto GetDistanceToTarget() const { return distance_to_target_; }
55 [[nodiscard]] auto GetGraphViewMode() const { return graph_view_mode_.load(); }
56
57 // Setters:
58 void SetRandomGenerator(TRandom* rand)
59 {
60 if (rand != nullptr)
61 {
62 random_gen_ = rand;
63 }
64 }
65 void SetDistanceToTarget(double distance) { distance_to_target_ = distance; }
66 void SetUcesbSource(UcesbSource* source) { ucesb_source_ = source; }
67
68 template <typename SpecType, typename = std::enable_if_t<std::is_base_of_v<OnlineCanvas, SpecType>>>
69 auto AddCanvas(std::string_view name, CalTrigger trigger = CalTrigger::all) -> SpecType&
70 {
71 auto& spectrum = spectra_.emplace_back(std::make_unique<SpecType>(name));
72 spectrum->SetOnlineSpectra(this);
73 spectrum->SetTrigger(trigger);
74 return *static_cast<SpecType*>(spectrum.get());
75 }
76
77 template <typename UnaryOp>
78 void ActionToSpectra(UnaryOp optn)
79 {
80 for (auto& spectrum : spectra_)
81 {
82 optn(spectrum.get());
83 }
84 }
85
86 // Methods for https server:
87 void ResetHistos();
88 void ResetHistosMapped();
89 void SaveAll();
90 void RestartUcesbServer();
92 {
93 R3BLOG(info, "Graph is changed to full view!");
95 }
97 {
98 R3BLOG(info, "Graph is changed to 2 hour view!");
100 }
102 {
103 R3BLOG(info, "Graph is changed to 4 hour view!");
105 }
106
107 // for backward compability
108 [[deprecated("Please use SetTrigger()")]] void SetCosmicTpat(UInt_t CosmicTpat = 0) {}
109
110 private:
112 std::atomic<CountRateCanvas::RangeViewMode> graph_view_mode_ = CountRateCanvas::RangeViewMode::full;
113 std::vector<std::unique_ptr<OnlineCanvas>> spectra_;
115 TRandom* random_gen_ = gRandom; // non-owning
116
117 // virtual functions:
118 void HistogramInit(DataMonitor& histograms) override;
119 void ExtraInit(FairRootManager* rootMan) override;
120 void SetExtraPar(FairRuntimeDb* rtdb) override;
121 void TriggeredExec() override;
122 // void EndOfTask() override;
123 // [[nodiscard]] auto CheckConditions() const -> bool override;
124
125 // non-virtual member functions:
126 void init_http_server(FairRunOnline* run);
127
128 public:
130 };
131
132} // namespace R3B::Neuland
133
#define R3BLOG(severity, x)
Definition R3BLogger.h:32
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)
void init_http_server(FairRunOnline *run)
std::vector< std::unique_ptr< OnlineCanvas > > spectra_
OnlineSpectra(OnlineSpectra &&)=delete
void ExtraInit(FairRootManager *rootMan) override
void SetUcesbSource(UcesbSource *source)
std::atomic< CountRateCanvas::RangeViewMode > graph_view_mode_
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.