Logo ROOT   6.30.04
Reference Guide
 All Namespaces Files Pages
TEveCalo.h
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 #ifndef ROOT_TEveCalo
13 #define ROOT_TEveCalo
14 
15 #include "TEveElement.h"
16 #include "TEveProjectionBases.h"
17 #include "TEveProjectionManager.h"
18 
19 #include "TAtt3D.h"
20 #include "TAttBBox.h"
21 #include "TEveCaloData.h"
22 
23 class TClass;
24 class TEveRGBAPalette;
25 
26 class TEveCaloViz : public TEveElement,
27  public TNamed,
28  public TAtt3D,
29  public TAttBBox,
30  public TEveProjectable
31 {
32  friend class TEveCaloVizEditor;
33 
34 private:
35  TEveCaloViz(const TEveCaloViz&); // Not implemented
36  TEveCaloViz& operator=(const TEveCaloViz&); // Not implemented
37 
38 protected:
39  TEveCaloData* fData; // event data reference
40  Bool_t fCellIdCacheOK; // data cell ids cache state
41 
42  Double_t fEtaMin;
43  Double_t fEtaMax;
44 
45  Double_t fPhi;
46  Double_t fPhiOffset; // phi range +/- offset
47 
48  Bool_t fAutoRange; // set eta phi limits on DataChanged()
49 
50  Float_t fBarrelRadius; // barrel raidus in cm
51  Float_t fEndCapPosF; // forward end cap z coordinate in cm
52  Float_t fEndCapPosB; // backward end cap z coordinate in cm (should be < 0)
53 
54  Float_t fPlotEt; // plot E or Et.
55 
56  Float_t fMaxTowerH; // bounding box z dimesion
57  Bool_t fScaleAbs;
58  Float_t fMaxValAbs;
59 
60  Bool_t fValueIsColor; // Interpret signal value as RGBA color.
61  TEveRGBAPalette* fPalette; // Pointer to signal-color palette.
62 
63 
64  void AssignCaloVizParameters(TEveCaloViz* cv);
65 
66  void SetupColorHeight(Float_t value, Int_t slice, Float_t& height) const;
67 
68  virtual void BuildCellIdCache() = 0;
69 
70 public:
71  TEveCaloViz(TEveCaloData* data=0, const char* n="TEveCaloViz", const char* t="");
72 
73  virtual ~TEveCaloViz();
74 
75  virtual TEveElement* ForwardSelection();
76  virtual TEveElement* ForwardEdit();
77 
78  virtual void Paint(Option_t* option="");
79 
80  virtual TClass* ProjectedClass(const TEveProjection* p) const;
81  virtual Float_t GetValToHeight() const;
82  virtual void CellSelectionChanged() {}
83 
84  virtual void SetScaleAbs(Bool_t x) { fScaleAbs = x; }
85 
86  TEveCaloData* GetData() const { return fData; }
87  void SetData(TEveCaloData* d);
88  void DataChanged();
89  Float_t GetMaxVal() const;
90 
91  Bool_t AssertCellIdCache() const;
92  void InvalidateCellIdCache() { fCellIdCacheOK=kFALSE; ResetBBox(); };
93 
94  Float_t GetDataSliceThreshold(Int_t slice) const;
95  void SetDataSliceThreshold(Int_t slice, Float_t val);
96  Color_t GetDataSliceColor(Int_t slice) const;
97  void SetDataSliceColor(Int_t slice, Color_t col);
98 
99  Float_t GetBarrelRadius() const { return fBarrelRadius; }
100  void SetBarrelRadius(Float_t r) { fBarrelRadius = r; ResetBBox(); }
101  Float_t GetEndCapPos () const { return fEndCapPosF; } // get end cap position, assuming fEndCapPosF = -fEndCapPosB
102  Float_t GetForwardEndCapPos () const { return fEndCapPosF; }
103  Float_t GetBackwardEndCapPos () const { return fEndCapPosB; }
104  void SetEndCapPos (Float_t z) { fEndCapPosF = z; fEndCapPosB = -z; ResetBBox(); }
105  void SetForwardEndCapPos (Float_t z) { fEndCapPosF = z; ResetBBox(); }
106  void SetBackwardEndCapPos(Float_t z) { fEndCapPosB = z; ResetBBox(); }
107 
108  Bool_t GetPlotEt() const { return fPlotEt; }
109  void SetPlotEt(Bool_t x);
110 
111  void SetMaxTowerH(Float_t x) { fMaxTowerH = x; }
112  Float_t GetMaxTowerH() const { return fMaxTowerH; }
113  Bool_t GetScaleAbs() const { return fScaleAbs; }
114  void SetMaxValAbs(Float_t x) { fMaxValAbs = x; }
115  Float_t GetMaxValAbs() const { return fMaxValAbs; }
116 
117  Float_t GetTransitionEta() const;
118  Float_t GetTransitionEtaForward() const;
119  Float_t GetTransitionEtaBackward() const;
120  Float_t GetTransitionTheta() const;
121  Float_t GetTransitionThetaForward() const;
122  Float_t GetTransitionThetaBackward() const;
123 
124  TEveRGBAPalette* GetPalette() const { return fPalette; }
125  void SetPalette(TEveRGBAPalette* p);
126 
127  TEveRGBAPalette* AssertPalette();
128  Bool_t GetValueIsColor() const { return fValueIsColor;}
129  void SetValueIsColor(Bool_t x) { fValueIsColor = x;}
130 
131  Bool_t GetAutoRange() const { return fAutoRange; }
132  void SetAutoRange(Bool_t x) { fAutoRange = x; }
133 
134  void SetEta(Float_t l, Float_t u);
135  Float_t GetEta() const { return 0.5f*(fEtaMin+fEtaMax); }
136  Float_t GetEtaMin() const { return fEtaMin; }
137  Float_t GetEtaMax() const { return fEtaMax; }
138  Float_t GetEtaRng() const { return fEtaMax-fEtaMin; }
139 
140  void SetPhi(Float_t phi) { SetPhiWithRng(phi, fPhiOffset); }
141  void SetPhiRng(Float_t rng) { SetPhiWithRng(fPhi, rng); }
142  void SetPhiWithRng(Float_t x, Float_t r);
143  Float_t GetPhi() const { return fPhi; }
144  Float_t GetPhiMin() const { return fPhi-fPhiOffset; }
145  Float_t GetPhiMax() const { return fPhi+fPhiOffset; }
146  Float_t GetPhiRng() const { return 2.0f*fPhiOffset; }
147 
148  Bool_t CellInEtaPhiRng (TEveCaloData::CellData_t&) const;
149 
150  ClassDef(TEveCaloViz, 0); // Base-class for visualization of calorimeter eventdata.
151 };
152 
153 /**************************************************************************/
154 /**************************************************************************/
155 
156 class TEveCalo3D : public TEveCaloViz
157 {
158  friend class TEveCalo3DGL;
159 private:
160  TEveCalo3D(const TEveCalo3D&); // Not implemented
161  TEveCalo3D& operator=(const TEveCalo3D&); // Not implemented
162 
163 protected:
164  TEveCaloData::vCellId_t fCellList;
165 
166  Bool_t fRnrEndCapFrame;
167  Bool_t fRnrBarrelFrame;
168 
169  Float_t fFrameWidth;
170  Color_t fFrameColor;
171  Char_t fFrameTransparency;
172 
173  virtual void BuildCellIdCache();
174 
175 public:
176  TEveCalo3D(TEveCaloData* d=0, const char* n="TEveCalo3D", const char* t="xx");
177  virtual ~TEveCalo3D() {}
178  virtual void ComputeBBox();
179 
180  void SetFrameWidth(Float_t w) { fFrameWidth = w; }
181  Float_t GetFrameWidth() const { return fFrameWidth; }
182 
183  void SetRnrFrame(Bool_t e, Bool_t b) { fRnrEndCapFrame = e; fRnrBarrelFrame = b; }
184  void GetRnrFrame(Bool_t &e, Bool_t &b) const { e = fRnrEndCapFrame; b = fRnrBarrelFrame; }
185  void SetRnrEndCapFrame(Bool_t r) { fRnrEndCapFrame = r; }
186  void SetRnrBarrelFrame(Bool_t r) { fRnrBarrelFrame = r; }
187  Bool_t GetRnrEndCapFrame() const { return fRnrEndCapFrame; }
188  Bool_t GetRnrBarrelFrame() const { return fRnrBarrelFrame; }
189 
190  void SetFrameTransparency(Char_t x) { fFrameTransparency = x; }
191  Char_t GetFrameTransparency() const { return fFrameTransparency; }
192 
193  ClassDef(TEveCalo3D, 0); // Class for 3D visualization of calorimeter event data.
194 };
195 
196 /**************************************************************************/
197 /**************************************************************************/
198 
199 class TEveCalo2D : public TEveCaloViz,
200  public TEveProjected
201 {
202  friend class TEveCalo2DGL;
203 
204 public:
205  typedef std::vector<TEveCaloData::vCellId_t*> vBinCells_t;
206  typedef std::vector<TEveCaloData::vCellId_t*>::iterator vBinCells_i;
207 
208 private:
209  TEveCalo2D(const TEveCalo2D&); // Not implemented
210  TEveCalo2D& operator=(const TEveCalo2D&); // Not implemented
211 
212  TEveProjection::EPType_e fOldProjectionType;
213  void CellSelectionChangedInternal(TEveCaloData::vCellId_t& cells, std::vector<TEveCaloData::vCellId_t*>& cellLists);
214 
215 protected:
216  std::vector<TEveCaloData::vCellId_t*> fCellLists;
217 
218  std::vector<TEveCaloData::vCellId_t*> fCellListsSelected;
219  std::vector<TEveCaloData::vCellId_t*> fCellListsHighlighted;
220 
221  Float_t fMaxESumBin;
222  Float_t fMaxEtSumBin;
223 
224  virtual void BuildCellIdCache();
225 
226  virtual void SetDepthLocal(Float_t x) { fDepth = x; }
227 
228 public:
229  TEveCalo2D(const char* n="TEveCalo2D", const char* t="");
230  virtual ~TEveCalo2D();
231 
232  virtual void SetProjection(TEveProjectionManager* proj, TEveProjectable* model);
233  virtual void UpdateProjection();
234  virtual void ComputeBBox();
235 
236  virtual void CellSelectionChanged();
237 
238  virtual void SetScaleAbs(Bool_t);
239 
240  virtual Float_t GetValToHeight() const;
241 
242  const TEveCalo2D::vBinCells_t& GetBinLists() const { return fCellLists; }
243 
244  ClassDef(TEveCalo2D, 0); // Class for visualization of projected calorimeter event data.
245 };
246 /**************************************************************************/
247 /**************************************************************************/
248 
249 class TEveCaloLego : public TEveCaloViz
250 {
251  friend class TEveCaloLegoGL;
252  friend class TEveCaloLegoOverlay;
253 
254 public:
255  enum EProjection_e { kAuto, k3D, k2D };
256  enum E2DMode_e { kValColor, kValSize, kValSizeOutline };
257  enum EBoxMode_e { kNone, kFrontBack, kBack};
258 
259 private:
260  TEveCaloLego(const TEveCaloLego&); // Not implemented
261  TEveCaloLego& operator=(const TEveCaloLego&); // Not implemented
262 
263 protected:
264  TEveCaloData::vCellId_t fCellList;
265 
266  Color_t fFontColor;
267  Color_t fGridColor;
268  Color_t fPlaneColor;
269  Char_t fPlaneTransparency;
270 
271  Int_t fNZSteps; // Z axis label step in GeV
272  Float_t fZAxisStep;
273 
274  Bool_t fAutoRebin;
275  Int_t fPixelsPerBin;
276  Bool_t fNormalizeRebin;
277 
278  EProjection_e fProjection;
279  E2DMode_e f2DMode;
280  EBoxMode_e fBoxMode; // additional scale info
281 
282  Bool_t fDrawHPlane;
283  Float_t fHPlaneVal;
284 
285  Bool_t fHasFixedHeightIn2DMode;
286  Float_t fFixedHeightValIn2DMode; // 1% of whole height
287 
288  Int_t fDrawNumberCellPixels;
289  Int_t fCellPixelFontSize;
290 
291  virtual void BuildCellIdCache();
292 
293 public:
294  TEveCaloLego(TEveCaloData* data=0, const char* n="TEveCaloLego", const char* t="");
295  virtual ~TEveCaloLego(){}
296 
297  virtual void ComputeBBox();
298  virtual void SetData(TEveCaloData* d);
299 
300  Color_t GetFontColor() const { return fFontColor; }
301  void SetFontColor(Color_t ci) { fFontColor=ci; }
302 
303  Color_t GetGridColor() const { return fGridColor; }
304  void SetGridColor(Color_t ci) { fGridColor=ci; }
305 
306  Color_t GetPlaneColor() const { return fPlaneColor; }
307  void SetPlaneColor(Color_t ci) { fPlaneColor=ci; }
308 
309  Char_t GetPlaneTransparency() const { return fPlaneTransparency; }
310  void SetPlaneTransparency(Char_t t) { fPlaneTransparency=t; }
311 
312  Int_t GetNZSteps() const { return fNZSteps; }
313  void SetNZSteps(Int_t s) { fNZSteps = s;}
314 
315  Int_t GetPixelsPerBin() const { return fPixelsPerBin; }
316  void SetPixelsPerBin(Int_t bw) { fPixelsPerBin = bw; }
317 
318  Bool_t GetAutoRebin() const { return fAutoRebin; }
319  void SetAutoRebin(Bool_t s) { fAutoRebin = s;}
320 
321  Bool_t GetNormalizeRebin() const { return fNormalizeRebin; }
322  void SetNormalizeRebin(Bool_t s) { fNormalizeRebin = s; fCellIdCacheOK=kFALSE;}
323 
324  EProjection_e GetProjection() const { return fProjection; }
325  void SetProjection(EProjection_e p) { fProjection = p; }
326 
327  void Set2DMode(E2DMode_e p) { f2DMode = p; }
328  E2DMode_e Get2DMode() { return f2DMode; }
329 
330  bool GetHasFixedHeightIn2DMode() const { return fHasFixedHeightIn2DMode; }
331  void SetHasFixedHeightIn2DMode(bool x) { fHasFixedHeightIn2DMode = x; }
332 
333  float GetFixedHeightValIn2DMode() const { return fFixedHeightValIn2DMode; }
334  void SetFixedHeightValIn2DMode(float x) { fFixedHeightValIn2DMode = x; }
335 
336  void SetBoxMode(EBoxMode_e p) { fBoxMode = p; }
337  EBoxMode_e GetBoxMode() { return fBoxMode; }
338 
339  Bool_t GetDrawHPlane() const { return fDrawHPlane; }
340  void SetDrawHPlane(Bool_t s) { fDrawHPlane = s;}
341 
342  Float_t GetHPlaneVal() const { return fHPlaneVal; }
343  void SetHPlaneVal(Float_t s) { fHPlaneVal = s;}
344 
345  Int_t GetDrawNumberCellPixels() { return fDrawNumberCellPixels; }
346  void SetDrawNumberCellPixels(Int_t x) { fDrawNumberCellPixels = x; }
347  Int_t GetCellPixelFontSize() { return fCellPixelFontSize; }
348  void SetCellPixelFontSize(Int_t x) { fCellPixelFontSize = x; }
349 
350  ClassDef(TEveCaloLego, 0); // Class for visualization of calorimeter histogram data.
351 };
352 
353 #endif