Belle II Software  release-08-01-10
EclPainterPolar.cc
1 /**************************************************************************
2  * basf2 (Belle II Analysis Software Framework) *
3  * Author: The Belle II Collaboration *
4  * *
5  * See git log for contributors and copyright holders. *
6  * This file is licensed under LGPL-3.0, see LICENSE.md. *
7  **************************************************************************/
8 //This module
9 #include <ecl/modules/eclDisplay/EclPainterPolar.h>
10 
11 //Root
12 #include <TMath.h>
13 #include <TColor.h>
14 #include <TH2.h>
15 #include <TCrown.h>
16 #include <TText.h>
17 
18 //ECL
19 #include <ecl/modules/eclDisplay/geometry.h>
20 
21 
22 using namespace Belle2;
23 using namespace ECLDisplayUtility;
24 
26  EclPainter(data)
27 {
28  m_type = type;
29 
30  char obj_name[255];
31  getNewRootObjectName(obj_name, 255);
32  m_hist = new TH2F(obj_name, "title",
33  60, 0.0, 1.0, 60, 0.0, 1.0);
34 
35  Double_t deg2rad = TMath::Pi() / 180;
36 
37  m_segs = new TCrown*[36];
38  m_labels = new TText*[36];
39  char label_txt[32];
40  for (int i = 0; i < 36; i++) {
41  m_segs[i] = new TCrown(0.5, 0.5, 0.3, 0.4, (i - 9) * 10, (i - 8) * 10);
42 
43  float x = 0.475 + 0.45 * TMath::Cos(deg2rad * (i - 9) * 10);
44  float y = 0.48 + 0.44 * TMath::Sin(deg2rad * (i - 9) * 10);
45  snprintf(label_txt, 32, "%d", i * 10);
46  m_labels[i] = new TText(x, y, label_txt);
47  m_labels[i]->SetTextSize(0.03);
48  }
49 }
50 
52 {
53  delete m_hist;
54 }
55 
57 {
58  m_type = other.m_type;
59  m_hist = new TH2F(*other.m_hist);
60  m_segs = new TCrown*[36];
61  for (int i = 0; i < 36; i++) { m_segs[i] = other.m_segs[i]; }
62  m_labels = new TText*[36];
63  for (int i = 0; i < 36; i++) { m_labels[i] = other.m_labels[i]; }
64 }
65 
67 {
68  if (m_type == PHI)
69  return getData()->getPhiId(ch) / 4;
70  else if (m_type == THETA) {
71  int theta_id = getData()->getThetaId(ch);
72 
73  if (theta_id < 23)
74  return 3 + theta_id * 12 / 23;
75  else
76  return 21 + (theta_id - 23) * 12 / 23;
77  }
78 
79  return 0;
80 }
81 
83 {
84  const char* name[2][2] = {
85  {"Events per phi", "Events per theta"},
86  {"Energy per phi", "Energy per theta"}
87  };
88  const char* zname[2] = {"Event count", "Energy (MeV)"};
89 
90  TString title = TString(name[GetMode()][m_type]) + " (" +
92 
93  m_hist->SetTitle(title);
94  m_hist->SetZTitle(zname[GetMode()]);
95  m_hist->GetZaxis()->CenterTitle();
96 }
97 
99 {
100  EclPainter::getInformation(px, py, panel);
101 }
102 
104 {
105  return m_type;
106 }
107 
109 {
110  setTitles();
111 
112  EclData* data = getData();
113  const int* ev_counts = data->getEventCounts();
114  const float* energy_sums = data->getEnergySums();
115 
116  float seg_val[36];
117  TCrown** segs = m_segs;
118  for (int i = 0; i < 36; i++)
119  seg_val[i] = 0;
120 
121  for (int i = 1; i <= getData()->getCrystalCount(); i++) {
122  if (!data->isCrystalInSubsystem(i, getDisplayedSubsystem())) continue;
123  int id = channelToSegId(i);
124  if (GetMode())
125  seg_val[id] += energy_sums[i];
126  else
127  seg_val[id] += ev_counts[i];
128  }
129 
130  float max = 0;
131  float min = seg_val[0];
132  for (int i = 0; i < 36; i++) {
133  if (max < seg_val[i])
134  max = seg_val[i];
135  if (min > seg_val[i])
136  min = seg_val[i];
137  }
138 
139  Double_t r[5] = { 0.00, 0.00, 0.87, 1.00, 0.51 };
140  Double_t g[5] = { 0.00, 0.81, 1.00, 0.20, 0.00 };
141  Double_t b[5] = { 0.51, 1.00, 0.12, 0.00, 0.00 };
142  Double_t stop[5] = { 0.00, 0.34, 0.61, 0.84, 1.00 };
143 
144  int palette = TColor::CreateGradientColorTable(5, stop, r, g, b, 37);
145  m_hist->Reset();
146  m_hist->Fill(0.5, 0.05, 0.1);
147  m_hist->SetMaximum(max);
148  m_hist->SetMinimum(min);
149  m_hist->Draw("COLZ");
150 
151  for (int i = 0; i < 36; i++) {
152  float val = 36.0 * TMath::Log(1 + seg_val[i]) / TMath::Log(1 + max);
153  segs[i]->SetFillColor(palette + val);
154  segs[i]->Draw(/*"SAME"*/);
155  m_labels[i]->Draw();
156  }
157 }
This class contains data for ECLSimHit's and provides several relevant conversion functions for bette...
Definition: EclData.h:31
int getThetaId(int ch)
ECL CellId -> theta_id.
Definition: EclData.cc:288
int getPhiId(int ch)
ECL CellId -> phi_id.
Definition: EclData.cc:278
static int getCrystalCount()
Get number of crystals in ECL.
Definition: EclData.cc:148
Painter for EclData, polar energy/event_count distribution.
Type m_type
Type for polar histogram.
Type
Type for polar histogram.
void setTitles()
Update titles of the histogram.
EclPainterPolar(EclData *data, Type type)
Constructor for EclPainter subclass.
int channelToSegId(int channel)
Convert ECL channel id to id of the phi (theta) segment.
void cloneFrom(const EclPainterPolar &other)
Clone attributes from other EclPainterPolar.
virtual void getInformation(int px, int py, MultilineWidget *panel) override
Sets the information to be displayed in the provided MultilineWidget.
Type getType()
Return subtype of ECLPainterPolar.
TText ** m_labels
Labels for phi segments.
TCrown ** m_segs
Phi (or theta) segments of the ECL.
TH2F * m_hist
Histogram that generates Z-axis.
~EclPainterPolar()
Destructor for EclPainter subclass.
virtual void Draw() override
Redraw the canvas.
Painter for EclData, parent class, created with EclPainterFactory.
Definition: EclPainter.h:29
EclData * getData()
Return currently displayed EclData.
Definition: EclPainter.h:46
EclData::EclSubsystem getDisplayedSubsystem()
Get currently displayed ECL subsystem.
Definition: EclPainter.cc:51
virtual void getInformation(int px, int py, MultilineWidget *panel)
Sets the information to be displayed in the provided MultilineWidget.
Definition: EclPainter.cc:72
TString getSubsystemTitle(EclData::EclSubsystem subsys)
Return title of ECL subsystem to use in painter.
Definition: EclPainter.cc:56
void getNewRootObjectName(char *buf, int size)
Make unique name for next root object.
Definition: EclPainter.cc:88
Widget which contains the dynamic amount of TGLabel objects.
int GetMode()
Returns current displayed mode (0 shows event count, 1 shows total energy)
Definition: geometry.cc:19
Abstract base class for different kinds of events.