CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
global_simpleAngular.cc
Go to the documentation of this file.
1 
2 //#include "DetectorDescription/Base/interface/DDdebug.h"
3 // GENERATED FILE. DO NOT MODIFY!
4 #include "global_simpleAngular.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 #define MAX_DOUBLE DBL_MAX
9 //#include <climits>
10 
11 
13 //#include "CLHEP/Geometry/Transform3D.h"
14 
15 #include "CLHEP/Units/GlobalSystemOfUnits.h"
16 #include <Math/RotationZ.h>
17 
18 
19 // always the same ctor
21  : AlgoImpl(a,label)
22 { }
23 
25 { }
26 
28 {
29 /* besides the automatic generated checking for the input params,
30  we have to decide, whether the params are correct and should
31  select this implementation
32  */
33 
34  bool result = true;
35 
36  // check for presence of delta
37  if (ParE_["delta"].size() == 0) {
38  result = false; // don't select this implementation, because delta is missing
39  }
40  else {
41  // check for valid delta-value
42  if (ParE_["delta"][0] == 0.) {
43  err_ += "\tdelta can not be zero\n";
44  result = false;
45  }
46  }
47 
48  // check for presence of number
49  if (ParE_["number"].size() != 0) {
50 // err_ += "\tcan not specify a delta and a number\n";
51  result = false;
52  }
53  return result;
54 }
55 
56 
58 {
59  double offset = ParE_["offset"][0]/rad;
60  double delta = ParE_["delta"][0]/rad;
61  double radius = ParE_["radius"][0];
62 // std::cout << "x = " << radius * cos(offset + delta * (count_ - 1)) << " y = " << radius * sin(offset + delta * (count_ - 1)) << std::endl;
63  DDTranslation trans(radius * cos(offset + delta * (count_ - 1)),
64  radius * sin(offset + delta * (count_ - 1)),
65  0. );
66 
67  return trans;
68 }
69 
70 
72 {
73  std::cout << "ParS_[\"rotate\"][0] = " << ParS_["rotate"][0] << std::endl;
74  if (ParS_["rotate"][0] == "T" || ParS_["rotate"][0] == "1"
75  || ParS_["rotate"][0] == "True")
76  {
77  double angle = -(ParE_["offset"][0]/rad + (ParE_["delta"][0]/rad) * (count_ - 1));
78  DDRotationMatrix rm1;
79  if (ParS_["orientation"].size() != 0)
80  {
81  std::string name=ParS_["orientation"][0];
82  size_t foundColon = 0;
83  std::string rn = "";
84  std::string ns = "";
85  while (foundColon < name.size() && name[foundColon] != ':')
86  ++foundColon;
87  if (foundColon != name.size())
88  {
89  for (size_t j = foundColon + 1; j < name.size(); ++j)
90  rn = rn + name[j];
91  for (size_t i = 0; i < foundColon; ++i)
92  ns = ns + name[i];
93  }
94  if (rn != "" && ns != "")
95  {
96  DDRotation myDDRotation(DDName(rn, ns));
97  rm1 = *(myDDRotation.rotation());
98  }
99  else
100  std::cout << "MAJOR PROBLEM: expected a fully qualified DDName but got :"
101  << name << std::endl;
102  }
103  ROOT::Math::RotationZ rm(angle);
104  rm1.Invert();
105  rm.Invert();
106  return rm * rm1;
107  }
108  else if (ParS_["orientation"].size() != 0)
109  {
110  // return the orientation matrix
111  std::string name=ParS_["orientation"][0];
112  size_t foundColon = 0;
113  std::string rn = "";
114  std::string ns = "";
115  while (foundColon < name.size() && name[foundColon] != ':')
116  ++foundColon;
117  if (foundColon != name.size())
118  {
119  for (size_t j = foundColon + 1; j < name.size(); ++j)
120  rn = rn + name[j];
121  for (size_t i = 0; i < foundColon; ++i)
122  ns = ns + name[i];
123  }
124  if (rn != "" && ns != "")
125  {
126 
127  DDRotation myDDRotation(DDName(rn, ns));
128  std::cout << "about to return *(myDDRotation.rotation())" << std::endl;
129  std::cout << *myDDRotation.rotation() << std::endl;
130  return *(myDDRotation.rotation());
131  }
132  else
133  std::cout << "MAJOR PROBLEM: expected a fully qualified DDName but got "
134  << name << " therefore could not look up the rotation." << std::endl;
135  return DDRotationMatrix();
136  }
137  else
138  {
139  return DDRotationMatrix(); // return identity matrix.
140  }
141 }
142 
143 
144 
145 
146 
147 // optional, not in the XML, omitted.
149 {
150  // initially I thought of ending our rotation algorithm at the vertical
151  // (+x), but decided it should always go full circle.
152  // if ((ParE_["offset"][0] + ParE_["delta"][0] * count_ / deg) > 360.)
153  if (ParE_["delta"][0] * count_ / deg > 360.)
154  terminate();
155 
156 }
157 
158 
159 void global_simpleAngular_0::stream(std::ostream & os) const
160 {
161  os << "global_simplesimpleAngular_0::stream(): not implemented.";
162 }
163 
164 
165 
166 
167 // always the same ctor
169  : AlgoImpl(a,label)
170 { }
171 
173 { }
174 
176 {
177  bool result = true;
178 
179  // check for delta
180  if (ParE_["number"].size() == 0) {
181  result = false; // don't select this implementation, because number is missing
182  }
183  else {
184  // check for valid number value
185  if (ParE_["number"][0] == 0.) {
186  err_ += "\tnumber must not be 0\n";
187  result = false;
188  }
189  }
190 
191  // check for presence of delta
192  if (ParE_["delta"].size() != 0) {
193 // err_ += "\tcan not specify delta and number\n";
194  result = false;
195  }
196 
197  return result;
198 }
199 
200 
202 {
203  // we can safely fetch all parameters, because they
204  // have been checked already ...
205  double offset = ParE_["offset"][0];
206  double number = ParE_["number"][0];
207  double delta = (360.0 / number) * deg;
208  double radius = ParE_["radius"][0];
209 // std::cout << "x = " << radius * cos(offset + delta * (count_ - 1)) << " y = " << radius * sin(offset + delta * (count_ - 1)) << std::endl;
210  DDTranslation trans(radius * cos(offset + delta * (count_ - 1)),
211  radius * sin(offset + delta * (count_ - 1)),
212  0. );
213 
214  return trans;
215 }
216 
217 
219 {
220  double number = ParE_["number"][0];
221  double delta = (360.0 / number) * deg;
222  if (ParS_["rotate"][0] == "T" || ParS_["rotate"][0] == "1"
223  || ParS_["rotate"][0] == "True")
224  {
225  double angle = -(ParE_["offset"][0]/rad + (delta/rad) * (count_ - 1));
226 
227  DDRotationMatrix rm1;
228  if (ParS_["orientation"].size() != 0)
229  {
230  std::string name=ParS_["orientation"][0];
231  size_t foundColon = 0;
232  std::string rn = "";
233  std::string ns = "";
234  while (foundColon < name.size() && name[foundColon] != ':')
235  ++foundColon;
236  if (foundColon != name.size())
237  {
238  for (size_t j = foundColon + 1; j < name.size(); ++j)
239  rn = rn + name[j];
240  for (size_t i = 0; i < foundColon; ++i)
241  ns = ns + name[i];
242  }
243  if (rn != "" && ns != "")
244  {
245  DDRotation myDDRotation(DDName(rn, ns));
246  rm1 = *(myDDRotation.rotation());
247  }
248  else
249  std::cout << "MAJOR PROBLEM: expected a fully qualified DDName but got :"
250  << name << " therefore could not look up the rotation." << std::endl;
251  }
252  ROOT::Math::RotationZ rm(angle);
253  rm1.Invert();
254  rm.Invert();
255  return rm * rm1;
256  }
257  else if (ParS_["orientation"].size() != 0)
258  {
259  std::string name=ParS_["orientation"][0];
260  size_t foundColon = 0;
261  std::string rn = "";
262  std::string ns = "";
263  while (foundColon < name.size() && name[foundColon] != ':')
264  ++foundColon;
265  if (foundColon != name.size())
266  {
267  for (size_t j = foundColon + 1; j < name.size(); ++j)
268  rn = rn + name[j];
269  for (size_t i = 0; i < foundColon; ++i)
270  ns = ns + name[i];
271  }
272  if (rn != "" && ns != "")
273  {
274 
275  DDRotation myDDRotation(DDName(rn, ns));
276  return *(myDDRotation.rotation());
277  }
278  else
279  std::cout << "MAJOR PROBLEM: expected a fully qualified DDName but got "
280  << name << " therefore could not look up the rotation." << std::endl;
281 
282  return DDRotationMatrix();
283  }
284  else
285  {
286  return DDRotationMatrix(); // return identity matrix.
287  }
288 }
289 
290 
291 
292 
293 
294 // optional, not in the XML, omitted.
296 {
297  //double delta = (360.0 / ParE_["number"][0]) * deg;
298  // if ((ParE_["offset"][0] + count_ * delta) / deg > 360.)
299  if (count_ > ParE_["number"][0])
300  terminate();
301 }
302 
303 
304 void global_simpleAngular_1::stream(std::ostream & os) const
305 {
306  os << "global_simpleAngular_0::stream(): not implemented.";
307 }
308 
309 
310 
311 
312 // always the same ctor
314  : AlgoImpl(a,label)
315 { }
316 
318 { }
319 
321 {
322  bool result = true;
323 
324  // check for delta
325  if (ParE_["number"].size() == 0) {
326  result = false; // don't select this implementation, because number is missing
327  }
328  else {
329  // check for valid number value
330  if (ParE_["number"][0] == 0.) {
331  err_ += "\tnumber must not be 0\n";
332  result = false;
333  }
334  }
335 
336  // check for presence of delta
337  if (ParE_["delta"].size() == 0) {
338  result = false; // don't select this implementation, because delta is missing.
339  }
340  else {
341  // check for valid delta value
342  if (ParE_["delta"][0] == 0.) {
343  err_ += "\tdelta must not be 0\n";
344  result = false;
345  }
346  }
347 
348  double delta = ParE_["delta"][0];
349  double number = ParE_["number"][0];
350  if (delta * number > 360. * deg) {
351  err_ += "\tat this time delta * number can not be greater than 360 degrees\n";
352  result = false;
353  }
354  return result;
355 }
356 
357 
359 {
360  // we can safely fetch all parameters, because they
361  // have been checked already ...
362  double offset = ParE_["offset"][0];
363 // double number = ParE_["number"][0];
364  double delta = ParE_["delta"][0];
365  double radius = ParE_["radius"][0];
366 // std::cout << "x = " << radius * cos(offset + delta * (count_ - 1)) << " y = " << radius * sin(offset + delta * (count_ - 1)) << std::endl;
367  DDTranslation trans(radius * cos(offset + delta * (count_ - 1)),
368  radius * sin(offset + delta * (count_ - 1)),
369  0. );
370 
371  return trans;
372 }
373 
374 
376 {
377 
378 // double number = ParE_["number"][0];
379  double delta = ParE_["delta"][0];
380  if (ParS_["rotate"][0] == "T" || ParS_["rotate"][0] == "1"
381  || ParS_["rotate"][0] == "True")
382  {
383  double angle = -(ParE_["offset"][0]/rad + (delta/rad) * (count_ - 1));
384  DDRotationMatrix rm1;
385  if (ParS_["orientation"].size() != 0)
386  {
387  std::string name=ParS_["orientation"][0];
388  size_t foundColon = 0;
389  std::string rn = "";
390  std::string ns = "";
391  while (foundColon < name.size() && name[foundColon] != ':')
392  ++foundColon;
393  if (foundColon != name.size())
394  {
395  for (size_t j = foundColon + 1; j < name.size(); ++j)
396  rn = rn + name[j];
397  for (size_t i = 0; i < foundColon; ++i)
398  ns = ns + name[i];
399  }
400  if (rn != "" && ns != "")
401  {
402  DDRotation myDDRotation(DDName(rn, ns));
403  rm1 = *(myDDRotation.rotation());
404  }
405  else
406  std::cout << "MAJOR PROBLEM: expected a fully qualified DDName but got :"
407  << name << std::endl;
408  }
409  ROOT::Math::RotationZ rm(angle);
410  rm1.Invert();
411  rm.Invert();
412  return rm * rm1;
413  }
414  else if (ParS_["orientation"].size() != 0)
415  {
416  // return the orientation matrix
417  std::string name=ParS_["orientation"][0];
418  size_t foundColon = 0;
419  std::string rn = "";
420  std::string ns = "";
421  while (foundColon < name.size() && name[foundColon] != ':')
422  ++foundColon;
423  if (foundColon != name.size())
424  {
425  for (size_t j = foundColon + 1; j < name.size(); ++j)
426  rn = rn + name[j];
427  for (size_t i = 0; i < foundColon; ++i)
428  ns = ns + name[i];
429  }
430  if (rn != "" && ns != "")
431  {
432 
433  DDRotation myDDRotation(DDName(rn, ns));
434  return *(myDDRotation.rotation());
435  }
436  else
437  std::cout << "MAJOR PROBLEM: expected a fully qualified DDName but got "
438  << name << " therefore could not look up the rotation." << std::endl;
439  return DDRotationMatrix();
440  }
441  else
442  {
443  return DDRotationMatrix(); // return identity matrix.
444  }
445 }
446 
447 
448 
449 
450 
451 // optional, not in the XML, omitted.
453 {
454  //double delta = (360.0 / ParE_["number"][0]) * deg;
455  // if ((ParE_["offset"][0] + count_ * delta) / deg > 360.)
456  if (count_ > ParE_["number"][0])
457  terminate();
458 }
459 
460 
461 void global_simpleAngular_2::stream(std::ostream & os) const
462 {
463  os << "global_simpleAngular_0::stream(): not implemented.";
464 }
465 
466 
467 /***********************************************************************************/
468 
469 /**************************************************************************
470 
471  The following Code gets only generated IF the code-generator
472  has the capability of generating evaluation/checking code for
473  the specification of the parameters in the algorithm XML.
474 
475  If the following is not generated, there will be not automatic
476  checking of the basic properties of the user-supplied parameters
477  (bounds, occurences, default values, ...)
478 
479 ***************************************************************************/
480 
481 // IT IS ADVISABLE TO HAVE SCHEMA VALIDATION DURING PARSING THE ALGORITHM-XML
482 // IN ORDER TO GET DEFAULT VALUES & CONTRAINTS FOR THE PARAMTERS OF THE ALGORITHM
483 // The code-generator has to fill data-structures containing the parameter names
484 // and their constraints. This information is only completely available during
485 // parsing of an algorithm-defintion-xml when schema validation is turned on.
487 {
488  // for the time being only expression-valued parameters can be automatically checked
489  // against their specified constraints
490 
491  // schema default values will be shown if necessary in the following XML comments
492  // on the second line. The fist shows the values as given in the instance document
493 
494  // expressions have to be converted into doubles. No variables [bla] shall be allowed
495  // inside the expressions; SystemOfUnits-symbols are the only supported ones.
496 
497 
498  constraintsE_["radius"] = ConstraintE( 1, // minOccurs
499  1, // maxOccurs
500  -MAX_DOUBLE, // min
501  +MAX_DOUBLE, // max
502  false, // use, true=required, false=optional
503  true, // use, true=use default, false=no default
504  0.0
505  );
506 
507  constraintsE_["offset"] = ConstraintE( 1, // minOccurs
508  1, // maxOccurs
509  0.0*deg, // min
510  360.0*deg, // max
511  false, // use, true=required, false=optional
512  true, // use, true=use default, false=no default
513  0.0
514  );
515 
516  constraintsE_["delta"] = ConstraintE( 1, // minOccurs
517  1, // maxOccurs
518  0.0*deg, // min
519  360.0*deg, // max
520  false, // use, true=required, false=optional
521  false, // use, true=use default, false=no default
522  0.
523  );
524 
525  constraintsE_["number"] = ConstraintE( 1, // minOccurs
526  1, // maxOccurs
527  -MAX_DOUBLE, // min
528  +MAX_DOUBLE, // max
529  false, // use, true=required, false=optional
530  false, // use, true=use default, false=no default
531  0.
532  );
533 
534  constraintsE_["radius"] = ConstraintE( 1, // minOccurs
535  1, // maxOccurs
536  -MAX_DOUBLE, // min
537  +MAX_DOUBLE, // max
538  true, // use, true=required, false=optional
539  true, // use, true=use default, false=no default
540  0.0
541  );
542 
543  constraintsS_["rotate"] = ConstraintS( 1, // minOccurs
544  1, // maxOccurs
545 
546 
547  false, // use, true=required, false=optional
548  true, // use, true=use default, false=no default
549  "1"
550  );
551 
552  constraintsS_["orientation"] = ConstraintS( 1, // minOccurs
553  1, // maxOccurs
554 
555 
556  false, // use, true=required, false=optional
557  false, // use, true=use default, false=no default
558  ""
559  );
560 
561 }
562 
563 
dbl * delta
Definition: mlp_gen.cc:36
const DDRotationMatrix * rotation() const
Returns the read-only rotation-matrix.
Definition: DDTransform.h:90
int i
Definition: DBlmapReader.cc:9
void stream(std::ostream &) const
class for algorithmic positioning, represents an algorithm
Definition: AlgoPos.h:27
void stream(std::ostream &) const
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
void checkTermination()
for algorithms with incr_==0 the algorithm must check whether to terminate
DDTranslation translation()
subclass must calculate a translation std::vector
DDName is used to identify DDD entities uniquely.
Definition: DDName.h:18
void stream(std::ostream &) const
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
DDTranslation translation()
subclass must calculate a translation std::vector
ROOT::Math::DisplacementVector3D< ROOT::Math::Cartesian3D< double > > DDTranslation
Definition: DDTranslation.h:7
bool checkParameters()
subclass must check the supplied parameters ParE_, ParS_
Represents a uniquely identifyable rotation matrix.
Definition: DDTransform.h:66
void checkTermination()
for algorithms with incr_==0 the algorithm must check whether to terminate
DDRotationMatrix rotation()
subclass must calculate a rotation matrix
std::string & err_
Definition: AlgoImpl.h:120
DDTranslation translation()
subclass must calculate a translation std::vector
bool checkParameters()
subclass must check the supplied parameters ParE_, ParS_
tuple result
Definition: query.py:137
string rm
Definition: submit.py:76
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
implementation of an algorithm, non generated checking code.
Definition: AlgoImpl.h:19
int j
Definition: DBlmapReader.cc:9
const int & count_
Definition: AlgoImpl.h:118
unsigned int offset(bool)
global_simpleAngular_1(AlgoPos *, std::string label)
DDRotationMatrix rotation()
subclass must calculate a rotation matrix
constraintsS_type constraintsS_
format: &quot;ParameterName&quot; -&gt; ConstraintS
Definition: AlgoCheck.h:76
bool checkParameters()
subclass must check the supplied parameters ParE_, ParS_
constraintsE_type constraintsE_
format: &quot;ParameterName&quot; -&gt; ConstraintE
Definition: AlgoCheck.h:73
#define MAX_DOUBLE
global_simpleAngular_0(AlgoPos *, std::string label)
void checkTermination()
for algorithms with incr_==0 the algorithm must check whether to terminate
double a
Definition: hdecay.h:121
parS_type & ParS_
Definition: AlgoImpl.h:112
tuple cout
Definition: gather_cfg.py:121
DDRotationMatrix rotation()
subclass must calculate a rotation matrix
ROOT::Math::Rotation3D DDRotationMatrix
A DDRotationMatrix is currently implemented with a ROOT Rotation3D.
tuple size
Write out results.
void terminate()
stop the current iteration of the algorithm (for incr_==0 types of algorithms)
Definition: AlgoImpl.cc:28
global_simpleAngular_2(AlgoPos *, std::string label)
T angle(T x1, T y1, T z1, T x2, T y2, T z2)
Definition: angle.h:11