Belle II Software development
ARICHMergerHist Class Reference

ARICH merger histogram (72 blocks). More...

#include <ARICHMergerHist.h>

Inheritance diagram for ARICHMergerHist:

Public Member Functions

 ARICHMergerHist ()=default
 Default constructor.
 
 ARICHMergerHist (const char *name, const char *title, double globalRotationDeg=0.0, bool rightToLeftNumbering=true)
 Constructor.
 
void fillFromTH1 (TH1 *hist)
 Fill from TH1.
 
void SetBinContentFromSN (unsigned mergerID, double value)
 Set content using the real ARICH hardware MergerID.
 
void Draw (Option_t *option="") override
 Draw with sector lines and labels.
 

Static Protected Member Functions

static void pol2xy (double r, double angDeg, double &x, double &y)
 Convert polar coordinates to cartesian.
 

Protected Attributes

std::vector< int > m_merger2bin
 Merger number (1..72) → TH2Poly bin index.
 
double m_globalRotationDeg = 0.0
 Global rotation applied to the geometry (degrees).
 
bool m_rightToLeft = true
 If true, numbering in each ring is right-to-left.
 
TLine m_lines [6]
 Sector boundary lines drawn on top of the histogram.
 

Detailed Description

ARICH merger histogram (72 blocks).

Two numbering systems exist:

1) Internal position (1..72)

  • This is the drawing / geometry order.
  • Used by fillFromTH1().
  • Bins correspond to 1_1, 2_1, 12_1,...,6_12 merger positions

2) Real ARICH hardware MergerID

  • Used by SetBinContentFromSN(mergerID, value).

Definition at line 34 of file ARICHMergerHist.h.

Constructor & Destructor Documentation

◆ ARICHMergerHist()

ARICHMergerHist ( const char * name,
const char * title,
double globalRotationDeg = 0.0,
bool rightToLeftNumbering = true )

Constructor.

Parameters
nameHistogram name
titleHistogram title
globalRotationDegGlobal rotation applied to the whole layout (degrees)
rightToLeftNumberingIf true, bins inside each ring are numbered right-to-left

Definition at line 69 of file ARICHMergerHist.cc.

73 : TH2Poly()
74{
75 m_globalRotationDeg = globalRotationDeg;
76 m_rightToLeft = rightToLeftNumbering;
77 m_merger2bin.assign(72, 0);
78
79 SetName(name);
80 SetTitle(title);
81
82 int polyBin = 1;
83 int mergerNumber = 1;
84
85 auto add_block = [&](double r, double angDeg) {
86
87 double cx, cy;
88 pol2xy(r, angDeg, cx, cy);
89
90 const double rot = (angDeg + 90.0) * M_PI / 180.0;
91 const double c = std::cos(rot);
92 const double s = std::sin(rot);
93
94 const double hx = BLOCK_W / 2.0;
95 const double hy = BLOCK_H / 2.0;
96
97 const double lx[5] = {-hx, +hx, +hx, -hx, -hx};
98 const double ly[5] = {-hy, -hy, +hy, +hy, -hy};
99
100 double gx[5], gy[5];
101 for (int i = 0; i < 5; ++i) {
102 const double rx = lx[i] * c - ly[i] * s;
103 const double ry = lx[i] * s + ly[i] * c;
104 gx[i] = rx + cx;
105 gy[i] = ry + cy;
106 }
107
108 auto* g = new TGraph(5, gx, gy);
109 AddBin(g);
110
111 if (mergerNumber >= 1 && mergerNumber <= 72)
112 m_merger2bin[mergerNumber - 1] = polyBin;
113
114 ++polyBin;
115 ++mergerNumber;
116 };
117
118 auto add_ring = [&](double r, const double * offsets, int nOffsets, double centerDeg) {
119 if (m_rightToLeft) {
120 for (int i = nOffsets - 1; i >= 0; --i)
121 add_block(r, centerDeg + offsets[i]);
122 } else {
123 for (int i = 0; i < nOffsets; ++i)
124 add_block(r, centerDeg + offsets[i]);
125 }
126 };
127
128 for (int X = 1; X <= 6; ++X) {
129 const double cdeg = SECTOR_CENTER_DEG[X] + m_globalRotationDeg;
130
131 add_ring(R1, ROW1_OFFSETS, 3, cdeg);
132 add_ring(R2, ROW2_OFFSETS, 4, cdeg);
133 add_ring(R3, ROW3_OFFSETS, 4, cdeg);
134 add_block(R4, cdeg + ROW4_OFFSETS[0]);
135 }
136
137 if (mergerNumber != 73)
138 B2ERROR("ARICHMergerHist internal error: expected 72 bins, got "
139 << mergerNumber - 1);
140
141 SetOption("colz");
142 SetStats(0);
143 GetXaxis()->SetLimits(-140., 140.);
144 GetYaxis()->SetLimits(-140., 140.);
145}
static void pol2xy(double r, double angDeg, double &x, double &y)
Convert polar coordinates to cartesian.
bool m_rightToLeft
If true, numbering in each ring is right-to-left.
double m_globalRotationDeg
Global rotation applied to the geometry (degrees).
std::vector< int > m_merger2bin
Merger number (1..72) → TH2Poly bin index.

Member Function Documentation

◆ Draw()

void Draw ( Option_t * option = "")
override

Draw with sector lines and labels.

Parameters
optionROOT draw option string

Definition at line 179 of file ARICHMergerHist.cc.

180{
181 TH2Poly::Draw(option);
182
183 // -------------------------------------------------
184 // Sector lines
185 // -------------------------------------------------
186 const double rInner = 50.0;
187 const double rOuter = 130.0;
188
189 for (int k = 0; k < 6; ++k) {
190 const double aDeg = k * 60.0 + m_globalRotationDeg;
191
192 double x1, y1, x2, y2;
193 pol2xy(rInner, aDeg, x1, y1);
194 pol2xy(rOuter, aDeg, x2, y2);
195
196 m_lines[k] = TLine(x1, y1, x2, y2);
197 m_lines[k].SetLineWidth(2);
198 m_lines[k].SetLineColor(kGray + 2);
199 m_lines[k].Draw();
200 }
201
202 // -------------------------------------------------
203 // Sector labels S-1 ... S-6
204 // -------------------------------------------------
205 const double rLabel = 45.0;
206
207 for (int s = 0; s < 6; ++s) {
208 const double centerDeg = SECTOR_CENTER_DEG[s + 1] + m_globalRotationDeg;
209
210 double x, y;
211 pol2xy(rLabel, centerDeg, x, y);
212
213 auto* txt = new TLatex(x, y, Form("S-%d", s + 1));
214 txt->SetBit(kCanDelete);
215 txt->SetTextAlign(22);
216 txt->SetTextFont(62);
217 txt->SetTextSize(0.030);
218 txt->Draw();
219 }
220}
TLine m_lines[6]
Sector boundary lines drawn on top of the histogram.

◆ fillFromTH1()

void fillFromTH1 ( TH1 * hist)

Fill from TH1.

Histogram must have exactly 72 bins.

Parameters
histInput TH1 with 72 bins

Definition at line 150 of file ARICHMergerHist.cc.

151{
152 if (!hist) return;
153
154 if (hist->GetNbinsX() != 72) {
155 B2ERROR("ARICHMergerHist::fillFromTH1: histogram must have 72 bins (got "
156 << hist->GetNbinsX() << ")");
157 return;
158 }
159
160 for (int i = 1; i <= 72; ++i) {
161 const int b = m_merger2bin[i - 1];
162 SetBinContent(b, hist->GetBinContent(i));
163 }
164}

◆ pol2xy()

void pol2xy ( double r,
double angDeg,
double & x,
double & y )
staticprotected

Convert polar coordinates to cartesian.

Parameters
rRadius
angDegAngle in degrees
xOutput x coordinate
yOutput y coordinate

Definition at line 62 of file ARICHMergerHist.cc.

63{
64 const double th = angDeg * M_PI / 180.0;
65 x = r * std::cos(th);
66 y = r * std::sin(th);
67}

◆ SetBinContentFromSN()

void SetBinContentFromSN ( unsigned mergerID,
double value )

Set content using the real ARICH hardware MergerID.

Definition at line 169 of file ARICHMergerHist.cc.

170{
171 if (mergerID < 1 || mergerID > 100) return;
172
173 int internal = MERGER_TO_INTERNAL.at(mergerID);
174 int polybin = m_merger2bin[internal - 1];
175
176 SetBinContent(polybin, value);
177}

Member Data Documentation

◆ m_globalRotationDeg

double m_globalRotationDeg = 0.0
protected

Global rotation applied to the geometry (degrees).

Definition at line 63 of file ARICHMergerHist.h.

◆ m_lines

TLine m_lines[6]
protected

Sector boundary lines drawn on top of the histogram.

Definition at line 65 of file ARICHMergerHist.h.

◆ m_merger2bin

std::vector<int> m_merger2bin
protected

Merger number (1..72) → TH2Poly bin index.

Definition at line 62 of file ARICHMergerHist.h.

◆ m_rightToLeft

bool m_rightToLeft = true
protected

If true, numbering in each ring is right-to-left.

Definition at line 64 of file ARICHMergerHist.h.


The documentation for this class was generated from the following files: