GSI Object Oriented Online Offline (Go4)  GO4-6.3.0
TGo4ShapedCond.h
Go to the documentation of this file.
1 // $Id$
2 //-----------------------------------------------------------------------
3 // The GSI Online Offline Object Oriented (Go4) Project
4 // Experiment Data Processing at EE department, GSI
5 //-----------------------------------------------------------------------
6 // Copyright (C) 2000- GSI Helmholtzzentrum fuer Schwerionenforschung GmbH
7 // Planckstr. 1, 64291 Darmstadt, Germany
8 // Contact: http://go4.gsi.de
9 //-----------------------------------------------------------------------
10 // This software can be used under the license agreements as stated
11 // in Go4License.txt file which is part of the distribution.
12 //-----------------------------------------------------------------------
13 
14 #ifndef TGO4SHAPEDCOND_H
15 #define TGO4SHAPEDCOND_H
16 
17 #include "TGo4PolyCond.h"
18 
19 class TH1;
20 class TH2;
21 
22 /* default number of points to render ellipse*/
23 #define GO4ELLIPSECOND_DEFAULTRESOLUTION 180
24 
26 {
32 };
33 /*
34  * JAM Jan-2015
35  * New : specialized polygon condition for circular/elliptical shaped cuts.
36  * Benefit is setter methods with dedicated radius/ point parameters
37  *
38  * */
39 
40 class TGo4ShapedCond : public TGo4PolyCond {
41  public:
43 
44  TGo4ShapedCond(const char *name, const char *title = "Go4 ellipse condition");
45 
46  virtual ~TGo4ShapedCond();
47 
48  /* Delete old cut values and redefine them as elliptical shape.
49  * Parameters: center coordinates cx,cy
50  * half axes a1,a2
51  * tilt angle theta
52  * number of polygon points npoints (0 uses default granularity)*/
53  void SetEllipse(Double_t cx, Double_t cy, Double_t a1, Double_t a2, Double_t theta = 0, Int_t npoints = 0);
54 
55  /* Delete old cut values and redefine them as circular shape.
56  * Parameters: center coordinates cx,cy
57  * radius r
58  * number of polygon points npoints (0 uses default granularity)*/
59  void SetCircle(Double_t cx, Double_t cy, Double_t r, Int_t npoints = 0);
60 
61  /* Delete old cut values and redefine them as tilted box shape.
62  * Parameters: center coordinates cx,cy
63  * half axes a1,a2
64  * tilt angle theta
65  * number of polygon points is always 5 for box*/
66  void SetBox(Double_t cx, Double_t cy, Double_t a1, Double_t a2, Double_t theta = 0);
67 
68  /* mark this ellipse as circle type. useful for condition editor display*/
70  Bool_t IsCircle() const { return fiShapeType == Go4Cond_Shape_Circle; }
71 
73  Bool_t IsEllipse() const { return fiShapeType == Go4Cond_Shape_Ellipse; }
74 
76  Bool_t IsBox() const { return fiShapeType == Go4Cond_Shape_Box; }
77 
79  Bool_t IsFreeShape() const { return fiShapeType == Go4Cond_Shape_Free; }
80 
81  const char *GetShapeName() const
82  {
83  switch (fiShapeType) {
84  case Go4Cond_Shape_Free: return "Free style polygon";
85  case Go4Cond_Shape_Circle: return "Circle shaped polygon";
86  case Go4Cond_Shape_Ellipse: return "Ellipse shaped polygon";
87  case Go4Cond_Shape_Box: return "Rectangular box shaped polygon";
88  case Go4Cond_Shape_None: return "Shape not defined!";
89  };
90  return nullptr;
91  }
92 
93  /* Retrieve current center coordinates*/
94  void GetCenter(Double_t& x, Double_t& y) const
95  {
96  x = fdCenterX;
97  y = fdCenterY;
98  }
99 
100  /* Set Center coordinates and recalculate polygon*/
101  void SetCenter(Double_t x, Double_t y);
102 
103  /* Retrieve ellipse half axis coordinates*/
104  void GetRadius(Double_t& a1, Double_t& a2) const
105  {
106  a1 = fdRadius1;
107  a2 = fdRadius2;
108  }
109 
110  /* Set Center coordinates and recalculate polygon*/
111  void SetRadius(Double_t a1, Double_t a2);
112 
113  /* get current ellipse tilt angle in degrees*/
114  Double_t GetTheta() const { return fdTheta; }
115 
116  /* change ellipse tilt angle and recalculate polygon*/
117  void SetTheta(Double_t angle);
118 
120  void PrintCondition(Bool_t points = kTRUE) override;
121 
124  Bool_t UpdateFrom(TGo4Condition *cond, Bool_t counts) override;
125 
127  Bool_t UpdateFromUrl(const char *rest_url_opt) override;
128 
129  Bool_t IsShapedType() const { return kTRUE; }
130 
131  void SetResolution(Int_t npoints) { fiResolution = npoints; }
132 
133  Int_t GetResolution() const { return fiResolution; }
134 
136  static TString fgxURL_RESOLUTION;
138  static TString fgxURL_CX;
140  static TString fgxURL_CY;
142  static TString fgxURL_A1;
144  static TString fgxURL_A2;
146  static TString fgxURL_TH;
148  static TString fgxURL_SHAPE;
149 
150  protected:
151 
152  /* This function will evaluate new polygon points whenever an ellipse parameter is changed.*/
153  void ResetPolygon();
154 
155  /* evaluate polygon array to form elliptical/circular shapes*/
156  void DefineEllipse(Double_t *x, Double_t *y, Int_t n);
157 
158  /* evaluate polygon array to form box shapes*/
159  void DefineBox(Double_t *x, Double_t *y, Int_t n);
160 
161  private:
162 
163  Int_t fiResolution{0}; //< number of polygon points to render
164  Double_t fdCenterX{0.}; //< centroid coordinate X
165  Double_t fdCenterY{0.}; //< centroid coordinate Y
166 
167  Double_t fdRadius1{0.}; //< ellipse/box first half axis
168  Double_t fdRadius2{0.}; //< ellipse/box second half axis
169 
170  Double_t fdTheta{0.}; //< ellipse tilt angle
172 
173  ClassDefOverride(TGo4ShapedCond,1)
174 };
175 
177 
178 /* < this is for simple backward compatibility and better than typedef*/
179 
180 #endif //TGO4SHAPEDCOND_H
void SetTheta(Double_t angle)
Double_t fdCenterX
static TString fgxURL_TH
void DefineEllipse(Double_t *x, Double_t *y, Int_t n)
static TString fgxURL_SHAPE
void GetCenter(Double_t &x, Double_t &y) const
Double_t fdRadius2
static TString fgxURL_A1
void PrintCondition(Bool_t points=kTRUE) override
void SetResolution(Int_t npoints)
void DefineBox(Double_t *x, Double_t *y, Int_t n)
void SetRadius(Double_t a1, Double_t a2)
const char * GetShapeName() const
void SetCenter(Double_t x, Double_t y)
Bool_t UpdateFrom(TGo4Condition *cond, Bool_t counts) override
Bool_t IsCircle() const
Bool_t UpdateFromUrl(const char *rest_url_opt) override
Bool_t IsShapedType() const
Bool_t IsBox() const
Bool_t IsEllipse() const
static TString fgxURL_CY
static TString fgxURL_CX
static TString fgxURL_A2
Double_t GetTheta() const
Int_t GetResolution() const
void GetRadius(Double_t &a1, Double_t &a2) const
Double_t fdRadius1
static TString fgxURL_RESOLUTION
Double_t fdCenterY
Go4CondShape_t fiShapeType
Bool_t IsFreeShape() const
virtual ~TGo4ShapedCond()
TGo4ShapedCond TGo4EllipseCond
Go4CondShape_t