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  DDRotationMatrix rm = *(myDDRotation.rotation());
277  return *(myDDRotation.rotation());
278  }
279  else
280  std::cout << "MAJOR PROBLEM: expected a fully qualified DDName but got "
281  << name << " therefore could not look up the rotation." << std::endl;
282 
283  return DDRotationMatrix();
284  }
285  else
286  {
287  return DDRotationMatrix(); // return identity matrix.
288  }
289 }
290 
291 
292 
293 
294 
295 // optional, not in the XML, omitted.
297 {
298  //double delta = (360.0 / ParE_["number"][0]) * deg;
299  // if ((ParE_["offset"][0] + count_ * delta) / deg > 360.)
300  if (count_ > ParE_["number"][0])
301  terminate();
302 }
303 
304 
305 void global_simpleAngular_1::stream(std::ostream & os) const
306 {
307  os << "global_simpleAngular_0::stream(): not implemented.";
308 }
309 
310 
311 
312 
313 // always the same ctor
315  : AlgoImpl(a,label)
316 { }
317 
319 { }
320 
322 {
323  bool result = true;
324 
325  // check for delta
326  if (ParE_["number"].size() == 0) {
327  result = false; // don't select this implementation, because number is missing
328  }
329  else {
330  // check for valid number value
331  if (ParE_["number"][0] == 0.) {
332  err_ += "\tnumber must not be 0\n";
333  result = false;
334  }
335  }
336 
337  // check for presence of delta
338  if (ParE_["delta"].size() == 0) {
339  result = false; // don't select this implementation, because delta is missing.
340  }
341  else {
342  // check for valid delta value
343  if (ParE_["delta"][0] == 0.) {
344  err_ += "\tdelta must not be 0\n";
345  result = false;
346  }
347  }
348 
349  double delta = ParE_["delta"][0];
350  double number = ParE_["number"][0];
351  if (delta * number > 360. * deg) {
352  err_ += "\tat this time delta * number can not be greater than 360 degrees\n";
353  result = false;
354  }
355  return result;
356 }
357 
358 
360 {
361  // we can safely fetch all parameters, because they
362  // have been checked already ...
363  double offset = ParE_["offset"][0];
364 // double number = ParE_["number"][0];
365  double delta = ParE_["delta"][0];
366  double radius = ParE_["radius"][0];
367 // std::cout << "x = " << radius * cos(offset + delta * (count_ - 1)) << " y = " << radius * sin(offset + delta * (count_ - 1)) << std::endl;
368  DDTranslation trans(radius * cos(offset + delta * (count_ - 1)),
369  radius * sin(offset + delta * (count_ - 1)),
370  0. );
371 
372  return trans;
373 }
374 
375 
377 {
378 
379 // double number = ParE_["number"][0];
380  double delta = ParE_["delta"][0];
381  if (ParS_["rotate"][0] == "T" || ParS_["rotate"][0] == "1"
382  || ParS_["rotate"][0] == "True")
383  {
384  double angle = -(ParE_["offset"][0]/rad + (delta/rad) * (count_ - 1));
385  DDRotationMatrix rm1;
386  if (ParS_["orientation"].size() != 0)
387  {
388  std::string name=ParS_["orientation"][0];
389  size_t foundColon = 0;
390  std::string rn = "";
391  std::string ns = "";
392  while (foundColon < name.size() && name[foundColon] != ':')
393  ++foundColon;
394  if (foundColon != name.size())
395  {
396  for (size_t j = foundColon + 1; j < name.size(); ++j)
397  rn = rn + name[j];
398  for (size_t i = 0; i < foundColon; ++i)
399  ns = ns + name[i];
400  }
401  if (rn != "" && ns != "")
402  {
403  DDRotation myDDRotation(DDName(rn, ns));
404  rm1 = *(myDDRotation.rotation());
405  }
406  else
407  std::cout << "MAJOR PROBLEM: expected a fully qualified DDName but got :"
408  << name << std::endl;
409  }
410  ROOT::Math::RotationZ rm(angle);
411  rm1.Invert();
412  rm.Invert();
413  return rm * rm1;
414  }
415  else if (ParS_["orientation"].size() != 0)
416  {
417  // return the orientation matrix
418  std::string name=ParS_["orientation"][0];
419  size_t foundColon = 0;
420  std::string rn = "";
421  std::string ns = "";
422  while (foundColon < name.size() && name[foundColon] != ':')
423  ++foundColon;
424  if (foundColon != name.size())
425  {
426  for (size_t j = foundColon + 1; j < name.size(); ++j)
427  rn = rn + name[j];
428  for (size_t i = 0; i < foundColon; ++i)
429  ns = ns + name[i];
430  }
431  if (rn != "" && ns != "")
432  {
433 
434  DDRotation myDDRotation(DDName(rn, ns));
435  DDRotationMatrix rm = *(myDDRotation.rotation());
436  return *(myDDRotation.rotation());
437  }
438  else
439  std::cout << "MAJOR PROBLEM: expected a fully qualified DDName but got "
440  << name << " therefore could not look up the rotation." << std::endl;
441  return DDRotationMatrix();
442  }
443  else
444  {
445  return DDRotationMatrix(); // return identity matrix.
446  }
447 }
448 
449 
450 
451 
452 
453 // optional, not in the XML, omitted.
455 {
456  //double delta = (360.0 / ParE_["number"][0]) * deg;
457  // if ((ParE_["offset"][0] + count_ * delta) / deg > 360.)
458  if (count_ > ParE_["number"][0])
459  terminate();
460 }
461 
462 
463 void global_simpleAngular_2::stream(std::ostream & os) const
464 {
465  os << "global_simpleAngular_0::stream(): not implemented.";
466 }
467 
468 
469 /***********************************************************************************/
470 
471 /**************************************************************************
472 
473  The following Code gets only generated IF the code-generator
474  has the capability of generating evaluation/checking code for
475  the specification of the parameters in the algorithm XML.
476 
477  If the following is not generated, there will be not automatic
478  checking of the basic properties of the user-supplied parameters
479  (bounds, occurences, default values, ...)
480 
481 ***************************************************************************/
482 
483 // IT IS ADVISABLE TO HAVE SCHEMA VALIDATION DURING PARSING THE ALGORITHM-XML
484 // IN ORDER TO GET DEFAULT VALUES & CONTRAINTS FOR THE PARAMTERS OF THE ALGORITHM
485 // The code-generator has to fill data-structures containing the parameter names
486 // and their constraints. This information is only completely available during
487 // parsing of an algorithm-defintion-xml when schema validation is turned on.
489 {
490  // for the time being only expression-valued parameters can be automatically checked
491  // against their specified constraints
492 
493  // schema default values will be shown if necessary in the following XML comments
494  // on the second line. The fist shows the values as given in the instance document
495 
496  // expressions have to be converted into doubles. No variables [bla] shall be allowed
497  // inside the expressions; SystemOfUnits-symbols are the only supported ones.
498 
499 
500  constraintsE_["radius"] = ConstraintE( 1, // minOccurs
501  1, // maxOccurs
502  -MAX_DOUBLE, // min
503  +MAX_DOUBLE, // max
504  false, // use, true=required, false=optional
505  true, // use, true=use default, false=no default
506  0.0
507  );
508 
509  constraintsE_["offset"] = ConstraintE( 1, // minOccurs
510  1, // maxOccurs
511  0.0*deg, // min
512  360.0*deg, // max
513  false, // use, true=required, false=optional
514  true, // use, true=use default, false=no default
515  0.0
516  );
517 
518  constraintsE_["delta"] = ConstraintE( 1, // minOccurs
519  1, // maxOccurs
520  0.0*deg, // min
521  360.0*deg, // max
522  false, // use, true=required, false=optional
523  false, // use, true=use default, false=no default
524  0.
525  );
526 
527  constraintsE_["number"] = ConstraintE( 1, // minOccurs
528  1, // maxOccurs
529  -MAX_DOUBLE, // min
530  +MAX_DOUBLE, // max
531  false, // use, true=required, false=optional
532  false, // use, true=use default, false=no default
533  0.
534  );
535 
536  constraintsE_["radius"] = ConstraintE( 1, // minOccurs
537  1, // maxOccurs
538  -MAX_DOUBLE, // min
539  +MAX_DOUBLE, // max
540  true, // use, true=required, false=optional
541  true, // use, true=use default, false=no default
542  0.0
543  );
544 
545  constraintsS_["rotate"] = ConstraintS( 1, // minOccurs
546  1, // maxOccurs
547 
548 
549  false, // use, true=required, false=optional
550  true, // use, true=use default, false=no default
551  "1"
552  );
553 
554  constraintsS_["orientation"] = ConstraintS( 1, // minOccurs
555  1, // maxOccurs
556 
557 
558  false, // use, true=required, false=optional
559  false, // use, true=use default, false=no default
560  ""
561  );
562 
563 }
564 
565 
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
const std::string & label
Definition: MVAComputer.cc:186
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:41
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:27
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