BmnRoot
Loading...
Searching...
No Matches
BmnHistHgnd.h
Go to the documentation of this file.
1#ifndef BMNHISTHGND_H
2#define BMNHISTHGND_H
3
4#include "BmnHist.h"
5#include "BmnNdetAddress.h"
6#include "BmnNdetGeo.h"
7#include "PadInfo.h"
8#include "TCanvas.h"
9#include "TH1F.h"
10#include "TH2F.h"
11#include "THttpServer.h"
12
13#include <limits>
14#include <map>
15#include <memory>
16#include <set>
17#include <string>
18#include <vector>
19
20class BmnHistHgnd : public BmnHist
21{
22 public:
23 struct CanvasInfo
24 {
25 TCanvas* canvas{nullptr};
26 std::vector<PadInfo*> pads;
27
28 CanvasInfo() = default;
29 CanvasInfo(TCanvas* c)
30 : canvas(c)
31 {}
32 ~CanvasInfo() { delete canvas; }
33
34 CanvasInfo(const CanvasInfo&) = delete;
35 CanvasInfo& operator=(const CanvasInfo&) = delete;
36 CanvasInfo(CanvasInfo&& other) noexcept
37 : canvas(std::exchange(other.canvas, nullptr))
38 , pads(std::move(other.pads))
39 {}
40 CanvasInfo& operator=(CanvasInfo&& other) noexcept
41 {
42 if (this != &other) {
43 delete canvas;
44 canvas = std::exchange(other.canvas, nullptr);
45 pads = std::move(other.pads);
46 }
47 return *this;
48 }
49 };
50
51 BmnHistHgnd(TString title, TString path, Int_t PeriodID, BmnSetup stp);
52 virtual ~BmnHistHgnd();
53
55 void Register(THttpServer* serv) override;
56 void SetDir(TFile* outFile, TTree* recoTree) override;
57 void DrawBoth() override;
58 void FillFromDigi(DigiArrays* fDigiArrays) override;
59 void Reset() override;
60
62 void ClearRefRun() override;
63
64 void SetSelection(Int_t Trigger);
65
66 private:
67 void SetGeometry(const std::string& path);
68 void InitializeAddresses();
69 void setupAxis(TH1* hist, const std::string& xTitle, const std::string& yTitle);
70
71 template<typename T, typename... Args>
72 T* createH1(Args&&... args);
73
74 template<typename T, typename... Args>
75 T* createH2(Args&&... args);
76
77 // Geometry
78 std::unique_ptr<BmnNdetGeo> fGeoHandler;
79
80 // All possible detector addresses
81 std::set<uint32_t> fAddresses;
82
83 // Address-indexed histograms
84 std::map<uint32_t, TH1F*> hProfCell; // profile across layers for each cell
85 std::map<uint32_t, TH2F*> hCellAmpTime; // time vs amplitude per cell
86 std::map<uint32_t, TH2F*> hLayerAmps; // 2d row:col for each layer
87
88 // Individual histograms (for convenient access)
89 TH1F* h1_ECells{nullptr};
90 TH1F* h1_ProfileSlice{nullptr};
91
92 TH2F* h2_grid{nullptr};
93 TH2F* h2_Layer_Cell{nullptr};
94
95 // All histograms for bulk operations
96 std::vector<TH1*> m_allHistograms;
97
98 // Canvases
99 std::vector<std::unique_ptr<CanvasInfo>> m_canvases;
100
101 // Selection
102 bool fSelection{false};
103 Int_t fSelectedTrigger{-1};
104
105 UInt_t fEventCounter{1};
106
107 static constexpr UInt_t kLAYRS = 2; // number of layers
108 static constexpr UInt_t kROWS = 1; // rows per layer
109 static constexpr UInt_t kCOLS = 1; // columns per layer
110
111 ClassDefOverride(BmnHistHgnd, 3);
112};
113
114// Template implementations must be in header
115template<typename T, typename... Args>
116T* BmnHistHgnd::createH1(Args&&... args)
117{
118 T* hist = new T(std::forward<Args>(args)...);
119 m_allHistograms.push_back(hist);
120 return hist;
121}
122
123template<typename T, typename... Args>
124T* BmnHistHgnd::createH2(Args&&... args)
125{
126 T* hist = new T(std::forward<Args>(args)...);
127 m_allHistograms.push_back(hist);
128 return hist;
129}
130
131#endif
BmnStatus
Definition BmnEnums.h:24
BmnSetup
Definition BmnEnums.h:89
virtual ~BmnHistHgnd()
void FillFromDigi(DigiArrays *fDigiArrays) override
void SetDir(TFile *outFile, TTree *recoTree) override
void SetSelection(Int_t Trigger)
void CreateHistos()
void ClearRefRun() override
BmnHistHgnd(TString title, TString path, Int_t PeriodID, BmnSetup stp)
void Register(THttpServer *serv) override
BmnStatus SetRefRun(Int_t id)
void DrawBoth() override
void Reset() override
CanvasInfo(CanvasInfo &&other) noexcept
Definition BmnHistHgnd.h:36
std::vector< PadInfo * > pads
Definition BmnHistHgnd.h:26
CanvasInfo & operator=(CanvasInfo &&other) noexcept
Definition BmnHistHgnd.h:40
CanvasInfo(const CanvasInfo &)=delete
CanvasInfo & operator=(const CanvasInfo &)=delete