Logo ROOT  
Reference Guide
Loading...
Searching...
No Matches
TEveCaloVizEditor.cxx
Go to the documentation of this file.
1// @(#)root/eve:$Id$
2// Author: Matevz Tadel 2007
3
4/*************************************************************************
5 * Copyright (C) 1995-2007, Rene Brun and Fons Rademakers. *
6 * All rights reserved. *
7 * *
8 * For the licensing terms see $ROOTSYS/LICENSE. *
9 * For the list of contributors see $ROOTSYS/README/CREDITS. *
10 *************************************************************************/
11
12#include "TEveCaloVizEditor.h"
13#include "TEveCalo.h"
14#include "TEveGValuators.h"
16#include "TEveCaloData.h"
17
18#include "TGClient.h"
19#include "TGFont.h"
20#include "TGedEditor.h"
21
22#include "TGLabel.h"
23#include "TGNumberEntry.h"
24#include "TGDoubleSlider.h"
25#include "TG3DLine.h"
26#include "TGButtonGroup.h"
27#include "TColor.h"
28#include "TGColorSelect.h"
29
30#include "TMathBase.h"
31#include "TMath.h"
32
33/** \class TEveCaloVizEditor
34\ingroup TEve
35GUI editor for TEveCaloEditor.
36*/
37
38
39////////////////////////////////////////////////////////////////////////////////
40/// Constructor.
41
43 UInt_t options, Pixel_t back) :
44 TGedFrame(p, width, height, options | kVerticalFrame, back),
45 fM(nullptr),
46
47 fPlotE(nullptr),
48 fPlotEt(nullptr),
49
50 fScaleAbs(nullptr),
51 fMaxValAbs(nullptr),
52 fMaxTowerH(nullptr),
53
54 fEtaRng(nullptr),
55 fPhi(nullptr),
56 fPhiOffset(nullptr),
57 fDataFrame(nullptr),
58 fSliceFrame(nullptr)
59{
60 MakeTitle("TEveCaloViz");
61
62 TGLabel* label = nullptr;
63 Int_t labelW = 45;
64
65 // scaling
66 TGHorizontalFrame* scf = new TGHorizontalFrame(this);
67
68 label = new TGLabel(scf, "ScaleAbsolute:");
70
71 fScaleAbs = new TGCheckButton(scf);
72 scf->AddFrame(fScaleAbs, new TGLayoutHints(kLHintsLeft, 3, 5, 3, 0));
73 fScaleAbs->Connect("Toggled(Bool_t)", "TEveCaloVizEditor", this, "DoScaleAbs()");
74
75
76 fMaxValAbs = new TEveGValuator(scf, "MaxEVal:", 70, 0);
77 fMaxValAbs->SetLabelWidth(56);
78 fMaxValAbs->SetNELength(5);
79 fMaxValAbs->SetShowSlider(kFALSE);
80 fMaxValAbs->Build();
81 fMaxValAbs->SetLimits(0, 1000);
82 fMaxValAbs->Connect("ValueSet(Double_t)", "TEveCaloVizEditor", this, "DoMaxValAbs()");
83 scf->AddFrame(fMaxValAbs, new TGLayoutHints(kLHintsTop, 1, 1, 1, 1));
84
85 AddFrame(scf, new TGLayoutHints(kLHintsTop, 4, 1, 1, 0));
86
87
88 // tower height
89 fMaxTowerH = new TEveGValuator(this, "MaxTowerH:", 96, 0);
90 fMaxTowerH->SetLabelWidth(71);
91 fMaxTowerH->SetNELength(5);
92 fMaxTowerH->SetShowSlider(kFALSE);
93 fMaxTowerH->Build();
94 fMaxTowerH->SetLimits(0.1, 500, 501, TGNumberFormat::kNESRealOne);
95 fMaxTowerH->Connect("ValueSet(Double_t)", "TEveCaloVizEditor", this, "DoMaxTowerH()");
97
98
99 //______________________________________________________________________________
100
102
103 // E/Et Plot
104 {
106 TGCompositeFrame *labfr = new TGHorizontalFrame(group, 28, 20, kFixedSize);
107
108 TGFont *myfont = gClient->GetFont("-adobe-times-bold-r-*-*-12-*-*-*-*-*-iso8859-1");
109 label = new TGLabel(labfr, "Plot:");
110 label->SetTextFont(myfont);
111 labfr->AddFrame(label, new TGLayoutHints(kLHintsLeft | kLHintsBottom));
112 group->AddFrame(labfr, new TGLayoutHints(kLHintsLeft));
113
114 fPlotE = new TGRadioButton(group, new TGHotString("E"), 11);
115 fPlotE->Connect("Clicked()", "TEveCaloVizEditor", this, "DoPlot()");
116 group->AddFrame(fPlotE, new TGLayoutHints(kLHintsLeft | kLHintsBottom, 2, 2, 0, 0));
117
118 fPlotEt = new TGRadioButton(group, new TGHotString("Et"), 22);
119 fPlotEt->Connect("Clicked()", "TEveCaloVizEditor", this, "DoPlot()");
120 group->AddFrame(fPlotEt, new TGLayoutHints(kLHintsLeft | kLHintsBottom, 2, 2, 0, 0));
121
122 fDataFrame->AddFrame(group, new TGLayoutHints(kLHintsTop, 4, 1, 1, 0));
123 }
124
125 // eta
126 fEtaRng = new TEveGDoubleValuator(fDataFrame,"Eta rng:", 40, 0);
127 fEtaRng->SetNELength(6);
128 fEtaRng->SetLabelWidth(labelW);
129 fEtaRng->Build();
130 fEtaRng->GetSlider()->SetWidth(195);
131 fEtaRng->SetLimits(-5.5, 5.5, TGNumberFormat::kNESRealTwo);
132 fEtaRng->Connect("ValueSet()", "TEveCaloVizEditor", this, "DoEtaRange()");
133 fDataFrame->AddFrame(fEtaRng, new TGLayoutHints(kLHintsTop, 1, 1, 4, 5));
134
135 // phi
136 fPhi = new TEveGValuator(fDataFrame, "Phi:", 90, 0);
137 fPhi->SetLabelWidth(labelW);
138 fPhi->SetNELength(6);
139 fPhi->Build();
141 fPhi->Connect("ValueSet(Double_t)", "TEveCaloVizEditor", this, "DoPhi()");
142 fDataFrame->AddFrame(fPhi, new TGLayoutHints(kLHintsTop, 1, 1, 1, 1));
143
144 fPhiOffset = new TEveGValuator(fDataFrame, "PhiOff:", 90, 0);
145 fPhiOffset->SetLabelWidth(labelW);
146 fPhiOffset->SetNELength(6);
147 fPhiOffset->Build();
149 fPhiOffset->Connect("ValueSet(Double_t)", "TEveCaloVizEditor", this, "DoPhi()");
150 fDataFrame->AddFrame(fPhiOffset, new TGLayoutHints(kLHintsTop, 1, 1, 1, 1));
151
153 fDataFrame->AddFrame(fSliceFrame);
154}
155
156////////////////////////////////////////////////////////////////////////////////
157/// Create slice info gui.
158
160{
161 Int_t ns = fM->GetData()->GetNSlices();
162 Int_t nf = fSliceFrame->GetList()->GetSize();
163
164 if (ns > nf)
165 {
166 for (Int_t i=nf; i<ns; ++i)
167 {
169
170 TEveGValuator* threshold = new TEveGValuator(f,"", 90, 0, i);
171 threshold->SetLabelWidth(50);
172 threshold->SetNELength(6);
173 threshold->SetShowSlider(kFALSE);
174 threshold->Build();
175 threshold->SetLimits(0, 1000, TGNumberFormat::kNESRealTwo);
176 threshold->Connect("ValueSet(Double_t)", "TEveCaloVizEditor", this, "DoSliceThreshold()");
177 f->AddFrame(threshold, new TGLayoutHints(kLHintsTop, 1, 1, 1, 1));
178
179 TGColorSelect* color = new TGColorSelect(f, 0, i);
180 f->AddFrame(color, new TGLayoutHints(kLHintsLeft|kLHintsTop, 3, 1, 0, 1));
181 color->Connect("ColorSelected(Pixel_t)", "TEveCaloVizEditor", this, "DoSliceColor(Pixel_t)");
182
183 TGNumberEntry* transparency = new TGNumberEntry(f, 0., 2, i,
186 transparency->SetHeight(18);
187 transparency->GetNumberEntry()->SetToolTipText("Transparency: 0 is opaque, 100 fully transparent.");
188 f->AddFrame(transparency, new TGLayoutHints(kLHintsLeft, 0, 0, 0, 0));
189 transparency->Connect("ValueSet(Long_t)", "TEveCaloVizEditor", this, "DoSliceTransparency(Long_t)");
190
191
192 fSliceFrame->AddFrame(f, new TGLayoutHints(kLHintsTop, 1, 1, 1, 0));
193 }
194 nf = ns;
195 }
196
197 TIter frame_iterator(fSliceFrame->GetList());
198 for (Int_t i=0; i<nf; ++i)
199 {
200 TGFrameElement *el = (TGFrameElement*) frame_iterator();
202 if (i < ns)
203 {
204 TEveCaloData::SliceInfo_t &si = fM->GetData()->RefSliceInfo(i);
205
206 TEveGValuator *threshold = (TEveGValuator*) ((TGFrameElement*) fr->GetList()->At(0))->fFrame;
207 TGColorSelect *color = (TGColorSelect*) ((TGFrameElement*) fr->GetList()->At(1) )->fFrame;
208 TGNumberEntry *transp = (TGNumberEntry*) ((TGFrameElement*) fr->GetList()->At(2))->fFrame;
209
210 threshold->GetLabel()->SetText(si.fName);
211 threshold->SetValue(si.fThreshold);
212 color->SetColor(TColor::Number2Pixel(si.fColor), kFALSE);
213 transp->SetNumber(si.fTransparency);
214
215 if (! fr->IsMapped()) {
216 fr->MapSubwindows();
217 fr->MapWindow();
218 }
219 }
220 else
221 {
222 if (fr->IsMapped()) {
223 fr->UnmapWindow();
224 }
225 }
226 }
227}
228
229////////////////////////////////////////////////////////////////////////////////
230/// Set model object.
231
233{
234 fM = dynamic_cast<TEveCaloViz*>(obj);
235 if (fM->GetPlotEt())
236 {
237 fPlotEt->SetState(kButtonDown, kFALSE);
238 fPlotE->SetState(kButtonUp, kFALSE);
239 }
240 else
241 {
242 fPlotE->SetState(kButtonDown, kFALSE);
243 fPlotEt->SetState(kButtonUp, kFALSE);
244 }
245
246 if (fM->fData)
247 {
249 if (p->GetList()->IsEmpty())
250 {
251 p->MapWindow();
252 p->MapSubwindows();
253 }
254
255 fScaleAbs->SetState(fM->GetScaleAbs() ? kButtonDown : kButtonUp);
256 fMaxValAbs->SetValue(fM->GetMaxValAbs());
257 fMaxTowerH->SetValue(fM->GetMaxTowerH());
258
259 Double_t min, max;
260 fM->GetData()->GetEtaLimits(min, max);
261 fEtaRng->SetLimits((Float_t)min, (Float_t)max);
262 fEtaRng->SetValues(fM->fEtaMin, fM->fEtaMax);
263
264 fM->GetData()->GetPhiLimits(min, max);
265 fPhi->SetLimits(min, max, 101, TGNumberFormat::kNESRealTwo);
266 fPhi->SetValue(fM->fPhi);
267 if ( fM->GetData()->GetWrapTwoPi())
268 {
269 fPhi->SetToolTip("Center angle in radians");
270 fPhiOffset->SetLimits(1e-3, TMath::Pi(), 101, TGNumberFormat::kNESRealTwo);
271 }
272 else
273 {
274 Float_t d = (max-min)*0.5;
275 fPhiOffset->SetLimits(1e-3, d, 101, TGNumberFormat::kNESRealTwo);
276 }
277 fPhiOffset->SetValue(fM->fPhiOffset);
278 fPhiOffset->SetToolTip("Phi range in radians");
279
281 }
282 else
283 {
284
285 fDataFrame->UnmapWindow();
286 }
287}
288
289////////////////////////////////////////////////////////////////////////////////
290/// Slot for setting max tower height.
291
293{
294 fM->SetMaxTowerH(fMaxTowerH->GetValue());
295 Update();
296}
297
298////////////////////////////////////////////////////////////////////////////////
299/// Slot for enabling/disabling absolute scale.
300
302{
303 fM->SetScaleAbs(fScaleAbs->IsOn());
304 Update();
305}
306
307////////////////////////////////////////////////////////////////////////////////
308/// Slot for setting max E in for absolute scale.
309
311{
312 fM->SetMaxValAbs(fMaxValAbs->GetValue());
313 Update();
314}
315
316////////////////////////////////////////////////////////////////////////////////
317/// Slot for setting E/Et plot.
318
320{
321 TGButton *btn = (TGButton *) gTQSender;
322 Int_t id = btn->WidgetId();
323
324 if (id == fPlotE->WidgetId())
325 fPlotEt->SetState(kButtonUp);
326 else
327 fPlotE->SetState(kButtonUp);
328
329 fM->SetPlotEt(fPlotEt->IsDown());
330 Update();
331}
332
333////////////////////////////////////////////////////////////////////////////////
334/// Slot for setting eta range.
335
337{
338 fM->SetEta(fEtaRng->GetMin(), fEtaRng->GetMax());
339 Update();
340}
341
342////////////////////////////////////////////////////////////////////////////////
343/// Slot for setting phi range.
344
346{
347 fM->SetPhiWithRng(fPhi->GetValue(), fPhiOffset->GetValue());
348 Update();
349}
350
351////////////////////////////////////////////////////////////////////////////////
352/// Slot for SliceThreshold.
353
355{
357 fM->SetDataSliceThreshold(st->WidgetId(), st->GetValue());
358 Update();
359}
360
361////////////////////////////////////////////////////////////////////////////////
362/// Slot for slice info Color.
363
365{
367 fM->SetDataSliceColor(cs->WidgetId(), Color_t(TColor::GetColor(pixel)));
368 Update();
369}
370
371////////////////////////////////////////////////////////////////////////////////
372/// Slot for slice transparency.
373
375{
377 fM->GetData()->SetSliceTransparency(cs->WidgetId(), t);
378 Update();
379}
380
381/** \class TEveCalo3DEditor
382\ingroup TEve
383GUI editor for TEveCalo3D.
384*/
385
386
387////////////////////////////////////////////////////////////////////////////////
388/// Constructor.
389
391 UInt_t options, Pixel_t back) :
392 TGedFrame(p, width, height, options | kVerticalFrame, back),
393 fM(nullptr),
394 fFrameTransparency(nullptr)
395{
396 MakeTitle("TEveCalo3D");
397
399 TGLabel* lab = new TGLabel(f, "Frame transparency: ");
400 f->AddFrame(lab, new TGLayoutHints(kLHintsLeft|kLHintsBottom, 1, 1, 1, 1));
401
402 fFrameTransparency = new TGNumberEntry(f, 0., 2, -1,
405
406 fFrameTransparency->SetHeight(18);
407 fFrameTransparency->GetNumberEntry()->SetToolTipText("Transparency: 0 is opaque, 100 fully transparent.");
408 f->AddFrame(fFrameTransparency, new TGLayoutHints(kLHintsLeft, 0, 0, 0, 0));
409 fFrameTransparency->Connect("ValueSet(Long_t)","TEveCalo3DEditor", this, "DoFrameTransparency()");
410
411 AddFrame(f, new TGLayoutHints(kLHintsTop, 1, 1, 1, 0));
412}
413
414////////////////////////////////////////////////////////////////////////////////
415/// Set model object.
416
418{
419 fM = dynamic_cast<TEveCalo3D*>(obj);
420 fFrameTransparency->SetNumber(fM->GetFrameTransparency());
421}
422
423////////////////////////////////////////////////////////////////////////////////
424/// Slot for frame transparency.
425
427{
428 fM->SetFrameTransparency((Char_t)(fFrameTransparency->GetNumber()));
429 Update();
430}
@ kVerticalFrame
Definition GuiTypes.h:382
@ kFixedSize
Definition GuiTypes.h:391
ULong_t Pixel_t
Pixel value.
Definition GuiTypes.h:41
#define d(i)
Definition RSha256.hxx:102
#define f(i)
Definition RSha256.hxx:104
#define e(i)
Definition RSha256.hxx:103
int Int_t
Signed integer 4 bytes (int).
Definition RtypesCore.h:59
char Char_t
Character 1 byte (char).
Definition RtypesCore.h:51
unsigned int UInt_t
Unsigned integer 4 bytes (unsigned int).
Definition RtypesCore.h:60
long Long_t
Signed long integer 4 bytes (long). Size depends on architecture.
Definition RtypesCore.h:68
constexpr Bool_t kFALSE
Definition RtypesCore.h:108
double Double_t
Double 8 bytes.
Definition RtypesCore.h:73
short Color_t
Color number (short).
Definition RtypesCore.h:99
float Float_t
Float 4 bytes (float).
Definition RtypesCore.h:71
@ kButtonDown
Definition TGButton.h:54
@ kButtonUp
Definition TGButton.h:53
#define gClient
Definition TGClient.h:157
@ kLHintsLeft
Definition TGLayout.h:24
@ kLHintsBottom
Definition TGLayout.h:29
@ kLHintsTop
Definition TGLayout.h:27
externvoid * gTQSender
Definition TQObject.h:46
virtual Bool_t IsEmpty() const
static Int_t GetColor(const char *hexcolor)
static ULong_t Number2Pixel(Int_t ci)
void DoFrameTransparency()
Slot for frame transparency.
void SetModel(TObject *obj) override
Set model object.
TGNumberEntry * fFrameTransparency
TEveCalo3DEditor(const TEveCalo3DEditor &)
Visualization of a calorimeter event data in 3D.
Definition TEveCalo.h:158
void DoMaxValAbs()
Slot for setting max E in for absolute scale.
TEveGValuator * fPhiOffset
TGRadioButton * fPlotEt
void DoPlot()
Slot for setting E/Et plot.
void SetModel(TObject *obj) override
Set model object.
void DoEtaRange()
Slot for setting eta range.
TEveCaloVizEditor(const TEveCaloVizEditor &)
void DoScaleAbs()
Slot for enabling/disabling absolute scale.
TEveGDoubleValuator * fEtaRng
TEveGValuator * fPhi
TGCheckButton * fScaleAbs
TGVerticalFrame * fSliceFrame
void DoSliceTransparency(Long_t transp)
Slot for slice transparency.
TEveGValuator * fMaxTowerH
TGVerticalFrame * fDataFrame
void DoMaxTowerH()
Slot for setting max tower height.
TGRadioButton * fPlotE
void DoSliceColor(Pixel_t color)
Slot for slice info Color.
void DoSliceThreshold()
Slot for SliceThreshold.
void MakeSliceInfo()
Create slice info gui.
TEveGValuator * fMaxValAbs
void DoPhi()
Slot for setting phi range.
Base class for calorimeter data visualization.
Definition TEveCalo.h:32
Composite GUI element for selection of range (label, two number-entries and double-slider).
void SetLabelWidth(Int_t w)
void SetShowSlider(Bool_t s=kTRUE)
void SetNELength(Int_t l)
TGLabel * GetLabel()
Composite GUI element for single value selection (supports label, number-entry and slider).
void Build(Bool_t connect=kTRUE) override
Create sub-components (label, number entry, slider).
void SetLimits(Int_t min, Int_t max)
Set limits of the represented value for integer values.
Float_t GetValue() const
virtual void SetValue(Float_t v, Bool_t emit=kFALSE)
Set value, optionally emit signal.
A button abstract base class.
Definition TGButton.h:68
Selects different options.
Definition TGButton.h:264
Like a checkbutton but instead of the check mark there is color area with a little down arrow.
virtual void AddFrame(TGFrame *f, TGLayoutHints *l=nullptr)
Add frame to the composite frame using the specified layout hints.
Definition TGFrame.cxx:1109
virtual TList * GetList() const
Definition TGFrame.h:312
void MapSubwindows() override
Map all sub windows that are part of the composite frame.
Definition TGFrame.cxx:1156
TGCompositeFrame(const TGCompositeFrame &)=delete
Encapsulate fonts used in the GUI system.
Definition TGFont.h:140
TGFrame * fFrame
Definition TGLayout.h:112
void MapWindow() override
map window
Definition TGFrame.h:206
void UnmapWindow() override
unmap window
Definition TGFrame.h:208
virtual void SetHeight(UInt_t h)
Definition TGFrame.h:249
A composite frame that layout their children in horizontal way.
Definition TGFrame.h:387
TGHotString is a string with a "hot" character underlined.
Definition TGString.h:42
This class handles GUI labels.
Definition TGLabel.h:24
virtual void SetText(TGString *newText)
Set new text in label.
Definition TGLabel.cxx:179
virtual void SetTextFont(TGFont *font, Bool_t global=kFALSE)
Changes text font specified by pointer to TGFont object.
Definition TGLabel.cxx:323
This class describes layout hints used by the layout classes.
Definition TGLayout.h:50
TGNumberEntry is a number entry input widget with up/down buttons.
TGNumberEntryField * GetNumberEntry() const
Get the number entry field.
virtual void SetNumber(Double_t val, Bool_t emit=kTRUE)
@ kNEANonNegative
Non-negative number.
@ kNESRealOne
Fixed fraction real, one digit.
@ kNESInteger
Style of number entry field.
@ kNESRealTwo
Fixed fraction real, two digit.
@ kNELLimitMinMax
Both lower and upper limits.
Selects different options.
Definition TGButton.h:321
virtual void SetToolTipText(const char *text, Long_t delayms=500)
Set tool tip text associated with this text entry.
A composite frame that layout their children in vertical way.
Definition TGFrame.h:376
Int_t WidgetId() const
Definition TGWidget.h:68
ROOT GUI Window base class.
Definition TGWindow.h:23
virtual Bool_t IsMapped()
Returns kTRUE if window is mapped on screen, kFALSE otherwise.
Definition TGWindow.cxx:293
virtual TGCompositeFrame * GetEditorTab(const char *name)
Find or create tab with name.
virtual TGVerticalFrame * CreateEditorTabSubFrame(const char *name)
Create a vertical frame to be used by 'owner' in extra tab 'name'.
TGedFrame(const TGedFrame &)=delete
virtual void MakeTitle(const char *title)
Create attribute frame title.
Definition TGedFrame.cxx:94
virtual void Update()
Update the current pad when an attribute is changed via GUI.
Definition TGedFrame.cxx:71
TGedEditor * GetGedEditor()
Definition TGedFrame.h:71
TObject * At(Int_t idx) const override
Returns the object at position idx. Returns 0 if idx is out of range.
Definition TList.cxx:487
Mother of all ROOT objects.
Definition TObject.h:42
Bool_t Connect(const char *signal, const char *receiver_class, void *receiver, const char *slot)
Non-static method is used to connect from the signal of this object to the receiver slot.
Definition TQObject.cxx:865
constexpr Double_t Pi()
Definition TMath.h:40