CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
global_angular.cc
Go to the documentation of this file.
1 
3 // GENERATED FILE. DO NOT MODIFY!
4 #include "global_angular.h"
5 // I tried the following on CERN lxplus and still no MAX_DOUBLE was defined.
6 // so I tried DBL_MAX which does exist, but I do not know the source of this.
7 // So, in keeping with everything else I saw:
8 #include <cfloat>
9 #define MAX_DOUBLE DBL_MAX
10 //#include <climits>
11 
12 #include "CLHEP/Units/GlobalSystemOfUnits.h"
13 #include <Math/RotationZ.h>
14 
15 
16  //your code here
17 
18 
19 // always the same ctor
21  : AlgoImpl(a,label),
22  rotate_(0), center_(3), rotateSolid_(0),
23  alignSolid_(true), n_(1), startCopyNo_(1), incrCopyNo_(1),
24  startAngle_(0), rangeAngle_(360.*deg)
25 {
26  DCOUT('A', "Creating angular label=" << label);
27 }
28 
30 { }
31 
32 
33 DD3Vector fUnitVector(double theta, double phi)
34 {
35  return DD3Vector(cos(phi)*sin(theta),
36  sin(phi)*sin(theta),
37  cos(theta));
38 }
39 
40 
42 {
43  bool result = true;
44 
47 
48  radius_ = ParE_["radius"][0];
49 
50  startAngle_ = ParE_["startAngle"][0];
51  rangeAngle_ = ParE_["rangeAngle"][0];
52  n_ = int(ParE_["n"][0]);
53  startCopyNo_ = int(ParE_["startCopyNo"][0]);
54  incrCopyNo_ = int(ParE_["incrCopyNo"][0]);
55 
56  if (fabs(rangeAngle_-360.0*deg)<0.001*deg) { // a full 360deg range
57  delta_ = rangeAngle_/double(n_);
58  }
59  else {
60  if (n_ > 1) {
61  delta_ = rangeAngle_/double(n_-1);
62  }
63  else {
64  delta_ = 0.;
65  }
66  }
67 
68  DCOUT('a', " startA=" << startAngle_/deg << " rangeA=" << rangeAngle_/deg <<
69  " n=" << n_ << " delta=" << delta_/deg);
70 
71  //======= collect data concerning the rotation of the solid
72  typedef parE_type::mapped_type::size_type sz_type;
73  sz_type sz = ParE_["rotateSolid"].size();
74  rotateSolid_.clear();
75  rotateSolid_.resize(sz);
76  if (sz%3) {
77  err_ += "\trotateSolid must occur 3*n times (defining n subsequent rotations)\n";
78  err_ += "\t currently it appears " + d2s(sz) + " times!\n";
79  result = false;
80  }
81  for (sz_type i=0; i<sz; ++i) {
82  rotateSolid_[i] = ParE_["rotateSolid"][i];
83  }
84  for (sz_type i=0; i<sz; i += 3 ) {
85  if ( (rotateSolid_[i] > 180.*deg) || (rotateSolid_[i] < 0.) ) {
86  err_ += "\trotateSolid \'theta\' must be in range [0,180*deg]\n";
87  err_ += "\t currently it is " + d2s(rotateSolid_[i]/deg)
88  + "*deg in rotateSolid[" + d2s(double(i)) + "]!\n";
89  result = false;
90  }
92  rotateSolid_[i+2]);
93  DCOUT('a', " rotsolid[" << i << "] axis=" << temp.Axis() << " rot.angle=" << temp.Angle()/deg);
94  solidRot_ = temp*solidRot_;
95  }
96  // DCOUT('a', " rotsolid axis=" << solidRot_.getAxis() << " rot.angle=" << solidRot_.delta()/deg);
97 
98 
99  //======== collect data concerning the rotation of the x-y plane
100  sz = ParE_["rotate"].size();
101  rotate_.clear();
102  rotate_.resize(sz);
103  if (sz%3) {
104  err_ += "\trotate must occur 3*n times (defining n subsequent rotations)\n";
105  err_ += "\t currently it appears " + d2s(sz) + " times!\n";
106  result = false;
107  }
108  for (sz_type i=0; i<sz; ++i) {
109  rotate_[i] = ParE_["rotate"][i];
110  }
111  for (sz_type i=0; i<sz; i += 3 ) {
112  if ( (rotate_[i] > 180.*deg) || (rotate_[i] < 0) ) {
113  err_ += "\trotate \'theta\' must be in range [0,180*deg]\n";
114  err_ += "\t currently it is " + d2s(rotate_[i]/deg)
115  + "*deg in rotate[" + d2s(double(i)) + "]!\n";
116  result = false;
117  }
119  rotateSolid_[i+2]);
120  DCOUT('a', " rotsolid[" << i << "] axis=" << temp.Axis() << " rot.angle=" << temp.Angle()/deg);
121  planeRot_ = planeRot_*temp;
122  }
123  // DCOUT('a', " rotplane axis=" << planeRot_.getAxis() << " rot.angle=" << planeRot_.delta()/deg);
124 
125  center_[0] = ParE_["center"][0];
126  center_[1] = ParE_["center"][1];
127  center_[2] = ParE_["center"][2];
128 
129  if (ParS_["alignSolid"][0] != "T") {
130  DCOUT('a', " alignSolid = false");
131  alignSolid_ = false;
132  }
133  else {
134  alignSolid_ = true;
135  }
136 
137  return result;
138 }
139 
140 
142 {
143  double angle = startAngle_+ double(count_-1)*delta_;
144 
145  DD3Vector v = fUnitVector(90*deg,angle)*radius_ ;
146 
147  if (rotate_[2]!=0) {
148  //v = planeRot_.inverse()*v;
149  v = planeRot_*v;
150  }
151 
152  v += DD3Vector(center_[0], center_[1], center_[2]); // offset
153 
154  DCOUT('A', " angle=" << angle/deg << " translation=" << v << " count_=" << count_);
155  return v;
156 }
157 
158 
160 {
161  //your code here
163 
164  if (alignSolid_) { // rotate the solid as well
165  double angle = startAngle_+ double(count_-1)*delta_;
166  ROOT::Math::RotationZ r2(angle);
167  rot = r2*rot;
168  }
169  // DCOUT('A', " rot.axis=" << rot.getAxis() << " rot.angle=" << rot.delta()/deg);
170 
171  if (rotate_[2]!=0) {
172  rot = planeRot_*rot;
173  //rot = rot*planeRot_.inverse();
174  //rot = planeRot_.inverse()*rot;
175  }
176 
177  return rot;
178 }
179 
180 // optional, not in the XML, omitted.
182 {
183  // for the moment rely on the automatic copy-number generation
184  // ( copy-no == invocation count count_ )
185  int factor = AlgoImpl::copyno() - 1;
186  return startCopyNo_ + factor*incrCopyNo_;
187 }
188 
189 
190 
191 // optional, not in the XML, omitted.
193 {
194  if ( (n_-count_) == -1 ) terminate();
195 }
196 
197 
198 void global_angular_0::stream(std::ostream & os) const
199 {
200  os << "global_angular_0::stream(): not implemented.";
201 }
202 
203 
204 /***********************************************************************************/
205 
206 /**************************************************************************
207 
208  The following Code gets only generated IF the code-generator
209  has the capability of generating evaluation/checking code for
210  the specification of the parameters in the algorithm XML.
211 
212  If the following is not generated, there will be not automatic
213  checking of the basic properties of the user-supplied parameters
214  (bounds, occurences, default values, ...)
215 
216 ***************************************************************************/
217 
218 // IT IS ADVISABLE TO HAVE SCHEMA VALIDATION DURING PARSING THE ALGORITHM-XML
219 // IN ORDER TO GET DEFAULT VALUES & CONTRAINTS FOR THE PARAMTERS OF THE ALGORITHM
220 // The code-generator has to fill data-structures containing the parameter names
221 // and their constraints. This information is only completely available during
222 // parsing of an algorithm-defintion-xml when schema validation is turned on.
224 {
225  // for the time being only expression-valued parameters can be automatically checked
226  // against their specified constraints
227 
228  // schema default values will be shown if necessary in the following XML comments
229  // on the second line. The fist shows the values as given in the instance document
230 
231  // expressions have to be converted into doubles. No variables [bla] shall be allowed
232  // inside the expressions; SystemOfUnits-symbols are the only supported ones.
233 
234 
235  constraintsE_["startAngle"] = ConstraintE( 1, // minOccurs
236  1, // maxOccurs
237  0., // min
238  360.0*deg, // max
239  false, // use, true=required, false=optional
240  true, // use, true=use default, false=no default
241  0.0
242  );
243 
244  constraintsE_["rangeAngle"] = ConstraintE( 1, // minOccurs
245  1, // maxOccurs
246  0., // min
247  360.0*deg, // max
248  false, // use, true=required, false=optional
249  true, // use, true=use default, false=no default
250  360.0*deg
251  );
252 
253  constraintsE_["n"] = ConstraintE( 1, // minOccurs
254  1, // maxOccurs
255  1, // min
256  +MAX_DOUBLE, // max
257  false, // use, true=required, false=optional
258  true, // use, true=use default, false=no default
259  1
260  );
261  constraintsE_["startCopyNo"] = ConstraintE( 1, // minOccurs
262  1, // maxOccurs
263  -MAX_DOUBLE, // min
264  +MAX_DOUBLE, // max
265  false, // use, true=required, false=optional
266  true, // use, true=use default, false=no default
267  1
268  );
269 
270  constraintsE_["incrCopyNo"] = ConstraintE( 1, // minOccurs
271  1, // maxOccurs
272  -MAX_DOUBLE, // min
273  +MAX_DOUBLE, // max
274  false, // use, true=required, false=optional
275  true, // use, true=use default, false=no default
276  1
277  );
278 
279 
280  constraintsE_["radius"] = ConstraintE( 1, // minOccurs
281  1, // maxOccurs
282  0., // min
283  +MAX_DOUBLE, // max
284  true, // use, true=required, false=optional
285  false, // use, true=use default, false=no default
286  2
287  );
288 
289  constraintsS_["alignSolid"] = ConstraintS( 1, // minOccurs
290  1, // maxOccurs
291 
292 
293  false, // use, true=required, false=optional
294  true, // use, true=use default, false=no default
295  "T"
296  );
297 
298  constraintsE_["center"] = ConstraintE( 3, // minOccurs
299  3, // maxOccurs
300  -MAX_DOUBLE, // min
301  +MAX_DOUBLE, // max
302  false, // use, true=required, false=optional
303  true, // use, true=use default, false=no default
304  0.
305  );
306 
307  constraintsE_["rotate"] = ConstraintE( 3, // minOccurs
308  9, // maxOccurs
309  -360.0*deg, // min
310  360.0*deg, // max
311  false, // use, true=required, false=optional
312  true, // use, true=use default, false=no default
313  0.0
314  );
315 
316  constraintsE_["rotateSolid"] = ConstraintE( 3, // minOccurs
317  9, // maxOccurs
318  -360.0*deg, // min
319  360.0*deg, // max
320  false, // use, true=required, false=optional
321  true, // use, true=use default, false=no default
322  0.0
323  );
324 
325 }
326 
327 
void checkTermination()
for algorithms with incr_==0 the algorithm must check whether to terminate
int i
Definition: DBlmapReader.cc:9
DDRotationMatrix planeRot_
const std::string & label
Definition: MVAComputer.cc:186
class for algorithmic positioning, represents an algorithm
Definition: AlgoPos.h:27
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
Geom::Theta< T > theta() const
std::vector< double > rotateSolid_
constraints as defined for algorithm-parameters in the XML schema Algorithm.xsd, strings ...
Definition: AlgoCheck.h:37
parE_type & ParE_
Definition: AlgoImpl.h:113
constraints as defined for algorithm-parameters in the XML schema Algorithm.xsd, expressions ...
Definition: AlgoCheck.h:19
uint16_t size_type
ROOT::Math::DisplacementVector3D< ROOT::Math::Cartesian3D< double > > DDTranslation
Definition: DDTranslation.h:7
virtual int copyno() const
copy-number calculation
Definition: AlgoImpl.cc:21
std::string & err_
Definition: AlgoImpl.h:120
ROOT::Math::DisplacementVector3D< ROOT::Math::Cartesian3D< double > > DD3Vector
A DD Translation is currently implemented with Root Vector3D.
Definition: DDTranslation.h:6
DDTranslation translation()
subclass must calculate a translation std::vector
tuple result
Definition: query.py:137
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
implementation of an algorithm, non generated checking code.
Definition: AlgoImpl.h:19
const int & count_
Definition: AlgoImpl.h:118
int copyno() const
copy-number calculation
constraintsS_type constraintsS_
format: &quot;ParameterName&quot; -&gt; ConstraintS
Definition: AlgoCheck.h:76
DD3Vector fUnitVector(double theta, double phi)
static std::string d2s(double x)
ahh, converts a double into a std::string ... yet another one of this kind!
Definition: AlgoImpl.cc:39
std::vector< double > rotate_
constraintsE_type constraintsE_
format: &quot;ParameterName&quot; -&gt; ConstraintE
Definition: AlgoCheck.h:73
std::vector< double > center_
global_angular_0(AlgoPos *, std::string label)
#define MAX_DOUBLE
double a
Definition: hdecay.h:121
void stream(std::ostream &) const
parS_type & ParS_
Definition: AlgoImpl.h:112
DDRotationMatrix rotation()
subclass must calculate a rotation matrix
DDRotationMatrix solidRot_
ROOT::Math::AxisAngle DDAxisAngle
ROOT::Math::Rotation3D DDRotationMatrix
A DDRotationMatrix is currently implemented with a ROOT Rotation3D.
#define DCOUT(M_v_Y, M_v_S)
Definition: DDdebug.h:53
mathSSE::Vec4< T > v
bool checkParameters()
subclass must check the supplied parameters ParE_, ParS_
void terminate()
stop the current iteration of the algorithm (for incr_==0 types of algorithms)
Definition: AlgoImpl.cc:27
T angle(T x1, T y1, T z1, T x2, T y2, T z2)
Definition: angle.h:11
Definition: DDAxes.h:10