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 ),
23  center_( 3 ),
24  rotateSolid_( 0 ),
25  alignSolid_( true ),
26  n_( 1 ),
27  startCopyNo_( 1 ),
28  incrCopyNo_( 1 ),
29  startAngle_( 0 ),
30  rangeAngle_( 360.*deg ),
31  radius_( 0. ),
32  delta_( 0. )
33 {
34  DCOUT('A', "Creating angular label=" << label);
35 }
36 
38 { }
39 
40 
41 DD3Vector fUnitVector(double theta, double phi)
42 {
43  return DD3Vector(cos(phi)*sin(theta),
44  sin(phi)*sin(theta),
45  cos(theta));
46 }
47 
48 
50 {
51  bool result = true;
52 
55 
56  radius_ = ParE_["radius"][0];
57 
58  startAngle_ = ParE_["startAngle"][0];
59  rangeAngle_ = ParE_["rangeAngle"][0];
60  n_ = int(ParE_["n"][0]);
61  startCopyNo_ = int(ParE_["startCopyNo"][0]);
62  incrCopyNo_ = int(ParE_["incrCopyNo"][0]);
63 
64  if (fabs(rangeAngle_-360.0*deg)<0.001*deg) { // a full 360deg range
65  delta_ = rangeAngle_/double(n_);
66  }
67  else {
68  if (n_ > 1) {
69  delta_ = rangeAngle_/double(n_-1);
70  }
71  else {
72  delta_ = 0.;
73  }
74  }
75 
76  DCOUT('a', " startA=" << startAngle_/deg << " rangeA=" << rangeAngle_/deg <<
77  " n=" << n_ << " delta=" << delta_/deg);
78 
79  //======= collect data concerning the rotation of the solid
80  typedef parE_type::mapped_type::size_type sz_type;
81  sz_type sz = ParE_["rotateSolid"].size();
82  rotateSolid_.clear();
83  rotateSolid_.resize(sz);
84  if (sz%3) {
85  err_ += "\trotateSolid must occur 3*n times (defining n subsequent rotations)\n";
86  err_ += "\t currently it appears " + d2s(sz) + " times!\n";
87  result = false;
88  }
89  for (sz_type i=0; i<sz; ++i) {
90  rotateSolid_[i] = ParE_["rotateSolid"][i];
91  }
92  for (sz_type i=0; i<sz; i += 3 ) {
93  if ( (rotateSolid_[i] > 180.*deg) || (rotateSolid_[i] < 0.) ) {
94  err_ += "\trotateSolid \'theta\' must be in range [0,180*deg]\n";
95  err_ += "\t currently it is " + d2s(rotateSolid_[i]/deg)
96  + "*deg in rotateSolid[" + d2s(double(i)) + "]!\n";
97  result = false;
98  }
100  rotateSolid_[i+2]);
101  DCOUT('a', " rotsolid[" << i << "] axis=" << temp.Axis() << " rot.angle=" << temp.Angle()/deg);
102  solidRot_ = temp*solidRot_;
103  }
104  // DCOUT('a', " rotsolid axis=" << solidRot_.getAxis() << " rot.angle=" << solidRot_.delta()/deg);
105 
106 
107  //======== collect data concerning the rotation of the x-y plane
108  sz = ParE_["rotate"].size();
109  rotate_.clear();
110  rotate_.resize(sz);
111  if (sz%3) {
112  err_ += "\trotate must occur 3*n times (defining n subsequent rotations)\n";
113  err_ += "\t currently it appears " + d2s(sz) + " times!\n";
114  result = false;
115  }
116  for (sz_type i=0; i<sz; ++i) {
117  rotate_[i] = ParE_["rotate"][i];
118  }
119  for (sz_type i=0; i<sz; i += 3 ) {
120  if ( (rotate_[i] > 180.*deg) || (rotate_[i] < 0) ) {
121  err_ += "\trotate \'theta\' must be in range [0,180*deg]\n";
122  err_ += "\t currently it is " + d2s(rotate_[i]/deg)
123  + "*deg in rotate[" + d2s(double(i)) + "]!\n";
124  result = false;
125  }
127  rotateSolid_[i+2]);
128  DCOUT('a', " rotsolid[" << i << "] axis=" << temp.Axis() << " rot.angle=" << temp.Angle()/deg);
129  planeRot_ = planeRot_*temp;
130  }
131  // DCOUT('a', " rotplane axis=" << planeRot_.getAxis() << " rot.angle=" << planeRot_.delta()/deg);
132 
133  center_[0] = ParE_["center"][0];
134  center_[1] = ParE_["center"][1];
135  center_[2] = ParE_["center"][2];
136 
137  if (ParS_["alignSolid"][0] != "T") {
138  DCOUT('a', " alignSolid = false");
139  alignSolid_ = false;
140  }
141  else {
142  alignSolid_ = true;
143  }
144 
145  return result;
146 }
147 
148 
150 {
151  double angle = startAngle_+ double(count_-1)*delta_;
152 
153  DD3Vector v = fUnitVector(90*deg,angle)*radius_ ;
154 
155  if (rotate_[2]!=0) {
156  //v = planeRot_.inverse()*v;
157  v = planeRot_*v;
158  }
159 
160  v += DD3Vector(center_[0], center_[1], center_[2]); // offset
161 
162  DCOUT('A', " angle=" << angle/deg << " translation=" << v << " count_=" << count_);
163  return v;
164 }
165 
166 
168 {
169  //your code here
171 
172  if (alignSolid_) { // rotate the solid as well
173  double angle = startAngle_+ double(count_-1)*delta_;
174  ROOT::Math::RotationZ r2(angle);
175  rot = r2*rot;
176  }
177  // DCOUT('A', " rot.axis=" << rot.getAxis() << " rot.angle=" << rot.delta()/deg);
178 
179  if (rotate_[2]!=0) {
180  rot = planeRot_*rot;
181  //rot = rot*planeRot_.inverse();
182  //rot = planeRot_.inverse()*rot;
183  }
184 
185  return rot;
186 }
187 
188 // optional, not in the XML, omitted.
190 {
191  // for the moment rely on the automatic copy-number generation
192  // ( copy-no == invocation count count_ )
193  int factor = AlgoImpl::copyno() - 1;
194  return startCopyNo_ + factor*incrCopyNo_;
195 }
196 
197 
198 
199 // optional, not in the XML, omitted.
201 {
202  if ( (n_-count_) == -1 ) terminate();
203 }
204 
205 
206 void global_angular_0::stream(std::ostream & os) const
207 {
208  os << "global_angular_0::stream(): not implemented.";
209 }
210 
211 
212 /***********************************************************************************/
213 
214 /**************************************************************************
215 
216  The following Code gets only generated IF the code-generator
217  has the capability of generating evaluation/checking code for
218  the specification of the parameters in the algorithm XML.
219 
220  If the following is not generated, there will be not automatic
221  checking of the basic properties of the user-supplied parameters
222  (bounds, occurences, default values, ...)
223 
224 ***************************************************************************/
225 
226 // IT IS ADVISABLE TO HAVE SCHEMA VALIDATION DURING PARSING THE ALGORITHM-XML
227 // IN ORDER TO GET DEFAULT VALUES & CONTRAINTS FOR THE PARAMTERS OF THE ALGORITHM
228 // The code-generator has to fill data-structures containing the parameter names
229 // and their constraints. This information is only completely available during
230 // parsing of an algorithm-defintion-xml when schema validation is turned on.
232 {
233  // for the time being only expression-valued parameters can be automatically checked
234  // against their specified constraints
235 
236  // schema default values will be shown if necessary in the following XML comments
237  // on the second line. The fist shows the values as given in the instance document
238 
239  // expressions have to be converted into doubles. No variables [bla] shall be allowed
240  // inside the expressions; SystemOfUnits-symbols are the only supported ones.
241 
242 
243  constraintsE_["startAngle"] = ConstraintE( 1, // minOccurs
244  1, // maxOccurs
245  0., // min
246  360.0*deg, // max
247  false, // use, true=required, false=optional
248  true, // use, true=use default, false=no default
249  0.0
250  );
251 
252  constraintsE_["rangeAngle"] = ConstraintE( 1, // minOccurs
253  1, // maxOccurs
254  0., // min
255  360.0*deg, // max
256  false, // use, true=required, false=optional
257  true, // use, true=use default, false=no default
258  360.0*deg
259  );
260 
261  constraintsE_["n"] = ConstraintE( 1, // minOccurs
262  1, // maxOccurs
263  1, // 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  constraintsE_["startCopyNo"] = ConstraintE( 1, // minOccurs
270  1, // maxOccurs
271  -MAX_DOUBLE, // min
272  +MAX_DOUBLE, // max
273  false, // use, true=required, false=optional
274  true, // use, true=use default, false=no default
275  1
276  );
277 
278  constraintsE_["incrCopyNo"] = ConstraintE( 1, // minOccurs
279  1, // maxOccurs
280  -MAX_DOUBLE, // min
281  +MAX_DOUBLE, // max
282  false, // use, true=required, false=optional
283  true, // use, true=use default, false=no default
284  1
285  );
286 
287 
288  constraintsE_["radius"] = ConstraintE( 1, // minOccurs
289  1, // maxOccurs
290  0., // min
291  +MAX_DOUBLE, // max
292  true, // use, true=required, false=optional
293  false, // use, true=use default, false=no default
294  2
295  );
296 
297  constraintsS_["alignSolid"] = ConstraintS( 1, // minOccurs
298  1, // maxOccurs
299 
300 
301  false, // use, true=required, false=optional
302  true, // use, true=use default, false=no default
303  "T"
304  );
305 
306  constraintsE_["center"] = ConstraintE( 3, // minOccurs
307  3, // maxOccurs
308  -MAX_DOUBLE, // min
309  +MAX_DOUBLE, // max
310  false, // use, true=required, false=optional
311  true, // use, true=use default, false=no default
312  0.
313  );
314 
315  constraintsE_["rotate"] = ConstraintE( 3, // minOccurs
316  9, // maxOccurs
317  -360.0*deg, // min
318  360.0*deg, // max
319  false, // use, true=required, false=optional
320  true, // use, true=use default, false=no default
321  0.0
322  );
323 
324  constraintsE_["rotateSolid"] = ConstraintE( 3, // minOccurs
325  9, // maxOccurs
326  -360.0*deg, // min
327  360.0*deg, // max
328  false, // use, true=required, false=optional
329  true, // use, true=use default, false=no default
330  0.0
331  );
332 
333 }
334 
335 
void checkTermination()
for algorithms with incr_==0 the algorithm must check whether to terminate
int i
Definition: DBlmapReader.cc:9
DDRotationMatrix planeRot_
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:22
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:40
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:28
T angle(T x1, T y1, T z1, T x2, T y2, T z2)
Definition: angle.h:11
Definition: DDAxes.h:10