ROOT  6.06/09
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 //______________________________________________________________________________
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
The TGLRnrCtx class aggregates data for a given redering context as needed by various parts of the RO...
Definition: TGLRnrCtx.h:40
virtual void DrawHighlight(TGLRnrCtx &rnrCtx, const TGLPhysicalShape *ps, Int_t lvl=-1) const
Draw highligted cells.
static Vc_ALWAYS_INLINE int_v min(const int_v &x, const int_v &y)
Definition: vector.h:433
virtual Bool_t SupportsSecondarySelect() const
Float_t fValToPixel
float Float_t
Definition: RtypesCore.h:53
virtual ~TEveCaloLegoGL()
Destructor.
const char Option_t
Definition: RtypesCore.h:62
virtual void DLCachePurge()
Unregister all display-lists.
void Make3DDisplayListRebin(TEveCaloData::RebinData_t &rebinData, SliceDLMap_t &map, Bool_t select) const
Create display-list that draws histogram bars for rebinned data.
OpenGL renderer class for TEveCaloLego.
Color_t fGridColor
void PrepareCell2DData(TEveCaloData::vCellId_t &cellList, vCell2D_t &cells2D) const
Prepare cells 2D data non-rebinned for drawing.
TEveCaloLegoGL()
Constructor.
Bool_t GetWrapTwoPi() const
Definition: TEveCaloData.h:227
Short_t Min(Short_t a, Short_t b)
Definition: TMathBase.h:170
int Int_t
Definition: RtypesCore.h:41
bool Bool_t
Definition: RtypesCore.h:59
std::vector< Cell2D_t >::iterator vCell2D_i
TGLAxisPainter fAxisPainter
Concrete physical shape - a GL drawable.
void DrawHistBase(TGLRnrCtx &rnrCtx) const
Draw basic histogram components: x-y grid.
virtual void DirectDraw(TGLRnrCtx &rnrCtx) const
Draw the object.
Int_t GetGridStep(TGLRnrCtx &rnrCtx) const
Calculate view-dependent grid density.
Double_t x[n]
Definition: legend1.C:17
SliceDLMap_t fDLMap
Int_t fCurrentPixelsPerBin
void DrawCells3D(TGLRnrCtx &rnrCtx) const
Render the calo lego-plot with OpenGL.
TEveVector fXAxisTitlePos
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
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.
Double_t TwoPi()
Definition: TMath.h:45
void DrawCells2D(TGLRnrCtx &rnrCtx, vCell2D_t &cells2D) const
Draw cells in top view.
void PrepareCell2DDataRebin(TEveCaloData::RebinData_t &rebinData, vCell2D_t &cells2D) const
Prepare cells 2D rebinned data for drawing.
TEveCaloData::RebinData_t fRebinData
short Color_t
Definition: RtypesCore.h:79
TEveVector fBackPlaneYConst[2]
virtual void DLCacheDrop()
Drop all display-list definitions.
void GetScaleForMatrix(Float_t &sx, Float_t &sy, Float_t &sz) const
Get scale for matrix.
ClassDef(TEveCaloLegoGL, 0)
TEveCaloData * GetData() const
Definition: TEveCalo.h:86
TEveCaloLego * fM
Class to manage histogram axis.
Definition: TAxis.h:36
Color_t fFontColor
void WrapTwoPi(Float_t &min, Float_t &max) const
Standard selection record including information about containing scene and details ob out selected ob...
Float_t GetPhiMin() const
Definition: TEveCalo.h:144
virtual Bool_t AlwaysSecondarySelect() const
void SetGeom(Float_t x0, Float_t x1, Float_t y0, Float_t y1)
std::map< Int_t, UInt_t > SliceDLMap_t
void DrawAxis3D(TGLRnrCtx &rnrCtx) const
Draw z-axis and z-box at the appropriate grid corner-point including tick-marks and labels...
void Make3DDisplayList(TEveCaloData::vCellId_t &cellList, SliceDLMap_t &map, Bool_t select) const
Create display-list that draws histogram bars for non-rebinned data.
TEveCaloLegoGL & operator=(const TEveCaloLegoGL &)
virtual void SetBBox()
Set bounding box.
std::vector< Cell2D_t > vCell2D_t
Double_t Pi()
Definition: TMath.h:44
Visualization of calorimeter data as eta/phi histogram.
Definition: TEveCalo.h:249
static const double x1[5]
void DrawAxis2D(TGLRnrCtx &rnrCtx) const
Draw XY axis.
Float_t GetPhiMax() const
Definition: TEveCalo.h:145
Double_t y[n]
Definition: legend1.C:17
std::map< Int_t, UInt_t >::iterator SliceDLMap_i
static Vc_ALWAYS_INLINE int_v max(const int_v &x, const int_v &y)
Definition: vector.h:440
Mother of all ROOT objects.
Definition: TObject.h:58
virtual Bool_t SetModel(TObject *obj, const Option_t *opt=0)
Set model object.
virtual void ProcessSelection(TGLRnrCtx &rnrCtx, TGLSelectRecord &rec)
Processes tower selection from TGLViewer.
void DrawSelectedCells(TGLRnrCtx &rnrCtx, TEveCaloData::vCellId_t cells) const
Draw selected cells in highlight mode.
TEveVector fBackPlaneXConst[2]
void SetAxis3DTitlePos(TGLRnrCtx &rnrCtx, Float_t x0, Float_t x1, Float_t y0, Float_t y1) const
Set the axis 3D title position.
TEveVector fZAxisTitlePos
const Bool_t kTRUE
Definition: Rtypes.h:91
TObject * obj
GL-overlay control GUI for TEveCaloLego.
void RebinAxis(TAxis *orig, TAxis *curr) const
Rebin eta, phi axis.
vCell2D_t fCells2D
Cell2D_t(Int_t id, Float_t sumVal, Int_t maxSlice)