CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions
global_simpleAngular_2 Class Reference

#include <global_simpleAngular.h>

Inheritance diagram for global_simpleAngular_2:
AlgoImpl

Public Member Functions

bool checkParameters ()
 subclass must check the supplied parameters ParE_, ParS_ More...
 
void checkTermination ()
 for algorithms with incr_==0 the algorithm must check whether to terminate More...
 
 global_simpleAngular_2 (AlgoPos *, std::string label)
 
DDRotationMatrix rotation ()
 subclass must calculate a rotation matrix More...
 
void stream (std::ostream &) const
 
DDTranslation translation ()
 subclass must calculate a translation std::vector More...
 
 ~global_simpleAngular_2 ()
 
- Public Member Functions inherited from AlgoImpl
 AlgoImpl (AlgoPos *, std::string label)
 subclass must provide a similar constructor and call this one More...
 

Additional Inherited Members

- Protected Member Functions inherited from AlgoImpl
virtual int copyno () const
 copy-number calculation More...
 
void terminate ()
 stop the current iteration of the algorithm (for incr_==0 types of algorithms) More...
 
virtual ~AlgoImpl ()
 
- Static Protected Member Functions inherited from AlgoImpl
static std::string d2s (double x)
 ahh, converts a double into a std::string ... yet another one of this kind! More...
 
- Protected Attributes inherited from AlgoImpl
const int & count_
 
const int & curr_
 
const int & end_
 
std::string & err_
 
const int & incr_
 
std::string label_
 
parE_typeParE_
 
parS_typeParS_
 
const int & start_
 
bool & terminate_
 

Detailed Description

Definition at line 99 of file global_simpleAngular.h.

Constructor & Destructor Documentation

global_simpleAngular_2::global_simpleAngular_2 ( AlgoPos a,
std::string  label 
)

Definition at line 314 of file global_simpleAngular.cc.

315  : AlgoImpl(a,label)
316 { }
const std::string & label
Definition: MVAComputer.cc:186
AlgoImpl(AlgoPos *, std::string label)
subclass must provide a similar constructor and call this one
Definition: AlgoImpl.cc:5
global_simpleAngular_2::~global_simpleAngular_2 ( )

Definition at line 318 of file global_simpleAngular.cc.

319 { }

Member Function Documentation

bool global_simpleAngular_2::checkParameters ( )
virtual

subclass must check the supplied parameters ParE_, ParS_

whether they are correct and should select this paricular algorithm.

If the parameters are correct by should not select this particular algorithm, checkParamters must return false otherwise true.

The std::string err_ is to be used to be extended with error information in case any errors have been detected. Error information must be attached to err_ because of the possibility of already contained error information.

In case of errors: If an DDException is thrown by the algorithm implementation, further processing of any other implementations of the algorithm will be stopped. If no exception is thrown, checkParamters must return false. It's preferable not to throw an exception in case of errors. The algorithm implementation will throw if all checkParamters() of all registered algorithm implementations have returned false.

Implements AlgoImpl.

Definition at line 321 of file global_simpleAngular.cc.

References delta, AlgoImpl::err_, AlgoImpl::ParE_, query::result, and findQualityFiles::size.

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 }
dbl * delta
Definition: mlp_gen.cc:36
parE_type & ParE_
Definition: AlgoImpl.h:113
std::string & err_
Definition: AlgoImpl.h:120
tuple result
Definition: query.py:137
tuple size
Write out results.
void global_simpleAngular_2::checkTermination ( void  )
virtual

for algorithms with incr_==0 the algorithm must check whether to terminate

Overload this function in case the algorithm is a 'incr_==0' type. In this case provide some code which checks using perhaps the value of count_ and/or supplied algorithm parameters to check whether terminate() has to be called or not. If terminate() is called, the current iteration of the algorithm is not taken into account!

The default implementation will immidiately terminate the algorithm in case incr_==0.

In case of incr_!=0: checkTermination() is not called at all; the algorithm will terminate automatically when the specified range [start_, end_, incr_] has been covered or terminate() has been called from within translation() or rotation().

Reimplemented from AlgoImpl.

Definition at line 454 of file global_simpleAngular.cc.

References AlgoImpl::count_, AlgoImpl::ParE_, and AlgoImpl::terminate().

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 }
parE_type & ParE_
Definition: AlgoImpl.h:113
const int & count_
Definition: AlgoImpl.h:118
void terminate()
stop the current iteration of the algorithm (for incr_==0 types of algorithms)
Definition: AlgoImpl.cc:27
DDRotationMatrix global_simpleAngular_2::rotation ( )
virtual

subclass must calculate a rotation matrix

depending on the current position curr_ in the range [start_,end_,incr_] and the user supplied parameters ParE_, ParS_

Implements AlgoImpl.

Definition at line 376 of file global_simpleAngular.cc.

References angle(), AlgoImpl::count_, gather_cfg::cout, delta, i, j, AlCaRecoCosmics_cfg::name, AlgoImpl::ParE_, AlgoImpl::ParS_, submit::rm, DDRotation::rotation(), and findQualityFiles::size.

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 }
dbl * delta
Definition: mlp_gen.cc:36
int i
Definition: DBlmapReader.cc:9
DDName is used to identify DDD entities uniquely.
Definition: DDName.h:18
parE_type & ParE_
Definition: AlgoImpl.h:113
Represents a uniquely identifyable rotation matrix.
Definition: DDTransform.h:66
string rm
Definition: submit.py:76
int j
Definition: DBlmapReader.cc:9
const int & count_
Definition: AlgoImpl.h:118
parS_type & ParS_
Definition: AlgoImpl.h:112
tuple cout
Definition: gather_cfg.py:41
ROOT::Math::Rotation3D DDRotationMatrix
A DDRotationMatrix is currently implemented with a ROOT Rotation3D.
tuple size
Write out results.
T angle(T x1, T y1, T z1, T x2, T y2, T z2)
Definition: angle.h:11
void global_simpleAngular_2::stream ( std::ostream &  os) const

Definition at line 463 of file global_simpleAngular.cc.

464 {
465  os << "global_simpleAngular_0::stream(): not implemented.";
466 }
DDTranslation global_simpleAngular_2::translation ( )
virtual

subclass must calculate a translation std::vector

depending on the current position curr_ in the range [start_,end_,incr_] and the user supplied parameters ParE_, ParS_

Implements AlgoImpl.

Definition at line 359 of file global_simpleAngular.cc.

References funct::cos(), AlgoImpl::count_, delta, evf::evtn::offset(), AlgoImpl::ParE_, CosmicsPD_Skims::radius, and funct::sin().

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 }
dbl * delta
Definition: mlp_gen.cc:36
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
parE_type & ParE_
Definition: AlgoImpl.h:113
ROOT::Math::DisplacementVector3D< ROOT::Math::Cartesian3D< double > > DDTranslation
Definition: DDTranslation.h:7
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
const int & count_
Definition: AlgoImpl.h:118
unsigned int offset(bool)