7#include <arich/utility/ARICHMergerHist.h>
8#include <framework/logging/Logger.h>
20#define M_PI 3.14159265358979323846
26static const std::map<int, int> MERGER_TO_INTERNAL = {
27 {53, 1}, {24, 2}, {22, 3}, {11, 4}, {2, 5}, {12, 6}, {76, 7}, {34, 8}, {32, 9}, {72, 10},
28 {7, 11}, {66, 12}, {97, 13}, {63, 14}, {19, 15}, {57, 16}, {5, 17}, {79, 18}, {6, 19}, {80, 20},
29 {10, 21}, {37, 22}, {60, 23}, {35, 24}, {30, 25}, {41, 26}, {69, 27}, {20, 28}, {55, 29}, {47, 30},
30 {71, 31}, {15, 32}, {14, 33}, {74, 34}, {77, 35}, {64, 36}, {62, 37}, {67, 38}, {82, 39}, {56, 40},
31 {68, 41}, {78, 42}, {46, 43}, {81, 44}, {27, 45}, {39, 46}, {18, 47}, {44, 48}, {17, 49}, {25, 50},
32 {16, 51}, {51, 52}, {1, 53}, {61, 54}, {54, 55}, {48, 56}, {8, 57}, {29, 58}, {3, 59}, {73, 60},
33 {93, 61}, {38, 62}, {58, 63}, {59, 64}, {50, 65}, {26, 66}, {31, 67}, {33, 68}, {49, 69}, {65, 70},
40static const double SECTOR_CENTER_DEG[7] =
41{0.0, 30.0, 90.0, 150.0, 210.0, 270.0, 330.0};
44static const double GEOM_SCALE = 11.0;
47static const double BLOCK_W = 1.3 * GEOM_SCALE;
48static const double BLOCK_H = 0.8 * GEOM_SCALE;
51static const double R1 = 6.1 * GEOM_SCALE;
52static const double R2 = 7.7 * GEOM_SCALE;
53static const double R3 = 9.5 * GEOM_SCALE;
54static const double R4 = 11.25 * GEOM_SCALE;
56static const double ROW1_OFFSETS[3] = {+21.5, 0.0, -21.5};
57static const double ROW2_OFFSETS[4] = {+22.5, +9.5, -9.5, -22.5};
58static const double ROW3_OFFSETS[4] = {+19.0, +8.0, -8.0, -19.0};
59static const double ROW4_OFFSETS[1] = {+1.0};
64 const double th = angDeg * M_PI / 180.0;
71 double globalRotationDeg,
72 bool rightToLeftNumbering)
85 auto add_block = [&](
double r,
double angDeg) {
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);
94 const double hx = BLOCK_W / 2.0;
95 const double hy = BLOCK_H / 2.0;
97 const double lx[5] = {-hx, +hx, +hx, -hx, -hx};
98 const double ly[5] = {-hy, -hy, +hy, +hy, -hy};
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;
108 auto* g =
new TGraph(5, gx, gy);
111 if (mergerNumber >= 1 && mergerNumber <= 72)
118 auto add_ring = [&](
double r,
const double * offsets,
int nOffsets,
double centerDeg) {
120 for (
int i = nOffsets - 1; i >= 0; --i)
121 add_block(r, centerDeg + offsets[i]);
123 for (
int i = 0; i < nOffsets; ++i)
124 add_block(r, centerDeg + offsets[i]);
128 for (
int X = 1; X <= 6; ++X) {
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]);
137 if (mergerNumber != 73)
138 B2ERROR(
"ARICHMergerHist internal error: expected 72 bins, got "
139 << mergerNumber - 1);
143 GetXaxis()->SetLimits(-140., 140.);
144 GetYaxis()->SetLimits(-140., 140.);
154 if (hist->GetNbinsX() != 72) {
155 B2ERROR(
"ARICHMergerHist::fillFromTH1: histogram must have 72 bins (got "
156 << hist->GetNbinsX() <<
")");
160 for (
int i = 1; i <= 72; ++i) {
162 SetBinContent(b, hist->GetBinContent(i));
171 if (mergerID < 1 || mergerID > 100)
return;
173 int internal = MERGER_TO_INTERNAL.at(mergerID);
176 SetBinContent(polybin, value);
181 TH2Poly::Draw(option);
186 const double rInner = 50.0;
187 const double rOuter = 130.0;
189 for (
int k = 0; k < 6; ++k) {
192 double x1, y1, x2, y2;
193 pol2xy(rInner, aDeg, x1, y1);
194 pol2xy(rOuter, aDeg, x2, y2);
196 m_lines[k] = TLine(x1, y1, x2, y2);
198 m_lines[k].SetLineColor(kGray + 2);
205 const double rLabel = 45.0;
207 for (
int s = 0; s < 6; ++s) {
211 pol2xy(rLabel, centerDeg, x, y);
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);
void fillFromTH1(TH1 *hist)
Fill from TH1.
void Draw(Option_t *option="") override
Draw with sector lines and labels.
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.
ARICHMergerHist()=default
Default constructor.
double m_globalRotationDeg
Global rotation applied to the geometry (degrees).
TLine m_lines[6]
Sector boundary lines drawn on top of the histogram.
std::vector< int > m_merger2bin
Merger number (1..72) → TH2Poly bin index.
void SetBinContentFromSN(unsigned mergerID, double value)
Set content using the real ARICH hardware MergerID.
Abstract base class for different kinds of events.