Belle II Software development
EclPainter2D Class Reference

Painter for EclData, 2D histograms. More...

#include <EclPainter2D.h>

Inheritance diagram for EclPainter2D:
EclPainter

Public Types

enum  Type {
  CHANNEL_2D ,
  SHAPER_2D ,
  NONE
}
 Subtype of histogram to draw. More...
 

Public Member Functions

 EclPainter2D (EclData *data, Type type)
 Constructor for EclPainter subclass.
 
 EclPainter2D (const EclPainter2D &other)
 Copy constructor.
 
EclPainter2Doperator= (const EclPainter2D &other)
 Assignment operator.
 
 ~EclPainter2D ()
 Destructor for EclPainter subclass.
 
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 ECLPainter2D.
 
virtual void Draw () override
 Redraw the canvas.
 
void setData (EclData *data)
 Set EclData to display in painter.
 
EclDatagetData ()
 Return currently displayed EclData.
 
const EclDatagetData () const
 Return currently displayed EclData.
 
void setMapper (ECL::ECLChannelMapper *mapper)
 Set ECLChannelMapper for CellID <-> (crate, shaper, chid) conversion.
 
ECL::ECLChannelMappergetMapper ()
 Return currently set ECLChannelMapper.
 
void setDisplayedSubsystem (EclData::EclSubsystem sys)
 Change between the displayed ECL subsystem (barrel, forward and backward endcaps).
 
EclData::EclSubsystem getDisplayedSubsystem ()
 Get currently displayed ECL subsystem.
 
TString getSubsystemTitle (EclData::EclSubsystem subsys)
 Return title of ECL subsystem to use in painter.
 
virtual EclPainterhandleClick (int px, int py)
 Some EclPainters can shift to another view upon click.
 
virtual void setXRange (int x1, int x2)
 Set XRange for histogram in EclPainter.
 

Protected Member Functions

void getNewRootObjectName (char *buf, int size)
 Make unique name for next root object.
 

Private Member Functions

void cloneFrom (const EclPainter2D &other)
 Clone attributes from other EclPainter2D.
 
void setTitles ()
 Update histogram titles.
 
int getMaxX ()
 Returns number of X bins.
 
int getMaxY ()
 Returns number of Y bins.
 
int channelToSegIdX (int channel)
 Convert channel id to X bin number.
 
int channelToSegIdY (int channel)
 Convert channel id to Y bin number.
 
void initGrid ()
 Initialize grid for drawGrid().
 
void drawGrid ()
 Draw grid over histogram.
 

Private Attributes

Type m_type
 Display subtypes of this class.
 
TH2F * m_hist
 Displayed histogram.
 
TH2C * hgrid
 The grid itself, drawn in drawGrid().
 
TPad * grid
 Grid pad, drawn in drawGrid().
 
EclDatam_ecl_data
 Data to draw.
 
ECL::ECLChannelMapperm_mapper
 mapper for CellID <-> (crate, shaper, chid) conversion.
 
EclData::EclSubsystem displayed_subsys
 Identifier of displayed ECL subsystem.
 

Static Private Attributes

static int m_obj_counter = 0
 Counter to make unique names for new root objects.
 

Detailed Description

Painter for EclData, 2D histograms.

Definition at line 26 of file EclPainter2D.h.

Member Enumeration Documentation

◆ Type

enum Type

Subtype of histogram to draw.

Enumerator
CHANNEL_2D 

(theta_id:phi_id) histogram.

SHAPER_2D 

(shaper:crate) histogram.

Definition at line 29 of file EclPainter2D.h.

29 {
31 SHAPER_2D,
32 NONE
33 };
@ CHANNEL_2D
(theta_id:phi_id) histogram.
Definition: EclPainter2D.h:30
@ SHAPER_2D
(shaper:crate) histogram.
Definition: EclPainter2D.h:31

Constructor & Destructor Documentation

◆ EclPainter2D() [1/2]

EclPainter2D ( EclData data,
EclPainter2D::Type  type 
)

Constructor for EclPainter subclass.

Definition at line 29 of file EclPainter2D.cc.

29 :
30 EclPainter(data)
31{
32 this->m_type = type;
33
34 int max_x = getMaxX();
35 int max_y = getMaxY();
36 char obj_name[255];
37 getNewRootObjectName(obj_name, 255);
38
39 m_hist = new TH2F(obj_name, "title", max_x, 1, max_x + 1,
40 max_y, 1, max_y + 1);
41
42 m_hist->GetXaxis()->CenterTitle();
43 m_hist->GetXaxis()->SetTitleOffset(1.1);
44 m_hist->GetYaxis()->CenterTitle();
45 m_hist->GetYaxis()->SetTitleOffset(-1.1);
46 m_hist->GetZaxis()->CenterTitle();
47
48 grid = 0;
49 hgrid = 0;
50}
Type m_type
Display subtypes of this class.
Definition: EclPainter2D.h:56
int getMaxX()
Returns number of X bins.
Definition: EclPainter2D.cc:96
TH2C * hgrid
The grid itself, drawn in drawGrid().
Definition: EclPainter2D.h:61
TPad * grid
Grid pad, drawn in drawGrid().
Definition: EclPainter2D.h:63
int getMaxY()
Returns number of Y bins.
TH2F * m_hist
Displayed histogram.
Definition: EclPainter2D.h:58
Painter for EclData, parent class, created with EclPainterFactory.
Definition: EclPainter.h:29
void getNewRootObjectName(char *buf, int size)
Make unique name for next root object.
Definition: EclPainter.cc:88

◆ EclPainter2D() [2/2]

EclPainter2D ( const EclPainter2D other)
inline

Copy constructor.

Definition at line 43 of file EclPainter2D.h.

43: EclPainter(other) { cloneFrom(other); }
void cloneFrom(const EclPainter2D &other)
Clone attributes from other EclPainter2D.
Definition: EclPainter2D.cc:60
EclPainter(EclData *data)
Default constructor.
Definition: EclPainter.cc:24

◆ ~EclPainter2D()

Destructor for EclPainter subclass.

Definition at line 52 of file EclPainter2D.cc.

53{
54 delete m_hist;
55 delete grid;
56 if (hgrid)
57 delete hgrid;
58}

Member Function Documentation

◆ channelToSegIdX()

int channelToSegIdX ( int  channel)
private

Convert channel id to X bin number.

Definition at line 115 of file EclPainter2D.cc.

116{
117 if (m_type == CHANNEL_2D)
118 return getData()->getThetaId(ch);
119 else if (m_type == SHAPER_2D)
120 return getMapper()->getShaperPosition(ch);
121
122 return 0;
123}
int getShaperPosition(int cellID)
Get position of the shaper in the crate by given CellId.
int getThetaId(int ch)
ECL CellId -> theta_id.
Definition: EclData.cc:288
EclData * getData()
Return currently displayed EclData.
Definition: EclPainter.h:46
ECL::ECLChannelMapper * getMapper()
Return currently set ECLChannelMapper.
Definition: EclPainter.cc:41

◆ channelToSegIdY()

int channelToSegIdY ( int  channel)
private

Convert channel id to Y bin number.

Definition at line 124 of file EclPainter2D.cc.

125{
126 if (m_type == CHANNEL_2D)
127 return getData()->getPhiId(ch);
128 else if (m_type == SHAPER_2D)
129 return getMapper()->getCrateID(ch);
130
131 return 0;
132}
int getCrateID(int iCOPPERNode, int iFINESSE, bool pcie40=false)
Get crate number by given COPPER node number and FINESSE number.
int getPhiId(int ch)
ECL CellId -> phi_id.
Definition: EclData.cc:278

◆ cloneFrom()

void cloneFrom ( const EclPainter2D other)
private

Clone attributes from other EclPainter2D.

Definition at line 60 of file EclPainter2D.cc.

61{
62 m_type = other.m_type;
63 m_hist = new TH2F(*other.m_hist);
64 hgrid = 0;
65 grid = 0;
66 initGrid();
67}
void initGrid()
Initialize grid for drawGrid().

◆ Draw()

void Draw ( )
overridevirtual

Redraw the canvas.

Implements EclPainter.

Definition at line 218 of file EclPainter2D.cc.

219{
220 setTitles();
221
222 EclData* data = getData();
223
224 const int* ev_counts = data->getEventCounts();
225 const float* energy_sums = data->getEnergySums();
226
227 m_hist->Reset();
228 for (int i = 1; i <= getData()->getCrystalCount(); i++) {
229 if (!data->isCrystalInSubsystem(i, getDisplayedSubsystem())) continue;
230
231 int id_x = channelToSegIdX(i);
232 int id_y = channelToSegIdY(i);
233 if (GetMode())
234 m_hist->Fill(id_x, id_y, energy_sums[i]);
235 else
236 m_hist->Fill(id_x, id_y, ev_counts[i]);
237 }
238
239 gStyle->SetNumberContours(255);
240 gStyle->SetPalette(PALETTE_ID);
241
242 m_hist->GetXaxis()->SetTicks("+-");
243 m_hist->GetYaxis()->SetTicks("+-");
244
245 m_hist->Draw("COLZ");
246
247 initGrid();
248 drawGrid();
249}
This class contains data for ECLSimHit's and provides several relevant conversion functions for bette...
Definition: EclData.h:31
static int getCrystalCount()
Get number of crystals in ECL.
Definition: EclData.cc:148
int channelToSegIdX(int channel)
Convert channel id to X bin number.
void setTitles()
Update histogram titles.
Definition: EclPainter2D.cc:69
int channelToSegIdY(int channel)
Convert channel id to Y bin number.
void drawGrid()
Draw grid over histogram.
EclData::EclSubsystem getDisplayedSubsystem()
Get currently displayed ECL subsystem.
Definition: EclPainter.cc:51
int GetMode()
Returns current displayed mode (0 shows event count, 1 shows total energy)
Definition: geometry.cc:19

◆ drawGrid()

void drawGrid ( )
private

Draw grid over histogram.

Call after initGrid().

Definition at line 145 of file EclPainter2D.cc.

146{
147 TVirtualPad* main = gPad;
148 grid->Draw("COLZ");
149 grid->cd();
150
151 /* Creating grid */
152 char obj_name[255];
153 getNewRootObjectName(obj_name, 255);
154
155 // NOTE: Root can't divide the histogram axes into more than 99
156 // primary sections, limiting the maximum grid cell size.
157 // To change this, new grid implementation might be necessary.
158 double max_y = getMaxY();
159 // Reducing the number of grid lines.
160 while (max_y >= 100) {
161 max_y /= 2;
162 }
163
164 hgrid = new TH2C(obj_name, "", getMaxX(), 0, getMaxX(), max_y, 0, max_y);
165 hgrid->GetXaxis()->SetNdivisions(getMaxX());
166 hgrid->GetYaxis()->SetNdivisions(max_y);
167 // Hiding axis labels.
168 hgrid->GetYaxis()->SetLabelOffset(1e3);
169 hgrid->GetXaxis()->SetLabelOffset(1e3);
170 // Hiding axis ticks.
171 hgrid->GetYaxis()->SetTickLength(0.);
172 hgrid->GetXaxis()->SetTickLength(0.);
173
174 hgrid->Draw();
175
176 main->cd();
177}

◆ getData() [1/2]

EclData * getData ( )
inlineinherited

Return currently displayed EclData.

Definition at line 46 of file EclPainter.h.

46{ return m_ecl_data; }
EclData * m_ecl_data
Data to draw.
Definition: EclPainter.h:111

◆ getData() [2/2]

const EclData * getData ( ) const
inlineinherited

Return currently displayed EclData.

Definition at line 48 of file EclPainter.h.

48{ return m_ecl_data; }

◆ getDisplayedSubsystem()

EclData::EclSubsystem getDisplayedSubsystem ( )
inherited

Get currently displayed ECL subsystem.

Definition at line 51 of file EclPainter.cc.

52{
53 return displayed_subsys;
54}
EclData::EclSubsystem displayed_subsys
Identifier of displayed ECL subsystem.
Definition: EclPainter.h:116

◆ getInformation()

void getInformation ( int  px,
int  py,
MultilineWidget panel 
)
overridevirtual

Sets the information to be displayed in the provided MultilineWidget.

Parameters
pxX coordinate of mouse cursor.
pyY coordinate of mouse cursor.
panelMultilineWidget to display the information

Reimplemented from EclPainter.

Definition at line 179 of file EclPainter2D.cc.

180{
181 EclPainter::getInformation(px, py, panel);
182
183 char info[255];
184
185 Float_t upx = gPad->AbsPixeltoX(px);
186 Float_t x = gPad->PadtoX(upx);
187 int binx = m_hist->GetXaxis()->FindBin(x);
188
189 Float_t upy = gPad->AbsPixeltoY(py);
190 Float_t y = gPad->PadtoY(upy);
191 int biny = m_hist->GetYaxis()->FindBin(y);
192
193 if (m_type == CHANNEL_2D) {
194 sprintf(info, "theta_id = %d", binx);
195 panel->setLine(1, info);
196 sprintf(info, "phi_id = %d", biny);
197 panel->setLine(2, info);
198 sprintf(info, "channel_id = %d", getData()->getChannel(biny, binx));
199 panel->setLine(3, info);
200 }
201 if (m_type == SHAPER_2D) {
202 sprintf(info, "crate_id = %d", biny);
203 panel->setLine(1, info);
204 sprintf(info, "shaper_id = %d (%d)", (biny - 1) * 12 + binx, binx);
205 panel->setLine(2, info);
206 }
207}
virtual void getInformation(int px, int py, MultilineWidget *panel)
Sets the information to be displayed in the provided MultilineWidget.
Definition: EclPainter.cc:72
void setLine(int line_id, const char *text)
Set content of the specified line to 'text'.

◆ getMapper()

ECL::ECLChannelMapper * getMapper ( )
inherited

Return currently set ECLChannelMapper.

Definition at line 41 of file EclPainter.cc.

42{
43 return m_mapper;
44}
ECL::ECLChannelMapper * m_mapper
mapper for CellID <-> (crate, shaper, chid) conversion.
Definition: EclPainter.h:113

◆ getMaxX()

int getMaxX ( )
private

Returns number of X bins.

Definition at line 96 of file EclPainter2D.cc.

97{
98 if (m_type == CHANNEL_2D)
99 return 68;
100 else if (m_type == SHAPER_2D)
101 return 12;
102
103 return 1;
104}

◆ getMaxY()

int getMaxY ( )
private

Returns number of Y bins.

Definition at line 105 of file EclPainter2D.cc.

106{
107 if (m_type == CHANNEL_2D)
108 return 144;
109 else if (m_type == SHAPER_2D)
110 return 52;
111
112 return 1;
113}

◆ getNewRootObjectName()

void getNewRootObjectName ( char *  buf,
int  size 
)
protectedinherited

Make unique name for next root object.

Definition at line 88 of file EclPainter.cc.

89{
90 snprintf(buf, n, "ECL DATA_%d", m_obj_counter++);
91}
static int m_obj_counter
Counter to make unique names for new root objects.
Definition: EclPainter.h:109

◆ getSubsystemTitle()

TString getSubsystemTitle ( EclData::EclSubsystem  subsys)
inherited

Return title of ECL subsystem to use in painter.

Definition at line 56 of file EclPainter.cc.

57{
58 switch (subsys) {
59 case EclData::BARR:
60 return TString("Barrel");
61 case EclData::FORW:
62 return TString("Forward endcap");
63 case EclData::BACKW:
64 return TString("Backward endcap");
65 case EclData::ALL:
66 return TString("Full ECL");
67 default:
68 return TString();
69 }
70}

◆ getType()

EclPainter2D::Type getType ( )

Return subtype of ECLPainter2D.

Definition at line 209 of file EclPainter2D.cc.

210{
211 return m_type;
212}

◆ handleClick()

EclPainter * handleClick ( int  px,
int  py 
)
virtualinherited

Some EclPainters can shift to another view upon click.

(For example, clicking on crate reveals histogram of shapers in that crate)

Returns
EclPainter with new perspective/range.

Reimplemented in EclPainter1D.

Definition at line 79 of file EclPainter.cc.

80{
81 return nullptr;
82}

◆ initGrid()

void initGrid ( )
private

Initialize grid for drawGrid().

Definition at line 134 of file EclPainter2D.cc.

135{
136 /* Adding second TPad (layer) for the grid overlay */
137 grid = new TPad("grid", "", 0, 0, 1, 1);
138 grid->SetGrid();
139 grid->SetRightMargin(gPad->GetRightMargin());
140 // Setting transparent fill style.
141 grid->SetFillStyle(4000);
142 grid->SetFrameFillStyle(0);
143}

◆ operator=()

EclPainter2D & operator= ( const EclPainter2D other)
inline

Assignment operator.

Definition at line 47 of file EclPainter2D.h.

47{ cloneFrom(other); return *this; }

◆ setData()

void setData ( EclData data)
inlineinherited

Set EclData to display in painter.


Definition at line 44 of file EclPainter.h.

44{ m_ecl_data = data; }

◆ setDisplayedSubsystem()

void setDisplayedSubsystem ( EclData::EclSubsystem  sys)
inherited

Change between the displayed ECL subsystem (barrel, forward and backward endcaps).

Definition at line 46 of file EclPainter.cc.

47{
48 displayed_subsys = sys;
49}

◆ setMapper()

void setMapper ( ECL::ECLChannelMapper mapper)
inherited

Set ECLChannelMapper for CellID <-> (crate, shaper, chid) conversion.

Definition at line 36 of file EclPainter.cc.

37{
38 m_mapper = mapper;
39}

◆ setTitles()

void setTitles ( )
private

Update histogram titles.

Definition at line 69 of file EclPainter2D.cc.

70{
71 const char* name[3][3] = {
72 {"Events per channel", "Events per shaper"},
73 {"Energy per channel (MeV)", "Energy per shaper (MeV)"},
74 {"Time per channel (ns)", "Time per shaper (ns)"}
75 };
76 const char* zname[3] = {
77 "Events", "Energy (MeV)", "Time"
78 };
79
80 TString title = TString(name[GetMode()][(int)m_type]) + " (" +
82
83 m_hist->SetTitle(title);
84
85 if (m_type == CHANNEL_2D) {
86 m_hist->GetXaxis()->SetTitle("Theta id");
87 m_hist->GetYaxis()->SetTitle("Phi id");
88 }
89 if (m_type == SHAPER_2D) {
90 m_hist->GetXaxis()->SetTitle("Shaper id");
91 m_hist->GetYaxis()->SetTitle("Collector id");
92 }
93 m_hist->GetZaxis()->SetTitle(zname[GetMode()]);
94}
TString getSubsystemTitle(EclData::EclSubsystem subsys)
Return title of ECL subsystem to use in painter.
Definition: EclPainter.cc:56

◆ setXRange()

void setXRange ( int  x1,
int  x2 
)
virtualinherited

Set XRange for histogram in EclPainter.

Reimplemented in EclPainter1D.

Definition at line 84 of file EclPainter.cc.

85{
86}

Member Data Documentation

◆ displayed_subsys

EclData::EclSubsystem displayed_subsys
privateinherited

Identifier of displayed ECL subsystem.

Definition at line 116 of file EclPainter.h.

◆ grid

TPad* grid
private

Grid pad, drawn in drawGrid().

Definition at line 63 of file EclPainter2D.h.

◆ hgrid

TH2C* hgrid
private

The grid itself, drawn in drawGrid().

Definition at line 61 of file EclPainter2D.h.

◆ m_ecl_data

EclData* m_ecl_data
privateinherited

Data to draw.

Definition at line 111 of file EclPainter.h.

◆ m_hist

TH2F* m_hist
private

Displayed histogram.

Definition at line 58 of file EclPainter2D.h.

◆ m_mapper

ECL::ECLChannelMapper* m_mapper
privateinherited

mapper for CellID <-> (crate, shaper, chid) conversion.

Definition at line 113 of file EclPainter.h.

◆ m_obj_counter

int m_obj_counter = 0
staticprivateinherited

Counter to make unique names for new root objects.

Definition at line 109 of file EclPainter.h.

◆ m_type

Type m_type
private

Display subtypes of this class.

Definition at line 56 of file EclPainter2D.h.


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