GSI Object Oriented Online Offline (Go4)  GO4-6.2.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
TGo4ShapedCond.h
Go to the documentation of this file.
1 // $Id: TGo4ShapedCond.h 3493 2022-01-21 14:58:25Z linev $
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()
82  {
83  switch(fiShapeType)
84  {
85  case Go4Cond_Shape_Free:
86  return "Free style polygon";
88  return "Circle shaped polygon";
90  return "Ellipse shaped polygon";
91  case Go4Cond_Shape_Box:
92  return "Rectangular box shaped polygon";
93  case Go4Cond_Shape_None:
94  return "Shape not defined!";
95  };
96  return 0;
97  }
98 
99  /* Retrieve current center coordinates*/
100  void GetCenter(Double_t& x, Double_t& y)
101  {
102  x = fdCenterX;
103  y = fdCenterY;
104  }
105 
106  /* Set Center coordinates and recalculate polygon*/
107  void SetCenter(Double_t x, Double_t y);
108 
109  /* Retrieve ellipse half axis coordinates*/
110  void GetRadius(Double_t& a1, Double_t& a2)
111  {
112  a1 = fdRadius1;
113  a2 = fdRadius2;
114  }
115 
116  /* Set Center coordinates and recalculate polygon*/
117  void SetRadius(Double_t a1, Double_t a2);
118 
119  /* get current ellipse tilt angle in degrees*/
120  Double_t GetTheta()
121  {
122  return fdTheta;
123  }
124 
125  /* change ellipse tilt angle and recalculate polygon*/
126  void SetTheta(Double_t angle);
127 
128 
130  virtual void PrintCondition(Bool_t points = kTRUE);
131 
134  Bool_t UpdateFrom(TGo4Condition * cond, Bool_t counts);
135 
137  virtual Bool_t UpdateFromUrl(const char* rest_url_opt);
138 
139  Bool_t IsShapedType()
140  {
141  return kTRUE;
142  }
143 
144  void SetResolution(Int_t npoints)
145  {
146  fiResolution=npoints;
147  }
148 
150  {
151  return fiResolution;
152  }
153 
155  static TString fgxURL_RESOLUTION;
157  static TString fgxURL_CX;
159  static TString fgxURL_CY;
161  static TString fgxURL_A1;
163  static TString fgxURL_A2;
165  static TString fgxURL_TH;
167  static TString fgxURL_SHAPE;
168 
169 
170  protected:
171 
172  /* This function will evaluate new polygon points whenever an ellipse parameter is changed.*/
173  void ResetPolygon();
174 
175  /* evaluate polygon array to form elliptical/circular shapes*/
176  void DefineEllipse(Double_t *x, Double_t *y, Int_t n);
177 
178  /* evaluate polygon array to form box shapes*/
179  void DefineBox(Double_t *x, Double_t *y, Int_t n);
180 
181  private:
182 
183  Int_t fiResolution; //< number of polygon points to render
184  Double_t fdCenterX; //< centroid coordinate X
185  Double_t fdCenterY; //< centroid coordinate Y
186 
187  Double_t fdRadius1; //< ellipse/box first half axis
188  Double_t fdRadius2; //< ellipse/box second half axis
189 
190  Double_t fdTheta; //< ellipse tilt angle
191  Go4CondShape_t fiShapeType; //< type of shaped form
192 
193  ClassDef(TGo4ShapedCond,1)
194 };
195 
196 #define TGo4EllipseCond TGo4ShapedCond
197 
198 /* < this is for simple backward compatibility and better than typedef*/
199 
200 #endif //TGO4SHAPEDCOND_H
void SetTheta(Double_t angle)
void GetRadius(Double_t &a1, Double_t &a2)
Double_t fdCenterX
static TString fgxURL_TH
void DefineEllipse(Double_t *x, Double_t *y, Int_t n)
Bool_t IsCircle() const
static TString fgxURL_SHAPE
const char * GetShapeName()
Bool_t IsFreeShape() const
Double_t fdRadius2
Bool_t UpdateFrom(TGo4Condition *cond, Bool_t counts)
static TString fgxURL_A1
Bool_t IsEllipse() const
void SetResolution(Int_t npoints)
void DefineBox(Double_t *x, Double_t *y, Int_t n)
Int_t GetResolution()
void SetRadius(Double_t a1, Double_t a2)
Bool_t IsBox() const
void SetCenter(Double_t x, Double_t y)
Bool_t IsShapedType()
virtual Bool_t UpdateFromUrl(const char *rest_url_opt)
static TString fgxURL_CY
static TString fgxURL_CX
static TString fgxURL_A2
virtual void PrintCondition(Bool_t points=kTRUE)
Double_t fdRadius1
void GetCenter(Double_t &x, Double_t &y)
static TString fgxURL_RESOLUTION
Double_t fdCenterY
Go4CondShape_t fiShapeType
Double_t GetTheta()
virtual ~TGo4ShapedCond()
Go4CondShape_t