Belle II Software development
EclPainter1D Class Reference

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

#include <EclPainter1D.h>

Inheritance diagram for EclPainter1D:
EclPainter

Public Types

enum  Type {
  CHANNEL ,
  SHAPER ,
  CRATE ,
  PHI ,
  THETA
}
 Subtype of histogram to draw. More...
 

Public Member Functions

 EclPainter1D (EclData *data, Type type)
 Constructor for EclPainter subclass.
 
virtual ~EclPainter1D ()
 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 ECLPainter1D.
 
virtual EclPainterhandleClick (int px, int py) override
 Creates sub-histogram for crates and shapers.
 
void setXRange (int xmin, int xmax) override
 Set XRange for histogram.
 
void setShaper (int crate, int shaper)
 Show data only from specific shaper.
 
void setCrate (int crate)
 Show data only from specific crate.
 
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.
 

Protected Member Functions

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

Private Member Functions

int channelToSegId (int channel)
 Convert channel id to X bin number.
 
int getMaxX ()
 Returns number of X bins.
 
void initHisto ()
 Initialize histogram.
 
void setTitles ()
 Update titles of the histogram.
 
void cloneFrom (const EclPainter &other)
 Clone attributes from other EclPainter.
 

Private Attributes

Type m_type
 Display subtypes of this class.
 
TH1F * m_hist
 Displayed histogram.
 
int m_shaper
 ID of currently selected shaper.
 
int m_crate
 ID of currently selected crate.
 
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, 1D histograms.

Definition at line 24 of file EclPainter1D.h.

Member Enumeration Documentation

◆ Type

enum Type

Subtype of histogram to draw.

Enumerator
CHANNEL 

Events/energy per channel.

SHAPER 

Events/energy per ShaperDSP.

CRATE 

Events/energy per crate/ECLCollector.

Definition at line 27 of file EclPainter1D.h.

27 {
28 CHANNEL,
29 SHAPER,
30 CRATE,
31 PHI,
32 THETA
33 };
@ SHAPER
Events/energy per ShaperDSP.
Definition: EclPainter1D.h:29
@ CRATE
Events/energy per crate/ECLCollector.
Definition: EclPainter1D.h:30
@ CHANNEL
Events/energy per channel.
Definition: EclPainter1D.h:28

Constructor & Destructor Documentation

◆ EclPainter1D()

EclPainter1D ( EclData data,
EclPainter1D::Type  type 
)

Constructor for EclPainter subclass.

Definition at line 24 of file EclPainter1D.cc.

24 :
25 EclPainter(data)
26{
27 m_type = type;
28
29 initHisto();
30 m_hist->GetXaxis()->CenterTitle();
31 m_hist->GetXaxis()->SetTitleOffset(1.1);
32 m_hist->GetYaxis()->SetTitleOffset(1.1);
33
34 m_shaper = -1;
35 m_crate = -1;
36}
Type m_type
Display subtypes of this class.
Definition: EclPainter1D.h:46
TH1F * m_hist
Displayed histogram.
Definition: EclPainter1D.h:48
int m_crate
ID of currently selected crate.
Definition: EclPainter1D.h:53
int m_shaper
ID of currently selected shaper.
Definition: EclPainter1D.h:51
void initHisto()
Initialize histogram.
Definition: EclPainter1D.cc:80
Painter for EclData, parent class, created with EclPainterFactory.
Definition: EclPainter.h:29

◆ ~EclPainter1D()

~EclPainter1D ( )
virtual

Destructor for EclPainter subclass.

Definition at line 38 of file EclPainter1D.cc.

39{
40 delete m_hist;
41}

Member Function Documentation

◆ channelToSegId()

int channelToSegId ( int  channel)
private

Convert channel id to X bin number.

Definition at line 43 of file EclPainter1D.cc.

44{
45 switch (m_type) {
46 case CHANNEL:
47 return channel;
48 case SHAPER:
49 return 12 * getMapper()->getCrateID(channel) +
50 getMapper()->getShaperPosition(channel) - 12;
51 case CRATE:
52 return getMapper()->getCrateID(channel);
53 case PHI:
54 return getData()->getPhiId(channel);
55 case THETA:
56 return getData()->getThetaId(channel);
57 }
58
59 return 0;
60}
int getShaperPosition(int cellID)
Get position of the shaper in the crate by given CellId.
int getCrateID(int iCOPPERNode, int iFINESSE, bool pcie40=false)
Get crate number by given COPPER node number and FINESSE number.
int getThetaId(int ch)
ECL CellId -> theta_id.
Definition: EclData.cc:288
int getPhiId(int ch)
ECL CellId -> phi_id.
Definition: EclData.cc:278
EclData * getData()
Return currently displayed EclData.
Definition: EclPainter.h:46
ECL::ECLChannelMapper * getMapper()
Return currently set ECLChannelMapper.
Definition: EclPainter.cc:41

◆ cloneFrom()

void cloneFrom ( const EclPainter other)
privateinherited

Clone attributes from other EclPainter.

Definition at line 93 of file EclPainter.cc.

94{
95 m_ecl_data = new EclData(*other.m_ecl_data);
96 m_mapper = other.m_mapper;
98}
This class contains data for ECLSimHit's and provides several relevant conversion functions for bette...
Definition: EclData.h:31
ECL::ECLChannelMapper * m_mapper
mapper for CellID <-> (crate, shaper, chid) conversion.
Definition: EclPainter.h:113
EclData * m_ecl_data
Data to draw.
Definition: EclPainter.h:111
EclData::EclSubsystem displayed_subsys
Identifier of displayed ECL subsystem.
Definition: EclPainter.h:116

◆ Draw()

void Draw ( )
overridevirtual

Redraw the canvas.

Implements EclPainter.

Definition at line 215 of file EclPainter1D.cc.

216{
217 setTitles();
218
219 EclData* data = getData();
220
221 const int* ev_counts = data->getEventCounts();
222 const float* energy_sums = data->getEnergySums();
223
224 m_hist->Reset();
225 for (int i = 1; i <= getData()->getCrystalCount(); i++) {
226 if (!data->isCrystalInSubsystem(i, getDisplayedSubsystem())) continue;
227
228 // If filter is set, display only specified channels.
229 if (m_type == CHANNEL && m_crate > 0 && m_shaper > 0) {
230 if (m_crate != getMapper()->getCrateID(i) ||
232 continue;
233 }
234 }
235 if (m_type == SHAPER && m_crate > 0) {
236 if (m_crate != getMapper()->getCrateID(i)) {
237 continue;
238 }
239 }
240 //
241 int id = channelToSegId(i);
242 if (GetMode())
243 m_hist->Fill(id, energy_sums[i]);
244 else
245 m_hist->Fill(id, ev_counts[i]);
246 }
247
248 m_hist->Draw("HIST");
249}
static int getCrystalCount()
Get number of crystals in ECL.
Definition: EclData.cc:148
void setTitles()
Update titles of the histogram.
Definition: EclPainter1D.cc:88
int channelToSegId(int channel)
Convert channel id to X bin number.
Definition: EclPainter1D.cc:43
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

◆ getData() [1/2]

EclData * getData ( )
inlineinherited

Return currently displayed EclData.

Definition at line 46 of file EclPainter.h.

46{ return m_ecl_data; }

◆ 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}

◆ 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 124 of file EclPainter1D.cc.

125{
126 EclPainter::getInformation(px, py, panel);
127
128 char info[255];
129
130 Float_t upx = gPad->AbsPixeltoX(px);
131 Float_t x = gPad->PadtoX(upx);
132 int binx = m_hist->GetXaxis()->FindBin(x) - 1;
133
134 if (m_type == CHANNEL) {
135 sprintf(info, "channel_id = %d (%d)", binx,
136 getMapper()->getShaperChannel(binx));
137 panel->setLine(1, info);
138 sprintf(info, "shaper_id = %d", getMapper()->getShaperPosition(binx));
139 panel->setLine(2, info);
140 sprintf(info, "crate_id = %d", getMapper()->getCrateID(binx));
141 panel->setLine(3, info);
142 }
143 if (m_type == SHAPER) {
144 sprintf(info, "shaper_id = %d (%d)", binx, (binx - 1) % 12 + 1);
145 panel->setLine(1, info);
146 sprintf(info, "crate_id = %d", (binx - 1) / 12 + 1);
147 panel->setLine(2, info);
148 }
149 if (m_type == CRATE) {
150 sprintf(info, "crate_id = %d", binx);
151 panel->setLine(1, info);
152 }
153 if (m_type == PHI) {
154 sprintf(info, "phi_id = %d", binx);
155 panel->setLine(1, info);
156 }
157 if (m_type == THETA) {
158 sprintf(info, "theta_id = %d", binx);
159 panel->setLine(1, info);
160 }
161}
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}

◆ getMaxX()

int getMaxX ( )
private

Returns number of X bins.

Definition at line 62 of file EclPainter1D.cc.

63{
64 switch (m_type) {
65 case CHANNEL:
66 return getData()->getCrystalCount();
67 case SHAPER:
68 return 52 * 12;
69 case CRATE:
70 return 52;
71 case PHI:
72 return 144;
73 case THETA:
74 return 69;
75 }
76
77 return 1;
78}

◆ 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()

EclPainter1D::Type getType ( )

Return subtype of ECLPainter1D.

Definition at line 163 of file EclPainter1D.cc.

164{
165 return m_type;
166}

◆ handleClick()

EclPainter * handleClick ( int  px,
int  py 
)
overridevirtual

Creates sub-histogram for crates and shapers.

This function is called upon click in EclFrame.

Reimplemented from EclPainter.

Definition at line 168 of file EclPainter1D.cc.

169{
170 Float_t upx = gPad->AbsPixeltoX(px);
171 Float_t x = gPad->PadtoX(upx);
172 int binx = m_hist->GetXaxis()->FindBin(x) - 1;
173
174 Float_t upy = gPad->AbsPixeltoY(py);
175 Float_t y = gPad->PadtoY(upy);
176
177 if (y < 0) return nullptr;
178
179 if (m_type == SHAPER) {
181 ret->setMapper(getMapper());
183 //ret->setXRange(binx * 16, binx * 16 + 15);
184 ret->setShaper((binx - 1) / 12 + 1, (binx - 1) % 12 + 1);
185 return ret;
186 }
187 if (m_type == CRATE) {
189 ret->setMapper(getMapper());
191 ret->setXRange((binx - 1) * 12 + 1, (binx - 1) * 12 + 12);
192 //ret->setCrate(binx);
193 return ret;
194 }
195
196 return nullptr;
197}
Painter for EclData, 1D histograms.
Definition: EclPainter1D.h:24
void setXRange(int xmin, int xmax) override
Set XRange for histogram.
void setShaper(int crate, int shaper)
Show data only from specific shaper.
void setMapper(ECL::ECLChannelMapper *mapper)
Set ECLChannelMapper for CellID <-> (crate, shaper, chid) conversion.
Definition: EclPainter.cc:36
void setDisplayedSubsystem(EclData::EclSubsystem sys)
Change between the displayed ECL subsystem (barrel, forward and backward endcaps).
Definition: EclPainter.cc:46

◆ initHisto()

void initHisto ( )
private

Initialize histogram.

Definition at line 80 of file EclPainter1D.cc.

81{
82 char obj_name[255];
83 getNewRootObjectName(obj_name, 255);
84
85 m_hist = new TH1F(obj_name, "title", getMaxX() + 1, 0, getMaxX() + 1);
86}
int getMaxX()
Returns number of X bins.
Definition: EclPainter1D.cc:62
void getNewRootObjectName(char *buf, int size)
Make unique name for next root object.
Definition: EclPainter.cc:88

◆ setCrate()

void setCrate ( int  crate)

Show data only from specific crate.

Show data for all crates if param 'crate' < 0.

Definition at line 210 of file EclPainter1D.cc.

211{
212 m_crate = crate;
213}

◆ 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}

◆ setShaper()

void setShaper ( int  crate,
int  shaper 
)

Show data only from specific shaper.

Show data for all shapers if on of the arguments is negative.

Definition at line 204 of file EclPainter1D.cc.

205{
206 m_crate = crate;
207 m_shaper = shaper;
208}

◆ setTitles()

void setTitles ( )
private

Update titles of the histogram.

Definition at line 88 of file EclPainter1D.cc.

89{
90 // TODO: These extra labels might not be necessary.
91 const char* name[3][5] = {
92 {
93 "Events per channel", "Events per shaper", "Events per collector",
94 "Events per phi_id", "Events per theta_id"
95 },
96
97 {
98 "Energy per channel (MeV)", "Energy per shaper (MeV)", "Energy per collector (MeV)"
99 "Energy per phi_id (MeV)", "Energy per theta_id (MeV)"
100 },
101
102 {
103 "Time per channel (ns)", "Time per shaper (ns)", "Time per collector (ns)",
104 "Time per phi_id (ns)", "Time per theta_id (ns)"
105 }
106 };
107 const char* xname[3] = {
108 "Channel id", "Shaper id", "Collector id"
109 };
110 const char* yname[3] = {
111 "Events", "Energy", "Time"
112 };
113
114 TString title = TString(name[GetMode()][(int)m_type]) + " (" +
116 const char* xtitle = xname[(int)m_type];
117 const char* ytitle = yname[GetMode()];
118
119 m_hist->SetTitle(title);
120 m_hist->SetXTitle(xtitle);
121 m_hist->SetYTitle(ytitle);
122}
TString getSubsystemTitle(EclData::EclSubsystem subsys)
Return title of ECL subsystem to use in painter.
Definition: EclPainter.cc:56

◆ setXRange()

void setXRange ( int  xmin,
int  xmax 
)
overridevirtual

Set XRange for histogram.

Reimplemented from EclPainter.

Definition at line 199 of file EclPainter1D.cc.

200{
201 m_hist->GetXaxis()->SetRange(xmin + 1, xmax + 1);
202}

Member Data Documentation

◆ displayed_subsys

EclData::EclSubsystem displayed_subsys
privateinherited

Identifier of displayed ECL subsystem.

Definition at line 116 of file EclPainter.h.

◆ m_crate

int m_crate
private

ID of currently selected crate.

Definition at line 53 of file EclPainter1D.h.

◆ m_ecl_data

EclData* m_ecl_data
privateinherited

Data to draw.

Definition at line 111 of file EclPainter.h.

◆ m_hist

TH1F* m_hist
private

Displayed histogram.

Definition at line 48 of file EclPainter1D.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_shaper

int m_shaper
private

ID of currently selected shaper.

Definition at line 51 of file EclPainter1D.h.

◆ m_type

Type m_type
private

Display subtypes of this class.

Definition at line 46 of file EclPainter1D.h.


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