GSI Object Oriented Online Offline (Go4)  GO4-5.3.2
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
TGo4ShapedCond.h
Go to the documentation of this file.
1 // $Id: TGo4ShapedCond.h 1581 2015-06-16 15:24:41Z 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 für 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 
49  /* Delete old cut values and redefine them as elliptical shape.
50  * Parameters: center coordinates cx,cy
51  * half axes a1,a2
52  * tilt angle theta
53  * number of polygon points npoints (0 uses default granularity)*/
54  void SetEllipse(Double_t cx, Double_t cy, Double_t a1, Double_t a2, Double_t theta=0, Int_t npoints=0);
55 
56  /* Delete old cut values and redefine them as circular shape.
57  * Parameters: center coordinates cx,cy
58  * radius r
59  * number of polygon points npoints (0 uses default granularity)*/
60  void SetCircle(Double_t cx, Double_t cy, Double_t r, Int_t npoints=0);
61 
62 
63 
64  /* Delete old cut values and redefine them as tilted box shape.
65  * Parameters: center coordinates cx,cy
66  * half axes a1,a2
67  * tilt angle theta
68  * number of polygon points is always 5 for box*/
69  void SetBox(Double_t cx, Double_t cy, Double_t a1, Double_t a2, Double_t theta=0);
70 
71 
72 
73  /* mark this ellipse as circle type. usefull for condition editor display*/
74  void SetCircle()
75  {
77  }
78  Bool_t IsCircle()
79  {
81  }
82  void SetEllipse()
83  {
85  }
86  Bool_t IsEllipse()
87  {
89  }
90 
91  void SetBox()
92  {
94  }
95  Bool_t IsBox()
96  {
98  }
99 
101  {
103  }
104  Bool_t IsFreeShape()
105  {
107  }
108 
109 
110  const char* GetShapeName()
111  {
112  switch(fiShapeType)
113  {
114  case Go4Cond_Shape_Free:
115  return "Free style polygon";
116  break;
118  return "Circle shaped polygon";
119  break;
121  return "Ellipse shaped polygon";
122  break;
123  case Go4Cond_Shape_Box:
124  return "Rectangular box shaped polygon";
125  break;
126  default:
127  return "Shape not defined!";
128  break;
129  };
130  return 0;
131 
132  }
133 
134  /* Retrieve current center coordinates*/
135  void GetCenter(Double_t& x, Double_t& y)
136  {
137  x=fdCenterX;
138  y=fdCenterY;
139  }
140 
141  /* Set Center coordinates and recalculate polygon*/
142  void SetCenter(Double_t x, Double_t y);
143 
144  /* Retrieve ellipse half axis coordinates*/
145  void GetRadius(Double_t& a1, Double_t& a2)
146  {
147  a1=fdRadius1;
148  a2=fdRadius2;
149  }
150 
151  /* Set Center coordinates and recalculate polygon*/
152  void SetRadius(Double_t a1, Double_t a2);
153 
154  /* get current ellipse tilt angle in degrees*/
155  Double_t GetTheta(){
156  return fdTheta;
157  }
158 
159  /* change ellipse tilt angle and recalculate polygon*/
160  void SetTheta(Double_t angle);
161 
162 
164  virtual void PrintCondition(Bool_t points = kTRUE);
165 
168  Bool_t UpdateFrom(TGo4Condition * cond, Bool_t counts);
169 
171  virtual Bool_t UpdateFromUrl(const char* rest_url_opt);
172 
173  Bool_t IsShapedType()
174  {
175  return kTRUE;
176  }
177 
178  void SetResolution(Int_t npoints)
179  {
180  fiResolution=npoints;
181  }
182 
183  Int_t GetResolution(){
184  return fiResolution;
185  }
186 
188  static TString fgxURL_RESOLUTION;
190  static TString fgxURL_CX;
192  static TString fgxURL_CY;
194  static TString fgxURL_A1;
196  static TString fgxURL_A2;
198  static TString fgxURL_TH;
200  static TString fgxURL_SHAPE;
201 
202 
203  protected:
204 
205  /* This function will evaluate new polygon points whenever an ellipse parameter is changed.*/
206  void ResetPolygon();
207 
208  /* evaluate polygon array to form elliptical/circular shapes*/
209  void DefineEllipse(Double_t *x, Double_t *y, Int_t n);
210 
211  /* evaluate polygon array to form box shapes*/
212  void DefineBox(Double_t *x, Double_t *y, Int_t n);
213 
214  private:
215 
216  Int_t fiResolution; //< number of polygon points to render
217  Double_t fdCenterX; //< centroid coordinate X
218  Double_t fdCenterY; //< centroid coordinate Y
219 
220  Double_t fdRadius1; //< ellipse/box first half axis
221  Double_t fdRadius2; //< ellipse/box second half axis
222 
223  Double_t fdTheta; //< ellipse tilt angle
224  Go4CondShape_t fiShapeType; //< type of shaped form
225 
226  ClassDef(TGo4ShapedCond,1)
227 };
228 
229 #define TGo4EllipseCond TGo4ShapedCond
230 
231 /* < this is for simple backward compatibility and better than typedef*/
232 
233 #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)
static TString fgxURL_SHAPE
const char * GetShapeName()
Bool_t IsCircle()
Double_t fdRadius2
Bool_t UpdateFrom(TGo4Condition *cond, Bool_t counts)
static TString fgxURL_A1
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)
void SetCenter(Double_t x, Double_t y)
Bool_t IsShapedType()
virtual Bool_t UpdateFromUrl(const char *rest_url_opt)
Bool_t IsEllipse()
static TString fgxURL_CY
Bool_t IsFreeShape()
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