Logo ROOT   6.12/07
Reference Guide
TEveCaloLegoGL.h
Go to the documentation of this file.
1 // @(#)root/eve:$Id$
2 // Author: Alja Mrak-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 #ifndef ROOT_TEveCaloLegoGL
13 #define ROOT_TEveCaloLegoGL
14 
15 #include "TGLObject.h"
16 #include "TGLAxisPainter.h"
17 
18 #include "TEveCaloData.h"
19 #include "TEveVector.h"
20 #include "TEveCalo.h"
21 
22 #include <map>
23 
24 class TEveCaloLego;
25 
26 class TEveCaloLegoGL : public TGLObject
27 {
28  friend class TEveCaloLegoOverlay;
29 
30 private:
31  struct Cell2D_t
32  {
36 
38 
39  Cell2D_t(Int_t id, Float_t sumVal, Int_t maxSlice)
40  {
41  fId = id;
42  fSumVal = sumVal;
43  fMaxSlice = maxSlice;
44  fX0 = fX1 = fY0 = fY1 = 0;
45  }
46 
48  {
49  fX0 = x0; fX1 = x1;
50  fY0 = y0; fY1 = y1;
51  }
52 
53  Float_t MinSize() { return TMath::Min(fX1- fX0, fY1 - fY0); }
54  Float_t X() { return 0.5*(fX0 + fX1); }
55  Float_t Y() { return 0.5*(fY0 + fY1); }
56  };
57 
58  typedef std::vector<Cell2D_t> vCell2D_t;
59  typedef std::vector<Cell2D_t>::iterator vCell2D_i;
60 
61  typedef std::map<Int_t, UInt_t> SliceDLMap_t;
62  typedef std::map<Int_t, UInt_t>::iterator SliceDLMap_i;
63 
64  // histogram base
67 
68  mutable TAxis *fEtaAxis;
69  mutable TAxis *fPhiAxis;
70  mutable TAxis *fZAxis;
76 
78 
79  // cached
81  mutable Bool_t fDLCacheOK;
82  mutable vCell2D_t fCells2D;
83 
85  mutable Float_t fMaxVal;
86  mutable Float_t fValToPixel; // top logaritmic viewview
88 
89  mutable SliceDLMap_t fDLMap;
90  mutable Bool_t fCells3D;
91 
92  mutable Int_t fBinStep;
93 
94  TEveCaloLegoGL(const TEveCaloLegoGL&); // Stop default
95  TEveCaloLegoGL& operator=(const TEveCaloLegoGL&); // Stop default
96 
97 private:
98  void GetScaleForMatrix(Float_t& sx, Float_t& sy, Float_t& sz) const;
99  Int_t GetGridStep(TGLRnrCtx &rnrCtx) const;
100  void RebinAxis(TAxis *orig, TAxis *curr) const;
101 
102  void SetAxis3DTitlePos(TGLRnrCtx &rnrCtx, Float_t x0, Float_t x1, Float_t y0, Float_t y1) const;
103  void DrawAxis3D(TGLRnrCtx &rnrCtx) const;
104  void DrawAxis2D(TGLRnrCtx &rnrCtx) const;
105  void DrawHistBase(TGLRnrCtx &rnrCtx) const;
106 
107  // highlight
108  void DrawSelectedCells(TGLRnrCtx & rnrCtx, TEveCaloData::vCellId_t cells) const;
109 
110  // top view
111  void PrepareCell2DData(TEveCaloData::vCellId_t& cellList, vCell2D_t& cells2D) const;
112  void PrepareCell2DDataRebin(TEveCaloData::RebinData_t& rebinData, vCell2D_t& cells2D) const;
113  void DrawCells2D(TGLRnrCtx & rnrCtx, vCell2D_t& cells2D) const;
114 
115  // 3D view
116  void DrawCells3D(TGLRnrCtx & rnrCtx) const;
117  void MakeQuad(Float_t x, Float_t y, Float_t z, Float_t xw, Float_t yw, Float_t zh) const;
118  void Make3DDisplayList(TEveCaloData::vCellId_t& cellList, SliceDLMap_t& map, Bool_t select) const;
119  void Make3DDisplayListRebin(TEveCaloData::RebinData_t& rebinData, SliceDLMap_t& map, Bool_t select) const;
120 
121  void WrapTwoPi(Float_t &min, Float_t &max) const;
122 
123 public:
124  TEveCaloLegoGL();
125  virtual ~TEveCaloLegoGL();
126 
127  virtual Bool_t SetModel(TObject* obj, const Option_t* opt = 0);
128 
129  virtual void SetBBox();
130 
131  virtual void DLCacheDrop();
132  virtual void DLCachePurge();
133 
134  virtual void DirectDraw(TGLRnrCtx & rnrCtx) const;
135  virtual void DrawHighlight(TGLRnrCtx& rnrCtx, const TGLPhysicalShape* ps, Int_t lvl=-1) const;
136 
137  virtual Bool_t SupportsSecondarySelect() const { return kTRUE; }
138  virtual Bool_t AlwaysSecondarySelect() const { return kTRUE; }
139  virtual void ProcessSelection(TGLRnrCtx & rnrCtx, TGLSelectRecord & rec);
140 
141  ClassDef(TEveCaloLegoGL, 0); // GL renderer class for TEveCaloLego.
142 };
143 
144 //______________________________________________________________________________
145 inline void TEveCaloLegoGL::WrapTwoPi(Float_t &min, Float_t &max) const
146 {
147  if (fM->GetData()->GetWrapTwoPi())
148  {
149  if (fM->GetPhiMax()>TMath::Pi() && max<=fM->GetPhiMin())
150  {
151  min += TMath::TwoPi();
152  max += TMath::TwoPi();
153  }
154  else if (fM->GetPhiMin()<-TMath::Pi() && min>=fM->GetPhiMax())
155  {
156  min -= TMath::TwoPi();
157  max -= TMath::TwoPi();
158  }
159  }
160 }
161 #endif
void DrawSelectedCells(TGLRnrCtx &rnrCtx, TEveCaloData::vCellId_t cells) const
Draw selected cells in highlight mode.
TEveCaloData * GetData() const
Definition: TEveCalo.h:86
void Make3DDisplayListRebin(TEveCaloData::RebinData_t &rebinData, SliceDLMap_t &map, Bool_t select) const
Create display-list that draws histogram bars for rebinned data.
The TGLRnrCtx class aggregates data for a given redering context as needed by various parts of the RO...
Definition: TGLRnrCtx.h:40
Float_t fValToPixel
Bool_t GetWrapTwoPi() const
Definition: TEveCaloData.h:227
float Float_t
Definition: RtypesCore.h:53
virtual ~TEveCaloLegoGL()
Destructor.
const char Option_t
Definition: RtypesCore.h:62
void PrepareCell2DDataRebin(TEveCaloData::RebinData_t &rebinData, vCell2D_t &cells2D) const
Prepare cells 2D rebinned data for drawing.
constexpr Double_t TwoPi()
Definition: TMath.h:44
virtual void DLCachePurge()
Unregister all display-lists.
OpenGL renderer class for TEveCaloLego.
void MakeQuad(Float_t x, Float_t y, Float_t z, Float_t xw, Float_t yw, Float_t zh) const
Draw an axis-aligned box using quads.
Color_t fGridColor
void DrawCells3D(TGLRnrCtx &rnrCtx) const
Render the calo lego-plot with OpenGL.
Float_t GetPhiMax() const
Definition: TEveCalo.h:145
TEveCaloLegoGL()
Constructor.
static constexpr double ps
Short_t Min(Short_t a, Short_t b)
Definition: TMathBase.h:168
int Int_t
Definition: RtypesCore.h:41
bool Bool_t
Definition: RtypesCore.h:59
std::vector< Cell2D_t >::iterator vCell2D_i
TGLAxisPainter fAxisPainter
void DrawHistBase(TGLRnrCtx &rnrCtx) const
Draw basic histogram components: x-y grid.
Concrete physical shape - a GL drawable.
void PrepareCell2DData(TEveCaloData::vCellId_t &cellList, vCell2D_t &cells2D) const
Prepare cells 2D data non-rebinned for drawing.
void Make3DDisplayList(TEveCaloData::vCellId_t &cellList, SliceDLMap_t &map, Bool_t select) const
Create display-list that draws histogram bars for non-rebinned data.
void RebinAxis(TAxis *orig, TAxis *curr) const
Rebin eta, phi axis.
Double_t x[n]
Definition: legend1.C:17
#define ClassDef(name, id)
Definition: Rtypes.h:320
virtual Bool_t SupportsSecondarySelect() const
SliceDLMap_t fDLMap
Int_t fCurrentPixelsPerBin
Float_t GetPhiMin() const
Definition: TEveCalo.h:144
TEveVector fXAxisTitlePos
void DrawCells2D(TGLRnrCtx &rnrCtx, vCell2D_t &cells2D) const
Draw cells in top view.
void DrawAxis2D(TGLRnrCtx &rnrCtx) const
Draw XY axis.
Base-class for direct OpenGL renderers.
Definition: TGLObject.h:21
TEveVector fYAxisTitlePos
std::vector< CellId_t > vCellId_t
Definition: TEveCaloData.h:146
XFontStruct * id
Definition: TGX11.cxx:108
constexpr Double_t Pi()
Definition: TMath.h:40
void GetScaleForMatrix(Float_t &sx, Float_t &sy, Float_t &sz) const
Get scale for matrix.
TEveCaloData::RebinData_t fRebinData
short Color_t
Definition: RtypesCore.h:79
TEveVector fBackPlaneYConst[2]
void DrawAxis3D(TGLRnrCtx &rnrCtx) const
Draw z-axis and z-box at the appropriate grid corner-point including tick-marks and labels...
void SetAxis3DTitlePos(TGLRnrCtx &rnrCtx, Float_t x0, Float_t x1, Float_t y0, Float_t y1) const
Set the axis 3D title position.
virtual void DLCacheDrop()
Drop all display-list definitions.
TEveCaloLego * fM
Class to manage histogram axis.
Definition: TAxis.h:30
Color_t fFontColor
Standard selection record including information about containing scene and details ob out selected ob...
void WrapTwoPi(Float_t &min, Float_t &max) const
void SetGeom(Float_t x0, Float_t x1, Float_t y0, Float_t y1)
std::map< Int_t, UInt_t > SliceDLMap_t
virtual void DrawHighlight(TGLRnrCtx &rnrCtx, const TGLPhysicalShape *ps, Int_t lvl=-1) const
Draw highligted cells.
TEveCaloLegoGL & operator=(const TEveCaloLegoGL &)
virtual void SetBBox()
Set bounding box.
std::vector< Cell2D_t > vCell2D_t
Visualization of calorimeter data as eta/phi histogram.
Definition: TEveCalo.h:249
static const double x1[5]
virtual Bool_t AlwaysSecondarySelect() const
Double_t y[n]
Definition: legend1.C:17
std::map< Int_t, UInt_t >::iterator SliceDLMap_i
Mother of all ROOT objects.
Definition: TObject.h:37
virtual Bool_t SetModel(TObject *obj, const Option_t *opt=0)
Set model object.
you should not use this method at all Int_t Int_t z
Definition: TRolke.cxx:630
virtual void ProcessSelection(TGLRnrCtx &rnrCtx, TGLSelectRecord &rec)
Processes tower selection from TGLViewer.
Int_t GetGridStep(TGLRnrCtx &rnrCtx) const
Calculate view-dependent grid density.
TEveVector fBackPlaneXConst[2]
virtual void DirectDraw(TGLRnrCtx &rnrCtx) const
Draw the object.
TEveVector fZAxisTitlePos
GL-overlay control GUI for TEveCaloLego.
const Bool_t kTRUE
Definition: RtypesCore.h:87
vCell2D_t fCells2D
Cell2D_t(Int_t id, Float_t sumVal, Int_t maxSlice)