Logo ROOT  
Reference Guide
REveUtil.hxx
Go to the documentation of this file.
1 // @(#)root/eve7:$Id$
2 // Authors: Matevz Tadel & Alja Mrak-Tadel: 2006, 2007
3 
4 /*************************************************************************
5  * Copyright (C) 1995-2019, 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 ROOT7_REveUtil
13 #define ROOT7_REveUtil
14 
15 #include "REveTypes.hxx"
16 
17 #include "TError.h"
18 
19 #include <map>
20 #include <set>
21 #include <exception>
22 
23 class TGeoManager;
24 
25 namespace ROOT {
26 namespace Experimental {
27 
28 class REveElement;
29 
30 ////////////////////////////////////////////////////////////////////////////////
31 /// REveUtil
32 /// Standard utility functions for Reve.
33 ////////////////////////////////////////////////////////////////////////////////
34 
35 class REveUtil
36 {
37 private:
39 
40 public:
41  virtual ~REveUtil() {}
42 
43  // Macro functions
44 
45  static Bool_t CheckMacro(const char *mac);
46  static void AssertMacro(const char *mac);
47  static void Macro(const char *mac);
48  static void LoadMacro(const char *mac);
49 
50  // Color management
51 
52  static void ColorFromIdx(Color_t ci, UChar_t col[4], Bool_t alpha = kTRUE);
53  static void ColorFromIdx(Color_t ci, UChar_t col[4], Char_t transparency);
54  static void ColorFromIdx(Float_t f1, Color_t c1, Float_t f2, Color_t c2, UChar_t col[4], Bool_t alpha = kTRUE);
55  static Color_t *FindColorVar(TObject *obj, const char *varname);
56 
57  static void SetColorBrightness(Float_t value, Bool_t full_redraw = kFALSE);
58 
59  // Math utilities
60 
61  static Bool_t IsU1IntervalContainedByMinMax(Float_t minM, Float_t maxM, Float_t minQ, Float_t maxQ);
63 
64  static Bool_t IsU1IntervalContainedByMeanDelta(Float_t meanM, Float_t deltaM, Float_t meanQ, Float_t deltaQ);
65  static Bool_t IsU1IntervalOverlappingByMeanDelta(Float_t meanM, Float_t deltaM, Float_t meanQ, Float_t deltaQ);
66 
67  static Float_t GetFraction(Float_t minM, Float_t maxM, Float_t minQ, Float_t maxQ);
68 };
69 
71 {
72  return IsU1IntervalContainedByMinMax(meanM - deltaM, meanM + deltaM, meanQ - deltaQ, meanQ + deltaQ);
73 }
74 
76 {
77  return IsU1IntervalContainedByMinMax(meanM - deltaM, meanM + deltaM, meanQ - deltaQ, meanQ + deltaQ);
78 }
79 
80 
81 ////////////////////////////////////////////////////////////////////////////////
82 /// REveGeoManagerHolder
83 /// Exception-safe global variable holders
84 ////////////////////////////////////////////////////////////////////////////////
85 
87 {
88 private:
89  TGeoManager *fManager{nullptr}; ///<! hold manager
90  Int_t fNSegments{0}; ///<! previous settings for num segments
91 
92 public:
93  REveGeoManagerHolder(TGeoManager *new_gmgr = nullptr, Int_t n_seg = 0);
95 };
96 
97 ////////////////////////////////////////////////////////////////////////////////
98 /// REveRefCnt
99 /// REveRefCnt base-class (interface)
100 ////////////////////////////////////////////////////////////////////////////////
101 
103 {
104 protected:
106 
107 public:
108  REveRefCnt() = default;
109  virtual ~REveRefCnt() {}
110 
111  REveRefCnt(const REveRefCnt &) : fRefCount(0) {}
112  REveRefCnt &operator=(const REveRefCnt &) { return *this; }
113 
114  void IncRefCount() { ++fRefCount; }
115  void DecRefCount()
116  {
117  if (--fRefCount <= 0)
118  OnZeroRefCount();
119  }
120 
121  virtual void OnZeroRefCount() { delete this; }
122 };
123 
124 ////////////////////////////////////////////////////////////////////////////////
125 /// REveRefBackPtr
126 /// reference-count with back pointers
127 ////////////////////////////////////////////////////////////////////////////////
128 
130 {
131 protected:
132  typedef std::map<REveElement *, Int_t> RefMap_t;
133 
135 
136 public:
137  REveRefBackPtr();
138  virtual ~REveRefBackPtr();
139 
142 
145  virtual void IncRefCount(REveElement *re);
146  virtual void DecRefCount(REveElement *re);
147 
148  virtual void StampBackPtrElements(UChar_t stamps);
149 };
150 
151 } // namespace Experimental
152 } // namespace ROOT
153 
154 #endif
ROOT::Experimental::REveGeoManagerHolder::~REveGeoManagerHolder
~REveGeoManagerHolder()
Destructor.
Definition: REveUtil.cxx:360
ROOT::Experimental::REveRefCnt::fRefCount
Int_t fRefCount
Definition: REveUtil.hxx:105
kTRUE
const Bool_t kTRUE
Definition: RtypesCore.h:91
TObjArray
An array of TObjects.
Definition: TObjArray.h:37
ROOT::Experimental::REveUtil::LoadMacro
static void LoadMacro(const char *mac)
Makes sure that macro 'mac' is loaded, but do not reload it.
Definition: REveUtil.cxx:105
Float_t
float Float_t
Definition: RtypesCore.h:57
ROOT::Experimental::REveRefBackPtr::DecRefCount
void DecRefCount()
Definition: REveUtil.hxx:115
ROOT::Experimental::REveRefCnt::DecRefCount
void DecRefCount()
Definition: REveUtil.hxx:115
Int_t
int Int_t
Definition: RtypesCore.h:45
ROOT::Experimental::REveUtil::CheckMacro
static Bool_t CheckMacro(const char *mac)
Checks if macro 'mac' is loaded.
Definition: REveUtil.cxx:65
ROOT::Experimental::REveRefBackPtr::~REveRefBackPtr
virtual ~REveRefBackPtr()
Destructor. Noop, should complain if back-ref list is not empty.
Definition: REveUtil.cxx:397
ROOT::Experimental::REveRefBackPtr::StampBackPtrElements
virtual void StampBackPtrElements(UChar_t stamps)
Add given stamps to elements in the list of reverse references.
Definition: REveUtil.cxx:449
ROOT::Experimental::REveRefCnt
REveRefCnt REveRefCnt base-class (interface)
Definition: REveUtil.hxx:103
ROOT::Experimental::REveElement
Definition: REveElement.hxx:41
Bool_t
bool Bool_t
Definition: RtypesCore.h:63
ROOT::Experimental::REveUtil::IsU1IntervalContainedByMeanDelta
static Bool_t IsU1IntervalContainedByMeanDelta(Float_t meanM, Float_t deltaM, Float_t meanQ, Float_t deltaQ)
Definition: REveUtil.hxx:70
Color_t
short Color_t
Definition: RtypesCore.h:83
ROOT::Experimental::REveRefCnt::operator=
REveRefCnt & operator=(const REveRefCnt &)
Definition: REveUtil.hxx:112
REveTypes.hxx
bool
ROOT::Experimental::REveUtil::SetColorBrightness
static void SetColorBrightness(Float_t value, Bool_t full_redraw=kFALSE)
Tweak all ROOT colors to become brighter (if value > 0) or darker (value < 0).
Definition: REveUtil.cxx:205
ROOT::Experimental::REveRefBackPtr::REveRefBackPtr
REveRefBackPtr()
Default constructor.
Definition: REveUtil.cxx:388
ROOT::Experimental::REveUtil::Macro
static void Macro(const char *mac)
Execute macro 'mac'. Do not reload the macro.
Definition: REveUtil.cxx:93
ROOT::Experimental::REveUtil::IsU1IntervalOverlappingByMinMax
static Bool_t IsU1IntervalOverlappingByMinMax(Float_t minM, Float_t maxM, Float_t minQ, Float_t maxQ)
Return true if interval Q is overlapping within interval M for U1 variables.
Definition: REveUtil.cxx:292
ROOT::Experimental::REveUtil::fgDefaultColors
static TObjArray * fgDefaultColors
Definition: REveUtil.hxx:38
ROOT::Experimental::REveGeoManagerHolder::fManager
TGeoManager * fManager
! hold manager
Definition: REveUtil.hxx:89
kFALSE
const Bool_t kFALSE
Definition: RtypesCore.h:92
ROOT::Experimental::REveRefBackPtr::RefMap_t
std::map< REveElement *, Int_t > RefMap_t
Definition: REveUtil.hxx:132
ROOT::Experimental::REveRefBackPtr
REveRefBackPtr reference-count with back pointers.
Definition: REveUtil.hxx:130
ROOT::Experimental::REveUtil::IsU1IntervalContainedByMinMax
static Bool_t IsU1IntervalContainedByMinMax(Float_t minM, Float_t maxM, Float_t minQ, Float_t maxQ)
Return true if interval Q is contained within interval M for U1 variables.
Definition: REveUtil.cxx:271
ROOT::Experimental::REveRefCnt::REveRefCnt
REveRefCnt(const REveRefCnt &)
Definition: REveUtil.hxx:111
ROOT::Experimental::REveRefCnt::OnZeroRefCount
virtual void OnZeroRefCount()
Definition: REveUtil.hxx:121
ROOT::Experimental::REveGeoManagerHolder::REveGeoManagerHolder
REveGeoManagerHolder(TGeoManager *new_gmgr=nullptr, Int_t n_seg=0)
Constructor.
Definition: REveUtil.cxx:341
ROOT::Experimental::REveUtil::GetFraction
static Float_t GetFraction(Float_t minM, Float_t maxM, Float_t minQ, Float_t maxQ)
Get fraction of interval [minQ, maxQ] in [minM, maxM].
Definition: REveUtil.cxx:311
ROOT::Experimental::REveRefBackPtr::operator=
REveRefBackPtr & operator=(const REveRefBackPtr &)
Assignment operator.
Definition: REveUtil.cxx:417
f1
TF1 * f1
Definition: legend1.C:11
ROOT::Experimental::REveUtil::ColorFromIdx
static void ColorFromIdx(Color_t ci, UChar_t col[4], Bool_t alpha=kTRUE)
Fill col with RGBA values corresponding to index ci.
Definition: REveUtil.cxx:117
ROOT::Experimental::REveUtil::IsU1IntervalOverlappingByMeanDelta
static Bool_t IsU1IntervalOverlappingByMeanDelta(Float_t meanM, Float_t deltaM, Float_t meanQ, Float_t deltaQ)
Definition: REveUtil.hxx:75
UChar_t
unsigned char UChar_t
Definition: RtypesCore.h:38
ROOT::Experimental::REveGeoManagerHolder
REveGeoManagerHolder Exception-safe global variable holders.
Definition: REveUtil.hxx:87
TObject
Mother of all ROOT objects.
Definition: TObject.h:37
ROOT::Experimental::REveUtil::FindColorVar
static Color_t * FindColorVar(TObject *obj, const char *varname)
Find address of Color_t data-member with name varname in object obj.
Definition: REveUtil.cxx:186
c2
return c2
Definition: legend2.C:14
ROOT::Experimental::REveRefBackPtr::fBackRefs
RefMap_t fBackRefs
Definition: REveUtil.hxx:134
ROOT::Experimental::REveRefCnt::IncRefCount
void IncRefCount()
Definition: REveUtil.hxx:114
ROOT::Experimental::REveUtil
REveUtil Standard utility functions for Reve.
Definition: REveUtil.hxx:36
Char_t
char Char_t
Definition: RtypesCore.h:33
TGeoManager
The manager class for any TGeo geometry.
Definition: TGeoManager.h:45
ROOT::Experimental::REveRefBackPtr::IncRefCount
void IncRefCount()
Definition: REveUtil.hxx:114
ROOT::Experimental::REveUtil::~REveUtil
virtual ~REveUtil()
Definition: REveUtil.hxx:41
ROOT
VSD Structures.
Definition: StringConv.hxx:21
ROOT::Experimental::REveRefCnt::REveRefCnt
REveRefCnt()=default
ROOT::Experimental::REveRefCnt::~REveRefCnt
virtual ~REveRefCnt()
Definition: REveUtil.hxx:109
ROOT::Experimental::REveGeoManagerHolder::fNSegments
Int_t fNSegments
! previous settings for num segments
Definition: REveUtil.hxx:90
ROOT::Experimental::REveUtil::AssertMacro
static void AssertMacro(const char *mac)
Load and execute macro 'mac' if it has not been loaded yet.
Definition: REveUtil.cxx:83
int
TError.h
c1
return c1
Definition: legend1.C:41