Belle II Software development
ARICHChannelHist Class Reference

ARICH histogram with HAPD plane 3 options for bin segmentation are available type 0 - one bin per HAPD, type 1 - one bin per channel, type 2 - one bin per APD chip HAPD numbering is 1-420 (software numbering), channel is ASIC channel, APD is ASIC channel / 36. More...

#include <ARICHChannelHist.h>

Inheritance diagram for ARICHChannelHist:

Public Member Functions

 ARICHChannelHist ()
 Default constructor.
 
 ARICHChannelHist (const char *name, const char *title, int type=0, const std::vector< unsigned > &moduleIDs=std::vector< unsigned >())
 Constructor with name, title, and type (0 for channel bins (144/HAPD), 1 for HAPD bins (1/HAPD), 2 for APD bins (4/HAPD))
 
void fillBin (unsigned hapdID, unsigned chID, double weight=1.)
 Add entry to bin corresponding to hapd hapdID and channel chID.
 
void setBinContent (unsigned hapdID, unsigned chID, double value)
 Set content of bin corresponding to hapd hapdID and channel chID.
 
void fillBin (unsigned hapdID, double weight=1.)
 Add entry to bin corresponding to hapd hapdID.
 
void setBinContent (unsigned hapdID, double value)
 Set content of bin corresponding to hapd hapdID.
 
void Draw (Option_t *option="") override
 Draw the histogram.
 
void fillFromTH1 (TH1 *hist)
 Fill the channelHist from the histogram Type 0 channelHist has to be filled with 420*144bin TH1 (each channel) Type 1 channelHist can be filled with 420*144 (channels) or 420*4 (chips), or 420 (HAPDs) bin TH1 Type 2 channelHist can be filled with 420*144 or 420*4 bin TH1 In case histogram has more bins than channelHist bin content is summed up Exampl: histogram with hits/channel can be used to make ChannelHist with hits/hapd.
 
void setPoly (TH2Poly *poly)
 Fill pure TH2Poly from ARICHChannelHist, makes bins and fills content.
 

Protected Member Functions

 ClassDefOverride (ARICHChannelHist, 2)
 ClassDef.
 

Protected Attributes

TLine lines [6]
 array of lines
 
TText labels [6]
 array of labels
 
int m_type = 0
 histogram type
 
std::vector< unsigned > m_hapd2binMap
 map of bins
 

Detailed Description

ARICH histogram with HAPD plane 3 options for bin segmentation are available type 0 - one bin per HAPD, type 1 - one bin per channel, type 2 - one bin per APD chip HAPD numbering is 1-420 (software numbering), channel is ASIC channel, APD is ASIC channel / 36.

Definition at line 27 of file ARICHChannelHist.h.

Constructor & Destructor Documentation

◆ ARICHChannelHist() [1/2]

ARICHChannelHist ( )
inline

Default constructor.

Definition at line 34 of file ARICHChannelHist.h.

34{};

◆ ARICHChannelHist() [2/2]

ARICHChannelHist ( const char *  name,
const char *  title,
int  type = 0,
const std::vector< unsigned > &  moduleIDs = std::vector<unsigned>() 
)

Constructor with name, title, and type (0 for channel bins (144/HAPD), 1 for HAPD bins (1/HAPD), 2 for APD bins (4/HAPD))

Parameters
namename
titletitle
typetype
moduleIDsvector of module IDs

Definition at line 21 of file ARICHChannelHist.cc.

22 : TH2Poly()
23{
24
25 m_type = type;
26 SetName(name);
27 SetTitle(title);
28 m_hapd2binMap.assign(420, 0);
29
30 // positions of HAPDs and channel mapping (avoid using DB classes...)
31 const double rs[7] = {57.35, 65.81, 74.37, 82.868, 91.305, 99.794, 108.185};
32 const unsigned nhapds[7] = {42, 48, 54, 60, 66, 72, 78};
33 const unsigned chmap[144] = {88, 86, 96, 87, 75, 72, 97, 108, 73, 74, 98, 109, 84, 85, 120, 110, 76, 77, 132, 121, 136, 124, 99, 133, 125, 113, 122, 111, 101, 137, 134, 123, 89, 112, 100, 135, 52, 28, 3, 40, 41, 5, 15, 2, 17, 29, 27, 14, 4, 16, 1, 26, 53, 65, 0, 13, 48, 49, 39, 12, 61, 62, 25, 38, 63, 60, 24, 37, 64, 50, 51, 36, 91, 115, 140, 103, 102, 138, 128, 141, 126, 114, 116, 129, 139, 127, 142, 117, 90, 78, 143, 130, 95, 94, 104, 131, 82, 81, 118, 105, 80, 83, 119, 106, 79, 93, 92, 107, 55, 57, 47, 56, 68, 71, 46, 35, 70, 69, 45, 34, 59, 58, 23, 33, 67, 66, 11, 22, 7, 19, 44, 10, 18, 30, 21, 32, 42, 6, 9, 20, 54, 31, 43, 8};
34 const double chns[12] = { -2.88, -2.37, -1.86, -1.35, -0.84, -0.33, 0.33, 0.84, 1.35, 1.86, 2.37, 2.88};
35
36 float size = 0.5 / 2. - 0.01;
37 if (m_type == 1) size = 7.0 / 2. - 0.5;
38 if (m_type == 2) size = 3.3 / 2.;
39
40 float X[5], Y[5], globX[5], globY[5];
41 X[0] = -size; Y[0] = -size;
42 X[1] = size; Y[1] = -size;
43 X[2] = size; Y[2] = size;
44 X[3] = -size; Y[3] = size;
45 X[4] = -size; Y[4] = -size;
46
47 int nhapd = 1;
48 unsigned iring = 0;
49 unsigned ihapd = 0;
50
51 std::vector<unsigned> ids;
52 if (moduleIDs.size() > 0) ids = moduleIDs;
53 else {
54 for (int hapdID = 1; hapdID < 421; hapdID++) {
55 ids.push_back(hapdID);
56 }
57 }
58
59 // HAPD bins
60 if (m_type == 1) {
61 for (int hapdID = 1; hapdID < 421; hapdID++) {
62 //for (unsigned hapdID : ids) {
63 //m_hapd2binMap[hapdID - 1] = nhapd;
64 //nhapd++;
65 float r = rs[iring];
66 float dphi = 2.*M_PI / nhapds[iring];
67 float fi = dphi / 2. + ihapd * dphi;
68 ROOT::Math::XYVector centerPos(r * cos(fi), r * sin(fi));
69 for (int i = 0; i < 5; i++) {
70 float rotX = X[i] * cos(fi) - Y[i] * sin(fi);
71 float rotY = X[i] * sin(fi) + Y[i] * cos(fi);
72 globX[i] = rotX + centerPos.X();
73 globY[i] = rotY + centerPos.Y();
74 }
75 if (std::find(ids.begin(), ids.end(), hapdID) != ids.end()) {
76 m_hapd2binMap[hapdID - 1] = nhapd;
77 nhapd++;
78 TGraph* mybox = new TGraph(5, globX, globY);
79 mybox->SetName((to_string(hapdID)).c_str());
80 AddBin(mybox);
81 }
82 ihapd++;
83 if (ihapd == nhapds[iring]) { iring++; ihapd = 0;}
84 }
85
86 } else if (m_type == 0) {
87 for (int hapdID = 1; hapdID < 421; hapdID++) {
88 //for (unsigned hapdID : ids) {
89 // m_hapd2binMap[hapdID - 1] = nhapd;
90 // nhapd++;
91 float dphi = 2.*M_PI / nhapds[iring];
92 float fi = dphi / 2. + ihapd * dphi;
93 float r = rs[iring];
94 for (int chID = 0; chID < 144; chID++) {
95
96 unsigned chX = chmap[chID] % 12;
97 unsigned chY = chmap[chID] / 12;
98 ROOT::Math::XYVector hapdPos(r * cos(fi), r * sin(fi));
99 ROOT::Math::XYVector locPos(chns[chX], chns[chY]);
100 ROOT::Math::XYVector rotatedLocPos(locPos.X() * std::cos(fi) - locPos.Y() * std::sin(fi),
101 locPos.X() * std::sin(fi) + locPos.Y() * std::cos(fi));
102 ROOT::Math::XYVector centerPos = hapdPos + rotatedLocPos;
103
104 for (int i = 0; i < 5; i++) {
105 float rotX = X[i] * cos(fi) - Y[i] * sin(fi);
106 float rotY = X[i] * sin(fi) + Y[i] * cos(fi);
107 globX[i] = rotX + centerPos.X();
108 globY[i] = rotY + centerPos.Y();
109 }
110 if (std::find(ids.begin(), ids.end(), hapdID) != ids.end()) {
111 m_hapd2binMap[hapdID - 1] = nhapd;
112 if (chID == 143) nhapd++;
113 TGraph* mybox = new TGraph(5, globX, globY);
114 mybox->SetName((to_string(hapdID)).c_str());
115 AddBin(mybox);
116 }
117 }
118 ihapd++;
119 if (ihapd == nhapds[iring]) { iring++; ihapd = 0;}
120 }
121 } else if (m_type == 2) {
122 size += 0.2;
123 for (int hapdID = 1; hapdID < 421; hapdID++) {
124 float dphi = 2.*M_PI / nhapds[iring];
125 float fi = dphi / 2. + ihapd * dphi;
126 float r = rs[iring];
127 ROOT::Math::XYVector hapdPos(r * cos(fi), r * sin(fi));
128 for (int chipID = 0; chipID < 4; chipID++) {
129 ROOT::Math::XYVector locPos(-size + (chipID / 2)*size * 2, size - (chipID % 2)*size * 2);
130 ROOT::Math::XYVector rotatedLocPos(locPos.X() * std::cos(fi) - locPos.Y() * std::sin(fi),
131 locPos.X() * std::sin(fi) + locPos.Y() * std::cos(fi));
132 ROOT::Math::XYVector centerPos = hapdPos + rotatedLocPos;
133
134 for (int i = 0; i < 5; i++) {
135 float rotX = X[i] * cos(fi) - Y[i] * sin(fi);
136 float rotY = X[i] * sin(fi) + Y[i] * cos(fi);
137 globX[i] = rotX + centerPos.X();
138 globY[i] = rotY + centerPos.Y();
139 }
140
141 if (std::find(ids.begin(), ids.end(), hapdID) != ids.end()) {
142 m_hapd2binMap[hapdID - 1] = nhapd;
143 if (chipID == 3) nhapd++;
144 TGraph* mybox = new TGraph(5, globX, globY);
145 mybox->SetName((to_string(hapdID)).c_str());
146 AddBin(mybox);
147 }
148 }
149 ihapd++;
150 if (ihapd == nhapds[iring]) { iring++; ihapd = 0;}
151 }
152 } else std::cout << "Invalid histogram type! use 0 for channel bins or 1 for HAPD bins" << std::endl;
153 SetOption("colz");
154 SetStats(0);
155 GetXaxis()->SetLimits(-115., 115.);
156 GetYaxis()->SetLimits(-115., 115.);
157}
std::vector< unsigned > m_hapd2binMap
map of bins
int m_type
histogram type

Member Function Documentation

◆ Draw()

void Draw ( Option_t *  option = "")
override

Draw the histogram.

Parameters
optionroot draw option

Definition at line 159 of file ARICHChannelHist.cc.

160{
161 TH2Poly::Draw(option);
162 double rlin = 40;
163 double rlout = 113;
164 for (int isec = 0; isec < 6; isec++) {
165 double x1 = rlin * cos(M_PI / 3.*isec);
166 double x2 = rlout * cos(M_PI / 3.*isec);
167 double y1 = rlin * sin(M_PI / 3.*isec);
168 double y2 = rlout * sin(M_PI / 3.*isec);
169 lines[isec] = TLine(x1, y1, x2, y2);
170 lines[isec].Draw();
171 x1 = rlin * cos(M_PI / 3.*isec + M_PI / 6.);
172 y1 = rlin * sin(M_PI / 3.*isec + M_PI / 6.);
173 labels[isec] = TText(x1, y1, TString::Format("S-%d", isec + 1));
174 labels[isec].SetTextAlign(22);
175 labels[isec].SetTextSize(0.03);
176 labels[isec].Draw();
177 }
178}
TLine lines[6]
array of lines
TText labels[6]
array of labels

◆ fillBin() [1/2]

void fillBin ( unsigned  hapdID,
double  weight = 1. 
)

Add entry to bin corresponding to hapd hapdID.

Parameters
hapdIDID number of HAPD module
weightvalue to be added to bin

Definition at line 202 of file ARICHChannelHist.cc.

203{
204 SetBinContent(m_hapd2binMap[hapdID - 1], GetBinContent(hapdID) + weight);
205}

◆ fillBin() [2/2]

void fillBin ( unsigned  hapdID,
unsigned  chID,
double  weight = 1. 
)

Add entry to bin corresponding to hapd hapdID and channel chID.

Parameters
hapdIDID number of HAPD module
chIDchannel ID (asic channel) or APD ID
weightvalue to be added to bin

Definition at line 181 of file ARICHChannelHist.cc.

182{
183 unsigned chIndex = 0;
184 if (m_type == 0) chIndex = (m_hapd2binMap[hapdID - 1] - 1) * 144 + chID + 1;
185 if (m_type == 2) chIndex = (m_hapd2binMap[hapdID - 1] - 1) * 4 + chID + 1;
186 SetBinContent(chIndex, GetBinContent(chIndex) + weight);
187}

◆ fillFromTH1()

void fillFromTH1 ( TH1 *  hist)

Fill the channelHist from the histogram Type 0 channelHist has to be filled with 420*144bin TH1 (each channel) Type 1 channelHist can be filled with 420*144 (channels) or 420*4 (chips), or 420 (HAPDs) bin TH1 Type 2 channelHist can be filled with 420*144 or 420*4 bin TH1 In case histogram has more bins than channelHist bin content is summed up Exampl: histogram with hits/channel can be used to make ChannelHist with hits/hapd.

Parameters
histhistoram

Definition at line 207 of file ARICHChannelHist.cc.

208{
209
210 int nbins = hist->GetNbinsX();
211 if (m_type == 1) {
212 if (nbins < 420) { B2ERROR("Number of bins in histogram small than number of ChannelHist bins!"); return;}
213 if (nbins == 420) for (int i = 0; i < nbins; i++) setBinContent(i + 1, hist->GetBinContent(i + 1));
214 if (nbins == 420 * 4) {
215 for (int i = 0; i < 420; i++) {
216 for (int j = 0; j < 4; j++) fillBin(i + 1, hist->GetBinContent(i * 4 + j + 1));
217 }
218 }
219 if (nbins == 420 * 144) {
220 for (int i = 0; i < 420; i++) {
221 for (int j = 0; j < 144; j++) fillBin(i + 1, hist->GetBinContent(i * 144 + j + 1));
222 }
223 }
224 } else if (m_type == 0) {
225 if (nbins < 420 * 144) { B2ERROR("Number of bins in histogram small than number of ChannelHist bins!"); return;}
226 for (int i = 0; i < 420; i++) {
227 for (int j = 0; j < 144; j++) setBinContent(i + 1, j, hist->GetBinContent(i * 144 + j + 1));
228 }
229 } else if (m_type == 2) {
230 if (nbins < 420 * 4) { B2ERROR("Number of bins in histogram small than number of ChannelHist bins!"); return;}
231 if (nbins == 420 * 4) for (int i = 0; i < nbins; i++) setBinContent(i / 4 + 1, i % 4, hist->GetBinContent(i + 1));
232 if (nbins == 420 * 144) {
233 for (int i = 0; i < 420; i++) {
234 for (int j = 0; j < 144; j++) fillBin(i + 1, j / 36, hist->GetBinContent(i * 144 + j + 1));
235 }
236 }
237 } else return;
238}
void setBinContent(unsigned hapdID, unsigned chID, double value)
Set content of bin corresponding to hapd hapdID and channel chID.
void fillBin(unsigned hapdID, unsigned chID, double weight=1.)
Add entry to bin corresponding to hapd hapdID and channel chID.

◆ setBinContent() [1/2]

void setBinContent ( unsigned  hapdID,
double  value 
)

Set content of bin corresponding to hapd hapdID.

Parameters
hapdIDID number of HAPD module
valuebin content

Definition at line 197 of file ARICHChannelHist.cc.

198{
199 SetBinContent(m_hapd2binMap[hapdID - 1], value);
200}

◆ setBinContent() [2/2]

void setBinContent ( unsigned  hapdID,
unsigned  chID,
double  value 
)

Set content of bin corresponding to hapd hapdID and channel chID.

Parameters
hapdIDID number of HAPD module
chIDchannel ID (asic channel) or APD ID
valuebin content

Definition at line 189 of file ARICHChannelHist.cc.

190{
191 unsigned chIndex = 0;
192 if (m_type == 0) chIndex = (m_hapd2binMap[hapdID - 1] - 1) * 144 + chID + 1;
193 if (m_type == 2) chIndex = (m_hapd2binMap[hapdID - 1] - 1) * 4 + chID + 1;
194 SetBinContent(chIndex, value);
195}

◆ setPoly()

void setPoly ( TH2Poly *  poly)

Fill pure TH2Poly from ARICHChannelHist, makes bins and fills content.

Definition at line 240 of file ARICHChannelHist.cc.

241{
242
243 if (poly->GetNumberOfBins() == 0) {
244 for (const auto&& bin : *fBins) {
245 poly->AddBin((TGraph*)((TH2PolyBin*)bin)->GetPolygon());
246 }
247 }
248 if (poly->GetNumberOfBins() != GetNumberOfBins()) {std::cout << "Mismatch between number of bins in TH2Poly and ARICHChannelHist" << std::endl; return;}
249
250 double max = poly->GetMaximum();
251 for (int i = 1; i < GetNumberOfBins() + 1; i++) {
252 poly->SetBinContent(i, GetBinContent(i) > max ? max : GetBinContent(i));
253 }
254 return;
255}

Member Data Documentation

◆ labels

TText labels[6]
protected

array of labels

Definition at line 101 of file ARICHChannelHist.h.

◆ lines

TLine lines[6]
protected

array of lines

Definition at line 100 of file ARICHChannelHist.h.

◆ m_hapd2binMap

std::vector<unsigned> m_hapd2binMap
protected

map of bins

Definition at line 103 of file ARICHChannelHist.h.

◆ m_type

int m_type = 0
protected

histogram type

Definition at line 102 of file ARICHChannelHist.h.


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