GSI Object Oriented Online Offline (Go4) GO4-6.4.0
Loading...
Searching...
No Matches
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
19class TH1;
20class TH2;
21
22/* default number of points to render ellipse*/
23#define GO4ELLIPSECOND_DEFAULTRESOLUTION 180
24
33
42
43
45 public:
47
48 TGo4ShapedCond(const char *name, const char *title = "Go4 ellipse condition");
49
50 virtual ~TGo4ShapedCond();
51
52 /* Delete old cut values and redefine them as elliptical shape.
53 * Parameters: center coordinates cx,cy
54 * half axes a1,a2
55 * tilt angle theta
56 * number of polygon points npoints (0 uses default granularity)*/
57 void SetEllipse(Double_t cx, Double_t cy, Double_t a1, Double_t a2, Double_t theta = 0, Int_t npoints = 0);
58
59 /* Delete old cut values and redefine them as circular shape.
60 * Parameters: center coordinates cx,cy
61 * radius r
62 * number of polygon points npoints (0 uses default granularity)*/
63 void SetCircle(Double_t cx, Double_t cy, Double_t r, Int_t npoints = 0);
64
65 /* Delete old cut values and redefine them as tilted box shape.
66 * Parameters: center coordinates cx,cy
67 * half axes a1,a2
68 * tilt angle theta
69 * number of polygon points is always 5 for box*/
70 void SetBox(Double_t cx, Double_t cy, Double_t a1, Double_t a2, Double_t theta = 0);
71
72 /* mark this ellipse as circle type. useful for condition editor display*/
74 Bool_t IsCircle() const { return fiShapeType == Go4Cond_Shape_Circle; }
75
77 Bool_t IsEllipse() const { return fiShapeType == Go4Cond_Shape_Ellipse; }
78
80 Bool_t IsBox() const { return fiShapeType == Go4Cond_Shape_Box; }
81
83 Bool_t IsFreeShape() const { return fiShapeType == Go4Cond_Shape_Free; }
84
85 const char *GetShapeName() const
86 {
87 switch (fiShapeType) {
88 case Go4Cond_Shape_Free: return "Free style polygon";
89 case Go4Cond_Shape_Circle: return "Circle shaped polygon";
90 case Go4Cond_Shape_Ellipse: return "Ellipse shaped polygon";
91 case Go4Cond_Shape_Box: return "Rectangular box shaped polygon";
92 case Go4Cond_Shape_None: return "Shape not defined!";
93 };
94 return nullptr;
95 }
96
97 /* Retrieve current center coordinates*/
98 void GetCenter(Double_t& x, Double_t& y) const
99 {
100 x = fdCenterX;
101 y = fdCenterY;
102 }
103
104 /* Set Center coordinates and recalculate polygon*/
105 void SetCenter(Double_t x, Double_t y);
106
107 /* Retrieve ellipse half axis coordinates*/
108 void GetRadius(Double_t& a1, Double_t& a2) const
109 {
110 a1 = fdRadius1;
111 a2 = fdRadius2;
112 }
113
114 /* Set Center coordinates and recalculate polygon*/
115 void SetRadius(Double_t a1, Double_t a2);
116
117 /* get current ellipse tilt angle in degrees*/
118 Double_t GetTheta() const { return fdTheta; }
119
120 /* change ellipse tilt angle and recalculate polygon*/
121 void SetTheta(Double_t angle);
122
124 void PrintCondition(Bool_t points = kTRUE) override;
125
128 Bool_t UpdateFrom(TGo4Condition *cond, Bool_t counts) override;
129
131 Bool_t UpdateFromUrl(const char *rest_url_opt) override;
132
133 Bool_t IsShapedType() const { return kTRUE; }
134
135 void SetResolution(Int_t npoints) { fiResolution = npoints; }
136
137 Int_t GetResolution() const { return fiResolution; }
138
140 static TString fgxURL_RESOLUTION;
142 static TString fgxURL_CX;
144 static TString fgxURL_CY;
146 static TString fgxURL_A1;
148 static TString fgxURL_A2;
150 static TString fgxURL_TH;
152 static TString fgxURL_SHAPE;
153
154 protected:
155
156 /* This function will evaluate new polygon points whenever an ellipse parameter is changed.*/
157 void ResetPolygon();
158
159 /* evaluate polygon array to form elliptical/circular shapes*/
160 void DefineEllipse(Double_t *x, Double_t *y, Int_t n);
161
162 /* evaluate polygon array to form box shapes*/
163 void DefineBox(Double_t *x, Double_t *y, Int_t n);
164
165 private:
166
167 Int_t fiResolution{0}; //< number of polygon points to render
168 Double_t fdCenterX{0.}; //< centroid coordinate X
169 Double_t fdCenterY{0.}; //< centroid coordinate Y
170
171 Double_t fdRadius1{0.}; //< ellipse/box first half axis
172 Double_t fdRadius2{0.}; //< ellipse/box second half axis
173
174 Double_t fdTheta{0.}; //< ellipse tilt angle
176
177 ClassDefOverride(TGo4ShapedCond,1)
178};
179
181
182/* < this is for simple backward compatibility and better than typedef*/
183
184#endif //TGO4SHAPEDCOND_H
#define TGo4EllipseCond
Go4CondShape_t
@ Go4Cond_Shape_Box
@ Go4Cond_Shape_Free
@ Go4Cond_Shape_None
@ Go4Cond_Shape_Circle
@ Go4Cond_Shape_Ellipse
Go4 condition class.
Shaped condition.
void DefineEllipse(Double_t *x, Double_t *y, Int_t n)
Bool_t IsShapedType() const
Bool_t UpdateFromUrl(const char *rest_url_opt) override
Method used by HTTP server to update some fields, specified in URL syntax.
void SetTheta(Double_t angle)
Bool_t IsCircle() const
void DefineBox(Double_t *x, Double_t *y, Int_t n)
static TString fgxURL_A1
web condition editor keyword used in UpdateFromUrl.
void SetResolution(Int_t npoints)
void GetRadius(Double_t &a1, Double_t &a2) const
Bool_t IsBox() const
Bool_t UpdateFrom(TGo4Condition *cond, Bool_t counts) override
Copy values from cond to this.
Go4CondShape_t fiShapeType
void SetCenter(Double_t x, Double_t y)
const char * GetShapeName() const
Bool_t IsFreeShape() const
Double_t GetTheta() const
static TString fgxURL_A2
web condition editor keyword used in UpdateFromUrl.
static TString fgxURL_CX
web condition editor keyword used in UpdateFromUrl.
void GetCenter(Double_t &x, Double_t &y) const
Int_t GetResolution() const
static TString fgxURL_CY
web condition editor keyword used in UpdateFromUrl.
virtual ~TGo4ShapedCond()
void SetRadius(Double_t a1, Double_t a2)
static TString fgxURL_SHAPE
web condition editor keyword used in UpdateFromUrl.
static TString fgxURL_TH
web condition editor keyword used in UpdateFromUrl.
Bool_t IsEllipse() const
void PrintCondition(Bool_t points=kTRUE) override
Printout values.
static TString fgxURL_RESOLUTION
web condition editor keyword used in UpdateFromUrl.